Skip to content
Snippets Groups Projects
Allrun 3.35 KiB
Newer Older
#!/bin/sh
#------------------------------------------------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
#   \\  /    A nd           | www.openfoam.com
#    \\/     M anipulation  |
#------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
#     Copyright (C) 2011-2016 OpenFOAM Foundation
#     Copyright (C) 2017-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
#     This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
#     Allrun
#
# Description
#     Run tutorial cases and summarize the outcome as 'testLoopReport'
#
#------------------------------------------------------------------------------
cd "${0%/*}" || exit    # Run from this directory
options:
  -collect          Collect logs only. Can be useful for aborted runs.
  -no-collect       Run without collecting logs
  -test             Pass -test argument to scripts, end of option processing
  --                End of option processing
  -help             print the usage

Run tutorial cases and summarize the outcome as 'testLoopReport'
    exit 0  # A clean exit
}

# Report error and exit
die()
{
    exec 1>&2
    echo
    echo "Error encountered:"
    while [ "$#" -ge 1 ]; do echo "    $1"; shift; done
    echo
    echo "See '${0##*/} -help' for usage"
    echo
    exit 1
}

#------------------------------------------------------------------------------
while [ "$#" -gt 0 ]
do
    case "$1" in
    ('') ;;
    (- | --)
        shift
        break   # Stop option parsing
    (-h | -help* | --help*)
        printHelp

    -collect)       optCollect=true ;;
    -no-collect)    optCollect=false ;;
    -test) break;;  # Pass-thru option, and stop option parsing

    -*) die "unknown option: $1" ;;
    *)  break;;     # Pass-thru arguments
    esac
    shift
done

#------------------------------------------------------------------------------
. ${WM_PROJECT_DIR:?}/bin/tools/LogFunctions    # Tutorial log-file functions
printRunHeader()
{
    echo "========================================"
    date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown"
    echo "$@: ${WM_PROJECT_DIR##*/}"
    echo "  $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
    echo "  ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
    echo "========================================"
}

printRunEnviron()
{
    echo "PATH:$PATH" | sed 's/::*/\n  /g'
    echo ==
    if [ -n "$DYLD_LIBRARY_PATH" ]
    then
        echo "DYLD_LIBRARY_PATH:$DYLD_LIBRARY_PATH" | sed 's/::*/\n  /g'
        echo ==
    fi
    if [ -n "$LD_LIBRARY_PATH" ]
    then
        echo "LD_LIBRARY_PATH:$LD_LIBRARY_PATH" | sed 's/::*/\n  /g'
        echo ==
    fi
}


if [ "$optCollect" != true ]
then
    printRunHeader "Starting run" | tee log.Allrun
    printRunEnviron | tee -a log.Allrun

    foamRunTutorials -self $*   # Run recursively but avoid self

    printRunHeader "Finishing run" | tee -a log.Allrun
fi

if [ "$optCollect" = false ]
    echo "Collecting log files - disabled"
else
    # Collect log files as 'testLoopReport'
    collectLogs
#------------------------------------------------------------------------------