Skip to content

Commit

Permalink
Merge remote-tracking branch 'noaa-gfdl/dev/gfdl' into porous_barrier…
Browse files Browse the repository at this point in the history
…_touchup
  • Loading branch information
herrwang0 committed Aug 23, 2022
2 parents bbc59f8 + e3c71b0 commit 97b00c7
Show file tree
Hide file tree
Showing 18 changed files with 1,619 additions and 267 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/macos-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ jobs:
runs-on: macOS-latest

env:
FC: gfortran
CC: gcc-11
FC: gfortran-11

defaults:
run:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/macos-stencil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ jobs:
runs-on: macOS-latest

env:
FC: gfortran
CC: gcc-11
FC: gfortran-11

defaults:
run:
Expand Down
12 changes: 9 additions & 3 deletions config_src/drivers/FMS_cap/ocean_model_MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module ocean_model_mod
use MOM_variables, only : surface
use MOM_verticalGrid, only : verticalGrid_type
use MOM_ice_shelf, only : initialize_ice_shelf, shelf_calc_flux, ice_shelf_CS
use MOM_ice_shelf, only : initialize_ice_shelf_fluxes, initialize_ice_shelf_forces
use MOM_ice_shelf, only : add_shelf_forces, ice_shelf_end, ice_shelf_save_restart
use MOM_wave_interface, only: wave_parameters_CS, MOM_wave_interface_init
use MOM_wave_interface, only: Update_Surface_Waves
Expand Down Expand Up @@ -274,9 +275,13 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, wind_stagger, gas
if (.not.OS%is_ocean_pe) return

OS%Time = Time_in ; OS%Time_dyn = Time_in
! Call initialize MOM with an optional Ice Shelf CS which, if present triggers
! initialization of ice shelf parameters and arrays.

call initialize_MOM(OS%Time, Time_init, param_file, OS%dirs, OS%MOM_CSp, &
OS%restart_CSp, Time_in, offline_tracer_mode=OS%offline_tracer_mode, &
diag_ptr=OS%diag, count_calls=.true., waves_CSp=OS%Waves)
diag_ptr=OS%diag, count_calls=.true., ice_shelf_CSp=OS%ice_shelf_CSp, &
waves_CSp=OS%Waves)
call get_MOM_state_elements(OS%MOM_CSp, G=OS%grid, GV=OS%GV, US=OS%US, C_p=OS%C_p, &
C_p_scaled=OS%fluxes%C_p, use_temp=use_temperature)

Expand Down Expand Up @@ -372,9 +377,10 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, wind_stagger, gas
endif

if (OS%use_ice_shelf) then
call initialize_ice_shelf(param_file, OS%grid, OS%Time, OS%ice_shelf_CSp, &
OS%diag, OS%forces, OS%fluxes)
call initialize_ice_shelf_fluxes(OS%ice_shelf_CSp, OS%grid, OS%US, OS%fluxes)
call initialize_ice_shelf_forces(OS%ice_shelf_CSp, OS%grid, OS%US, OS%forces)
endif

if (OS%icebergs_alter_ocean) then
call marine_ice_init(OS%Time, OS%grid, param_file, OS%diag, OS%marine_ice_CSp)
if (.not. OS%use_ice_shelf) &
Expand Down
37 changes: 37 additions & 0 deletions config_src/external/database_comms/MOM_database_comms.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
!> Contains routines necessary to initialize communication with a database
module MOM_database_comms
! This file is part of MOM6. See LICENSE.md for the license.
use MOM_file_parser, only : param_file_type
use MOM_error_handler, only : MOM_error, WARNING
use database_client_interface, only : dbclient_type

implicit none; private

!> Control structure to store Database communication related parameters and objects
type, public :: dbcomms_CS_type
type(dbclient_type) :: client !< The Database client itself
logical :: use_dbclient !< If True, use Database within MOM6
logical :: colocated !< If True, the orchestrator was setup in 'co-located' mode
logical :: cluster !< If True, the orchestrator has three shards or more
integer :: colocated_stride !< Sets which ranks will load the model from the file
!! e.g. mod(rank,colocated_stride) == 0
end type dbcomms_CS_type

public :: database_comms_init
public :: dbclient_type

contains

subroutine database_comms_init(param_file, CS, client_in)
type(param_file_type), intent(in ) :: param_file !< Parameter file structure
type(dbcomms_CS_type), intent(inout) :: CS !< Control structure for Database
type(dbclient_type), optional, intent(in ) :: client_in !< If present, use a previously initialized
!! Database client

call MOM_error(WARNING,"dbcomms_init was compiled using the dummy module. If this was\n"//&
"a mistake, please follow the instructions in:\n"//&
"MOM6/config_src/external/dbclient/README.md")
end subroutine database_comms_init

end module MOM_database_comms

25 changes: 25 additions & 0 deletions config_src/external/database_comms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Overview
This module is designed to be used in conjunction with the SmartSim and
SmartRedis libraries found at https://github.com/CrayLabs/. These
libraries are used to perform machine-learning inference and online
analysis using a Redis-based database.

An earlier implementation of these routines was used in Partee et al. [2022]:
"Using Machine Learning at scale in numerical simulations with SmartSim:
An application to ocean climate modeling" (doi.org/10.1016/j.jocs.2022.101707)
to predict eddy kinetic energy for use in the MEKE module. The additional
scripts and installation instructions for compiling MOM6 for this case can
be found at: https://github.com/CrayLabs/NCAR_ML_EKE/. The substantive
code in the new implementation is part of `MOM_MEKE.F90`.

# File description

- `MOM_database_comms` contains just method signatures and elements of the
control structure that are imported elsewhere within the primary MOM6
code. This includes: `dbcomms_CS_type`, `dbclient_type`, and `database_comms_init`

- `database_client_interface.F90` contains the methods for a communication client
to transfer data and/or commands between MOM6 and a remote database. This is
roughly based on the SmartRedis library, though only the methods that are most
likely to be used with MOM6 are retained. This is to ensure that the API can be
tested without requiring MOM6 users to compile in the the full library.
Loading

0 comments on commit 97b00c7

Please sign in to comment.