openfoam-selector.csh.in 1.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
# -*- sh -*-
# Copyright (c) 2007 Cisco Systems, Inc.  All rights reserved.
# Copyright (C) 2018 OpenCFD Ltd.
#
# File installed for C-shell startups to select which OPENFOAM
# installation to use.  Not using "alternatives" because we want to be
# able to set per-user level defaults, not just system-wide defaults.

set openfoam_selector_dir="@OPENFOAM_SELECTOR_DATADIR@"
set openfoam_selector_homefile="$HOME/@OPENFOAM_SELECTOR_HOME_FILE@"
set openfoam_selector_sysfile="@OPENFOAM_SELECTOR_SYSCONFDIR@/@OPENFOAM_SELECTOR_SYSCONFIG_FILE@"

# The selection name
set openfoam_selection=
if ( -f "$openfoam_selector_homefile" ) then
    set openfoam_selection=`cat $openfoam_selector_homefile`
else if ( -f "$openfoam_selector_sysfile" ) then
    set openfoam_selection=`cat $openfoam_selector_sysfile`
endif

# 1st: get selection name -> directory name correspondence
if ("$openfoam_selection" != "" && -f "$openfoam_selector_dir/$openfoam_selection") then
    openfoam_selection=`cat "$openfoam_selector_dir/$openfoam_selection"`

    # 2nd: test for and source OpenFOAM etc/cshrc
    if ("$openfoam_selection" != "" && -f "$openfoam_selection/etc/cshrc") then
        source "$openfoam_selection/etc/cshrc"
    fi
fi
# -----------------------------------------------------------------------------