Skip to content

Commit

Permalink
Merge pull request #255 from marshallward/tc4_rule_fixes
Browse files Browse the repository at this point in the history
.testing: Fix concurrency errors in tc4 rules
  • Loading branch information
Hallberg-NOAA authored Nov 25, 2022
2 parents 321e0eb + 7a962e5 commit 571ddd9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ $(foreach c,$(CONFIGS),$(eval $(call CONFIG_DIM_RULE,$(c))))
# NOTE: This only support tc4, but can be generalized over all tests.
.PHONY: preproc
preproc: tc4/Makefile
cd tc4 && make
cd tc4 && $(MAKE) LAUNCHER="$(MPIRUN)"

tc4/Makefile: tc4/configure tc4/Makefile.in
cd $(@D) && ./configure || (cat config.log && false)
Expand Down
33 changes: 27 additions & 6 deletions .testing/tc4/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,43 @@ FCFLAGS = @FCFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@

OUT = topog.nc ocean_hgrid.nc temp_salt_ic.nc sponge.nc
LAUNCHER ?=

all: $(OUT)
OUT = ocean_hgrid.nc topog.nc temp_salt_ic.nc sponge.nc

ocean_hgrid.nc topog.nc: gen_grid
./gen_grid
# Since each program generates two outputs, we can only use one to track the
# creation. The second rule is used to indirectly re-invoke the first rule.
#
# Reference:
# https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html

temp_salt_ic.nc sponge.nc: gen_data
./gen_data
# Program output
all: ocean_hgrid.nc temp_salt_ic.nc

ocean_hgrid.nc: gen_grid
$(LAUNCHER) ./gen_grid
topog.nc: ocean_hgrid.nc
@test -f $@ || rm -f $^
@test -f $@ || $(MAKE) $^

temp_salt_ic.nc: gen_data ocean_hgrid.nc
$(LAUNCHER) ./gen_data
sponge.nc: temp_salt_ic.nc
@test -f $@ || rm -f $^
@test -f $@ || $(MAKE) $^


# Programs

gen_grid: gen_grid.F90
$(FC) $(FCFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)

gen_data: gen_data.F90
$(FC) $(FCFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)


# Support

.PHONY: clean
clean:
rm -rf $(OUT) gen_grid gen_data
Expand Down

0 comments on commit 571ddd9

Please sign in to comment.