Last active
March 25, 2020 19:01
-
-
Save BinWang0213/29a15dc143dec8d007bec628cd6d476b to your computer and use it in GitHub Desktop.
Calculix 2.13 install on REHL 6.5 SuperMike II Cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#PBS -A hpc_cdss01 | |
#PBS -q workq | |
#PBS -l nodes=2:ppn=16 | |
#PBS -l walltime=30:00:00 | |
#PBS -V | |
#PBS -j oe | |
#PBS -N TransmissionLine | |
#-----------------Environment setup--------------------- | |
#Load libraries | |
module load gcc/6.4.0 | |
module unload mpich/3.2/INTEL-18.0.0 | |
module load petsc/3.9.2/INTEL-180-MVAPICH2-2.2 | |
module load mvapich2/2.2/INTEL-18.0.0 | |
#Set libraries include path | |
export PROJECT=/project/cs16/tma5/Calculix_Precice | |
export PROGSDIR=$PROJECT/build | |
export PATH=$PROGSDIR/bin:$PATH | |
export LD_LIBRARY_PATH=$PROGSDIR/lib:$LD_LIBRARY_PATH | |
export INCLUDE=$PROGSDIR/include:$INCLUDE | |
export LDFLAGS="-L$PROGSDIR/lib" | |
export CPPFLAGS="-I$PROGSDIR/include" | |
export MY_LIB=$PROGSDIR/lib | |
export MY_INCLUDE=$PROGSDIR/include | |
export HOME_BUILD=$PROJECT | |
export BOOST_ROOT=$PROJECT/boost_1_66_0/build | |
export LIBRARY_PATH=$BOOST_ROOT/lib:$LIBRARY_PATH | |
export LD_LIBRARY_PATH=$BOOST_ROOT/lib:$LD_LIBRARY_PATH | |
export CPLUS_INCLUDE_PATH=$BOOST_ROOT/include:$CPLUS_INCLUDE_PATH | |
export PRECICE_ROOT=$PROJECT/precice-1.3.0/ | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PRECICE_ROOT/build/last/ | |
export PATH=/project/cs16/tma5/calculix-adapter-foam/bin:$PATH | |
export WORKCALX=/ddnB/work/tma5/run/ | |
#--------------------Run example--------------------- | |
export OMP_NUM_THREADS=16 | |
cd /work/tma5/run/CalxFoam/test | |
ccx_CalxFOAM -i tower -Calxfoam-participant Calculix > log.Tower 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Using node for faster compile | |
qsub -I -l nodes=2:ppn=16,walltime=00:120:00 -q workq -A hpc_cdss01 | |
# Create an Define project dir | |
cd /project/cs16/tma5/ | |
mkdir Calculix_Precice | |
cd Calculix_Precice | |
export PROJECT=/project/cs16/tma5/Calculix_Precice | |
#export PROJECT=/home/bwang31/Calculix | |
### Step1. CCX 2.13 with pardiso and spooles | |
#------------------------------------------ | |
# You will need gcc-fortran, cpio, freeglut, glu | |
cd $PROJECT | |
export PROGSDIR=$PROJECT/build | |
export PATH=$PROGSDIR/bin:$PATH | |
export LD_LIBRARY_PATH=$PROGSDIR/lib:$LD_LIBRARY_PATH | |
export INCLUDE=$PROGSDIR/include:$INCLUDE | |
export LDFLAGS="-L$PROGSDIR/lib" | |
export CPPFLAGS="-I$PROGSDIR/include" | |
export MY_LIB=$PROGSDIR/lib | |
export MY_INCLUDE=$PROGSDIR/include | |
export HOME_BUILD=$PWD | |
mkdir -p $PROGSDIR | |
mkdir -p $PROGSDIR/bin | |
mkdir -p $PROGSDIR/lib | |
mkdir -p $PROGSDIR/doc | |
mkdir -p $PROGSDIR/include | |
module load gcc/6.4.0 | |
#Download Calculix 2.13, ARPACK and SPOOLES 2.2 | |
git clone https://github.com/luvres/calculix.git | |
cd calculix && rm -r CalculiX CalculiX.12 ccx_2.14* ccx_2.12* cgx_2.14* cgx_2.12* | |
cp -a . $PROJECT | |
cd .. && rm -r calculix | |
## Spooles as solver for CCX | |
#----------------------------- | |
echo 'Building Spooles' | |
cd $PROJECT/SPOOLES.2.2 | |
#make lib > ../spooles_make.txt 2> ../spooles_error.txt | |
make lib -j 16 | |
cp spooles.a $PROGSDIR/lib | |
mkdir $PROGSDIR/include/spooles | |
find . -name '*.h' | cpio -updm $PROGSDIR/include/spooles | |
cd MT/src | |
#!! To make the multithreading -DUSEMT=1 works copy makeGlobalLib into makefile !! | |
#make > ../../../spoolesMT_make.txt 2> ../../../spoolesMT_error.txt | |
make | |
cp spoolesMT.a $PROGSDIR/lib | |
cp spoolesMT.a $PROJECT/SPOOLES.2.2 | |
cd .. | |
cp spoolesMT.h $PROGSDIR/include/spooles/MT | |
cp spoolesMT.h $PROJECT/SPOOLES.2.2 | |
cd ../.. | |
### Install ARPACK to support CalculiX | |
#-------------------------------------- | |
echo 'Building ARPACK' | |
cd $PROJECT/ARPACK | |
#make lib > ../ARPACK_make.txt 2> ../ARPACK_error.txt | |
make lib -j 16 | |
cp libarpack_linux.a $PROGSDIR/lib | |
cd .. | |
### CCX 2.13 with pardiso and spooles | |
#------------------------------------- | |
module load intel/18.0.0 | |
echo 'Installing CCX 2.13' | |
cd $PROJECT/CalculiX.13/ccx_2.13/src | |
#Replace makefile with pardiso one @ https://gist.github.com/BinWang0213/29a15dc143dec8d007bec628cd6d476b | |
#make -j 16 > $PROGSDIR/ccx_make.txt 2> $PROGSDIR/ccx_error.txt | |
make -j 16 | |
cp ccx_2.13 $PROGSDIR/bin | |
cp LOGBOOK $PROGSDIR/doc | |
##Check and run ccx | |
cd $PROGSDIR/bin | |
ccx_2.13 | |
### Step1. Precice 1.3.0 compile | |
#------------------------------------- | |
#build boost 1.66 | |
cd $PROJECT | |
wget -c https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz -O - | tar -xz | |
cd $PROJECT/boost_1_66_0 | |
mkdir build | |
./bootstrap.sh --without-libraries=python --prefix=$PROJECT/boost_1_66_0/build | |
./b2 -j16 install | |
#Replace old boost path | |
export BOOST_ROOT=$PROJECT/boost_1_66_0/build | |
export LIBRARY_PATH=$BOOST_ROOT/lib:$LIBRARY_PATH | |
export LD_LIBRARY_PATH=$BOOST_ROOT/lib:$LD_LIBRARY_PATH | |
export CPLUS_INCLUDE_PATH=$BOOST_ROOT/include:$CPLUS_INCLUDE_PATH | |
#build libxml2 (optional, /usr/include/libxml2 may already have this lib) | |
if [ -d "/usr/include/libxml2" ] | |
then | |
echo "Directory libxml2 exists." | |
else | |
cd $PROJECT | |
git clone https://gitlab.gnome.org/GNOME/libxml2.git | |
cd libxml2 | |
mkdir build | |
./autogen.sh --without-python --prefix=$PROJECT/libxml2/build | |
make | |
make install | |
fi | |
#Load and setup some libraries | |
module load eigen/3.2.3/INTEL-18.0.0 | |
module load petsc/3.9.2/INTEL-180-MVAPICH2-2.2 | |
module load cmake/3.7.2/INTEL-18.0.0 | |
module load python/3.6.4-anaconda | |
module display eigen/3.2.3/INTEL-18.0.0 | |
export EIGEN3_INCLUDE_DIR=/usr/local/packages/eigen/3.2.3/INTEL-18.0.0/include | |
export EIGEN3_VERSION_OK=3.2.3 | |
#build SCONS builder | |
cd $PROJECT | |
wget -c http://prdownloads.sourceforge.net/scons/scons-3.0.5.tar.gz -O - | tar -xz | |
cd scons-3.0.5 | |
mkdir $PROGSDIR/scons | |
python setup.py install --prefix=$PROGSDIR/scons | |
export PATH=$PATH:$PROGSDIR/scons/bin | |
#build precice | |
#https://github.com/precice/precice/wiki/Building:-using-SCons | |
#https://github.com/precice/precice/wiki/Dependencies/4b5cc49c5a6934b2a1d62ffd009b6cce1df8895c | |
cd $PROJECT | |
wget -c https://github.com/precice/precice/archive/v1.3.0.tar.gz -O - | tar -xz | |
export PRECICE_ROOT=$PROJECT/precice-1.3.0/ | |
cd $PRECICE_ROOT | |
#Replace SConstruct with | |
scons petsc=yes python=no -j 1 platform=hazelhen | |
### build yaml-cpp (optional) | |
cd $PROJECT | |
git clone https://github.com/jbeder/yaml-cpp.git | |
cd yaml-cpp | |
mkdir build | |
cd build | |
cmake ./.. | |
make | |
### Build calculix adaptor | |
#------------------------------------- | |
cd $PROJECT | |
git clone https://github.com/precice/calculix-adapter.git | |
cd calculix-adapter | |
git checkout 7278341 | |
cd $PROJECT/calculix-adapter | |
#Modify makefile as Makefile_Precice_Pardiso | |
make clean | |
make -j 16 | |
#testing | |
cd $PROJECT/calculix-adapter/bin | |
./ccx_preCICE | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This is makefile for compiling calculix with intel mkl pardiso | |
# Note that in order to run PARDISO with Multithreading, | |
# the environment variable OMP_NUM_THREADS needs to be set to | |
# the desired number of cpus, before compiling and before running ccx | |
# e.g. by entering | |
# >export OMP_NUM_THREADS=2 | |
# in terminal to run PARDISO with 2 cpus | |
# More info in ccx user manual section 2 | |
OPT = -O3 | |
CFLAGS = -Wall $(OPT) -L $(MY_LIB) -I $(MY_INCLUDE) -fopenmp -DARCH="Linux" -DPARDISO -DMATRIXSTORAGE -DUSE_MT=1 -DMKL_LP64 | |
FFLAGS = -Wall $(OPT) $(OPTIONS) -I$(MKL_INCLUDE) -fopenmp | |
#ARPACK | |
CFLAGS += -DARPACK | |
#SPOOLES | |
CFLAGS += -I $(MY_INCLUDE)/spooles -DSPOOLES | |
#BLAS and LAPACK | |
#CFLAGS+= -llpack -lblas | |
CC=gcc | |
FC=gfortran | |
OPTIONS = -w -fno-second-underscore -fcray-pointer -x f77-cpp-input | |
FPPSTOP= -x none | |
#INTEL MKL | |
MKL_LIB = /home/compilers/Intel/parallel_studio_xe_2018.0/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/ | |
MKL_INCLUDE = /home/compilers/Intel/parallel_studio_xe_2018.0/compilers_and_libraries_2018.0.128/linux/mkl/include/ | |
CMPLR_PATH = /home/compilers/Intel/parallel_studio_xe_2018.0/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/ | |
.c.o : | |
$(CC) $(CFLAGS) -c $< | |
.f.o : | |
$(FC) $(FFLAGS) -c $< | |
include Makefile.inc | |
SCCXMAIN = ccx_2.13.c | |
OCCXF = $(SCCXF:.f=.o) | |
OCCXC = $(SCCXC:.c=.o) | |
OCCXMAIN = $(SCCXMAIN:.c=.o) | |
LIBS = \ | |
$(MY_LIB)/libarpack_linux.a \ | |
$(MY_LIB)/spoolesMT.a \ | |
$(MY_LIB)/spooles.a \ | |
-lpthread -lm -lc | |
ccx_2.13: $(OCCXMAIN) ccx_2.13.a \ | |
./date.pl; $(CC) $(CFLAGS) -c ccx_2.13.c; \ | |
$(FC) $(OPT) $(FFLAGS) -o $@ $(FPPSTOP) $(OCCXMAIN) ccx_2.13.a $(LDFLAGS) $(LIBS)\ | |
-Wl,--start-group \ | |
$(MKL_LIB)/libmkl_gf_lp64.a \ | |
$(MKL_LIB)/libmkl_gnu_thread.a \ | |
$(MKL_LIB)/libmkl_core.a \ | |
-Wl,--end-group \ | |
-L$(CMPLR_PATH) -liomp5 -lpthread -lm -ldl -lc | |
ccx_2.13.a: $(OCCXF) $(OCCXC) | |
ar vr $@ $? | |
clean: | |
rm *.a *.o ccx_2.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Specify the locations of: the original CCX source, SPOOLES and ARPACK | |
CCX = $(PROJECT)/CalculiX.13/ccx_2.13/src | |
SPOOLES = $(PROJECT)/SPOOLES.2.2/ | |
ARPACK = $(PROJECT)/ARPACK | |
PRECICE_ROOT = $(PROJECT)/precice-1.3.0/ | |
YAML = $(PROJECT)/yaml-cpp | |
# Specify where to store the generated .o files | |
OBJDIR = bin | |
# Includes and libs | |
INCLUDES = \ | |
-I./ \ | |
-I./adapter \ | |
-I$(CCX) \ | |
-I$(SPOOLES) \ | |
-I$(PRECICE_ROOT)/src \ | |
-I$(ARPACK) \ | |
-I$(YAML)/include | |
LIBS = \ | |
$(SPOOLES)/spooles.a \ | |
-L$(PRECICE_ROOT)/build/last -lprecice \ | |
-lboost_log \ | |
-lboost_log_setup \ | |
-lboost_thread \ | |
-lboost_system \ | |
-lboost_filesystem \ | |
-lboost_program_options \ | |
-lstdc++ \ | |
-L$(PETSC_DIR)/lib -lpetsc \ | |
-L$(YAML)/build -lyaml-cpp \ | |
-lxml2 | |
# OS-specific options | |
UNAME_S := $(shell uname -s) | |
ifeq ($(UNAME_S),Darwin) | |
LIBS += $(ARPACK)/libarpack_MAC.a | |
else | |
LIBS += $(ARPACK)/libarpack_linux.a | |
LIBS += -lpthread -lm -lc | |
endif | |
# Compilers and flags | |
#CFLAGS = -g -Wall -std=c++11 -O0 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE | |
#FFLAGS = -g -Wall -O0 -fopenmp $(INCLUDES) | |
CFLAGS = -Wall -O3 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DUSE_MT=1 -DPARDISO -DMKL_LP64 | |
# OS-specific options | |
ifeq ($(UNAME_S),Darwin) | |
CC = /usr/local/bin/gcc | |
else | |
CC = gcc | |
endif | |
FFLAGS = -Wall -O3 -fopenmp $(INCLUDES) | |
#FC = mpifort | |
# FC = mpif90 | |
FC = gfortran | |
#INTEL MKL | |
MKL_LIB = /home/compilers/Intel/parallel_studio_xe_2018.0/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/ | |
MKL_INCLUDE = /home/compilers/Intel/parallel_studio_xe_2018.0/compilers_and_libraries_2018.0.128/linux/mkl/include/ | |
CMPLR_PATH = /home/compilers/Intel/parallel_studio_xe_2018.0/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/ | |
# Include a list of all the source files | |
include $(CCX)/Makefile.inc | |
SCCXMAIN = ccx_2.13.c | |
# Append additional sources | |
SCCXC += nonlingeo_Calxfoam.c nonlingeo_precice.c \ | |
CCXHelpers.c PreciceInterface.c \ | |
CalxfoamInterface.c DataReader.c map.c | |
SCCXF += getflux.f getkdeltatemp.f | |
# Source files in this folder and in the adapter directory | |
$(OBJDIR)/%.o : %.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : %.f | |
$(FC) $(FFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : adapter/%.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : adapter/%.cpp | |
g++ -std=c++11 -I$(YAML)/include -c $< -o $@ $(LIBS) | |
#$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ $(LIBS) | |
# Source files in the $(CCX) folder | |
$(OBJDIR)/%.o : $(CCX)/%.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : $(CCX)/%.f | |
$(FC) $(FFLAGS) -c $< -o $@ | |
# Generate list of object files from the source files, prepend $(OBJDIR) | |
OCCXF = $(SCCXF:%.f=$(OBJDIR)/%.o) | |
OCCXC = $(SCCXC:%.c=$(OBJDIR)/%.o) | |
OCCXMAIN = $(SCCXMAIN:%.c=$(OBJDIR)/%.o) | |
OCCXC += $(OBJDIR)/ConfigReader.o | |
OCCXC += $(OBJDIR)/ConfigReader.o | |
OCCXC += $(OBJDIR)/File_Reader.o | |
OCCXC += $(OBJDIR)/CalxfoamReader.o | |
$(OBJDIR)/ccx_CalxFOAM: $(OBJDIR) $(OCCXMAIN) $(OBJDIR)/ccx_2.13.a | |
$(FC) -fopenmp -Wall -O3 -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_2.13.a $(LDFLAGS) $(LIBS) \ | |
-Wl,--start-group \ | |
$(MKL_LIB)/libmkl_gf_lp64.a \ | |
$(MKL_LIB)/libmkl_gnu_thread.a \ | |
$(MKL_LIB)/libmkl_core.a \ | |
-Wl,--end-group \ | |
-L$(CMPLR_PATH) -liomp5 -lpthread -lm -ldl -lc | |
$(OBJDIR)/ccx_2.13.a: $(OCCXF) $(OCCXC) | |
ar vr $@ $? | |
$(OBJDIR): | |
mkdir -p $(OBJDIR) | |
clean: | |
rm -f $(OBJDIR)/*.o $(OBJDIR)/ccx_2.13.a $(OBJDIR)/ccx_CalxFOAM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Specify the locations of: the original CCX source, SPOOLES and ARPACK | |
CCX = $(PROJECT)/CalculiX.13/ccx_2.13/src | |
SPOOLES = $(PROJECT)/SPOOLES.2.2/ | |
ARPACK = $(PROJECT)/ARPACK | |
PRECICE_ROOT = $(PROJECT)/precice-1.3.0/ | |
YAML = $(PROJECT)/yaml-cpp | |
# Specify where to store the generated .o files | |
OBJDIR = bin | |
# Includes and libs | |
INCLUDES = \ | |
-I./ \ | |
-I./adapter \ | |
-I$(CCX) \ | |
-I$(SPOOLES) \ | |
-I$(PRECICE_ROOT)/src \ | |
-I$(ARPACK) \ | |
-I$(YAML)/include | |
LIBS = \ | |
$(SPOOLES)/spooles.a \ | |
-L$(PRECICE_ROOT)/build/last -lprecice \ | |
-lboost_log \ | |
-lboost_log_setup \ | |
-lboost_thread \ | |
-lboost_system \ | |
-lboost_filesystem \ | |
-lboost_program_options \ | |
-lstdc++ \ | |
-L$(PETSC_DIR)/lib -lpetsc \ | |
-L$(YAML)/build -lyaml-cpp \ | |
-lxml2 | |
# OS-specific options | |
UNAME_S := $(shell uname -s) | |
ifeq ($(UNAME_S),Darwin) | |
LIBS += $(ARPACK)/libarpack_MAC.a | |
else | |
LIBS += $(ARPACK)/libarpack_linux.a | |
LIBS += -lpthread -lm -lc | |
endif | |
# Compilers and flags | |
#CFLAGS = -g -Wall -std=c++11 -O0 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE | |
#FFLAGS = -g -Wall -O0 -fopenmp $(INCLUDES) | |
CFLAGS = -Wall -O3 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DUSE_MT=1 -DPARDISO -DMKL_LP64 | |
# OS-specific options | |
ifeq ($(UNAME_S),Darwin) | |
CC = /usr/local/bin/gcc | |
else | |
CC = gcc | |
endif | |
FFLAGS = -Wall -O3 -fopenmp $(INCLUDES) | |
#FC = mpifort | |
# FC = mpif90 | |
FC = gfortran | |
#INTEL MKL | |
MKL_LIB = /home/compilers/Intel/parallel_studio_xe_2018.0/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/ | |
MKL_INCLUDE = /home/compilers/Intel/parallel_studio_xe_2018.0/compilers_and_libraries_2018.0.128/linux/mkl/include/ | |
CMPLR_PATH = /home/compilers/Intel/parallel_studio_xe_2018.0/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/ | |
# Include a list of all the source files | |
include $(CCX)/Makefile.inc | |
SCCXMAIN = ccx_2.13.c | |
# Append additional sources | |
SCCXC += nonlingeo_precice.c CCXHelpers.c PreciceInterface.c | |
SCCXF += getflux.f getkdeltatemp.f | |
# Source files in this folder and in the adapter directory | |
$(OBJDIR)/%.o : %.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : %.f | |
$(FC) $(FFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : adapter/%.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : adapter/%.cpp | |
g++ -std=c++11 -I$(YAML)/include -c $< -o $@ $(LIBS) | |
#$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ $(LIBS) | |
# Source files in the $(CCX) folder | |
$(OBJDIR)/%.o : $(CCX)/%.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : $(CCX)/%.f | |
$(FC) $(FFLAGS) -c $< -o $@ | |
# Generate list of object files from the source files, prepend $(OBJDIR) | |
OCCXF = $(SCCXF:%.f=$(OBJDIR)/%.o) | |
OCCXC = $(SCCXC:%.c=$(OBJDIR)/%.o) | |
OCCXMAIN = $(SCCXMAIN:%.c=$(OBJDIR)/%.o) | |
OCCXC += $(OBJDIR)/ConfigReader.o | |
$(OBJDIR)/ccx_preCICE: $(OBJDIR) $(OCCXMAIN) $(OBJDIR)/ccx_2.13.a | |
$(FC) -fopenmp -Wall -O3 -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_2.13.a $(LDFLAGS) $(LIBS) \ | |
-Wl,--start-group \ | |
$(MKL_LIB)/libmkl_gf_lp64.a \ | |
$(MKL_LIB)/libmkl_gnu_thread.a \ | |
$(MKL_LIB)/libmkl_core.a \ | |
-Wl,--end-group \ | |
-L$(CMPLR_PATH) -liomp5 -lpthread -lm -ldl -lc | |
$(OBJDIR)/ccx_2.13.a: $(OCCXF) $(OCCXC) | |
ar vr $@ $? | |
$(OBJDIR): | |
mkdir -p $(OBJDIR) | |
clean: | |
rm -f $(OBJDIR)/*.o $(OBJDIR)/ccx_2.13.a $(OBJDIR)/ccx_preCICE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note that in order to run PARDISO with Multithreading, | |
# the environment variable OMP_NUM_THREADS needs to be set to | |
# the desired number of cpus, before compiling and before running ccx | |
# e.g. by entering | |
# >export OMP_NUM_THREADS=2 | |
# in terminal to run PARDISO with 2 cpus | |
# More info in ccx user manual section 2 | |
# Specify the locations of: the original CCX source, SPOOLES and ARPACK | |
CCX = $(PROJECT)/CalculiX.13/ccx_2.13/src | |
SPOOLES = $(PROJECT)/SPOOLES.2.2/ | |
ARPACK = $(PROJECT)/ARPACK | |
PRECICE_ROOT = $(PROJECT)/precice-1.3.0/ | |
YAML = $(PROJECT)/yaml-cpp | |
# Specify where to store the generated .o files | |
OBJDIR = bin | |
# -I$(SPOOLES) | |
# -I$(ARPACK) | |
# Includes and libs | |
# Includes and libs | |
INCLUDES = \ | |
-I./ \ | |
-I./adapter \ | |
-I$(CCX) \ | |
-I$(SPOOLES) \ | |
-I$(PRECICE_ROOT)/src \ | |
-I$(ARPACK) \ | |
-I$(YAML)/include | |
LIBS = \ | |
$(SPOOLES)/spooles.a \ | |
-L$(PRECICE_ROOT)/build/last -lprecice \ | |
-lboost_log \ | |
-lboost_log_setup \ | |
-lboost_thread \ | |
-lboost_system \ | |
-lboost_filesystem \ | |
-lboost_program_options \ | |
-lstdc++ \ | |
-L$(PETSC_DIR)/lib -lpetsc \ | |
-lmpi \ | |
-L$(YAML)/build -lyaml-cpp \ | |
-lxml2 | |
# OS-specific options | |
UNAME_S := $(shell uname -s) | |
ifeq ($(UNAME_S),Darwin) | |
LIBS += $(ARPACK)/libarpack_MAC.a | |
else | |
LIBS += $(ARPACK)/libarpack_linux.a | |
LIBS += -lpthread -lm -lc | |
endif | |
# Compilers and flags | |
#CFLAGS = -g -Wall -std=c++11 -O0 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE | |
#FFLAGS = -g -Wall -O0 -fopenmp $(INCLUDES) | |
CFLAGS = -Wall -O3 -fopenmp $(INCLUDES) -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE | |
# OS-specific options | |
ifeq ($(UNAME_S),Darwin) | |
CC = /usr/local/bin/gcc | |
else | |
CC = gcc | |
endif | |
FFLAGS = -Wall -O3 -fopenmp $(INCLUDES) | |
#FC = mpifort | |
# FC = mpif90 | |
FC = gfortran | |
# Include a list of all the source files | |
include $(CCX)/Makefile.inc | |
SCCXMAIN = ccx_2.13.c | |
# Append additional sources | |
SCCXC += nonlingeo_Calxfoam.c nonlingeo_precice.c \ | |
CCXHelpers.c PreciceInterface.c \ | |
CalxfoamInterface.c DataReader.c map.c | |
SCCXF += getflux.f getkdeltatemp.f | |
# Source files in this folder and in the adapter directory | |
$(OBJDIR)/%.o : %.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : %.f | |
$(FC) $(FFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : adapter/%.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : adapter/%.cpp | |
g++ -std=c++11 -I$(YAML)/include -c $< -o $@ $(LIBS) | |
#$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ $(LIBS) | |
# Source files in the $(CCX) folder | |
$(OBJDIR)/%.o : $(CCX)/%.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
$(OBJDIR)/%.o : $(CCX)/%.f | |
$(FC) $(FFLAGS) -c $< -o $@ | |
# Generate list of object files from the source files, prepend $(OBJDIR) | |
OCCXF = $(SCCXF:%.f=$(OBJDIR)/%.o) | |
OCCXC = $(SCCXC:%.c=$(OBJDIR)/%.o) | |
OCCXMAIN = $(SCCXMAIN:%.c=$(OBJDIR)/%.o) | |
OCCXC += $(OBJDIR)/ConfigReader.o | |
OCCXC += $(OBJDIR)/File_Reader.o | |
OCCXC += $(OBJDIR)/CalxfoamReader.o | |
$(OBJDIR)/ccx_CalxFOAM: $(OBJDIR) $(OCCXMAIN) $(OBJDIR)/ccx_2.13.a | |
$(FC) -fopenmp -Wall -O3 -o $@ $(OCCXMAIN) $(OBJDIR)/ccx_2.13.a $(LIBS) | |
$(OBJDIR)/ccx_2.13.a: $(OCCXF) $(OCCXC) | |
ar vr $@ $? | |
$(OBJDIR): | |
mkdir -p $(OBJDIR) | |
clean: | |
rm -f $(OBJDIR)/*.o $(OBJDIR)/ccx_2.13.a $(OBJDIR)/ccx_CalxFOAM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Corrected SCONS build file for precice 1.3.0 | |
import os | |
import subprocess | |
import sys | |
import sysconfig | |
from os.path import join | |
try: | |
import numpy | |
except ImportError: | |
pass | |
##################################################################### FUNCTIONS | |
def checkAdd(lib = None, header = None, usage = ""): | |
""" Checks for a library and/or header and appends it to env if not already appended. """ | |
usage = " (needed for " + usage + ") " if usage else "" | |
if lib and header: | |
if not conf.CheckLibWithHeader(lib, header = header, autoadd=0, language="C++"): | |
print("ERROR: Library '" + str(lib) + "' or header '" + str(header) + "'" + usage + "not found.") | |
Exit(1) | |
conf.env.AppendUnique(LIBS = [lib]) | |
elif lib: | |
if not conf.CheckLib(lib, autoadd=0, language="C++"): | |
print("ERROR: Library '" + str(lib) + "'" + usage + "not found!") | |
Exit(1) | |
conf.env.AppendUnique(LIBS = [lib]) | |
elif header: | |
if not conf.CheckCXXHeader(header): | |
print("ERROR: Header '" + str(header) + "'" + usage + "not found!") | |
Exit(1) | |
def print_options(vars): | |
""" Print all build option and if they have been modified from their default value. """ | |
for opt in vars.options: | |
try: | |
is_default = vars.args[opt.key] == opt.default | |
except KeyError: | |
is_default = True | |
vprint(opt.key, env[opt.key], is_default, opt.help) | |
def vprint(name, value, default=True, description = None): | |
""" Pretty prints an environment variabe with value and modified or not. """ | |
mod = "(default)" if default else "(modified)" | |
desc = " " + description if description else "" | |
print("{0:10} {1:10} = {2!s:8}{3}".format(mod, name, value, desc)) | |
def checkset_var(varname, default): | |
""" Checks if environment variable is set, use default otherwise and print the value. """ | |
var = os.getenv(varname) | |
if not var: | |
var = default | |
vprint(varname, var) | |
else: | |
vprint(varname, var, False) | |
return var | |
def get_real_compiler(compiler): | |
""" Gets the compiler behind the MPI compiler wrapper. """ | |
if compiler.startswith("mpi"): | |
try: | |
output = subprocess.check_output("%s -show" % compiler, shell=True) | |
except (OSError, subprocess.CalledProcessError) as e: | |
print("Error getting wrapped compiler from MPI compiler") | |
print("Command was:", e.cmd, "Output was:", e.output) | |
else: | |
return output.split()[0] | |
else: | |
return compiler | |
########################################################################## MAIN | |
vars = Variables(None, ARGUMENTS) | |
vars.Add(PathVariable("builddir", "Directory holding build files.", "build", PathVariable.PathAccept)) | |
vars.Add(EnumVariable('build', 'Build type', "Debug", allowed_values=('release', 'debug', 'Release', 'Debug'))) | |
vars.Add(PathVariable("libprefix", "Path prefix for libraries", "/usr", PathVariable.PathIsDir)) | |
vars.Add("compiler", "Compiler to use.", "mpicxx") | |
vars.Add(BoolVariable("mpi", "Enables MPI-based communication and running coupling tests.", True)) | |
vars.Add(BoolVariable("petsc", "Enable use of the Petsc linear algebra library.", True)) | |
vars.Add(BoolVariable("python", "Used for Python scripted solver actions.", False)) | |
vars.Add(BoolVariable("gprof", "Used in detailed performance analysis.", False)) | |
vars.Add(EnumVariable('platform', 'Special configuration for certain platforms', "none", allowed_values=('none', 'supermuc', 'hazelhen'))) | |
env = Environment(variables = vars, ENV = os.environ, tools = ["default", "textfile"]) | |
conf = Configure(env) # For checking libraries, headers, ... | |
Help(vars.GenerateHelpText(env)) | |
env.Append(CPPPATH = ['#src']) | |
print_options(vars) | |
if env["build"] == 'debug': | |
env["build"] = 'Debug' | |
print("WARNING: Lower-case build type 'debug' is deprecated, use 'Debug' instead!") | |
if env["build"] == 'release': | |
env["build"] = 'Release' | |
print("WARNING: Lower-case build type 'release' is deprecated, use 'Release' instead!") | |
prefix = env["libprefix"] | |
buildpath = join(env["builddir"], "") # Ensures to have a trailing slash | |
env.Append(LIBPATH = [('#' + buildpath)]) | |
env.Append(CCFLAGS= ['-Wall', '-Wextra', '-Wno-unused-parameter', '-std=c++11']) | |
# ====== PRECICE_VERSION number ====== | |
PRECICE_VERSION = "1.3.0" | |
# ====== Compiler Settings ====== | |
# Produce position independent code for dynamic linking | |
env.Append(CCFLAGS = ['-fPIC']) | |
real_compiler = get_real_compiler(env["compiler"]) | |
if real_compiler == 'icc': | |
env.AppendUnique(LIBPATH = ['/usr/lib/']) | |
env.Append(LIBS = ['stdc++']) | |
if env["build"] == 'debug': | |
env.Append(CCFLAGS = ['-align']) | |
elif env["build"] == 'release': | |
env.Append(CCFLAGS = ['-w', '-fast', '-align', '-ansi-alias']) | |
elif real_compiler == 'g++': | |
pass | |
elif real_compiler == "clang++": | |
env.Append(CCFLAGS= ['-Wsign-compare']) # sign-compare not enabled in Wall with clang. | |
elif real_compiler == "g++-mp-4.9": | |
# Some special treatment that seems to be necessary for Mac OS. | |
# See https://github.com/precice/precice/issues/2 | |
env.Append(LIBS = ['libstdc++.6']) | |
env.AppendUnique(LIBPATH = ['/opt/local/lib/']) | |
env.Replace(CXX = env["compiler"]) | |
env.Replace(CC = env["compiler"]) | |
if prefix is not "/usr": # explicitely add standard search paths | |
env.Append(CPPPATH = join( prefix, 'include')) | |
env.Append(LIBPATH = join( prefix, 'lib')) | |
if not conf.CheckCXX(): | |
Exit(1) | |
# ====== Build Directories ====== | |
if env["build"] == 'Debug': | |
# The Assert define does not actually switches asserts on/off, these are controlled by NDEBUG. | |
# It's kept in place for some legacy code. | |
env.Append(CCFLAGS = ['-g3', '-O0']) | |
env.Append(LINKFLAGS = ["-rdynamic"]) # Gives more informative backtraces | |
buildpath += "debug" | |
elif env["build"] == 'Release': | |
env.Append(CPPDEFINES = ['NDEBUG']) # Standard C++ macro which disables all asserts, also used by Eigen | |
env.Append(CCFLAGS = ['-O3']) | |
buildpath += "release" | |
# ====== libpthread ====== | |
checkAdd("pthread") | |
# ====== PETSc ====== | |
PETSC_VERSION_MAJOR = 0 | |
PETSC_VERSION_MINOR = 0 | |
if env["petsc"]: | |
PETSC_DIR = checkset_var("PETSC_DIR", "") | |
PETSC_ARCH = checkset_var("PETSC_ARCH", "") | |
if not env["mpi"]: | |
print("PETSc requires MPI to be enabled.") | |
Exit(1) | |
env.Append(CPPPATH = [join(prefix, PETSC_DIR, "include"), | |
join(prefix, PETSC_DIR, PETSC_ARCH, "include")]) | |
env.Append(LIBPATH = [join(prefix, PETSC_DIR, PETSC_ARCH, "lib"), | |
join(prefix, PETSC_DIR, "lib")]) | |
if env["platform"] == "NotUsed": | |
checkAdd("craypetsc_gnu_real") | |
else: | |
checkAdd("petsc") | |
# Set PETSC_VERSION to correct values | |
with open(PETSC_DIR + "/include/petscversion.h", "r") as versionfile: | |
for line in versionfile: | |
tokens = line.split() | |
try: | |
if tokens[1] == "PETSC_VERSION_MAJOR": | |
PETSC_VERSION_MAJOR = tokens[2] | |
if tokens[1] == "PETSC_VERSION_MINOR": | |
PETSC_VERSION_MINOR = tokens[2] | |
except IndexError: | |
continue | |
else: | |
env.Append(CPPDEFINES = ['PRECICE_NO_PETSC']) | |
buildpath += "-nopetsc" | |
# ====== Eigen ====== | |
env.Append(CPPPATH = join(prefix, 'include/eigen3')) | |
checkAdd(header = "Eigen/Dense", usage = "Eigen") | |
if env["build"] == "debug": | |
env.Append(CPPDEFINES = ['EIGEN_INITIALIZE_MATRICES_BY_NAN']) | |
# ====== Boost ====== | |
# Needed for correct linking on Hazel Hen | |
# Otherwise it would link partly to old system boost, partly to newer modules boost | |
if env["platform"] == "hazelhen": | |
env.Append(CPPPATH = join( os.environ['BOOST_ROOT'], 'include')) | |
env.Append(LIBPATH = join( os.environ['BOOST_ROOT'], 'lib')) | |
env.Append(CPPDEFINES= ['BOOST_ALL_DYN_LINK', | |
'BOOST_ASIO_ENABLE_OLD_SERVICES']) # Interfaces have changed in 1.66 | |
#https://stackoverflow.com/questions/16720195/mongo-c-client-library-doesnt-see-my-boost | |
#Order matters | |
checkAdd("boost_system") | |
checkAdd("boost_filesystem") | |
checkAdd("boost_atomic") | |
checkAdd("boost_date_time") | |
checkAdd("boost_regex") | |
checkAdd("boost_thread") | |
checkAdd("boost_chrono") | |
checkAdd("boost_log") | |
checkAdd("boost_log_setup") | |
checkAdd("boost_program_options") | |
checkAdd("boost_unit_test_framework") | |
checkAdd(header = 'boost/vmd/is_empty.hpp', usage = 'Boost Variadic Macro Data Library') | |
checkAdd(header = 'boost/geometry.hpp', usage = 'Boost Geometry Library') | |
checkAdd(header = 'boost/signals2.hpp', usage = 'Boost Signals2') | |
# ====== MPI ====== | |
if env["mpi"]: | |
if not conf.CheckCXXHeader("mpi.h"): | |
print("mpi.h not found. Maybe try 'compiler=mpicxx' or 'compiler=mpic++' as scons argument?") | |
Exit(1) | |
# Skip (deprecated) MPI C++ bindings. | |
env.Append(CPPDEFINES = ['MPICH_SKIP_MPICXX']) | |
elif not env["mpi"]: | |
env.Append(CPPDEFINES = ['PRECICE_NO_MPI']) | |
buildpath += "-nompi" | |
# ====== Python ====== | |
if env["python"]: | |
installation_scheme = sysconfig._get_default_scheme() | |
if installation_scheme is 'posix_local': # for ubuntu with python 2.7 posix_local scheme points to an empty include path, fix this by using posix_prefix. See https://stackoverflow.com/questions/48826123/why-do-include-paths-in-python2-and-python3-differ | |
installation_scheme = 'posix_prefix' | |
# Try to extract the default values for Python version and paths | |
pythonLibDefault = 'python'+str(sys.version_info.major)+'.'+str(sys.version_info.minor) | |
pythonLibPathDefault = sysconfig.get_config_var('LIBDIR') | |
pythonIncPathDefault = sysconfig.get_path('include', scheme=installation_scheme) | |
# Set the used values for Python version and paths, allowing the user to override them | |
pythonLib = checkset_var('PRECICE_PYTHON_LIB', pythonLibDefault) | |
pythonLibPath = checkset_var('PRECICE_PYTHON_LIB_PATH', pythonLibPathDefault) | |
pythonIncPath = checkset_var('PRECICE_PYTHON_INC_PATH', pythonIncPathDefault) | |
# Set the used path for NumPy. | |
# As a default value, it tries to get the information from the imported | |
# package. However, we only need the path to the C++ NumPy header. | |
# If the user specifies a different path, then there should not be an error here. | |
# An error will be triggered later by checkAdd(). | |
try: | |
numpyIncPathDefault = numpy.get_include() | |
except NameError: | |
print("WARNING: Python package numpy could not be imported by SCons. If you don't need the Python action interface, specify 'python=no'.") | |
numpyIncPathDefault = None | |
numpyIncPath = checkset_var('PRECICE_NUMPY_INC_PATH', numpyIncPathDefault) | |
# FIXME: Supresses NumPy deprecation warnings. Needs to converted to the newer API. | |
env.Append(CPPDEFINES = ['NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION']) | |
env.AppendUnique(CPPPATH = [pythonIncPath, numpyIncPath]) | |
env.AppendUnique(LIBPATH = [pythonLibPath]) | |
checkAdd(lib = pythonLib, header = "Python.h") | |
# Check for numpy header needs python header first to compile | |
checkAdd( header = ['Python.h', 'numpy/arrayobject.h'], usage = "NumPy") | |
else: | |
buildpath += "-nopython" | |
env.Append(CPPDEFINES = ['PRECICE_NO_PYTHON']) | |
# ====== GProf ====== | |
if env["gprof"]: | |
env.Append(CCFLAGS = ['-p', '-pg']) | |
env.Append(LINKFLAGS = ['-p', '-pg']) | |
buildpath += "-gprof" | |
# ====== Special Platforms ====== | |
if env["platform"] == "supermuc": | |
env.Append(CPPDEFINES = ['SuperMUC_WORK']) | |
elif env["platform"] == "NotUsed": | |
env.Append(LINKFLAGS = ['-dynamic']) # Needed for correct linking against boost.log | |
# ====== LibXML2 ====== | |
env.Append(CPPPATH = join(prefix, 'include/libxml2')) | |
checkAdd("xml2") | |
env = conf.Finish() # Used to check libraries | |
#--------------------------------------------- Define sources and build targets | |
(sourcesAllNoMain, sourcesMain, sourcesTests) = SConscript ( | |
'src/SConscript-linux', | |
variant_dir = buildpath, | |
duplicate = 0 | |
) | |
staticlib = env.StaticLibrary ( | |
target = buildpath + '/libprecice', | |
source = [sourcesAllNoMain] | |
) | |
env.Alias("staticlib", staticlib) | |
solib = env.SharedLibrary ( | |
target = buildpath + '/libprecice', | |
source = [sourcesAllNoMain] | |
) | |
env.Alias("solib", solib) | |
bin = env.Program ( | |
target = buildpath + '/binprecice', | |
source = [sourcesAllNoMain, | |
sourcesMain] | |
) | |
env.Alias("bin", bin) | |
tests = env.Program ( | |
target = buildpath + '/testprecice', | |
source = [sourcesAllNoMain, | |
sourcesTests] | |
) | |
env.Alias("tests", tests) | |
# Creates a symlink that always points to the latest build | |
symlink = env.Command( | |
target = "symlink", | |
source = None, | |
action = "ln -fns {0} {1}".format(os.path.split(buildpath)[-1], join(os.path.split(buildpath)[0], "last")) | |
) | |
# Substitute strings in version.hpp.in, save it as version.hpp | |
versions = env.Substfile( | |
"src/versions.hpp.in", | |
SUBST_DICT = { | |
"@preCICE_VERSION@" : PRECICE_VERSION, | |
"@PETSC_VERSION_MAJOR@" : PETSC_VERSION_MAJOR, | |
"@PETSC_VERSION_MINOR@" : PETSC_VERSION_MINOR} | |
) | |
Default(versions, solib, tests, symlink) | |
AlwaysBuild(versions, symlink) | |
print("Targets: " + ", ".join([str(i) for i in BUILD_TARGETS])) | |
print("Buildpath: " + buildpath) | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment