Skip to content

Commit d92ccc1

Browse files
authored
Merge pull request #943 from CEED/jed/petsc-format-string
examples: use PetscInt_FMT instead of %D
2 parents 6f44865 + 0814089 commit d92ccc1

11 files changed

Lines changed: 47 additions & 43 deletions

File tree

examples/fluids/navierstokes.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ int main(int argc, char **argv) {
259259
" Mesh:\n"
260260
" Number of 1D Basis Nodes (P) : %d\n"
261261
" Number of 1D Quadrature Points (Q) : %d\n"
262-
" Global DoFs : %D\n"
263-
" Owned DoFs : %D\n"
264-
" DoFs per node : %D\n"
265-
" Global nodes : %D\n"
266-
" Owned nodes : %D\n",
262+
" Global DoFs : %" PetscInt_FMT "\n"
263+
" Owned DoFs : %" PetscInt_FMT "\n"
264+
" DoFs per node : %" PetscInt_FMT "\n"
265+
" Global nodes : %" PetscInt_FMT "\n"
266+
" Owned nodes : %" PetscInt_FMT "\n",
267267
num_P, num_Q, glob_dofs, owned_dofs, num_comp_q,
268268
glob_nodes, owned_nodes); CHKERRQ(ierr);
269269
}

examples/fluids/src/cloptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ PetscErrorCode ProcessCommandLineOptions(MPI_Comm comm, AppCtx app_ctx,
134134
for (PetscInt w = 0; w < bc->num_wall; w++)
135135
if (bc->slips[c][s] == bc->walls[w])
136136
SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG,
137-
"Boundary condition already set on face %D!\n",
137+
"Boundary condition already set on face %" PetscInt_FMT "!\n",
138138
bc->walls[w]);
139139

140140
// Inflow BCs

examples/fluids/src/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ PetscErrorCode PostProcess_NS(TS ts, CeedData ceed_data, DM dm,
202202
ierr = TSGetStepNumber(ts, &steps); CHKERRQ(ierr);
203203
if (!app_ctx->test_mode) {
204204
ierr = PetscPrintf(PETSC_COMM_WORLD,
205-
"Time integrator took %D time steps to reach final time %g\n",
205+
"Time integrator took %" PetscInt_FMT " time steps to reach final time %g\n",
206206
steps, (double)final_time); CHKERRQ(ierr);
207207
}
208208

examples/fluids/src/setupts.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ PetscErrorCode TSMonitor_NS(TS ts, PetscInt step_no, PetscReal time,
220220
ierr = DMGlobalToLocal(user->dm, Q, INSERT_VALUES, Q_loc); CHKERRQ(ierr);
221221

222222
// Output
223-
ierr = PetscSNPrintf(file_path, sizeof file_path, "%s/ns-%03D.vtu",
223+
ierr = PetscSNPrintf(file_path, sizeof file_path,
224+
"%s/ns-%03" PetscInt_FMT ".vtu",
224225
user->app_ctx->output_dir, step_no + user->app_ctx->cont_steps);
225226
CHKERRQ(ierr);
226227
ierr = PetscViewerVTKOpen(PetscObjectComm((PetscObject)Q), file_path,
@@ -241,7 +242,7 @@ PetscErrorCode TSMonitor_NS(TS ts, PetscInt step_no, PetscReal time,
241242
ierr = DMGlobalToLocal(user->dm_viz, Q_refined, INSERT_VALUES, Q_refined_loc);
242243
CHKERRQ(ierr);
243244
ierr = PetscSNPrintf(file_path_refined, sizeof file_path_refined,
244-
"%s/nsrefined-%03D.vtu", user->app_ctx->output_dir,
245+
"%s/nsrefined-%03" PetscInt_FMT ".vtu", user->app_ctx->output_dir,
245246
step_no + user->app_ctx->cont_steps);
246247
CHKERRQ(ierr);
247248
ierr = PetscViewerVTKOpen(PetscObjectComm((PetscObject)Q_refined),

examples/petsc/area.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ int main(int argc, char **argv) {
190190
" Mesh:\n"
191191
" Number of 1D Basis Nodes (p) : %d\n"
192192
" Number of 1D Quadrature Points (q) : %d\n"
193-
" Global nodes : %D\n"
194-
" DoF per node : %D\n"
195-
" Global DoFs : %D\n",
193+
" Global nodes : %" PetscInt_FMT "\n"
194+
" DoF per node : %" PetscInt_FMT "\n"
195+
" Global DoFs : %" PetscInt_FMT "\n",
196196
used_resource, CeedMemTypes[mem_type_backend], P, Q,
197197
g_size/num_comp_u, num_comp_u, g_size); CHKERRQ(ierr);
198198
}

examples/petsc/bps.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ static PetscErrorCode RunWithDM(RunParams rp, DM dm,
183183
" Mesh:\n"
184184
" Number of 1D Basis Nodes (P) : %d\n"
185185
" Number of 1D Quadrature Points (Q) : %d\n"
186-
" Global nodes : %D\n"
187-
" Local Elements : %D\n"
188-
" Owned nodes : %D\n"
189-
" DoF per node : %D\n",
186+
" Global nodes : %" PetscInt_FMT "\n"
187+
" Local Elements : %" PetscInt_FMT "\n"
188+
" Owned nodes : %" PetscInt_FMT "\n"
189+
" DoF per node : %" PetscInt_FMT "\n",
190190
rp->bp_choice+1, rp->hostname, comm_size,
191191
rp->ranks_per_node, vec_type, used_resource,
192192
CeedMemTypes[mem_type_backend],
@@ -308,7 +308,7 @@ static PetscErrorCode RunWithDM(RunParams rp, DM dm,
308308
" KSP:\n"
309309
" KSP Type : %s\n"
310310
" KSP Convergence : %s\n"
311-
" Total KSP Iterations : %D\n"
311+
" Total KSP Iterations : %" PetscInt_FMT "\n"
312312
" Final rnorm : %e\n",
313313
ksp_type, KSPConvergedReasons[reason], its,
314314
(double)rnorm); CHKERRQ(ierr);

examples/petsc/bpsraw.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,14 @@ int main(int argc, char **argv) {
555555
" Mesh:\n"
556556
" Number of 1D Basis Nodes (P) : %d\n"
557557
" Number of 1D Quadrature Points (Q) : %d\n"
558-
" Global nodes : %D\n"
559-
" Process Decomposition : %D %D %D\n"
560-
" Local Elements : %D = %D %D %D\n"
561-
" Owned nodes : %D = %D %D %D\n"
562-
" DoF per node : %D\n",
558+
" Global nodes : %" PetscInt_FMT "\n"
559+
" Process Decomposition : %" PetscInt_FMT
560+
" %" PetscInt_FMT " %" PetscInt_FMT "\n"
561+
" Local Elements : %" PetscInt_FMT
562+
" = %" PetscInt_FMT " %" PetscInt_FMT " %" PetscInt_FMT "\n"
563+
" Owned nodes : %" PetscInt_FMT
564+
" = %" PetscInt_FMT " %" PetscInt_FMT " %" PetscInt_FMT "\n"
565+
" DoF per node : %" PetscInt_FMT "\n",
563566
bp_choice+1, vec_type, used_resource,
564567
CeedMemTypes[mem_type_backend],
565568
P, Q, gsize/num_comp_u, p[0], p[1], p[2], local_elem,
@@ -903,7 +906,7 @@ int main(int argc, char **argv) {
903906
" KSP:\n"
904907
" KSP Type : %s\n"
905908
" KSP Convergence : %s\n"
906-
" Total KSP Iterations : %D\n"
909+
" Total KSP Iterations : %" PetscInt_FMT "\n"
907910
" Final rnorm : %e\n",
908911
ksp_type, KSPConvergedReasons[reason], its,
909912
(double)rnorm); CHKERRQ(ierr);

examples/petsc/bpssphere.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ int main(int argc, char **argv) {
200200
" Mesh:\n"
201201
" Number of 1D Basis Nodes (p) : %d\n"
202202
" Number of 1D Quadrature Points (q) : %d\n"
203-
" Global nodes : %D\n",
203+
" Global nodes : %" PetscInt_FMT "\n",
204204
bp_choice+1, ceed_resource, CeedMemTypes[mem_type_backend], P, Q,
205205
g_size/num_comp_u); CHKERRQ(ierr);
206206
}
@@ -326,7 +326,7 @@ int main(int argc, char **argv) {
326326
" KSP:\n"
327327
" KSP Type : %s\n"
328328
" KSP Convergence : %s\n"
329-
" Total KSP Iterations : %D\n"
329+
" Total KSP Iterations : %" PetscInt_FMT "\n"
330330
" Final rnorm : %e\n",
331331
ksp_type, KSPConvergedReasons[reason], its,
332332
(double)rnorm); CHKERRQ(ierr);

examples/petsc/multigrid.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ int main(int argc, char **argv) {
112112
"Epsilon parameter for Kershaw mesh transformation",
113113
NULL, eps, &eps, NULL);
114114
if (eps > 1 || eps <= 0) SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_OUTOFRANGE,
115-
"-eps %D must be (0,1]", eps);
115+
"-eps %g must be (0,1]", (double)PetscRealPart(eps));
116116
degree = test_mode ? 3 : 2;
117117
ierr = PetscOptionsInt("-degree", "Polynomial degree of tensor product basis",
118118
NULL, degree, &degree, NULL); CHKERRQ(ierr);
119119
if (degree < 1) SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_OUTOFRANGE,
120-
"-degree %D must be at least 1", degree);
120+
"-degree %" PetscInt_FMT " must be at least 1", degree);
121121
q_extra = bp_options[bp_choice].q_extra;
122122
ierr = PetscOptionsInt("-q_extra", "Number of extra quadrature points",
123123
NULL, q_extra, &q_extra, NULL); CHKERRQ(ierr);
@@ -273,9 +273,9 @@ int main(int argc, char **argv) {
273273
" Mesh:\n"
274274
" Number of 1D Basis Nodes (p) : %d\n"
275275
" Number of 1D Quadrature Points (q) : %d\n"
276-
" Global Nodes : %D\n"
277-
" Owned Nodes : %D\n"
278-
" DoF per node : %D\n"
276+
" Global Nodes : %" PetscInt_FMT "\n"
277+
" Owned Nodes : %" PetscInt_FMT "\n"
278+
" DoF per node : %" PetscInt_FMT "\n"
279279
" Multigrid:\n"
280280
" Number of Levels : %d\n",
281281
bp_choice+1, vec_type, used_resource,
@@ -296,10 +296,10 @@ int main(int argc, char **argv) {
296296
for (int i=0; i<num_levels; i++) {
297297
// Print level information
298298
if (!test_mode && (i == 0 || i == fine_level)) {
299-
ierr = PetscPrintf(comm," Level %D (%s):\n"
299+
ierr = PetscPrintf(comm," Level %" PetscInt_FMT " (%s):\n"
300300
" Number of 1D Basis Nodes (p) : %d\n"
301-
" Global Nodes : %D\n"
302-
" Owned Nodes : %D\n",
301+
" Global Nodes : %" PetscInt_FMT "\n"
302+
" Owned Nodes : %" PetscInt_FMT "\n",
303303
i, (i? "fine" : "coarse"), level_degrees[i] + 1,
304304
g_size[i]/num_comp_u, l_size[i]/num_comp_u); CHKERRQ(ierr);
305305
}
@@ -562,7 +562,7 @@ int main(int argc, char **argv) {
562562
" KSP:\n"
563563
" KSP Type : %s\n"
564564
" KSP Convergence : %s\n"
565-
" Total KSP Iterations : %D\n"
565+
" Total KSP Iterations : %" PetscInt_FMT "\n"
566566
" Final rnorm : %e\n",
567567
ksp_type, KSPConvergedReasons[reason], its,
568568
(double)rnorm); CHKERRQ(ierr);

examples/solids/elasticity.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ int main(int argc, char **argv) {
388388
" File : %s\n"
389389
" Number of 1D Basis Nodes (p) : %d\n"
390390
" Number of 1D Quadrature Points (q) : %d\n"
391-
" Global nodes : %D\n"
392-
" Owned nodes : %D\n"
393-
" DoF per node : %D\n"
391+
" Global nodes : %" PetscInt_FMT "\n"
392+
" Owned nodes : %" PetscInt_FMT "\n"
393+
" DoF per node : %" PetscInt_FMT "\n"
394394
" Multigrid:\n"
395395
" Type : %s\n"
396396
" Number of Levels : %d\n",
@@ -412,10 +412,10 @@ int main(int argc, char **argv) {
412412
for (PetscInt i = 0; i < 2; i++) {
413413
CeedInt level = i ? fine_level : 0;
414414
ierr = PetscPrintf(comm,
415-
" Level %D (%s):\n"
415+
" Level %" PetscInt_FMT " (%s):\n"
416416
" Number of 1D Basis Nodes (p) : %d\n"
417-
" Global Nodes : %D\n"
418-
" Owned Nodes : %D\n",
417+
" Global Nodes : %" PetscInt_FMT "\n"
418+
" Owned Nodes : %" PetscInt_FMT "\n",
419419
level, i ? "fine" : "coarse",
420420
app_ctx->level_degrees[level] + 1,
421421
U_g_size[level]/num_comp_u, U_l_size[level]/num_comp_u);
@@ -763,7 +763,7 @@ int main(int argc, char **argv) {
763763
" SNES Convergence : %s\n"
764764
" Number of Load Increments : %d\n"
765765
" Completed Load Increments : %d\n"
766-
" Total SNES Iterations : %D\n"
766+
" Total SNES Iterations : %" PetscInt_FMT "\n"
767767
" Final rnorm : %e\n",
768768
snes_type, SNESConvergedReasons[reason],
769769
app_ctx->num_increments, increment - 1,
@@ -777,7 +777,7 @@ int main(int argc, char **argv) {
777777
ierr = PetscPrintf(comm,
778778
" Linear Solver:\n"
779779
" KSP Type : %s\n"
780-
" Total KSP Iterations : %D\n",
780+
" Total KSP Iterations : %" PetscInt_FMT "\n",
781781
ksp_type, ksp_its); CHKERRQ(ierr);
782782

783783
// -- PC

0 commit comments

Comments
 (0)