-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathloadd.f90
executable file
·202 lines (190 loc) · 5.66 KB
/
loadd.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
module mod_loadflds
use decomp_2d
use decomp_2d_io
use mod_cons
use mod_global
use mod_var
use mod_restart
implicit none
private
public loadflds
contains
!
subroutine loadflds(in,nr)
implicit none
integer :: in,nr
integer :: fh
integer(kind=MPI_OFFSET_KIND) :: filesize,disp
character(len=30) :: istepchar
real, dimension(3) :: fldinfo
real, dimension(imax,jmax,kmax) :: temp
integer:: i,j
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! this is to read in data
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (in.eq.0) then
write(istepchar,'(I0)') nr
! then check if the restart file is there!
call ck_restart(trim(istepchar))
call MPI_FILE_OPEN(MPI_COMM_WORLD, datadir//'fld'//trim(istepchar), &
MPI_MODE_RDONLY, MPI_INFO_NULL,fh, error)
disp = 0_MPI_OFFSET_KIND
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! unew !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
unew(1:imax,1:jmax,1:kmax) = temp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! vnew !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
vnew(1:imax,1:jmax,1:kmax) = temp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! wnew !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
wnew(1:imax,1:jmax,1:kmax) = temp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! pnew !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
pnew(1:imax,1:jmax,1:kmax) = temp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! pold !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
pold(1:imax,1:jmax,1:kmax) = temp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Tnew !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
Tnew(1:imax,1:jmax,1:kmax) = temp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Phi !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
PFM_phi(1:imax,1:jmax,1:kmax) = temp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Phi boundary !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
do i=1,imax
do j=1,jmax
PFM_phi(i,j,0) = temp(i,j,1)
PFM_phi(i,j,k1) = temp(i,j,2)
enddo
enddo
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! C !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
PFM_c(1:imax,1:jmax,1:kmax) = temp
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! C boundary !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
do i=1,imax
do j=1,jmax
PFM_c(i,j,0) = temp(i,j,1)
PFM_c(i,j,k1) = temp(i,j,2)
enddo
enddo
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Phi_c !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
call decomp_2d_read_var(fh,disp,3,temp)
Phi_c(1:imax,1:jmax,1:kmax) = temp
! the other information
call decomp_2d_read_scalar(fh,disp,3,fldinfo)
time = fldinfo(1)
nr = int(fldinfo(2))
dt = fldinfo(3)
call MPI_FILE_CLOSE(fh,error)
endif
!
!this is to write files
if (in.eq.1) then
!write(istepchar,'(i8.8)') nr
write(istepchar,'(I0)') nr
fldinfo = (/time,1.*nr,dt/)
call MPI_FILE_OPEN(MPI_COMM_WORLD, datadir//'fld'//trim(istepchar), &
MPI_MODE_CREATE+MPI_MODE_WRONLY, MPI_INFO_NULL,fh, error)
filesize = 0_MPI_OFFSET_KIND
call MPI_FILE_SET_SIZE(fh,filesize,error) ! guarantee overwriting
disp = 0_MPI_OFFSET_KIND
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! unew !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = unew(1:imax,1:jmax,1:kmax)
call decomp_2d_write_var(fh,disp,3,temp)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! vnew !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = vnew(1:imax,1:jmax,1:kmax)
call decomp_2d_write_var(fh,disp,3,temp)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! wnew !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = wnew(1:imax,1:jmax,1:kmax)
call decomp_2d_write_var(fh,disp,3,temp)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! pnew !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = pnew(1:imax,1:jmax,1:kmax)
call decomp_2d_write_var(fh,disp,3,temp)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! pold !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = pold(1:imax,1:jmax,1:kmax)
call decomp_2d_write_var(fh,disp,3,temp)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Tew !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = Tnew(1:imax,1:jmax,1:kmax)
call decomp_2d_write_var(fh,disp,3,temp)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Phi !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = PFM_phi(1:imax,1:jmax,1:kmax)
call decomp_2d_write_var(fh,disp,3,temp)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Phi bou !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = 0.
do i=1,imax
do j=1,jmax
temp(i,j,1) = PFM_phi(i,j,0)
temp(i,j,2) = PFM_phi(i,j,k1)
enddo
enddo
call decomp_2d_write_var(fh,disp,3,temp)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! C !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = PFM_c(1:imax,1:jmax,1:kmax)
call decomp_2d_write_var(fh,disp,3,temp)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! C bou !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = 0.
do i=1,imax
do j=1,jmax
temp(i,j,1) = PFM_c(i,j,0)
temp(i,j,2) = PFM_c(i,j,k1)
enddo
enddo
call decomp_2d_write_var(fh,disp,3,temp)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! Phi_c !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
temp = Phi_c(1:imax,1:jmax,1:kmax)
call decomp_2d_write_var(fh,disp,3,temp)
! write in other information
call decomp_2d_write_scalar(fh,disp,3,fldinfo)
call MPI_FILE_CLOSE(fh,error)
endif
!
return
end subroutine loadflds
!
end module mod_loadflds