Skip to content

Commit

Permalink
renamed test
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardhartnett committed Aug 28, 2020
1 parent 5ff9844 commit f1e58bd
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 86 deletions.
10 changes: 5 additions & 5 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ endif ()
add_dependencies (tests pio_unit_test)

# Add ftst_vars.F90.
add_executable (ftst_vars EXCLUDE_FROM_ALL ftst_vars.F90)
target_link_libraries (ftst_vars piof)
add_dependencies (tests ftst_vars)
add_executable (ftst_vars_chunking EXCLUDE_FROM_ALL ftst_vars_chunking.F90)
target_link_libraries (ftst_vars_chunking piof)
add_dependencies (tests ftst_vars_chunking)

# Test Timeout in seconds.
set (DEFAULT_TEST_TIMEOUT 60)
Expand All @@ -63,8 +63,8 @@ else ()
EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/pio_unit_test
NUMPROCS 4
TIMEOUT ${DEFAULT_TEST_TIMEOUT})
add_mpi_test(ftst_vars
EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/ftst_vars
add_mpi_test(ftst_vars_chunking
EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/ftst_vars_chunking
NUMPROCS 4
TIMEOUT ${DEFAULT_TEST_TIMEOUT})
endif ()
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ LDADD = ${top_builddir}/src/flib/libpiof.la \
${top_builddir}/src/clib/libpioc.la

# Build the test for make check.
check_PROGRAMS = pio_unit_test_driver ftst_vars
check_PROGRAMS = pio_unit_test_driver ftst_vars_chunking
pio_unit_test_driver_SOURCES = driver.F90
pio_unit_test_driver_LDADD = libglobal_vars.la libncdf_tests.la \
libbasic_tests.la ${top_builddir}/src/flib/libpiof.la \
${top_builddir}/src/clib/libpioc.la
ftst_vars_SOURCES = ftst_vars.F90
ftst_vars_chunking_SOURCES = ftst_vars_chunking.F90

# Build these uninstalled convenience libraries.
noinst_LTLIBRARIES = libglobal_vars.la libncdf_tests.la \
Expand Down
79 changes: 0 additions & 79 deletions tests/unit/ftst_vars.F90

This file was deleted.

88 changes: 88 additions & 0 deletions tests/unit/ftst_vars_chunking.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
! This is a test of the PIO Fortran library.

! This tests var functions.

! Ed Hartnett, 8/28/20
#include "config.h"

program ftst_vars
use mpi
use pio
use pio_nf

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) :: var_name = 'Caesar'
integer :: dimid, dim_len = 40
integer :: chunksize = 10
integer :: storage_in
integer (kind=PIO_OFFSET_KIND) :: chunksizes_in(2)
integer, parameter :: NUM_IOTYPES = 2
integer :: iotype(NUM_IOTYPES) = (/ PIO_iotype_netcdf4c, PIO_iotype_netcdf4p /)
integer :: iotype_idx, ierr

! Set up MPI
call MPI_Init(ierr)
call MPI_Comm_rank(MPI_COMM_WORLD, my_rank, ierr)
call MPI_Comm_size(MPI_COMM_WORLD, ntasks , ierr)

! This whole test only works for netCDF/HDF5 files, because it is
! about chunking.
#ifdef _NETCDF4
if (my_rank .eq. 0) print *,'Testing variables...'

! Initialize PIO.
call PIO_init(my_rank, MPI_COMM_WORLD, niotasks, 0, stride, &
PIO_rearr_subset, pio_iosystem, base=1)

! Set error handling for test.
call PIO_seterrorhandling(pio_iosystem, PIO_RETURN_ERROR)
call PIO_seterrorhandling(PIO_DEFAULT, PIO_RETURN_ERROR)

!ret_val = PIO_set_log_level(3)
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)
if (ierr .ne. PIO_NOERR) stop 5

! Define a var.
ret_val = PIO_def_var(pio_file, var_name, PIO_int, (/dimid/), 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/))
if (ierr .ne. PIO_NOERR) stop 9

! Close the file.
call PIO_closefile(pio_file)

! Open the file.
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

! Close the file.
call PIO_closefile(pio_file)

end do

! Finalize PIO.
call PIO_finalize(pio_iosystem, ierr)

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

0 comments on commit f1e58bd

Please sign in to comment.