41 #define _GET_VAR1 get_var1_real 43 #define _GET_VAR1 get_var1_double 109 use fms_mod
, only: file_exist, read_data, &
110 field_exist, write_version_number
111 use mpp_mod
, only: mpp_error, fatal, note, mpp_pe
112 use mpp_domains_mod
, only: mpp_get_tile_id, &
114 mpp_update_domains, &
117 use tracer_manager_mod
,only: get_tracer_names, &
118 get_number_tracers, &
120 use field_manager_mod
, only: model_atmos
122 use constants_mod
, only: pi=>pi_8, omega, grav, kappa, &
161 type(domain2d),
intent(inout) :: fv_domain
166 character(len=128) :: fname
167 real(kind=4),
allocatable:: wk1(:), wk2(:,:), wk3(:,:,:)
168 real(kind=4),
allocatable:: wk3_u(:,:,:), wk3_v(:,:,:)
169 real,
allocatable:: tp(:,:,:), qp(:,:,:)
170 real,
dimension(:,:,:),
allocatable:: u_inc, v_inc, ud_inc, vd_inc
171 real,
allocatable:: lat(:), lon(:)
172 real,
allocatable:: pt_c(:,:,:), pt_d(:,:,:)
173 real:: s2c(atm(1)%bd%is:atm(1)%bd%ie,atm(1)%bd%js:atm(1)%bd%je,4)
174 real:: s2c_c(atm(1)%bd%is:atm(1)%bd%ie+1,atm(1)%bd%js:atm(1)%bd%je,4)
175 real:: s2c_d(atm(1)%bd%is:atm(1)%bd%ie,atm(1)%bd%js:atm(1)%bd%je+1,4)
176 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je):: &
178 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie+1,Atm(1)%bd%js:Atm(1)%bd%je)::&
180 integer,
dimension(Atm(1)%bd%is:Atm(1)%bd%ie,Atm(1)%bd%js:Atm(1)%bd%je+1)::&
183 integer:: i, j, k, im, jm, km, npz, npt
184 integer:: i1, i2, j1, ncid
187 real(kind=R_GRID),
dimension(2):: p1, p2, p3
188 real(kind=R_GRID),
dimension(3):: e1, e2, ex, ey
191 integer :: is, ie, js, je
192 integer :: isd, ied, jsd, jed
193 integer :: sphum, liq_wat
195 integer :: spfo, spfo2, spfo3
213 fname =
'INPUT/'//atm(1)%flagstruct%res_latlon_dynamics
215 if( file_exist(fname) )
then 221 im = tsize(1); jm = tsize(2); km = tsize(3)
224 if (is_master()) print *,
'km = ', km
225 call mpp_error(fatal, &
226 '==> Error in read_da_inc: km is not equal to npz')
229 if(is_master())
write(*,*) fname,
' DA increment dimensions:', tsize
234 call _get_var1 (ncid,
'lon', im, lon )
235 call _get_var1 (ncid,
'lat', jm, lat )
239 lon(i) = lon(i) * deg2rad
242 lat(j) = lat(j) * deg2rad
246 call mpp_error(fatal,
'==> Error in read_da_inc: Expected file '&
247 //trim(fname)//
' for DA increment does not exist')
252 im, jm, lon, lat, id1, id2, jdc, s2c, &
253 atm(1)%gridstruct%agrid(is:ie,js:je,:))
256 jbeg = jm-1; jend = 2
261 jend = max(jend, j1+1)
265 sphum = get_tracer_index(model_atmos,
'sphum')
267 spfo3 = get_tracer_index(model_atmos,
'spfo3')
268 spfo = get_tracer_index(model_atmos,
'spfo')
269 spfo2 = get_tracer_index(model_atmos,
'spfo2')
271 o3mr = get_tracer_index(model_atmos,
'o3mr')
273 liq_wat = get_tracer_index(model_atmos,
'liq_wat')
276 allocate ( wk3(1:im,jbeg:jend, 1:km) )
277 allocate ( tp(is:ie,js:je,km) )
281 if (.not. atm(1)%flagstruct%hydrostatic)
then 298 allocate (pt_c(is:ie+1,js:je ,2))
299 allocate (pt_d(is:ie ,js:je+1,2))
300 allocate (ud_inc(is:ie , js:je+1, km))
301 allocate (vd_inc(is:ie+1, js:je , km))
305 isd, ied, jsd, jed, &
306 atm(1)%gridstruct%grid, pt_c, pt_d)
311 im, jm, lon, lat, id1_c, id2_c, jdc_c, s2c_c, &
315 jbeg = jm-1; jend = 2
320 jend = max(jend, j1+1)
324 allocate ( wk3_u(1:im,jbeg:jend, 1:km) )
325 allocate ( wk3_v(1:im,jbeg:jend, 1:km) )
326 allocate ( u_inc(is:ie+1,js:je,km) )
327 allocate ( v_inc(is:ie+1,js:je,km) )
329 call get_var3_r4( ncid,
'u_inc', 1,im, jbeg,jend, 1,km, wk3_u )
330 call get_var3_r4( ncid,
'v_inc', 1,im, jbeg,jend, 1,km, wk3_v )
338 u_inc(i,j,k) = s2c_c(i,j,1)*wk3_u(i1,j1 ,k) + &
339 s2c_c(i,j,2)*wk3_u(i2,j1 ,k) + &
340 s2c_c(i,j,3)*wk3_u(i2,j1+1,k) + &
341 s2c_c(i,j,4)*wk3_u(i1,j1+1,k)
342 v_inc(i,j,k) = s2c_c(i,j,1)*wk3_v(i1,j1 ,k) + &
343 s2c_c(i,j,2)*wk3_v(i2,j1 ,k) + &
344 s2c_c(i,j,3)*wk3_v(i2,j1+1,k) + &
345 s2c_c(i,j,4)*wk3_v(i1,j1+1,k)
346 p1(:) = atm(1)%gridstruct%grid(i,j ,1:2)
347 p2(:) = atm(1)%gridstruct%grid(i,j+1,1:2)
351 vd_inc(i,j,k) = u_inc(i,j,k)*
inner_prod(e2,ex) + &
353 atm(1)%v(i,j,k) = atm(1)%v(i,j,k) + vd_inc(i,j,k)
358 deallocate ( u_inc, v_inc )
359 deallocate ( wk3_u, wk3_v )
364 im, jm, lon, lat, id1_d, id2_d, jdc_d, s2c_d, &
368 jbeg = jm-1; jend = 2
373 jend = max(jend, j1+1)
377 allocate ( wk3_u(1:im,jbeg:jend, 1:km) )
378 allocate ( wk3_v(1:im,jbeg:jend, 1:km) )
379 allocate ( u_inc(is:ie,js:je+1,km) )
380 allocate ( v_inc(is:ie,js:je+1,km) )
382 call get_var3_r4( ncid,
'u_inc', 1,im, jbeg,jend, 1,km, wk3_u )
383 call get_var3_r4( ncid,
'v_inc', 1,im, jbeg,jend, 1,km, wk3_v )
391 u_inc(i,j,k) = s2c_d(i,j,1)*wk3_u(i1,j1 ,k) + &
392 s2c_d(i,j,2)*wk3_u(i2,j1 ,k) + &
393 s2c_d(i,j,3)*wk3_u(i2,j1+1,k) + &
394 s2c_d(i,j,4)*wk3_u(i1,j1+1,k)
395 v_inc(i,j,k) = s2c_d(i,j,1)*wk3_v(i1,j1 ,k) + &
396 s2c_d(i,j,2)*wk3_v(i2,j1 ,k) + &
397 s2c_d(i,j,3)*wk3_v(i2,j1+1,k) + &
398 s2c_d(i,j,4)*wk3_v(i1,j1+1,k)
399 p1(:) = atm(1)%gridstruct%grid(i, j,1:2)
400 p2(:) = atm(1)%gridstruct%grid(i+1,j,1:2)
404 ud_inc(i,j,k) = u_inc(i,j,k)*
inner_prod(e1,ex) + &
406 atm(1)%u(i,j,k) = atm(1)%u(i,j,k) + ud_inc(i,j,k)
411 deallocate ( u_inc, v_inc )
412 deallocate ( wk3_u, wk3_v )
422 deallocate ( pt_c, pt_d, ud_inc, vd_inc )
424 deallocate ( lon, lat )
431 character(len=*),
intent(in) :: field_name
432 real,
dimension(isd:ied,jsd:jed,1:km),
intent(inout) :: var
437 call get_var3_r4( ncid, field_name, 1,im, jbeg,jend, 1,km, wk3 )
439 if (is_master()) print *,
'warning: no increment for ',trim(field_name),
' found, assuming zero' 449 tp(i,j,k) = s2c(i,j,1)*wk3(i1,j1 ,k) + s2c(i,j,2)*wk3(i2,j1 ,k)+&
450 s2c(i,j,3)*wk3(i2,j1+1,k) + s2c(i,j,4)*wk3(i1,j1+1,k)
451 var(i,j,k) = var(i,j,k)+tp(i,j,k)
464 im, jm, lon, lat, id1, id2, jdc, s2c, agrid )
466 integer,
intent(in):: is, ie, js, je
467 integer,
intent(in):: im, jm
468 real,
intent(in):: lon(im), lat(jm)
469 real,
intent(out):: s2c(is:ie,js:je,4)
470 integer,
intent(out),
dimension(is:ie,js:je):: id1, id2, jdc
471 real,
intent(in):: agrid(is:ie,js:je,2)
476 integer i,j, i1, i2, jc, i0, j0
478 rdlon(i) = 1. / (lon(i+1) - lon(i))
480 rdlon(im) = 1. / (lon(1) + 2.*pi - lon(im))
483 rdlat(j) = 1. / (lat(j+1) - lat(j))
491 if ( agrid(i,j,1)>lon(im) )
then 493 a1 = (agrid(i,j,1)-lon(im)) * rdlon(im)
494 elseif ( agrid(i,j,1)<lon(1) )
then 496 a1 = (agrid(i,j,1)+2.*pi-lon(im)) * rdlon(im)
499 if ( agrid(i,j,1)>=lon(i0) .and. agrid(i,j,1)<=lon(i0+1) )
then 501 a1 = (agrid(i,j,1)-lon(i1)) * rdlon(i0)
508 if ( agrid(i,j,2)<lat(1) )
then 511 elseif ( agrid(i,j,2)>lat(jm) )
then 516 if ( agrid(i,j,2)>=lat(j0) .and. agrid(i,j,2)<=lat(j0+1) )
then 518 b1 = (agrid(i,j,2)-lat(jc)) * rdlat(jc)
525 if ( a1<0.0 .or. a1>1.0 .or. b1<0.0 .or. b1>1.0 )
then 526 write(*,*)
'gid=', mpp_pe(), i,j,a1, b1
529 s2c(i,j,1) = (1.-a1) * (1.-b1)
530 s2c(i,j,2) = a1 * (1.-b1)
532 s2c(i,j,4) = (1.-a1) * b1
546 isd, ied, jsd, jed, &
548 integer,
intent(in) :: is, ie, js, je
549 integer,
intent(in) :: isd, ied, jsd, jed
550 real,
dimension(isd:ied+1,jsd:jed+1,2),
intent(in) :: pt_b
551 real,
dimension(is:ie+1,js:je ,2),
intent(out) :: pt_c
552 real,
dimension(is:ie ,js:je+1,2),
intent(out) :: pt_d
554 real(kind=R_GRID),
dimension(2):: p1, p2, p3
559 p1(:) = pt_b(i, j,1:2)
560 p2(:) = pt_b(i+1,j,1:2)
562 pt_d(i,j,1:2) = p3(:)
567 p1(:) = pt_b(i,j ,1:2)
568 p2(:) = pt_b(i,j+1,1:2)
570 pt_c(i,j,1:2) = p3(:)
subroutine, public mid_pt_sphere(p1, p2, pm)
subroutine, public get_var3_r4(ncid, var3_name, is, ie, js, je, ks, ke, var3, time_slice)
The module 'fv_mp_mod' is a single program multiple data (SPMD) parallel decompostion/communication m...
The type 'fv_grid_type' is made up of grid-dependent information from fv_grid_tools and fv_grid_utils...
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'.
real function, public inner_prod(v1, v2)
subroutine, public get_latlon_vector(pp, elon, elat)
subroutine, public get_unit_vect2(e1, e2, uc)
integer, parameter, public r_grid
subroutine, public get_var1_real(ncid, var1_name, im, var1, var_exist)
subroutine, public get_var1_double(ncid, var1_name, im, var1, var_exist)
The 'get_var' subroutines read in variables from netcdf files.
real, parameter, public ptop_min
The module 'fv_arrays' contains the 'fv_atmos_type' and associated datatypes.
The module 'sim_nc' is a netcdf file reader.
subroutine apply_inc_on_3d_scalar(field_name, var)
The subroutine 'apply_inc_on3d_scalar' applies the input increments to the prognostic variables...
subroutine, public get_var2_real(ncid, var_name, im, jm, var2)
'The module 'tread_da_increment' contains routines for treating the increments of the prognostic vari...
subroutine, public open_ncfile(iflnm, ncid)
integer, parameter, public ng
subroutine get_staggered_grid(is, ie, js, je, isd, ied, jsd, jed, pt_b, pt_c, pt_d)
The subroutine 'get_staggered_grid' gets the lat-lon locations of the staggered points.
The module 'fv_grid_utils' contains routines for setting up and computing grid-related quantities...
subroutine, public read_da_inc(Atm, fv_domain)
The subroutine 'read_da_inc' reads the increments of the diagnostic variables from the DA-generated f...
subroutine, public remap_coef(is, ie, js, je, im, jm, lon, lat, id1, id2, jdc, s2c, agrid)
The subroutine 'remap_coef' calculates the coefficients for horizonal regridding. ...
subroutine, public get_ncdim1(ncid, var1_name, im)
subroutine, public cubed_to_latlon(u, v, ua, va, gridstruct, npx, npy, km, mode, grid_type, domain, nested, c2l_ord, bd)
subroutine, public check_var_exists(ncid, var_name, status)
subroutine, public close_ncfile(ncid)