Skip to content

Commit

Permalink
Expose finer-grained control over physics subroutines (#7)
Browse files Browse the repository at this point in the history
This PR ports the changes in ai2cm/fv3gfs-fortran#317 to the SHiELD wrapper, which give us finer grained control over the steps of the time loop related to the physics.

It depends on NOAA-GFDL/atmos_drivers#30, which was merged upstream and incorporated into this repository in #11.
  • Loading branch information
spencerkclark authored Nov 3, 2023
1 parent af8c3be commit 41b9cc4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
21 changes: 17 additions & 4 deletions wrapper/lib/coupler_lib.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ module coupler_lib
update_atmos_model_dynamics, &
update_atmos_radiation_physics, &
update_atmos_model_state, &
atmos_data_type, atmos_model_restart
atmos_data_type, &
atmos_model_restart, &
update_atmos_pre_radiation, &
update_atmos_radiation, &
update_atmos_physics

!--- FMS old io
#ifdef use_deprecated_io
use fms_io_mod, only: fms_io_exit!< This can't be removed until fms_io is not used at all
Expand Down Expand Up @@ -194,12 +199,20 @@ subroutine do_dynamics() bind(c)
Time_atmos = Time_atmos + Time_step_atmos
call update_atmos_model_dynamics (Atm)
end subroutine do_dynamics

! substepped physics
subroutine do_pre_radiation() bind(c)
call update_atmos_pre_radiation (Atm)
end subroutine do_pre_radiation

subroutine do_radiation() bind(c)
call update_atmos_radiation (Atm)
end subroutine do_radiation

subroutine do_physics() bind(c)
call update_atmos_radiation_physics (Atm)
call update_atmos_model_state (Atm)
call update_atmos_physics (Atm)
end subroutine do_physics

subroutine compute_physics_subroutine() bind(c)
call update_atmos_radiation_physics (Atm)
end subroutine compute_physics_subroutine
Expand Down
3 changes: 3 additions & 0 deletions wrapper/shield/wrapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
initialize,
step,
step_dynamics,
step_radiation,
step_pre_radiation,
step_post_radiation_physics,
step_physics,
save_intermediate_restart_if_enabled,
save_fortran_restart,
Expand Down
22 changes: 22 additions & 0 deletions wrapper/templates/_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,28 @@ def _get_diagnostic_data(int idx):
return pace.util.Quantity(array, dims, units=units)


cdef extern:
void do_pre_radiation()
void do_radiation()
void do_physics()


def step_pre_radiation():
"""Do pre-radiation computations (e.g. time varying logic)"""
do_pre_radiation()


def step_radiation():
"""Compute Radiative transfer scheme"""
do_radiation()


def step_post_radiation_physics():
"""Compute Post-radiation physics (e.g. moist physics turbulence)"""
# TODO ensure that IPD_control.first_step is set in this routine
do_physics()


def transform_agrid_winds_to_dgrid_winds(ua, va):
"""Transform A-grid lat-lon winds to D-grid cubed-sphere winds.
This function wraps the cubed_a2d subroutine from the fortran model, making
Expand Down

0 comments on commit 41b9cc4

Please sign in to comment.