From d3000b207d02e36c04c9b8b2e98836a8b64cf2f7 Mon Sep 17 00:00:00 2001 From: Benjamin Hillman Date: Wed, 15 May 2024 16:15:24 -0700 Subject: [PATCH 1/9] Enable modis_ctptau calculation and output --- .../eamxx/src/physics/cosp/cosp_c2f.F90 | 25 +++++++++++-------- .../eamxx/src/physics/cosp/cosp_functions.hpp | 8 +++--- .../eamxx/src/physics/cosp/eamxx_cosp.cpp | 11 +++++--- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/components/eamxx/src/physics/cosp/cosp_c2f.F90 b/components/eamxx/src/physics/cosp/cosp_c2f.F90 index 957c546c4aa..febef82c6b0 100644 --- a/components/eamxx/src/physics/cosp/cosp_c2f.F90 +++ b/components/eamxx/src/physics/cosp/cosp_c2f.F90 @@ -43,7 +43,7 @@ module cosp_c2f lsingle = .false., & ! True if using MMF_v3_single_moment CLOUDSAT microphysical scheme (default) ldouble = .true., & ! True if using MMF_v3.5_two_moment CLOUDSAT microphysical scheme lisccp = .true. , & ! Local on/off switch for simulators (used by initialization) - lmodis = .false., & ! + lmodis = .true., & ! lmisr = .false., & ! lcalipso = .false., & ! lgrLidar532 = .false., & ! @@ -82,7 +82,7 @@ module cosp_c2f Lpctmodis = .false., & ! MODIS cloud top pressure Llwpmodis = .false., & ! MODIS cloud liquid water path Liwpmodis = .false., & ! MODIS cloud ice water path - Lclmodis = .false., & ! MODIS cloud area fraction + Lclmodis = .true. , & ! MODIS cloud area fraction Latb532 = .false., & ! CALIPSO attenuated total backscatter (532nm) Latb532gr = .false., & ! GROUND LIDAR @ 532NM attenuated total backscatter (532nm) Latb355 = .false., & ! ATLID attenuated total backscatter (355nm) @@ -239,11 +239,9 @@ module cosp_c2f subroutine cosp_c2f_init(npoints, ncolumns, nlevels) bind(c, name='cosp_c2f_init') integer(kind=c_int), value, intent(in) :: npoints, ncolumns, nlevels - ! Initialize/allocate COSP input and output derived types + + ! Number of vertical levels for Cloudsat/CALIPSO nlvgrid = 40 - call construct_cospIN(npoints,ncolumns,nlevels,cospIN) - call construct_cospstatein(npoints,nlevels,rttov_nchannels,cospstateIN) - call construct_cosp_outputs(npoints, ncolumns, nlevels, nlvgrid, rttov_nchannels, cospOUT) ! Initialize quickbeam_optics, also if two-moment radar microphysics scheme is wanted... if (cloudsat_micro_scheme == 'MMF_v3.5_two_moment') then @@ -264,11 +262,17 @@ subroutine cosp_c2f_init(npoints, ncolumns, nlevels) bind(c, name='cosp_c2f_init cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs, & cloudsat_do_ray, isccp_topheight, isccp_topheight_direction, surface_radar, & rcfg_cloudsat, use_vgrid, csat_vgrid, Nlvgrid, Nlevels, cloudsat_micro_scheme) + + ! Initialize/allocate COSP input and output derived types + call construct_cospIN(npoints,ncolumns,nlevels,cospIN) + call construct_cospstatein(npoints,nlevels,rttov_nchannels,cospstateIN) + call construct_cosp_outputs(npoints, ncolumns, nlevels, nlvgrid, rttov_nchannels, cospOUT) + end subroutine cosp_c2f_init subroutine cosp_c2f_run(npoints, ncolumns, nlevels, ntau, nctp, & emsfc_lw, sunlit, skt, T_mid, p_mid, p_int, qv, & - cldfrac, reff_qc, reff_qi, dtau067, dtau105, isccp_cldtot, isccp_ctptau & + cldfrac, reff_qc, reff_qi, dtau067, dtau105, isccp_cldtot, isccp_ctptau, modis_ctptau & ) bind(C, name='cosp_c2f_run') integer(kind=c_int), value, intent(in) :: npoints, ncolumns, nlevels, ntau, nctp real(kind=c_double), value, intent(in) :: emsfc_lw @@ -276,7 +280,7 @@ subroutine cosp_c2f_run(npoints, ncolumns, nlevels, ntau, nctp, & real(kind=c_double), intent(in), dimension(npoints,nlevels) :: T_mid, p_mid, qv, 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 + real(kind=c_double), intent(inout), dimension(npoints,ntau,nctp) :: isccp_ctptau, modis_ctptau ! Takes normal arrays as input and populates COSP derived types character(len=256),dimension(100) :: cosp_status integer :: nptsperit @@ -351,6 +355,9 @@ subroutine cosp_c2f_run(npoints, ncolumns, nlevels, ntau, nctp, & isccp_cldtot(:npoints) = cospOUT%isccp_totalcldarea(:npoints) isccp_ctptau(:npoints,:,:) = cospOUT%isccp_fq(:npoints,:,:) + ! Modis + modis_ctptau(:npoints,:,:) = cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure(:npoints,:,:) + end subroutine cosp_c2f_run subroutine cosp_c2f_final() bind(C, name='cosp_c2f_final') @@ -455,8 +462,6 @@ end subroutine construct_cospstateIN ! ! This subroutine allocates output fields based on input logical flag switches. ! ###################################################################################### - ! TODO: This is WAY too many dummy arguments! These can just be defined at module scope I think - ! and then initialized once at init subroutine construct_cosp_outputs(Npoints,Ncolumns,Nlevels,Nlvgrid,Nchan,x) ! Inputs integer,intent(in) :: & diff --git a/components/eamxx/src/physics/cosp/cosp_functions.hpp b/components/eamxx/src/physics/cosp/cosp_functions.hpp index f969cdcfed1..ef6e5493d46 100644 --- a/components/eamxx/src/physics/cosp/cosp_functions.hpp +++ b/components/eamxx/src/physics/cosp/cosp_functions.hpp @@ -8,7 +8,7 @@ extern "C" void cosp_c2f_run(const int ncol, const int nsubcol, const int nlay, const Real emsfc_lw, const Real* sunlit, const Real* skt, const Real* T_mid, const Real* p_mid, const Real* p_int, const Real* qv, const Real* cldfrac, const Real* reff_qc, const Real* reff_qi, const Real* dtau067, const Real* dtau105, - Real* isccp_cldtot, Real* isccp_ctptau); + Real* isccp_cldtot, Real* isccp_ctptau, Real* modis_ctptau); namespace scream { @@ -36,7 +36,7 @@ namespace scream { view_2d& qv , view_2d& cldfrac, view_2d& reff_qc, view_2d& reff_qi, view_2d& dtau067, view_2d& dtau105, - view_1d& isccp_cldtot , view_3d& isccp_ctptau) { + view_1d& isccp_cldtot , view_3d& isccp_ctptau, view_3d& modis_ctptau) { // Make host copies and permute data as needed lview_host_2d @@ -45,6 +45,7 @@ namespace scream { 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); + lview_host_3d modis_ctptau_h("modis_ctptau_h", ncol, ntau, nctp); // Copy to layoutLeft host views for (int i = 0; i < ncol; i++) { @@ -72,13 +73,14 @@ namespace scream { emsfc_lw, sunlit.data(), skt.data(), T_mid_h.data(), p_mid_h.data(), p_int_h.data(), qv_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()); + isccp_cldtot.data(), isccp_ctptau_h.data(), modis_ctptau_h.data()); // Copy outputs back to layoutRight views for (int i = 0; i < ncol; i++) { for (int j = 0; j < ntau; j++) { for (int k = 0; k < nctp; k++) { isccp_ctptau(i,j,k) = isccp_ctptau_h(i,j,k); + modis_ctptau(i,j,k) = modis_ctptau_h(i,j,k); } } } diff --git a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp index 0f4b9f1559e..30de0e75c4f 100644 --- a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp +++ b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp @@ -83,6 +83,7 @@ void Cosp::set_grids(const std::shared_ptr grids_manager) // Set of fields used strictly as output add_field("isccp_cldtot", scalar2d, percent, grid_name); add_field("isccp_ctptau", scalar4d_ctptau, percent, grid_name, 1); + add_field("modis_ctptau", scalar4d_ctptau, percent, grid_name, 1); add_field("isccp_mask" , scalar2d, nondim, grid_name); } @@ -96,8 +97,8 @@ void Cosp::initialize_impl (const RunType /* run_type */) // Add note to output files about processing ISCCP fields that are only valid during // daytime. This can go away once I/O can handle masked time averages. using stratts_t = std::map; - std::list vnames = {"isccp_cldtot", "isccp_ctptau"}; - for (const auto field_name : {"isccp_cldtot", "isccp_ctptau"}) { + std::list vnames = {"isccp_cldtot", "isccp_ctptau", "modis_ctptau"}; + for (const auto field_name : {"isccp_cldtot", "isccp_ctptau", "modis_ctptau"}) { auto& f = get_field_out(field_name); auto& atts = f.get_header().get_extra_data("io: string attributes"); atts["note"] = "Night values are zero; divide by isccp_mask to get daytime mean"; @@ -160,6 +161,7 @@ void Cosp::run_impl (const double dt) auto dtau105 = get_field_in("dtau105").get_view(); auto isccp_cldtot = get_field_out("isccp_cldtot").get_view(); auto isccp_ctptau = get_field_out("isccp_ctptau").get_view(); + auto modis_ctptau = get_field_out("modis_ctptau").get_view(); auto isccp_mask = get_field_out("isccp_mask" ).get_view(); // Copy of sunlit flag with COSP frequency for proper averaging // Call COSP wrapper routines @@ -170,7 +172,7 @@ void Cosp::run_impl (const double dt) m_num_cols, m_num_subcols, m_num_levs, m_num_isccptau, m_num_isccpctp, emsfc_lw, sunlit, skt, T_mid, p_mid, p_int, qv, cldfrac, reff_qc, reff_qi, dtau067, dtau105, - isccp_cldtot, isccp_ctptau + isccp_cldtot, isccp_ctptau, modis_ctptau ); // Remask night values to ZERO since our I/O does not know how to handle masked/missing values // in temporal averages; this is all host data, so we can just use host loops like its the 1980s @@ -180,6 +182,7 @@ void Cosp::run_impl (const double dt) for (int j = 0; j < m_num_isccptau; j++) { for (int k = 0; k < m_num_isccpctp; k++) { isccp_ctptau(i,j,k) = 0; + modis_ctptau(i,j,k) = 0; } } } @@ -196,10 +199,12 @@ void Cosp::run_impl (const double dt) // TODO: mask this when/if the AD ever supports masked averages Kokkos::deep_copy(isccp_cldtot, 0.0); Kokkos::deep_copy(isccp_ctptau, 0.0); + Kokkos::deep_copy(modis_ctptau, 0.0); Kokkos::deep_copy(isccp_mask , 0.0); } get_field_out("isccp_cldtot").sync_to_dev(); get_field_out("isccp_ctptau").sync_to_dev(); + get_field_out("modis_ctptau").sync_to_dev(); get_field_out("isccp_mask" ).sync_to_dev(); } From d957b7f7f9af2cb508a937c876e9e5d5d631c70b Mon Sep 17 00:00:00 2001 From: Benjamin Hillman Date: Tue, 21 May 2024 12:19:25 -0700 Subject: [PATCH 2/9] Enable MISR simulator and update cosp dimension names --- .../eamxx/src/physics/cosp/cosp_c2f.F90 | 26 ++++---- .../eamxx/src/physics/cosp/cosp_functions.hpp | 25 +++++--- .../eamxx/src/physics/cosp/eamxx_cosp.cpp | 64 ++++++++++++++++--- .../eamxx/src/physics/cosp/eamxx_cosp.hpp | 14 +++- 4 files changed, 97 insertions(+), 32 deletions(-) diff --git a/components/eamxx/src/physics/cosp/cosp_c2f.F90 b/components/eamxx/src/physics/cosp/cosp_c2f.F90 index febef82c6b0..77db4858ccd 100644 --- a/components/eamxx/src/physics/cosp/cosp_c2f.F90 +++ b/components/eamxx/src/physics/cosp/cosp_c2f.F90 @@ -40,11 +40,11 @@ module cosp_c2f ! Local variables; control what runs and what does not logical :: & - lsingle = .false., & ! True if using MMF_v3_single_moment CLOUDSAT microphysical scheme (default) - ldouble = .true., & ! True if using MMF_v3.5_two_moment CLOUDSAT microphysical scheme + lsingle = .false., & ! True if using MMF_v3_single_moment CLOUDSAT microphysical scheme (default) + ldouble = .true. , & ! True if using MMF_v3.5_two_moment CLOUDSAT microphysical scheme lisccp = .true. , & ! Local on/off switch for simulators (used by initialization) - lmodis = .true., & ! - lmisr = .false., & ! + lmodis = .true. , & ! + lmisr = .true. , & ! lcalipso = .false., & ! lgrLidar532 = .false., & ! latlid = .false., & ! @@ -64,7 +64,7 @@ module cosp_c2f Lmeantbisccp = .false., & ! ISCCP mean all-sky 10.5micron brightness temperature Lmeantbclrisccp = .false., & ! ISCCP mean clear-sky 10.5micron brightness temperature Lalbisccp = .false., & ! ISCCP mean cloud albedo - LclMISR = .false., & ! MISR cloud fraction + LclMISR = .true. , & ! MISR cloud fraction Lcltmodis = .false., & ! MODIS total cloud fraction Lclwmodis = .false., & ! MODIS liquid cloud fraction Lclimodis = .false., & ! MODIS ice cloud fraction @@ -270,17 +270,18 @@ 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, & - emsfc_lw, sunlit, skt, T_mid, p_mid, p_int, qv, & - cldfrac, reff_qc, reff_qi, dtau067, dtau105, isccp_cldtot, isccp_ctptau, modis_ctptau & + subroutine cosp_c2f_run(npoints, ncolumns, nlevels, ntau, nctp, ncth, & + emsfc_lw, sunlit, skt, T_mid, p_mid, p_int, z_mid, qv, & + 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 + 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, qv, cldfrac, reff_qc, reff_qi, dtau067, dtau105 + 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+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 + real(kind=c_double), intent(inout), dimension(npoints,ntau,ncth) :: misr_cthtau ! Takes normal arrays as input and populates COSP derived types character(len=256),dimension(100) :: cosp_status integer :: nptsperit @@ -326,7 +327,7 @@ subroutine cosp_c2f_run(npoints, ncolumns, nlevels, ntau, nctp, & ! Translate arrays to derived types cospIN%emsfc_lw = emsfc_lw cospIN%rcfg_cloudsat = rcfg_cloudsat -! cospstateIN%hgt_matrix = zlev(start_idx:end_idx,Nlevels:1:-1) ! km + cospstateIN%hgt_matrix = z_mid(start_idx:end_idx,1:Nlevels) ! m cospstateIN%sunlit = sunlit(start_idx:end_idx) ! 0-1 cospstateIN%skt = skt(start_idx:end_idx) ! K ! cospstateIN%surfelev = surfelev(start_idx:end_idx) ! m @@ -358,6 +359,9 @@ subroutine cosp_c2f_run(npoints, ncolumns, nlevels, ntau, nctp, & ! Modis modis_ctptau(:npoints,:,:) = cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure(:npoints,:,:) + ! MISR + misr_cthtau(:npoints,:,:) = cospOUT%misr_fq(:npoints,:,:) + end subroutine cosp_c2f_run subroutine cosp_c2f_final() bind(C, name='cosp_c2f_final') diff --git a/components/eamxx/src/physics/cosp/cosp_functions.hpp b/components/eamxx/src/physics/cosp/cosp_functions.hpp index ef6e5493d46..37377ca1475 100644 --- a/components/eamxx/src/physics/cosp/cosp_functions.hpp +++ b/components/eamxx/src/physics/cosp/cosp_functions.hpp @@ -4,11 +4,11 @@ using scream::Real; 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, +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* qv, + const Real* T_mid, const Real* p_mid, const Real* p_int, const Real* z_mid, const Real* qv, 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* isccp_cldtot, Real* isccp_ctptau, Real* modis_ctptau, Real* misr_cthtau); namespace scream { @@ -30,28 +30,30 @@ namespace scream { cosp_c2f_final(); }; inline void main( - const Int ncol, const Int nsubcol, const Int nlay, const Int ntau, const Int nctp, const Real emsfc_lw, + const Int ncol, const Int nsubcol, const Int nlay, const Int ntau, const Int nctp, const Int ncth, const Real emsfc_lw, view_1d& sunlit , view_1d& skt, view_2d& T_mid , view_2d& p_mid , view_2d& p_int, - view_2d& qv , view_2d& cldfrac, + view_2d& z_mid , view_2d& qv , view_2d& cldfrac, view_2d& reff_qc, view_2d& reff_qi, view_2d& dtau067, view_2d& dtau105, - view_1d& isccp_cldtot , view_3d& isccp_ctptau, view_3d& modis_ctptau) { + view_1d& isccp_cldtot , view_3d& isccp_ctptau, view_3d& modis_ctptau, view_3d& 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), - 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), 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); lview_host_3d modis_ctptau_h("modis_ctptau_h", ncol, ntau, nctp); + lview_host_3d misr_cthtau_h("misr_cthtau_h", ncol, ntau, ncth); // Copy to layoutLeft host views for (int i = 0; i < ncol; i++) { for (int j = 0; j < nlay; j++) { T_mid_h(i,j) = T_mid(i,j); 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); cldfrac_h(i,j) = cldfrac(i,j); reff_qc_h(i,j) = reff_qc(i,j); @@ -69,11 +71,11 @@ namespace scream { // Subsample here? // Call COSP wrapper - cosp_c2f_run(ncol, nsubcol, nlay, ntau, nctp, + 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(), - qv_h.data(), + z_mid_h.data(), qv_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()); + isccp_cldtot.data(), isccp_ctptau_h.data(), modis_ctptau_h.data(), misr_cthtau_h.data()); // Copy outputs back to layoutRight views for (int i = 0; i < ncol; i++) { @@ -82,6 +84,9 @@ namespace scream { isccp_ctptau(i,j,k) = isccp_ctptau_h(i,j,k); modis_ctptau(i,j,k) = modis_ctptau_h(i,j,k); } + for (int k = 0; k < ncth; k++) { + misr_cthtau(i,j,k) = misr_cthtau_h(i,j,k); + } } } } diff --git a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp index 30de0e75c4f..004aa754207 100644 --- a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp +++ b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp @@ -39,6 +39,8 @@ void Cosp::set_grids(const std::shared_ptr grids_manager) Units nondim = Units::nondimensional(); Units percent (nondim,"%"); auto micron = micro*m; + auto m2 = pow(m, 2); + auto s2 = pow(s, 2); m_grid = grids_manager->get_grid("Physics"); const auto& grid_name = m_grid->name(); @@ -52,8 +54,11 @@ void Cosp::set_grids(const std::shared_ptr grids_manager) FieldLayout scalar3d_mid = m_grid->get_3d_scalar_layout(true); FieldLayout scalar3d_int = m_grid->get_3d_scalar_layout(false); FieldLayout scalar4d_ctptau ( {COL,CMP,CMP}, - {m_num_cols,m_num_isccptau,m_num_isccpctp}, - {e2str(COL), "ISCCPTAU", "ISCCPPRS"}); + {m_num_cols,m_num_tau,m_num_ctp}, + {e2str(COL), "cosp_tau", "cosp_prs"}); + FieldLayout scalar4d_cthtau ( {COL,CMP,CMP}, + {m_num_cols,m_num_tau,m_num_cth}, + {e2str(COL), "cosp_tau", "cosp_cth"}); // Set of fields used strictly as input // Name in AD Layout Units Grid Group @@ -69,6 +74,8 @@ void Cosp::set_grids(const std::shared_ptr grids_manager) add_field("qv", scalar3d_mid, kg/kg, grid_name, "tracers"); add_field("qc", scalar3d_mid, kg/kg, grid_name, "tracers"); add_field("qi", scalar3d_mid, kg/kg, grid_name, "tracers"); + add_field("phis", scalar2d , m2/s2, grid_name); + add_field("pseudo_density", scalar3d_mid, Pa, grid_name); add_field("cldfrac_rad", scalar3d_mid, nondim, grid_name); // Optical properties, should be computed in radiation interface add_field("dtau067", scalar3d_mid, nondim, grid_name); // 0.67 micron optical depth @@ -84,6 +91,7 @@ void Cosp::set_grids(const std::shared_ptr grids_manager) add_field("isccp_cldtot", scalar2d, percent, grid_name); add_field("isccp_ctptau", scalar4d_ctptau, percent, grid_name, 1); add_field("modis_ctptau", scalar4d_ctptau, percent, grid_name, 1); + add_field("misr_cthtau" , scalar4d_cthtau, percent, grid_name, 1); add_field("isccp_mask" , scalar2d, nondim, grid_name); } @@ -97,8 +105,8 @@ void Cosp::initialize_impl (const RunType /* run_type */) // Add note to output files about processing ISCCP fields that are only valid during // daytime. This can go away once I/O can handle masked time averages. using stratts_t = std::map; - std::list vnames = {"isccp_cldtot", "isccp_ctptau", "modis_ctptau"}; - for (const auto field_name : {"isccp_cldtot", "isccp_ctptau", "modis_ctptau"}) { + std::list vnames = {"isccp_cldtot", "isccp_ctptau", "modis_ctptau", "misr_cthtau"}; + for (const auto field_name : {"isccp_cldtot", "isccp_ctptau", "modis_ctptau", "misr_cthtau"}) { auto& f = get_field_out(field_name); auto& atts = f.get_header().get_extra_data("io: string attributes"); atts["note"] = "Night values are zero; divide by isccp_mask to get daytime mean"; @@ -145,6 +153,8 @@ void Cosp::run_impl (const double dt) get_field_in("eff_radius_qi").sync_to_host(); get_field_in("dtau067").sync_to_host(); get_field_in("dtau105").sync_to_host(); + get_field_in("phis").sync_to_host(); + get_field_in("pseudo_density").sync_to_host(); auto qv = get_field_in("qv").get_view(); auto qc = get_field_in("qc").get_view(); @@ -154,6 +164,8 @@ void Cosp::run_impl (const double dt) auto T_mid = get_field_in("T_mid").get_view(); auto p_mid = get_field_in("p_mid").get_view(); auto p_int = get_field_in("p_int").get_view(); + auto phis = get_field_in("phis").get_view(); + auto pseudo_density = get_field_in("pseudo_density").get_view(); auto cldfrac = get_field_in("cldfrac_rad").get_view(); auto reff_qc = get_field_in("eff_radius_qc").get_view(); auto reff_qi = get_field_in("eff_radius_qi").get_view(); @@ -162,28 +174,60 @@ void Cosp::run_impl (const double dt) auto isccp_cldtot = get_field_out("isccp_cldtot").get_view(); auto isccp_ctptau = get_field_out("isccp_ctptau").get_view(); auto modis_ctptau = get_field_out("modis_ctptau").get_view(); + auto misr_cthtau = get_field_out("misr_cthtau" ).get_view(); auto isccp_mask = get_field_out("isccp_mask" ).get_view(); // Copy of sunlit flag with COSP frequency for proper averaging + // Compute heights + const auto z_mid = CospFunc::view_2d("z_mid", m_num_cols, m_num_levs); + const auto z_int = CospFunc::view_2d("z_int", m_num_cols, m_num_levs); + const auto dz = z_mid; // reuse tmp memory for dz + const auto ncol = m_num_cols; + const auto nlev = m_num_levs; + // calculate_z_int contains a team-level parallel_scan, which requires a special policy + // TODO: do this on device? + const auto scan_policy = ekat::ExeSpaceUtils::get_thread_range_parallel_scan_team_policy(ncol, nlev); + Kokkos::parallel_for(scan_policy, KOKKOS_LAMBDA (const KTH::MemberType& team) { + const int i = team.league_rank(); + const auto dz_s = ekat::subview(dz, i); + const auto p_mid_s = ekat::subview(p_mid, i); + const auto T_mid_s = ekat::subview(T_mid, i); + const auto qv_s = ekat::subview(qv, i); + const auto z_int_s = ekat::subview(z_int, i); + const auto z_mid_s = ekat::subview(z_mid, i); + const Real z_surf = phis(i) / 9.81; + const auto pseudo_density_s = ekat::subview(pseudo_density, i); + PF::calculate_dz(team, pseudo_density_s, p_mid_s, T_mid_s, qv_s, dz_s); + team.team_barrier(); + PF::calculate_z_int(team,nlev,dz_s,z_surf,z_int_s); + team.team_barrier(); + PF::calculate_z_mid(team,nlev,z_int_s,z_mid_s); + team.team_barrier(); + }); + // Call COSP wrapper routines if (update_cosp) { Real emsfc_lw = 0.99; Kokkos::deep_copy(isccp_mask, sunlit); + CospFunc::view_2d 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_isccptau, m_num_isccpctp, - emsfc_lw, sunlit, skt, T_mid, p_mid, p_int, qv, + 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, cldfrac, reff_qc, reff_qi, dtau067, dtau105, - isccp_cldtot, isccp_ctptau, modis_ctptau + isccp_cldtot, isccp_ctptau, modis_ctptau, misr_cthtau ); // Remask night values to ZERO since our I/O does not know how to handle masked/missing values // in temporal averages; this is all host data, so we can just use host loops like its the 1980s for (int i = 0; i < m_num_cols; i++) { if (sunlit(i) == 0) { isccp_cldtot(i) = 0; - for (int j = 0; j < m_num_isccptau; j++) { - for (int k = 0; k < m_num_isccpctp; k++) { + for (int j = 0; j < m_num_tau; j++) { + for (int k = 0; k < m_num_ctp; k++) { isccp_ctptau(i,j,k) = 0; modis_ctptau(i,j,k) = 0; } + for (int k = 0; k < m_num_cth; k++) { + misr_cthtau (i,j,k) = 0; + } } } } @@ -200,11 +244,13 @@ void Cosp::run_impl (const double dt) Kokkos::deep_copy(isccp_cldtot, 0.0); Kokkos::deep_copy(isccp_ctptau, 0.0); Kokkos::deep_copy(modis_ctptau, 0.0); + Kokkos::deep_copy(misr_cthtau , 0.0); Kokkos::deep_copy(isccp_mask , 0.0); } get_field_out("isccp_cldtot").sync_to_dev(); get_field_out("isccp_ctptau").sync_to_dev(); get_field_out("modis_ctptau").sync_to_dev(); + get_field_out("misr_cthtau" ).sync_to_dev(); get_field_out("isccp_mask" ).sync_to_dev(); } diff --git a/components/eamxx/src/physics/cosp/eamxx_cosp.hpp b/components/eamxx/src/physics/cosp/eamxx_cosp.hpp index 99f3c179a36..f7ff41d5a2d 100644 --- a/components/eamxx/src/physics/cosp/eamxx_cosp.hpp +++ b/components/eamxx/src/physics/cosp/eamxx_cosp.hpp @@ -2,6 +2,7 @@ #define SCREAM_COSP_HPP #include "share/atm_process/atmosphere_process.hpp" +#include "share/util/scream_common_physics_functions.hpp" #include "ekat/ekat_parameter_list.hpp" #include @@ -19,6 +20,10 @@ class Cosp : public AtmosphereProcess { public: + //using Pack = ekat::Pack; + using PF = scream::PhysicsFunctions; + using KT = KokkosTypes; + using KTH = KokkosTypes; // Constructors Cosp (const ekat::Comm& comm, const ekat::ParameterList& params); @@ -49,7 +54,12 @@ class Cosp : public AtmosphereProcess // The three main overrides for the subcomponent void initialize_impl (const RunType run_type); +#ifdef KOKKOS_ENABLE_CUDA + // Cuda requires methods enclosing __device__ lambda's to be public +public: +#endif void run_impl (const double dt); +protected: void finalize_impl (); // cosp frequency; positive is interpreted as number of steps, negative as number of hours @@ -60,8 +70,8 @@ class Cosp : public AtmosphereProcess Int m_num_cols; Int m_num_subcols; Int m_num_levs; - Int m_num_isccptau = 7; - Int m_num_isccpctp = 7; + Int m_num_tau = 7; + Int m_num_ctp = 7; Int m_num_cth = 16; std::shared_ptr m_grid; From 7c053580b83e410002d6ba0d22f38f6a7137d5f7 Mon Sep 17 00:00:00 2001 From: Benjamin Hillman Date: Tue, 21 May 2024 12:37:17 -0700 Subject: [PATCH 3/9] Rename isccp_mask to cosp_sunlit since used for all passive simulators --- components/eamxx/src/physics/cosp/eamxx_cosp.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp index 004aa754207..ea7972ff5eb 100644 --- a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp +++ b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp @@ -92,7 +92,7 @@ void Cosp::set_grids(const std::shared_ptr grids_manager) add_field("isccp_ctptau", scalar4d_ctptau, percent, grid_name, 1); add_field("modis_ctptau", scalar4d_ctptau, percent, grid_name, 1); add_field("misr_cthtau" , scalar4d_cthtau, percent, grid_name, 1); - add_field("isccp_mask" , scalar2d, nondim, grid_name); + add_field("cosp_sunlit" , scalar2d, nondim, grid_name); } // ========================================================================================= @@ -109,7 +109,7 @@ void Cosp::initialize_impl (const RunType /* run_type */) for (const auto field_name : {"isccp_cldtot", "isccp_ctptau", "modis_ctptau", "misr_cthtau"}) { auto& f = get_field_out(field_name); auto& atts = f.get_header().get_extra_data("io: string attributes"); - atts["note"] = "Night values are zero; divide by isccp_mask to get daytime mean"; + atts["note"] = "Night values are zero; divide by cosp_sunlit to get daytime mean"; } } @@ -175,7 +175,7 @@ void Cosp::run_impl (const double dt) auto isccp_ctptau = get_field_out("isccp_ctptau").get_view(); auto modis_ctptau = get_field_out("modis_ctptau").get_view(); auto misr_cthtau = get_field_out("misr_cthtau" ).get_view(); - auto isccp_mask = get_field_out("isccp_mask" ).get_view(); // Copy of sunlit flag with COSP frequency for proper averaging + auto cosp_sunlit = get_field_out("isccp_mask" ).get_view(); // Copy of sunlit flag with COSP frequency for proper averaging // Compute heights const auto z_mid = CospFunc::view_2d("z_mid", m_num_cols, m_num_levs); @@ -207,7 +207,7 @@ void Cosp::run_impl (const double dt) // Call COSP wrapper routines if (update_cosp) { Real emsfc_lw = 0.99; - Kokkos::deep_copy(isccp_mask, sunlit); + Kokkos::deep_copy(cosp_sunlit, sunlit); CospFunc::view_2d 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, @@ -245,13 +245,13 @@ void Cosp::run_impl (const double dt) Kokkos::deep_copy(isccp_ctptau, 0.0); Kokkos::deep_copy(modis_ctptau, 0.0); Kokkos::deep_copy(misr_cthtau , 0.0); - Kokkos::deep_copy(isccp_mask , 0.0); + Kokkos::deep_copy(cosp_sunlit , 0.0); } get_field_out("isccp_cldtot").sync_to_dev(); get_field_out("isccp_ctptau").sync_to_dev(); get_field_out("modis_ctptau").sync_to_dev(); get_field_out("misr_cthtau" ).sync_to_dev(); - get_field_out("isccp_mask" ).sync_to_dev(); + get_field_out("cosp_sunlit" ).sync_to_dev(); } // ========================================================================================= From 976db8490bee4c6c7730fe4feba0d815e650efc2 Mon Sep 17 00:00:00 2001 From: Benjamin Hillman Date: Wed, 22 May 2024 14:18:27 -0700 Subject: [PATCH 4/9] Make sure effective radius and mixing ratios are populated for MODIS --- components/eamxx/src/physics/cosp/cosp_c2f.F90 | 13 ++++++++----- .../eamxx/src/physics/cosp/cosp_functions.hpp | 12 ++++++++---- components/eamxx/src/physics/cosp/eamxx_cosp.cpp | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/components/eamxx/src/physics/cosp/cosp_c2f.F90 b/components/eamxx/src/physics/cosp/cosp_c2f.F90 index 77db4858ccd..25d27d8ca71 100644 --- a/components/eamxx/src/physics/cosp/cosp_c2f.F90 +++ b/components/eamxx/src/physics/cosp/cosp_c2f.F90 @@ -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 @@ -311,9 +311,9 @@ 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 @@ -321,6 +321,8 @@ subroutine cosp_c2f_run(npoints, ncolumns, nlevels, ntau, nctp, ncth, & 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 @@ -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), & diff --git a/components/eamxx/src/physics/cosp/cosp_functions.hpp b/components/eamxx/src/physics/cosp/cosp_functions.hpp index 37377ca1475..1dc7e3bd007 100644 --- a/components/eamxx/src/physics/cosp/cosp_functions.hpp +++ b/components/eamxx/src/physics/cosp/cosp_functions.hpp @@ -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); @@ -33,7 +33,8 @@ 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& sunlit , view_1d& skt, view_2d& T_mid , view_2d& p_mid , view_2d& p_int, - view_2d& z_mid , view_2d& qv , view_2d& cldfrac, + view_2d& z_mid , view_2d& qv , view_2d& qc , view_2d& qi, + view_2d& cldfrac, view_2d& reff_qc, view_2d& reff_qi, view_2d& dtau067, view_2d& dtau105, view_1d& isccp_cldtot , view_3d& isccp_ctptau, view_3d& modis_ctptau, view_3d& misr_cthtau) { @@ -41,7 +42,8 @@ namespace scream { // 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); @@ -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); @@ -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()); diff --git a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp index ea7972ff5eb..0997754b482 100644 --- a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp +++ b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp @@ -175,7 +175,7 @@ void Cosp::run_impl (const double dt) auto isccp_ctptau = get_field_out("isccp_ctptau").get_view(); auto modis_ctptau = get_field_out("modis_ctptau").get_view(); auto misr_cthtau = get_field_out("misr_cthtau" ).get_view(); - auto cosp_sunlit = get_field_out("isccp_mask" ).get_view(); // Copy of sunlit flag with COSP frequency for proper averaging + auto cosp_sunlit = get_field_out("cosp_sunlit").get_view(); // Copy of sunlit flag with COSP frequency for proper averaging // Compute heights const auto z_mid = CospFunc::view_2d("z_mid", m_num_cols, m_num_levs); @@ -211,7 +211,7 @@ void Cosp::run_impl (const double dt) CospFunc::view_2d 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 ); From 9ea131ff9d30a85d4e1b3e169d95b6427ab49622 Mon Sep 17 00:00:00 2001 From: Benjamin Hillman Date: Tue, 28 May 2024 08:13:17 -0700 Subject: [PATCH 5/9] Add pseudo_density to cosp test input --- components/eamxx/tests/single-process/cosp/input.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/components/eamxx/tests/single-process/cosp/input.yaml b/components/eamxx/tests/single-process/cosp/input.yaml index 1447bcc654f..e3a80db73f0 100644 --- a/components/eamxx/tests/single-process/cosp/input.yaml +++ b/components/eamxx/tests/single-process/cosp/input.yaml @@ -33,6 +33,7 @@ initial_conditions: eff_radius_qi: 0.0 sunlit: 1.0 surf_radiative_T: 288.0 + pseudo_density: 1.0 # The parameters for I/O control Scorpio: From a25da34ade29d4d67bebfefe084fa6847e0e2a11 Mon Sep 17 00:00:00 2001 From: Benjamin Hillman Date: Tue, 28 May 2024 21:17:03 -0700 Subject: [PATCH 6/9] Fix whitespace weirdness --- components/eamxx/src/physics/cosp/eamxx_cosp.cpp | 14 +++++++------- components/eamxx/src/physics/cosp/eamxx_cosp.hpp | 7 +++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp index 0997754b482..2395aaad3dc 100644 --- a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp +++ b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp @@ -91,8 +91,8 @@ void Cosp::set_grids(const std::shared_ptr grids_manager) add_field("isccp_cldtot", scalar2d, percent, grid_name); add_field("isccp_ctptau", scalar4d_ctptau, percent, grid_name, 1); add_field("modis_ctptau", scalar4d_ctptau, percent, grid_name, 1); - add_field("misr_cthtau" , scalar4d_cthtau, percent, grid_name, 1); - add_field("cosp_sunlit" , scalar2d, nondim, grid_name); + add_field("misr_cthtau", scalar4d_cthtau, percent, grid_name, 1); + add_field("cosp_sunlit", scalar2d, nondim, grid_name); } // ========================================================================================= @@ -174,7 +174,7 @@ void Cosp::run_impl (const double dt) auto isccp_cldtot = get_field_out("isccp_cldtot").get_view(); auto isccp_ctptau = get_field_out("isccp_ctptau").get_view(); auto modis_ctptau = get_field_out("modis_ctptau").get_view(); - auto misr_cthtau = get_field_out("misr_cthtau" ).get_view(); + auto misr_cthtau = get_field_out("misr_cthtau").get_view(); auto cosp_sunlit = get_field_out("cosp_sunlit").get_view(); // Copy of sunlit flag with COSP frequency for proper averaging // Compute heights @@ -244,14 +244,14 @@ void Cosp::run_impl (const double dt) Kokkos::deep_copy(isccp_cldtot, 0.0); Kokkos::deep_copy(isccp_ctptau, 0.0); Kokkos::deep_copy(modis_ctptau, 0.0); - Kokkos::deep_copy(misr_cthtau , 0.0); - Kokkos::deep_copy(cosp_sunlit , 0.0); + Kokkos::deep_copy(misr_cthtau, 0.0); + Kokkos::deep_copy(cosp_sunlit, 0.0); } get_field_out("isccp_cldtot").sync_to_dev(); get_field_out("isccp_ctptau").sync_to_dev(); get_field_out("modis_ctptau").sync_to_dev(); - get_field_out("misr_cthtau" ).sync_to_dev(); - get_field_out("cosp_sunlit" ).sync_to_dev(); + get_field_out("misr_cthtau").sync_to_dev(); + get_field_out("cosp_sunlit").sync_to_dev(); } // ========================================================================================= diff --git a/components/eamxx/src/physics/cosp/eamxx_cosp.hpp b/components/eamxx/src/physics/cosp/eamxx_cosp.hpp index f7ff41d5a2d..894c8c9f511 100644 --- a/components/eamxx/src/physics/cosp/eamxx_cosp.hpp +++ b/components/eamxx/src/physics/cosp/eamxx_cosp.hpp @@ -20,10 +20,9 @@ class Cosp : public AtmosphereProcess { public: - //using Pack = ekat::Pack; - using PF = scream::PhysicsFunctions; - using KT = KokkosTypes; - using KTH = KokkosTypes; + using PF = scream::PhysicsFunctions; + using KT = KokkosTypes; + using KTH = KokkosTypes; // Constructors Cosp (const ekat::Comm& comm, const ekat::ParameterList& params); From b065a7f196fba713c0b43052323c22322b6699e5 Mon Sep 17 00:00:00 2001 From: Benjamin Hillman Date: Thu, 30 May 2024 12:35:40 -0600 Subject: [PATCH 7/9] Fix grid def for cosp standalone --- components/eamxx/tests/single-process/cosp/input.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/eamxx/tests/single-process/cosp/input.yaml b/components/eamxx/tests/single-process/cosp/input.yaml index e3a80db73f0..5b3b2787943 100644 --- a/components/eamxx/tests/single-process/cosp/input.yaml +++ b/components/eamxx/tests/single-process/cosp/input.yaml @@ -14,18 +14,17 @@ atmosphere_processes: grids_manager: Type: Mesh Free geo_data_source: IC_FILE - grids_names: [Physics] - Physics: - aliases: [Point Grid] + grids_names: [Physics GLL] + Physics GLL: type: point_grid + aliases: [Physics] number_of_global_columns: 218 number_of_vertical_levels: 72 - initial_conditions: # The name of the file containing the initial conditions for this test. Filename: ${SCREAM_DATA_DIR}/init/${EAMxx_tests_IC_FILE_72lev} - topography_filename: ${TOPO_DATA_DIR}/USGS-gtopo30_ne4np4pg2_16x_converted.c20200527.nc + topography_filename: ${TOPO_DATA_DIR}/${EAMxx_tests_TOPO_FILE} dtau067: 1.0 dtau105: 1.0 cldfrac_rad: 0.5 From 8a57eaf703d08c938a48411fa21b1776519cd40c Mon Sep 17 00:00:00 2001 From: Benjamin Hillman Date: Thu, 30 May 2024 23:59:04 -0600 Subject: [PATCH 8/9] Fix number of levels in z_int --- components/eamxx/src/physics/cosp/eamxx_cosp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp index 2395aaad3dc..4aa8d53fea8 100644 --- a/components/eamxx/src/physics/cosp/eamxx_cosp.cpp +++ b/components/eamxx/src/physics/cosp/eamxx_cosp.cpp @@ -179,7 +179,7 @@ void Cosp::run_impl (const double dt) // Compute heights const auto z_mid = CospFunc::view_2d("z_mid", m_num_cols, m_num_levs); - const auto z_int = CospFunc::view_2d("z_int", m_num_cols, m_num_levs); + const auto z_int = CospFunc::view_2d("z_int", m_num_cols, m_num_levs+1); const auto dz = z_mid; // reuse tmp memory for dz const auto ncol = m_num_cols; const auto nlev = m_num_levs; From 45e462ea5515d47cf7fddd1480a8e4bcae63785d Mon Sep 17 00:00:00 2001 From: "Benjamin R. Hillman" Date: Fri, 31 May 2024 11:38:08 -0600 Subject: [PATCH 9/9] Need non-zero eff_radius for COSP standalone --- components/eamxx/tests/single-process/cosp/input.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/eamxx/tests/single-process/cosp/input.yaml b/components/eamxx/tests/single-process/cosp/input.yaml index 5b3b2787943..c6b79c01982 100644 --- a/components/eamxx/tests/single-process/cosp/input.yaml +++ b/components/eamxx/tests/single-process/cosp/input.yaml @@ -28,8 +28,8 @@ initial_conditions: dtau067: 1.0 dtau105: 1.0 cldfrac_rad: 0.5 - eff_radius_qc: 0.0 - eff_radius_qi: 0.0 + eff_radius_qc: 10.0 + eff_radius_qi: 10.0 sunlit: 1.0 surf_radiative_T: 288.0 pseudo_density: 1.0