Cantera  2.0
include/cantera/base/mdp_allo.h
1 /**
2  * @file mdp_allo.h
3  * Declarations for Multi Dimensional Pointer (mdp) malloc routines, which
4  * allow for dimensioning of arbitrarily dimensioned pointer arrays using
5  * one call.
6  */
7 
8 /*
9  * Copyright 2004 Sandia Corporation. Under the terms of Contract
10  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
11  * retains certain rights in this software.
12  * See file License.txt for licensing information.
13  */
14 
15 #ifndef MDP_ALLO_H
16 #define MDP_ALLO_H
17 
18 #include <stdexcept>
19 
20 /*
21  * Include the header here in order to pick up size_t definition
22  */
23 #include <cstring>
24 
25 /**
26  * The mdp routines are extremely lightweight and fast fortran compatibile
27  * malloc routines for allocating multiple dimensioned arrays of doubles
28  * ints, char, and pointers using a single call. These routines don't
29  * use the std C+ lib routines.
30  *
31  * All calls are essentially wrappers around the routine mdp_alloc_array()
32  * which allocates multidimensioned arrays. The arrays contain room for
33  * the data and the pointer information that is used to access data
34  * in the object.
35  *
36  * One convention that is always used is that a pointer that is
37  * not malloced always has a value of zero. If the pointer is nonnull,
38  * then it may be freed, always (and vica-versa).
39  *
40  * Where possible, the low leve routines
41  * memcpy and memset are used to copy or zero memory.
42  *
43  * No array bounds checking is ever done within these routines. buyer beware.
44  * The bounds of arrays are not carried with the array object, ever.
45  * Bounds of arrays are input via the parameter list. Normally,
46  * for applications this is not a problem, since the application
47  * knows what the array dimensions are.
48  *
49  * There are several other general principles.
50  *
51  * If an allocation size is set to 0, then the actual
52  * allocation size is set to 1 within the program.
53  * Something is always allocated whenever a call is made
54  * to an mdp routine.
55  *
56  * All checks for allocations are always checked for success.
57  * If a failure is found, thene mdp_alloc_eh() is called
58  * for disposition of the error condition.
59  *
60  * Error handling behavior is set by the MDP_ALLO_errorOption external
61  * int. The default error behavior is to print an error message to stderr, and
62  * then throw an exception that inherited from std::exception. Usually
63  * std::bad_alloc() is thrown whenever there is a problem.
64  *
65  */
66 namespace mdp
67 {
68 
69 /**
70  * If we have array_alloc() from another Sandia program, we will not use
71  * the one from this mdp_array_alloc. Instead we will redefine the names
72  */
73 #ifdef HAVE_ARRAY_ALLOC
74 # define mdp_array_alloc array_alloc
75 # define mdp_safe_free safe_free
76 #endif
77 
78 /*!
79  * MDP_INT_NOINIT is a poor man's way of specifying whether a value should be
80  * initialized. These are seldom used numbers which can be used in place
81  * of real ints and dbls to indicate that initialization shouldn't take
82  * place.
83  */
84 #define MDP_INT_NOINIT -68361
85 
86 /*!
87  * MDP_DBL_NOINIT is a poor man's way of specifying whether a value should be
88  * initialized. These are seldom used numbers which can be used in place
89  * of real ints and dbls to indicate that initialization shouldn't take
90  * place.
91  */
92 #define MDP_DBL_NOINIT -1.241E11
93 
94 /*!
95  * Error Handling
96  * 7 print and exit
97  * 6 exit
98  * 5 print and create a divide by zero for stack trace analysis.
99  * 4 create a divide by zero for stack analysis trace
100  * 3 print a message and throw the std::bad_alloc() exception.
101  * 2 throw the std::bad_alloc() exception and be quiet.
102  * 1 print a message and return from package with the NULL pointer
103  * 0 Keep completely silent about the matter and return with
104  * a null pointer.
105  *
106  * -> Right now, the only way to change this option is to right here
107  *
108  * The default is to set it to 3.
109  */
110 extern int MDP_ALLO_errorOption;
111 
112 
113 /****************************************************************************/
114 /*
115  * Externals that should be set by the calling program.
116  * These are only used for debugging purposes.
117  */
118 #ifdef MDP_MPDEBUGIO
119 extern int MDP_MP_Nprocs;
120 extern int MDP_MP_myproc;
121 #endif
122 
123 /****************************************************************************/
124 /*
125  * MDP_SAFE_DELETE()
126  * This useful define is great for delete single instances of
127  * mallocing using new.
128  */
129 #define MDP_SAFE_DELETE(a) if (a) { delete (a); a = 0; }
130 
131 
132 /****************************************************************************/
133 
134 #define mdp_alloc_struct(x, num) (x *) mdp_array_alloc(1, (num), sizeof(x))
135 
136 
137 /* function declarations for dynamic array allocation */
138 
139 //! allocates multidimensional pointer arrays of arbitrary length
140 //! via a single malloc call
141 /*!
142  * The first dimension is the number of dimensions in the allocation
143  */
144 extern double* mdp_array_alloc(int numdim, ...);
145 
146 //! Free a vector and set its value to 0
147 /*!
148  * This function carries out the following operation
149  * @code
150  * free(*hndVec);
151  * *hndVec = 0;
152  * @endcode
153  *
154  * @param hndVec This is the address of the pointer, expressed as
155  * a void **
156  *
157  * Note, a key idea behind the mdp suite of routines is that
158  * a pointer that can be malloced is either malloced or its value
159  * is 0. This routine enforces this convention.
160  */
161 extern void mdp_safe_free(void** hndVec);
162 
163 //! Allocate a vector of integers
164 /*!
165  * The vector is initialized, unless the default int value is set
166  * to MDP_INT_NOINIT
167  *
168  * @param len Length of the vector
169  * @param defval Default value for the int, defaults to MDP_INT_NOINIT
170  *
171  * @return returns a pointer to the vector
172  */
173 extern int* mdp_alloc_int_1(int len, const int defval = MDP_INT_NOINIT);
174 
175 //! Allocate a vector of integers, potentially freeing memory first
176 /*!
177  * The vector is initialized, unless the default int value is set
178  * to MDP_INT_NOINIT
179  *
180  * Input
181  * --------------
182  * @param array_hdl Previous value of pointer. If non-NULL will try
183  * to free the memory at this address before doing
184  * a new alloc
185  * @param len Length of the vector
186  * @param defval Default value for the int, defaults to MDP_INT_NOINIT
187  *
188  * Output
189  * ---------
190  * @return *array_hdl = This value is initialized to the correct address
191  * of the array.
192  * A NULL value in the position indicates an error.
193  */
194 extern void mdp_safe_alloc_int_1(int** array_hdl, int len,
195  const int defval = MDP_INT_NOINIT);
196 
197 //! Reallocates a one dimensional array of ints, copying old
198 //! information to the new array
199 /*!
200  * Reallocates a one dimensional array of ints.
201  * This routine always allocates space for at least one int.
202  * Calls the smalloc() routine to ensure that all malloc
203  * calls go through one location. This routine will then copy
204  * the pertinent information from the old array to the
205  * new array.
206  *
207  * NewArray[0:old_len-1] = OldArray[0:old_len-1];
208  * NewArray[old_len:new_len-1] = defval;
209  *
210  * Input
211  * --------------
212  * @param array_hdl Previous value of pointer. If non-NULL will try
213  * to free the memory at this address before doing
214  * a new alloc
215  * @param new_len New Length of the vector
216  * @param old_len New Length of the vector
217  * @param defval Default value for the int, defaults to MDP_INT_NOINIT
218  *
219  * Output
220  * ---------
221  * @return *array_hdl = This value is initialized to the correct address
222  * of the array.
223  * A NULL value in the position indicates an error.
224  */
225 extern void mdp_realloc_int_1(int** array_hdl, int new_len, int old_len,
226  const int defval = MDP_INT_NOINIT);
227 
228 
229 //! Allocate a 2D matrix of integers
230 /*!
231  * The matrix is initialized, unless the default int value is set
232  * to MDP_INT_NOINIT, which is the default.
233  *
234  * matrix[len1][len2]
235  *
236  * All int data entries are contiguous. Therefore, it may
237  * be used as input into BLAS matrix function calls.
238  * This can be considered to be in fortran order format with
239  * len2 as the number of rows, and len1 as the number of columns.
240  *
241  * matrix[jcol] refers to the jcol column of the matrix.
242  * Therefore, matrix[0] is a pointer to the beginning of the
243  * data portion of the structure.
244  * The structure will have len1 pointers at the beginning
245  * that holds pointers into the top of the columns of the
246  * contiguous data.
247  *
248  * The entire structure may be deallocated via one free call.
249  *
250  * @param len1 Outer Length of the vector
251  * @param len2 Inner length of the matrix
252  * @param defval Default value for the int, defaults to MDP_INT_NOINIT
253  *
254  * @return returns a pointer to the matrix
255  */
256 extern int** mdp_alloc_int_2(int len1, int len2,
257  const int defval = MDP_INT_NOINIT);
258 
259 
260 //! Allocate and initialize a one dimensional array of doubles.
261 /*!
262  * As per the convention in mdp, this routine always initializes
263  * at least one slot.
264  *
265  * @param nvalues Length of the array. If this number is
266  * less than one, it is set to one. Therefore,
267  * This routine always initializes at least
268  * one double.
269  * @param val initialization value. Set it to the
270  * constant MDP_DBL_NOINIT if you don't
271  * want any initialization. memset() is
272  * used for zero initialization for fast
273  * execution speed.
274  *
275  * @return Pointer to the initialized array of doubles
276  * Failures are indicated by returning the NULL pointer.
277  */
278 extern double* mdp_alloc_dbl_1(int nvalues, const double val=MDP_DBL_NOINIT);
279 
280 //! Allocates and/or initializes a one dimensional array of doubles.
281 /*!
282  * This routine will free any old memory that was located at that
283  * position, before it will allocate a new vector.
284  *
285  * @param hndVec Previous value of pointer. If non-NULL will try
286  * to free the memory at this address. On output,
287  * this value is initialized to the correct address
288  * of the array. A NULL value in the position
289  * indicates an error.
290  * @param nvalues Length of the array
291  * @param val initialization value
292  *
293  */
294 extern void mdp_safe_alloc_dbl_1(double** hndVec, int nvalues,
295  const double val=MDP_DBL_NOINIT);
296 
297 //! Reallocate a vector of doubles possibly retaining a subset of values
298 /*!
299  * Reallocates the array and sets:
300  *
301  * (*hndVec)[0:oldLen-1] = oldVec[0:oldLen-1]
302  * (*hndVec)[oldLen:newLen] = defVal
303  *
304  * Input
305  * ------
306  * @param newLen New Length of the vector
307  *
308  * Output
309  * -------
310  * @param oldLen Old Length of the vector
311  *
312  */
313 extern void mdp_realloc_dbl_1(double** hndVec, int newLen, int oldLen,
314  const double defVal=MDP_DBL_NOINIT);
315 
316 //! Allocate and initialize a two dimensional array of doubles.
317 /*!
318  * Allocate a two dimensional array of doubles. The array is in
319  * fortran order and can be accessed via the following form:
320  *
321  * dblArray[ndim1][ndim2]
322  *
323  * Note, ndim2 is the inner dimension. i.e., the array is
324  * in column ordering.
325  *
326  * Input
327  * -------
328  * @param ndim1 Length of the first dimension of the array
329  * @param ndim2 Length of the second dimension of the array
330  * @param val Initialization value
331  *
332  *
333  * @return Pointer to the initialized array of doubles.
334  * Failures are indicated by returning the NULL pointer.
335  */
336 extern double** mdp_alloc_dbl_2(int ndim1, int ndim2, const double val);
337 
338 //! Allocate and initialize a two dimensional array of doubles.
339 /*!
340  * Allocate a two dimensional array of doubles. The array is in
341  * fortran order and can be accessed via the following form:
342  *
343  * (*arrayHndl)[ndim1][ndim2]
344  *
345  * Note, ndim2 is the inner dimension. i.e., the array is
346  * in column ordering.
347  *
348  * Input
349  * -------
350  * @param ndim1 Length of the first dimension of the array
351  * @param ndim2 Length of the second dimension of the array
352  * @param val Initialization value
353  * @param arrayHndl Handle to the array. If nonnull, the array
354  * is first freed. Failures are indicated
355  * by returning the NULL pointer.
356  */
357 extern void mdp_safe_alloc_dbl_2(double** *arrayHndl, int ndim1, int ndim2,
358  const double val = MDP_DBL_NOINIT);
359 
360 //! Reallocates a two dimensional array of doubles to a new set of
361 //! dimensions, copying the old results into the new array.
362 /*!
363  * This routine will then copy the pertinent information from
364  * the old array to the new array.
365  *
366  * If both old dimensions are set to zero or less, then this routine
367  * will free the old memory before mallocing the new memory. This may
368  * be a benefit for extremely large mallocs.
369  * In all other cases, the new and the old malloced arrays will
370  * exist for a short time together.
371  *
372  * Input
373  * -------
374  * @param hndArray = Pointer to the global variable that
375  * holds the old and (eventually new)
376  * address of the array of doubles to be reallocated
377  * @param ndim1 = First dimension of the new array
378  * @param ndim2 = Second dimension of the new array
379  * @param ndim1Old = First dimension of the old array
380  * @param ndim2Old = Second dimension of the old array
381  * @param defVal = Default fill value.
382  *
383  * Output
384  * --------------
385  * The resulting vector looks like this:
386  *
387  * (*hndArray)[0:ndim1Old-1][0:ndim2Old-1] = oldVec[0:ndim1Old-1][0:ndim2Old-1]
388  * (*hndArray)[ndim1Old:ndim1][ndim2Old:ndim2] = defVal
389  *
390  */
391 extern void mdp_realloc_dbl_2(double** * hndArray, int ndim1, int ndim2,
392  int ndim1Old, int ndim2Old,
393  const double defVal=MDP_DBL_NOINIT);
394 
395 //! Allocate and initialize a one dimensional array of characters.
396 /*!
397  * The array is always initialized.
398  *
399  * Input
400  * -------
401  * @param nvalues Length of the array
402  * @param val initialization value. defaults to the NULL char
403  *
404  * @return Pointer to the initialized character array
405  * Failures are indicated by returning the NULL pointer.
406  */
407 extern char* mdp_alloc_char_1(int nvalues, const char val = '\0');
408 
409 //! Allocate and initialize a one dimensional array of characters,
410 //! deallocating the space before hand.
411 /*!
412  * This routine will free any old memory that was located at that
413  * position, before it will allocate a new vector.
414  *
415  * The array is always initialized.
416  *
417  * @param arrayHnd Pointer to the global variable that
418  * holds the old and (eventually new)
419  * address of the array of char to be reallocated
420  * @param nvalues Length of the array
421  * @param val initialization value. defaults to the NULL char
422  *
423  * @return Pointer to the initialized character array
424  * Failures are indicated by returning the NULL pointer.
425  */
426 extern void mdp_safe_alloc_char_1(char** arrayHnd, int nvalues,
427  const char val = '\0');
428 
429 //! Allocate and initialize a vector of fixed-length
430 //! strings. Each string is initialized to the NULL string.
431 /*!
432  * @param numStrings Number of strings
433  * @param lenString Length of each string including the trailing null
434  * character
435  *
436  * @return Value is initialized to the correct address
437  * of the new array on exit.
438  * A NULL value in the position indicates an error.
439  */
440 extern char** mdp_alloc_VecFixedStrings(int numStrings, int lenString);
441 
442 //! Allocate and initialize an array of strings of fixed length
443 /*!
444  * @param numStrings Number of strings
445  * @param lenString Length of each string including the trailing null
446  * character
447  *
448  * @param array_hdl Value is initialized to the correct address
449  * of the new array on exit.
450  * A NULL value in the position indicates an error.
451  * If non-NULL on entry the routine will first
452  * free the memory at the address.
453  */
454 extern void mdp_safe_alloc_VecFixedStrings(char** *arrayHnd, int numStrings,
455  int lenString);
456 
457 //! Reallocate and initialize a vector of fixed-length strings.
458 /*!
459  * Each new string is initialized to the NULL string.
460  * Old strings are copied.
461  *
462  * @param array_hdl The pointer to the char ** location holding
463  * the data to be reallocated.
464  * @param numStrings Number of strings
465  * @param numOldStrings Number of old strings
466  * @param lenString Length of each string including the trailing null
467  * character
468  */
469 extern void mdp_realloc_VecFixedStrings(char** *array_hdl, int numStrings,
470  int numOldStrings, int lenString);
471 
472 //! Allocate and initialize a vector of pointers of type pointer to void.
473 /*!
474  * All pointers are initialized to the NULL value.
475  *
476  * @param numPointers Number of pointers
477  *
478  * @return This value is initialized to the correct address of the vector.
479  * A NULL value in the position indicates an error.
480  */
481 extern void** mdp_alloc_ptr_1(int numPointers);
482 
483 //! Allocate and initialize a vector of pointers of type pointer to void.
484 /*!
485  * All pointers are initialized to the NULL value.
486  *
487  * @param numPointers Number of pointers
488  * @param array_hdl This value is initialized to the correct address
489  * of the array.
490  * A NULL value in the position indicates an error.
491  * Previous value of pointer. If non-NULL will try
492  * to free the memory at this address.
493  */
494 extern void mdp_safe_alloc_ptr_1(void** *array_hnd, int numPointers);
495 
496 //! Reallocate and initialize a vector of pointers
497 /*!
498  * All old pointers are copied
499  * Each new pointer not associated with an old pointer is
500  * initialized to NULL.
501  *
502  * @param array_hdl The pointer to the char ** location holding
503  * the data to be reallocated.
504  * @param numLen Number of new pointers
505  * @param numOldLen Number of old pointers
506  */
507 extern void mdp_realloc_ptr_1(void** *array_hdl, int numLen, int numOldLen);
508 
509 //! Copies one ptr vector into another ptr vector
510 /*!
511  *
512  * @param copyFrom Vector of ptr values to be copied
513  * @param len Length of the vector
514  *
515  * @param copyTo Vector of values to receive the copy
516  */
517 extern void mdp_copy_ptr_1(void* const copyTo,
518  const void* const copyFrom, const int len);
519 
520 //! Duplicates one ptr vector into another ptr vector
521 /*!
522  * Mallocs a copy of one vector of pointers and returns the pointer
523  * to the copy.
524  *
525  * Input
526  * -------------
527  * @param *copyFrom Vector of ptr values to be copied
528  * @param len Length of the vector
529  *
530  * Output
531  * ------------
532  * @return Vector of values to receive the copy
533  */
534 extern void** mdp_dupl_ptr_1(const void* const copyFrom, int len);
535 
536 //! Copies an array of string vectors from one char ** vector to
537 //! another
538 /*!
539  * The space must have already been allocated within copyFrom and copyTo
540  * arrays. Overwrites are prevented by the proper application of the
541  * variable maxLenString. Strings are forced to be null-terminated
542  * Therefore copyTo[maxLenString-1] = '/0'
543  *
544  * Input
545  * -------
546  * @param copyFrom vector of C strings. It should be null terminated
547  * @param numStrings number of strings
548  * @param maxLenString maximum of the size of the string arrays,
549  * copyTo and copyFrom. This is used as the
550  * argument to strncpy() function.
551  *
552  * Output
553  * ------
554  * @param copyTo vector of strings
555  *
556  */
557 extern void mdp_copy_VecFixedStrings(char** const copyTo,
558  const char** const copyFrom,
559  int numStrings, size_t maxLenString);
560 
561 //! Allocates space for and copies a string
562 /*!
563  *
564  * @param copyFrom null terminated string. If NULL is supplied, then
565  * nothing is malloced and a NULL value is returned.
566  *
567  * @return This value is initialized to the correct address of the array.
568  * A NULL value in the position either indicates an error, or
569  * that the original pointer to the string was NULL.
570  */
571 extern char* mdp_copy_string(const char* const copyFrom);
572 
573 //! Allocates space for and copies a string
574 /*!
575  * @param stringHnd Previous value of pointer. If non-NULL will try
576  * to free the memory at this address.
577  *
578  * @param copyFrom null terminated string. If NULL is supplied, then
579  * nothing is malloced and a NULL value is returned.
580  *
581  * @return This value is initialized to the correct address of the array.
582  * A NULL value in the position either indicates an error, or
583  * that the original pointer to the string was NULL.
584  */
585 extern void mdp_safe_copy_string(char** stringHnd, const char* const copyFrom);
586 
587 //! Copy a double vector to a double vector
588 /*!
589  * copyTo[len] = copyFrom[len]
590  *
591  * Input
592  * -------
593  * @param copyFrom Vector to copy ( length >= len)
594  * @param len Length of the copy
595  *
596  * Output
597  * -------
598  * @param copyTo Vector to receive the copy ( length >= len)
599  */
600 extern void mdp_copy_dbl_1(double* const copyTo,
601  const double* const copyFrom,
602  const int len);
603 
604 //! Copy a double array to a double array
605 /*!
606  * This routine carries out a straight copy on the effective 1D description
607  * of each of the arrays. It copies
608  * the first len1*len2 doubless stored within copyFrom into the
609  * the first len1*len2 double slots in copyTo. It does not account
610  * for the actual dimensions of the two arrays.
611  *
612  * Input
613  * --------
614  * @param copyFrom Vector to copy ( length >= len1 * len2)
615  * @param len1 Length of the first dimension
616  * @param len2 Length of the second dimension
617  *
618  * Output
619  * ----------
620  * @param copyTo Array to receive the copy ( length >= len1 * len2)
621  */
622 extern void mdp_copy_dbl_2(double** const copyTo, const double** const copyFrom,
623  const int len1, const int len2);
624 
625 //! Copies one int vector into one int vector
626 /*!
627  * Input
628  * -------------
629  * @param copyFrom Vector of values to be copied
630  * @param len Length of the vector
631  *
632  * Output
633  * ------------
634  * *copyTo = Vector of values to receive the copy
635  */
636 extern void mdp_copy_int_1(int* const copyTo, const int* const copyFrom,
637  const int len);
638 
639 //! Copies one 2D int array into another 2D int array
640 /*!
641  * This routine carries out a straight copy. Actually it copies
642  * the first len1*len2 ints stored within copyFrom into the
643  * the first len1*len2 int slots in copyTo. It does not account
644  * for the actual dimensions of the two arrays.
645  *
646  * @param copyFrom Vector of values to be copied
647  * @param len1 Length of the first array
648  * @param len2 Length of the second array
649  * Output
650  * ------------
651  * @param copyTo Vector of values to receive the copy
652  */
653 extern void mdp_copy_int_2(int** const copyTo, const int** const copyFrom,
654  const int len1, const int len2);
655 
656 //! Assigns a single value to a double vector
657 /*!
658  * @param v Vector of values to be assigned
659  * @param value Value to assign with
660  * @param len Length of the vector
661  */
662 extern void mdp_init_dbl_1(double* const v, const double value, const int len);
663 
664 //! Zeroes a double vector
665 /*!
666  * @param v = Vector of values to be assigned
667  * @param len = Length of the vector
668  */
669 extern void mdp_zero_dbl_1(double* const v , const int len);
670 
671 //! Zeroes an int vector
672 /*!
673  * @param v = Vector of values to be assigned
674  * @param len = Length of the vector
675  */
676 extern void mdp_zero_int_1(int* const v , const int len);
677 
678 //! Assigns a single value to a double matrix. Contiguous data for the
679 //! matrix is assumed.
680 /*!
681  * Input
682  * -------------
683  * @param v matrix of values to be assigned
684  * @param value value to assign with
685  * @param len1 Length one of the vector
686  * @param len2 length two of the vector
687  */
688 extern void mdp_init_dbl_2(double** const v, const double value,
689  const int len1, const int len2);
690 
691 //! Assigns a single value to an int vector
692 /*!
693  * @param v Vector of values to be assigned
694  * @param value Value to assign with
695  * @param len Length of the vector
696  */
697 extern void mdp_init_int_1(int* const v, const int value, const int len);
698 
699 
700 /*
701  * Utility routines to check that a number is finite
702  */
703 
704 //! Utility routine to check to see that a number is neither zero
705 //! nor indefinite.
706 /*!
707  * This check can be used before using the number in a denominator.
708  *
709  * @param tmp number to be checked
710  */
711 extern void checkZeroFinite(const double tmp);
712 
713 //! Utility routine to check to see that a number is finite.
714 /*!
715  * @param tmp number to be checked
716  */
717 extern void checkFinite(const double tmp);
718 
719 //! Utility routine to link checkFinte() to fortran program
720 /*!
721  * This routine is accessible from fortran, usually
722  *
723  * @param tmp Pointer to the number to check
724  *
725  * @todo link it into the usual way Cantera handles Fortran calls
726  */
727 extern "C" void checkfinite_(double* tmp);
728 
729 //! utility routine to check that a double stays bounded
730 /*!
731  * This routine checks to see if a number stays bounded. The absolute
732  * value of the number is required to stay below the trigger.
733  *
734  * @param tmp Number to be checked
735  * @param trigger bounds on the number. Defaults to 1.0E20
736  */
737 extern void checkMagnitude(const double tmp, const double trigger = 1.0E20);
738 
739 } /* end of mdp namespace */
740 /****************************************************************************/
741 #endif
742 /****************************************************************************/
743