Skip to content

Commit

Permalink
Merge Pull Request #2903 from E3SM-Project/scream/bogensch/dpxx_iop_l…
Browse files Browse the repository at this point in the history
…ev_fix

Automatically Merged using E3SM Pull Request AutoTester
PR Title: DPxx: IOP pressure level fix and fix to lat/lon relative error checking
PR Author: bogensch
PR LABELS: Non-B4B, AT: AUTOMERGE, bugfix, SCREAMv1, DP-SCREAM
  • Loading branch information
E3SM-Autotester authored Jul 17, 2024
2 parents 94496f4 + f2a7b97 commit 17dda18
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions components/eamxx/src/share/iop/intensive_observation_period.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ initialize_iop_file(const util::TimeStamp& run_t0,
scorpio::read_var(iop_file,"lon",&iop_file_lon);

const Real rel_lat_err = std::fabs(iop_file_lat - m_params.get<Real>("target_latitude"))/
m_params.get<Real>("target_latitude");
std::max(m_params.get<Real>("target_latitude"),(Real)0.1);
const Real rel_lon_err = std::fabs(std::fmod(iop_file_lon + 360.0, 360.0)-m_params.get<Real>("target_longitude"))/
m_params.get<Real>("target_longitude");
std::max(m_params.get<Real>("target_longitude"),(Real)0.1);
EKAT_REQUIRE_MSG(rel_lat_err < std::numeric_limits<float>::epsilon(),
"Error! IOP file variable \"lat\" does not match target_latitude from IOP parameters.\n");
EKAT_REQUIRE_MSG(rel_lon_err < std::numeric_limits<float>::epsilon(),
Expand Down Expand Up @@ -541,6 +541,14 @@ read_iop_file_data (const util::TimeStamp& current_ts)
scorpio::read_var(iop_file,"Ps",ps_data,iop_file_time_idx);
surface_pressure.sync_to_dev();

// Read in IOP lev data
auto data = iop_file_pressure.get_view<Real*, Host>().data();
scorpio::read_var(iop_file,"lev",data);

// Convert to pressure to millibar (file gives pressure in Pa)
for (int ilev=0; ilev<file_levs; ++ilev) data[ilev] /= 100;
iop_file_pressure.sync_to_dev();

// Pre-process file pressures, store number of file levels
// where the last level is the first level equal to surface pressure.
const auto iop_file_pres_v = iop_file_pressure.get_view<Real*>();
Expand Down

0 comments on commit 17dda18

Please sign in to comment.