6 use fckit_log_module,
only : log
21 use fckit_mpi_module,
only : fckit_mpi_comm
39 type(c_ptr),
intent(in) :: c_conf
40 type(datetime),
intent(inout) :: vdate
49 use mpp_mod,
only: mpp_pe, mpp_root_pe
56 type(c_ptr),
intent(in) :: c_conf
57 type(datetime),
intent(inout) :: vdate
63 integer :: id_restart, iounit, io_status
64 integer :: date_init(6), date(6), calendar_type, layout(2)
65 integer(kind=c_int) :: idate, isecs
67 character(len=64) :: filename_core
68 character(len=64) :: filename_trcr
69 character(len=64) :: filename_cplr
70 character(len=64) :: datefile
72 character(len=20) :: sdate,validitydate
74 character(len=255) :: datapath_out
79 datapath_out =
"Data/" 80 if (config_element_exists(c_conf,
"datapath_write"))
then 81 datapath_out = config_get_string(c_conf,len(datapath_out),
"datapath_write")
87 call datetime_to_ifs(vdate, idate, isecs)
89 date(2) = idate/100 - date(1)*100
90 date(3) = idate - (date(1)*10000 + date(2)*100)
92 date(5) = (isecs - date(4)*3600)/60
93 date(6) = isecs - (date(4)*3600 + date(5)*60)
98 filename_core =
'fv_core.res.nc' 99 if (config_element_exists(c_conf,
"filename_core"))
then 100 filename_core = config_get_string(c_conf,len(filename_core),
"filename_core")
103 filename_trcr =
'fv_tracer.res.nc' 104 if (config_element_exists(c_conf,
"filename_trcr"))
then 105 filename_trcr = config_get_string(c_conf,len(filename_trcr),
"filename_trcr")
108 filename_cplr =
'coupler.res' 109 if (config_element_exists(c_conf,
"filename_cplr"))
then 110 filename_cplr = config_get_string(c_conf,len(filename_cplr),
"filename_cplr")
114 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),
"." 115 filename_core = trim(datefile)//trim(filename_core)
116 filename_trcr = trim(datefile)//trim(filename_trcr)
117 filename_cplr = trim(datefile)//trim(filename_cplr)
138 if (.not. incr%hydrostatic)
then 153 call save_restart(fv_restart, directory=trim(adjustl(datapath_out))//
'RESTART')
168 call save_restart(tr_restart, directory=trim(adjustl(datapath_out))//
'RESTART')
175 if (mpp_pe() == mpp_root_pe())
then 176 print *,
'write_file: date model init = ',incr%date_init
177 print *,
'write_file: date model now = ',incr%date
178 print *,
'write_file: date vdate = ',date
179 open(iounit, file=trim(adjustl(datapath_out))//
'RESTART/'//trim(adjustl(filename_cplr)), form=
'formatted')
180 write( iounit,
'(i6,8x,a)' ) incr%calendar_type, &
181 '(Calendar: no_calendar=0, thirty_day_months=1, julian=2, gregorian=3, noleap=4)' 182 write( iounit,
'(6i6,8x,a)' )date, &
183 'Model start time: year, month, day, hour, minute, second' 184 write( iounit,
'(6i6,8x,a)' )date, &
185 'Current model time: year, month, day, hour, minute, second' 202 type(c_ptr),
intent(in) :: c_conf
203 type(datetime),
intent(inout) :: vdate
217 type(c_ptr),
intent(in) :: c_conf
218 type(datetime),
intent(inout) :: vdate
221 character(len=255) :: datapath
222 character(len=255) :: filename
223 character(len=64) :: datefile
226 integer :: geostiledim = 0
228 integer,
parameter :: nvar = 10
229 integer :: ncid, varid(nvar)
232 integer(kind=c_int) :: idate, isecs
234 integer :: isc,iec,jsc,jec,im,jm,km
235 integer :: x_dimid, y_dimid, z_dimid
236 integer :: t_dimid, tile_dimid
237 integer,
allocatable :: dimids2(:), dimids3(:)
238 integer,
allocatable :: istart2(:), icount2(:)
239 integer,
allocatable :: istart3(:), icount3(:)
242 type(fckit_mpi_comm) :: f_comm
251 f_comm = fckit_mpi_comm()
256 if (config_element_exists(c_conf,
"datapath"))
then 257 datapath = config_get_string(c_conf,len(datapath),
"datapath")
263 call datetime_to_ifs(vdate, idate, isecs)
265 date(1) = idate/10000
266 date(2) = idate/100 - date(1)*100
267 date(3) = idate - (date(1)*10000 + date(2)*100)
269 date(5) = (isecs - date(4)*3600)/60
270 date(6) = isecs - (date(4)*3600 + date(5)*60)
274 if (config_element_exists(c_conf,
"geos_tile_dim"))
then 275 geostiledim = config_get_int(c_conf,
"geos_tile_dim")
280 filename =
'GEOS.eta.' 282 if (config_element_exists(c_conf,
"filename"))
then 283 filename = config_get_string(c_conf,len(filename),
"filename")
287 write(datefile,
'(I4,I0.2,I0.2,A1,I0.2,I0.2,I0.2)') date(1),date(2),date(3),
"_",date(4),date(5),date(6)
288 filename = trim(datapath)//trim(filename)//trim(datefile)//trim(
"z.nc4")
290 writeprec = nf90_float
294 if (f_comm%rank() == 0)
then 297 if (geostiledim == 0)
then 298 jm = 6*(geom%npy - 1)
305 call nccheck ( nf90_create(trim(filename), nf90_clobber, ncid),
"nf90_create" )
308 call nccheck ( nf90_def_dim(ncid,
"lon", im, x_dimid),
"nf90_def_dim lon" )
309 call nccheck ( nf90_def_dim(ncid,
"lat", jm, y_dimid),
"nf90_def_dim lat" )
310 call nccheck ( nf90_def_dim(ncid,
"lev", km, z_dimid),
"nf90_def_dim lev" )
311 call nccheck ( nf90_def_dim(ncid,
"time", 1, t_dimid),
"nf90_def_dim time" )
314 if (geostiledim == 1)
then 316 call nccheck ( nf90_def_dim(ncid,
"tile", geom%ntiles, tile_dimid),
"nf90_def_dim tile" )
319 dimids2 = (/ x_dimid, y_dimid, t_dimid, tile_dimid /)
321 dimids3 = (/ x_dimid, y_dimid, z_dimid, t_dimid, tile_dimid /)
326 dimids2 = (/ x_dimid, y_dimid /)
328 dimids3 = (/ x_dimid, y_dimid, z_dimid, t_dimid /)
334 call nccheck( nf90_def_var(ncid,
"lon", nf90_double, dimids2, varid(1)),
"nf90_def_var lon" )
335 call nccheck( nf90_def_var(ncid,
"lat", nf90_double, dimids2, varid(2)),
"nf90_def_var lat" )
338 call nccheck( nf90_def_var(ncid,
"ua" , writeprec , dimids3, varid(3)),
"nf90_def_var ua" )
341 call nccheck( nf90_enddef(ncid),
"nf90_enddef" )
342 call nccheck( nf90_close(ncid),
"nf90_close" )
344 deallocate(dimids3,dimids2)
350 call f_comm%broadcast(varid,0)
354 if (geostiledim == 1)
then 356 allocate(istart3(5),istart2(4))
357 allocate(icount3(5),icount2(4))
361 istart3(3) = geom%ntile
364 icount3(1) = iec-isc+1
365 icount3(2) = jec-jsc+1
367 icount3(4) = geom%npz
372 istart2(3) = geom%ntile
374 icount2(1) = iec-isc+1
375 icount2(2) = jec-jsc+1
381 allocate(istart3(4),istart2(2))
382 allocate(icount3(4),icount2(2))
385 istart3(2) = (geom%ntile-1)*(jm/geom%ntiles) + jsc
388 icount3(1) = iec-isc+1
389 icount3(2) = jec-jsc+1
390 icount3(3) = geom%npz
394 istart2(2) = (geom%ntile-1)*(jm/geom%ntiles) + jsc
396 icount2(1) = iec-isc+1
397 icount2(2) = jec-jsc+1
402 call nccheck( nf90_open(trim(filename), nf90_write, ncid),
"nf90_open" )
405 call nccheck( nf90_put_var(ncid, varid(1), geom%grid_lon(isc:iec,jsc:jec), istart2, icount2),
"nf90_put_var lon" )
411 call nccheck( nf90_close(ncid),
"nf90_close" )
413 deallocate(istart2,istart3)
414 deallocate(icount2,icount3)
416 call abor1_ftn(
"done")
425 integer,
intent ( in) :: status
426 character(len=*),
optional :: iam
428 character(len=255) :: error_descr
430 if(status /= nf90_noerr)
then 432 error_descr =
"fv3jedi_increment_io_mod: NetCDF error, aborting" 434 if (
present(iam))
then 435 error_descr = trim(error_descr)//
", "//trim(iam)
438 error_descr = trim(error_descr)//
". Error code: "//trim(nf90_strerror(status))
440 call abor1_ftn(trim(error_descr))
Fortran derived type to hold FV3JEDI increment.
subroutine, public free_restart_type(fileObj)
Fortran derived type to hold geometry data for the FV3JEDI model.
subroutine, public write_fms_restart(geom, incr, c_conf, vdate)
Utilities for increment for the FV3JEDI model.
subroutine, public write_geos_restart(geom, incr, c_conf, vdate)
Fortran module handling geometry for the FV3 model.
integer, parameter, public kind_real
subroutine nccheck(status, iam)
subroutine, public read_geos_restart(geom, incr, c_conf, vdate)
subroutine, public save_restart(fileObj, time_stamp, directory, append, time_level)
subroutine, public read_fms_restart(geom, incr, c_conf, vdate)