-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.restart
111 lines (96 loc) · 5.92 KB
/
Makefile.restart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Executable targets: build/compiler/mode/mom6_memory/mom6_configuration/MOM6
#
# compiler = gnu, intel, pgi, cray, ...
# mode = repro, debug, coverage, ...
# If mom6_memory = dynamic or dynamic_symmetric
# mom6_configuration = ocean_only, ice_ocean_SIS, ice_ocean_SIS2, land_ice_ocean_LM3_SIS2, coupled_AM2_LM3_SIS, coupled_AM2_LM3_SIS2
# Include local configs if present
-include config.mk
CONFIGS ?= MOM6-examples
BUILD = build
MPIRUN = srun -mblock --exclusive
SHELL = bash
COMPILERS ?= gnu intel pgi
LOG = > log
SKIP = circle_obcs|tracer_mixing|unit_test|mixed_layer_restrat_2d
all:
# Converts a path a/b/c to a list "a b c"
slash_to_list = $(subst /, ,$(1))
# Replaces a path a/b/c with ../../../
noop =
rel_path = $(subst $(noop) $(noop),,$(patsubst %,../,$(call slash_to_list,$(1))))
manifest.mk:
bash MRS/generate_manifest.sh $(CONFIGS) > manifest.mk
# Setup restart structure
$(foreach s,01 12 02,$(foreach f,input.nml MOM_input MOM_override,$(CONFIGS)/%/$(s).ignore/$(f))): | $(CONFIGS)/%
bash MRS/setup_restart_test.sh $|
%/restart.gnu: %/12.ignore/ocean.stats.gnu %/02.ignore/ocean.stats.gnu
bash MRS/check_restarts.sh $^
%/restart.intel: %/12.ignore/ocean.stats.intel %/02.ignore/ocean.stats.intel
bash MRS/check_restarts.sh $^
%/restart.pgi: %/12.ignore/ocean.stats.pgi %/02.ignore/ocean.stats.pgi
bash MRS/check_restarts.sh $^
# Running
-include manifest.mk
MODE ?= repro
MEMORY ?= dynamic
# Dynamic pathway for building ocean.stats.*
define run-dynamic-model
$(CONFIGS)/$(2)/%/02.ignore/ocean.stats.$(1): $(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6 $(CONFIGS)/$(2)/%/02.ignore/input.nml $(CONFIGS)/$(2)/%/02.ignore/MOM_input $(CONFIGS)/$(2)/%/02.ignore/MOM_override
echo $(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6"("$$(NPES)")" "=>" $$@
cd $$(@D) && rm -rf Depth_list.nc CPU_stats.$(1) time_stamp.out $$(@F) RESTART FAIL && mkdir RESTART
cd $$(@D) && tic=$$$$(date +%s) && \
(OMP_NUM_THREADS=1 KMP_STACKSIZE=512m NC_BLKSZ=1M time $(MPIRUN) -n $$(NPES) $$(call rel_path,$$(@D))$(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6 > log.$(1).out || touch FAIL;) \
2>&1 | tee std.err | egrep -v "ing coupler_init| initializ|ing " | sed 's,^,$$@: ,' && toc=$$$$(date +%s) && echo $$$$(($$$$toc-$$$$tic)) > walltime.$(1).out
@test -f $$(@D)/FAIL && exit 9 || true
$(CONFIGS)/$(2)/%/01.ignore/ocean.stats.$(1): $(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6 $(CONFIGS)/$(2)/%/01.ignore/input.nml $(CONFIGS)/$(2)/%/01.ignore/MOM_input $(CONFIGS)/$(2)/%/01.ignore/MOM_override
echo $(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6"("$$(NPES)")" "=>" $$@
cd $$(@D) && rm -rf Depth_list.nc CPU_stats.$(1) time_stamp.out $$(@F) RESTART FAIL && mkdir RESTART
cd $$(@D) && tic=$$$$(date +%s) && \
(OMP_NUM_THREADS=1 KMP_STACKSIZE=512m NC_BLKSZ=1M time $(MPIRUN) -n $$(NPES) $$(call rel_path,$$(@D))$(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6 > log.$(1).out || touch FAIL;) \
2>&1 | tee std.err | egrep -v "ing coupler_init| initializ|ing " | sed 's,^,$$@: ,' && toc=$$$$(date +%s) && echo $$$$(($$$$toc-$$$$tic)) > walltime.$(1).out
@test -f $$(@D)/FAIL && exit 9 || true
$(CONFIGS)/$(2)/%/12.ignore/ocean.stats.$(1): $(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6 $(CONFIGS)/$(2)/%/12.ignore/input.nml $(CONFIGS)/$(2)/%/12.ignore/MOM_input $(CONFIGS)/$(2)/%/12.ignore/MOM_override $(CONFIGS)/$(2)/%/01.ignore/ocean.stats.$(1)
echo $(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6"("$$(NPES)")" "=>" $$@
cd $$(@D) && rm -rf Depth_list.nc CPU_stats.$(1) time_stamp.out $$(@F) RESTART FAIL && mkdir RESTART
cd $$(@D) && mkdir -p INPUT ; cd INPUT && ln -sf ../../01.ignore/RESTART/* .
cd $$(@D) && tic=$$$$(date +%s) && \
(OMP_NUM_THREADS=1 KMP_STACKSIZE=512m NC_BLKSZ=1M time $(MPIRUN) -n $$(NPES) $$(call rel_path,$$(@D))$(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6 > log.$(1).out || touch FAIL;) \
2>&1 | tee std.err | egrep -v "ing coupler_init| initializ|ing " | sed 's,^,$$@: ,' && toc=$$$$(date +%s) && echo $$$$(($$$$toc-$$$$tic)) > walltime.$(1).out
@test -f $$(@D)/FAIL && exit 9 || true
endef
$(foreach c,gnu intel pgi,$(foreach o,ocean_only ice_ocean_SIS2 land_ice_ocean_LM3_SIS2 coupled_AM2_LM3_SIS coupled_AM2_LM3_SIS2,$(eval $(call run-dynamic-model,$(c),$(o)))))
define stats-files
$$(shell grep " NPES" manifest.mk | grep $(3) | grep $(1) | egrep -v "$(SKIP)" | sed 's/%:.*/$(2)/')
endef
define restart-test
$$(shell grep " NPES" manifest.mk | grep $(2) | grep 02.ignore | egrep -v "$(SKIP)" | sed 's,02.ignore.*,restart.$(1),')
endef
.SECONDARY: $(shell grep " NPES" manifest.mk | sed 's,ocean.stats.*,input.nml,')
.SECONDARY: $(shell grep " NPES" manifest.mk | sed 's,ocean.stats.*,MOM_input,')
.SECONDARY: $(shell grep " NPES" manifest.mk | sed 's,ocean.stats.*,MOM_override,')
# Build restart tests
$(CONFIGS)/%/02.ignore $(CONFIGS)/%/01.ignore $(CONFIGS)/%/12.ignore: $(CONFIGS)/%
# e.g. gnu_ocean_only, ..., gnu_all
define generate-targets
$(foreach s,01 12 02,MOM6-examples/ocean_only/circle_obcs/$(s).ignore/ocean.stats.$(1)): MEMORY=dynamic_symmetric
$(1)_ocean_only: $(call stats-files,ocean_only,$(1),$(RESTART_STAGE).ignore)
$(1)_ice_ocean_SIS2: $(call stats-files,ice_ocean_SIS2,$(1),$(RESTART_STAGE).ignore)
$(1)_land_ice_ocean_LM3_SIS2: $(call stats-files,land_ice_ocean_LM3_SIS2,$(1),$(RESTART_STAGE).ignore)
$(1)_coupled_AM2_LM3_SIS: $(call stats-files,coupled_AM2_LM3_SIS/,$(1),$(RESTART_STAGE).ignore)
$(1)_coupled_AM2_LM3_SIS2: $(call stats-files,coupled_AM2_LM3_SIS2,$(1),$(RESTART_STAGE).ignore)
$(1)_all: $(call stats-files,/,$(1),$(RESTART_STAGE).ignore)
restart_$(1)_ocean_only: $(call restart-test,$(1),ocean_only)
restart_$(1)_ice_ocean_SIS2: $(call restart-test,$(1),ice_ocean_SIS2)
endef
$(foreach c,$(COMPILERS),$(eval $(call generate-targets,$(c))))
clean_gnu:
find $(CONFIGS) -name "ocean.stats.gnu" -exec rm {} \;
clean_intel:
find $(CONFIGS) -name "ocean.stats.intel" -exec rm {} \;
clean_pgi:
find $(CONFIGS) -name "ocean.stats.pgi" -exec rm {} \;
clean:
find $(CONFIGS) -name "*.out" -exec rm {} \;
clean_setup:
find $(CONFIGS)/[oilc]* -name "??.ignore" -prune -exec rm -rf {} \;