-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.f90
executable file
·304 lines (272 loc) · 9.66 KB
/
output.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! regional model module - output
! usage: output all results
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module output
use allocate_variable
use constant_parameter
implicit none
contains
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_open_files
! usage: open all output files for output
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_open_bin_files()
open (unit = pi_file_no, file = resultfolder//pi_file, status='new',form='unformatted',recl=2*10)
open (unit = Pa_file_no, file = resultfolder//Pa_file, status='new',form='unformatted',recl=2*10)
if(PVTmodel==1) open (unit = PVT_file_no, file = resultfolder//PTV_file, status='new',form='unformatted',recl=2*10)
open (unit = u_file_no, file = resultfolder//u_file, status='new',form='unformatted',recl=2*10)
open (unit = v_file_no, file = resultfolder//v_file, status='new',form='unformatted',recl=2*10)
open (unit = w_file_no, file = resultfolder//w_file, status='new',form='unformatted',recl=2*10)
open (unit = nu_file_no, file = resultfolder//nu_file, status='new',form='unformatted',recl=2*10)
open (unit = K_t_file_no, file = resultfolder//K_t_file, status='new',form='unformatted',recl=2*10)
open (unit = geopot_file_no, file = resultfolder//geopot_file, status='new',form='unformatted',recl=2*10)
if(PVTmodel==1) open (unit = Temp_file_no, file = resultfolder//Temp_file, status='new',form='unformatted',recl=2*10)
open (unit = rhoa_file_no, file = resultfolder//rhoa_file, status='new',form='unformatted',recl=2*10)
if(qvmodel==1) open (unit = qv_file_no, file = resultfolder//qv_file, status='new',form='unformatted',recl=2*10)
if(gasmodel==1) open (unit = gas_file_no, file = resultfolder//qv_file, status='new',form='unformatted',recl=2*10)
end subroutine output_open_bin_files
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_open_files
! usage: open all output files for output
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_open_txt_files()
open (unit = pi_file_no, file = resultfolder//pi_file)
open (unit = Pa_file_no, file = resultfolder//Pa_file)
if(PVTmodel==1) open (unit = PVT_file_no, file = resultfolder//PTV_file)
open (unit = u_file_no, file = resultfolder//u_file)
open (unit = v_file_no, file = resultfolder//v_file)
open (unit = w_file_no, file = resultfolder//w_file)
open (unit = nu_file_no, file = resultfolder//nu_file)
open (unit = K_t_file_no, file = resultfolder//K_t_file)
open (unit = geopot_file_no, file = resultfolder//geopot_file)
if(PVTmodel==1) open (unit = Temp_file_no, file = resultfolder//Temp_file)
open (unit = rhoa_file_no, file = resultfolder//rhoa_file)
if(qvmodel==1) open (unit = qv_file_no, file = resultfolder//qv_file)
if(gasmodel==1) open (unit = gas_file_no, file = resultfolder//gas_file)
end subroutine output_open_txt_files
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_all_variables
! usage: output all variables
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_all_variables()
! column pressure
call output_2Dcellcenter_variables(pi_c,pi_file_no,pi_format)
! air pressure
call output_3Dcellcenter_variables(Pa_c,Pa_file_no,Pa_format)
! u
call output_3Duface_variables(u,u_file_no,u_format)
! v
call output_3Dvface_variables(v,v_file_no,v_format)
! w_sigma
call output_3Dvertical_variables(w_sigma,w_file_no,w_format)
! eddy viscousity
call output_3Dcellcenter_variables(nu_t,nu_file_no,nu_t_format)
! eddy diffusivity
call output_3Dcellcenter_variables(K_t,K_t_file_no,K_t_format)
! geopotential
call output_3Dcellcenter_variables(geopot_c,geopot_file_no,geopot_format)
if(PVTmodel==1) then
! Temperature
call output_3Dcellcenter_variables(Temp_c,Temp_file_no,Temp_format)
! potential virtual temperature
call output_3Dcellcenter_variables(PVT_c,PVT_file_no,PVT_format)
endif
! air density
call output_3Dcellcenter_variables(rhoa_c,rhoa_file_no,rhoa_format)
! specific humidity
if(qvmodel==1) call output_3Dcellcenter_variables(qv_c,qv_file_no,qv_format)
! gas concentration
if(gasmodel==1) call output_3Dcellcenter_variables(gas_c,gas_file_no,gas_format)
end subroutine output_all_variables
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_3Dcellcenter_variables
! usage: output 3D cellcenter all variables
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_3Dcellcenter_variables(Value,file_no,format)
real(dp),dimension(NLAT,NLONG,NVERT),intent(in):: Value
integer, intent(in):: file_no
integer:: i,j,k,ios
character(*), intent(in)::format
do i=1,NLAT
do j=1,NLONG
do k=1,NVERT-1
write(file_no, format, iostat=ios, advance="no") Value(i,j,k)
enddo
write(file_no, format, iostat=ios) Value(i,j,NVERT)
if ( ios /= 0 ) then
print *,file_no
stop "Write error in output file"
endif
enddo
enddo
end subroutine output_3Dcellcenter_variables
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_3Duface_variables
! usage: output 3D variables at u flux face
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_3Duface_variables(Value,file_no,format)
real(dp),dimension(NLAT,NLONG+1,NVERT),intent(in):: Value
integer, intent(in):: file_no
integer:: i,j,k,ios
character(*), intent(in)::format
do i=1,NLAT
do j=1,NLONG+1
do k=1,NVERT-1
write(file_no, format, iostat=ios,advance="no") Value(i,j,k)
enddo
write(file_no, format, iostat=ios) Value(i,j,NVERT)
if ( ios /= 0 ) then
print *,file_no
stop "Write error in output file"
endif
enddo
enddo
end subroutine output_3Duface_variables
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_3Duface_variables
! usage: output 3D variables at v flux face
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_3Dvface_variables(Value,file_no,format)
real(dp),dimension(NLAT+1,NLONG,NVERT),intent(in):: Value
integer, intent(in):: file_no
integer:: i,j,k,ios
character(*), intent(in)::format
do i=1,NLAT+1
do j=1,NLONG
do k=1,NVERT-1
write(file_no, format, iostat=ios,advance="no") Value(i,j,k)
enddo
write(file_no, format, iostat=ios) Value(i,j,NVERT)
if ( ios /= 0 ) then
print *,file_no
stop "Write error in output file"
endif
enddo
enddo
end subroutine output_3Dvface_variables
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_3Dvertical_variables
! usage: output 3D variables at vertical face layer top-bottom
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_3Dvertical_variables(Value,file_no,format)
real(dp),dimension(NLAT,NLONG,0:NVERT),intent(in):: Value
integer, intent(in):: file_no
integer:: i,j,k,ios
character(*), intent(in)::format
do i=1,NLAT
do j=1,NLONG
do k=0,NVERT-1
write(file_no, format, iostat=ios,advance="no") Value(i,j,k)
enddo
write(file_no, format, iostat=ios) Value(i,j,NVERT)
if ( ios /= 0 ) then
print *,file_no
stop "Write error in output file"
endif
enddo
enddo
end subroutine output_3Dvertical_variables
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_2Dcellcenter_variables
! usage: output 2D cellcenter all variables
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_2Dcellcenter_variables(Value,file_no,format)
real(dp),dimension(NLAT,NLONG),intent(in):: Value
integer, intent(in):: file_no
integer:: i,j,k,ios
character(*), intent(in)::format
do i=1,NLAT
do j=1,NLONG-1
write(file_no, format, iostat=ios, advance="no") Value(i,j)
enddo
write(file_no, format, iostat=ios) Value(i,NLONG)
if ( ios /= 0 ) then
print *,file_no
stop "Write error in output file"
endif
enddo
end subroutine output_2Dcellcenter_variables
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_2Duface_variables
! usage: output 2D cellcenter at uface
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_2Duface_variables(Value,file_no,format)
real(dp),dimension(NLAT,NLONG+1),intent(in):: Value
integer, intent(in):: file_no
integer:: i,j,k,ios
character(*), intent(in)::format
do i=1,NLAT
do j=1,NLONG
write(file_no, format, iostat=ios,advance="no") Value(i,j)
enddo
write(file_no, format, iostat=ios) Value(i,NLONG+1)
if ( ios /= 0 ) then
print *,file_no
stop "Write error in output file"
endif
enddo
end subroutine output_2Duface_variables
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_2Dvface_variables
! usage: output 2D cellcenter at v flux face
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_2Dvface_variables(Value,file_no,format)
real(dp),dimension(NLAT+1,NLONG),intent(in):: Value
integer, intent(in):: file_no
integer:: i,j,k,ios
character(*), intent(in)::format
do i=1,NLAT+1
do j=1,NLONG-1
write(file_no, format, iostat=ios,advance="no") Value(i,j)
enddo
write(file_no, format, iostat=ios) Value(i,NLONG)
if ( ios /= 0 ) then
print *,file_no
stop "Write error in output file"
endif
enddo
end subroutine output_2Dvface_variables
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! output_close_files
! usage: close all output files for output
! Yun Zhang 05/03/2015
! @stanford
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine output_close_files()
close (pi_file_no)
close (Pa_file_no)
close (PVT_file_no)
close (u_file_no)
close (v_file_no)
close (w_file_no)
close (nu_file_no)
close (K_t_file_no)
close (geopot_file_no)
close (Temp_file_no)
close (rhoa_file_no)
close (qv_file_no)
end subroutine output_close_files
end module output