From e03d43f8699c1d25bda9a6397dd97a39a77013ae Mon Sep 17 00:00:00 2001 From: Ed Hartnett Date: Mon, 8 Jul 2019 06:07:16 -0600 Subject: [PATCH] adding run_tests.sh script in fncint test directory --- tests/fncint/Makefile.am | 17 ++++++----------- tests/fncint/ftst_pio.f90 | 13 ++++++++++++- tests/fncint/run_tests.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 12 deletions(-) create mode 100755 tests/fncint/run_tests.sh diff --git a/tests/fncint/Makefile.am b/tests/fncint/Makefile.am index 6e73a038531..6b6d7568547 100644 --- a/tests/fncint/Makefile.am +++ b/tests/fncint/Makefile.am @@ -5,24 +5,19 @@ # Put together AM_CPPFLAGS and AM_LDFLAGS. AM_FCFLAGS = -I$(top_srcdir)/src/flib -LDADD = ${top_builddir}/src/clib/libpioc.la +AM_LDADD = ${top_builddir}/src/clib/libpioc.la # Build the test for make check. check_PROGRAMS = ftst_pio ftst_pio_SOURCES = ftst_pio.f90 -#if RUN_TESTS +if RUN_TESTS # Tests will run from a bash script. -#TESTS = run_tests.sh -#endif # RUN_TESTS - -# if RUN_TESTS -# # Tests will run from a bash script. -# TESTS = run_tests.sh -# endif # RUN_TESTS +TESTS = run_tests.sh +endif # RUN_TESTS # Distribute the test script. -#EXTRA_DIST = run_tests.sh +EXTRA_DIST = run_tests.sh # Clean up files produced during testing. -#CLEANFILES = *.nc *.log +CLEANFILES = *.nc *.log diff --git a/tests/fncint/ftst_pio.f90 b/tests/fncint/ftst_pio.f90 index f523370bd19..04c589bc219 100644 --- a/tests/fncint/ftst_pio.f90 +++ b/tests/fncint/ftst_pio.f90 @@ -4,6 +4,17 @@ program ftst_pio use pio implicit none + include 'mpif.h' - print *, '*** SUCCESS running ftst_pio!' + integer :: myRank, ntasks + integer :: ierr + + call MPI_Init(ierr) + call MPI_Comm_rank(MPI_COMM_WORLD, myRank, ierr) + call MPI_Comm_size(MPI_COMM_WORLD, ntasks, 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