Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big rework of P3 around new BFB baseline unit tests #3096

Merged
merged 30 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0e5ef84
Refactor cmake
jgfouca Oct 31, 2024
48ea3a9
progress
jgfouca Oct 31, 2024
7f9aaac
Transition to object complete
jgfouca Oct 31, 2024
4d404f9
rain_sed working
jgfouca Oct 31, 2024
f669e8b
Upwind working
jgfouca Nov 1, 2024
cda50ba
p3_unit_tests and macro cleanup
jgfouca Nov 1, 2024
c3560ef
p3_cloud_water_autoconversion_test
jgfouca Nov 1, 2024
cd28419
p3_back_to_cell_average was not following the standard pattern
jgfouca Nov 1, 2024
a287040
p3_back_to_cell_average
jgfouca Nov 1, 2024
eae74a8
Two more easy ones
jgfouca Nov 1, 2024
ac5851d
Four more
jgfouca Nov 1, 2024
3a64d91
get_latent_heat is not being used on the cxx side
jgfouca Nov 1, 2024
dd7f453
More
jgfouca Nov 1, 2024
343c6d6
More
jgfouca Nov 1, 2024
e166eaa
All bfb unit tests complete
jgfouca Nov 4, 2024
a2b0af0
p3_run_and_cmp fixed up
jgfouca Nov 4, 2024
5e46e33
Progress. Can not remove fortran
jgfouca Nov 4, 2024
58b70ac
Remove most of the f90 bridges
jgfouca Nov 4, 2024
576d7b4
Rename FortranData
jgfouca Nov 4, 2024
312ee63
reorg
jgfouca Nov 5, 2024
3c2c875
More reorg
jgfouca Nov 5, 2024
6caafa3
Fix typo
jgfouca Nov 5, 2024
2b6fd04
pre sed
jgfouca Nov 7, 2024
68edf0c
seds
jgfouca Nov 7, 2024
037d5af
seds
jgfouca Nov 7, 2024
abf91a6
Fix bug
jgfouca Nov 7, 2024
23dbd2e
Minor fixes
jgfouca Nov 7, 2024
03630d3
Another minor fix
jgfouca Nov 8, 2024
bf6aeb7
Merge remote-tracking branch 'origin/master' into jgfouca/bfb_unit_no…
jgfouca Nov 11, 2024
e779856
Update based on better ekat flag handling
jgfouca Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions components/eamxx/src/physics/p3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
set(P3_SRCS
p3_f90.cpp
p3_ic_cases.cpp
p3_iso_c.f90
${SCREAM_BASE_DIR}/../eam/src/physics/p3/scream/micro_p3.F90
eamxx_p3_process_interface.cpp
eamxx_p3_run.cpp
)

if (NOT SCREAM_LIB_ONLY)
list(APPEND P3_SRCS
p3_functions_f90.cpp
p3_main_wrap.cpp
) # Add f90 bridges needed for testing
endif()

# Add ETI source files if not on CUDA/HIP
if (NOT EAMXX_ENABLE_GPU OR Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE OR Kokkos_ENABLE_HIP_RELOCATABLE_DEVICE_CODE)
list(APPEND P3_SRCS
Expand All @@ -27,6 +18,7 @@ if (NOT EAMXX_ENABLE_GPU OR Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE OR Kokkos
eti/p3_table_ice.cpp
eti/p3_dsd2.cpp
eti/p3_find.cpp
eti/p3_init.cpp
eti/p3_update_prognostics.cpp
eti/p3_get_time_space_phys_variables.cpp
eti/p3_autoconversion.cpp
Expand Down Expand Up @@ -123,11 +115,6 @@ endforeach()
add_executable(p3_tables_setup EXCLUDE_FROM_ALL p3_tables_setup.cpp)
target_link_libraries(p3_tables_setup p3)

#crusher change
if (Kokkos_ENABLE_HIP)
set_source_files_properties(p3_functions_f90.cpp PROPERTIES COMPILE_FLAGS -O0)
endif()

if (NOT SCREAM_LIB_ONLY)
add_subdirectory(tests)
endif()
Expand Down
10 changes: 4 additions & 6 deletions components/eamxx/src/physics/p3/eamxx_p3_process_interface.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "physics/p3/eamxx_p3_process_interface.hpp"
#include "share/property_checks/field_within_interval_check.hpp"
#include "share/property_checks/field_lower_bound_check.hpp"
// Needed for p3_init, the only F90 code still used.
#include "physics/p3/p3_functions.hpp"
#include "physics/p3/p3_f90.hpp"
#include "p3_functions.hpp"
#include "eamxx_p3_process_interface.hpp"

#include "ekat/ekat_assert.hpp"
#include "ekat/util/ekat_units.hpp"
Expand Down Expand Up @@ -243,8 +241,8 @@ void P3Microphysics::initialize_impl (const RunType /* run_type */)
add_postcondition_check<FieldWithinIntervalCheck>(get_field_out("eff_radius_qr"),m_grid,0.0,5.0e3,false);

// Initialize p3
p3::p3_init(/* write_tables = */ false,
this->get_comm().am_i_root());
P3F::p3_init(/* write_tables = */ false,
this->get_comm().am_i_root());

// Initialize all of the structures that are passed to p3_main in run_impl.
// Note: Some variables in the structures are not stored in the field manager. For these
Expand Down
14 changes: 14 additions & 0 deletions components/eamxx/src/physics/p3/eti/p3_init.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "p3_init_impl.hpp"

namespace scream {
namespace p3 {

/*
* Explicit instantiation for doing find functions on Reals using the
* default device.
*/

template struct Functions<Real,DefaultDevice>;

} // namespace p3
} // namespace scream
40 changes: 40 additions & 0 deletions components/eamxx/src/physics/p3/impl/p3_init_impl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef P3_INIT_IMPL_HPP
#define P3_INIT_IMPL_HPP

#include "p3_functions.hpp" // for ETI only but harmless for GPU

extern "C" {
void micro_p3_utils_init_c(scream::Real Cpair, scream::Real Rair, scream::Real RH2O, scream::Real RHO_H2O,
scream::Real MWH2O, scream::Real MWdry, scream::Real gravit, scream::Real LatVap, scream::Real LatIce,
scream::Real CpLiq, scream::Real Tmelt, scream::Real Pi, bool masterproc);
void p3_init_c(const char** lookup_file_dir, int* info, const bool& write_tables);
}

namespace scream {
namespace p3 {

/*
* Implementation of p3 init. Clients should NOT #include
* this file, #include p3_functions.hpp instead.
*/
template <typename S, typename D>
void Functions<S,D>
::p3_init (const bool write_tables, const bool masterproc) {
static bool is_init = false;
if (!is_init) {
using c = scream::physics::Constants<Real>;
micro_p3_utils_init_c(c::Cpair, c::Rair, c::RH2O, c::RHO_H2O,
c::MWH2O, c::MWdry, c::gravit, c::LatVap, c::LatIce,
c::CpLiq, c::Tmelt, c::Pi, masterproc);
static const char* dir = SCREAM_DATA_DIR "/tables";
Int info;
p3_init_c(&dir, &info, write_tables);
EKAT_REQUIRE_MSG(info == 0, "p3_init_c returned info " << info);
is_init = true;
}
}

} // namespace p3
} // namespace scream

#endif
4 changes: 4 additions & 0 deletions components/eamxx/src/physics/p3/p3_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ struct Functions
static void init_kokkos_ice_lookup_tables(
view_ice_table& ice_table_vals, view_collect_table& collect_table_vals);

static void p3_init(const bool write_tables = false,
const bool masterproc = false);

// Map (mu_r, lamr) to Table3 data.
KOKKOS_FUNCTION
static void lookup(const Spack& mu_r, const Spack& lamr,
Expand Down Expand Up @@ -1468,5 +1471,6 @@ void init_tables_from_f90_c(Real* vn_table_vals_data, Real* vm_table_vals_data,
# include "p3_nr_conservation_impl.hpp"
# include "p3_ni_conservation_impl.hpp"
# include "p3_prevent_liq_supersaturation_impl.hpp"
# include "p3_init_impl.hpp"
#endif // GPU && !KOKKOS_ENABLE_*_RELOCATABLE_DEVICE_CODE
#endif // P3_FUNCTIONS_HPP
Loading
Loading