NAMD
Macros | Functions | Variables
ParseOptions.C File Reference
#include <stdlib.h>
#include <string.h>
#include "ParseOptions.h"
#include "ConfigList.h"
#include "InfoStream.h"
#include "strlib.h"
#include <tcl.h>

Go to the source code of this file.

Macros

#define dataelement_cons_macro_default(Mtype, MType, Mptr, Mdef)
 
#define dataelement_cons_macro(Mtype, MType, Mptr)
 
#define parse_input_macro_default(fctnname, type, optional)
 routines to add dependencies to the array More...
 
#define parse_input_macro(fctnname, type, optional)
 
#define parse_input_macro_default_b(fctnname, type, optional, extra)
 
#define parse_input_macro_b(fctnname, type, optional, extra)
 
#define parse_stringlist_macro(fctn, xxx)
 
#define set_macro(type, field, fieldptr)
 
#define simple_set_macro(type, field, fieldptr)
 
#define PRINT_DOUBLE(BUF, VAL)   Tcl_PrintDouble(0,VAL,BUF)
 

Functions

const char * rstring (Range r)
 
const char * ustring (Units u)
 
static Units next (Units u)
 
BigReal convert (Units to, Units from)
 
static char * Strdup (const char *newname)
 
 dataelement_cons_macro_default (BigReal, FLOAT, fptr, fdef)
 
 dataelement_cons_macro_default (int, INT, iptr, idef)
 
 dataelement_cons_macro_default (unsigned int, UINT, uiptr, uidef)
 
 dataelement_cons_macro_default (Vector, VECTOR, vptr, vdef)
 
 dataelement_cons_macro (BigReal, FLOAT, fptr)
 
 dataelement_cons_macro (Vector, VECTOR, vptr)
 
 dataelement_cons_macro (int, INT, iptr)
 
 dataelement_cons_macro (unsigned int, UINT, uiptr)
 
 dataelement_cons_macro (char, STRING, sptr)
 
 parse_input_macro (require, BigReal, FALSE)
 
 parse_input_macro (require, Vector, FALSE)
 
 parse_input_macro (require, int, FALSE)
 
 parse_input_macro (require, unsigned int, FALSE)
 
 parse_input_macro_b (requireB, int, FALSE, tmp->type=DataElement::BOOL)
 
 parse_input_macro (require, char, FALSE)
 
 parse_input_macro (optional, BigReal, TRUE)
 
 parse_input_macro (optional, Vector, TRUE)
 
 parse_input_macro (optional, int, TRUE)
 
 parse_input_macro (optional, unsigned int, TRUE)
 
 parse_input_macro_b (optionalB, int, TRUE, tmp->type=DataElement::BOOL)
 
 parse_input_macro (optional, char, TRUE)
 
 parse_input_macro_default (require, BigReal, FALSE)
 
 parse_input_macro_default (require, Vector, FALSE)
 
 parse_input_macro_default (require, int, FALSE)
 
 parse_input_macro_default (require, unsigned int, FALSE)
 
 parse_input_macro_default_b (requireB, int, FALSE, tmp->type=DataElement::BOOL)
 
 parse_input_macro_default (optional, BigReal, TRUE)
 
 parse_input_macro_default (optional, Vector, TRUE)
 
 parse_input_macro_default (optional, int, TRUE)
 
 parse_input_macro_default (optional, unsigned int, TRUE)
 
 parse_input_macro_default_b (optionalB, int, TRUE, tmp->type=DataElement::BOOL)
 
 parse_stringlist_macro (require, FALSE)
 
 parse_stringlist_macro (optional, TRUE)
 
 set_macro (float, fdata, fptr)
 
 set_macro (int, idata, iptr)
 
 set_macro (uint, uidata, uiptr)
 
 simple_set_macro (bool, idata, iptr)
 
 simple_set_macro (vector, vdata, vptr)
 
 simple_set_macro (stringlist, sldata, slptr)
 
static void PRINT_VECTOR (char *buf, Vector val)
 

Variables

static const char * unit_string_array [N_UNITS_UNDEFINED+1]
 
static BigReal scaling_factors [N_UNITS_UNDEFINED+1]
 

Macro Definition Documentation

#define dataelement_cons_macro (   Mtype,
  MType,
  Mptr 
)
Value:
const char *newparent, int optional, const char *err, \
Mtype *ptr) \
{ \
init(newname, newparent, optional, err); \
type = MType; \
Mptr = ptr; \
}
DataElement(const char *newname, const char *newparent, int optional, const char *err, BigReal *ptr, BigReal defalt)

Definition at line 153 of file ParseOptions.C.

#define dataelement_cons_macro_default (   Mtype,
  MType,
  Mptr,
  Mdef 
)
Value:
const char *newparent, int optional, const char *err, \
Mtype *ptr, Mtype defalt) \
{ \
init(newname, newparent, optional, err); \
type = MType; \
Mptr = ptr; \
Mdef = defalt; \
has_default = TRUE; \
if ( ptr ) *ptr = defalt; \
}
DataElement(const char *newname, const char *newparent, int optional, const char *err, BigReal *ptr, BigReal defalt)
if(ComputeNonbondedUtil::goMethod==2)
#define TRUE
Definition: common.h:119

Definition at line 140 of file ParseOptions.C.

#define parse_input_macro (   fctnname,
  type,
  optional 
)
Value:
int ParseOptions::fctnname(const char *parent, const char *newname, \
const char *msg, type *ptr) \
{ \
DataElement *tmp = new DataElement(newname, parent, optional, msg, \
ptr); \
if (!make_dependencies(tmp)) { \
iout << iERROR << "ParseOption '" << newname << "' already exists" << "\n" << endi; \
return FALSE; \
} \
add_element(tmp); \
return TRUE; \
}
#define FALSE
Definition: common.h:118
if(ComputeNonbondedUtil::goMethod==2)
#define iout
Definition: InfoStream.h:87
std::ostream & iERROR(std::ostream &s)
Definition: InfoStream.C:109
infostream & endi(infostream &s)
Definition: InfoStream.C:38
#define TRUE
Definition: common.h:119

Definition at line 284 of file ParseOptions.C.

#define parse_input_macro_b (   fctnname,
  type,
  optional,
  extra 
)
Value:
int ParseOptions::fctnname(const char *parent, const char *newname, \
const char *msg, type *ptr) \
{ \
DataElement *tmp = new DataElement(newname, parent, optional, msg, \
ptr); \
if (!make_dependencies(tmp)) { \
iout << iERROR << "ParseOption '" << newname << "' already exists" << "\n" << endi; \
return FALSE; \
} \
add_element(tmp); \
extra; \
return TRUE; \
}
#define FALSE
Definition: common.h:118
if(ComputeNonbondedUtil::goMethod==2)
#define iout
Definition: InfoStream.h:87
std::ostream & iERROR(std::ostream &s)
Definition: InfoStream.C:109
infostream & endi(infostream &s)
Definition: InfoStream.C:38
#define TRUE
Definition: common.h:119

Definition at line 311 of file ParseOptions.C.

#define parse_input_macro_default (   fctnname,
  type,
  optional 
)
Value:
int ParseOptions::fctnname(const char *parent, const char *newname, \
const char *msg, type *ptr, type defalt) \
{ \
DataElement *tmp = new DataElement(newname, parent, optional, msg, \
ptr, defalt); \
if (!make_dependencies(tmp)) { \
iout << iERROR << "ParseOption '" << newname << "' already exists" << "\n" << endi; \
return FALSE; \
} \
add_element(tmp); \
return TRUE; \
}
#define FALSE
Definition: common.h:118
if(ComputeNonbondedUtil::goMethod==2)
#define iout
Definition: InfoStream.h:87
std::ostream & iERROR(std::ostream &s)
Definition: InfoStream.C:109
infostream & endi(infostream &s)
Definition: InfoStream.C:38
#define TRUE
Definition: common.h:119

routines to add dependencies to the array

Definition at line 271 of file ParseOptions.C.

#define parse_input_macro_default_b (   fctnname,
  type,
  optional,
  extra 
)
Value:
int ParseOptions::fctnname(const char *parent, const char *newname, \
const char *msg, type *ptr, type defalt) \
{ \
DataElement *tmp = new DataElement(newname, parent, optional, msg, \
ptr, defalt); \
if (!make_dependencies(tmp)) { \
iout << iERROR << "ParseOption '" << newname << "' already exists" << "\n" << endi; \
return FALSE; \
} \
add_element(tmp); \
extra; \
return TRUE; \
}
#define FALSE
Definition: common.h:118
if(ComputeNonbondedUtil::goMethod==2)
#define iout
Definition: InfoStream.h:87
std::ostream & iERROR(std::ostream &s)
Definition: InfoStream.C:109
infostream & endi(infostream &s)
Definition: InfoStream.C:38
#define TRUE
Definition: common.h:119

Definition at line 297 of file ParseOptions.C.

#define parse_stringlist_macro (   fctn,
  xxx 
)
Value:
int ParseOptions::fctn(const char *parent, const char *newname, \
const char *msg, StringList **ptr, int many_allowed)\
{ \
DataElement *tmp = new DataElement(newname, parent, xxx, msg, \
ptr, many_allowed); \
if (!make_dependencies(tmp)) { \
iout << iERROR << "ParseOption '" << newname << "' already exists" << "\n" << endi;\
return FALSE; \
} \
add_element(tmp); \
return TRUE; \
}
#define FALSE
Definition: common.h:118
if(ComputeNonbondedUtil::goMethod==2)
#define iout
Definition: InfoStream.h:87
std::ostream & iERROR(std::ostream &s)
Definition: InfoStream.C:109
infostream & endi(infostream &s)
Definition: InfoStream.C:38
#define TRUE
Definition: common.h:119

Definition at line 352 of file ParseOptions.C.

#define PRINT_DOUBLE (   BUF,
  VAL 
)    Tcl_PrintDouble(0,VAL,BUF)

Definition at line 925 of file ParseOptions.C.

Referenced by ParseOptions::getfromptr(), and PRINT_VECTOR().

#define set_macro (   type,
  field,
  fieldptr 
)
Value:
int ParseOptions::set_##type(DataElement *el) \
{ \
if (el->range == FREE_RANGE || \
(el->range == POSITIVE && el->field > 0) || \
(el->range == NOT_NEGATIVE && el->field >= 0) || \
(el->range == NEGATIVE && el->field < 0) || \
(el->range == NOT_POSITIVE && el->field <= 0)) { \
if (el->fieldptr) *(el->fieldptr) = el->field; \
return 1; \
} \
iout << iERROR << "'" << el->name << "' was set to " << el->field << " but it " \
<< "should be " << rstring(el->range) \
<< "\n" << endi; \
return 0; \
}
if(ComputeNonbondedUtil::goMethod==2)
#define iout
Definition: InfoStream.h:87
const char * rstring(Range r)
Definition: ParseOptions.C:25
std::ostream & iERROR(std::ostream &s)
Definition: InfoStream.C:109
infostream & endi(infostream &s)
Definition: InfoStream.C:38

Definition at line 603 of file ParseOptions.C.

#define simple_set_macro (   type,
  field,
  fieldptr 
)
Value:
void ParseOptions::set_##type(DataElement *el) \
{ \
if (el->fieldptr) *(el->fieldptr) = el->field; \
}
if(ComputeNonbondedUtil::goMethod==2)

Definition at line 624 of file ParseOptions.C.

Function Documentation

BigReal convert ( Units  to,
Units  from 
)

Definition at line 89 of file ParseOptions.C.

References N_ANGSTROM, N_EV, N_FSEC, N_HOUR, N_KCAL, N_KELVIN, N_KJOULE, N_METER, N_MIN, N_NANOMETER, N_NSEC, N_SEC, and N_UNIT.

90 {
91 // cout << "Converting from " << string(from) << " to " << string(to) << std::endl;
92 // cout << scaling_factors[from] << " <--> " << scaling_factors[to] << std::endl;
93  if (from == N_UNIT && to == N_UNIT) { return 1.0; }
94  if ((from == N_NSEC || from == N_FSEC || from == N_SEC || from == N_MIN ||
95  from == N_HOUR) &&
96  (to == N_NSEC || to == N_FSEC || to == N_SEC || to == N_MIN ||
97  to == N_HOUR)) {
98  return scaling_factors[from]/scaling_factors[to];
99  }
100  if ((from == N_METER || from == N_NANOMETER || from == N_ANGSTROM) &&
101  (to == N_METER || to == N_NANOMETER || to == N_ANGSTROM)) {
102  return scaling_factors[from]/scaling_factors[to];
103  }
104  if ((from == N_KCAL || from == N_KJOULE || from == N_EV) &&
105  (to == N_KCAL || to == N_KJOULE || to == N_EV)) {
106  return scaling_factors[from]/scaling_factors[to];
107  }
108  if (from == N_KELVIN && to == N_KELVIN) {
109  return scaling_factors[from]/scaling_factors[to];
110  }
111  return 0.0;
112 }
static BigReal scaling_factors[N_UNITS_UNDEFINED+1]
Definition: ParseOptions.C:82
dataelement_cons_macro ( BigReal  ,
FLOAT  ,
fptr   
)
dataelement_cons_macro ( Vector  ,
VECTOR  ,
vptr   
)
dataelement_cons_macro ( int  ,
INT  ,
iptr   
)
dataelement_cons_macro ( unsigned  int,
UINT  ,
uiptr   
)
dataelement_cons_macro ( char  ,
STRING  ,
sptr   
)
dataelement_cons_macro_default ( BigReal  ,
FLOAT  ,
fptr  ,
fdef   
)
dataelement_cons_macro_default ( int  ,
INT  ,
iptr  ,
idef   
)
dataelement_cons_macro_default ( unsigned  int,
UINT  ,
uiptr  ,
uidef   
)
dataelement_cons_macro_default ( Vector  ,
VECTOR  ,
vptr  ,
vdef   
)
static Units next ( Units  u)
static

Definition at line 48 of file ParseOptions.C.

References N_ANGSTROM, N_EV, N_FSEC, N_HOUR, N_KCAL, N_KELVIN, N_KJOULE, N_METER, N_MIN, N_NANOMETER, N_NSEC, N_SEC, N_UNIT, and N_UNITS_UNDEFINED.

Referenced by ConfigList::add_element(), ResidueLookupElem::append(), bin_evaluation_1away(), bin_evaluation_k_away(), PDB::PDB(), Rebalancer::refine(), ParseOptions::set(), spatial_hashing(), ConfigList::~ConfigList(), and ReductionSet::~ReductionSet().

48  {
49  switch (u) {
50  case N_UNIT: return N_FSEC;
51  case N_FSEC: return N_NSEC;
52  case N_NSEC: return N_SEC;
53  case N_SEC: return N_MIN;
54  case N_MIN: return N_HOUR;
55  case N_HOUR: return N_ANGSTROM;
56  case N_ANGSTROM: return N_NANOMETER;
57  case N_NANOMETER: return N_METER;
58  case N_METER: return N_KCAL;
59  case N_KCAL: return N_KJOULE;
60  case N_KJOULE: return N_EV;
61  case N_EV: return N_KELVIN;
62  case N_KELVIN: return N_UNITS_UNDEFINED;
63  default: return N_UNITS_UNDEFINED;
64  }
65 }
parse_input_macro ( require  ,
BigReal  ,
FALSE   
)
parse_input_macro ( require  ,
Vector  ,
FALSE   
)
parse_input_macro ( require  ,
int  ,
FALSE   
)
parse_input_macro ( require  ,
unsigned  int,
FALSE   
)
parse_input_macro ( require  ,
char  ,
FALSE   
)
parse_input_macro ( optional  ,
BigReal  ,
TRUE   
)
parse_input_macro ( optional  ,
Vector  ,
TRUE   
)
parse_input_macro ( optional  ,
int  ,
TRUE   
)
parse_input_macro ( optional  ,
unsigned  int,
TRUE   
)
parse_input_macro ( optional  ,
char  ,
TRUE   
)
parse_input_macro_b ( requireB  ,
int  ,
FALSE  ,
tmp->  type = DataElement::BOOL 
)
parse_input_macro_b ( optionalB  ,
int  ,
TRUE  ,
tmp->  type = DataElement::BOOL 
)
parse_input_macro_default ( require  ,
BigReal  ,
FALSE   
)
parse_input_macro_default ( require  ,
Vector  ,
FALSE   
)
parse_input_macro_default ( require  ,
int  ,
FALSE   
)
parse_input_macro_default ( require  ,
unsigned  int,
FALSE   
)
parse_input_macro_default ( optional  ,
BigReal  ,
TRUE   
)
parse_input_macro_default ( optional  ,
Vector  ,
TRUE   
)
parse_input_macro_default ( optional  ,
int  ,
TRUE   
)
parse_input_macro_default ( optional  ,
unsigned  int,
TRUE   
)
parse_input_macro_default_b ( requireB  ,
int  ,
FALSE  ,
tmp->  type = DataElement::BOOL 
)
parse_input_macro_default_b ( optionalB  ,
int  ,
TRUE  ,
tmp->  type = DataElement::BOOL 
)
parse_stringlist_macro ( require  ,
FALSE   
)
parse_stringlist_macro ( optional  ,
TRUE   
)
static void PRINT_VECTOR ( char *  buf,
Vector  val 
)
static

Definition at line 927 of file ParseOptions.C.

References PRINT_DOUBLE, Vector::x, Vector::y, and Vector::z.

Referenced by ParseOptions::getfromptr().

927  {
928  PRINT_DOUBLE(buf, val.x);
929  buf += strlen(buf); buf[0] = ' '; ++buf;
930  PRINT_DOUBLE(buf, val.y);
931  buf += strlen(buf); buf[0] = ' '; ++buf;
932  PRINT_DOUBLE(buf, val.z);
933  buf += strlen(buf); buf[0] = ' '; buf[1] = 0;
934 }
BigReal z
Definition: Vector.h:66
BigReal x
Definition: Vector.h:66
#define PRINT_DOUBLE(BUF, VAL)
Definition: ParseOptions.C:925
BigReal y
Definition: Vector.h:66
const char* rstring ( Range  r)

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 25 of file ParseOptions.C.

References FREE_RANGE, NEGATIVE, NOT_NEGATIVE, NOT_POSITIVE, and POSITIVE.

26 {
27  switch (r) {
28  case FREE_RANGE: return "unconstrained";
29  case POSITIVE: return "positive";
30  case NOT_NEGATIVE: return "non-negative";
31  case NEGATIVE: return "negative";
32  case NOT_POSITIVE: return "non-positive";
33  default: return "error in rstring(Range )";
34  }
35 }
set_macro ( float  ,
fdata  ,
fptr   
)
set_macro ( int  ,
idata  ,
iptr   
)
set_macro ( uint  ,
uidata  ,
uiptr   
)
simple_set_macro ( bool  ,
idata  ,
iptr   
)
simple_set_macro ( vector  ,
vdata  ,
vptr   
)
simple_set_macro ( stringlist  ,
sldata  ,
slptr   
)
static char* Strdup ( const char *  newname)
static

Definition at line 114 of file ParseOptions.C.

115 {
116  char *tmp = new char[strlen(newname)+1];
117  strcpy(tmp, newname);
118  return tmp;
119 }
const char* ustring ( Units  u)

Definition at line 42 of file ParseOptions.C.

References unit_string_array.

Referenced by ParseOptions::units().

43 {
44  return unit_string_array[u];
45 }
static const char * unit_string_array[N_UNITS_UNDEFINED+1]
Definition: ParseOptions.C:37

Variable Documentation

BigReal scaling_factors[N_UNITS_UNDEFINED+1]
static
Initial value:
= {
1, 1, 1000, 1E15, 60E15, 3600E15, 1, 10, 1E10, 1, 1/4.1855, 1/23.052,
1, 0
}

Definition at line 82 of file ParseOptions.C.

const char* unit_string_array[N_UNITS_UNDEFINED+1]
static
Initial value:
= {
"", "fs", "ns", "sec", "min", "hr", "A", "nm", "m",
"kcal", "kJ", "eV", "K", "undefined units"
}

Definition at line 37 of file ParseOptions.C.

Referenced by ustring().