Skip to content

Commit

Permalink
Parallel version works as well
Browse files Browse the repository at this point in the history
  • Loading branch information
addman2 committed Dec 6, 2023
1 parent b93e20a commit 22d0bec
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
*.i90
*.mod

# Old build system files
make.inc
make.txt

# iOS
.DS_Store

Expand Down
40 changes: 28 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,28 @@ $(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/make.inc.examples/make.inc.example.gcc make.inc; \
echo "c"; \
else \
echo "n"; \
fi)
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

Expand All @@ -29,12 +45,12 @@ $(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/make.inc.examples/make.txt.example.gcc make.txt; \
echo "c"; \
else \
echo "n"; \
fi)
if [ "$$ans" = "y" ]; then \
cp devel_tools/configs/make.txt.example make.txt; \
echo "c"; \
else \
echo "n"; \
fi)

endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ SUFFIX=-serial.x

BUILD_DIR=/home/addman/Software/turborvb-rm/build-serial

# Setup compilers Fortran and C. Note that for MPI version Fortran compiler wrapper should be used.
# For this FC and CC variables are used respectively.
# Setup compilers Fortran and C. For this FC and CC variables are used respectively.

FC=gfortran
CC=gcc
Expand Down
85 changes: 85 additions & 0 deletions devel_tools/configs/make.inc.example.gccmpi
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
1 change: 1 addition & 0 deletions src/m_common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ MODULE_SRCS := $(SRC_DIR)/constants.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)
Expand Down

0 comments on commit 22d0bec

Please sign in to comment.