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