Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated compile.sh with cmake build of coolprop libray #1568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 46 additions & 19 deletions wrappers/Fluent/compile.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# This Script build the CoolProp sources into a shared library, then it links it to the Fluent udf

# Warning: this script deletes directory libudf before creating a new one

Expand All @@ -7,23 +8,27 @@
SOLVER="$1"
FLUENT_BIN_FOLDER="$2"

if [ "$SOLVER" = "" ]
if [ "$SOLVER" == "" ]
then
$SOLVER = "2ddp" #compiles 2d double precision by default
#compiles 3d double precision by default --> adapt the following line
SOLVER="3ddp"
fi

if [ "$FLUENT_BIN_FOLDER" == "" ]
then
#call by default qualified Fluent version for studies --> adapt the following line
FLUENT_BIN_FOLDER="/users5/appli/produits/ansys_inc/v150/fluent/bin"
fi
FLUENT_COMPILER=g++

HOME=`pwd`

# Copy CoolProp sources to a local folder called coolprop
mkdir coolprop
cp -r ../../CoolProp ./coolprop/CoolProp

cd coolprop
g++ -c CoolProp/*.cpp -ICoolProp -fPIC -D_GNU_SOURCE -ansi -O -Wall -DPTR_RESTRICT=
cd $HOME

#CoolProp root source file (where CMakelist.txt is) --> adapt the following line
CoolProp_sources_repository="/usersCFD/epd/ah33666/CoolProp-6.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be read in from an environment variable or passed as a command line argument rather than being hard coded. Can you please change that?

#Python 2.7 is mandatory to use cmake, by default on our machines the Python version is 2.4 --> adapt the following line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, any modern version of python can be used, including 3.x

PYTHON_273="/users5/appli/produits/PYTHON/2.7.3/bin/python"
#Specify cmake shortcut if default cmake<2.8 --> adapt the following line
alias cmake='/users5/appli/tools/CMAKE/3.6.0/bin/cmake'
# beginning usefull Fluent environnement variables extraction
echo exit > exit.jou
if [ "$FLUENT_BIN_FOLDER" = "" ]
then
Expand All @@ -38,6 +43,10 @@ FLUENT_PROD_DIR=`cat FluentEnvironment.dat | grep FLUENT_PROD_DIR | sed 's/FLUEN
PATH_MAKEFILE1=$FLUENT_PROD_DIR"/src/makefile.udf"
PATH_MAKEFILE2=$FLUENT_PROD_DIR"/src/makefile.udf2"
PATH_LIBRARY="libudf/"$FLUENT_ARCH"/"$SOLVER
# extraction ending

#building the libudf directory
cd $HOME
rm -rf libudf/
mkdir libudf
cp $PATH_MAKEFILE2 libudf/makefile
Expand Down Expand Up @@ -66,17 +75,35 @@ echo -e "\n"FLUENT_INC=$FLUENT_INC >> ${PATH_LIBRARY}/user.udf
echo GPU_SUPPORT=off >> ${PATH_LIBRARY}/user.udf
cp ${PATH_LIBRARY}/user.udf ${PATH_LIBRARY}_host/user.udf
cp ${PATH_LIBRARY}/user.udf ${PATH_LIBRARY}_node/user.udf
#moving and compiling the source
cp *.c libudf/src/
cp *.h libudf/src/
cd libudf && make "FLUENT_ARCH=$FLUENT_ARCH" "SOURCES=$udfNames" "FLUENT_INC=$FLUENT_INC" "CC=$FLUENT_COMPILER" "CFLAGS_LNAMD64=-D_lnamd64 -D_GNU_SOURCE -fpic -shared -ansi -O -Wall -DPTR_RESTRICT= "
cd libudf
#make "FLUENT_ARCH=lnamd64" "SOURCES=$udfNames" "FLUENT_INC=$FLUENT_INC" "CC=$FLUENT_COMPILER" "CFLAGS_LNAMD64=-D_lnamd64 -D_GNU_SOURCE -fpic -shared -ansi -O -Wall -DPTR_RESTRICT= "
make "FLUENT_ARCH=$FLUENT_ARCH"
cd $HOME
cp coolprop/*.o ${PATH_LIBRARY}
cp coolprop/*.o ${PATH_LIBRARY}"_host"
cp coolprop/*.o ${PATH_LIBRARY}"_node"
cd ${PATH_LIBRARY} && g++ -shared -lm -ldl *.o -o libudf.so
#remove the CoolProp build directory before compilation in the build directory
rm -rf CoolProp_Build
mkdir CoolProp_Build
cd CoolProp_Build
#uncomment following line for make file generation if python version <2.7
cmake -G "Unix Makefiles" -DCOOLPROP_EXTERNC_LIBRARY:BOOL="ON" -DCOOLPROP_SHARED_LIBRARY:BOOL="ON" -DPYTHON_EXECUTABLE:FILEPATH=$PYTHON_273 $CoolProp_sources_repository
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what is going on here. It should work just fine with any non-ancient version of python

#uncomment following line make file generation if python is 2.7
#cmake -G "Unix Makefiles" -DCOOLPROP_EXTERNC_LIBRARY:BOOL="ON" -DCOOLPROP_SHARED_LIBRARY:BOOL="ON" $CoolProp_sources_repository
make
cd $HOME
cd ${PATH_LIBRARY}"_host" && g++ -shared -lm -ldl *.o -o libudf.so
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/CoolProp_Build/

cp CoolProp_Build/*.so* ${PATH_LIBRARY}/.
cd ${PATH_LIBRARY}/
g++ -Wall -shared *.o libCoolProp.so -o libudf.so

cd $HOME
cd ${PATH_LIBRARY}"_node" && g++ -shared -lm -ldl *.o -o libudf.so
cp CoolProp_Build/*.so* ${PATH_LIBRARY}_host/.
cd ${PATH_LIBRARY}_host
g++ -Wall -shared *.o libCoolProp.so -o libudf.so

rm -rf coolprop
cd $HOME
cp CoolProp_Build/*.so* ${PATH_LIBRARY}_node/.
cd ${PATH_LIBRARY}_node
g++ -Wall -shared *.o libCoolProp.so -o libudf.so