#!/usr/bin/bash
#
# Remove all MOLA log files, cache files, debug files, status files and plots


display_help() {
    echo "Usage: $0 [option...]" >&2
    echo
    echo "   remove all MOLA log files, cache files, debug files, status files and plots"
    echo
    echo "   -h, --help           display help"
    echo "   -f, --full           remove also MOLA inputs and outputs"
    echo
    exit 1
}

remove_inputs() {
    echo "remove all MOLA inputs"
    rm -f main.cgns 
    rm -f compute.py coprocess.py job.sh 
    rm -f mask.cgns hub_shroud_lines*
}

remove_outputs() {
    echo "remove all MOLA outputs"
    rm -rf OUTPUT
    rm -rf RadialProfiles/*
}

remove_logs() {
    echo "remove all MOLA log files, cache files, debug files, status files and plots"
    # remove cache
    rm -rf __pycache__ *.pyc TurboVariables
    # remove logs
    rm -rf LOGS *.log elsA_MPI_* 
    # remove core files in case of bugs
    rm -f bk00* core* debug_* dbg_*
    # remove MOLA status files
    rm -f COMPLETED FAILED NEWJOB_REQUIRED ERROR_PREPARING_WORKFLOW
}

while [[ "$#" -gt 0 ]]; do
    case $1 in
        -h|--help) 
            display_help
            exit;;
        -f|--full)
            remove_inputs; remove_outputs;;
        *) 
            echo "Unknown parameter passed: $1" 
            display_help;;
    esac
    shift
done

remove_logs
