Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: tc4 installs python-netCDF4 via venv #1166

Merged
merged 12 commits into from
Jul 27, 2020
54 changes: 50 additions & 4 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,34 @@ TARGET_SOURCE = $(call SOURCE,build/target_codebase/src) \
$(wildcard build/target_codebase/config_src/ext*/*.F90)
FMS_SOURCE = $(call SOURCE,$(DEPS)/fms/src)

#---
# Python preprocessing environment configuration

HAS_NUMPY = $(shell python -c "import numpy" 2> /dev/null && echo "yes")
HAS_NETCDF4 = $(shell python -c "import netCDF4" 2> /dev/null && echo "yes")

USE_VENV =
ifneq ($(HAS_NUMPY), yes)
USE_VENV = yes
endif
ifneq ($(HAS_NETCDF4), yes)
USE_VENV = yes
endif

# When disabled, activation is a null operation (`true`)
VENV_PATH =
VENV_ACTIVATE = true
ifeq ($(USE_VENV), yes)
VENV_PATH = work/local-env
VENV_ACTIVATE = . $(VENV_PATH)/bin/activate
endif


#---
# Rules

.PHONY: all build.regressions
all: $(foreach b,$(BUILDS),build/$(b)/MOM6)
all: $(foreach b,$(BUILDS),build/$(b)/MOM6) $(VENV_PATH)
build.regressions: $(foreach b,symmetric target,build/$(b)/MOM6)

# Executable
Expand Down Expand Up @@ -184,6 +207,18 @@ $(LIST_PATHS) $(MKMF):
cd $(DEPS)/mkmf; git checkout $(MKMF_COMMIT)


#---
# Python preprocessing
# NOTE: Some less mature environments (e.g. Arm64 Ubuntu) require explicit
# installation of numpy before netCDF4, as well as wheel and cython support.
work/local-env:
python3 -m venv $@
. $@/bin/activate \
&& pip3 install wheel \
&& pip3 install cython \
&& pip3 install numpy \
&& pip3 install netCDF4

#----
# Testing

Expand Down Expand Up @@ -264,7 +299,6 @@ $(eval $(call CMP_RULE,regression,symmetric target))

# TODO: chksum_diag parsing of restart files


#---
# Test run output files

Expand All @@ -281,7 +315,13 @@ work/%/$(1)/ocean.stats work/%/$(1)/chksum_diag: build/$(2)/MOM6
if [ $(3) ]; then find build/$(2) -name *.gcda -exec rm -f '{}' \; ; fi
mkdir -p $$(@D)
cp -rL $$*/* $$(@D)
cd $$(@D) && if [ -f Makefile ]; then $(MAKE); fi
if [ -f $$(@D)/Makefile ]; then \
$$(VENV_ACTIVATE) \
&& cd $$(@D) \
&& $(MAKE); \
else \
cd $$(@D); \
fi
mkdir -p $$(@D)/RESTART
echo -e "$(4)" > $$(@D)/MOM_override
cd $$(@D) \
Expand Down Expand Up @@ -327,7 +367,13 @@ work/%/restart/ocean.stats: build/symmetric/MOM6
rm -rf $(@D)
mkdir -p $(@D)
cp -rL $*/* $(@D)
cd work/$*/restart && if [ -f Makefile ]; then $(MAKE); fi
if [ -f $(@D)/Makefile ]; then \
$(VENV_ACTIVATE) \
&& cd work/$*/restart \
&& $(MAKE); \
else \
cd work/$*/restart; \
fi
mkdir -p $(@D)/RESTART
# Generate the half-period input namelist
# TODO: Assumes that runtime set by DAYMAX, will fail if set by input.nml
Expand Down
4 changes: 4 additions & 0 deletions .testing/tc4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ocean_hgrid.nc
sponge.nc
temp_salt_ic.nc
topog.nc
7 changes: 6 additions & 1 deletion .testing/tc4/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
ocean_hgrid.nc topog.nc temp_salt_ic.nc sponge.nc:
OUT=ocean_hgrid.nc sponge.nc temp_salt_ic.nc topog.nc

$(OUT):
python build_grid.py
python build_data.py

clean:
rm -rf $(OUT)
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ addons:
- mpich libmpich-dev
- doxygen graphviz flex bison cmake
- python-numpy python-netcdf4
- python3 python3-dev python3-venv python3-pip
- bc

jobs:
Expand Down