diff --git a/src/mains/CMakeLists.txt b/src/mains/CMakeLists.txt index 874a75c4..bee4de4c 100644 --- a/src/mains/CMakeLists.txt +++ b/src/mains/CMakeLists.txt @@ -80,6 +80,11 @@ ecbuild_add_executable( TARGET soca_convertstate.x LIBS soca ) +ecbuild_add_executable( TARGET soca_converttostructuredgrid.x + SOURCES ConvertToStructuredGrid.cc + LIBS soca + ) + ecbuild_add_executable( TARGET soca_addincrement.x SOURCES AddIncrement.cc LIBS soca diff --git a/src/mains/ConvertToStructuredGrid.cc b/src/mains/ConvertToStructuredGrid.cc new file mode 100644 index 00000000..75d0958d --- /dev/null +++ b/src/mains/ConvertToStructuredGrid.cc @@ -0,0 +1,18 @@ +/* + * (C) Copyright 2017-2024 UCAR + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + */ + + +#include "oops/runs/ConvertToStructuredGrid.h" +#include "oops/runs/Run.h" +#include "soca/Traits.h" + +int main(int argc, char ** argv) { + oops::Run run(argc, argv); + oops::ConvertToStructuredGrid converttostructuredgrid; + return run.execute(converttostructuredgrid); +} + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ae2c4603..eca69c7d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -35,6 +35,7 @@ set( soca_test_input testinput/convertstate_changevar.yml testinput/convertstate_soca2cice.yml testinput/convertstate.yml + testinput/converttogauss.yml testinput/diffstates.yml testinput/dirac_diffusion.yml testinput/dirac_diffusion_lowres.yml @@ -120,6 +121,7 @@ set( soca_test_ref testref/convertstate_changevar.test testref/convertstate_soca2cice.test testref/convertstate.test + testref/converttogauss.test testref/diffstates.test testref/dirac_diffusion.test testref/dirac_parametric_ocean_stddev.test @@ -536,6 +538,11 @@ soca_add_test( NAME convertstate # NOTRAPFPE TEST_DEPENDS test_soca_gridgen ) +# Convert to Gaussian grid +soca_add_test( NAME converttogauss + EXE soca_converttostructuredgrid.x + TEST_DEPENDS test_soca_gridgen ) + # Apply a nonlinear change of variable to an ensemble of states soca_add_test( NAME convertstate_changevar EXE soca_convertstate.x diff --git a/test/testinput/converttogauss.yml b/test/testinput/converttogauss.yml new file mode 100644 index 00000000..d0fce361 --- /dev/null +++ b/test/testinput/converttogauss.yml @@ -0,0 +1,40 @@ +states to structured grid: +- state geometry: + geom_grid_file: data_generated/gridgen/soca_gridspec.72x35x25.nc + mom6_input_nml: data_static/72x35x25/input.nml + fields metadata: data_static/fields_metadata.yml + + state: + read_from_file: 1 + basename: data_static/72x35x25/restarts/ + ocn_filename: MOM.res.nc + ice_filename: cice.res.nc + sfc_filename: sfc.res.nc + date: &bkg_date 2018-04-15T00:00:00Z + state variables: + - sea_surface_height_above_geoid + - sea_water_potential_temperature + - sea_water_salinity + - sea_water_cell_thickness + - sea_ice_area_fraction + - sea_water_depth + + structured grid interpolation: + grid type: regular gaussian + local interpolator type: atlas interpolator + interpolation method: + type: finite-element + number of latitude gridpoints: 12 + variables to output: + - sea_surface_height_above_geoid + - sea_water_potential_temperature + - sea_water_salinity + - sea_ice_area_fraction + all model levels: true + bottom model level: false + datapath: data_output/ + prefix: converttogauss +test: + reference filename: testref/converttogauss.test + test output filename: testoutput/converttogauss.test + float relative tolerance: 1.0e-3 diff --git a/test/testref/converttogauss.test b/test/testref/converttogauss.test new file mode 100644 index 00000000..bd2d0a2e --- /dev/null +++ b/test/testref/converttogauss.test @@ -0,0 +1,4 @@ +StructuredGridWriter:: +Grid Resolution: 12 +Variables: 4 variables: sea_surface_height_above_geoid, sea_water_potential_temperature, sea_water_salinity, sea_ice_area_fraction +Output on Levels: All Model Levels