Skip to content
Snippets Groups Projects
Commit e804282d authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Merge branch 'v2.0-fixes' into v2.0

parents 8ad7c9b0 0a5ad68b
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
along with plumed. If not, see <http://www.gnu.org/licenses/>. along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#include "DLLoader.h" #include "DLLoader.h"
#include "Exception.h"
#ifdef __PLUMED_HAS_DLOPEN #ifdef __PLUMED_HAS_DLOPEN
#include <dlfcn.h> #include <dlfcn.h>
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
void* load(const std::string&); void* load(const std::string&);
/// Returns the last error in dynamic loader /// Returns the last error in dynamic loader
const std::string & error(); const std::string & error();
/// Returs true if the dynamic loader is available (on some systems it may not). /// Returns true if the dynamic loader is available (on some systems it may not).
static bool installed(); static bool installed();
}; };
......
...@@ -59,6 +59,12 @@ extensive error message can be added. ...@@ -59,6 +59,12 @@ extensive error message can be added.
if(a<=0) plumed_error(); if(a<=0) plumed_error();
if(a<=0) plumed_merror("a should be larger than zero"); if(a<=0) plumed_merror("a should be larger than zero");
\endverbatim \endverbatim
The additional macros
plumed_dbg_assert() and plumed_dbg_massert() are similar
to plumed_assert() and plumed_massert() respectively, but the corresponding
check is only performed when NDEBUG macro is not defined. They should
be used when the check is expensive and should be skipped in production
code.
By default, execution is terminated imediately and a message is printed on stderr. By default, execution is terminated imediately and a message is printed on stderr.
...@@ -133,7 +139,7 @@ public: ...@@ -133,7 +139,7 @@ public:
/// Conditionally print file/line/function information and exit when NDEBUG flag is not present /// Conditionally print file/line/function information and exit when NDEBUG flag is not present
#define plumed_dbg_assert(test) if(!(test)) throw PLMD::Exception("assertion failed " #test,__FILE__,__LINE__,__PRETTY_FUNCTION__) #define plumed_dbg_assert(test) if(!(test)) throw PLMD::Exception("assertion failed " #test,__FILE__,__LINE__,__PRETTY_FUNCTION__)
/// \relates PLMD::Exception /// \relates PLMD::Exception
/// Conditionally print file/line/function information plus msg and exit when NDEBUG flast is not present /// Conditionally print file/line/function information plus msg and exit when NDEBUG flag is not present
#define plumed_dbg_massert(test,msg) if(!(test)) throw PLMD::Exception("assertion failed " #test ", " msg,__FILE__,__LINE__,__PRETTY_FUNCTION__) #define plumed_dbg_massert(test,msg) if(!(test)) throw PLMD::Exception("assertion failed " #test ", " msg,__FILE__,__LINE__,__PRETTY_FUNCTION__)
#endif #endif
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
namespace PLMD{ namespace PLMD{
class Communicator;
/// Class containing the log stream. /// Class containing the log stream.
/// ///
/// It is similar to a FILE stream. It allows a printf() function, and /// It is similar to a FILE stream. It allows a printf() function, and
......
...@@ -26,10 +26,18 @@ ...@@ -26,10 +26,18 @@
namespace PLMD{ namespace PLMD{
/// Small utility class. /**
/// It has no implemented methods, and all its data are public. \ingroup TOOLBOX
/// It just simplify the syntax of functions which should pass the Small utility class that contains information about units.
/// value of all the units.
This class can be used to contain in a single place all the
information about units. Units are expressed in terms of
standard PLUMED units, i.e. kj/mol, nm, and ps.
Units can be set as double or as string. In the latter case,
one can also use strings such as kcal/mol.
*/
class Units{ class Units{
/// Units for energy, expressed in kj/mol (e.g. 4.184 means kcal/mol) /// Units for energy, expressed in kj/mol (e.g. 4.184 means kcal/mol)
double energy; double energy;
...@@ -41,19 +49,40 @@ class Units{ ...@@ -41,19 +49,40 @@ class Units{
double time; double time;
std::string timeString; std::string timeString;
public: public:
// Constructor, setting default values (1.0) /// Constructor, setting default values (1.0)
Units(); Units();
/// Set energy units from string.
/// Also understands the following strings:
/// kj/mol, kcal/mol, j/mol, and eV.
void setEnergy(const std::string &); void setEnergy(const std::string &);
/// Set time units from string.
/// Also understands the following strings:
/// ps, ns, fs.
void setTime(const std::string &); void setTime(const std::string &);
/// Set lengh units from string.
/// Also understands the following strings:
/// nm, A, um.
void setLength(const std::string &); void setLength(const std::string &);
void setEnergy(const double); /// Set energy units from double.
void setTime(const double); /// Should be specified in units of kj/mol (e.g. 4.184 means kcal/mol)
void setLength(const double); void setEnergy(double);
/// Set time units from double.
/// Should be specified in units of ps (e.g. 0.001 means fs)
void setTime(double);
/// Set lenght units from double.
/// Should be specified in units of nm (e.g. 0.1 means A)
void setLength(double);
/// Get energy units as double.
const double & getEnergy()const; const double & getEnergy()const;
/// Get length units as double.
const double & getLength()const; const double & getLength()const;
/// Get time units as double.
const double & getTime()const; const double & getTime()const;
/// Get energy units as string.
const std::string & getEnergyString()const; const std::string & getEnergyString()const;
/// Get length units as string.
const std::string & getLengthString()const; const std::string & getLengthString()const;
/// Get time units as string.
const std::string & getTimeString()const; const std::string & getTimeString()const;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment