Skip to content

Commit

Permalink
fixes for vard and nag
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards4b committed Mar 12, 2018
1 parent d513eac commit c8cff06
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
61 changes: 25 additions & 36 deletions src/clib/pio_darray_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int get_gdim0(file_desc_t *file,io_desc_t *iodesc, int varid, int fndims, MPI_Of
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 *subarray, MPI_Datatype *filetype)
MPI_Datatype *filetype)
{

int sa_ndims;
Expand All @@ -111,6 +111,7 @@ int get_vard_mpidatatype(io_desc_t *iodesc, MPI_Offset gdim0, PIO_Offset unlimdi
int mpierr;
MPI_Aint displacements[rrcnt];
int blocklengths[rrcnt];
MPI_Datatype subarray[rrcnt];

if(rrcnt == 0)
return PIO_NOERR;
Expand All @@ -123,9 +124,6 @@ int get_vard_mpidatatype(io_desc_t *iodesc, MPI_Offset gdim0, PIO_Offset unlimdi
}
if(*filetype != MPI_DATATYPE_NULL)
{
for( int rc=0; rc<rrcnt; rc++)
if ((mpierr = MPI_Type_free(subarray + rc)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);
if ((mpierr = MPI_Type_free(filetype)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);
}
Expand Down Expand Up @@ -198,6 +196,12 @@ int get_vard_mpidatatype(io_desc_t *iodesc, MPI_Offset gdim0, PIO_Offset unlimdi

if((mpierr = MPI_Type_commit(filetype)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);

for( int rc=0; rc<rrcnt; rc++)
if (subarray[rc] != MPI_DATATYPE_NULL && (mpierr = MPI_Type_free(subarray + rc)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);


return PIO_NOERR;
}

Expand Down Expand Up @@ -419,7 +423,6 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
{
#ifdef USE_VARD_WRITE
MPI_Datatype filetype = MPI_DATATYPE_NULL;
MPI_Datatype subarray[rrcnt];
#endif
/* For each variable to be written. */
for (int nv = 0; nv < nvars; nv++)
Expand All @@ -446,8 +449,7 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
thisframe = 0;
ierr = get_vard_mpidatatype(iodesc, gdim0, unlimdimoffset,
rrcnt, ndims, fndims,
thisframe, startlist, countlist,
subarray, &filetype);
thisframe, startlist, countlist, &filetype);
}
#else
if (vdesc->record >= 0 && ndims < fndims)
Expand All @@ -464,10 +466,6 @@ int write_darray_multi_par(file_desc_t *file, int nvars, int fndims, const int *
if(nv==nvars-1 && filetype != MPI_DATATYPE_NULL)
{
int mpierr;
for(int i=0; i<rrcnt; i++)
if (subarray[i] != MPI_DATATYPE_NULL)
if((mpierr = MPI_Type_free(subarray+i)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);
if((mpierr = MPI_Type_free(&filetype)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);
}
Expand Down Expand Up @@ -1137,36 +1135,27 @@ int pio_read_darray_nc(file_desc_t *file, io_desc_t *iodesc, int vid, void *iobu
if (regioncnt == iodesc->maxregions - 1)
{
#if USE_VARD_READ
MPI_Datatype filetype, subarray[rrlen];
PIO_Offset unlimdimoffset;
int mpierr;
if (gdim0 == 0) /* if there is an unlimited dimension get the offset between records of a variable */
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__);
if((ierr = ncmpi_inq_recsize(file->fh, &unlimdimoffset)))
return pio_err(NULL, file, ierr, __FILE__, __LINE__);
}
else
unlimdimoffset = gdim0;

filetype = MPI_DATATYPE_NULL;
for(int i=0; i<rrlen; i++)
subarray[i] = MPI_DATATYPE_NULL;

ierr = get_vard_mpidatatype(iodesc, gdim0, unlimdimoffset,
rrlen, ndims, fndims,
vdesc->record, startlist, countlist,
subarray, &filetype);
ierr = ncmpi_get_vard_all(file->fh, vid, filetype, iobuf, iodesc->llen, iodesc->mpitype);
for(int i=0; i<rrlen; i++)
if (subarray[i] != MPI_DATATYPE_NULL)
if((mpierr = MPI_Type_free(subarray+i)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);
if((mpierr = MPI_Type_free(&filetype)))
return check_mpi(NULL, mpierr, __FILE__, __LINE__);
else
unlimdimoffset = gdim0;

#else
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);
Expand Down
14 changes: 9 additions & 5 deletions tests/general/ncdf_simple_tests.F90.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion tests/general/util/pio_tf_f90gen.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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}}){
Expand Down

0 comments on commit c8cff06

Please sign in to comment.