From 1f59eabd1dcd79c9f6790c64b2458a979088514c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 9 Mar 2010 09:31:37 +0100 Subject: [PATCH] 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. --- .gitignore | 4 ++++ etc/bashrc | 20 +++++++++++++++++ etc/cshrc | 10 ++++++++- etc/prefs.csh-EXAMPLE | 52 +++++++++++++++++++++++++++++++++++++++++++ etc/prefs.sh-EXAMPLE | 52 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 etc/prefs.csh-EXAMPLE create mode 100644 etc/prefs.sh-EXAMPLE diff --git a/.gitignore b/.gitignore index f567511db3..3cc18eb468 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/etc/bashrc b/etc/bashrc index bb9d6215a8..c5a42761fc 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -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 diff --git a/etc/cshrc b/etc/cshrc index b0b6ec822f..e37bac6cbb 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -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 diff --git a/etc/prefs.csh-EXAMPLE b/etc/prefs.csh-EXAMPLE new file mode 100644 index 0000000000..3e7065fced --- /dev/null +++ b/etc/prefs.csh-EXAMPLE @@ -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 + +# ----------------------------------------------------------------------------- diff --git a/etc/prefs.sh-EXAMPLE b/etc/prefs.sh-EXAMPLE new file mode 100644 index 0000000000..7d03887ab4 --- /dev/null +++ b/etc/prefs.sh-EXAMPLE @@ -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 + +# -----------------------------------------------------------------------------