Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto

# Binaries
*.nc binary
*.png binary

# Fortran namelist file identification
*.nl text diff=fortran-free-form
*.nl linguist-language=fortran-free-form
11 changes: 9 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,24 @@ Code Reviewer: <!-- CR id, filled by SSD -->

- [ ] I have performed a self-review of my own code
- [ ] My code follows the project's style guidelines
- [ ] Comments have been included that aid undertanding and enhance the
- [ ] Comments have been included that aid understanding and enhance the
readability of the code
- [ ] My changes generate no new warnings

## Testing

- [ ] I have tested this change locally, using the Moci rose-stem suite
- [ ] I have tested this change locally, using the Moci rose-stem suite. Required for any changes to
* Coupled_Drivers application
* Postprocessing application
* Unittests
- [ ] If any tests fail (rose-stem or CI) the reason is understood and
acceptable (eg. kgo changes)
- [ ] I have added tests to cover new functionality as appropriate (eg. system
tests, unit tests, etc.)

### trac.log

<!-- Paste your trac.log from testing output here -->

<!-- Describe other testing performed (if applicable) -->

Expand Down
7 changes: 6 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
| james-bruten-mo | James Bruten | Met Office | 2025-12-09 |
| Pierre-siddall | Pierre Siddall | Met Office | 2025-01-19 |
| ericaneininger | Erica Neininger | Met Office | 2026-02-04 |
| dcalve | Daley Calvert | Met Office | 2026-02-04 |
| dcalve | Daley Calvert | Met Office | 2026-02-04 |
| harry-shepherd | Harry Shepherd | Met Office | 2026-02-27 |
| marcstring | Marc Stringer | NCAS | 2026-04-01 |
| jonseddon | Jon Seddon | Met Office | 2026-05-11 |
| jonnyhtw | Jonny Williams | NCAS | 2026-05-13 |

1 change: 0 additions & 1 deletion Coupled_Drivers/cice_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import re
import datetime
import time
import subprocess
import time2days
import inc_days
import common
Expand Down
12 changes: 12 additions & 0 deletions Coupled_Drivers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ def exec_subproc_timeout(cmd, timeout_sec=10):
the commands to be run, and an integer timeout_sec for how long to
wait for the command to run. Returns the return code from the process
and the standard out from the command or 'None' if the command times out.

This function is now DEPRECATED in favour of the exec_shellout function in
mocilib

'''
process = subprocess.Popen(cmd, shell=False,
stdin=subprocess.PIPE,
Expand All @@ -260,6 +264,10 @@ def exec_subproc(cmd, verbose=True):
Execute given shell command. Takes a list containing the commands to be
run, and a logical verbose which if set to true will write the output of
the command to stdout.

This function is now DEPRECATED in favour of the exec_shellout function in
mocilib

'''
process = subprocess.Popen(cmd, shell=False,
stdin=subprocess.PIPE,
Expand All @@ -281,6 +289,10 @@ def __exec_subproc_true_shell(cmd, verbose=True):
exec_subproc does not work correctly. Takes a list containing the commands
to be run, and a logical verbose which if set to true will write the
output of the command to stdout.

This function is now DEPRECATED in favour of the exec_shellout function in
mocilib

'''
process = subprocess.Popen(cmd, shell=True,
stdin=subprocess.PIPE,
Expand Down
1 change: 1 addition & 0 deletions Coupled_Drivers/mct_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import dr_env_lib.mct_def
import dr_env_lib.env_lib
import cpmip_controller

try:
import f90nml
except ImportError:
Expand Down
1 change: 1 addition & 0 deletions Coupled_Drivers/rivers_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import error
import dr_env_lib.rivers_def
import dr_env_lib.env_lib

try:
import f90nml
except ImportError:
Expand Down
21 changes: 21 additions & 0 deletions Documentation/mocilib/mocilib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MOCIlib

MOCIlib is intended as a library to hold an assorted range on utility functions that can be used throughout new development and maintainance of MOCI along with their associated unit tests to ensure robust and unified approach to MOCI's functionality.

## shellout

The shelllout module contains the relevant functions to execute and handle shell commands in a safe manner.

exec_subprocess is a function to execute a shell subprocess and takes the several parameters as follows:

```python
def exec_subprocess(cmd, verbose=False, timeout=None, current_working_directory=os.getcwd())
```

cmd - the command to be executed by exec_subprocess given as a string.

verbose - a boolean (True or False) to determine if the standard output (stdout) stream is output during the execution of the shell command.

timeout - an integer number determining the number of seconds a shell command can run for before a TimeoutExpired error is raised.

current_working_directory - The working directory which the shell command will be executed in given as a string.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [ -z "$SUITE_REVISION" ]; then
SUITE_REVISION='Revision: undefined'
revision='undefined'
else
revision=$(echo $SUITE_REVISION | grep -oP '\d+')
revision=$SUITE_REVISION
fi

oasis_mod_version_path=$OASIS_MOD_NAME/$OASIS_MOD_VERSION/$revision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if [ -z "$SUITE_REVISION" ]; then
SUITE_REVISION='Revision: undefined'
revision='undefined'
else
revision=$(echo $SUITE_REVISION | grep -oP '\d+')
revision=$SUITE_REVISION
fi

module_file_path=$MODULE_BASE/modules/$PRG_ENV_NAME/$PRG_ENV_VERSION
Expand Down Expand Up @@ -73,17 +73,6 @@ set version $PRG_ENV_VERSION

EOF

for mod in $MODULE_STR; do
if [[ $mod == *'PrgEnv'* ]]; then
line="module swap PrgEnv-cray $mod"
else
line="module load $mod"
fi
cat <<EOF >>$module_file
$line
EOF
done

# now do the oasis and xios modules
if [ "XIOS_ONLY" = "True" ]; then
line="module load $XIOS_MODULE_PATH";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [ -z "$SUITE_REVISION" ]; then
SUITE_REVISION='Revision: undefined'
revision='undefined'
else
revision=$(echo $SUITE_REVISION | grep -oP '\d+')
revision=$SUITE_REVISION
fi

xios_mod_version_path=$XIOS_MOD_NAME/$XIOS_MOD_VERSION/$revision
Expand Down
20 changes: 10 additions & 10 deletions Infrastructure_Builds/infrastructure_suite/bin/extract_oasis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# ENVIRONMENT VARIABLES (COMPULSORY):
# EXTRACT_OASIS
# HPC_HOST_OASIS
# HPC_HOST
# OASIS_BRANCH
# OASIS_REPOSITORY
#
Expand All @@ -27,7 +27,7 @@ if [ "$EXTRACT_OASIS" = "True" ]; then
exit 999
fi

if [ -z "$HPC_HOST_OASIS" ]; then
if [ -z "$HPC_HOST" ]; then
hpc_build="False"
else
hpc_build="True"
Expand Down Expand Up @@ -55,31 +55,31 @@ if [ "$hpc_build" = "True" ] && [ -z "$CYLC_SUITE_RUN_DIR" ]; then
# manually
# upload to the HPC
ssh $user@$HPC_HOST "mkdir -p $OASIS_BUILD_DIR/";
scp -r $oasis_extract_dir $user@$HPC_HOST_OASIS:$OASIS_BUILD_DIR/;
scp -r $oasis_extract_dir $user@$HPC_HOST:$OASIS_BUILD_DIR/;
# cleanup, only if we have extracted the code from GIT
if [ "$EXTRACT_OASIS" = "True" ]; then
rm -rf $oasis_extract_dir
fi
# upload build scripts to hpc
scp bin/oasis_build.sh $user@$HPC_HOST_OASIS:$OASIS_BUILD_DIR/
scp bin/oasis_build.sh $user@$HPC_HOST:$OASIS_BUILD_DIR/
# pass
if [ "$BUILD_TEST" = "True" ]; then
# upload our test executables to the HPC
scp src/*.F90 $user@$HPC_HOST_OASIS:$OASIS_BUILD_DIR/oasis3-mct/examples/tutorial/
scp src/*.F90 $user@$HPC_HOST:$OASIS_BUILD_DIR/oasis3-mct/examples/tutorial/
# upload the run script
scp bin/run_tutorial_mo_xc40.sh $user@$HPC_HOST_OASIS:$OASIS_BUILD_DIR/oasis3-mct/examples/tutorial/
scp bin/run_tutorial_mo_xc40.sh $user@$HPC_HOST:$OASIS_BUILD_DIR/oasis3-mct/examples/tutorial/
# upload the other files to make the test run
for i_file in namcouple_TP script_ferret_FRECVOCN.jnl script_ferret_FSENDOCN_to_File.jnl
do
scp file/$i_file $user@$HPC_HOST_OASIS:$OASIS_BUILD_DIR/oasis3-mct/examples/tutorial/data_oasis3
scp file/$i_file $user@$HPC_HOST:$OASIS_BUILD_DIR/oasis3-mct/examples/tutorial/data_oasis3
done
fi
else
# we are running in a suite context and only need to upload the oasis
# source code
scp -r $oasis_extract_dir $user@$HPC_HOST_OASIS:$OASIS_BUILD_DIR/;
scp -r $oasis_extract_dir $user@$HPC_HOST:$OASIS_BUILD_DIR/;
if [ $? -ne 0 ]; then
1>&2 echo "Unable to succesfully upload oasis source to $HPC_HOST_OASIS"
1>&2 echo "Unable to succesfully upload oasis source to $HPC_HOST"
exit 999;
fi
# cleanup, only if we have extracted the code from GIT
Expand All @@ -89,5 +89,5 @@ else
fi

#End of script test, check that the code is avaliable
ssh $user@$HPC_HOST_OASIS ls $OASIS_BUILD_DIR/oasis3-mct
ssh $user@$HPC_HOST ls $OASIS_BUILD_DIR/oasis3-mct
[ $? -eq 0 ] || exit 1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ fcm co $XIOS_URL/$XIOS_VERSION@$XIOS_REV
XIOS_VERSION_BASE="$(basename $XIOS_VERSION)"
mv $XIOS_VERSION_BASE $XIOSPATH

if [[ "$XIOS_REV" == "1873" ]]; then
sed -i 's/#include <mpi.h>/#include <stdint.h>\n#include <mpi.h>/g' $XIOSPATH/src/mpi.hpp
fi

#End of script test
ls $XIOSPATH
[ $? -eq 0 ] || exit 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,40 @@
#!jinja2

{% set HPC_HOST_OASIS = DEPLOYMENT_HOST if DEPLOYMENT_HOST is defined else HPC_HOST_OASIS %}
{% set HPC_HOST = DEPLOYMENT_HOST if DEPLOYMENT_HOST is defined else HPC_HOST %}

MODULE_STR = {{ MODULES|join(' ') }}
{% set MODULE_STR = MODULES|join(' ') %}
{% set MODULE_CMD = 'for mod in '+MODULE_STR+'; do module load $mod; module swap $mod; done; module list' %}


[cylc]
[scheduler]
UTC mode = True
install = src/, file/
[[events]]
timeout handler = "rose suite-hook --shutdown"
timeout = PT6H
stall timeout handlers = "rose suite-hook --shutdown"

[scheduling]
[[dependencies]]
graph = """
prepare_hpc_host => extract_xios_background => build_xios => create_xios_module => create_prgenv_module => run_xios_toy_attached & run_xios_toy_server
[scheduling]
[[graph]]
R1 = """
prepare_hpc_host => extract_xios_background => build_xios => create_xios_module => create_prgenv_module => run_xios_toy_attached & run_xios_toy_server
{% if not XIOS_ONLY %}
prepare_hpc_host => extract_oasis => build_oasis => run_oasis_tutorial => create_oasis_module => build_xios
{% endif %}
"""

[runtime]
[[root]]
script = 'rose task-run --verbose'
[[LINUX_SERVER]]
[[[job]]]
batch system = slurm
execution time limit = PT15M
execution time limit = PT15M
platform = slurm
[[[directives]]]
--ntasks=1
--mem=1G
--qos=normal
--partition=rhel7
[[LOCALHOST]]
[[[remote]]]
host={{ROSE_ORIG_HOST}}
[[[job]]]
batch system = background
platform=localhost
[[HPC]]
env-script = "{{MODULE_CMD}}"
[[[job]]]
batch system = pbs
[[[remote]]]
host = $(rose host-select {{ HPC_HOST_OASIS }})
platform = {{HPC_HOST}}
[[HPC_SERIAL]]
inherit = None, HPC
[[[job]]]
execution time limit = PT10M
execution time limit = PT10M
[[[environment]]]
ROSE_TASK_N_JOBS = 1
[[[directives]]]
Expand All @@ -72,7 +58,7 @@ MODULE_STR = {{ MODULES|join(' ') }}
--mem=8G
[[[environment]]]
HPC_HOST_USERNAME={{HPC_HOST_USERNAME}}
HPC_HOST_OASIS={{HPC_HOST_OASIS}}
HPC_HOST={{HPC_HOST}}
EXTRACT_OASIS={{EXTRACT_OASIS}}
{% if EXTRACT_OASIS == true %}
OASIS_BRANCH={{OASIS_BRANCH}}
Expand All @@ -82,8 +68,7 @@ MODULE_STR = {{ MODULES|join(' ') }}
{% endif %}
[[build_oasis]]
inherit = None, HPC_SERIAL, OASIS
[[[job]]]
execution time limit = PT20M
execution time limit = PT20M
[[[environment]]]
BUILD_MCT={{BUILD_MCT}}
BUILD_TEST={{BUILD_TEST}}
Expand Down Expand Up @@ -130,18 +115,15 @@ MODULE_STR = {{ MODULES|join(' ') }}
[[[environment]]]
XIOSPATH=$CYLC_SUITE_RUN_DIR/share/xios
[[extract_xios_background]]
inherit = XIOS
[[[remote]]]
host = login.exz
[[[job]]]
execution time limit = PT10M
inherit = XIOS, HPC_SERIAL
[[[environment]]]
ROSE_TASK_APP=extract_xios
XIOS_VERSION={{XIOS_VERSION}}
XIOS_REV={{XIOS_REV}}
XIOS_URL={{XIOS_URL}}
[[build_xios]]
inherit = None, HPC, XIOS
execution time limit = PT2H
env-script = """
{{MODULE_CMD}};
{% if not XIOS_ONLY %}
Expand All @@ -153,8 +135,6 @@ MODULE_STR = {{ MODULES|join(' ') }}
"""
[[[environment]]]
XIOS_ONLY={{XIOS_ONLY}}
[[[job]]]
execution time limit = PT2H
[[[directives]]]
-l select=1:ncpus=8
[[create_xios_module]]
Expand All @@ -176,6 +156,7 @@ MODULE_STR = {{ MODULES|join(' ') }}
{% endif %}
[[RUN_XIOS_TOY]]
env-script = """
{{MODULE_CMD}};
eval $(cat $CYLC_SUITE_RUN_DIR/share/load_prgenv_mod.sh);
module use $TEST_PRGENV_MODULE_PATH
module load $TEST_PRGENV_MODULE_NAME
Expand Down Expand Up @@ -206,7 +187,7 @@ MODULE_STR = {{ MODULES|join(' ') }}
"""
[[[environment]]]
XIOS_ONLY={{XIOS_ONLY}}
MODULE_STR={{MODULE_STR}}
MODULE_STR={{MODULE_CMD}}
{% if not XIOS_ONLY %}
PRG_ENV_VERSION={{GC_PRG_ENV_VERSION}}
PRG_ENV_NAME={{GC_PRG_ENV_NAME}}
Expand Down
Loading