From 1062373c639fdf3a5c8860f9bf80e1266b3b2986 Mon Sep 17 00:00:00 2001 From: Aaron Donahue Date: Tue, 5 Nov 2024 14:38:08 -0800 Subject: [PATCH] Expose EAMxx to the git-version hash saved in the component cpl. This commit retrieves the git-hash saved in the component coupler and makes sure it is passed into the atmosphere driver. This is then used to improve the netcdf metadata in all EAMxx output files. --- components/eamxx/src/control/atmosphere_driver.cpp | 7 +++++-- components/eamxx/src/control/atmosphere_driver.hpp | 3 ++- components/eamxx/src/mct_coupling/atm_comp_mct.F90 | 10 ++++++---- .../src/mct_coupling/scream_cxx_f90_interface.cpp | 5 +++-- components/eamxx/src/mct_coupling/scream_f2c_mod.F90 | 6 ++++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/components/eamxx/src/control/atmosphere_driver.cpp b/components/eamxx/src/control/atmosphere_driver.cpp index 9cf2b48e358..0f1cb1e31ab 100644 --- a/components/eamxx/src/control/atmosphere_driver.cpp +++ b/components/eamxx/src/control/atmosphere_driver.cpp @@ -807,7 +807,8 @@ void AtmosphereDriver:: set_provenance_data (std::string caseid, std::string rest_caseid, std::string hostname, - std::string username) + std::string username, + std::string versionid) { #ifdef SCREAM_CIME_BUILD // Check the inputs are valid @@ -816,6 +817,7 @@ set_provenance_data (std::string caseid, "Error! Invalid restart case id: " + rest_caseid + "\n"); EKAT_REQUIRE_MSG (hostname!="", "Error! Invalid hostname: " + hostname + "\n"); EKAT_REQUIRE_MSG (username!="", "Error! Invalid username: " + username + "\n"); + EKAT_REQUIRE_MSG (versionid!="", "Error! Invalid version: " + versionid + "\n"); #else caseid = rest_caseid = m_casename; char* user = new char[32]; @@ -835,13 +837,14 @@ set_provenance_data (std::string caseid, } delete[] user; delete[] host; + versionid = EAMXX_GIT_VERSION; #endif auto& provenance = m_atm_params.sublist("provenance"); provenance.set("caseid",caseid); provenance.set("rest_caseid",rest_caseid); provenance.set("hostname",hostname); provenance.set("username",username); - provenance.set("version",std::string(EAMXX_GIT_VERSION)); + provenance.set("git_version",versionid); } void AtmosphereDriver:: diff --git a/components/eamxx/src/control/atmosphere_driver.hpp b/components/eamxx/src/control/atmosphere_driver.hpp index 41801745ea2..a3acfba5d94 100644 --- a/components/eamxx/src/control/atmosphere_driver.hpp +++ b/components/eamxx/src/control/atmosphere_driver.hpp @@ -116,7 +116,8 @@ class AtmosphereDriver void set_provenance_data (std::string caseid = "", std::string rest_caseid = "", std::string hostname = "", - std::string username = ""); + std::string username = "", + std::string versionid = ""); // Load initial conditions for atm inputs void initialize_fields (); diff --git a/components/eamxx/src/mct_coupling/atm_comp_mct.F90 b/components/eamxx/src/mct_coupling/atm_comp_mct.F90 index eb9165c2acb..0a248a2b608 100644 --- a/components/eamxx/src/mct_coupling/atm_comp_mct.F90 +++ b/components/eamxx/src/mct_coupling/atm_comp_mct.F90 @@ -137,8 +137,8 @@ subroutine atm_init_mct( EClock, cdata, x2a, a2x, NLFilename ) ! TODO: read this from the namelist? character(len=256) :: yaml_fname = "./data/scream_input.yaml" character(kind=c_char,len=256), target :: yaml_fname_c, atm_log_fname_c - character(len=256) :: caseid, username, hostname, rest_caseid - character(kind=c_char,len=256), target :: caseid_c, username_c, hostname_c, calendar_c, rest_caseid_c + character(len=256) :: caseid, username, hostname, rest_caseid, versionid + character(kind=c_char,len=256), target :: caseid_c, username_c, hostname_c, calendar_c, rest_caseid_c, versionid_c integer (kind=c_int) :: run_type_c !------------------------------------------------------------------------------- @@ -151,7 +151,8 @@ subroutine atm_init_mct( EClock, cdata, x2a, a2x, NLFilename ) infodata=infodata) call seq_infodata_getData(infodata, atm_phase=phase, start_type=run_type, & username=username, case_name=caseid, & - rest_case_name=rest_caseid, hostname=hostname) + rest_case_name=rest_caseid, hostname=hostname, & + model_version=versionid) call seq_infodata_PutData(infodata, atm_aero=.true.) call seq_infodata_PutData(infodata, atm_prognostic=.true.) @@ -213,10 +214,11 @@ subroutine atm_init_mct( EClock, cdata, x2a, a2x, NLFilename ) call string_f2c(trim(rest_caseid),rest_caseid_c) call string_f2c(trim(hostname),hostname_c) call string_f2c(trim(username),username_c) + call string_f2c(trim(versionid),versionid_c) call scream_create_atm_instance (mpicom_atm, ATM_ID, yaml_fname_c, atm_log_fname_c, run_type_c, & INT(cur_ymd,kind=C_INT), INT(cur_tod,kind=C_INT), & INT(case_start_ymd,kind=C_INT), INT(case_start_tod,kind=C_INT), & - calendar_c, caseid_c, rest_caseid_c, hostname_c, username_c) + calendar_c, caseid_c, rest_caseid_c, hostname_c, username_c, versionid_c) ! Init MCT gsMap call atm_Set_gsMap_mct (mpicom_atm, ATM_ID, gsMap_atm) diff --git a/components/eamxx/src/mct_coupling/scream_cxx_f90_interface.cpp b/components/eamxx/src/mct_coupling/scream_cxx_f90_interface.cpp index 1e51aa47a36..8d2edd5ee9f 100644 --- a/components/eamxx/src/mct_coupling/scream_cxx_f90_interface.cpp +++ b/components/eamxx/src/mct_coupling/scream_cxx_f90_interface.cpp @@ -110,7 +110,8 @@ void scream_create_atm_instance (const MPI_Fint f_comm, const int atm_id, const char* caseid, const char* rest_caseid, const char* hostname, - const char* username) + const char* username, + const char* versionid) { using namespace scream; using namespace scream::control; @@ -176,7 +177,7 @@ void scream_create_atm_instance (const MPI_Fint f_comm, const int atm_id, ad.set_params(scream_params); ad.init_scorpio(atm_id); ad.init_time_stamps(run_t0,case_t0,run_type); - ad.set_provenance_data (caseid,rest_caseid,hostname,username); + ad.set_provenance_data (caseid,rest_caseid,hostname,username,versionid); ad.create_output_managers (); ad.create_atm_processes (); ad.create_grids (); diff --git a/components/eamxx/src/mct_coupling/scream_f2c_mod.F90 b/components/eamxx/src/mct_coupling/scream_f2c_mod.F90 index 5adb0825041..434639e8f82 100644 --- a/components/eamxx/src/mct_coupling/scream_f2c_mod.F90 +++ b/components/eamxx/src/mct_coupling/scream_f2c_mod.F90 @@ -18,7 +18,8 @@ subroutine scream_create_atm_instance (f_comm,atm_id,yaml_fname,atm_log_fname, & run_start_ymd,run_start_tod, & case_start_ymd,case_start_tod, & calendar_name, & - caseid, rest_caseid, hostname, username) bind(c) + caseid, rest_caseid, hostname, username, & + versionid) bind(c) use iso_c_binding, only: c_int, c_char ! ! Input(s) @@ -27,7 +28,8 @@ subroutine scream_create_atm_instance (f_comm,atm_id,yaml_fname,atm_log_fname, & integer (kind=c_int), value, intent(in) :: run_start_tod, run_start_ymd integer (kind=c_int), value, intent(in) :: case_start_tod, case_start_ymd character(kind=c_char), target, intent(in) :: yaml_fname(*), atm_log_fname(*), calendar_name(*), & - caseid(*), rest_caseid(*), hostname(*), username(*) + caseid(*), rest_caseid(*), hostname(*), username(*), & + versionid(*) end subroutine scream_create_atm_instance subroutine scream_get_cols_latlon (lat, lon) bind(c)