summaryrefslogtreecommitdiffstats
path: root/fortran/examples/ph5example.f90
diff options
context:
space:
mode:
Diffstat (limited to 'fortran/examples/ph5example.f90')
-rw-r--r--fortran/examples/ph5example.f9018
1 files changed, 16 insertions, 2 deletions
diff --git a/fortran/examples/ph5example.f90 b/fortran/examples/ph5example.f90
index 4f19268..543e6fa 100644
--- a/fortran/examples/ph5example.f90
+++ b/fortran/examples/ph5example.f90
@@ -22,10 +22,11 @@
IMPLICIT NONE
INCLUDE 'mpif.h'
- ! Hard coded the file name. Change it according to where your PFS is.
- CHARACTER(LEN=20), PARAMETER :: filename = "/tmp/sds.h5" ! File name
+ CHARACTER(LEN=10), PARAMETER :: default_fname = "sds.h5" ! Default name
CHARACTER(LEN=8), PARAMETER :: dsetname = "IntArray" ! Dataset name
+ CHARACTER(LEN=100) :: filename ! File name
+ INTEGER :: fnamelen ! File name length
INTEGER(HID_T) :: file_id ! File identifier
INTEGER(HID_T) :: dset_id ! Dataset identifier
INTEGER(HID_T) :: filespace ! Dataspace identifier in file
@@ -73,6 +74,19 @@
CALL h5pset_fapl_mpio_f(plist_id, comm, info, error)
!
+ ! Figure out the filename to use. If your system does not support
+ ! getenv, comment that statement with this,
+ ! filename = ""
+ CALL getenv("HDF5_PARAPREFIX", filename)
+ fnamelen = LEN_TRIM(filename)
+ if ( fnamelen == 0 ) then
+ filename = default_fname
+ else
+ filename = filename(1:fnamelen) // "/" // default_fname
+ endif
+ print *, "Using filename = ", filename
+
+ !
! Create the file collectively.
!
CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error, access_prp = plist_id)