Skip to content

Commit

Permalink
Make sure effective radius and mixing ratios are populated for MODIS
Browse files Browse the repository at this point in the history
  • Loading branch information
brhillman committed May 29, 2024
1 parent 7c05358 commit 976db84
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
13 changes: 8 additions & 5 deletions components/eamxx/src/physics/cosp/cosp_c2f.F90
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ subroutine cosp_c2f_init(npoints, ncolumns, nlevels) bind(c, name='cosp_c2f_init
end subroutine cosp_c2f_init

subroutine cosp_c2f_run(npoints, ncolumns, nlevels, ntau, nctp, ncth, &
emsfc_lw, sunlit, skt, T_mid, p_mid, p_int, z_mid, qv, &
emsfc_lw, sunlit, skt, T_mid, p_mid, p_int, z_mid, qv, qc, qi, &
cldfrac, reff_qc, reff_qi, dtau067, dtau105, isccp_cldtot, isccp_ctptau, modis_ctptau, misr_cthtau &
) bind(C, name='cosp_c2f_run')
integer(kind=c_int), value, intent(in) :: npoints, ncolumns, nlevels, ntau, nctp, ncth
real(kind=c_double), value, intent(in) :: emsfc_lw
real(kind=c_double), intent(in), dimension(npoints) :: sunlit, skt
real(kind=c_double), intent(in), dimension(npoints,nlevels) :: T_mid, p_mid, z_mid, qv, cldfrac, reff_qc, reff_qi, dtau067, dtau105
real(kind=c_double), intent(in), dimension(npoints,nlevels) :: T_mid, p_mid, z_mid, qv, qc, qi, cldfrac, reff_qc, reff_qi, dtau067, dtau105
real(kind=c_double), intent(in), dimension(npoints,nlevels+1) :: p_int
real(kind=c_double), intent(inout), dimension(npoints) :: isccp_cldtot
real(kind=c_double), intent(inout), dimension(npoints,ntau,nctp) :: isccp_ctptau, modis_ctptau
Expand Down Expand Up @@ -311,16 +311,18 @@ subroutine cosp_c2f_run(npoints, ncolumns, nlevels, ntau, nctp, ncth, &
cca(:npoints,:nlevels) = 0 ! Cloud fraction of convective clouds; not present or used in our model
dtau_c(:npoints,:nlevels) = 0 ! Optical depth of convective clouds; not present or used in our model
dem_c (:npoints,:nlevels) = 0 ! Emissivity of convective clouds; not present or used in our model
mr_lsliq(:npoints,:nlevels) = 0 ! Mixing ratio of cloud liquid; will be needed for radar/lidar
mr_ccliq(:npoints,:nlevels) = 0 ! Mixing ratio of cloud liquid for convective clouds; not present or used in our model
mr_lsice(:npoints,:nlevels) = 0 ! Mixing ratio of cloud ice; will be needed for radar/lidar
mr_lsliq(:npoints,:nlevels) = qc(:npoints,:nlevels) ! Mixing ratio of cloud liquid; will be needed for radar/lidar
mr_ccliq(:npoints,:nlevels) = 0 ! Mixing ratio of cloud liquid for convective clouds; not present or used in our model
mr_lsice(:npoints,:nlevels) = qi(:npoints,:nlevels) ! Mixing ratio of cloud ice; will be needed for radar/lidar
mr_ccice(:npoints,:nlevels) = 0 ! Mixing ratio of cloud ice for convective clouds; not present or used in our model
mr_lsrain(:npoints,:nlevels) = 0 ! Mixing ratio of rain; will be needed for radar/lidar
mr_ccrain(:npoints,:nlevels) = 0 ! Mixing ratio of rain for convective clouds; not present or used in our model
mr_lssnow(:npoints,:nlevels) = 0 ! Mixing ratio of snow; will be needed for radar/lidar
mr_ccsnow(:npoints,:nlevels) = 0 ! Mixing ratio of snow for convective clouds; will be needed for radar/lidar
mr_lsgrpl(:npoints,:nlevels) = 0 ! Mixing ratio of graupel; will be needed for radar/lidar
reff = 0 ! Effective radii; will be needed for MODIS
reff(:npoints,:nlevels,I_LSCLIQ) = 1e-6 * reff_qc(:npoints,:nlevels)
reff(:npoints,:nlevels,I_LSCICE) = 1e-6 * reff_qi(:npoints,:nlevels)

start_idx = 1
end_idx = npoints
Expand Down Expand Up @@ -1323,6 +1325,7 @@ subroutine subsample_and_optics(nPoints, nLevels, nColumns, nHydro, overlap, use

!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! MODIS optics
! TODO: we can probably bypass this block if we take asym and ss_alb from radiation
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (Lmodis) then
allocate(MODIS_cloudWater(nPoints,nColumns,nLevels), &
Expand Down
12 changes: 8 additions & 4 deletions components/eamxx/src/physics/cosp/cosp_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern "C" void cosp_c2f_init(int ncol, int nsubcol, int nlay);
extern "C" void cosp_c2f_final();
extern "C" void cosp_c2f_run(const int ncol, const int nsubcol, const int nlay, const int ntau, const int nctp, const int ncth,
const Real emsfc_lw, const Real* sunlit, const Real* skt,
const Real* T_mid, const Real* p_mid, const Real* p_int, const Real* z_mid, const Real* qv,
const Real* T_mid, const Real* p_mid, const Real* p_int, const Real* z_mid, const Real* qv, const Real* qc, const Real* qi,
const Real* cldfrac, const Real* reff_qc, const Real* reff_qi, const Real* dtau067, const Real* dtau105,
Real* isccp_cldtot, Real* isccp_ctptau, Real* modis_ctptau, Real* misr_cthtau);

Expand All @@ -33,15 +33,17 @@ namespace scream {
const Int ncol, const Int nsubcol, const Int nlay, const Int ntau, const Int nctp, const Int ncth, const Real emsfc_lw,
view_1d<const Real>& sunlit , view_1d<const Real>& skt,
view_2d<const Real>& T_mid , view_2d<const Real>& p_mid , view_2d<const Real>& p_int,
view_2d<const Real>& z_mid , view_2d<const Real>& qv , view_2d<const Real>& cldfrac,
view_2d<const Real>& z_mid , view_2d<const Real>& qv , view_2d<const Real>& qc , view_2d<const Real>& qi,
view_2d<const Real>& cldfrac,
view_2d<const Real>& reff_qc, view_2d<const Real>& reff_qi,
view_2d<const Real>& dtau067, view_2d<const Real>& dtau105,
view_1d<Real>& isccp_cldtot , view_3d<Real>& isccp_ctptau, view_3d<Real>& modis_ctptau, view_3d<Real>& misr_cthtau) {

// Make host copies and permute data as needed
lview_host_2d
T_mid_h("T_mid_h", ncol, nlay), p_mid_h("p_mid_h", ncol, nlay), p_int_h("p_int_h", ncol, nlay+1),
z_mid_h("z_mid_h", ncol, nlay), qv_h("qv_h", ncol, nlay), cldfrac_h("cldfrac_h", ncol, nlay),
z_mid_h("z_mid_h", ncol, nlay), qv_h("qv_h", ncol, nlay), qc_h("qc_h", ncol, nlay), qi_h("qi_h", ncol, nlay),
cldfrac_h("cldfrac_h", ncol, nlay),
reff_qc_h("reff_qc_h", ncol, nlay), reff_qi_h("reff_qi_h", ncol, nlay),
dtau067_h("dtau_067_h", ncol, nlay), dtau105_h("dtau105_h", ncol, nlay);
lview_host_3d isccp_ctptau_h("isccp_ctptau_h", ncol, ntau, nctp);
Expand All @@ -55,6 +57,8 @@ namespace scream {
p_mid_h(i,j) = p_mid(i,j);
z_mid_h(i,j) = z_mid(i,j);
qv_h(i,j) = qv(i,j);
qc_h(i,j) = qc(i,j);
qi_h(i,j) = qi(i,j);
cldfrac_h(i,j) = cldfrac(i,j);
reff_qc_h(i,j) = reff_qc(i,j);
reff_qi_h(i,j) = reff_qi(i,j);
Expand All @@ -73,7 +77,7 @@ namespace scream {
// Call COSP wrapper
cosp_c2f_run(ncol, nsubcol, nlay, ntau, nctp, ncth,
emsfc_lw, sunlit.data(), skt.data(), T_mid_h.data(), p_mid_h.data(), p_int_h.data(),
z_mid_h.data(), qv_h.data(),
z_mid_h.data(), qv_h.data(), qc_h.data(), qi_h.data(),
cldfrac_h.data(), reff_qc_h.data(), reff_qi_h.data(), dtau067_h.data(), dtau105_h.data(),
isccp_cldtot.data(), isccp_ctptau_h.data(), modis_ctptau_h.data(), misr_cthtau_h.data());

Expand Down
4 changes: 2 additions & 2 deletions components/eamxx/src/physics/cosp/eamxx_cosp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void Cosp::run_impl (const double dt)
auto isccp_ctptau = get_field_out("isccp_ctptau").get_view<Real***, Host>();
auto modis_ctptau = get_field_out("modis_ctptau").get_view<Real***, Host>();
auto misr_cthtau = get_field_out("misr_cthtau" ).get_view<Real***, Host>();
auto cosp_sunlit = get_field_out("isccp_mask" ).get_view<Real*, Host>(); // Copy of sunlit flag with COSP frequency for proper averaging
auto cosp_sunlit = get_field_out("cosp_sunlit").get_view<Real*, Host>(); // Copy of sunlit flag with COSP frequency for proper averaging

// Compute heights
const auto z_mid = CospFunc::view_2d<Real>("z_mid", m_num_cols, m_num_levs);
Expand Down Expand Up @@ -211,7 +211,7 @@ void Cosp::run_impl (const double dt)
CospFunc::view_2d<const Real> z_mid_c = z_mid; // Need a const version of z_mid for call to CospFunc::main
CospFunc::main(
m_num_cols, m_num_subcols, m_num_levs, m_num_tau, m_num_ctp, m_num_cth,
emsfc_lw, sunlit, skt, T_mid, p_mid, p_int, z_mid_c, qv,
emsfc_lw, sunlit, skt, T_mid, p_mid, p_int, z_mid_c, qv, qc, qi,
cldfrac, reff_qc, reff_qi, dtau067, dtau105,
isccp_cldtot, isccp_ctptau, modis_ctptau, misr_cthtau
);
Expand Down

0 comments on commit 976db84

Please sign in to comment.