!
! The following example shows how to create a dataset
! that has a string datatype
!

     PROGRAM DSETSTR

     USE HDF5 ! This module contains all necessary modules 
        
     IMPLICIT NONE

     CHARACTER(LEN=8), PARAMETER :: filename = "strf.h5" ! File name
     CHARACTER(LEN=4), PARAMETER :: dsetname = "dset"     ! Dataset name

     INTEGER(HID_T) :: file_id       ! File identifier 
     INTEGER(HID_T) :: dset_id       ! Dataset identifier 
     INTEGER(HID_T) :: dspace_id     ! Dataspace identifier
     INTEGER(HID_T) :: type_id       ! Datatype identifier
     CHARACTER(LEN=13), PARAMETER :: strbuf ="Anthropology "

     INTEGER(HSIZE_T), DIMENSION(1)  :: dimstr


     INTEGER     ::   rank = 2                        ! Dataset rank

     INTEGER     ::   error ! Error flag


     dimstr(1)=1
     !
     ! Initialize FORTRAN predefined datatypes.
     !
     CALL h5open_f(error)

     !
     ! Create a new file using default properties.
     ! 
     CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
     print *, 'h5fcreate_f returns', file_id 


     CALL h5tcopy_f (H5T_NATIVE_CHARACTER, type_id, error)
     print *, 'h5tcopy_f returns', type_id 
     CALL h5tset_size_f (type_id, 13, error)
     print *, 'h5tset_size_f returns', error
     ! 
     ! Create the dataspace.
     !
     CALL h5screate_f (H5S_SCALAR_F, dspace_id, error)
     print *, 'h5screate_f returns', dspace_id 

     !
     ! Create the dataset with default properties.
     !
     CALL h5dcreate_f(file_id, dsetname, type_id, dspace_id, &
                      dset_id, error)
     print *, 'h5dcreate_f returns', dset_id 

     CALL h5dwrite_f (dset_id, type_id, strbuf, dimstr, error)
     print *, 'h5dwrite_f returns', error

     CALL h5tclose_f(type_id, error)
     print *, 'h5tclose_f returns', error
     CALL h5dclose_f(dset_id, error)
     print *, 'h5dclose_f returns', error
     CALL h5sclose_f(dspace_id, error)
     print *, 'h5sclose_f returns', error
     CALL h5fclose_f(file_id, error)
     print *, 'h5fclose_f returns', error

     !
     ! Close FORTRAN predefined datatypes.
     !
     CALL h5close_f(error)

     END PROGRAM DSETSTR
     
 
