-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.run
114 lines (100 loc) · 5.39 KB
/
Makefile.run
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
112
113
114
# 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
# If mom6_memory = static
# mom6_configuration = ocean_only/DOME ocean_only/benchmark ocean_only/double_gyre ...
# Include local configs if present
-include config.mk
CONFIGS ?= MOM6-examples
BUILD = build
MPIRUN ?= srun -mblock --exclusive
SHELL = bash
COMPILERS ?= gnu intel pgi cray
all:
time make -f MRS/Makefile.run gnu_all -s -j
time make -f MRS/Makefile.run intel_all -s -j
time make -f MRS/Makefile.run pgi_all -s -j
# 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
# Running
include manifest.mk
MODE ?= repro
MEMORY ?= dynamic
ifeq ($(MEMORY),static)
# Static pathway for building ocean.stats.*
define run-static-model
$(CONFIGS)/%/ocean.stats.$(1): $(CONFIGS)/%/input.nml $(CONFIGS)/%/MOM_input $(CONFIGS)/%/MOM_override
echo $(BUILD)/$(1)/$$(MODE)/static/$$*/MOM6"("$$(STATIC_NPES)")" "=>" $$@
cd $$(@D) && rm -rf Depth_list.nc CPU_stats.$(1) time_stamp.out $$(@F) RESTART FAIL U_velocity_truncations V_velocity_truncations && mkdir RESTART
cd $$(@D) && tic=$$$$(date +%s) && \
(OMP_NUM_THREADS=1 KMP_STACKSIZE=512m NC_BLKSZ=1M time $(MPIRUN) -n $$(STATIC_NPES) $$(call rel_path,$$(@D))$(BUILD)/$(1)/$$(MODE)/static/$$*/MOM6 > log.$(1).out || touch FAIL;) \
2>&1 | 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,$(COMPILERS),$(eval $(call run-static-model,$(c))))
# e.g. gnu_static, ...
define generate-targets
$(1)_static_ocean_only: $(foreach e,$(STATIC_OCEAN_ONLY),$(CONFIGS)/ocean_only/$(e)/ocean.stats.$(1))
endef
$(foreach c,$(COMPILERS),$(eval $(call generate-targets,$(c))))
else
ifeq ($(LAYOUT),alt)
# Dynamic pathway for building ocean.stats.* running with ALT_NPES
define run-dynamic-model
$(CONFIGS)/$(2)/%/ocean.stats.$(1): $(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6 $(CONFIGS)/$(2)/%/input.nml $(CONFIGS)/$(2)/%/MOM_input $(CONFIGS)/$(2)/%/MOM_override
echo $(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6"("$$(ALT_NPES)")" "=>" $$@
cd $$(@D) && rm -rf Depth_list.nc CPU_stats.$(1) time_stamp.out $$(@F) RESTART FAIL U_velocity_truncations V_velocity_truncations && mkdir RESTART
cd $$(@D) && tic=$$$$(date +%s) && \
(OMP_NUM_THREADS=1 KMP_STACKSIZE=512m NC_BLKSZ=1M time $(MPIRUN) -n $$(ALT_NPES) $$(call rel_path,$$(@D))$(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6 > log.$(1).out || touch FAIL;) \
2>&1 | 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,$(COMPILERS),$(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 " ALT_NPES" manifest.mk | grep -v ignore | grep $(1) | sed 's/%:.*/$(2)/')
endef
else
# Dynamic pathway for building ocean.stats.* running with NPES
define run-dynamic-model
$(CONFIGS)/$(2)/%/ocean.stats.$(1): $(BUILD)/$(1)/$$(MODE)/$$(MEMORY)/$(2)/MOM6 $(CONFIGS)/$(2)/%/input.nml $(CONFIGS)/$(2)/%/MOM_input $(CONFIGS)/$(2)/%/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 U_velocity_truncations V_velocity_truncations && 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 | 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,$(COMPILERS),$(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 -v ignore | grep $(1) | sed 's/%:.*/$(2)/')
endef
endif
# e.g. gnu_ocean_only, ..., gnu_all
define generate-targets
$(CONFIGS)/ocean_only/circle_obcs/ocean.stats.$(1): MEMORY=dynamic_symmetric
$(1)_ocean_only: $(call stats-files,ocean_only,$(1))
$(1)_ice_ocean_SIS2: $(call stats-files,ice_ocean_SIS2,$(1))
$(1)_land_ice_ocean_LM3_SIS2: $(call stats-files,land_ice_ocean_LM3_SIS2,$(1))
$(1)_coupled_AM2_LM3_SIS: $(call stats-files,coupled_AM2_LM3_SIS/,$(1))
$(1)_coupled_AM2_LM3_SIS2: $(call stats-files,coupled_AM2_LM3_SIS2,$(1))
$(1)_all: $(call stats-files,/,$(1))
endef
$(foreach c,$(COMPILERS),$(eval $(call generate-targets,$(c))))
endif
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_all: clean_gnu clean_intel clean_pgi
clean:
find $(CONFIGS) -name "*.out" -exec rm {} \;