Skip to content

Commit

Permalink
Merge pull request #186 from gustavo-marques/main-candidate-ncar-2021…
Browse files Browse the repository at this point in the history
…-04-21

Merging the main candidate from GFDL 2021-03-26
  • Loading branch information
alperaltuntas authored Apr 22, 2021
2 parents c4c8747 + 3b121cf commit d3f4f0f
Show file tree
Hide file tree
Showing 25 changed files with 853 additions and 429 deletions.
9 changes: 6 additions & 3 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ FCFLAGS_COVERAGE ?=
# - FMS cannot be built with the same aggressive initialization flags as MOM6,
# so FCFLAGS_INIT is used to provide additional MOM6 configuration.

# User-defined LDFLAGS (applied to all builds and FMS)
LDFLAGS_USER ?=

# Set to `true` to require identical results from DEBUG and REPRO builds
# NOTE: Many compilers (Intel, GCC on ARM64) do not yet produce identical
# results across DEBUG and REPRO builds (as defined below), so we disable on
Expand Down Expand Up @@ -217,8 +220,8 @@ REPRO_FCFLAGS := FCFLAGS="$(FCFLAGS_REPRO) $(FCFLAGS_FMS)"
OPENMP_FCFLAGS := FCFLAGS="$(FCFLAGS_DEBUG) $(FCFLAGS_INIT) $(FCFLAGS_FMS)"
TARGET_FCFLAGS := FCFLAGS="$(FCFLAGS_DEBUG) $(FCFLAGS_INIT) $(FCFLAGS_FMS)"

MOM_LDFLAGS := LDFLAGS="$(LDFLAGS_FMS)"
SYMMETRIC_LDFLAGS := LDFLAGS="$(COVERAGE) $(LDFLAGS_FMS)"
MOM_LDFLAGS := LDFLAGS="$(LDFLAGS_FMS) $(LDFLAGS_USER)"
SYMMETRIC_LDFLAGS := LDFLAGS="$(COVERAGE) $(LDFLAGS_FMS) $(LDFLAGS_USER)"


# Environment variable configuration
Expand Down Expand Up @@ -286,7 +289,7 @@ $(TARGET_CODEBASE)/ac/configure: $(TARGET_CODEBASE)

$(TARGET_CODEBASE):
git clone --recursive $(MOM_TARGET_URL) $@
cd $@ && git checkout $(MOM_TARGET_BRANCH)
cd $@ && git checkout --recurse-submodules $(MOM_TARGET_BRANCH)


#---
Expand Down
3 changes: 2 additions & 1 deletion config_src/drivers/ice_solo_driver/ice_shelf_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ program Shelf_main
endif
endif

call Get_MOM_Input(param_file, dirs)

! Read ocean_solo restart, which can override settings from the namelist.
if (file_exists(trim(dirs%restart_input_dir)//'ice_solo.res')) then
call open_ASCII_file(unit, trim(dirs%restart_input_dir)//'ice_solo.res', action=READONLY_FILE)
Expand Down Expand Up @@ -215,7 +217,6 @@ program Shelf_main
Start_time = real_to_time(0.0)
endif

call Get_MOM_Input(param_file, dirs)
! Determining the internal unit scaling factors for this run.
call unit_scaling_init(param_file, US)

Expand Down
4 changes: 2 additions & 2 deletions config_src/drivers/mct_cap/mom_surface_forcing_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ subroutine convert_IOB_to_fluxes(IOB, fluxes, index_bounds, Time, valid_time, G,
if (associated(fluxes%frunoff)) then
fluxes%latent(i,j) = fluxes%latent(i,j) - &
IOB%rofi_flux(i-i0,j-j0)*US%W_m2_to_QRZ_T*CS%latent_heat_fusion
fluxes%latent_frunoff_diag(i,j) = - G%mask2dT(i,j) * &
IOB%rofi_flux(i-i0,j-j0)*US%W_m2_to_QRZ_T*CS%latent_heat_fusion
fluxes%latent_frunoff_diag(i,j) = -G%mask2dT(i,j) &
* IOB%rofi_flux(i-i0,j-j0)*US%W_m2_to_QRZ_T*CS%latent_heat_fusion
endif
! contribution from evaporation
if (associated(IOB%q_flux)) then
Expand Down
55 changes: 31 additions & 24 deletions config_src/drivers/nuopc_cap/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module MOM_cap_mod
use ESMF, only: ESMF_Grid, ESMF_GridCreate, ESMF_GridAddCoord
use ESMF, only: ESMF_GridGetCoord, ESMF_GridAddItem, ESMF_GridGetItem
use ESMF, only: ESMF_GridComp, ESMF_GridCompSetEntryPoint, ESMF_GridCompGet
use ESMF, only: ESMF_LogFoundError, ESMF_LogWrite, ESMF_LogSetError
use ESMF, only: ESMF_LogWrite, ESMF_LogSetError
use ESMF, only: ESMF_LOGERR_PASSTHRU, ESMF_KIND_R8, ESMF_RC_VAL_WRONG
use ESMF, only: ESMF_GEOMTYPE_MESH, ESMF_GEOMTYPE_GRID, ESMF_SUCCESS
use ESMF, only: ESMF_METHOD_INITIALIZE, ESMF_MethodRemove, ESMF_State
Expand All @@ -79,6 +79,7 @@ module MOM_cap_mod
use ESMF, only: ESMF_AlarmCreate, ESMF_ClockGetAlarmList, ESMF_AlarmList_Flag
use ESMF, only: ESMF_AlarmGet, ESMF_AlarmIsCreated, ESMF_ALARMLIST_ALL, ESMF_AlarmIsEnabled
use ESMF, only: ESMF_STATEITEM_NOTFOUND, ESMF_FieldWrite
use ESMF, only: ESMF_END_ABORT, ESMF_Finalize
use ESMF, only: operator(==), operator(/=), operator(+), operator(-)

! TODO ESMF_GridCompGetInternalState does not have an explicit Fortran interface.
Expand Down Expand Up @@ -140,6 +141,7 @@ module MOM_cap_mod
logical :: profile_memory = .true.
logical :: grid_attach_area = .false.
logical :: use_coldstart = .true.
logical :: use_mommesh = .true.
character(len=128) :: scalar_field_name = ''
integer :: scalar_field_count = 0
integer :: scalar_field_idx_grid_nx = 0
Expand All @@ -153,7 +155,7 @@ module MOM_cap_mod
type(ESMF_GeomType_Flag) :: geomtype = ESMF_GEOMTYPE_MESH
#else
logical :: cesm_coupled = .false.
type(ESMF_GeomType_Flag) :: geomtype = ESMF_GEOMTYPE_GRID
type(ESMF_GeomType_Flag) :: geomtype
#endif
character(len=8) :: restart_mode = 'alarms'

Expand Down Expand Up @@ -353,6 +355,25 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc)
write(logmsg,*) use_coldstart
call ESMF_LogWrite('MOM_cap:use_coldstart = '//trim(logmsg), ESMF_LOGMSG_INFO)

use_mommesh = .true.
call NUOPC_CompAttributeGet(gcomp, name="use_mommesh", value=value, &
isPresent=isPresent, isSet=isSet, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
if (isPresent .and. isSet) use_mommesh=(trim(value)=="true")
write(logmsg,*) use_mommesh
call ESMF_LogWrite('MOM_cap:use_mommesh = '//trim(logmsg), ESMF_LOGMSG_INFO)

if(use_mommesh)then
geomtype = ESMF_GEOMTYPE_MESH
call NUOPC_CompAttributeGet(gcomp, name='mesh_ocn', isPresent=isPresent, isSet=isSet, rc=rc)
if (.not. isPresent .and. .not. isSet) then
call ESMF_LogWrite('geomtype set to mesh but mesh_ocn is not specified', ESMF_LOGMSG_INFO)
call ESMF_Finalize(endflag=ESMF_END_ABORT)
endif
else
geomtype = ESMF_GEOMTYPE_GRID
endif

end subroutine

!> Called by NUOPC to advertise import and export fields. "Advertise"
Expand Down Expand Up @@ -443,18 +464,11 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc)
!---------------------------------

call ESMF_VMGet(vm, pet=localPet, peCount=localPeCount, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out

if (ChkErr(rc,__LINE__,u_FILE_u)) return

if(localPeCount == 1) then
call NUOPC_CompAttributeGet(gcomp, "nthreads", value=cvalue, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) nthrds
else
nthrds = localPeCount
Expand Down Expand Up @@ -879,18 +893,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
!---------------------------------

call ESMF_VMGet(vm, pet=localPet, peCount=localPeCount, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out

if (ChkErr(rc,__LINE__,u_FILE_u)) return

if(localPeCount == 1) then
call NUOPC_CompAttributeGet(gcomp, "nthreads", value=cvalue, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue,*) nthrds
else
nthrds = localPeCount
Expand Down Expand Up @@ -1054,7 +1061,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)

! Determine mesh areas for regridding
call ESMF_MeshGet(Emesh, numOwnedElements=numOwnedElements, spatialDim=spatialDim, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (ChkErr(rc,__LINE__,u_FILE_u)) return

allocate (mod2med_areacor(numOwnedElements))
allocate (med2mod_areacor(numOwnedElements))
Expand All @@ -1064,11 +1071,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc)
#ifdef CESMCOUPLED
! Determine model areas and flux correction factors (module variables in mom_)
call ESMF_StateGet(exportState, itemName=trim(fldsFrOcn(2)%stdname), field=lfield, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldRegridGetArea(lfield, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(lfield, farrayPtr=dataPtr_mesh_areas, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
if (ChkErr(rc,__LINE__,u_FILE_u)) return

allocate(mesh_areas(numOwnedElements))
allocate(model_areas(numOwnedElements))
Expand Down
4 changes: 2 additions & 2 deletions config_src/drivers/nuopc_cap/mom_surface_forcing_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS)
endif
forces%ustar(i,j) = sqrt(gustiness*Irho0 + Irho0*tau_mag)
enddo ; enddo

call pass_vector(forces%taux, forces%tauy, G%Domain, halo=1)
elseif (wind_stagger == AGRID) then
call pass_vector(taux_at_h, tauy_at_h, G%Domain, To_All+Omit_Corners, stagger=AGRID, halo=1)

Expand All @@ -822,7 +822,7 @@ subroutine convert_IOB_to_forces(IOB, forces, index_bounds, Time, G, US, CS)
forces%ustar(i,j) = sqrt(gustiness*Irho0 + Irho0 * G%mask2dT(i,j) * &
sqrt(taux_at_h(i,j)**2 + tauy_at_h(i,j)**2))
enddo ; enddo

call pass_vector(forces%taux, forces%tauy, G%Domain, halo=1)
else ! C-grid wind stresses.
if (G%symmetric) &
call fill_symmetric_edges(forces%taux, forces%tauy, G%Domain)
Expand Down
4 changes: 4 additions & 0 deletions config_src/drivers/solo_driver/MOM_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ program MOM_main
! This call sets the number and affinity of threads with openMP.
!$ call set_MOM_thread_affinity(ocean_nthreads, use_hyper_thread)

! This call is required to initiate dirs%restart_input_dir for ocean_solo.res
! The contents of dirs will be reread in initialize_MOM.
call get_MOM_input(dirs=dirs)

! Read ocean_solo restart, which can override settings from the namelist.
if (file_exists(trim(dirs%restart_input_dir)//'ocean_solo.res')) then
call open_ASCII_file(unit, trim(dirs%restart_input_dir)//'ocean_solo.res', action=READONLY_FILE)
Expand Down
4 changes: 2 additions & 2 deletions config_src/infra/FMS1/MOM_diag_manager_infra.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ module MOM_diag_manager_infra
use diag_manager_mod, only : register_diag_field_fms => register_diag_field
use diag_manager_mod, only : register_static_field_fms => register_static_field
use diag_manager_mod, only : get_diag_field_id_fms => get_diag_field_id
use time_manager_mod, only : time_type
use MOM_time_manager, only : time_type
use MOM_domain_infra, only : MOM_domain_type
use MOM_error_handler, only : MOM_error, FATAL, WARNING
use MOM_error_infra, only : MOM_error => MOM_err, FATAL, WARNING

implicit none ; private

Expand Down
4 changes: 3 additions & 1 deletion config_src/infra/FMS1/MOM_domain_infra.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module MOM_domain_infra
! This file is part of MOM6. See LICENSE.md for the license.

use MOM_coms_infra, only : PE_here, root_PE, num_PEs
use MOM_cpu_clock, only : cpu_clock_begin, cpu_clock_end
use MOM_cpu_clock_infra, only : cpu_clock_begin, cpu_clock_end
use MOM_error_infra, only : MOM_error=>MOM_err, NOTE, WARNING, FATAL

use mpp_domains_mod, only : domain2D, domain1D
Expand Down Expand Up @@ -1689,6 +1689,8 @@ subroutine clone_MD_to_d2D(MD_in, mpp_domain, min_halo, halo_size, symmetric, &
if ((MD_in%io_layout(1) + MD_in%io_layout(2) > 0) .and. &
(MD_in%layout(1)*MD_in%layout(2) > 1)) then
call mpp_define_io_domain(mpp_domain, MD_in%io_layout)
else
call mpp_define_io_domain(mpp_domain, (/ 1, 1 /) )
endif

end subroutine clone_MD_to_d2D
Expand Down
Loading

0 comments on commit d3f4f0f

Please sign in to comment.