Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,47 @@ if test "$ac_cv_sizeof_MPI_Offset" -lt "8"; then
-----------------------------------------------------------------------])
fi

MPI_OFFSET_FMT="%lld"
if test "x$GCC" = xyes ; then
# check if MPI_Offset is long long int or long int.
AC_MSG_CHECKING([MPI_Offset type])
saved_CFLAGS=$CFLAGS
MPI_Offset_type="unknown"
CFLAGS="$CFLAGS -Werror=format"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
#include <mpi.h>]],
[[printf("%lld\n", (MPI_Offset)1);]])],
[MPI_Offset_is_long_long=yes],
[MPI_Offset_is_long_long=no])
if test $MPI_Offset_is_long_long = no ; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
#include <mpi.h>]],
[[printf("%ld\n", (MPI_Offset)1);]])],
[MPI_Offset_is_long=yes],
[MPI_Offset_is_long=no])
if test $MPI_Offset_is_long = no ; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
#include <mpi.h>]],
[[printf("%d\n", (MPI_Offset)1);]])],
[MPI_Offset_is_int=yes],
[MPI_Offset_is_int=no])
if test $MPI_Offset_is_int = yes ; then
MPI_Offset_type="int"
MPI_OFFSET_FMT="%d"
fi
else
MPI_Offset_type="long"
MPI_OFFSET_FMT="%ld"
fi
else
MPI_Offset_type="long long"
MPI_OFFSET_FMT="%lld"
fi
AC_MSG_RESULT([$MPI_Offset_type])
CFLAGS=$saved_CFLAGS
fi
AC_DEFINE_UNQUOTED([OFFFMT], ["$MPI_OFFSET_FMT"], [MPI_Offset printf format])

AC_CHECK_SIZEOF([MPI_Aint], [], [#include <mpi.h>])
AM_CONDITIONAL(SIZEOF_MPI_AINT_IS_4, [test x$ac_cv_sizeof_MPI_Aint = x4])

Expand Down
11 changes: 6 additions & 5 deletions src/dispatchers/cdl_header_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ typedef long long MPI_Offset;
#define NC_ENFILE (-34) /**< Too many netcdfs open */
#define NC_EBADDIM (-46) /**< Invalid dimension id or name */
#define NC_ENOTNC (-51) /**< Not a netcdf file */
#define NC_ENOMEM (-61) /**< Memory allocation (malloc) failure */
#define NC_EFILE (-204) /**< Unknown error in file operation */
#define NC_ENOENT (-220) /**< File does not exist */

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

/* retrieve number of variables defined in the CDL file */
Expand All @@ -1039,10 +1040,10 @@ int main(int argc, char **argv)
err = cdl_hdr_inq_attr(hid, i, j, &name, &xtype, &nelems, &value);
ERR
if (xtype == NC_CHAR)
printf("\t\tattr %s type %d nelems %lld (%s)\n",
printf("\t\tattr %s type %d nelems "OFFFMT" (%s)\n",
name, xtype,nelems,(char*)value);
else
printf("\t\tattr %s type %d nelems %lld\n",
printf("\t\tattr %s type %d nelems "OFFFMT"\n",
name, xtype, nelems);
}
}
Expand All @@ -1058,10 +1059,10 @@ int main(int argc, char **argv)
err = cdl_hdr_inq_attr(hid, NC_GLOBAL, i, &name, &xtype, &nelems, &value);
ERR
if (xtype == NC_CHAR)
printf("\t name %s type %d nelems %lld (%s)\n",
printf("\t name %s type %d nelems "OFFFMT" (%s)\n",
name, xtype, nelems,(char*)value);
else
printf("\t name %s type %d nelems %lld\n",
printf("\t name %s type %d nelems "OFFFMT"\n",
name, xtype, nelems);
}

Expand Down
4 changes: 2 additions & 2 deletions src/dispatchers/var_getput.m4
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ int check_EEDGE(const MPI_Offset *start,
pncp->driver->inq_var(pncp->ncp, varid, name, NULL, NULL, \
NULL, NULL, NULL, NULL, NULL); \
if (stride != NULL) \
fprintf(stderr, "Rank %d: NC_EEDGE variable %s: shape[%d]=%lld but start[%d]=%lld count[%d]=%lld stride[%d]=%lld\n", \
fprintf(stderr, "Rank %d: NC_EEDGE variable %s: shape[%d]="OFFFMT" but start[%d]="OFFFMT" count[%d]="OFFFMT" stride[%d]="OFFFMT"\n", \
_rank, name, dim, shape[dim], dim, start[dim], dim, count[dim], dim, stride[dim]); \
else \
fprintf(stderr, "Rank %d: NC_EEDGE variable %s: shape[%d]=%lld but start[%d]=%lld count[%d]=%lld\n", \
fprintf(stderr, "Rank %d: NC_EEDGE variable %s: shape[%d]="OFFFMT" but start[%d]="OFFFMT" count[%d]="OFFFMT"\n", \
_rank, name, dim, shape[dim], dim, start[dim], dim, count[dim]); \
} \
} \
Expand Down
28 changes: 14 additions & 14 deletions src/drivers/ncmpio/ncmpio_enddef.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ move_file_block(NC *ncp,
get_size = pread(fd, buf, chunk_size, off_from);
if (get_size < 0) {
fprintf(stderr,
"Error at %s line %d: pread file %s offset %lld size %zd (%s)\n",
"Error at %s line %d: pread file %s offset "OFFFMT" size %zd (%s)\n",
__func__,__LINE__,path,off_from,chunk_size,strerror(errno));
DEBUG_RETURN_ERROR(NC_EREAD)
}
Expand All @@ -138,7 +138,7 @@ move_file_block(NC *ncp,
put_size = pwrite(fd, buf, get_size, off_to);
if (put_size < 0) {
fprintf(stderr,
"Error at %s line %d: pwrite file %s offset %lld size %zd (%s)\n",
"Error at %s line %d: pwrite file %s offset "OFFFMT" size %zd (%s)\n",
__func__,__LINE__,path,off_to,get_size,strerror(errno));
DEBUG_RETURN_ERROR(NC_EREAD)
}
Expand Down Expand Up @@ -953,7 +953,7 @@ ncmpio_NC_check_voffs(NC *ncp)
NC_var *varp = ncp->vars.value[i];
if (varp->begin < ncp->xsz) {
if (ncp->safe_mode) {
printf("Variable %s begin offset (%lld) is less than file header extent (%lld)\n",
printf("Variable %s begin offset ("OFFFMT") is less than file header extent ("OFFFMT")\n",
varp->name, varp->begin, ncp->xsz);
}
NCI_Free(var_off_len);
Expand Down Expand Up @@ -982,7 +982,7 @@ ncmpio_NC_check_voffs(NC *ncp)
if (ncp->safe_mode) {
NC_var *var_cur = ncp->vars.value[var_off_len[i].ID];
NC_var *var_prv = ncp->vars.value[var_off_len[i-1].ID];
printf("Variable %s begin offset (%lld) overlaps variable %s (begin=%lld, length=%lld)\n",
printf("Variable %s begin offset ("OFFFMT") overlaps variable %s (begin="OFFFMT", length="OFFFMT")\n",
var_cur->name, var_cur->begin, var_prv->name, var_prv->begin, var_prv->len);
}
NCI_Free(var_off_len);
Expand All @@ -994,7 +994,7 @@ ncmpio_NC_check_voffs(NC *ncp)

if (ncp->begin_rec < max_var_end) {
if (ncp->safe_mode)
printf("Record variable section begin (%lld) is less than fixed-size variable section end (%lld)\n",
printf("Record variable section begin ("OFFFMT") is less than fixed-size variable section end ("OFFFMT")\n",
ncp->begin_rec, max_var_end);
NCI_Free(var_off_len);
DEBUG_RETURN_ERROR(NC_ENOTNC)
Expand Down Expand Up @@ -1030,7 +1030,7 @@ ncmpio_NC_check_voffs(NC *ncp)
if (ncp->safe_mode) {
NC_var *var_cur = ncp->vars.value[var_off_len[i].ID];
NC_var *var_prv = ncp->vars.value[var_off_len[i-1].ID];
printf("Variable %s begin offset (%lld) overlaps variable %s (begin=%lld, length=%lld)\n",
printf("Variable %s begin offset ("OFFFMT") overlaps variable %s (begin="OFFFMT", length="OFFFMT")\n",
var_cur->name, var_cur->begin, var_prv->name, var_prv->begin, var_prv->len);
}
NCI_Free(var_off_len);
Expand All @@ -1052,10 +1052,10 @@ ncmpio_NC_check_voffs(NC *ncp)
if (varp->begin < prev_off) {
if (ncp->safe_mode) {
if (i == 0)
printf("Variable \"%s\" begin offset (%lld) is less than header extent (%lld)\n",
printf("Variable \"%s\" begin offset ("OFFFMT") is less than header extent ("OFFFMT")\n",
varp->name, varp->begin, prev_off);
else
printf("Variable \"%s\" begin offset (%lld) is less than previous variable \"%s\" end offset (%lld)\n",
printf("Variable \"%s\" begin offset ("OFFFMT") is less than previous variable \"%s\" end offset ("OFFFMT")\n",
varp->name, varp->begin, ncp->vars.value[prev]->name, prev_off);
}
DEBUG_RETURN_ERROR(NC_ENOTNC)
Expand All @@ -1066,7 +1066,7 @@ ncmpio_NC_check_voffs(NC *ncp)

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

if (varp->begin < prev_off) {
if (ncp->safe_mode) {
printf("Variable \"%s\" begin offset (%lld) is less than previous variable end offset (%lld)\n",
printf("Variable \"%s\" begin offset ("OFFFMT") is less than previous variable end offset ("OFFFMT")\n",
varp->name, varp->begin, prev_off);
if (i == 0)
printf("Variable \"%s\" begin offset (%lld) is less than record variable section begin offset (%lld)\n",
printf("Variable \"%s\" begin offset ("OFFFMT") is less than record variable section begin offset ("OFFFMT")\n",
varp->name, varp->begin, prev_off);
else
printf("Variable \"%s\" begin offset (%lld) is less than previous variable \"%s\" end offset (%lld)\n",
printf("Variable \"%s\" begin offset ("OFFFMT") is less than previous variable \"%s\" end offset ("OFFFMT")\n",
varp->name, varp->begin, ncp->vars.value[prev]->name, prev_off);
}
DEBUG_RETURN_ERROR(NC_ENOTNC)
Expand Down Expand Up @@ -1312,9 +1312,9 @@ ncmpio__enddef(void *ncdp,
/* reflect the hint changes to the MPI info object, so the user can inquire
* what the true hint values are being used
*/
sprintf(value, "%lld", ncp->v_align);
sprintf(value, OFFFMT, ncp->v_align);
MPI_Info_set(ncp->mpiinfo, "nc_var_align_size", value);
sprintf(value, "%lld", ncp->r_align);
sprintf(value, OFFFMT, ncp->r_align);
MPI_Info_set(ncp->mpiinfo, "nc_record_align_size", value);

#ifdef ENABLE_SUBFILING
Expand Down
6 changes: 3 additions & 3 deletions src/drivers/ncmpio/ncmpio_file_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ncmpio_read_write(NC *ncp,
}
else if (btype_size == MPI_UNDEFINED) {
#ifdef PNETCDF_DEBUG
fprintf(stderr,"%d: %s line %d: btype_size MPI_UNDEFINED buf_count=%lld\n",
fprintf(stderr,"%d: %s line %d: btype_size MPI_UNDEFINED buf_count="OFFFMT"\n",
ncp->rank, __func__,__LINE__,buf_count);
#endif
DEBUG_ASSIGN_ERROR(err, NC_EINTOVERFLOW)
Expand Down Expand Up @@ -99,7 +99,7 @@ ncmpio_read_write(NC *ncp,
if (buf_count > NC_MAX_INT) {
if (coll_indep == NC_REQ_COLL) {
#ifdef PNETCDF_DEBUG
fprintf(stderr,"%d: %s line %d: NC_EINTOVERFLOW buf_count=%lld\n",
fprintf(stderr,"%d: %s line %d: NC_EINTOVERFLOW buf_count="OFFFMT"\n",
ncp->rank, __func__,__LINE__,buf_count);
#endif
DEBUG_ASSIGN_ERROR(status, NC_EINTOVERFLOW)
Expand Down Expand Up @@ -221,7 +221,7 @@ ncmpio_read_write(NC *ncp,
if (buf_count > NC_MAX_INT) {
if (coll_indep == NC_REQ_COLL) {
#ifdef PNETCDF_DEBUG
fprintf(stderr,"%d: %s line %d: NC_EINTOVERFLOW buf_count=%lld\n",
fprintf(stderr,"%d: %s line %d: NC_EINTOVERFLOW buf_count="OFFFMT"\n",
ncp->rank, __func__,__LINE__,buf_count);
#endif
DEBUG_ASSIGN_ERROR(status, NC_EINTOVERFLOW)
Expand Down
6 changes: 3 additions & 3 deletions src/drivers/ncmpio/ncmpio_file_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ ncmpio_inq_misc(void *ncdp,
* user.
*/

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

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

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

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

#ifdef ENABLE_SUBFILING
Expand Down
8 changes: 4 additions & 4 deletions src/drivers/ncmpio/ncmpio_subfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ int ncmpio_subfile_partition(NC *ncp)
max = (MPI_Offset)yy-(yy-(MPI_Offset)yy==0.0?1:0);
if (max >= dim_sz0) max = dim_sz0-1;
#ifdef SUBFILE_DEBUG
if (myrank == 0) printf("subfile(%d): min=%lld, max=%lld\n", jj, min, max);
if (myrank == 0) printf("subfile(%d): min="OFFFMT", max="OFFFMT"\n", jj, min, max);
#endif
if (j == par_dim_id) { /* partitioning dims? */
sf_range[jj][j][0] = min;
Expand Down Expand Up @@ -621,12 +621,12 @@ ncmpio_subfile_getput_vars(NC *ncp,
jj++;
else {
#ifdef SUBFILE_DEBUG
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);
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);
#endif
if (kk == 0) {
my_req[aproc].start[jx] = ii;
#ifdef SUBFILE_DEBUG
printf("rank(%d): var(%s): my_req[%d].start[%d]=%lld\n",
printf("rank(%d): var(%s): my_req[%d].start[%d]="OFFFMT"\n",
myrank, varp->name, aproc, jx, ii);
#endif
}
Expand Down Expand Up @@ -817,7 +817,7 @@ ncmpio_subfile_getput_vars(NC *ncp,
/* making diff is necessary?? */
diff[i] = ABS(my_req[myrank].start_org[i]-start[i])/stride_count;
#ifdef SUBFILE_DEBUG
if (myrank == 0) printf("rank(%d): my_req[%d].start_org[%d]=%d, start[%d]=%d, diff[%d]=%lld\n", myrank,
if (myrank == 0) printf("rank(%d): my_req[%d].start_org[%d]=%d, start[%d]=%d, diff[%d]="OFFFMT"\n", myrank,
myrank, i, my_req[myrank].start_org[i], i, start[i], i, diff[i]);
#endif
}
Expand Down
8 changes: 4 additions & 4 deletions src/drivers/ncmpio/ncmpio_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void ncmpio_set_pnetcdf_hints(NC *ncp,
if (ncp->info_v_align == -1)
sprintf(value, "%d", FILE_ALIGNMENT_DEFAULT);
else
sprintf(value, "%lld", ncp->info_v_align);
sprintf(value, OFFFMT, ncp->info_v_align);
MPI_Info_set(info_used, "nc_var_align_size", value);

if (user_info != MPI_INFO_NULL) {
Expand All @@ -78,7 +78,7 @@ void ncmpio_set_pnetcdf_hints(NC *ncp,
*/
if (info_h_align >= 0 && ncp->info_v_align == -1) {
ncp->info_v_align = info_h_align;
sprintf(value, "%lld", ncp->info_v_align);
sprintf(value, OFFFMT, ncp->info_v_align);
MPI_Info_set(info_used, "nc_var_align_size", value);
}
}
Expand All @@ -98,7 +98,7 @@ void ncmpio_set_pnetcdf_hints(NC *ncp,
if (ncp->info_r_align == -1)
sprintf(value, "%d", FILE_ALIGNMENT_DEFAULT);
else
sprintf(value, "%lld", ncp->info_r_align);
sprintf(value, OFFFMT, ncp->info_r_align);
MPI_Info_set(info_used, "nc_record_align_size", value);

ncp->chunk = PNC_DEFAULT_CHUNKSIZE;
Expand Down Expand Up @@ -154,7 +154,7 @@ void ncmpio_set_pnetcdf_hints(NC *ncp,
if (errno == 0 && ibuf_size >= 0) ncp->ibuf_size = ibuf_size;
}
}
sprintf(value, "%lld", ncp->ibuf_size);
sprintf(value, OFFFMT, ncp->ibuf_size);
MPI_Info_set(info_used, "nc_ibuf_size", value);

#ifdef ENABLE_SUBFILING
Expand Down
Loading
Loading