diff --git a/.gitignore b/.gitignore index 5ee139f..cc3b492 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,10 @@ *.i90 *.mod +# Old build system files +make.inc +make.txt + # iOS .DS_Store diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2249c9c --- /dev/null +++ b/Makefile @@ -0,0 +1,122 @@ +$(info ===================================================) +$(info ) +$(info TurboRVB Legacy build system) +$(info ) +$(info ===================================================) +$(info ) + +# Test if make.inc exists + +make_inc_c := e +make_txt_c := e + +ifeq ($(wildcard make.inc),) +$(info ) +$(warning make.inc not found. ) + +make_inc_c := $(shell read -p "Do you want to create make.inc? [y/n]: " ans; \ + if [ "$$ans" = "y" ]; then \ + cp devel_tools/configs/make.inc.example.gcc make.inc; \ + echo "c"; \ + else \ + echo "n"; \ + fi) + +ifeq ($(make_inc_c) ,c) + $(info ) + $(info Please select an example: ) + $(info ) + $(info 1 GNU Fortran Compiler ) + $(info 2 GNU Fortran Compiler with MPI) + $(info ) + $(shell read -p "Select an example [1-2]: " ans; \ + if [ "$$ans" = "1" ]; then \ + cp devel_tools/make.inc.examples/make.inc.example.gcc make.inc; \ + elif [ "$$ans" = "2" ]; then \ + cp devel_tools/configs/make.inc.example.gccmpi make.inc; \ + fi) + +endif + +endif + +ifeq ($(wildcard make.txt),) +$(info ) +$(warning make.txt not found. ) + +make_txt_c := $(shell read -p "Do you want to create make.txt? [y/n]: " ans; \ + if [ "$$ans" = "y" ]; then \ + cp devel_tools/configs/make.txt.example make.txt; \ + echo "c"; \ + else \ + echo "n"; \ + fi) + +endif + +$(info ) + +ifeq ($(make_inc_c),c) +$(info make.inc created. Please edit it.) +endif + +ifeq ($(make_txt_c),c) +$(info make.txt created. Please edit it.) +endif + +ifeq ($(make_inc_c),n) +$(info make.inc not created. Exiting.) +endif + +ifeq ($(make_inc_c),n) +$(info make.inc not created. Exiting.) +endif + +ifneq ($(make_inc_c),e) +$(info ) +$(error Exiting.) +endif + +ifneq ($(make_txt_c),e) +$(info ) +$(error Exiting.) +endif + +include make.inc + +$(info ) +$(info Using make.inc found in $(CURDIR)) +$(info Building in $(BUILD_DIR)) +$(info ) +$(info Fortran compiler: $(FC)) +$(info Fortran compiler flags: $(FCFLAGS)) +$(info Fortran passive flags: $(FCFLAGS_PASSIVE)) +$(info Fortran aggressive flags: $(FCFLAGS_AGGRESSIVE)) +$(info ) +$(info C compiler: $(CC)) +$(info C compiler flags: $(CFLAGS)) +$(info ) +$(info Linker: $(LD)) +$(info Linker flags: $(FLINK)) +$(info ) +$(info Libraries: $(LINK_LIBS)) +$(info ) +$(info ===================================================) + + +all: + make -C src/m_pfapack -f Makefile + make -C src/m_common -f Makefile + make -C src/d_qlapack -f Makefile + make -C src/c_adjoint_forward -f Makefile + make -C src/c_adjoint_backward -f Makefile + make -C src/b_complex -f Makefile + make -C src/a_turborvb -f Makefile + + @echo " " + @echo " DONE - Enjoy TurboRVB! " + @echo " " + +clean: + rm -rf $(BUILD_DIR) + diff --git a/devel_tools/configs/make.inc.example.gcc b/devel_tools/configs/make.inc.example.gcc new file mode 100644 index 0000000..0ba532c --- /dev/null +++ b/devel_tools/configs/make.inc.example.gcc @@ -0,0 +1,83 @@ +# Makefile inc for TurboRVB + +# This make.inc is also a tutorial how to setup Makefile for TurboRVB. +# This one is set up for GNU Compilers Collection (GCC) and Netlib LAPACK. +# You might have to check your compiler and LAPACK installation and change + +# First we specifies suffix for our executable. This is not necessary but it is good practice. + +SUFFIX=-serial.x + +# This Makefile uses out-of-source build. This means that all object files and modules +# will be stored in separate directory. This directory is specified here. +# Keep in mind this have to be ABSOLUTE PATH. This file is loaded by sub-makefiles +# therefore $(pwd) or $(CURDIR) will not work. + +BUILD_DIR=/home/addman/Software/turborvb-rm/build-serial + +# Setup compilers Fortran and C. For this FC and CC variables are used respectively. + +FC=gfortran +CC=gcc + +# Setup compiler flags. Note that for MPI version Fortran compiler wrapper should be used. +# For this FCFLAGS and CFLAGS variables are used respectively. + +# It is important NOT to specify optimization flags here! + +# First we have to specify that Fortran should use C preprocessor. +# This is important for gfortran it is "-cpp" flag. However, for other compilers, +# such as Intel Fortran, it is "-fpp" flag. + +FCFLAGS=-cpp + +# Now we have to disable compilers check for argument mismatch. This is important for gfortran. + +FCFLAGS+=-fallow-argument-mismatch + +# Now we have to disable compilers check for line length. + +FCFLAGS+=-ffree-line-length-none + +# One might like to use OpenMP parallelism + +FCFLAGS+=-fopenmp + +# Debug -g flag is not slowing down modern code so we can use it all the time. + +FCFLAGS+=-g + +# Here we specify optimization flags. Note that for gfortran it is "-O" flag. +# C optimization flags CAN be specified here. This is one difference between C and Fortran flags. + +CFLAGS=-O3 -g -fopenmp + +# Here we specify flags for aggressive optimization. Note that for gfortran it is "-O" flag. +# Not all source files can be compiled with aggressive optimization. These files has to +# carefully selected and precified in the file make.txt + +FCFLAGS_AGGRESSIVE=-O3 +FCFLAGS_PASSIVE=-O0 + +# Here we specify flags that control storing and including of modules. +# For gfortran it is "-J" and "-I" flags respectively. This is true for most compilers. +# Normally, it is not necessary to specify these flags. + +MODULE_STORE=-J +MODULE_INCLUDE=-I + +# Here we can add preprocessort directives. Keep in mind it is good add them to FCFLAGS +# as well as to CFLAGS. For this a helper variable PP_DIRECTIVES is used. + +PP_DIRECTIVES=-D_TIME + +FCFLAGS+=$(PP_DIRECTIVES) +CFLAGS+=$(PP_DIRECTIVES) + +# Link options. Here we specify libraries that are needed for linking. + +FLINK=-fopenmp + +# Here we specify libraries that are needed for linking. + +LINK_LIBS=-L/opt/addman/spack/opt/spack/linux-debian11-zen/gcc-12.3.0/netlib-lapack-3.11.0-y7uuukt5z6xv6gquhqe6lmificwmatuj/lib -llapack -lblas diff --git a/devel_tools/configs/make.inc.example.gccmpi b/devel_tools/configs/make.inc.example.gccmpi new file mode 100644 index 0000000..23d9bcd --- /dev/null +++ b/devel_tools/configs/make.inc.example.gccmpi @@ -0,0 +1,85 @@ +# Makefile inc for TurboRVB + +# This make.inc is also a tutorial how to setup Makefile for TurboRVB. +# This one is set up for GNU Compilers Collection (GCC) and Netlib LAPACK. +# You might have to check your compiler and LAPACK installation and change + +# First we specifies suffix for our executable. This is not necessary but it is good practice. + +SUFFIX=-mpi.x + +# This Makefile uses out-of-source build. This means that all object files and modules +# will be stored in separate directory. This directory is specified here. +# Keep in mind this have to be ABSOLUTE PATH. This file is loaded by sub-makefiles +# therefore $(pwd) or $(CURDIR) will not work. + +BUILD_DIR=/home/addman/Software/turborvb-rm/build-mpi + +# Setup compilers Fortran and C. For MPI version MPI compiler wrappers should be used. +# For this FC and CC variables are used respectively. + +FC=mpif90 +CC=mpicc + +# Setup compiler flags. Note that for MPI version Fortran compiler wrapper should be used. +# For this FCFLAGS and CFLAGS variables are used respectively. + +# It is important NOT to specify optimization flags here! + +# First we have to specify that Fortran should use C preprocessor. +# This is important for gfortran it is "-cpp" flag. However, for other compilers, +# such as Intel Fortran, it is "-fpp" flag. + +FCFLAGS=-cpp + +# Now we have to disable compilers check for argument mismatch. This is important for gfortran. + +FCFLAGS+=-fallow-argument-mismatch + +# Now we have to disable compilers check for line length. + +FCFLAGS+=-ffree-line-length-none + +# One might like to use OpenMP parallelism + +FCFLAGS+=-fopenmp + +# Debug -g flag is not slowing down modern code so we can use it all the time. + +FCFLAGS+=-g + +# Here we specify optimization flags. Note that for gfortran it is "-O" flag. +# C optimization flags CAN be specified here. This is one difference between C and Fortran flags. + +CFLAGS=-O3 -g -fopenmp + +# Here we specify flags for aggressive optimization. Note that for gfortran it is "-O" flag. +# Not all source files can be compiled with aggressive optimization. These files has to +# carefully selected and precified in the file make.txt + +FCFLAGS_AGGRESSIVE=-O3 +FCFLAGS_PASSIVE=-O0 + +# Here we specify flags that control storing and including of modules. +# For gfortran it is "-J" and "-I" flags respectively. This is true for most compilers. +# Normally, it is not necessary to specify these flags. + +MODULE_STORE=-J +MODULE_INCLUDE=-I + +# Here we can add preprocessort directives. Keep in mind it is good add them to FCFLAGS +# as well as to CFLAGS. For this a helper variable PP_DIRECTIVES is used. +# For MPI version it is necessary to specify -DPARALLEL directive. + +PP_DIRECTIVES=-D_TIME -DPARALLEL + +FCFLAGS+=$(PP_DIRECTIVES) +CFLAGS+=$(PP_DIRECTIVES) + +# Link options. Here we specify libraries that are needed for linking. + +FLINK=-fopenmp + +# Here we specify libraries that are needed for linking. + +LINK_LIBS=-L/opt/addman/spack/opt/spack/linux-debian11-zen/gcc-12.3.0/netlib-lapack-3.11.0-y7uuukt5z6xv6gquhqe6lmificwmatuj/lib -llapack -lblas diff --git a/devel_tools/configs/make.txt.example b/devel_tools/configs/make.txt.example new file mode 100644 index 0000000..025a5c7 --- /dev/null +++ b/devel_tools/configs/make.txt.example @@ -0,0 +1,44 @@ +SOURCES_AGGRESSIVE=\ + cell.f90\ + conjginv_prep.f90\ + dgemm_my.f90\ + dielectric.f90\ + dsktri.f90\ + dsktrs.f90\ + ewald.f90\ + hopping_pbc.f90\ + jastrow_ee_exp.f90\ + jastrow_ei.f90\ + jastrow_exp.f90\ + jastrowgrad_exp.f90\ + jastrowgrad_exp_pbc.f90\ + makefun_bump.f90\ + makefun.f90\ + makefun_pbc.f90\ + makefun0_bump.f90\ + makefun0.f90 \ + makefun0_pbc.f90\ + mapping_sz.f90\ + ngivej_pbc.f90\ + ratiofn_psi.f90\ + ratio_psi.f90\ + ratiovar.f90\ + scalevect.f90\ + scratchdet.f90\ + subener.f90\ + t_lrdmc.f90\ + updiag.f90\ + upinvhop_fnf_new.f90\ + upinvhop.f90\ + upnewwf_new.f90\ + upsim.f90\ + upsimp.f90\ + uptable.f90\ + uptabpip_new.f90\ + upvpot_pbc_exp.f90\ + upwinv.f90\ + upwinvp.f90\ + up2bodypsi_pbc_exp.f90\ + zsktri.f90\ + zsktrs.f90\ + diff --git a/src/a_turborvb/Makefile b/src/a_turborvb/Makefile new file mode 100644 index 0000000..bc29d08 --- /dev/null +++ b/src/a_turborvb/Makefile @@ -0,0 +1,109 @@ +# Load settings + +include ../../make.inc + +# Variables + +SRC_DIR := . +MAIN_BUILD_DIR := $(BUILD_DIR)/main +MODULE_DIR := $(BUILD_DIR)/modules +TARGET := $(BUILD_DIR)/turborvb.x +TARGET_NAME := $(BUILD_DIR)/turborvb$(SUFFIX).x +TARGET_MODULES := $(BUILD_DIR)/turborvb$(SUFFIX)_module.a + +# File Lists +# +# First set modules: + +MODULE_SRCS := $(SRC_DIR)/scal_lins.f90 + +MODULE_OBJS := $(MODULE_SRCS:%=$(MAIN_BUILD_DIR)/%.o) +MODULE_MODS := $(MODULE_SRCS:%=$(BUILD_DIR)/%.mod) + +# Set rest files +SRCS := $(wildcard $(SRC_DIR)/*.f90) +SRCS += $(wildcard $(SRC_DIR)/*.c) +SRCS := $(filter-out $(MODULE_SRCS), $(SRCS)) +OBJS := $(SRCS:%=$(MAIN_BUILD_DIR)/%.o) + +# Default rule +all: dirs $(TARGET) + +# Rule for making the build directory +dirs: + mkdir -p $(MAIN_BUILD_DIR) + mkdir -p $(MODULE_DIR) + echo $(MODULE_OBJS) + +# Compile modules +$(MAIN_BUILD_DIR)/%.f90.o: %.f90 + $(FC) $(FCFLAGS) \ + $(MODULE_STORE) $(MODULE_DIR) \ + $(MODULE_INCLUDE) $(MODULE_DIR) \ + -c $< -o $@ + + +# Common module +$(TARGET_MODULES): $(MODULE_OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(AR) $(ARFLAGS) $(TARGET_MODULES) $(MODULE_OBJS) + +# Rule for making the target +$(TARGET): $(TARGET_MODULES) $(OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(FC) $(FLINK) \ + $(OBJS) \ + $(MODULE_OBJS) \ + $(BUILD_DIR)/complex.a \ + $(BUILD_DIR)/complex_module.a \ + $(BUILD_DIR)/adjoint_forward.a \ + $(BUILD_DIR)/adjoint_forward_module.a \ + $(BUILD_DIR)/adjoint_backward.a \ + $(BUILD_DIR)/qlapack.a \ + $(BUILD_DIR)/common.a \ + $(BUILD_DIR)/common_module.a \ + $(BUILD_DIR)/pfapack.a \ + $(BUILD_DIR)/complex.a \ + $(BUILD_DIR)/complex_module.a \ + $(BUILD_DIR)/adjoint_forward.a \ + $(BUILD_DIR)/adjoint_forward_module.a \ + $(BUILD_DIR)/adjoint_backward.a \ + $(BUILD_DIR)/qlapack.a \ + $(BUILD_DIR)/common.a \ + $(BUILD_DIR)/common_module.a \ + $(BUILD_DIR)/pfapack.a \ + -J $(MODULE_DIR) \ + $(LINK_LIBS) \ + -o $(TARGET) + +################################################################################ + +# Generic rule for compiling Fortran files +$(MAIN_BUILD_DIR)/%.f90.o: %.f90 + + $(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + @echo "\e[31m Compiling $< with aggressive optimization\e[0m", \ + @echo "\e[32m Compiling $<\e[0m" \ + ) + + $(eval FCFLAGS_SPECIAL=$(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + $(FCFLAGS_AGGRESSIVE), \ + $(FCFLAGS_PASSIVE)) \ + ) + + $(FC) $(FCFLAGS) $(FCFLAGS_SPECIAL) \ + $(MODULE_STORE) $(MODULE_DIR) \ + $(MODULE_INCLUDE) $(MODULE_DIR) \ + -c $< -o $@ + +# Generic rule for compiling C files +$(MAIN_BUILD_DIR)/%.c.o: %.c + @echo "\e[32m Compiling $<\e[0m" + $(CC) $(CFLAGS) -c $< -o $(SUFFIX) + +# Cleaning everything +clean: + rm -rf $(BUILD_DIR) + +.PHONY: all dirs clean + diff --git a/src/b_complex/Makefile b/src/b_complex/Makefile new file mode 100644 index 0000000..7b77032 --- /dev/null +++ b/src/b_complex/Makefile @@ -0,0 +1,84 @@ +# Load settings + +include ../../make.inc + +# Variables + +SRC_DIR := . +COMPLEX_BUILD_DIR := $(BUILD_DIR)/complex +MODULE_DIR := $(BUILD_DIR)/modules +TARGET := $(BUILD_DIR)/complex.a +TARGET_MODULES := $(BUILD_DIR)/complex_module.a + +# File Lists +# +# First set modules: + +MODULE_SRCS := $(SRC_DIR)/convertmod.f90 + +MODULE_OBJS := $(MODULE_SRCS:%=$(COMPLEX_BUILD_DIR)/%.o) +MODULE_MODS := $(MODULE_SRCS:%=$(BUILD_DIR)/%.mod) + +# Set rest files +SRCS := $(wildcard $(SRC_DIR)/*.f90) +SRCS += $(wildcard $(SRC_DIR)/*.c) +SRCS := $(filter-out $(MODULE_SRCS), $(SRCS)) +OBJS := $(SRCS:%=$(COMPLEX_BUILD_DIR)/%.o) + +# Default rule +all: dirs $(TARGET) + +# Rule for making the build directory +dirs: + mkdir -p $(COMPLEX_BUILD_DIR) + mkdir -p $(MODULE_DIR) + echo $(MODULE_OBJ) + +# Compile modules +$(COMPLEX_BUILD_DIR)/%.f90.o: %.f90 + $(FC) $(FCFLAGS) \ + $(MODULE_STORE) $(MODULE_DIR) \ + $(MODULE_INCLUDE) $(MODULE_DIR) \ + -c $< -o $@ + +# Common module +$(TARGET_MODULES): $(MODULE_OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(AR) $(ARFLAGS) $(TARGET_MODULES) $(MODULE_OBJS) + +# Rule for making the target +$(TARGET): $(TARGET_MODULES) $(OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(AR) $(ARFLAGS) $(TARGET) $(OBJS) $(TARGET_MODULES) + +################################################################################ + +# Generic rule for compiling Fortran files +$(COMPLEX_BUILD_DIR)/%.f90.o: %.f90 + + $(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + @echo "\e[31m Compiling $< with aggressive optimization\e[0m", \ + @echo "\e[32m Compiling $<\e[0m" \ + ) + + $(eval FCFLAGS_SPECIAL=$(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + $(FCFLAGS_AGGRESSIVE), \ + $(FCFLAGS_PASSIVE)) \ + ) + + $(FC) $(FCFLAGS) $(FCFLAGS_SPECIAL) \ + $(MODULE_STORE) $(MODULE_DIR) \ + $(MODULE_INCLUDE) $(MODULE_DIR) \ + -c $< -o $@ + +# Generic rule for compiling C files +$(COMPLEX_BUILD_DIR)/%.c.o: %.c + @echo "\e[32m Compiling $<\e[0m" + $(CC) $(CFLAGS) -c $< -o $@ + +# Cleaning everything +clean: + rm -rf $(BUILD_DIR) + +.PHONY: all dirs clean + diff --git a/src/c_adjoint_backward/Makefile b/src/c_adjoint_backward/Makefile new file mode 100644 index 0000000..51b4534 --- /dev/null +++ b/src/c_adjoint_backward/Makefile @@ -0,0 +1,62 @@ +# Load settings + +include ../../make.inc + +# Variables + +SRC_DIR := . +ADJOINT_BACKWARD_BUILD_DIR := $(BUILD_DIR)/adjoint_backward +MODULE_DIR := $(BUILD_DIR)/modules +TARGET := $(BUILD_DIR)/adjoint_backward.a + +# File Lists +# +# First set modules: + +# Set rest files +SRCS := $(wildcard $(SRC_DIR)/*.f90) +OBJS := $(SRCS:%=$(ADJOINT_BACKWARD_BUILD_DIR)/%.o) + +# Default rule +all: dirs $(TARGET) + +# Rule for making the build directory +dirs: + mkdir -p $(ADJOINT_BACKWARD_BUILD_DIR) + mkdir -p $(MODULE_DIR) + echo $(MODULE_OBJ) + +# Rule for making the target +$(TARGET): $(TARGET_MODULES) $(OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(AR) $(ARFLAGS) $(TARGET) $(OBJS) $(TARGET_MODULES) + +# Generic rule for compiling Fortran files +$(ADJOINT_BACKWARD_BUILD_DIR)/%.f90.o: %.f90 + + $(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + @echo "\e[31m Compiling $< with aggressive optimization\e[0m", \ + @echo "\e[32m Compiling $<\e[0m" \ + ) + + $(eval FCFLAGS_SPECIAL=$(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + $(FCFLAGS_AGGRESSIVE), \ + $(FCFLAGS_PASSIVE)) \ + ) + + $(FC) $(FCFLAGS) $(FCFLAGS_SPECIAL) \ + $(MODULE_STORE) $(MODULE_DIR) \ + $(MODULE_INCLUDE) $(MODULE_DIR) \ + -c $< -o $@ + +# Generic rule for compiling C files +$(ADJOINT_BACKWARD_BUILD_DIR)/%.c.o: %.c + @echo "\e[30m Compiling $<\e[0m" + $(CC) $(CFLAGS) -c $< -o $@ + +# Cleaning everything +clean: + rm -rf $(BUILD_DIR) + +.PHONY: all dirs clean + diff --git a/src/c_adjoint_forward/Makefile b/src/c_adjoint_forward/Makefile new file mode 100644 index 0000000..891a98f --- /dev/null +++ b/src/c_adjoint_forward/Makefile @@ -0,0 +1,84 @@ +# Load settings + +include ../../make.inc + +# Variables + +SRC_DIR := . +ADJOINT_FORWARD_BUILD_DIR := $(BUILD_DIR)/adjoint_forward +MODULE_DIR := $(BUILD_DIR)/modules +TARGET := $(BUILD_DIR)/adjoint_forward.a +TARGET_MODULES := $(BUILD_DIR)/adjoint_forward_module.a + +# File Lists +# +# First set modules: + +MODULE_SRCS := $(SRC_DIR)/dspev_drv.f90 + +MODULE_OBJS := $(MODULE_SRCS:%=$(ADJOINT_FORWARD_BUILD_DIR)/%.o) +MODULE_MODS := $(MODULE_SRCS:%=$(BUILD_DIR)/%.mod) + +# Set rest files +SRCS := $(wildcard $(SRC_DIR)/*.f90) +SRCS += $(wildcard $(SRC_DIR)/*.c) +SRCS := $(filter-out $(MODULE_SRCS), $(SRCS)) +OBJS := $(SRCS:%=$(ADJOINT_FORWARD_BUILD_DIR)/%.o) + +# Default rule +all: dirs $(TARGET) + +# Rule for making the build directory +dirs: + mkdir -p $(ADJOINT_FORWARD_BUILD_DIR) + mkdir -p $(MODULE_DIR) + echo $(MODULE_OBJ) + +# Compile modules +$(ADJOINT_FORWARD_BUILD_DIR)/%.f90.o: %.f90 + $(FC) $(FCFLAGS) \ + $(MODULE_STORE) $(MODULE_DIR) \ + $(MODULE_INCLUDE) $(MODULE_DIR) \ + -c $< -o $@ + +# Common module +$(TARGET_MODULES): $(MODULE_OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(AR) $(ARFLAGS) $(TARGET_MODULES) $(MODULE_OBJS) + +# Rule for making the target +$(TARGET): $(TARGET_MODULES) $(OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(AR) $(ARFLAGS) $(TARGET) $(OBJS) $(TARGET_MODULES) + +################################################################################ + +# Generic rule for compiling Fortran files +$(ADJOINT_FORWARD_BUILD_DIR)/%.f90.o: %.f90 + + $(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + @echo "\e[31m Compiling $< with aggressive optimization\e[0m", \ + @echo "\e[32m Compiling $<\e[0m" \ + ) + + $(eval FCFLAGS_SPECIAL=$(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + $(FCFLAGS_AGGRESSIVE), \ + $(FCFLAGS_PASSIVE)) \ + ) + + $(FC) $(FCFLAGS) $(FCFLAGS_SPECIAL) \ + $(MODULE_STORE) $(MODULE_DIR) \ + $(MODULE_INCLUDE) $(MODULE_DIR) \ + -c $< -o $@ + +# Generic rule for compiling C files +$(ADJOINT_FORWARD_BUILD_DIR)/%.c.o: %.c + @echo "\e[30m Compiling $<\e[0m" + $(CC) $(CFLAGS) -c $< -o $@ + +# Cleaning everything +clean: + rm -rf $(BUILD_DIR) + +.PHONY: all dirs clean + diff --git a/src/c_adjoint_forward/compute_fast.f90 b/src/c_adjoint_forward/compute_fast.f90 index 144cb94..1111047 100644 --- a/src/c_adjoint_forward/compute_fast.f90 +++ b/src/c_adjoint_forward/compute_fast.f90 @@ -1,20 +1,26 @@ !TL off -subroutine compute_eloc_logpsi(indt, indt4, indt4j, nelorb, nelup, neldo& - &, tabpip, kelind, kel, winv, winvup, winvdo, ainv, ainvup, ainvdo, psip & - &, ipsip, wconfn, psisn, iesdr, vj, dd & - &, zeta, rion, dist, ioccup, ioccdo, ioptorb & - &, nshell, nshelldo, ivic, alat, plat, vpot, tmu& - &, nion, r, rmu, kion, iond, winvj, ioccj, kionj, vju, nelorbj & - &, ioptorbj, nshellj, winvbar, detmat, winvjbar, winvjbarsz, jasmat & - &, jasmatsz, muj_c, jasmat_c, jasmatsz_c, contractionj, nelorbj_c, iessz, cnorm, iflag, ncore, lmax & - &, nintpseudo, prefactor, rcutoff, parshell & - &, nparpshell, kindion, pshell, wpseudo, legendre, versor, wintpseudo & - &, jpseudo, pseudolocal, istart, costz, costz3& - &, angle, indtm, LBox, rmucos, rmusin, oldkappa, vpotreg, cutreg & - &, psidetln, walker, nelorbh, nelorbjh, niesd& - &, iond_cart, mu_c, detmat_c, projm, yesprojm, nelorb_c, firstmol, nmol, yesfast, eloc, logpsi& - &, nelorbjmax, neldomax, indtmax, nshelljmax, cellscalen& - &, indpar_tab, indorb_tab, indshell_tab, indparj_tab, indorbj_tab, indshellj_tab) +subroutine compute_eloc_logpsi(indt, indt4, indt4j, nelorb, nelup, neldo & + &, tabpip, kelind, kel, winv, winvup, winvdo, ainv & + &, ainvup, ainvdo, psip, ipsip, wconfn, psisn, iesdr, vj, dd & + &, zeta, rion, dist, ioccup, ioccdo, ioptorb & + &, nshell, nshelldo, ivic, alat, plat, vpot, tmu & + &, nion, r, rmu, kion, iond, winvj, ioccj, kionj, vju, nelorbj& + &, ioptorbj, nshellj, winvbar & + &, detmat, winvjbar, winvjbarsz, jasmat & + &, jasmatsz, muj_c, jasmat_c, jasmatsz_c, contractionj & + &, nelorbj_c, iessz, cnorm, iflag, ncore, lmax & + &, nintpseudo, prefactor, rcutoff, parshell & + &, nparpshell, kindion, pshell, wpseudo & + &, legendre, versor, wintpseudo & + &, jpseudo, pseudolocal, istart, costz, costz3 & + &, angle, indtm, LBox, rmucos, rmusin, oldkappa & + &, vpotreg, cutreg & + &, psidetln, walker, nelorbh, nelorbjh, niesd & + &, iond_cart, mu_c, detmat_c, projm & + &, yesprojm, nelorb_c, firstmol, nmol, yesfast, eloc, logpsi & + &, nelorbjmax, neldomax, indtmax, nshelljmax, cellscalen & + &, indpar_tab, indorb_tab, indshell_tab, indparj_tab & + &, indorbj_tab, indshellj_tab) ! NB here yesfast and yesfastj DO NOT necessarily coincide with global ! variables contraction and contractionj in the main, respectively ! (>0 if contracted orbitals are used). @@ -29,25 +35,33 @@ subroutine compute_eloc_logpsi(indt, indt4, indt4j, nelorb, nelup, neldo& #endif use Ewald use Cell - use Constants, only : yes_ontarget,ip4, zzero, zone, nbdgetri, ipc, ipj, ipf, pi, two_pi - use allio, only : yes_complex, jastrowall_ei, jastrowall_ee, & - &winvfn, nel2wtfn, winvbarfn, nel2barfn, itestrfn, psiln, contraction, & - &test_aad, iespbc, pseudologic, iesrandoml, rank, versoralat, singdet, & - &epscuttype, iflagnorm, agp, agpn, itest, pointvj, nelup_mat, nel_mat, ndiff& - &, n_body_on, gamma, lrdmc_der, lrdmc_nonodes, molecular, npar_eagp, eagp_pfaff,timings,cutweight,true_wagner,npow,membig,membigcpu,count_zerowf,count_allwf,yes_crystalj,nelsquare,vpotsav_ee,yes_sparse,nnozeroj,nelorbjh2,nozeroj, norm_metric + use Constants, only : yes_ontarget,ip4, zzero, zone, nbdgetri& + &, ipc, ipj, ipf, pi, two_pi + use allio, only : yes_complex, jastrowall_ei, jastrowall_ee, & + &winvfn, nel2wtfn, winvbarfn, nel2barfn, itestrfn & + &, psiln, contraction, test_aad, iespbc, pseudologic & + &, iesrandoml, rank, versoralat, singdet, epscuttype & + &, iflagnorm, agp, agpn, itest, pointvj, nelup_mat, nel_mat & + &, ndiff, n_body_on, gamma, lrdmc_der, lrdmc_nonodes & + &, molecular, npar_eagp, eagp_pfaff, timings, cutweight & + &, true_wagner, npow, membig, membigcpu & + &,count_zerowf,count_allwf,yes_crystalj,nelsquare,vpotsav_ee & + &,yes_sparse,nnozeroj,nelorbjh2,nozeroj, norm_metric implicit none - integer nelup, nelused, neldo, nel, i, j, k, ierr, j1, j2, info, ispin, indt4, indt4j& - &, iesd, iesdr, iesdr2iesd, nelorb, nelorbj, nion & - &, kk, jj, nshell, nshelldo, indt, nelorb5, nelorbj5 & - &, iflag, ncore, lmax, istart, nintpseudo& - &, psidetsn, walker, firstmmu, firstmdet& - &, nelorbh, nelorbjh, niesd, signold, signnew, nelorb_c, firstmol, nmol, yesfast& - &, ind1, ind2, ind3, ind4, ind5, ind6, isdistp, ip5, sizework1& - &, sizewsz, nelorbjmax, neldomax, indtmax, nshellj, nshelljmax, nelorbj_c& - &, nshellh, nshelljh, nshelldoh, nmolipf, nmolshift, nelup1, zerop1& - &, contractionj, nelorbjc, nelorbjcp, wf_sign, nelorbju, indexi, indexj, istartu& - &, indpfaff,ix,iy + integer nelup, nelused, neldo, nel, i, j, k, ierr, j1, j2, info & + &, ispin, indt4, indt4j, iesd, iesdr, iesdr2iesd, nelorb & + &, nelorbj, nion, kk, jj, nshell, nshelldo, indt, nelorb5 & + &, nelorbj5, iflag, ncore, lmax, istart, nintpseudo & + &, psidetsn, walker, firstmmu, firstmdet & + &, nelorbh, nelorbjh, niesd, signold, signnew, nelorb_c & + &, firstmol, nmol, yesfast , ind1, ind2, ind3, ind4 & + &, ind5, ind6, isdistp, ip5, sizework1 & + &, sizewsz, nelorbjmax, neldomax, indtmax, nshellj & + &, nshelljmax, nelorbj_c , nshellh, nshelljh, nshelldoh & + &, nmolipf, nmolshift, nelup1, zerop1, contractionj & + &, nelorbjc, nelorbjcp, wf_sign, nelorbju, indexi, indexj & + &, istartu, indpfaff, ix, iy integer ioccup(*), ioccdo(*), ioptorb(*), ioptorbj(*)& &, kion(*), kionj(*)& diff --git a/src/d_qlapack/Makefile b/src/d_qlapack/Makefile new file mode 100644 index 0000000..8ff6f1d --- /dev/null +++ b/src/d_qlapack/Makefile @@ -0,0 +1,52 @@ +# Load settings + +include ../../make.inc + +# Variables + +SRC_DIR := . +QLAPACK_BUILD_DIR := $(BUILD_DIR)/qlapack +MODULE_DIR := $(BUILD_DIR)/modules +TARGET := $(BUILD_DIR)/qlapack.a + +# Set rest files +SRCS := $(wildcard $(SRC_DIR)/*.f) +OBJS := $(SRCS:%=$(QLAPACK_BUILD_DIR)/%.o) + +# Default rule +all: dirs $(TARGET) + +# Rule for making the build directory +dirs: + mkdir -p $(QLAPACK_BUILD_DIR) + echo $(OBJS) + +# Generic rule for compiling Fortran files +$(QLAPACK_BUILD_DIR)/%.f.o: %.f + + $(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + @echo "\e[31m Compiling $< with aggressive optimization\e[0m", \ + @echo "\e[32m Compiling $<\e[0m" \ + ) + + $(eval FCFLAGS_SPECIAL=$(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + $(FCFLAGS_AGGRESSIVE), \ + $(FCFLAGS_PASSIVE)) \ + ) + + $(FC) $(FCFLAGS) $(FCFLAGS_SPECIAL) \ + $(MODULE_STORE) $(MODULE_DIR) \ + $(MODULE_INCLUDE) $(MODULE_DIR) \ + -c $< -o $@ + +# Rule for making the target +$(TARGET): $(OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(AR) $(ARFLAGS) $(TARGET) $(OBJS) + +# Cleaning everything +clean: + rm -rf $(BUILD_DIR) + +.PHONY: all dirs clean + diff --git a/src/m_common/Makefile b/src/m_common/Makefile new file mode 100644 index 0000000..9ee1c2c --- /dev/null +++ b/src/m_common/Makefile @@ -0,0 +1,92 @@ +# Load settings + +include ../../make.inc +include ../../make.txt + +# Variables + +SRC_DIR := . +COMMON_BUILD_DIR := $(BUILD_DIR)/common +COMMON_MODULES_BUILD_DIR := $(BUILD_DIR)/common +MODULE_DIR := $(BUILD_DIR)/modules +TARGET := $(BUILD_DIR)/common.a +TARGET_MODULES := $(BUILD_DIR)/common_module.a + +# File Lists +# +# First set modules: + +MODULE_SRCS := $(SRC_DIR)/constants.f90 \ + $(SRC_DIR)/symmetries.f90 \ + $(SRC_DIR)/cell.f90 \ + $(SRC_DIR)/dielectric.f90 \ + $(SRC_DIR)/ewald.f90 \ + $(SRC_DIR)/types.f90 \ + $(SRC_DIR)/kpoints.f90 \ + $(SRC_DIR)/mod_IO.f90 \ + $(SRC_DIR)/mod_extpot.f90 \ + $(SRC_DIR)/sub_comm.f90 \ + $(SRC_DIR)/mpiio.f90 \ + $(SRC_DIR)/kind.f90 \ + $(SRC_DIR)/allio.f90 \ + +MODULE_OBJS := $(MODULE_SRCS:%=$(COMMON_MODULES_BUILD_DIR)/%.o) +MODULE_MODS := $(MODULE_SRCS:%=$(BUILD_DIR)/%.mod) + +# Set rest files +SRCS := $(wildcard $(SRC_DIR)/*.f90) +SRCS += $(wildcard $(SRC_DIR)/*.c) +SRCS := $(filter-out $(MODULE_SRCS), $(SRCS)) +OBJS := $(SRCS:%=$(COMMON_BUILD_DIR)/%.o) + +# Default rule +all: dirs $(TARGET) + +# Rule for making the build directory +dirs: + mkdir -p $(COMMON_BUILD_DIR) + mkdir -p $(COMMON_MODULES_BUILD_DIR) + mkdir -p $(MODULE_DIR) + +# Common module +$(TARGET_MODULES): $(MODULE_OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(AR) $(ARFLAGS) $(TARGET_MODULES) $(MODULE_OBJS) + +# Rule for making the target +$(TARGET): $(TARGET_MODULES) $(OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(AR) $(ARFLAGS) $(TARGET) $(OBJS) $(TARGET_MODULES) + +################################################################################ + +# Generic rule for compiling Fortran files +$(COMMON_BUILD_DIR)/%.f90.o: %.f90 + + $(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + @echo "\e[31m Compiling $< with aggressive optimization\e[0m", \ + @echo "\e[32m Compiling $<\e[0m" \ + ) + + $(eval FCFLAGS_SPECIAL=$(if $(filter $<, $(SOURCES_AGGRESSIVE)), \ + $(FCFLAGS_AGGRESSIVE), \ + $(FCFLAGS_PASSIVE)) \ + ) + + $(FC) $(FCFLAGS) $(FCFLAGS_SPECIAL) \ + $(MODULE_STORE) $(MODULE_DIR) \ + $(MODULE_INCLUDE) $(MODULE_DIR) \ + -c $< -o $@ + +# Generic rule for compiling C files +$(COMMON_BUILD_DIR)/%.c.o: %.c + @echo "\e[32m Compiling $<\e[0m" + $(CC) $(CFLAGS) \ + -c $< -o $@ + +# Cleaning everything +clean: + rm -rf $(BUILD_DIR) + +.PHONY: all dirs clean + diff --git a/src/m_pfapack/Makefile b/src/m_pfapack/Makefile new file mode 100644 index 0000000..45e69a9 --- /dev/null +++ b/src/m_pfapack/Makefile @@ -0,0 +1,37 @@ +# Load settings + +include ../../make.inc + +# Variables + +PFAPACK_SRC_DIR := . +PFAPACK_BUILD_DIR := $(BUILD_DIR)/pfapack +TARGET := $(BUILD_DIR)/pfapack.a + +# File Lists +SRCS := $(wildcard $(PFAPACK_SRC_DIR)/*.f) +OBJS := $(SRCS:%=$(PFAPACK_BUILD_DIR)/%.o) + +# Default rule +all: dirs $(TARGET) + +# Rule for making the build directory +dirs: + mkdir -p $(PFAPACK_BUILD_DIR) + +# Rule for making the target +$(TARGET): $(OBJS) + @echo "\e[34m Linking $(notdir $(TARGET))\e[0m" + $(AR) $(ARFLAGS) $(TARGET) $(OBJS) + +# Generic rule for compiling Fortran files +$(PFAPACK_BUILD_DIR)/%.f.o: %.f + @echo "\e[31m Compiling $< with aggressive optimization\e[0m" + $(FC) $(FCFLAGS) $(FCFLAGS_AGGRESSIVE) -c $< -o $@ + +# Cleaning everything +clean: + rm -rf $(PFAPACK_BUILD_DIR) + +.PHONY: all dirs clean +