diff --git a/configure.ac b/configure.ac index 9e9a880eeb2..612fc8a5f42 100644 --- a/configure.ac +++ b/configure.ac @@ -302,6 +302,7 @@ AC_OUTPUT(Makefile tests/Makefile tests/cunit/Makefile tests/ncint/Makefile + tests/fncint/Makefile tests/unit/Makefile tests/general/Makefile tests/general/util/Makefile diff --git a/src/flib/pio.F90 b/src/flib/pio.F90 index 75f46fc4758..50fc33fc85f 100644 --- a/src/flib/pio.F90 +++ b/src/flib/pio.F90 @@ -26,6 +26,9 @@ module pio ! nf_init_intracom, & !#endif pio_set_rearr_opts +! #ifdef NETCDF_INTEGRATION +! nf_init_intracom, & +! #endif use pio_types, only : io_desc_t, file_desc_t, var_desc_t, iosystem_desc_t, & pio_rearr_opt_t, pio_rearr_comm_fc_opt_t, pio_rearr_comm_fc_2d_enable,& diff --git a/src/flib/piolib_mod.F90 b/src/flib/piolib_mod.F90 index 0cd6292054c..014e641840c 100644 --- a/src/flib/piolib_mod.F90 +++ b/src/flib/piolib_mod.F90 @@ -1,4 +1,5 @@ #define __PIO_FILE__ "piolib_mod.f90" +#include "config.h" !> !! @file !! Initialization Routines for PIO. diff --git a/tests/Makefile.am b/tests/Makefile.am index 8c58db5bd99..502597242d0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,9 +17,12 @@ endif # BUILD_FORTRAN # Are we building with netCDF integration? if BUILD_NCINT NCINT = ncint +if BUILD_FORTRAN +FNCINT = fncint +endif # BUILD_FORTRAN endif # BUILD_NCINT # Build in these subdirs. -SUBDIRS = cunit ${UNIT} ${NCINT} ${GENERAL} ${PERFORMANCE} +SUBDIRS = cunit ${UNIT} ${NCINT} ${GENERAL} ${PERFORMANCE} ${FNCINT} EXTRA_DIST = CMakeLists.txt diff --git a/tests/fncint/Makefile.am b/tests/fncint/Makefile.am new file mode 100644 index 00000000000..3cc3d3df955 --- /dev/null +++ b/tests/fncint/Makefile.am @@ -0,0 +1,28 @@ +## This is the automake file for building the netCDF integration layer +## tests. + +# Ed Hartnett 7/3/19 + +# Link to the PIO Fortran and C libraries. +LDADD = ${top_builddir}/src/flib/libpiof.la ${top_builddir}/src/clib/libpioc.la + +# Link to the netCDF fortran library. +LDADD += -lnetcdff + +# Find the pio.mod file. +AM_FCFLAGS = -I${top_builddir}/src/flib ${CPPFLAGS} + +# Build the test for make check. +check_PROGRAMS = ftst_pio +ftst_pio_SOURCES = ftst_pio.f90 + +if RUN_TESTS +# Tests will run from a bash script. +TESTS = run_tests.sh +endif # RUN_TESTS + +# Distribute the test script. +EXTRA_DIST = run_tests.sh + +# Clean up files produced during testing. +CLEANFILES = *.nc *.log diff --git a/tests/fncint/ftst_pio.f90 b/tests/fncint/ftst_pio.f90 new file mode 100644 index 00000000000..1172cd65534 --- /dev/null +++ b/tests/fncint/ftst_pio.f90 @@ -0,0 +1,35 @@ + !> This is a test program for the Fortran API use of the netCDF + !! integration layer. + +program ftst_pio + use pio + implicit none + include 'mpif.h' + include 'netcdf.inc' + + integer :: myRank, ntasks + type(iosystem_desc_t) :: ioSystem + integer :: niotasks = 1, numAggregator = 0, stride = 1, base = 0 + integer :: ncid + character*(*) FILE_NAME + parameter (FILE_NAME='ftst_pio.nc') + integer :: ierr + + call MPI_Init(ierr) + call MPI_Comm_rank(MPI_COMM_WORLD, myRank, ierr) + call MPI_Comm_size(MPI_COMM_WORLD, ntasks, ierr) + + ierr = pio_set_log_level(2) + ierr = nf_set_log_level(2) + call nf_init_intracom(myRank, MPI_COMM_WORLD, niotasks, numAggregator, & + stride, PIO_rearr_subset, ioSystem, base) + + ierr = nf_create(FILE_NAME, 64, ncid) + ierr = nf_close(ncid) + + call PIO_finalize(ioSystem, ierr) + call MPI_Finalize(ierr) + if (myRank .eq. 0) then + print *, '*** SUCCESS running ftst_pio!' + endif +end program ftst_pio diff --git a/tests/fncint/run_tests.sh b/tests/fncint/run_tests.sh new file mode 100755 index 00000000000..fbe296e54a9 --- /dev/null +++ b/tests/fncint/run_tests.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# This is a test script for PIO. +# Ed Hartnett + +# Stop execution of script if error is returned. +set -e + +# Stop loop if ctrl-c is pressed. +trap exit INT TERM + +printf 'running Fortran tests for PIO netCDF integration...\n' + +PIO_TESTS='ftst_pio' + +success1=true +for TEST in $PIO_TESTS +do + success1=false + echo "running ${TEST}" + mpiexec -n 4 ./${TEST} && success1=true + if test $success1 = false; then + break + fi +done + +# Did we succeed? +if test x$success1 = xtrue; then + exit 0 +fi +exit 1