diff --git a/src/flib/ncint_mod.F90 b/src/flib/ncint_mod.F90 index f21b385d790..f16da84155e 100644 --- a/src/flib/ncint_mod.F90 +++ b/src/flib/ncint_mod.F90 @@ -194,4 +194,40 @@ function nf_def_decomp(iosysid, basepiotype, dims, compdof, & status = 0 end function nf_def_decomp + !> + !! @public + !! @ingroup ncint + !! Put distributed array subset of an integer variable. + !! + !! This routine is called collectively by all tasks in the + !! communicator ios.union_comm. + !! + !! @param ncid identifies the netCDF file + !! @param varid the variable ID number + !! @param decompid the decomposition ID. + !! @param recnum the record number. + !! @param op pointer to the data to be written. + !! @return PIO_NOERR on success, error code otherwise. + !! @author Ed Hartnett + !< + function nf_put_vard_int(ncid, varid, decompid, recnum, ivals) result(status) + use iso_c_binding + integer, intent(in):: ncid, varid, decompid, recnum + integer, intent(in):: ivals(*) + integer(c_int):: ierr + integer:: status + + interface + function nc_put_vard_int(ncid, varid, decompid, recnum, op) bind(c) + use iso_c_binding + integer(c_int), value, intent(in) :: ncid, varid, decompid + integer(c_int64_t), value, intent(in) :: recnum + integer(c_int), intent(in) :: op(*) + integer(c_int) :: nc_put_vard_int + end function nc_put_vard_int + end interface + + status = 0 + end function nf_put_vard_int + end module ncint_mod diff --git a/src/ncint/nc_put_vard.c b/src/ncint/nc_put_vard.c index f90f67d2f4b..1c2eadf7225 100644 --- a/src/ncint/nc_put_vard.c +++ b/src/ncint/nc_put_vard.c @@ -1,11 +1,11 @@ /** - * @file - * PIO functions to write data with distributed arrays. - * - * @author Ed Hartnett - * @date 2019 - * @see https://github.com/NCAR/ParallelIO - */ + * @file + * PIO functions to write data with distributed arrays. + * + * @author Ed Hartnett + * @date 2019 + * @see https://github.com/NCAR/ParallelIO + */ #include #include #include @@ -32,7 +32,7 @@ */ int nc_put_vard_text(int ncid, int varid, int decompid, const size_t recnum, - const char *op) + const char *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_CHAR, op); } @@ -53,7 +53,7 @@ nc_put_vard_text(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard_uchar(int ncid, int varid, int decompid, const size_t recnum, - const unsigned char *op) + const unsigned char *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_UBYTE, op); } @@ -74,7 +74,7 @@ nc_put_vard_uchar(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard_schar(int ncid, int varid, int decompid, const size_t recnum, - const signed char *op) + const signed char *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_BYTE, op); } @@ -96,7 +96,7 @@ nc_put_vard_schar(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard_ushort(int ncid, int varid, int decompid, const size_t recnum, - const unsigned short *op) + const unsigned short *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_USHORT, op); } @@ -117,7 +117,7 @@ nc_put_vard_ushort(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard_short(int ncid, int varid, int decompid, const size_t recnum, - const short *op) + const short *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_SHORT, op); } @@ -139,7 +139,7 @@ nc_put_vard_short(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard_uint(int ncid, int varid, int decompid, const size_t recnum, - const unsigned int *op) + const unsigned int *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_UINT, op); } @@ -160,7 +160,7 @@ nc_put_vard_uint(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard_int(int ncid, int varid, int decompid, const size_t recnum, - const int *op) + const int *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_INT, op); } @@ -202,7 +202,7 @@ nc_put_vard_int(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard_float(int ncid, int varid, int decompid, const size_t recnum, - const float *op) + const float *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_FLOAT, op); } @@ -224,7 +224,7 @@ nc_put_vard_float(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard_longlong(int ncid, int varid, int decompid, const size_t recnum, - const long long *op) + const long long *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_INT64, op); } @@ -246,7 +246,7 @@ nc_put_vard_longlong(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard_double(int ncid, int varid, int decompid, const size_t recnum, - const double *op) + const double *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_DOUBLE, op); } @@ -268,7 +268,7 @@ nc_put_vard_double(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard_ulonglong(int ncid, int varid, int decompid, const size_t recnum, - const unsigned long long *op) + const unsigned long long *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_UINT64, op); } @@ -289,7 +289,7 @@ nc_put_vard_ulonglong(int ncid, int varid, int decompid, const size_t recnum, */ int nc_put_vard(int ncid, int varid, int decompid, const size_t recnum, - const void *op) + const void *op) { return PIOc_put_vard_tc(ncid, varid, decompid, recnum, NC_NAT, op); } diff --git a/tests/fncint/ftst_pio.f90 b/tests/fncint/ftst_pio.f90 index e448a7add29..e4cd28ee946 100644 --- a/tests/fncint/ftst_pio.f90 +++ b/tests/fncint/ftst_pio.f90 @@ -18,8 +18,8 @@ program ftst_pio integer :: my_rank, ntasks integer :: niotasks = 1, numAggregator = 0, stride = 1, base = 0 integer :: ncid - integer(kind = PIO_OFFSET_KIND), dimension(3) :: data_buffer integer(kind = PIO_OFFSET_KIND), dimension(:), allocatable :: compdof + integer, dimension(:), allocatable :: data_buffer integer, dimension(2) :: dims integer, dimension(3) :: var_dim integer :: maplen @@ -47,8 +47,10 @@ program ftst_pio dims(2) = NLON / ntasks maplen = dims(1) * dims(2) allocate(compdof(maplen)) + allocate(data_buffer(maplen)) do i = 1, maplen compdof(i) = i + (my_rank - 1) * maplen + data_buffer(i) = (my_rank - 1) * 10 + i end do ierr = nf_def_decomp(iosysid, PIO_int, dims, compdof, decompid) if (ierr .ne. nf_noerr) call handle_err(ierr) @@ -72,9 +74,6 @@ program ftst_pio ierr = nf_enddef(ncid) if (ierr .ne. nf_noerr) call handle_err(ierr) - data_buffer = my_rank - - ! Close the file. ierr = nf_close(ncid) if (ierr .ne. nf_noerr) call handle_err(ierr) @@ -84,6 +83,8 @@ program ftst_pio if (ierr .ne. nf_noerr) call handle_err(ierr) ierr = nf_free_iosystem() if (ierr .ne. nf_noerr) call handle_err(ierr) + deallocate(compdof) + deallocate(data_buffer) ! We're done! call MPI_Finalize(ierr)