ENH: use prefs.{csh,sh} to provide user/site configuration without

editing the respective settings files.

- foamEtcFile is used to find the files, thus follows the standard
  ~OpenFOAM/fileName expansion mechanism.
This commit is contained in:
Mark Olesen 2010-03-09 09:31:37 +01:00
parent 77f0192dac
commit 1f59eabd1d
5 changed files with 137 additions and 1 deletions

4
.gitignore vendored
View File

@ -55,6 +55,10 @@ doc/[Dd]oxygen/man
/*.html
/doc/*.html
# untracked configuration files
/etc/prefs.csh
/etc/prefs.sh
# source packages - anywhere
*.tar.bz2
*.tar.gz

View File

@ -54,6 +54,26 @@ foamInstall=$HOME/$WM_PROJECT
# note the location for later use (eg, in job scripts)
: ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
# Source files, possibly with some verbosity
_foamSource()
{
while [ $# -ge 1 ]
do
[ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1"
. $1
shift
done
}
# Add in user or site preset preferences.
foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh`
if [ $? -eq 0 ]
then
_foamSource $foamPrefs
fi
unset foamPrefs
# The old dirs to be cleaned from the various environment variables
# - remove anything under top-level directory.
# NB: the WM_PROJECT_INST_DIR might not be identical between versions

View File

@ -53,6 +53,15 @@ set foamInstall = $HOME/$WM_PROJECT
# note the location for later use (eg, in job scripts)
if ( ! $?FOAM_INST_DIR ) setenv FOAM_INST_DIR $foamInstall
# Source files, possibly with some verbosity
alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; source \!*'
# Add in user or site preset preferences.
set foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
if ( $status == 0 ) _foamSource $foamPrefs
unset foamPrefs
# The old dirs to be cleaned from the various environment variables
# - remove anything under top-level directory.
# NB: the WM_PROJECT_INST_DIR might not be identical between versions
@ -223,7 +232,6 @@ setenv MANPATH `$cleanProg "$MANPATH" "$foamOldDirs"`
# Source project setup files
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Executing: \!*"; source \!*'
_foamSource $WM_PROJECT_DIR/etc/settings.csh
_foamSource $WM_PROJECT_DIR/etc/aliases.csh

52
etc/prefs.csh-EXAMPLE Normal file
View File

@ -0,0 +1,52 @@
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# etc/prefs.csh
#
# Description
# Preset variables for the OpenFOAM configuration - C-Shell shell syntax.
#
# The prefs.csh file will be sourced by the OpenFOAM etc/cshrc when it is
# found by foamEtcFile.
#
# See Also
# 'foamEtcFile -help' or 'foamEtcFile -list' for information about the
# paths searched
#
#------------------------------------------------------------------------------
# Specify system compiler
# ~~~~~~~~~~~~~~~~~~~~~~~
set compilerInstall=system
# Specify system openmpi
# ~~~~~~~~~~~~~~~~~~~~~~
setenv WM_MPLIB SYSTEMOPENMPI
# Specify ParaView version
# ~~~~~~~~~~~~~~~~~~~~~~~~
setenv ParaView_VERSION 3.7.0 # eg, cvs/git version
# -----------------------------------------------------------------------------

52
etc/prefs.sh-EXAMPLE Normal file
View File

@ -0,0 +1,52 @@
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# etc/prefs.sh
#
# Description
# Preset variables for the OpenFOAM configuration - POSIX shell syntax.
#
# The prefs.sh file will be sourced by the OpenFOAM etc/bashrc when it is
# found by foamEtcFile.
#
# See Also
# 'foamEtcFile -help' or 'foamEtcFile -list' for information about the
# paths searched
#
#------------------------------------------------------------------------------
# Specify system compiler
# ~~~~~~~~~~~~~~~~~~~~~~~
compilerInstall=system
# Specify system openmpi
# ~~~~~~~~~~~~~~~~~~~~~~
export WM_MPLIB=SYSTEMOPENMPI
# Specify ParaView version
# ~~~~~~~~~~~~~~~~~~~~~~~~
export ParaView_VERSION=3.7.0 # eg, cvs/git version
# -----------------------------------------------------------------------------