Skip to content

Commit

Permalink
Merge pull request ESCOMP#228 from mvertens/feature/history_refactor
Browse files Browse the repository at this point in the history
refactor mediator history to permit new functionality
### Description of changes
refactor mediator history to permit new functionality

### Specific notes
This PR is a large refactor of CMEPS history function capability. There are 3 categories where this capability is now extended or added: instantaneous, average and auxiliary output.
- Each component post phase (i.e. `med_phases_post_xxx_mod.F90`) now calls `med_phases_history_write_comp` and passes it its component id.
- In turn med_phases_write_comp calls instantaneous, average and auxiliary output for that component. 

- **med_phases_history_write_inst_comp**
    - writes the import and export state for that component based on the new input attribute settings 
      `history_n_xxx_inst` and  `history_option_xxx_inst` - where xxx = [atm,ice,glc,lnd,ocn,rof,wav and med]
     - output files will have the form `<casename>.cpl.hi.atm.yyyy-mm-dd-sssss.nc`
    
- **med_phases_history_write_avg_comp**
    - writes the import and export state for that component based on the new input attribute settings 
      `history_n_xxx_avg` and  `history_option_xxx_avg` - where xxx = [atm,ice,glc,lnd,ocn,rof,wav]
     - output files will have the form `<casename>.cpl.ha.atm.yyyy-mm-dd-sssss.nc`
 
- **med_phases_history_write_aux_comp**
    - writes auxiliary history files that are normally high frequency mediator output files that contain more than one time sample on a file and that are used to spin up a prognostic component (e.g. the ocn or lnd carbon cycle)
    -  the following auxiliary files are now supported and to enable them simply set the histaux_*_enabled flage to .true.
     ```histaux_atm2med_file1_enabled = .true.
     histaux_atm2med_file1_auxname = atm.1h.inst
     histaux_atm2med_file1_doavg = .false.
     histaux_atm2med_file1_flds = Faxa_swndr:Faxa_swvdr:Faxa_swndf:Faxa_swvdf
     histaux_atm2med_file1_history_n = 1
     histaux_atm2med_file1_history_option = nhours

     histaux_atm2med_file2_enabled = .false.
     histaux_atm2med_file1_ntperfile = 24
     histaux_atm2med_file2_auxname = atm.1h.avrg
     histaux_atm2med_file2_doavg = .true.
     histaux_atm2med_file2_flds = Sa_u:Sa_v
     histaux_atm2med_file2_history_n = 1
     histaux_atm2med_file2_history_option = nhours
     histaux_atm2med_file2_ntperfile = 24

     histaux_atm2med_file3_enabled = .false.
     histaux_atm2med_file3_auxname = atm.3hprec.avrg
     histaux_atm2med_file3_doavg = .true.
     histaux_atm2med_file3_flds = Faxa_rainc:Faxa_rainl:Faxa_snowc:Faxa_snowl
     histaux_atm2med_file3_history_n = 3
     histaux_atm2med_file3_history_option = nhours
     histaux_atm2med_file3_ntperfile = 8

     histaux_atm2med_file4_enabled = .false.
     histaux_atm2med_file4_auxname = atm.3h.avrg
     histaux_atm2med_file4_doavg = .true.
     histaux_atm2med_file4_flds = Sa_z:Sa_topo:Sa_u:Sa_v:Sa_tbot:Sa_ptem:Sa_shum:Sa_dens:Sa_pbot:Sa_pslv:Faxa_lwdn:Faxa_rainc:Faxa_rainl:Faxa_snowc:Faxa_snowl:Faxa_swndr:Faxa_swvdr:Faxa_swndf:Faxa_swvdf:Sa_co2diag:Sa_co2prog
     histaux_atm2med_file4_history_n = 3
     histaux_atm2med_file4_history_option = nhours
     histaux_atm2med_file4_ntperfile = 8

     histaux_atm2med_file5_auxname = atm.24h.avrg
     histaux_atm2med_file5_doavg = .true.
     histaux_atm2med_file5_enabled = .false.
     histaux_atm2med_file5_flds = Faxa_bcph:Faxa_ocph:Faxa_dstwet:Faxa_dstdry:Sa_co2prog:Sa_co2diag
     histaux_atm2med_file5_history_n = 1
     histaux_atm2med_file5_history_option = ndays
     histaux_atm2med_file5_ntperfile = 1

     histaux_lnd2med_file1_auxname = lnd.ncpl.inst
     histaux_lnd2med_file1_doavg = .false.
     histaux_lnd2med_file1_enabled = .false.
     histaux_lnd2med_file1_flds = all
     histaux_lnd2med_file1_history_n = 1
     histaux_lnd2med_file1_history_option = nsteps
     histaux_lnd2med_file1_ntperfile = 1
     ```
     - for file 1 history output is of the form <casename>.cpl.hx.atm.1h.inst.yyyy-mm-dd-sssss.nc - and the <atm.1h.inst>
        is specified by <histaux_atm2med_file1_auxname>
Contributors other than yourself, if any: None
CMEPS Issues Fixed: None
Are changes expected to change answers?
 - [x] bit for bit
Any User Interface Changes (namelist or namelist defaults changes)? (see above summary)
 - [x] Yes
  • Loading branch information
mvertens authored Oct 13, 2021
2 parents f06fe9c + ca2ecb3 commit f1d514f
Show file tree
Hide file tree
Showing 25 changed files with 3,806 additions and 2,272 deletions.
7 changes: 1 addition & 6 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
#----------------------------------------------------
nmlgen.init_defaults(infile, config)

if case.get_value('MEDIATOR_READ_RESTART'):
nmlgen.set_value('mediator_read_restart', value='.true.')
else:
nmlgen.set_value('mediator_read_restart', value='.false.')

#--------------------------------
# Overwrite: set brnch_retain_casename
#--------------------------------
Expand Down Expand Up @@ -292,7 +287,7 @@ def _create_drv_namelists(case, infile, confdir, nmlgen, files):
# the driver restart pointer will look like a mediator is present even if it is not
nmlgen.set_value("drv_restart_pointer", value="rpointer.cpl")

logger.info("Writing nuopc_runseq for components {}".format(valid_comps))
logger.info("Writing nuopc_runconfig for components {}".format(valid_comps))
nuopc_config_file = os.path.join(confdir, "nuopc.runconfig")
nmlgen.write_nuopc_config_file(nuopc_config_file, data_list_path=data_list_path)

Expand Down
103 changes: 30 additions & 73 deletions cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -435,27 +435,6 @@
</values>
</entry>

<entry id="BARRIER_N">
<type>char</type>
<default_value>1</default_value>
<group>run_begin_stop_restart</group>
<file>env_run.xml</file>
<desc>
Sets periodic model barriers with BARRIER_OPTION and BARRIER_DATE for synchronization
</desc>
</entry>

<entry id="BARRIER_DATE">
<type>char</type>
<default_value>-999</default_value>
<group>run_begin_stop_restart</group>
<file>env_run.xml</file>
<desc>
Alternative date in yyyymmdd format
sets periodic model barriers with BARRIER_OPTION and BARRIER_N for synchronization
</desc>
</entry>

<entry id="ESP_RUN_ON_PAUSE">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
Expand Down Expand Up @@ -841,6 +820,21 @@
machines.</desc>
</entry>

<entry id="CLM_USE_PETSC">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>build_component_clm</group>
<file>env_build.xml</file>
<desc>TRUE implies CLM is built with support for the PETSc
library. The Variably Saturated Flow Model (VSFM) solver in CLM
uses the PETSc library. In order to use the VSFM solver, CLM
must be built with PETSc support and linking to PETSc must occur
when building the ACME executable. This occurs if this variable
is set to TRUE. Note that is only available on a limited set of
machines/compilers.</desc>
</entry>

<entry id="USE_MOAB">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
Expand Down Expand Up @@ -2294,10 +2288,6 @@
<desc>standard full pathname of the cprnc executable</desc>
</entry>

<!-- ===================================================================== -->
<!-- component coupling options and frequencies -->
<!-- ===================================================================== -->

<entry id="CPL_I2O_PER_CAT">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
Expand All @@ -2307,38 +2297,6 @@
<desc>determine if per ice thickness category fields are passed from ice to ocean - DO NOT EDIT (set by POP build-namelist)</desc>
</entry>

<!-- ===================================================================== -->
<!-- history frequencies -->
<!-- ===================================================================== -->

<entry id="HIST_OPTION">
<type>char</type>
<valid_values>none,never,nsteps,nstep,nseconds,nsecond,nminutes,nminute,nhours,nhour,ndays,nday,nmonths,nmonth,nyears,nyear,end</valid_values>
<default_value>never</default_value>
<group>run_drv_history</group>
<file>env_run.xml</file>
<desc>Sets driver snapshot history file frequency (like REST_OPTION)</desc>
</entry>

<entry id="HIST_N">
<type>integer</type>
<valid_values></valid_values>
<default_value>-999</default_value>
<group>run_drv_history</group>
<file>env_run.xml</file>
<desc>Sets driver snapshot history file frequency (like REST_N)
</desc>
</entry>

<entry id="HIST_DATE">
<type>integer</type>
<valid_values></valid_values>
<default_value>-999</default_value>
<group>run_drv_history</group>
<file>env_run.xml</file>
<desc>yyyymmdd format, sets coupler snapshot history date (like REST_DATE)</desc>
</entry>

<entry id="INFO_DBUG">
<type>integer</type>
<valid_values>0,1,2,3,4,5,6,7,8,9</valid_values>
Expand All @@ -2348,22 +2306,6 @@
<desc>level of debug output, 0=minimum, 1=normal, 2=more, 3=too much</desc>
</entry>

<entry id="CLM_USE_PETSC">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>build_component_clm</group>
<file>env_build.xml</file>
<desc>TRUE implies CLM is built with support for the PETSc
library. The Variably Saturated Flow Model (VSFM) solver in CLM
uses the PETSc library. In order to use the VSFM solver, CLM
must be built with PETSc support and linking to PETSc must occur
when building the ACME executable. This occurs if this variable
is set to TRUE. Note that is only available on a limited set of
machines/compilers.</desc>
</entry>


<!-- Prerun/postrun custom script options -->

<entry id="PRERUN_SCRIPT">
Expand Down Expand Up @@ -2541,6 +2483,21 @@
<desc>add aoflux calculation to runseq</desc>
</entry>

<!-- ===================================================================== -->
<!-- TODO: the following should be deleted. They are still used by -->
<!-- the component testing but are not doing anything in cmeps -->
<!-- ===================================================================== -->

<entry id="BFBFLAG">
<type>logical</type>
<valid_values>TRUE,FALSE</valid_values>
<default_value>FALSE</default_value>
<group>run_flags</group>
<file>env_run.xml</file>
<desc>turns on coupler bit-for-bit reproducibility with varying pe counts</desc>
</entry>


<help>
=========================================
Notes:
Expand Down
Loading

0 comments on commit f1d514f

Please sign in to comment.