| 1 | trap onexit EXIT
|
|---|
| 2 |
|
|---|
| 3 | function onexit() {
|
|---|
| 4 | retval=$?
|
|---|
| 5 | if [ $retval -gt 0 ] && [ $retval -lt 11 ]; then
|
|---|
| 6 | printf "\nAn ERROR occured, see build.log for details\n"
|
|---|
| 7 | fi
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 | function build_3rdparty() {
|
|---|
| 11 | printf "building 3rd-party dependencies ... "
|
|---|
| 12 | set -o pipefail
|
|---|
| 13 |
|
|---|
| 14 | cd $SOURCE_ROOT_BLAS
|
|---|
| 15 | FFLAGS="-O0 $FF77 $FFLAGS" ./install 2>&1 | tee -a $CASEDIR/build.log >/dev/null
|
|---|
| 16 | cd $CASEDIR
|
|---|
| 17 |
|
|---|
| 18 | cd $SOURCE_ROOT_GSLIB
|
|---|
| 19 | CFLAGS="-O2 $CFLAGS" ./install 2>&1 | tee -a $CASEDIR/build.log >/dev/null
|
|---|
| 20 | cd $CASEDIR
|
|---|
| 21 |
|
|---|
| 22 | if [ $PARRSB -ne 0 ]; then
|
|---|
| 23 | cd $SOURCE_ROOT_PARRSB
|
|---|
| 24 | CFLAGS="-O2 $CFLAGS" ./install 2>&1 | tee -a $CASEDIR/build.log >/dev/null
|
|---|
| 25 | fi
|
|---|
| 26 | cd $CASEDIR
|
|---|
| 27 |
|
|---|
| 28 | if [ $PARMETIS -ne 0 ]; then
|
|---|
| 29 | cd $SOURCE_ROOT_PARMETIS
|
|---|
| 30 | CFLAGS="-O2 $CFLAGS" ./install 2>&1 | tee -a $CASEDIR/build.log >/dev/null
|
|---|
| 31 | fi
|
|---|
| 32 | cd $CASEDIR
|
|---|
| 33 |
|
|---|
| 34 | if [ $CVODE -ne 0 ]; then
|
|---|
| 35 | cd $SOURCE_ROOT_CVODE
|
|---|
| 36 | CFLAGS="-O2 $CFLAGS" ./install 2>&1 | tee -a $CASEDIR/build.log >/dev/null
|
|---|
| 37 | fi
|
|---|
| 38 | cd $CASEDIR
|
|---|
| 39 |
|
|---|
| 40 | if [ $HYPRE -ne 0 ]; then
|
|---|
| 41 | cd $SOURCE_ROOT_HYPRE
|
|---|
| 42 | CFLAGS="-O2 $CFLAGS" ./install 2>&1 | tee -a $CASEDIR/build.log >/dev/null
|
|---|
| 43 | fi
|
|---|
| 44 | cd $CASEDIR
|
|---|
| 45 |
|
|---|
| 46 | printf "done\n"
|
|---|
| 47 | set +o pipefail
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | function clean_3rdparty() {
|
|---|
| 51 | cd $SOURCE_ROOT_BLAS; ./install clean 2>/dev/null
|
|---|
| 52 | cd $CASEDIR
|
|---|
| 53 | cd $SOURCE_ROOT_GSLIB; ./install clean 2>/dev/null
|
|---|
| 54 | cd $CASEDIR
|
|---|
| 55 | cd $SOURCE_ROOT_PARRSB; ./install clean 2>/dev/null
|
|---|
| 56 | cd $CASEDIR
|
|---|
| 57 | cd $SOURCE_ROOT_PARMETIS; ./install clean 2>/dev/null
|
|---|
| 58 | cd $CASEDIR
|
|---|
| 59 | cd $SOURCE_ROOT_CVODE; ./install clean 2>/dev/null
|
|---|
| 60 | cd $CASEDIR
|
|---|
| 61 | cd $SOURCE_ROOT_HYPRE; ./install clean 2>/dev/null
|
|---|
| 62 | cd $CASEDIR
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | function config_nek() {
|
|---|
| 66 |
|
|---|
| 67 | # set defaults
|
|---|
| 68 | : ${NEK_SOURCE_ROOT:="$HOME/Nek5000"}
|
|---|
| 69 | : ${FC:="mpif77"}
|
|---|
| 70 | : ${CC:="mpicc"}
|
|---|
| 71 | : ${MPI:=1}
|
|---|
| 72 | : ${PROFILING:=1}
|
|---|
| 73 | : ${VISIT:=0}
|
|---|
| 74 | : ${PPLIST:=""}
|
|---|
| 75 |
|
|---|
| 76 | # first do some checks ...
|
|---|
| 77 | if [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$PPLIST" == "?" ]; then
|
|---|
| 78 | echo "Options and arguments:"
|
|---|
| 79 | echo " <casename> name of usr file without extension"
|
|---|
| 80 | echo " clean cleanup build environment"
|
|---|
| 81 | echo " -build-dep build dependencies"
|
|---|
| 82 | echo ""
|
|---|
| 83 | echo "PPLIST config options:"
|
|---|
| 84 | echo " NOMPIIO disable MPI-IO"
|
|---|
| 85 | echo " BGQ use BGQ optimized mxm"
|
|---|
| 86 | echo " XSMM use libxsmm for mxm"
|
|---|
| 87 | echo " CVODE enable CVODE support"
|
|---|
| 88 | echo " HYPRE enable HYPRE support"
|
|---|
| 89 | echo " VENDOR_BLAS use VENDOR BLAS/LAPACK"
|
|---|
| 90 | echo " DPROCMAP use distributed processor mapping"
|
|---|
| 91 | echo " PARRSB use online RSB partitioner (experimental)"
|
|---|
| 92 | return 11
|
|---|
| 93 | fi
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | if [ "$VERMAKENEK" != "19.0.1" ]; then
|
|---|
| 97 | echo "FATAL ERROR: Your makenek is incompatible!"
|
|---|
| 98 | echo "Please upgrade to the version shipped the source"
|
|---|
| 99 | return 11
|
|---|
| 100 | fi
|
|---|
| 101 |
|
|---|
| 102 | rm -rf build.log
|
|---|
| 103 | nargs=$#
|
|---|
| 104 |
|
|---|
| 105 | CASEDIR=`pwd`
|
|---|
| 106 | CASENAME=$1
|
|---|
| 107 | NODEP=0
|
|---|
| 108 | ONLYDEP=0
|
|---|
| 109 |
|
|---|
| 110 | SOURCE_ROOT_BLAS="$NEK_SOURCE_ROOT/3rd_party/blasLapack"
|
|---|
| 111 | export SOURCE_ROOT_BLAS
|
|---|
| 112 | SOURCE_ROOT_GSLIB="$NEK_SOURCE_ROOT/3rd_party/gslib"
|
|---|
| 113 | export SOURCE_ROOT_GSLIB
|
|---|
| 114 | SOURCE_ROOT_PARRSB="$NEK_SOURCE_ROOT/3rd_party/parRSB"
|
|---|
| 115 | export SOURCE_ROOT_PARRSB
|
|---|
| 116 | SOURCE_ROOT_PARMETIS="$NEK_SOURCE_ROOT/3rd_party/parMETIS"
|
|---|
| 117 | export SOURCE_ROOT_PARMETIS
|
|---|
| 118 | SOURCE_ROOT_CVODE="$NEK_SOURCE_ROOT/3rd_party/cvode"
|
|---|
| 119 | export SOURCE_ROOT_CVODE
|
|---|
| 120 | SOURCE_ROOT_HYPRE="$NEK_SOURCE_ROOT/3rd_party/hypre"
|
|---|
| 121 | export SOURCE_ROOT_HYPRE
|
|---|
| 122 |
|
|---|
| 123 | NODEP=1
|
|---|
| 124 | if [ "$1" == "-build-dep" ]; then
|
|---|
| 125 | ONLYDEP=1
|
|---|
| 126 | nargs=0
|
|---|
| 127 | fi
|
|---|
| 128 |
|
|---|
| 129 | if [[ $1 = "clean" ]]; then
|
|---|
| 130 | while true; do
|
|---|
| 131 | read -p "do you want to cleanup all 3rd party dependencies too? [N]" yn
|
|---|
| 132 | case $yn in
|
|---|
| 133 | [Yy]* )
|
|---|
| 134 | clean_3rdparty;
|
|---|
| 135 | if [ -f makefile ]; then make clean; fi
|
|---|
| 136 | break ;;
|
|---|
| 137 | * )
|
|---|
| 138 | if [ -f makefile ]; then make clean; fi
|
|---|
| 139 | break ;;
|
|---|
| 140 | esac
|
|---|
| 141 | done
|
|---|
| 142 | rm -rf build.log
|
|---|
| 143 | rm -rf makefile
|
|---|
| 144 | rm -rf .state
|
|---|
| 145 | return 0
|
|---|
| 146 | fi
|
|---|
| 147 |
|
|---|
| 148 | #if [ -f makefile ] && [ $ONLYDEP -ne 1 ]; then
|
|---|
| 149 | # while true; do
|
|---|
| 150 | # echo "makefile exists already!"
|
|---|
| 151 | # read -p "Are you sure you want to continue? [N]" yn
|
|---|
| 152 | # case $yn in
|
|---|
| 153 | # [Yy]* )
|
|---|
| 154 | # break ;;
|
|---|
| 155 | # * )
|
|---|
| 156 | # return 0
|
|---|
| 157 | # break ;;
|
|---|
| 158 | # esac
|
|---|
| 159 | # done
|
|---|
| 160 | #fi
|
|---|
| 161 |
|
|---|
| 162 | if [ ! -f $NEK_SOURCE_ROOT/core/makefile.template ]; then
|
|---|
| 163 | echo "FATAL ERROR: Cannot find $NEK_SOURCE_ROOT/core/makefile.template!"
|
|---|
| 164 | return 11
|
|---|
| 165 | fi
|
|---|
| 166 |
|
|---|
| 167 | # test compiler
|
|---|
| 168 | if ! which `echo $FC | awk '{print $1}'` 1>/dev/null ; then
|
|---|
| 169 | echo "FATAL ERROR: Cannot find `echo $FC | awk '{print $1}'`!"
|
|---|
| 170 | return 11
|
|---|
| 171 | fi
|
|---|
| 172 | if ! which `echo $CC | awk '{print $1}'` 1>/dev/null ; then
|
|---|
| 173 | echo "FATAL ERROR: Cannot find `echo $CC | awk '{print $1}'`!"
|
|---|
| 174 | return 11
|
|---|
| 175 | fi
|
|---|
| 176 |
|
|---|
| 177 | # trying to figure which compiler the wrapper is using
|
|---|
| 178 | FCok=0
|
|---|
| 179 |
|
|---|
| 180 | FCcomp_=`$FC -showme 2>/dev/null | head -1 2>/dev/null 1>.tmp || true`
|
|---|
| 181 | FCcomp=`cat .tmp | awk '{print $1}' | awk -F/ '{print $NF}' || true`
|
|---|
| 182 | if [ -f "`which $FCcomp 2>/dev/null`" ]; then
|
|---|
| 183 | FCok=1
|
|---|
| 184 | fi
|
|---|
| 185 |
|
|---|
| 186 | if [ $FCok -eq 0 ]; then
|
|---|
| 187 | FCcomp_=`$FC -show 2>/dev/null | head -1 2>/dev/null 1>.tmp || true`
|
|---|
| 188 | FCcomp=`cat .tmp | awk '{print $1}' | awk -F/ '{print $NF}' || true`
|
|---|
| 189 | if [ -f "`which $FCcomp 2>/dev/null`" ]; then
|
|---|
| 190 | FCok=1
|
|---|
| 191 | fi
|
|---|
| 192 | fi
|
|---|
| 193 |
|
|---|
| 194 | if [ $FCok -eq 0 ]; then
|
|---|
| 195 | FCcomp_=`$FC -craype-verbose 2>/dev/null 1>.tmp || true`
|
|---|
| 196 | FCcomp=`cat .tmp | awk '{print $1}' | awk -F/ '{print $NF}' || true`
|
|---|
| 197 | if [ -f "`which $FCcomp 2>/dev/null`" ]; then
|
|---|
| 198 | FCok=1
|
|---|
| 199 | fi
|
|---|
| 200 | fi
|
|---|
| 201 |
|
|---|
| 202 | if [ $FCok -eq 0 ]; then
|
|---|
| 203 | FCcomp=`echo $FC | awk '{print $1}'`
|
|---|
| 204 | if [ -f "`which $FCcomp 2>/dev/null`" ]; then
|
|---|
| 205 | FCok=1
|
|---|
| 206 | fi
|
|---|
| 207 | fi
|
|---|
| 208 |
|
|---|
| 209 | \rm -f .tmp
|
|---|
| 210 | if [ $FCok -eq 0 ]; then
|
|---|
| 211 | FCcomp="unknown"
|
|---|
| 212 | fi
|
|---|
| 213 |
|
|---|
| 214 | # assign FC compiler specific flags
|
|---|
| 215 | case $FCcomp in
|
|---|
| 216 | *pgf*) FCPP="-Mpreprocess"
|
|---|
| 217 | FR8="-r8"
|
|---|
| 218 | ;;
|
|---|
| 219 | *gfortran*) FCPP="-cpp"
|
|---|
| 220 | FR8="-fdefault-real-8 -fdefault-double-8"
|
|---|
| 221 | FF77="-std=legacy"
|
|---|
| 222 | ;;
|
|---|
| 223 | *ftn*) FCPP="-eZ"
|
|---|
| 224 | FR8="-sreal64"
|
|---|
| 225 | ;;
|
|---|
| 226 | *armflang*) FCPP="-cpp"
|
|---|
| 227 | FR8="-r8"
|
|---|
| 228 | FF77="-std=legacy"
|
|---|
| 229 | ;;
|
|---|
| 230 | *ifort*) FCPP="-fpp"
|
|---|
| 231 | FR8="-r8 -fpconstant"
|
|---|
| 232 | ;;
|
|---|
| 233 | *xlf*) FCPP="-qsuffix=cpp=f"
|
|---|
| 234 | FR8="-qrealsize=8 -qdpc=e"
|
|---|
| 235 | FF77="-qfixed"
|
|---|
| 236 | PPPO="-WF,"
|
|---|
| 237 | ;;
|
|---|
| 238 | *) echo "ERROR: Cannot find a supported compiler!"
|
|---|
| 239 | echo ""
|
|---|
| 240 | read;;
|
|---|
| 241 | esac
|
|---|
| 242 |
|
|---|
| 243 | LONGLONGINT=1
|
|---|
| 244 |
|
|---|
| 245 | # Check if the compiler adds an underscore to external functions
|
|---|
| 246 | UNDERSCORE=0
|
|---|
| 247 | cat > test_underscore.f << _ACEOF
|
|---|
| 248 | subroutine underscore_test
|
|---|
| 249 | call test
|
|---|
| 250 | end
|
|---|
| 251 | _ACEOF
|
|---|
| 252 | $FCcomp -c test_underscore.f 2>&1 >/dev/null
|
|---|
| 253 | if nm test_underscore.o | grep -q test_ ; then
|
|---|
| 254 | UNDERSCORE=1
|
|---|
| 255 | fi
|
|---|
| 256 | \rm test_underscore.* 2>/dev/null
|
|---|
| 257 |
|
|---|
| 258 | # Check if ld option is available
|
|---|
| 259 | cat > _test.f << _ACEOF
|
|---|
| 260 | program test
|
|---|
| 261 | end
|
|---|
| 262 | _ACEOF
|
|---|
| 263 | $FCcomp -Wl,--allow-multiple-definition -o _test _test.f >/dev/null 2>&1 || true
|
|---|
| 264 | \rm _test.f 2>/dev/null
|
|---|
| 265 | if [ -f _test ]; then
|
|---|
| 266 | LDFLAGS+=" -Wl,--allow-multiple-definition"
|
|---|
| 267 | \rm _test 2>/dev/null
|
|---|
| 268 | fi
|
|---|
| 269 |
|
|---|
| 270 | # set preprocessor symbols
|
|---|
| 271 | if [ $MPI -eq 0 ]; then
|
|---|
| 272 | PPLIST="${PPLIST} NOMPIIO"
|
|---|
| 273 | else
|
|---|
| 274 | MPI=1
|
|---|
| 275 | PPLIST="${PPLIST} MPI"
|
|---|
| 276 | fi
|
|---|
| 277 |
|
|---|
| 278 | if [ $UNDERSCORE -ne 0 ]; then
|
|---|
| 279 | PPLIST="${PPLIST} UNDERSCORE"
|
|---|
| 280 | fi
|
|---|
| 281 |
|
|---|
| 282 | if [ $LONGLONGINT -ne 0 ]; then
|
|---|
| 283 | PPLIST="${PPLIST} GLOBAL_LONG_LONG"
|
|---|
| 284 | fi
|
|---|
| 285 |
|
|---|
| 286 | if [ $PROFILING -ne 0 ]; then
|
|---|
| 287 | PPLIST="${PPLIST} TIMER"
|
|---|
| 288 | fi
|
|---|
| 289 |
|
|---|
| 290 | PPLIST="${PPLIST}"
|
|---|
| 291 |
|
|---|
| 292 | # add user defined preprocessor symbols
|
|---|
| 293 | CMT=0
|
|---|
| 294 | MPIIO=1
|
|---|
| 295 | DPROCMAP=0
|
|---|
| 296 | PARRSB=0
|
|---|
| 297 | PARMETIS=0
|
|---|
| 298 | CVODE=0
|
|---|
| 299 | HYPRE=0
|
|---|
| 300 | MXM_USER="mxm_std.o"
|
|---|
| 301 | VENDOR_BLAS=0
|
|---|
| 302 |
|
|---|
| 303 | for i in $PPLIST
|
|---|
| 304 | do
|
|---|
| 305 | if [ "$i" == "CMTNEK" ]; then
|
|---|
| 306 | CMT=1
|
|---|
| 307 | fi
|
|---|
| 308 | if [ "$i" == "NOMPIIO" ]; then
|
|---|
| 309 | MPIIO=0
|
|---|
| 310 | fi
|
|---|
| 311 | if [ "$i" == "DPROCMAP" ]; then
|
|---|
| 312 | DPROCMAP=1
|
|---|
| 313 | fi
|
|---|
| 314 | if [ "$i" == "PARRSB" ]; then
|
|---|
| 315 | PARRSB=1
|
|---|
| 316 | PARRSB_OPT=" DESTDIR=.. UNDERSCORE=$UNDERSCORE MPI=$MPI"
|
|---|
| 317 | PARRSB_OPT+=" GSLIBPATH=$SOURCE_ROOT_GSLIB"
|
|---|
| 318 | USR_LFLAGS+=" -L$SOURCE_ROOT_PARRSB/lib -lparRSB"
|
|---|
| 319 | PARRSB_INC="$SOURCE_ROOT_PARRSB/include"
|
|---|
| 320 | fi
|
|---|
| 321 | if [ "$i" == "PARMETIS" ]; then
|
|---|
| 322 | PARMETIS=1
|
|---|
| 323 | USR_LFLAGS+=" -L$SOURCE_ROOT_PARMETIS/lib -lparmetis -lmetis"
|
|---|
| 324 | METIS_INC="$SOURCE_ROOT_PARMETIS/include"
|
|---|
| 325 | fi
|
|---|
| 326 | if [ "$i" == "CVODE" ]; then
|
|---|
| 327 | CVODE=1
|
|---|
| 328 | if [ $MPI -eq 1 ]; then
|
|---|
| 329 | USR_LFLAGS+=" -L$SOURCE_ROOT_CVODE/lib -lsundials_fcvode -lsundials_cvode"
|
|---|
| 330 | USR_LFLAGS+=" -lsundials_fnvecparallel -lsundials_nvecparallel"
|
|---|
| 331 | else
|
|---|
| 332 | USR_LFLAGS+=" -L$SOURCE_ROOT_CVODE/lib -lsundials_fcvode -lsundials_cvode"
|
|---|
| 333 | USR_LFLAGS+=" -lsundials_fnvecserial -lsundials_nvecserial"
|
|---|
| 334 | fi
|
|---|
| 335 | fi
|
|---|
| 336 | if [ "$i" == "HYPRE" ]; then
|
|---|
| 337 | HYPRE=1
|
|---|
| 338 | USR_LFLAGS+=" -L$SOURCE_ROOT_HYPRE/lib -lHYPRE"
|
|---|
| 339 | HYPRE_INC="$SOURCE_ROOT_HYPRE/include"
|
|---|
| 340 | fi
|
|---|
| 341 | if [ "$i" == "BGQ" ]; then
|
|---|
| 342 | MXM_USER+=" mxm_bgq.o"
|
|---|
| 343 | fi
|
|---|
| 344 | if [ "$i" == "VENDOR_BLAS" ]; then
|
|---|
| 345 | VENDOR_BLAS=1
|
|---|
| 346 | fi
|
|---|
| 347 | done
|
|---|
| 348 |
|
|---|
| 349 | if [ $VENDOR_BLAS -ne 1 ]; then
|
|---|
| 350 | USR_LFLAGS+=" -L$SOURCE_ROOT_BLAS -lblasLapack"
|
|---|
| 351 | fi
|
|---|
| 352 |
|
|---|
| 353 | # gslib build options
|
|---|
| 354 | GSLIB_OPT+=" DESTDIR=.."
|
|---|
| 355 | GSLIB_OPT+=" MPI=$MPI MPIIO=$MPIIO"
|
|---|
| 356 | GSLIB_OPT+=" ADDUS=$UNDERSCORE USREXIT=0 BLAS=2"
|
|---|
| 357 | GSLIB_IFLAGS=" -I$SOURCE_ROOT_GSLIB/include"
|
|---|
| 358 | USR_LFLAGS+=" -L$SOURCE_ROOT_GSLIB/lib -lgs"
|
|---|
| 359 |
|
|---|
| 360 | if ! which openssl >/dev/null; then
|
|---|
| 361 | echo "FATAL ERROR: Cannot find openssl!"
|
|---|
| 362 | return 11
|
|---|
| 363 | fi
|
|---|
| 364 | if ! which wget >/dev/null; then
|
|---|
| 365 | echo "FATAL ERROR: Cannot find wget!"
|
|---|
| 366 | return 11
|
|---|
| 367 | fi
|
|---|
| 368 | if ! which tar >/dev/null; then
|
|---|
| 369 | echo "FATAL ERROR: Cannot find tar!"
|
|---|
| 370 | return 11
|
|---|
| 371 | fi
|
|---|
| 372 | if ! which make >/dev/null; then
|
|---|
| 373 | echo "FATAL ERROR: Cannot find make!"
|
|---|
| 374 | return 11
|
|---|
| 375 | fi
|
|---|
| 376 | if [ $HYPRE -ne 0 ]; then
|
|---|
| 377 | if ! which cmake >/dev/null; then
|
|---|
| 378 | echo "FATAL ERROR: Cannot find cmake!"
|
|---|
| 379 | return 11
|
|---|
| 380 | fi
|
|---|
| 381 | fi
|
|---|
| 382 |
|
|---|
| 383 | export FC
|
|---|
| 384 | export FCPP
|
|---|
| 385 | export FR8
|
|---|
| 386 | export FF77
|
|---|
| 387 | export CC
|
|---|
| 388 | export NEK_WARN
|
|---|
| 389 | export MPI
|
|---|
| 390 | export MPIO
|
|---|
| 391 | export UNDERSCORE
|
|---|
| 392 | export GSLIB_OPT
|
|---|
| 393 | export PARRSB_OPT
|
|---|
| 394 |
|
|---|
| 395 | if [ $ONLYDEP -eq 1 ]; then
|
|---|
| 396 | build_3rdparty
|
|---|
| 397 | return 0
|
|---|
| 398 | fi
|
|---|
| 399 |
|
|---|
| 400 | if [ $nargs -eq 0 ]; then
|
|---|
| 401 | NCASEFILES=`find *.usr 2>/dev/null| wc -l`
|
|---|
| 402 | if [ $NCASEFILES == "0" ]; then
|
|---|
| 403 | true
|
|---|
| 404 | elif [ $NCASEFILES != "1" ]; then
|
|---|
| 405 | echo "FATAL ERROR: Found multiple .usr files!"
|
|---|
| 406 | echo "Please use makenek [.usr filename]"
|
|---|
| 407 | return 11
|
|---|
| 408 | else
|
|---|
| 409 | CASENAME=`find *.usr | sed 's/\.usr$//g'`
|
|---|
| 410 | fi
|
|---|
| 411 | fi
|
|---|
| 412 |
|
|---|
| 413 | if [ ! -f ${CASENAME}'.usr' ]; then
|
|---|
| 414 | echo "FATAL ERROR: Cannot find $1.usr!"
|
|---|
| 415 | return 11
|
|---|
| 416 | fi
|
|---|
| 417 |
|
|---|
| 418 | printf "generating makefile ... "
|
|---|
| 419 | rm -rf makefile 2>/dev/null
|
|---|
| 420 |
|
|---|
| 421 | sed -e "s:^FC[ ]*=.*:FC=$FC:" \
|
|---|
| 422 | -e "s:^CC[ ]*=.*:CC=$CC:" \
|
|---|
| 423 | -e "s:^FFLAGS[ ]*+=.*:FFLAGS+=$FCPP $FR8 $FF77 $FFLAGS:" \
|
|---|
| 424 | -e "s:^CFLAGS[ ]*+=.*:CFLAGS+=$CFLAGS:" \
|
|---|
| 425 | -e "s:^LDFLAGS[ ]*+=.*:LDFLAGS+=$LDFLAGS:" \
|
|---|
| 426 | -e "s/^PPPO[ ]*=.*/PPPO=$PPPO/" \
|
|---|
| 427 | -e "s/^PPS[ ]*=.*/PPS=$PPLIST/" \
|
|---|
| 428 | -e "s:^MXM[ ]*=.*:MXM=$MXM_USER:" \
|
|---|
| 429 | -e "s:^BLAS[ ]*=.*:BLAS=$BLAS:" \
|
|---|
| 430 | -e "s/^MPI[ ]*=.*/MPI=$MPI/" \
|
|---|
| 431 | -e "s/^CVODE[ ]*=.*/CVODE=$CVODE/" \
|
|---|
| 432 | -e "s/^CMT[ ]*=.*/CMT=$CMT/" \
|
|---|
| 433 | -e "s:^GSLIB_IFLAGS[ ]*=.*:GSLIB_IFLAGS\:=${GSLIB_IFLAGS}:" \
|
|---|
| 434 | -e "s/^DPROCMAP[ ]*=.*/DPROCMAP=${DPROCMAP}/" \
|
|---|
| 435 | -e "s/^VISIT[ ]*=.*/VISIT=${VISIT}/" \
|
|---|
| 436 | -e "s:^USR[ ]*=.*:USR=$USR:" \
|
|---|
| 437 | -e "s:^USR_LFLAGS[ ]*=.*:USR_LFLAGS=$USR_LFLAGS:" \
|
|---|
| 438 | -e "s:^S[ ]*=.*:S=${NEK_SOURCE_ROOT}/core:" \
|
|---|
| 439 | -e "s:^SCMT[ ]*=.*:SCMT=${NEK_SOURCE_ROOT}/core/cmt:" \
|
|---|
| 440 | $NEK_SOURCE_ROOT/core/makefile.template >.makefile
|
|---|
| 441 |
|
|---|
| 442 | if [ $VISIT -ne 0 ]; then
|
|---|
| 443 | echo ""
|
|---|
| 444 | echo "Activate VisIt Sim Mode"
|
|---|
| 445 |
|
|---|
| 446 | if [ -z "$VISIT_INC" ]; then
|
|---|
| 447 | VISIT_INC=${VISIT_INSTALL}/libsim/V2/include
|
|---|
| 448 | fi
|
|---|
| 449 | echo " VISIT_INC = ($VISIT_INC)"
|
|---|
| 450 | if [ -z "$VISIT_LIB" ]; then
|
|---|
| 451 | VISIT_LIB=${VISIT_INSTALL}/libsim/V2/lib
|
|---|
| 452 | fi
|
|---|
| 453 | echo " VISIT_LIB = ($VISIT_LIB)"
|
|---|
| 454 | if [ -n "$VISIT_STOP" ]; then
|
|---|
| 455 | VISIT_STOP="VISIT_STOP"
|
|---|
| 456 | echo " VISIT_STOP is defined. Nek5000 will wait for VisIt to Connect."
|
|---|
| 457 | fi
|
|---|
| 458 |
|
|---|
| 459 | sed -e "s/^VISIT[ ]*=.*/VISIT:=${VISIT}/" \
|
|---|
| 460 | -e "s:^VISIT_IFLAGS[ ]*=.*:VISIT_IFLAGS\:=-I${VISIT_INC}:" \
|
|---|
| 461 | -e "s:^VISIT_LFLAGS[ ]*=.*:VISIT_LFLAGS\:=-L${VISIT_LIB} -lsimV2 -lsimV2f -ldl -lstdc++:" \
|
|---|
| 462 | -e "s/^PPS[ ]*=.*/PPS=${PPLIST} VISIT ${VISIT_STOP}/" \
|
|---|
| 463 | .makefile > .makefile.tmp
|
|---|
| 464 |
|
|---|
| 465 | mv .makefile.tmp .makefile
|
|---|
| 466 | echo ""
|
|---|
| 467 | fi
|
|---|
| 468 |
|
|---|
| 469 | if [ $HYPRE -ne 0 ]; then
|
|---|
| 470 | sed -e "s:^HYPRE_IFLAGS[ ]*=.*:HYPRE_IFLAGS\:=-I${HYPRE_INC}:" \
|
|---|
| 471 | -e "s:^USR_LFLAGS[ ]*=.*:USR_LFLAGS=$USR_LFLAGS:" \
|
|---|
| 472 | .makefile > .makefile.tmp
|
|---|
| 473 |
|
|---|
| 474 | mv .makefile.tmp .makefile
|
|---|
| 475 | fi
|
|---|
| 476 |
|
|---|
| 477 | if [ $PARMETIS -ne 0 ]; then
|
|---|
| 478 | sed -e "s:^PARRSB_IFLAGS[ ]*=.*:PARRSB_IFLAGS\:=-I${METIS_INC}:" \
|
|---|
| 479 | -e "s:^USR_LFLAGS[ ]*=.*:USR_LFLAGS=$USR_LFLAGS:" \
|
|---|
| 480 | .makefile > .makefile.tmp
|
|---|
| 481 |
|
|---|
| 482 | mv .makefile.tmp .makefile
|
|---|
| 483 | fi
|
|---|
| 484 |
|
|---|
| 485 | if [ $PARRSB -ne 0 ]; then
|
|---|
| 486 | sed -e "s:^PARRSB_IFLAGS[ ]*=.*:PARRSB_IFLAGS\:=-I${PARRSB_INC}:" \
|
|---|
| 487 | -e "s:^USR_LFLAGS[ ]*=.*:USR_LFLAGS=$USR_LFLAGS:" \
|
|---|
| 488 | .makefile > .makefile.tmp
|
|---|
| 489 |
|
|---|
| 490 | mv .makefile.tmp .makefile
|
|---|
| 491 | fi
|
|---|
| 492 |
|
|---|
| 493 |
|
|---|
| 494 | if [ "$USR" != "" ]; then
|
|---|
| 495 | echo "###########################################################" >> makefile
|
|---|
| 496 | echo "include makefile_usr.inc" >> .makefile
|
|---|
| 497 | fi
|
|---|
| 498 |
|
|---|
| 499 | if [ -f .makefile ]; then
|
|---|
| 500 | sed -e "1i\\
|
|---|
| 501 | ### makefile automatically created by makenek `date +"%m/%d/%Y %T"` ###" \
|
|---|
| 502 | -e "s:^CASEDIR[ ]*=.*:CASEDIR\:=${CASEDIR}:" \
|
|---|
| 503 | -e "s:^CASENAME[ ]*=.*:CASENAME\:=${CASENAME}:" .makefile > makefile
|
|---|
| 504 | printf "done\n"
|
|---|
| 505 | else
|
|---|
| 506 | printf "failed!\n"
|
|---|
| 507 | return 1
|
|---|
| 508 | fi
|
|---|
| 509 | \rm .makefile 2>/dev/null
|
|---|
| 510 |
|
|---|
| 511 | # tweak SIZE file
|
|---|
| 512 | if [ -f SIZEu ]; then
|
|---|
| 513 | if [ -f SIZE ]; then
|
|---|
| 514 | echo "FATAL ERROR: found SIZEu and SIZE!"
|
|---|
| 515 | return 11
|
|---|
| 516 | fi
|
|---|
| 517 | NEK_WARN="WARNING: SIZEu will be deprecated in a future release!"
|
|---|
| 518 | mv -v SIZEu SIZE
|
|---|
| 519 | fi
|
|---|
| 520 |
|
|---|
| 521 | if [ ! -f SIZE ]; then
|
|---|
| 522 | echo "FATAL ERROR: Cannot find SIZE!"
|
|---|
| 523 | return 11
|
|---|
| 524 | fi
|
|---|
| 525 |
|
|---|
| 526 | if ! cat SIZE | grep -qi 'lelr' ; then
|
|---|
| 527 | echo >>SIZE
|
|---|
| 528 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 529 | echo ' integer lelr' >>SIZE
|
|---|
| 530 | echo ' parameter (lelr=lelt) ! max number of local elements per restart file' >>SIZE
|
|---|
| 531 | fi
|
|---|
| 532 | if ! cat SIZE | grep -qi 'ldimt_proj' ; then
|
|---|
| 533 | echo >>SIZE
|
|---|
| 534 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 535 | echo ' integer ldimt_proj' >>SIZE
|
|---|
| 536 | echo ' parameter(ldimt_proj=1) ! max auxiliary fields residual projection ' >>SIZE
|
|---|
| 537 | fi
|
|---|
| 538 |
|
|---|
| 539 | # tweak leagacy SIZE file
|
|---|
| 540 | if ! cat SIZE | grep -q 'SIZE.inc' ; then
|
|---|
| 541 | NEK_WARN="WARNING: Deprecated SIZE will be removed in a future release!"
|
|---|
| 542 | if ! cat SIZE | grep -qi 'optlevel' ; then
|
|---|
| 543 | echo >>SIZE
|
|---|
| 544 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 545 | echo ' integer optlevel,loglevel' >>SIZE
|
|---|
| 546 | echo ' common /lolevels/ optlevel,loglevel' >>SIZE
|
|---|
| 547 | fi
|
|---|
| 548 | if ! cat SIZE | grep -qi 'lxo' ; then
|
|---|
| 549 | echo >>SIZE
|
|---|
| 550 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 551 | echo ' parameter(lxo = lx1) ! max output grid size (lxo>=lx1)' >>SIZE
|
|---|
| 552 | fi
|
|---|
| 553 | if ! cat SIZE | grep -qi 'ax1' ; then
|
|---|
| 554 | echo >>SIZE
|
|---|
| 555 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 556 | echo ' integer ax1,ay1,az1,ax2,ay2,az2' >> SIZE
|
|---|
| 557 | echo ' parameter (ax1=lx1,ay1=ly1,az1=lz1,ax2=lx2,ay2=ly2,az2=lz2) ! running averages' >> SIZE
|
|---|
| 558 | fi
|
|---|
| 559 | if ! cat SIZE | grep -qi 'lys=lxs' ; then
|
|---|
| 560 | cat SIZE | grep -iv lxs > SIZE.x; mv SIZE.x SIZE # Clean existing SIZE file of old version
|
|---|
| 561 | echo >>SIZE
|
|---|
| 562 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 563 | echo ' parameter (lxs=1,lys=lxs,lzs=(lxs-1)*(ldim-2)+1) !New Pressure Preconditioner' >> SIZE
|
|---|
| 564 |
|
|---|
| 565 | fi
|
|---|
| 566 | if ! cat SIZE | grep -qi 'lcvx1' ; then
|
|---|
| 567 | echo >>SIZE
|
|---|
| 568 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 569 | echo ' integer lcvx1,lcvy1,lcvz1,lcvelt' >> SIZE
|
|---|
| 570 | echo ' parameter (lcvx1=1,lcvy1=1,lcvz1=1,lcvelt=1) ! cvode arrays' >> SIZE
|
|---|
| 571 | fi
|
|---|
| 572 | if ! cat SIZE | grep -qi 'lfdm' ; then
|
|---|
| 573 | echo >>SIZE
|
|---|
| 574 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 575 | echo ' parameter (lfdm=0) ! == 1 for fast diagonalization method' >> SIZE
|
|---|
| 576 | fi
|
|---|
| 577 | if ! cat SIZE | grep -qi 'nsessmax' ; then
|
|---|
| 578 | echo >>SIZE
|
|---|
| 579 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 580 | echo ' parameter (nsessmax=1) ! max sessions to NEKNEK' >> SIZE
|
|---|
| 581 | fi
|
|---|
| 582 | if ! cat SIZE | grep -qi 'nmaxl_nn' ; then
|
|---|
| 583 | echo >>SIZE
|
|---|
| 584 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 585 | echo ' parameter (nmaxl_nn=' >> SIZE
|
|---|
| 586 | echo ' $ min(1+(nsessmax-1)*2*ldim*lxz*lelt,2*ldim*lxz*lelt))' >>SIZE
|
|---|
| 587 | fi
|
|---|
| 588 | if ! cat SIZE | grep -qi 'nfldmax_nn' ; then
|
|---|
| 589 | echo >>SIZE
|
|---|
| 590 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 591 | echo ' parameter (nfldmax_nn=' >> SIZE
|
|---|
| 592 | echo ' $ min(1+(nsessmax-1)*(ldim+1+ldimt),ldim+1+ldimt))' >>SIZE
|
|---|
| 593 | fi
|
|---|
| 594 | if ! cat SIZE | grep -qi 'nio' ; then
|
|---|
| 595 | echo >>SIZE
|
|---|
| 596 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 597 | echo ' common/IOFLAG/nio ! for logfile verbosity control' >> SIZE
|
|---|
| 598 | fi
|
|---|
| 599 |
|
|---|
| 600 | if ! cat SIZE | grep -qi 'toteq' ; then
|
|---|
| 601 | if [ $CMT -ne 0 ]; then
|
|---|
| 602 | echo >>SIZE
|
|---|
| 603 | echo 'c automatically added by makenek' >>SIZE
|
|---|
| 604 | echo ' integer toteq' >> SIZE
|
|---|
| 605 | echo ' parameter(toteq = 5 ) ! Number of conserved variables ' >>SIZE
|
|---|
| 606 | fi
|
|---|
| 607 | fi
|
|---|
| 608 | fi
|
|---|
| 609 |
|
|---|
| 610 | declare -a varlist=(
|
|---|
| 611 | "NEK_SOURCE_ROOT"
|
|---|
| 612 | "FC"
|
|---|
| 613 | "FFLAGS"
|
|---|
| 614 | "FCPP"
|
|---|
| 615 | "FR8"
|
|---|
| 616 | "FF77"
|
|---|
| 617 | "CC"
|
|---|
| 618 | "CFLAGS"
|
|---|
| 619 | "PPLIST"
|
|---|
| 620 | )
|
|---|
| 621 | if [ -f .state ]; then
|
|---|
| 622 | for i in "${varlist[@]}"
|
|---|
| 623 | do
|
|---|
| 624 | if ! cat .state | grep -q "$i=${!i}" ; then
|
|---|
| 625 | echo "configuration change detected, preparing fresh build"
|
|---|
| 626 | rm -rf .state
|
|---|
| 627 | while true; do
|
|---|
| 628 | read -p "do you want to rebuild all 3rd party dependencies too? [N]" yn
|
|---|
| 629 | case $yn in
|
|---|
| 630 | [Yy]* )
|
|---|
| 631 | clean_3rdparty;
|
|---|
| 632 | break ;;
|
|---|
| 633 | * )
|
|---|
| 634 | break ;;
|
|---|
| 635 | esac
|
|---|
| 636 | done
|
|---|
| 637 | make clean;
|
|---|
| 638 | break
|
|---|
| 639 | fi
|
|---|
| 640 | done ;
|
|---|
| 641 | fi
|
|---|
| 642 |
|
|---|
| 643 | rm -rf .state
|
|---|
| 644 | for i in "${varlist[@]}"
|
|---|
| 645 | do
|
|---|
| 646 | echo "$i=${!i}" >> .state
|
|---|
| 647 | done ;
|
|---|
| 648 |
|
|---|
| 649 | if [ $NODEP -ne 1 ]; then
|
|---|
| 650 | build_3rdparty
|
|---|
| 651 | fi
|
|---|
| 652 |
|
|---|
| 653 | return 0
|
|---|
| 654 | }
|
|---|