Skip to content

Commit

Permalink
Move set_provenence_data call to in front of create_output_managers
Browse files Browse the repository at this point in the history
  • Loading branch information
tcclevenger committed Oct 15, 2024
1 parent 2a600d9 commit 6245275
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
32 changes: 16 additions & 16 deletions components/eamxx/src/mct_coupling/atm_comp_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,13 @@ subroutine atm_init_mct( EClock, cdata, x2a, a2x, NLFilename )
call string_f2c(yaml_fname,yaml_fname_c)
call string_f2c(calendar,calendar_c)
call string_f2c(trim(atm_log_fname),atm_log_fname_c)
call string_f2c(trim(caseid),caseid_c)
call string_f2c(trim(hostname),hostname_c)
call string_f2c(trim(username),username_c)
call scream_create_atm_instance (mpicom_atm, ATM_ID, yaml_fname_c, atm_log_fname_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)
calendar_c, caseid_c, hostname_c, username_c)


! Init MCT gsMap
Expand Down Expand Up @@ -269,10 +272,7 @@ subroutine atm_init_mct( EClock, cdata, x2a, a2x, NLFilename )
c_loc(export_constant_multiple), c_loc(do_export_during_init), &
num_cpl_exports, num_scream_exports, export_field_size)

call string_f2c(trim(caseid),caseid_c)
call string_f2c(trim(username),username_c)
call string_f2c(trim(hostname),hostname_c)
call scream_init_atm (caseid_c,hostname_c,username_c)
call scream_init_atm ()
#ifdef HAVE_MOAB
! data should be set now inside moab from import and export fields
! do we import and export or just export at init stage ?
Expand Down Expand Up @@ -308,7 +308,7 @@ subroutine atm_run_mct(EClock, cdata, x2a, a2x)
#ifdef MOABCOMP
use mct_mod
use seq_comm_mct, only : num_moab_exports
#endif
#endif

integer :: ent_type
#ifdef MOABCOMP
Expand All @@ -324,7 +324,7 @@ subroutine atm_run_mct(EClock, cdata, x2a, a2x)

type(ESMF_Clock) ,intent(inout) :: EClock ! clock
type(seq_cdata) ,intent(inout) :: cdata
type(mct_aVect) ,intent(inout) :: x2a ! driver -> atmosphere
type(mct_aVect) ,intent(inout) :: x2a ! driver -> atmosphere
type(mct_aVect) ,intent(inout) :: a2x ! atmosphere -> driver

!--- local ---
Expand Down Expand Up @@ -403,7 +403,7 @@ subroutine atm_final_mct(EClock, cdata, x2a, a2x)
! !INPUT/OUTPUT PARAMETERS:
type(ESMF_Clock) ,intent(inout) :: EClock ! clock
type(seq_cdata) ,intent(inout) :: cdata
type(mct_aVect) ,intent(inout) :: x2a ! driver -> atmosphere
type(mct_aVect) ,intent(inout) :: x2a ! driver -> atmosphere
type(mct_aVect) ,intent(inout) :: a2x ! atmosphere -> driver

!----------------------------------------------------------------------------
Expand Down Expand Up @@ -437,7 +437,7 @@ subroutine atm_Set_gsMap_mct( mpicom_atm, ATMID, GSMap_atm )
! Build the atmosphere grid numbering for MCT
! NOTE: Numbering scheme is: West to East and South to North
! starting at south pole. Should be the same as what's used in SCRIP

! Determine global seg map
num_local_cols = scream_get_num_local_cols()
num_global_cols = scream_get_num_global_cols()
Expand Down Expand Up @@ -466,7 +466,7 @@ subroutine atm_domain_mct( lsize, gsMap_atm, dom_atm )
!
integer , intent(in) :: lsize
type(mct_gsMap), intent(in) :: gsMap_atm
type(mct_ggrid), intent(inout):: dom_atm
type(mct_ggrid), intent(inout):: dom_atm
!
! Local Variables
!
Expand All @@ -488,20 +488,20 @@ subroutine atm_domain_mct( lsize, gsMap_atm, dom_atm )

! Fill in correct values for domain components
call scream_get_cols_latlon(c_loc(data1),c_loc(data2))
call mct_gGrid_importRAttr(dom_atm,"lat",data1,lsize)
call mct_gGrid_importRAttr(dom_atm,"lon",data2,lsize)
call mct_gGrid_importRAttr(dom_atm,"lat",data1,lsize)
call mct_gGrid_importRAttr(dom_atm,"lon",data2,lsize)

call scream_get_cols_area(c_loc(data1))
call mct_gGrid_importRAttr(dom_atm,"area",data1,lsize)
call mct_gGrid_importRAttr(dom_atm,"area",data1,lsize)

! Mask and frac are both exactly 1
data1 = 1.0
call mct_gGrid_importRAttr(dom_atm,"mask",data1,lsize)
call mct_gGrid_importRAttr(dom_atm,"frac",data1,lsize)
call mct_gGrid_importRAttr(dom_atm,"mask",data1,lsize)
call mct_gGrid_importRAttr(dom_atm,"frac",data1,lsize)

! Aream is computed by mct, so give invalid initial value
data1 = -9999.0_R8
call mct_gGrid_importRAttr(dom_atm,"aream",data1,lsize)
call mct_gGrid_importRAttr(dom_atm,"aream",data1,lsize)
end subroutine atm_domain_mct

#ifdef HAVE_MOAB
Expand Down
13 changes: 6 additions & 7 deletions components/eamxx/src/mct_coupling/scream_cxx_f90_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ void scream_create_atm_instance (const MPI_Fint f_comm, const int atm_id,
const int run_start_tod,
const int case_start_ymd,
const int case_start_tod,
const char* calendar_name)
const char* calendar_name,
const char* caseid,
const char* hostname,
const char* username)
{
using namespace scream;
using namespace scream::control;
Expand Down Expand Up @@ -171,6 +174,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);
ad.set_provenance_data (caseid,hostname,username);
ad.create_output_managers ();
ad.create_atm_processes ();
ad.create_grids ();
Expand Down Expand Up @@ -240,9 +244,7 @@ void scream_init_hip_atm () {
}
#endif

void scream_init_atm (const char* caseid,
const char* hostname,
const char* username)
void scream_init_atm ()
{
using namespace scream;
using namespace scream::control;
Expand All @@ -251,9 +253,6 @@ void scream_init_atm (const char* caseid,
// Get the ad, then complete initialization
auto& ad = get_ad_nonconst();

// Set provenance info in the driver (will be added to the output files)
ad.set_provenance_data (caseid,hostname,username);

// Init all fields, atm processes, and output streams
ad.initialize_fields ();
ad.initialize_atm_procs ();
Expand Down
10 changes: 5 additions & 5 deletions components/eamxx/src/mct_coupling/scream_f2c_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ module scream_f2c_mod
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) bind(c)
calendar_name, &
caseid, hostname, username) bind(c)
use iso_c_binding, only: c_int, c_char
!
! Input(s)
!
integer (kind=c_int), value, intent(in) :: f_comm, atm_id
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(*)
character(kind=c_char), target, intent(in) :: yaml_fname(*), atm_log_fname(*), calendar_name(*), &
caseid(*), hostname(*), username(*)
end subroutine scream_create_atm_instance

subroutine scream_get_cols_latlon (lat, lon) bind(c)
Expand Down Expand Up @@ -91,9 +93,7 @@ end subroutine scream_init_hip_atm
! During this call, all fields are initialized (i.e., initial conditions are
! loaded), as well as the atm procs (which might use some initial conditions
! to further initialize internal structures), and the output manager.
subroutine scream_init_atm (caseid,hostname,username) bind(c)
use iso_c_binding, only: c_char
character(kind=c_char), target, intent(in) :: caseid(*), hostname(*), username(*)
subroutine scream_init_atm () bind(c)
end subroutine scream_init_atm

! This subroutine will run the whole atm model for one atm timestep
Expand Down

0 comments on commit 6245275

Please sign in to comment.