summaryrefslogtreecommitdiffstats
path: root/fortran/examples
diff options
context:
space:
mode:
authorJordan Henderson <jhenderson@hdfgroup.org>2020-02-21 20:30:34 (GMT)
committerJordan Henderson <jhenderson@hdfgroup.org>2020-02-21 20:30:34 (GMT)
commit51b8c63864c72de9a7b40c00673fe07510fec27e (patch)
tree298e9a2584860a24f55d2bce1fc60faed2bef2dd /fortran/examples
parentc4f785bc93c5f4e8677b325c321e0f9ed41c3baa (diff)
parentc5ab2285639a801f87a77987db1a0b609a020314 (diff)
downloadhdf5-51b8c63864c72de9a7b40c00673fe07510fec27e.zip
hdf5-51b8c63864c72de9a7b40c00673fe07510fec27e.tar.gz
hdf5-51b8c63864c72de9a7b40c00673fe07510fec27e.tar.bz2
Merge develop
Diffstat (limited to 'fortran/examples')
-rw-r--r--fortran/examples/CMakeLists.txt2
-rw-r--r--fortran/examples/CMakeTests.cmake138
-rw-r--r--fortran/examples/Makefile.am4
-rw-r--r--fortran/examples/run-fortran-ex.sh.in27
4 files changed, 98 insertions, 73 deletions
diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt
index e8dddd3..be98963 100644
--- a/fortran/examples/CMakeLists.txt
+++ b/fortran/examples/CMakeLists.txt
@@ -173,6 +173,6 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
endif ()
endif ()
-if (BUILD_TESTING)
+if (BUILD_TESTING AND HDF5_TEST_FORTRAN AND HDF5_TEST_EXAMPLES)
include (CMakeTests.cmake)
endif ()
diff --git a/fortran/examples/CMakeTests.cmake b/fortran/examples/CMakeTests.cmake
index 5e7dfa8..a52375b 100644
--- a/fortran/examples/CMakeTests.cmake
+++ b/fortran/examples/CMakeTests.cmake
@@ -16,77 +16,79 @@
##############################################################################
##############################################################################
-set (test_ex_fortran_CLEANFILES
- compound.h5
- copy1.h5
- copy2.h5
- dsetf.h5
- extend.h5
- FORTRAN.h5
- groupf.h5
- groupsf.h5
- h5_cmprss.h5
- mount1.h5
- mount2.h5
- sdsf.h5
- subset.h5
- SDScompound.h5
- test.h5
-)
+if (HDF5_TEST_SERIAL)
+ set (test_ex_fortran_CLEANFILES
+ compound.h5
+ copy1.h5
+ copy2.h5
+ dsetf.h5
+ extend.h5
+ FORTRAN.h5
+ groupf.h5
+ groupsf.h5
+ h5_cmprss.h5
+ mount1.h5
+ mount2.h5
+ sdsf.h5
+ subset.h5
+ SDScompound.h5
+ test.h5
+ )
-# Remove any output file left over from previous test run
-add_test (
- NAME f90_ex-clear-objects
- COMMAND ${CMAKE_COMMAND} -E remove ${test_ex_fortran_CLEANFILES}
-)
-set_tests_properties (f90_ex-clear-objects PROPERTIES FIXTURES_SETUP clear_f90_ex)
+ # Remove any output file left over from previous test run
+ add_test (
+ NAME f90_ex-clear-objects
+ COMMAND ${CMAKE_COMMAND} -E remove ${test_ex_fortran_CLEANFILES}
+ )
+ set_tests_properties (f90_ex-clear-objects PROPERTIES FIXTURES_SETUP clear_f90_ex)
-foreach (example ${examples})
- if (HDF5_ENABLE_USING_MEMCHECKER)
- add_test (NAME f90_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:f90_ex_${example}>)
- else ()
- add_test (NAME f90_ex_${example} COMMAND "${CMAKE_COMMAND}"
- -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
- -D "TEST_PROGRAM=$<TARGET_FILE:f90_ex_${example}>"
- -D "TEST_ARGS:STRING="
- -D "TEST_EXPECT=0"
- -D "TEST_SKIP_COMPARE=TRUE"
- -D "TEST_OUTPUT=f90_ex_${example}.txt"
- #-D "TEST_REFERENCE=f90_ex_${example}.out"
- -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
- -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
- )
- endif ()
- set_tests_properties (f90_ex_${example} PROPERTIES FIXTURES_REQUIRED clear_f90_ex)
- if (last_test)
- set_tests_properties (f90_ex_${example} PROPERTIES DEPENDS ${last_test})
- endif ()
- set (last_test "f90_ex_${example}")
-endforeach ()
+ foreach (example ${examples})
+ if (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (NAME f90_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:f90_ex_${example}>)
+ else ()
+ add_test (NAME f90_ex_${example} COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:f90_ex_${example}>"
+ -D "TEST_ARGS:STRING="
+ -D "TEST_EXPECT=0"
+ -D "TEST_SKIP_COMPARE=TRUE"
+ -D "TEST_OUTPUT=f90_ex_${example}.txt"
+ #-D "TEST_REFERENCE=f90_ex_${example}.out"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
+ )
+ endif ()
+ set_tests_properties (f90_ex_${example} PROPERTIES FIXTURES_REQUIRED clear_f90_ex)
+ if (last_test)
+ set_tests_properties (f90_ex_${example} PROPERTIES DEPENDS ${last_test})
+ endif ()
+ set (last_test "f90_ex_${example}")
+ endforeach ()
-foreach (example ${F2003_examples})
- if (HDF5_ENABLE_USING_MEMCHECKER)
- add_test (NAME f03_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:f03_ex_${example}>)
- else ()
- add_test (NAME f03_ex_${example} COMMAND "${CMAKE_COMMAND}"
- -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
- -D "TEST_PROGRAM=$<TARGET_FILE:f03_ex_${example}>"
- -D "TEST_ARGS:STRING="
- -D "TEST_EXPECT=0"
- -D "TEST_SKIP_COMPARE=TRUE"
- -D "TEST_OUTPUT=f03_ex_${example}.txt"
- #-D "TEST_REFERENCE=f03_ex_${example}.out"
- -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
- -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
- )
- endif ()
- set_tests_properties (f03_ex_${example} PROPERTIES FIXTURES_REQUIRED clear_f90_ex)
- if (last_test)
- set_tests_properties (f03_ex_${example} PROPERTIES DEPENDS ${last_test})
- endif ()
- set (last_test "f03_ex_${example}")
-endforeach ()
+ foreach (example ${F2003_examples})
+ if (HDF5_ENABLE_USING_MEMCHECKER)
+ add_test (NAME f03_ex_${example} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:f03_ex_${example}>)
+ else ()
+ add_test (NAME f03_ex_${example} COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:f03_ex_${example}>"
+ -D "TEST_ARGS:STRING="
+ -D "TEST_EXPECT=0"
+ -D "TEST_SKIP_COMPARE=TRUE"
+ -D "TEST_OUTPUT=f03_ex_${example}.txt"
+ #-D "TEST_REFERENCE=f03_ex_${example}.out"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake"
+ )
+ endif ()
+ set_tests_properties (f03_ex_${example} PROPERTIES FIXTURES_REQUIRED clear_f90_ex)
+ if (last_test)
+ set_tests_properties (f03_ex_${example} PROPERTIES DEPENDS ${last_test})
+ endif ()
+ set (last_test "f03_ex_${example}")
+ endforeach ()
+endif ()
-if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
+if (H5_HAVE_PARALLEL AND HDF5_TEST_PARALLEL AND MPI_Fortran_FOUND)
add_test (NAME MPI_TEST_f90_ex_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:f90_ex_ph5example> ${MPIEXEC_POSTFLAGS})
endif ()
diff --git a/fortran/examples/Makefile.am b/fortran/examples/Makefile.am
index 6bf2edb..fb510bc 100644
--- a/fortran/examples/Makefile.am
+++ b/fortran/examples/Makefile.am
@@ -74,8 +74,8 @@ endif
# Tell automake how to install examples
# Note: no '/' after DESTDIR. Explanation in commence.am
-EXAMPLEDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples/fortran
-EXAMPLETOPDIR=${DESTDIR}$(exec_prefix)/share/hdf5_examples
+EXAMPLEDIR=$(examplesdir)/fortran
+EXAMPLETOPDIR=$(examplesdir)
# List dependencies for each example. Normally, automake would take
# care of this for us, but if we tell automake about the programs it
diff --git a/fortran/examples/run-fortran-ex.sh.in b/fortran/examples/run-fortran-ex.sh.in
index aa17f89..81e54ea 100644
--- a/fortran/examples/run-fortran-ex.sh.in
+++ b/fortran/examples/run-fortran-ex.sh.in
@@ -18,7 +18,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This script will compile and run the fortran examples from source files #
-# installed in .../share/hdf5_examples/fortran using h5fc or h5pfc. The #
+# installed in @examplesdir@/fortran using h5fc or h5pfc. The #
# order for running programs with RunTest in the MAIN section below is taken #
# from the Makefile. The order is important since some of the test programs #
# use data files created by earlier test programs. Any future additions should #
@@ -30,9 +30,32 @@
EXIT_SUCCESS=0
EXIT_FAILURE=1
+#
+# Try to derive the path to the installation $prefix established
+# by ./configure relative to the examples directory established by
+# ./configure. If successful, set `prefix_relto_examplesdir` to the
+# relative path. Otherwise, set `prefix_relto_examplesdir` to the
+# absolute installation $prefix.
+#
+# This script uses the value of `prefix` in the user's environment, if
+# it is set, below. The content of $() is evaluated in a sub-shell, so
+# if `prefix` is set in the user's environment, the shell statements in
+# $() won't clobbered it.
+#
+prefix_relto_examplesdir=$(
+prefix=@prefix@
+examplesdir=@examplesdir@
+if [ ${examplesdir##${prefix}/} != ${examplesdir} ]; then
+ echo $(echo ${examplesdir##${prefix}/} | \
+ sed 's,[^/][^/]*,..,g')
+else
+ echo $prefix
+fi
+)
+
# Where the tool is installed.
# default is relative path to installed location of the tools
-prefix="${prefix:-../../..}"
+prefix="${prefix:-../${prefix_relto_examplesdir}}"
PARALLEL=@PARALLEL@ # Am I in parallel mode?
AR="@AR@"
RANLIB="@RANLIB@"