Skip to content

Commit

Permalink
pack data with missing value (#27)
Browse files Browse the repository at this point in the history
* pack data with missing value

* use XIOS int conversion

* skip notImplemented

* ipsl domain

* skip notImplemented

* restore skip
  • Loading branch information
mo-marqh authored Oct 25, 2024
1 parent ea19d2d commit 5f31386
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
sudo apt -yq install $(<dependencies)
- name: clone and build XIOS
run: |
svn co http://forge.ipsl.jussieu.fr/ioserver/svn/${{ matrix.version }} XIOS
svn co http://forge.ipsl.fr/ioserver/svn/${{ matrix.version }} XIOS
cp arch/* XIOS/arch/
cd XIOS
if [ ${{ matrix.version }} == 'XIOS3/trunk' ]; then
Expand Down
12 changes: 3 additions & 9 deletions xios_examples/packing_scale_offset/axis_check.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@

<calendar type="Gregorian"/>

<axis_definition>
<axis id="x" unit="1" long_name="original x coordinate" />
<axis id="y" unit="1" long_name="original y coordinate" />

</axis_definition>

<grid_definition>
<grid id="oax_grid">
<axis axis_ref="x" />
<axis axis_ref="y" />
<axis id="x" />
<axis id="y" />
</grid>

</grid_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" grid_ref="oax_grid" operation="instant" />
<field id="odatax" name="original_data" grid_ref="oax_grid" operation="instant" read_access=".true." />
</file>
</file_definition>

Expand Down
6 changes: 3 additions & 3 deletions xios_examples/packing_scale_offset/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<calendar type="Gregorian"/>

<domain_definition>

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

</domain_definition>

Expand All @@ -24,10 +24,10 @@

<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="odatain" name="original_data" grid_ref="original_grid" operation="instant" read_access=".true." />
</file>
<file id="domain_output" output_freq="1ts">
<field_group operation="once">
<field_group operation="once" conversion_by_netcdf=".false.">
<field field_ref="odata" />
<field field_ref="pdata" />
</field_group>
Expand Down
18 changes: 15 additions & 3 deletions xios_examples/packing_scale_offset/pack.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ subroutine initialise()
integer :: mpi_error
integer :: lenx
integer :: leny
double precision, dimension (:), allocatable :: latvals, lonvals
double precision, dimension (:,:), allocatable :: latb, lonb

! Arbitrary datetime setup, required for XIOS but unused
origin = xios_date(2022, 2, 2, 12, 0, 0)
Expand All @@ -54,14 +56,23 @@ subroutine initialise()
call xios_get_axis_attr('x', n_glo=lenx)
call xios_get_axis_attr('y', n_glo=leny)

! initialize the main context for interacting with the data.
allocate ( lonvals(lenx) )
allocate ( latvals(leny) )
allocate ( lonb(2, lenx) )
allocate ( latb(2, leny) )

call xios_get_axis_attr('x', value=lonvals)
call xios_get_axis_attr('y', value=latvals)

! ! initialize the main context for interacting with the data.
call xios_context_initialize('main', comm)

call xios_set_time_origin(origin)
call xios_set_start_date(start)
call xios_set_timestep(tstep)

call xios_set_domain_attr("original_domain", ni=lenx, nj=leny, ibegin=0, jbegin=0)
call xios_set_domain_attr("original_domain", ni_glo=lenx, nj_glo=leny, ni=lenx, nj=leny, ibegin=0, jbegin=0)
call xios_set_domain_attr("original_domain", lonvalue_1d=lonvals, latvalue_1d=latvals)

call xios_close_context_definition()

Expand All @@ -76,7 +87,7 @@ subroutine finalise()
call xios_context_finalize()
call xios_set_current_context('main')
call xios_context_finalize()
call MPI_Comm_free(comm, mpi_error)
! call MPI_Comm_free(comm, mpi_error)
call xios_finalize()
call MPI_Finalize(mpi_error)

Expand All @@ -93,6 +104,7 @@ subroutine simulate()
! Allocatable arrays, size is taken from input file
double precision, dimension (:,:), allocatable :: inodata

print *, "simulate"
call xios_get_domain_attr('original_domain', ni_glo=lenx)
call xios_get_domain_attr('original_domain', nj_glo=leny)

Expand Down
31 changes: 31 additions & 0 deletions xios_examples/packing_scale_offset/pack_data_thirds_missing.cdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
netcdf domain_input {
dimensions:
x = 5 ;
y = 5 ;
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";
double original_data(y,x) ;
original_data:long_name = "input data values" ;
original_data:units = "1";

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

data:

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

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

original_data = 0, 0.6666666666666666, 1.3333333333333333, 2, 2.6666666666666665,
0.6666666666666666, 1.3333333333333333, 2, 2.6666666666666665, 3.3333333333333335,
1.3333333333333333, 2, 2.6666666666666665, 3.3333333333333335, 4,
2, 2.6666666666666665, 3.3333333333333335, 4, 4.666666666666667,
2.6666666666666665, 3.3333333333333335, 4, 4.666666666666667, _ ;

}
6 changes: 3 additions & 3 deletions xios_examples/packing_scale_offset/test_packing_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def test_pack(self):
# unique name for the test
tname = 'test_{}'.format(os.path.splitext(os.path.basename(f))[0])
# add the test as an attribute (function) to the test class
if os.environ.get('MVER', '').startswith('XIOS3/trunk'):
# these tests are hitting exceptions with XIOS3
# but not XIOS2, so skip for XIOS3 runner
if os.environ.get('MVER', '') == 'XIOS/trunk@2252':
# this test is hitting exceptions with XIOS2@2252
# notImplemented "conversion_by_netcdf" , so skip for XIOS2@2252 runner
setattr(TestPackDomain, tname,
unittest.skip(TestPackDomain.make_a_pack_test(f)))
elif tname in known_failures:
Expand Down

0 comments on commit 5f31386

Please sign in to comment.