Skip to content

Commit 0fbd70f

Browse files
committed
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.
1 parent 397aaff commit 0fbd70f

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

components/eamxx/src/control/atmosphere_driver.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,8 @@ void AtmosphereDriver::
807807
set_provenance_data (std::string caseid,
808808
std::string rest_caseid,
809809
std::string hostname,
810-
std::string username)
810+
std::string username,
811+
std::string versionid)
811812
{
812813
#ifdef SCREAM_CIME_BUILD
813814
// Check the inputs are valid
@@ -816,6 +817,7 @@ set_provenance_data (std::string caseid,
816817
"Error! Invalid restart case id: " + rest_caseid + "\n");
817818
EKAT_REQUIRE_MSG (hostname!="", "Error! Invalid hostname: " + hostname + "\n");
818819
EKAT_REQUIRE_MSG (username!="", "Error! Invalid username: " + username + "\n");
820+
EKAT_REQUIRE_MSG (versionid!="", "Error! Invalid version: " + versionid + "\n");
819821
#else
820822
caseid = rest_caseid = m_casename;
821823
char* user = new char[32];
@@ -835,13 +837,14 @@ set_provenance_data (std::string caseid,
835837
}
836838
delete[] user;
837839
delete[] host;
840+
versionid = EAMXX_GIT_VERSION;
838841
#endif
839842
auto& provenance = m_atm_params.sublist("provenance");
840843
provenance.set("caseid",caseid);
841844
provenance.set("rest_caseid",rest_caseid);
842845
provenance.set("hostname",hostname);
843846
provenance.set("username",username);
844-
provenance.set("version",std::string(EAMXX_GIT_VERSION));
847+
provenance.set("git_version",versionid);
845848
}
846849

847850
void AtmosphereDriver::

components/eamxx/src/control/atmosphere_driver.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class AtmosphereDriver
116116
void set_provenance_data (std::string caseid = "",
117117
std::string rest_caseid = "",
118118
std::string hostname = "",
119-
std::string username = "");
119+
std::string username = "",
120+
std::string versionid = "");
120121

121122
// Load initial conditions for atm inputs
122123
void initialize_fields ();

components/eamxx/src/mct_coupling/atm_comp_mct.F90

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ subroutine atm_init_mct( EClock, cdata, x2a, a2x, NLFilename )
137137
! TODO: read this from the namelist?
138138
character(len=256) :: yaml_fname = "./data/scream_input.yaml"
139139
character(kind=c_char,len=256), target :: yaml_fname_c, atm_log_fname_c
140-
character(len=256) :: caseid, username, hostname, rest_caseid
141-
character(kind=c_char,len=256), target :: caseid_c, username_c, hostname_c, calendar_c, rest_caseid_c
140+
character(len=256) :: caseid, username, hostname, rest_caseid, versionid
141+
character(kind=c_char,len=256), target :: caseid_c, username_c, hostname_c, calendar_c, rest_caseid_c, versionid_c
142142
integer (kind=c_int) :: run_type_c
143143
!-------------------------------------------------------------------------------
144144

@@ -151,7 +151,8 @@ subroutine atm_init_mct( EClock, cdata, x2a, a2x, NLFilename )
151151
infodata=infodata)
152152
call seq_infodata_getData(infodata, atm_phase=phase, start_type=run_type, &
153153
username=username, case_name=caseid, &
154-
rest_case_name=rest_caseid, hostname=hostname)
154+
rest_case_name=rest_caseid, hostname=hostname, &
155+
model_version=versionid)
155156
call seq_infodata_PutData(infodata, atm_aero=.true.)
156157
call seq_infodata_PutData(infodata, atm_prognostic=.true.)
157158

@@ -213,10 +214,11 @@ subroutine atm_init_mct( EClock, cdata, x2a, a2x, NLFilename )
213214
call string_f2c(trim(rest_caseid),rest_caseid_c)
214215
call string_f2c(trim(hostname),hostname_c)
215216
call string_f2c(trim(username),username_c)
217+
call string_f2c(trim(versionid),versionid_c)
216218
call scream_create_atm_instance (mpicom_atm, ATM_ID, yaml_fname_c, atm_log_fname_c, run_type_c, &
217219
INT(cur_ymd,kind=C_INT), INT(cur_tod,kind=C_INT), &
218220
INT(case_start_ymd,kind=C_INT), INT(case_start_tod,kind=C_INT), &
219-
calendar_c, caseid_c, rest_caseid_c, hostname_c, username_c)
221+
calendar_c, caseid_c, rest_caseid_c, hostname_c, username_c, versionid_c)
220222

221223
! Init MCT gsMap
222224
call atm_Set_gsMap_mct (mpicom_atm, ATM_ID, gsMap_atm)

components/eamxx/src/mct_coupling/scream_cxx_f90_interface.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ void scream_create_atm_instance (const MPI_Fint f_comm, const int atm_id,
110110
const char* caseid,
111111
const char* rest_caseid,
112112
const char* hostname,
113-
const char* username)
113+
const char* username,
114+
const char* versionid)
114115
{
115116
using namespace scream;
116117
using namespace scream::control;
@@ -176,7 +177,7 @@ void scream_create_atm_instance (const MPI_Fint f_comm, const int atm_id,
176177
ad.set_params(scream_params);
177178
ad.init_scorpio(atm_id);
178179
ad.init_time_stamps(run_t0,case_t0,run_type);
179-
ad.set_provenance_data (caseid,rest_caseid,hostname,username);
180+
ad.set_provenance_data (caseid,rest_caseid,hostname,username,versionid);
180181
ad.create_output_managers ();
181182
ad.create_atm_processes ();
182183
ad.create_grids ();

components/eamxx/src/mct_coupling/scream_f2c_mod.F90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ subroutine scream_create_atm_instance (f_comm,atm_id,yaml_fname,atm_log_fname, &
1818
run_start_ymd,run_start_tod, &
1919
case_start_ymd,case_start_tod, &
2020
calendar_name, &
21-
caseid, rest_caseid, hostname, username) bind(c)
21+
caseid, rest_caseid, hostname, username, &
22+
versionid) bind(c)
2223
use iso_c_binding, only: c_int, c_char
2324
!
2425
! Input(s)
@@ -27,7 +28,8 @@ subroutine scream_create_atm_instance (f_comm,atm_id,yaml_fname,atm_log_fname, &
2728
integer (kind=c_int), value, intent(in) :: run_start_tod, run_start_ymd
2829
integer (kind=c_int), value, intent(in) :: case_start_tod, case_start_ymd
2930
character(kind=c_char), target, intent(in) :: yaml_fname(*), atm_log_fname(*), calendar_name(*), &
30-
caseid(*), rest_caseid(*), hostname(*), username(*)
31+
caseid(*), rest_caseid(*), hostname(*), username(*), &
32+
versionid(*)
3133
end subroutine scream_create_atm_instance
3234

3335
subroutine scream_get_cols_latlon (lat, lon) bind(c)

0 commit comments

Comments
 (0)