22 #include <fms_platform.h> 36 use fv_mp_nlm_mod,
only: mp_reduce_sum, mp_reduce_min, mp_reduce_max
45 #ifdef NO_QUAD_PRECISION 47 integer,
parameter::
f_p = selected_real_kind(15)
50 integer,
parameter::
f_p = selected_real_kind(20)
55 real(kind=R_GRID) ::
radius=cnst_radius
88 TYPE(FV_ATMOS_TYPE),
INTENT(INOUT),
TARGET :: atm
89 LOGICAL,
INTENT(IN) :: non_ortho
90 INTEGER,
INTENT(IN) :: npx, npy, npz
91 INTEGER,
INTENT(IN) :: grid_type, c2l_order
98 REAL(kind=r_grid),
INTENT(IN) :: q1(2), q2(2)
99 REAL(kind=r_grid),
INTENT(IN),
OPTIONAL ::
radius 100 REAL(f_p) :: p1(2), p2(2)
112 beta = asin(sqrt(sin((p1(2)-p2(2))/2.)**2+cos(p1(2))*cos(p2(2))*sin(&
113 & (p1(1)-p2(1))/2.)**2))*2.
122 & mode, grid_type, domain, nested, c2l_ord, bd)
125 INTEGER,
INTENT(IN) :: km, npx, npy,
grid_type, c2l_ord
127 INTEGER,
INTENT(IN) :: mode
129 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, km)
130 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, km)
131 REAL,
INTENT(OUT) :: ua(bd%isd:bd%ied, bd%jsd:bd%jed, km)
132 REAL,
INTENT(OUT) :: va(bd%isd:bd%ied, bd%jsd:bd%jed, km)
133 TYPE(
domain2d),
INTENT(INOUT) :: domain
134 LOGICAL,
INTENT(IN) :: nested
135 IF (c2l_ord .EQ. 2)
THEN 140 & domain, nested, mode, bd)
143 SUBROUTINE c2l_ord4(u, v, ua, va, gridstruct, npx, npy, km, grid_type&
144 & , domain, nested, mode, bd)
146 TYPE(FV_GRID_BOUNDS_TYPE),
INTENT(IN) :: bd
147 INTEGER,
INTENT(IN) :: km, npx, npy, grid_type
149 INTEGER,
INTENT(IN) :: mode
150 TYPE(FV_GRID_TYPE),
INTENT(IN),
TARGET :: gridstruct
151 REAL,
INTENT(INOUT) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, km)
152 REAL,
INTENT(INOUT) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, km)
153 REAL,
INTENT(OUT) :: ua(bd%isd:bd%ied, bd%jsd:bd%jed, km)
154 REAL,
INTENT(OUT) :: va(bd%isd:bd%ied, bd%jsd:bd%jed, km)
155 TYPE(DOMAIN2D),
INTENT(INOUT) :: domain
156 LOGICAL,
INTENT(IN) :: nested
159 REAL,
SAVE :: a1=0.5625
160 REAL,
SAVE :: a2=-0.0625
161 REAL,
SAVE :: c1=1.125
162 REAL,
SAVE :: c2=-0.125
163 REAL :: utmp(bd%is:bd%ie, bd%js:bd%je+1)
164 REAL :: vtmp(bd%is:bd%ie+1, bd%js:bd%je)
165 REAL :: wu(bd%is:bd%ie, bd%js:bd%je+1)
166 REAL :: wv(bd%is:bd%ie+1, bd%js:bd%je)
168 INTEGER :: is, ie, js, je
183 IF (mode .GT. 0)
THEN 200 IF (npy - 1 .GT. je)
THEN 211 IF (npx - 1 .GT. ie)
THEN 217 utmp(i, j) = c2*(u(i, j-1, k)+u(i, j+2, k)) + c1*(u(i, j, &
219 vtmp(i, j) = c2*(v(i-1, j, k)+v(i+2, j, k)) + c1*(v(i, j, &
229 IF (npy - 2 .GT. je)
THEN 240 IF (npx - 2 .GT. ie)
THEN 246 utmp(i, j) = c2*(u(i, j-1, k)+u(i, j+2, k)) + c1*(u(i, j, &
248 vtmp(i, j) = c2*(v(i-1, j, k)+v(i+2, j, k)) + c1*(v(i, j, &
254 wv(i, 1) = v(i, 1, k)*gridstruct%dy(i, 1)
257 vtmp(i, 1) = 2.*(wv(i, 1)+wv(i+1, 1))/(gridstruct%dy(i, 1)&
258 & +gridstruct%dy(i+1, 1))
259 utmp(i, 1) = 2.*(u(i, 1, k)*gridstruct%dx(i, 1)+u(i, 2, k)&
260 & *gridstruct%dx(i, 2))/(gridstruct%dx(i, 1)+gridstruct%dx&
266 IF (je + 1 .EQ. npy)
THEN 269 wv(i, j) = v(i, j, k)*gridstruct%dy(i, j)
272 vtmp(i, j) = 2.*(wv(i, j)+wv(i+1, j))/(gridstruct%dy(i, j)&
273 & +gridstruct%dy(i+1, j))
274 utmp(i, j) = 2.*(u(i, j, k)*gridstruct%dx(i, j)+u(i, j+1, &
275 & k)*gridstruct%dx(i, j+1))/(gridstruct%dx(i, j)+&
276 & gridstruct%dx(i, j+1))
284 wv(1, j) = v(1, j, k)*gridstruct%dy(1, j)
285 wv(2, j) = v(2, j, k)*gridstruct%dy(2, j)
288 wu(i, j) = u(i, j, k)*gridstruct%dx(i, j)
291 utmp(i, j) = 2.*(wu(i, j)+wu(i, j+1))/(gridstruct%dx(i, j)&
292 & +gridstruct%dx(i, j+1))
293 vtmp(i, j) = 2.*(wv(1, j)+wv(2, j))/(gridstruct%dy(1, j)+&
294 & gridstruct%dy(2, j))
299 IF (ie + 1 .EQ. npx)
THEN 302 wv(i, j) = v(i, j, k)*gridstruct%dy(i, j)
303 wv(i+1, j) = v(i+1, j, k)*gridstruct%dy(i+1, j)
306 wu(i, j) = u(i, j, k)*gridstruct%dx(i, j)
309 utmp(i, j) = 2.*(wu(i, j)+wu(i, j+1))/(gridstruct%dx(i, j)&
310 & +gridstruct%dx(i, j+1))
311 vtmp(i, j) = 2.*(wv(i, j)+wv(i+1, j))/(gridstruct%dy(i, j)&
312 & +gridstruct%dy(i+1, j))
321 ua(i, j, k) = gridstruct%a11(i, j)*utmp(i, j) + gridstruct%&
322 & a12(i, j)*vtmp(i, j)
323 va(i, j, k) = gridstruct%a21(i, j)*utmp(i, j) + gridstruct%&
324 & a22(i, j)*vtmp(i, j)
331 ua(i, j, k) = a2*(u(i, j-1, k)+u(i, j+2, k)) + a1*(u(i, j, k&
333 va(i, j, k) = a2*(v(i-1, j, k)+v(i+2, j, k)) + a1*(v(i, j, k&
360 SUBROUTINE c2l_ord2_fwd(u, v, ua, va, gridstruct, km, grid_type, bd, &
367 REAL,
INTENT(IN) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, km)
368 REAL,
INTENT(IN) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, km)
370 LOGICAL,
INTENT(IN) :: do_halo
372 REAL :: ua(bd%isd:bd%ied, bd%jsd:bd%jed, km)
373 REAL :: va(bd%isd:bd%ied, bd%jsd:bd%jed, km)
376 REAL :: wu(bd%is-1:bd%ie+1, bd%js-1:bd%je+2)
377 REAL :: wv(bd%is-1:bd%ie+2, bd%js-1:bd%je+1)
378 REAL :: u1(bd%is-1:bd%ie+1), v1(bd%is-1:bd%ie+1)
380 INTEGER :: is, ie, js, je
381 REAL,
DIMENSION(:, :),
POINTER :: a11, a12, a21, a22
382 REAL,
DIMENSION(:, :),
POINTER :: dx, dy, rdxa, rdya
393 a11 => gridstruct%a11
394 a12 => gridstruct%a12
395 a21 => gridstruct%a21
396 a22 => gridstruct%a22
416 wu(i, j) = u(i, j, k)*dx(i, j)
421 wv(i, j) = v(i, j, k)*dy(i, j)
427 u1(i) = 2.*(wu(i, j)+wu(i, j+1))/(dx(i, j)+dx(i, j+1))
428 v1(i) = 2.*(wv(i, j)+wv(i+1, j))/(dy(i, j)+dy(i+1, j))
433 ua(i, j, k) = a11(i, j)*u1(i) + a12(i, j)*v1(i)
435 va(i, j, k) = a21(i, j)*u1(i) + a22(i, j)*v1(i)
444 ua(i, j, k) = 0.5*(u(i, j, k)+u(i, j+1, k))
446 va(i, j, k) = 0.5*(v(i, j, k)+v(i+1, j, k))
483 SUBROUTINE c2l_ord2_bwd(u, u_ad, v, v_ad, ua, ua_ad, va, va_ad, &
484 & gridstruct, km, grid_type, bd, do_halo)
490 REAL,
INTENT(IN) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, km)
491 REAL :: u_ad(bd%isd:bd%ied, bd%jsd:bd%jed+1, km)
492 REAL,
INTENT(IN) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, km)
493 REAL :: v_ad(bd%isd:bd%ied+1, bd%jsd:bd%jed, km)
495 LOGICAL,
INTENT(IN) :: do_halo
496 REAL :: ua(bd%isd:bd%ied, bd%jsd:bd%jed, km)
497 REAL :: ua_ad(bd%isd:bd%ied, bd%jsd:bd%jed, km)
498 REAL :: va(bd%isd:bd%ied, bd%jsd:bd%jed, km)
499 REAL :: va_ad(bd%isd:bd%ied, bd%jsd:bd%jed, km)
500 REAL :: wu(bd%is-1:bd%ie+1, bd%js-1:bd%je+2)
501 REAL :: wu_ad(bd%is-1:bd%ie+1, bd%js-1:bd%je+2)
502 REAL :: wv(bd%is-1:bd%ie+2, bd%js-1:bd%je+1)
503 REAL :: wv_ad(bd%is-1:bd%ie+2, bd%js-1:bd%je+1)
504 REAL :: u1(bd%is-1:bd%ie+1), v1(bd%is-1:bd%ie+1)
505 REAL :: u1_ad(bd%is-1:bd%ie+1), v1_ad(bd%is-1:bd%ie+1)
507 INTEGER :: is, ie, js, je
508 REAL,
DIMENSION(:, :),
POINTER :: a11, a12, a21, a22
509 REAL,
DIMENSION(:, :),
POINTER :: dx, dy, rdxa, rdya
528 a21 => gridstruct%a21
530 a22 => gridstruct%a22
538 a11 => gridstruct%a11
540 a12 => gridstruct%a12
548 IF (branch .EQ. 0)
THEN 552 v_ad(i, j, k) = v_ad(i, j, k) + 0.5*va_ad(i, j, k)
553 v_ad(i+1, j, k) = v_ad(i+1, j, k) + 0.5*va_ad(i, j, k)
556 u_ad(i, j, k) = u_ad(i, j, k) + 0.5*ua_ad(i, j, k)
557 u_ad(i, j+1, k) = u_ad(i, j+1, k) + 0.5*ua_ad(i, j, k)
565 u1_ad(i) = u1_ad(i) + a11(i, j)*ua_ad(i, j, k) + a21(i, j)*&
567 v1_ad(i) = v1_ad(i) + a12(i, j)*ua_ad(i, j, k) + a22(i, j)*&
572 temp_ad = 2.*v1_ad(i)/(dy(i, j)+dy(i+1, j))
573 wv_ad(i, j) = wv_ad(i, j) + temp_ad
574 wv_ad(i+1, j) = wv_ad(i+1, j) + temp_ad
576 temp_ad0 = 2.*u1_ad(i)/(dx(i, j)+dx(i, j+1))
577 wu_ad(i, j) = wu_ad(i, j) + temp_ad0
578 wu_ad(i, j+1) = wu_ad(i, j+1) + temp_ad0
584 v_ad(i, j, k) = v_ad(i, j, k) + dy(i, j)*wv_ad(i, j)
590 u_ad(i, j, k) = u_ad(i, j, k) + dx(i, j)*wu_ad(i, j)
597 SUBROUTINE c2l_ord2(u, v, ua, va, gridstruct, km, grid_type, bd, &
602 REAL,
INTENT(IN) :: u(bd%isd:bd%ied, bd%jsd:bd%jed+1, km)
603 REAL,
INTENT(IN) :: v(bd%isd:bd%ied+1, bd%jsd:bd%jed, km)
605 LOGICAL,
INTENT(IN) :: do_halo
607 REAL,
INTENT(OUT) :: ua(bd%isd:bd%ied, bd%jsd:bd%jed, km)
608 REAL,
INTENT(OUT) :: va(bd%isd:bd%ied, bd%jsd:bd%jed, km)
611 REAL :: wu(bd%is-1:bd%ie+1, bd%js-1:bd%je+2)
612 REAL :: wv(bd%is-1:bd%ie+2, bd%js-1:bd%je+1)
613 REAL :: u1(bd%is-1:bd%ie+1), v1(bd%is-1:bd%ie+1)
615 INTEGER :: is, ie, js, je
616 REAL,
DIMENSION(:, :),
POINTER :: a11, a12, a21, a22
617 REAL,
DIMENSION(:, :),
POINTER :: dx, dy, rdxa, rdya
618 a11 => gridstruct%a11
619 a12 => gridstruct%a12
620 a21 => gridstruct%a21
621 a22 => gridstruct%a22
624 rdxa => gridstruct%rdxa
625 rdya => gridstruct%rdya
643 wu(i, j) = u(i, j, k)*dx(i, j)
648 wv(i, j) = v(i, j, k)*dy(i, j)
654 u1(i) = 2.*(wu(i, j)+wu(i, j+1))/(dx(i, j)+dx(i, j+1))
655 v1(i) = 2.*(wv(i, j)+wv(i+1, j))/(dy(i, j)+dy(i+1, j))
659 ua(i, j, k) = a11(i, j)*u1(i) + a12(i, j)*v1(i)
660 va(i, j, k) = a21(i, j)*u1(i) + a22(i, j)*v1(i)
667 ua(i, j, k) = 0.5*(u(i, j, k)+u(i, j+1, k))
668 va(i, j, k) = 0.5*(v(i, j, k)+v(i+1, j, k))
675 subroutine g_sum_adm(domain, p, p_ad, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce, g_sum_ad)
677 integer,
intent(IN) :: ifirst, ilast
678 integer,
intent(IN) :: jfirst, jlast, ngc
679 integer,
intent(IN) :: mode
680 logical,
intent(in),
optional :: reproduce
681 real,
intent(IN) :: p(ifirst:ilast,jfirst:jlast)
682 real,
intent(INOUT) :: p_ad(ifirst:ilast,jfirst:jlast)
683 real(kind=R_GRID),
intent(IN) :: area(ifirst-ngc:ilast+ngc,jfirst-ngc:jlast+ngc)
684 type(
domain2d),
intent(IN) :: domain
685 real,
intent(INOUT) :: g_sum_ad
686 real,
dimension(ifirst:ilast,jfirst:jlast) :: gsuma_ad, tmp
687 real,
dimension(ifirst:ilast,jfirst:jlast) :: arg1_ad
690 logical,
SAVE :: g_sum_initialized = .false.
691 real(kind=R_GRID),
SAVE :: global_area
693 if ( .not. g_sum_initialized )
then 695 if ( is_master() )
write(*,*)
'Global Area=',global_area
696 g_sum_initialized = .true.
700 gsum_ad = g_sum_ad / global_area
732 real function g_sum(domain, p, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce)
734 integer,
intent(IN) :: ifirst, ilast
735 integer,
intent(IN) :: jfirst, jlast, ngc
736 integer,
intent(IN) :: mode
737 logical,
intent(in),
optional :: reproduce
738 real,
intent(IN) :: p(ifirst:ilast,jfirst:jlast)
739 real(kind=R_GRID),
intent(IN) :: area(ifirst-ngc:ilast+ngc,jfirst-ngc:jlast+ngc)
740 type(
domain2d),
intent(IN) :: domain
743 logical,
SAVE :: g_sum_initialized = .false.
744 real(kind=R_GRID),
SAVE :: global_area
745 real :: tmp(ifirst:ilast,jfirst:jlast)
747 if ( .not. g_sum_initialized )
then 749 if ( is_master() )
write(*,*)
'Global Area=',global_area
750 g_sum_initialized = .true.
756 if (
present(reproduce) )
then 758 gsum =
mpp_global_sum(domain, p(:,:)*area(ifirst:ilast,jfirst:jlast), &
759 flags=bitwise_efp_sum)
761 gsum =
mpp_global_sum(domain, p(:,:)*area(ifirst:ilast,jfirst:jlast))
770 gsum = gsum + p(i,j)*area(i,j)
773 call mp_reduce_sum(gsum)
777 g_sum = gsum / global_area
real, parameter, public radius
Radius of the Earth [m].
real function, public great_circle_dist(q1, q2, radius)
real, parameter, public omega
Rotation rate of the Earth [1/s].
real(kind=8), parameter, public pi_8
Ratio of circle circumference to diameter [N/A].
subroutine c2l_ord4(u, v, ua, va, gridstruct, npx, npy, km, grid_type, domain, nested, mode, bd)
subroutine, public set_eta(km, ks, ptop, ak, bk)
integer, parameter, public corner
integer, parameter, public f_p
subroutine, public pushcontrol(ctype, field)
subroutine, public g_sum_adm(domain, p, p_ad, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce, g_sum_ad)
integer, parameter, public agrid
subroutine, public c2l_ord2_fwd(u, v, ua, va, gridstruct, km, grid_type, bd, do_halo)
integer, parameter, public ng
subroutine timing_on(blk_name)
subroutine, public c2l_ord2(u, v, ua, va, gridstruct, km, grid_type, bd, do_halo)
real, parameter, public big_number
integer, parameter, public r_grid
real, parameter tiny_number
subroutine grid_utils_end()
real function, public g_sum(domain, p, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce)
subroutine, public cubed_to_latlon(u, v, ua, va, gridstruct, npx, npy, km, mode, grid_type, domain, nested, c2l_ord, bd)
subroutine grid_utils_init(atm, npx, npy, npz, non_ortho, grid_type, c2l_order)
subroutine, public c2l_ord2_bwd(u, u_ad, v, v_ad, ua, ua_ad, va, va_ad, gridstruct, km, grid_type, bd, do_halo)
integer, parameter, public scalar_pair
subroutine, public popcontrol(ctype, field)
integer, parameter, public cgrid_ne
Derived type containing the data.
real, parameter, public ptop_min
real(fp), parameter, public pi
subroutine timing_off(blk_name)