Skip to content

Commit

Permalink
starting to add first vard
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jul 19, 2019
1 parent 3279fd0 commit 47a4e5e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 23 deletions.
36 changes: 36 additions & 0 deletions src/flib/ncint_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 19 additions & 19 deletions src/ncint/nc_put_vard.c
Original file line number Diff line number Diff line change
@@ -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 <config.h>
#include <pio.h>
#include <pio_internal.h>
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
9 changes: 5 additions & 4 deletions tests/fncint/ftst_pio.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 47a4e5e

Please sign in to comment.