Skip to content

Commit

Permalink
Merge branch 'dev/gfdl' into PR_ZB_2020_combined
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallward authored Jun 26, 2023
2 parents 7c75722 + dd1ee34 commit a9f7e2a
Show file tree
Hide file tree
Showing 37 changed files with 1,278 additions and 1,064 deletions.
16 changes: 11 additions & 5 deletions ac/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,21 @@ AC_COMPILE_IFELSE(
]
)

# Python interpreter test

# Verify that Python is available
AC_PATH_PROGS([PYTHON], [python python3 python2], [
AC_MSG_ERROR([Could not find python.])
])
AC_ARG_VAR([PYTHON], [Python interpreter command])

AS_VAR_SET_IF([PYTHON], [
AC_PATH_PROGS([PYTHON], ["$PYTHON"], [none])
], [
AC_PATH_PROGS([PYTHON], [python python3 python2], [none])
])
AS_VAR_IF([PYTHON], [none], [
AC_MSG_ERROR([Python interpreter not found.])
])


# Verify that makedep is available
# Makedep test
AC_PATH_PROG([MAKEDEP], [makedep], [${srcdir}/ac/makedep])
AC_SUBST([MAKEDEP])

Expand Down
5 changes: 3 additions & 2 deletions ac/makedep
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ from __future__ import print_function

import argparse
import glob
import io
import os
import re
import sys # used only to get path to current script
import sys


# Pre-compile re searches
Expand Down Expand Up @@ -255,7 +256,7 @@ def scan_fortran_file(src_file):
"""Scan the Fortran file "src_file" and return lists of module defined,
module used, and files included."""
module_decl, used_modules, cpp_includes, f90_includes, programs = [], [], [], [], []
with open(src_file, 'r') as file:
with io.open(src_file, 'r', errors='replace') as file:
lines = file.readlines()
for line in lines:
match = re_module.match(line.lower())
Expand Down
15 changes: 9 additions & 6 deletions config_src/drivers/FMS_cap/MOM_surface_forcing_gfdl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module MOM_surface_forcing_gfdl
use MOM_grid, only : ocean_grid_type
use MOM_interpolate, only : init_external_field, time_interp_external
use MOM_interpolate, only : time_interp_external_init
use MOM_interpolate, only : external_field
use MOM_io, only : slasher, write_version_number, MOM_read_data
use MOM_io, only : read_netCDF_data
use MOM_io, only : stdout_if_root
Expand Down Expand Up @@ -153,8 +154,10 @@ module MOM_surface_forcing_gfdl
!! in inputdir/temp_restore_mask.nc and the field should
!! be named 'mask'
real, pointer, dimension(:,:) :: trestore_mask => NULL() !< Mask for SST restoring [nondim]
integer :: id_srestore = -1 !< An id number for time_interp_external.
integer :: id_trestore = -1 !< An id number for time_interp_external.
type(external_field) :: srestore_handle
!< Handle for time-interpolated salt restoration field
type(external_field) :: trestore_handle
!< Handle for time-interpolated temperature restoration field

type(forcing_diags), public :: handles !< Diagnostics handles

Expand Down Expand Up @@ -345,7 +348,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! Salinity restoring logic
if (CS%restore_salt) then
call time_interp_external(CS%id_srestore, Time, data_restore, scale=US%ppt_to_S)
call time_interp_external(CS%srestore_handle, Time, data_restore, scale=US%ppt_to_S)
! open_ocn_mask indicates where to restore salinity (1 means restore, 0 does not)
open_ocn_mask(:,:) = 1.0
if (CS%mask_srestore_under_ice) then ! Do not restore under sea-ice
Expand Down Expand Up @@ -403,7 +406,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! SST restoring logic
if (CS%restore_temp) then
call time_interp_external(CS%id_trestore, Time, data_restore, scale=US%degC_to_C)
call time_interp_external(CS%trestore_handle, Time, data_restore, scale=US%degC_to_C)
if ( CS%trestore_SPEAR_ECDA ) then
do j=js,je ; do i=is,ie
if (abs(data_restore(i,j)+1.8*US%degC_to_C) < 0.0001*US%degC_to_C) then
Expand Down Expand Up @@ -1610,7 +1613,7 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, wind_stagger)

if (CS%restore_salt) then
salt_file = trim(CS%inputdir) // trim(CS%salt_restore_file)
CS%id_srestore = init_external_field(salt_file, CS%salt_restore_var_name, MOM_domain=G%Domain)
CS%srestore_handle = init_external_field(salt_file, CS%salt_restore_var_name, MOM_domain=G%Domain)
call safe_alloc_ptr(CS%srestore_mask,isd,ied,jsd,jed); CS%srestore_mask(:,:) = 1.0
if (CS%mask_srestore) then ! read a 2-d file containing a mask for restoring fluxes
flnam = trim(CS%inputdir) // 'salt_restore_mask.nc'
Expand All @@ -1620,7 +1623,7 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, wind_stagger)

if (CS%restore_temp) then
temp_file = trim(CS%inputdir) // trim(CS%temp_restore_file)
CS%id_trestore = init_external_field(temp_file, CS%temp_restore_var_name, MOM_domain=G%Domain)
CS%trestore_handle = init_external_field(temp_file, CS%temp_restore_var_name, MOM_domain=G%Domain)
call safe_alloc_ptr(CS%trestore_mask,isd,ied,jsd,jed); CS%trestore_mask(:,:) = 1.0
if (CS%mask_trestore) then ! read a 2-d file containing a mask for restoring fluxes
flnam = trim(CS%inputdir) // 'temp_restore_mask.nc'
Expand Down
15 changes: 9 additions & 6 deletions config_src/drivers/mct_cap/mom_surface_forcing_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module MOM_surface_forcing_mct
use MOM_grid, only : ocean_grid_type
use MOM_interpolate, only : init_external_field, time_interp_external
use MOM_interpolate, only : time_interp_external_init
use MOM_interpolate, only : external_field
use MOM_io, only : slasher, write_version_number, MOM_read_data
use MOM_io, only : stdout
use MOM_restart, only : register_restart_field, restart_init, MOM_restart_CS
Expand Down Expand Up @@ -134,8 +135,10 @@ module MOM_surface_forcing_mct
!! in inputdir/temp_restore_mask.nc and the field should
!! be named 'mask'
real, pointer, dimension(:,:) :: trestore_mask => NULL() !< mask for SST restoring
integer :: id_srestore = -1 !< id number for time_interp_external.
integer :: id_trestore = -1 !< id number for time_interp_external.
type(external_field) :: srestore_handle
!< Handle for time-interpolated salt restoration field
type(external_field) :: trestore_handle
!< Handle for time-interpolated temperature restoration field

type(forcing_diags), public :: handles !< diagnostics handles
type(MOM_restart_CS), pointer :: restart_CSp => NULL() !< restart pointer
Expand Down Expand Up @@ -348,7 +351,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! Salinity restoring logic
if (restore_salinity) then
call time_interp_external(CS%id_srestore, Time, data_restore, scale=US%ppt_to_S)
call time_interp_external(CS%srestore_handle, Time, data_restore, scale=US%ppt_to_S)
! open_ocn_mask indicates where to restore salinity (1 means restore, 0 does not)
open_ocn_mask(:,:) = 1.0
if (CS%mask_srestore_under_ice) then ! Do not restore under sea-ice
Expand Down Expand Up @@ -405,7 +408,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! SST restoring logic
if (restore_sst) then
call time_interp_external(CS%id_trestore, Time, data_restore, scale=US%degC_to_C)
call time_interp_external(CS%trestore_handle, Time, data_restore, scale=US%degC_to_C)
do j=js,je ; do i=is,ie
delta_sst = data_restore(i,j) - sfc_state%SST(i,j)
delta_sst = sign(1.0,delta_sst)*min(abs(delta_sst),CS%max_delta_trestore)
Expand Down Expand Up @@ -1292,7 +1295,7 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, restore_salt,

if (present(restore_salt)) then ; if (restore_salt) then
salt_file = trim(CS%inputdir) // trim(CS%salt_restore_file)
CS%id_srestore = init_external_field(salt_file, CS%salt_restore_var_name, domain=G%Domain%mpp_domain)
CS%srestore_handle = init_external_field(salt_file, CS%salt_restore_var_name, domain=G%Domain%mpp_domain)
call safe_alloc_ptr(CS%srestore_mask,isd,ied,jsd,jed); CS%srestore_mask(:,:) = 1.0
if (CS%mask_srestore) then ! read a 2-d file containing a mask for restoring fluxes
flnam = trim(CS%inputdir) // 'salt_restore_mask.nc'
Expand All @@ -1302,7 +1305,7 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, restore_salt,

if (present(restore_temp)) then ; if (restore_temp) then
temp_file = trim(CS%inputdir) // trim(CS%temp_restore_file)
CS%id_trestore = init_external_field(temp_file, CS%temp_restore_var_name, domain=G%Domain%mpp_domain)
CS%trestore_handle = init_external_field(temp_file, CS%temp_restore_var_name, domain=G%Domain%mpp_domain)
call safe_alloc_ptr(CS%trestore_mask,isd,ied,jsd,jed); CS%trestore_mask(:,:) = 1.0
if (CS%mask_trestore) then ! read a 2-d file containing a mask for restoring fluxes
flnam = trim(CS%inputdir) // 'temp_restore_mask.nc'
Expand Down
28 changes: 17 additions & 11 deletions config_src/drivers/nuopc_cap/mom_surface_forcing_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module MOM_surface_forcing_nuopc
use MOM_grid, only : ocean_grid_type
use MOM_interpolate, only : init_external_field, time_interp_external
use MOM_interpolate, only : time_interp_external_init
use MOM_interpolate, only : external_field
use MOM_CFC_cap, only : CFC_cap_fluxes
use MOM_io, only : slasher, write_version_number, MOM_read_data
use MOM_io, only : stdout
Expand Down Expand Up @@ -146,10 +147,14 @@ module MOM_surface_forcing_nuopc
character(len=30) :: cfc11_var_name !< name of cfc11 in CFC_BC_file
character(len=30) :: cfc12_var_name !< name of cfc11 in CFC_BC_file
real, pointer, dimension(:,:) :: trestore_mask => NULL() !< mask for SST restoring
integer :: id_srestore = -1 !< id number for time_interp_external.
integer :: id_trestore = -1 !< id number for time_interp_external.
integer :: id_cfc11_atm = -1 !< id number for time_interp_external.
integer :: id_cfc12_atm = -1 !< id number for time_interp_external.
type(external_field) :: srestore_handle
!< Handle for time-interpolated salt restoration field
type(external_field) :: trestore_handle
!< Handle for time-interpolated temperature restoration field
type(external_field) :: cfc11_atm_handle
!< Handle for time-interpolated CFC11 restoration field
type(external_field) :: cfc12_atm_handle
!< Handle for time-interpolated CFC12 restoration field

! Diagnostics handles
type(forcing_diags), public :: handles
Expand Down Expand Up @@ -377,7 +382,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! Salinity restoring logic
if (restore_salinity) then
call time_interp_external(CS%id_srestore, Time, data_restore, scale=US%ppt_to_S)
call time_interp_external(CS%srestore_handle, Time, data_restore, scale=US%ppt_to_S)
! open_ocn_mask indicates where to restore salinity (1 means restore, 0 does not)
open_ocn_mask(:,:) = 1.0
if (CS%mask_srestore_under_ice) then ! Do not restore under sea-ice
Expand Down Expand Up @@ -434,7 +439,7 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! SST restoring logic
if (restore_sst) then
call time_interp_external(CS%id_trestore, Time, data_restore, scale=US%degC_to_C)
call time_interp_external(CS%trestore_handle, Time, data_restore, scale=US%degC_to_C)
do j=js,je ; do i=is,ie
delta_sst = data_restore(i,j) - sfc_state%SST(i,j)
delta_sst = sign(1.0,delta_sst)*min(abs(delta_sst),CS%max_delta_trestore)
Expand Down Expand Up @@ -596,7 +601,8 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,

! CFCs
if (CS%use_CFC) then
call CFC_cap_fluxes(fluxes, sfc_state, G, US, CS%Rho0, Time, CS%id_cfc11_atm, CS%id_cfc11_atm)
call CFC_cap_fluxes(fluxes, sfc_state, G, US, CS%Rho0, Time, &
CS%cfc11_atm_handle, CS%cfc11_atm_handle)
endif

if (associated(IOB%salt_flux)) then
Expand Down Expand Up @@ -1394,7 +1400,7 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, restore_salt,

if (present(restore_salt)) then ; if (restore_salt) then
salt_file = trim(CS%inputdir) // trim(CS%salt_restore_file)
CS%id_srestore = init_external_field(salt_file, CS%salt_restore_var_name, domain=G%Domain%mpp_domain)
CS%srestore_handle = init_external_field(salt_file, CS%salt_restore_var_name, domain=G%Domain%mpp_domain)
call safe_alloc_ptr(CS%srestore_mask,isd,ied,jsd,jed); CS%srestore_mask(:,:) = 1.0
if (CS%mask_srestore) then ! read a 2-d file containing a mask for restoring fluxes
flnam = trim(CS%inputdir) // 'salt_restore_mask.nc'
Expand All @@ -1404,7 +1410,7 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, restore_salt,

if (present(restore_temp)) then ; if (restore_temp) then
temp_file = trim(CS%inputdir) // trim(CS%temp_restore_file)
CS%id_trestore = init_external_field(temp_file, CS%temp_restore_var_name, domain=G%Domain%mpp_domain)
CS%trestore_handle = init_external_field(temp_file, CS%temp_restore_var_name, domain=G%Domain%mpp_domain)
call safe_alloc_ptr(CS%trestore_mask,isd,ied,jsd,jed); CS%trestore_mask(:,:) = 1.0
if (CS%mask_trestore) then ! read a 2-d file containing a mask for restoring fluxes
flnam = trim(CS%inputdir) // 'temp_restore_mask.nc'
Expand All @@ -1430,8 +1436,8 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, restore_salt,
"The name of the variable representing CFC-12 in "//&
"CFC_BC_FILE.", default="CFC_12", do_not_log=.true.)

CS%id_cfc11_atm = init_external_field(CS%CFC_BC_file, CS%cfc11_var_name, domain=G%Domain%mpp_domain)
CS%id_cfc12_atm = init_external_field(CS%CFC_BC_file, CS%cfc12_var_name, domain=G%Domain%mpp_domain)
CS%cfc11_atm_handle = init_external_field(CS%CFC_BC_file, CS%cfc11_var_name, domain=G%Domain%mpp_domain)
CS%cfc12_atm_handle = init_external_field(CS%CFC_BC_file, CS%cfc12_var_name, domain=G%Domain%mpp_domain)
endif
endif

Expand Down
Loading

0 comments on commit a9f7e2a

Please sign in to comment.