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