by Holger Wolff, CLEX CMS
In this example, we want to add an additional task before every instance of the coupler to update the sea surface temperature ancillary file.
Run this command on accessdev to make a copy of the ACCESS-CM2 suite:
rosie copy u-br565
This command will create a copy of the original ACCESS-CM2 suite with a new suite-id that we can modify and track without interfering with the original suite.
"Suite Directory" from now on will mean the directory ${HOME}/roses/<suite-id>
.
Create a file called update_sst.sh
and located in the directory apps/update_sst/bin
under your rose suite directory:
#!/bin/bash
# Ensure that the relevant variables are set:
test -z ${FILE_TEMPLATE} && exit 1
test -z ${SST_FILE} && exit 2
test -z ${YEAR} && exit 3
# Obtain current model year f
export YEAR_FILE=${FILE_TEMPLATE/YEAR/${YEAR}}
echo ===============================================
echo Running script to update Sea Surface Temparatures
echo Input file: ${YEAR_FILE}
echo Output file: ${SST_FILE}
echo ===============================================
CMD="cp ${YEAR_FILE} ${SST_FILE}"
echo $CMD
$CMD || exit 4
echo ===============================================
Make sure that the script is executable by running the command:
chmod +x update_sst.sh
Modify the file rose-suite.conf
in your suite directory:
Somewhere in the section [jinja2:suite.rc]
(which should be the only section in this file), add the line:
UPDATE_SST=true
Modify the file meta/rose-meta.conf
and add this block:
[jinja2:suite.rc=UPDATE_SST]
compulsory=true
description=Run a script to update the SST files every run
help=
title=Update SST
ns=Build and Run
sort-key=3
type=boolean
More info on the metadata can be found on the Rose Documentation on Metadata
What's important is that this will add the option to switch the task on and off to the suite conf
-> Build and Run
window in rose.
Create a new subdirectory app/update_sst
and in this directory, create the file rose-app.conf
:
[command]
default=update_sst.sh
[env]
FILE_TEMPLATE=/PATH/TO/SST_FILES/sst_YEAR_something.nc
SST_FILE=work/ocean/INPUT/temp_sfc_restore.nc
Note that these are the default values. There is an option to change these values in the rose editor.
Create a new subdirectory app/update_sst/meta
.
In this subdirectory, create the following file rose-meta.conf
:
[env=FILE_TEMPLATE]
description=All SST Files
help=Template of the files that contain the sea surface temperatures by year.
=the term YEAR will be replaced with the actual year.
compulsory=true
pattern=^.*YEAR.*$
[env=SST_FILE]
description=SST File
help=SST file expected by model
compulsory=true
Edit the file suite.rc
Search for the entry [[coupled]]
, create a new section directly before that called [[update_sst]]
:
[[update_sst]]
inherit = None, NCI, SHARE
script = rose task-run --verbose
[[[remote]]]
host = {{ COMPUTE_HOST }}
[[[job]]]
batch system = background
[[[environment]]]
YEAR = $(cylc cyclepoint --print-year)
Notice how most of these settings are taken directly from other similar tasks.
We now need to add the update_sst
task to the task graph, if UPDATE_SST
is true.
The graph is described in two sections, [[[ R1 ]]]
for the initial run, and [[[ {RESUB} ]]]
for successive runs.
The second is easier to read, so we start there.
On line 86, we add the new part graph:
{% if UPDATE_SST %} filemove[-{{RESUB}}] => update_sst => coupled {% endif %}
The central location in the graph for [[[ R1 ]]]
is harder to parse, manual folding of if
and endifs
is needed to deduce that the central graph for running the model is in line 72 and reads:
install_ancil => coupled
We add our task like this:
{% if UPDATE_SST %} install_ancil => update_sst => coupled {% endif %}
svn add app/update_sst
svn ci -m 'include script to update SST files'
Hi Holger.
This looks good, just a couple of minor changes. In Step 1, the script should be placed in the
app/update_sst/bin
directory. This directory is on-path for theupdate_sst
task. This means that[command]
inapp/update_sst/rose-app.conf
can be set toupdate_sst.sh
. You should also put a note in there about making sureupdate_sst.sh
has executable permissions. That way the script is also in version control.One other change I'd make is to add an
{{{environment]]]
section to the[[update_sst]]
and defineYEAR
there instead of at the top of the script.