25 use mpp_domains_mod
, only: domain2d
26 use mpp_domains_mod
, only: domain1d, mpp_get_domain_components, &
27 mpp_get_global_domain, &
28 mpp_get_data_domain, &
29 mpp_get_compute_domain, &
30 north, south, east, west, &
32 mpp_domains_set_stack_size, &
33 mpp_update_domains, mpp_get_neighbor_pe
34 use mpp_mod
, only: fatal, input_nml_file, &
35 mpp_error ,mpp_pe, mpp_sync, &
36 mpp_npes, mpp_root_pe, mpp_gather, &
37 mpp_get_current_pelist, note, null_pe
39 use tracer_manager_mod
,only: get_tracer_index,get_tracer_names
40 use field_manager_mod
, only: model_atmos
41 use time_manager_mod
, only: get_time &
42 ,
operator(-),
operator(/) &
43 ,time_type,time_type_to_real
44 use constants_mod
, only: cp_air, cp_vapor, grav, kappa &
45 ,pi=>pi_8,rdgas, rvgas
58 use fv_mp_mod, only: is_master, mp_reduce_min, mp_reduce_max
61 use fms_mod
, only: check_nml_error,file_exist
62 use fms_io_mod
, only: read_data,get_global_att_value
115 integer,
parameter ::
nvars_core=7 & !<-- # of prognostic variables in core restart file
147 real,
save ::
dt_atmos & !<-- The physics (large) timestep (sec)
150 real(kind=R_GRID),
dimension(:,:,:),
allocatable ::
agrid_reg & !<-- Lon/lat of cell centers
168 real,
dimension(:,:,:),
allocatable :: delp_bc, divgd_bc, u_bc, v_bc, uc_bc, vc_bc
169 real,
dimension(:,:,:,:),
allocatable :: q_bc
171 real,
dimension(:,:,:),
allocatable :: pt_bc, w_bc, delz_bc
173 real,
dimension(:,:,:),
allocatable :: q_con_bc
175 real,
dimension(:,:,:),
allocatable :: cappa_bc
186 real,
dimension(:,:,:),
pointer :: north, south, east, west
190 real,
dimension(:,:),
pointer :: ptr
191 character(len=10) :: name
195 real,
dimension(:,:,:),
pointer :: ptr
196 character(len=10) :: name
222 real,
parameter ::
tice=273.16 &
226 real,
parameter ::
zvir = rvgas/rdgas - 1. &
227 ,
cv_air = cp_air - rdgas &
228 ,
cv_vap = cp_vapor - rvgas
233 ,
oro_data =
'oro_data.tile7.halo4.nc' 240 real(kind=R_GRID),
parameter::
dbl_snan=x
'FFF7FFFFFFFFFFFF' 272 integer,
intent(in) :: isd,ied,jsd,jed,npx,npy
274 real,
intent(in) :: dt_atmos
282 integer :: dimid,i,i_start,i_end,j,j_start,j_end,klev_out &
283 ,nrows_bc_data,nrows_blend_in_data,sec
287 character(len=2) :: char2_1,char2_2
288 character(len=3) :: int_to_char
289 character(len=6) :: fmt=
'(i3.3)' 290 character(len=50) :: file_name
381 if(.not.atm%flagstruct%regional_bcs_from_gsi)
then 382 file_name=
'INPUT/gfs_bndy.tile7.'//int_to_char//
'.nc' 384 file_name=
'INPUT/gfs_bndy.tile7.'//int_to_char//
'_gsi.nc' 387 if (is_master())
then 388 write(*,20011)trim(file_name)
389 20011
format(
' regional_bc_data file_name=',a)
395 call check(nf90_open(file_name,nf90_nowrite,
ncid))
396 if (is_master())
then 397 write(0,*)
' opened BC file ',trim(file_name)
407 call check(nf90_inq_dimid(
ncid,
'halo',dimid))
408 call check(nf90_inquire_dimension(
ncid,dimid,len=nrows_bc_data))
414 write(char2_2,
'(I2.2)')nrows_blend_in_data
415 call mpp_error(fatal,
'User wants to use '//char2_1//
' blending rows but only '//char2_2//
' blending rows are in the BC file!')
462 ,atm%regional_bc_bounds%is_north &
463 ,atm%regional_bc_bounds%ie_north &
464 ,atm%regional_bc_bounds%js_north &
465 ,atm%regional_bc_bounds%je_north &
466 ,atm%regional_bc_bounds%is_north_uvs &
467 ,atm%regional_bc_bounds%ie_north_uvs &
468 ,atm%regional_bc_bounds%js_north_uvs &
469 ,atm%regional_bc_bounds%je_north_uvs &
470 ,atm%regional_bc_bounds%is_north_uvw &
471 ,atm%regional_bc_bounds%ie_north_uvw &
472 ,atm%regional_bc_bounds%js_north_uvw &
473 ,atm%regional_bc_bounds%je_north_uvw &
482 ,atm%regional_bc_bounds%is_north &
483 ,atm%regional_bc_bounds%ie_north &
484 ,atm%regional_bc_bounds%js_north &
485 ,atm%regional_bc_bounds%je_north &
486 ,atm%regional_bc_bounds%is_north_uvs &
487 ,atm%regional_bc_bounds%ie_north_uvs &
488 ,atm%regional_bc_bounds%js_north_uvs &
489 ,atm%regional_bc_bounds%je_north_uvs &
490 ,atm%regional_bc_bounds%is_north_uvw &
491 ,atm%regional_bc_bounds%ie_north_uvw &
492 ,atm%regional_bc_bounds%js_north_uvw &
493 ,atm%regional_bc_bounds%je_north_uvw &
507 ,atm%regional_bc_bounds%is_south &
508 ,atm%regional_bc_bounds%ie_south &
509 ,atm%regional_bc_bounds%js_south &
510 ,atm%regional_bc_bounds%je_south &
511 ,atm%regional_bc_bounds%is_south_uvs &
512 ,atm%regional_bc_bounds%ie_south_uvs &
513 ,atm%regional_bc_bounds%js_south_uvs &
514 ,atm%regional_bc_bounds%je_south_uvs &
515 ,atm%regional_bc_bounds%is_south_uvw &
516 ,atm%regional_bc_bounds%ie_south_uvw &
517 ,atm%regional_bc_bounds%js_south_uvw &
518 ,atm%regional_bc_bounds%je_south_uvw &
527 ,atm%regional_bc_bounds%is_south &
528 ,atm%regional_bc_bounds%ie_south &
529 ,atm%regional_bc_bounds%js_south &
530 ,atm%regional_bc_bounds%je_south &
531 ,atm%regional_bc_bounds%is_south_uvs &
532 ,atm%regional_bc_bounds%ie_south_uvs &
533 ,atm%regional_bc_bounds%js_south_uvs &
534 ,atm%regional_bc_bounds%je_south_uvs &
535 ,atm%regional_bc_bounds%is_south_uvw &
536 ,atm%regional_bc_bounds%ie_south_uvw &
537 ,atm%regional_bc_bounds%js_south_uvw &
538 ,atm%regional_bc_bounds%je_south_uvw &
552 ,atm%regional_bc_bounds%is_east &
553 ,atm%regional_bc_bounds%ie_east &
554 ,atm%regional_bc_bounds%js_east &
555 ,atm%regional_bc_bounds%je_east &
556 ,atm%regional_bc_bounds%is_east_uvs &
557 ,atm%regional_bc_bounds%ie_east_uvs &
558 ,atm%regional_bc_bounds%js_east_uvs &
559 ,atm%regional_bc_bounds%je_east_uvs &
560 ,atm%regional_bc_bounds%is_east_uvw &
561 ,atm%regional_bc_bounds%ie_east_uvw &
562 ,atm%regional_bc_bounds%js_east_uvw &
563 ,atm%regional_bc_bounds%je_east_uvw &
572 ,atm%regional_bc_bounds%is_east &
573 ,atm%regional_bc_bounds%ie_east &
574 ,atm%regional_bc_bounds%js_east &
575 ,atm%regional_bc_bounds%je_east &
576 ,atm%regional_bc_bounds%is_east_uvs &
577 ,atm%regional_bc_bounds%ie_east_uvs &
578 ,atm%regional_bc_bounds%js_east_uvs &
579 ,atm%regional_bc_bounds%je_east_uvs &
580 ,atm%regional_bc_bounds%is_east_uvw &
581 ,atm%regional_bc_bounds%ie_east_uvw &
582 ,atm%regional_bc_bounds%js_east_uvw &
583 ,atm%regional_bc_bounds%je_east_uvw &
597 ,atm%regional_bc_bounds%is_west &
598 ,atm%regional_bc_bounds%ie_west &
599 ,atm%regional_bc_bounds%js_west &
600 ,atm%regional_bc_bounds%je_west &
601 ,atm%regional_bc_bounds%is_west_uvs &
602 ,atm%regional_bc_bounds%ie_west_uvs &
603 ,atm%regional_bc_bounds%js_west_uvs &
604 ,atm%regional_bc_bounds%je_west_uvs &
605 ,atm%regional_bc_bounds%is_west_uvw &
606 ,atm%regional_bc_bounds%ie_west_uvw &
607 ,atm%regional_bc_bounds%js_west_uvw &
608 ,atm%regional_bc_bounds%je_west_uvw &
617 ,atm%regional_bc_bounds%is_west &
618 ,atm%regional_bc_bounds%ie_west &
619 ,atm%regional_bc_bounds%js_west &
620 ,atm%regional_bc_bounds%je_west &
621 ,atm%regional_bc_bounds%is_west_uvs &
622 ,atm%regional_bc_bounds%ie_west_uvs &
623 ,atm%regional_bc_bounds%js_west_uvs &
624 ,atm%regional_bc_bounds%je_west_uvs &
625 ,atm%regional_bc_bounds%is_west_uvw &
626 ,atm%regional_bc_bounds%ie_west_uvw &
627 ,atm%regional_bc_bounds%js_west_uvw &
628 ,atm%regional_bc_bounds%je_west_uvw &
681 if(.not.atm%flagstruct%warm_start)
then 697 if(.not.atm%flagstruct%warm_start)
then 712 if(.not.atm%flagstruct%warm_start)
then 727 if(.not.atm%flagstruct%warm_start)
then 739 sphum_index = get_tracer_index(model_atmos,
'sphum')
746 o3mr_index = get_tracer_index(model_atmos,
'o3mr')
802 integer,
parameter :: invalid_index = -99
809 regional_bc_bounds%is_north = invalid_index
810 regional_bc_bounds%ie_north = invalid_index
811 regional_bc_bounds%js_north = invalid_index
812 regional_bc_bounds%je_north = invalid_index
813 regional_bc_bounds%is_north_uvs = invalid_index
814 regional_bc_bounds%ie_north_uvs = invalid_index
815 regional_bc_bounds%js_north_uvs = invalid_index
816 regional_bc_bounds%je_north_uvs = invalid_index
817 regional_bc_bounds%is_north_uvw = invalid_index
818 regional_bc_bounds%ie_north_uvw = invalid_index
819 regional_bc_bounds%js_north_uvw = invalid_index
820 regional_bc_bounds%je_north_uvw = invalid_index
822 regional_bc_bounds%is_south = invalid_index
823 regional_bc_bounds%ie_south = invalid_index
824 regional_bc_bounds%js_south = invalid_index
825 regional_bc_bounds%je_south = invalid_index
826 regional_bc_bounds%is_south_uvs = invalid_index
827 regional_bc_bounds%ie_south_uvs = invalid_index
828 regional_bc_bounds%js_south_uvs = invalid_index
829 regional_bc_bounds%je_south_uvs = invalid_index
830 regional_bc_bounds%is_south_uvw = invalid_index
831 regional_bc_bounds%ie_south_uvw = invalid_index
832 regional_bc_bounds%js_south_uvw = invalid_index
833 regional_bc_bounds%je_south_uvw = invalid_index
835 regional_bc_bounds%is_east = invalid_index
836 regional_bc_bounds%ie_east = invalid_index
837 regional_bc_bounds%js_east = invalid_index
838 regional_bc_bounds%je_east = invalid_index
839 regional_bc_bounds%is_east_uvs = invalid_index
840 regional_bc_bounds%ie_east_uvs = invalid_index
841 regional_bc_bounds%js_east_uvs = invalid_index
842 regional_bc_bounds%je_east_uvs = invalid_index
843 regional_bc_bounds%is_east_uvw = invalid_index
844 regional_bc_bounds%ie_east_uvw = invalid_index
845 regional_bc_bounds%js_east_uvw = invalid_index
846 regional_bc_bounds%je_east_uvw = invalid_index
848 regional_bc_bounds%is_west = invalid_index
849 regional_bc_bounds%ie_west = invalid_index
850 regional_bc_bounds%js_west = invalid_index
851 regional_bc_bounds%je_west = invalid_index
852 regional_bc_bounds%is_west_uvs = invalid_index
853 regional_bc_bounds%ie_west_uvs = invalid_index
854 regional_bc_bounds%js_west_uvs = invalid_index
855 regional_bc_bounds%je_west_uvs = invalid_index
856 regional_bc_bounds%is_west_uvw = invalid_index
857 regional_bc_bounds%ie_west_uvw = invalid_index
858 regional_bc_bounds%js_west_uvw = invalid_index
859 regional_bc_bounds%je_west_uvw = invalid_index
878 regional_bc_bounds%is_north=isd-1
879 regional_bc_bounds%ie_north=ied+1
881 regional_bc_bounds%js_north=jsd-1
890 regional_bc_bounds%is_south=isd-1
891 regional_bc_bounds%ie_south=ied+1
894 regional_bc_bounds%je_south=jed+1
902 regional_bc_bounds%is_east=isd-1
905 regional_bc_bounds%js_east=jsd-1
907 regional_bc_bounds%js_east=1
910 regional_bc_bounds%je_east=jed+1
922 regional_bc_bounds%ie_west=ied+1
924 regional_bc_bounds%js_west=jsd-1
926 regional_bc_bounds%js_west=1
929 regional_bc_bounds%je_west=jed+1
944 regional_bc_bounds%is_north_uvs=isd
945 regional_bc_bounds%ie_north_uvs=ied
947 regional_bc_bounds%js_north_uvs=jsd
950 regional_bc_bounds%is_north_uvw=isd
951 regional_bc_bounds%ie_north_uvw=ied+1
953 regional_bc_bounds%js_north_uvw=jsd
962 regional_bc_bounds%is_south_uvs=isd
963 regional_bc_bounds%ie_south_uvs=ied
966 regional_bc_bounds%je_south_uvs=jed+1
968 regional_bc_bounds%is_south_uvw=isd
969 regional_bc_bounds%ie_south_uvw=ied+1
972 regional_bc_bounds%je_south_uvw=jed
980 regional_bc_bounds%is_east_uvs=isd
983 regional_bc_bounds%js_east_uvs=jsd
985 regional_bc_bounds%js_east_uvs=1
988 regional_bc_bounds%je_east_uvs=jed+1
994 regional_bc_bounds%is_east_uvw=isd
997 regional_bc_bounds%js_east_uvw=jsd
999 regional_bc_bounds%js_east_uvw=1
1001 regional_bc_bounds%je_east_uvw=jed
1013 regional_bc_bounds%ie_west_uvs=ied
1015 regional_bc_bounds%js_west_uvs=jsd
1017 regional_bc_bounds%js_west_uvs=1
1020 regional_bc_bounds%je_west_uvs=jed+1
1026 regional_bc_bounds%ie_west_uvw=ied+1
1028 regional_bc_bounds%js_west_uvw=jsd
1030 regional_bc_bounds%js_west_uvw=1
1033 regional_bc_bounds%je_west_uvw=jed
1063 integer :: i_start_data,istat,j_start_data,n,ncid_grid,var_id
1065 character(len=150) :: filename,vname
1077 call check(nf90_open(filename,nf90_nowrite,ncid_grid))
1079 call mpp_error(note,
' opened grid file '//trim(filename))
1095 call check(nf90_inq_varid(ncid_grid,vname,var_id))
1096 call check(nf90_get_var(ncid_grid,var_id &
1097 ,
grid_reg(isd-1:ied+2,jsd-1:jed+2,1) &
1098 ,start=(/i_start_data,j_start_data/) &
1106 call check(nf90_inq_varid(ncid_grid,vname,var_id))
1107 call check(nf90_get_var(ncid_grid,var_id &
1108 ,
grid_reg(isd-1:ied+2,jsd-1:jed+2,2) &
1109 ,start=(/i_start_data,j_start_data/) &
1112 call check(nf90_close(ncid_grid))
1159 integer :: i,i_start_data,istat,j,j_start_data,ncid_oro,var_id
1161 character(len=150) :: filename,vname
1174 if (is_master())
then 1175 write(*,23421)trim(filename)
1176 23421
format(
' topo filename=',a)
1179 call check(nf90_open(filename,nf90_nowrite,ncid_oro))
1189 call check(nf90_inq_varid(ncid_oro,vname,var_id))
1190 call check(nf90_get_var(ncid_oro,var_id &
1191 ,
phis_reg(isd-1:ied+1,jsd-1:jed+1) &
1192 ,start=(/i_start_data,j_start_data/)))
1194 call check(nf90_close(ncid_oro))
1236 integer ,
intent(in) :: is ,ie ,js ,je & !<-- Integration limits of task subdomain
1237 ,isd,ied,jsd,jed & !<-- Memory limits of task subdomain
1240 real,
intent(in) :: dt_atmos
1241 real,
intent(in) :: ak(1:levp+1), bk(1:levp+1)
1260 ,isd, ied, jsd, jed &
1266 ,isd, ied, jsd, jed &
1271 ,atm%regional_bc_bounds )
1281 if(atm%flagstruct%regional_bcs_from_gsi)
then 1282 atm%flagstruct%regional_bcs_from_gsi=.false.
1287 ,isd, ied, jsd, jed &
1290 allocate (
ak_in(1:levp+1))
1291 allocate (
bk_in(1:levp+1))
1304 if(atm%flagstruct%write_restart_with_bcs)
then 1332 real,
intent(in) :: dt_atmos
1334 integer ,
intent(in) :: isc,iec,jsc,jec & !<-- Integration limits of task subdomain
1341 integer :: ierr, ios
1342 real,
allocatable :: wk2(:,:)
1344 logical :: filtered_terrain = .true.
1345 logical :: gfs_dwinds = .true.
1346 integer :: levp = 64
1347 logical :: checker_tr = .false.
1348 integer :: nt_checker = 0
1349 namelist /external_ic_nml/ filtered_terrain, levp, gfs_dwinds &
1350 ,checker_tr, nt_checker
1359 read (input_nml_file,external_ic_nml,iostat=ios)
1360 ierr = check_nml_error(ios,
'external_ic_nml')
1363 11011
format(
' start_regional_restart failed to read external_ic_nml ierr=',i3)
1377 ,isd, ied, jsd, jed &
1380 allocate (wk2(levp+1,2))
1381 allocate (
ak_in(levp+1))
1382 allocate (
bk_in(levp+1))
1383 call read_data(
'INPUT/gfs_ctrl.nc',
'vcoord',wk2, no_domain=.true.)
1384 ak_in(1:levp+1) = wk2(1:levp+1,1)
1386 bk_in(1:levp+1) = wk2(1:levp+1,2)
1395 ,isc, iec, jsc, jec &
1396 ,isd, ied, jsd, jed &
1406 if(atm%flagstruct%regional_bcs_from_gsi)
then 1407 atm%flagstruct%regional_bcs_from_gsi=.false.
1417 if(atm%flagstruct%write_restart_with_bcs)
then 1444 type(time_type),
intent(in) :: Time
1445 type(time_type),
intent(in) :: time_step_atmos
1447 integer,
intent(in) :: isd,ied,jsd,jed & !<-- Memory limits of task subdomain
1454 integer :: atmos_time_step, sec
1456 type(time_type) :: atmos_time
1462 atmos_time = time - atm%Time_init
1463 atmos_time_step = atmos_time / time_step_atmos
1465 if (mpp_pe() == 0 .and. atm%flagstruct%fv_debug)
write(*,
"('current_time_seconds = ',f9.1)")
current_time_in_seconds 1467 call get_time (time_step_atmos, sec)
1468 dt_atmos =
real(sec)
1470 if(atmos_time_step==0.or.atm%flagstruct%warm_start)
then 1488 ,atm%regional_bc_bounds )
1496 ,atm%bd%is, atm%bd%ie &
1497 ,atm%bd%js, atm%bd%je &
1498 ,isd, ied, jsd, jed &
1530 integer,
intent(in) :: bc_hour
1532 integer,
intent(in) :: is,ie,js,je & !<-- Compute limits of task subdomain
1535 real,
dimension(:),
intent(in) :: ak,bk
1547 integer :: dimid,i,j,k,klev_in,klev_out,n,nlev
1549 integer :: is_north,is_south,is_east,is_west &
1550 ,ie_north,ie_south,ie_east,ie_west &
1551 ,js_north,js_south,js_east,js_west &
1552 ,je_north,je_south,je_east,je_west
1554 integer :: is_u,ie_u,js_u,je_u &
1555 ,is_v,ie_v,js_v,je_v
1557 integer :: is_input,ie_input,js_input,je_input
1559 integer :: i_start,i_end,j_start,j_end
1561 integer :: nside,nt,index
1563 real,
dimension(:,:,:),
allocatable :: ud,vd,uc,vc
1565 real,
dimension(:,:),
allocatable :: ps_reg
1566 real,
dimension(:,:,:),
allocatable :: delp_input,delz_input &
1569 real,
dimension(:,:,:),
allocatable :: u_s_input,v_s_input &
1570 ,u_w_input,v_w_input
1571 real,
dimension(:,:,:,:),
allocatable :: tracers_input
1573 real(kind=R_GRID),
dimension(2):: p1, p2, p3, p4
1574 real(kind=R_GRID),
dimension(3):: e1, e2, ex, ey
1578 integer :: isc2, iec2, jsc2, jec2
1579 real(kind=R_GRID),
allocatable,
dimension(:,:) :: tmpx, tmpy
1580 integer :: start(4), nread(4)
1581 real(kind=R_GRID),
allocatable,
dimension(:,:,:) :: reg_grid
1582 real(kind=R_GRID),
allocatable,
dimension(:,:,:) :: reg_agrid
1585 logical,
save :: computed_regional_bc_indices=.false.
1587 character(len=3) :: int_to_char
1588 character(len=5) :: side
1589 character(len=6) :: fmt=
'(i3.3)' 1591 character(len=50) :: file_name
1593 integer,
save :: kount1=0,kount2=0
1594 integer :: istart, iend, jstart, jend
1597 character(len=60) :: var_name_root
1600 logical :: call_remap
1625 write(int_to_char,fmt) bc_hour
1626 if(.not.atm%flagstruct%regional_bcs_from_gsi)
then 1627 file_name=
'INPUT/gfs_bndy.tile7.'//int_to_char//
'.nc' 1629 file_name=
'INPUT/gfs_bndy.tile7.'//int_to_char//
'_gsi.nc' 1632 if (is_master())
then 1633 write(*,22211)trim(file_name)
1634 22211
format(
' regional_bc_data file_name=',a)
1641 call check(nf90_open(file_name,nf90_nowrite,
ncid))
1642 if (is_master())
then 1643 write(0,*)
' opened BC file ',trim(file_name)
1646 call check(nf90_inq_dimid(
ncid,
'lev',dimid))
1647 call check(nf90_inquire_dimension(
ncid,dimid,len=klev_in))
1660 allocate( ps_input(is_input:ie_input,js_input:je_input,1)) ; ps_input=
real_snan 1661 allocate( t_input(is_input:ie_input,js_input:je_input,1:klev_in)) ; t_input=
real_snan 1662 allocate( w_input(is_input:ie_input,js_input:je_input,1:klev_in)) ; w_input=
real_snan 1663 allocate(u_s_input(is_input:ie_input,js_input:je_input,1:klev_in)) ; u_s_input=
real_snan 1664 allocate(v_s_input(is_input:ie_input,js_input:je_input,1:klev_in)) ; v_s_input=
real_snan 1665 allocate(u_w_input(is_input:ie_input,js_input:je_input,1:klev_in)) ; u_w_input=
real_snan 1666 allocate(v_w_input(is_input:ie_input,js_input:je_input,1:klev_in)) ; v_w_input=
real_snan 1668 if(atm%flagstruct%regional_bcs_from_gsi)
then 1669 allocate(delp_input(is_input:ie_input,js_input:je_input,1:klev_in)) ; delp_input=
real_snan 1670 allocate(delz_input(is_input:ie_input,js_input:je_input,1:klev_in)) ; delz_input=
real_snan 1672 allocate( zh_input(is_input:ie_input,js_input:je_input,1:klev_in+1)) ; zh_input=
real_snan 1675 allocate(tracers_input(is_input:ie_input,js_input:je_input,klev_in,
ntracers)) ; tracers_input=
real_snan 1693 ,array_3d=ps_input )
1712 if(.not.atm%flagstruct%regional_bcs_from_gsi)
then 1726 if (
data_source ==
'FV3GFS GAUSSIAN NEMSIO FILE')
then 1748 ,array_3d=u_s_input)
1761 ,array_3d=v_s_input)
1774 ,array_3d=u_w_input)
1787 ,array_3d=v_w_input)
1794 if(atm%flagstruct%regional_bcs_from_gsi)
then 1796 var_name_root=
'delp' 1801 ,array_3d=delp_input)
1802 var_name_root=
'delz' 1807 ,array_3d=delz_input)
1824 call get_tracer_names(model_atmos, nt, var_name_root)
1825 index= get_tracer_index(model_atmos,trim(var_name_root))
1835 ,array_4d=tracers_input &
1837 ,required=required )
1849 data_to_bc:
if(atm%flagstruct%regional_bcs_from_gsi)
then 1867 allocate(ps_reg(is_input:ie_input,js_input:je_input)) ; ps_reg=-9999999
1884 sides_scalars:
do nside=1,4
1939 ,klev_in, klev_out &
1964 if (ie == npx-1)
then 1991 if (ie == npx-1)
then 2011 if (ie == npx-1)
then 2039 if (ie == npx-1)
then 2061 if (je == npy-1)
then 2086 if (je == npy-1)
then 2127 allocate(tmpx(isc2:iec2, jsc2:jec2)) ; tmpx=
dbl_snan 2128 allocate(tmpy(isc2:iec2, jsc2:jec2)) ; tmpy=
dbl_snan 2129 start = 1; nread = 1
2130 start(1) = isc2; nread(1) = iec2 - isc2 + 1
2131 start(2) = jsc2; nread(2) = jec2 - jsc2 + 1
2132 call read_data(
"INPUT/grid.tile7.halo4.nc",
'x', tmpx, start, nread, no_domain=.true.)
2133 call read_data(
"INPUT/grid.tile7.halo4.nc",
'y', tmpy, start, nread, no_domain=.true.)
2135 allocate(reg_grid(isd-1:ied+2,jsd-1:jed+2,1:2)) ; reg_grid=
dbl_snan 2140 if ( reg_grid(i,j,1) /=
grid_reg(i,j,1) )
then 2141 write(0,*)
' reg_grid(i,j,1) /= grid_reg(i,j,1) ',i,j, reg_grid(i,j,1),
grid_reg(i,j,1)
2146 allocate(reg_agrid(isd-1:ied+1,jsd-1:jed+1,1:2)) ; reg_agrid=
dbl_snan 2149 call cell_center2(reg_grid(i,j, 1:2), reg_grid(i+1,j, 1:2), &
2150 reg_grid(i,j+1,1:2), reg_grid(i+1,j+1,1:2), &
2151 reg_agrid(i,j,1:2) )
2161 sides_winds:
do nside=1,4
2171 is_u=atm%regional_bc_bounds%is_north_uvs
2172 ie_u=atm%regional_bc_bounds%ie_north_uvs
2173 js_u=atm%regional_bc_bounds%js_north_uvs
2174 je_u=atm%regional_bc_bounds%je_north_uvs
2176 is_v=atm%regional_bc_bounds%is_north_uvw
2177 ie_v=atm%regional_bc_bounds%ie_north_uvw
2178 js_v=atm%regional_bc_bounds%js_north_uvw
2179 je_v=atm%regional_bc_bounds%je_north_uvw
2188 is_u=atm%regional_bc_bounds%is_south_uvs
2189 ie_u=atm%regional_bc_bounds%ie_south_uvs
2190 js_u=atm%regional_bc_bounds%js_south_uvs
2191 je_u=atm%regional_bc_bounds%je_south_uvs
2193 is_v=atm%regional_bc_bounds%is_south_uvw
2194 ie_v=atm%regional_bc_bounds%ie_south_uvw
2195 js_v=atm%regional_bc_bounds%js_south_uvw
2196 je_v=atm%regional_bc_bounds%je_south_uvw
2205 is_u=atm%regional_bc_bounds%is_east_uvs
2206 ie_u=atm%regional_bc_bounds%ie_east_uvs
2207 js_u=atm%regional_bc_bounds%js_east_uvs
2208 je_u=atm%regional_bc_bounds%je_east_uvs
2210 is_v=atm%regional_bc_bounds%is_east_uvw
2211 ie_v=atm%regional_bc_bounds%ie_east_uvw
2212 js_v=atm%regional_bc_bounds%js_east_uvw
2213 je_v=atm%regional_bc_bounds%je_east_uvw
2222 is_u=atm%regional_bc_bounds%is_west_uvs
2223 ie_u=atm%regional_bc_bounds%ie_west_uvs
2224 js_u=atm%regional_bc_bounds%js_west_uvs
2225 je_u=atm%regional_bc_bounds%je_west_uvs
2227 is_v=atm%regional_bc_bounds%is_west_uvw
2228 ie_v=atm%regional_bc_bounds%ie_west_uvw
2229 js_v=atm%regional_bc_bounds%js_west_uvw
2230 je_v=atm%regional_bc_bounds%je_west_uvw
2236 allocate(ud(is_u:ie_u,js_u:je_u,1:nlev)) ; ud=
real_snan 2237 allocate(vd(is_v:ie_v,js_v:je_v,1:nlev)) ; vd=
real_snan 2238 allocate(vc(is_u:ie_u,js_u:je_u,1:nlev)) ; vc=
real_snan 2239 allocate(uc(is_v:ie_v,js_v:je_v,1:nlev)) ; uc=
real_snan 2288 ,klev_in, klev_out &
2296 deallocate(ud,vd,uc,vc)
2317 if(
allocated(ps_input))
then 2318 deallocate(ps_input)
2320 if(
allocated(t_input))
then 2323 if(
allocated(zh_input))
then 2324 deallocate(zh_input)
2326 if(
allocated(w_input))
then 2329 if(
allocated(tracers_input))
then 2330 deallocate(tracers_input)
2332 if(
allocated(u_s_input))
then 2333 deallocate(u_s_input)
2335 if(
allocated(u_w_input))
then 2336 deallocate(u_w_input)
2338 if(
allocated(v_s_input))
then 2339 deallocate(v_s_input)
2341 if(
allocated(v_w_input))
then 2342 deallocate(v_w_input)
2344 if(
allocated(delp_input))
then 2345 deallocate(delp_input)
2347 if(
allocated(delz_input))
then 2348 deallocate(delz_input)
2386 if(atm%flagstruct%nudge_qv)
then 2429 is_input=lbound(
bc_t1%north%delp_BC,1)
2430 ie_input=ubound(
bc_t1%north%delp_BC,1)
2431 js_input=lbound(
bc_t1%north%delp_BC,2)
2432 je_input=ubound(
bc_t1%north%delp_BC,2)
2435 do j=js_input,je_input
2436 do i=is_input,ie_input
2437 bc_t1%north%delp_BC(i,j,k)=delp_input(i,j,k)
2438 bc_t1%north%pt_BC(i,j,k)=t_input(i,j,k)
2439 bc_t1%north%w_BC(i,j,k)=w_input(i,j,k)
2440 bc_t1%north%delz_BC(i,j,k)=delz_input(i,j,k)
2447 do j=js_input,je_input
2448 do i=is_input,ie_input
2449 bc_t1%north%q_BC(i,j,k,n)=tracers_input(i,j,k,n)
2455 is_input=lbound(
bc_t1%north%u_BC,1)
2456 ie_input=ubound(
bc_t1%north%u_BC,1)
2457 js_input=lbound(
bc_t1%north%u_BC,2)
2458 je_input=ubound(
bc_t1%north%u_BC,2)
2461 do j=js_input,je_input
2462 do i=is_input,ie_input
2463 bc_t1%north%u_BC(i,j,k)=u_s_input(i,j,k)
2464 bc_t1%north%vc_BC(i,j,k)=v_s_input(i,j,k)
2469 is_input=lbound(
bc_t1%north%v_BC,1)
2470 ie_input=ubound(
bc_t1%north%v_BC,1)
2471 js_input=lbound(
bc_t1%north%v_BC,2)
2472 je_input=ubound(
bc_t1%north%v_BC,2)
2475 do j=js_input,je_input
2476 do i=is_input,ie_input
2477 bc_t1%north%v_BC(i,j,k)=v_w_input(i,j,k)
2478 bc_t1%north%uc_BC(i,j,k)=u_w_input(i,j,k)
2490 is_input=lbound(
bc_t1%south%delp_BC,1)
2491 ie_input=ubound(
bc_t1%south%delp_BC,1)
2492 js_input=lbound(
bc_t1%south%delp_BC,2)
2493 je_input=ubound(
bc_t1%south%delp_BC,2)
2496 do j=js_input,je_input
2497 do i=is_input,ie_input
2498 bc_t1%south%delp_BC(i,j,k)=delp_input(i,j,k)
2499 bc_t1%south%pt_BC(i,j,k)=t_input(i,j,k)
2500 bc_t1%south%w_BC(i,j,k)=w_input(i,j,k)
2501 bc_t1%south%delz_BC(i,j,k)=delz_input(i,j,k)
2508 do j=js_input,je_input
2509 do i=is_input,ie_input
2510 bc_t1%south%q_BC(i,j,k,n)=tracers_input(i,j,k,n)
2516 is_input=lbound(
bc_t1%south%u_BC,1)
2517 ie_input=ubound(
bc_t1%south%u_BC,1)
2518 js_input=lbound(
bc_t1%south%u_BC,2)
2519 je_input=ubound(
bc_t1%south%u_BC,2)
2522 do j=js_input,je_input
2523 do i=is_input,ie_input
2524 bc_t1%south%u_BC(i,j,k)=u_s_input(i,j,k)
2525 bc_t1%south%vc_BC(i,j,k)=v_s_input(i,j,k)
2530 is_input=lbound(
bc_t1%south%v_BC,1)
2531 ie_input=ubound(
bc_t1%south%v_BC,1)
2532 js_input=lbound(
bc_t1%south%v_BC,2)
2533 je_input=ubound(
bc_t1%south%v_BC,2)
2536 do j=js_input,je_input
2537 do i=is_input,ie_input
2538 bc_t1%south%v_BC(i,j,k)=v_w_input(i,j,k)
2539 bc_t1%south%uc_BC(i,j,k)=u_w_input(i,j,k)
2551 is_input=lbound(
bc_t1%east%delp_BC,1)
2552 ie_input=ubound(
bc_t1%east%delp_BC,1)
2553 js_input=lbound(
bc_t1%east%delp_BC,2)
2554 je_input=ubound(
bc_t1%east%delp_BC,2)
2557 do j=js_input,je_input
2558 do i=is_input,ie_input
2559 bc_t1%east%delp_BC(i,j,k)=delp_input(i,j,k)
2560 bc_t1%east%pt_BC(i,j,k)=t_input(i,j,k)
2561 bc_t1%east%w_BC(i,j,k)=w_input(i,j,k)
2562 bc_t1%east%delz_BC(i,j,k)=delz_input(i,j,k)
2569 do j=js_input,je_input
2570 do i=is_input,ie_input
2571 bc_t1%east%q_BC(i,j,k,n)=tracers_input(i,j,k,n)
2577 is_input=lbound(
bc_t1%east%u_BC,1)
2578 ie_input=ubound(
bc_t1%east%u_BC,1)
2579 js_input=lbound(
bc_t1%east%u_BC,2)
2580 je_input=ubound(
bc_t1%east%u_BC,2)
2583 do j=js_input,je_input
2584 do i=is_input,ie_input
2585 bc_t1%east%u_BC(i,j,k)=u_s_input(i,j,k)
2586 bc_t1%east%vc_BC(i,j,k)=v_s_input(i,j,k)
2591 is_input=lbound(
bc_t1%east%v_BC,1)
2592 ie_input=ubound(
bc_t1%east%v_BC,1)
2593 js_input=lbound(
bc_t1%east%v_BC,2)
2594 je_input=ubound(
bc_t1%east%v_BC,2)
2597 do j=js_input,je_input
2598 do i=is_input,ie_input
2599 bc_t1%east%v_BC(i,j,k)=v_w_input(i,j,k)
2600 bc_t1%east%uc_BC(i,j,k)=u_w_input(i,j,k)
2612 is_input=lbound(
bc_t1%west%delp_BC,1)
2613 ie_input=ubound(
bc_t1%west%delp_BC,1)
2614 js_input=lbound(
bc_t1%west%delp_BC,2)
2615 je_input=ubound(
bc_t1%west%delp_BC,2)
2618 do j=js_input,je_input
2619 do i=is_input,ie_input
2620 bc_t1%west%delp_BC(i,j,k)=delp_input(i,j,k)
2621 bc_t1%west%pt_BC(i,j,k)=t_input(i,j,k)
2622 bc_t1%west%w_BC(i,j,k)=w_input(i,j,k)
2623 bc_t1%west%delz_BC(i,j,k)=delz_input(i,j,k)
2630 do j=js_input,je_input
2631 do i=is_input,ie_input
2632 bc_t1%west%q_BC(i,j,k,n)=tracers_input(i,j,k,n)
2638 is_input=lbound(
bc_t1%west%u_BC,1)
2639 ie_input=ubound(
bc_t1%west%u_BC,1)
2640 js_input=lbound(
bc_t1%west%u_BC,2)
2641 je_input=ubound(
bc_t1%west%u_BC,2)
2644 do j=js_input,je_input
2645 do i=is_input,ie_input
2646 bc_t1%west%u_BC(i,j,k)=u_s_input(i,j,k)
2647 bc_t1%west%vc_BC(i,j,k)=v_s_input(i,j,k)
2652 is_input=lbound(
bc_t1%west%v_BC,1)
2653 ie_input=ubound(
bc_t1%west%v_BC,1)
2654 js_input=lbound(
bc_t1%west%v_BC,2)
2655 je_input=ubound(
bc_t1%west%v_BC,2)
2658 do j=js_input,je_input
2659 do i=is_input,ie_input
2660 bc_t1%west%v_BC(i,j,k)=v_w_input(i,j,k)
2661 bc_t1%west%uc_BC(i,j,k)=u_w_input(i,j,k)
2688 integer :: i,ie0,is0,j,je0,js0,k,nside
2708 is0=lbound(
bc_t1%north%divgd_BC,1)
2709 ie0=ubound(
bc_t1%north%divgd_BC,1)
2710 js0=lbound(
bc_t1%north%divgd_BC,2)
2711 je0=ubound(
bc_t1%north%divgd_BC,2)
2719 is0=lbound(
bc_t1%south%divgd_BC,1)
2720 ie0=ubound(
bc_t1%south%divgd_BC,1)
2721 js0=lbound(
bc_t1%south%divgd_BC,2)
2722 je0=ubound(
bc_t1%south%divgd_BC,2)
2730 is0=lbound(
bc_t1%east%divgd_BC,1)
2731 ie0=ubound(
bc_t1%east%divgd_BC,1)
2732 js0=lbound(
bc_t1%east%divgd_BC,2)
2733 je0=ubound(
bc_t1%east%divgd_BC,2)
2741 is0=lbound(
bc_t1%west%divgd_BC,1)
2742 ie0=ubound(
bc_t1%west%divgd_BC,1)
2743 js0=lbound(
bc_t1%west%divgd_BC,2)
2744 je0=ubound(
bc_t1%west%divgd_BC,2)
2769 subroutine fill_q_con_bc
2782 integer :: i,ie0,is0,j,je0,js0,k,nside
2801 is0=lbound(
bc_t1%north%q_con_BC,1)
2802 ie0=ubound(
bc_t1%north%q_con_BC,1)
2803 js0=lbound(
bc_t1%north%q_con_BC,2)
2804 je0=ubound(
bc_t1%north%q_con_BC,2)
2812 is0=lbound(
bc_t1%south%q_con_BC,1)
2813 ie0=ubound(
bc_t1%south%q_con_BC,1)
2814 js0=lbound(
bc_t1%south%q_con_BC,2)
2815 je0=ubound(
bc_t1%south%q_con_BC,2)
2823 is0=lbound(
bc_t1%east%q_con_BC,1)
2824 ie0=ubound(
bc_t1%east%q_con_BC,1)
2825 js0=lbound(
bc_t1%east%q_con_BC,2)
2826 je0=ubound(
bc_t1%east%q_con_BC,2)
2834 is0=lbound(
bc_t1%west%q_con_BC,1)
2835 ie0=ubound(
bc_t1%west%q_con_BC,1)
2836 js0=lbound(
bc_t1%west%q_con_BC,2)
2837 je0=ubound(
bc_t1%west%q_con_BC,2)
2855 end subroutine fill_q_con_bc
2863 subroutine fill_cappa_bc
2876 integer :: i1,i2,j1,j2,nside
2878 real,
dimension(:,:,:),
pointer :: cappa,temp,liq_wat,sphum
2880 logical :: call_compute
2887 call_compute=.false.
2917 if(call_compute)
then 2926 call compute_cappa(i1,i2,j1,j2,cappa,temp,liq_wat,sphum)
2933 end subroutine fill_cappa_bc
2939 subroutine compute_cappa(i1,i2,j1,j2,cappa,temp,liq_wat,sphum)
2949 integer,
intent(in) :: i1,i2,j1,j2
2951 real,
dimension(i1:i2,j1:j2,1:npz),
intent(in) :: temp,liq_wat,sphum
2952 real,
dimension(i1:i2,j1:j2,1:npz),
intent(inout) :: cappa
2958 integer :: i,ie,is,j,je,js,k
2960 real :: cvm,qd,ql,qs,qv
2974 qd=max(0.,liq_wat(i,j,k))
2975 if( temp(i,j,k) >
tice )
then 2977 elseif( temp(i,j,k) <
tice-
t_i0 )
then 2983 qv=max(0.,sphum(i,j,k))
2986 cappa(i,j,k)=rdgas/(rdgas+cvm/(1.+
zvir*sphum(i,j,k)))
2994 end subroutine compute_cappa
3005 ,js_input,je_input &
3029 integer,
intent(in) :: is_input,ie_input,js_input,je_input,nlev
3030 integer,
intent(in) :: ntracers
3032 integer,
intent(in),
optional :: tlev
3034 character(len=*),
intent(in) :: var_name_root
3035 logical,
intent(in),
optional :: required
3041 real,
dimension(is_input:ie_input,js_input:je_input,1:nlev),
intent(out),
optional :: array_3d
3043 real,
dimension(is_input:ie_input,js_input:je_input,1:nlev,1:ntracers),
intent(out),
optional :: array_4d
3049 integer :: halo,lat,lev,lon
3051 integer :: i_count,i_start_array,i_start_data,i_end_array &
3052 ,j_count,j_start_array,j_start_data,j_end_array
3054 integer :: dim_id,nctype,ndims,var_id
3055 integer :: nside,status
3057 character(len=5) :: dim_name_x & !<-- Dimension names in
3060 character(len=80) :: var_name
3062 logical :: call_get_var,is_root_pe
3063 logical :: required_local
3073 if(
present(required))
then 3074 required_local=required
3076 required_local=.true.
3079 is_root_pe=(mpp_pe()==mpp_root_pe())
3089 call_get_var=.false.
3109 var_name=trim(var_name_root)//
"_bottom" 3111 i_start_array=is_input
3112 i_end_array =ie_input
3113 j_start_array=js_input
3114 if(trim(var_name_root)==
'u_s'.or.trim(var_name_root)==
'v_s')
then 3121 i_count=i_end_array-i_start_array+1
3123 j_count=j_end_array-j_start_array+1
3136 var_name=trim(var_name_root)//
"_top" 3138 i_start_array=is_input
3139 i_end_array =ie_input
3141 j_end_array =je_input
3144 i_count=i_end_array-i_start_array+1
3146 j_count=j_end_array-j_start_array+1
3159 var_name=trim(var_name_root)//
"_left" 3161 j_start_array=js_input
3162 j_end_array =je_input
3164 i_start_array=is_input
3166 if(trim(var_name_root)==
'u_w'.or.trim(var_name_root)==
'v_w')
then 3173 if(trim(var_name_root)==
'u_s'.or.trim(var_name_root)==
'v_s')
then 3184 i_count=i_end_array-i_start_array+1
3185 if(trim(var_name_root)==
'u_s'.or.trim(var_name_root)==
'v_s')
then 3186 j_start_data=j_start_array-1
3188 j_start_data=j_start_array
3190 j_count=j_end_array-j_start_array+1
3203 var_name=trim(var_name_root)//
"_right" 3205 j_start_array=js_input
3206 j_end_array =je_input
3209 i_end_array=ie_input
3212 if(trim(var_name_root)==
'u_s'.or.trim(var_name_root)==
'v_s')
then 3224 i_count=i_end_array-i_start_array+1
3225 if(trim(var_name_root)==
'u_s'.or.trim(var_name_root)==
'v_s')
then 3226 j_start_data=j_start_array-1
3228 j_start_data=j_start_array
3230 j_count=j_end_array-j_start_array+1
3245 if(call_get_var)
then 3246 if (
present(array_4d))
then 3247 status=nf90_inq_varid(
ncid,trim(var_name),var_id)
3248 if (required_local)
then 3251 if (status /= nf90_noerr)
then 3252 if (
east_bc.and.is_master())
write(0,*)
' WARNING: Tracer ',trim(var_name),
' not in input file' 3253 array_4d(:,:,:,tlev)=0.
3259 ,array_4d(i_start_array:i_end_array &
3260 ,j_start_array:j_end_array &
3262 ,start=(/i_start_data,j_start_data,1,tlev/) &
3263 ,count=(/i_count,j_count,nlev,1/)))
3268 call check(nf90_inq_varid(
ncid,trim(var_name),var_id))
3270 ,array_3d(i_start_array:i_end_array &
3271 ,j_start_array:j_end_array &
3273 ,start=(/i_start_data,j_start_data,1/) &
3274 ,count=(/i_count,j_count,nlev/)))
3289 subroutine check(status)
3290 integer,
intent(in) :: status
3292 if(status /= nf90_noerr)
then 3293 write(0,*)
' check netcdf status=',status
3294 call mpp_error(fatal,
' NetCDF error ' // trim(nf90_strerror(status)))
3297 end subroutine check 3304 ,north_bc,south_bc &
3306 ,is_0,ie_0,js_0,je_0 &
3307 ,is_sn,ie_sn,js_sn,je_sn &
3308 ,is_we,ie_we,js_we,je_we &
3322 integer,
intent(in) :: klev,ntracers
3324 integer,
intent(in) :: is_0,ie_0,js_0,je_0
3325 integer,
intent(in) :: is_sn,ie_sn,js_sn,je_sn
3326 integer,
intent(in) :: is_we,ie_we,js_we,je_we
3328 character(len=5),
intent(in) :: side
3330 logical,
intent(in) :: north_bc,south_bc,east_bc,west_bc
3334 real,
dimension(:,:,:),
pointer,
intent(inout),
optional :: delz_side
3340 if(
allocated(bc_side%delp_BC))
then 3344 allocate(bc_side%delp_BC (is_0:ie_0,js_0:je_0,klev)) ; bc_side%delp_BC=
real_snan 3345 allocate(bc_side%divgd_BC(is_0:ie_0,js_0:je_0,klev)) ; bc_side%divgd_BC=
real_snan 3347 allocate(bc_side%q_BC (is_0:ie_0,js_0:je_0,1:klev,1:ntracers)) ; bc_side%q_BC=
real_snan 3355 allocate(bc_side%pt_BC (is_0:ie_0,js_0:je_0,klev)) ; bc_side%pt_BC=
real_snan 3356 allocate(bc_side%w_BC (is_0:ie_0,js_0:je_0,klev)) ; bc_side%w_BC=
real_snan 3357 allocate(bc_side%delz_BC (is_0:ie_0,js_0:je_0,klev)) ; bc_side%delz_BC=
real_snan 3358 if(
present(delz_side))
then 3359 if(.not.
associated(delz_side))
then 3360 allocate(delz_side(is_0:ie_0,js_0:je_0,klev)) ; delz_side=
real_snan 3364 allocate(bc_side%q_con_BC(is_0:ie_0,js_0:je_0,klev)) ; bc_side%q_con_BC=
real_snan 3366 allocate(bc_side%cappa_BC(is_0:ie_0,js_0:je_0,klev)) ; bc_side%cappa_BC=
real_snan 3377 allocate(bc_side%u_BC (is_sn:ie_sn, js_sn:je_sn, klev)) ; bc_side%u_BC=
real_snan 3378 allocate(bc_side%vc_BC(is_sn:ie_sn, js_sn:je_sn, klev)) ; bc_side%vc_BC=
real_snan 3382 allocate(bc_side%uc_BC(is_we:ie_we, js_we:je_we, klev)) ; bc_side%uc_BC=
real_snan 3383 allocate(bc_side%v_BC (is_we:ie_we, js_we:je_we, klev)) ; bc_side%v_BC=
real_snan 3396 ,is_bc,ie_bc,js_bc,je_bc &
3397 ,km, npz, ncnst, ak0, bk0 &
3398 ,psc, t_in, qa, omga, zh &
3404 integer,
intent(in):: isd,ied,jsd,jed
3405 integer,
intent(in):: is_bc,ie_bc,js_bc,je_bc
3406 integer,
intent(in):: km & !<-- # of levels in 3-D input variables
3407 ,npz & !<-- # of levels in final 3-D integration variables
3409 real,
intent(in):: ak0(km+1), bk0(km+1)
3410 real,
intent(in),
dimension(is_bc:ie_bc,js_bc:je_bc):: psc
3411 real,
intent(in),
dimension(is_bc:ie_bc,js_bc:je_bc,km):: t_in
3412 real,
intent(in),
dimension(is_bc:ie_bc,js_bc:je_bc,km):: omga
3413 real,
intent(in),
dimension(is_bc:ie_bc,js_bc:je_bc,km,ncnst):: qa
3414 real,
intent(in),
dimension(is_bc:ie_bc,js_bc:je_bc,km+1):: zh
3415 real,
intent(inout),
dimension(isd-1:ied+1,jsd-1:jed+1):: phis_reg
3416 real,
intent(out),
dimension(is_bc:ie_bc,js_bc:je_bc) :: ps
3417 character(len=5),
intent(in) :: side
3422 real,
dimension(:,:),
allocatable :: pe0
3423 real,
dimension(:,:),
allocatable :: qn1
3424 real,
dimension(:,:),
allocatable :: dp2
3425 real,
dimension(:,:),
allocatable :: pe1
3426 real,
dimension(:,:),
allocatable :: qp
3428 real wk(is_bc:ie_bc,js_bc:je_bc)
3429 real,
dimension(is_bc:ie_bc,js_bc:je_bc):: phis
3432 real(kind=R_GRID),
dimension(is_bc:ie_bc,npz+1):: pn1
3433 real(kind=R_GRID):: gz_fv(npz+1)
3434 real(kind=R_GRID),
dimension(2*km+1):: gz, pn
3435 real(kind=R_GRID),
dimension(is_bc:ie_bc,km+1):: pn0
3436 real(kind=R_GRID):: pst
3438 integer i,ie,is,j,je,js,k,l,m, k2,iq
3439 integer sphum, o3mr, liq_wat, ice_wat, rainwat, snowwat, graupel, cld_amt
3454 if (mpp_pe()==1)
then 3455 print *,
'sphum = ', sphum
3456 print *,
'clwmr = ', liq_wat
3457 print *,
' o3mr = ', o3mr
3458 print *,
'ncnst = ', ncnst
3462 if ( sphum/=1 )
then 3463 call mpp_error(fatal,
'SPHUM must be 1st tracer')
3472 if(side==
'west')
then 3477 if(side==
'east')
then 3482 if(side==
'south')
then 3487 if(side==
'north')
then 3491 allocate(pe0(is:ie,km+1)) ; pe0=
real_snan 3492 allocate(qn1(is:ie,npz)) ; qn1=
real_snan 3493 allocate(dp2(is:ie,npz)) ; dp2=
real_snan 3494 allocate(pe1(is:ie,npz+1)) ; pe1=
real_snan 3503 pe0(i,k) = ak0(k) + bk0(k)*psc(i,j)
3504 pn0(i,k) = log(pe0(i,k))
3511 gz(k) = zh(i,j,k)*grav
3517 gz(k) = 2.*gz(km+1) - gz(l)
3518 pn(k) = 2.*pn(km+1) - pn(l)
3522 if( phis_reg(i,j).le.gz(k) .and. phis_reg(i,j).ge.gz(k+1) )
then 3523 pst = pn(k) + (pn(k+1)-pn(k))*(gz(k)-phis_reg(i,j))/(gz(k)-gz(k+1))
3527 123 ps(i,j) = exp(pst)
3558 is=lbound(bc_side%delp_BC,1)
3559 ie=ubound(bc_side%delp_BC,1)
3560 js=lbound(bc_side%delp_BC,2)
3561 je=ubound(bc_side%delp_BC,2)
3568 pe0(i,k) = ak0(k) + bk0(k)*psc(i,j)
3569 pn0(i,k) = log(pe0(i,k))
3574 pe1(i,1) = atm%ak(1)
3575 pn1(i,1) = log(pe1(i,1))
3579 pe1(i,k) = atm%ak(k) + atm%bk(k)*ps(i,j)
3580 pn1(i,k) = log(pe1(i,k))
3587 dp2(i,k) = pe1(i,k+1) - pe1(i,k)
3588 bc_side%delp_BC(i,j,k) = dp2(i,k)
3595 if (iq /= cld_amt)
then 3598 qp(i,k) = qa(i,j,k,iq)
3602 call mappm(km, pe0, qp, npz, pe1, qn1, is,ie, 0, 8, atm%ptop)
3604 if ( iq==sphum )
then 3605 call fillq(ie-is+1, npz, 1, qn1, dp2)
3607 call fillz(ie-is+1, npz, 1, qn1, dp2)
3612 bc_side%q_BC(i,j,k,iq) = qn1(i,k)
3625 if ( pn1(i,1) .lt. pn0(i,1) )
then 3626 call mpp_error(fatal,
'FV3 top higher than NCEP/GFS')
3631 gz(k) = zh(i,j,k)*grav
3636 gz(k) = 2.*gz(km+1) - gz(l)
3637 pn(k) = 2.*pn(km+1) - pn(l)
3641 gz_fv(npz+1) = phis_reg(i,j)
3647 #ifdef USE_ISOTHERMO 3649 if ( (pn1(i,k).le.pn(l+1)) .and. (pn1(i,k).ge.pn(l)) )
then 3650 gz_fv(k) = gz(l) + (gz(l+1)-gz(l))*(pn1(i,k)-pn(l))/(pn(l+1)-pn(l))
3652 elseif ( pn1(i,k) .gt. pn(km+1) )
then 3654 gz_fv(k) = gz(km+1) + (gz_fv(npz+1)-gz(km+1))*(pn1(i,k)-pn(km+1))/(pn1(i,npz+1)-pn(km+1))
3660 if ( (pn1(i,k).le.pn(l+1)) .and. (pn1(i,k).ge.pn(l)) )
then 3661 gz_fv(k) = gz(l) + (gz(l+1)-gz(l))*(pn1(i,k)-pn(l))/(pn(l+1)-pn(l))
3679 if (
data_source /=
'FV3GFS GAUSSIAN NEMSIO FILE')
then 3681 bc_side%pt_BC(i,j,k) = (gz_fv(k)-gz_fv(k+1))/( rdgas*(pn1(i,k+1)-pn1(i,k))*(1.+
zvir*bc_side%q_BC(i,j,k,sphum)) )
3686 if ( .not. atm%flagstruct%hydrostatic )
then 3688 bc_side%delz_BC(i,j,k) = (gz_fv(k+1) - gz_fv(k)) / grav
3704 if (cld_amt .gt. 0) bc_side%q_BC(:,:,:,cld_amt) = 0.
3705 if (trim(
data_source) /=
'FV3GFS GAUSSIAN NEMSIO FILE')
then 3706 if ( atm%flagstruct%nwat .eq. 6 )
then 3709 qn1(i,k) = bc_side%q_BC(i,j,k,liq_wat)
3710 bc_side%q_BC(i,j,k,rainwat) = 0.
3711 bc_side%q_BC(i,j,k,snowwat) = 0.
3712 bc_side%q_BC(i,j,k,graupel) = 0.
3713 if ( bc_side%pt_BC(i,j,k) > 273.16 )
then 3714 bc_side%q_BC(i,j,k,liq_wat) = qn1(i,k)
3715 bc_side%q_BC(i,j,k,ice_wat) = 0.
3716 #ifdef ORIG_CLOUDS_PART 3717 else if ( bc_side%pt_BC(i,j,k) < 258.16 )
then 3718 bc_side%q_BC(i,j,k,liq_wat) = 0.
3719 bc_side%q_BC(i,j,k,ice_wat) = qn1(i,k)
3721 bc_side%q_BC(i,j,k,liq_wat) = qn1(i,k)*((bc_side%pt_BC(i,j,k)-258.16)/15.)
3722 bc_side%q_BC(i,j,k,ice_wat) = qn1(i,k) - bc_side%q_BC(i,j,k,liq_wat)
3725 else if ( bc_side%pt_BC(i,j,k) < 233.16 )
then 3726 bc_side%q_BC(i,j,k,liq_wat) = 0.
3727 bc_side%q_BC(i,j,k,ice_wat) = qn1(i,k)
3730 bc_side%q_BC(i,j,k,liq_wat) = qn1(i,k)*((bc_side%pt_BC(i,j,k)-233.16)/40.)
3731 bc_side%q_BC(i,j,k,ice_wat) = qn1(i,k) - bc_side%q_BC(i,j,k,liq_wat)
3733 if (bc_side%pt_BC(i,j,k)<258.16 .and. bc_side%q_BC(i,j,k-1,ice_wat)>1.e-5 )
then 3734 bc_side%q_BC(i,j,k,liq_wat) = 0.
3735 bc_side%q_BC(i,j,k,ice_wat) = qn1(i,k)
3737 bc_side%q_BC(i,j,k,liq_wat) = qn1(i,k)*((bc_side%pt_BC(i,j,k)-233.16)/40.)
3738 bc_side%q_BC(i,j,k,ice_wat) = qn1(i,k) - bc_side%q_BC(i,j,k,liq_wat)
3744 bc_side%q_BC(i,j,k,ice_wat), bc_side%q_BC(i,j,k,snowwat) )
3756 if ( .not. atm%flagstruct%hydrostatic )
then 3759 qp(i,k) = omga(i,j,k)
3763 call mappm(km, pe0, qp, npz, pe1, qn1, is,ie, -1, 4, atm%ptop)
3765 if (
data_source ==
'FV3GFS GAUSSIAN NEMSIO FILE')
then 3768 bc_side%w_BC(i,j,k) = qn1(i,k)
3776 qp(i,k) = t_in(i,j,k)
3780 call mappm(km, pe0, qp, npz, pe1, qn1, is,ie, 2, 4, atm%ptop)
3784 bc_side%pt_BC(i,j,k) = qn1(i,k)
3791 bc_side%w_BC(i,j,k) = qn1(i,k)/bc_side%delp_BC(i,j,k)*bc_side%delz_BC(i,j,k)
3805 wk(i,j) = phis_reg(i,j)/grav - zh(i,j,km+1)
3812 wk(i,j) = ps(i,j) - psc(i,j)
3816 deallocate (pe0,qn1,dp2,pe1,qp)
3817 if (is_master())
write(*,*)
'done remap_scalar_nggps_regional_bc' 3827 ,is_input,ie_input &
3828 ,js_input,je_input &
3829 ,is_u,ie_u,js_u,je_u &
3830 ,is_v,ie_v,js_v,je_v &
3833 ,psc, ud, vd, uc, vc &
3836 integer,
intent(in):: is_input, ie_input, js_input, je_input
3837 integer,
intent(in):: is_u,ie_u,js_u,je_u
3838 integer,
intent(in):: is_v,ie_v,js_v,je_v
3839 integer,
intent(in):: km & !<-- # of levels in 3-D input variables
3841 real,
intent(in):: ak0(km+1), bk0(km+1)
3843 real,
intent(in) :: psc(is_input:ie_input,js_input:je_input)
3845 real,
intent(in):: ud(is_u:ie_u,js_u:je_u,km)
3846 real,
intent(in):: vc(is_u:ie_u,js_u:je_u,km)
3847 real,
intent(in):: vd(is_v:ie_v,js_v:je_v,km)
3848 real,
intent(in):: uc(is_v:ie_v,js_v:je_v,km)
3851 real,
dimension(:,:),
allocatable :: pe0
3852 real,
dimension(:,:),
allocatable :: pe1
3853 real,
dimension(:,:),
allocatable :: qn1_d,qn1_c
3856 allocate(pe0(is_u:ie_u, km+1)) ; pe0=
real_snan 3857 allocate(pe1(is_u:ie_u, npz+1)) ; pe1=
real_snan 3858 allocate(qn1_d(is_u:ie_u, npz)) ; qn1_d=
real_snan 3859 allocate(qn1_c(is_u:ie_u, npz)) ; qn1_c=
real_snan 3862 j_loopu:
do j=js_u,je_u
3870 pe0(i,k) = ak0(k) + bk0(k)*0.5*(psc(i,j-1)+psc(i,j))
3875 pe1(i,k) = atm%ak(k) + atm%bk(k)*0.5*(psc(i,j-1)+psc(i,j))
3878 call mappm(km, pe0(is_u:ie_u,1:km+1), ud(is_u:ie_u,j,1:km), npz, pe1(is_u:ie_u,1:npz+1), &
3879 qn1_d(is_u:ie_u,1:npz), is_u,ie_u, -1, 8, atm%ptop )
3880 call mappm(km, pe0(is_u:ie_u,1:km+1), vc(is_u:ie_u,j,1:km), npz, pe1(is_u:ie_u,1:npz+1), &
3881 qn1_c(is_u:ie_u,1:npz), is_u,ie_u, -1, 8, atm%ptop )
3884 bc_side%u_BC(i,j,k) = qn1_d(i,k)
3885 bc_side%vc_BC(i,j,k) = qn1_c(i,k)
3896 allocate(pe0(is_v:ie_v, km+1)) ; pe0=
real_snan 3897 allocate(pe1(is_v:ie_v, npz+1)) ; pe1=
real_snan 3898 allocate(qn1_d(is_v:ie_v, npz)) ; qn1_d=
real_snan 3899 allocate(qn1_c(is_v:ie_v, npz)) ; qn1_c=
real_snan 3902 j_loopv:
do j=js_v,je_v
3911 pe0(i,k) = ak0(k) + bk0(k)*0.5*(psc(i-1,j)+psc(i,j))
3916 pe1(i,k) = atm%ak(k) + atm%bk(k)*0.5*(psc(i-1,j)+psc(i,j))
3919 call mappm(km, pe0(is_v:ie_v,1:km+1), vd(is_v:ie_v,j,1:km), npz, pe1(is_v:ie_v,1:npz+1), &
3920 qn1_d(is_v:ie_v,1:npz), is_v,ie_v, -1, 8, atm%ptop)
3921 call mappm(km, pe0(is_v:ie_v,1:km+1), uc(is_v:ie_v,j,1:km), npz, pe1(is_v:ie_v,1:npz+1), &
3922 qn1_c(is_v:ie_v,1:npz), is_v,ie_v, -1, 8, atm%ptop)
3925 bc_side%v_BC(i,j,k) = qn1_d(i,k)
3926 bc_side%uc_BC(i,j,k) = qn1_c(i,k)
3937 if (is_master())
write(*,*)
'done remap_dwinds' 3971 integer,
intent(in) :: nlayers
3973 real,
intent(in) :: fcst_time
3981 real,
dimension(bd%isd:bd%ied,bd%jsd:bd%jed,npz),
intent(out) :: &
3985 real,
dimension(bd%isd:,bd%jsd:,1:),
intent(out) :: w
3986 real,
dimension(bd%is:,bd%js:,1:),
intent(out) :: delz
3988 real,
dimension(bd%isd:,bd%jsd:,1:),
intent(out) :: q_con
3992 real,
dimension(bd%isd:bd%ied,bd%jsd:bd%jed,npz,ntracers),
intent(out) :: q
3995 real,
dimension(bd%isd:bd%ied,bd%jsd:bd%jed,npz),
intent(out) :: cappa
4000 real,
dimension(bd%isd:bd%ied,bd%jsd:bd%jed+1,npz),
intent(out) :: u,vc
4002 real,
dimension(bd%isd:bd%ied+1,bd%jsd:bd%jed,npz),
intent(out) :: uc,v
4008 real :: fraction_interval
4101 ,i1_uvs,i2_uvs,j1_uvs,j2_uvs &
4102 ,i1_uvw,i2_uvw,j1_uvw,j2_uvw )
4118 character(len=*),
intent(in) :: side
4120 integer,
intent(in) :: i1,i2,j1,j2 &
4121 ,i1_uvs,i2_uvs,j1_uvs,j2_uvs &
4122 ,i1_uvw,i2_uvw,j1_uvw,j2_uvw
4128 integer :: i,ie,j,je,jend,jend_uvs,jend_uvw &
4129 ,jstart,jstart_uvs,jstart_uvw,k,nt,nz
4131 real,
dimension(:,:,:),
pointer :: delz_ptr
4143 if((trim(side)==
'east'.or.trim(side)==
'west').and..not.
north_bc)
then 4148 if((trim(side)==
'east'.or.trim(side)==
'west').and..not.
south_bc)
then 4154 select case (trim(side))
4168 delp(i,j,k)=side_t0%delp_BC(i,j,k) &
4169 +(side_t1%delp_BC(i,j,k)-side_t0%delp_BC(i,j,k)) &
4171 pt(i,j,k)=side_t0%pt_BC(i,j,k) &
4172 +(side_t1%pt_BC(i,j,k)-side_t0%pt_BC(i,j,k)) &
4177 delz_ptr(i,j,k)=side_t0%delz_BC(i,j,k) &
4178 +(side_t1%delz_BC(i,j,k)-side_t0%delz_BC(i,j,k)) &
4181 cappa(i,j,k)=side_t0%cappa_BC(i,j,k) &
4182 +(side_t1%cappa_BC(i,j,k)-side_t0%cappa_BC(i,j,k)) &
4186 q_con(i,j,k)=side_t0%q_con_BC(i,j,k) &
4187 +(side_t1%q_con_BC(i,j,k)-side_t0%q_con_BC(i,j,k)) &
4190 w(i,j,k)=side_t0%w_BC(i,j,k) &
4191 +(side_t1%w_BC(i,j,k)-side_t0%w_BC(i,j,k)) &
4196 do j=jstart_uvs,jend_uvs
4198 u(i,j,k)=side_t0%u_BC(i,j,k) &
4199 +(side_t1%u_BC(i,j,k)-side_t0%u_BC(i,j,k)) &
4201 vc(i,j,k)=side_t0%vc_BC(i,j,k) &
4202 +(side_t1%vc_BC(i,j,k)-side_t0%vc_BC(i,j,k)) &
4207 do j=jstart_uvw,jend_uvw
4209 v(i,j,k)=side_t0%v_BC(i,j,k) &
4210 +(side_t1%v_BC(i,j,k)-side_t0%v_BC(i,j,k)) &
4212 uc(i,j,k)=side_t0%uc_BC(i,j,k) &
4213 +(side_t1%uc_BC(i,j,k)-side_t0%uc_BC(i,j,k)) &
4219 ie=min(ubound(side_t0%w_BC,1),ubound(w,1))
4220 je=min(ubound(side_t0%w_BC,2),ubound(w,2))
4227 q(i,j,k,nt)=side_t0%q_BC(i,j,k,nt) &
4228 +(side_t1%q_BC(i,j,k,nt)-side_t0%q_BC(i,j,k,nt)) &
4269 integer,
intent(in) :: lbnd_x,ubnd_x,lbnd_y,ubnd_y,ubnd_z
4271 integer,
intent(in) :: is,ie,js,je & !<-- Compute limits
4274 integer,
intent(in),
optional :: index4
4276 real,
intent(in) :: fcst_time
4278 character(len=*),
intent(in) :: bc_vbl_name
4284 real,
dimension(lbnd_x:ubnd_x,lbnd_y:ubnd_y,1:ubnd_z) &
4285 ,
intent(out) :: array
4291 integer :: i1,i2,j1,j2
4292 integer :: i_bc,j_bc
4293 integer :: i1_blend,i2_blend,j1_blend,j2_blend
4294 integer :: lbnd1,ubnd1,lbnd2,ubnd2
4298 real,
dimension(:,:,:),
pointer :: bc_t0,bc_t1
4300 logical :: blend,call_interp
4312 if(
present(index4))
then 4340 if(trim(bc_vbl_name)==
'uc'.or.trim(bc_vbl_name)==
'v')
then 4349 if(trim(bc_vbl_name)==
'uc'.or.trim(bc_vbl_name)==
'v')
then 4372 if(trim(bc_vbl_name)==
'uc'.or.trim(bc_vbl_name)==
'v')
then 4378 if(trim(bc_vbl_name)==
'u'.or.trim(bc_vbl_name)==
'vc')
then 4385 if(trim(bc_vbl_name)==
'uc'.or.trim(bc_vbl_name)==
'v')
then 4389 if(trim(bc_vbl_name)==
'u'.or.trim(bc_vbl_name)==
'vc')
then 4413 if(trim(bc_vbl_name)==
'vc'.or.trim(bc_vbl_name)==
'u')
then 4426 if(trim(bc_vbl_name)==
'u'.or.trim(bc_vbl_name)==
'vc')
then 4441 if(trim(bc_vbl_name)==
'u'.or.trim(bc_vbl_name)==
'vc')
then 4464 if(trim(bc_vbl_name)==
'vc'.or.trim(bc_vbl_name)==
'u')
then 4471 if(trim(bc_vbl_name)==
'uc'.or.trim(bc_vbl_name)==
'v')
then 4481 if(trim(bc_vbl_name)==
'u'.or.trim(bc_vbl_name)==
'vc')
then 4496 if(trim(bc_vbl_name)==
'u'.or.trim(bc_vbl_name)==
'vc')
then 4516 ,lbnd1,ubnd1,lbnd2,ubnd2 &
4520 ,lbnd_x,ubnd_x,lbnd_y,ubnd_y,ubnd_z &
4522 ,lbnd1,ubnd1,lbnd2,ubnd2 &
4527 ,i1_blend,i2_blend,j1_blend,j2_blend &
4528 ,i_bc,j_bc,nside,bc_vbl_name,blend )
4544 ,bc_side_t0,bc_side_t1 &
4546 ,lbnd1,ubnd1,lbnd2,ubnd2 &
4560 integer,
intent(in) :: iq
4562 character(len=*),
intent(in) :: bc_vbl_name
4571 integer,
intent(out) :: lbnd1,ubnd1,lbnd2,ubnd2
4573 real,
dimension(:,:,:),
pointer :: bc_t0,bc_t1
4579 select case (bc_vbl_name)
4582 bc_t0=>bc_side_t0%delp_BC
4583 bc_t1=>bc_side_t1%delp_BC
4585 bc_t0=>bc_side_t0%delz_BC
4586 bc_t1=>bc_side_t1%delz_BC
4588 bc_t0=>bc_side_t0%pt_BC
4589 bc_t1=>bc_side_t1%pt_BC
4591 bc_t0=>bc_side_t0%w_BC
4592 bc_t1=>bc_side_t1%w_BC
4594 bc_t0=>bc_side_t0%divgd_BC
4595 bc_t1=>bc_side_t1%divgd_BC
4598 bc_t0=>bc_side_t0%cappa_BC
4599 bc_t1=>bc_side_t1%cappa_BC
4603 bc_t0=>bc_side_t0%q_con_BC
4604 bc_t1=>bc_side_t1%q_con_BC
4608 call mpp_error(fatal,
' iq<1 is not a valid index for q_BC array in retrieve_bc_variable_data')
4610 lbnd1=lbound(bc_side_t0%q_BC,1)
4611 lbnd2=lbound(bc_side_t0%q_BC,2)
4612 ubnd1=ubound(bc_side_t0%q_BC,1)
4613 ubnd2=ubound(bc_side_t0%q_BC,2)
4614 bc_t0=>bc_side_t0%q_BC(:,:,:,iq)
4615 bc_t1=>bc_side_t1%q_BC(:,:,:,iq)
4617 bc_t0=>bc_side_t0%u_BC
4618 bc_t1=>bc_side_t1%u_BC
4620 bc_t0=>bc_side_t0%v_BC
4621 bc_t1=>bc_side_t1%v_BC
4623 bc_t0=>bc_side_t0%uc_BC
4624 bc_t1=>bc_side_t1%uc_BC
4626 bc_t0=>bc_side_t0%vc_BC
4627 bc_t1=>bc_side_t1%vc_BC
4631 if(trim(bc_vbl_name)/=
'q')
then 4632 lbnd1=lbound(bc_t0,1)
4633 lbnd2=lbound(bc_t0,2)
4634 ubnd1=ubound(bc_t0,1)
4635 ubnd2=ubound(bc_t0,2)
4656 ,bc_update_interval &
4657 ,i1_blend,i2_blend,j1_blend,j2_blend &
4658 ,i_bc,j_bc,nside,bc_vbl_name,blend )
4672 integer,
intent(in) :: lbnd_x,ubnd_x,lbnd_y,ubnd_y,ubnd_z
4674 integer,
intent(in) :: lbnd1,ubnd1,lbnd2,ubnd2
4676 integer,
intent(in) :: i1,i2,j1,j2 & !<-- Index limits of the updated boundary region.
4677 ,i_bc,j_bc & !<-- Innermost bndry indices (anchor pts for blending)
4678 ,i1_blend,i2_blend,j1_blend,j2_blend & !<-- Index limits of the updated blending region.
4681 integer,
intent(in) :: is,ie,js,je
4683 integer,
intent(in) :: bc_update_interval
4685 real,
intent(in) :: fcst_time
4687 real,
dimension(lbnd1:ubnd1,lbnd2:ubnd2,1:ubnd_z),
intent(in) :: bc_t0 & !<-- Interpolate between these
4690 character(len=*),
intent(in) :: bc_vbl_name
4692 logical,
intent(in) :: blend
4698 real,
dimension(lbnd_x:ubnd_x,lbnd_y:ubnd_y,1:ubnd_z) &
4699 ,
intent(out) :: array
4707 real :: blend_value,factor_dist,fraction_interval,rdenom
4718 fraction_interval=mod(fcst_time,(bc_update_interval*3600.)) &
4719 /(bc_update_interval*3600.)
4726 array(i,j,k)=bc_t0(i,j,k) &
4727 +(bc_t1(i,j,k)-bc_t0(i,j,k))*fraction_interval
4753 rdenom=1./
real(j2_blend-j_bc-1)
4755 do j=j1_blend,j2_blend
4757 do i=i1_blend,i2_blend
4758 blend_value=bc_t0(i,j,k) &
4759 +(bc_t1(i,j,k)-bc_t0(i,j,k))*fraction_interval
4761 array(i,j,k)=(1.-factor_dist)*array(i,j,k)+factor_dist*blend_value
4772 rdenom=1./
real(j_bc-j1_blend-1)
4774 do j=j1_blend,j2_blend
4776 do i=i1_blend,i2_blend
4777 blend_value=bc_t0(i,j,k) &
4778 +(bc_t1(i,j,k)-bc_t0(i,j,k))*fraction_interval
4779 array(i,j,k)=(1.-factor_dist)*array(i,j,k)+factor_dist*blend_value
4790 rdenom=1./
real(i2_blend-i_bc-1)
4792 do j=j1_blend,j2_blend
4793 do i=i1_blend,i2_blend
4795 blend_value=bc_t0(i,j,k) &
4796 +(bc_t1(i,j,k)-bc_t0(i,j,k))*fraction_interval
4800 array(i,j,k)=(1.-factor_dist)*array(i,j,k)+factor_dist*blend_value
4811 rdenom=1./
real(i_bc-i1_blend-1)
4813 do j=j1_blend,j2_blend
4814 do i=i1_blend,i2_blend
4816 blend_value=bc_t0(i,j,k) &
4817 +(bc_t1(i,j,k)-bc_t0(i,j,k))*fraction_interval
4821 array(i,j,k)=(1.-factor_dist)*array(i,j,k)+factor_dist*blend_value
4836 ,nlev,ntracers,bnds )
4850 integer,
intent(in) :: nlev & !<-- # of model layers.
4863 integer :: i,ie_c,ie_s,ie_w,is_c,is_s,is_w &
4864 ,j,je_c,je_s,je_w,js_c,js_s,js_w &
4892 is_s=bnds%is_north_uvs
4893 ie_s=bnds%ie_north_uvs
4894 js_s=bnds%js_north_uvs
4895 je_s=bnds%je_north_uvs
4897 is_w=bnds%is_north_uvw
4898 ie_w=bnds%ie_north_uvw
4899 js_w=bnds%js_north_uvw
4900 je_w=bnds%je_north_uvw
4915 is_s=bnds%is_south_uvs
4916 ie_s=bnds%ie_south_uvs
4917 js_s=bnds%js_south_uvs
4918 je_s=bnds%je_south_uvs
4920 is_w=bnds%is_south_uvw
4921 ie_w=bnds%ie_south_uvw
4922 js_w=bnds%js_south_uvw
4923 je_w=bnds%je_south_uvw
4938 is_s=bnds%is_east_uvs
4939 ie_s=bnds%ie_east_uvs
4940 js_s=bnds%js_east_uvs
4941 je_s=bnds%je_east_uvs
4943 is_w=bnds%is_east_uvw
4944 ie_w=bnds%ie_east_uvw
4945 js_w=bnds%js_east_uvw
4946 je_w=bnds%je_east_uvw
4961 is_s=bnds%is_west_uvs
4962 ie_s=bnds%ie_west_uvs
4963 js_s=bnds%js_west_uvs
4964 je_s=bnds%je_west_uvs
4966 is_w=bnds%is_west_uvw
4967 ie_w=bnds%ie_west_uvw
4968 js_w=bnds%js_west_uvw
4969 je_w=bnds%je_west_uvw
5054 integer,
intent(in) :: isd,ied,jsd,jed,npz
5060 integer :: i1,i2,j1,j2
5064 real,
dimension(:,:,:),
pointer :: delp,delz,pt
5066 real,
dimension(:,:,:),
pointer :: q_con
5069 real,
dimension(:,:,:),
pointer ::cappa
5072 real,
dimension(:,:,:,:),
pointer :: q
5089 q =>
bc_t1%north%q_BC
5091 q_con=>
bc_t1%north%q_con_BC
5093 delp =>
bc_t1%north%delp_BC
5094 delz =>
bc_t1%north%delz_BC
5096 cappa=>
bc_t1%north%cappa_BC
5098 pt =>
bc_t1%north%pt_BC
5107 q =>
bc_t1%south%q_BC
5109 q_con=>
bc_t1%south%q_con_BC
5111 delp =>
bc_t1%south%delp_BC
5112 delz =>
bc_t1%south%delz_BC
5114 cappa=>
bc_t1%south%cappa_BC
5116 pt =>
bc_t1%south%pt_BC
5127 q_con=>
bc_t1%east%q_con_BC
5129 delp =>
bc_t1%east%delp_BC
5130 delz =>
bc_t1%east%delz_BC
5132 cappa=>
bc_t1%east%cappa_BC
5134 pt =>
bc_t1%east%pt_BC
5145 q_con=>
bc_t1%west%q_con_BC
5147 delp =>
bc_t1%west%delp_BC
5148 delz =>
bc_t1%west%delz_BC
5150 cappa=>
bc_t1%west%cappa_BC
5152 pt =>
bc_t1%west%pt_BC
5189 pkz=exp(cappa(i,j,k)*log(rdg*delp(i,j,k)*pt(i,j,k) &
5190 *(1.+dp1)*(1.-q_con(i,j,k))/delz(i,j,k)))
5192 pkz=exp(kappa*log(rdg*delp(i,j,k)*pt(i,j,k) &
5193 *(1.+dp1)*(1.-q_con(i,j,k))/delz(i,j,k)))
5195 pt(i,j,k)=pt(i,j,k)*(1.+dp1)*(1.-q_con(i,j,k))/pkz
5197 pkz=exp(kappa*log(rdg*delp(i,j,k)*pt(i,j,k) &
5198 *(1.+dp1)/delz(i,j,k)))
5199 pt(i,j,k)=pt(i,j,k)*(1.+dp1)/pkz
5225 subroutine p_maxmin(qname, q, is, ie, js, je, km, fac)
5226 character(len=*),
intent(in):: qname
5227 integer,
intent(in):: is, ie, js, je, km
5228 real,
intent(in):: q(is:ie, js:je, km)
5229 real,
intent(in):: fac
5238 if( q(i,j,k) < qmin )
then 5240 elseif( q(i,j,k) > qmax )
then 5246 call mp_reduce_min(qmin)
5247 call mp_reduce_max(qmax)
5248 if(is_master())
write(6,*) qname, qmax*fac, qmin*fac
5253 subroutine pmaxmn(qname, q, is, ie, js, je, km, fac, area, domain)
5254 character(len=*),
intent(in):: qname
5255 integer,
intent(in):: is, ie, js, je
5256 integer,
intent(in):: km
5257 real,
intent(in):: q(is:ie, js:je, km)
5258 real,
intent(in):: fac
5259 real(kind=R_GRID),
intent(IN):: area(is-3:ie+3, js-3:je+3)
5260 type(domain2d),
intent(INOUT) :: domain
5262 real qmin, qmax, gmean
5272 if( q(i,j,k) < qmin )
then 5274 elseif( q(i,j,k) > qmax )
then 5281 call mp_reduce_min(qmin)
5282 call mp_reduce_max(qmax)
5284 gmean =
g_sum(domain, q(is,js,km), is, ie, js, je, 3, area, 1, reproduce=.true.)
5285 if(is_master())
write(6,*) qname, qmax*fac, qmin*fac, gmean*fac
5290 subroutine fillq(im, km, nq, q, dp)
5291 integer,
intent(in):: im
5292 integer,
intent(in):: km
5293 integer,
intent(in):: nq
5294 real ,
intent(in):: dp(im,km)
5295 real ,
intent(inout) :: q(im,km,nq)
5297 integer i, k, ic, k1
5304 if( q(i,k,ic) < 0. )
then 5305 q(i,k1,ic) = q(i,k1,ic) + q(i,k,ic)*dp(i,k)/dp(i,k1)
5314 if( q(i,k,ic) < 0. )
then 5315 q(i,k1,ic) = q(i,k1,ic) + q(i,k,ic)*dp(i,k)/dp(i,k1)
5323 end subroutine fillq 5326 real,
intent(inout):: ql, qr, qi, qs
5327 real,
parameter:: qi0_max = 2.0e-3
5328 real,
parameter:: ql0_max = 2.5e-3
5331 if ( ql > ql0_max )
then 5336 if ( qi > qi0_max )
then 5358 integer,
intent(in) :: isd,ied,jsd,jed
5366 integer :: i,i_x,ie,is,j,j_x,je,js,k
5368 real,
parameter:: q1_h2o = 2.2e-6
5369 real,
parameter:: q7_h2o = 3.8e-6
5370 real,
parameter:: q100_h2o = 3.8e-6
5371 real,
parameter:: q1000_h2o = 3.1e-6
5372 real,
parameter:: q2000_h2o = 2.8e-6
5373 real,
parameter:: q3000_h2o = 3.0e-6
5374 real,
parameter:: wt=2., xt=1./(1.+wt)
5384 bnds=>atm%regional_bc_bounds
5391 is=lbound(
bc_t1%north%q_BC,1)
5392 ie=ubound(
bc_t1%north%q_BC,1)
5393 js=lbound(
bc_t1%north%q_BC,2)
5394 je=ubound(
bc_t1%north%q_BC,2)
5413 p00=p00+
bc_t1%north%delp_BC(i_x,j_x,k)
5422 is=lbound(
bc_t1%south%q_BC,1)
5423 ie=ubound(
bc_t1%south%q_BC,1)
5424 js=lbound(
bc_t1%south%q_BC,2)
5425 je=ubound(
bc_t1%south%q_BC,2)
5444 p00=p00+
bc_t1%south%delp_BC(i_x,j_x,k)
5453 is=lbound(
bc_t1%east%q_BC,1)
5454 ie=ubound(
bc_t1%east%q_BC,1)
5455 js=lbound(
bc_t1%east%q_BC,2)
5456 je=ubound(
bc_t1%east%q_BC,2)
5475 p00=p00+
bc_t1%east%delp_BC(i_x,j_x,k)
5484 is=lbound(
bc_t1%west%q_BC,1)
5485 ie=ubound(
bc_t1%west%q_BC,1)
5486 js=lbound(
bc_t1%west%q_BC,2)
5487 je=ubound(
bc_t1%west%q_BC,2)
5506 p00=p00+
bc_t1%west%delp_BC(i_x,j_x,k)
5526 if ( p00 < 30.e2 )
then 5527 if ( p00 < 1. )
then 5529 elseif ( p00 <= 7. .and. p00 >= 1. )
then 5530 q00 = q1_h2o + (q7_h2o-q1_h2o)*log(
pref(k)/1.)/log(7.)
5531 elseif ( p00 < 100. .and. p00 >= 7. )
then 5532 q00 = q7_h2o + (q100_h2o-q7_h2o)*log(
pref(k)/7.)/log(100./7.)
5533 elseif ( p00 < 1000. .and. p00 >= 100. )
then 5534 q00 = q100_h2o + (q1000_h2o-q100_h2o)*log(
pref(k)/1.e2)/log(10.)
5535 elseif ( p00 < 2000. .and. p00 >= 1000. )
then 5536 q00 = q1000_h2o + (q2000_h2o-q1000_h2o)*log(
pref(k)/1.e3)/log(2.)
5538 q00 = q2000_h2o + (q3000_h2o-q2000_h2o)*log(
pref(k)/2.e3)/log(1.5)
5553 subroutine dump_field_3d (domain, name, field, isd, ied, jsd, jed, nlev, stag)
5568 type(domain2d),
intent(INOUT) :: domain
5569 character(len=*),
intent(IN) :: name
5570 real,
dimension(isd:ied,jsd:jed,1:nlev),
intent(INOUT) :: field
5571 integer,
intent(IN) :: isd, ied, jsd, jed, nlev
5572 integer,
intent(IN) :: stag
5575 character(len=128) :: fname
5576 type(axistype) :: x, y, z
5577 type(fieldtype) :: f
5578 type(domain1d) :: xdom, ydom
5580 integer :: is, ie, js, je
5581 integer :: isg, ieg, jsg, jeg, nxg, nyg, npx, npy
5582 integer :: i, j, halo, iext, jext
5583 logical :: is_root_pe
5584 real,
allocatable,
dimension(:,:,:) :: glob_field
5585 integer,
allocatable,
dimension(:) :: pelist
5586 character(len=1) :: stagname
5587 integer :: isection_s, isection_e, jsection_s, jsection_e
5589 write(fname,
"(A,A,A,I1.1,A)")
"regional_",name,
".tile", 7 ,
".nc" 5590 write(0,*)
'dump_field_3d: file name = |', trim(fname) ,
'|' 5592 call mpp_get_domain_components( domain, xdom, ydom )
5593 call mpp_get_compute_domain( domain, is, ie, js, je )
5594 call mpp_get_global_domain ( domain, isg, ieg, jsg, jeg, xsize=npx, ysize=npy, position=center )
5597 if ( halo /= 3 )
then 5598 write(0,*)
'dusan- halo should be 3 ', halo
5613 nxg = npx + 2*halo + iext
5614 nyg = npy + 2*halo + jext
5615 nz =
size(field,dim=3)
5617 allocate( glob_field(isg-halo:ieg+halo+iext, jsg-halo:jeg+halo+jext, 1:nz) )
5624 if ( isd < 0 ) isection_s = isd
5625 if ( ied > npx-1 ) isection_e = ied
5626 if ( jsd < 0 ) jsection_s = jsd
5627 if ( jed > npy-1 ) jsection_e = jed
5629 allocate( pelist(mpp_npes()) )
5630 call mpp_get_current_pelist(pelist)
5632 is_root_pe = (mpp_pe()==mpp_root_pe())
5634 call mpp_gather(isection_s,isection_e,jsection_s,jsection_e, nz, &
5635 pelist, field(isection_s:isection_e,jsection_s:jsection_e,:), glob_field, is_root_pe, halo, halo)
5637 call mpp_open( unit, trim(fname), action=mpp_overwr, form=mpp_netcdf, threading=mpp_single)
5639 call mpp_write_meta( unit, x,
'grid_xt',
'km',
'X distance',
'X', domain=xdom, data=(/(i*1.0,i=1,nxg)/) )
5640 call mpp_write_meta( unit, y,
'grid_yt',
'km',
'Y distance',
'Y', domain=ydom, data=(/(j*1.0,j=1,nyg)/) )
5641 call mpp_write_meta( unit, z,
'lev',
'km',
'Z distance', data=(/(i*1.0,i=1,nz)/) )
5643 call mpp_write_meta( unit, f, (/x,y,z/), name,
'unit', name)
5644 call mpp_write_meta( unit,
"stretch_factor", rval=
stretch_factor )
5645 call mpp_write_meta( unit,
"target_lon", rval=
target_lon )
5646 call mpp_write_meta( unit,
"target_lat", rval=
target_lat )
5647 call mpp_write_meta( unit,
"cube_res", ival=
cube_res)
5648 call mpp_write_meta( unit,
"parent_tile", ival=
parent_tile )
5649 call mpp_write_meta( unit,
"refine_ratio", ival=
refine_ratio )
5650 call mpp_write_meta( unit,
"istart_nest", ival=
istart_nest )
5651 call mpp_write_meta( unit,
"jstart_nest", ival=
jstart_nest )
5652 call mpp_write_meta( unit,
"iend_nest", ival=
iend_nest )
5653 call mpp_write_meta( unit,
"jend_nest", ival=
jend_nest )
5654 call mpp_write_meta( unit,
"ihalo_shift", ival=halo )
5655 call mpp_write_meta( unit,
"jhalo_shift", ival=halo )
5656 call mpp_write_meta( unit, mpp_get_id(f),
"hstagger", cval=stagname )
5657 call mpp_write( unit, x )
5658 call mpp_write( unit, y )
5659 call mpp_write( unit, z )
5660 call mpp_write( unit, f, glob_field )
5662 call mpp_close( unit )
5666 subroutine dump_field_2d (domain, name, field, isd, ied, jsd, jed, stag)
5668 type(domain2d),
intent(INOUT) :: domain
5669 character(len=*),
intent(IN) :: name
5670 real,
dimension(isd:ied,jsd:jed),
intent(INOUT) :: field
5671 integer,
intent(IN) :: isd, ied, jsd, jed
5672 integer,
intent(IN) :: stag
5675 character(len=128) :: fname
5676 type(axistype) :: x, y
5677 type(fieldtype) :: f
5678 type(domain1d) :: xdom, ydom
5679 integer :: is, ie, js, je
5680 integer :: isg, ieg, jsg, jeg, nxg, nyg, npx, npy
5681 integer :: i, j, halo, iext, jext
5682 logical :: is_root_pe
5683 real,
allocatable,
dimension(:,:) :: glob_field
5684 integer,
allocatable,
dimension(:) :: pelist
5685 character(len=1) :: stagname
5686 integer :: isection_s, isection_e, jsection_s, jsection_e
5688 write(fname,
"(A,A,A,I1.1,A)")
"regional_",name,
".tile", 7 ,
".nc" 5689 write(0,*)
'dump_field_3d: file name = |', trim(fname) ,
'|' 5691 call mpp_get_domain_components( domain, xdom, ydom )
5692 call mpp_get_compute_domain( domain, is, ie, js, je )
5693 call mpp_get_global_domain ( domain, isg, ieg, jsg, jeg, xsize=npx, ysize=npy, position=center )
5696 if ( halo /= 3 )
then 5697 write(0,*)
'dusan- halo should be 3 ', halo
5712 nxg = npx + 2*halo + iext
5713 nyg = npy + 2*halo + jext
5715 allocate( glob_field(isg-halo:ieg+halo+iext, jsg-halo:jeg+halo+jext) )
5722 if ( isd < 0 ) isection_s = isd
5723 if ( ied > npx-1 ) isection_e = ied
5724 if ( jsd < 0 ) jsection_s = jsd
5725 if ( jed > npy-1 ) jsection_e = jed
5727 allocate( pelist(mpp_npes()) )
5728 call mpp_get_current_pelist(pelist)
5730 is_root_pe = (mpp_pe()==mpp_root_pe())
5732 call mpp_gather(isection_s,isection_e,jsection_s,jsection_e, &
5733 pelist, field(isection_s:isection_e,jsection_s:jsection_e), glob_field, is_root_pe, halo, halo)
5735 call mpp_open( unit, trim(fname), action=mpp_overwr, form=mpp_netcdf, threading=mpp_single)
5737 call mpp_write_meta( unit, x,
'grid_xt',
'km',
'X distance',
'X', domain=xdom, data=(/(i*1.0,i=1,nxg)/) )
5738 call mpp_write_meta( unit, y,
'grid_yt',
'km',
'Y distance',
'Y', domain=ydom, data=(/(j*1.0,j=1,nyg)/) )
5740 call mpp_write_meta( unit, f, (/x,y/), name,
'unit', name)
5741 call mpp_write_meta( unit,
"stretch_factor", rval=
stretch_factor )
5742 call mpp_write_meta( unit,
"target_lon", rval=
target_lon )
5743 call mpp_write_meta( unit,
"target_lat", rval=
target_lat )
5744 call mpp_write_meta( unit,
"cube_res", ival=
cube_res)
5745 call mpp_write_meta( unit,
"parent_tile", ival=
parent_tile )
5746 call mpp_write_meta( unit,
"refine_ratio", ival=
refine_ratio )
5747 call mpp_write_meta( unit,
"istart_nest", ival=
istart_nest )
5748 call mpp_write_meta( unit,
"jstart_nest", ival=
jstart_nest )
5749 call mpp_write_meta( unit,
"iend_nest", ival=
iend_nest )
5750 call mpp_write_meta( unit,
"jend_nest", ival=
jend_nest )
5751 call mpp_write_meta( unit,
"ihalo_shift", ival=halo )
5752 call mpp_write_meta( unit,
"jhalo_shift", ival=halo )
5753 call mpp_write_meta( unit, mpp_get_id(f),
"hstagger", cval=stagname )
5754 call mpp_write( unit, x )
5755 call mpp_write( unit, y )
5756 call mpp_write( unit, f, glob_field )
5758 call mpp_close( unit )
5785 integer :: index,istat,n &
5788 ,ndims,nkount,nv_core,nv_tracers &
5791 integer :: lbnd1,lbnd2,lbnd3,ubnd1,ubnd2,ubnd3
5793 integer,
dimension(ndims_core) :: dim_lengths_core
5795 integer,
dimension(ndims_tracers) :: dim_lengths_tracers
5797 integer,
dimension(1:4) :: dimids=(/0,0,0,0/)
5799 real,
dimension(:),
allocatable :: dim_values
5801 character(len=50) :: att_name,var_name
5803 character(len=9),
dimension(ndims_core) :: dim_names_core=(/ &
5812 character(len=9),
dimension(ndims_tracers) :: dim_names_tracers=(/ &
5846 lbnd1=lbound(atm%delz,1)
5847 ubnd1=ubound(atm%delz,1)
5848 lbnd2=lbound(atm%delz,2)
5849 ubnd2=ubound(atm%delz,2)
5851 ubnd3=ubound(atm%delz,3)
5863 allocate(
fields_core(7)%ptr(lbound(atm%phis,1):ubound(atm%phis,1) &
5864 ,lbound(atm%phis,2):ubound(atm%phis,2) &
5878 ,mode=nf90_nowrite &
5879 ,
ncid=ncid_tracers_new ))
5881 call check(nf90_inquire(
ncid =ncid_tracers_new &
5882 ,nvariables=nv_tracers ))
5887 call mpp_error(fatal,
' Failed to allocate fields_tracers.')
5891 33012
format(
' Allocated fields_tracers(1:',i3,
')')
5898 call check(nf90_inquire_variable(
ncid =ncid_tracers_new &
5905 index=get_tracer_index(model_atmos, trim(var_name))
5913 call check(nf90_close(ncid_tracers_new))
5933 integer :: count_i,count_j
5934 integer :: iend,istart,jend,jstart,kend,kstart,nz
5935 integer :: iend_ptr,istart_ptr,jend_ptr,jstart_ptr
5936 integer :: iend_g,istart_g,jend_g,jstart_g
5937 integer :: ieg,iext,isg,jeg,jext,jsg,k
5938 integer :: n,ncid_core_new,ncid_tracers_new,nv,var_id
5941 integer,
dimension(:),
allocatable :: pelist
5943 real,
dimension(:,:,:),
allocatable :: global_field
5944 real,
dimension(:,:,:),
pointer :: field_3d
5946 character(len=10) :: var_name
5948 logical :: is_root_pe
5954 allocate( pelist(mpp_npes()) )
5955 call mpp_get_current_pelist(pelist)
5960 is_root_pe = (mpp_pe()==mpp_root_pe())
5970 call mpp_get_global_domain (atm%domain, isg, ieg, jsg, jeg, position=center )
5981 call check(nf90_inq_varid(ncid_core_new,var_name,var_id))
5991 if(var_name==
'u'.or.var_name==
'vc')
then 5994 if(var_name==
'v'.or.var_name==
'uc')
then 5998 call mpp_get_global_domain (atm%domain, isg, ieg, jsg, jeg, position=center )
6000 iend_g =ieg+halo+iext
6002 jend_g =jeg+halo+jext
6004 count_i=iend_g-istart_g+1
6005 count_j=jend_g-jstart_g+1
6009 allocate( global_field(istart_g:iend_g, jstart_g:jend_g, 1:nz) )
6024 if(iend<ieg-halo)
then 6034 if(jend<jeg-halo)
then 6069 call mpp_gather(istart,iend,jstart,jend &
6070 ,pelist,
fields_core(nv)%ptr(istart:iend,jstart:jend,k) &
6071 ,global_field(:,:,k), is_root_pe, halo, halo)
6074 call check(nf90_put_var(ncid_core_new,var_id &
6075 ,global_field(:,:,k) &
6077 ,count=(/count_i,count_j,1/)))
6081 deallocate(global_field)
6086 call check(nf90_close(ncid_core_new))
6103 call mpp_get_global_domain (atm%domain, isg, ieg, jsg, jeg, position=center )
6109 count_i=iend_g-istart_g+1
6110 count_j=jend_g-jstart_g+1
6113 allocate( global_field(istart_g:iend_g, jstart_g:jend_g, 1:nz) )
6138 if(iend<ieg-halo)
then 6148 if(jend<jeg-halo)
then 6186 call check(nf90_inq_varid(ncid_tracers_new,var_name,var_id))
6195 call mpp_gather(istart,iend,jstart,jend &
6196 ,pelist,
fields_tracers(nv)%ptr(istart_ptr:iend_ptr,jstart_ptr:jend_ptr,k) &
6197 ,global_field(:,:,k), is_root_pe, halo, halo)
6200 call check(nf90_put_var(ncid_tracers_new,var_id &
6201 ,global_field(:,:,k) &
6203 ,count=(/count_i,count_j,1/)))
6209 deallocate(global_field)
6212 call check(nf90_close(ncid_tracers_new))
6235 integer,
intent(in) :: istart,iend,jstart,jend
6237 character(len=*),
intent(in) :: name
6241 real,
dimension(istart:iend,jstart:jend,1:nz),
intent(inout) :: field
6247 integer :: i1,i2,j1,j2,nz
6248 integer :: lbnd1,lbnd2,ubnd1,ubnd2,i,j,k
6252 real,
dimension(:,:,:),
pointer :: delz_ptr
6265 if (trim(name)==
'DZ')
then 6266 lbnd1=lbound(atm%delz,1)
6267 ubnd1=ubound(atm%delz,1)
6268 lbnd2=lbound(atm%delz,2)
6269 ubnd2=ubound(atm%delz,2)
6274 field(i,j,k)=atm%delz(i,j,k)
6295 if(trim(name)==
'T')
then 6297 elseif(trim(name)==
'DZ')
then 6310 if(trim(name)==
'T')
then 6312 elseif(trim(name)==
'DZ')
then 6330 if(trim(name)==
'T')
then 6332 elseif(trim(name)==
'DZ')
then 6350 if(trim(name)==
'T')
then 6352 elseif(trim(name)==
'DZ')
then 6368 real :: cappa,cvm,dp1,part1,part2
6381 cappa=rdgas/(rdgas+cvm/(1.+dp1))
6383 part1=(1.+dp1)*(1.-atm%q_con(i,j,k))
6384 part2=rdg*atm%delp(i,j,k)*(1.+dp1)*(1.-atm%q_con(i,j,k)) &
6386 field(i,j,k)=exp((log(field(i,j,k))-log(part1)+cappa*log(part2)) &
6401 integer :: lbnd1,lbnd2,ubnd1,ubnd2
6414 field(i,j,k)=delz_ptr(i,j,k)
6429 subroutine exch_uv(domain, bd, npz, u, v)
6434 type(domain2d),
intent(inout) :: domain
6436 integer,
intent(in) :: npz
6437 real,
intent(inout) :: u (bd%isd:bd%ied ,bd%jsd:bd%jed+1,1:npz)
6438 real,
intent(inout) :: v (bd%isd:bd%ied+1,bd%jsd:bd%jed ,1:npz)
6440 real,
dimension(:),
allocatable :: buf1,buf2,buf3,buf4
6441 integer :: ihandle1,ihandle2,ihandle3,ihandle4
6442 integer,
dimension(MPI_STATUS_SIZE) :: istat
6443 integer :: ic, i, j, k, is, ie, js, je
6444 integer :: irecv, isend, ierr
6447 integer :: north_pe, south_pe, east_pe, west_pe
6450 call mpp_get_neighbor_pe( domain, north, north_pe)
6451 call mpp_get_neighbor_pe( domain, south, south_pe)
6452 call mpp_get_neighbor_pe( domain, west, west_pe)
6453 call mpp_get_neighbor_pe( domain, east, east_pe)
6470 allocate(buf1(1:24*npz))
6471 allocate(buf2(1:36*npz))
6472 allocate(buf3(1:36*npz))
6473 allocate(buf4(1:24*npz))
6478 #define _DYN_MPI_REAL MPI_REAL 6480 #define _DYN_MPI_REAL MPI_DOUBLE_PRECISION 6484 if( north_pe /= null_pe )
then 6485 call mpi_irecv(buf1,
size(buf1),_dyn_mpi_real,north_pe,north_pe &
6486 ,mpi_comm_world,ihandle1,irecv)
6490 if( south_pe /= null_pe )
then 6491 call mpi_irecv(buf2,
size(buf2),_dyn_mpi_real,south_pe,south_pe &
6492 ,mpi_comm_world,ihandle2,irecv)
6496 if( north_pe /= null_pe )
then 6522 if (ic/=
size(buf2).or.ic/=
size(buf3)) &
6523 call mpp_error(fatal,
'Buffer sizes buf2 and buf3 in routine exch_uv do not match actual message size')
6524 call mpi_issend(buf3,
size(buf3),_dyn_mpi_real,north_pe,mype &
6525 ,mpi_comm_world,ihandle3,isend)
6529 if( south_pe /= null_pe )
then 6556 if (ic/=
size(buf1).or.ic/=
size(buf4)) &
6557 call mpp_error(fatal,
'Buffer sizes buf1 and buf4 in routine exch_uv do not match actual message size')
6558 call mpi_issend(buf4,
size(buf4),_dyn_mpi_real,south_pe,mype &
6559 ,mpi_comm_world,ihandle4,isend)
6563 if( south_pe /= null_pe )
then 6565 call mpi_wait(ihandle2,istat,ierr)
6594 if( north_pe /= null_pe )
then 6596 call mpi_wait(ihandle1,istat,ierr)
6639 character (len = 80) :: source
6640 integer :: ncids,sourceLength
6641 logical :: lstatus,regional
6646 lstatus = get_global_att_value(
'INPUT/gfs_data.nc',
"source", source)
6648 lstatus = get_global_att_value(
'INPUT/gfs_data.tile1.nc',
"source", source)
6650 if (.not. lstatus)
then 6651 if (mpp_pe() == 0)
write(0,*)
'INPUT source not found ',lstatus,
' set source=No Source Attribute' 6652 source=
'No Source Attribute' 6670 integer :: k, j, i, iq, is, ie, js, je
6671 integer :: liq_wat, ice_wat, rainwat, snowwat, graupel, cld_amt
6672 real :: qt, wt, m_fac
6674 is=lbound(bc_side%delp_BC,1)
6675 ie=ubound(bc_side%delp_BC,1)
6676 js=lbound(bc_side%delp_BC,2)
6677 je=ubound(bc_side%delp_BC,2)
6679 liq_wat = get_tracer_index(model_atmos,
'liq_wat')
6680 ice_wat = get_tracer_index(model_atmos,
'ice_wat')
6681 rainwat = get_tracer_index(model_atmos,
'rainwat')
6682 snowwat = get_tracer_index(model_atmos,
'snowwat')
6683 graupel = get_tracer_index(model_atmos,
'graupel')
6684 cld_amt = get_tracer_index(model_atmos,
'cld_amt')
6686 source:
if (trim(
data_source) ==
'FV3GFS GAUSSIAN NEMSIO FILE')
then 6692 wt = bc_side%delp_BC(i,j,k)
6693 if ( nwat == 6 )
then 6694 qt = wt*(1. + bc_side%q_BC(i,j,k,liq_wat) + &
6695 bc_side%q_BC(i,j,k,ice_wat) + &
6696 bc_side%q_BC(i,j,k,rainwat) + &
6697 bc_side%q_BC(i,j,k,snowwat) + &
6698 bc_side%q_BC(i,j,k,graupel))
6700 qt = wt*(1. + sum(bc_side%q_BC(i,j,k,2:nwat)))
6703 bc_side%delp_BC(i,j,k) = qt
6714 wt = bc_side%delp_BC(i,j,k)
6715 if ( nwat == 6 )
then 6716 qt = wt*(1. + bc_side%q_BC(i,j,k,liq_wat) + &
6717 bc_side%q_BC(i,j,k,ice_wat) + &
6718 bc_side%q_BC(i,j,k,rainwat) + &
6719 bc_side%q_BC(i,j,k,snowwat) + &
6720 bc_side%q_BC(i,j,k,graupel))
6722 qt = wt*(1. + sum(bc_side%q_BC(i,j,k,2:nwat)))
6726 bc_side%q_BC(i,j,k,iq) = m_fac * bc_side%q_BC(i,j,k,iq)
6728 bc_side%delp_BC(i,j,k) = qt
subroutine dump_field_2d(domain, name, field, isd, ied, jsd, jed, stag)
character(len=50) filename_tracers_new
integer, parameter jend_nest
integer, parameter iend_nest
subroutine, public mid_pt_sphere(p1, p2, pm)
subroutine, public prt_height(qname, is, ie, js, je, ng, km, press, phis, delz, peln, area, lat)
integer, save lbnd_x_tracers
subroutine dump_field_3d(domain, name, field, isd, ied, jsd, jed, nlev, stag)
logical, save, public begin_regional_restart
subroutine, public regional_boundary_update(array, bc_vbl_name, lbnd_x, ubnd_x, lbnd_y, ubnd_y, ubnd_z, is, ie, js, je, isd, ied, jsd, jed, fcst_time, index4)
real, public current_time_in_seconds
The module 'fv_mp_mod' is a single program multiple data (SPMD) parallel decompostion/communication m...
type(vars_3d), dimension(:), allocatable fields_core
integer, parameter refine_ratio
subroutine, public regional_bc_t1_to_t0(BC_t1, BC_t0, nlev, ntracers, bnds)
logical, dimension(:), allocatable, save blend_this_tracer
integer, parameter, public h_stagger
integer, save cld_amt_index
--
integer, save bc_update_interval
subroutine, public setup_regional_bc(Atm, dt_atmos, isd, ied, jsd, jed, npx, npy)
character(len=100) grid_data
real, parameter stretch_factor
subroutine, public moist_cv(is, ie, isd, ied, jsd, jed, km, j, k, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, q, qd, cvm, t1)
The subroutine 'moist_cv' computes the FV3-consistent moist heat capacity under constant volume...
subroutine, public mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
The subroutine 'mappm' is a general-purpose routine for remapping one set of vertical levels to anoth...
type(fv_regional_bc_variables), pointer, save bc_east_t1
subroutine, public regional_bc_data(Atm, bc_hour, is, ie, js, je, isd, ied, jsd, jed, ak, bk)
subroutine, public start_regional_cold_start(Atm, dt_atmos, ak, bk, levp, is, ie, js, je, isd, ied, jsd, jed)
integer, save nfields_tracers
subroutine mp_auto_conversion(ql, qr, qi, qs)
subroutine remap_scalar_nggps_regional_bc(Atm, side, isd, ied, jsd, jed, is_bc, ie_bc, js_bc, je_bc, km, npz, ncnst, ak0, bk0, psc, t_in, qa, omga, zh, phis_reg, ps, BC_side)
integer, parameter cube_res
character(len=50) filename_core
subroutine, public get_eta_level(npz, p_s, pf, ph, ak, bk, pscale)
The subroutine 'get_eta_level' returns the interface and layer-mean pressures for reference...
type(fv_domain_sides), target, save, public bc_t1
– Boundary values for all BC variables at successive times from the regional BC file ...
real function, public g_sum(domain, p, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce)
The function 'g_sum' is the fast version of 'globalsum'.
integer, save liq_water_index
integer, parameter ndims_core
-- # of core restart dimensions
subroutine, public start_regional_restart(Atm, dt_atmos, isc, iec, jsc, jec, isd, ied, jsd, jed)
real function, public inner_prod(v1, v2)
subroutine convert_to_virt_pot_temp(isd, ied, jsd, jed, npz)
subroutine, public get_latlon_vector(pp, elon, elat)
subroutine, public get_unit_vect2(e1, e2, uc)
subroutine nudge_qv_bc(Atm, isd, ied, jsd, jed)
integer, parameter, public r_grid
integer, parameter ndims_tracers
– # of tracer restart dimensions
integer, save, public next_time_to_read_bcs
'allocate_fv_nest_BC_type' is an interface to subroutines that allocate the 'fv_nest_BC_type' structu...
integer, parameter parent_tile
subroutine read_regional_lon_lat
subroutine compute_halo_t
type(fv_regional_bc_variables), pointer, save bc_south_t1
real(kind=r_grid), dimension(:,:,:), allocatable grid_reg
– Lon/lat of cell corners
character(len=50) filename_core_new
subroutine read_regional_bc_file(is_input, ie_input, js_input, je_input, nlev, ntracers, var_name_root, array_3d, array_4d, tlev, required)
integer, parameter, public bc_time_interval
type(fv_regional_bc_variables), pointer, save bc_south_t0
type(fv_domain_sides), target, save, public bc_t0
real, dimension(:), allocatable dum1d
The module 'boundary' contains utility routines for grid nesting and boundary conditions.
type(fv_regional_bc_variables), pointer bc_side_t0
integer, parameter nhalo_data
character(len=80) data_source
real, parameter real_snan
subroutine prepare_full_fields(Atm)
subroutine, public set_regional_bcs(delp, delz, w, pt ifdef USE_COND
type(fv_regional_bc_variables), pointer, save bc_north_t1
real, dimension(:), allocatable, public bk_in
The module 'fv_mapz' contains the vertical mapping routines .
real, dimension(:), allocatable pref
real, parameter target_lon
integer, save ice_water_index
subroutine bc_time_interpolation(array, lbnd_x, ubnd_x, lbnd_y, ubnd_y, ubnd_z, bc_t0, bc_t1, lbnd1, ubnd1, lbnd2, ubnd2, i1, i2, j1, j2, is, ie, js, je, fcst_time, bc_update_interval, i1_blend, i2_blend, j1_blend, j2_blend, i_bc, j_bc, nside, bc_vbl_name, blend)
subroutine, public fillz(im, km, nq, q, dp)
The subroutine 'fillz' is for mass-conservative filling of nonphysical negative values in the tracers...
real, save dt_atmos
-- The physics (large) timestep (sec)
subroutine apply_delz_boundary(istart, iend, jstart, jend, nz, Atm, name, field)
The module 'fv_arrays' contains the 'fv_atmos_type' and associated datatypes.
subroutine allocate_regional_bc_arrays(side, north_bc, south_bc, east_bc, west_bc, is_0, ie_0, js_0, je_0, is_sn, ie_sn, js_sn, je_sn, is_we, ie_we, js_we, je_we, klev, ntracers, BC_side, delz_side)
subroutine p_maxmin(qname, q, is, ie, js, je, km, fac)
type(single_vbl3d_sides) delz_auxiliary
– Boundary delz that follows integration through forecast time.
integer, save graupel_index
integer, save ubnd_y_tracers
– Local upper bounds of x,y for tracer arrays
subroutine, public cell_center2(q1, q2, q3, q4, e2)
subroutine bc_values_into_arrays(side_t0, side_t1, side, i1, i2, j1, j2, i1_uvs, i2_uvs, j1_uvs, j2_uvs, i1_uvw, i2_uvw, j1_uvw, j2_uvw)
The module 'fv_eta' contains routine to set up the reference (Eulerian) pressure coordinate.
character(len=100) oro_data
integer, parameter nvars_core
-- # of prognostic variables in core restart file
type(vars_3d), dimension(:), allocatable fields_tracers
type(fv_regional_bc_variables), pointer, save bc_east_t0
integer, parameter istart_nest
subroutine, public moist_cp(is, ie, isd, ied, jsd, jed, km, j, k, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, q, qd, cpm, t1)
The subroutine 'moist_cp' computes the FV3-consistent moist heat capacity under constant pressure...
integer, save ubnd_x_tracers
type(fv_nest_bc_type_3d), public delz_regbc
subroutine, public get_data_source(source, regional)
subroutine compute_regional_bc_indices(regional_bc_bounds)
type(fv_regional_bc_variables), pointer bc_side_t1
integer, save sphum_index
–
type(fv_regional_bc_bounds_type), pointer, save regional_bounds
real, dimension(:,:), allocatable phis_reg
– Filtered sfc geopotential
subroutine set_delp_and_tracers(BC_side, npz, nwat)
real, parameter blend_exp1
integer, parameter, public v_stagger
integer, save lbnd_y_tracers
-- Local lower bounds of x,y for tracer arrays
@ The module 'fv_diagnostics' contains routines to compute diagnosic fields.
integer, save snow_water_index
The module 'fv_grid_utils' contains routines for setting up and computing grid-related quantities...
real(kind=r_grid), parameter dbl_snan
integer, save, public bc_hour
real, save dyn_timestep
– The dynamics timestep (sec)
type(fv_regional_bc_variables), pointer, save bc_west_t0
type(fv_regional_bc_variables), pointer, save bc_north_t0
subroutine, public write_full_fields(Atm)
subroutine, public prt_gb_nh_sh(qname, is, ie, js, je, a2, area, lat)
real, parameter target_lat
integer, save nrows_blend_user
real(kind=r_grid), dimension(:,:,:), allocatable agrid_reg
-- Lon/lat of cell centers
subroutine remap_dwinds_regional_bc(Atm, is_input, ie_input, js_input, je_input, is_u, ie_u, js_u, je_u, is_v, ie_v, js_v, je_v, km, npz, ak0, bk0, psc, ud, vd, uc, vc, BC_side)
integer, parameter jstart_nest
subroutine pmaxmn(qname, q, is, ie, js, je, km, fac, area, domain)
subroutine retrieve_bc_variable_data(bc_vbl_name, bc_side_t0, bc_side_t1, bc_t0, bc_t1, lbnd1, ubnd1, lbnd2, ubnd2, iq)
real, dimension(:), allocatable, public ak_in
integer, save, public ntimesteps_per_bc_update
integer, parameter nhalo_model
subroutine, public exch_uv(domain, bd, npz, u, v)
integer, save nrows_blend
– # of blending rows in the BC data files.
subroutine read_regional_filtered_topo
integer, save rain_water_index
subroutine fill_bc_for_da
character(len=50) filename_tracers
real, parameter blend_exp2
– Define the exponential dropoff of weights
subroutine fillq(im, km, nq, q, dp)
type(fv_regional_bc_variables), pointer, save bc_west_t1
subroutine, public read_new_bc_data(Atm, Time, Time_step_atmos, p_split, isd, ied, jsd, jed)
integer, parameter, public u_stagger