Writes the data describing the cryosphere to the disc as an HDF5
file. h5open_f
must have been called once prior to using this
method. After the method has been used, h5close_f
must be
called once before the end of the program.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(cryosphere), | intent(in) | :: | this | |||
character(len=*), | intent(in) | :: | outfile | The file to which to write the data describing the state of the cryosphere |
subroutine write_data(this,outfile)
!* Author: Christopher MacMackin
! Date: April 2016
!
! Writes the data describing the cryosphere to the disc as an HDF5
! file. `h5open_f` must have been called once prior to using this
! method. After the method has been used, `h5close_f` must be
! called once before the end of the program.
!
class(cryosphere), intent(in) :: this
character(len=*), intent(in) :: outfile
!! The file to which to write the data describing the state of the
!! cryosphere
integer(hid_t) :: file_id, error_code
call h5fcreate_f(outfile, H5F_ACC_TRUNC_F, file_id, error_code)
if (error_code /= 0) then
call logger%error('cryosphere%write_data','Error code '// &
trim(str(error_code))//' returned when '// &
'creating HDF5 file '//outfile)
return
end if
! Write any whole-system data...
call h5ltset_attribute_string_f(file_id,'/',hdf_version,version(),error_code)
call h5ltset_attribute_string_f(file_id,'/',hdf_comp_time,compile_time(), &
error_code)
call h5ltset_attribute_string_f(file_id,'/',hdf_write_time,current_time(), &
error_code)
call h5ltset_attribute_double_f(file_id,'/',hdf_simulation_time,[this%time], &
1_size_t,error_code)
if (error_code /= 0) then
call logger%warning('cryosphere%write_data','Error code '// &
trim(str(error_code))//' returned when '// &
'writing attributes to HDF5 file '//outfile)
end if
! Call for subobjects
call this%ice%write_data(file_id, hdf_glacier, error_code)
call this%sub_ice%write_data(file_id, hdf_basal, error_code)
call h5fclose_f(file_id, error_code)
if (error_code /= 0) then
call logger%warning('cryosphere%write_data','Error code '// &
trim(str(error_code))//' returned when '// &
'closing HDF5 file '//outfile)
end if
#ifdef DEBUG
call logger%debug('cryosphere%write_data','Wrote cryosphere data to '// &
'HDF file '//outfile//' at simulation time '// &
trim(str(this%time)))
#endif
end subroutine write_data