Started HDF5 interface.

This commit is contained in:
Paul Romano 2012-01-17 13:13:39 -05:00
parent 6c0f36eedf
commit 4bc81d501d
6 changed files with 116 additions and 5 deletions

View file

@ -67,6 +67,9 @@ global.o: source_header.o
global.o: tally_header.o
global.o: timing.o
hdf5_interface.o: constants.o
hdf5_interface.o: global.o
initialize.o: ace.o
initialize.o: bank_header.o
initialize.o: constants.o
@ -77,6 +80,7 @@ initialize.o: error.o
initialize.o: geometry.o
initialize.o: geometry_header.o
initialize.o: global.o
initialize.o: hdf5_interface.o
initialize.o: input_xml.o
initialize.o: output.o
initialize.o: random_lcg.o
@ -117,6 +121,7 @@ interpolation.o: string.o
main.o: constants.o
main.o: global.o
main.o: hdf5_interface.o
main.o: initialize.o
main.o: intercycle.o
main.o: output.o

View file

@ -14,6 +14,7 @@ fission.o \
geometry.o \
geometry_header.o \
global.o \
hdf5_interface.o \
initialize.o \
intercycle.o \
interpolation.o \

View file

@ -17,6 +17,10 @@ module global
use mpi
#endif
#ifdef HDF5
use hdf5
#endif
implicit none
save
@ -163,6 +167,13 @@ module global
real(8) :: plot_basis(6)
real(8) :: pixel
! ============================================================================
! HDF5 VARIABLES
#ifdef HDF5
integer(HID_T) :: hdf5_output_file
#endif
! ============================================================================
! MISCELLANEOUS VARIABLES

72
src/hdf5_interface.F90 Normal file
View file

@ -0,0 +1,72 @@
module hdf5_interface
use constants
use global
#ifdef HDF5
use hdf5, only: HSIZE_T, h5open_f, h5fcreate_f, h5fclose_f, h5close_f
use h5lt, only: h5ltmake_dataset_int_f
#endif
implicit none
contains
#ifdef HDF5
!===============================================================================
! OPEN_HDF5_OUTPUT
!===============================================================================
subroutine open_hdf5_output()
character(9), parameter :: filename = "output.h5" ! File name
integer :: error ! Error flag
! Initialize FORTRAN interface.
call h5open_f (error)
! Create a new file using default properties.
call h5fcreate_f(filename, H5F_ACC_TRUNC_F, hdf5_output_file, error)
end subroutine open_hdf5_output
!===============================================================================
! WRITE_HDF5_SUMMARY
!===============================================================================
subroutine write_hdf5_summary()
integer :: error ! Error flag
integer :: rank = 1
integer(HSIZE_T) :: dims(1) = (/1/)
! Write version information
call h5ltmake_dataset_int_f(hdf5_output_file, "/version_major", rank, &
dims, (/ VERSION_MAJOR /), error)
call h5ltmake_dataset_int_f(hdf5_output_file, "/version_minor", rank, &
dims, (/ VERSION_MINOR /), error)
call h5ltmake_dataset_int_f(hdf5_output_file, "/version_release", rank, &
dims, (/ VERSION_RELEASE /), error)
end subroutine write_hdf5_summary
!===============================================================================
! CLOSE_HDF5_OUTPUT
!===============================================================================
subroutine close_hdf5_output()
integer :: error ! Error flag
! Terminate access to the file.
call h5fclose_f(hdf5_output_file, error)
! Close FORTRAN interface.
call h5close_f(error)
end subroutine close_hdf5_output
#endif
end module hdf5_interface

View file

@ -25,6 +25,10 @@ module initialize
use mpi
#endif
#ifdef HDF5
use hdf5_interface, only: open_hdf5_output
#endif
implicit none
type(DictionaryII), pointer :: build_dict => null()
@ -50,13 +54,20 @@ contains
! Read command line arguments
call read_command_line()
if (master) call create_summary_file()
! Print the OpenMC title and version/date/time information
if (master) call title()
if (master) then
! Create summary.out file
call create_summary_file()
! Print initialization header block
if (master) call header("INITIALIZATION", level=1)
#ifdef HDF5
! Open HDF5 output file for writing
call open_hdf5_output()
#endif
! Display title and initialization header
call title()
call header("INITIALIZATION", level=1)
end if
! Initialize random number generator
call initialize_prng()

View file

@ -19,6 +19,10 @@ program main
use mpi
#endif
#ifdef HDF5
use hdf5_interface, only: write_hdf5_summary, close_hdf5_output
#endif
implicit none
! start timer for total run time
@ -45,6 +49,13 @@ program main
! deallocate arrays
call free_memory()
#ifdef HDF5
if (master) then
call write_hdf5_summary()
call close_hdf5_output()
end if
#endif
#ifdef MPI
! If MPI is in use and enabled, terminate it
call MPI_FINALIZE(mpi_err)