-
Notifications
You must be signed in to change notification settings - Fork 3
/
io_hdf5_a.F90
97 lines (69 loc) · 2.18 KB
/
io_hdf5_a.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
! ADIOS is freely available under the terms of the BSD license described
! in the COPYING file in the top level directory of this source distribution.
!
! Copyright (c) 2008 - 2009. UT-BATTELLE, LLC. All rights reserved.
!
!
! HDF5 based I/O for the heat_transfer example,
! producing one file per process per step
!
! (c) Oak Ridge National Laboratory, 2014
! Author: Jeremy Logan
!
module heat_io
contains
subroutine io_init()
use heat_vars
use HDF5
! Initialize FORTRAN interface
call h5open_f(err)
end subroutine io_init
subroutine io_finalize()
use heat_vars
use HDF5
! Close FORTRAN interface.
call h5close_f(err)
end subroutine io_finalize
subroutine io_write(tstep,curr)
use heat_vars
use HDF5
implicit none
include 'mpif.h'
integer, intent(in) :: tstep
integer, intent(in) :: curr
integer :: ndims
integer*8, dimension(1:2) :: dims
integer*8 io_size
INTEGER(HID_T) :: file_id
INTEGER(HID_T) :: dset_id
INTEGER(HID_T) :: dspace_id
character (len=200) :: filename
character(2) :: mode = "w"
write(filename,'(a,".",i3.3,".",i3.3,".h5")') trim(outputfile), rank, tstep
print '("rank ",i0," writes to: ",a)', rank, trim(filename)
call MPI_BARRIER(app_comm, err)
io_start_time = MPI_WTIME()
ndims = 2
dims(1) = ndx
dims(2) = ndy
call h5fcreate_f (filename, H5F_ACC_TRUNC_F, file_id, err)
call h5screate_simple_f(ndims, dims, dspace_id, err)
call h5dcreate_f(file_id, "T", H5T_NATIVE_DOUBLE, dspace_id, &
dset_id, err)
io_size = 11*4 + 2*8*ndx*ndy
call h5dwrite_f(dset_id, H5T_NATIVE_DOUBLE, T(1:ndx,1:ndy,curr), dims, err)
! close dataset
call h5dclose_f(dset_id, err)
! close dataspace
call h5sclose_f(dspace_id, err)
! close file
call h5fclose_f(file_id, err)
call MPI_BARRIER(app_comm ,err)
io_end_time = MPI_WTIME()
io_total_time = io_end_time - io_start_time
sz = io_size * nproc/1024.d0/1024.d0/1024.d0 !size in GB
gbs = sz/io_total_time
if (rank==0) print '("Step ",i3,": ",a20,f12.4,2x,f12.3,2x,f12.3)', &
tstep,filename,sz,io_total_time,gbs
end subroutine io_write
end module heat_io