Skip to content

Commit

Permalink
Merge pull request #7 from adcroft/brankart
Browse files Browse the repository at this point in the history
merge Brankart
  • Loading branch information
pjpegion committed Sep 17, 2020
2 parents d9286df + 14d8de3 commit 576dd73
Show file tree
Hide file tree
Showing 61 changed files with 2,019 additions and 1,698 deletions.
55 changes: 42 additions & 13 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,21 @@ test.nans: $(foreach c,$(CONFIGS),$(c).nan $(c).nan.diag)
test.dims: $(foreach c,$(CONFIGS),$(foreach d,$(DIMS),$(c).dim.$(d) $(c).dim.$(d).diag))
test.regressions: $(foreach c,$(CONFIGS),$(c).regression $(c).regression.diag)

.PHONY: run.symmetric run.asymmetric run.nans run.openmp
run.symmetric: $(foreach c,$(CONFIGS),work/$(c)/symmetric/ocean.stats)
run.asymmetric: $(foreach c,$(filter-out tc3,$(CONFIGS)),$(CONFIGS),work/$(c)/asymmetric/ocean.stats)
run.nans: $(foreach c,$(CONFIGS),work/$(c)/nan/ocean.stats)
run.openmp: $(foreach c,$(CONFIGS),work/$(c)/openmp/ocean.stats)

# Color highlights for test results
RED=\033[0;31m
YELLOW=\033[0;33m
GREEN=\033[0;32m
RESET=\033[0m

DONE=${GREEN}DONE${RESET}
PASS=${GREEN}PASS${RESET}
WARN=${YELLOW}WARN${RESET}
FAIL=${RED}FAIL${RESET}

# Comparison rules
Expand All @@ -261,18 +269,18 @@ define CMP_RULE
@cmp $$^ || !( \
mkdir -p results/$$*; \
(diff $$^ | tee results/$$*/ocean.stats.$(1).diff | head) ; \
echo -e "${FAIL}: Solutions $$*.$(1) have changed." \
echo -e "$(FAIL): Solutions $$*.$(1) have changed." \
)
@echo -e "${PASS}: Solutions $$*.$(1) agree."
@echo -e "$(PASS): Solutions $$*.$(1) agree."

.PRECIOUS: $(foreach b,$(2),work/%/$(b)/chksum_diag)
%.$(1).diag: $(foreach b,$(2),work/%/$(b)/chksum_diag)
@cmp $$^ || !( \
mkdir -p results/$$*; \
(diff $$^ | tee results/$$*/chksum_diag.$(1).diff | head) ; \
echo -e "${FAIL}: Diagnostics $$*.$(1).diag have changed." \
echo -e "$(FAIL): Diagnostics $$*.$(1).diag have changed." \
)
@echo -e "${PASS}: Diagnostics $$*.$(1).diag agree."
@echo -e "$(PASS): Diagnostics $$*.$(1).diag agree."
endef

$(eval $(call CMP_RULE,grid,symmetric asymmetric))
Expand All @@ -282,7 +290,7 @@ $(eval $(call CMP_RULE,repro,symmetric repro))
$(eval $(call CMP_RULE,openmp,symmetric openmp))
$(eval $(call CMP_RULE,nan,symmetric nan))
$(foreach d,$(DIMS),$(eval $(call CMP_RULE,dim.$(d),symmetric dim.$(d))))
$(eval $(call CMP_RULE,regression,symmetric target))
#$(eval $(call CMP_RULE,regression,symmetric target))

# Custom comparison rules

Expand All @@ -292,13 +300,34 @@ $(eval $(call CMP_RULE,regression,symmetric target))
@cmp $(foreach f,$^,<(tr -s ' ' < $(f) | cut -d ' ' -f3- | tail -n 1)) \
|| !( \
mkdir -p results/$*; \
(diff $$^ | tee results/$*/chksum_diag.restart.diff | head) ; \
echo -e "${FAIL}: Diagnostics $*.restart.diag have changed." \
(diff $^ | tee results/$*/chksum_diag.restart.diff | head) ; \
echo -e "$(FAIL): Solutions $*.restart have changed." \
)
@echo -e "${PASS}: Diagnostics $*.restart.diag agree."
@echo -e "$(PASS): Solutions $*.restart agree."

# TODO: chksum_diag parsing of restart files

# stats rule is unchanged, but we cannot use CMP_RULE to generate it.
%.regression: $(foreach b,symmetric target,work/%/$(b)/ocean.stats)
@cmp $^ || !( \
mkdir -p results/$*; \
(diff $^ | tee results/$*/ocean.stats.regression.diff | head) ; \
echo -e "$(FAIL): Solutions $*.regression have changed." \
)
@echo -e "$(PASS): Solutions $*.regression agree."

# Regression testing only checks for changes in existing diagnostics
%.regression.diag: $(foreach b,symmetric target,work/%/$(b)/chksum_diag)
@! diff $^ | grep "^[<>]" | grep "^>" \
|| ! (\
mkdir -p results/$*; \
(diff $^ | tee results/$*/chksum_diag.regression.diff | head) ; \
echo -e "$(FAIL): Diagnostics $*.regression.diag have changed." \
)
diff $^ || echo -e "$(WARN): New diagnostics in $<"
@echo -e "$(PASS): Diagnostics $*.regression.diag agree."


#---
# Test run output files

Expand Down Expand Up @@ -331,9 +360,9 @@ work/%/$(1)/ocean.stats work/%/$(1)/chksum_diag: build/$(2)/MOM6
cat std.out | tee ../../../results/$$*/std.$(1).out | tail -20 ; \
cat std.err | tee ../../../results/$$*/std.$(1).err | tail -20 ; \
rm ocean.stats chksum_diag ; \
echo -e "${FAIL}: $$*.$(1) failed at runtime." \
echo -e "$(FAIL): $$*.$(1) failed at runtime." \
)
@echo -e "${DONE}: $$*.$(1); no runtime errors."
@echo -e "$(DONE): $$*.$(1); no runtime errors."
if [ $(3) ]; then \
mkdir -p results/$$* ; \
bash <(curl -s https://codecov.io/bash) -n $$@ \
Expand Down Expand Up @@ -389,7 +418,7 @@ work/%/restart/ocean.stats: build/symmetric/MOM6
|| !( \
cat std1.out | tee ../../../results/$*/std.restart1.out | tail ; \
cat std1.err | tee ../../../results/$*/std.restart1.err | tail ; \
echo -e "${FAIL}: $*.restart failed at runtime." \
echo -e "$(FAIL): $*.restart failed at runtime." \
)
# Setup the next inputs
cd $(@D) && rm -rf INPUT && mv RESTART INPUT
Expand All @@ -400,7 +429,7 @@ work/%/restart/ocean.stats: build/symmetric/MOM6
|| !( \
cat std2.out | tee ../../../results/$*/std.restart2.out | tail ; \
cat std2.err | tee ../../../results/$*/std.restart2.err | tail ; \
echo -e "${FAIL}: $*.restart failed at runtime." \
echo -e "$(FAIL): $*.restart failed at runtime." \
)

# TODO: Restart checksum diagnostics
Expand Down Expand Up @@ -428,7 +457,7 @@ test.summary:
fi; \
false ; \
else \
echo -e "${PASS}: All tests passed!"; \
echo -e "$(PASS): All tests passed!"; \
fi


Expand Down
3 changes: 3 additions & 0 deletions .testing/tc0/MOM_input
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ THICKNESS_CONFIG = "uniform" !

! === module MOM_diag_mediator ===

USE_GRID_SPACE_DIAG_COORDINATE_AXES = True ! [Boolean] default = False
! If true, use a grid index coordinate convention for diagnostic axes.

! === module MOM_MEKE ===

! === module MOM_lateral_mixing_coeffs ===
Expand Down
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ jobs:
- make test.summary

# NOTE: Code coverage upload is here to reduce load imbalance
# We do coverage with the regressions if part of a pull request
# otherwise as a separate job.
- if: type = pull_request
env:
- JOB="x86 Regression testing"
Expand All @@ -57,6 +59,19 @@ jobs:
- make -k -s test.regressions
- make test.summary

- if: NOT type = pull_request
env:
- JOB="Coverage upload"
- REPORT_COVERAGE=true
- DO_REGRESSION_TESTS=false
- MKMF_TEMPLATE=linux-ubuntu-xenial-gnu.mk
script:
- cd .testing
- echo 'Build executables...' && echo -en 'travis_fold:start:script.1\\r'
- make build/symmetric/MOM6
- echo -en 'travis_fold:end:script.1\\r'
- make -k -s run.symmetric

- arch: arm64
env:
- JOB="ARM64 Configuration testing"
Expand Down
4 changes: 1 addition & 3 deletions config_src/coupled_driver/MOM_surface_forcing_gfdl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ module MOM_surface_forcing_gfdl
use MOM_constants, only : hlv, hlf
use MOM_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end
use MOM_cpu_clock, only : CLOCK_SUBCOMPONENT
use MOM_diag_mediator, only : diag_ctrl
use MOM_diag_mediator, only : safe_alloc_ptr, time_type
use MOM_diag_mediator, only : diag_ctrl, safe_alloc_ptr, time_type
use MOM_domains, only : pass_vector, pass_var, fill_symmetric_edges
use MOM_domains, only : global_field_sum, BITWISE_EXACT_SUM
use MOM_domains, only : AGRID, BGRID_NE, CGRID_NE, To_All
use MOM_domains, only : To_North, To_East, Omit_Corners
use MOM_error_handler, only : MOM_error, WARNING, FATAL, is_root_pe, MOM_mesg
Expand Down
5 changes: 3 additions & 2 deletions config_src/ice_solo_driver/ice_shelf_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ program Shelf_main
call close_file(unit)
endif

if (cpu_steps > 0) call write_cputime(Time, 0, nmax, write_CPU_CSp)
if (cpu_steps > 0) call write_cputime(Time, 0, write_CPU_CSp)

if (((.not.BTEST(Restart_control,1)) .and. (.not.BTEST(Restart_control,0))) &
.or. (Restart_control < 0)) permit_incr_restart = .false.
Expand Down Expand Up @@ -403,7 +403,7 @@ program Shelf_main
Time = Master_Time

if (cpu_steps > 0) then ; if (MOD(ns, cpu_steps) == 0) then
call write_cputime(Time, ns, nmax, write_CPU_CSp)
call write_cputime(Time, ns, write_CPU_CSp, nmax)
endif ; endif

! See if it is time to write out a restart file - timestamped or not.
Expand Down Expand Up @@ -459,6 +459,7 @@ program Shelf_main

call callTree_waypoint("End Shelf_main")
call diag_mediator_end(Time, diag, end_diag_manager=.true.)
if (cpu_steps > 0) call write_cputime(Time, ns-1, write_CPU_CSp, call_end=.true.)
call cpu_clock_end(termClock)

call io_infra_end ; call MOM_infra_end
Expand Down
103 changes: 53 additions & 50 deletions config_src/mct_driver/mom_ocean_model_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,57 @@ module MOM_ocean_model_mct
! This code is a stop-gap wrapper of the MOM6 code to enable it to be called
! in the same way as MOM4.

use MOM, only : initialize_MOM, step_MOM, MOM_control_struct, MOM_end
use MOM, only : extract_surface_state, allocate_surface_state, finish_MOM_initialization
use MOM, only : get_MOM_state_elements, MOM_state_is_synchronized
use MOM, only : get_ocean_stocks, step_offline
use MOM_constants, only : CELSIUS_KELVIN_OFFSET, hlf
use MOM_diag_mediator, only : diag_ctrl, enable_averaging, disable_averaging
use MOM_diag_mediator, only : diag_mediator_close_registration, diag_mediator_end
use MOM_domains, only : pass_var, pass_vector, AGRID, BGRID_NE, CGRID_NE
use MOM_domains, only : TO_ALL, Omit_Corners
use MOM_error_handler, only : MOM_error, FATAL, WARNING, is_root_pe
use MOM_error_handler, only : callTree_enter, callTree_leave
use MOM_file_parser, only : get_param, log_version, close_param_file, param_file_type
use MOM_forcing_type, only : allocate_forcing_type
use MOM_forcing_type, only : forcing, mech_forcing
use MOM_forcing_type, only : forcing_accumulate, copy_common_forcing_fields
use MOM_forcing_type, only : copy_back_forcing_fields, set_net_mass_forcing
use MOM_forcing_type, only : set_derived_forcing_fields
use MOM_forcing_type, only : forcing_diagnostics, mech_forcing_diags
use MOM_get_input, only : Get_MOM_Input, directories
use MOM_grid, only : ocean_grid_type
use MOM_io, only : close_file, file_exists, read_data, write_version_number
use MOM_marine_ice, only : iceberg_forces, iceberg_fluxes, marine_ice_init, marine_ice_CS
use MOM_restart, only : MOM_restart_CS, save_restart
use MOM_string_functions, only : uppercase
use MOM_surface_forcing_mct, only : surface_forcing_init, convert_IOB_to_fluxes
use MOM_surface_forcing_mct, only : convert_IOB_to_forces, ice_ocn_bnd_type_chksum
use MOM_surface_forcing_mct, only : ice_ocean_boundary_type, surface_forcing_CS
use MOM_surface_forcing_mct, only : forcing_save_restart
use MOM_time_manager, only : time_type, get_time, set_time, operator(>)
use MOM_time_manager, only : operator(+), operator(-), operator(*), operator(/)
use MOM_time_manager, only : operator(/=), operator(<=), operator(>=)
use MOM_time_manager, only : operator(<), real_to_time_type, time_type_to_real
use MOM_tracer_flow_control, only : call_tracer_register, tracer_flow_control_init
use MOM_tracer_flow_control, only : call_tracer_flux_init
use MOM_unit_scaling, only : unit_scale_type
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 : add_shelf_forces, ice_shelf_end, ice_shelf_save_restart
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
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 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
use MOM_wave_interface, only: MOM_wave_interface_init_lite, Update_Surface_Waves
use MOM, only : initialize_MOM, step_MOM, MOM_control_struct, MOM_end
use MOM, only : extract_surface_state, allocate_surface_state, finish_MOM_initialization
use MOM, only : get_MOM_state_elements, MOM_state_is_synchronized
use MOM, only : get_ocean_stocks, step_offline
use MOM_constants, only : CELSIUS_KELVIN_OFFSET, hlf
use MOM_diag_mediator, only : diag_ctrl, enable_averaging, disable_averaging
use MOM_diag_mediator, only : diag_mediator_close_registration, diag_mediator_end
use MOM_domains, only : pass_var, pass_vector, AGRID, BGRID_NE, CGRID_NE
use MOM_domains, only : TO_ALL, Omit_Corners
use MOM_error_handler, only : MOM_error, FATAL, WARNING, is_root_pe
use MOM_error_handler, only : callTree_enter, callTree_leave
use MOM_file_parser, only : get_param, log_version, close_param_file, param_file_type
use MOM_forcing_type, only : allocate_forcing_type
use MOM_forcing_type, only : forcing, mech_forcing
use MOM_forcing_type, only : forcing_accumulate, copy_common_forcing_fields
use MOM_forcing_type, only : copy_back_forcing_fields, set_net_mass_forcing
use MOM_forcing_type, only : set_derived_forcing_fields
use MOM_forcing_type, only : forcing_diagnostics, mech_forcing_diags
use MOM_get_input, only : Get_MOM_Input, directories
use MOM_grid, only : ocean_grid_type
use MOM_io, only : close_file, file_exists, read_data, write_version_number
use MOM_marine_ice, only : iceberg_forces, iceberg_fluxes, marine_ice_init, marine_ice_CS
use MOM_restart, only : MOM_restart_CS, save_restart
use MOM_string_functions, only : uppercase
use MOM_surface_forcing_mct, only : surface_forcing_init, convert_IOB_to_fluxes
use MOM_surface_forcing_mct, only : convert_IOB_to_forces, ice_ocn_bnd_type_chksum
use MOM_surface_forcing_mct, only : ice_ocean_boundary_type, surface_forcing_CS
use MOM_surface_forcing_mct, only : forcing_save_restart
use MOM_time_manager, only : time_type, get_time, set_time, operator(>)
use MOM_time_manager, only : operator(+), operator(-), operator(*), operator(/)
use MOM_time_manager, only : operator(/=), operator(<=), operator(>=)
use MOM_time_manager, only : operator(<), real_to_time_type, time_type_to_real
use MOM_tracer_flow_control, only : call_tracer_register, tracer_flow_control_init
use MOM_tracer_flow_control, only : call_tracer_flux_init
use MOM_unit_scaling, only : unit_scale_type
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 : add_shelf_forces, ice_shelf_end, ice_shelf_save_restart
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
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 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
use MOM_wave_interface, only : MOM_wave_interface_init_lite, Update_Surface_Waves
use time_interp_external_mod, only : time_interp_external_init

! MCT specfic routines
use MOM_domains, only : MOM_infra_end
Expand Down Expand Up @@ -265,6 +266,8 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
OS%is_ocean_pe = Ocean_sfc%is_ocean_pe
if (.not.OS%is_ocean_pe) return

call time_interp_external_init

OS%Time = Time_in
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, &
Expand Down
Loading

0 comments on commit 576dd73

Please sign in to comment.