Commit ca1ef807 authored by Sergio Ferraris's avatar Sergio Ferraris
Browse files

Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

parents b69ebd9e 328f44b3
......@@ -487,9 +487,31 @@ case QSMPI:
breaksw
case SGIMPI:
setenv FOAM_MPI ${MPI_ROOT##*/}
if ( ! $?MPI_ROOT) setenv MPI_ROOT /dummy
if ( ! -d "$MPI_ROOT" ) then
echo "Warning in $WM_PROJECT_DIR/etc/config/settings.csh:"
echo " MPI_ROOT not a valid mpt installation directory."
echo " Please set MPI_ROOT to the mpt installation directory."
echo " (usually done by loading the mpt module)"
echo " MPI_ROOT currently set to '$MPI_ROOT'"
endif
if ( "${MPI_ROOT:h}/" == $MPI_ROOT ) then
setenv MPI_ROOT ${MPI_ROOT:h}
endif
setenv FOAM_MPI ${MPI_ROOT:t}
setenv MPI_ARCH_PATH $MPI_ROOT
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using SGI MPT:"
echo " MPI_ROOT : $MPI_ROOT"
echo " FOAM_MPI : $FOAM_MPI"
endif
_foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib
breaksw
......
......@@ -511,9 +511,30 @@ QSMPI)
;;
SGIMPI)
lastCharID=$(( ${#MPI_ROOT} - 1 ))
if [ "${MPI_ROOT:$lastCharID:1}" == '/' ]
then
MPI_ROOT=${MPI_ROOT:0:$lastCharID}
fi
export FOAM_MPI=${MPI_ROOT##*/}
export MPI_ARCH_PATH=$MPI_ROOT
if [ -d "$MPI_ROOT" -o -z "$MPI_ARCH_PATH" ]
then
echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:" 1>&2
echo " MPI_ROOT not a valid mpt installation directory or ending in a '/'." 1>&2
echo " Please set MPI_ROOT to the mpt installation directory." 1>&2
echo " MPI_ROOT currently set to '$MPI_ROOT'" 1>&2
fi
if [ "$FOAM_VERBOSE" -a "$PS1" ]
then
echo "Using SGI MPT:"
echo " MPI_ROOT : $MPI_ROOT"
echo " FOAM_MPI : $FOAM_MPI"
fi
_foamAddPath $MPI_ARCH_PATH/bin
_foamAddLib $MPI_ARCH_PATH/lib
;;
......
......@@ -58,6 +58,11 @@ OptimisationSwitches
commsType nonBlocking; //scheduled; //blocking;
floatTransfer 0;
nProcsSimpleSum 0;
// Force dumping (at next timestep) upon signal (-1 to disable)
writeNowSignal -1; //10;
// Force dumping (at next timestep) upon signal (-1 to disable) and exit
stopAtWriteNowSignal -1;
}
......
......@@ -2,6 +2,8 @@ signals/sigFpe.C
signals/sigSegv.C
signals/sigInt.C
signals/sigQuit.C
signals/sigStopAtWriteNow.C
signals/sigWriteNow.C
regExp.C
timer.C
fileStat.C
......
......@@ -123,7 +123,7 @@ bool Foam::setEnv
}
Foam::word Foam::hostName(bool full)
Foam::string Foam::hostName(bool full)
{
char buf[128];
::gethostname(buf, sizeof(buf));
......@@ -142,7 +142,7 @@ Foam::word Foam::hostName(bool full)
}
Foam::word Foam::domainName()
Foam::string Foam::domainName()
{
char buf[128];
::gethostname(buf, sizeof(buf));
......@@ -159,11 +159,11 @@ Foam::word Foam::domainName()
}
}
return word::null;
return string::null;
}
Foam::word Foam::userName()
Foam::string Foam::userName()
{
struct passwd* pw = ::getpwuid(::getuid());
......@@ -173,7 +173,7 @@ Foam::word Foam::userName()
}
else
{
return word::null;
return string::null;
}
}
......@@ -209,7 +209,7 @@ Foam::fileName Foam::home()
}
Foam::fileName Foam::home(const word& userName)
Foam::fileName Foam::home(const string& userName)
{
struct passwd* pw;
......@@ -1069,7 +1069,7 @@ void Foam::fdClose(const int fd)
bool Foam::ping
(
const word& destName,
const string& destName,
const label destPort,
const label timeOut
)
......@@ -1083,7 +1083,7 @@ bool Foam::ping
{
FatalErrorIn
(
"Foam::ping(const word&, ...)"
"Foam::ping(const string&, ...)"
) << "gethostbyname error " << h_errno << " for host " << destName
<< abort(FatalError);
}
......@@ -1097,7 +1097,7 @@ bool Foam::ping
{
FatalErrorIn
(
"Foam::ping(const word&, const label)"
"Foam::ping(const string&, const label)"
) << "socket error"
<< abort(FatalError);
}
......@@ -1149,7 +1149,7 @@ bool Foam::ping
}
bool Foam::ping(const word& hostname, const label timeOut)
bool Foam::ping(const string& hostname, const label timeOut)
{
return ping(hostname, 222, timeOut) || ping(hostname, 22, timeOut);
}
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "sigStopAtWriteNow.H"
#include "error.H"
#include "JobInfo.H"
#include "IOstreams.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// Signal number to catch
int Foam::sigStopAtWriteNow::signal_
(
debug::optimisationSwitch("stopAtWriteNowSignal", -1)
);
static Foam::Time const* runTimePtr_ = NULL;
struct sigaction Foam::sigStopAtWriteNow::oldAction_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sigStopAtWriteNow::sigHandler(int)
{
// Reset old handling
if (sigaction(signal_, &oldAction_, NULL) < 0)
{
FatalErrorIn
(
"Foam::sigStopAtWriteNow::sigHandler(int)"
) << "Cannot reset " << signal_ << " trapping"
<< abort(FatalError);
}
// Update jobInfo file
jobInfo.signalEnd();
Info<< "sigStopAtWriteNow :"
<< " setting up write and stop at end of the next iteration"
<< nl << endl;
runTimePtr_->stopAt(Time::saWriteNow);
//// Throw signal (to old handler)
//raise(signal_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sigStopAtWriteNow::sigStopAtWriteNow(){}
Foam::sigStopAtWriteNow::sigStopAtWriteNow
(
const bool verbose,
const Time& runTime
)
{
if (signal_ > 0)
{
// Store runTime
runTimePtr_ = &runTime;
struct sigaction newAction;
newAction.sa_handler = sigHandler;
newAction.sa_flags = SA_NODEFER;
sigemptyset(&newAction.sa_mask);
if (sigaction(signal_, &newAction, &oldAction_) < 0)
{
FatalErrorIn
(
"Foam::sigStopAtWriteNow::sigStopAtWriteNow"
"(const bool, const Time&)"
) << "Cannot set " << signal_ << " trapping"
<< abort(FatalError);
}
if (verbose)
{
Info<< "sigStopAtWriteNow :"
<< " Enabling writing and stopping upon signal " << signal_
<< endl;
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sigStopAtWriteNow::~sigStopAtWriteNow()
{
// Reset old handling
if (signal_ > 0)
{
if (sigaction(signal_, &oldAction_, NULL) < 0)
{
FatalErrorIn
(
"Foam::sigStopAtWriteNow::~sigStopAtWriteNow()"
) << "Cannot reset " << signal_ << " trapping"
<< abort(FatalError);
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sigStopAtWriteNow::active() const
{
return signal_ > 0;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::sigStopAtWriteNow
Description
Signal handler for interupt defined by
OptimisationSwitches::stopAtWriteNowSignal
Write and stop the job.
SourceFiles
sigStopAtWriteNow.C
\*---------------------------------------------------------------------------*/
#ifndef sigStopAtWriteNow_H
#define sigStopAtWriteNow_H
#include <signal.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class Time;
/*---------------------------------------------------------------------------*\
Class sigStopAtWriteNow Declaration
\*---------------------------------------------------------------------------*/
class sigStopAtWriteNow
{
// Private data
//- number of signal to use
static int signal_;
//- Saved old signal trapping setting
static struct sigaction oldAction_;
// Private Member Functions
static void sigHandler(int);
public:
// Constructors
//- Construct null
sigStopAtWriteNow();
//- Construct from components
sigStopAtWriteNow(const bool verbose, const Time& runTime);
//- Destructor
~sigStopAtWriteNow();
// Member functions
//- Is active?
bool active() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "sigWriteNow.H"
#include "error.H"
#include "JobInfo.H"
#include "IOstreams.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// Signal number to catch
int Foam::sigWriteNow::signal_
(
debug::optimisationSwitch("writeNowSignal", -1)
);
static Foam::Time* runTimePtr_ = NULL;
struct sigaction Foam::sigWriteNow::oldAction_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::sigWriteNow::sigHandler(int)
{
Info<< "sigWriteNow :"
<< " setting up write at end of the next iteration" << nl << endl;
runTimePtr_->writeOnce();
//// Throw signal (to old handler)
//raise(signal_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sigWriteNow::sigWriteNow()
{}
Foam::sigWriteNow::sigWriteNow(const bool verbose, Time& runTime)
{
if (signal_ >= 0)
{
// Store runTime
runTimePtr_ = &runTime;
struct sigaction newAction;
newAction.sa_handler = sigHandler;
newAction.sa_flags = SA_NODEFER;
sigemptyset(&newAction.sa_mask);
if (sigaction(signal_, &newAction, &oldAction_) < 0)
{
FatalErrorIn
(
"Foam::sigWriteNow::sigWriteNow(const bool, const Time&)"
) << "Cannot set " << signal_ << " trapping"
<< abort(FatalError);
}
if (verbose)
{
Info<< "sigWriteNow :"
<< " Enabling writing upon signal " << signal_
<< endl;
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sigWriteNow::~sigWriteNow()
{
// Reset old handling
if (signal_ > 0)
{
if (sigaction(signal_, &oldAction_, NULL) < 0)
{
FatalErrorIn
(
"Foam::sigWriteNow::~sigWriteNow()"
) << "Cannot reset " << signal_ << " trapping"
<< abort(FatalError);
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::sigWriteNow::active() const
{
return signal_ > 0;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::sigWriteNow
Description
Signal handler for interupt defined by OptimisationSwitches::writeNowSignal
Write once and continue.
SourceFiles
sigWriteNow.C
\*---------------------------------------------------------------------------*/
#ifndef sigWriteNow_H
#define sigWriteNow_H
#include <signal.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class Time;
/*---------------------------------------------------------------------------*\
Class sigWriteNow Declaration
\*---------------------------------------------------------------------------*/
class sigWriteNow
{
// Private data
//- number of signal to use
static int signal_;
//- Saved old signal trapping setting
static struct sigaction oldAction_;
// Private Member Functions
static void sigHandler(int);
public:
// Constructors
//- Construct null
sigWriteNow();
//- Construct from components
sigWriteNow(const bool verbose, Time& runTime);
//- Destructor
~sigWriteNow();
// Member functions
//- Is active?
bool active() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam