diff --git a/src/clib/CMakeLists.txt b/src/clib/CMakeLists.txt index 53ef0daa37e..baf4dcd3c75 100644 --- a/src/clib/CMakeLists.txt +++ b/src/clib/CMakeLists.txt @@ -8,12 +8,12 @@ project (PIOC C) add_library (pioc topology.c pio_file.c pioc_support.c pio_lists.c pioc.c pioc_sc.c pio_spmd.c pio_rearrange.c pio_nc4.c bget.c - pio_nc.c pio_put_nc.c pio_get_nc.c pio_getput_int.c pio_msg.c + pio_nc.c pio_put_nc.c pio_get_nc.c pio_getput_int.c pio_msg.c pio_darray.c pio_darray_int.c) # set up include-directories include_directories( - "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}" "${PROJECT_SOURCE_DIR}" # to find foo/foo.h "${PROJECT_BINARY_DIR}") # to find foo/config.h @@ -36,7 +36,7 @@ elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "PGI") PRIVATE -c99) elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") target_compile_options (pioc - PRIVATE -std=c99) + PRIVATE -std=c99 -debug minimal) elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") target_compile_options (pioc PRIVATE -std=c99) diff --git a/src/clib/pio_darray_int.c b/src/clib/pio_darray_int.c index 4387db172f0..3467c70fc3e 100644 --- a/src/clib/pio_darray_int.c +++ b/src/clib/pio_darray_int.c @@ -13,6 +13,12 @@ #include #include +#if USE_VARD +#define USE_VARD_READ 1 +#define USE_VARD_WRITE 1 +#endif + + /* 10MB default limit. */ extern PIO_Offset pio_buffer_size_limit; @@ -66,6 +72,142 @@ int compute_buffer_init(iosystem_desc_t *ios) return PIO_NOERR; } +#if USE_VARD +int get_gdim0(file_desc_t *file,io_desc_t *iodesc, int varid, int fndims, MPI_Offset *gdim0) +{ + int ierr=PIO_NOERR; + *gdim0 = 0; + if(file->iotype == PIO_IOTYPE_PNETCDF && iodesc->ndims < fndims) + { + int numunlimdims; + /* We need to confirm the file has an unlimited dimension and if it doesn't we need to find + the extent of the first variable dimension */ + LOG((3,"look for numunlimdims")); + if ((ierr = PIOc_inq_unlimdims(file->pio_ncid, &numunlimdims, NULL))) + return check_netcdf(file, ierr, __FILE__, __LINE__); + LOG((3,"numunlimdims = %d", numunlimdims)); + if (numunlimdims <= 0) + { + int dimids[fndims]; + if ((ierr = PIOc_inq_vardimid(file->pio_ncid, varid, dimids))) + return check_netcdf(file, ierr, __FILE__, __LINE__); + if ((ierr = PIOc_inq_dimlen(file->pio_ncid, dimids[0], gdim0))) + return check_netcdf(file, ierr, __FILE__, __LINE__); + } + } + LOG((3,"gdim0 = %d",*gdim0)); + return ierr; +} + +int get_vard_mpidatatype(io_desc_t *iodesc, MPI_Offset gdim0, PIO_Offset unlimdimoffset, + int rrcnt, int ndims, int fndims, + int frame, PIO_Offset **startlist, PIO_Offset **countlist, + MPI_Datatype *filetype) +{ + + int sa_ndims; + int gdims[fndims]; + int dim_offset; + int mpierr; + MPI_Aint displacements[rrcnt]; + int blocklengths[rrcnt]; + MPI_Datatype subarray[rrcnt]; + + if(rrcnt == 0) + return PIO_NOERR; + + for ( int rc=0; rc ndims) + { + if ( gdim0 > 0) + { + gdims[0] = gdim0; + sa_ndims = fndims; + dim_offset = 0; + for (int i=1; i < fndims; i++) + gdims[i] = iodesc->dimlen[i-1]; + } + else + { + sa_ndims = ndims; + dim_offset = 1; + for (int i=0; i < ndims; i++) + gdims[i] = iodesc->dimlen[i]; + } + } + else + { + sa_ndims = fndims; + dim_offset = 0; + for (int i=0; i < fndims; i++) + gdims[i] = iodesc->dimlen[i]; + } + + for( int rc=0; rc 0) + { + unlimdimoffset = gdim0; + sastart[0] = max(0, frame); + displacements[rc]=0; + } + else + displacements[rc] = unlimdimoffset * max(0, frame); + +#if PIO_ENABLE_LOGGING + for (int i=0; i< sa_ndims; i++) + LOG((3, "vard: sastart[%d]=%d sacount[%d]=%d gdims[%d]=%d %ld %ld displacement = %ld un %d", + i,sastart[i], i,sacount[i], i, gdims[i], startlist[rc][i], countlist[rc][i], displacements[rc], unlimdimoffset)); +#endif + if((mpierr = MPI_Type_create_subarray(sa_ndims, gdims, + sacount, sastart,MPI_ORDER_C + ,iodesc->mpitype, subarray + rc))) + return check_mpi(NULL, mpierr, __FILE__, __LINE__); + + if((mpierr = MPI_Type_commit(subarray + rc))) + return check_mpi(NULL, mpierr, __FILE__, __LINE__); + +#if PIO_ENABLE_LOGGING + LOG((3,"vard: blocklengths[%d]=%d displacement[%d]=%ld unlimdimoffset=%ld",rc,blocklengths[rc], rc, displacements[rc], unlimdimoffset)); +#endif + + + } + + if((mpierr = MPI_Type_create_struct(rrcnt, blocklengths, displacements, subarray, filetype))) + return check_mpi(NULL, mpierr, __FILE__, __LINE__); + + if((mpierr = MPI_Type_commit(filetype))) + return check_mpi(NULL, mpierr, __FILE__, __LINE__); + + for( int rc=0; rciosystem && varids && varids[0] >= 0 && varids[0] <= PIO_MAX_VARS && @@ -195,27 +339,13 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * PIO_Offset llen = fill ? iodesc->holegridsize : iodesc->llen; void *iobuf = fill ? vdesc->fillbuf : file->iobuf; -#if USE_VARD - if(file->iotype == PIO_IOTYPE_PNETCDF && iodesc->ndims < fndims) +#if USE_VARD_WRITE + if (!ios->async || !ios->ioproc) { - int numunlimdims; - gdim0 = 0; - /* We need to confirm the file has an unlimited dimension and if it doesn't we need to find - the extent of the first variable dimension */ - LOG((3,"look for numunlimdims")); - if ((ierr = PIOc_inq_unlimdims(file->pio_ncid, &numunlimdims, NULL))) - return check_netcdf(file, ierr, __FILE__, __LINE__); - LOG((3,"numunlimdims = %d", numunlimdims)); - if (numunlimdims <= 0) - { - int dimids[fndims]; - if ((ierr = PIOc_inq_vardimid(file->pio_ncid, varids[0], dimids))) - return check_netcdf(file, ierr, __FILE__, __LINE__); - if ((ierr = PIOc_inq_dimlen(file->pio_ncid, dimids[0], &gdim0))) - return check_netcdf(file, ierr, __FILE__, __LINE__); - } + if ((ierr = get_gdim0(file, iodesc, varids[0], fndims, &gdim0))) + return pio_err(NULL, file, ierr, __FILE__, __LINE__); + } - LOG((3,"gdim0 = %d",gdim0)); #endif /* If this is an IO task write the data. */ @@ -228,20 +358,6 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * int ndims = iodesc->ndims; PIO_Offset *startlist[num_regions]; /* Array of start arrays for ncmpi_iput_varn(). */ PIO_Offset *countlist[num_regions]; /* Array of count arrays for ncmpi_iput_varn(). */ -#if USE_VARD - PIO_Offset unlimdimoffset; - int mpierr; - MPI_Datatype filetype; - MPI_Datatype subarray[num_regions]; - filetype = MPI_DATATYPE_NULL; - - if (gdim0 == 0) /* if there is an unlimited dimension get the offset between records of a variable */ - { - if((ierr = ncmpi_inq_recsize(file->fh, &unlimdimoffset))) - return pio_err(NULL, file, ierr, __FILE__, __LINE__); - } -#endif - LOG((3, "num_regions = %d", num_regions)); /* Process each region of data to be written. */ for (int regioncnt = 0; regioncnt < num_regions; regioncnt++) @@ -310,114 +426,45 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * /* Do this when we reach the last region. */ if (regioncnt == num_regions - 1) { +#ifdef USE_VARD_WRITE + MPI_Datatype filetype = MPI_DATATYPE_NULL; +#endif + int fvartype; /* For each variable to be written. */ for (int nv = 0; nv < nvars; nv++) { + /* Get the var info. */ if ((ierr = get_var_desc(varids[nv], &file->varlist, &vdesc))) return pio_err(NULL, file, ierr, __FILE__, __LINE__); -#if USE_VARD +#if USE_VARD_WRITE + /* vard does not support type conversion fail over to varn if var is not the same type as defined in file */ + if ((ierr = ncmpi_inq_vartype(file->fh, varids[nv], &fvartype))) + return pio_err(NULL, file, ierr, __FILE__, __LINE__); + if (fvartype != vdesc->pio_type){ + LOG((0, "ERROR: pnetcdf vard does not support type conversion varid %d filetype %d piotype %d" + ,varids[nv],fvartype, vdesc->pio_type)); + } + /* If this is the first variable or the frame has changed between variables (this should be rare) */ if(nv==0 || (nv > 0 && frame != NULL && frame[nv] != frame[nv-1])){ - int sa_ndims; - int sacount[fndims]; - int sastart[fndims]; - int gdims[fndims]; - int dim_offset; - int mpierr; - MPI_Aint displacements[rrcnt]; - int blocklengths[rrcnt]; - - if(gdim0) - sacount[0] = 1; - - for ( int rc=0; rc ndims) - { - if ( gdim0 > 0) - { - gdims[0] = gdim0; - sa_ndims = fndims; - dim_offset = 0; - for (int i=1; i < fndims; i++) - gdims[i] = iodesc->dimlen[i-1]; - } - else - { - sa_ndims = ndims; - dim_offset = 1; - for (int i=0; i < ndims; i++) - gdims[i] = iodesc->dimlen[i]; - } - } + if((ierr = ncmpi_inq_recsize(file->fh, &unlimdimoffset))) + return pio_err(NULL, file, ierr, __FILE__, __LINE__); + LOG((3, "num_regions = %d unlimdimoffset %ld", num_regions, unlimdimoffset)); + }else + unlimdimoffset = gdim0; + if (frame) + thisframe = frame[nv]; else - { - sa_ndims = fndims; - dim_offset = 0; - for (int i=0; i < fndims; i++) - gdims[i] = iodesc->dimlen[i]; - } - - for( int rc=0; rc 0) - { - if(frame != NULL) - { - sastart[0] = frame[nv]; - displacements[rc]=0; - } - } - else - if (frame != NULL) - displacements[rc] = unlimdimoffset * frame[nv]; - else - displacements[rc] = 0; - - for (int i=0; i< sa_ndims; i++) - LOG((3, "vard: sastart[%d]=%d sacount[%d]=%d gdims[%d]=%d %ld %ld", - i,sastart[i], i,sacount[i], i, gdims[i], startlist[rc][i], countlist[rc][i])); - - if((mpierr = MPI_Type_create_subarray(sa_ndims, gdims, - sacount, sastart,MPI_ORDER_C - ,iodesc->mpitype, subarray + rc))) - return check_mpi(NULL, mpierr, __FILE__, __LINE__); - - if((mpierr = MPI_Type_commit(subarray + rc))) - return check_mpi(NULL, mpierr, __FILE__, __LINE__); - - - LOG((3,"vard: blocklengths[%d]=%d displacement[%d]=%ld unlimdimoffset=%ld",rc,blocklengths[rc], rc, displacements[rc], unlimdimoffset)); - - - - } - - if((mpierr = MPI_Type_create_struct(rrcnt, blocklengths, displacements, subarray, &filetype))) - return check_mpi(NULL, mpierr, __FILE__, __LINE__); - - if((mpierr = MPI_Type_commit(&filetype))) - return check_mpi(NULL, mpierr, __FILE__, __LINE__); - + thisframe = 0; + ierr = get_vard_mpidatatype(iodesc, gdim0, unlimdimoffset, + rrcnt, ndims, fndims, + thisframe, startlist, countlist, &filetype); } #else if (vdesc->record >= 0 && ndims < fndims) @@ -427,6 +474,17 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * /* Get a pointer to the data. */ bufptr = (void *)((char *)iobuf + nv * iodesc->mpitype_size * llen); +#if USE_VARD_WRITE + LOG((3, "vard: call ncmpi_put_vard llen = %d %d", llen, iodesc->mpitype_size )); + ierr = ncmpi_put_vard_all(file->fh, varids[nv], filetype, bufptr, llen, iodesc->mpitype); + LOG((3, "vard: return ncmpi_put_vard ierr = %d", ierr)); + if(nv==nvars-1 && filetype != MPI_DATATYPE_NULL) + { + int mpierr; + if((mpierr = MPI_Type_free(&filetype))) + return check_mpi(NULL, mpierr, __FILE__, __LINE__); + } +#else if (vdesc->nreqs % PIO_REQUEST_ALLOC_CHUNK == 0) { if (!(vdesc->request = realloc(vdesc->request, sizeof(int) * @@ -437,11 +495,6 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * vdesc->request[i] = NC_REQ_NULL; } -#if USE_VARD - LOG((3, "vard: call ncmpi_put_vard llen = %d %d ", llen, iodesc->mpitype_size )); - ierr = ncmpi_put_vard_all(file->fh, varids[nv], filetype, bufptr, llen, iodesc->mpitype); - LOG((3, "vard: return ncmpi_put_vard ierr = %d", ierr)); -#else /* Write, in non-blocking fashion, a list of subarrays. */ LOG((3, "about to call ncmpi_iput_varn() varids[%d] = %d rrcnt = %d, llen = %d", nv, varids[nv], rrcnt, llen)); @@ -473,18 +526,6 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int * if (region) region = region->next; } /* next regioncnt */ -#if USE_VARD - if(filetype != MPI_DATATYPE_NULL) - { - int mpierr; - for(int i=0; iioproc) */ /* Check the return code from the netCDF/pnetcdf call. */ @@ -920,6 +961,10 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobu int ndims; /* Number of dims in decomposition. */ int fndims; /* Number of dims for this var in file. */ int ierr; /* Return code from netCDF functions. */ +#ifdef USE_VARD_READ + MPI_Offset gdim0; + gdim0 = 0; +#endif /* Check inputs. */ pioassert(file && file->iosystem && iodesc && vid <= PIO_MAX_VARS, "invalid input", @@ -943,8 +988,12 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobu /* Get the number of dims for this var in the file. */ if ((ierr = PIOc_inq_varndims(file->pio_ncid, vid, &fndims))) return pio_err(ios, file, ierr, __FILE__, __LINE__); +#if USE_VARD_READ + if(!ios->async || !ios->ioproc) + ierr = get_gdim0(file, iodesc, vid, fndims, &gdim0); +#endif - /* IO procs will actially read the data. */ + /* IO procs will read the data. */ if (ios->ioproc) { io_region *region; @@ -965,8 +1014,6 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobu * and the file. */ if (fndims > ndims) { - ndims++; - /* If the user did not call setframe, use a default frame * of 0. This is required for backward compatibility. */ if (vdesc->record < 0) @@ -1004,7 +1051,7 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobu /* This is a record var. The unlimited dimension * (0) is handled specially. */ start[0] = vdesc->record; - for (int i = 1; i < ndims; i++) + for (int i = 1; i < fndims; i++) { start[i] = region->start[i-1]; count[i] = region->count[i-1]; @@ -1017,7 +1064,7 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobu else { /* Non-time dependent array */ - for (int i = 0; i < ndims; i++) + for (int i = 0; i < fndims; i++) { start[i] = region->start[i]; count[i] = region->count[i]; @@ -1102,10 +1149,32 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobu /* Is this is the last region to process? */ if (regioncnt == iodesc->maxregions - 1) { +#if USE_VARD_READ + MPI_Datatype filetype; + PIO_Offset unlimdimoffset; + int mpierr; + if (gdim0 == 0) /* if there is an unlimited dimension get the offset between records of a variable */ + { + if((ierr = ncmpi_inq_recsize(file->fh, &unlimdimoffset))) + return pio_err(NULL, file, ierr, __FILE__, __LINE__); + } + else + unlimdimoffset = gdim0; + + filetype = MPI_DATATYPE_NULL; + + ierr = get_vard_mpidatatype(iodesc, gdim0, unlimdimoffset, + rrlen, ndims, fndims, + vdesc->record, startlist, countlist, &filetype); + ierr = ncmpi_get_vard_all(file->fh, vid, filetype, iobuf, iodesc->llen, iodesc->mpitype); + if(filetype != MPI_DATATYPE_NULL && (mpierr = MPI_Type_free(&filetype))) + return check_mpi(NULL, mpierr, __FILE__, __LINE__); + +#else /* Read a list of subarrays. */ ierr = ncmpi_get_varn_all(file->fh, vid, rrlen, startlist, countlist, iobuf, iodesc->llen, iodesc->mpitype); - +#endif /* Release the start and count arrays. */ for (int i = 0; i < rrlen; i++) { @@ -1465,7 +1534,7 @@ int flush_output_buffer(file_desc_t *file, bool force, PIO_Offset addsize) /* Check inputs. */ pioassert(file, "invalid input", __FILE__, __LINE__); - + LOG((1, "flush_output_buffer")); /* Find out the buffer usage. */ if ((ierr = ncmpi_inq_buffer_usage(file->fh, &usage))) /* allow the buffer to be undefined */ @@ -1486,9 +1555,10 @@ int flush_output_buffer(file_desc_t *file, bool force, PIO_Offset addsize) if (usage > maxusage) maxusage = usage; + LOG((2, "flush_output_buffer usage=%ld force=%d",usage, force)); /* If the user forces it, or the buffer has exceeded the size * limit, then flush to disk. */ - if (force || usage >= pio_buffer_size_limit) + if (force || (usage >= pio_buffer_size_limit)) { int rcnt; int maxreq; @@ -1655,7 +1725,6 @@ int flush_buffer(int ncid, wmulti_buffer *wmb, bool flushtodisk) /* Check input. */ pioassert(wmb, "invalid input", __FILE__, __LINE__); - /* Get the file info (to get error handler). */ if ((ret = pio_get_file(ncid, &file))) return pio_err(NULL, NULL, ret, __FILE__, __LINE__); diff --git a/src/clib/pio_file.c b/src/clib/pio_file.c index 104dd6aa999..ba94ac223e2 100644 --- a/src/clib/pio_file.c +++ b/src/clib/pio_file.c @@ -205,7 +205,6 @@ int PIOc_closefile(int ncid) int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ LOG((1, "PIOc_closefile ncid = %d", ncid)); - /* Find the info about this file. */ if ((ierr = pio_get_file(ncid, &file))) return pio_err(NULL, NULL, ierr, __FILE__, __LINE__); diff --git a/src/clib/pio_lists.c b/src/clib/pio_lists.c index c4edb5d5042..4f5af7858ac 100644 --- a/src/clib/pio_lists.c +++ b/src/clib/pio_lists.c @@ -388,7 +388,7 @@ int get_var_desc(int varid, var_desc_t **varlist, var_desc_t **var_desc) var_desc_t *my_var; /* Check inputs. */ - pioassert(varlist, "invalid input", __FILE__, __LINE__); + pioassert(varlist, "invalid input", __FILE__, __LINE__); /* Empty varlist. */ if (!*varlist) diff --git a/src/clib/pioc.c b/src/clib/pioc.c index 1f83c597e02..f375621408e 100644 --- a/src/clib/pioc.c +++ b/src/clib/pioc.c @@ -121,7 +121,7 @@ int PIOc_advanceframe(int ncid, int varid) int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */ int ret; - LOG((1, "PIOc_advanceframe ncid = %d varid = %d")); + LOG((1, "PIOc_advanceframe ncid = %d varid = %d", ncid, varid)); /* Get the file info. */ if ((ret = pio_get_file(ncid, &file))) @@ -877,7 +877,7 @@ int PIOc_Init_Intracomm(MPI_Comm comp_comm, int num_iotasks, int stride, int bas /* Create a group for the IO tasks. */ if ((mpierr = MPI_Group_incl(compgroup, ios->num_iotasks, ios->ioranks, &iogroup))) - return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); + return check_mpi2(ios, NULL, mpierr, __FILE__, __LINE__); /* Create an MPI communicator for the IO tasks. */ if ((mpierr = MPI_Comm_create(ios->comp_comm, iogroup, &ios->io_comm))) @@ -1287,7 +1287,7 @@ int PIOc_init_async(MPI_Comm world, int num_io_procs, int *io_proc_list, /* Determine which tasks to use for each computational component. */ if ((ret = determine_procs(num_io_procs, component_count, num_procs_per_comp, proc_list, my_proc_list))) - return pio_err(NULL, NULL, ret, __FILE__, __LINE__); + return pio_err(NULL, NULL, ret, __FILE__, __LINE__); /* Get rank of this task in world. */ if ((ret = MPI_Comm_rank(world, &my_rank))) @@ -1519,7 +1519,7 @@ int PIOc_init_async(MPI_Comm world, int num_io_procs, int *io_proc_list, if ((ret = MPI_Comm_rank(my_iosys->union_comm, &my_iosys->union_rank))) return check_mpi(NULL, ret, __FILE__, __LINE__); LOG((3, "my_iosys->union_rank %d", my_iosys->union_rank)); - + /* Set my_comm to union_comm for async. */ my_iosys->my_comm = my_iosys->union_comm; LOG((3, "intracomm created for union cmp = %d union_rank = %d union_comm = %d", diff --git a/src/clib/pioc_support.c b/src/clib/pioc_support.c index e47c36dcf7e..0c36b2b5523 100644 --- a/src/clib/pioc_support.c +++ b/src/clib/pioc_support.c @@ -213,6 +213,7 @@ void pio_log(int severity, const char *fmt, ...) ptr += strlen(ERROR_PREFIX); rem_len -= strlen(ERROR_PREFIX); } + for (t = 0; t < severity; t++) { strncpy(ptr++, "\t", (rem_len > 0) ? rem_len : 0); @@ -225,11 +226,18 @@ void pio_log(int severity, const char *fmt, ...) ptr += strlen(rank_str); rem_len -= strlen(rank_str); + /* Show the severity. */ + snprintf(rank_str, MAX_RANK_STR, ":%d ", severity); + strncpy(ptr, rank_str, (rem_len > 0) ? rem_len : 0); + ptr += strlen(rank_str); + rem_len -= strlen(rank_str); + /* Print out the variable list of args with vprintf. */ va_start(argp, fmt); vsnprintf(ptr, ((rem_len > 0) ? rem_len : 0), fmt, argp); va_end(argp); + /* Put on a final linefeed. */ ptr = msg + strlen(msg); rem_len = MAX_LOG_MSG - strlen(msg); diff --git a/src/flib/CMakeLists.txt b/src/flib/CMakeLists.txt index 8d510961d4f..49bc3e67b7a 100644 --- a/src/flib/CMakeLists.txt +++ b/src/flib/CMakeLists.txt @@ -52,11 +52,16 @@ if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU") target_compile_options (piof PRIVATE -ffree-line-length-none) elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") - set ( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mismatch_all" ) + set ( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mismatch_all " ) # target_compile_options (piof # PRIVATE -mismatch_all) elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ef") +elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -debug minimal") +endif() +if (CMAKE_BUILD_TYPE STREQUAL "DEBUG") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g") endif() # Look for c_sizeof capability diff --git a/tests/cunit/test_async_multicomp.c b/tests/cunit/test_async_multicomp.c index 9822106fdd8..9fecc7c839a 100644 --- a/tests/cunit/test_async_multicomp.c +++ b/tests/cunit/test_async_multicomp.c @@ -55,9 +55,9 @@ int main(int argc, char **argv) -1, &test_comm))) ERR(ERR_INIT); - /* Is the current process a computation task? */ + /* Is the current process a computation task? */ int comp_task = my_rank < NUM_IO_PROCS ? 0 : 1; - + /* Only do something on TARGET_NTASKS tasks. */ if (my_rank < TARGET_NTASKS) { @@ -90,7 +90,7 @@ int main(int argc, char **argv) int my_comp_idx = my_rank - 1; /* Index in iosysid array. */ int dim_len_2d[NDIM2] = {DIM_LEN2, DIM_LEN3}; int ioid = 0; - + if ((ret = create_decomposition_2d(NUM_COMP_PROCS, my_rank, iosysid[my_comp_idx], dim_len_2d, &ioid, PIO_SHORT))) ERR(ret); @@ -103,7 +103,7 @@ int main(int argc, char **argv) if ((ret = create_nc_sample_3(iosysid[my_comp_idx], iotype[i], my_rank, my_comp_idx, filename, TEST_NAME, verbose, use_darray, ioid))) ERR(ret); - + /* Check the file for correctness. */ if ((ret = check_nc_sample_3(iosysid[my_comp_idx], iotype[i], my_rank, my_comp_idx, filename, verbose, 0, ioid))) diff --git a/tests/cunit/test_darray_async.c b/tests/cunit/test_darray_async.c index 9d493fc51eb..199ccad6e91 100644 --- a/tests/cunit/test_darray_async.c +++ b/tests/cunit/test_darray_async.c @@ -104,19 +104,19 @@ int check_darray_file(int iosysid, char *data_filename, int iotype, int my_rank, switch (piotype) { case PIO_BYTE: - if (((signed char *)data_in)[r] != (tmp_r/2 + 1) * 10.0 + tmp_r % 2) + if (((signed char *)data_in)[r] != (tmp_r/2 + 1) * 10 + tmp_r % 2) ERR(ret); break; case PIO_CHAR: - if (((char *)data_in)[r] != (tmp_r/2 + 1) * 10.0 + tmp_r % 2) + if (((char *)data_in)[r] != (tmp_r/2 + 1) * 10 + tmp_r % 2) ERR(ret); break; case PIO_SHORT: - if (((short *)data_in)[r] != (tmp_r/2 + 1) * 10.0 + tmp_r % 2) + if (((short *)data_in)[r] != (tmp_r/2 + 1) * 10 + tmp_r % 2) ERR(ret); break; case PIO_INT: - if (((int *)data_in)[r] != (tmp_r/2 + 1) * 10.0 + tmp_r % 2) + if (((int *)data_in)[r] != (tmp_r/2 + 1) * 10 + tmp_r % 2) ERR(ret); break; case PIO_FLOAT: @@ -129,23 +129,23 @@ int check_darray_file(int iosysid, char *data_filename, int iotype, int my_rank, break; #ifdef _NETCDF4 case PIO_UBYTE: - if (((unsigned char *)data_in)[r] != (tmp_r/2 + 1) * 10.0 + tmp_r % 2) + if (((unsigned char *)data_in)[r] != (tmp_r/2 + 1) * 10 + tmp_r % 2) ERR(ret); break; case PIO_USHORT: - if (((unsigned short *)data_in)[r] != (tmp_r/2 + 1) * 10.0 + tmp_r % 2) + if (((unsigned short *)data_in)[r] != (tmp_r/2 + 1) * 10 + tmp_r % 2) ERR(ret); break; case PIO_UINT: - if (((unsigned int *)data_in)[r] != (tmp_r/2 + 1) * 10.0 + tmp_r % 2) + if (((unsigned int *)data_in)[r] != (tmp_r/2 + 1) * 10 + tmp_r % 2) ERR(ret); break; case PIO_INT64: - if (((long long *)data_in)[r] != (tmp_r/2 + 1) * 10.0 + tmp_r % 2) + if (((long long *)data_in)[r] != (tmp_r/2 + 1) * 10 + tmp_r % 2) ERR(ret); break; case PIO_UINT64: - if (((unsigned long long *)data_in)[r] != (tmp_r/2 + 1) * 10.0 + tmp_r % 2) + if (((unsigned long long *)data_in)[r] != (tmp_r/2 + 1) * 10 + tmp_r % 2) ERR(ret); break; #endif /* _NETCDF4 */ diff --git a/tests/general/CMakeLists.txt b/tests/general/CMakeLists.txt index 09358d5b9fd..4f54c783178 100644 --- a/tests/general/CMakeLists.txt +++ b/tests/general/CMakeLists.txt @@ -45,6 +45,10 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") # PRIVATE -mismatch_all) endif () +if (CMAKE_BUILD_TYPE STREQUAL "DEBUG") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g") +endif() + #============================================================================== # DEFINE THE TARGETS AND TESTS #============================================================================== diff --git a/tests/general/ncdf_simple_tests.F90.in b/tests/general/ncdf_simple_tests.F90.in index b1d8133194a..2af0e21c651 100644 --- a/tests/general/ncdf_simple_tests.F90.in +++ b/tests/general/ncdf_simple_tests.F90.in @@ -115,6 +115,7 @@ PIO_TF_AUTO_TEST_SUB_BEGIN test_data_conversion integer :: pio_dim integer :: i, ierr + do i=1,VEC_LOCAL_SZ compdof_rel_disps(i) = i end do @@ -147,11 +148,14 @@ PIO_TF_AUTO_TEST_SUB_BEGIN test_data_conversion call PIO_syncfile(pio_file) - ! Read the variable back (data conversion might occur) - call PIO_read_darray(pio_file, pio_var, riodesc, rbuf, ierr) - PIO_TF_CHECK_ERR(ierr, "Failed to read darray : " // trim(data_fname)) - - PIO_TF_CHECK_VAL((rbuf, exp_val), "Got wrong val") + if (tgv_iotype .eq. PIO_iotype_pnetcdf) then + PIO_TF_LOG(0,*) "WARNING: Data type conversion not supported in pnetcdf vard interface, skipping test" + else + ! Read the variable back (data conversion might occur) + call PIO_read_darray(pio_file, pio_var, riodesc, rbuf, ierr) + PIO_TF_CHECK_ERR(ierr, "Failed to read darray : " // trim(data_fname)) + PIO_TF_CHECK_VAL((rbuf, exp_val), "Got wrong val") + endif call PIO_closefile(pio_file) call PIO_deletefile(pio_tf_iosystem_, data_fname); diff --git a/tests/general/util/pio_tf_f90gen.pl b/tests/general/util/pio_tf_f90gen.pl index f880cda1beb..7cf2672cda5 100755 --- a/tests/general/util/pio_tf_f90gen.pl +++ b/tests/general/util/pio_tf_f90gen.pl @@ -563,7 +563,11 @@ sub parse_and_store_gen_templ_funcs $ifline_num, \$is_transformed); } if($annotate_source){ - $out_line = $out_line . " ! $base_file_name:$ifline_num" . "\n"; + if($out_line =~ /[^#]/){ + $out_line .= "\n"; + }else{ + $out_line = $out_line . " ! $base_file_name:$ifline_num" . "\n"; + } } if($verbose) { print "Adding \"$out_line\" to ${$ref_templ_funcname}\n"; } if(exists $template_funcs{${$ref_templ_funcname}}){