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
112 use fv_mp_mod, only: mp_gather, is_master
113 use fms_io_mod
, only: set_domain
147 type(domain2d),
intent(inout) :: fv_domain
150 character(len=64) :: fname, tracer_name
151 character(len=6) :: stile_name
152 integer :: isc, iec, jsc, jec, n, nt, nk, ntracers
154 integer :: ks, ntiles
157 character(len=128) :: tracer_longname, tracer_units
159 ntileme =
size(atm(:))
161 call restore_state(atm(1)%Fv_restart)
162 if (atm(1)%flagstruct%external_eta)
then 166 if ( use_ncep_sst .or. atm(1)%flagstruct%nudge .or. atm(1)%flagstruct%ncep_ic )
then 167 call mpp_error(note,
'READING FROM SST_RESTART DISABLED')
172 ntiles = mpp_get_ntile_count(fv_domain)
173 if(ntiles == 1 .and. .not. atm(1)%neststruct%nested)
then 174 stile_name =
'.tile1' 180 call restore_state(atm(n)%Fv_tile_restart)
183 fname =
'INPUT/fv_tracer.res'//trim(stile_name)//
'.nc' 184 if (file_exist(fname))
then 185 call restore_state(atm(n)%Tra_restart)
187 call mpp_error(note,
'==> Warning from fv_read_restart: Expected file '//trim(fname)//
' does not exist')
191 fname =
'INPUT/fv_srf_wnd.res'//trim(stile_name)//
'.nc' 192 if (file_exist(fname))
then 193 call restore_state(atm(n)%Rsf_restart)
194 atm(n)%flagstruct%srf_init = .true.
196 call mpp_error(note,
'==> Warning from fv_read_restart: Expected file '//trim(fname)//
' does not exist')
197 atm(n)%flagstruct%srf_init = .false.
200 if ( atm(n)%flagstruct%fv_land )
then 202 fname =
'INPUT/mg_drag.res'//trim(stile_name)//
'.nc' 203 if (file_exist(fname))
then 204 call restore_state(atm(n)%Mg_restart)
206 call mpp_error(note,
'==> Warning from fv_read_restart: Expected file '//trim(fname)//
' does not exist')
209 fname =
'INPUT/fv_land.res'//trim(stile_name)//
'.nc' 210 if (file_exist(fname))
then 211 call restore_state(atm(n)%Lnd_restart)
213 call mpp_error(note,
'==> Warning from fv_read_restart: Expected file '//trim(fname)//
' does not exist')
228 type(domain2d),
intent(inout) :: fv_domain
230 integer :: n, ntracers, ntprog, nt, isc, iec, jsc, jec, id_restart
231 character(len=6) :: stile_name
232 character(len=64):: fname, tracer_name
233 type(restart_file_type) :: Tra_restart_r
241 call get_number_tracers(model_atmos, num_tracers=ntracers, num_prog=ntprog)
244 ntiles = mpp_get_ntile_count(fv_domain)
245 if(ntiles == 1 .and. .not. atm(1)%neststruct%nested)
then 246 stile_name =
'.tile1' 251 fname =
'fv_tracer.res'//trim(stile_name)//
'.nc' 253 call get_tracer_names(model_atmos, nt, tracer_name)
254 call set_tracer_profile (model_atmos, nt, atm(n)%q(isc:iec,jsc:jec,:,nt) )
255 id_restart = register_restart_field(tra_restart_r, fname, tracer_name, atm(n)%q(:,:,:,nt), &
256 domain=fv_domain, mandatory=.false., tile_count=n)
258 do nt = ntprog+1, ntracers
259 call get_tracer_names(model_atmos, nt, tracer_name)
260 call set_tracer_profile (model_atmos, nt, atm(n)%qdiag(isc:iec,jsc:jec,:,nt) )
261 id_restart = register_restart_field(tra_restart_r, fname, tracer_name, atm(n)%qdiag(:,:,:,nt), &
262 domain=fv_domain, mandatory=.false., tile_count=n)
264 if (file_exist(
'INPUT'//trim(fname)))
then 265 call restore_state(tra_restart_r)
266 call free_restart_type(tra_restart_r)
268 call mpp_error(note,
'==> Warning from fv_io_read_tracers: Expected file '//trim(fname)//
' does not exist')
281 type(domain2d),
intent(inout) :: fv_domain
284 character(len=64) :: fname, tracer_name
285 character(len=6) :: stile_name
286 integer :: isc, iec, jsc, jec, n, nt, nk, ntracers, ntprog, ntdiag
287 integer :: isd, ied, jsd, jed
289 type(restart_file_type) :: FV_restart_r, FV_tile_restart_r, Tra_restart_r
290 integer :: id_restart
294 real,
allocatable:: ak_r(:), bk_r(:)
295 real,
allocatable:: u_r(:,:,:), v_r(:,:,:), pt_r(:,:,:), delp_r(:,:,:)
296 real,
allocatable:: w_r(:,:,:), delz_r(:,:,:), ze0_r(:,:,:)
297 real,
allocatable:: q_r(:,:,:,:), qdiag_r(:,:,:,:)
299 integer npz, npz_rst, ng
303 npz_rst = atm(1)%flagstruct%npz_rst
304 isc = atm(1)%bd%isc; iec = atm(1)%bd%iec; jsc = atm(1)%bd%jsc; jec = atm(1)%bd%jec
307 isd = isc - ng; ied = iec + ng
308 jsd = jsc - ng; jed = jec + ng
312 ntprog =
size(atm(1)%q,4)
313 ntdiag =
size(atm(1)%qdiag,4)
314 ntracers = ntprog+ntdiag
320 allocate ( ak_r(npz_rst+1) )
321 allocate ( bk_r(npz_rst+1) )
323 allocate ( u_r(isc:iec, jsc:jec+1,npz_rst) )
324 allocate ( v_r(isc:iec+1,jsc:jec ,npz_rst) )
326 allocate ( pt_r(isc:iec, jsc:jec, npz_rst) )
327 allocate ( delp_r(isc:iec, jsc:jec, npz_rst) )
328 allocate ( q_r(isc:iec, jsc:jec, npz_rst, ntprog) )
329 allocate (qdiag_r(isc:iec, jsc:jec, npz_rst, ntprog+1:ntracers) )
331 if ( (.not.atm(1)%flagstruct%hydrostatic) .and. (.not.atm(1)%flagstruct%make_nh) )
then 332 allocate ( w_r(isc:iec, jsc:jec, npz_rst) )
333 allocate ( delz_r(isc:iec, jsc:jec, npz_rst) )
334 if ( atm(1)%flagstruct%hybrid_z ) &
335 allocate ( ze0_r(isc:iec, jsc:jec, npz_rst+1) )
338 fname =
'fv_core.res.nc' 339 id_restart = register_restart_field(fv_restart_r, fname,
'ak', ak_r(:), no_domain=.true.)
340 id_restart = register_restart_field(fv_restart_r, fname,
'bk', bk_r(:), no_domain=.true.)
341 call restore_state(fv_restart_r)
342 call free_restart_type(fv_restart_r)
345 ntiles = mpp_get_ntile_count(fv_domain)
346 if(ntiles == 1 .and. .not. atm(1)%neststruct%nested)
then 347 stile_name =
'.tile1' 358 fname =
'fv_core.res'//trim(stile_name)//
'.nc' 359 id_restart = register_restart_field(fv_tile_restart_r, fname,
'u', u_r, &
360 domain=fv_domain, position=north,tile_count=n)
361 id_restart = register_restart_field(fv_tile_restart_r, fname,
'v', v_r, &
362 domain=fv_domain, position=east,tile_count=n)
363 if (.not.atm(n)%flagstruct%hydrostatic)
then 364 id_restart = register_restart_field(fv_tile_restart_r, fname,
'W', w_r, &
365 domain=fv_domain, mandatory=.false., tile_count=n)
366 id_restart = register_restart_field(fv_tile_restart_r, fname,
'DZ', delz_r, &
367 domain=fv_domain, mandatory=.false., tile_count=n)
368 if ( atm(n)%flagstruct%hybrid_z )
then 369 id_restart = register_restart_field(fv_tile_restart_r, fname,
'ZE0', ze0_r, &
370 domain=fv_domain, mandatory=.false., tile_count=n)
373 id_restart = register_restart_field(fv_tile_restart_r, fname,
'T', pt_r, &
374 domain=fv_domain, tile_count=n)
375 id_restart = register_restart_field(fv_tile_restart_r, fname,
'delp', delp_r, &
376 domain=fv_domain, tile_count=n)
377 id_restart = register_restart_field(fv_tile_restart_r, fname,
'phis', atm(n)%phis, &
378 domain=fv_domain, tile_count=n)
379 call restore_state(fv_tile_restart_r)
380 call free_restart_type(fv_tile_restart_r)
381 fname =
'fv_srf_wnd.res'//trim(stile_name)//
'.nc' 382 if (file_exist(
'INPUT/'//fname))
then 383 call restore_state(atm(n)%Rsf_restart)
384 atm(n)%flagstruct%srf_init = .true.
386 call mpp_error(note,
'==> Warning from remap_restart: Expected file '//trim(fname)//
' does not exist')
387 atm(n)%flagstruct%srf_init = .false.
390 if ( atm(n)%flagstruct%fv_land )
then 392 fname =
'mg_drag.res'//trim(stile_name)//
'.nc' 393 if (file_exist(
'INPUT/'//fname))
then 394 call restore_state(atm(n)%Mg_restart)
396 call mpp_error(note,
'==> Warning from remap_restart: Expected file '//trim(fname)//
' does not exist')
399 fname =
'fv_land.res'//trim(stile_name)//
'.nc' 400 if (file_exist(
'INPUT/'//fname))
then 401 call restore_state(atm(n)%Lnd_restart)
403 call mpp_error(note,
'==> Warning from remap_restart: Expected file '//trim(fname)//
' does not exist')
407 fname =
'fv_tracer.res'//trim(stile_name)//
'.nc' 408 if (file_exist(
'INPUT/'//fname))
then 410 call get_tracer_names(model_atmos, nt, tracer_name)
411 call set_tracer_profile (model_atmos, nt, q_r(isc:iec,jsc:jec,:,nt) )
412 id_restart = register_restart_field(tra_restart_r, fname, tracer_name, q_r(:,:,:,nt), &
413 domain=fv_domain, mandatory=.false., tile_count=n)
415 do nt = ntprog+1, ntracers
416 call get_tracer_names(model_atmos, nt, tracer_name)
417 call set_tracer_profile (model_atmos, nt, qdiag_r(isc:iec,jsc:jec,:,nt) )
418 id_restart = register_restart_field(tra_restart_r, fname, tracer_name, qdiag_r(:,:,:,nt), &
419 domain=fv_domain, mandatory=.false., tile_count=n)
421 call restore_state(tra_restart_r)
422 call free_restart_type(tra_restart_r)
424 call mpp_error(note,
'==> Warning from remap_restart: Expected file '//trim(fname)//
' does not exist')
428 if (atm(n)%flagstruct%read_increment)
then 433 if( is_master() )
write(*,*)
'Calling read_da_inc',pt_r(i,j,k)
434 call read_da_inc(atm(n), atm(n)%domain, atm(n)%bd, npz_rst, ntprog, &
435 u_r, v_r, q_r, delp_r, pt_r, delz_r, isc, jsc, iec, jec, &
437 if( is_master() )
write(*,*)
'Back from read_da_inc',pt_r(i,j,k)
441 call rst_remap(npz_rst, npz, isc, iec, jsc, jec, isd, ied, jsd, jed, ntracers, ntprog, &
442 delp_r, u_r, v_r, w_r, delz_r, pt_r, q_r, qdiag_r,&
443 atm(n)%delp, atm(n)%u, atm(n)%v, atm(n)%w, atm(n)%delz, atm(n)%pt, atm(n)%q, &
444 atm(n)%qdiag, ak_r, bk_r, atm(n)%ptop, atm(n)%ak, atm(n)%bk, &
445 atm(n)%flagstruct%hydrostatic, atm(n)%flagstruct%make_nh, atm(n)%domain, &
446 atm(n)%gridstruct%square_domain)
456 deallocate( qdiag_r )
458 if ( (.not.atm(1)%flagstruct%hydrostatic) .and. (.not.atm(1)%flagstruct%make_nh) )
then 460 deallocate ( delz_r )
461 if ( atm(1)%flagstruct%hybrid_z )
deallocate ( ze0_r )
471 character(len=64) :: fname
472 integer :: id_restart
475 call mpp_error(note,
'READING FROM SST_restart DISABLED')
476 if ( use_ncep_sst .or. atm(1)%flagstruct%nudge .or. atm(1)%flagstruct%ncep_ic )
then 478 fname =
'sst_ncep.res.nc' 479 id_restart = register_restart_field(atm(1)%SST_restart, fname,
'sst_ncep', sst_ncep)
480 id_restart = register_restart_field(atm(1)%SST_restart, fname,
'sst_anom', sst_anom)
487 type(domain2d),
intent(inout) :: fv_domain
490 character(len=64) :: fname, tracer_name
491 character(len=6) :: gn, stile_name
492 integer :: id_restart
493 integer :: n, nt, ntracers, ntprog, ntdiag, ntileMe, ntiles
495 ntileme =
size(atm(:))
496 ntprog =
size(atm(1)%q,4)
497 ntdiag =
size(atm(1)%qdiag,4)
498 ntracers = ntprog+ntdiag
501 if (atm(1)%grid_number > 1)
then 502 write(gn,
'(A4, I2.2)')
"nest", atm(1)%grid_number
506 call set_filename_appendix(gn)
509 ntiles = mpp_get_ntile_count(fv_domain)
510 if(ntiles == 1 .and. .not. atm(1)%neststruct%nested)
then 511 stile_name =
'.tile1' 526 fname =
'fv_core.res.nc' 527 id_restart = register_restart_field(atm(1)%Fv_restart, fname,
'ak', atm(1)%ak(:), no_domain=.true.)
528 id_restart = register_restart_field(atm(1)%Fv_restart, fname,
'bk', atm(1)%bk(:), no_domain=.true.)
531 fname =
'fv_core.res'//trim(stile_name)//
'.nc' 532 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'u', atm(n)%u, &
533 domain=fv_domain, position=north,tile_count=n)
534 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'v', atm(n)%v, &
535 domain=fv_domain, position=east,tile_count=n)
536 if (.not.atm(n)%flagstruct%hydrostatic)
then 537 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'W', atm(n)%w, &
538 domain=fv_domain, mandatory=.false., tile_count=n)
539 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'DZ', atm(n)%delz, &
540 domain=fv_domain, mandatory=.false., tile_count=n)
541 if ( atm(n)%flagstruct%hybrid_z )
then 542 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'ZE0', atm(n)%ze0, &
543 domain=fv_domain, mandatory=.false., tile_count=n)
546 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'T', atm(n)%pt, &
547 domain=fv_domain, tile_count=n)
548 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'delp', atm(n)%delp, &
549 domain=fv_domain, tile_count=n)
550 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'phis', atm(n)%phis, &
551 domain=fv_domain, tile_count=n)
554 if (atm(n)%flagstruct%agrid_vel_rst)
then 555 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'ua', atm(n)%ua, &
556 domain=fv_domain, tile_count=n, mandatory=.false.)
557 id_restart = register_restart_field(atm(n)%Fv_tile_restart, fname,
'va', atm(n)%va, &
558 domain=fv_domain, tile_count=n, mandatory=.false.)
561 fname =
'fv_srf_wnd.res'//trim(stile_name)//
'.nc' 562 id_restart = register_restart_field(atm(n)%Rsf_restart, fname,
'u_srf', atm(n)%u_srf, &
563 domain=fv_domain, tile_count=n)
564 id_restart = register_restart_field(atm(n)%Rsf_restart, fname,
'v_srf', atm(n)%v_srf, &
565 domain=fv_domain, tile_count=n)
567 id_restart = register_restart_field(rsf_restart(n), fname,
'ts', atm(n)%ts, &
568 domain=fv_domain, tile_count=n)
571 if ( atm(n)%flagstruct%fv_land )
then 574 fname =
'mg_drag.res'//trim(stile_name)//
'.nc' 575 id_restart = register_restart_field(atm(n)%Mg_restart, fname,
'ghprime', atm(n)%sgh, &
576 domain=fv_domain, tile_count=n)
578 fname =
'fv_land.res'//trim(stile_name)//
'.nc' 579 id_restart = register_restart_field(atm(n)%Lnd_restart, fname,
'oro', atm(n)%oro, &
580 domain=fv_domain, tile_count=n)
583 fname =
'fv_tracer.res'//trim(stile_name)//
'.nc' 585 call get_tracer_names(model_atmos, nt, tracer_name)
587 call set_tracer_profile (model_atmos, nt, atm(n)%q(:,:,:,nt) )
588 id_restart = register_restart_field(atm(n)%Tra_restart, fname, tracer_name, atm(n)%q(:,:,:,nt), &
589 domain=fv_domain, mandatory=.false., tile_count=n)
591 do nt = ntprog+1, ntracers
592 call get_tracer_names(model_atmos, nt, tracer_name)
594 call set_tracer_profile (model_atmos, nt, atm(n)%qdiag(:,:,:,nt) )
595 id_restart = register_restart_field(atm(n)%Tra_restart, fname, tracer_name, atm(n)%qdiag(:,:,:,nt), &
596 domain=fv_domain, mandatory=.false., tile_count=n)
599 if ( atm(n)%neststruct%nested )
then 610 character(len=*),
optional,
intent(in) :: timestamp
617 if ( (use_ncep_sst .or. atm%flagstruct%nudge) .and. .not. atm%gridstruct%nested )
then 618 call save_restart(atm%SST_restart, timestamp)
621 call save_restart(atm%Fv_restart, timestamp)
622 call save_restart(atm%Fv_tile_restart, timestamp)
623 call save_restart(atm%Rsf_restart, timestamp)
625 if ( atm%flagstruct%fv_land )
then 626 call save_restart(atm%Mg_restart, timestamp)
627 call save_restart(atm%Lnd_restart, timestamp)
630 call save_restart(atm%Tra_restart, timestamp)
635 subroutine register_bcs_2d(Atm, BCfile_ne, BCfile_sw, fname_ne, fname_sw, &
636 var_name, var, var_bc, istag, jstag)
638 type(restart_file_type),
intent(inout) :: BCfile_ne, BCfile_sw
639 character(len=120),
intent(in) :: fname_ne, fname_sw
640 character(len=*),
intent(in) :: var_name
641 real,
dimension(:,:),
intent(in),
optional :: var
643 integer,
intent(in),
optional :: istag, jstag
645 integer :: npx, npy, i_stag, j_stag
646 integer :: is, ie, js, je, isd, ied, jsd, jed, n
647 integer :: x_halo, y_halo, x_halo_ns, id_restart
648 integer :: layout(2), global_size(2), indices(4)
649 integer,
allocatable,
dimension(:) :: x1_pelist, y1_pelist
650 integer,
allocatable,
dimension(:) :: x2_pelist, y2_pelist
651 logical :: is_root_pe
655 if (
present(istag)) i_stag = i_stag
656 if (
present(jstag)) j_stag = j_stag
657 call mpp_get_global_domain(atm%domain, xsize = npx, ysize = npy, position=corner )
658 call mpp_get_data_domain(atm%domain, isd, ied, jsd, jed )
659 call mpp_get_compute_domain(atm%domain, is, ie, js, je )
660 call mpp_get_layout(atm%domain, layout)
661 allocate (x1_pelist(layout(1)))
662 allocate (y1_pelist(layout(2)))
663 allocate (x2_pelist(layout(1)))
664 allocate (y2_pelist(layout(2)))
669 y1_pelist(n)=mpp_root_pe()+layout(1)*n-1
670 y2_pelist(n)=mpp_root_pe()+layout(1)*(n-1)
674 x1_pelist(n)=mpp_root_pe()+layout(1)*(layout(2)-1)+(n-1)
675 x2_pelist(n)=mpp_root_pe()+(n-1)
678 call mpp_declare_pelist(x1_pelist)
679 call mpp_declare_pelist(x2_pelist)
680 call mpp_declare_pelist(y1_pelist)
681 call mpp_declare_pelist(y2_pelist)
688 indices(4) = jed+j_stag
689 global_size(1) = x_halo
690 global_size(2) = npy-1+2*y_halo+j_stag
694 if (is.eq.1 .and. js.eq.1) is_root_pe = .true.
696 if (
present(var_bc)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
697 trim(var_name)//
'_west_t1', &
699 indices, global_size, y2_pelist, &
700 is_root_pe, jshift=y_halo)
702 if (
present(var)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
703 trim(var_name)//
'_west', &
704 var, indices, global_size, &
705 y2_pelist, is_root_pe, jshift=y_halo)
709 if (ie.eq.npx-1 .and. je.eq.npy-1) is_root_pe = .true.
711 if (
present(var_bc)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
712 trim(var_name)//
'_east_t1', &
714 indices, global_size, y1_pelist, &
715 is_root_pe, jshift=y_halo)
718 indices(1) = ied-x_halo+1+i_stag
719 indices(2) = ied+i_stag
721 if (
present(var)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
722 trim(var_name)//
'_east', &
723 var, indices, global_size, &
724 y1_pelist, is_root_pe, jshift=y_halo, &
725 x_halo=(
size(var,1)-x_halo), ishift=-(ie+i_stag))
730 indices(2) = ied+i_stag
733 global_size(1) = npx-1+i_stag
734 global_size(2) = y_halo
736 if (is.eq.1) indices(1) = is
737 if (ie.eq.npx-1) indices(2) = ie+i_stag
739 if (is.eq.1) x_halo_ns=x_halo
743 if (is.eq.1 .and. js.eq.1) is_root_pe = .true.
745 if (
present(var_bc)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
746 trim(var_name)//
'_south_t1', &
748 indices, global_size, x2_pelist, &
749 is_root_pe, x_halo=x_halo_ns)
751 if (
present(var)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
752 trim(var_name)//
'_south', &
753 var, indices, global_size, &
754 x2_pelist, is_root_pe, x_halo=x_halo_ns)
758 if (ie.eq.npx-1 .and. je.eq.npy-1) is_root_pe = .true.
760 if (
present(var_bc)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
761 trim(var_name)//
'_north_t1', &
763 indices, global_size, x1_pelist, &
764 is_root_pe, x_halo=x_halo_ns)
767 indices(3) = jed-y_halo+1+j_stag
768 indices(4) = jed+j_stag
770 if (
present(var)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
771 trim(var_name)//
'_north', &
772 var, indices, global_size, &
773 x1_pelist, is_root_pe, x_halo=x_halo_ns, &
774 y_halo=(
size(var,2)-y_halo), jshift=-(je+j_stag))
779 subroutine register_bcs_3d(Atm, BCfile_ne, BCfile_sw, fname_ne, fname_sw, &
780 var_name, var, var_bc, istag, jstag, mandatory)
782 type(restart_file_type),
intent(inout) :: BCfile_ne, BCfile_sw
783 character(len=120),
intent(in) :: fname_ne, fname_sw
784 character(len=*),
intent(in) :: var_name
785 real,
dimension(:,:,:),
intent(in),
optional :: var
787 integer,
intent(in),
optional :: istag, jstag
788 logical,
intent(IN),
optional :: mandatory
790 integer :: npx, npy, i_stag, j_stag
791 integer :: is, ie, js, je, isd, ied, jsd, jed, n
792 integer :: x_halo, y_halo, x_halo_ns, id_restart
793 integer :: layout(2), global_size(3), indices(4)
794 integer,
allocatable,
dimension(:) :: x1_pelist, y1_pelist
795 integer,
allocatable,
dimension(:) :: x2_pelist, y2_pelist
796 logical :: is_root_pe
800 if (
present(istag)) i_stag = istag
801 if (
present(jstag)) j_stag = jstag
802 call mpp_get_global_domain(atm%domain, xsize = npx, ysize = npy, position=corner )
803 call mpp_get_data_domain(atm%domain, isd, ied, jsd, jed )
804 call mpp_get_compute_domain(atm%domain, is, ie, js, je )
805 call mpp_get_layout(atm%domain, layout)
806 allocate (x1_pelist(layout(1)))
807 allocate (y1_pelist(layout(2)))
808 allocate (x2_pelist(layout(1)))
809 allocate (y2_pelist(layout(2)))
814 y1_pelist(n)=mpp_root_pe()+layout(1)*n-1
815 y2_pelist(n)=mpp_root_pe()+layout(1)*(n-1)
819 x1_pelist(n)=mpp_root_pe()+layout(1)*(layout(2)-1)+(n-1)
820 x2_pelist(n)=mpp_root_pe()+(n-1)
823 call mpp_declare_pelist(x1_pelist)
824 call mpp_declare_pelist(x2_pelist)
825 call mpp_declare_pelist(y1_pelist)
826 call mpp_declare_pelist(y2_pelist)
833 indices(4) = jed + j_stag
834 global_size(1) = x_halo
835 global_size(2) = npy-1+2*y_halo + j_stag
836 global_size(3) = atm%npz
840 if (is.eq.1 .and. js.eq.1) is_root_pe = .true.
842 if (
present(var_bc)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
843 trim(var_name)//
'_west_t1', &
845 indices, global_size, y2_pelist, &
846 is_root_pe, jshift=y_halo, mandatory=mandatory)
848 if (
present(var)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
849 trim(var_name)//
'_west', &
850 var, indices, global_size, &
851 y2_pelist, is_root_pe, jshift=y_halo, mandatory=mandatory)
855 if (ie.eq.npx-1 .and. je.eq.npy-1) is_root_pe = .true.
857 if (
present(var_bc)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
858 trim(var_name)//
'_east_t1', &
860 indices, global_size, y1_pelist, &
861 is_root_pe, jshift=y_halo, mandatory=mandatory)
864 indices(1) = ied-x_halo+1+i_stag
865 indices(2) = ied+i_stag
867 if (
present(var)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
868 trim(var_name)//
'_east', &
869 var, indices, global_size, &
870 y1_pelist, is_root_pe, jshift=y_halo, &
871 x_halo=(
size(var,1)-x_halo), ishift=-(ie+i_stag), mandatory=mandatory)
876 indices(2) = ied+i_stag
879 global_size(1) = npx-1+i_stag
880 global_size(2) = y_halo
881 global_size(3) = atm%npz
883 if (is.eq.1) indices(1) = is
884 if (ie.eq.npx-1) indices(2) = ie+i_stag
886 if (is.eq.1) x_halo_ns=x_halo
890 if (is.eq.1 .and. js.eq.1) is_root_pe = .true.
892 if (
present(var_bc)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
893 trim(var_name)//
'_south_t1', &
895 indices, global_size, x2_pelist, &
896 is_root_pe, x_halo=x_halo_ns, mandatory=mandatory)
898 if (
present(var)) id_restart = register_restart_field(bcfile_sw, trim(fname_sw), &
899 trim(var_name)//
'_south', &
900 var, indices, global_size, &
901 x2_pelist, is_root_pe, x_halo=x_halo_ns, mandatory=mandatory)
905 if (ie.eq.npx-1 .and. je.eq.npy-1) is_root_pe = .true.
907 if (
present(var_bc)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
908 trim(var_name)//
'_north_t1', &
910 indices, global_size, x1_pelist, &
911 is_root_pe, x_halo=x_halo_ns, mandatory=mandatory)
914 indices(3) = jed-y_halo+1+j_stag
915 indices(4) = jed+j_stag
917 if (
present(var)) id_restart = register_restart_field(bcfile_ne, trim(fname_ne), &
918 trim(var_name)//
'_north', &
919 var, indices, global_size, &
920 x1_pelist, is_root_pe, x_halo=x_halo_ns, &
921 y_halo=(
size(var,2)-y_halo), jshift=-(je+j_stag), mandatory=mandatory)
930 integer :: n, ntracers, ntprog, ntdiag
931 character(len=120) :: tname, fname_ne, fname_sw
933 fname_ne =
'fv_BC_ne.res.nc' 934 fname_sw =
'fv_BC_sw.res.nc' 937 ntdiag=
size(atm%qdiag,4)
938 ntracers=ntprog+ntdiag
940 call set_domain(atm%domain)
942 call register_bcs_2d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
943 fname_ne, fname_sw,
'phis', var=atm%phis)
944 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
945 fname_ne, fname_sw,
'delp', atm%delp, atm%neststruct%delp_BC)
947 call get_tracer_names(model_atmos, n, tname)
948 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
949 fname_ne, fname_sw, trim(tname), atm%q(:,:,:,n), atm%neststruct%q_BC(n), mandatory=.false.)
951 do n=ntprog+1,ntracers
952 call get_tracer_names(model_atmos, n, tname)
953 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
954 fname_ne, fname_sw, trim(tname), var=atm%qdiag(:,:,:,n), mandatory=.false.)
957 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
958 fname_ne, fname_sw,
'pt', atm%pt, atm%neststruct%pt_BC)
959 if ((.not.atm%flagstruct%hydrostatic))
then 960 if (is_master()) print*,
'fv_io_register_restart_BCs: REGISTERING NH BCs' 961 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
962 fname_ne, fname_sw,
'w', atm%w, atm%neststruct%w_BC, mandatory=.false.)
963 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
964 fname_ne, fname_sw,
'delz', var_bc=atm%neststruct%delz_BC, mandatory=.false.)
968 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
969 fname_ne, fname_sw,
'q_con', var_bc=atm%neststruct%q_con_BC, mandatory=.false.)
971 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
972 fname_ne, fname_sw,
'cappa', var_bc=atm%neststruct%cappa_BC, mandatory=.false.)
976 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
977 fname_ne, fname_sw,
'u', atm%u, atm%neststruct%u_BC, jstag=1)
978 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
979 fname_ne, fname_sw,
'v', atm%v, atm%neststruct%v_BC, istag=1)
980 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
981 fname_ne, fname_sw,
'uc', var_bc=atm%neststruct%uc_BC, istag=1)
982 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
983 fname_ne, fname_sw,
'vc', var_bc=atm%neststruct%vc_BC, jstag=1)
984 call register_bcs_3d(atm, atm%neststruct%BCfile_ne, atm%neststruct%BCfile_sw, &
985 fname_ne, fname_sw,
'divg', var_bc=atm%neststruct%divg_BC, istag=1,jstag=1, mandatory=.false.)
993 character(len=*),
intent(in),
optional :: timestamp
995 call save_restart_border(atm%neststruct%BCfile_ne, timestamp)
996 call save_restart_border(atm%neststruct%BCfile_sw, timestamp)
1005 call restore_state_border(atm%neststruct%BCfile_ne)
1006 call restore_state_border(atm%neststruct%BCfile_sw)
logical module_is_initialized
subroutine, public fv_io_read_bcs(Atm)
The module 'fv_mp_mod' is a single program multiple data (SPMD) parallel decompostion/communication m...
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, public read_da_inc(Atm, fv_domain, bd, npz_in, nq, u, v, q, delp, pt, delz, is_in, js_in, ie_in, je_in, isc_in, jsc_in, iec_in, jec_in)
The subroutine 'read_da_inc' reads the increments of the diagnostic variables from the DA-generated f...
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)
subroutine, public fv_io_exit
Close the fv core restart facilities.
'The module 'tread_da_increment' contains routines for treating the increments of the prognostic vari...
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 fv_io_write_restart(Atm, timestamp)
The subroutine 'fv_io_write_restart' writes restart files.
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...