summaryrefslogtreecommitdiffstats
path: root/fortran/examples
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2015-08-14 19:58:54 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2015-08-14 19:58:54 (GMT)
commitc27d1808480a4ffae4af5ff5384993f63ea6b5d4 (patch)
tree251081393f02ad4fb6767af9d23be50971761d79 /fortran/examples
parent37b14fd3ed8aae8f3b83df03ca29f82178c25f8f (diff)
parentd3e931c772a1fea1d8d0676dd6dd3fe95b000d9e (diff)
downloadhdf5-c27d1808480a4ffae4af5ff5384993f63ea6b5d4.zip
hdf5-c27d1808480a4ffae4af5ff5384993f63ea6b5d4.tar.gz
hdf5-c27d1808480a4ffae4af5ff5384993f63ea6b5d4.tar.bz2
[svn-r27507] Merge of r27237-27500 from the trunk.
Tested w/ h5committest NOTES: - The manifest may still be messed up. - Cmake fails since the dual binary work needs to be merged with this repo's CMake externals.
Diffstat (limited to 'fortran/examples')
-rw-r--r--fortran/examples/CMakeLists.txt82
-rw-r--r--fortran/examples/CMakeTests.cmake41
-rw-r--r--fortran/examples/Makefile.am12
-rw-r--r--fortran/examples/nested_derived_type.f9012
-rw-r--r--fortran/examples/rwdset_fortran2003.f9024
5 files changed, 126 insertions, 45 deletions
diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt
index 2bf0bf6..f2dc896 100644
--- a/fortran/examples/CMakeLists.txt
+++ b/fortran/examples/CMakeLists.txt
@@ -40,8 +40,8 @@ set (F2003_examples
foreach (example ${examples})
add_executable (f90_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90)
- TARGET_NAMING (f90_ex_${example} ${LIB_TYPE})
- TARGET_FORTRAN_PROPERTIES (f90_ex_${example} ${LIB_TYPE} " " " ")
+ TARGET_NAMING (f90_ex_${example} STATIC)
+ TARGET_FORTRAN_PROPERTIES (f90_ex_${example} STATIC " " " ")
target_link_libraries (f90_ex_${example}
${HDF5_F90_LIB_TARGET}
${HDF5_LIB_TARGET}
@@ -50,32 +50,60 @@ foreach (example ${examples})
set_target_properties (f90_ex_${example} PROPERTIES
LINKER_LANGUAGE Fortran
FOLDER examples/fortran
- Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
+ Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static
)
+ if (BUILD_SHARED_LIBS)
+ add_executable (f90_ex_${example}-shared ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90)
+ TARGET_NAMING (f90_ex_${example}-shared SHARED)
+ TARGET_FORTRAN_PROPERTIES (f90_ex_${example}-shared SHARED " " " ")
+ target_link_libraries (f90_ex_${example}-shared
+ ${HDF5_F90_LIBSH_TARGET}
+ ${HDF5_LIBSH_TARGET}
+ )
+ target_include_directories (f90_ex_${example}-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared)
+ set_target_properties (f90_ex_${example}-shared PROPERTIES
+ LINKER_LANGUAGE Fortran
+ FOLDER examples/fortran
+ Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared
+ )
+ endif (BUILD_SHARED_LIBS)
endforeach (example ${examples})
-if (HDF5_ENABLE_F2003)
- foreach (example ${F2003_examples})
- add_executable (f03_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90)
- TARGET_NAMING (f03_ex_${example} ${LIB_TYPE})
- TARGET_FORTRAN_PROPERTIES (f03_ex_${example} ${LIB_TYPE} " " " ")
- target_link_libraries (f03_ex_${example}
- ${HDF5_F90_LIB_TARGET}
- ${HDF5_LIB_TARGET}
+foreach (example ${F2003_examples})
+ add_executable (f03_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90)
+ TARGET_NAMING (f03_ex_${example} STATIC)
+ TARGET_FORTRAN_PROPERTIES (f03_ex_${example} STATIC " " " ")
+ target_link_libraries (f03_ex_${example}
+ ${HDF5_F90_LIB_TARGET}
+ ${HDF5_LIB_TARGET}
+ )
+ target_include_directories (f03_ex_${example} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static)
+ set_target_properties (f03_ex_${example} PROPERTIES
+ LINKER_LANGUAGE Fortran
+ FOLDER examples/fortran03
+ Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
+ )
+ if (BUILD_SHARED_LIBS)
+ add_executable (f03_ex_${example}-shared ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90)
+ TARGET_NAMING (f03_ex_${example}-shared SHARED)
+ TARGET_FORTRAN_PROPERTIES (f03_ex_${example}-shared SHARED " " " ")
+ target_link_libraries (f03_ex_${example}-shared
+ ${HDF5_F90_LIBSH_TARGET}
+ ${HDF5_LIBSH_TARGET}
)
- target_include_directories (f03_ex_${example} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static)
- set_target_properties (f03_ex_${example} PROPERTIES
+ target_include_directories (f03_ex_${example}-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared)
+ set_target_properties (f03_ex_${example}-shared PROPERTIES
LINKER_LANGUAGE Fortran
FOLDER examples/fortran03
- Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
+ Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared
)
- endforeach (example ${F2003_examples})
-endif (HDF5_ENABLE_F2003)
+ endif (BUILD_SHARED_LIBS)
+endforeach (example ${F2003_examples})
if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
add_executable (f90_ex_ph5example ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90)
- TARGET_NAMING (f90_ex_ph5example ${LIB_TYPE})
- TARGET_FORTRAN_PROPERTIES (f90_ex_ph5example ${LIB_TYPE} " " " ")
+ TARGET_NAMING (f90_ex_ph5example STATIC)
+ TARGET_FORTRAN_PROPERTIES (f90_ex_ph5example STATIC " " " ")
target_link_libraries (f90_ex_ph5example
${HDF5_F90_LIB_TARGET}
${HDF5_LIB_TARGET}
@@ -85,8 +113,24 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
set_target_properties (f90_ex_ph5example PROPERTIES
LINKER_LANGUAGE Fortran
FOLDER examples/fortran
- Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
+ Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static
)
+ if (BUILD_SHARED_LIBS)
+ add_executable (f90_ex_ph5example-shared ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90)
+ TARGET_NAMING (f90_ex_ph5example-shared SHARED)
+ TARGET_FORTRAN_PROPERTIES (f90_ex_ph5example-shared SHARED " " " ")
+ target_link_libraries (f90_ex_ph5example-shared
+ ${HDF5_F90_LIBSH_TARGET}
+ ${HDF5_LIBSH_TARGET}
+ ${MPI_Fortran_LIBRARIES}
+ )
+ target_include_directories (f90_ex_ph5example-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared)
+ set_target_properties (f90_ex_ph5example-shared PROPERTIES
+ LINKER_LANGUAGE Fortran
+ FOLDER examples/fortran
+ Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared
+ )
+ endif (BUILD_SHARED_LIBS)
endif (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
if (BUILD_TESTING)
diff --git a/fortran/examples/CMakeTests.cmake b/fortran/examples/CMakeTests.cmake
index 57aec53..173984c 100644
--- a/fortran/examples/CMakeTests.cmake
+++ b/fortran/examples/CMakeTests.cmake
@@ -28,6 +28,30 @@
set_tests_properties (f90_ex-clear-objects PROPERTIES DEPENDS ${last_test})
endif (NOT "${last_test}" STREQUAL "")
set (last_test "f90_ex-clear-objects")
+ if (BUILD_SHARED_LIBS)
+ add_test (
+ NAME f90_ex-shared-clear-objects
+ COMMAND ${CMAKE_COMMAND}
+ -E remove
+ 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
+ )
+ if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (f90_ex-shared-clear-objects PROPERTIES DEPENDS ${last_test})
+ endif (NOT "${last_test}" STREQUAL "")
+ set (last_test "f90_ex-shared-clear-objects")
+ endif (BUILD_SHARED_LIBS)
foreach (example ${examples})
add_test (NAME f90_ex_${example} COMMAND $<TARGET_FILE:f90_ex_${example}>)
@@ -35,6 +59,13 @@ foreach (example ${examples})
set_tests_properties (f90_ex_${example} PROPERTIES DEPENDS ${last_test})
endif (NOT "${last_test}" STREQUAL "")
set (last_test "f90_ex_${example}")
+ if (BUILD_SHARED_LIBS)
+ add_test (NAME f90_ex-shared_${example} COMMAND $<TARGET_FILE:f90_ex_${example}-shared>)
+ if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (f90_ex-shared_${example} PROPERTIES DEPENDS ${last_test})
+ endif (NOT "${last_test}" STREQUAL "")
+ set (last_test "f90_ex-shared_${example}")
+ endif (BUILD_SHARED_LIBS)
endforeach (example ${examples})
if (HDF5_ENABLE_F2003)
@@ -44,9 +75,19 @@ if (HDF5_ENABLE_F2003)
set_tests_properties (f03_ex_${example} PROPERTIES DEPENDS ${last_test})
endif (NOT "${last_test}" STREQUAL "")
set (last_test "f03_ex_${example}")
+ if (BUILD_SHARED_LIBS)
+ add_test (NAME f03_ex-shared_${example} COMMAND $<TARGET_FILE:f03_ex_${example}-shared>)
+ if (NOT "${last_test}" STREQUAL "")
+ set_tests_properties (f03_ex-shared_${example} PROPERTIES DEPENDS ${last_test})
+ endif (NOT "${last_test}" STREQUAL "")
+ set (last_test "f03_ex-shared_${example}")
+ endif (BUILD_SHARED_LIBS)
endforeach (example ${F2003_examples})
endif (HDF5_ENABLE_F2003)
if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
add_test (NAME f90_ex_ph5example COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $<TARGET_FILE:f90_ex_ph5example>)
+ if (BUILD_SHARED_LIBS)
+ add_test (NAME f90_ex-shared_ph5example COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $<TARGET_FILE:f90_ex_ph5example>)
+ endif (BUILD_SHARED_LIBS)
endif (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND)
diff --git a/fortran/examples/Makefile.am b/fortran/examples/Makefile.am
index caaa08c..cdd9317 100644
--- a/fortran/examples/Makefile.am
+++ b/fortran/examples/Makefile.am
@@ -46,12 +46,10 @@ INSTALL_FILES=h5_crtdat.f90 h5_rdwt.f90 \
# Add attention tests for Fortran 2003 features
-if FORTRAN_2003_CONDITIONAL_F
- EXAMPLE_PROG += rwdset_fortran2003 nested_derived_type \
- compound_fortran2003 compound_complex_fortran2003
- INSTALL_FILES += rwdset_fortran2003.f90 nested_derived_type.f90 \
- compound_fortran2003.f90 compound_complex_fortran2003.f90
-endif
+EXAMPLE_PROG += rwdset_fortran2003 nested_derived_type \
+ compound_fortran2003 compound_complex_fortran2003
+INSTALL_FILES += rwdset_fortran2003.f90 nested_derived_type.f90 \
+ compound_fortran2003.f90 compound_complex_fortran2003.f90
TEST_SCRIPT=testh5fc.sh
TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES)
@@ -103,12 +101,10 @@ refregexample: refregexample.f90
mountexample: mountexample.f90
compound: compound.f90
ph5example: ph5example.f90
-if FORTRAN_2003_CONDITIONAL_F
rwdset_fortran2003: rwdset_fortran2003.f90
nested_derived_type: nested_derived_type.f90
compound_fortran2003: compound_fortran2003.f90
compound_complex_fortran2003: compound_complex_fortran2003.f90
-endif
include $(top_srcdir)/config/examples.am
include $(top_srcdir)/config/conclude.am
diff --git a/fortran/examples/nested_derived_type.f90 b/fortran/examples/nested_derived_type.f90
index f806110..65e7e75 100644
--- a/fortran/examples/nested_derived_type.f90
+++ b/fortran/examples/nested_derived_type.f90
@@ -23,13 +23,13 @@ PROGRAM main
IMPLICIT NONE
! KIND parameters
- INTEGER, PARAMETER :: int_k1 = SELECTED_INT_KIND(Fortran_INTEGER_1) ! This should map to INTEGER*1 on most modern processors
- INTEGER, PARAMETER :: int_k4 = SELECTED_INT_KIND(Fortran_INTEGER_2) ! This should map to INTEGER*2 on most modern processors
- INTEGER, PARAMETER :: int_k8 = SELECTED_INT_KIND(Fortran_INTEGER_4) ! This should map to INTEGER*4 on most modern processors
- INTEGER, PARAMETER :: int_k16 = SELECTED_INT_KIND(Fortran_INTEGER_8) ! This should map to INTEGER*8 on most modern processors
+ INTEGER, PARAMETER :: int_k1 = SELECTED_INT_KIND(2) ! This should map to INTEGER*1 on most modern processors
+ INTEGER, PARAMETER :: int_k4 = SELECTED_INT_KIND(4) ! This should map to INTEGER*2 on most modern processors
+ INTEGER, PARAMETER :: int_k8 = SELECTED_INT_KIND(9) ! This should map to INTEGER*4 on most modern processors
+ INTEGER, PARAMETER :: int_k16 = SELECTED_INT_KIND(18) ! This should map to INTEGER*8 on most modern processors
- INTEGER, PARAMETER :: r_k4 = SELECTED_REAL_KIND(Fortran_REAL_4) ! This should map to REAL*4 on most modern processors
- INTEGER, PARAMETER :: r_k8 = SELECTED_REAL_KIND(Fortran_REAL_8) ! This should map to REAL*8 on most modern processors
+ INTEGER, PARAMETER :: r_k4 = SELECTED_REAL_KIND(6,37) ! This should map to REAL*4 on most modern processors
+ INTEGER, PARAMETER :: r_k8 = SELECTED_REAL_KIND(15,307) ! This should map to REAL*8 on most modern processors
! FILES
diff --git a/fortran/examples/rwdset_fortran2003.f90 b/fortran/examples/rwdset_fortran2003.f90
index d65db9e..682676f 100644
--- a/fortran/examples/rwdset_fortran2003.f90
+++ b/fortran/examples/rwdset_fortran2003.f90
@@ -28,13 +28,13 @@ PROGRAM RWDSET_FORTRAN2003
IMPLICIT NONE
- INTEGER, PARAMETER :: int_kind_1 = SELECTED_INT_KIND(Fortran_INTEGER_1) !should map to INTEGER*1 on most modern processors
- INTEGER, PARAMETER :: int_kind_4 = SELECTED_INT_KIND(Fortran_INTEGER_2) !should map to INTEGER*2 on most modern processors
- INTEGER, PARAMETER :: int_kind_8 = SELECTED_INT_KIND(Fortran_INTEGER_4) !should map to INTEGER*4 on most modern processors
- INTEGER, PARAMETER :: int_kind_16 = SELECTED_INT_KIND(Fortran_INTEGER_8) !should map to INTEGER*8 on most modern processors
+ INTEGER, PARAMETER :: int_kind_1 = SELECTED_INT_KIND(2) !should map to INTEGER*1 on most modern processors
+ INTEGER, PARAMETER :: int_kind_4 = SELECTED_INT_KIND(4) !should map to INTEGER*2 on most modern processors
+ INTEGER, PARAMETER :: int_kind_8 = SELECTED_INT_KIND(9) !should map to INTEGER*4 on most modern processors
+ INTEGER, PARAMETER :: int_kind_16 = SELECTED_INT_KIND(18) !should map to INTEGER*8 on most modern processors
- INTEGER, PARAMETER :: real_kind_7 = SELECTED_REAL_KIND(Fortran_REAL_4) !should map to REAL*4 on most modern processors
- INTEGER, PARAMETER :: real_kind_15 = SELECTED_REAL_KIND(Fortran_REAL_8) !should map to REAL*8 on most modern processors
+ INTEGER, PARAMETER :: real_kind_7 = SELECTED_REAL_KIND(6,37) !should map to REAL*4 on most modern processors
+ INTEGER, PARAMETER :: real_kind_15 = SELECTED_REAL_KIND(15,307) !should map to REAL*8 on most modern processors
CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name
CHARACTER(LEN=5), PARAMETER :: dsetname1 = "dset1" ! Dataset name
@@ -148,12 +148,12 @@ PROGRAM RWDSET_FORTRAN2003
CALL h5dread_f(dset_idr8, h5kind_to_type(real_kind_15,H5_REAL_KIND), f_ptr, error)
! memory type
- WRITE(*,'(A,4i8)' )'SELECTED_INT_KIND(Fortran_INTEGER_1): ',data_out_i8a
- WRITE(*,'(A,4i8)' )'SELECTED_INT_KIND(Fortran_INTEGER_4): ',data_out_i4
- WRITE(*,'(A,4i8)' )'SELECTED_INT_KIND(Fortran_INTEGER_8): ',data_out_i8
- WRITE(*,'(A,4i8)' )'SELECTED_INT_KIND(Fortran_INTEGER_16): ',data_out_i16
- WRITE(*,'(A,4(1x,f9.4))' )'SELECTED_REAL_KIND(Fortran_REAL_7): ',data_out_r7
- WRITE(*,'(A,4(1x,f16.10))' )'SELECTED_REAL_KIND(Fortran_REAL_15): ',data_out_r15
+ WRITE(*,'(A,4i8)' )'SELECTED_INT_KIND(2): ',data_out_i8a
+ WRITE(*,'(A,4i8)' )'SELECTED_INT_KIND(4): ',data_out_i4
+ WRITE(*,'(A,4i8)' )'SELECTED_INT_KIND(9): ',data_out_i8
+ WRITE(*,'(A,4i8)' )'SELECTED_INT_KIND(18): ',data_out_i16
+ WRITE(*,'(A,4(1x,f9.4))' )'SELECTED_REAL_KIND(6,37): ',data_out_r7
+ WRITE(*,'(A,4(1x,f16.10))' )'SELECTED_REAL_KIND(15,307): ',data_out_r15
!
! Close the dataset.
!