FV3 Bundle
fv3jedi_state_io_mod.f90
Go to the documentation of this file.
2 
3 use config_mod
4 use iso_c_binding
5 use datetime_mod
6 use fckit_log_module, only : log
7 
11 
12 !For FMS like restarts
13 use mpp_domains_mod, only: east, north
16 
17 !For GEOS like restarts
18 use netcdf
19 
20 implicit none
21 private
24 
25 contains
26 
27 ! ------------------------------------------------------------------------------
28 
29 subroutine read_fms_restart(geom, state, c_conf, vdate)
30 
31 use iso_c_binding
32 use datetime_mod
33 
34 use mpp_domains_mod, only: mpp_update_domains, dgrid_ne
37 
38 implicit none
39 
40 !Arguments
41 type(fv3jedi_geom), intent(inout) :: geom
42 type(fv3jedi_state), intent(inout) :: state !< State
43 type(c_ptr), intent(in) :: c_conf !< Configuration
44 type(datetime), intent(inout) :: vdate !< DateTime
45 
46 !Locals
47 type(restart_file_type) :: fv_restart
48 type(restart_file_type) :: tr_restart
49 type(restart_file_type) :: sf_restart
50 
51 integer :: id_restart, iounit, io_status, layout(2)
52 integer :: date_init(6), date(6), calendar_type
53 integer(kind=c_int) :: idate, isecs
54 
55 character(len=255) :: datapath_in, datapath_ti
56 character(len=255) :: filename_core
57 character(len=255) :: filename_trcr
58 character(len=255) :: filename_sfcd
59 character(len=255) :: filename_sfcw
60 character(len=255) :: filename_cplr
61 
62 character(len=20) :: sdate,validitydate
63 character(len=1024) :: buf
64 
65 integer :: k
66 
67 character(len=64):: tracer_name
68 integer :: ntracers, ntprog, nt, ierr
69 
70 integer :: print_read_info = 0
71 
72 integer :: read_crtm_surface
73 
74  !Set filenames
75  !--------------
76  filename_core = 'fv_core.res.nc'
77  filename_trcr = 'fv_tracer.res.nc'
78  filename_sfcd = 'sfc_data.nc'
79  filename_sfcw = 'srf_wnd.nc'
80  filename_cplr = 'coupler.res'
81 
82  if (config_element_exists(c_conf,"filename_core")) then
83  filename_core = config_get_string(c_conf,len(filename_core),"filename_core")
84  endif
85  if (config_element_exists(c_conf,"filename_trcr")) then
86  filename_trcr = config_get_string(c_conf,len(filename_trcr),"filename_trcr")
87  endif
88  if (config_element_exists(c_conf,"filename_sfcd")) then
89  filename_sfcd = config_get_string(c_conf,len(filename_sfcd),"filename_sfcd")
90  endif
91  if (config_element_exists(c_conf,"filename_sfcw")) then
92  filename_sfcw = config_get_string(c_conf,len(filename_sfcw),"filename_sfcw")
93  endif
94  if (config_element_exists(c_conf,"filename_cplr")) then
95  filename_cplr = config_get_string(c_conf,len(filename_cplr),"filename_cplr")
96  endif
97 
98  datapath_in = config_get_string(c_conf,len(datapath_in),"datapath_read")
99  datapath_ti = config_get_string(c_conf,len(datapath_ti),"datapath_tile")
100 
101  ! Register the variables that should be read
102  ! ------------------------------------------
103  !D-Grid winds, nonlinear model only
104  id_restart = register_restart_field(fv_restart, filename_core, 'u', state%ud, &
105  domain=geom%domain, position=north)
106  id_restart = register_restart_field(fv_restart, filename_core, 'v', state%vd, &
107  domain=geom%domain, position=east)
108 
109  !A-Grid winds, increment
110  id_restart = register_restart_field(fv_restart, filename_core, 'ua', state%ua, &
111  domain=geom%domain)
112  id_restart = register_restart_field(fv_restart, filename_core, 'va', state%va, &
113  domain=geom%domain)
114 
115  !phis
116  id_restart = register_restart_field(fv_restart, filename_core, 'phis', state%phis, &
117  domain=geom%domain)
118 
119  !Temperature
120  id_restart = register_restart_field(fv_restart, filename_core, 'T', state%t, &
121  domain=geom%domain)
122 
123  !Pressure thickness
124  id_restart = register_restart_field(fv_restart, filename_core, 'DELP', state%delp, &
125  domain=geom%domain)
126 
127  !Nonhydrostatic variables
128  if (.not. state%hydrostatic) then
129  id_restart = register_restart_field(fv_restart, filename_core, 'W', state%w, &
130  domain=geom%domain)
131  id_restart = register_restart_field(fv_restart, filename_core, 'DZ', state%delz, &
132  domain=geom%domain)
133  endif
134 
135  ! Read file and fill variables
136  ! ----------------------------
137  call restore_state(fv_restart, directory=trim(adjustl(datapath_ti)))
138  call free_restart_type(fv_restart)
139 
140 
141  !Register and read tracers
142  !-------------------------
143  id_restart = register_restart_field(tr_restart, filename_trcr, 'sphum' , state%q , &
144  domain=geom%domain)
145  id_restart = register_restart_field(tr_restart, filename_trcr, 'ice_wat', state%qi, &
146  domain=geom%domain)
147  id_restart = register_restart_field(tr_restart, filename_trcr, 'liq_wat', state%ql, &
148  domain=geom%domain)
149  id_restart = register_restart_field(tr_restart, filename_trcr, 'o3mr' , state%o3, &
150  domain=geom%domain)
151 
152  call restore_state(tr_restart, directory=trim(adjustl(datapath_ti)))
153  call free_restart_type(tr_restart)
154 
155  !Register and read surface state needed for crtm calculation
156  !------------------------------------------------------------
157  read_crtm_surface = 0
158  if (config_element_exists(c_conf,"read_crtm_surface")) then
159  read_crtm_surface = config_get_int(c_conf,"read_crtm_surface")
160  endif
161 
162  if (read_crtm_surface == 1) then
163  id_restart = register_restart_field( sf_restart, filename_sfcd, 'slmsk' , state%slmsk , domain=geom%domain)
164  id_restart = register_restart_field( sf_restart, filename_sfcd, 'sheleg', state%sheleg, domain=geom%domain)
165  id_restart = register_restart_field( sf_restart, filename_sfcd, 'tsea' , state%tsea , domain=geom%domain)
166  id_restart = register_restart_field( sf_restart, filename_sfcd, 'vtype' , state%vtype , domain=geom%domain)
167  id_restart = register_restart_field( sf_restart, filename_sfcd, 'stype' , state%stype , domain=geom%domain)
168  id_restart = register_restart_field( sf_restart, filename_sfcd, 'vfrac' , state%vfrac , domain=geom%domain)
169  id_restart = register_restart_field( sf_restart, filename_sfcd, 'stc' , state%stc , domain=geom%domain)
170  id_restart = register_restart_field( sf_restart, filename_sfcd, 'smc' , state%smc , domain=geom%domain)
171  id_restart = register_restart_field( sf_restart, filename_sfcd, 'snwdph', state%snwdph, domain=geom%domain)
172  id_restart = register_restart_field( sf_restart, filename_sfcd, 'f10m' , state%f10m , domain=geom%domain)
173 
174  call restore_state(sf_restart, directory=trim(adjustl(datapath_ti)))
175  call free_restart_type(sf_restart)
176 
177  id_restart = register_restart_field( sf_restart, filename_sfcw, 'u_srf' , state%u_srf , domain=geom%domain)
178  id_restart = register_restart_field( sf_restart, filename_sfcw, 'v_srf' , state%v_srf , domain=geom%domain)
179 
180  call restore_state(sf_restart, directory=trim(adjustl(datapath_ti)))
181  call free_restart_type(sf_restart)
182  state%havecrtmfields = .true.
183  else
184  state%havecrtmfields = .false.
185  state%slmsk = 0.0_kind_real
186  state%sheleg = 0.0_kind_real
187  state%tsea = 0.0_kind_real
188  state%vtype = 0.0_kind_real
189  state%stype = 0.0_kind_real
190  state%vfrac = 0.0_kind_real
191  state%stc = 0.0_kind_real
192  state%smc = 0.0_kind_real
193  state%u_srf = 0.0_kind_real
194  state%u_srf = 0.0_kind_real
195  state%v_srf = 0.0_kind_real
196  state%f10m = 0.0_kind_real
197  endif
198 
199  ! Get dates from file
200  !--------------------
201 
202  ! read date from coupler.res text file.
203  sdate = config_get_string(c_conf,len(sdate),"date")
204  iounit = 101
205  open(iounit, file=trim(adjustl(datapath_in))//filename_cplr, form='formatted')
206  read(iounit, '(i6)') calendar_type
207  read(iounit, '(6i6)') date_init
208  read(iounit, '(6i6)') date
209  close(iounit)
210  state%date = date
211  state%date_init = date_init
212  state%calendar_type = calendar_type
213  idate=date(1)*10000+date(2)*100+date(3)
214  isecs=date(4)*3600+date(5)*60+date(6)
215 
216  call datetime_from_ifs(vdate, idate, isecs)
217  call datetime_to_string(vdate, validitydate)
218 
219  call log%info("read_file: validity date: "//trim(validitydate))
220  call log%info("read_file: expected validity date: "//trim(sdate))
221 
222  return
223 
224 end subroutine read_fms_restart
225 
226 ! ------------------------------------------------------------------------------
227 
228 subroutine write_fms_restart(geom, state, c_conf, vdate)
230 use mpp_mod, only: mpp_pe, mpp_root_pe
231 
232 implicit none
233 
234 !Arguments
235 type(fv3jedi_geom), intent(inout) :: geom
236 type(fv3jedi_state), intent(in) :: state !< State
237 type(c_ptr), intent(in) :: c_conf !< Configuration
238 type(datetime), intent(inout) :: vdate !< DateTime
239 
240 !Locals
241 type(restart_file_type) :: fv_restart
242 type(restart_file_type) :: tr_restart
243 
244 integer :: id_restart, iounit, io_status
245 integer :: date_init(6), date(6), calendar_type, layout(2)
246 integer(kind=c_int) :: idate, isecs
247 
248 character(len=64) :: filename_core
249 character(len=64) :: filename_trcr
250 character(len=64) :: filename_cplr
251 character(len=64) :: datefile
252 
253 character(len=20) :: sdate,validitydate
254 
255 character(len=255) :: datapath_out
256 
257 
258  ! Place to save restarts
259  ! ----------------------
260  datapath_out = "Data/"
261  if (config_element_exists(c_conf,"datapath_write")) then
262  datapath_out = config_get_string(c_conf,len(datapath_out),"datapath_write")
263  endif
264 
265 
266  ! Current date
267  ! ------------
268  call datetime_to_ifs(vdate, idate, isecs)
269  date(1) = idate/10000
270  date(2) = idate/100 - date(1)*100
271  date(3) = idate - (date(1)*10000 + date(2)*100)
272  date(4) = isecs/3600
273  date(5) = (isecs - date(4)*3600)/60
274  date(6) = isecs - (date(4)*3600 + date(5)*60)
275 
276 
277  ! Naming convection for the file
278  ! ------------------------------
279  filename_core = 'fv_core.res.nc'
280  if (config_element_exists(c_conf,"filename_core")) then
281  filename_core = config_get_string(c_conf,len(filename_core),"filename_core")
282  endif
283 
284  filename_trcr = 'fv_tracer.res.nc'
285  if (config_element_exists(c_conf,"filename_trcr")) then
286  filename_trcr = config_get_string(c_conf,len(filename_trcr),"filename_trcr")
287  endif
288 
289  filename_cplr = 'coupler.res'
290  if (config_element_exists(c_conf,"filename_cplr")) then
291  filename_cplr = config_get_string(c_conf,len(filename_cplr),"filename_cplr")
292  endif
293 
294  !Append with the date
295  write(datefile,'(I4,I0.2,I0.2,A1,I0.2,I0.2,I0.2,A1)') date(1),date(2),date(3),".",date(4),date(5),date(6),"."
296  filename_core = trim(datefile)//trim(filename_core)
297  filename_trcr = trim(datefile)//trim(filename_trcr)
298  filename_cplr = trim(datefile)//trim(filename_cplr)
299 
300 
301  ! Register the variables that should be written
302  ! ---------------------------------------------
303  !D-Grid winds, nonlinear model only
304  id_restart = register_restart_field( fv_restart, filename_core, 'u', state%ud, &
305  domain=geom%domain,position=north )
306  id_restart = register_restart_field( fv_restart, filename_core, 'v', state%vd, &
307  domain=geom%domain,position=east )
308 
309  !A-Grid winds, increment
310  id_restart = register_restart_field(fv_restart, filename_core, 'ua', state%ua, &
311  domain=geom%domain )
312  id_restart = register_restart_field(fv_restart, filename_core, 'va', state%va, &
313  domain=geom%domain )
314 
315  !phis
316  id_restart = register_restart_field( fv_restart, filename_core, 'phis', state%phis, &
317  domain=geom%domain )
318 
319  !Temperature
320  id_restart = register_restart_field( fv_restart, filename_core, 'T', state%t, &
321  domain=geom%domain )
322 
323  !Pressure thickness
324  id_restart = register_restart_field( fv_restart, filename_core, 'DELP', state%delp, &
325  domain=geom%domain )
326 
327  !Nonhydrostatic state
328  if (.not. state%hydrostatic) then
329  id_restart = register_restart_field( fv_restart, filename_core, 'W', state%w, &
330  domain=geom%domain )
331  id_restart = register_restart_field( fv_restart, filename_core, 'DZ', state%delz, &
332  domain=geom%domain )
333  endif
334 
335  !Cell center lat/lon
336  id_restart = register_restart_field( fv_restart, filename_core, 'grid_lat', geom%grid_lat, &
337  domain=geom%domain )
338  id_restart = register_restart_field( fv_restart, filename_core, 'grid_lon', geom%grid_lon, &
339  domain=geom%domain )
340 
341  ! Write variables to file
342  ! -----------------------`/
343  call save_restart(fv_restart, directory=trim(adjustl(datapath_out))//'RESTART')
344  call free_restart_type(fv_restart)
345 
346 
347  !Write tracers to file
348  !---------------------
349  id_restart = register_restart_field( tr_restart, filename_trcr, 'sphum' , state%q, &
350  domain=geom%domain )
351  id_restart = register_restart_field( tr_restart, filename_trcr, 'ice_wat', state%qi, &
352  domain=geom%domain )
353  id_restart = register_restart_field( tr_restart, filename_trcr, 'liq_wat', state%ql, &
354  domain=geom%domain )
355  id_restart = register_restart_field( tr_restart, filename_trcr, 'o3mr' , state%o3, &
356  domain=geom%domain )
357 
358  call save_restart(tr_restart, directory=trim(adjustl(datapath_out))//'RESTART')
359  call free_restart_type(tr_restart)
360 
361 
362  !Write date/time info in coupler.res
363  !-----------------------------------
364  iounit = 101
365  if (mpp_pe() == mpp_root_pe()) then
366  print *,'write_file: date model init = ',state%date_init
367  print *,'write_file: date model now = ',state%date
368  print *,'write_file: date vdate = ',date
369  open(iounit, file=trim(adjustl(datapath_out))//'RESTART/'//trim(adjustl(filename_cplr)), form='formatted')
370  write( iounit, '(i6,8x,a)' ) state%calendar_type, &
371  '(Calendar: no_calendar=0, thirty_day_months=1, julian=2, gregorian=3, noleap=4)'
372  write( iounit, '(6i6,8x,a)' )date, &
373  'Model start time: year, month, day, hour, minute, second'
374  write( iounit, '(6i6,8x,a)' )date, &
375  'Current model time: year, month, day, hour, minute, second'
376  close(iounit)
377  endif
378 
379  return
380 
381 end subroutine write_fms_restart
382 
383 ! ------------------------------------------------------------------------------
384 
385 subroutine read_geos_restart(state, c_conf, vdate)
387 implicit none
388 
389 !Arguments
390 type(fv3jedi_state), intent(inout) :: state !< State
391 type(c_ptr), intent(in) :: c_conf !< Configuration
392 type(datetime), intent(inout) :: vdate !< DateTime
393 
394 character(len=255) :: datapath
395 character(len=255) :: filename_eta
396 
397 integer :: ncid, ncstat, dimid, varid
398 
399 integer :: im, jm, lm, nm, l
400 
401 integer :: date(6)
402 integer :: intdate, inttime
403 character(len=8) :: cdate
404 character(len=6) :: ctime
405 integer(kind=c_int) :: idate, isecs
406 character(len=20) :: sdate, validitydate
407 
408 integer, allocatable :: istart(:), icount(:)
409 
410 integer :: tileoff
411 logical :: tiledimension = .false.
412 
413 integer :: isc,iec,jsc,jec
414 
415 character(len=20) :: var
416 
417  !> Convenience
418  !> -----------
419  isc = state%isc
420  iec = state%iec
421  jsc = state%jsc
422  jec = state%jec
423 
424 
425  !> Set filenames
426  !> -------------
427  filename_eta = 'GEOS.bkg.eta.nc4'
428 
429  if (config_element_exists(c_conf,"filename_eta")) then
430  filename_eta = config_get_string(c_conf,len(filename_eta),"filename_eta")
431  endif
432 
433  datapath = config_get_string(c_conf,len(datapath),"datapath_read")
434 
435  filename_eta = trim(datapath)//trim("/")//trim(filename_eta )
436 
437  !> Open the file
438  ncstat = nf90_open(filename_eta, nf90_nowrite, ncid)
439  if(ncstat /= nf90_noerr) print *, trim(nf90_strerror(ncstat))
440 
441  !> Get dimensions, lon,lat,lev,time
442  ncstat = nf90_inq_dimid(ncid, "lon", dimid)
443  if(ncstat /= nf90_noerr) print *, trim(nf90_strerror(ncstat))
444  ncstat = nf90_inquire_dimension(ncid, dimid, len = im)
445  if(ncstat /= nf90_noerr) print *, trim(nf90_strerror(ncstat))
446 
447  ncstat = nf90_inq_dimid(ncid, "lat", dimid)
448  if(ncstat /= nf90_noerr) print *, trim(nf90_strerror(ncstat))
449  ncstat = nf90_inquire_dimension(ncid, dimid, len = jm)
450  if(ncstat /= nf90_noerr) print *, trim(nf90_strerror(ncstat))
451 
452  ncstat = nf90_inq_dimid(ncid, "lev", dimid)
453  if(ncstat /= nf90_noerr) print *, trim(nf90_strerror(ncstat))
454  ncstat = nf90_inquire_dimension(ncid, dimid, len = lm)
455  if(ncstat /= nf90_noerr) print *, trim(nf90_strerror(ncstat))
456 
457  ncstat = nf90_inq_dimid(ncid, "time", dimid)
458  if(ncstat /= nf90_noerr) print *, trim(nf90_strerror(ncstat))
459  ncstat = nf90_inquire_dimension(ncid, dimid, len = nm)
460  if(ncstat /= nf90_noerr) print *, trim(nf90_strerror(ncstat))
461 
462 
463  !> Read the time
464  !> -------------
465  allocate(istart(1))
466  allocate(icount(1))
467  istart = 1
468  icount = 1
469 
470  !> Get time attributes
471  ncstat = nf90_inq_varid(ncid, "time", varid)
472  if(ncstat /= nf90_noerr) print *, "time: "//trim(nf90_strerror(ncstat))
473  ncstat = nf90_get_att(ncid, varid, "begin_date", intdate)
474  if(ncstat /= nf90_noerr) print *, "time: "//trim(nf90_strerror(ncstat))
475  ncstat = nf90_get_att(ncid, varid, "begin_time", inttime)
476  if(ncstat /= nf90_noerr) print *, "time: "//trim(nf90_strerror(ncstat))
477 
478  !> Pad with leading zeros if need be
479  write(cdate,"(I0.8)") intdate
480  write(ctime,"(I0.6)") inttime
481 
482  !> Back to integer
483  read(cdate(1:4),*) date(1)
484  read(cdate(5:6),*) date(2)
485  read(cdate(7:8),*) date(3)
486  read(ctime(1:2),*) date(4)
487  read(ctime(3:4),*) date(5)
488  read(ctime(5:6),*) date(6)
489 
490  !> To idate/isecs for Jedi
491  idate = date(1)*10000 + date(2)*100 + date(3)
492  isecs = date(4)*3600 + date(5)*60 + date(6)
493 
494  call datetime_from_ifs(vdate, idate, isecs)
495  call datetime_to_string(vdate, validitydate)
496 
497  !> Print info to user
498  sdate = config_get_string(c_conf,len(sdate),"date")
499  call log%info("read_file: validity date: "//trim(validitydate))
500  call log%info("read_file: expected validity date: "//trim(sdate))
501 
502  !> Make sure file dimensions equal to geometry
503  if ( im /= state%npx-1 .or. lm /= state%npz) then
504  call abor1_ftn("GEOS restarts: restart dimension not compatible with geometry")
505  endif
506 
507  !> GEOS can use concatenated tiles or tile as a dimension
508  if ( (im == state%npx-1) .and. (jm == 6*(state%npy-1) ) ) then
509  tiledimension = .false.
510  tileoff = (state%ntile-1)*(jm/state%ntiles)
511  else
512  tiledimension = .true.
513  tileoff = 0
514  call abor1_ftn("GEOS restarts: tile dimension in file not done yet")
515  endif
516 
517 
518  !Rank three variables
519  !--------------------
520  deallocate(istart,icount)
521 
522  if (.not. tiledimension) then
523  allocate(istart(4))
524  allocate(icount(4))
525  istart(1) = isc
526  istart(2) = tileoff + jsc
527  istart(3) = 1
528  istart(4) = 1
529 
530  icount(1) = iec-isc+1
531  icount(2) = jec-jsc+1
532  icount(3) = state%npz
533  icount(4) = 1
534  else
535  allocate(istart(5))
536  allocate(icount(5))
537  istart(1) = isc
538  istart(2) = jsc
539  istart(3) = state%ntile
540  istart(4) = 1
541  istart(5) = 1
542 
543  icount(1) = iec-isc+1
544  icount(2) = jec-jsc+1
545  icount(3) = 1
546  icount(4) = state%npz
547  icount(5) = 1
548  endif
549 
550  var = 'ud'
551  ncstat = nf90_inq_varid(ncid, trim(var), varid)
552  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
553  ncstat = nf90_get_var(ncid, varid, state%ud(isc:iec,jsc:jec,:), istart, icount)
554  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
555 
556  var = 'vd'
557  ncstat = nf90_inq_varid(ncid, trim(var), varid)
558  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
559  ncstat = nf90_get_var(ncid, varid, state%vd(isc:iec,jsc:jec,:), istart, icount)
560  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
561 
562  var = 'ua'
563  ncstat = nf90_inq_varid(ncid, trim(var), varid)
564  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
565  ncstat = nf90_get_var(ncid, varid, state%ua(isc:iec,jsc:jec,:), istart, icount)
566  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
567 
568  var = 'va'
569  ncstat = nf90_inq_varid(ncid, trim(var), varid)
570  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
571  ncstat = nf90_get_var(ncid, varid, state%va(isc:iec,jsc:jec,:), istart, icount)
572  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
573 
574  var = 't'
575  ncstat = nf90_inq_varid(ncid, trim(var), varid)
576  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
577  ncstat = nf90_get_var(ncid, varid, state%t(isc:iec,jsc:jec,:), istart, icount)
578  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
579 
580  var = 'delp'
581  ncstat = nf90_inq_varid(ncid, trim(var), varid)
582  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
583  ncstat = nf90_get_var(ncid, varid, state%delp(isc:iec,jsc:jec,:), istart, icount)
584  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
585 
586  var = 'q'
587  ncstat = nf90_inq_varid(ncid, trim(var), varid)
588  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
589  ncstat = nf90_get_var(ncid, varid, state%q(isc:iec,jsc:jec,:), istart, icount)
590  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
591 
592  var = 'qi'
593  ncstat = nf90_inq_varid(ncid, trim(var), varid)
594  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
595  ncstat = nf90_get_var(ncid, varid, state%qi(isc:iec,jsc:jec,:), istart, icount)
596  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
597 
598  var = 'ql'
599  ncstat = nf90_inq_varid(ncid, trim(var), varid)
600  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
601  ncstat = nf90_get_var(ncid, varid, state%ql(isc:iec,jsc:jec,:), istart, icount)
602  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
603 
604  var = 'o3mr'
605  ncstat = nf90_inq_varid(ncid, trim(var), varid)
606  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
607  ncstat = nf90_get_var(ncid, varid, state%o3(isc:iec,jsc:jec,:), istart, icount)
608  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
609 
610  var = 'qls'
611  ncstat = nf90_inq_varid(ncid, trim(var), varid)
612  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
613  ncstat = nf90_get_var(ncid, varid, state%qls(isc:iec,jsc:jec,:), istart, icount)
614  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
615 
616  var = 'qcn'
617  ncstat = nf90_inq_varid(ncid, trim(var), varid)
618  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
619  ncstat = nf90_get_var(ncid, varid, state%qcn(isc:iec,jsc:jec,:), istart, icount)
620  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
621 
622  var = 'cfcn'
623  ncstat = nf90_inq_varid(ncid, trim(var), varid)
624  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
625  ncstat = nf90_get_var(ncid, varid, state%cfcn(isc:iec,jsc:jec,:), istart, icount)
626  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
627 
628  !Rank two variables
629  !------------------
630  deallocate(istart,icount)
631 
632  if (.not. tiledimension) then
633  allocate(istart(3))
634  allocate(icount(3))
635  istart(1) = isc
636  istart(2) = tileoff + jsc
637  istart(3) = 1
638 
639  icount(1) = iec-isc+1
640  icount(2) = jec-jsc+1
641  icount(3) = 1
642  else
643  allocate(istart(4))
644  allocate(icount(4))
645  istart(1) = isc
646  istart(2) = jsc
647  istart(3) = state%ntile
648  istart(4) = 1
649 
650  icount(1) = iec-isc+1
651  icount(2) = jec-jsc+1
652  icount(3) = 1
653  icount(4) = 1
654  endif
655 
656  var = 'phis'
657  ncstat = nf90_inq_varid(ncid, trim(var), varid)
658  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
659  ncstat = nf90_get_var(ncid, varid, state%phis(isc:iec,jsc:jec), istart, icount)
660  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
661 
662  var = 'frland'
663  ncstat = nf90_inq_varid(ncid, trim(var), varid)
664  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
665  ncstat = nf90_get_var(ncid, varid, state%frland(isc:iec,jsc:jec), istart, icount)
666  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
667 
668  var = 'frocean'
669  ncstat = nf90_inq_varid(ncid, trim(var), varid)
670  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
671  ncstat = nf90_get_var(ncid, varid, state%frocean(isc:iec,jsc:jec), istart, icount)
672  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
673 
674  var = 'kcbl'
675  ncstat = nf90_inq_varid(ncid, trim(var), varid)
676  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
677  ncstat = nf90_get_var(ncid, varid, state%kcbl(isc:iec,jsc:jec), istart, icount)
678  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
679 
680  var = 'ts'
681  ncstat = nf90_inq_varid(ncid, trim(var), varid)
682  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
683  ncstat = nf90_get_var(ncid, varid, state%ts(isc:iec,jsc:jec), istart, icount)
684  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
685 
686  var = 'khl'
687  ncstat = nf90_inq_varid(ncid, trim(var), varid)
688  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
689  ncstat = nf90_get_var(ncid, varid, state%khl(isc:iec,jsc:jec), istart, icount)
690  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
691 
692  var = 'khu'
693  ncstat = nf90_inq_varid(ncid, trim(var), varid)
694  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
695  ncstat = nf90_get_var(ncid, varid, state%khu(isc:iec,jsc:jec), istart, icount)
696  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
697 
698  var = 'varflt'
699  ncstat = nf90_inq_varid(ncid, trim(var), varid)
700  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
701  ncstat = nf90_get_var(ncid, varid, state%varflt(isc:iec,jsc:jec), istart, icount)
702  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
703 
704  var = 'ustar'
705  ncstat = nf90_inq_varid(ncid, trim(var), varid)
706  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
707  ncstat = nf90_get_var(ncid, varid, state%ustar(isc:iec,jsc:jec), istart, icount)
708  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
709 
710  var = 'bstar'
711  ncstat = nf90_inq_varid(ncid, trim(var), varid)
712  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
713  ncstat = nf90_get_var(ncid, varid, state%bstar(isc:iec,jsc:jec), istart, icount)
714  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
715 
716  var = 'zpbl'
717  ncstat = nf90_inq_varid(ncid, trim(var), varid)
718  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
719  ncstat = nf90_get_var(ncid, varid, state%zpbl(isc:iec,jsc:jec), istart, icount)
720  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
721 
722  var = 'cm'
723  ncstat = nf90_inq_varid(ncid, trim(var), varid)
724  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
725  ncstat = nf90_get_var(ncid, varid, state%cm(isc:iec,jsc:jec), istart, icount)
726  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
727 
728  var = 'ct'
729  ncstat = nf90_inq_varid(ncid, trim(var), varid)
730  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
731  ncstat = nf90_get_var(ncid, varid, state%ct(isc:iec,jsc:jec), istart, icount)
732  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
733 
734  var = 'cq'
735  ncstat = nf90_inq_varid(ncid, trim(var), varid)
736  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
737  ncstat = nf90_get_var(ncid, varid, state%cq(isc:iec,jsc:jec), istart, icount)
738  if(ncstat /= nf90_noerr) print *, trim(var)//trim(nf90_strerror(ncstat))
739 
740 
741  !Close this file
742  ncstat = nf90_close(ncid)
743  if(ncstat /= nf90_noerr) print *, trim(nf90_strerror(ncstat))
744 
745  deallocate(istart,icount)
746 
747 
748 end subroutine read_geos_restart
749 
750 ! ------------------------------------------------------------------------------
751 
752 subroutine write_geos_restart(geom, state, c_conf, vdate)
754 implicit none
755 
756 !Arguments
757 type(fv3jedi_geom), intent(inout) :: geom
758 type(fv3jedi_state), intent(in) :: state !< State
759 type(c_ptr), intent(in) :: c_conf !< Configuration
760 type(datetime), intent(inout) :: vdate !< DateTime
761 
762 
763 end subroutine write_geos_restart
764 
765 ! ------------------------------------------------------------------------------
766 
767 end module fv3jedi_state_io_mod
integer, parameter, public model_atmos
subroutine, public free_restart_type(fileObj)
Definition: fms_io.F90:1413
Fortran derived type to hold FV3JEDI state.
subroutine, public read_fms_restart(geom, state, c_conf, vdate)
subroutine, public get_number_tracers(model, num_tracers, num_prog, num_diag, num_family)
Fortran derived type to hold geometry data for the FV3JEDI model.
Definition: mpp.F90:39
subroutine, public read_geos_restart(state, c_conf, vdate)
subroutine, public set_tracer_profile(model, n, tracer, err_msg)
subroutine, public write_fms_restart(geom, state, c_conf, vdate)
Utilities for state for the FV3JEDI model.
Fortran module handling geometry for the FV3 model.
subroutine, public get_tracer_names(model, n, name, longname, units, err_msg)
integer, parameter, public kind_real
subroutine, public write_geos_restart(geom, state, c_conf, vdate)
subroutine, public save_restart(fileObj, time_stamp, directory, append, time_level)
Definition: fms_io.F90:2467