Skip to content

Commit

Permalink
Matt's changes to drivers
Browse files Browse the repository at this point in the history
Merge branch 'revert_drivers' of https://github.com/MJHarrison-GFDL/MOM6 into matts-revert-drivers
  • Loading branch information
OlgaSergienko committed Dec 23, 2020
2 parents 39dd3e3 + aa26c60 commit d27bcbd
Show file tree
Hide file tree
Showing 38 changed files with 1,542 additions and 1,550 deletions.
14 changes: 1 addition & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,7 @@
html


# Build output
*.o
*.mod
MOM6
build/
_build/
deps/
MOM6.tags
bib*.aux
citelist.doc*


# Autoconf
# Autoconf output
aclocal.m4
autom4te.cache/
config.log
Expand Down
69 changes: 50 additions & 19 deletions ac/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,56 @@ AX_FC_CHECK_MODULE([mpi],

# netCDF configuration

# NOTE: `nf-config --flibs` combines library paths (-L) and libraries (-l),
# even though these ought to be separated in the invocation of `ld`.
#
# We use `sed` to strip the -l and pass the -L to LDFLAGS, and rely on autoconf
# to configure the -l flags.
AC_PROG_SED

AC_PATH_PROG([NF_CONFIG], [nf-config])
AS_IF([test -n "$NF_CONFIG"],
[CPPFLAGS="$CPPFLAGS $($NF_CONFIG --fflags)"
FCFLAGS="$FCFLAGS $($NF_CONFIG --fflags)"
LDFLAGS="$LDFLAGS $($NF_CONFIG --flibs | $SED -e 's/-l[[^ ]]*//g')"],
[AC_MSG_ERROR([Could not find nf-config.])])

AX_FC_CHECK_MODULE([netcdf],
[], [AC_MSG_ERROR([Could not find netcdf module.])])
AX_FC_CHECK_LIB([netcdff], [nf_create], [netcdf],
[], [AC_MSG_ERROR([Could not link netcdff library.])]
)
# Search for the Fortran netCDF module, fallback to nf-config.
AX_FC_CHECK_MODULE([netcdf], [], [
AS_UNSET([ax_fc_cv_mod_netcdf])
AC_PATH_PROG([NF_CONFIG], [nf-config])
AS_IF([test -n "$NF_CONFIG"], [
AC_SUBST([FCFLAGS], ["$FCFLAGS -I$($NF_CONFIG --includedir)"])
], [AC_MSG_ERROR([Could not find nf-config.])]
)
AX_FC_CHECK_MODULE([netcdf], [], [
AC_MSG_ERROR([Could not find netcdf module.])
])
])

# FMS may invoke netCDF C calls, so we link to libnetcdf.
AC_LANG_PUSH([C])
AC_CHECK_LIB([netcdf], [nc_create], [], [
AS_UNSET([ac_cv_lib_netcdf_nc_create])
AC_PATH_PROG([NC_CONFIG], [nc-config])
AS_IF([test -n "$NC_CONFIG"], [
AC_SUBST([LDFLAGS],
["$LDFLAGS -L$($NC_CONFIG --libdir)"]
)
], [AC_MSG_ERROR([Could not find nc-config.])]
)
AC_CHECK_LIB([netcdf], [nc_create], [], [
AC_MSG_ERROR([Could not find libnetcdf.])
])
])
AC_LANG_POP([C])

# NOTE: We test for nf_create, rather than nf90_create, because AX_FC_CHECK_LIB
# is currently not yet able to properly probe inside modules.
# Testing of the nf90_* functions will require a macro update.
# NOTE: nf-config does not have a --libdir flag, so we use --prefix and assume
# that libraries are in the $prefix/lib directory.

# Link to Fortran netCDF library, netcdff
AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [
AS_UNSET([ax_fc_cv_lib_netcdff_nf_create])
AC_PATH_PROG([NF_CONFIG], [nf-config])
AS_IF([test -n "$NF_CONFIG"], [
AC_SUBST([LDFLAGS],
["$LDFLAGS -L$($NF_CONFIG --prefix)/lib"]
)
], [AC_MSG_ERROR([Could not find nf-config.])]
)
AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [
AC_MSG_ERROR([Could not find libnetcdff.])
])
])


# Force 8-byte reals
Expand Down
2 changes: 1 addition & 1 deletion ac/deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MKMF_COMMIT ?= master

# FMS framework
FMS_URL ?= https://github.com/NOAA-GFDL/FMS.git
FMS_COMMIT ?= 2019.01.03
FMS_COMMIT ?= 2020.04


# List of source files to link this Makefile's dependencies to model Makefiles
Expand Down
52 changes: 33 additions & 19 deletions ac/deps/configure.fms.ac
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ AC_PROG_CC
AX_MPI
CC=$MPICC


# FMS configuration

# Linux and macOS have a gettid system call, but it is not implemented in older
Expand Down Expand Up @@ -74,25 +75,38 @@ AC_DEFINE([use_libMPI])

# netCDF configuration

# NOTE: `nf-config --flibs` combines library paths (-L) and libraries (-l),
# even though these ought to be separated in the invocation of `ld`.
#
# We use `sed` to strip the -l and pass the -L to LDFLAGS, and rely on autoconf
# to configure the -l flags.
AC_PROG_SED

AC_PATH_PROG([NF_CONFIG], [nf-config])
AS_IF([test -n "$NF_CONFIG"],
[CPPFLAGS="$CPPFLAGS $($NF_CONFIG --fflags)"
FCFLAGS="$FCFLAGS $($NF_CONFIG --fflags)"
LDFLAGS="$LDFLAGS $($NF_CONFIG --flibs | $SED -e 's/-l[[^ ]]*//g')"],
[AC_MSG_ERROR([Could not find nf-config.])])

AX_FC_CHECK_MODULE([netcdf],
[], [AC_MSG_ERROR([Could not find netcdf module.])])
AX_FC_CHECK_LIB([netcdff], [nf_create], [netcdf],
[], [AC_MSG_ERROR([Could not link netcdff library.])]
)
# Check for netcdf.h header function declarations.
# If unavailable, then try to invoke nc-create.
AC_LANG_PUSH([C])
AC_CHECK_HEADERS([netcdf.h], [], [
AS_UNSET([ac_cv_header_netcdf_h])
AC_PATH_PROG([NC_CONFIG], [nc-config])
AS_IF([test -n "$NC_CONFIG"], [
AC_SUBST([CPPFLAGS], ["$CPPFLAGS -I$($NC_CONFIG --includedir)"])
],
[AC_MSG_ERROR([Could not find nc-config.])]
)
AC_CHECK_HEADERS([netcdf.h], [], [
AC_MSG_ERROR([Could not find netcdf.h])
])
])
AC_LANG_POP([C])

# Search for the Fortran netCDF module, fallback to nf-config.
AX_FC_CHECK_MODULE([netcdf], [], [
AS_UNSET([ax_fc_cv_mod_netcdf])
AC_PATH_PROG([NF_CONFIG], [nf-config])
AS_IF([test -n "$NF_CONFIG"], [
AC_SUBST([FCFLAGS], ["$FCFLAGS -I$($NF_CONFIG --includedir)"])
],
[AC_MSG_ERROR([Could not find nf-config.])]
)
AX_FC_CHECK_MODULE([netcdf], [], [
AC_MSG_ERROR([Could not find netcdf module.])
])
])

# FMS requires this macro to signal netCDF support.
AC_DEFINE([use_netCDF])


Expand Down
13 changes: 7 additions & 6 deletions ac/m4/ax_fc_check_lib.m4
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dnl library with different -L flags, or perhaps other ld configurations.
dnl
dnl Results are cached in the ax_fc_cv_lib_LIBRARY_FUNCTION variable.
dnl
AC_DEFUN([AX_FC_CHECK_LIB],[dnl
AC_DEFUN([AX_FC_CHECK_LIB],[
AS_VAR_PUSHDEF([ax_fc_Lib], [ax_fc_cv_lib_$1_$2])
m4_ifval([$6],
[ax_fc_lib_msg_LDFLAGS=" with $6"],
Expand All @@ -29,14 +29,15 @@ AC_DEFUN([AX_FC_CHECK_LIB],[dnl
LDFLAGS="$6 $LDFLAGS"
ax_fc_check_lib_save_LIBS=$LIBS
LIBS="-l$1 $7 $LIBS"
AS_IF([test -n $3],
AS_IF([test -n "$3"],
[ax_fc_use_mod="use $3"],
[ax_fc_use_mod=""])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([], [dnl
AC_LINK_IFELSE([dnl
dnl Begin 7-column code block
AC_LANG_PROGRAM([], [dnl
$ax_fc_use_mod
call $2]dnl
)
call $2])dnl
dnl End code block
],
[AS_VAR_SET([ax_fc_Lib], [yes])],
[AS_VAR_SET([ax_fc_Lib], [no])]
Expand Down
24 changes: 9 additions & 15 deletions config_src/coupled_driver/ocean_model_MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ module ocean_model_mod
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 : add_shelf_forces, ice_shelf_end, ice_shelf_save_restart
use MOM_IS_diag_mediator, only : diag_IS_ctrl => diag_ctrl, diag_mediator_IS_end=>diag_mediator_end
use coupler_types_mod, only : coupler_1d_bc_type, coupler_2d_bc_type
use coupler_types_mod, only : coupler_type_spawn, coupler_type_write_chksums
use coupler_types_mod, only : coupler_type_initialized, coupler_type_copy_data
Expand Down Expand Up @@ -182,13 +181,13 @@ module ocean_model_mod
!! processes before time stepping the dynamics.

type(directories) :: dirs !< A structure containing several relevant directory paths.
type(mech_forcing), pointer :: forces => NULL() !< A structure with the driving mechanical surface forces
type(forcing), pointer :: fluxes => NULL() !< A structure containing pointers to
type(mech_forcing) :: forces !< A structure with the driving mechanical surface forces
type(forcing) :: fluxes !< A structure containing pointers to
!! the thermodynamic ocean forcing fields.
type(forcing), pointer :: flux_tmp => NULL() !< A secondary structure containing pointers to the
type(forcing) :: flux_tmp !< A secondary structure containing pointers to the
!! ocean forcing fields for when multiple coupled
!! timesteps are taken per thermodynamic step.
type(surface), pointer :: sfc_state => NULL() !< A structure containing pointers to
type(surface) :: sfc_state !< A structure containing pointers to
!! the ocean surface state fields.
type(ocean_grid_type), pointer :: &
grid => NULL() !< A pointer to a grid structure containing metrics
Expand Down Expand Up @@ -217,9 +216,6 @@ module ocean_model_mod
!! that will be used for MOM restart files.
type(diag_ctrl), pointer :: &
diag => NULL() !< A pointer to the diagnostic regulatory structure
type(diag_IS_ctrl), pointer :: &
diag_IS => NULL() !< A pointer to the diagnostic regulatory structure
!! for the ice shelf module.
end type ocean_state_type

contains
Expand Down Expand Up @@ -273,9 +269,9 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, wind_stagger, gas
endif
allocate(OS)

allocate(OS%fluxes)
allocate(OS%forces)
allocate(OS%flux_tmp)
! allocate(OS%fluxes)
! allocate(OS%forces)
! allocate(OS%flux_tmp)

OS%is_ocean_pe = Ocean_sfc%is_ocean_pe
if (.not.OS%is_ocean_pe) return
Expand Down Expand Up @@ -365,7 +361,7 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, wind_stagger, gas
use_melt_pot=.false.
endif

allocate(OS%sfc_state)
!allocate(OS%sfc_state)
call allocate_surface_state(OS%sfc_state, OS%grid, use_temperature, do_integrals=.true., &
gas_fields_ocn=gas_fields_ocn, use_meltpot=use_melt_pot)

Expand All @@ -379,7 +375,7 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, wind_stagger, gas

if (OS%use_ice_shelf) then
call initialize_ice_shelf(param_file, OS%grid, OS%Time, OS%ice_shelf_CSp, &
OS%diag_IS, OS%forces, OS%fluxes)
OS%diag, OS%forces, OS%fluxes)
endif
if (OS%icebergs_alter_ocean) then
call marine_ice_init(OS%Time, OS%grid, param_file, OS%diag, OS%marine_ice_CSp)
Expand Down Expand Up @@ -728,8 +724,6 @@ subroutine ocean_model_end(Ocean_sfc, Ocean_state, Time)

call ocean_model_save_restart(Ocean_state, Time)
call diag_mediator_end(Time, Ocean_state%diag)
if (Ocean_state%use_ice_shelf) &
call diag_mediator_IS_end(Time, Ocean_state%diag_IS)
call MOM_end(Ocean_state%MOM_CSp)
if (Ocean_state%use_ice_shelf) call ice_shelf_end(Ocean_state%Ice_shelf_CSp)
end subroutine ocean_model_end
Expand Down
32 changes: 13 additions & 19 deletions config_src/mct_driver/mom_ocean_model_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module MOM_ocean_model_mct
use coupler_types_mod, only : coupler_type_set_diags, coupler_type_send_data
use mpp_domains_mod, only : domain2d, mpp_get_layout, mpp_get_global_domain
use mpp_domains_mod, only : mpp_define_domains, mpp_get_compute_domain, mpp_get_data_domain
use fms_mod, only : stdout
use MOM_io, only : stdout
use mpp_mod, only : mpp_chksum
use MOM_EOS, only : gsw_sp_from_sr, gsw_pt_from_ct
use MOM_wave_interface, only : wave_parameters_CS, MOM_wave_interface_init
Expand Down Expand Up @@ -409,10 +409,6 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i

call close_param_file(param_file)
call diag_mediator_close_registration(OS%diag)

if (is_root_pe()) &
write(*,'(/12x,a/)') '======== COMPLETED MOM INITIALIZATION ========'

call callTree_leave("ocean_model_init(")
end subroutine ocean_model_init

Expand Down Expand Up @@ -1053,20 +1049,18 @@ subroutine ocean_public_type_chksum(id, timestep, ocn)
integer, intent(in) :: timestep !< The number of elapsed timesteps
type(ocean_public_type), intent(in) :: ocn !< A structure containing various publicly
!! visible ocean surface fields.
integer :: n, m, outunit

outunit = stdout()

write(outunit,*) "BEGIN CHECKSUM(ocean_type):: ", id, timestep
write(outunit,100) 'ocean%t_surf ',mpp_chksum(ocn%t_surf )
write(outunit,100) 'ocean%s_surf ',mpp_chksum(ocn%s_surf )
write(outunit,100) 'ocean%u_surf ',mpp_chksum(ocn%u_surf )
write(outunit,100) 'ocean%v_surf ',mpp_chksum(ocn%v_surf )
write(outunit,100) 'ocean%sea_lev ',mpp_chksum(ocn%sea_lev)
write(outunit,100) 'ocean%frazil ',mpp_chksum(ocn%frazil )
write(outunit,100) 'ocean%melt_potential ',mpp_chksum(ocn%melt_potential)

call coupler_type_write_chksums(ocn%fields, outunit, 'ocean%')
integer :: n, m

write(stdout,*) "BEGIN CHECKSUM(ocean_type):: ", id, timestep
write(stdout,100) 'ocean%t_surf ',mpp_chksum(ocn%t_surf )
write(stdout,100) 'ocean%s_surf ',mpp_chksum(ocn%s_surf )
write(stdout,100) 'ocean%u_surf ',mpp_chksum(ocn%u_surf )
write(stdout,100) 'ocean%v_surf ',mpp_chksum(ocn%v_surf )
write(stdout,100) 'ocean%sea_lev ',mpp_chksum(ocn%sea_lev)
write(stdout,100) 'ocean%frazil ',mpp_chksum(ocn%frazil )
write(stdout,100) 'ocean%melt_potential ',mpp_chksum(ocn%melt_potential)

call coupler_type_write_chksums(ocn%fields, stdout, 'ocean%')
100 FORMAT(" CHECKSUM::",A20," = ",Z20)

end subroutine ocean_public_type_chksum
Expand Down
Loading

0 comments on commit d27bcbd

Please sign in to comment.