@@ -35,10 +35,15 @@ MAMMicrophysics::MAMMicrophysics(const ekat::Comm &comm,
35
35
config_.amicphys .newnuc_h2so4_conc_optaa = 2 ;
36
36
37
37
// LINOZ namelist parameters
38
- config_.linoz .o3_lbl = m_params.get <int >(" mam4_o3_lbl" );
39
- config_.linoz .o3_tau = m_params.get <double >(" mam4_o3_tau" );
40
- config_.linoz .o3_sfc = m_params.get <double >(" mam4_o3_sfc" );
41
- config_.linoz .psc_T = m_params.get <double >(" mam4_psc_T" );
38
+ config_.linoz .compute = m_params.get <bool >(" mam4_run_linoz" , true );
39
+
40
+ if (config_.linoz .compute ) {
41
+ config_.linoz .o3_lbl = m_params.get <int >(" mam4_o3_lbl" );
42
+ config_.linoz .o3_tau = m_params.get <double >(" mam4_o3_tau" );
43
+ config_.linoz .o3_sfc = m_params.get <double >(" mam4_o3_sfc" );
44
+ config_.linoz .psc_T = m_params.get <double >(" mam4_psc_T" );
45
+ }
46
+
42
47
}
43
48
// ================================================================
44
49
// SET_GRIDS
@@ -231,7 +236,7 @@ void MAMMicrophysics::set_grids(
231
236
232
237
// Creating a Linoz reader and setting Linoz parameters involves reading data
233
238
// from a file and configuring the necessary parameters for the Linoz model.
234
- {
239
+ if (config_. linoz . compute ) {
235
240
linoz_file_name_ = m_params.get <std::string>(" mam4_linoz_file_name" );
236
241
const std::string linoz_map_file =
237
242
m_params.get <std::string>(" aero_microphys_remap_file" , " " );
@@ -383,6 +388,7 @@ void MAMMicrophysics::set_grids(
383
388
mam_coupling::find_season_index_reader (season_wes_file, clat,
384
389
index_season_lai_);
385
390
}
391
+
386
392
} // set_grids
387
393
388
394
// ================================================================
@@ -531,39 +537,39 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
531
537
// the units are mixed and the user should be careful when using these fields.
532
538
// Following map contains the map of fields with mixed units and their long names.
533
539
const std::map<std::string, std::string> mixed_units_fields = {
534
- {" mam4_microphysics_tendency_gas_phase_chemistry" ,
540
+ {" mam4_microphysics_tendency_gas_phase_chemistry" ,
535
541
" MAM4xx microphysics tendencies due to gas phase chemistry [mixed units: kg/kg/s or #/kg/s]" },
536
542
537
543
{" mam4_microphysics_tendency_aqueous_chemistry" ,
538
544
" MAM4xx microphysics tendencies due to aqueous chemistry [mixed units: kg/kg/s or #/kg/s]" },
539
545
540
- {" mam4_microphysics_tendency_aqso4" ,
546
+ {" mam4_microphysics_tendency_aqso4" ,
541
547
" MAM4xx microphysics tendencies due to aqueous SO4 [mixed units: kg/kg/s or #/kg/s]" },
542
548
543
- {" mam4_microphysics_tendency_aqh2so4" ,
549
+ {" mam4_microphysics_tendency_aqh2so4" ,
544
550
" MAM4xx microphysics tendencies due to aqueous H2SO4 [mixed units: kg/kg/s or #/kg/s]" },
545
551
546
- {" mam4_microphysics_tendency_condensation" ,
552
+ {" mam4_microphysics_tendency_condensation" ,
547
553
" MAM4xx microphysics tendencies due to gas aerosol exchange (condensation) [mixed units: mol/mol/s or #/mol/s]" },
548
554
549
- {" mam4_microphysics_tendency_renaming" ,
555
+ {" mam4_microphysics_tendency_renaming" ,
550
556
" MAM4xx microphysics tendencies due to gas aerosol exchange (renaming) [mixed units: mol/mol/s or #/mol/s]" },
551
557
552
- {" mam4_microphysics_tendency_nucleation" ,
558
+ {" mam4_microphysics_tendency_nucleation" ,
553
559
" MAM4xx microphysics tendencies due to gas aerosol exchange (nucleation) [mixed units: mol/mol/s or #/mol/s]" },
554
560
555
- {" mam4_microphysics_tendency_coagulation" ,
561
+ {" mam4_microphysics_tendency_coagulation" ,
556
562
" MAM4xx microphysics tendencies due to gas aerosol exchange (coagulation) [mixed units: mol/mol/s or #/mol/s]" },
557
563
558
- {" mam4_microphysics_tendency_renaming_cloud_borne" ,
564
+ {" mam4_microphysics_tendency_renaming_cloud_borne" ,
559
565
" MAM4xx microphysics tendencies due to gas aerosol exchange (renaming cloud borne) [mixed units: mol/mol/s or #/mol/s]" },
560
-
566
+
561
567
};
562
568
// Add docstring to the fields with mixed units
563
569
add_io_docstring_to_fields_with_mixed_units (mixed_units_fields);
564
570
}
565
571
566
-
572
+
567
573
// set field property checks for the fields in this process
568
574
/* e.g.
569
575
using Interval = FieldWithinIntervalCheck;
@@ -574,7 +580,7 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
574
580
add_postcondition_check<LowerBound>(get_field_out("tke"),m_grid,0);
575
581
*/
576
582
577
- {
583
+ if (config_. linoz . compute ) {
578
584
// climatology data for linear stratospheric chemistry
579
585
auto linoz_o3_clim = buffer_.scratch [0 ]; // ozone (climatology) [vmr]
580
586
auto linoz_o3col_clim =
@@ -599,7 +605,7 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
599
605
scream::mam_coupling::create_linoz_chlorine_reader (
600
606
linoz_chlorine_file, ts, chlorine_loading_ymd, chlorine_values_,
601
607
chlorine_time_secs_);
602
- } // LINOZ
608
+ }
603
609
604
610
init_temporary_views ();
605
611
// FIXME : why are we only using nlev_ instead of ncol_xnlev?
@@ -608,10 +614,10 @@ void MAMMicrophysics::initialize_impl(const RunType run_type) {
608
614
// Note: At the first time step, the data will be moved into extfrc_lst_beg,
609
615
// and extfrc_lst_end will be reloaded from file with the new month.
610
616
const int curr_month = start_of_step_ts ().get_month () - 1 ; // 0-based
611
-
612
- scream::mam_coupling::update_tracer_data_from_file (
617
+ if (config_. linoz . compute ) {
618
+ scream::mam_coupling::update_tracer_data_from_file (
613
619
LinozDataReader_, curr_month, *LinozHorizInterp_, linoz_data_);
614
-
620
+ }
615
621
scream::mam_coupling::update_tracer_data_from_file (
616
622
TracerDataReader_, curr_month, *TracerHorizInterp_, tracer_data_);
617
623
@@ -730,38 +736,44 @@ void MAMMicrophysics::run_impl(const double dt) {
730
736
731
737
// climatology data for linear stratospheric chemistry
732
738
// ozone (climatology) [vmr]
733
- auto linoz_o3_clim = buffer_. scratch [ 0 ] ;
739
+ view_2d linoz_o3_clim;
734
740
// column o3 above box (climatology) [Dobson Units (DU)]
735
- auto linoz_o3col_clim = buffer_.scratch [1 ];
736
- auto linoz_t_clim = buffer_.scratch [2 ]; // temperature (climatology) [K]
737
- auto linoz_PmL_clim = buffer_.scratch [3 ]; // P minus L (climatology) [vmr/s]
741
+ view_2d linoz_o3col_clim;
742
+ // temperature (climatology) [K]
743
+ view_2d linoz_t_clim;
744
+ // P minus L (climatology) [vmr/s]
745
+ view_2d linoz_PmL_clim;
738
746
// sensitivity of P minus L to O3 [1/s]
739
- auto linoz_dPmL_dO3 = buffer_. scratch [ 4 ] ;
747
+ view_2d linoz_dPmL_dO3;
740
748
// sensitivity of P minus L to T3 [K]
741
- auto linoz_dPmL_dT = buffer_. scratch [ 5 ] ;
749
+ view_2d linoz_dPmL_dT;
742
750
// sensitivity of P minus L to overhead O3 column [vmr/DU]
743
- auto linoz_dPmL_dO3col = buffer_. scratch [ 6 ] ;
751
+ view_2d linoz_dPmL_dO3col;
744
752
// Cariolle parameter for PSC loss of ozone [1/s]
745
- auto linoz_cariolle_pscs = buffer_.scratch [7 ];
746
-
747
- view_2d linoz_output[8 ];
748
- linoz_output[0 ] = linoz_o3_clim;
749
- linoz_output[1 ] = linoz_o3col_clim;
750
- linoz_output[2 ] = linoz_t_clim;
751
- linoz_output[3 ] = linoz_PmL_clim;
752
- linoz_output[4 ] = linoz_dPmL_dO3;
753
- linoz_output[5 ] = linoz_dPmL_dT;
754
- linoz_output[6 ] = linoz_dPmL_dO3col;
755
- linoz_output[7 ] = linoz_cariolle_pscs;
753
+ view_2d linoz_cariolle_pscs;
754
+
755
+ if (config_.linoz .compute ) {
756
+ linoz_o3_clim = buffer_.scratch [0 ];
757
+ linoz_o3col_clim = buffer_.scratch [1 ];
758
+ linoz_t_clim = buffer_.scratch [2 ];
759
+ linoz_PmL_clim = buffer_.scratch [3 ];
760
+ linoz_dPmL_dO3 = buffer_.scratch [4 ];
761
+ linoz_dPmL_dT = buffer_.scratch [5 ];
762
+ linoz_dPmL_dO3col = buffer_.scratch [6 ];
763
+ linoz_cariolle_pscs = buffer_.scratch [7 ];
764
+ }
756
765
// it's a bit wasteful to store this for all columns, but simpler from an
757
766
// allocation perspective
758
767
auto o3_col_dens = buffer_.scratch [8 ];
759
768
760
769
/* Gather time and state information for interpolation */
761
770
const auto ts = end_of_step_ts ();
762
771
772
+ if (config_.linoz .compute ) {
763
773
const Real chlorine_loading = scream::mam_coupling::chlorine_loading_advance (
764
774
ts, chlorine_values_, chlorine_time_secs_);
775
+ config_.linoz .chlorine_loading =chlorine_loading;
776
+ }
765
777
766
778
// Update the TracerTimeState to reflect the current time
767
779
trace_time_state_.t_now = ts.frac_of_year_in_days ();
@@ -774,15 +786,26 @@ void MAMMicrophysics::run_impl(const double dt) {
774
786
cnst_offline_); // out
775
787
Kokkos::fence ();
776
788
777
- scream::mam_coupling::advance_tracer_data (
789
+ if (config_.linoz .compute ) {
790
+ view_2d linoz_output[8 ];
791
+ linoz_output[0 ] = linoz_o3_clim;
792
+ linoz_output[1 ] = linoz_o3col_clim;
793
+ linoz_output[2 ] = linoz_t_clim;
794
+ linoz_output[3 ] = linoz_PmL_clim;
795
+ linoz_output[4 ] = linoz_dPmL_dO3;
796
+ linoz_output[5 ] = linoz_dPmL_dT;
797
+ linoz_output[6 ] = linoz_dPmL_dO3col;
798
+ linoz_output[7 ] = linoz_cariolle_pscs;
799
+
800
+ scream::mam_coupling::advance_tracer_data (
778
801
LinozDataReader_, // in
779
802
*LinozHorizInterp_, // out
780
803
ts, // in
781
804
linoz_time_state_, linoz_data_, // out
782
805
dry_atm_.p_mid , dry_atm_.z_iface , // in
783
806
linoz_output); // out
784
- Kokkos::fence ();
785
-
807
+ Kokkos::fence ();
808
+ }
786
809
787
810
int i = 0 ;
788
811
for (const auto &var_name : extfrc_lst_) {
@@ -804,6 +827,7 @@ void MAMMicrophysics::run_impl(const double dt) {
804
827
mam_coupling::DryAtmosphere &dry_atm = dry_atm_;
805
828
mam_coupling::AerosolState &dry_aero = dry_aero_;
806
829
830
+
807
831
mam4::mo_photo::PhotoTableData &photo_table = photo_table_;
808
832
const Config &config = config_;
809
833
const auto &work_photo_table = work_photo_table_;
@@ -894,10 +918,10 @@ void MAMMicrophysics::run_impl(const double dt) {
894
918
const auto &index_season_lai = index_season_lai_;
895
919
const int pcnst = mam4::pcnst;
896
920
const bool extra_mam4_aero_microphys_diags = extra_mam4_aero_microphys_diags_;
897
-
898
921
// NOTE: we need to initialize photo_rates_
899
922
Kokkos::deep_copy (photo_rates_,0.0 );
900
- // loop over atmosphere columns and compute aerosol microphyscs
923
+ // loop over atmosphere columns and compute aerosol microphysics
924
+
901
925
Kokkos::parallel_for (
902
926
" MAMMicrophysics::run_impl" , policy,
903
927
KOKKOS_LAMBDA (const ThreadTeam &team) {
@@ -943,7 +967,6 @@ void MAMMicrophysics::run_impl(const double dt) {
943
967
for (int i = 0 ; i < mam4::mo_setinv::num_tracer_cnst; ++i) {
944
968
cnst_offline_icol[i] = ekat::subview (cnst_offline[i], icol);
945
969
}
946
-
947
970
// calculate o3 column densities (first component of col_dens in Fortran
948
971
// code)
949
972
auto o3_col_dens_i = ekat::subview (o3_col_dens, icol);
@@ -952,17 +975,20 @@ void MAMMicrophysics::run_impl(const double dt) {
952
975
953
976
const auto &photo_rates_icol = ekat::subview (photo_rates, icol);
954
977
955
- const auto linoz_o3_clim_icol = ekat::subview (linoz_o3_clim, icol);
956
- const auto linoz_t_clim_icol = ekat::subview (linoz_t_clim, icol);
957
- const auto linoz_o3col_clim_icol =
978
+ mam4::microphysics::LinozData linoz_data;
979
+ if (config.linoz .compute ) {
980
+ linoz_data.linoz_o3_clim_icol = ekat::subview (linoz_o3_clim, icol);
981
+ linoz_data.linoz_t_clim_icol = ekat::subview (linoz_t_clim, icol);
982
+ linoz_data.linoz_o3col_clim_icol =
958
983
ekat::subview (linoz_o3col_clim, icol);
959
- const auto linoz_PmL_clim_icol = ekat::subview (linoz_PmL_clim, icol);
960
- const auto linoz_dPmL_dO3_icol = ekat::subview (linoz_dPmL_dO3, icol);
961
- const auto linoz_dPmL_dT_icol = ekat::subview (linoz_dPmL_dT, icol);
962
- const auto linoz_dPmL_dO3col_icol =
984
+ linoz_data. linoz_PmL_clim_icol = ekat::subview (linoz_PmL_clim, icol);
985
+ linoz_data. linoz_dPmL_dO3_icol = ekat::subview (linoz_dPmL_dO3, icol);
986
+ linoz_data. linoz_dPmL_dT_icol = ekat::subview (linoz_dPmL_dT, icol);
987
+ linoz_data. linoz_dPmL_dO3col_icol =
963
988
ekat::subview (linoz_dPmL_dO3col, icol);
964
- const auto linoz_cariolle_pscs_icol =
989
+ linoz_data. linoz_cariolle_pscs_icol =
965
990
ekat::subview (linoz_cariolle_pscs, icol);
991
+ }
966
992
const auto nevapr_icol = ekat::subview (nevapr, icol);
967
993
const auto prain_icol = ekat::subview (prain, icol);
968
994
const auto work_set_het_icol = ekat::subview (work_set_het, icol);
@@ -1036,16 +1062,15 @@ void MAMMicrophysics::run_impl(const double dt) {
1036
1062
mam4::microphysics::perform_atmospheric_chemistry_and_microphysics (
1037
1063
team, dt, rlats, sfc_temperature (icol), sfc_pressure (icol),
1038
1064
wind_speed, rain, solar_flux, cnst_offline_icol, forcings_in, atm,
1039
- photo_table, chlorine_loading, config.setsox , config.amicphys ,
1040
- config. linoz . psc_T , zenith_angle (icol), d_sfc_alb_dir_vis (icol),
1065
+ photo_table, config.setsox , config.amicphys ,
1066
+ zenith_angle (icol), d_sfc_alb_dir_vis (icol),
1041
1067
o3_col_dens_i, photo_rates_icol, extfrc_icol, invariants_icol,
1042
- work_photo_table_icol, linoz_o3_clim_icol, linoz_t_clim_icol,
1043
- linoz_o3col_clim_icol, linoz_PmL_clim_icol, linoz_dPmL_dO3_icol,
1044
- linoz_dPmL_dT_icol, linoz_dPmL_dO3col_icol,
1045
- linoz_cariolle_pscs_icol, eccf, adv_mass_kg_per_moles,
1068
+ work_photo_table_icol,
1069
+ config.linoz , linoz_data,
1070
+ eccf, adv_mass_kg_per_moles,
1046
1071
fraction_landuse_icol, index_season, clsmap_4, permute_4,
1047
- offset_aerosol, config. linoz . o3_sfc , config. linoz . o3_tau ,
1048
- config. linoz . o3_lbl , dry_diameter_icol, wet_diameter_icol,
1072
+ offset_aerosol,
1073
+ dry_diameter_icol, wet_diameter_icol,
1049
1074
wetdens_icol, dry_atm.phis (icol), cmfdqr, prain_icol, nevapr_icol,
1050
1075
work_set_het_icol, drydep_data, aqso4_flx_col, aqh2so4_flx_col,
1051
1076
diag_arrays, dvel_col, dflx_col, progs);
@@ -1090,6 +1115,7 @@ void MAMMicrophysics::run_impl(const double dt) {
1090
1115
// postprocess output
1091
1116
post_process (wet_aero_, dry_aero_, dry_atm_);
1092
1117
Kokkos::fence ();
1118
+
1093
1119
} // MAMMicrophysics::run_impl
1094
1120
1095
1121
} // namespace scream
0 commit comments