diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9c85c17 --- /dev/null +++ b/Makefile @@ -0,0 +1,159 @@ +###################################################################### +# GNU MAKEFILE # +###################################################################### +# There may be some trickery involved in this file; most of which is # +# hopefully explained sufficiently. This makefile is unlikely to # +# work with non-GNU make utilities. # +# # +###################################################################### +SHELL = /bin/bash +# clear out suffix list +.SUFFIXES : +# declare suffixes allowed to be subject to implicit rules. +.SUFFIXES : .f .o .f90 + +current_version=4.0c +tarname=NH3-Plus + + +src = ./src/ +build = ./obj/ +bin = ./bin/ + +ldir = $(src)lib/ +pdir = $(src)parser/ +mdl = $(src)model/ + + +# DEFINE THE PATH + +VPATH = $(src) +VPATH += $(ldir) +VPATH += $(pdir) +VPATH += $(mdl) + + +# extra dir +extra_dirs = logs nnfits scans +gincl = -I$(src) -I$(pdir) -I$(ldir) -I$(mdl) + +# GFORTRAN COMPILER +FC := gfortran +GFFLAGS = -O2 -fopenmp -fbackslash -fmax-errors=5 -Wall -Werror +GFFLAGS += -std=legacy -cpp -J$(build) +GFFLAGS += $(gincl) +#GFFLAGS += -Wall -Wextra -Werror -Wno-error=integer-division -Wno-error=conversion \ + -Wno-error=intrinsic-shadow z +GLLAPCK = -llapack + +DBGFFLAGS = -O0 -fcheck=bounds -fcheck=do -fcheck=mem -fcheck=pointer -p -g -fsanitize=thread + +#cGINCL = -I -I$(pdir) -I$(ldir) + +GFFLAGS += $(GINCL) +GFFLAGS += $(GLLAPCK) +DBGFFLAGS += $(GLLAPCK) + +#IFORT COMPILER + +IFC := ifort +IFFLAGS = -O3 -qopenmp -qmkl -fpp -stand f95 -warn all -warn noerrors \ + -fp-model precise -traceback -assume byterecl +IFFLAGS += -g -diag-disable=10448 +DBGIFC = -O0 -g -check all -traceback -fpp -warn all -fp-stack-check + +LDFLAGS = -llapack + +# CHOSE THE COMPILER +########################### +COMPILER = $(FC) + +ifeq ($(COMPILER),IFC) + FC = $(IFC) + FFLAGS = $(IFFLAGS) + DBGFLAGS = $(DBGIFC) +else + #FC = $(FC) + FFLAGS = $(GFFLAGS) + DBGFLAGS = $(DBGFFLAGS) +endif +###################################################################### +### Functions +###################################################################### + +# return 'true' if file $(1) exists, else return '' +file_exists = $(shell if [ -f $(1) ]; then echo "true"; fi) +# return 'true' if file $(1) doesn't exist, else return '' +file_lost = $(shell if [ ! -f $(1) ]; then echo "true"; fi) + +###################################################################### +### Objects +###################################################################### + +# Objects solely relying on ANN parameters +ann_objects = backprop.o ff_neunet.o neuron_types.o \ + axel.o nnmqo.o scans.o nnread.o +parameter_object = accuracy_constants.o nn_params.o io_parameters.o \ + nn_common_param.o nndbg.o +data_obj = Phase_correction.o data_transform.o write_error.o +# Objects relying on both genetic & ANN params +genann_objects = geNNetic.o iNNterface.o puNNch.o \ + mkNN.o error.o long_io.o parse_errors.o parser.o + +# Objects depending on model +pln_objects = invariants_nh3.o nncoords_nh3.o fit_genetic.o pes_model.o \ + dipole_model.o nnadia_nh3.o + + +# Objects belonging to internal library +lib_objects = misc.o ran_gv.o choldc.o diag.o \ + qsort.o dmatrix.o imatrix.o strings.o ran.o \ + fileread.o keyread.o long_keyread.o + +# Objects from hell; if it exists, don't compile it +hell_objects = $(ldir)random.o +hell_flags = -O3 -fopenmp -std=legacy + +project_objects = $(ann_objects) $(data_obj) $(genann_objects) $(pln_objects) +objects = $(addprefix $(build),$(parameter_object) $(project_objects) $(lib_objects)) + +main = genANN + +###################################################################### +### Remaining include files +###################################################################### + +gen_include = keylist.incl errcat.incl + +# Misc. files generated during compilation +trash = *__genmod* *~ *\# *.g .mod + +$(main) : $(objects) +ifeq ($(call file_exists,$(hell_objects)),) + $(MAKE) hell +endif + $(FC) $(FFLAGS) $(hell_objects) $(objects) $(LDFLAGS) -o $(bin)$(main) + +$(build)%.o : %.f + $(FC) -c $(FFLAGS) $< -o $@ +$(build)%.o : %.f90 + $(FC) -c $(FFLAGS) $< -o $@ + +$(hell_objects) : $(ldir)random.f + $(FC) -c $(hell_flags) $< -o $@ + +# making + +.PHONY : clean dirs neat hell pyram_ANN all debug +clean: + rm -rf $(build)*.o $(build)*.mod $(hell_objects) $(trash) $(bin)$(main) +# $(RM) $(objects) $(hell_objects) $(trash) $(bin)/$(main) +dirs: + @mkdir -p $(build) $(bin) $(extra_dirs) +neat: + $(RM) -f $(TRASH) +hell : $(hell_objects) + +debug: override FFLAGS += $(DBGFLAGS) +debug: clean $(hell) $(main) +all : clean hell $(main) pyram_ANN libdipole_surface.a