Skip to content

Commit

Permalink
Merge pull request ESMCI#1239 from NCAR/dontuse_nc_max
Browse files Browse the repository at this point in the history
dont use NC_MAX values
  • Loading branch information
jedwards4b authored Dec 8, 2017
2 parents 63dee3d + 29aee05 commit fbc3584
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 40 deletions.
6 changes: 3 additions & 3 deletions ctest/runcdash-nwscla-intel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ module unload netcdf
module swap intel intel/17.0.1
module load cmake/3.7.2
module load netcdf-mpi/4.4.1.1
module load pnetcdf/1.8.0
module switch mpt mpt/2.15
module load pnetcdf/1.8.1
module switch mpt mpt/2.16
echo "MODULE LIST..."
module list

export CC=mpicc
export FC=mpif90

export MPI_TYPE_DEPTH=24
export PIO_DASHBOARD_ROOT=/glade/scratch/jedwards/dashboard
export PIO_COMPILER_ID=Intel-`$CC --version | head -n 1 | cut -d' ' -f3`

Expand Down
45 changes: 27 additions & 18 deletions src/clib/pio_getput_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,6 @@ int PIOc_get_var_tc(int ncid, int varid, nc_type xtype, void *buf)
PIO_Offset *startp = NULL; /* Pointer to start array. */
PIO_Offset *countp = NULL; /* Pointer to count array. */
int ndims; /* The number of dimensions in the variable. */
PIO_Offset my_start[PIO_MAX_DIMS];
PIO_Offset dimlen[PIO_MAX_DIMS];
int ierr; /* Return code from function calls. */

LOG((1, "PIOc_get_var_tc ncid = %d varid = %d xtype = %d", ncid, varid,
Expand All @@ -821,26 +819,33 @@ int PIOc_get_var_tc(int ncid, int varid, nc_type xtype, void *buf)
int dimids[ndims];
if ((ierr = PIOc_inq_vardimid(ncid, varid, dimids)))
return pio_err(ios, file, ierr, __FILE__, __LINE__);
if (!(startp = malloc(ndims * sizeof(PIO_Offset))))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);
if (!(countp = malloc(ndims * sizeof(PIO_Offset))))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);

/* Find the dimension lengths. */
for (int d = 0; d < ndims; d++)
if ((ierr = PIOc_inq_dimlen(ncid, dimids[d], &dimlen[d])))
if ((ierr = PIOc_inq_dimlen(ncid, dimids[d], &countp[d])))
return pio_err(ios, file, ierr, __FILE__, __LINE__);

/* Set up start array. */
for (int d = 0; d < ndims; d++)
{
my_start[d] = 0;
LOG((3, "my_start[%d] = %d dimlen[%d] = %d", d, my_start[d], d,
dimlen[d]));
startp[d] = 0;
LOG((3, "startp[%d] = %d countp[%d] = %d", d, startp[d], d,
countp[d]));
}

/* Set the start/count arrays. */
startp = my_start;
countp = dimlen;
}

return PIOc_get_vars_tc(ncid, varid, startp, countp, NULL, xtype, buf);
ierr = PIOc_get_vars_tc(ncid, varid, startp, countp, NULL, xtype, buf);
if(startp != NULL)
free(startp);
if(countp != NULL)
free(countp);
return ierr;

}

/**
Expand Down Expand Up @@ -1294,8 +1299,6 @@ int PIOc_put_var_tc(int ncid, int varid, nc_type xtype, const void *op)
file_desc_t *file; /* Pointer to file information. */
PIO_Offset *startp = NULL; /* Pointer to start array. */
PIO_Offset *countp = NULL; /* Pointer to count array. */
PIO_Offset start[PIO_MAX_DIMS];
PIO_Offset count[PIO_MAX_DIMS];
int ndims; /* The number of dimensions in the variable. */
int ierr; /* Return code from function calls. */

Expand All @@ -1316,24 +1319,30 @@ int PIOc_put_var_tc(int ncid, int varid, nc_type xtype, const void *op)
if (ndims)
{
int dimid[ndims];
if (!(startp = malloc(ndims * sizeof(PIO_Offset))))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);
if (!(countp = malloc(ndims * sizeof(PIO_Offset))))
return pio_err(ios, file, PIO_ENOMEM, __FILE__, __LINE__);

/* Set up start array. */
for (int d = 0; d < ndims; d++)
start[d] = 0;
startp[d] = 0;

/* Get the dimids for this var. */
if ((ierr = PIOc_inq_vardimid(ncid, varid, dimid)))
return check_netcdf(file, ierr, __FILE__, __LINE__);

/* Count array are the dimlens. */
for (int d = 0; d < ndims; d++)
if ((ierr = PIOc_inq_dimlen(ncid, dimid[d], &count[d])))
if ((ierr = PIOc_inq_dimlen(ncid, dimid[d], &countp[d])))
return pio_err(ios, file, ierr, __FILE__, __LINE__);

/* Set the array pointers. */
startp = start;
countp = count;
}

return PIOc_put_vars_tc(ncid, varid, startp, countp, NULL, xtype, op);
ierr = PIOc_put_vars_tc(ncid, varid, startp, countp, NULL, xtype, op);
if (startp != NULL)
free(startp);
if (countp != NULL)
free(countp);
return ierr;
}
33 changes: 19 additions & 14 deletions src/clib/pio_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ int create_file_handler(iosystem_desc_t *ios)

/* Call the create file function. */
PIOc_createfile(ios->iosysid, &ncid, &iotype, filename, mode);



LOG((1, "create_file_handler succeeded!"));
return PIO_NOERR;
}
Expand Down Expand Up @@ -276,7 +277,7 @@ int inq_handler(iosystem_desc_t *ios)

/* Call the inq function to get the values. */
PIOc_inq(ncid, ndimsp, nvarsp, ngattsp, unlimdimidp);

return PIO_NOERR;
}

Expand Down Expand Up @@ -1006,7 +1007,7 @@ int inq_var_handler(iosystem_desc_t *ios)
char name[NC_MAX_NAME + 1], *namep = NULL;
nc_type xtype, *xtypep = NULL;
int *ndimsp = NULL, *dimidsp = NULL, *nattsp = NULL;
int ndims, dimids[NC_MAX_DIMS], natts;
int ndims, natts;
int mpierr;

LOG((1, "inq_var_handler"));
Expand Down Expand Up @@ -1040,7 +1041,8 @@ int inq_var_handler(iosystem_desc_t *ios)
if (ndims_present)
ndimsp = &ndims;
if (dimids_present)
dimidsp = dimids;
if (!(dimidsp = malloc(ndims)))
return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__);
if (natts_present)
nattsp = &natts;

Expand All @@ -1064,9 +1066,10 @@ int inq_var_chunking_handler(iosystem_desc_t *ios)
{
int ncid;
int varid;
int ndims;
char storage_present, chunksizes_present;
int storage, *storagep = NULL;
PIO_Offset chunksizes[NC_MAX_DIMS], *chunksizesp = NULL;
PIO_Offset *chunksizesp = NULL;
int mpierr;

assert(ios);
Expand All @@ -1080,6 +1083,8 @@ int inq_var_chunking_handler(iosystem_desc_t *ios)
return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast(&storage_present, 1, MPI_CHAR, 0, ios->intercomm)))
return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast(&ndims, 1, MPI_INT, 0, ios->intercomm)))
return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast(&chunksizes_present, 1, MPI_CHAR, 0, ios->intercomm)))
return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__);
LOG((2,"inq_var_handler ncid = %d varid = %d storage_present = %d chunksizes_present = %d",
Expand All @@ -1089,7 +1094,8 @@ int inq_var_chunking_handler(iosystem_desc_t *ios)
if (storage_present)
storagep = &storage;
if (chunksizes_present)
chunksizesp = chunksizes;
if (!(chunksizesp = malloc(ndims)))
return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__);

/* Call the inq function to get the values. */
PIOc_inq_var_chunking(ncid, varid, storagep, chunksizesp);
Expand Down Expand Up @@ -1492,7 +1498,7 @@ int def_var_chunking_handler(iosystem_desc_t *ios)
int ndims;
int storage;
char chunksizes_present;
PIO_Offset chunksizes[NC_MAX_DIMS], *chunksizesp = NULL;
PIO_Offset *chunksizesp = NULL;
int mpierr;

assert(ios);
Expand All @@ -1510,16 +1516,15 @@ int def_var_chunking_handler(iosystem_desc_t *ios)
return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast(&chunksizes_present, 1, MPI_CHAR, 0, ios->intercomm)))
return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__);
if (chunksizes_present)
if ((mpierr = MPI_Bcast(chunksizes, ndims, MPI_OFFSET, 0, ios->intercomm)))
if (chunksizes_present){
if (!(chunksizesp = malloc(ndims)))
return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__);
if ((mpierr = MPI_Bcast(chunksizesp, ndims, MPI_OFFSET, 0, ios->intercomm)))
return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__);
}
LOG((1, "def_var_chunking_handler got parameters ncid = %d varid = %d storage = %d "
"ndims = %d chunksizes_present = %d", ncid, varid, storage, ndims, chunksizes_present));

/* Set the non-NULL pointers. */
if (chunksizes_present)
chunksizesp = chunksizes;

/* Call the function. */
PIOc_def_var_chunking(ncid, varid, storage, chunksizesp);

Expand Down Expand Up @@ -2703,7 +2708,7 @@ int pio_msg_handler2(int io_rank, int component_count, iosystem_desc_t **iosys,
/* If an error was returned by the handler, exit. */
LOG((3, "pio_msg_handler2 ret %d msg %d index %d io_rank %d", ret, msg, index, io_rank));
if (ret)
return pio_err(my_iosys, NULL, ret, __FILE__, __LINE__);
return pio_err(my_iosys, NULL, ret, __FILE__, __LINE__);

/* Listen for another msg from the component whose message we
* just handled. */
Expand Down
2 changes: 2 additions & 0 deletions src/clib/pio_nc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ int PIOc_inq_var_chunking(int ncid, int varid, int *storagep, PIO_Offset *chunks
mpierr = MPI_Bcast(&varid, 1, MPI_INT, ios->compmaster, ios->intercomm);
if (!mpierr)
mpierr = MPI_Bcast(&storage_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm);
if (!mpierr)
mpierr = MPI_Bcast(&ndims, 1, MPI_INT, ios->compmaster, ios->intercomm);
if (!mpierr)
mpierr = MPI_Bcast(&chunksizes_present, 1, MPI_CHAR, ios->compmaster, ios->intercomm);
LOG((2, "PIOc_inq_var_chunking ncid = %d varid = %d storage_present = %d chunksizes_present = %d",
Expand Down
10 changes: 5 additions & 5 deletions src/flib/pio_types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ module pio_types
integer, public, parameter :: PIO_NOCLOBBER = nf_NOclobber
integer, public, parameter :: PIO_NOFILL = nf_nofill
integer, public, parameter :: PIO_MAX_NAME = nf_max_name
integer, public, parameter :: PIO_MAX_VAR_DIMS = nf_max_var_dims
integer, public, parameter :: PIO_MAX_VAR_DIMS = min(6,nf_max_var_dims)
integer, public, parameter :: PIO_64BIT_OFFSET = nf_64bit_offset
integer, public, parameter :: PIO_64BIT_DATA = nf_64bit_data
integer, public, parameter :: PIO_FILL_INT = nf_fill_int;
Expand All @@ -209,7 +209,7 @@ module pio_types
integer, public, parameter :: PIO_NOCLOBBER = nf_NOclobber
integer, public, parameter :: PIO_NOFILL = nf_nofill
integer, public, parameter :: PIO_MAX_NAME = nf_max_name
integer, public, parameter :: PIO_MAX_VAR_DIMS = nf_max_var_dims
integer, public, parameter :: PIO_MAX_VAR_DIMS = min(6,nf_max_var_dims)
integer, public, parameter :: PIO_64BIT_OFFSET = nf_64bit_offset
integer, public, parameter :: PIO_64BIT_DATA = 0
integer, public, parameter :: PIO_FILL_INT = nf_fill_int;
Expand Down Expand Up @@ -239,7 +239,7 @@ module pio_types

!>
!! @defgroup PIO_rearr_comm_t PIO_rearr_comm_t
!! @public
!! @public
!! @brief The two choices for rearranger communication
!! @details
!! - PIO_rearr_comm_p2p : Point to point
Expand All @@ -252,7 +252,7 @@ module pio_types

!>
!! @defgroup PIO_rearr_comm_dir PIO_rearr_comm_dir
!! @public
!! @public
!! @brief The four choices for rearranger communication direction
!! @details
!! - PIO_rearr_comm_fc_2d_enable : COMM procs to IO procs and vice versa
Expand All @@ -271,7 +271,7 @@ module pio_types
!! @defgroup PIO_rearr_comm_fc_options PIO_rearr_comm_fc_options
!! @brief Type that defines the PIO rearranger options
!! @details
!! - enable_hs : Enable handshake (true/false)
!! - enable_hs : Enable handshake (true/false)
!! - enable_isend : Enable Isends (true/false)
!! - max_pend_req : Maximum pending requests (To indicated unlimited
!! number of requests use PIO_REARR_COMM_UNLIMITED_PEND_REQ)
Expand Down

0 comments on commit fbc3584

Please sign in to comment.