Skip to content

Instantly share code, notes, and snippets.

@BinWang0213
Last active June 13, 2023 08:56
Show Gist options
  • Save BinWang0213/ad7d225b20adced4f563c9d45685bee4 to your computer and use it in GitHub Desktop.
Save BinWang0213/ad7d225b20adced4f563c9d45685bee4 to your computer and use it in GitHub Desktop.

OpenFoam 2.4 install on SuperMike III with gcc8.5 and REHL8

#http://www.tfd.chalmers.se/~hani/wikis/haniWiki/index.php?title=Tips_and_tricks_/_FOAM_/_Installation

qsub -I -A hpc_hpc_cdss08 -V -l walltime=05:00:00,nodes=1:ppn=20

cd /project/cs16/tma5/RHEL8/
#Download and unpack
git clone https://github.com/OpenFOAM/OpenFOAM-2.4.x.git
git clone https://github.com/OpenFOAM/ThirdParty-2.4.x.git

cd ThirdParty-2.4.x

wget https://gforge.inria.fr/frs/download.php/file/34099/scotch_6.0.3.tar.gz
tar -zxf scotch_6.0.3.tar.gz


module purge
module load intel/2021.5.0
module load intel-mpi/2021.5.1

export MPI_ROOT=$I_MPI_ROOT

export WM_NCOMPPROCS=8
vi > OpenFOAM-2.4.x/etc/bashrc
FOAM_INST_DIR=/ddnA/project/cs16/tma5/RHEL8/OpenFOAM/bwtest/
export WM_COMPILER=Icc
export WM_MPLIB=INTELMPI

vi > etc/config/settings.sh
a. case $WM_ARCH in Linux 
	case `uname -m` in 
	> x86_64 
		case $WM_ARCH_OPTION in 
			i ) 32 
			ii) 64 
				> export WM_CC='icc' 
				> export WM_CXX='icpc' 
				> export WM_CFLAGS='-O2 -no-prec-div -m64 -fPIC'
				> export WM_CXXFLAGS='-O1 -no-prec-div -m64 -fPIC' 
b.INTELMPI)
    _foamAddPath    $MPI_ARCH_PATH/bin
    _foamAddLib     $MPI_ARCH_PATH/lib

vi > $WM_PROJECT_DIR/wmake/rules/linux64Icc/mplibINTELMPI
PINC       = -I$(MPI_ARCH_PATH)/include
PLIBS      = -L$(MPI_ARCH_PATH)/lib -lmpi

vi >  $WM_THIRD_PARTY_DIR/etc/wmakeFiles/scotch/Makefile.inc.i686_pc_linux2.shlib-OpenFOAM-64
>AR = icc
	>CCS = icc
	>CCP = mpicc
	>CFLAGS = $(WM_CFLAGS) -O3 -fPIC -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -Drestrict=__restrict -I$(MPI_ROOT)/include -L$(MPI_ROOT)/lib 
	
#fix aa flex error form ansys2foam, etc
find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1='

#Error1: ensight/part/ensightPart.C(54): error: identifier "isnan" is undefined Answer: https://gist.github.com/saifthe1/e1ac2db5b7d5d356da33

replace isnan by std::isnan @ /src/conversion/ensight/part/ensightPart.C

replace isnan by std::isnan @ /src/conversion/ensight/part/ensightPartIO.C

#Error2: SloanRenumber.C(34): catastrophic error: cannot open source file "boost/config.hpp"

unset BOOST_ARCH_PATH @ Thirdparty2.x/makeCGAL

#Error3: icpc: error #10106: Fatal error

Change WM_CXXFLAGS = "-O2" to "-O1" @ etc/config/settings.sh

#Error4: undefined reference to `yyFlexLexer::yywrap() https://www.cfd-online.com/Forums/openfoam-installation/163986-building-openfoam-3-0-archlinux.html

find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1='

cd $WM_THIRD_PARTY_DIR

#Setup building environment
source /home/packages/compilers/intel/compiler/2022.0.2/env/vars.sh intel64
source /home/packages/compilers/intel/mpi/2021.5.1/env/vars.sh
source /ddnA/project/cs16/tma5/RHEL8/OpenFOAM/bwtest/OpenFOAM-2.4.x/etc/bashrc WM_LABEL_SIZE=64 WM_COMPILER_TYPE=system

unset CGAL_ARCH_PATH

./Allwmake -j $WM_NCOMPPROCS > log.make 2>&1
wmREFRESH
cd $WM_PROJECT_DIR

#Setup building environment
source /home/packages/compilers/intel/compiler/2022.0.2/env/vars.sh intel64
source /home/packages/compilers/intel/mpi/2021.5.1/env/vars.sh
source /ddnA/project/cs16/tma5/RHEL8/OpenFOAM/bwtest/OpenFOAM-2.4.x/etc/bashrc WM_LABEL_SIZE=64 WM_COMPILER_TYPE=system

unset CGAL_ARCH_PATH

#it will fail if compile in parallel
./Allwmake > log.make 2>&1
wmREFRESH

#https://www.icode9.com/content-3-1202280.html #https://zhouyuqian.com/2021/11/30/build-install-gcc-4-8-5/

#Using node for faster compile
qsub -I -A hpc_hpc_cdss08 -V -l walltime=05:00:00,nodes=1:ppn=20

module purge
cd /project/cs16/tma5/RHEL8/OpenFOAM/

GCC_VERSION=4.8.5

curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2 -O

tar -xf gcc-${GCC_VERSION}.tar.bz2

cd gcc-${GCC_VERSION}
./contrib/download_prerequisites

#Fix gcc with patches
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=883312dc79806f513275b72502231c751c14ff72;hp=601d22f69093aa98dcf9593bc138da7ba8281e05
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ec1cc0263f156f70693a62cf17b254a0029f4852

#patch 1
sed -i -e 's/__attribute__/\/\/__attribute__/g' gcc-${GCC_VERSION}/gcc/cp/cfns.h
sed -i 's/struct ucontext/ucontext_t/g' gcc-${GCC_VERSION}/libgcc/config/i386/linux-unwind.h

#patch 2
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ec1cc0263f156f70693a62cf17b254a0029f4852

mkdir gcc-${GCC_VERSION}_build
mkdir install
cd   gcc-${GCC_VERSION}_build

module purge

../configure --prefix=$(pwd)/../install --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j 32
make -j 32   install

#patch 3 - `CXXABI_1.3.9' not found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment