Commit 6c566dab authored by Simon Brass's avatar Simon Brass
Browse files

[Build] add script for finding FC version

parent 799a39c4
Pipeline #9 skipped
#!/bin/bash
PREFIX=/var/lib/jenkins/slave/opt
MATCH=0
# Working on slave2
# LIB_SUFFIX=lib64
case "$HOST_LABEL" in
ELF32 )
LIB_SUFFIX=lib
;;
ELF64 )
LIB_SUFFIX=lib64
;;
MACHO64 )
LIB_SUFFIX=lib
;;
* )
echo unknown HOST_LABEL $HOST_LABEL ;
exit 1
;;
esac
function gcc-check {
if [[ "$FCMINOR" == "LATEST" ]]; then
# Howto Version :)
# Main-Release.Subrelease.Minor - Revision Number
# |----: Main Release
# |---------: Subrelease, if zero, track lastest version
# |--------------: Version, if given, this is a stable version
set -x
FC_PATH=$PREFIX/`ls -l $PREFIX/$FC_LABEL | grep -o -E gcc-[0-9]+.[0-9]+-[0-9]+$`
FC_REVISION=`ls -l $PREFIX/$FC_LABEL | grep -o -E [0-9]+$`
FC_BINPATH=$FC_PATH/bin
FC_LIBPATH=$FC_PATH/$LIB_SUFFIX/
MATCH=1
# What's the real version of our gcc
FCOUTVERSION=`$FC_BINPATH/$FCBIN --version | head -n 1 | grep -o [0-9].[0-9].[0-9] | head -n 1`
FC_VERSION=$FCOUTVERSION-$FC_REVISION
FC_ACTUAL_LABEL=$FC_LABEL
set +x
echo "Link: $FC_LABEL -> $FC_VERSION"
else
FCOUT=`$FC_BINPATH/$FCBIN --version | grep $FC_VERSION`
FCOUTVERSION=`echo $FCOUT | grep -o $FC_VERSION`
FCOUTDATE=""
FC_REVISION=""
FC_ACTUAL_LABEL=$FC_LABEL
if [[ "$FCOUTVERSION" == "$FC_VERSION" ]]
then
MATCH=1
else
MATCH=0
fi
fi
export LHAPDF_PREFIX=$FC_PATH
export FC=gfortran
}
function nagfor-check {
# WORKAROUND FOR nagfor 6.00
if [[ "$FCRELEASE" == '6.00' ]]; then
FCRELEASE=6.0
fi
if [[ "$FCRELEASE" == '6-LATEST' ]]; then
FCRELEASE=6.0
fi
FCOUT=`$FC_BINPATH/$FCBIN -V 2>&1 | grep $FCRELEASE`
if [[ "$FCRELEASE" == '6.0' ]]; then
FCOUTMINOR=`echo $FCOUT | grep -E -o "[0123456789]{4}"`
else
FCOUTMINOR=`echo $FCOUT | grep -E -o "[0123456789]{3}"`
fi
FCOUTRELEASE=`echo $FCOUT | grep -o "[0123456789]\.[0123456789]"`
if [[ "$FCOUTRELEASE" == "$FCRELEASE" ]]; then
MATCH=1
else
MATCH=0
fi
if [[ "$FCOUTRELEASE" == '6.0' ]]; then
FCOUTRELEASE=6.00
fi
FC_PATH=$PREFIX/$FCBIN-$FCOUTRELEASE-$FCOUTMINOR
FC_BINPATH=$FC_PATH/bin
FC_LIBPATH=$FC_PATH/lib:$PREFIX/gcc-5-LATEST/lib/
FC_ACTUAL_LABEL=${FC_LABEL/LATEST/$FCOUTMINOR}
#Test gcc-4.7.0
export LDFLAGS=-L$PREFIX/gcc-5-LATEST/lib/
#
# On request of JRR:
# export FCFLAGS="$FCFLAGS -C=all -nan -gline -w -f2003 -maxcontin=512"
export FCFLAGS="$FCFLAGS -C=all -gline -nan -f2008"
export LHAPDF_PREFIX=$PREFIX/gcc-5-LATEST
export FC=nagfor
}
function ekopath-check {
FC_PATH=$PREFIX/ekopath
FC_BINPATH=$FC_PATH/bin
FC_LIBPATH=$FC_PATH/lib/$FC_VERSION/x8664/
export LHAPDF_PREFIX=$PREFIX/gcc-5-LATEST
export FC=pathf95
if [ -f "${FC_BINPATH}/${FC}" ]
then
MATCH=1
else
MATCH=0
fi
}
set -x
FCBIN=${FC_LABEL/-*/""}
FC_VERSION=${FC_LABEL/$FCBIN-/""}
FCRELEASE=`echo $FC_VERSION | grep -oE [0-9].[0-9]+`
FCMINOR_CUT=`expr length $FCRELEASE`
let "FCMINOR_CUT += 1"
FCMINOR=${FC_VERSION:$FCMINOR_CUT}
FC_PATH=$PREFIX/$FC_LABEL
FC_BINPATH=$FC_PATH/bin
FC_LIBPATH=$FC_PATH/$LIB_SUFFIX/
set +x
echo "Compiler-Version: ${FC_VERSION}"
echo "Compiler: ${FCBIN}"
echo "Minor Version: ${FCMINOR}"
case "${FCBIN}" in
"gcc" )
gcc-check
;;
"nagfor" )
nagfor-check
;;
"ekopath" )
ekopath-check
;;
"*" )
echo "unkown fortran binary: ${FCBIN}"
;;
esac
echo "#!/bin/bash" > ${WORKSPACE}/FC_PATH.sh
echo "export PATH=$FC_BINPATH:$PATH" >> ${WORKSPACE}/FC_PATH.sh
if [ -n $LD_LIBRARY_PATH ]
then
echo "export LD_LIBRARY_PATH=$FC_LIBPATH:$LD_LIBRARY_PATH" >> ${WORKSPACE}/FC_PATH.sh
else
echo "export LD_LIBRARY_PATH=$FC_LIBPATH" >> ${WORKSPACE}/FC_PATH.sh
fi
echo "export LDFLAGS=$LDFLAGS" >> ${WORKSPACE}/FC_PATH.sh
echo "export FCFLAGS=\"$FCFLAGS\"" >> ${WORKSPACE}/FC_PATH.sh
echo "export LHAPDF_PREFIX=$LHAPDF_PREFIX" >> ${WORKSPACE}/FC_PATH.sh
echo "export FC=$FC" >> ${WORKSPACE}/FC_PATH.sh
if [[ $MATCH == 0 ]]
then
echo "${FC_LABEL} not found".
echo "FCBIN=$FCBIN"
echo "FC_VERSION=$FC_VERSION"
exit 1
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment