Skip to content

Commit

Permalink
Add multi-rank domain decomposition test (#13)
Browse files Browse the repository at this point in the history
* Add multi-rank domain decomposition test

* Add MPI_FLAVOUR environment variable for github
  • Loading branch information
jeff-cole authored Apr 18, 2024
1 parent 7316624 commit 8db37f6
Show file tree
Hide file tree
Showing 14 changed files with 479 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/buildTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ jobs:
export XIOS_LIBDIR=$PWD/XIOS/lib
export MVER=${{ matrix.version }}
export MPI_FLAVOUR='openmpi'
python3 -m unittest discover -v -s xios_examples
1 change: 1 addition & 0 deletions xios_examples/read_domain_decomp_resample/Makefile
5 changes: 5 additions & 0 deletions xios_examples/read_domain_decomp_resample/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
read_domain_resample
--------------------

These examples read in arbitrary data from a netCDF file and resample to a different horizontal domain as defined within the input netCDF file using bilinear interpolation.
The original and resampled data as well as a diff between them are written to one output NetCDF file. The unit tests include two known failure test cases where the expected result is not produced.
3 changes: 3 additions & 0 deletions xios_examples/read_domain_decomp_resample/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Enable this folder to be a module path, for imports and test discovery.
"""
24 changes: 24 additions & 0 deletions xios_examples/read_domain_decomp_resample/domain_check.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<context>

<calendar type="Gregorian"/>

<domain_definition>

<domain id="original_domain" type="rectilinear" >
<generate_rectilinear_domain/>
</domain>

<domain id="resampled_domain" type="rectilinear" >
<generate_rectilinear_domain/>
</domain>

</domain_definition>

<file_definition type="one_file">
<file id="din" name="domain_input" output_freq="1ts" mode="read" enabled=".true.">
<field id="odatax" name="original_data" domain_ref="original_domain" operation="instant" />
<field id="edatax" name="resample_data" domain_ref="resampled_domain" operation="instant" />
</file>
</file_definition>

</context>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
netcdf domain_input {
dimensions:
x = 5 ;
y = 5 ;
x_resample = 4 ;
y_resample = 4 ;
variables:
float x(x) ;
x:long_name = "original x coordinate" ;
x:units = "1";
float y(y) ;
y:long_name = "original y coordinate" ;
y:units = "1";
float x_resample(x_resample) ;
x_resample:long_name = "resampled x coordinate" ;
x_resample:units = "1";
float y_resample(y_resample) ;
y_resample:long_name = "resampled y coordinate" ;
y_resample:units = "1";
double original_data(y,x) ;
original_data:long_name = "input data values" ;
original_data:units = "1";
double resample_data(y_resample,x_resample) ;
resample_data:long_name = "expected resampled data values" ;
resample_data:units = "1";

// global attributes:
:title = "Input data for XIOS Domain resampling; data is a square function of the x & y coordinates; x^2+y^2." ;

data:

x = 0, 2, 4, 6, 8 ;

y = 0, 2, 4, 6, 8 ;

x_resample = 1, 3, 5, 7 ;

y_resample = 1, 3, 5, 7 ;

original_data = 0, 4, 16, 36, 64,
4, 8, 20, 40, 68,
16, 20, 32, 52, 80,
36, 40, 52, 72, 100,
64, 68, 80, 100, 128 ;

resample_data = 2, 10, 26, 50,
10, 18, 34, 58,
26, 34, 50, 74,
50, 58, 74, 98 ;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
netcdf domain_input {
dimensions:
x = 5 ;
y = 5 ;
x_resample = 2 ;
y_resample = 2 ;
variables:
float x(x) ;
x:long_name = "original x coordinate" ;
x:units = "1";
float y(y) ;
y:long_name = "original y coordinate" ;
y:units = "1";
float x_resample(x_resample) ;
x_resample:long_name = "resampled x coordinate" ;
x_resample:units = "1";
float y_resample(y_resample) ;
y_resample:long_name = "resampled y coordinate" ;
y_resample:units = "1";
double original_data(y,x) ;
original_data:long_name = "input data values" ;
original_data:units = "1";
double resample_data(y_resample,x_resample) ;
resample_data:long_name = "expected resampled data values" ;
resample_data:units = "1";

// global attributes:
:title = "Input data for XIOS Domain resampling; data is a sum of the x & y coordinates; x + y ." ;

data:

x = 0, 2, 4, 6, 8 ;

y = 0, 2, 4, 6, 8 ;

x_resample = 3, 5 ;

y_resample = 3, 5 ;

original_data = 0, 2, 4, 6, 8,
2, 4, 6, 8, 10,
4, 6, 8, 10, 12,
6, 8, 10, 12, 14,
8, 10, 12, 14, 16 ;

resample_data = 6, 8,
8, 10 ;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
netcdf domain_input {
dimensions:
x = 5 ;
y = 5 ;
x_resample = 2 ;
y_resample = 2 ;
variables:
float x(x) ;
x:long_name = "original x coordinate" ;
x:units = "1";
float y(y) ;
y:long_name = "original y coordinate" ;
y:units = "1";
float x_resample(x_resample) ;
x_resample:long_name = "resampled x coordinate" ;
x_resample:units = "1";
float y_resample(y_resample) ;
y_resample:long_name = "resampled y coordinate" ;
y_resample:units = "1";
double original_data(y,x) ;
original_data:long_name = "input data values" ;
original_data:units = "1";
double resample_data(y_resample,x_resample) ;
resample_data:long_name = "expected resampled data values" ;
resample_data:units = "1";

// global attributes:
:title = "Input data for XIOS Domain resampling; data is a square function of the x & y coordinates; x^2+y^2." ;

data:

x = 0, 2, 4, 6, 8 ;

y = 0, 2, 4, 6, 8 ;

x_resample = 3, 5 ;

y_resample = 3, 5 ;

original_data = 0, 4, 16, 36, 64,
4, 8, 20, 40, 68,
16, 20, 32, 52, 80,
36, 40, 52, 72, 100,
64, 68, 80, 100, 128 ;

resample_data = 18, 34,
34, 50 ;

}
9 changes: 9 additions & 0 deletions xios_examples/read_domain_decomp_resample/iodef.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<simulation>

<context id="main" src="main.xml"/>
<context id="domain_check" src="domain_check.xml"/>

<context id="xios" src="xios.xml"/>

</simulation>
48 changes: 48 additions & 0 deletions xios_examples/read_domain_decomp_resample/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<context>

<calendar type="Gregorian"/>

<domain_definition>

<domain id="original_domain" type="rectilinear" />
<domain id="resampled_domain" type="rectilinear" >
<interpolate_domain id="interpolator" order="1"/>
</domain>

</domain_definition>

<grid_definition>

<grid id="original_grid">
<domain domain_ref="original_domain" />
</grid>
<grid id="resampled_grid">
<domain domain_ref="resampled_domain" />
</grid>

</grid_definition>

<field_definition prec="8">
<field id="edata" name="resample_data" grid_ref="resampled_grid" long_name="expected resampled data values" unit="1" />
<field id="odata" name="original_data" grid_ref="original_grid" long_name="input data values" unit="1" />
<field id="rdata" name="resampled_data" field_ref="odata" grid_ref="resampled_grid" long_name="resampled data values" unit="1" />
<field id="diff" name="resampled_minus_resample" grid_ref="resampled_grid" long_name="resampled - expected" unit="1" >rdata-edata</field>
</field_definition>


<file_definition type="one_file">
<file id="domain_input" output_freq="1ts" mode="read" enabled=".true.">
<field id="odatain" name="original_data" grid_ref="original_grid" operation="instant" />
<field id="edatain" name="resample_data" grid_ref="resampled_grid" operation="instant" />
</file>
<file id="domain_output" output_freq="1ts">
<field_group operation="once">
<field field_ref="edata" />
<field field_ref="odata" />
<field field_ref="rdata" />
<field field_ref="diff" />
</field_group>
</file>
</file_definition>

</context>
Loading

0 comments on commit 8db37f6

Please sign in to comment.