Skip to content

Commit

Permalink
Merge pull request #1974 from jedwards4b/fix_scalar_write_issue
Browse files Browse the repository at this point in the history
fix scalar write issue, fix serial build issue
  • Loading branch information
jedwards4b authored Aug 29, 2023
2 parents 6d52a8c + 3661a58 commit f52ade0
Show file tree
Hide file tree
Showing 20 changed files with 247 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .github/actions/parallelio_cmake/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,5 @@ runs:
-DPnetCDF_C_LIBRARY=${{ inputs.pnetcdf_library }} \
$GITHUB_WORKSPACE/parallelio-src
make VERBOSE=1
make tests
#make tests
make install
6 changes: 3 additions & 3 deletions .github/workflows/autotools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ jobs:
cd $GITHUB_WORKSPACE
make check
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
1 change: 1 addition & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
sudo apt-get update
sudo apt-get install netcdf-bin libnetcdf-dev doxygen graphviz wget gfortran \
libjpeg-dev libz-dev openmpi-bin libopenmpi-dev cmake pnetcdf-bin libpnetcdf-dev libnetcdff-dev
nc-config --all
- name: cmake build
uses: ./.github/actions/parallelio_cmake
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ jobs:
- name: parallelio tests
run: |
pushd $GITHUB_WORKSPACE/build
#make tests
make tests
ctest -VV -E test_async_
popd
# the following can be used by developers to login to the github server in case of errors
# see https://github.com/marketplace/actions/debugging-with-tmate for further details
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project (PIO C)
# The project version number.
set(VERSION_MAJOR 2 CACHE STRING "Project major version number.")
set(VERSION_MINOR 6 CACHE STRING "Project minor version number.")
set(VERSION_PATCH 1 CACHE STRING "Project patch version number.")
set(VERSION_PATCH 2 CACHE STRING "Project patch version number.")
mark_as_advanced(VERSION_MAJOR VERSION_MINOR VERSION_PATCH)

# Create version info in autotools parlance for pio_meta.h.
Expand Down Expand Up @@ -358,8 +358,16 @@ int main() {return 0;}" HAVE_SZIP_WRITE)
# Check to see if parallel filters are supported by HDF5/netcdf-c.
###
if (HAVE_NETCDF_PAR)
check_function_exists(nc_inq_filter_avail HAVE_PAR_FILTERS)
CHECK_C_SOURCE_COMPILES("
#include <netcdf_meta.h>
#if !NC_HAS_PAR_FILTERS
choke me
#endif
int main() {return 0;}" HAVE_PAR_FILTERS)
else()
set(HAVE_PAR_FILTERS 0)
endif()

###
# Check to see if this is netcdf-c-4.7.2, which won't work.
###
Expand Down
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Ed Hartnett 8/16/17

# Initialize autoconf and automake.
AC_INIT(pio, 2.6.1)
AC_INIT(pio, 2.6.2)
AC_CONFIG_SRCDIR(src/clib/pio_darray.c)
AM_INIT_AUTOMAKE([foreign serial-tests])

Expand All @@ -11,15 +11,15 @@ AM_INIT_AUTOMAKE([foreign serial-tests])
# AC_DEFINE_UNQUOTED for config.h.
AC_SUBST([PIO_VERSION_MAJOR]) PIO_VERSION_MAJOR=2
AC_SUBST([PIO_VERSION_MINOR]) PIO_VERSION_MINOR=6
AC_SUBST([PIO_VERSION_PATCH]) PIO_VERSION_PATCH=1
AC_SUBST([PIO_VERSION_PATCH]) PIO_VERSION_PATCH=2
AC_DEFINE_UNQUOTED([PIO_VERSION_MAJOR], [$PIO_VERSION_MAJOR], [PIO major version])
AC_DEFINE_UNQUOTED([PIO_VERSION_MINOR], [$PIO_VERSION_MINOR], [PIO minor version])
AC_DEFINE_UNQUOTED([PIO_VERSION_PATCH], [$PIO_VERSION_PATCH], [PIO patch version])

# Once more for the documentation.
AC_SUBST([VERSION_MAJOR], [2])
AC_SUBST([VERSION_MINOR], [6])
AC_SUBST([VERSION_PATCH], [1])
AC_SUBST([VERSION_PATCH], [2])


# The m4 directory holds macros for autoconf.
Expand Down
5 changes: 2 additions & 3 deletions src/clib/pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -1267,9 +1267,8 @@ extern "C" {
const long long *op);
int PIOc_put_vard_ulonglong(int ncid, int varid, int decompid, const PIO_Offset recnum,
const unsigned long long *op);
/* use this variable in the NETCDF library (introduced in v4.9.0) to determine if the following
functions are available */
#ifdef NC_HAS_MULTIFILTERS

#ifdef NC_HAS_PAR_FILTERS
int PIOc_def_var_filter(int ncid, int varid,unsigned int id, size_t nparams, unsigned int *params);
int PIOc_inq_var_filter_ids(int ncid, int varid, size_t *nfiltersp, unsigned int *ids);
int PIOc_inq_var_filter_info(int ncid, int varid, unsigned int id, size_t *nparamsp, unsigned int *params );
Expand Down
2 changes: 1 addition & 1 deletion src/clib/pio_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ PIOc_createfile(int iosysid, int *ncidp, int *iotype, const char *filename,

PLOG((1, "PIOc_createfile iosysid = %d iotype = %d filename = %s mode = %d",
iosysid, *iotype, filename, mode));

/* Create the file. */
if ((ret = PIOc_createfile_int(iosysid, ncidp, iotype, filename, mode, 0)))
return pio_err(ios, NULL, ret, __FILE__, __LINE__);
Expand Down
121 changes: 36 additions & 85 deletions src/clib/pio_getput_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,100 +1085,51 @@ PIOc_put_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Offset
#ifdef _PNETCDF
if (file->iotype == PIO_IOTYPE_PNETCDF)
{
if (ndims == 0)
if ((ierr = ncmpi_begin_indep_data(file->fh)))
return pio_err(ios, file, ierr, __FILE__, __LINE__);
if (ios->iomain == MPI_ROOT)
{
/* Scalars have to be handled differently. */
if (ndims == 0)
/* This is not a scalar var. */
var_desc_t *vdesc;

PLOG((2, "PIOc_put_vars_tc calling pnetcdf function"));

if ((ierr = get_var_desc(varid, &file->varlist, &vdesc)))
return pio_err(ios, file, ierr, __FILE__, __LINE__);

switch(xtype)
{
/* This is a scalar var. */
PLOG((2, "pnetcdf writing scalar with ncmpi_put_vars_*() file->fh = %d varid = %d",
file->fh, varid));
pioassert(!start && !count && !stride, "expected NULLs", __FILE__, __LINE__);


/* Only the IO main does the IO, so we are not really
* getting parallel IO here. */

switch(xtype)
{
case NC_BYTE:
ierr = ncmpi_put_vars_schar(file->fh, varid, start, count, stride, buf);
break;
case NC_CHAR:
ierr = ncmpi_put_vars_text(file->fh, varid, start, count, stride, buf);
break;
case NC_SHORT:
ierr = ncmpi_put_vars_short(file->fh, varid, start, count, stride, buf);
break;
case NC_INT:
ierr = ncmpi_put_vars_int(file->fh, varid, start, count, stride, buf);
break;
case PIO_LONG_INTERNAL:
ierr = ncmpi_put_vars_long(file->fh, varid, start, count, stride, buf);
break;
case NC_FLOAT:
ierr = ncmpi_put_vars_float(file->fh, varid, start, count, stride, buf);
break;
case NC_DOUBLE:
ierr = ncmpi_put_vars_double(file->fh, varid, start, count, stride, buf);
break;
default:
return pio_err(ios, file, PIO_EBADIOTYPE, __FILE__, __LINE__);
}
case NC_BYTE:
ierr = ncmpi_bput_vars_schar(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case NC_CHAR:
ierr = ncmpi_bput_vars_text(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case NC_SHORT:
ierr = ncmpi_bput_vars_short(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case NC_INT:
ierr = ncmpi_bput_vars_int(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case PIO_LONG_INTERNAL:
ierr = ncmpi_bput_vars_long(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case NC_FLOAT:
ierr = ncmpi_bput_vars_float(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case NC_DOUBLE:
ierr = ncmpi_bput_vars_double(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
default:
return pio_err(ios, file, PIO_EBADTYPE, __FILE__, __LINE__);
}
else
{
/* This is not a scalar var. */
var_desc_t *vdesc;

PLOG((2, "PIOc_put_vars_tc calling pnetcdf function"));

if ((ierr = get_var_desc(varid, &file->varlist, &vdesc)))
return pio_err(ios, file, ierr, __FILE__, __LINE__);

switch(xtype)
{
case NC_BYTE:
ierr = ncmpi_bput_vars_schar(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case NC_CHAR:
ierr = ncmpi_bput_vars_text(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case NC_SHORT:
ierr = ncmpi_bput_vars_short(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case NC_INT:
ierr = ncmpi_bput_vars_int(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case PIO_LONG_INTERNAL:
ierr = ncmpi_bput_vars_long(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case NC_FLOAT:
ierr = ncmpi_bput_vars_float(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
case NC_DOUBLE:
ierr = ncmpi_bput_vars_double(file->fh, varid, start, count, fake_stride, buf, NULL);
break;
default:
return pio_err(ios, file, PIO_EBADTYPE, __FILE__, __LINE__);
}
PLOG((2, "PIOc_put_vars_tc io_rank 0 done with pnetcdf call, ierr=%d", ierr));


vdesc->nreqs++;
PLOG((2, "PIOc_put_vars_tc io_rank 0 done with pnetcdf call, ierr=%d", ierr));


vdesc->nreqs++;

if(ierr == PIO_EINVALCOORDS)
for(int i=0; i<ndims; i++)
PLOG((2,"start[%d] %ld count[%d] %ld\n",i,start[i],i,count[i]));
} /* endif ndims == 0 */
} /* end if MPI_ROOT */
/* Turn off independent access for pnetcdf file. */
if(ndims == 0)
if ((ierr = ncmpi_end_indep_data(file->fh)))
return pio_err(ios, file, ierr, __FILE__, __LINE__);
}
#endif /* _PNETCDF */

Expand Down
2 changes: 1 addition & 1 deletion src/clib/pio_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <limits.h>
#include <math.h>
#include <netcdf.h>
#ifdef PIO_HAS_PAR_FILTERS
#ifdef NC_HAS_PAR_FILTERS
#include <netcdf_filter.h>
#include <netcdf_meta.h>
#endif
Expand Down
9 changes: 6 additions & 3 deletions src/clib/pio_nc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,6 @@ PIOc_def_var_filter(int ncid, int varid, unsigned int id, size_t nparams, unsign
return PIO_NOERR;
}
#ifdef PIO_HAS_PAR_FILTERS

/**
* Get the variable filter ids if any
*
Expand Down Expand Up @@ -1794,8 +1793,10 @@ PIOc_inq_var_zstandard(int ncid, int varid, int* hasfilterp, int *levelp)

return PIO_NOERR;
}
// NC_HAS_ZSTD
#endif

#endif
#ifdef PIO_HAS_PAR_FILTERS
/**
*
*
Expand Down Expand Up @@ -1875,7 +1876,9 @@ PIOc_inq_filter_avail(int ncid, unsigned int id )

return ierr;
}
#endif
// PIO_HAS_PAR_FILTERS
#endif
// NC_HAS_MULTIFILTERS
#endif
#ifdef NC_HAS_QUANTIZE
/**
Expand Down
4 changes: 2 additions & 2 deletions src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -3111,15 +3111,15 @@ iotype_is_valid(int iotype)
ret++;

/* Some builds include netCDF-4. */
#ifdef _NETCDF4
#ifdef NC_HAS_NC4
if (iotype == PIO_IOTYPE_NETCDF4C || iotype == PIO_IOTYPE_NETCDF4P)
ret++;
#endif /* _NETCDF4 */

/* Some builds include pnetcdf. */
#ifdef _PNETCDF
if (iotype == PIO_IOTYPE_PNETCDF)
ret++;
#ifdef _PNETCDF
#endif /* _PNETCDF */

return ret;
Expand Down
1 change: 1 addition & 0 deletions src/flib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ else ()
target_compile_definitions (gptl
PUBLIC NO_MPIMOD)
endif()
target_compile_definitions (piof PUBLIC NO_MPIMOD)
endif ()

#===== GPTL =====
Expand Down
5 changes: 4 additions & 1 deletion src/ncint/ncintdispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ NC_Dispatch NCINT_dispatcher = {
NC_NOTNC4_def_var_filter,
NC_NOTNC4_set_var_chunk_cache,
NC_NOTNC4_get_var_chunk_cache,
#ifdef PIO_HAS_PAR_FILTERS
#if NC_DISPATCH_VERSION == 2
PIO_NCINT_filter_actions,
#endif
Expand All @@ -141,6 +142,7 @@ NC_Dispatch NCINT_dispatcher = {
#if NC_DISPATCH_VERSION >= 5
PIOc_inq_filter_avail,
#endif
#endif
};

/**
Expand Down Expand Up @@ -229,10 +231,11 @@ PIO_NCINT_create(const char *path, int cmode, size_t initialsz, int basepe,
if ((ret = nc4_file_list_add(ncid, path, cmode, NULL)))
return ret;

/* Create the file with PIO. The final parameter tests
/* Create the file with PIO. The final parameter tells
* createfile_int to accept the externally assigned ncid. */
if ((ret = PIOc_createfile_int(diosysid, &ncid, &iotype, path, cmode, 1)))
return ret;


return PIO_NOERR;
}
Expand Down
1 change: 1 addition & 0 deletions tests/cunit/test_intercomm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ int main(int argc, char **argv)
sprintf(filename[fmt], "test_intercomm2_%d.nc", flavor[fmt]);

/* Create a netCDF file with one dimension and one variable. */

if ((ret = PIOc_createfile(iosysid[my_comp_idx], &ncid, &flavor[fmt], filename[fmt],
NC_CLOBBER)))
ERR(ret);
Expand Down
4 changes: 3 additions & 1 deletion tests/cunit/test_pioc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,9 @@ int test_scalar(int iosysid, int num_flavors, int *flavor, int my_rank, int asyn
int test_val = TEST_VAL_42;
if ((ret = PIOc_put_var_int(ncid, varid, &test_val)))
ERR(ret);
/* flush the write buffer */
if ((ret = PIOc_sync(ncid)))
ERR(ret);

/* Check the scalar var. */
if ((ret = check_scalar_var(ncid, varid, flavor[fmt], my_rank)))
Expand Down Expand Up @@ -2326,7 +2329,6 @@ int test_all(int iosysid, int num_flavors, int *flavor, int my_rank, MPI_Comm te
/* This will be our file name for writing out decompositions. */
sprintf(filename, "decomp_%d.txt", my_rank);
sprintf(nc_filename, "decomp_%d.nc", my_rank);

/* This is a simple test that just creates the decomp with
* async. */
if (async)
Expand Down
Loading

0 comments on commit f52ade0

Please sign in to comment.