89 use fms_mod
, only: file_exist
90 use fms_io_mod
, only: fms_io_exit, get_tile_string, &
91 restart_file_type, register_restart_field, &
92 save_restart, restore_state, &
93 set_domain, nullify_domain, set_filename_appendix, &
94 get_mosaic_tile_file, get_instance_filename, &
95 save_restart_border, restore_state_border, free_restart_type, &
97 use mpp_mod
, only: mpp_error, fatal, note, warning, mpp_root_pe, &
98 mpp_sync, mpp_pe, mpp_declare_pelist
99 use mpp_domains_mod
, only: domain2d, east, west, north, center, south, corner, &
100 mpp_get_compute_domain, mpp_get_data_domain, &
101 mpp_get_layout, mpp_get_ntile_count, &
102 mpp_get_global_domain
103 use tracer_manager_mod
, only: tr_get_tracer_names=>get_tracer_names, &
104 get_tracer_names, get_number_tracers, &
105 set_tracer_profile, &
107 use field_manager_mod
, only: model_atmos
144 type(domain2d),
intent(inout) :: fv_domain
147 character(len=64) :: fname, tracer_name
148 character(len=6) :: stile_name
149 integer :: isc, iec, jsc, jec, n, nt, nk, ntracers
151 integer :: ks, ntiles
154 character(len=128) :: tracer_longname, tracer_units
156 ntileme =
size(atm(:))
158 call restore_state(atm(1)%Fv_restart)
159 if (atm(1)%flagstruct%external_eta)
then 163 if ( use_ncep_sst .or. atm(1)%flagstruct%nudge .or. atm(1)%flagstruct%ncep_ic )
then 164 call mpp_error(note,
'READING FROM SST_RESTART DISABLED')
169 ntiles = mpp_get_ntile_count(fv_domain)
170 if(ntiles == 1 .and. .not. atm(1)%neststruct%nested)
then 171 stile_name =
'.tile1' 177 call restore_state(atm(n)%Fv_tile_restart)
180 fname =
'INPUT/fv_tracer.res'//trim(stile_name)//
'.nc' 181 if (file_exist(fname))
then 182 call restore_state(atm(n)%Tra_restart)
184 call mpp_error(note,
'==> Warning from fv_read_restart: Expected file '//trim(fname)//
' does not exist')
188 fname =
'INPUT/fv_srf_wnd.res'//trim(stile_name)//
'.nc' 189 if (file_exist(fname))
then 190 call restore_state(atm(n)%Rsf_restart)
191 atm(n)%flagstruct%srf_init = .true.
193 call mpp_error(note,
'==> Warning from fv_read_restart: Expected file '//trim(fname)//
' does not exist')
194 atm(n)%flagstruct%srf_init = .false.
197 if ( atm(n)%flagstruct%fv_land )
then 199 fname =
'INPUT/mg_drag.res'//trim(stile_name)//
'.nc' 200 if (file_exist(fname))
then 201 call restore_state(atm(n)%Mg_restart)
203 call mpp_error(note,
'==> Warning from fv_read_restart: Expected file '//trim(fname)//
' does not exist')
206 fname =
'INPUT/fv_land.res'//trim(stile_name)//
'.nc' 207 if (file_exist(fname))
then 208 call restore_state(atm(n)%Lnd_restart)
210 call mpp_error(note,
'==> Warning from fv_read_restart: Expected file '//trim(fname)//
' does not exist')
225 type(domain2d),
intent(inout) :: fv_domain
227 integer :: n, ntracers, ntprog, nt, isc, iec, jsc, jec, id_restart
228 character(len=6) :: stile_name
229 character(len=64):: fname, tracer_name
230 type(restart_file_type) :: Tra_restart_r
238 call get_number_tracers(model_atmos, num_tracers=ntracers, num_prog=ntprog)
241 ntiles = mpp_get_ntile_count(fv_domain)
242 if(ntiles == 1 .and. .not. atm(1)%neststruct%nested)
then 243 stile_name =
'.tile1' 248 fname =
'fv_tracer.res'//trim(stile_name)//
'.nc' 250 call get_tracer_names(model_atmos, nt, tracer_name)
251 call set_tracer_profile (model_atmos, nt, atm(n)%q(isc:iec,jsc:jec,:,nt) )
252 id_restart = register_restart_field(tra_restart_r, fname, tracer_name, atm(n)%q(:,:,:,nt), &
253 domain=fv_domain, mandatory=.false., tile_count=n)
255 do nt = ntprog+1, ntracers
256 call get_tracer_names(model_atmos, nt, tracer_name)
257 call set_tracer_profile (model_atmos, nt, atm(n)%qdiag(isc:iec,jsc:jec,:,nt) )
258 id_restart = register_restart_field(tra_restart_r, fname, tracer_name, atm(n)%qdiag(:,:,:,nt), &
259 domain=fv_domain, mandatory=.false., tile_count=n)
261 if (file_exist(
'INPUT'//trim(fname)))
then 262 call restore_state(tra_restart_r)
263 call free_restart_type(tra_restart_r)
265 call mpp_error(note,
'==> Warning from fv_io_read_tracers: Expected file '//trim(fname)//
' does not exist')
278 type(domain2d),
intent(inout) :: fv_domain
281 character(len=64) :: fname, tracer_name
282 character(len=6) :: stile_name
283 integer :: isc, iec, jsc, jec, n, nt, nk, ntracers, ntprog, ntdiag
284 integer :: isd, ied, jsd, jed
286 type(restart_file_type) :: FV_restart_r, FV_tile_restart_r, Tra_restart_r
287 integer :: id_restart
291 real,
allocatable:: ak_r(:), bk_r(:)
292 real,
allocatable:: u_r(:,:,:), v_r(:,:,:), pt_r(:,:,:), delp_r(:,:,:)
293 real,
allocatable:: w_r(:,:,:), delz_r(:,:,:), ze0_r(:,:,:)
294 real,
allocatable:: q_r(:,:,:,:), qdiag_r(:,:,:,:)
296 integer npz, npz_rst, ng
299 npz_rst = atm(1)%flagstruct%npz_rst
300 isc = atm(1)%bd%isc; iec = atm(1)%bd%iec; jsc = atm(1)%bd%jsc; jec = atm(1)%bd%jec
303 isd = isc - ng; ied = iec + ng
304 jsd = jsc - ng; jed = jec + ng
308 ntprog =
size(atm(1)%q,4)
309 ntdiag =
size(atm(1)%qdiag,4)
310 ntracers = ntprog+ntdiag
316 allocate ( ak_r(npz_rst+1) )
317 allocate ( bk_r(npz_rst+1) )
319 allocate ( u_r(isc:iec, jsc:jec+1,npz_rst) )
320 allocate ( v_r(isc:iec+1,jsc:jec ,npz_rst) )
322 allocate ( pt_r(isc:iec, jsc:jec, npz_rst) )
323 allocate ( delp_r(isc:iec, jsc:jec, npz_rst) )
324 allocate ( q_r(isc:iec, jsc:jec, npz_rst, ntprog) )
325 allocate (qdiag_r(isc:iec, jsc:jec, npz_rst, ntprog+1:ntracers) )
327 if ( (.not.atm(1)%flagstruct%hydrostatic) .and. (.not.atm(1)%flagstruct%make_nh) )
then 328 allocate ( w_r(isc:iec, jsc:jec, npz_rst) )
329 allocate ( delz_r(isc:iec, jsc:jec, npz_rst) )
330 if ( atm(1)%flagstruct%hybrid_z ) &
331 allocate ( ze0_r(isc:iec, jsc:jec, npz_rst+1) )
334 fname =
'fv_core.res.nc' 335 id_restart = register_restart_field(fv_restart_r, fname,
'ak', ak_r(:), no_domain=.true.)
336 id_restart = register_restart_field(fv_restart_r, fname,
'bk', bk_r(:), no_domain=.true.)
337 call restore_state(fv_restart_r)
338 call free_restart_type(fv_restart_r)
341 ntiles = mpp_get_ntile_count(fv_domain)
342 if(ntiles == 1 .and. .not. atm(1)%neststruct%nested)
then 343 stile_name =
'.tile1' 350 fname =
'fv_core.res'//trim(stile_name)//
'.nc' 351 id_restart = register_restart_field(fv_tile_restart_r, fname,
'u', u_r, &
352 domain=fv_domain, position=north,tile_count=n)
353 id_restart = register_restart_field(fv_tile_restart_r, fname,
'v', v_r, &
354 domain=fv_domain, position=east,tile_count=n)
355 if (.not.atm(n)%flagstruct%hydrostatic)
then 356 id_restart = register_restart_field(fv_tile_restart_r, fname,
'W', w_r, &
357 domain=fv_domain, mandatory=.false., tile_count=n)
358 id_restart = register_restart_field(fv_tile_restart_r, fname,
'DZ', delz_r, &
359 domain=fv_domain, mandatory=.false., tile_count=n)
360 if ( atm(n)%flagstruct%hybrid_z )
then 361 id_restart = register_restart_field(fv_tile_restart_r, fname,
'ZE0', ze0_r, &
362 domain=fv_domain, mandatory=.false., tile_count=n)
365 id_restart = register_restart_field(fv_tile_restart_r, fname,
'T', pt_r, &
366 domain=fv_domain, tile_count=n)
367 id_restart = register_restart_field(fv_tile_restart_r, fname,
'delp', delp_r, &
368 domain=fv_domain, tile_count=n)
369 id_restart = register_restart_field(fv_tile_restart_r, fname,
'phis', atm(n)%phis, &
370 domain=fv_domain, tile_count=n)
371 call restore_state(fv_tile_restart_r)
372 call free_restart_type(fv_tile_restart_r)
373 fname =
'INPUT/fv_srf_wnd.res'//trim(stile_name)//
'.nc' 374 if (file_exist(fname))
then 375 call restore_state(atm(n)%Rsf_restart)
376 atm(n)%flagstruct%srf_init = .true.
378 call mpp_error(note,
'==> Warning from remap_restart: Expected file '//trim(fname)//
' does not exist')
379 atm(n)%flagstruct%srf_init = .false.
382 if ( atm(n)%flagstruct%fv_land )
then 384 fname =
'INPUT/mg_drag.res'//trim(stile_name)//
'.nc' 385 if (file_exist(fname))
then 386 call restore_state(atm(n)%Mg_restart)
388 call mpp_error(note,
'==> Warning from remap_restart: Expected file '//trim(fname)//
' does not exist')
391 fname =
'INPUT/fv_land.res'//trim(stile_name)//
'.nc' 392 if (file_exist(fname))
then 393 call restore_state(atm(n)%Lnd_restart)
395 call mpp_error(note,
'==> Warning from remap_restart: Expected file '//trim(fname)//
' does not exist')
399 fname =
'fv_tracer.res'//trim(stile_name)//
'.nc' 400 if (file_exist(
'INPUT'//trim(fname)))
then 402 call get_tracer_names(model_atmos, nt, tracer_name)
403 call set_tracer_profile (model_atmos, nt, q_r(isc:iec,jsc:jec,:,nt) )
404 id_restart = register_restart_field(tra_restart_r, fname, tracer_name, q_r(:,:,:,nt), &
405 domain=fv_domain, mandatory=.false., tile_count=n)
407 do nt = ntprog+1, ntracers
408 call get_tracer_names(model_atmos, nt, tracer_name)
409 call set_tracer_profile (model_atmos, nt, qdiag_r(isc:iec,jsc:jec,:,nt) )
410 id_restart = register_restart_field(tra_restart_r, fname, tracer_name, qdiag_r(:,:,:,nt), &
411 domain=fv_domain, mandatory=.false., tile_count=n)
413 call restore_state(tra_restart_r)
414 call free_restart_type(tra_restart_r)
416 call mpp_error(note,
'==> Warning from remap_restart: Expected file '//trim(fname)//
' does not exist')
419 call rst_remap(npz_rst, npz, isc, iec, jsc, jec, isd, ied, jsd, jed, ntracers, ntprog, &
420 delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r,&
421 atm(n)%delp, atm(n)%u, atm(n)%v, atm(n)%w, atm(n)%delz, atm(n)%pt, atm(n)%q, &
422 atm(n)%qdiag, ak_r, bk_r, atm(n)%ptop, atm(n)%ak, atm(n)%bk, &
423 atm(n)%flagstruct%hydrostatic, atm(n)%flagstruct%make_nh, atm(n)%domain, &
424 atm(n)%gridstruct%square_domain)
434 deallocate( qdiag_r )
436 if ( (.not.atm(1)%flagstruct%hydrostatic) .and. (.not.atm(1)%flagstruct%make_nh) )
then 438 deallocate ( delz_r )
439 if ( atm(1)%flagstruct%hybrid_z )
deallocate ( ze0_r )
449 character(len=64) :: fname
450 integer :: id_restart
453 call mpp_error(note,
'READING FROM SST_restart DISABLED')
464 type(domain2d),
intent(inout) :: fv_domain
467 character(len=64) :: fname, tracer_name
468 character(len=6) :: gn, stile_name
469 integer :: id_restart
470 integer :: n, nt, ntracers, ntprog, ntdiag, ntileMe, ntiles
472 ntileme =
size(atm(:))
473 ntprog =
size(atm(1)%q,4)
474 ntdiag =
size(atm(1)%qdiag,4)
475 ntracers = ntprog+ntdiag
478 if (atm(1)%grid_number > 1)
then 479 write(gn,
'(A4, I2.2)')
"nest", atm(1)%grid_number
483 call set_filename_appendix(gn)
486 ntiles = mpp_get_ntile_count(fv_domain)
487 if(ntiles == 1 .and. .not. atm(1)%neststruct%nested)
then 488 stile_name =
'.tile1' 495 call mpp_error(note,
'READING FROM SST_RESTART DISABLED')
503 fname =
'fv_core.res.nc' 504 id_restart = register_restart_field(atm(1)%Fv_restart, fname,
'ak', atm(1)%ak(:), no_domain=.true.)
505 id_restart = register_restart_field(atm(1)%Fv_restart, fname,
'bk', atm(1)%bk(:), no_domain=.true.)
508 fname =
'fv_core.res'//trim(stile_name)//
'.nc' 509 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'u', atm(n)%u, &
510 domain=fv_domain, position=north,tile_count=n)
511 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'v', atm(n)%v, &
512 domain=fv_domain, position=east,tile_count=n)
513 if (.not.atm(n)%flagstruct%hydrostatic)
then 514 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'W', atm(n)%w, &
515 domain=fv_domain, mandatory=.false., tile_count=n)
516 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'DZ', atm(n)%delz, &
517 domain=fv_domain, mandatory=.false., tile_count=n)
518 if ( atm(n)%flagstruct%hybrid_z )
then 519 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'ZE0', atm(n)%ze0, &
520 domain=fv_domain, mandatory=.false., tile_count=n)
523 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'T', atm(n)%pt, &
524 domain=fv_domain, tile_count=n)
525 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'delp', atm(n)%delp, &
526 domain=fv_domain, tile_count=n)
527 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'phis', atm(n)%phis, &
528 domain=fv_domain, tile_count=n)
531 if (atm(n)%flagstruct%agrid_vel_rst)
then 532 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'ua', atm(n)%ua, &
533 domain=fv_domain, tile_count=n, mandatory=.false.)
534 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'va', atm(n)%va, &
535 domain=fv_domain, tile_count=n, mandatory=.false.)
538 fname =
'fv_srf_wnd.res'//trim(stile_name)//
'.nc' 539 id_restart = register_restart_field(atm(n)%Rsf_restart, fname,
'u_srf', atm(n)%u_srf, &
540 domain=fv_domain, tile_count=n)
541 id_restart = register_restart_field(atm(n)%Rsf_restart, fname,
'v_srf', atm(n)%v_srf, &
542 domain=fv_domain, tile_count=n)
544 id_restart = register_restart_field(rsf_restart(n), fname,
'ts', atm(n)%ts, &
545 domain=fv_domain, tile_count=n)
548 if ( atm(n)%flagstruct%fv_land )
then 551 fname =
'mg_drag.res'//trim(stile_name)//
'.nc' 552 id_restart = register_restart_field(atm(n)%Mg_restart, fname,
'ghprime', atm(n)%sgh, &
553 domain=fv_domain, tile_count=n)
555 fname =
'fv_land.res'//trim(stile_name)//
'.nc' 556 id_restart = register_restart_field(atm(n)%Lnd_restart, fname,
'oro', atm(n)%oro, &
557 domain=fv_domain, tile_count=n)
560 fname =
'fv_tracer.res'//trim(stile_name)//
'.nc' 562 call get_tracer_names(model_atmos, nt, tracer_name)
564 call set_tracer_profile (model_atmos, nt, atm(n)%q(:,:,:,nt) )
565 id_restart = register_restart_field(atm(n)%Tra_restart, fname, tracer_name, atm(n)%q(:,:,:,nt), &
566 domain=fv_domain, mandatory=.false., tile_count=n)
568 do nt = ntprog+1, ntracers
569 call get_tracer_names(model_atmos, nt, tracer_name)
571 call set_tracer_profile (model_atmos, nt, atm(n)%qdiag(:,:,:,nt) )
572 id_restart = register_restart_field(atm(n)%Tra_restart, fname, tracer_name, atm(n)%qdiag(:,:,:,nt), &
573 domain=fv_domain, mandatory=.false., tile_count=n)
584 logical,
intent(IN) :: grids_on_this_pe(:)
585 character(len=*),
optional,
intent(in) :: timestamp
586 integer :: n, ntileMe
588 ntileme =
size(atm(:))
590 if ( use_ncep_sst .or. atm(1)%flagstruct%nudge .or. atm(1)%flagstruct%ncep_ic )
then 591 call mpp_error(note,
'READING FROM SST_RESTART DISABLED')
596 if (.not. grids_on_this_pe(n)) cycle
598 if ( (use_ncep_sst .or. atm(n)%flagstruct%nudge) .and. .not. atm(n)%gridstruct%nested )
then 599 call save_restart(atm(n)%SST_restart, timestamp)
602 call save_restart(atm(n)%Fv_restart, timestamp)
603 call save_restart(atm(n)%Fv_tile_restart, timestamp)
604 call save_restart(atm(n)%Rsf_restart, timestamp)
606 if ( atm(n)%flagstruct%fv_land )
then 607 call save_restart(atm(n)%Mg_restart, timestamp)
608 call save_restart(atm(n)%Lnd_restart, timestamp)
611 call save_restart(atm(n)%Tra_restart, timestamp)
617 subroutine register_bcs_2d(Atm, BCfile_ne, BCfile_sw, fname_ne, fname_sw, &
618 var_name, var, var_bc, istag, jstag)
620 type(restart_file_type),
intent(inout) :: BCfile_ne, BCfile_sw
621 character(len=120),
intent(in) :: fname_ne, fname_sw
622 character(len=*),
intent(in) :: var_name
623 real,
dimension(:,:),
intent(in),
optional :: var
625 integer,
intent(in),
optional :: istag, jstag
627 integer :: npx, npy, i_stag, j_stag
628 integer :: is, ie, js, je, isd, ied, jsd, jed, n
629 integer :: x_halo, y_halo, x_halo_ns, id_restart
630 integer :: layout(2), global_size(2), indices(4)
631 integer,
allocatable,
dimension(:) :: x1_pelist, y1_pelist
632 integer,
allocatable,
dimension(:) :: x2_pelist, y2_pelist
633 logical :: is_root_pe
637 if (
present(istag)) i_stag = i_stag
638 if (
present(jstag)) j_stag = j_stag
639 call mpp_get_global_domain(atm%domain, xsize = npx, ysize = npy, position=corner )
640 call mpp_get_data_domain(atm%domain, isd, ied, jsd, jed )
641 call mpp_get_compute_domain(atm%domain, is, ie, js, je )
642 call mpp_get_layout(atm%domain, layout)
643 allocate (x1_pelist(layout(1)))
644 allocate (y1_pelist(layout(2)))
645 allocate (x2_pelist(layout(1)))
646 allocate (y2_pelist(layout(2)))
651 y1_pelist(n)=mpp_root_pe()+layout(1)*n-1
652 y2_pelist(n)=mpp_root_pe()+layout(1)*(n-1)
656 x1_pelist(n)=mpp_root_pe()+layout(1)*(layout(2)-1)+(n-1)
657 x2_pelist(n)=mpp_root_pe()+(n-1)
660 call mpp_declare_pelist(x1_pelist)
661 call mpp_declare_pelist(x2_pelist)
662 call mpp_declare_pelist(y1_pelist)
663 call mpp_declare_pelist(y2_pelist)
670 indices(4) = jed+j_stag
671 global_size(1) = x_halo
672 global_size(2) = npy-1+2*y_halo+j_stag
676 if (is.eq.1 .and. js.eq.1) is_root_pe = .true.
678 if (
present(var_bc)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
679 trim(var_name)//
'_west_t1', &
681 indices, global_size, y2_pelist, &
682 is_root_pe, jshift=y_halo)
684 if (
present(var)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
685 trim(var_name)//
'_west', &
686 var, indices, global_size, &
687 y2_pelist, is_root_pe, jshift=y_halo)
691 if (ie.eq.npx-1 .and. je.eq.npy-1) is_root_pe = .true.
693 if (
present(var_bc)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
694 trim(var_name)//
'_east_t1', &
696 indices, global_size, y1_pelist, &
697 is_root_pe, jshift=y_halo)
700 indices(1) = ied-x_halo+1+i_stag
701 indices(2) = ied+i_stag
703 if (
present(var)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
704 trim(var_name)//
'_east', &
705 var, indices, global_size, &
706 y1_pelist, is_root_pe, jshift=y_halo, &
707 x_halo=(
size(var,1)-x_halo), ishift=-(ie+i_stag))
712 indices(2) = ied+i_stag
715 global_size(1) = npx-1+i_stag
716 global_size(2) = y_halo
718 if (is.eq.1) indices(1) = is
719 if (ie.eq.npx-1) indices(2) = ie+i_stag
721 if (is.eq.1) x_halo_ns=x_halo
725 if (is.eq.1 .and. js.eq.1) is_root_pe = .true.
727 if (
present(var_bc)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
728 trim(var_name)//
'_south_t1', &
730 indices, global_size, x2_pelist, &
731 is_root_pe, x_halo=x_halo_ns)
733 if (
present(var)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
734 trim(var_name)//
'_south', &
735 var, indices, global_size, &
736 x2_pelist, is_root_pe, x_halo=x_halo_ns)
740 if (ie.eq.npx-1 .and. je.eq.npy-1) is_root_pe = .true.
742 if (
present(var_bc)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
743 trim(var_name)//
'_north_t1', &
745 indices, global_size, x1_pelist, &
746 is_root_pe, x_halo=x_halo_ns)
749 indices(3) = jed-y_halo+1+j_stag
750 indices(4) = jed+j_stag
752 if (
present(var)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
753 trim(var_name)//
'_north', &
754 var, indices, global_size, &
755 x1_pelist, is_root_pe, x_halo=x_halo_ns, &
756 y_halo=(
size(var,2)-y_halo), jshift=-(je+j_stag))
761 subroutine register_bcs_3d(Atm, BCfile_ne, BCfile_sw, fname_ne, fname_sw, &
762 var_name, var, var_bc, istag, jstag, mandatory)
764 type(restart_file_type),
intent(inout) :: BCfile_ne, BCfile_sw
765 character(len=120),
intent(in) :: fname_ne, fname_sw
766 character(len=*),
intent(in) :: var_name
767 real,
dimension(:,:,:),
intent(in),
optional :: var
769 integer,
intent(in),
optional :: istag, jstag
770 logical,
intent(IN),
optional :: mandatory
772 integer :: npx, npy, i_stag, j_stag
773 integer :: is, ie, js, je, isd, ied, jsd, jed, n
774 integer :: x_halo, y_halo, x_halo_ns, id_restart
775 integer :: layout(2), global_size(3), indices(4)
776 integer,
allocatable,
dimension(:) :: x1_pelist, y1_pelist
777 integer,
allocatable,
dimension(:) :: x2_pelist, y2_pelist
778 logical :: is_root_pe
782 if (
present(istag)) i_stag = istag
783 if (
present(jstag)) j_stag = jstag
784 call mpp_get_global_domain(atm%domain, xsize = npx, ysize = npy, position=corner )
785 call mpp_get_data_domain(atm%domain, isd, ied, jsd, jed )
786 call mpp_get_compute_domain(atm%domain, is, ie, js, je )
787 call mpp_get_layout(atm%domain, layout)
788 allocate (x1_pelist(layout(1)))
789 allocate (y1_pelist(layout(2)))
790 allocate (x2_pelist(layout(1)))
791 allocate (y2_pelist(layout(2)))
796 y1_pelist(n)=mpp_root_pe()+layout(1)*n-1
797 y2_pelist(n)=mpp_root_pe()+layout(1)*(n-1)
801 x1_pelist(n)=mpp_root_pe()+layout(1)*(layout(2)-1)+(n-1)
802 x2_pelist(n)=mpp_root_pe()+(n-1)
805 call mpp_declare_pelist(x1_pelist)
806 call mpp_declare_pelist(x2_pelist)
807 call mpp_declare_pelist(y1_pelist)
808 call mpp_declare_pelist(y2_pelist)
815 indices(4) = jed + j_stag
816 global_size(1) = x_halo
817 global_size(2) = npy-1+2*y_halo + j_stag
818 global_size(3) = atm%npz
822 if (is.eq.1 .and. js.eq.1) is_root_pe = .true.
824 if (
present(var_bc)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
825 trim(var_name)//
'_west_t1', &
827 indices, global_size, y2_pelist, &
828 is_root_pe, jshift=y_halo, mandatory=mandatory)
830 if (
present(var)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
831 trim(var_name)//
'_west', &
832 var, indices, global_size, &
833 y2_pelist, is_root_pe, jshift=y_halo, mandatory=mandatory)
837 if (ie.eq.npx-1 .and. je.eq.npy-1) is_root_pe = .true.
839 if (
present(var_bc)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
840 trim(var_name)//
'_east_t1', &
842 indices, global_size, y1_pelist, &
843 is_root_pe, jshift=y_halo, mandatory=mandatory)
846 indices(1) = ied-x_halo+1+i_stag
847 indices(2) = ied+i_stag
849 if (
present(var)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
850 trim(var_name)//
'_east', &
851 var, indices, global_size, &
852 y1_pelist, is_root_pe, jshift=y_halo, &
853 x_halo=(
size(var,1)-x_halo), ishift=-(ie+i_stag), mandatory=mandatory)
858 indices(2) = ied+i_stag
861 global_size(1) = npx-1+i_stag
862 global_size(2) = y_halo
863 global_size(3) = atm%npz
865 if (is.eq.1) indices(1) = is
866 if (ie.eq.npx-1) indices(2) = ie+i_stag
868 if (is.eq.1) x_halo_ns=x_halo
872 if (is.eq.1 .and. js.eq.1) is_root_pe = .true.
874 if (
present(var_bc)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
875 trim(var_name)//
'_south_t1', &
877 indices, global_size, x2_pelist, &
878 is_root_pe, x_halo=x_halo_ns, mandatory=mandatory)
880 if (
present(var)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
881 trim(var_name)//
'_south', &
882 var, indices, global_size, &
883 x2_pelist, is_root_pe, x_halo=x_halo_ns, mandatory=mandatory)
887 if (ie.eq.npx-1 .and. je.eq.npy-1) is_root_pe = .true.
889 if (
present(var_bc)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
890 trim(var_name)//
'_north_t1', &
892 indices, global_size, x1_pelist, &
893 is_root_pe, x_halo=x_halo_ns, mandatory=mandatory)
896 indices(3) = jed-y_halo+1+j_stag
897 indices(4) = jed+j_stag
899 if (
present(var)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
900 trim(var_name)//
'_north', &
901 var, indices, global_size, &
902 x1_pelist, is_root_pe, x_halo=x_halo_ns, &
903 y_halo=(
size(var,2)-y_halo), jshift=-(je+j_stag), mandatory=mandatory)
912 integer :: n, ntracers, ntprog, ntdiag
913 character(len=120) :: tname, fname_ne, fname_sw
915 fname_ne =
'fv_BC_ne.res.nc' 916 fname_sw =
'fv_BC_sw.res.nc' 919 ntdiag=
size(atm%qdiag,4)
920 ntracers=ntprog+ntdiag
922 call set_domain(atm%domain)
924 call register_bcs_2d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
925 fname_ne, fname_sw,
'phis', var=atm%phis)
926 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
927 fname_ne, fname_sw,
'delp', atm%delp, atm%neststruct%delp_BC)
929 call get_tracer_names(model_atmos, n, tname)
930 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
931 fname_ne, fname_sw, trim(tname), atm%q(:,:,:,n), atm%neststruct%q_BC(n), mandatory=.false.)
933 do n=ntprog+1,ntracers
934 call get_tracer_names(model_atmos, n, tname)
935 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
936 fname_ne, fname_sw, trim(tname), var=atm%qdiag(:,:,:,n), mandatory=.false.)
939 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
940 fname_ne, fname_sw,
'pt', atm%pt, atm%neststruct%pt_BC)
941 if ((.not.atm%flagstruct%hydrostatic) .and. (.not.atm%flagstruct%make_nh))
then 942 if (is_master()) print*,
'fv_io_register_restart_BCs: REGISTERING NH BCs', atm%flagstruct%hydrostatic, atm%flagstruct%make_nh
943 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
944 fname_ne, fname_sw,
'w', atm%w, atm%neststruct%w_BC, mandatory=.false.)
945 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
946 fname_ne, fname_sw,
'delz', atm%delz, atm%neststruct%delz_BC, mandatory=.false.)
949 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
950 fname_ne, fname_sw,
'q_con', var_bc=atm%neststruct%q_con_BC, mandatory=.false.)
952 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
953 fname_ne, fname_sw,
'cappa', var_bc=atm%neststruct%cappa_BC, mandatory=.false.)
957 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
958 fname_ne, fname_sw,
'u', atm%u, atm%neststruct%u_BC, jstag=1)
959 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
960 fname_ne, fname_sw,
'v', atm%v, atm%neststruct%v_BC, istag=1)
961 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
962 fname_ne, fname_sw,
'uc', var_bc=atm%neststruct%uc_BC, istag=1)
963 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
964 fname_ne, fname_sw,
'vc', var_bc=atm%neststruct%vc_BC, jstag=1)
965 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
966 fname_ne, fname_sw,
'divg', var_bc=atm%neststruct%divg_BC, istag=1,jstag=1, mandatory=.false.)
967 atm%neststruct%divg_BC%initialized = field_exist(fname_ne,
'divg_north_t1', atm%domain)
978 character(len=120) :: tname, fname_ne, fname_sw
980 fname_ne =
'fv_BC_ne.res.nc' 981 fname_sw =
'fv_BC_sw.res.nc' 983 call set_domain(atm%domain)
985 if (is_master()) print*,
'fv_io_register_restart_BCs_NH: REGISTERING NH BCs', atm%flagstruct%hydrostatic, atm%flagstruct%make_nh
987 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
988 fname_ne, fname_sw,
'w', atm%w, atm%neststruct%w_BC)
989 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
990 fname_ne, fname_sw,
'delz', atm%delz, atm%neststruct%delz_BC)
1000 character(len=*),
intent(in),
optional :: timestamp
1002 call save_restart_border(atm%neststruct%BCfile_ne, timestamp)
1003 call save_restart_border(atm%neststruct%BCfile_sw, timestamp)
1012 call restore_state_border(atm%neststruct%BCfile_ne)
1013 call restore_state_border(atm%neststruct%BCfile_sw)
logical module_is_initialized
subroutine, public fv_io_read_bcs(Atm)
The subroutine 'fv_io_read_BCs' reads BCs from a restart file.
The module 'fv_mp_mod' is a single program multiple data (SPMD) parallel decompostion/communication m...
subroutine, public fv_io_write_restart(Atm, grids_on_this_pe, timestamp)
The subroutine 'fv_io_write_restart' writes restart files.
subroutine, public fv_io_init()
Initialize the fv core restart facilities.
subroutine, public fv_io_read_restart(fv_domain, Atm)
Write the fv core restart quantities.
subroutine register_bcs_2d(Atm, BCfile_ne, BCfile_sw, fname_ne, fname_sw, var_name, var, var_bc, istag, jstag)
The module 'fv_io' contains restart facilities for FV core.
subroutine, public fv_io_register_restart(fv_domain, Atm)
The subroutine 'fv_io_register_restart' registers model restart fields.
subroutine, public fv_io_register_restart_bcs(Atm)
The subroutine 'fv_io_register_restart_BCs' registers restarts for nested-grid boundary conditions...
subroutine register_bcs_3d(Atm, BCfile_ne, BCfile_sw, fname_ne, fname_sw, var_name, var, var_bc, istag, jstag, mandatory)
subroutine, public fv_io_read_tracers(fv_domain, Atm)
The subroutine 'fv_io_read_tracers' reads in only tracers from restart files.
The module 'fv_mapz' contains the vertical mapping routines .
subroutine, public rst_remap(km, kn, is, ie, js, je, isd, ied, jsd, jed, nq, ntp, delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r, delp, u, v, w, delz, pt, q, qdiag, ak_r, bk_r, ptop, ak, bk, hydrostatic, make_nh, domain, square_domain)
The subroutine 'rst_remap' remaps all variables required for a restart.
The module 'fv_arrays' contains the 'fv_atmos_type' and associated datatypes.
subroutine, public set_external_eta(ak, bk, ptop, ks)
The subroutine 'set_external_eta' sets 'ptop' (model top) and 'ks' (first level of pure pressure coor...
The module 'fv_eta' contains routine to set up the reference (Eulerian) pressure coordinate.
subroutine, public fv_io_write_bcs(Atm, timestamp)
The subroutine 'fv_io_write_BCs' writes BCs to a restart file.
subroutine, public fv_io_exit
Close the fv core restart facilities.
integer, parameter, public ng
subroutine, public fv_io_register_nudge_restart(Atm)
The subroutine 'fv_io_register_nudge_restart' registers restarts for SST fields used in HiRAM...
subroutine, public remap_restart(fv_domain, Atm)
The subroutine 'remap_restart' remaps the model state from remap files to a new set of Eulerian coord...
subroutine, public fv_io_register_restart_bcs_nh(Atm)