4 #define DEALLOCGLOB_(A) if(associated(A)) then;A=0;call MAPL_DeAllocNodeArray(A,rc=STATUS);if(STATUS==MAPL_NoShm) deallocate(A,stat=STATUS);NULLIFY(A);endif 28 use,
intrinsic :: iso_fortran_env, only: real64, real32
32 use fv_mp_nlm_mod,
only: is_master,
ng, mp_barrier, mp_gather, mp_bcst, &
33 is,js,ie,je, isd,jsd,ied,jed, fill_corners, ydir
59 real(FVPRC),
parameter :: GRAV =
mapl_grav 61 real(FVPRC),
parameter :: RDGAS =
mapl_rgas 62 real(FVPRC),
parameter :: RVGAS =
mapl_rvap 63 real(FVPRC),
parameter :: CP_AIR =
mapl_cp 66 real(FVPRC),
parameter::
zvir = rvgas/rdgas - 1.
79 subroutine get_external_ic( Atm, fv_domain, use_geos_latlon_restart, use_geos_cubed_restart, ntracers )
82 type(
domain2d),
intent(inout) :: fv_domain
83 logical,
optional,
intent(in) :: use_geos_latlon_restart
84 logical,
optional,
intent(in) :: use_geos_cubed_restart
85 integer,
optional,
intent(in) :: ntracers(3)
86 real(FVPRC):: alpha = 0.
88 logical :: cubed_sphere,fv_diag_ic
94 atm(1)%gridstruct%fc(i,j) = 2.*omega*( -1.*cos(atm(1)%gridstruct%grid(i,j,1))*cos(atm(1)%gridstruct%grid(i,j,2))*sin(alpha) + &
95 sin(atm(1)%gridstruct%grid(i,j,2))*cos(alpha) )
101 atm(1)%gridstruct%f0(i,j) = 2.*omega*( -1.*cos(atm(1)%gridstruct%agrid(i,j,1))*cos(atm(1)%gridstruct%agrid(i,j,2))*sin(alpha) + &
102 sin(atm(1)%gridstruct%agrid(i,j,2))*cos(alpha) )
109 if ( cubed_sphere )
call fill_corners(atm(1)%gridstruct%f0, atm(1)%npx, atm(1)%npy, ydir)
112 if ( atm(1)%flagstruct%mountain )
then 119 if (
present(use_geos_latlon_restart))
then 120 if (
allocated(atm(1)%q))
deallocate( atm(1)%q )
121 allocate ( atm(1)%q(isd:ied,jsd:jed,atm(1)%npz,atm(1)%ncnst) )
123 elseif (
present(use_geos_cubed_restart))
then 124 if (
allocated(atm(1)%q))
deallocate( atm(1)%q )
125 allocate ( atm(1)%q(isd:ied,jsd:jed,atm(1)%npz,atm(1)%ncnst) )
128 if ( atm(1)%flagstruct%ncep_ic )
then 134 #ifndef NO_FV_TRACERS 136 if(is_master())
write(6,*)
'All tracers except sphum replaced by FV IC' 139 elseif ( fv_diag_ic )
then 141 nq =
size(atm(1)%q,4)
149 nq =
size(atm(1)%q,4)
154 call prt_maxmin(
'T', atm(1)%pt, is, ie, js, je,
ng, atm(1)%npz, 1.0_fvprc)
156 call p_var(atm(1)%npz, is, ie, js, je, atm(1)%ak(1), ptop_min, &
157 atm(1)%delp, atm(1)%delz, atm(1)%pt, atm(1)%ps, &
158 atm(1)%pe, atm(1)%peln, atm(1)%pk, atm(1)%pkz, &
159 kappa, atm(1)%q,
ng, atm(1)%ncnst, dble(atm(1)%gridstruct%area),atm(1)%flagstruct%dry_mass, &
160 atm(1)%flagstruct%adjust_dry_mass, atm(1)%flagstruct%mountain, atm(1)%flagstruct%moist_phys, &
161 atm(1)%flagstruct%hydrostatic, atm(1)%flagstruct%nwat, atm(1)%domain,atm(1)%flagstruct%make_nh)
169 type(
domain2d),
intent(inout) :: fv_domain
171 integer,
allocatable :: tile_id(:)
172 character(len=64) :: fname
174 integer :: jbeg, jend
206 deallocate( tile_id )
214 type(fv_atmos_type),
intent(inout) :: Atm(:)
215 type(domain2d),
intent(inout) :: fv_domain
216 integer,
intent(in):: nq
218 character(len=128) :: fname, tracer_name
219 real(kind=4),
allocatable:: wk1(:), wk2(:,:), wk3(:,:,:)
220 real(FVPRC),
allocatable:: tp(:,:,:), qp(:,:,:,:)
221 real(FVPRC),
allocatable:: ua(:,:,:), va(:,:,:), wa(:,:,:)
222 real(FVPRC),
allocatable:: lat(:), lon(:), ak0(:), bk0(:)
223 real(FVPRC):: s2c(is:ie,js:je,4)
224 integer,
dimension(is:ie,js:je):: id1, id2, jdc
225 real(FVPRC) psc(is:ie,js:je)
226 real(FVPRC) gzc(is:ie,js:je)
227 integer:: i, j, k, im, jm, km, npz, npt
228 integer:: i1, i2, j1, ncid
230 integer tsize(4), tr_ind
233 integer sphum, liq_wat, rainwat, ice_wat, snowwat, graupel
1567 type(fv_atmos_type),
intent(inout) :: Atm(:)
1568 type(domain2d),
intent(inout) :: fv_domain
1569 integer,
intent(in):: nq
1571 character(len=128) :: fname
1572 real(kind=4),
allocatable:: wk1(:), wk2(:,:), wk3(:,:,:)
1573 real(FVPRC),
allocatable:: tp(:,:,:), qp(:,:,:)
1574 real(FVPRC),
allocatable:: ua(:,:,:), va(:,:,:)
1575 real(FVPRC),
allocatable:: lat(:), lon(:), ak0(:), bk0(:)
1576 real(FVPRC):: s2c(is:ie,js:je,4)
1577 integer,
dimension(is:ie,js:je):: id1, id2, jdc
1578 real(FVPRC) psc(is:ie,js:je)
1579 real(FVPRC) gzc(is:ie,js:je)
1581 integer:: i, j, k, im, jm, km, npz, npt
1582 integer:: i1, i2, j1, ncid
1583 integer:: jbeg, jend
1585 logical:: read_ts = .true.
1586 logical:: land_ts = .false.
1835 subroutine get_fv_ic( Atm, fv_domain, nq )
1836 type(fv_atmos_type),
intent(inout) :: Atm(:)
1837 type(domain2d),
intent(inout) :: fv_domain
1838 integer,
intent(in):: nq
1840 character(len=128) :: fname, tracer_name
1841 real(FVPRC),
allocatable:: ps0(:,:), gz0(:,:), u0(:,:,:), v0(:,:,:), t0(:,:,:), dp0(:,:,:), q0(:,:,:,:)
1842 real(FVPRC),
allocatable:: ua(:,:,:), va(:,:,:)
1843 real(FVPRC),
allocatable:: lat(:), lon(:), ak0(:), bk0(:)
1844 integer :: i, j, k, im, jm, km, npz, tr_ind
1982 subroutine ncep2fms(im, jm, lon, lat, wk)
1984 integer,
intent(in):: im, jm
1985 real(FVPRC),
intent(in):: lon(im), lat(jm)
1986 real(kind=4),
intent(in):: wk(im,jm)
1988 real(FVPRC) :: rdlon(im)
1989 real(FVPRC) :: rdlat(jm)
1990 real(FVPRC):: a1, b1
1991 real(FVPRC):: delx, dely
1992 real(FVPRC):: xc, yc
1993 real(FVPRC):: c1, c2, c3, c4
1994 integer i,j, i1, i2, jc, i0, j0, it, jt
1997 rdlon(i) = 1. / (lon(i+1) - lon(i))
1999 rdlon(im) = 1. / (lon(1) + 2.*pi - lon(im))
2002 rdlat(j) = 1. / (lat(j+1) - lat(j))
2009 delx = 360./
real(i_sst)
2010 dely = 180./
real(j_sst)
2015 yc = (-90. + dely * (0.5+
real(j-1))) * deg2rad
2016 if ( yc<lat(1) )
then 2019 elseif ( yc>lat(jm) )
then 2024 if ( yc>=lat(j0) .and. yc<=lat(j0+1) )
then 2027 b1 = (yc-lat(jc)) * rdlat(jc)
2036 xc = delx * (0.5+
real(i-1)) * deg2rad
2037 if ( xc>lon(im) )
then 2039 a1 = (xc-lon(im)) * rdlon(im)
2040 elseif ( xc<lon(1) )
then 2042 a1 = (xc+2.*pi-lon(im)) * rdlon(im)
2045 if ( xc>=lon(i0) .and. xc<=lon(i0+1) )
then 2048 a1 = (xc-lon(i1)) * rdlon(i0)
2055 if ( a1<0.0 .or. a1>1.0 .or. b1<0.0 .or. b1>1.0 )
then 2056 write(*,*)
'gid=', mpp_pe(), i,j,a1, b1
2059 c1 = (1.-a1) * (1.-b1)
2064 sst_ncep(i,j) = c1*wk(i1,jc ) + c2*wk(i2,jc ) + &
2065 c3*wk(i2,jc+1) + c4*wk(i1,jc+1)
2073 subroutine remap_coef( im, jm, lon, lat, id1, id2, jdc, s2c, agrid, bd )
2075 type(fv_grid_bounds_type),
intent(IN) :: bd
2076 integer,
intent(in):: im, jm
2077 real(FVPRC),
intent(in):: lon(im), lat(jm)
2078 real(FVPRC),
intent(out):: s2c(bd%is:bd%ie,bd%js:bd%je,4)
2079 integer,
intent(out),
dimension(bd%is:bd%ie,bd%js:bd%je):: id1, id2, jdc
2080 real(FVPRC),
intent(in):: agrid(bd%isd:bd%ied,bd%jsd:bd%jed,2)
2082 real(FVPRC) :: rdlon(im)
2083 real(FVPRC) :: rdlat(jm)
2084 real(FVPRC):: a1, b1
2085 integer i,j, i1, i2, jc, i0, j0
2087 integer :: is, ie, js, je
2088 integer :: isd, ied, jsd, jed
2099 rdlon(i) = 1. / (lon(i+1) - lon(i))
2101 rdlon(im) = 1. / (lon(1) + 2.*pi - lon(im))
2104 rdlat(j) = 1. / (lat(j+1) - lat(j))
2112 if ( agrid(i,j,1)>lon(im) )
then 2114 a1 = (agrid(i,j,1)-lon(im)) * rdlon(im)
2115 elseif ( agrid(i,j,1)<lon(1) )
then 2117 a1 = (agrid(i,j,1)+2.*pi-lon(im)) * rdlon(im)
2120 if ( agrid(i,j,1)>=lon(i0) .and. agrid(i,j,1)<=lon(i0+1) )
then 2122 a1 = (agrid(i,j,1)-lon(i1)) * rdlon(i0)
2128 if ( agrid(i,j,2)<lat(1) )
then 2131 elseif ( agrid(i,j,2)>lat(jm) )
then 2136 if ( agrid(i,j,2)>=lat(j0) .and. agrid(i,j,2)<=lat(j0+1) )
then 2138 b1 = (agrid(i,j,2)-lat(jc)) * rdlat(jc)
2145 if ( a1<0.0 .or. a1>1.0 .or. b1<0.0 .or. b1>1.0 )
then 2146 write(*,*)
'gid=', mpp_pe(), i,j,a1, b1
2149 s2c(i,j,1) = (1.-a1) * (1.-b1)
2150 s2c(i,j,2) = a1 * (1.-b1)
2151 s2c(i,j,3) = a1 * b1
2152 s2c(i,j,4) = (1.-a1) * b1
2161 subroutine remap_scalar(im, jm, km, npz, nq, ncnst, ak0, bk0, psc, gzc, ta, qa, Atm)
2162 type(fv_atmos_type),
intent(inout) :: Atm
2163 integer,
intent(in):: im, jm, km, npz, nq, ncnst
2164 real(FVPRC),
intent(in):: ak0(km+1), bk0(km+1)
2165 real(FVPRC),
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je):: psc, gzc
2166 real(FVPRC),
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km):: ta
2167 real(FVPRC),
intent(in),
dimension(Atm%bd%is:Atm%bd%ie,Atm%bd%js:Atm%bd%je,km,ncnst):: qa
2169 real(FVPRC),
dimension(Atm%bd%is:Atm%bd%ie,km):: tp
2170 real(FVPRC),
dimension(Atm%bd%is:Atm%bd%ie,km+1):: pe0, pn0
2171 real(FVPRC),
dimension(Atm%bd%is:Atm%bd%ie,npz):: qn1
2172 real(FVPRC),
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pe1, pn1
2173 real(FVPRC) pt0(km), gz(km+1), pk0(km+1)
2174 real(FVPRC) qp(Atm%bd%is:Atm%bd%ie,km,ncnst)
2175 real(FVPRC) pst, p1, p2, alpha, rdg
2178 integer :: is, ie, js, je
2179 integer :: isd, ied, jsd, jed
2196 if ( sphum/=1 )
then 2197 call mpp_error(fatal,
'SPHUM must be 1st tracer')
2205 qp(i,k,iq) = qa(i,j,k,iq)
2217 tp(i,k) = ta(i,j,k)*(1.+
zvir*qp(i,k,sphum))
2223 pe0(i,k) = ak0(k) + bk0(k)*psc(i,j)
2224 pn0(i,k) = log(pe0(i,k))
2225 pk0(k) = pe0(i,k)**kappa
2229 atm% ps(i,j) = psc(i,j)
2230 atm%phis(i,j) = gzc(i,j)
2236 gz(k) = gz(k+1) + rdgas*tp(i,k)*(pn0(i,k+1)-pn0(i,k))
2239 pt0(km) = tp(i,km)/(pk0(km+1)-pk0(km))*(kappa*(pn0(i,km+1)-pn0(i,km)))
2240 if( atm%phis(i,j)>gzc(i,j) )
then 2242 if( atm%phis(i,j) < gz(k) .and. &
2243 atm%phis(i,j) >= gz(k+1) )
then 2244 pst = pk0(k) + (pk0(k+1)-pk0(k))*(gz(k)-atm%phis(i,j))/(gz(k)-gz(k+1))
2250 pst = pk0(km+1) + (gzc(i,j)-atm%phis(i,j))/(cp_air*pt0(km))
2253 123 atm%ps(i,j) = pst**(1./kappa)
2259 pe1(i,1) = atm%ak(1)
2260 pn1(i,1) = log(pe1(i,1))
2264 pe1(i,k) = atm%ak(k) + atm%bk(k)*atm%ps(i,j)
2265 pn1(i,k) = log(pe1(i,k))
2272 atm%delp(i,j,k) = pe1(i,k+1) - pe1(i,k)
2280 call mappm(km, pe0, qp(is,1,iq), npz, pe1, qn1, is,ie, 0, 11, atm%ptop)
2281 if ( iq==sphum .and. atm%flagstruct%ncep_ic )
then 2287 pst = 0.5*(pe1(i,k)+pe1(i,k+1))
2288 if ( pst > p1 )
then 2289 atm%q(i,j,k,iq) = qn1(i,k)
2290 elseif( pst > p2 )
then 2291 alpha = (pst-p2)/(p1-p2)
2292 atm%q(i,j,k,1) = qn1(i,k)*alpha + atm%q(i,j,k,1)*(1.-alpha)
2299 atm%q(i,j,k,iq) = qn1(i,k)
2308 call mappm(km, pn0, tp, npz, pn1, qn1, is,ie, 1, 9, atm%ptop)
2311 atm%pt(i,j,k) = qn1(i,k)/(1.+
zvir*atm%q(i,j,k,sphum))
2315 if ( .not. atm%flagstruct%hydrostatic .and. atm%flagstruct%ncep_ic )
then 2320 atm%delz(i,j,k) = rdg*qn1(i,k)*(pn1(i,k+1)-pn1(i,k))
2327 call prt_maxmin(
'PS_model', atm%ps, is, ie, js, je,
ng, 1, 0.01_fvprc)
2329 if (is_master())
write(*,*)
'done remap_scalar' 2333 subroutine remap_winds(im, jm, km, npz, ak0, bk0, psc, ua, va, Atm)
2334 type(fv_atmos_type),
intent(inout) :: Atm(:)
2335 integer,
intent(in):: im, jm, km, npz
2336 real(FVPRC),
intent(in):: ak0(km+1), bk0(km+1)
2337 real(FVPRC),
intent(in):: psc(is:ie,js:je)
2338 real(FVPRC),
intent(in),
dimension(is:ie,js:je,km):: ua, va
2340 real(FVPRC),
dimension(isd:ied,jsd:jed,npz):: ut, vt
2341 real(FVPRC),
dimension(is:ie, km+1):: pe0
2342 real(FVPRC),
dimension(is:ie,npz+1):: pe1
2343 real(FVPRC),
dimension(is:ie,npz):: qn1
2352 pe0(i,k) = ak0(k) + bk0(k)*psc(i,j)
2358 pe1(i,k) = atm(1)%ak(k) + atm(1)%bk(k)*atm(1)%ps(i,j)
2365 call mappm(km, pe0, ua(is:ie,j,1:km), npz, pe1, qn1, is,ie, -1, 4, atm(1)%ptop)
2368 ut(i,j,k) = qn1(i,k)
2374 call mappm(km, pe0, va(is:ie,j,1:km), npz, pe1, qn1, is,ie, -1, 4, atm(1)%ptop)
2377 vt(i,j,k) = qn1(i,k)
2383 call prt_maxmin(
'UT', ut, is, ie, js, je,
ng, npz, 1.0_fvprc)
2384 call prt_maxmin(
'VT', vt, is, ie, js, je,
ng, npz, 1.0_fvprc)
2389 call cubed_a2d(atm(1)%npx, atm(1)%npy, npz, ut, vt, atm(1)%u, atm(1)%v, atm(1)%gridstruct, &
2390 atm(1)%domain, atm(1)%bd )
2392 if (is_master())
write(*,*)
'done remap_winds' 2397 subroutine remap_wz(im, jm, km, npz, mg, ak0, bk0, psc, wa, wz, Atm)
2398 type(fv_atmos_type),
intent(inout) :: Atm(:)
2399 integer,
intent(in):: im, jm, km, npz
2400 integer,
intent(in):: mg
2401 real(FVPRC),
intent(in):: ak0(km+1), bk0(km+1)
2402 real(FVPRC),
intent(in):: psc(is:ie,js:je)
2403 real(FVPRC),
intent(in),
dimension(is:ie,js:je,km):: wa
2404 real(FVPRC),
intent(out):: wz(is-mg:ie+mg,js-mg:je+mg,npz)
2406 real(FVPRC),
dimension(is:ie, km+1):: pe0
2407 real(FVPRC),
dimension(is:ie,npz+1):: pe1
2408 real(FVPRC),
dimension(is:ie,npz):: qn1
2415 pe0(i,k) = ak0(k) + bk0(k)*psc(i,j)
2421 pe1(i,k) = atm(1)%ak(k) + atm(1)%bk(k)*atm(1)%ps(i,j)
2428 call mappm(km, pe0, wa(is:ie,j,1:km), npz, pe1, qn1, is,ie, -1, 4, atm(1)%ptop)
2431 wz(i,j,k) = qn1(i,k)
2442 subroutine remap_xyz( im, jbeg, jend, jm, km, npz, nq, ncnst, lon, lat, ak0, bk0, ps0, gz0, &
2443 ua, va, ta, qa, Atm )
2445 type(fv_atmos_type),
intent(inout),
target :: Atm
2446 integer,
intent(in):: im, jm, km, npz, nq, ncnst
2447 integer,
intent(in):: jbeg, jend
2448 real(FVPRC),
intent(in):: lon(im), lat(jm), ak0(km+1), bk0(km+1)
2449 real(FVPRC),
intent(in):: gz0(im,jbeg:jend), ps0(im,jbeg:jend)
2450 real(FVPRC),
intent(in),
dimension(im,jbeg:jend,km):: ua, va, ta
2451 real(FVPRC),
intent(in),
dimension(im,jbeg:jend,km,ncnst):: qa
2453 real(FVPRC),
pointer,
dimension(:,:,:) :: agrid
2456 real(FVPRC),
dimension(Atm%bd%isd:Atm%bd%ied,Atm%bd%jsd:Atm%bd%jed,npz):: ut, vt
2457 real(FVPRC),
dimension(Atm%bd%is:Atm%bd%ie,km):: up, vp, tp
2458 real(FVPRC),
dimension(Atm%bd%is:Atm%bd%ie,km+1):: pe0, pn0
2459 real(FVPRC) pt0(km), gz(km+1), pk0(km+1)
2460 real(FVPRC) qp(Atm%bd%is:Atm%bd%ie,km,ncnst)
2461 real(FVPRC),
dimension(Atm%bd%is:Atm%bd%ie,npz):: qn1
2462 real(FVPRC),
dimension(Atm%bd%is:Atm%bd%ie,npz+1):: pe1, pn1
2463 real(FVPRC) :: rdlon(im)
2464 real(FVPRC) :: rdlat(jm)
2465 real(FVPRC):: a1, b1, c1, c2, c3, c4
2466 real(FVPRC):: gzc, psc, pst
2467 integer i,j,k, i1, i2, jc, i0, j0, iq
2470 integer :: is, ie, js, je
2471 integer :: isd, ied, jsd, jed
2483 agrid => atm%gridstruct%agrid
2490 if ( sphum/=1 )
then 2491 call mpp_error(fatal,
'SPHUM must be 1st tracer')
2493 pk0(1) = ak0(1)**kappa
2496 rdlon(i) = 1. / (lon(i+1) - lon(i))
2498 rdlon(im) = 1. / (lon(1) + 2.*pi - lon(im))
2501 rdlat(j) = 1. / (lat(j+1) - lat(j))
2509 pn0(i,1) = log(ak0(1))
2514 if ( agrid(i,j,1)>lon(im) )
then 2516 a1 = (agrid(i,j,1)-lon(im)) * rdlon(im)
2517 elseif ( agrid(i,j,1)<lon(1) )
then 2519 a1 = (agrid(i,j,1)+2.*pi-lon(im)) * rdlon(im)
2522 if ( agrid(i,j,1)>=lon(i0) .and. agrid(i,j,1)<=lon(i0+1) )
then 2524 a1 = (agrid(i,j,1)-lon(i1)) * rdlon(i0)
2531 if ( agrid(i,j,2)<lat(1) )
then 2534 elseif ( agrid(i,j,2)>lat(jm) )
then 2539 if ( agrid(i,j,2)>=lat(j0) .and. agrid(i,j,2)<=lat(j0+1) )
then 2541 b1 = (agrid(i,j,2)-lat(jc)) * rdlat(jc)
2549 if ( a1<0.0 .or. a1>1.0 .or. b1<0.0 .or. b1>1.0 )
then 2550 write(*,*) i,j,a1, b1
2553 c1 = (1.-a1) * (1.-b1)
2559 psc = c1*ps0(i1,jc ) + c2*ps0(i2,jc ) + &
2560 c3*ps0(i2,jc+1) + c4*ps0(i1,jc+1)
2563 gzc = c1*gz0(i1,jc ) + c2*gz0(i2,jc ) + &
2564 c3*gz0(i2,jc+1) + c4*gz0(i1,jc+1)
2570 qp(i,k,iq) = c1*qa(i1,jc, k,iq) + c2*qa(i2,jc, k,iq) + &
2571 c3*qa(i2,jc+1,k,iq) + c4*qa(i1,jc+1,k,iq)
2576 up(i,k) = c1*ua(i1,jc, k) + c2*ua(i2,jc, k) + &
2577 c3*ua(i2,jc+1,k) + c4*ua(i1,jc+1,k)
2578 vp(i,k) = c1*va(i1,jc, k) + c2*va(i2,jc, k) + &
2579 c3*va(i2,jc+1,k) + c4*va(i1,jc+1,k)
2580 tp(i,k) = c1*ta(i1,jc, k) + c2*ta(i2,jc, k) + &
2581 c3*ta(i2,jc+1,k) + c4*ta(i1,jc+1,k)
2583 tp(i,k) = tp(i,k)*(1.+
zvir*qp(i,k,sphum))
2588 pe0(i,k) = ak0(k) + bk0(k)*psc
2589 pn0(i,k) = log(pe0(i,k))
2590 pk0(k) = pe0(i,k)**kappa
2601 gz(k) = gz(k+1) + rdgas*tp(i,k)*(pn0(i,k+1)-pn0(i,k))
2604 pt0(km) = tp(i,km)/(pk0(km+1)-pk0(km))*(kappa*(pn0(i,km+1)-pn0(i,km)))
2605 if( atm%phis(i,j)>gzc )
then 2607 if( atm%phis(i,j) < gz(k) .and. &
2608 atm%phis(i,j) >= gz(k+1) )
then 2609 pst = pk0(k) + (pk0(k+1)-pk0(k))*(gz(k)-atm%phis(i,j))/(gz(k)-gz(k+1))
2615 pst = pk0(km+1) + (gzc-atm%phis(i,j))/(cp_air*pt0(km))
2618 123 atm%ps(i,j) = pst**(1./kappa)
2625 pe1(i,1) = atm%ak(1)
2626 pn1(i,1) = log(pe1(i,1))
2630 pe1(i,k) = atm%ak(k) + atm%bk(k)*atm%ps(i,j)
2631 pn1(i,k) = log(pe1(i,k))
2637 atm%delp(i,j,k) = pe1(i,k+1) - pe1(i,k)
2645 call mappm(km, pe0, up, npz, pe1, qn1, is,ie, -1, 9, atm%ptop)
2648 ut(i,j,k) = qn1(i,k)
2654 call mappm(km, pe0, vp, npz, pe1, qn1, is,ie, -1, 9, atm%ptop)
2657 vt(i,j,k) = qn1(i,k)
2667 call mappm(km, pe0, qp(is,1,iq), npz, pe1, qn1, is,ie, 0, 11, atm%ptop)
2670 atm%q(i,j,k,iq) = qn1(i,k)
2679 call mappm(km, pn0, tp, npz, pn1, qn1, is,ie, 1, 9, atm%ptop)
2682 atm%pt(i,j,k) = qn1(i,k)/(1.+
zvir*atm%q(i,j,k,sphum))
2688 call prt_maxmin(
'PS_model', atm%ps, is, ie, js, je,
ng, 1, 0.01_fvprc)
2689 call prt_maxmin(
'UT', ut, is, ie, js, je,
ng, npz, 1._fvprc)
2690 call prt_maxmin(
'VT', vt, is, ie, js, je,
ng, npz, 1._fvprc)
2695 call cubed_a2d(atm%npx, atm%npy, npz, ut, vt, atm%u, atm%v, atm%gridstruct, atm%domain, atm%bd )
2697 if (is_master())
write(*,*)
'done remap_xyz' 2955 real(FVPRC),
Intent(In) :: a(:,:)
2956 real(FVPRC) :: b(
size(a,1),
size(a,2))
2968 subroutine cubed_a2d( npx, npy, npz, ua, va, u, v, gridstruct, fv_domain, bd )
2974 type(fv_grid_bounds_type),
intent(IN) :: bd
2975 integer,
intent(in):: npx, npy, npz
2976 real(FVPRC),
intent(inout),
dimension(bd%isd:bd%ied,bd%jsd:bd%jed,npz):: ua, va
2977 real(FVPRC),
intent(out):: u(bd%isd:bd%ied, bd%jsd:bd%jed+1,npz)
2978 real(FVPRC),
intent(out):: v(bd%isd:bd%ied+1,bd%jsd:bd%jed ,npz)
2979 type(fv_grid_type),
intent(IN),
target :: gridstruct
2980 type(domain2d),
intent(INOUT) :: fv_domain
2982 real(FVPRC) v3(3,bd%is-1:bd%ie+1,bd%js-1:bd%je+1)
2983 real(FVPRC) ue(3,bd%is-1:bd%ie+1,bd%js:bd%je+1)
2984 real(FVPRC) ve(3,bd%is:bd%ie+1,bd%js-1:bd%je+1)
2985 real(FVPRC),
dimension(bd%is:bd%ie):: ut1, ut2, ut3
2986 real(FVPRC),
dimension(bd%js:bd%je):: vt1, vt2, vt3
2987 integer i, j, k, im2, jm2
2989 real(REAL64),
pointer,
dimension(:,:,:) :: vlon, vlat
2990 real(REAL64),
pointer,
dimension(:) :: edge_vect_w, edge_vect_e, edge_vect_s, edge_vect_n
2991 real(REAL64),
pointer,
dimension(:,:,:,:) :: ew, es
2993 integer :: is, ie, js, je
2994 integer :: isd, ied, jsd, jed
3004 vlon => gridstruct%vlon
3005 vlat => gridstruct%vlat
3007 edge_vect_w => gridstruct%edge_vect_w
3008 edge_vect_e => gridstruct%edge_vect_e
3009 edge_vect_s => gridstruct%edge_vect_s
3010 edge_vect_n => gridstruct%edge_vect_n
3027 v3(1,i,j) = ua(i,j,k)*vlon(i,j,1) + va(i,j,k)*vlat(i,j,1)
3028 v3(2,i,j) = ua(i,j,k)*vlon(i,j,2) + va(i,j,k)*vlat(i,j,2)
3029 v3(3,i,j) = ua(i,j,k)*vlon(i,j,3) + va(i,j,k)*vlat(i,j,3)
3037 ue(1,i,j) = 0.5*(v3(1,i,j-1) + v3(1,i,j))
3038 ue(2,i,j) = 0.5*(v3(2,i,j-1) + v3(2,i,j))
3039 ue(3,i,j) = 0.5*(v3(3,i,j-1) + v3(3,i,j))
3045 ve(1,i,j) = 0.5*(v3(1,i-1,j) + v3(1,i,j))
3046 ve(2,i,j) = 0.5*(v3(2,i-1,j) + v3(2,i,j))
3047 ve(3,i,j) = 0.5*(v3(3,i-1,j) + v3(3,i,j))
3052 if (.not. gridstruct%nested)
then 3057 vt1(j) = edge_vect_w(j)*ve(1,i,j-1)+(1.-edge_vect_w(j))*ve(1,i,j)
3058 vt2(j) = edge_vect_w(j)*ve(2,i,j-1)+(1.-edge_vect_w(j))*ve(2,i,j)
3059 vt3(j) = edge_vect_w(j)*ve(3,i,j-1)+(1.-edge_vect_w(j))*ve(3,i,j)
3061 vt1(j) = edge_vect_w(j)*ve(1,i,j+1)+(1.-edge_vect_w(j))*ve(1,i,j)
3062 vt2(j) = edge_vect_w(j)*ve(2,i,j+1)+(1.-edge_vect_w(j))*ve(2,i,j)
3063 vt3(j) = edge_vect_w(j)*ve(3,i,j+1)+(1.-edge_vect_w(j))*ve(3,i,j)
3073 if ( (ie+1)==npx )
then 3077 vt1(j) = edge_vect_e(j)*ve(1,i,j-1)+(1.-edge_vect_e(j))*ve(1,i,j)
3078 vt2(j) = edge_vect_e(j)*ve(2,i,j-1)+(1.-edge_vect_e(j))*ve(2,i,j)
3079 vt3(j) = edge_vect_e(j)*ve(3,i,j-1)+(1.-edge_vect_e(j))*ve(3,i,j)
3081 vt1(j) = edge_vect_e(j)*ve(1,i,j+1)+(1.-edge_vect_e(j))*ve(1,i,j)
3082 vt2(j) = edge_vect_e(j)*ve(2,i,j+1)+(1.-edge_vect_e(j))*ve(2,i,j)
3083 vt3(j) = edge_vect_e(j)*ve(3,i,j+1)+(1.-edge_vect_e(j))*ve(3,i,j)
3098 ut1(i) = edge_vect_s(i)*ue(1,i-1,j)+(1.-edge_vect_s(i))*ue(1,i,j)
3099 ut2(i) = edge_vect_s(i)*ue(2,i-1,j)+(1.-edge_vect_s(i))*ue(2,i,j)
3100 ut3(i) = edge_vect_s(i)*ue(3,i-1,j)+(1.-edge_vect_s(i))*ue(3,i,j)
3102 ut1(i) = edge_vect_s(i)*ue(1,i+1,j)+(1.-edge_vect_s(i))*ue(1,i,j)
3103 ut2(i) = edge_vect_s(i)*ue(2,i+1,j)+(1.-edge_vect_s(i))*ue(2,i,j)
3104 ut3(i) = edge_vect_s(i)*ue(3,i+1,j)+(1.-edge_vect_s(i))*ue(3,i,j)
3114 if ( (je+1)==npy )
then 3118 ut1(i) = edge_vect_n(i)*ue(1,i-1,j)+(1.-edge_vect_n(i))*ue(1,i,j)
3119 ut2(i) = edge_vect_n(i)*ue(2,i-1,j)+(1.-edge_vect_n(i))*ue(2,i,j)
3120 ut3(i) = edge_vect_n(i)*ue(3,i-1,j)+(1.-edge_vect_n(i))*ue(3,i,j)
3122 ut1(i) = edge_vect_n(i)*ue(1,i+1,j)+(1.-edge_vect_n(i))*ue(1,i,j)
3123 ut2(i) = edge_vect_n(i)*ue(2,i+1,j)+(1.-edge_vect_n(i))*ue(2,i,j)
3124 ut3(i) = edge_vect_n(i)*ue(3,i+1,j)+(1.-edge_vect_n(i))*ue(3,i,j)
3137 u(i,j,k) = ue(1,i,j)*es(1,i,j,1) + &
3138 ue(2,i,j)*es(2,i,j,1) + &
3139 ue(3,i,j)*es(3,i,j,1)
3144 v(i,j,k) = ve(1,i,j)*ew(1,i,j,2) + &
3145 ve(2,i,j)*ew(2,i,j,2) + &
3146 ve(3,i,j)*ew(3,i,j,2)
3155 subroutine d2a3d(u, v, ua, va, im, jm, km, lon)
3156 integer,
intent(in):: im, jm, km
3157 real(FVPRC),
intent(in ) :: lon(im)
3158 real(FVPRC),
intent(in ),
dimension(im,jm,km):: u, v
3159 real(FVPRC),
intent(out),
dimension(im,jm,km):: ua, va
3161 real(FVPRC) :: coslon(im),sinlon(im)
3164 real(FVPRC) un, vn, us, vs
3171 sinlon(i) = sin(lon(i))
3172 coslon(i) = cos(lon(i))
3178 ua(i,j,k) = 0.5*(u(i,j,k) + u(i,j+1,k))
3184 va(i,j,k) = 0.5*(v(i,j,k) + v(i+1,j,k))
3186 va(im,j,k) = 0.5*(v(im,j,k) + v(1,j,k))
3193 us = us + (ua(i+imh,2,k)-ua(i,2,k))*sinlon(i) &
3194 + (va(i,2,k)-va(i+imh,2,k))*coslon(i)
3195 vs = vs + (ua(i+imh,2,k)-ua(i,2,k))*coslon(i) &
3196 + (va(i+imh,2,k)-va(i,2,k))*sinlon(i)
3201 ua(i,1,k) = -us*sinlon(i) - vs*coslon(i)
3202 va(i,1,k) = us*coslon(i) - vs*sinlon(i)
3203 ua(i+imh,1,k) = -ua(i,1,k)
3204 va(i+imh,1,k) = -va(i,1,k)
3211 un = un + (ua(i+imh,jm-1,k)-ua(i,jm-1,k))*sinlon(i) &
3212 + (va(i+imh,jm-1,k)-va(i,jm-1,k))*coslon(i)
3213 vn = vn + (ua(i,jm-1,k)-ua(i+imh,jm-1,k))*coslon(i) &
3214 + (va(i+imh,jm-1,k)-va(i,jm-1,k))*sinlon(i)
3220 ua(i,jm,k) = -un*sinlon(i) + vn*coslon(i)
3221 va(i,jm,k) = -un*coslon(i) - vn*sinlon(i)
3222 ua(i+imh,jm,k) = -ua(i,jm,k)
3223 va(i+imh,jm,k) = -va(i,jm,k)
3227 end subroutine d2a3d 3231 subroutine pmaxmin( qname, a, im, jm, fac )
3233 integer,
intent(in):: im, jm
3234 character(len=*) :: qname
3236 real(FVPRC) a(im,jm)
3238 real(FVPRC) qmin(jm), qmax(jm)
3239 real(FVPRC) pmax, pmin
3246 pmax =
max(pmax, a(i,j))
3247 pmin =
min(pmin, a(i,j))
3258 pmax =
max(pmax, qmax(j))
3259 pmin =
min(pmin, qmin(j))
3262 write(*,*) qname,
' max = ', pmax*fac,
' min = ', pmin*fac
3266 subroutine pmaxmin4d( qname, a, im, jm, km, lm, fac )
3269 integer,
intent(in):: im, jm, km, lm
3271 real(FVPRC) a(im,jm,km,lm)
3273 real(FVPRC) qmin(jm), qmax(jm)
3274 real(FVPRC) pmax, pmin
3283 pmax =
max(pmax, a(i,j,k,l))
3284 pmin =
min(pmin, a(i,j,k,l))
3290 write(*,*) qname,
' max = ', pmax*fac,
' min = ', pmin*fac
3296 is,ie,js,je,isd,ied,jsd,jed,tile)
3301 type(domain2D),
intent(OUT) :: domain
3302 integer,
intent(IN) :: npx,npy,nregions,ng,grid_type
3303 integer,
intent(OUT) :: is,ie,js,je,isd,ied,jsd,jed,tile
3305 integer :: layout(2)
3306 integer,
allocatable :: pe_start(:), pe_end(:)
3308 integer :: num_contact, ntiles, npes_per_tile
3309 integer,
allocatable,
dimension(:) :: npes_tile, tile1, tile2
3310 integer,
allocatable,
dimension(:) :: istart1, iend1, jstart1, jend1
3311 integer,
allocatable,
dimension(:) :: istart2, iend2, jstart2, jend2
3312 integer,
allocatable,
dimension(:,:) :: layout2D, global_indices
3314 character*80 :: evalue
3315 integer :: ios,nx,ny,n,num_alloc
3316 character(len=32) ::
type =
"unknown" 3317 logical :: is_symmetry
3318 logical :: debug=.false.
3328 call mpp_domains_init(mpp_domain_time)
3335 call mpp_domains_set_stack_size(3000000)
3337 select case(nregions)
3340 select case (grid_type)
3342 type=
"Lat-Lon: cyclic" 3345 if( mod(npes,ntiles) .NE. 0 )
then 3346 call mpp_error(note,
'TEST_MPP_DOMAINS: for Cyclic mosaic, npes should be multiple of ntiles. ' // &
3347 'No test is done for Cyclic mosaic. ' )
3350 npes_per_tile = npes/ntiles
3352 layout = (/1,npes_per_tile/)
3354 type=
"Cartesian: double periodic" 3357 npes_per_tile = npes/ntiles
3360 type=
"Lat-Lon: patch" 3363 npes_per_tile = npes/ntiles
3366 type=
"Lat-Lon: strip" 3369 npes_per_tile = npes/ntiles
3372 type=
"Cartesian: channel" 3375 npes_per_tile = npes/ntiles
3380 type=
"Cubic: cubed-sphere" 3384 if( mod(npes,ntiles) .NE. 0 .OR. npx-1 .NE. npy-1)
then 3385 call mpp_error(note,
'mpp_domain_decomp: for Cubic_grid mosaic, npes should be multiple of ntiles(6) ' // &
3386 'and npx-1 should equal npy-1, mpp_domain_decomp is NOT done for Cubic-grid mosaic. ' )
3389 npes_per_tile = npes/ntiles
3395 310
format(
'Invalid layout, NPES_X:',i4.4,
'NPES_Y:',i4.4,
'ncells_X:',i4.4,
'ncells_Y:',i4.4)
3396 call mpp_error(fatal,
'mpp_domain_decomp: bad decomp')
3399 call mpp_error(fatal,
'mpp_domain_decomp: no such test: '//type)
3404 allocate(layout2d(2,ntiles), global_indices(4,ntiles), npes_tile(ntiles) )
3405 allocate(pe_start(ntiles),pe_end(ntiles))
3406 npes_tile = npes_per_tile
3408 global_indices(:,n) = (/1,npx-1,1,npy-1/)
3409 layout2d(:,n) = layout
3410 pe_start(n) = (n-1)*layout(1)*layout(2)
3411 pe_end(n) = pe_start(n) + layout(1)*layout(2) -1
3413 num_alloc=
max(1,num_contact)
3414 allocate(tile1(num_alloc), tile2(num_alloc) )
3415 allocate(istart1(num_alloc), iend1(num_alloc), jstart1(num_alloc), jend1(num_alloc) )
3416 allocate(istart2(num_alloc), iend2(num_alloc), jstart2(num_alloc), jend2(num_alloc) )
3418 is_symmetry = .true.
3422 select case(nregions)
3425 select case (grid_type)
3428 tile1(1) = 1; tile2(1) = 2
3429 istart1(1) = nx; iend1(1) = nx; jstart1(1) = 1; jend1(1) = ny
3430 istart2(1) = 1; iend2(1) = 1; jstart2(1) = 1; jend2(1) = ny
3432 tile1(2) = 1; tile2(2) = 3
3433 istart1(2) = 1; iend1(2) = nx; jstart1(2) = 1; jend1(2) = 1
3434 istart2(2) = 1; iend2(2) = nx; jstart2(2) = ny; jend2(2) = ny
3436 tile1(3) = 1; tile2(3) = 2
3437 istart1(3) = 1; iend1(3) = 1; jstart1(3) = 1; jend1(3) = ny
3438 istart2(3) = nx; iend2(3) = nx; jstart2(3) = 1; jend2(3) = ny
3440 tile1(4) = 1; tile2(4) = 3
3441 istart1(4) = 1; iend1(4) = nx; jstart1(4) = ny; jend1(4) = ny
3442 istart2(4) = 1; iend2(4) = nx; jstart2(4) = 1; jend2(4) = 1
3444 tile1(5) = 2; tile2(5) = 4
3445 istart1(5) = 1; iend1(5) = nx; jstart1(5) = 1; jend1(5) = 1
3446 istart2(5) = 1; iend2(5) = nx; jstart2(5) = ny; jend2(5) = ny
3448 tile1(6) = 2; tile2(6) = 4
3449 istart1(6) = 1; iend1(6) = nx; jstart1(6) = ny; jend1(6) = ny
3450 istart2(6) = 1; iend2(6) = nx; jstart2(6) = 1; jend2(6) = 1
3452 tile1(7) = 3; tile2(7) = 4
3453 istart1(7) = nx; iend1(7) = nx; jstart1(7) = 1; jend1(7) = ny
3454 istart2(7) = 1; iend2(7) = 1; jstart2(7) = 1; jend2(7) = ny
3456 tile1(8) = 3; tile2(8) = 4
3457 istart1(8) = 1; iend1(8) = 1; jstart1(8) = 1; jend1(8) = ny
3458 istart2(8) = nx; iend2(8) = nx; jstart2(8) = 1; jend2(8) = ny
3459 is_symmetry = .false.
3462 tile1(1) = 1; tile2(1) = 1
3463 istart1(1) = nx; iend1(1) = nx; jstart1(1) = 1; jend1(1) = ny
3464 istart2(1) = 1; iend2(1) = 1; jstart2(1) = 1; jend2(1) = ny
3466 tile1(2) = 1; tile2(2) = 1
3467 istart1(2) = 1; iend1(2) = nx; jstart1(2) = 1; jend1(2) = 1
3468 istart2(2) = 1; iend2(2) = nx; jstart2(2) = ny; jend2(2) = ny
3473 tile1(1) = 1; tile2(1) = 1
3474 istart1(1) = nx; iend1(1) = nx; jstart1(1) = 1; jend1(1) = ny
3475 istart2(1) = 1; iend2(1) = 1; jstart2(1) = 1; jend2(1) = ny
3478 tile1(1) = 1; tile2(1) = 1
3479 istart1(1) = nx; iend1(1) = nx; jstart1(1) = 1; jend1(1) = ny
3480 istart2(1) = 1; iend2(1) = 1; jstart2(1) = 1; jend2(1) = ny
3485 tile1(1) = 1; tile2(1) = 2
3486 istart1(1) = nx; iend1(1) = nx; jstart1(1) = 1; jend1(1) = ny
3487 istart2(1) = 1; iend2(1) = 1; jstart2(1) = 1; jend2(1) = ny
3489 tile1(2) = 1; tile2(2) = 3
3490 istart1(2) = 1; iend1(2) = nx; jstart1(2) = ny; jend1(2) = ny
3491 istart2(2) = 1; iend2(2) = 1; jstart2(2) = ny; jend2(2) = 1
3493 tile1(3) = 1; tile2(3) = 5
3494 istart1(3) = 1; iend1(3) = 1; jstart1(3) = 1; jend1(3) = ny
3495 istart2(3) = nx; iend2(3) = 1; jstart2(3) = ny; jend2(3) = ny
3497 tile1(4) = 1; tile2(4) = 6
3498 istart1(4) = 1; iend1(4) = nx; jstart1(4) = 1; jend1(4) = 1
3499 istart2(4) = 1; iend2(4) = nx; jstart2(4) = ny; jend2(4) = ny
3501 tile1(5) = 2; tile2(5) = 3
3502 istart1(5) = 1; iend1(5) = nx; jstart1(5) = ny; jend1(5) = ny
3503 istart2(5) = 1; iend2(5) = nx; jstart2(5) = 1; jend2(5) = 1
3505 tile1(6) = 2; tile2(6) = 4
3506 istart1(6) = nx; iend1(6) = nx; jstart1(6) = 1; jend1(6) = ny
3507 istart2(6) = nx; iend2(6) = 1; jstart2(6) = 1; jend2(6) = 1
3509 tile1(7) = 2; tile2(7) = 6
3510 istart1(7) = 1; iend1(7) = nx; jstart1(7) = 1; jend1(7) = 1
3511 istart2(7) = nx; iend2(7) = nx; jstart2(7) = ny; jend2(7) = 1
3513 tile1(8) = 3; tile2(8) = 4
3514 istart1(8) = nx; iend1(8) = nx; jstart1(8) = 1; jend1(8) = ny
3515 istart2(8) = 1; iend2(8) = 1; jstart2(8) = 1; jend2(8) = ny
3517 tile1(9) = 3; tile2(9) = 5
3518 istart1(9) = 1; iend1(9) = nx; jstart1(9) = ny; jend1(9) = ny
3519 istart2(9) = 1; iend2(9) = 1; jstart2(9) = ny; jend2(9) = 1
3521 tile1(10) = 4; tile2(10) = 5
3522 istart1(10) = 1; iend1(10) = nx; jstart1(10) = ny; jend1(10) = ny
3523 istart2(10) = 1; iend2(10) = nx; jstart2(10) = 1; jend2(10) = 1
3525 tile1(11) = 4; tile2(11) = 6
3526 istart1(11) = nx; iend1(11) = nx; jstart1(11) = 1; jend1(11) = ny
3527 istart2(11) = nx; iend2(11) = 1; jstart2(11) = 1; jend2(11) = 1
3529 tile1(12) = 5; tile2(12) = 6
3530 istart1(12) = nx; iend1(12) = nx; jstart1(12) = 1; jend1(12) = ny
3531 istart2(12) = 1; iend2(12) = 1; jstart2(12) = 1; jend2(12) = ny
3534 call mpp_define_mosaic(global_indices, layout2d, domain, ntiles, num_contact, tile1, tile2, &
3535 istart1, iend1, jstart1, jend1, istart2, iend2, jstart2, jend2, &
3536 pe_start=pe_start, pe_end=pe_end, symmetry=is_symmetry, &
3537 shalo = ng, nhalo = ng, whalo = ng, ehalo = ng, name = type)
3540 deallocate(pe_start,pe_end)
3543 tile = mpp_pe()/npes_per_tile+1
3555 character(len=*),
intent(IN) :: fname
3556 integer,
intent(IN) :: npts, is,ie, js,je, km
3557 integer (kind=MPI_OFFSET_KIND),
intent(INOUT) :: offset
3558 real(FVPRC),
intent(INOUT) :: var(is:ie, js:je, km)
3561 real(REAL64) :: var_r8(is:ie, js:je)
3565 integer :: lsize, gsizes(2), distribs(2), dargs(2), psizes(2)
3567 integer :: mcol, mrow, irow, jcol, mpiio_rank
3568 integer :: rank, total_pes
3569 integer :: mpistatus(MPI_STATUS_SIZE)
3570 integer (kind=MPI_OFFSET_KIND) :: slice_2d
3572 real(FVPRC) :: xmod, ymod
3573 character(128) :: strErr
3576 write(strerr,
"(i4.4,' not evenly divisible by ',i4.4)") npts,
npes_x 3577 if (xmod /= 0)
call mpp_error(fatal, strerr)
3578 ymod = mod(npts*6,
npes_y)
3579 write(strerr,
"(i4.4,' not evenly divisible by ',i4.4)") npts*6,
npes_y 3580 if (ymod /= 0)
call mpp_error(fatal, strerr)
3582 call mpi_file_open(mpi_comm_world, fname, mpi_mode_rdonly, mpi_info_null, munit,
status)
3584 gsizes(2) = npts * 6
3585 distribs(1) = mpi_distribute_block
3586 distribs(2) = mpi_distribute_block
3587 dargs(1) = mpi_distribute_dflt_darg
3588 dargs(2) = mpi_distribute_dflt_darg
3591 call mpi_comm_size(mpi_comm_world, total_pes,
status)
3592 call mpi_comm_rank(mpi_comm_world, rank,
status)
3596 jcol = mod(rank, mcol)
3597 mpiio_rank = jcol*mrow + irow
3598 call mpi_type_create_darray(total_pes, mpiio_rank, 2, gsizes, distribs, dargs, psizes, mpi_order_fortran, mpi_double_precision, filetype,
status)
3599 call mpi_type_commit(filetype,
status)
3600 lsize = (ie-is+1)*(je-js+1)
3601 slice_2d = npts*npts*ntiles
3603 call mpi_file_set_view(munit, offset, mpi_double_precision, filetype,
"native", mpi_info_null,
status)
3604 call mpi_file_read_all(munit, var_r8, lsize, mpi_double_precision, mpistatus,
status)
3606 offset = offset + slice_2d*8 + 8
3608 call mpi_file_close(munit,
status)
3613 character(len=*),
intent(IN) :: fname
3614 integer,
intent(IN) :: npts, is,ie, js,je, km
3615 integer (kind=MPI_OFFSET_KIND),
intent(INOUT) :: offset
3616 real(FVPRC),
intent(INOUT) :: var(is:ie, js:je, km)
3619 real(REAL4) :: var_r4(is:ie, js:je)
3623 integer :: lsize, gsizes(2), distribs(2), dargs(2), psizes(2)
3625 integer :: mcol, mrow, irow, jcol, mpiio_rank
3626 integer :: rank, total_pes
3627 integer :: mpistatus(MPI_STATUS_SIZE)
3628 integer (kind=MPI_OFFSET_KIND) :: slice_2d
3630 real(FVPRC) :: xmod, ymod
3631 character(128) :: strErr
3634 write(strerr,
"(i4.4,' not evenly divisible by ',i4.4)") npts,
npes_x 3635 if (xmod /= 0)
call mpp_error(fatal, strerr)
3636 ymod = mod(npts*6,
npes_y)
3637 write(strerr,
"(i4.4,' not evenly divisible by ',i4.4)") npts*6,
npes_y 3638 if (ymod /= 0)
call mpp_error(fatal, strerr)
3640 call mpi_file_open(mpi_comm_world, fname, mpi_mode_rdonly, mpi_info_null, munit,
status)
3642 gsizes(2) = npts * 6
3643 distribs(1) = mpi_distribute_block
3644 distribs(2) = mpi_distribute_block
3645 dargs(1) = mpi_distribute_dflt_darg
3646 dargs(2) = mpi_distribute_dflt_darg
3649 call mpi_comm_size(mpi_comm_world, total_pes,
status)
3650 call mpi_comm_rank(mpi_comm_world, rank,
status)
3654 jcol = mod(rank, mcol)
3655 mpiio_rank = jcol*mrow + irow
3656 call mpi_type_create_darray(total_pes, mpiio_rank, 2, gsizes, distribs, dargs, psizes, mpi_order_fortran, mpi_real, filetype,
status)
3657 call mpi_type_commit(filetype,
status)
3658 lsize = (ie-is+1)*(je-js+1)
3659 slice_2d = npts*npts*ntiles
3661 call mpi_file_set_view(munit, offset, mpi_real, filetype,
"native", mpi_info_null,
status)
3662 call mpi_file_read_all(munit, var_r4, lsize, mpi_real, mpistatus,
status)
3664 offset = offset + slice_2d*4 + 8
3666 call mpi_file_close(munit,
status)
subroutine, public print_memuse_stats(text, unit, always)
real, parameter, public mapl_omega
integer, parameter, public model_atmos
subroutine, public p_var(km, ifirst, ilast, jfirst, jlast, ptop, ptop_min, delp, delz, pt, ps, pe, peln, pk, pkz, cappa, q, ng, nq, area, dry_mass, adjust_dry_mass, mountain, moist_phys, hydrostatic, nwat, domain, make_nh)
real, parameter, public omega
Rotation rate of the Earth [1/s].
subroutine, public open_ncfile(iflnm, ncid)
subroutine mpp_domain_decomp(domain, npx, npy, nregions, ng, grid_type, is, ie, js, je, isd, ied, jsd, jed, tile)
real, parameter, public ptop_min
subroutine, public get_var2_real(ncid, var_name, im, jm, var2)
real(kind=8), parameter, public pi_8
Ratio of circle circumference to diameter [N/A].
subroutine remap_wz(im, jm, km, npz, mg, ak0, bk0, psc, wa, wz, Atm)
subroutine parallel_read_file_r8(fname, npts, is, ie, js, je, km, offset, var)
real, parameter, public mapl_rvap
subroutine ncep2fms(im, jm, lon, lat, wk)
real(kind=mapl_r8), parameter, public mapl_pi_r8
subroutine d2a3d(u, v, ua, va, im, jm, km, lon)
subroutine, public get_var3_r4(ncid, var3_name, is, ie, js, je, ks, ke, var3, time_slice)
real, parameter, public rdgas
Gas constant for dry air [J/kg/deg].
subroutine remap_scalar(im, jm, km, npz, nq, ncnst, ak0, bk0, psc, gzc, ta, qa, Atm)
subroutine, public get_number_tracers(model, num_tracers, num_prog, num_diag, num_family)
real, parameter, public mapl_cp
subroutine cubed_a2d(npx, npy, npz, ua, va, u, v, gridstruct, fv_domain, bd)
subroutine get_diag_ic(Atm, fv_domain, nq)
subroutine, public get_external_ic(Atm, fv_domain, use_geos_latlon_restart, use_geos_cubed_restart, ntracers)
subroutine get_fv_ic(Atm, fv_domain, nq)
subroutine parallel_read_file_r4(fname, npts, is, ie, js, je, km, offset, var)
subroutine, public get_cubed_sphere_terrain(Atm, fv_domain)
integer, parameter, public agrid
real, parameter, public mapl_kappa
int field_exist(const char *file, const char *name)
subroutine pmaxmin4d(qname, a, im, jm, km, lm, fac)
real, parameter, public rvgas
Gas constant for water vapor [J/kg/deg].
integer, parameter, public ng
subroutine, public field_size(filename, fieldname, siz, field_found, domain, no_domain)
subroutine timing_on(blk_name)
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
subroutine, public surfdrv(npx, npy, grid, agrid, area, dx, dy, dxa, dya, dxc, dyc, sin_sg, phis, stretch_fac, nested, npx_global, domain, grid_number, bd)
real(fvprc) function, dimension(size(a, 1), size(a, 2)) reverse(A)
subroutine, public close_ncfile(ncid)
real(fvprc), parameter zvir
real, dimension(:,:), allocatable, public sst_ncep
real, parameter, public grav
Acceleration due to gravity [m/s^2].
subroutine, public get_var1_double(ncid, var1_name, im, var1, var_exist)
subroutine, public mappm(km, pe1, q1, kn, pe2, q2, i1, i2, iv, kord, ptop)
subroutine, public get_ncdim1(ncid, var1_name, im)
void normalize_vect(double *e)
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE size(field%axes(:)) axsiz(i)
subroutine, public get_tile_string(str_out, str_in, tile, str2_in)
subroutine, public get_tracer_names(model, n, name, longname, units, err_msg)
subroutine, public fv_io_read_tracers(fv_domain, Atm)
real, parameter, public mapl_rgas
real, parameter, public mapl_grav
subroutine remap_coef(im, jm, lon, lat, id1, id2, jdc, s2c, agrid, bd)
subroutine, public prt_maxmin(qname, q, is, ie, js, je, n_g, km, fac)
subroutine remap_xyz(im, jbeg, jend, jm, km, npz, nq, ncnst, lon, lat, ak0, bk0, ps0, gz0, ua, va, ta, qa, Atm)
subroutine pmaxmin(qname, a, im, jm, fac)
subroutine remap_winds(im, jm, km, npz, ak0, bk0, psc, ua, va, Atm)
subroutine get_ncep_ic(Atm, fv_domain, nq)
real, parameter, public kappa
RDGAS / CP_AIR [dimensionless].
real(fp), parameter, public pi
subroutine timing_off(blk_name)