chgres_cube 1.14.0
Loading...
Searching...
No Matches
nst_input_data.F90
Go to the documentation of this file.
1module nst_input_data
5
15 use esmf
16 use netcdf
17#ifdef CHGRES_ALL
18 use nemsio_module
19#endif
20
25
26 use model_grid, only : input_grid, &
29
30 use sfc_input_data, only : lsoil_input, &
31 read_fv3_grid_data_netcdf, &
32 landsea_mask_input_grid
33
34 use utilities, only : error_handler
35 implicit none
36
37! Fields associated with the nst model.
38
39 type(esmf_field), public :: c_d_input_grid
40 type(esmf_field), public :: c_0_input_grid
41 type(esmf_field), public :: d_conv_input_grid
42 type(esmf_field), public :: dt_cool_input_grid
43 type(esmf_field), public :: ifd_input_grid
45 !started.
46 type(esmf_field), public :: qrain_input_grid
47 type(esmf_field), public :: tref_input_grid
48 type(esmf_field), public :: w_d_input_grid
49 type(esmf_field), public :: w_0_input_grid
50 type(esmf_field), public :: xs_input_grid
51 type(esmf_field), public :: xt_input_grid
52 type(esmf_field), public :: xu_input_grid
53 type(esmf_field), public :: xv_input_grid
54 type(esmf_field), public :: xz_input_grid
55 type(esmf_field), public :: xtts_input_grid
56 type(esmf_field), public :: xzts_input_grid
57 type(esmf_field), public :: z_c_input_grid
58 type(esmf_field), public :: zm_input_grid
59
60 public :: read_input_nst_data
61 public :: cleanup_input_nst_data
62
63 contains
68 subroutine read_input_nst_data(localpet)
69
70 implicit none
71
72 integer, intent(in) :: localpet
73
74 integer :: rc
75
76 print*,"- READ INPUT GRID NST DATA."
77
78 print*,"- CALL FieldCreate FOR INPUT GRID C_D."
79 c_d_input_grid = esmf_fieldcreate(input_grid, &
80 typekind=esmf_typekind_r8, &
81 staggerloc=esmf_staggerloc_center, rc=rc)
82 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
83 call error_handler("IN FieldCreate", rc)
84
85 print*,"- CALL FieldCreate FOR INPUT GRID C_0."
86 c_0_input_grid = esmf_fieldcreate(input_grid, &
87 typekind=esmf_typekind_r8, &
88 staggerloc=esmf_staggerloc_center, rc=rc)
89 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
90 call error_handler("IN FieldCreate", rc)
91
92 print*,"- CALL FieldCreate FOR INPUT GRID D_CONV."
93 d_conv_input_grid = esmf_fieldcreate(input_grid, &
94 typekind=esmf_typekind_r8, &
95 staggerloc=esmf_staggerloc_center, rc=rc)
96 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
97 call error_handler("IN FieldCreate", rc)
98
99 print*,"- CALL FieldCreate FOR INPUT GRID DT_COOL."
100 dt_cool_input_grid = esmf_fieldcreate(input_grid, &
101 typekind=esmf_typekind_r8, &
102 staggerloc=esmf_staggerloc_center, rc=rc)
103 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
104 call error_handler("IN FieldCreate", rc)
105
106 print*,"- CALL FieldCreate FOR INPUT GRID IFD."
107 ifd_input_grid = esmf_fieldcreate(input_grid, &
108 typekind=esmf_typekind_r8, &
109 staggerloc=esmf_staggerloc_center, rc=rc)
110 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
111 call error_handler("IN FieldCreate", rc)
112
113 print*,"- CALL FieldCreate FOR INPUT GRID QRAIN."
114 qrain_input_grid = esmf_fieldcreate(input_grid, &
115 typekind=esmf_typekind_r8, &
116 staggerloc=esmf_staggerloc_center, rc=rc)
117 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
118 call error_handler("IN FieldCreate", rc)
119
120 print*,"- CALL FieldCreate FOR INPUT GRID TREF."
121 tref_input_grid = esmf_fieldcreate(input_grid, &
122 typekind=esmf_typekind_r8, &
123 staggerloc=esmf_staggerloc_center, rc=rc)
124 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
125 call error_handler("IN FieldCreate", rc)
126
127 print*,"- CALL FieldCreate FOR INPUT GRID W_D."
128 w_d_input_grid = esmf_fieldcreate(input_grid, &
129 typekind=esmf_typekind_r8, &
130 staggerloc=esmf_staggerloc_center, rc=rc)
131 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
132 call error_handler("IN FieldCreate", rc)
133
134 print*,"- CALL FieldCreate FOR INPUT GRID W_0."
135 w_0_input_grid = esmf_fieldcreate(input_grid, &
136 typekind=esmf_typekind_r8, &
137 staggerloc=esmf_staggerloc_center, rc=rc)
138 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
139 call error_handler("IN FieldCreate", rc)
140
141 print*,"- CALL FieldCreate FOR INPUT GRID XS."
142 xs_input_grid = esmf_fieldcreate(input_grid, &
143 typekind=esmf_typekind_r8, &
144 staggerloc=esmf_staggerloc_center, rc=rc)
145 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
146 call error_handler("IN FieldCreate", rc)
147
148 print*,"- CALL FieldCreate FOR INPUT GRID XT."
149 xt_input_grid = esmf_fieldcreate(input_grid, &
150 typekind=esmf_typekind_r8, &
151 staggerloc=esmf_staggerloc_center, rc=rc)
152 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
153 call error_handler("IN FieldCreate", rc)
154
155 print*,"- CALL FieldCreate FOR INPUT GRID XU."
156 xu_input_grid = esmf_fieldcreate(input_grid, &
157 typekind=esmf_typekind_r8, &
158 staggerloc=esmf_staggerloc_center, rc=rc)
159 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
160 call error_handler("IN FieldCreate", rc)
161
162 print*,"- CALL FieldCreate FOR INPUT GRID XV."
163 xv_input_grid = esmf_fieldcreate(input_grid, &
164 typekind=esmf_typekind_r8, &
165 staggerloc=esmf_staggerloc_center, rc=rc)
166 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
167 call error_handler("IN FieldCreate", rc)
168
169 print*,"- CALL FieldCreate FOR INPUT GRID XZ."
170 xz_input_grid = esmf_fieldcreate(input_grid, &
171 typekind=esmf_typekind_r8, &
172 staggerloc=esmf_staggerloc_center, rc=rc)
173 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
174 call error_handler("IN FieldCreate", rc)
175
176 print*,"- CALL FieldCreate FOR INPUT GRID XTTS."
177 xtts_input_grid = esmf_fieldcreate(input_grid, &
178 typekind=esmf_typekind_r8, &
179 staggerloc=esmf_staggerloc_center, rc=rc)
180 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
181 call error_handler("IN FieldCreate", rc)
182
183 print*,"- CALL FieldCreate FOR INPUT GRID XZTS."
184 xzts_input_grid = esmf_fieldcreate(input_grid, &
185 typekind=esmf_typekind_r8, &
186 staggerloc=esmf_staggerloc_center, rc=rc)
187 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
188 call error_handler("IN FieldCreate", rc)
189
190 print*,"- CALL FieldCreate FOR INPUT GRID Z_C."
191 z_c_input_grid = esmf_fieldcreate(input_grid, &
192 typekind=esmf_typekind_r8, &
193 staggerloc=esmf_staggerloc_center, rc=rc)
194 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
195 call error_handler("IN FieldCreate", rc)
196
197 print*,"- CALL FieldCreate FOR INPUT GRID ZM."
198 zm_input_grid = esmf_fieldcreate(input_grid, &
199 typekind=esmf_typekind_r8, &
200 staggerloc=esmf_staggerloc_center, rc=rc)
201 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
202 call error_handler("IN FieldCreate", rc)
203
204!--------------------------------------------------------------------------
205! Read input grid nst data from a fv3 gaussian nemsio history file or
206! spectral GFS nemsio file.
207!--------------------------------------------------------------------------
208
209#ifdef CHGRES_ALL
210 if (trim(input_type) == "gaussian_nemsio" .or. trim(input_type) == "gfs_gaussian_nemsio") then
211
212 call read_input_nst_nemsio_file(localpet)
213
214!---------------------------------------------------------------------------
215! Read nst data from these netcdf formatted fv3 files: tiled history,
216! tiled warm restart, and gaussian history.
217!---------------------------------------------------------------------------
218
219 else
220
221 call read_input_nst_netcdf_file(localpet)
222
223 endif
224#else
225
226 call read_input_nst_netcdf_file(localpet)
227
228#endif
229
230 end subroutine read_input_nst_data
231
237 subroutine read_input_nst_netcdf_file(localpet)
238
239 implicit none
240
241 integer, intent(in) :: localpet
242
243 character(len=10) :: field
244
245 integer :: rc, tile
246
247 real(esmf_kind_r8), allocatable :: data_one_tile(:,:)
248
249 if (localpet == 0) then
250 allocate(data_one_tile(i_input,j_input))
251 else
252 allocate(data_one_tile(0,0))
253 endif
254
255 tile_loop : do tile = 1, num_tiles_input_grid
256
257! c_d
258
259 if (localpet == 0) then
260 if (trim(input_type) == "restart") then
261 field='c_d'
262 else
263 field='cd'
264 endif
265 call read_fv3_grid_data_netcdf(trim(field), tile, i_input, j_input, &
266 lsoil_input, sfcdata=data_one_tile)
267 endif
268
269 print*,"- CALL FieldScatter FOR INPUT C_D"
270 call esmf_fieldscatter(c_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
271 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
272 call error_handler("IN FieldScatter", rc)
273
274! c_0
275
276 if (localpet == 0) then
277 if (trim(input_type) == "restart") then
278 field='c_0'
279 else
280 field='c0'
281 endif
282 call read_fv3_grid_data_netcdf(trim(field), tile, i_input, j_input, &
283 lsoil_input, sfcdata=data_one_tile)
284 endif
285
286 print*,"- CALL FieldScatter FOR INPUT C_0"
287 call esmf_fieldscatter(c_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
288 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
289 call error_handler("IN FieldScatter", rc)
290
291! d_conv
292
293 if (localpet == 0) then
294 if (trim(input_type) == "restart") then
295 field='d_conv'
296 else
297 field='dconv'
298 endif
299 call read_fv3_grid_data_netcdf(trim(field), tile, i_input, j_input, &
300 lsoil_input, sfcdata=data_one_tile)
301 endif
302
303 print*,"- CALL FieldScatter FOR INPUT D_CONV."
304 call esmf_fieldscatter(d_conv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
305 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
306 call error_handler("IN FieldScatter", rc)
307
308! dt_cool
309
310 if (localpet == 0) then
311 if (trim(input_type) == "restart") then
312 field='dt_cool'
313 else
314 field='dtcool'
315 endif
316 call read_fv3_grid_data_netcdf(trim(field), tile, i_input, j_input, &
317 lsoil_input, sfcdata=data_one_tile)
318 endif
319
320 print*,"- CALL FieldScatter FOR INPUT DT_COOL."
321 call esmf_fieldscatter(dt_cool_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
322 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
323 call error_handler("IN FieldScatter", rc)
324
325! ifd - xu li said initialize to '1'.
326
327 if (localpet == 0) then
328 data_one_tile = 1.0
329 endif
330
331 print*,"- CALL FieldScatter FOR INPUT IFD."
332 call esmf_fieldscatter(ifd_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
333 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
334 call error_handler("IN FieldScatter", rc)
335
336! qrain
337
338 if (localpet == 0) then
339 call read_fv3_grid_data_netcdf('qrain', tile, i_input, j_input, &
340 lsoil_input, sfcdata=data_one_tile)
341 endif
342
343 print*,"- CALL FieldScatter FOR INPUT QRAIN."
344 call esmf_fieldscatter(qrain_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
345 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
346 call error_handler("IN FieldScatter", rc)
347
348! tref
349
350 if (localpet == 0) then
351 call read_fv3_grid_data_netcdf('tref', tile, i_input, j_input, &
352 lsoil_input, sfcdata=data_one_tile)
353 endif
354
355 print*,"- CALL FieldScatter FOR INPUT TREF"
356 call esmf_fieldscatter(tref_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
357 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
358 call error_handler("IN FieldScatter", rc)
359
360! w_d
361
362 if (localpet == 0) then
363 if (trim(input_type) == "restart") then
364 field='w_d'
365 else
366 field='wd'
367 endif
368 call read_fv3_grid_data_netcdf(trim(field), tile, i_input, j_input, &
369 lsoil_input, sfcdata=data_one_tile)
370 endif
371
372 print*,"- CALL FieldScatter FOR INPUT W_D"
373 call esmf_fieldscatter(w_d_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
374 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
375 call error_handler("IN FieldScatter", rc)
376
377! w_0
378
379 if (localpet == 0) then
380 if (trim(input_type) == "restart") then
381 field='w_0'
382 else
383 field='w0'
384 endif
385 call read_fv3_grid_data_netcdf(trim(field), tile, i_input, j_input, &
386 lsoil_input, sfcdata=data_one_tile)
387 endif
388
389 print*,"- CALL FieldScatter FOR INPUT W_0"
390 call esmf_fieldscatter(w_0_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
391 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
392 call error_handler("IN FieldScatter", rc)
393
394! xs
395
396 if (localpet == 0) then
397 call read_fv3_grid_data_netcdf('xs', tile, i_input, j_input, &
398 lsoil_input, sfcdata=data_one_tile)
399 endif
400
401 print*,"- CALL FieldScatter FOR INPUT XS"
402 call esmf_fieldscatter(xs_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
403 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
404 call error_handler("IN FieldScatter", rc)
405
406! xt
407
408 if (localpet == 0) then
409 call read_fv3_grid_data_netcdf('xt', tile, i_input, j_input, &
410 lsoil_input, sfcdata=data_one_tile)
411 endif
412
413 print*,"- CALL FieldScatter FOR INPUT XT"
414 call esmf_fieldscatter(xt_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
415 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
416 call error_handler("IN FieldScatter", rc)
417
418! xu
419
420 if (localpet == 0) then
421 call read_fv3_grid_data_netcdf('xu', tile, i_input, j_input, &
422 lsoil_input, sfcdata=data_one_tile)
423 endif
424
425 print*,"- CALL FieldScatter FOR INPUT XU"
426 call esmf_fieldscatter(xu_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
427 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
428 call error_handler("IN FieldScatter", rc)
429
430! xv
431
432 if (localpet == 0) then
433 call read_fv3_grid_data_netcdf('xv', tile, i_input, j_input, &
434 lsoil_input, sfcdata=data_one_tile)
435 endif
436
437 print*,"- CALL FieldScatter FOR INPUT XV"
438 call esmf_fieldscatter(xv_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
439 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
440 call error_handler("IN FieldScatter", rc)
441
442! xz
443
444 if (localpet == 0) then
445 call read_fv3_grid_data_netcdf('xz', tile, i_input, j_input, &
446 lsoil_input, sfcdata=data_one_tile)
447 endif
448
449 print*,"- CALL FieldScatter FOR INPUT XZ"
450 call esmf_fieldscatter(xz_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
451 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
452 call error_handler("IN FieldScatter", rc)
453
454! xtts
455
456 if (localpet == 0) then
457 call read_fv3_grid_data_netcdf('xtts', tile, i_input, j_input, &
458 lsoil_input, sfcdata=data_one_tile)
459 endif
460
461 print*,"- CALL FieldScatter FOR INPUT XTTS"
462 call esmf_fieldscatter(xtts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
463 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
464 call error_handler("IN FieldScatter", rc)
465
466! xzts
467
468 if (localpet == 0) then
469 call read_fv3_grid_data_netcdf('xzts', tile, i_input, j_input, &
470 lsoil_input, sfcdata=data_one_tile)
471 endif
472
473 print*,"- CALL FieldScatter FOR INPUT XZTS"
474 call esmf_fieldscatter(xzts_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
475 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
476 call error_handler("IN FieldScatter", rc)
477
478! z_c
479
480 if (localpet == 0) then
481 if (trim(input_type) == "restart") then
482 field='z_c'
483 else
484 field='zc'
485 endif
486 call read_fv3_grid_data_netcdf(trim(field), tile, i_input, j_input, &
487 lsoil_input, sfcdata=data_one_tile)
488 endif
489
490 print*,"- CALL FieldScatter FOR INPUT Z_C"
491 call esmf_fieldscatter(z_c_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
492 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
493 call error_handler("IN FieldScatter", rc)
494
495! zm - Not used yet. Xu li said set to '0'.
496
497 if (localpet == 0) then
498 data_one_tile = 0.0
499 endif
500
501 print*,"- CALL FieldScatter FOR INPUT ZM"
502 call esmf_fieldscatter(zm_input_grid, data_one_tile, rootpet=0, tile=tile, rc=rc)
503 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
504 call error_handler("IN FieldScatter", rc)
505
506 enddo tile_loop
507
508 deallocate(data_one_tile)
509
510 end subroutine read_input_nst_netcdf_file
511
512#ifdef CHGRES_ALL
513
523 subroutine read_input_nst_nemsio_file(localpet)
524
525 implicit none
526
527 integer, intent(in) :: localpet
528
529 character(len=300) :: the_file
530
531 integer :: rc
532
533 real(nemsio_realkind), allocatable :: dummy(:)
534 real(esmf_kind_r8), allocatable :: dummy2d(:,:)
535
536 type(nemsio_gfile) :: gfile
537
538 if (trim(input_type) == "gfs_gaussian_nemsio") then ! spectral gfs nemsio in
539 ! separate file.
540 the_file = trim(data_dir_input_grid) // "/" // trim(nst_files_input_grid)
541 else
542 the_file = trim(data_dir_input_grid) // "/" // trim(sfc_files_input_grid(1))
543 endif
544
545 print*,"- READ NST DATA FROM: ", trim(the_file)
546
547 if (localpet == 0) then
548 allocate(dummy(i_input*j_input))
549 allocate(dummy2d(i_input,j_input))
550 call nemsio_open(gfile, the_file, "read", iret=rc)
551 else
552 allocate(dummy(0))
553 allocate(dummy2d(0,0))
554 endif
555
556 if (localpet == 0) then
557 print*,"- READ TREF"
558 call nemsio_readrecv(gfile, "tref", "sfc", 1, dummy, 0, iret=rc)
559 if (rc /= 0) call error_handler("READING TREF.", rc)
560 dummy2d = reshape(dummy, (/i_input,j_input/))
561 print*,'tref ',maxval(dummy2d),minval(dummy2d)
562 endif
563
564 print*,"- CALL FieldScatter FOR INPUT TREF."
565 call esmf_fieldscatter(tref_input_grid, dummy2d, rootpet=0, rc=rc)
566 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
567 call error_handler("IN FieldScatter", rc)
568
569 if (localpet == 0) then
570 print*,"- READ CD"
571 call nemsio_readrecv(gfile, "cd", "sfc", 1, dummy, 0, iret=rc)
572 if (rc /= 0) call error_handler("READING CD.", rc)
573 dummy2d = reshape(dummy, (/i_input,j_input/))
574 print*,'cd ',maxval(dummy2d),minval(dummy2d)
575 endif
576
577 print*,"- CALL FieldScatter FOR INPUT C_D."
578 call esmf_fieldscatter(c_d_input_grid, dummy2d, rootpet=0, rc=rc)
579 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
580 call error_handler("IN FieldScatter", rc)
581
582 if (localpet == 0) then
583 print*,"- READ C0"
584 call nemsio_readrecv(gfile, "c0", "sfc", 1, dummy, 0, iret=rc)
585 if (rc /= 0) call error_handler("READING C0.", rc)
586 dummy2d = reshape(dummy, (/i_input,j_input/))
587 print*,'c0 ',maxval(dummy2d),minval(dummy2d)
588 endif
589
590 print*,"- CALL FieldScatter FOR INPUT C_0."
591 call esmf_fieldscatter(c_0_input_grid, dummy2d, rootpet=0, rc=rc)
592 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
593 call error_handler("IN FieldScatter", rc)
594
595 if (localpet == 0) then
596 print*,"- READ DCONV"
597 call nemsio_readrecv(gfile, "dconv", "sfc", 1, dummy, 0, iret=rc)
598 if (rc /= 0) call error_handler("READING DCONV.", rc)
599 dummy2d = reshape(dummy, (/i_input,j_input/))
600 print*,'dconv ',maxval(dummy2d),minval(dummy2d)
601 endif
602
603 print*,"- CALL FieldScatter FOR INPUT D_CONV."
604 call esmf_fieldscatter(d_conv_input_grid, dummy2d, rootpet=0, rc=rc)
605 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
606 call error_handler("IN FieldScatter", rc)
607
608 if (localpet == 0) then
609 print*,"- READ DTCOOL"
610 call nemsio_readrecv(gfile, "dtcool", "sfc", 1, dummy, 0, iret=rc)
611 if (rc /= 0) call error_handler("READING DTCOOL.", rc)
612 dummy2d = reshape(dummy, (/i_input,j_input/))
613 print*,'dtcool ',maxval(dummy2d),minval(dummy2d)
614 endif
615
616 print*,"- CALL FieldScatter FOR INPUT DT_COOL."
617 call esmf_fieldscatter(dt_cool_input_grid, dummy2d, rootpet=0, rc=rc)
618 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
619 call error_handler("IN FieldScatter", rc)
620
621 if (localpet == 0) then
622 dummy2d = 1.0 ! IFD not in file. Set to '1' per Xu Li.
623 endif
624
625 print*,"- CALL FieldScatter FOR INPUT IFD."
626 call esmf_fieldscatter(ifd_input_grid, dummy2d, rootpet=0, rc=rc)
627 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
628 call error_handler("IN FieldScatter", rc)
629
630 if (localpet == 0) then
631 print*,"- READ QRAIN"
632 call nemsio_readrecv(gfile, "qrain", "sfc", 1, dummy, 0, iret=rc)
633 if (rc /= 0) call error_handler("READING QRAIN.", rc)
634 dummy2d = reshape(dummy, (/i_input,j_input/))
635 print*,'qrain ',maxval(dummy2d),minval(dummy2d)
636 endif
637
638 print*,"- CALL FieldScatter FOR INPUT QRAIN."
639 call esmf_fieldscatter(qrain_input_grid, dummy2d, rootpet=0, rc=rc)
640 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
641 call error_handler("IN FieldScatter", rc)
642
643 if (localpet == 0) then
644 print*,"- READ WD"
645 call nemsio_readrecv(gfile, "wd", "sfc", 1, dummy, 0, iret=rc)
646 if (rc /= 0) call error_handler("READING WD.", rc)
647 dummy2d = reshape(dummy, (/i_input,j_input/))
648 print*,'wd ',maxval(dummy2d),minval(dummy2d)
649 endif
650
651 print*,"- CALL FieldScatter FOR INPUT WD."
652 call esmf_fieldscatter(w_d_input_grid, dummy2d, rootpet=0, rc=rc)
653 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
654 call error_handler("IN FieldScatter", rc)
655
656 if (localpet == 0) then
657 print*,"- READ W0"
658 call nemsio_readrecv(gfile, "w0", "sfc", 1, dummy, 0, iret=rc)
659 if (rc /= 0) call error_handler("READING W0.", rc)
660 dummy2d = reshape(dummy, (/i_input,j_input/))
661 print*,'w0 ',maxval(dummy2d),minval(dummy2d)
662 endif
663
664 print*,"- CALL FieldScatter FOR INPUT W0."
665 call esmf_fieldscatter(w_0_input_grid, dummy2d, rootpet=0, rc=rc)
666 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
667 call error_handler("IN FieldScatter", rc)
668
669 if (localpet == 0) then
670 print*,"- READ XS"
671 call nemsio_readrecv(gfile, "xs", "sfc", 1, dummy, 0, iret=rc)
672 if (rc /= 0) call error_handler("READING XS.", rc)
673 dummy2d = reshape(dummy, (/i_input,j_input/))
674 print*,'xs ',maxval(dummy2d),minval(dummy2d)
675 endif
676
677 print*,"- CALL FieldScatter FOR INPUT XS."
678 call esmf_fieldscatter(xs_input_grid, dummy2d, rootpet=0, rc=rc)
679 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
680 call error_handler("IN FieldScatter", rc)
681
682 if (localpet == 0) then
683 print*,"- READ XT"
684 call nemsio_readrecv(gfile, "xt", "sfc", 1, dummy, 0, iret=rc)
685 if (rc /= 0) call error_handler("READING XT.", rc)
686 dummy2d = reshape(dummy, (/i_input,j_input/))
687 print*,'xt ',maxval(dummy2d),minval(dummy2d)
688 endif
689
690 print*,"- CALL FieldScatter FOR INPUT XT."
691 call esmf_fieldscatter(xt_input_grid, dummy2d, rootpet=0, rc=rc)
692 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
693 call error_handler("IN FieldScatter", rc)
694
695 if (localpet == 0) then
696 print*,"- READ XU"
697 call nemsio_readrecv(gfile, "xu", "sfc", 1, dummy, 0, iret=rc)
698 if (rc /= 0) call error_handler("READING XU.", rc)
699 dummy2d = reshape(dummy, (/i_input,j_input/))
700 print*,'xu ',maxval(dummy2d),minval(dummy2d)
701 endif
702
703 print*,"- CALL FieldScatter FOR INPUT XU."
704 call esmf_fieldscatter(xu_input_grid, dummy2d, rootpet=0, rc=rc)
705 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
706 call error_handler("IN FieldScatter", rc)
707
708 if (localpet == 0) then
709 print*,"- READ XV"
710 call nemsio_readrecv(gfile, "xv", "sfc", 1, dummy, 0, iret=rc)
711 if (rc /= 0) call error_handler("READING XV.", rc)
712 dummy2d = reshape(dummy, (/i_input,j_input/))
713 print*,'xv ',maxval(dummy2d),minval(dummy2d)
714 endif
715
716 print*,"- CALL FieldScatter FOR INPUT XV."
717 call esmf_fieldscatter(xv_input_grid, dummy2d, rootpet=0, rc=rc)
718 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
719 call error_handler("IN FieldScatter", rc)
720
721 if (localpet == 0) then
722 print*,"- READ XZ"
723 call nemsio_readrecv(gfile, "xz", "sfc", 1, dummy, 0, iret=rc)
724 if (rc /= 0) call error_handler("READING XZ.", rc)
725 dummy2d = reshape(dummy, (/i_input,j_input/))
726 print*,'xz ',maxval(dummy2d),minval(dummy2d)
727 endif
728
729 print*,"- CALL FieldScatter FOR INPUT XZ."
730 call esmf_fieldscatter(xz_input_grid, dummy2d, rootpet=0, rc=rc)
731 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
732 call error_handler("IN FieldScatter", rc)
733
734 if (localpet == 0) then
735 print*,"- READ XTTS"
736 call nemsio_readrecv(gfile, "xtts", "sfc", 1, dummy, 0, iret=rc)
737 if (rc /= 0) call error_handler("READING XTTS.", rc)
738 dummy2d = reshape(dummy, (/i_input,j_input/))
739 print*,'xtts ',maxval(dummy2d),minval(dummy2d)
740 endif
741
742 print*,"- CALL FieldScatter FOR INPUT XTTS."
743 call esmf_fieldscatter(xtts_input_grid, dummy2d, rootpet=0, rc=rc)
744 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
745 call error_handler("IN FieldScatter", rc)
746
747 if (localpet == 0) then
748 print*,"- READ XZTS"
749 call nemsio_readrecv(gfile, "xzts", "sfc", 1, dummy, 0, iret=rc)
750 if (rc /= 0) call error_handler("READING XZTS.", rc)
751 dummy2d = reshape(dummy, (/i_input,j_input/))
752 print*,'xzts ',maxval(dummy2d),minval(dummy2d)
753 endif
754
755 print*,"- CALL FieldScatter FOR INPUT XZTS."
756 call esmf_fieldscatter(xzts_input_grid, dummy2d, rootpet=0, rc=rc)
757 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
758 call error_handler("IN FieldScatter", rc)
759
760 if (localpet == 0) then
761 print*,"- READ ZC"
762 call nemsio_readrecv(gfile, "zc", "sfc", 1, dummy, 0, iret=rc)
763 if (rc /= 0) call error_handler("READING ZC.", rc)
764 dummy2d = reshape(dummy, (/i_input,j_input/))
765 print*,'zc ',maxval(dummy2d),minval(dummy2d)
766 endif
767
768 print*,"- CALL FieldScatter FOR INPUT Z_C."
769 call esmf_fieldscatter(z_c_input_grid, dummy2d, rootpet=0, rc=rc)
770 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
771 call error_handler("IN FieldScatter", rc)
772
773 if (localpet == 0) then
774 dummy2d = 0.0 ! zm not used yet. Set to zero per Xu Li.
775 endif
776
777 print*,"- CALL FieldScatter FOR INPUT ZM."
778 call esmf_fieldscatter(zm_input_grid, dummy2d, rootpet=0, rc=rc)
779 if(esmf_logfounderror(rctocheck=rc,msg=esmf_logerr_passthru,line=__line__,file=__file__)) &
780 call error_handler("IN FieldScatter", rc)
781
782 deallocate(dummy, dummy2d)
783
784 if (localpet == 0) call nemsio_close(gfile)
785
786 end subroutine read_input_nst_nemsio_file
787
788#endif
789
793 subroutine cleanup_input_nst_data
794
795 implicit none
796
797 integer :: rc
798
799 print*,'- DESTROY NST INPUT DATA.'
800
801 call esmf_fielddestroy(landsea_mask_input_grid, rc=rc)
802 call esmf_fielddestroy(c_d_input_grid, rc=rc)
803 call esmf_fielddestroy(c_0_input_grid, rc=rc)
804 call esmf_fielddestroy(d_conv_input_grid, rc=rc)
805 call esmf_fielddestroy(dt_cool_input_grid, rc=rc)
806 call esmf_fielddestroy(ifd_input_grid, rc=rc)
807 call esmf_fielddestroy(qrain_input_grid, rc=rc)
808 call esmf_fielddestroy(tref_input_grid, rc=rc)
809 call esmf_fielddestroy(w_d_input_grid, rc=rc)
810 call esmf_fielddestroy(w_0_input_grid, rc=rc)
811 call esmf_fielddestroy(xs_input_grid, rc=rc)
812 call esmf_fielddestroy(xt_input_grid, rc=rc)
813 call esmf_fielddestroy(xu_input_grid, rc=rc)
814 call esmf_fielddestroy(xv_input_grid, rc=rc)
815 call esmf_fielddestroy(xz_input_grid, rc=rc)
816 call esmf_fielddestroy(xtts_input_grid, rc=rc)
817 call esmf_fielddestroy(xzts_input_grid, rc=rc)
818 call esmf_fielddestroy(z_c_input_grid, rc=rc)
819 call esmf_fielddestroy(zm_input_grid, rc=rc)
820
821 end subroutine cleanup_input_nst_data
822
823 end module nst_input_data
Sets up the ESMF grid objects for the input data grid and target FV3 grid.
Definition model_grid.F90:9
type(esmf_grid), public input_grid
input grid esmf grid object
integer, public i_input
i-dimension of input grid (or of each global tile)
integer, public num_tiles_input_grid
Number of tiles, input grid.
integer, public j_input
j-dimension of input grid (or of each global tile)
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data,...
character(len=500), dimension(6), public sfc_files_input_grid
File names containing input surface data.
character(len=500), public nst_files_input_grid
File name of input nst data.
character(len=500), public data_dir_input_grid
Directory containing input atm or sfc files.
character(len=25), public input_type
Input data type: