@@ -95,6 +95,7 @@ module atmosphere_mod
9595use coarse_graining_mod, only: coarse_graining_init
9696use coarse_grained_diagnostics_mod, only: fv_coarse_diag_init, fv_coarse_diag
9797use coarse_grained_restart_files_mod, only: fv_coarse_restart_init
98+ use surf_diff_mod, only: surf_diff_type, compute_nu, compute_e, vert_diff_down_2
9899
99100implicit none
100101private
@@ -153,6 +154,7 @@ module atmosphere_mod
153154public :: atmosphere_coarse_graining_parameters
154155public :: atmosphere_coarsening_strategy
155156
157+ public :: populate_surf_diff, surf_diff_type
156158!- ----------------------------------------------------------------------
157159! version number of this module
158160! Include variable "version" to be written to log file.
@@ -1925,6 +1927,134 @@ subroutine atmosphere_coarsening_strategy(coarsening_strategy)
19251927 coarsening_strategy = Atm(mygrid)% coarse_graining% strategy
19261928 end subroutine atmosphere_coarsening_strategy
19271929
1930+ subroutine populate_surf_diff (surf_diff , IPD_Data , IAU_Data , Atm_block )
1931+ type (surf_diff_type), intent (in ) :: Surf_diff
1932+ type (IPD_data_type), intent (in ) :: IPD_Data(:)
1933+ type (IAU_external_data_type), intent (in ) :: IAU_Data
1934+ type (block_control_type), intent (in ) :: Atm_block
1935+
1936+ !- -- local variables ---
1937+ integer :: nb, blen, ix, i, j, k, k1, npz
1938+ integer :: isd,ied,jsd,jed
1939+ real :: rdt
1940+ real , dimension (isc:iec,jsc:jec,1 :atm(mygrid)% npz) :: p_full, z_full
1941+ real , dimension (isc:iec,jsc:jec,1 :atm(mygrid)% npz+1 ) :: p_half, z_half
1942+
1943+ ! necessary as some surf_diff calls will need variables over the compute domain only
1944+ real , dimension (isc:iec,jsc:jec,1 :atm(mygrid)% npz) :: diff_local, nu, local_delp, local_pt, local_q
1945+
1946+ real , dimension (isc:iec,jsc:jec,1 :atm(mygrid)% npz) :: e, a, b, c, g
1947+ real , dimension (isc:iec,jsc:jec,1 :atm(mygrid)% npz) :: temp_tend, trac_tend, local_f1
1948+ real , dimension (isc:iec,jsc:jec,1 :atm(mygrid)% npz) :: temp, e_global, f_t_global, f_q_global
1949+ real , dimension (isc:iec,jsc:jec) :: mu_delt_n, nu_n, e_n1, f_t_delt_n1, f_q_delt_n1, delta_t_n, delta_q_n
1950+
1951+ rdt= 1 ./ dt_atmos
1952+
1953+ npz= atm(mygrid)% npz
1954+
1955+ p_full(:,:,:)= 0 .
1956+ z_full(:,:,:)= 0 .
1957+ p_half(:,:,:)= 0 .
1958+ z_half(:,:,:)= 0 .
1959+
1960+ diff_local(:,:,:)= 0 .
1961+ temp_tend(:,:,:)= 0 .
1962+ trac_tend(:,:,:)= 0 .
1963+
1964+ Surf_diff % dtmass = 0.0
1965+ Surf_diff % dflux_t = 0.0
1966+ Surf_diff % delta_t = 0.0
1967+ Surf_diff % delta_u = 0.0
1968+ Surf_diff % delta_v = 0.0
1969+ Surf_diff % dflux_tr = 0.0
1970+ Surf_diff % delta_tr = 0.0
1971+
1972+ ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1973+ ! Populate surf_diff, this is for some variables and derivatives
1974+ ! at the bottom atmospheric layer for implicit land coupling
1975+ ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1976+ do k= 1 ,npz
1977+ do j= jsc,jec
1978+ do i= isc,iec
1979+ local_delp(i,j,k) = Atm(mygrid)% delp(i,j,k)
1980+ local_pt(i,j,k) = Atm(mygrid)% pt(i,j,k)
1981+ local_q(i,j,k) = Atm(mygrid)% q(i,j,k,1 )
1982+ temp(i,j,k)= atm(mygrid)% pt(i,j,k) ! + z_full(i,j,k)*(grav/cp_air)
1983+ enddo
1984+ enddo
1985+ enddo
1986+
1987+ do j= jsc,jec
1988+ do i= isc,iec
1989+ z_half(i,j,npz+1 ) = Atm(mygrid)% phis(i,j) * (1 ./ grav)
1990+ enddo
1991+ enddo
1992+
1993+ do k= npz,1 ,- 1
1994+ do j= jsc,jec
1995+ do i= isc,iec
1996+ p_half(i,j,k)= Atm(mygrid)% pe(i,k,j)
1997+ p_full(i,j,k) = Atm(mygrid)% delp(i,j,k)/ (Atm(mygrid)% peln(i,k+1 ,j)- Atm(mygrid)% peln(i,k,j))
1998+ z_half(i,j,k) = z_half(i,j,k+1 ) - Atm(mygrid)% delz(i,j,k)
1999+ z_full(i,j,k) = 0.5 * (z_half(i,j,k) + z_half(i,j,k+1 ))
2000+ enddo
2001+ enddo
2002+ enddo
2003+
2004+ ! f1 and f2 are flipped !!!
2005+ do k= 1 ,npz
2006+ k1= npz- k+1
2007+ do nb = 1 ,Atm_block% nblks
2008+ blen = Atm_block% blksz(nb)
2009+ do ix = 1 , blen
2010+ i = Atm_block% index (nb)% ii(ix)
2011+ j = Atm_block% index (nb)% jj(ix)
2012+ diff_local(i,j,k) = IPD_data(nb)% Statemid% dkt(ix,k1)
2013+ temp_tend(i,j,k) = IPD_data(nb)% Statemid% stored_dtdt(ix,k1)
2014+ trac_tend(i,j,k) = IPD_data(nb)% Statemid% stored_dqdt(ix,k1,1 )
2015+ enddo
2016+ enddo
2017+ enddo
2018+
2019+ do k= npz,npz
2020+ k1= npz- k+1
2021+ do nb = 1 ,Atm_block% nblks
2022+ blen = Atm_block% blksz(nb)
2023+ do ix = 1 , blen
2024+ i = Atm_block% index (nb)% ii(ix)
2025+ j = Atm_block% index (nb)% jj(ix)
2026+ temp_tend(i,j,k) = IPD_data(nb)% Statemid% stored_dtdt(ix,k1) + (IPD_data(nb)% Statemid% stored_f1_out(ix,k) - temp(i,j,k)) * rdt
2027+ trac_tend(i,j,k) = IPD_data(nb)% Statemid% stored_dqdt(ix,k1,1 ) + (IPD_data(nb)% Statemid% stored_f2_out(ix,k) - Atm(mygrid)% q(i,j,k,1 )) * rdt
2028+ enddo
2029+ enddo
2030+ enddo
2031+
2032+ call compute_nu (diff_local, p_half, p_full, z_full, local_pt, local_q, nu)
2033+ call compute_e (dt_atmos, 1 ./ local_delp, nu, e, a, b, c, g)
2034+
2035+ call vert_diff_down_2 &
2036+ (dt_atmos, 1 ./ local_delp, nu, temp, local_q, &
2037+ temp_tend, trac_tend, &
2038+ e_global (isc:iec,jsc:jec,:), &
2039+ f_t_global (isc:iec,jsc:jec,:), &
2040+ f_q_global (isc:iec,jsc:jec,:), &
2041+ mu_delt_n, nu_n, e_n1, f_t_delt_n1, f_q_delt_n1, &
2042+ delta_t_n, delta_q_n)
2043+
2044+ do j= jsc,jec
2045+ do i= isc,iec
2046+ Surf_diff % dtmass(i,j) = 1 ./ atm(mygrid)% delp(i,j,npz)
2047+ Surf_diff % dflux_t(i,j) = - nu(i,j,npz)* (1.0 - e(i,j,npz-1 ))
2048+ Surf_diff % dflux_tr(i,j,1 ) = - nu(i,j,npz)* (1.0 - e(i,j,npz-1 ))
2049+ Surf_diff % delta_t(i,j) = delta_t_n(i,j) + mu_delt_n(i,j)* nu_n(i,j)* f_t_delt_n1(i,j)
2050+ ! Surf_diff % delta_tr(i,j,1) =1*( delta_q_n(i,j) + mu_delt_n(i,j)*nu_n(i,j)*f_q_delt_n1(i,j) )
2051+ enddo
2052+ enddo
2053+
2054+ ! We also need to update these quantities that are used in flux_up_to_atmos
2055+
2056+ end subroutine populate_surf_diff
2057+
19282058#include " atmosphere_r4.fh"
19292059#include " atmosphere_r8.fh"
19302060
0 commit comments