Skip to content

Commit

Permalink
Feature/fv3core fortran api (#395)
Browse files Browse the repository at this point in the history
his PR adds an API to call the Pace dycore from GEOS.
Code changes:

    fv3core/pace/fv3core/initialization/geos_wrapper.py: Added a wrapper api to access the dynamical core from GEOS. Initialize it with a namelist, communicator, and backend, call it with numpy arrays and it returns a dictionary of numpy arrays.
    tests/main/fv3core/test_init_from_geos.py: A simple test that checks that the GEOS wrapper is initialized correctly, populates the dycore state correctly, steps through the dycore, and outputs arrays in the output dictionary.
    fv3core/pace/fv3core/init.py: Added the geos wrapper to init.py to make it importable at the base level.
    util/pace/util/grid/eta.py: Added code to setup atmosphere with 91 vertical levels for GEOS runs.
    util/pace/util/initialization/sizer.py: Revised the from_namelist method to work with our updated namelist configuration that doesn't use fv_core_nml as a key.
  • Loading branch information
oelbert authored Dec 9, 2022
1 parent 0620667 commit 5dddd21
Show file tree
Hide file tree
Showing 6 changed files with 1,018 additions and 7 deletions.
4 changes: 4 additions & 0 deletions fv3core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,7 @@ TEST_ARGS="-v -s --pdb" RUN_FLAGS="--rm -it" make tests
```

This can be done with any pytest target, such as `make savepoint_tests` and `make savepoint_tests_mpi`.

### GEOS API

The `GeosDycoreWrapper` class provides an API to run the dynamical core in a Python component of a GEOS model run. A `GeosDycoreWrapper` object is initialized with a namelist, communicator, and backend, which creates the communicators, partitioners, dycore state, and dycore object required to run the Pace dycore. A wrapper object takes numpy arrays of `u, v, w, delz, pt, delp, q, ps, pe, pk, peln, pkz, phis, q_con, omga, ua, va, uc, vc, mfxd, mfyd, cxd, cyd,` and `diss_estd` and returns a dictionary containing numpy arrays of those same variables. Wrapper objects contain a `timer` attrubite that tracks the amount of time moving input data to the dycore state, running the dynamical core, and retrieving the data from the state.
1 change: 1 addition & 0 deletions fv3core/pace/fv3core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ._config import DynamicalCoreConfig
from .initialization.dycore_state import DycoreState
from .initialization.geos_wrapper import GeosDycoreWrapper
from .stencils.fv_dynamics import DynamicalCore
from .stencils.fv_subgridz import DryConvectiveAdjustment

Expand Down
Loading

0 comments on commit 5dddd21

Please sign in to comment.