Skip to content

Commit 43c1210

Browse files
committed
Replace %lld with OFFFMT in case MPI_Offset is either long long or long
1 parent b20cf58 commit 43c1210

File tree

129 files changed

+270
-269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+270
-269
lines changed

src/dispatchers/cdl_header_parser.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ typedef long long MPI_Offset;
6363
#define NC_ENFILE (-34) /**< Too many netcdfs open */
6464
#define NC_EBADDIM (-46) /**< Invalid dimension id or name */
6565
#define NC_ENOTNC (-51) /**< Not a netcdf file */
66+
#define NC_ENOMEM (-61) /**< Memory allocation (malloc) failure */
6667
#define NC_EFILE (-204) /**< Unknown error in file operation */
6768
#define NC_ENOENT (-220) /**< File does not exist */
6869

@@ -1015,7 +1016,7 @@ int main(int argc, char **argv)
10151016
/* retrieve metadata of each dimension defined in the CDL file */
10161017
for (i=0; i<ndims; i++) {
10171018
err = cdl_hdr_inq_dim(hid, i, &name, &size); ERR
1018-
printf("\t name %s size %lld\n",name, size);
1019+
printf("\t name %s size " OFFFMT "\n",name, size);
10191020
}
10201021

10211022
/* retrieve number of variables defined in the CDL file */
@@ -1039,10 +1040,10 @@ int main(int argc, char **argv)
10391040
err = cdl_hdr_inq_attr(hid, i, j, &name, &xtype, &nelems, &value);
10401041
ERR
10411042
if (xtype == NC_CHAR)
1042-
printf("\t\tattr %s type %d nelems %lld (%s)\n",
1043+
printf("\t\tattr %s type %d nelems "OFFFMT" (%s)\n",
10431044
name, xtype,nelems,(char*)value);
10441045
else
1045-
printf("\t\tattr %s type %d nelems %lld\n",
1046+
printf("\t\tattr %s type %d nelems "OFFFMT"\n",
10461047
name, xtype, nelems);
10471048
}
10481049
}
@@ -1058,10 +1059,10 @@ int main(int argc, char **argv)
10581059
err = cdl_hdr_inq_attr(hid, NC_GLOBAL, i, &name, &xtype, &nelems, &value);
10591060
ERR
10601061
if (xtype == NC_CHAR)
1061-
printf("\t name %s type %d nelems %lld (%s)\n",
1062+
printf("\t name %s type %d nelems "OFFFMT" (%s)\n",
10621063
name, xtype, nelems,(char*)value);
10631064
else
1064-
printf("\t name %s type %d nelems %lld\n",
1065+
printf("\t name %s type %d nelems "OFFFMT"\n",
10651066
name, xtype, nelems);
10661067
}
10671068

src/dispatchers/var_getput.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ int check_EEDGE(const MPI_Offset *start,
116116
pncp->driver->inq_var(pncp->ncp, varid, name, NULL, NULL, \
117117
NULL, NULL, NULL, NULL, NULL); \
118118
if (stride != NULL) \
119-
fprintf(stderr, "Rank %d: NC_EEDGE variable %s: shape[%d]=%lld but start[%d]=%lld count[%d]=%lld stride[%d]=%lld\n", \
119+
fprintf(stderr, "Rank %d: NC_EEDGE variable %s: shape[%d]="OFFFMT" but start[%d]="OFFFMT" count[%d]="OFFFMT" stride[%d]="OFFFMT"\n", \
120120
_rank, name, dim, shape[dim], dim, start[dim], dim, count[dim], dim, stride[dim]); \
121121
else \
122-
fprintf(stderr, "Rank %d: NC_EEDGE variable %s: shape[%d]=%lld but start[%d]=%lld count[%d]=%lld\n", \
122+
fprintf(stderr, "Rank %d: NC_EEDGE variable %s: shape[%d]="OFFFMT" but start[%d]="OFFFMT" count[%d]="OFFFMT"\n", \
123123
_rank, name, dim, shape[dim], dim, start[dim], dim, count[dim]); \
124124
} \
125125
} \

src/drivers/ncmpio/ncmpio_enddef.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ move_file_block(NC *ncp,
118118
get_size = pread(fd, buf, chunk_size, off_from);
119119
if (get_size < 0) {
120120
fprintf(stderr,
121-
"Error at %s line %d: pread file %s offset %lld size %zd (%s)\n",
121+
"Error at %s line %d: pread file %s offset "OFFFMT" size %zd (%s)\n",
122122
__func__,__LINE__,path,off_from,chunk_size,strerror(errno));
123123
DEBUG_RETURN_ERROR(NC_EREAD)
124124
}
@@ -138,7 +138,7 @@ move_file_block(NC *ncp,
138138
put_size = pwrite(fd, buf, get_size, off_to);
139139
if (put_size < 0) {
140140
fprintf(stderr,
141-
"Error at %s line %d: pwrite file %s offset %lld size %zd (%s)\n",
141+
"Error at %s line %d: pwrite file %s offset "OFFFMT" size %zd (%s)\n",
142142
__func__,__LINE__,path,off_to,get_size,strerror(errno));
143143
DEBUG_RETURN_ERROR(NC_EREAD)
144144
}
@@ -953,7 +953,7 @@ ncmpio_NC_check_voffs(NC *ncp)
953953
NC_var *varp = ncp->vars.value[i];
954954
if (varp->begin < ncp->xsz) {
955955
if (ncp->safe_mode) {
956-
printf("Variable %s begin offset (%lld) is less than file header extent (%lld)\n",
956+
printf("Variable %s begin offset ("OFFFMT") is less than file header extent ("OFFFMT")\n",
957957
varp->name, varp->begin, ncp->xsz);
958958
}
959959
NCI_Free(var_off_len);
@@ -982,7 +982,7 @@ ncmpio_NC_check_voffs(NC *ncp)
982982
if (ncp->safe_mode) {
983983
NC_var *var_cur = ncp->vars.value[var_off_len[i].ID];
984984
NC_var *var_prv = ncp->vars.value[var_off_len[i-1].ID];
985-
printf("Variable %s begin offset (%lld) overlaps variable %s (begin=%lld, length=%lld)\n",
985+
printf("Variable %s begin offset ("OFFFMT") overlaps variable %s (begin="OFFFMT", length="OFFFMT")\n",
986986
var_cur->name, var_cur->begin, var_prv->name, var_prv->begin, var_prv->len);
987987
}
988988
NCI_Free(var_off_len);
@@ -994,7 +994,7 @@ ncmpio_NC_check_voffs(NC *ncp)
994994

995995
if (ncp->begin_rec < max_var_end) {
996996
if (ncp->safe_mode)
997-
printf("Record variable section begin (%lld) is less than fixed-size variable section end (%lld)\n",
997+
printf("Record variable section begin ("OFFFMT") is less than fixed-size variable section end ("OFFFMT")\n",
998998
ncp->begin_rec, max_var_end);
999999
NCI_Free(var_off_len);
10001000
DEBUG_RETURN_ERROR(NC_ENOTNC)
@@ -1030,7 +1030,7 @@ ncmpio_NC_check_voffs(NC *ncp)
10301030
if (ncp->safe_mode) {
10311031
NC_var *var_cur = ncp->vars.value[var_off_len[i].ID];
10321032
NC_var *var_prv = ncp->vars.value[var_off_len[i-1].ID];
1033-
printf("Variable %s begin offset (%lld) overlaps variable %s (begin=%lld, length=%lld)\n",
1033+
printf("Variable %s begin offset ("OFFFMT") overlaps variable %s (begin="OFFFMT", length="OFFFMT")\n",
10341034
var_cur->name, var_cur->begin, var_prv->name, var_prv->begin, var_prv->len);
10351035
}
10361036
NCI_Free(var_off_len);
@@ -1052,10 +1052,10 @@ ncmpio_NC_check_voffs(NC *ncp)
10521052
if (varp->begin < prev_off) {
10531053
if (ncp->safe_mode) {
10541054
if (i == 0)
1055-
printf("Variable \"%s\" begin offset (%lld) is less than header extent (%lld)\n",
1055+
printf("Variable \"%s\" begin offset ("OFFFMT") is less than header extent ("OFFFMT")\n",
10561056
varp->name, varp->begin, prev_off);
10571057
else
1058-
printf("Variable \"%s\" begin offset (%lld) is less than previous variable \"%s\" end offset (%lld)\n",
1058+
printf("Variable \"%s\" begin offset ("OFFFMT") is less than previous variable \"%s\" end offset ("OFFFMT")\n",
10591059
varp->name, varp->begin, ncp->vars.value[prev]->name, prev_off);
10601060
}
10611061
DEBUG_RETURN_ERROR(NC_ENOTNC)
@@ -1066,7 +1066,7 @@ ncmpio_NC_check_voffs(NC *ncp)
10661066

10671067
if (ncp->begin_rec < prev_off) {
10681068
if (ncp->safe_mode)
1069-
printf("Record variable section begin offset (%lld) is less than fixed-size variable section end offset (%lld)\n",
1069+
printf("Record variable section begin offset ("OFFFMT") is less than fixed-size variable section end offset ("OFFFMT")\n",
10701070
ncp->begin_rec, prev_off);
10711071
DEBUG_RETURN_ERROR(NC_ENOTNC)
10721072
}
@@ -1083,13 +1083,13 @@ ncmpio_NC_check_voffs(NC *ncp)
10831083

10841084
if (varp->begin < prev_off) {
10851085
if (ncp->safe_mode) {
1086-
printf("Variable \"%s\" begin offset (%lld) is less than previous variable end offset (%lld)\n",
1086+
printf("Variable \"%s\" begin offset ("OFFFMT") is less than previous variable end offset ("OFFFMT")\n",
10871087
varp->name, varp->begin, prev_off);
10881088
if (i == 0)
1089-
printf("Variable \"%s\" begin offset (%lld) is less than record variable section begin offset (%lld)\n",
1089+
printf("Variable \"%s\" begin offset ("OFFFMT") is less than record variable section begin offset ("OFFFMT")\n",
10901090
varp->name, varp->begin, prev_off);
10911091
else
1092-
printf("Variable \"%s\" begin offset (%lld) is less than previous variable \"%s\" end offset (%lld)\n",
1092+
printf("Variable \"%s\" begin offset ("OFFFMT") is less than previous variable \"%s\" end offset ("OFFFMT")\n",
10931093
varp->name, varp->begin, ncp->vars.value[prev]->name, prev_off);
10941094
}
10951095
DEBUG_RETURN_ERROR(NC_ENOTNC)
@@ -1312,9 +1312,9 @@ ncmpio__enddef(void *ncdp,
13121312
/* reflect the hint changes to the MPI info object, so the user can inquire
13131313
* what the true hint values are being used
13141314
*/
1315-
sprintf(value, "%lld", ncp->v_align);
1315+
sprintf(value, OFFFMT, ncp->v_align);
13161316
MPI_Info_set(ncp->mpiinfo, "nc_var_align_size", value);
1317-
sprintf(value, "%lld", ncp->r_align);
1317+
sprintf(value, OFFFMT, ncp->r_align);
13181318
MPI_Info_set(ncp->mpiinfo, "nc_record_align_size", value);
13191319

13201320
#ifdef ENABLE_SUBFILING

src/drivers/ncmpio/ncmpio_file_io.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ncmpio_read_write(NC *ncp,
5656
}
5757
else if (btype_size == MPI_UNDEFINED) {
5858
#ifdef PNETCDF_DEBUG
59-
fprintf(stderr,"%d: %s line %d: btype_size MPI_UNDEFINED buf_count=%lld\n",
59+
fprintf(stderr,"%d: %s line %d: btype_size MPI_UNDEFINED buf_count="OFFFMT"\n",
6060
ncp->rank, __func__,__LINE__,buf_count);
6161
#endif
6262
DEBUG_ASSIGN_ERROR(err, NC_EINTOVERFLOW)
@@ -99,7 +99,7 @@ ncmpio_read_write(NC *ncp,
9999
if (buf_count > NC_MAX_INT) {
100100
if (coll_indep == NC_REQ_COLL) {
101101
#ifdef PNETCDF_DEBUG
102-
fprintf(stderr,"%d: %s line %d: NC_EINTOVERFLOW buf_count=%lld\n",
102+
fprintf(stderr,"%d: %s line %d: NC_EINTOVERFLOW buf_count="OFFFMT"\n",
103103
ncp->rank, __func__,__LINE__,buf_count);
104104
#endif
105105
DEBUG_ASSIGN_ERROR(status, NC_EINTOVERFLOW)
@@ -221,7 +221,7 @@ ncmpio_read_write(NC *ncp,
221221
if (buf_count > NC_MAX_INT) {
222222
if (coll_indep == NC_REQ_COLL) {
223223
#ifdef PNETCDF_DEBUG
224-
fprintf(stderr,"%d: %s line %d: NC_EINTOVERFLOW buf_count=%lld\n",
224+
fprintf(stderr,"%d: %s line %d: NC_EINTOVERFLOW buf_count="OFFFMT"\n",
225225
ncp->rank, __func__,__LINE__,buf_count);
226226
#endif
227227
DEBUG_ASSIGN_ERROR(status, NC_EINTOVERFLOW)

src/drivers/ncmpio/ncmpio_file_misc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,10 @@ ncmpio_inq_misc(void *ncdp,
382382
* user.
383383
*/
384384

385-
sprintf(value, "%lld", ncp->v_align);
385+
sprintf(value, OFFFMT, ncp->v_align);
386386
MPI_Info_set(*info_used, "nc_var_align_size", value);
387387

388-
sprintf(value, "%lld", ncp->r_align);
388+
sprintf(value, OFFFMT, ncp->r_align);
389389
MPI_Info_set(*info_used, "nc_record_align_size", value);
390390

391391
sprintf(value, "%d", ncp->chunk);
@@ -398,7 +398,7 @@ ncmpio_inq_misc(void *ncdp,
398398
else
399399
MPI_Info_set(*info_used, "nc_in_place_swap", "auto");
400400

401-
sprintf(value, "%lld", ncp->ibuf_size);
401+
sprintf(value, OFFFMT, ncp->ibuf_size);
402402
MPI_Info_set(*info_used, "nc_ibuf_size", value);
403403

404404
#ifdef ENABLE_SUBFILING

src/drivers/ncmpio/ncmpio_subfile.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ int ncmpio_subfile_partition(NC *ncp)
378378
max = (MPI_Offset)yy-(yy-(MPI_Offset)yy==0.0?1:0);
379379
if (max >= dim_sz0) max = dim_sz0-1;
380380
#ifdef SUBFILE_DEBUG
381-
if (myrank == 0) printf("subfile(%d): min=%lld, max=%lld\n", jj, min, max);
381+
if (myrank == 0) printf("subfile(%d): min="OFFFMT", max="OFFFMT"\n", jj, min, max);
382382
#endif
383383
if (j == par_dim_id) { /* partitioning dims? */
384384
sf_range[jj][j][0] = min;
@@ -621,12 +621,12 @@ ncmpio_subfile_getput_vars(NC *ncp,
621621
jj++;
622622
else {
623623
#ifdef SUBFILE_DEBUG
624-
printf("rank(%d): var(%s): i=%d, j=%d, ii=%lld, jj=%lld, kk=%lld, jx=%d\n", myrank, varp->name, i, j, ii, jj, kk, jx);
624+
printf("rank(%d): var(%s): i=%d, j=%d, ii="OFFFMT", jj="OFFFMT", kk="OFFFMT", jx=%d\n", myrank, varp->name, i, j, ii, jj, kk, jx);
625625
#endif
626626
if (kk == 0) {
627627
my_req[aproc].start[jx] = ii;
628628
#ifdef SUBFILE_DEBUG
629-
printf("rank(%d): var(%s): my_req[%d].start[%d]=%lld\n",
629+
printf("rank(%d): var(%s): my_req[%d].start[%d]="OFFFMT"\n",
630630
myrank, varp->name, aproc, jx, ii);
631631
#endif
632632
}
@@ -817,7 +817,7 @@ ncmpio_subfile_getput_vars(NC *ncp,
817817
/* making diff is necessary?? */
818818
diff[i] = ABS(my_req[myrank].start_org[i]-start[i])/stride_count;
819819
#ifdef SUBFILE_DEBUG
820-
if (myrank == 0) printf("rank(%d): my_req[%d].start_org[%d]=%d, start[%d]=%d, diff[%d]=%lld\n", myrank,
820+
if (myrank == 0) printf("rank(%d): my_req[%d].start_org[%d]=%d, start[%d]=%d, diff[%d]="OFFFMT"\n", myrank,
821821
myrank, i, my_req[myrank].start_org[i], i, start[i], i, diff[i]);
822822
#endif
823823
}

src/drivers/ncmpio/ncmpio_util.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void ncmpio_set_pnetcdf_hints(NC *ncp,
5757
if (ncp->info_v_align == -1)
5858
sprintf(value, "%d", FILE_ALIGNMENT_DEFAULT);
5959
else
60-
sprintf(value, "%lld", ncp->info_v_align);
60+
sprintf(value, OFFFMT, ncp->info_v_align);
6161
MPI_Info_set(info_used, "nc_var_align_size", value);
6262

6363
if (user_info != MPI_INFO_NULL) {
@@ -78,7 +78,7 @@ void ncmpio_set_pnetcdf_hints(NC *ncp,
7878
*/
7979
if (info_h_align >= 0 && ncp->info_v_align == -1) {
8080
ncp->info_v_align = info_h_align;
81-
sprintf(value, "%lld", ncp->info_v_align);
81+
sprintf(value, OFFFMT, ncp->info_v_align);
8282
MPI_Info_set(info_used, "nc_var_align_size", value);
8383
}
8484
}
@@ -98,7 +98,7 @@ void ncmpio_set_pnetcdf_hints(NC *ncp,
9898
if (ncp->info_r_align == -1)
9999
sprintf(value, "%d", FILE_ALIGNMENT_DEFAULT);
100100
else
101-
sprintf(value, "%lld", ncp->info_r_align);
101+
sprintf(value, OFFFMT, ncp->info_r_align);
102102
MPI_Info_set(info_used, "nc_record_align_size", value);
103103

104104
ncp->chunk = PNC_DEFAULT_CHUNKSIZE;
@@ -154,7 +154,7 @@ void ncmpio_set_pnetcdf_hints(NC *ncp,
154154
if (errno == 0 && ibuf_size >= 0) ncp->ibuf_size = ibuf_size;
155155
}
156156
}
157-
sprintf(value, "%lld", ncp->ibuf_size);
157+
sprintf(value, OFFFMT, ncp->ibuf_size);
158158
MPI_Info_set(info_used, "nc_ibuf_size", value);
159159

160160
#ifdef ENABLE_SUBFILING

0 commit comments

Comments
 (0)