IO: Rewrite write_snapshot_h5().
Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
parent
ff4f600922
commit
3987c45cfe
@ -799,7 +799,7 @@ module io
|
|||||||
select case(snapshot_format)
|
select case(snapshot_format)
|
||||||
#ifdef HDF5
|
#ifdef HDF5
|
||||||
case(snapshot_hdf5)
|
case(snapshot_hdf5)
|
||||||
call write_snapshot_h5(problem)
|
call write_snapshot_h5(problem, status)
|
||||||
if (with_xdmf) then
|
if (with_xdmf) then
|
||||||
call write_snapshot_xdmf()
|
call write_snapshot_xdmf()
|
||||||
if (master) call write_snapshot_xdmf_master()
|
if (master) call write_snapshot_xdmf_master()
|
||||||
@ -3879,99 +3879,51 @@ module io
|
|||||||
! subroutine WRITE_SNAPSHOT_H5:
|
! subroutine WRITE_SNAPSHOT_H5:
|
||||||
! ----------------------------
|
! ----------------------------
|
||||||
!
|
!
|
||||||
! Subroutine writes the current simulation snapshot, i.e. parameters,
|
! Subroutine stores the current simulation snapshot, i.e. parameters,
|
||||||
! coordinates and variables to the HDF5 format files for further processing.
|
! coordinates and variables as the HDF5 file.
|
||||||
!
|
!
|
||||||
! Arguments:
|
! Arguments:
|
||||||
!
|
!
|
||||||
! problem - the problem's name;
|
! problem - the problem's name;
|
||||||
|
! status - the subroutine call status;
|
||||||
!
|
!
|
||||||
!===============================================================================
|
!===============================================================================
|
||||||
!
|
!
|
||||||
subroutine write_snapshot_h5(problem)
|
subroutine write_snapshot_h5(problem, status)
|
||||||
|
|
||||||
use hdf5 , only : hid_t
|
use hdf5
|
||||||
use hdf5 , only : H5F_ACC_TRUNC_F, H5F_SCOPE_GLOBAL_F
|
use helpers , only : print_message
|
||||||
use hdf5 , only : h5fcreate_f, h5fflush_f, h5fclose_f
|
use mpitools, only : nproc
|
||||||
use iso_fortran_env, only : error_unit
|
|
||||||
use mpitools , only : nproc
|
|
||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
character(len=*), intent(in) :: problem
|
character(len=*), intent(in) :: problem
|
||||||
|
integer , intent(out) :: status
|
||||||
|
|
||||||
character(len=64) :: fl
|
character(len=255) :: fname
|
||||||
integer(hid_t) :: fid
|
integer(hid_t) :: fid
|
||||||
integer :: err
|
|
||||||
|
|
||||||
character(len=*), parameter :: loc = 'IO::write_snapshot_h5()'
|
character(len=*), parameter :: loc = 'IO::write_snapshot_h5()'
|
||||||
|
|
||||||
!-------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------
|
||||||
!
|
!
|
||||||
! prepare the restart snapshot filename
|
write(fname,"('p',i6.6,'_',i5.5,'.h5')") isnap, nproc
|
||||||
!
|
|
||||||
write (fl, "(a1,i6.6,'_',i5.5,'.h5')") ftype, isnap, nproc
|
|
||||||
|
|
||||||
! create the new HDF5 file to store the snapshot
|
call h5fcreate_f(fname, H5F_ACC_TRUNC_F, fid, status)
|
||||||
!
|
if (status < 0) then
|
||||||
call h5fcreate_f(fl, H5F_ACC_TRUNC_F, fid, err)
|
call print_message(loc, "Could not create file " // trim(fname))
|
||||||
|
|
||||||
! if the file could not be created, print message and quit
|
|
||||||
!
|
|
||||||
if (err < 0) then
|
|
||||||
write(error_unit,"('[',a,']: ',a)") trim(loc) &
|
|
||||||
, "Cannot create file: " // trim(fl)
|
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
! write the global attributes
|
|
||||||
!
|
|
||||||
call write_attributes_h5(fid, problem)
|
call write_attributes_h5(fid, problem)
|
||||||
|
|
||||||
! write the coordinates (data block bounds, refinement levels, etc.)
|
|
||||||
!
|
|
||||||
call write_coordinates_h5(fid)
|
call write_coordinates_h5(fid)
|
||||||
|
|
||||||
! depending on the selected type of output file write the right groups
|
|
||||||
!
|
|
||||||
select case(ftype)
|
|
||||||
|
|
||||||
case('c')
|
|
||||||
|
|
||||||
! write the variables stored in data blocks (leafs)
|
|
||||||
!
|
|
||||||
call write_conservative_variables_h5(fid)
|
|
||||||
|
|
||||||
case('p')
|
|
||||||
|
|
||||||
! write the variables stored in data blocks (leafs)
|
|
||||||
!
|
|
||||||
call write_primitive_variables_h5(fid)
|
call write_primitive_variables_h5(fid)
|
||||||
|
|
||||||
case default
|
call h5fclose_f(fid, status)
|
||||||
|
if (status > 0) then
|
||||||
! print information about unsupported file format and quit
|
call print_message(loc, "Could not close file " // trim(fname))
|
||||||
!
|
|
||||||
write(error_unit,"('[',a,']: ',a)") trim(loc) &
|
|
||||||
, "File type is not suppoerted!"
|
|
||||||
call h5fclose_f(fid, err)
|
|
||||||
return
|
|
||||||
|
|
||||||
end select
|
|
||||||
|
|
||||||
! flush the file
|
|
||||||
!
|
|
||||||
call h5fflush_f(fid, H5F_SCOPE_GLOBAL_F, err)
|
|
||||||
|
|
||||||
! close the file
|
|
||||||
!
|
|
||||||
call h5fclose_f(fid, err)
|
|
||||||
|
|
||||||
! if the file could not be closed print message and quit
|
|
||||||
!
|
|
||||||
if (err > 0) then
|
|
||||||
write(error_unit,"('[',a,']: ',a)") trim(loc) &
|
|
||||||
, "Cannot close file: " // trim(fl)
|
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user