Adding MEDUSA to a coupled model

It is assumed here that the starting point is a coupled model, involving both the UM and NEMO, already at the resolution required (probably ORCA1), and that the desire is to add MEDUSA to this.

Adding MEDUSA requires

  • Changes to NEMO CPP key
  • Setting environment variable L_OCN_PASS_TRC to true, so the submission scripts (aka drivers) know to set up extra files etc.
  • Different files for XIOS2

It's not currently possible to turn MEDUSA off with a simple switch, and only changing a subset of these options will create a mess of a job, which will almost certainly fail.

In addition to the changes above, we want to couple some fields from MEDUSA to the UM and in the reverse direction and that requires further changes. The changes needed for this are shown in green. All the changes needed are described in the sections below below.

Adding the code and the NEMO CPP keys

  • ->fcm_make_ocean
    • ->env
      • ->NEMO Sources
        • ->nemo_sources: ADD branches/NERC/dev_r5518_NOC_MEDUSA_Stable (check it isn't already there, because it is also being used for the age tracer diagnostic, and you should probably take the latest revision. You can find this from the `Mirror for MEDUSA' link in the left hand buttons.)
        • ->nemo_path_incl: ADD NEMOGCM/NEMO/TOP_SRC
      • ->Pre-processing
        • ->keys_nemo_app: REMOVE
          • key_trdtrc (If kept in, this causes the compilation to fail because the parameters JPTRA_ATF and JPTRA_SMS are both 19 and both CASE options in the same SELECT CASE in TOP_SRC/TRP/trdtrc.F90. And Julien thinks we don't need it.)
          and ADD the following
          • key_top
          • key_medusa
          • key_roam
          • key_axy_carbchem
          • key_avgqsr_medusa
          • key_deep_fe_fix
          • key_mocsy
          • key_axy_pi_co2
          • key_idtra
          • key_cfc
          • key_age

Creation of app/ocean_passive_tracers/rose-app.conf

This file is needed for all the settings required by the TOP_SRC code in NEMO - which includes the MEDUSA code - and this includes the long list of parameters needed to run MEDUSA.

Creating this file from scratch would be a massive undertaking, so in all likelihood the addition of MEDUSA will require taking an existing file from an existing job. The parameters in this file have not changed for a few months and so this file should be consistent across all our jobs (although maybe we should try and version control it somewhere). Hence, there should be a number of jobs you can take this file, such as our current PD job, u-aj599, (as of 24 March 2017).

The environment variables defined in this file should be

  • L_OCN_PASS_TRC. This is read by the submission scripts (aka drivers) and should be true to indicate TOP_SRC code is wanted. This was originally called L_BGC to indicate turning on biogeochemistry, but the name was altered when we realised that a user might just want the age of tracer and not MEDUSA - which also requires this to be true.
  • PASSIVE_TRACERS_ANCIL=/projects/ocean/hadgem3/ancil/ocean/eORCA1/MEDUSA. Input files for MEDUSA, which should be
    • UKESM_fields.nc ($MED_ancil/eORCA1_climato_dic_1860.nc),
    • ccd_ocal_nemo.nc ($MED_ancil/eORCA1_ocal_ccd.nc) and
    • dust.orca.nc (eORCA1_dust.nc)
  • PASSIVE_TRACERS_NML= $CYLC_SUITE_SHARE_DIR/fcm_make_ocean/extract/nemo/NEMOGCM/CONFIG/SHARED. Namelist files which are stored in the MEDUSA branch, which should be
    • cfc1112.atm ($MEDUSA_NML/1_cfc1112.atm),
    • field_def_bgc.xml ($MEDUSA_NML/field_def_bgc.xml),
    • namelist_age_ref ($MEDUSA_NML/namelist_age_ref),
    • namelist_cfc_ref ($MEDUSA_NML/namelist_cfc_v1_ref),
    • namelist_idtra_ref ($MEDUSA_NML/namelist_idtra_ref),
    • namelist_medusa_ref ($MEDUSA_NML/namelist_medusa_ref) and
    • namelist_top_cfg ($MEDUSA_NML/namelist_top_MEDUSA_et_al_ref)
  • TOP_NL=namelist_top_cfg.
  • TOP_START. This needs setting if you want to run the passive tracers from anything other than climatology. However, even for pre-industrial run, we always want to run from climatology, so I think this is always set equal to nothing.

To ensure the dust field is properly coupled to MEDUSA check the following is true.

  • ->ocean_passive_tracers
    • ->namelist
      • ->MEDUSA
        • ->Surface boundary (nammedsbc)
          • ->bdustfer: false. (If it isn't false then climatology will be used, rather than the field sent from UM)

Change to app/coupled/rose-app.conf

Having created app/ocean_passive_tracers/rose-app.conf in the section above, it's necessary to import it into the coupled app. This is done by editing the top line of app/coupled/rose-app.conf so that it reads

import=um nemo_cice ocean_passive_tracers


Changes to app/nemo_cice/rose-app.conf

The only differences to this app, should be the addition of the extra coupling fields.

The only other difference is the addition of the coupling which requires the following lines adding below the `sn_rcv_antm' line

sn_rcv_atm_dust='medusa','no','','',''
sn_rcv_atm_pco2='medusa','no','','',''

and the following lines adding below the `sn_snd_alb' line

sn_snd_bio_co2='medusa','no','','',''
sn_snd_bio_dms='medusa','no','','',''


Changes to iodef.xml

The field definitions for ocean passive tracers need adding to the iodef.xml file, by adding a link to field_def_bgc.xml above the link to core field definitions file, field_def.xml, so we have

    ⟨field_definition src="./field_def_bgc.xml"/⟩
    ⟨field_definition src="./field_def.xml"/⟩

There should not be any repetition between field_def.xml and field_def_bgc.xml now, but there has been in the past. By linking to field_def_bgc.xml, Tim Graham thinks that this will take precedence if any fields are defined twice.

The group definition for the ocean passive tracers also need adding just before the line `⟨/file_group⟩', with the code below

        ⟨file id="file11" name_suffix="_ptrc_T" description="Medusa sms variables" ⟩
          ⟨field_group group_ref="groupMEDUSA" /⟩
          ⟨field_group group_ref="groupIDTRA" /⟩
          ⟨field_group group_ref="groupCFC" /⟩
          ⟨field_group group_ref="groupAGE" /⟩
        ⟨/file⟩

        ⟨file id="file12" name_suffix="_diad_T" description="Medusa diagnostic variables" ⟩
          ⟨field_group group_ref="groupMEDUSA_dia" /⟩
          ⟨field_group group_ref="groupMEDUSA_3dd" /⟩
          ⟨field_group group_ref="groupMEDUSA_dms" /⟩
          ⟨field_group group_ref="groupIDTRA_dia" /⟩
          ⟨field_group group_ref="groupCFC_dia" /⟩
          ⟨field_group group_ref="groupMEDUSA_cmip6" /⟩
        ⟨/file⟩

However, check the file id numbers. Here we start with id="file11", but if any further groups have been added to the core ocean definitions then this may need to be increased, e.g. if the last id in the core ocean definitions is "file14", our new ids will need to be "file15" and "file16".

Changes to app/um/rose-app.conf

The only changes needed to the UM app is to enable the coupling.

Some of the coupling fields will only be turned on if l_oasis_obgc, where `obgc' stands for Ocean BioGeoChemistry, is set to true.

  • ->um
    • ->namelist
      • ->Coupling
        • ->Main coupling controls
          • ->l_oasis_obgc: CHANGE TO true

The two fields received by the UM from MEDUSA are DMS concentration (stash 132) and CO2 flux (stash 250). These fields need to be turned on, otherwise a problem will occur when the coupling code tries to write these received fields to D1. To do this the following stash items need adding

[namelist:items(91826e0f)]
ancilfilename=''
domain=1
!!interval=5
!!netcdf_varname='unset'
!!period=3
source=4
stash_req=132
update_anc=.false.
!!user_prog_ancil_stash_req=
!!user_prog_rconst=0.0

and

[namelist:items(ce05eb52)]
ancilfilename=''
domain=1
!!interval=0
!!netcdf_varname='unset'
!!period=1
source=4
stash_req=250
update_anc=.false.
!!user_prog_ancil_stash_req=0
!!user_prog_rconst=0


To allow the total dust deposition flux to be sent from the UM to NEMO/MEDUSA, add the following STASH item

[namelist:items(7486d0f1)]
ancilfilename=''
domain=1
!!interval=1
!!netcdf_varname='unset'
!!period=1
source=3
stash_req=197
update_anc=.false.
!!user_prog_ancil_stash_req=
!!user_prog_rconst=0.0

which ensures that there's a dust field permanently available to send to the ocean (a stash request is not written to the dump, and so is unavailable at the start of a run). However, this field needs to populated from the stash request below

[namelist:streq(03440_d0f5c1e1)]
dom_name='DIAG'
isec=3
item=440
package=''
tim_name='TCOUPMN'
use_name='UPCOUP'

where stash 3,440 is the total dust deposition flux and this stash entry ensures that it is averaged over the correct period.

The partial pressure of CO2 (pCO2) is calculated from the surface value of CO2. If we don't have interactive CO2, when i_co2_opt=1 or 2, CO2 is just a constant everywhere set by the variable co2_mmr, and this is used to calculate the 2D field sent to the ocean (no changes are needed). However, changes are required if there is interactive CO2 (i_co2_opt=3), which are similar to the changes for the total dust deposition flux above. The stash item below needs adding

[namelist:items(068de6e4)]
ancilfilename=''
domain=1
!!interval=1
!!netcdf_varname='unset'
!!period=1
source=3
stash_req=196
update_anc=.false.
!!user_prog_ancil_stash_req=
!!user_prog_rconst=0.0

(The stash item 252 also needs to be on, but if you have interactive CO2 then this should already be on.) To ensure the stash item above is properly populated the following stash request is also needed

[namelist:streq(00252_91e56b40)]
dom_name='DIAG'
isec=0
item=252
package=''
tim_name='TCOUPMN'
use_name='UPCOUP'

which ensures that surface value of CO2 exists over the correct averaging period.

Changes to namcouple

We're coupling four new fields (two in each direction), so the argument under $NFIELDS needs increasing from 74 to 78. In addition the following code needs adding below the `model01_OIceKn_cat05' entry

############################################################################
# TRANSDEF: OCNT ATMT 76 90 ######################################################  
model01_OBioDMS dms_conc 470 10800 1 atmos_restart.nc   EXPORTED
 362 332 192 144 tor1 atm3 SEQ=+1
 P  2  P 0
#
 MAPPING
#
 rmp_tor1_to_atm3_CONSERV_FRACAREA.nc
#
############################################################################
# TRANSDEF: OCNT ATMT 77 91 ######################################################  
model01_OBioCO2 oCO2flux 470 10800 1 atmos_restart.nc   EXPORTED
 362 332 192 144 tor1 atm3 SEQ=+1
 P  2  P 0
#
 MAPPING
#
 rmp_tor1_to_atm3_CONSERV_FRACAREA.nc
#


and the following code below the `icesouth model01_OAntmass' entry

############################################################################
# TRANSDEF: ATMT OCNT 78 92 1 ######################################################  
 atmpco2 model01_OATMPCO2 466 10800 1 atmos_restart.nc   EXPORTED
 192 144 362 332 atm3 tor1 SEQ=+2
 P  0  P  2
#
 MAPPING
#
 rmp_atm3_to_tor1_CONSERV_DESTAREA.nc
#
############################################################################
# TRANSDEF: ATMT OCNT 79 93 1 ######################################################  
 atmdust model01_OATMDUST 466 10800 1 atmos_restart.nc   EXPORTED
 192 144 362 332 atm3 tor1 SEQ=+2
 P  0  P  2
#
 MAPPING
#
 rmp_atm3_to_tor1_CONSERV_DESTAREA.nc
#