Skip to content

Commit

Permalink
verMatrix
Browse files Browse the repository at this point in the history
  • Loading branch information
mo-marqh committed Feb 14, 2024
1 parent b3faa0b commit 5c1d325
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/buildTest.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
name: build-test-XIOS

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:

jobs:
build_test:
name: build XIOS and run tests
name: build test
runs-on: ubuntu-latest
strategy:
matrix:
version: [XIOS/trunk@2252, XIOS2/trunk, XIOS3/trunk]
# version: [XIOS/trunk@2252, XIOS2/trunk, XIOS3/trunk]
version: [XIOS/trunk@2252, XIOS2/trunk]
steps:
# Check out repository branch
- uses: actions/checkout@v4
Expand Down Expand Up @@ -42,8 +47,10 @@ jobs:
run: |
. arch/arch-GCC_LINUX_APT.env
. arch/arch-GCC_LINUX_APT.path
export XIOS_BINDIR=$PWD/XIOS2/bin
export XIOS_INCDIR=$PWD/XIOS2/inc
export XIOS_LIBDIR=$PWD/XIOS2/lib
export XIOS_BINDIR=$PWD/XIOS/bin
export XIOS_INCDIR=$PWD/XIOS/inc
export XIOS_LIBDIR=$PWD/XIOS/lib
python3 -m unittest Discover -v -s xios_examples
export MVER=${{ matrix.version }}
python3 -m unittest discover -v -s xios_examples
34 changes: 28 additions & 6 deletions xios_examples/read_axis_resample/test_resample_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import os
import subprocess
import glob
import unittest

this_path = os.path.realpath(__file__)
Expand All @@ -12,7 +13,7 @@
class TestResample(unittest.TestCase):
"""
UnitTest class to contain tests,
1 test casce function per input `.cdl` file
1 test case function per input `.cdl` file
"""
@classmethod
Expand All @@ -21,14 +22,34 @@ def setUpClass(cls):
First, build the fortran code only once for this class.
"""
subprocess.run(['make', 'clean'], cwd=this_dir)
subprocess.run(['make'], cwd=this_dir)
subprocess.run(['make', 'clean'], cwd=this_dir, check=True)
subprocess.run(['make'], cwd=this_dir, check=True)
if os.environ.get('MVER', '') == 'XIOS3/trunk':
with open(os.path.join(this_dir, 'iodef.xml'), 'r') as ioin:
iodef_in = ioin.read()
# patch in transport protocol choice for XIOS3
# needed for CI runners
in2 = '<variable_group id="parameters" >'
in3 = ('<variable_group id="parameters" >\n'
' <variable id="transport_protocol" '
'type="string" >p2p</variable>')
iodef_out = iodef_in.replace(in2, in3)
with open(os.path.join(this_dir, 'iodef.xml'), 'w') as ioout:
ioout.write(iodef_out)

def tearDown(self):
"""
After each test function, remove the input and output netCDF files.
After each test function,
report any errors from XIOS, then
remove the input and output netCDF files.
"""

for ef in glob.glob('{}/*.err'.format(this_dir)):
print(ef)
with open(ef, 'r') as efile:
print(efile.read(), flush=True)

os.remove('{}/axis_input.nc'.format(this_dir))
os.remove('{}/axis_output.nc'.format(this_dir))

Expand Down Expand Up @@ -59,10 +80,11 @@ def make_a_test(inf):
def test_resample(self):
# create a netCDF file from the `.cdl` input
subprocess.run(['ncgen', '-k', 'nc4', '-o', 'axis_input.nc',
infile], cwd=this_dir)
infile], cwd=this_dir, check=True)
# run the compiled Fortran XIOS programme
subprocess.run(['mpiexec', '-n', '1', './resample.exe', ':',
'-n', '1', './xios_server.exe'], cwd=this_dir)
'-n', '1', './xios_server.exe'],
cwd=this_dir, check=True)
# load the result netCDF file
rootgrp = netCDF4.Dataset('{}/axis_output.nc'.format(this_dir),
'r')
Expand Down

0 comments on commit 5c1d325

Please sign in to comment.