From fdebcf245247d486ae5b2a2cddbcdf6fdbcac7db Mon Sep 17 00:00:00 2001 From: adigitoleo Date: Tue, 26 Mar 2024 13:18:25 +1100 Subject: [PATCH] fix: Use python for arithmetic in Makefile Shell doesn't understand scientific notation and POSIX arithmetic is extremely brittle. --- examples/fluidity/corner2d/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/fluidity/corner2d/Makefile b/examples/fluidity/corner2d/Makefile index 883bc00d..4fec74c8 100644 --- a/examples/fluidity/corner2d/Makefile +++ b/examples/fluidity/corner2d/Makefile @@ -10,6 +10,8 @@ OUT_DIR := _out # Initial geometry options (in units of metres), passed to `pydrex-mesh`. WIDTH := 1e6 DEPTH := 2e5 +HALF_WIDTH := $(shell python3 -c 'print($(WIDTH)/2)') +HALF_DEPTH := $(shell python3 -c 'print($(DEPTH)/2)') RESOLUTION_HI := 1e2 RESOLUTION_LO := 1e4 # Initial conditions, used to parametrise velocity fields and spawn particles. @@ -57,7 +59,7 @@ $(OUT_DIR)/$(SIM_NAME).msh: @echo "********** Building the mesh file..." ./envcheck.sh -m pydrex-mesh -k="rectangle" -a xy $(WIDTH),$(DEPTH) \ - -c $$(($(WIDTH)/2)),$$((-$(DEPTH)/2)) -r NW:$(RESOLUTION_HI),SE:$(RESOLUTION_LO) $@ + -c $(HALF_WIDTH),$(HALF_DEPTH) -r NW:$(RESOLUTION_HI),SE:$(RESOLUTION_LO) $@ .PHONY: clean clean: