Skip to content

Commit

Permalink
set up twmo test
Browse files Browse the repository at this point in the history
  • Loading branch information
jaelynlitz committed Oct 6, 2023
1 parent 55b3498 commit a81290b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/mam4xx/tropopause.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ void get_dtdz(const Real pm, const Real pmk, const Real pmid1d_up,
dtdz = cnst_faktor * dtdp * pm / tm;

} // get_dtdz
// FIXME: move to tropopause.hpp
/* This routine is an implementation of Reichler et al. [2003] done by
! Reichler and downloaded from his web site. Minimal modifications were
! made to have the routine work within the CAM framework (i.e. using
Expand Down Expand Up @@ -197,7 +196,6 @@ void twmo(const ConstColumnView &temp1d, const ConstColumnView &pmid1d, const Re
} // kk

} // twmo
// FIXME: move to tropopause.hpp
// This routine uses an implementation of Reichler et al. [2003] done by
// Reichler and downloaded from his web site. This is similar to the WMO
// routines, but is designed for GCMs with a coarse vertical grid.
Expand Down
3 changes: 3 additions & 0 deletions src/validation/tropopause/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include_directories(${PROJECT_BINARY_DIR}/validation)
add_executable(tropopause_driver
tropopause_driver.cpp
get_dtdz.cpp
twmo.cpp
)

target_link_libraries(tropopause_driver skywalker;validation;${HAERO_LIBRARIES})
Expand All @@ -28,12 +29,14 @@ endforeach()
# Run the driver in several configurations to produce datasets.
set(TEST_LIST
get_dtdz_merged
twmo_ts_1400
)
# # matching the tests and errors, just for convenience

set(DEFAULT_TOL 1e-13)
set(ERROR_THRESHOLDS
9e-3
1e-2
)
foreach(input tol IN ZIP_LISTS TEST_LIST ERROR_THRESHOLDS)
# copy the baseline file into place.
Expand Down
3 changes: 3 additions & 0 deletions src/validation/tropopause/tropopause_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ using namespace mam4;

// Parameterizations used by the tropopause() process.
void get_dtdz(Ensemble *ensemble);
void twmo(Ensemble *ensemble);
int main(int argc, char **argv) {
if (argc == 1) {
usage();
Expand All @@ -47,6 +48,8 @@ int main(int argc, char **argv) {
try {
if (func_name == "get_dtdz") {
get_dtdz(ensemble);
} else if(func_name == "twmo") {
twmo(ensemble);
} else {
std::cerr << "Error: Function name '" << func_name
<< "' does not have an implemented test!" << std::endl;
Expand Down
46 changes: 46 additions & 0 deletions src/validation/tropopause/twmo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// mam4xx: Copyright (c) 2022,
// Battelle Memorial Institute and
// National Technology & Engineering Solutions of Sandia, LLC (NTESS)
// SPDX-License-Identifier: BSD-3-Clause

#include <mam4xx/mam4.hpp>

#include <mam4xx/aero_config.hpp>
#include <skywalker.hpp>
#include <validation.hpp>

using namespace skywalker;
using namespace mam4;
using namespace haero;

void twmo(Ensemble *ensemble) {
ensemble->process([=](const Input &input, Output &output) {
using View1DHost = typename HostType::view_1d<Real>;
using ColumnView = haero::ColumnView;
constexpr int pver = mam4::nlev;

const auto pmid1d_in = input.get_array("pmid1d");
const auto temp1d_in = input.get_array("temp1d");
const Real plimu = input.get_array("plimu")[0];
const Real pliml = input.get_array("pliml")[0];
const Real gam = input.get_array("gam")[0];
Real trp = input.get_array("trp")[0];
//const Real cnst_kap = input.get_array("cnst_kap")[0];
//const Real cnst_ka1 = input.get_array("cnst_ka1")[0];
//const Real cnst_faktor = input.get_array("cnst_faktor")[0];

ColumnView pmid1d, temp1d;
auto pmid1d_host = View1DHost((Real *)pmid1d_in.data(), pver);
auto temp1d_host = View1DHost((Real *)temp1d_in.data(), pver);
pmid1d = haero::testing::create_column_view(pver);
temp1d = haero::testing::create_column_view(pver);
Kokkos::deep_copy(pmid1d, pmid1d_host);
Kokkos::deep_copy(temp1d, temp1d_host);

std::cout << "trp: " << trp << std::endl;

tropopause::twmo(temp1d, pmid1d, plimu, pliml, gam, trp);

output.set("trp", trp);
});
}

0 comments on commit a81290b

Please sign in to comment.