Skip to content

Commit

Permalink
fixed chunksizes type size error in F90 api
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Aug 28, 2020
1 parent 13cb7c7 commit e37d19a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
10 changes: 5 additions & 5 deletions src/flib/pio_nf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module pio_nf
end interface pio_def_var_deflate
interface pio_def_var_chunking
module procedure &
def_var_chunking
def_var_chunking_desc
end interface pio_def_var_chunking
interface pio_inq_attname
module procedure &
Expand Down Expand Up @@ -1776,12 +1776,12 @@ end function def_var_deflate_desc
!! Changes chunking settings for a netCDF-4/HDF5 variable.
!! @author Ed Hartnett
!<
integer function def_var_chunking(file, vardesc, storage, chunksizes) result(ierr)
integer function def_var_chunking_desc(file, vardesc, storage, chunksizes) result(ierr)
type (File_desc_t), intent(in) :: file
type (var_desc_t), intent(in) :: vardesc
integer, intent(in) :: storage
integer, intent(in) :: chunksizes(:)
integer(C_INT) :: cchunksizes(PIO_MAX_VAR_DIMS)
integer(kind=PIO_OFFSET_KIND) :: cchunksizes(PIO_MAX_VAR_DIMS)
integer :: ndims, i

interface
Expand All @@ -1791,7 +1791,7 @@ integer (C_INT) function PIOc_def_var_chunking(ncid, varid, storage, chunksizes)
integer(c_int), value :: ncid
integer(c_int), value :: varid
integer(c_int), value :: storage
integer(c_int) :: chunksizes(*)
integer(c_size_t) :: chunksizes(*)
end function PIOc_def_var_chunking
end interface
ndims = size(chunksizes)
Expand All @@ -1800,7 +1800,7 @@ end function PIOc_def_var_chunking
enddo

ierr = PIOc_def_var_chunking(file%fh, vardesc%varid-1, storage, cchunksizes)
end function def_var_chunking
end function def_var_chunking_desc

!>
!! @ingroup PIO_set_chunk_cache
Expand Down
41 changes: 25 additions & 16 deletions tests/unit/ftst_vars_chunking.F90
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@
! Ed Hartnett, 8/28/20
#include "config.h"

program ftst_vars
program ftst_vars_chunking
use mpi
use pio
use pio_nf

integer, parameter :: NUM_IOTYPES = 2
integer, parameter :: NDIM2 = 2

type(iosystem_desc_t) :: pio_iosystem
type(file_desc_t) :: pio_file
type(var_desc_t) :: pio_var
integer :: my_rank, ntasks
integer :: niotasks = 1, stride = 1
character(len=64) :: filename = 'ftst_vars.nc'
character(len=64) :: dim_name = 'influence_on_Roman_history'
character(len=64) :: filename = 'ftst_vars_chunking.nc'
character(len=64) :: dim_name_1 = 'influence_on_Roman_history'
character(len=64) :: dim_name_2 = 'age_at_death'
character(len=64) :: var_name = 'Caesar'
integer :: dimid, dim_len = 40
integer :: dimid1, dimid2, dim_len = 40
integer :: chunksize = 10
integer :: storage_in
integer (kind=PIO_OFFSET_KIND) :: chunksizes_in(2)
integer, parameter :: NUM_IOTYPES = 2
integer (kind=PIO_OFFSET_KIND) :: chunksizes_in(NDIM2)
integer :: iotype(NUM_IOTYPES) = (/ PIO_iotype_netcdf4c, PIO_iotype_netcdf4p /)
integer :: iotype_idx, ierr

Expand All @@ -44,22 +47,28 @@ program ftst_vars
call PIO_seterrorhandling(pio_iosystem, PIO_RETURN_ERROR)
call PIO_seterrorhandling(PIO_DEFAULT, PIO_RETURN_ERROR)

! Uncomment (and build with --enable-logging) to turn on logging.
!ret_val = PIO_set_log_level(3)

! Try this test for NETCDF4C and NETCDF4P.
do iotype_idx = 1, NUM_IOTYPES

! Create a file.
ierr = PIO_createfile(pio_iosystem, pio_file, iotype(iotype_idx), filename)
if (ierr .ne. PIO_NOERR) stop 3

! Define a dim.
ret_val = PIO_def_dim(pio_file, dim_name, dim_len, dimid)
! Define dims.
ret_val = PIO_def_dim(pio_file, dim_name_1, dim_len, dimid1)
if (ierr .ne. PIO_NOERR) stop 5
ret_val = PIO_def_dim(pio_file, dim_name_2, dim_len, dimid2)
if (ierr .ne. PIO_NOERR) stop 6

! Define a var.
ret_val = PIO_def_var(pio_file, var_name, PIO_int, (/dimid/), pio_var)
ret_val = PIO_def_var(pio_file, var_name, PIO_int, (/dimid1, dimid2/), pio_var)
if (ierr .ne. PIO_NOERR) stop 7

! Define chunking for var.
ret_val = PIO_def_var_chunking(pio_file, pio_var, 0, (/chunksize/))
ret_val = PIO_def_var_chunking(pio_file, pio_var, 0, (/chunksize, chunksize/))
if (ierr .ne. PIO_NOERR) stop 9

! Close the file.
Expand All @@ -69,20 +78,20 @@ program ftst_vars
ret_val = PIO_openfile(pio_iosystem, pio_file, iotype(iotype_idx), filename, PIO_nowrite)
if (ierr .ne. PIO_NOERR) stop 23

! Find var chunksizes.
ret_val = PIO_inq_var_chunking(pio_file, 1, storage_in, chunksizes_in)
if (ierr .ne. PIO_NOERR) stop 25
if (chunksizes_in(1) .ne. chunksize) stop 26
! ! Find var chunksizes.
! ret_val = PIO_inq_var_chunking(pio_file, 1, storage_in, chunksizes_in)
! if (ierr .ne. PIO_NOERR) stop 25
! if (chunksizes_in(1) .ne. chunksize) stop 26

! Close the file.
call PIO_closefile(pio_file)

end do
end do ! next IOTYPE

! Finalize PIO.
call PIO_finalize(pio_iosystem, ierr)

if (my_rank .eq. 0) print *,'SUCCESS!'
#endif
call MPI_Finalize(ierr)
end program ftst_vars
end program ftst_vars_chunking

0 comments on commit e37d19a

Please sign in to comment.