Skip to content

Commit

Permalink
Merge branch 'mom-ocean:main' into dev/gfdl
Browse files Browse the repository at this point in the history
  • Loading branch information
hdrake authored Mar 24, 2023
2 parents c5e79f7 + b57ff02 commit a33588f
Show file tree
Hide file tree
Showing 72 changed files with 5,784 additions and 1,814 deletions.
1 change: 1 addition & 0 deletions .github/actions/macos-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ runs:
brew update
brew install automake
brew install netcdf
brew install netcdf-fortran
brew install mpich
echo "::endgroup::"
4 changes: 2 additions & 2 deletions .github/actions/ubuntu-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
sudo apt-get install netcdf-bin
sudo apt-get install libnetcdf-dev
sudo apt-get install libnetcdff-dev
sudo apt-get install mpich
sudo apt-get install libmpich-dev
sudo apt-get install openmpi-bin
sudo apt-get install libopenmpi-dev
sudo apt-get install linux-tools-common
echo "::endgroup::"
21 changes: 17 additions & 4 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,25 @@ endif
SOURCE = \
$(foreach ext,F90 inc c h,$(wildcard $(1)/*/*.$(ext) $(1)/*/*/*.$(ext)))

MOM_SOURCE = $(call SOURCE,../src) \
$(wildcard ../config_src/infra/FMS1/*.F90) \
MOM_SOURCE = \
$(call SOURCE,../src) \
$(wildcard ../config_src/drivers/solo_driver/*.F90) \
$(wildcard ../config_src/ext*/*/*.F90)
TARGET_SOURCE = $(call SOURCE,build/target_codebase/src) \
$(wildcard build/target_codebase/config_src/infra/FMS1/*.F90) \

TARGET_SOURCE = \
$(call SOURCE,build/target_codebase/src) \
$(wildcard build/target_codebase/config_src/drivers/solo_driver/*.F90) \
$(wildcard build/target_codebase/config_src/ext*/*.F90)

# NOTE: Current default framework is FMS1, but this could change.
ifeq ($(FRAMEWORK), fms2)
MOM_SOURCE +=$(wildcard ../config_src/infra/FMS2/*.F90)
TARGET_SOURCE += $(wildcard build/target_codebase/config_src/infra/FMS2/*.F90)
else
MOM_SOURCE += $(wildcard ../config_src/infra/FMS1/*.F90)
TARGET_SOURCE += $(wildcard build/target_codebase/config_src/infra/FMS1/*.F90)
endif

FMS_SOURCE = $(call SOURCE,deps/fms/src)


Expand Down Expand Up @@ -602,6 +613,7 @@ report.cov: run.cov codecov
2> build/cov/codecov.err \
&& echo -e "${MAGENTA}Report uploaded to codecov.${RESET}" \
|| { \
cat build/cov/codecov.err ; \
echo -e "${RED}Failed to upload report.${RESET}" ; \
if [ "$(REQUIRE_COVERAGE_UPLOAD)" = true ] ; then false ; fi ; \
}
Expand Down Expand Up @@ -740,6 +752,7 @@ report.cov.unit: build/unit/MOM_file_parser_tests.F90.gcov codecov
2> build/unit/codecov.err \
&& echo -e "${MAGENTA}Report uploaded to codecov.${RESET}" \
|| { \
cat build/unit/codecov.err ; \
echo -e "${RED}Failed to upload report.${RESET}" ; \
if [ "$(REQUIRE_COVERAGE_UPLOAD)" = true ] ; then false ; fi ; \
}
Expand Down
31 changes: 19 additions & 12 deletions ac/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,28 @@ AC_SUBST([SRC_DIRS],
AC_CONFIG_COMMANDS(Makefile.dep, [make depend])


# setjmp verification
# POSIX verification tests
AC_LANG_PUSH([C])

# Verify that either sigsetjmp (POSIX) or __sigsetjmp (glibc) are available.
AC_CHECK_FUNC([sigsetjmp])
AS_IF([test "$ac_cv_func_sigsetjmp" == "yes"], [
SIGSETJMP_NAME="sigsetjmp"
], [
AC_CHECK_FUNC([__sigsetjmp], [
SIGSETJMP_NAME="__sigsetjmp"
], [
AC_MSG_ERROR([Could not find a symbol for sigsetjmp.])
# These symbols may be defined as macros, making them inaccessible by Fortran.
# The following exist in BSD and Linux, so we just test for them.
AC_CHECK_FUNC([setjmp], [], [AC_MSG_ERROR([Could not find setjmp.])])
AC_CHECK_FUNC([longjmp], [], [AC_MSG_ERROR([Could not find longjmp.])])
AC_CHECK_FUNC([siglongjmp], [], [AC_MSG_ERROR([Could not find siglongjmp.])])

# Determine the sigsetjmp symbol. If missing, then point to sigsetjmp_missing.
#
# Supported symbols:
# sigsetjmp POSIX, BSD libc (MacOS)
# __sigsetjmp glibc (Linux)
SIGSETJMP="sigsetjmp_missing"
for sigsetjmp_fn in sigsetjmp __sigsetjmp; do
AC_CHECK_FUNC([${sigsetjmp_fn}], [
SIGSETJMP=${sigsetjmp_fn}
break
])
])
AC_DEFINE_UNQUOTED([SIGSETJMP_NAME], ["$SIGSETJMP_NAME"])
done
AC_DEFINE_UNQUOTED([SIGSETJMP_NAME], ["${SIGSETJMP}"])

# Determine the size of jmp_buf and sigjmp_buf
AC_CHECK_SIZEOF([jmp_buf], [], [#include <setjmp.h>])
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
88 changes: 9 additions & 79 deletions config_src/drivers/nuopc_cap/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ module MOM_cap_mod
use NUOPC_Model, only: model_label_Finalize => label_Finalize
use NUOPC_Model, only: SetVM

!$use omp_lib , only : omp_set_num_threads

implicit none; private

public SetServices
Expand Down Expand Up @@ -149,7 +147,6 @@ module MOM_cap_mod
integer :: scalar_field_count = 0
integer :: scalar_field_idx_grid_nx = 0
integer :: scalar_field_idx_grid_ny = 0
integer :: nthrds !< number of openmp threads per task
character(len=*),parameter :: u_FILE_u = &
__FILE__

Expand Down Expand Up @@ -465,30 +462,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
CALL ESMF_TimeIntervalGet(TINT, S=DT_OCEAN, RC=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!---------------------------------
! openmp threads
!---------------------------------

call ESMF_VMGet(vm, pet=localPet, peCount=localPeCount, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (localPeCount == 1) then
call NUOPC_CompAttributeGet(gcomp, name="nthreads", value=cvalue, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) nthrds
else
nthrds = localPeCount
endif
else
nthrds = localPeCount
endif
write(logmsg,*) nthrds
call ESMF_LogWrite(trim(subname)//': nthreads = '//trim(logmsg), ESMF_LOGMSG_INFO)

!$ call omp_set_num_threads(nthrds)

call fms_init(mpi_comm_mom)
call constants_init
call field_manager_init
Expand Down Expand Up @@ -781,23 +754,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
if (wave_method == "EFACTOR") then
call fld_list_add(fldsToOcn_num, fldsToOcn, "Sw_lamult" , "will provide")
else if (wave_method == "SURFACE_BANDS") then
if (cesm_coupled) then
call fld_list_add(fldsToOcn_num, fldsToOcn, "Sw_pstokes_x", "will provide", &
ungridded_lbound=1, ungridded_ubound=Ice_ocean_boundary%num_stk_bands)
call fld_list_add(fldsToOcn_num, fldsToOcn, "Sw_pstokes_y", "will provide", &
ungridded_lbound=1, ungridded_ubound=Ice_ocean_boundary%num_stk_bands)
else ! below is the old approach of importing partitioned stokes drift components. after the planned ww3 nuopc
! cap unification, this else block should be removed in favor of the more flexible import approach above.
if (Ice_ocean_boundary%num_stk_bands > 3) then
call MOM_error(FATAL, "Number of Stokes Bands > 3, NUOPC cap not set up for this")
endif
call fld_list_add(fldsToOcn_num, fldsToOcn, "eastward_partitioned_stokes_drift_1" , "will provide")
call fld_list_add(fldsToOcn_num, fldsToOcn, "northward_partitioned_stokes_drift_1", "will provide")
call fld_list_add(fldsToOcn_num, fldsToOcn, "eastward_partitioned_stokes_drift_2" , "will provide")
call fld_list_add(fldsToOcn_num, fldsToOcn, "northward_partitioned_stokes_drift_2", "will provide")
call fld_list_add(fldsToOcn_num, fldsToOcn, "eastward_partitioned_stokes_drift_3" , "will provide")
call fld_list_add(fldsToOcn_num, fldsToOcn, "northward_partitioned_stokes_drift_3", "will provide")
endif
call fld_list_add(fldsToOcn_num, fldsToOcn, "Sw_pstokes_x", "will provide", &
ungridded_lbound=1, ungridded_ubound=Ice_ocean_boundary%num_stk_bands)
call fld_list_add(fldsToOcn_num, fldsToOcn, "Sw_pstokes_y", "will provide", &
ungridded_lbound=1, ungridded_ubound=Ice_ocean_boundary%num_stk_bands)
else
call MOM_error(FATAL, "Unsupported WAVE_METHOD encountered in NUOPC cap.")
endif
Expand Down Expand Up @@ -936,28 +896,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
call ESMF_VMGet(vm, petCount=npet, mpiCommunicator=mpicom, localPet=localPet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!---------------------------------
! openmp threads
!---------------------------------

call ESMF_VMGet(vm, pet=localPet, peCount=localPeCount, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (localPeCount == 1) then
call NUOPC_CompAttributeGet(gcomp, name="nthreads", value=cvalue, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) then
read(cvalue,*) nthrds
else
nthrds = localPeCount
endif
else
nthrds = localPeCount
endif

!$ call omp_set_num_threads(nthrds)

!---------------------------------
! global mom grid size
!---------------------------------
Expand Down Expand Up @@ -1570,8 +1508,6 @@ subroutine ModelAdvance(gcomp, rc)

call shr_file_setLogUnit (logunit)

!$ call omp_set_num_threads(nthrds)

! query the Component for its clock, importState and exportState
call ESMF_GridCompGet(gcomp, clock=clock, importState=importState, &
exportState=exportState, rc=rc)
Expand Down Expand Up @@ -1763,16 +1699,10 @@ subroutine ModelAdvance(gcomp, rc)
close(writeunit)
endif
else ! not cesm_coupled
! write the final restart without a timestamp
if (ESMF_AlarmIsRinging(stop_alarm, rc=rc)) then
write(restartname,'(A)')"MOM.res"
write(stoch_restartname,'(A)')"ocn_stoch.res.nc"
else
write(restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2)') &
"MOM.res.", year, month, day, hour, minute, seconds
write(stoch_restartname,'(A,I4.4,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,"-",I2.2,A)') &
"ocn_stoch.res.", year, month, day, hour, minute, seconds,".nc"
endif
write(restartname,'(i4.4,2(i2.2),A,3(i2.2),A)') year, month, day,".", hour, minute, seconds, &
".MOM.res"
write(stoch_restartname,'(i4.4,2(i2.2),A,3(i2.2),A)') year, month, day,".", hour, minute, seconds, &
".ocn_stoch.res.nc"
call ESMF_LogWrite("MOM_cap: Writing restart : "//trim(restartname), ESMF_LOGMSG_INFO)

! write restart file(s)
Expand Down Expand Up @@ -1932,7 +1862,7 @@ subroutine ModelSetRunClock(gcomp, rc)
line=__LINE__, file=__FILE__, rcToReturn=rc)
return
endif
! not used in nems
! not used in ufs
call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
Expand Down
52 changes: 1 addition & 51 deletions config_src/drivers/nuopc_cap/mom_cap_methods.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!> Contains import/export methods for both NEMS and CMEPS.
!> Contains import/export methods for CMEPS.
module MOM_cap_methods

use ESMF, only: ESMF_Clock, ESMF_ClockGet, ESMF_time, ESMF_TimeGet
Expand Down Expand Up @@ -87,8 +87,6 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
character(len=128) :: fldname
real(ESMF_KIND_R8), allocatable :: taux(:,:)
real(ESMF_KIND_R8), allocatable :: tauy(:,:)
real(ESMF_KIND_R8), allocatable :: stkx1(:,:),stkx2(:,:),stkx3(:,:)
real(ESMF_KIND_R8), allocatable :: stky1(:,:),stky2(:,:),stky3(:,:)
real(ESMF_KIND_R8), allocatable :: stkx(:,:,:)
real(ESMF_KIND_R8), allocatable :: stky(:,:,:)
character(len=*) , parameter :: subname = '(mom_import)'
Expand Down Expand Up @@ -329,8 +327,6 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
! Partitioned Stokes Drift Components
!----
if ( associated(ice_ocean_boundary%ustkb) ) then

if (cesm_coupled) then
nsc = Ice_ocean_boundary%num_stk_bands
allocate(stkx(isc:iec,jsc:jec,1:nsc))
allocate(stky(isc:iec,jsc:jec,1:nsc))
Expand Down Expand Up @@ -358,52 +354,6 @@ subroutine mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary,
enddo
enddo
deallocate(stkx,stky)

else ! below is the old approach of importing partitioned stokes drift components. after the planned ww3 nuopc
! cap unification, this else block should be removed in favor of the more flexible import approach above.
allocate(stkx1(isc:iec,jsc:jec))
allocate(stky1(isc:iec,jsc:jec))
allocate(stkx2(isc:iec,jsc:jec))
allocate(stky2(isc:iec,jsc:jec))
allocate(stkx3(isc:iec,jsc:jec))
allocate(stky3(isc:iec,jsc:jec))

call state_getimport(importState,'eastward_partitioned_stokes_drift_1' , isc, iec, jsc, jec, stkx1,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState,'northward_partitioned_stokes_drift_1', isc, iec, jsc, jec, stky1,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState,'eastward_partitioned_stokes_drift_2' , isc, iec, jsc, jec, stkx2,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState,'northward_partitioned_stokes_drift_2', isc, iec, jsc, jec, stky2,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState,'eastward_partitioned_stokes_drift_3' , isc, iec, jsc, jec, stkx3,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call state_getimport(importState,'northward_partitioned_stokes_drift_3', isc, iec, jsc, jec, stky3,rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! rotate from true zonal/meridional to local coordinates
do j = jsc, jec
jg = j + ocean_grid%jsc - jsc
do i = isc, iec
ig = i + ocean_grid%isc - isc
ice_ocean_boundary%ustkb(i,j,1) = ocean_grid%cos_rot(ig,jg)*stkx1(i,j) &
- ocean_grid%sin_rot(ig,jg)*stky1(i,j)
ice_ocean_boundary%vstkb(i,j,1) = ocean_grid%cos_rot(ig,jg)*stky1(i,j) &
+ ocean_grid%sin_rot(ig,jg)*stkx1(i,j)

ice_ocean_boundary%ustkb(i,j,2) = ocean_grid%cos_rot(ig,jg)*stkx2(i,j) &
- ocean_grid%sin_rot(ig,jg)*stky2(i,j)
ice_ocean_boundary%vstkb(i,j,2) = ocean_grid%cos_rot(ig,jg)*stky2(i,j) &
+ ocean_grid%sin_rot(ig,jg)*stkx2(i,j)

ice_ocean_boundary%ustkb(i,j,3) = ocean_grid%cos_rot(ig,jg)*stkx3(i,j) &
- ocean_grid%sin_rot(ig,jg)*stky3(i,j)
ice_ocean_boundary%vstkb(i,j,3) = ocean_grid%cos_rot(ig,jg)*stky3(i,j) &
+ ocean_grid%sin_rot(ig,jg)*stkx3(i,j)
enddo
enddo
deallocate(stkx1,stkx2,stkx3,stky1,stky2,stky3)
endif
endif

end subroutine mom_import
Expand Down
1 change: 0 additions & 1 deletion config_src/drivers/nuopc_cap/mom_surface_forcing_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,6 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS)
endif
forces%accumulate_p_surf = .true. ! Multiple components may contribute to surface pressure.

! TODO: this does not seem correct for NEMS
#ifdef CESMCOUPLED
wind_stagger = AGRID
#else
Expand Down
Loading

0 comments on commit a33588f

Please sign in to comment.