From 63858b9098fa9ecff7b7c2039d0de1949407cf46 Mon Sep 17 00:00:00 2001 From: mo-marqh Date: Tue, 10 Dec 2024 13:24:27 +0000 Subject: [PATCH 01/14] non-functional read4D test case --- .github/workflows/buildTest.yml | 2 +- xios_examples/read4D/Makefile | 34 +++++++ xios_examples/read4D/domain_check.xml | 25 +++++ xios_examples/read4D/iodef.xml | 8 ++ xios_examples/read4D/read.F90 | 127 ++++++++++++++++++++++++ xios_examples/read4D/sample_smaller.cdl | 105 ++++++++++++++++++++ xios_examples/read4D/test_read4D.py | 26 +++++ xios_examples/read4D/xios.xml | 22 ++++ 8 files changed, 348 insertions(+), 1 deletion(-) create mode 100644 xios_examples/read4D/Makefile create mode 100644 xios_examples/read4D/domain_check.xml create mode 100644 xios_examples/read4D/iodef.xml create mode 100644 xios_examples/read4D/read.F90 create mode 100644 xios_examples/read4D/sample_smaller.cdl create mode 100644 xios_examples/read4D/test_read4D.py create mode 100644 xios_examples/read4D/xios.xml diff --git a/.github/workflows/buildTest.yml b/.github/workflows/buildTest.yml index 523f8d3..3d946b3 100644 --- a/.github/workflows/buildTest.yml +++ b/.github/workflows/buildTest.yml @@ -55,4 +55,4 @@ jobs: export MVER=${{ matrix.version }} export MPI_FLAVOUR='openmpi' - python3 -m unittest discover -v -s xios_examples + python3 -m unittest xios_examples.read4D.test_read4D diff --git a/xios_examples/read4D/Makefile b/xios_examples/read4D/Makefile new file mode 100644 index 0000000..85efd8f --- /dev/null +++ b/xios_examples/read4D/Makefile @@ -0,0 +1,34 @@ +# Make file for the read demonstartion XIOS programme +# Targets provided our detailed below... +# +# all: (default) Build the read programme +# clean: Delete all final products and working files +# run: run the programme +# +# Environment Variables expected by this MakeFile: +# +# FC: mpif90 +# FCFLAGS: -g & include files for netcdf & xios +# LD_FLAGS: for xios, netcdf, netcdff, stfc++ +# LD_LIBRARY_PATH: for netCDF & XIOS libs +# XIOS_BINDIR: The directory for XIOS binary files + +.PHONY: all, clean, run + +all: read + +# fortran compilation +%.o: %.F90 + $(FC) $(FCFLAGS) -c $< + +# fortran linking +read: read.o + $(FC) -o read.exe read.o $(LDFLAGS) \ + && ln -fs $(XIOS_BINDIR)/xios_server.exe . + +run: + mpiexec -n 1 ./read.exe : -n 1 ./xios_server.exe + +# cleanup +clean: + rm -f *.exe *.o *.mod *.MOD *.out *.err diff --git a/xios_examples/read4D/domain_check.xml b/xios_examples/read4D/domain_check.xml new file mode 100644 index 0000000..2fc7972 --- /dev/null +++ b/xios_examples/read4D/domain_check.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xios_examples/read4D/iodef.xml b/xios_examples/read4D/iodef.xml new file mode 100644 index 0000000..d435cc3 --- /dev/null +++ b/xios_examples/read4D/iodef.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/xios_examples/read4D/read.F90 b/xios_examples/read4D/read.F90 new file mode 100644 index 0000000..1523d69 --- /dev/null +++ b/xios_examples/read4D/read.F90 @@ -0,0 +1,127 @@ +!----------------------------------------------------------------------------- +! (C) Crown copyright 2020 Met Office. All rights reserved. +! The file LICENCE, distributed with this code, contains details of the terms +! under which the code may be used. +!----------------------------------------------------------------------------- +!> Read 3D data on a domain + axis grid +!> +program resample + use xios + use mpi + + implicit none + + integer :: comm = -1 + integer :: rank = -1 + integer :: npar = 0 + + call initialise() + ! call simulate() + call finalise() +contains + + subroutine initialise() + + type(xios_date) :: origin + type(xios_date) :: start + type(xios_duration) :: tstep + integer :: mpi_error + integer :: ni_glo + integer :: nj_glo + integer :: ni + integer :: nj + integer :: ibegin + integer :: jbegin + integer :: nk_glo + integer :: nk + integer :: kbegin + integer :: nl_glo + integer :: nl + integer :: lbegin + integer :: nm_glo + integer :: nm + integer :: mbegin + + ! Datetime setup, required for XIOS & matched to input + origin = xios_date(2024, 11, 15, 0, 0, 0) + start = xios_date(2024, 11, 15, 0, 0, 0) + tstep = xios_hour * 6 + + ! Initialise MPI and XIOS + call MPI_INIT(mpi_error) + + call xios_initialize('client', return_comm=comm) + + call MPI_Comm_rank(comm, rank, mpi_error) + call MPI_Comm_size(comm, npar, mpi_error) + + call xios_context_initialize('domain_check', comm) + call xios_set_time_origin(origin) + call xios_set_start_date(start) + call xios_set_timestep(tstep) + print *, "ready to close context domain_check" + call xios_close_context_definition() + print *, "context domain_check closed (read?)" + + call xios_get_domain_attr("original_domain", & + ni_glo=ni_glo, nj_glo=nj_glo, & + ni=ni, nj=nj, & + ibegin=ibegin, jbegin=jbegin) + print *, 'original_domain: rank,ni_glo,nj_glo,ni,nj,ibegin,jbegin ',rank,ni_glo,nj_glo,ni,nj,ibegin,jbegin + ! call xios_get_axis_attr("hm", n_glo=ni_glo, n=ni, begin=ibegin) + ! print *, 'hm: n_glo, n, begin', ni_glo, ni, ibegin + ! call xios_get_axis_attr("hmm", n_glo=nj_glo, n=nj, begin=jbegin) + ! print *, 'hm: n_glo, n, begin', nj_glo, nj, jbegin + call xios_get_axis_attr("eh", n_glo=nm_glo, n=nm, begin=mbegin) + print *, 'eh: n_glo, n, begin', nm_glo, nm, mbegin + call xios_get_axis_attr("mlev", n_glo=nk_glo, n=nk, begin=kbegin) + print *, 'mlev: n_glo, n, begin', nk_glo, nk, kbegin + call xios_get_axis_attr("t", n_glo=nl_glo, n=nl, begin=lbegin) + print *, 't: n_glo, n, begin', nl_glo, nl, lbegin + + + + end subroutine initialise + + subroutine finalise() + + integer :: mpi_error + + print *, "! Finalise all XIOS contexts and MPI" + call xios_set_current_context('domain_check') + call xios_context_finalize() + print *, "domain_check context finalised" + ! call xios_set_current_context('main') + ! call xios_context_finalize() + call MPI_Comm_free(comm, mpi_error) + call xios_finalize() + call MPI_Finalize(mpi_error) + + end subroutine finalise + + subroutine simulate() + + type(xios_date) :: current + integer :: ts + integer :: lenx + integer :: leny + integer :: lenz + integer :: lent + + ! Allocatable arrays, size is taken from input file + double precision, dimension (:,:,:,:), allocatable :: inshdata + + call xios_get_domain_attr('original_domain', ni=lenx, nj=leny) + call xios_get_axis_attr("mlev", n=lenz) + call xios_get_axis_attr("t", n=lent) + + allocate ( inshdata(lent, lenz, leny, lenx) ) + + ! Load data from the input file + call xios_recv_field('specific_humidity', inshdata) + print *, "data loaded from specific humidity array variable" + deallocate (inshdata) + + end subroutine simulate + +end program resample diff --git a/xios_examples/read4D/sample_smaller.cdl b/xios_examples/read4D/sample_smaller.cdl new file mode 100644 index 0000000..e70fc13 --- /dev/null +++ b/xios_examples/read4D/sample_smaller.cdl @@ -0,0 +1,105 @@ +netcdf sample_smaller { +dimensions: + time = 2 ; + model_level_number = 4 ; + latitude = 95 ; + longitude = 127 ; + bnds = 2 ; +variables: + float specific_humidity(time, model_level_number, latitude, longitude) ; + specific_humidity:standard_name = "specific_humidity" ; + specific_humidity:units = "kg kg-1" ; + specific_humidity:grid_mapping = "latitude_longitude" ; + specific_humidity:coordinates = "forecast_period forecast_reference_time level_height sigma surface_altitude" ; + int latitude_longitude ; + latitude_longitude:grid_mapping_name = "latitude_longitude" ; + latitude_longitude:longitude_of_prime_meridian = 0. ; + latitude_longitude:earth_radius = 6371229. ; + double time(time) ; + time:axis = "T" ; + time:units = "hours since 1970-01-01 00:00:00" ; + time:standard_name = "time" ; + time:calendar = "standard" ; + int model_level_number(model_level_number) ; + model_level_number:axis = "Z" ; + model_level_number:units = "1" ; + model_level_number:standard_name = "model_level_number" ; + model_level_number:positive = "up" ; + float latitude(latitude) ; + latitude:axis = "Y" ; + latitude:units = "degrees_north" ; + latitude:standard_name = "latitude" ; + float longitude(longitude) ; + longitude:axis = "X" ; + longitude:units = "degrees_east" ; + longitude:standard_name = "longitude" ; + double forecast_period ; + forecast_period:units = "hours" ; + forecast_period:standard_name = "forecast_period" ; + double forecast_reference_time(time) ; + forecast_reference_time:units = "hours since 1970-01-01 00:00:00" ; + forecast_reference_time:standard_name = "forecast_reference_time" ; + forecast_reference_time:calendar = "standard" ; + float level_height(model_level_number) ; + level_height:bounds = "level_height_bnds" ; + level_height:units = "m" ; + level_height:long_name = "level_height" ; + level_height:positive = "up" ; + level_height:standard_name = "atmosphere_hybrid_height_coordinate" ; + level_height:axis = "Z" ; + level_height:formula_terms = "a: level_height b: sigma orog: surface_altitude" ; + float level_height_bnds(model_level_number, bnds) ; + float sigma(model_level_number) ; + sigma:bounds = "sigma_bnds" ; + sigma:units = "1" ; + sigma:long_name = "sigma" ; + float sigma_bnds(model_level_number, bnds) ; + float surface_altitude(latitude, longitude) ; + surface_altitude:units = "m" ; + surface_altitude:standard_name = "surface_altitude" ; + +// global attributes: + :Conventions = "CF-1.7" ; +data: + + time = 481008, 481014 ; + + model_level_number = 0, 1, 2, 3 ; + + latitude = -89.95312, -89.85938, -89.76562, -89.67188, -89.57812, -89.48438, + -89.39062, -89.29688, -89.20312, -89.10938, -89.01562, -88.92188, + -88.82812, -88.73438, -88.64062, -88.54688, -88.45312, -88.35938, + -88.26562, -88.17188, -88.07812, -87.98438, -87.89062, -87.79688, + -87.70312, -87.60938, -87.51562, -87.42188, -87.32812, -87.23438, + -87.14062, -87.04688, -86.95312, -86.85938, -86.76562, -86.67188, + -86.57812, -86.48438, -86.39062, -86.29688, -86.20312, -86.10938, + -86.01562, -85.92188, -85.82812, -85.73438, -85.64062, -85.54688, + -85.45312, -85.35938, -85.26562, -85.17188, -85.07812, -84.98438, + -84.89062, -84.79688, -84.70312, -84.60938, -84.51562, -84.42188, + -84.32812, -84.23438, -84.14062, -84.04688, -83.95312, -83.85938, + -83.76562, -83.67188, -83.57812, -83.48438, -83.39062, -83.29688, + -83.20312, -83.10938, -83.01562, -82.92188, -82.82812, -82.73438, + -82.64062, -82.54688, -82.45312, -82.35938, -82.26562, -82.17188, + -82.07812, -81.98438, -81.89062, -81.79688, -81.70312, -81.60938, + -81.51562, -81.42188, -81.32812, -81.23438, -81.14062 ; + + longitude = 0.0703125, 0.2109375, 0.3515625, 0.4921875, 0.6328125, + 0.7734375, 0.9140625, 1.054688, 1.195312, 1.335938, 1.476562, 1.617188, + 1.757812, 1.898438, 2.039062, 2.179688, 2.320312, 2.460938, 2.601562, + 2.742188, 2.882812, 3.023438, 3.164062, 3.304688, 3.445312, 3.585938, + 3.726562, 3.867188, 4.007812, 4.148438, 4.289062, 4.429688, 4.570312, + 4.710938, 4.851562, 4.992188, 5.132812, 5.273438, 5.414062, 5.554688, + 5.695312, 5.835938, 5.976562, 6.117188, 6.257812, 6.398438, 6.539062, + 6.679688, 6.820312, 6.960938, 7.101562, 7.242188, 7.382812, 7.523438, + 7.664062, 7.804688, 7.945312, 8.085938, 8.226562, 8.367188, 8.507812, + 8.648438, 8.789062, 8.929688, 9.070312, 9.210938, 9.351562, 9.492188, + 9.632812, 9.773438, 9.914062, 10.05469, 10.19531, 10.33594, 10.47656, + 10.61719, 10.75781, 10.89844, 11.03906, 11.17969, 11.32031, 11.46094, + 11.60156, 11.74219, 11.88281, 12.02344, 12.16406, 12.30469, 12.44531, + 12.58594, 12.72656, 12.86719, 13.00781, 13.14844, 13.28906, 13.42969, + 13.57031, 13.71094, 13.85156, 13.99219, 14.13281, 14.27344, 14.41406, + 14.55469, 14.69531, 14.83594, 14.97656, 15.11719, 15.25781, 15.39844, + 15.53906, 15.67969, 15.82031, 15.96094, 16.10156, 16.24219, 16.38281, + 16.52344, 16.66406, 16.80469, 16.94531, 17.08594, 17.22656, 17.36719, + 17.50781, 17.64844, 17.78906 ; +} diff --git a/xios_examples/read4D/test_read4D.py b/xios_examples/read4D/test_read4D.py new file mode 100644 index 0000000..b658f0a --- /dev/null +++ b/xios_examples/read4D/test_read4D.py @@ -0,0 +1,26 @@ +import copy +import glob +import netCDF4 +import numpy as np +import os +import subprocess +import unittest + +import xios_examples.shared_testing as xshared + +this_path = os.path.realpath(__file__) +this_dir = os.path.dirname(this_path) + +class TestRead4D(xshared._TestCase): + test_dir = this_dir + transient_inputs = ['sample_smaller.nc'] + transient_outputs = [] + executable = './read.exe' + + def test_read_4d(self): + inputfile = self.transient_inputs[0] + infile = inputfile.replace('.nc', '.cdl') + + subprocess.run(['ncgen', '-k', 'nc4', '-o', inputfile, + infile], cwd=self.test_dir, check=True) + self.run_mpi_xios() diff --git a/xios_examples/read4D/xios.xml b/xios_examples/read4D/xios.xml new file mode 100644 index 0000000..9ec1df0 --- /dev/null +++ b/xios_examples/read4D/xios.xml @@ -0,0 +1,22 @@ + + + + + performance + + + 1.0 + + + + + true + + 100 + + + true + + + + From dfc8178eee4fdc4dada9da765d4e021fe663af6c Mon Sep 17 00:00:00 2001 From: mo-marqh Date: Tue, 10 Dec 2024 13:37:30 +0000 Subject: [PATCH 02/14] pin xios3 for patch --- .github/workflows/buildTest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildTest.yml b/.github/workflows/buildTest.yml index 3d946b3..b366d3e 100644 --- a/.github/workflows/buildTest.yml +++ b/.github/workflows/buildTest.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - version: [XIOS/trunk@2252, XIOS2/trunk, XIOS3/trunk] + version: [XIOS/trunk@2252, XIOS2/trunk, XIOS3/trunk@2686] steps: # Check out repository branch - uses: actions/checkout@v4 @@ -26,7 +26,7 @@ jobs: svn co http://forge.ipsl.fr/ioserver/svn/${{ matrix.version }} XIOS cp arch/* XIOS/arch/ cd XIOS - if [ ${{ matrix.version }} == 'XIOS3/trunk' ]; then + if [ ${{ matrix.version }} == 'XIOS3/trunk@2686' ]; then patch -p0 < ../patches/xios3/revert_svn2517_transport.patch sed -i 's// p2p<\/variable>/g' generic_testcase/iodef.xml cat generic_testcase/iodef.xml From d4db416fd8d0e4bf2b3fb9e084629143e6cb6e5c Mon Sep 17 00:00:00 2001 From: mo-marqh Date: Tue, 10 Dec 2024 13:47:33 +0000 Subject: [PATCH 03/14] pin ubuntu for xios builds (temporary) --- .github/workflows/buildTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildTest.yml b/.github/workflows/buildTest.yml index b366d3e..44d7689 100644 --- a/.github/workflows/buildTest.yml +++ b/.github/workflows/buildTest.yml @@ -9,7 +9,7 @@ on: jobs: build_test: name: build test - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: version: [XIOS/trunk@2252, XIOS2/trunk, XIOS3/trunk@2686] From a1b7e89995fc0a27137d909cecc7e20b921ac2a6 Mon Sep 17 00:00:00 2001 From: mo-marqh Date: Tue, 10 Dec 2024 14:28:33 +0000 Subject: [PATCH 04/14] match 4D skip r2252 --- xios_examples/read4D/domain_check.xml | 3 --- xios_examples/read4D/read.F90 | 14 +++----------- xios_examples/read4D/test_read4D.py | 2 ++ 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/xios_examples/read4D/domain_check.xml b/xios_examples/read4D/domain_check.xml index 2fc7972..d4fd36a 100644 --- a/xios_examples/read4D/domain_check.xml +++ b/xios_examples/read4D/domain_check.xml @@ -8,9 +8,6 @@ - - - diff --git a/xios_examples/read4D/read.F90 b/xios_examples/read4D/read.F90 index 1523d69..51e2db1 100644 --- a/xios_examples/read4D/read.F90 +++ b/xios_examples/read4D/read.F90 @@ -16,7 +16,7 @@ program resample integer :: npar = 0 call initialise() - ! call simulate() + call simulate() call finalise() contains @@ -38,9 +38,6 @@ subroutine initialise() integer :: nl_glo integer :: nl integer :: lbegin - integer :: nm_glo - integer :: nm - integer :: mbegin ! Datetime setup, required for XIOS & matched to input origin = xios_date(2024, 11, 15, 0, 0, 0) @@ -68,12 +65,6 @@ subroutine initialise() ni=ni, nj=nj, & ibegin=ibegin, jbegin=jbegin) print *, 'original_domain: rank,ni_glo,nj_glo,ni,nj,ibegin,jbegin ',rank,ni_glo,nj_glo,ni,nj,ibegin,jbegin - ! call xios_get_axis_attr("hm", n_glo=ni_glo, n=ni, begin=ibegin) - ! print *, 'hm: n_glo, n, begin', ni_glo, ni, ibegin - ! call xios_get_axis_attr("hmm", n_glo=nj_glo, n=nj, begin=jbegin) - ! print *, 'hm: n_glo, n, begin', nj_glo, nj, jbegin - call xios_get_axis_attr("eh", n_glo=nm_glo, n=nm, begin=mbegin) - print *, 'eh: n_glo, n, begin', nm_glo, nm, mbegin call xios_get_axis_attr("mlev", n_glo=nk_glo, n=nk, begin=kbegin) print *, 'mlev: n_glo, n, begin', nk_glo, nk, kbegin call xios_get_axis_attr("t", n_glo=nl_glo, n=nl, begin=lbegin) @@ -115,8 +106,9 @@ subroutine simulate() call xios_get_axis_attr("mlev", n=lenz) call xios_get_axis_attr("t", n=lent) - allocate ( inshdata(lent, lenz, leny, lenx) ) + allocate ( inshdata(lent, lenz, leny, lenx) ) + print *, "ready to load data from specific humidity array variable" ! Load data from the input file call xios_recv_field('specific_humidity', inshdata) print *, "data loaded from specific humidity array variable" diff --git a/xios_examples/read4D/test_read4D.py b/xios_examples/read4D/test_read4D.py index b658f0a..622ad2d 100644 --- a/xios_examples/read4D/test_read4D.py +++ b/xios_examples/read4D/test_read4D.py @@ -17,6 +17,8 @@ class TestRead4D(xshared._TestCase): transient_outputs = [] executable = './read.exe' + @unittest.skipIf(os.environ.get('MVER', '') == 'XIOS/trunk@2252', + "skipping for ") def test_read_4d(self): inputfile = self.transient_inputs[0] infile = inputfile.replace('.nc', '.cdl') From 1a6cd1fe25643173702095c2bd5566551b5cd613 Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Wed, 11 Dec 2024 11:44:16 +0000 Subject: [PATCH 05/14] xios3 read_access --- xios_examples/read4D/domain_check.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xios_examples/read4D/domain_check.xml b/xios_examples/read4D/domain_check.xml index d4fd36a..53f072e 100644 --- a/xios_examples/read4D/domain_check.xml +++ b/xios_examples/read4D/domain_check.xml @@ -15,7 +15,7 @@ - + From 8ae52edf0f6a7674e4db9f6e88cbb1f7a03e9c49 Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:55:13 +0000 Subject: [PATCH 06/14] try in situ syntax update for XIOS3 domain vname:: syntax --- xios_examples/read4D/test_read4D.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xios_examples/read4D/test_read4D.py b/xios_examples/read4D/test_read4D.py index 622ad2d..f880a81 100644 --- a/xios_examples/read4D/test_read4D.py +++ b/xios_examples/read4D/test_read4D.py @@ -26,3 +26,16 @@ def test_read_4d(self): subprocess.run(['ncgen', '-k', 'nc4', '-o', inputfile, infile], cwd=self.test_dir, check=True) self.run_mpi_xios() + + @classmethod + def setUpClass(cls): + if os.environ.get('MVER', '').startswith('XIOS3/trunk'): + with open(os.path.join(cls.test_dir, 'read.F90'), 'r') as ioin: + iodef_in = ioin.read() + # patch in XIOS3 domain access source code syntax + in2 = 'xios_get_domain_attr("original_domain"' + in3 = ('xios_get_domain_attr("specific_humidity::"') + iodef_out = iodef_in.replace(in2, in3) + with open(os.path.join(cls.test_dir, 'read.F90'), 'w') as ioout: + ioout.write(iodef_out) + super().setUpClass() From c0637f10f60761661c3926221ea4897c754f3cda Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:11:00 +0000 Subject: [PATCH 07/14] unpin xios3 --- .github/workflows/buildTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildTest.yml b/.github/workflows/buildTest.yml index 6cff782..e2ffc9d 100644 --- a/.github/workflows/buildTest.yml +++ b/.github/workflows/buildTest.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-24.04 strategy: matrix: - version: [XIOS/trunk@2252, XIOS2/trunk, XIOS3/trunk@2686] + version: [XIOS/trunk@2252, XIOS2/trunk, XIOS3/trunk] steps: # Check out repository branch - uses: actions/checkout@v4 From af13edd1fe60c8c7468becccab8a1d740e9b7348 Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:34:03 +0000 Subject: [PATCH 08/14] unchange --- xios_examples/read4D/test_read4D.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/xios_examples/read4D/test_read4D.py b/xios_examples/read4D/test_read4D.py index f880a81..622ad2d 100644 --- a/xios_examples/read4D/test_read4D.py +++ b/xios_examples/read4D/test_read4D.py @@ -26,16 +26,3 @@ def test_read_4d(self): subprocess.run(['ncgen', '-k', 'nc4', '-o', inputfile, infile], cwd=self.test_dir, check=True) self.run_mpi_xios() - - @classmethod - def setUpClass(cls): - if os.environ.get('MVER', '').startswith('XIOS3/trunk'): - with open(os.path.join(cls.test_dir, 'read.F90'), 'r') as ioin: - iodef_in = ioin.read() - # patch in XIOS3 domain access source code syntax - in2 = 'xios_get_domain_attr("original_domain"' - in3 = ('xios_get_domain_attr("specific_humidity::"') - iodef_out = iodef_in.replace(in2, in3) - with open(os.path.join(cls.test_dir, 'read.F90'), 'w') as ioout: - ioout.write(iodef_out) - super().setUpClass() From 7b39f71bb3070bd062f112f714cee8e0d9041932 Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:06:48 +0000 Subject: [PATCH 09/14] Update read.F90 --- xios_examples/read4D/read.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xios_examples/read4D/read.F90 b/xios_examples/read4D/read.F90 index 51e2db1..f634ee1 100644 --- a/xios_examples/read4D/read.F90 +++ b/xios_examples/read4D/read.F90 @@ -102,7 +102,7 @@ subroutine simulate() ! Allocatable arrays, size is taken from input file double precision, dimension (:,:,:,:), allocatable :: inshdata - call xios_get_domain_attr('original_domain', ni=lenx, nj=leny) + call xios_get_domain_attr("original_domain", ni=lenx, nj=leny) call xios_get_axis_attr("mlev", n=lenz) call xios_get_axis_attr("t", n=lent) From 5dbc4028baa826344ff8b574d9c67903cd73d759 Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:06:56 +0000 Subject: [PATCH 10/14] Update test_read4D.py --- xios_examples/read4D/test_read4D.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xios_examples/read4D/test_read4D.py b/xios_examples/read4D/test_read4D.py index 622ad2d..f880a81 100644 --- a/xios_examples/read4D/test_read4D.py +++ b/xios_examples/read4D/test_read4D.py @@ -26,3 +26,16 @@ def test_read_4d(self): subprocess.run(['ncgen', '-k', 'nc4', '-o', inputfile, infile], cwd=self.test_dir, check=True) self.run_mpi_xios() + + @classmethod + def setUpClass(cls): + if os.environ.get('MVER', '').startswith('XIOS3/trunk'): + with open(os.path.join(cls.test_dir, 'read.F90'), 'r') as ioin: + iodef_in = ioin.read() + # patch in XIOS3 domain access source code syntax + in2 = 'xios_get_domain_attr("original_domain"' + in3 = ('xios_get_domain_attr("specific_humidity::"') + iodef_out = iodef_in.replace(in2, in3) + with open(os.path.join(cls.test_dir, 'read.F90'), 'w') as ioout: + ioout.write(iodef_out) + super().setUpClass() From 4b6358336e4379857da977fb191be4fa9f9326b3 Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:26:13 +0000 Subject: [PATCH 11/14] run all tests --- .github/workflows/buildTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildTest.yml b/.github/workflows/buildTest.yml index e2ffc9d..dbb2015 100644 --- a/.github/workflows/buildTest.yml +++ b/.github/workflows/buildTest.yml @@ -56,4 +56,4 @@ jobs: export MVER=${{ matrix.version }} export MPI_FLAVOUR='openmpi' - python3 -m unittest xios_examples.read4D.test_read4D + python3 -m unittest discover -v -s xios_examples From 687fcb3f9c5deb0bd60fd5493a7fe7c5e1fe2f45 Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:53:29 +0000 Subject: [PATCH 12/14] Create __init__.py --- xios_examples/read4D/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 xios_examples/read4D/__init__.py diff --git a/xios_examples/read4D/__init__.py b/xios_examples/read4D/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/xios_examples/read4D/__init__.py @@ -0,0 +1 @@ + From f44e919f713bce3e69cfc76dfe854e076711eb38 Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:56:06 +0000 Subject: [PATCH 13/14] Create readme.md --- xios_examples/read4D/readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 xios_examples/read4D/readme.md diff --git a/xios_examples/read4D/readme.md b/xios_examples/read4D/readme.md new file mode 100644 index 0000000..5eacdf7 --- /dev/null +++ b/xios_examples/read4D/readme.md @@ -0,0 +1,8 @@ +read4D +------ + +This example reads in a sample NetCDF file of 4D structured data (data payload is `missing`). +XIOS simply reads data from that file into memory. + +This is designed to be extensible, enabling much larger files to be read, +across multiple client and server ranks, and performance analyses undertaken From 9e61d690a8effd2cbcda8c994c39fc2dbc415f9f Mon Sep 17 00:00:00 2001 From: mo-marqh <87382490+mo-marqh@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:38:59 +0000 Subject: [PATCH 14/14] justify skip --- xios_examples/read4D/test_read4D.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xios_examples/read4D/test_read4D.py b/xios_examples/read4D/test_read4D.py index f880a81..0467a2d 100644 --- a/xios_examples/read4D/test_read4D.py +++ b/xios_examples/read4D/test_read4D.py @@ -17,6 +17,16 @@ class TestRead4D(xshared._TestCase): transient_outputs = [] executable = './read.exe' + # There is a bug in the dimensionality reading of structured domains + # in XIOS2r2252 which is fixed in the newer version of XIOS2. + # this manifests as: + # ```In file "nc4_data_input.cpp", function "virtual void + # xios::CNc4DataInput::readFieldAttributes_(xios::CField*, bool)", + # line 154 -> Field 'specific_humidity' has incorrect dimension + # Verify dimension of grid defined by 'grid_ref' or 'domain_ref'/'axis_ref' + # and dimension of grid in read file.``` + # The dimensionality is correct in the test, but XIOS2r2252 gets this wrong. + # hence, skip test for this test matrix element. @unittest.skipIf(os.environ.get('MVER', '') == 'XIOS/trunk@2252', "skipping for ") def test_read_4d(self):