[Dart-dev] DART/branches Revision: 12326

dart at ucar.edu dart at ucar.edu
Fri Jan 12 14:48:23 MST 2018


thoar at ucar.edu
2018-01-12 14:48:23 -0700 (Fri, 12 Jan 2018)
304
readhdf5lt  can actually read a variable from hdf5 on my OSX software stack.
SMAP_L2_to_obs.f90 uses the same calls ... but is not nearly complete and
still has TONS of baggage from the netCDF origins.

The HDF5_utilities_mod.f90 is more of a hope than anything at this point.
Incremental improvements.




Modified: DART/branches/cesm_clm/assimilation_code/modules/utilities/HDF5_utilities_mod.f90
===================================================================
--- DART/branches/cesm_clm/assimilation_code/modules/utilities/HDF5_utilities_mod.f90	2018-01-12 21:36:51 UTC (rev 12325)
+++ DART/branches/cesm_clm/assimilation_code/modules/utilities/HDF5_utilities_mod.f90	2018-01-12 21:48:23 UTC (rev 12326)
@@ -7,7 +7,7 @@
 module HDF5_utilities_mod
 
 use        types_mod, only : i2, i4, r4, r8, MISSING_R8, MISSING_I
-use    utilities_mod, only : nc_check, E_MSG, E_ERR, error_handler
+use    utilities_mod, only : register_module, E_MSG, E_ERR, error_handler
 use time_manager_mod, only : time_type, operator(>=), set_time, get_time
 
 use HDF5
@@ -15,9 +15,8 @@
 implicit none
 private
 
-public :: H5_CRTDAT, H5_RDWT, h5_get_rank, h5_get_dimensions
+public :: h5_open, H5_CRTDAT, H5_RDWT, h5_get_rank, h5_get_dimensions
 
-
 ! interface hf_get_var
 !    module procedure hf_get_int_1d
 !    module procedure hf_get_real_1d
@@ -31,10 +30,53 @@
 
 character(len=512) :: string1, string2, string3
 
+logical :: module_initialized = .false.
 
+
 contains
 
 
+!-----------------------------------------------------------------------
+!> initialize the Fortran interface to HDF5
+
+subroutine initialize_module()
+
+integer :: hdferr
+
+if (module_initialized) return
+
+call register_module(source, revision, revdate)
+module_initialized = .true.
+
+! initialize the Fortran interface
+call h5open_f(hdferr)
+call h5_check(hdferr,'initialize_module','h5open_f','initializing Fortran interfaces') 
+
+end subroutine initialize_module 
+
+
+!-----------------------------------------------------------------------
+!>
+
+function h5_open(filename, flag, context) result(file_id)
+
+character(len=*),           intent(in) :: filename
+integer(HID_T),             intent(in) :: flag
+character(len=*), optional, intent(in) :: context
+integer(HID_T)                         :: file_id
+
+
+integer :: hdferr
+
+call h5fopen_f(filename, flag, file_id, hdferr)
+call h5_check(hdferr,'h5_open','h5fopen_f', context, filename)
+
+end function h5_open
+
+
+!-----------------------------------------------------------------------
+!>
+
 function h5_get_rank(dspace_id, error) result(rank)
 
 integer(HID_T), intent(in)  :: dspace_id
@@ -48,6 +90,8 @@
 end function h5_get_rank
 
 
+!-----------------------------------------------------------------------
+!>
 
 subroutine h5_get_dimensions(dspace_id, dims, error)
 
@@ -65,8 +109,33 @@
 
 end subroutine h5_get_dimensions
 
+!------------------------------------------------------------------
+!> check return code from previous call. on error, print and stop.
+!> if you want to continue after an error don't use this call. 
 
+subroutine h5_check(istatus, subr_name, h5routine, context, filename)
 
+integer,          intent(in)           :: istatus
+character(len=*), intent(in)           :: subr_name
+character(len=*), intent(in)           :: h5routine
+character(len=*), intent(in)           :: context


More information about the Dart-dev mailing list