diff options
| author | Charles BIENVENUE <charles.bienvenue@polymtl.ca> | 2025-11-05 22:47:07 +0000 |
|---|---|---|
| committer | Charles BIENVENUE <charles.bienvenue@polymtl.ca> | 2025-11-05 22:47:07 +0000 |
| commit | 2109f3ade9d6a202c413ed9ad3e3475caa944ae3 (patch) | |
| tree | 7e9ad87417236520023804b629e15e572bcb7c9d /Dragon | |
| parent | 8e8dd16f67ed325e2bf7fca0a9d878a18e6911ae (diff) | |
Parallel Build, OpenMP Support with Fortran 90, and Improved Module Dependencies
Diffstat (limited to 'Dragon')
| -rwxr-xr-x | Dragon/data/TEST_GEO_hex_sect_tspc.access | 4 | ||||
| -rwxr-xr-x | Dragon/data/TEST_GEO_latt_tspc_S30.access | 4 | ||||
| -rwxr-xr-x | Dragon/data/fbr_colorset.access | 4 | ||||
| -rwxr-xr-x | Dragon/data/fbr_tone.access | 4 | ||||
| -rw-r--r-- | Dragon/src/Makefile | 66 |
5 files changed, 56 insertions, 26 deletions
diff --git a/Dragon/data/TEST_GEO_hex_sect_tspc.access b/Dragon/data/TEST_GEO_hex_sect_tspc.access index aebf920..6c57516 100755 --- a/Dragon/data/TEST_GEO_hex_sect_tspc.access +++ b/Dragon/data/TEST_GEO_hex_sect_tspc.access @@ -27,7 +27,9 @@ if [ -f "$pos"/draglibendfb7r1SHEM315_v5p1.gz ] then echo 'gunzipping DLIB_315' chmod 755 "$pos" - gunzip "$pos"/draglibendfb7r1SHEM315_v5p1.gz + if [ ! -f "$pos"/draglibendfb7r1SHEM315_v5p1 ]; then + gunzip "$pos"/draglibendfb7r1SHEM315_v5p1.gz + fi fi if [ -f "$pos"/draglibendfb7r1SHEM315_v5p1 ] then diff --git a/Dragon/data/TEST_GEO_latt_tspc_S30.access b/Dragon/data/TEST_GEO_latt_tspc_S30.access index bb190e8..10c3098 100755 --- a/Dragon/data/TEST_GEO_latt_tspc_S30.access +++ b/Dragon/data/TEST_GEO_latt_tspc_S30.access @@ -27,7 +27,9 @@ if [ -f "$pos"/draglibendfb7r1SHEM315_v5p1.gz ] then echo 'gunzipping draglibendfb7r1SHEM315_v5p1' chmod 755 "$pos" - gunzip "$pos"/draglibendfb7r1SHEM315_v5p1.gz + if [ ! -f "$pos"/draglibendfb7r1SHEM315_v5p1 ]; then + gunzip "$pos"/draglibendfb7r1SHEM315_v5p1.gz + fi fi if [ -f "$pos"/draglibendfb7r1SHEM315_v5p1 ] then diff --git a/Dragon/data/fbr_colorset.access b/Dragon/data/fbr_colorset.access index 298d7b1..c25647b 100755 --- a/Dragon/data/fbr_colorset.access +++ b/Dragon/data/fbr_colorset.access @@ -27,7 +27,9 @@ if [ -f "$pos"/draglibendfb7r1SHEM315_v5p1.gz ] then echo 'gunzipping DLIB_315' chmod 755 "$pos" - gunzip "$pos"/draglibendfb7r1SHEM315_v5p1.gz + if [ ! -f "$pos"/draglibendfb7r1SHEM315_v5p1 ]; then + gunzip "$pos"/draglibendfb7r1SHEM315_v5p1.gz + fi fi if [ -f "$pos"/draglibendfb7r1SHEM315_v5p1 ] then diff --git a/Dragon/data/fbr_tone.access b/Dragon/data/fbr_tone.access index 396e3d6..fd8a33e 100755 --- a/Dragon/data/fbr_tone.access +++ b/Dragon/data/fbr_tone.access @@ -27,7 +27,9 @@ if [ -f "$pos"/draglibendfb7r1SHEM315_v5p1.gz ] then echo 'gunzipping DLIB_315' chmod 755 "$pos" - gunzip "$pos"/draglibendfb7r1SHEM315_v5p1.gz + if [ ! -f "$pos"/draglibendfb7r1SHEM315_v5p1 ]; then + gunzip "$pos"/draglibendfb7r1SHEM315_v5p1.gz + fi fi if [ -f "$pos"/draglibendfb7r1SHEM315_v5p1 ] then diff --git a/Dragon/src/Makefile b/Dragon/src/Makefile index c675c26..b423600 100644 --- a/Dragon/src/Makefile +++ b/Dragon/src/Makefile @@ -1,7 +1,7 @@ #--------------------------------------------------------------------------- # # Makefile for building the Dragon library and load module -# Author : A. Hebert (2018-5-10) +# Author : A. Hebert (2018-5-10) and C. Bienvenue (2025-11-04) # #--------------------------------------------------------------------------- # @@ -20,6 +20,7 @@ DIRNAME = $(shell uname -sm | sed 's/[ ]/_/') OS = $(shell uname -s | cut -d"_" -f1) opt = -O -g PREPRO = cpp +.DEFAULT_GOAL := all ifeq ($(openmp),1) COMP = -fopenmp PREPRO = cpp -D_OPENMP @@ -46,12 +47,11 @@ else endif ifeq ($(OS),AIX) - python_version_major := 2 + PY := python else - python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1))) - python_version_major := $(word 1,${python_version_full}) - ifneq ($(python_version_major),2) - python_version_major := 3 + PY := $(shell command -v python3 2>/dev/null) + ifeq ($(PY),) + PY := $(shell command -v python 2>/dev/null) endif endif @@ -158,7 +158,9 @@ else lib_module = ../lib/$(DIRNAME)_llvm/modules INCLUDE = -I../../Ganlib/lib/$(DIRNAME)_llvm/modules/ FFLAGS += -mmlir -fdynamic-heap-array - LFLAGS += -lclang_rt.osx + ifeq ($(OS),Darwin) + LFLAGS += -lclang_rt.osx + endif else lib = ../lib/$(DIRNAME) libUtl = ../../Utilib/lib/$(DIRNAME) @@ -177,18 +179,35 @@ ifeq ($(hdf5),1) LFLAGS += -L${HDF5_API} -lhdf5 endif -SRCC = $(shell ls *.c) -SRC77 = $(shell ls *.f) -SRCF77 = $(shell ls *.F) -ifeq ($(python_version_major),2) - SRC90 = $(shell python ../../script/make_depend.py *.f90) +FFLAGS += -cpp + +SRCC = $(shell ls *.c 2>/dev/null) +SRC77 = $(filter-out %.pp.f,$(shell ls *.f 2>/dev/null)) +SRCF77 = $(shell ls *.F 2>/dev/null) +ifeq ($(PY),) + $(warning No Python interpreter found; Fortran dependency ordering may be suboptimal) + SRC90_RAW = $(shell ls *.f90 *.F90 2>/dev/null) + SRC90 = $(filter-out %.pp.f90,$(SRC90_RAW)) else - SRC90 = $(shell python3 ../../script/make_depend_py3.py *.f90) + SRC90_RAW = $(shell $(PY) ../../script/make_depend.py *.f90 *.F90) + SRC90 = $(filter-out %.pp.f90,$(SRC90_RAW)) endif OBJC = $(SRCC:.c=.o) -OBJ90 = $(SRC90:.f90=.o) +OBJ90 = $(patsubst %.f90,%.o,$(patsubst %.F90,%.o,$(SRC90))) OBJ77 = $(SRC77:.f=.o) OBJF77 = $(SRCF77:.F=.o) + +# Auto-generated dependency file capturing Fortran module and include deps +DEPS_MK := .dragon_deps.mk +-include $(DEPS_MK) +$(DEPS_MK): $(SRC90) $(SRC77) $(SRCF77) +ifeq ($(PY),) + @echo "# Dependencies not generated: no Python available" > $(DEPS_MK) +else + @echo "# Generating Fortran dependencies into $(DEPS_MK)"; \ + $(PY) ../../script/make_depend.py --make-deps $(SRC90) $(SRC77) $(SRCF77) > $(DEPS_MK) || { rm -f $(DEPS_MK); exit 1; } +endif + all : sub-make Dragon ifeq ($(openmp),1) @echo 'Dragon: openmp is defined' @@ -206,26 +225,29 @@ ifeq ($(hdf5),1) @echo 'Dragon: hdf5 is defined' endif sub-make: + $(MAKE) openmp=$(openmp) intel=$(intel) nvidia=$(nvidia) llvm=$(llvm) hdf5=$(hdf5) -C ../../Utilib/src + $(MAKE) openmp=$(openmp) intel=$(intel) nvidia=$(nvidia) llvm=$(llvm) hdf5=$(hdf5) -C ../../Ganlib/src $(MAKE) openmp=$(openmp) intel=$(intel) nvidia=$(nvidia) llvm=$(llvm) hdf5=$(hdf5) -C ../../Trivac/src %.o : %.c $(C) $(CFLAGS) $(opt) $(COMP) -c $< -o $@ %.o : %.f90 $(F90) $(FFLAGS) $(opt) $(COMP) $(INCLUDE) -c $< -o $@ +%.o : %.F90 + # Use Fortran compiler's integrated preprocessor instead of cpp -traditional + $(F90) $(FFLAGS) $(opt) $(COMP) $(INCLUDE) $(FLAGS) -c $< -o $@ %.o : %.f - @/bin/rm -f temp.f $(F90) $(FFLAG77) $(opt) $(COMP) $(INCLUDE) -c $< -o $@ %.o : %.F - $(PREPRO) -P -W -traditional $(FLAGS) $< temp.f - $(F90) $(FFLAG77) $(opt) $(COMP) $(INCLUDE) -c temp.f -o $@ - /bin/rm temp.f + # Use Fortran compiler's integrated preprocessor only for .F (not for .f) + $(F90) $(FFLAG77) -cpp $(opt) $(COMP) $(INCLUDE) $(FLAGS) -c $< -o $@ $(lib_module)/: mkdir -p $(lib_module)/ $(lib)/: $(lib_module)/ mkdir -p $(lib)/ -libDragon.a: $(OBJC) $(OBJ90) $(OBJ77) $(OBJF77) $(lib)/ - ar r $@ $(OBJC) $(OBJ90) $(OBJ77) $(OBJF77) +libDragon.a: $(DEPS_MK) $(OBJC) $(OBJ90) $(OBJ77) $(OBJF77) $(lib)/ + ar rcs $@ $(OBJC) $(OBJ90) $(OBJ77) $(OBJF77) cp $@ $(lib)/$@ - cp *.mod $(lib_module) + if ls *.mod 1> /dev/null 2>&1; then cp *.mod $(lib_module); fi $(bin)/: mkdir -p $(bin)/ Dragon: libDragon.a DRAGON.o $(bin)/ sub-make @@ -234,4 +256,4 @@ Dragon: libDragon.a DRAGON.o $(bin)/ sub-make cp $@ $(bin)/$@ clean: $(MAKE) -C ../../Trivac/src clean - /bin/rm -f *.o *.mod *.a sub-make temp.* Dragon + /bin/rm -f *.o *.mod *.a sub-make temp.* Dragon $(DEPS_MK) *.pp.f *.pp.f90 |
