diff --git a/parm/soca/berror/saber_blocks.yaml b/parm/soca/berror/saber_blocks.yaml index d2d90fcd7..22a01dbf2 100644 --- a/parm/soca/berror/saber_blocks.yaml +++ b/parm/soca/berror/saber_blocks.yaml @@ -79,11 +79,15 @@ components: read local nicas: true model: do not cross mask boundaries: false - groups: - - group name: group 1 - variables: [tocn, socn, uocn, vocn, ssh] - - group name: group 2 - variables: [cicen, hicen, hsnon] +# groups: +# - group name: group 1 +# variables: [tocn, socn, uocn, vocn, ssh] +# - group name: group 2 +# variables: [cicen, hicen, hsnon] weight: - value: 0.5 + read_from_file: 3 + basename: ./ + ocn_filename: 'ocn.ens_weights.incr.{{ATM_WINDOW_MIDDLE}}.nc' + ice_filename: 'ice.ens_weights.incr.{{ATM_WINDOW_MIDDLE}}.nc' + date: '{{ATM_WINDOW_MIDDLE}}' diff --git a/parm/soca/berror/soca_ensweights.yaml b/parm/soca/berror/soca_ensweights.yaml new file mode 100644 index 000000000..4e302a48b --- /dev/null +++ b/parm/soca/berror/soca_ensweights.yaml @@ -0,0 +1,26 @@ +geometry: + mom6_input_nml: mom_input.nml + fields metadata: ./fields_metadata.yaml + +date: '{{ATM_WINDOW_MIDDLE}}' + +variables: + ice: [cicen, hicen, hsnon] + ocean: [tocn, socn, uocn, vocn, ssh] + +background: + date: '{{ATM_WINDOW_BEGIN}}' + basename: ./INPUT/ + ocn_filename: MOM.res.nc + ice_filename: cice.res.nc + read_from_file: 1 + +weights: + ice: 0.1 + ocean: 0.5 + +output: + datadir: ./ + date: '{{ATM_WINDOW_MIDDLE}}' + exp: ens_weights + type: incr diff --git a/scripts/exgdas_global_marine_analysis_bmat.sh b/scripts/exgdas_global_marine_analysis_bmat.sh index 6cc8e0efe..0c6e27178 100755 --- a/scripts/exgdas_global_marine_analysis_bmat.sh +++ b/scripts/exgdas_global_marine_analysis_bmat.sh @@ -180,6 +180,14 @@ if [ ${#files[@]} -gt 0 ]; then shopt -u nullglob fi +################################################################################ +# Write ensemble weights for the hybrid envar +$APRUN_OCNANAL $JEDI_BIN/socahybridweights.x soca_ensweights.yaml +export err=$?; err_chk +if [ $err -gt 0 ]; then + exit $err +fi + ################################################################################ # Set decorrelation scales for bump C $APRUN_OCNANAL $JEDI_BIN/soca_setcorscales.x soca_setcorscales.yaml diff --git a/scripts/exgdas_global_marine_analysis_prep.py b/scripts/exgdas_global_marine_analysis_prep.py index 2be745614..5391788a8 100755 --- a/scripts/exgdas_global_marine_analysis_prep.py +++ b/scripts/exgdas_global_marine_analysis_prep.py @@ -407,6 +407,13 @@ def find_clim_ens(input_date): config = Template.substitute_structure(config, TemplateConstants.DOLLAR_PARENTHESES, envconfig.get) config.save(berr_yaml) +logging.info(f"---------------- generate soca_ensweights.yaml") +berr_yaml = os.path.join(anl_dir, 'soca_ensweights.yaml') +berr_yaml_template = os.path.join(berror_yaml_dir, 'soca_ensweights.yaml') +config = YAMLFile(path=berr_yaml_template) +config = Template.substitute_structure(config, TemplateConstants.DOUBLE_CURLY_BRACES, envconfig.get) +config.save(berr_yaml) + ################################################################################ # copy yaml for decorrelation length scales diff --git a/test/soca/gw/CMakeLists.txt b/test/soca/gw/CMakeLists.txt index 4b48c7b6a..fd920a96b 100644 --- a/test/soca/gw/CMakeLists.txt +++ b/test/soca/gw/CMakeLists.txt @@ -40,8 +40,9 @@ set(jjob_list "JGDAS_GLOBAL_OCEAN_ANALYSIS_PREP" # "JGDAS_GLOBAL_OCEAN_ANALYSIS_BMAT_VRFY" "JGDAS_GLOBAL_OCEAN_ANALYSIS_RUN" "JGDAS_GLOBAL_OCEAN_ANALYSIS_CHKPT" - "JGDAS_GLOBAL_OCEAN_ANALYSIS_POST") +# "JGDAS_GLOBAL_OCEAN_ANALYSIS_POST") # "JGDAS_GLOBAL_OCEAN_ANALYSIS_VRFY") +) set(setup "") foreach(jjob ${jjob_list}) @@ -62,3 +63,8 @@ foreach(jjob ${jjob_list}) set(setup "--skip") # Only run the setup of the first test, if not, it will hang # waiting for standard input from setup_expt.py endforeach() + +# Test hyb-weights app +add_test(NAME test_gdasapp_hyb_weights + COMMAND ${PROJECT_BINARY_DIR}/bin/socahybridweights.x ${PROJECT_SOURCE_DIR}/test/testinput/soca_hybweights.yaml + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/soca/gw/testrun/testjjobs/RUNDIRS/gdas_test/gdasocnanal_12) diff --git a/test/testinput/soca_hybweights.yaml b/test/testinput/soca_hybweights.yaml new file mode 100644 index 000000000..cdad1ab27 --- /dev/null +++ b/test/testinput/soca_hybweights.yaml @@ -0,0 +1,26 @@ +geometry: + mom6_input_nml: mom_input.nml + fields metadata: ./fields_metadata.yaml + +date: 2018-04-15T09:00:00Z + +variables: + ice: [cicen, hicen, hsnon] + ocean: [tocn, socn, uocn, vocn, ssh] + +background: + date: '2018-04-15T09:00:00Z' + basename: ./INPUT/ + ocn_filename: MOM.res.nc + ice_filename: cice.res.nc + read_from_file: 1 + +weights: + ice: 0.1 + ocean: 0.5 + +output: + datadir: ./ + date: '2018-04-15T12:00:00Z' + exp: hybrid_weights + type: incr diff --git a/utils/socahybridweights.cc b/utils/socahybridweights.cc new file mode 100644 index 000000000..5869a090d --- /dev/null +++ b/utils/socahybridweights.cc @@ -0,0 +1,8 @@ +#include "socahybridweights.h" +#include "oops/runs/Run.h" + +int main(int argc, char ** argv) { + oops::Run run(argc, argv); + gdasapp::SocaHybridWeights socahybridweights; + return run.execute(socahybridweights); +} diff --git a/utils/socahybridweights.h b/utils/socahybridweights.h new file mode 100644 index 000000000..d6a52c357 --- /dev/null +++ b/utils/socahybridweights.h @@ -0,0 +1,86 @@ +#include +#include +#include + +#include "eckit/config/LocalConfiguration.h" + +#include "atlas/field.h" + +#include "oops/base/PostProcessor.h" +#include "oops/mpi/mpi.h" +#include "oops/runs/Application.h" +#include "oops/util/DateTime.h" +#include "oops/util/Duration.h" +#include "oops/util/Logger.h" + +#include "soca/State/State.h" +#include "soca/Geometry/Geometry.h" +#include "soca/Increment/Increment.h" + +namespace gdasapp { + + class SocaHybridWeights : public oops::Application { + public: + explicit SocaHybridWeights(const eckit::mpi::Comm & comm = oops::mpi::world()) + : Application(comm) {} + static const std::string classname() {return "gdasapp::SocaHybridWeights";} + + int execute(const eckit::Configuration & fullConfig, bool /*validate*/) const { + + /// Setup the soca geometry + const eckit::LocalConfiguration geomConfig(fullConfig, "geometry"); + oops::Log::info() << "geometry: " << std::endl << geomConfig << std::endl; + const soca::Geometry geom(geomConfig, this->getComm()); + + /// Get the date + std::string strdt; + fullConfig.get("date", strdt); + util::DateTime dt = util::DateTime(strdt); + + /// Get the list of variables + oops::Variables socaOcnVars(fullConfig, "variables.ocean"); + oops::Variables socaIceVars(fullConfig, "variables.ice"); + oops::Variables socaVars(socaIceVars); + socaVars += socaOcnVars; + + /// Read the background + // TODO: Use the ice extent to set the weights ... no clue if this is + // possible at this level + soca::State socaBkg(geom, socaVars, dt); + const eckit::LocalConfiguration socaBkgConfig(fullConfig, "background"); + socaBkg.read(socaBkgConfig); + oops::Log::info() << "socaBkg: " << std::endl << socaBkg << std::endl; + + /// Read weights + const eckit::LocalConfiguration socaHWConfig(fullConfig, "weights"); + double wIce = socaHWConfig.getDouble("ice"); + double wOcean = socaHWConfig.getDouble("ocean"); + oops::Log::info() << "wIce: " << wIce << std::endl; + oops::Log::info() << "wOcean: " << wOcean << std::endl; + + /// Create fields of weights for seaice + soca::Increment socaIceHW(geom, socaVars, dt); // ocean field is mandatory for writting + socaIceHW.ones(); + socaIceHW *= wIce; + oops::Log::info() << "socaIceHW: " << std::endl << socaIceHW << std::endl; + const eckit::LocalConfiguration socaHWOutConfig(fullConfig, "output"); + socaIceHW.write(socaHWOutConfig); + + /// Create fields of weights for the ocean + soca::Increment socaOcnHW(geom, socaOcnVars, dt); + socaOcnHW.ones(); + socaOcnHW *= wOcean; + oops::Log::info() << "socaOcnHW: " << std::endl << socaOcnHW << std::endl; + socaOcnHW.write(socaHWOutConfig); + + return 0; + } + // ----------------------------------------------------------------------------- + private: + std::string appname() const { + return "gdasapp::SocaHybridWeights"; + } + // ----------------------------------------------------------------------------- + }; + +} // namespace gdasapp diff --git a/utils/socaincr2mom6.h b/utils/socaincr2mom6.h index 01e109988..c644b4c01 100644 --- a/utils/socaincr2mom6.h +++ b/utils/socaincr2mom6.h @@ -13,7 +13,6 @@ #include "oops/util/Duration.h" #include "oops/util/Logger.h" -#include "soca/State/State.h" #include "soca/Geometry/Geometry.h" #include "soca/Increment/Increment.h"