11 #define _GET_VAR1 get_var1_real 13 #define _GET_VAR1 get_var1_double 69 real,
parameter :: CP_AIR =
mapl_cp 84 u_amb, v_amb, t_amb, dp_amb, q_amb, o3_amb, &
85 u_inc, v_inc, t_inc, dp_inc, q_inc, o3_inc)
86 type(fv_atmos_type),
intent(inout) :: Atm(:)
87 type(domain2d),
intent(inout) :: fv_domain
88 real,
intent(inout) :: lon(im), lat(jm)
89 real,
dimension(im,jm,km),
intent(inout) :: u_amb, v_amb, t_amb, dp_amb, q_amb, o3_amb
90 real,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je,Atm(1)%npz),
intent(inout):: &
91 u_inc, v_inc, t_inc, dp_inc, q_inc, o3_inc
93 real,
dimension(:,:) ,
allocatable:: ut_inc, vt_inc
94 real,
dimension(:,:,:),
allocatable:: ud_inc, vd_inc, ua_inc, va_inc
96 real,
allocatable:: pt_c(:,:,:), pt_d(:,:,:)
97 real:: s2c(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je,4)
98 real:: s2c_c(Atm(1)%bd%is:Atm(1)%bd%ie+1,Atm(1)%bd%js:Atm(1)%bd%je,4)
99 real:: s2c_d(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je+1,4)
100 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je):: &
102 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie+1,Atm(1)%bd%js:Atm(1)%bd%je)::&
104 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je+1)::&
106 integer,
parameter :: update_uv_ghost_cells=1
109 integer:: i, j, k, im, jm, km, npz
110 integer:: i1, i2, j1, IMsplit
111 real(kind=R_GRID),
dimension(2):: p1, p2, p3
112 real(kind=R_GRID),
dimension(3):: e1, e2, ex, ey
114 integer :: is, ie, js, je
115 integer :: isd, ied, jsd, jed
130 tmp1d( 1:imsplit) = lon(imsplit+1:im )
131 tmp1d(imsplit+1:im ) = 2.0*pi + lon( 1:imsplit)
137 tmp1d( 1:imsplit) = u_amb(imsplit+1:im ,j,k)
138 tmp1d(imsplit+1:im ) = u_amb( 1:imsplit,j,k)
141 tmp1d( 1:imsplit) = v_amb(imsplit+1:im ,j,k)
142 tmp1d(imsplit+1:im ) = v_amb( 1:imsplit,j,k)
145 tmp1d( 1:imsplit) = t_amb(imsplit+1:im ,j,k)
146 tmp1d(imsplit+1:im ) = t_amb( 1:imsplit,j,k)
149 tmp1d( 1:imsplit) = dp_amb(imsplit+1:im ,j,k)
150 tmp1d(imsplit+1:im ) = dp_amb( 1:imsplit,j,k)
151 dp_amb(:,j,k) = tmp1d
153 tmp1d( 1:imsplit) = q_amb(imsplit+1:im ,j,k)
154 tmp1d(imsplit+1:im ) = q_amb( 1:imsplit,j,k)
157 tmp1d( 1:imsplit) = o3_amb(imsplit+1:im ,j,k)
158 tmp1d(imsplit+1:im ) = o3_amb( 1:imsplit,j,k)
159 o3_amb(:,j,k) = tmp1d
164 call remap_coef( is, ie, js, je, isd, ied, jsd, jed, &
165 im, jm, lon, lat, id1, id2, jdc, s2c, &
166 atm(1)%gridstruct%agrid)
175 allocate (ud_inc(isd:ied , jsd:jed+1, km))
176 allocate (vd_inc(isd:ied+1, jsd:jed , km))
177 allocate ( pt_c(isd:ied+1, jsd:jed , 2))
178 allocate ( pt_d(isd:ied , jsd:jed+1, 2))
179 allocate (ut_inc(is :ie+1 , js :je ))
180 allocate (vt_inc(is :ie+1 , js :je ))
184 isd, ied, jsd, jed, &
185 atm(1)%gridstruct%grid, pt_c, pt_d)
189 call remap_coef( is, ie+1, js, je, isd, ied+1, jsd, jed, &
190 im, jm, lon, lat, id1_c, id2_c, jdc_c, s2c_c, &
199 ut_inc(i,j) = s2c_c(i,j,1)*u_amb(i1,j1 ,k) + &
200 s2c_c(i,j,2)*u_amb(i2,j1 ,k) + &
201 s2c_c(i,j,3)*u_amb(i2,j1+1,k) + &
202 s2c_c(i,j,4)*u_amb(i1,j1+1,k)
203 vt_inc(i,j) = s2c_c(i,j,1)*v_amb(i1,j1 ,k) + &
204 s2c_c(i,j,2)*v_amb(i2,j1 ,k) + &
205 s2c_c(i,j,3)*v_amb(i2,j1+1,k) + &
206 s2c_c(i,j,4)*v_amb(i1,j1+1,k)
207 p1(:) = atm(1)%gridstruct%grid(i,j ,1:2)
208 p2(:) = atm(1)%gridstruct%grid(i,j+1,1:2)
212 vd_inc(i,j,k) = ut_inc(i,j)*
inner_prod(e2,ex) + &
218 deallocate ( ut_inc, vt_inc )
222 call remap_coef( is, ie, js, je+1, isd, ied, jsd, jed+1, &
223 im, jm, lon, lat, id1_d, id2_d, jdc_d, s2c_d, &
226 allocate ( ut_inc(is:ie,js:je+1) )
227 allocate ( vt_inc(is:ie,js:je+1) )
235 ut_inc(i,j) = s2c_d(i,j,1)*u_amb(i1,j1 ,k) + &
236 s2c_d(i,j,2)*u_amb(i2,j1 ,k) + &
237 s2c_d(i,j,3)*u_amb(i2,j1+1,k) + &
238 s2c_d(i,j,4)*u_amb(i1,j1+1,k)
239 vt_inc(i,j) = s2c_d(i,j,1)*v_amb(i1,j1 ,k) + &
240 s2c_d(i,j,2)*v_amb(i2,j1 ,k) + &
241 s2c_d(i,j,3)*v_amb(i2,j1+1,k) + &
242 s2c_d(i,j,4)*v_amb(i1,j1+1,k)
243 p1(:) = atm(1)%gridstruct%grid(i, j,1:2)
244 p2(:) = atm(1)%gridstruct%grid(i+1,j,1:2)
248 ud_inc(i,j,k) = ut_inc(i,j)*
inner_prod(e1,ex) + &
254 deallocate ( ut_inc, vt_inc )
257 allocate (ua_inc(isd:ied , jsd:jed , km))
258 allocate (va_inc(isd:ied , jsd:jed , km))
259 call cubed_to_latlon(ud_inc, vd_inc, ua_inc, va_inc, atm(1)%gridstruct, &
260 atm(1)%npx, atm(1)%npy, atm(1)%npz, update_uv_ghost_cells, atm(1)%gridstruct%grid_type, &
261 fv_domain, atm(1)%gridstruct%nested, atm(1)%flagstruct%c2l_ord, atm(1)%bd)
262 u_inc(is:ie,js:je,1:npz) = ua_inc(is:ie,js:je,1:npz)
263 v_inc(is:ie,js:je,1:npz) = va_inc(is:ie,js:je,1:npz)
264 deallocate ( ua_inc, va_inc )
266 u_inc(is:ie,js:je,1:npz) = ud_inc(is:ie,js:je,1:npz)
267 v_inc(is:ie,js:je,1:npz) = vd_inc(is:ie,js:je,1:npz)
271 deallocate ( pt_c, pt_d )
272 deallocate ( ud_inc, vd_inc )
277 real,
dimension(1:im, 1:jm, 1:km),
intent(in ) :: amb
278 real,
dimension(is:ie,js:je,1:km),
intent( out) :: inc
286 inc(i,j,k) = s2c(i,j,1)*amb(i1,j1 ,k) + &
287 s2c(i,j,2)*amb(i2,j1 ,k) + &
288 s2c(i,j,3)*amb(i2,j1+1,k) + &
289 s2c(i,j,4)*amb(i1,j1+1,k)
305 type(
domain2d),
intent(inout) :: fv_domain
310 character(len=128) :: fname
311 real(kind=4),
allocatable:: wk1(:), wk2(:,:), wk3(:,:,:)
312 real(kind=4),
allocatable:: wk3_u(:,:,:), wk3_v(:,:,:)
313 real,
allocatable:: tp(:,:,:), qp(:,:,:)
314 real,
dimension(:,:,:),
allocatable:: u_inc, v_inc, ud_inc, vd_inc
315 real,
allocatable:: lat(:), lon(:)
316 real,
allocatable:: pt_c(:,:,:), pt_d(:,:,:)
317 real:: s2c(atm(1)%bd%is:atm(1)%bd%ie,atm(1)%bd%js:atm(1)%bd%je,4)
318 real:: s2c_c(atm(1)%bd%is:atm(1)%bd%ie+1,atm(1)%bd%js:atm(1)%bd%je,4)
319 real:: s2c_d(atm(1)%bd%is:atm(1)%bd%ie,atm(1)%bd%js:atm(1)%bd%je+1,4)
320 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je):: &
322 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie+1,Atm(1)%bd%js:Atm(1)%bd%je)::&
324 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je+1)::&
327 integer:: i, j, k, im, jm, km, npz, npt
328 integer:: i1, i2, j1, ncid
331 real(kind=R_GRID),
dimension(2):: p1, p2, p3
332 real(kind=R_GRID),
dimension(3):: e1, e2, ex, ey
335 integer :: is, ie, js, je
336 integer :: isd, ied, jsd, jed
337 integer :: sphum, liq_wat, o3mr
352 fname =
'INPUT/'//atm(1)%flagstruct%res_latlon_dynamics
354 if( file_exist(fname) )
then 360 im = tsize(1); jm = tsize(2); km = tsize(3)
363 if (is_master()) print *,
'km = ', km
365 '==> Error in read_da_inc: km is not equal to npz')
368 if(is_master())
write(*,*) fname,
' DA increment dimensions:', tsize
373 call _get_var1 (ncid,
'lon', im, lon )
374 call _get_var1 (ncid,
'lat', jm, lat )
378 lon(i) = lon(i) * deg2rad
381 lat(j) = lat(j) * deg2rad
385 call mpp_error(fatal,
'==> Error in read_da_inc: Expected file '&
386 //trim(fname)//
' for DA increment does not exist')
390 call remap_coef( is, ie, js, je, isd, ied, jsd, jed, &
391 im, jm, lon, lat, id1, id2, jdc, s2c, &
392 atm(1)%gridstruct%agrid)
395 jbeg = jm-1; jend = 2
400 jend =
max(jend, j1+1)
409 allocate ( wk3(1:im,jbeg:jend, 1:km) )
410 allocate ( tp(is:ie,js:je,km) )
422 allocate (pt_c(isd:ied+1,jsd:jed ,2))
423 allocate (pt_d(isd:ied ,jsd:jed+1,2))
424 allocate (ud_inc(is:ie , js:je+1, km))
425 allocate (vd_inc(is:ie+1, js:je , km))
429 isd, ied, jsd, jed, &
430 atm(1)%gridstruct%grid, pt_c, pt_d)
434 call remap_coef( is, ie+1, js, je, isd, ied+1, jsd, jed, &
435 im, jm, lon, lat, id1_c, id2_c, jdc_c, s2c_c, &
439 jbeg = jm-1; jend = 2
444 jend =
max(jend, j1+1)
448 allocate ( wk3_u(1:im,jbeg:jend, 1:km) )
449 allocate ( wk3_v(1:im,jbeg:jend, 1:km) )
450 allocate ( u_inc(is:ie+1,js:je,km) )
451 allocate ( v_inc(is:ie+1,js:je,km) )
453 call get_var3_r4( ncid,
'u_inc', 1,im, jbeg,jend, 1,km, wk3_u )
454 call get_var3_r4( ncid,
'v_inc', 1,im, jbeg,jend, 1,km, wk3_v )
462 u_inc(i,j,k) = s2c_c(i,j,1)*wk3_u(i1,j1 ,k) + &
463 s2c_c(i,j,2)*wk3_u(i2,j1 ,k) + &
464 s2c_c(i,j,3)*wk3_u(i2,j1+1,k) + &
465 s2c_c(i,j,4)*wk3_u(i1,j1+1,k)
466 v_inc(i,j,k) = s2c_c(i,j,1)*wk3_v(i1,j1 ,k) + &
467 s2c_c(i,j,2)*wk3_v(i2,j1 ,k) + &
468 s2c_c(i,j,3)*wk3_v(i2,j1+1,k) + &
469 s2c_c(i,j,4)*wk3_v(i1,j1+1,k)
470 p1(:) = atm(1)%gridstruct%grid(i,j ,1:2)
471 p2(:) = atm(1)%gridstruct%grid(i,j+1,1:2)
475 vd_inc(i,j,k) = u_inc(i,j,k)*
inner_prod(e2,ex) + &
477 atm(1)%v(i,j,k) = atm(1)%v(i,j,k) + vd_inc(i,j,k)
482 deallocate ( u_inc, v_inc )
483 deallocate ( wk3_u, wk3_v )
487 call remap_coef( is, ie, js, je+1, isd, ied, jsd, jed+1, &
488 im, jm, lon, lat, id1_d, id2_d, jdc_d, s2c_d, &
492 jbeg = jm-1; jend = 2
497 jend =
max(jend, j1+1)
501 allocate ( wk3_u(1:im,jbeg:jend, 1:km) )
502 allocate ( wk3_v(1:im,jbeg:jend, 1:km) )
503 allocate ( u_inc(is:ie,js:je+1,km) )
504 allocate ( v_inc(is:ie,js:je+1,km) )
506 call get_var3_r4( ncid,
'u_inc', 1,im, jbeg,jend, 1,km, wk3_u )
507 call get_var3_r4( ncid,
'v_inc', 1,im, jbeg,jend, 1,km, wk3_v )
515 u_inc(i,j,k) = s2c_d(i,j,1)*wk3_u(i1,j1 ,k) + &
516 s2c_d(i,j,2)*wk3_u(i2,j1 ,k) + &
517 s2c_d(i,j,3)*wk3_u(i2,j1+1,k) + &
518 s2c_d(i,j,4)*wk3_u(i1,j1+1,k)
519 v_inc(i,j,k) = s2c_d(i,j,1)*wk3_v(i1,j1 ,k) + &
520 s2c_d(i,j,2)*wk3_v(i2,j1 ,k) + &
521 s2c_d(i,j,3)*wk3_v(i2,j1+1,k) + &
522 s2c_d(i,j,4)*wk3_v(i1,j1+1,k)
523 p1(:) = atm(1)%gridstruct%grid(i, j,1:2)
524 p2(:) = atm(1)%gridstruct%grid(i+1,j,1:2)
528 ud_inc(i,j,k) = u_inc(i,j,k)*
inner_prod(e1,ex) + &
530 atm(1)%u(i,j,k) = atm(1)%u(i,j,k) + ud_inc(i,j,k)
535 deallocate ( u_inc, v_inc )
536 deallocate ( wk3_u, wk3_v )
546 deallocate ( pt_c, pt_d, ud_inc, vd_inc )
548 deallocate ( lon, lat )
553 character(len=*),
intent(in) :: field_name
554 real,
dimension(isd:ied,jsd:jed,1:km),
intent(inout) :: var
556 call get_var3_r4( ncid, field_name, 1,im, jbeg,jend, 1,km, wk3 )
564 tp(i,j,k) = s2c(i,j,1)*wk3(i1,j1 ,k) + s2c(i,j,2)*wk3(i2,j1 ,k)+&
565 s2c(i,j,3)*wk3(i2,j1+1,k) + s2c(i,j,4)*wk3(i1,j1+1,k)
566 var(i,j,k) = var(i,j,k)+tp(i,j,k)
577 subroutine remap_coef( is, ie, js, je, isd, ied, jsd, jed, &
578 im, jm, lon, lat, id1, id2, jdc, s2c, agrid )
580 integer,
intent(in):: is, ie, js, je, isd, ied, jsd, jed
581 integer,
intent(in):: im, jm
582 real,
intent(in):: lon(im), lat(jm)
583 real,
intent(out):: s2c(is:ie,js:je,4)
584 integer,
intent(out),
dimension(is:ie,js:je):: id1, id2, jdc
585 real,
intent(in):: agrid(isd:ied,jsd:jed,2)
590 integer i,j, i1, i2, jc, i0, j0
593 rdlon(i) = 1. / (lon(i+1) - lon(i))
595 rdlon(im) = 1. / (lon(1) + 2.*pi - lon(im))
598 rdlat(j) = 1. / (lat(j+1) - lat(j))
606 if ( agrid(i,j,1)>lon(im) )
then 608 a1 = (agrid(i,j,1)-lon(im)) * rdlon(im)
609 elseif ( agrid(i,j,1)<lon(1) )
then 611 a1 = (agrid(i,j,1)+2.*pi-lon(im)) * rdlon(im)
614 if ( agrid(i,j,1)>=lon(i0) .and. agrid(i,j,1)<=lon(i0+1) )
then 616 a1 = (agrid(i,j,1)-lon(i1)) * rdlon(i0)
623 if ( agrid(i,j,2)<lat(1) )
then 626 elseif ( agrid(i,j,2)>lat(jm) )
then 631 if ( agrid(i,j,2)>=lat(j0) .and. agrid(i,j,2)<=lat(j0+1) )
then 633 b1 = (agrid(i,j,2)-lat(jc)) * rdlat(jc)
640 if ( a1<0.0 .or. a1>1.0 .or. b1<0.0 .or. b1>1.0 )
then 641 write(*,*)
'gid=', mpp_pe(), i,j,a1, b1
644 s2c(i,j,1) = (1.-a1) * (1.-b1)
645 s2c(i,j,2) = a1 * (1.-b1)
647 s2c(i,j,4) = (1.-a1) * b1
658 isd, ied, jsd, jed, &
660 integer,
intent(in) :: is, ie, js, je, isd, ied, jsd, jed
661 real,
dimension(isd:ied+1,jsd:jed+1,2),
intent(in) :: pt_b
662 real,
dimension(isd:ied+1,jsd:jed ,2),
intent(out) :: pt_c
663 real,
dimension(isd:ied ,jsd:jed+1,2),
intent(out) :: pt_d
665 real(kind=R_GRID),
dimension(2):: p1, p2, p3
670 p1(:) = pt_b(i, j,1:2)
671 p2(:) = pt_b(i+1,j,1:2)
673 pt_d(i,j,1:2) = p3(:)
678 p1(:) = pt_b(i,j ,1:2)
679 p2(:) = pt_b(i,j+1,1:2)
681 pt_c(i,j,1:2) = p3(:)
real, parameter, public mapl_omega
integer, parameter, public model_atmos
real, parameter, public omega
Rotation rate of the Earth [1/s].
subroutine, public get_unit_vect2(e1, e2, uc)
subroutine, public open_ncfile(iflnm, ncid)
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, public get_var1_real(ncid, var1_name, im, var1, var_exist)
real, parameter, public mapl_rvap
subroutine get_inc_on_3d_scalar(amb, inc)
real(kind=mapl_r8), parameter, public mapl_pi_r8
subroutine geos_get_da_increments(Atm, fv_domain, lon, lat, im, jm, km, u_amb, v_amb, t_amb, dp_amb, q_amb, o3_amb, u_inc, v_inc, t_inc, dp_inc, q_inc, o3_inc)
void mid_pt_sphere(const double *p1, const double *p2, double *pm)
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, public get_number_tracers(model, num_tracers, num_prog, num_diag, num_family)
subroutine remap_coef(is, ie, js, je, isd, ied, jsd, jed, im, jm, lon, lat, id1, id2, jdc, s2c, agrid)
real, parameter, public mapl_cp
subroutine, public cubed_to_latlon(u, v, ua, va, gridstruct, npx, npy, km, mode, grid_type, domain, nested, c2l_ord, bd)
subroutine get_staggered_grid(is, ie, js, je, isd, ied, jsd, jed, pt_b, pt_c, pt_d)
real, parameter, public mapl_alhl
subroutine apply_inc_on_3d_scalar(field_name, var)
real, parameter, public mapl_kappa
subroutine, public read_da_inc(Atm, fv_domain)
description
int field_exist(const char *file, const char *name)
real, parameter, public rvgas
Gas constant for water vapor [J/kg/deg].
integer, parameter, public ng
real, parameter, public mapl_radius
real, parameter, public cp_air
Specific heat capacity of dry air at constant pressure [J/kg/deg].
integer, parameter, public r_grid
subroutine, public get_latlon_vector(pp, elon, elat)
subroutine, public close_ncfile(ncid)
real, parameter, public grav
Acceleration due to gravity [m/s^2].
real function, public g_sum(domain, p, ifirst, ilast, jfirst, jlast, ngc, area, mode, reproduce)
subroutine, public get_var1_double(ncid, var1_name, im, var1, var_exist)
subroutine, public get_ncdim1(ncid, var1_name, im)
subroutine, public get_tracer_names(model, n, name, longname, units, err_msg)
real, parameter, public mapl_rgas
real, parameter, public mapl_grav
real function, public inner_prod(v1, v2)
real, parameter, public kappa
RDGAS / CP_AIR [dimensionless].
real(fp), parameter, public pi