@@ -555,7 +555,11 @@ int wrf_w_benchmark(char *out_file,
555555 /* create the output file */
556556 cmode = NC_CLOBBER | NC_64BIT_DATA ;
557557 err = ncmpi_create (MPI_COMM_WORLD , out_file , cmode , info , & ncid );
558- CHECK_ERR ("ncmpi_create" )
558+ if (err != NC_NOERR ) {
559+ printf ("Error at line=%d: creating file %s (%s)\n" ,
560+ __LINE__ , out_file , ncmpi_strerror (err ));
561+ goto err_out ;
562+ }
559563
560564 /* define dimension, variables, and attributes */
561565 err = def_dims_vars (ncid , hid , & longitude , & latitude , vars );
@@ -730,7 +734,11 @@ int wrf_r_benchmark(char *in_file,
730734
731735 /* open input file */
732736 err = ncmpi_open (MPI_COMM_WORLD , in_file , NC_NOWRITE , info , & ncid );
733- CHECK_ERR ("ncmpi_open" )
737+ if (err != NC_NOERR ) {
738+ printf ("Error at line=%d: opening file %s (%s)\n" ,
739+ __LINE__ , in_file , ncmpi_strerror (err ));
740+ goto err_out ;
741+ }
734742
735743 /* start the timer */
736744 MPI_Barrier (MPI_COMM_WORLD );
@@ -1097,13 +1105,13 @@ int main(int argc, char** argv)
10971105 err = wrf_w_benchmark (fname [i ], hid , psizes , longitude , latitude ,
10981106 ntimes , info );
10991107
1100- if (err != NC_NOERR )
1101- printf ("%d: Error at %s line=%d: i=%d error=%s\n" ,
1102- rank , argv [0 ], __LINE__ , i , ncmpi_strerror (err ));
1103-
1108+ if (err != NC_NOERR ) goto err_out ;
11041109 free (fname [i ]);
11051110 }
1111+
11061112 if (nfiles > 0 ) free (fname );
1113+ cdl_hdr_close (hid );
1114+ if (out_files != NULL ) free (out_files );
11071115 }
11081116
11091117 if (do_read ) {
@@ -1115,19 +1123,15 @@ int main(int argc, char** argv)
11151123
11161124 err = wrf_r_benchmark (fname [i ], psizes , ntimes , info );
11171125
1118- if (err != NC_NOERR )
1119- printf ("%d: Error at %s line=%d: i=%d error=%s\n" ,
1120- rank , argv [0 ], __LINE__ , i , ncmpi_strerror (err ));
1121-
1126+ if (err != NC_NOERR ) goto err_out ;
11221127 free (fname [i ]);
11231128 }
1129+
11241130 if (nfiles > 0 ) free (fname );
1131+ if (in_files != NULL ) free (in_files );
11251132 }
11261133
11271134err_out :
1128- cdl_hdr_close (hid );
1129- if (out_files != NULL ) free (out_files );
1130- if (in_files != NULL ) free (in_files );
11311135 if (info != MPI_INFO_NULL ) MPI_Info_free (& info );
11321136
11331137 MPI_Finalize ();
0 commit comments