initializing and closing the HDF5 library

This commit is contained in:
Martin Diehl 2018-10-09 14:13:51 +02:00
parent e7e0cf7118
commit 48403c37b7
3 changed files with 25 additions and 19 deletions

View File

@ -37,6 +37,8 @@ subroutine CPFEM_initAll(el,ip)
mesh_init
use material, only: &
material_init
use HDF5_utilities, only: &
HDF5_utilities_init
use lattice, only: &
lattice_init
use constitutive, only: &
@ -72,6 +74,7 @@ subroutine CPFEM_initAll(el,ip)
call mesh_init(ip, el) ! pass on coordinates to alter calcMode of first ip
call lattice_init
call material_init
call HDF5_utilities_init
call constitutive_init
call crystallite_init
call homogenization_init

View File

@ -58,8 +58,19 @@ subroutine HDF5_Utilities_init
write(6,'(/,a)') ' <<<+- HDF5_Utilities init -+>>>'
#include "compilation_info.f90"
currentInc = -1_pInt
call HDF5_createJobFile
!currentInc = -1_pInt ToDo
!call HDF5_createJobFile ToDo
!--------------------------------------------------------------------------------------------------
!initialize HDF5 library and check if integer and float type size match
call h5open_f(hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_Utilities_init: h5open_f')
call h5tget_size_f(H5T_NATIVE_INTEGER,typeSize, hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_Utilities_init: h5tget_size_f (int)')
if (int(pInt,SIZE_T)/=typeSize) call IO_error(0_pInt,ext_msg='pInt does not match H5T_NATIVE_INTEGER')
call h5tget_size_f(H5T_NATIVE_DOUBLE,typeSize, hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_Utilities_init: h5tget_size_f (double)')
if (int(pReal,SIZE_T)/=typeSize) call IO_error(0_pInt,ext_msg='pReal does not match H5T_NATIVE_DOUBLE')
end subroutine HDF5_Utilities_init
@ -74,23 +85,11 @@ subroutine HDF5_createJobFile
implicit none
integer :: hdferr
integer(SIZE_T) :: typeSize
character(len=1024) :: path
#ifdef PETSc
#include <petsc/finclude/petscsys.h>
#endif
!--------------------------------------------------------------------------------------------------
!initialize HDF5 library and check if integer and float type size match
call h5open_f(hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_Utilities_init: h5open_f')
call h5tget_size_f(H5T_NATIVE_INTEGER,typeSize, hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_Utilities_init: h5tget_size_f (int)')
if (int(pInt,SIZE_T)/=typeSize) call IO_error(0_pInt,ext_msg='pInt does not match H5T_NATIVE_INTEGER')
call h5tget_size_f(H5T_NATIVE_DOUBLE,typeSize, hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_Utilities_init: h5tget_size_f (double)')
if (int(pReal,SIZE_T)/=typeSize) call IO_error(0_pInt,ext_msg='pReal does not match H5T_NATIVE_DOUBLE')
#ifdef PETSc
call h5pcreate_f(H5P_FILE_ACCESS_F, plist_id, hdferr)
@ -157,7 +156,7 @@ subroutine HDF5_closeJobFile()
call HDF5_removeLink('current')
call h5fclose_f(resultsFile,hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_closeJobFile: h5fclose_f',el=hdferr)
call h5close_f(hdferr)
! call h5close_f(hdferr)
end subroutine HDF5_closeJobFile
@ -171,8 +170,6 @@ integer(HID_T) function HDF5_openFile(filePath)
integer :: hdferr
character(len=*), intent(in) :: filePath
call h5open_f(hdferr)!############################################################ DANGEROUS
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_openFile: h5open_f',el=hdferr)
call h5fopen_f(filePath,H5F_ACC_RDONLY_F,HDF5_openFile,hdferr)
if (hdferr < 0) call IO_error(1_pInt,ext_msg='HDF5_openFile: h5fopen_f',el=hdferr)

View File

@ -14,18 +14,24 @@ subroutine quit(stop_id)
use prec, only: &
pInt
use PetscSys
use hdf5
implicit none
integer(pInt), intent(in) :: stop_id
integer, dimension(8) :: dateAndTime ! type default integer
integer :: hdferr
integer(pInt) :: error = 0_pInt
PetscErrorCode :: ierr = 0
call h5close_f(hdferr)
if (hdferr /= 0) write(6,'(a,i5)') ' Error in h5close_f',hdferr
call PETScFinalize(ierr)
CHKERRQ(ierr)
#ifdef _OPENMP
call MPI_finalize(error)
if (error /= 0) write(6,'(a)') ' Error in MPI_finalize'
if (error /= 0) write(6,'(a,i5)') ' Error in MPI_finalize',error
#endif
call date_and_time(values = dateAndTime)