enkf

Note

The uwtools drivers are idempotent, meaning that actions they successfully complete during one invocation are not repeated in subsequent invocations. For example, an asset like a configuration file will not be recreated when the driver is run again, even if its UW YAML configuration changes. To force recreation, remove the asset(s) in question – up to and including the entire provisioned run directory – then re-run the driver, which will recreate any missing assets based on the current configuration.

The uw mode for configuring and running the EnKF data assimilation tool. Each listed TASK may be called to generate the runtime asset(s) it is responsible for, and will call any task it depends on as needed. A provisioned_rundir comprises everything needed for a run, and a run runs the EnKF executable.

uw enkf --help
usage: uw enkf [-h] [--version] [--show-schema] TASK ...

Execute enkf tasks

Optional arguments:
  -h, --help
      Show help and exit
  --version
      Show version info and exit
  --show-schema
      Show driver schema and exit

Positional arguments:
  TASK
    background_files
      The ensemble background files
    files_copied
      Files copied for run
    files_hardlinked
      Files hardlinked for run
    files_linked
      Files linked for run
    namelist_file
      The namelist file
    provisioned_rundir
      Run directory provisioned with all required content
    run
      A run
    runscript
      The runscript
    show_output
      Show the output to be created by this component
    validate
      Validate the UW driver config

All tasks take the same arguments. For example:

uw enkf run --help
usage: uw enkf run --cycle CYCLE [-h] [--version] [--config-file PATH]
                   [--batch] [--dry-run] [--graph-file PATH]
                   [--key-path KEY[.KEY...]] [--schema-file PATH] [--quiet]
                   [--verbose]

A run

Required arguments:
  --cycle CYCLE
      The cycle in ISO8601 format (e.g. yyyy-mm-ddThh)

Optional arguments:
  -h, --help
      Show help and exit
  --version
      Show version info and exit
  --config-file PATH, -c PATH
      Path to UW YAML config file (default: read from stdin)
  --batch
      Submit job to batch scheduler
  --dry-run
      Only log info, making no changes
  --graph-file PATH
      Path to Graphviz DOT output [experimental]
  --key-path KEY[.KEY...]
      Dot-separated path of keys to driver config block
  --schema-file PATH
      Path to schema file to use for validation
  --quiet, -q
      Print no logging messages
  --verbose, -v
      Print all logging messages

Examples

The examples use a configuration file named config.yaml with contents similar to:

enkf:
  execution:
    batchargs:
      walltime: "00:50:00"
      cores: 120
      exclusive: true
    envcmds:
      - module use /some/path/to/modulefiles
      - module load some_module
      - ulimit -s unlimited
    executable: /path/to/enkf.x
    mpicmd: srun
    stacksize: 300M
    threads: 1
  background_files:
    ensemble_size: 80
    files:
      fv3sar_tile1_{{ '%03d' % member }}_dynvars: "/path/to/previous/fv3_{{ '%03d' % member }}/RESTART/fv_core.res.tile1.nc"
      fv3sar_tile1_{{ '%03d' % member }}_tracer: "/path/to/previous/fv3_{{ '%03d' % member }}/RESTART/fv_tracer.res.tile1.nc"
      fv3sar_tile1_{{ '%03d' % member }}_sfcdata: "/path/to/previous/fv3_{{ '%03d' % member }}/RESTART/sfc_data.nc"
      fv3sar_tile1_{{ '%03d' % member }}_phyvar: "/path/to/previous/fv3_{{ '%03d' % member }}/RESTART/phy_data.nc"
  files_to_copy:
    anavinfo: "{{ platform.gsi_fixdir }}/anavinfo.rrfs_conv_dbz"
    satinfo: "{{ platform.gsi_fixdir }}/global_satinfo.txt"
    convinfo: "{{ platform.gsi_fixdir }}/convinfo.rrfs"
    ozinfo: "{{ platform.gsi_fixdir }}/global_ozinfo.txt"
  files_to_link:
    fv3_coupler.res: "{{ platform.gsi_fixdir }}/RRFS_CONUS_13km/fv3_coupler.res"
    fv3_akbk: "{{ platform.gsi_fixdir }}/RRFS_CONUS_13km/fv3_akbk"
    fv3_grid_spec: "{{ platform.gsi_fixdir }}/RRFS_CONUS_13km/fv3_grid_spec"
    <diagfiles>: !glob "{{ observer.rundir }}/diag*"
  namelist:
    base_file: /path/to/a/run-ready/enkf.nml
  rundir: /path/to/run/dir
platform: 
  gsi_fixdir: /path/to/gsi/fix/files
  scheduler: slurm
  account: wrfruc

Its contents are described in depth in section enkf.

  • Run EnKF on an interactive node

    $ uw enkf run --config-file config.yaml --cycle 2025-02-12T12
    

    The driver creates a runscript.enkf file in the directory specified by rundir: in the config and runs it, executing enkf.

  • Run enkf via a batch job

    $ uw enkf run --config-file config.yaml --cycle 2025-02-12T12 --batch
    

    The driver creates a runscript.enkf file in the directory specified by rundir: in the config and submits it to the batch system. Running with --batch requires a correctly configured platform: block in config.yaml, as well as appropriate settings in the execution: block under enkf:.

  • Specifying the --dry-run flag results in the driver logging messages about actions it would have taken, without actually taking any.

    $ uw enkf run --config-file config.yaml --cycle 2025-02-12T12 --batch --dry-run
    
  • The --key-path option can be used to navigate from the top of the config to the driver’s configuration block. For example, specifying --key-path foo.bar with config

    foo:
      bar:
        driver:
          # driver config block
    

    is equivalent to using config

    driver:
      # driver config block
    

    without specifying --key-path.

  • The run task depends on the other available tasks and executes them as prerequisites. It is possible to execute any task directly, which entails execution of any of its dependencies. For example, to create an enkf run directory provisioned with all the files, directories, symlinks, etc. required per the configuration file:

    $ uw enkf provisioned_rundir --config-file config.yaml --cycle 2025-02-12T12 --batch
    
  • Specifying the --show-schema flag, with no other options, prints the driver’s schema:

    uw enkf --show-schema >schema
    head -n20 schema
    
    {
      "properties": {
        "enkf": {
          "additionalProperties": false,
          "properties": {
            "background_files": {
              "additionalProperties": false,
              "properties": {
                "ensemble_size": {
                  "minimum": 2,
                  "type": "integer"
                },
                "files": {
                  "additionalProperties": {
                    "type": "fs_src"
                  },
                  "minProperties": 1,
                  "type": "object"
                }
              },
    
  • Use the --schema-file option to specify a custom JSON Schema file with which to validate the driver config. A custom schema could range in complexity from the simplest, most permissive schema, {}, to one based on the internal schema shown by --show-schema.