cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cddefines.h
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2013 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 
4 #ifndef CDDEFINES_H_
5 #define CDDEFINES_H_
6 
7 #include "cdstd.h"
8 
9 #ifdef _MSC_VER
10 /* disable warning that conditional expression is constant, true or false in if */
11 # pragma warning( disable : 4127 )
12 /* we are not using MS foundation class */
13 # ifndef WIN32_LEAN_AND_MEAN
14 # define WIN32_LEAN_AND_MEAN
15 # endif
16 #endif
17 
18 #ifdef __clang__
19 // this would generate lots of warnings about mismatched tags in the STL valarray definition
20 #pragma clang diagnostic ignored "-Wmismatched-tags"
21 #endif
22 
23 /* these headers are needed by all files */
24 /*lint -e129 these resolve several issues pclint has with my system headers */
25 /*lint -e78 */
26 /*lint -e830 */
27 /*lint -e38 */
28 /*lint -e148 */
29 /*lint -e114 */
30 /*lint -e18 */
31 /*lint -e49 */
32 // C++ versions of C headers
33 #include <cstdio>
34 #include <cstdlib>
35 #include <cctype>
36 #ifdef _MSC_VER
37 // MSVC needs this before cmath in order provide numeric constants
38 // (M_PI etc.) defined by C99 but not C++ standards to date.
39 #define _USE_MATH_DEFINES
40 #endif
41 #include <cmath>
42 #include <cassert>
43 #include <cstring>
44 #include <cfloat>
45 #include <climits>
46 #include <ctime>
47 #if defined(__sun) && defined(__SUNPRO_CC)
48 // with Solaris Studio 12.2 under Sparc Solaris, csignal doesn't define sigaction...
49 #include <signal.h>
50 #else
51 #include <csignal>
52 #endif
53 // C++ headers
54 #include <limits>
55 #include <string>
56 #include <sstream>
57 #include <iomanip>
58 #include <vector>
59 #include <valarray>
60 #include <complex>
61 #include <map>
62 #include <memory>
63 #include <stdexcept>
64 #include <algorithm>
65 #include <fstream>
66 #include <bitset>
67 #ifdef DMALLOC
68 #include <dmalloc.h>
69 #endif
70 
71 // Workaround for Windows...
72 #if defined(_MSC_VER) && !defined(SYS_CONFIG)
73 #define SYS_CONFIG "cloudyconfig_vs.h"
74 #endif
75 
76 // platform specific configuration; generated by configure.sh
77 #ifdef SYS_CONFIG
78 #include SYS_CONFIG
79 #else
80 #include "cloudyconfig.h"
81 #endif
82 
83 #ifdef MPI_GRID_RUN
84 #define MPI_ENABLED
85 #endif
86 
87 /*lint +e18 */
88 /*lint +e49 */
89 /*lint +e38 */
90 /*lint +e148 */
91 /*lint +e830 */
92 /*lint +e78 */
93 /*lint -e129 */
94 
95 using namespace std;
96 
97 #undef STATIC
98 #ifdef USE_GPROF
99 #define STATIC
100 #else
101 #define STATIC static
102 #endif
103 
104 #ifdef FLT_IS_DBL
105 typedef double realnum;
106 #else
107 typedef float realnum;
108 #endif
109 
110 typedef float sys_float;
111 // prevent explicit float's from creeping back into the code
112 #define float PLEASE_USE_REALNUM_NOT_FLOAT
113 
114 //Compile-time assertion after Alexandrescu
115 template<bool> struct StaticAssertFailed;
116 template<> struct StaticAssertFailed<true> {};
117 #define STATIC_ASSERT(x) ((void)StaticAssertFailed< (x) == true >())
118 
119 typedef enum {
120  ES_SUCCESS=0, // everything went fine...
121  ES_FAILURE=1, // general failure exit
122  ES_WARNINGS, // warnings were present
123  ES_BOTCHES, // botched monitors were present
124  ES_CLOUDY_ABORT, // Cloudy aborted
125  ES_BAD_ASSERT, // an assert in the code failed
126  ES_BAD_ALLOC, // a memory allocation failed
127  ES_OUT_OF_RANGE, // an out-of-range exception was thrown
128  ES_USER_INTERRUPT, // the user terminated Cloudy (with ^C)
129  ES_TERMINATION_REQUEST, // Cloudy received a termination request
130  ES_ILLEGAL_INSTRUCTION, // the CPU encountered an illegal instruction
131  ES_FP_EXCEPTION, // a floating point exception was caught
132  ES_SEGFAULT, // a segmentation fault occurred
133  ES_BUS_ERROR, // a bus error occurred
134  ES_UNKNOWN_SIGNAL, // an unknown signal was caught
135  ES_UNKNOWN_EXCEPTION, // an unknown exception was caught
136  ES_TOP // NB NB -- this should always be the last entry
137 } exit_type;
138 
139 // make sure the system definitions are on par with ours
140 // especially EXIT_FAILURE does not have a guaranteed value!
141 #undef EXIT_SUCCESS
142 #define EXIT_SUCCESS ES_SUCCESS
143 #undef EXIT_FAILURE
144 #define EXIT_FAILURE ES_FAILURE
145 
146 /* make sure this is globally visible as well! */
147 /* This must be done at the start of every file, to ensure that policy
148  for FPE handling, etc., is guaranteed to be set up before the
149  construction of file-statics and globals. */
150 #include "cpu.h"
151 
152 //*************************************************************************
153 //
171 //
172 // This implementation has been obtained from Wikipedia
173 //
174 //*************************************************************************
175 
176 template<typename T> class Singleton
177 {
178 public:
179  static T& Inst()
180  {
181  static T instance; // assumes T has a protected default constructor
182  return instance;
183  }
184 };
185 
186 /**************************************************************************
187  *
188  * these are variables and pointers for output from the code, used everywhere
189  * declared extern here, and definition is in cddefines.cpp
190  *
191  **************************************************************************/
192 
196 extern FILE *ioQQQ;
197 
198 extern FILE *ioStdin;
199 
200 extern FILE *ioMAP;
201 
204 extern FILE* ioPrnErr;
205 
207 extern bool lgAbort;
208 
211 extern bool lgTestCodeCalled;
212 
215 extern bool lgTestCodeEnabled;
216 
219 extern bool lgPrnErr;
220 
223 extern long int nzone;
224 
226 extern double fnzone;
227 
230 extern long int iteration;
231 
238 extern const double ZeroNum;
239 
240 /**************************************************************************
241  *
242  * these are constants used to dimension several vectors and index arrays
243  *
244  **************************************************************************/
245 
250 const int FILENAME_PATH_LENGTH = 200;
251 
254 
258 const int INPUT_LINE_LENGTH = 2000;
259 
262 const int LIMELM = 30;
263 
265 const int NISO = 2;
266 
270 const int NHYDRO_MAX_LEVEL = 401;
271 
273 const double MAX_DENSITY = 1.e24;
274 
276 const double DEPTH_OFFSET = 1.e-30;
277 
278 enum {CHARS_SPECIES=10};
279 enum {CHARS_ISOTOPE_SYM = 6};
280 
281 /* indices within recombination coefficient array */
282 /* ipRecEsc is state specific escape probability*/
283 const int ipRecEsc = 2;
284 /* the net escaping, including destruction by background and optical deepth*/
285 const int ipRecNetEsc = 1;
286 /* ipRecRad is state specific radiative recombination rate*/
287 const int ipRecRad = 0;
292 /* these specify the form of the line redistribution function */
293 /* partial redistribution with wings */
294 const int ipPRD = 1;
295 /* complete redistribution, core only, no wings, Hummer's K2 function */
296 const int ipCRD = -1;
297 /* complete redistribution with wings */
298 const int ipCRDW = 2;
299 /* redistribution function for Lya, calls Hummer routine for H-like series only */
300 const int ipLY_A = -2;
301 /* core function for K2 destruction */
302 const int ipDEST_K2 = 1;
303 /* core function for complete redist destruction */
304 const int ipDEST_INCOM = 2;
305 /* core function for simple destruction */
306 const int ipDEST_SIMPL = 3;
307 
309 const int ipHYDROGEN = 0;
310 const int ipHELIUM = 1;
311 const int ipLITHIUM = 2;
312 const int ipBERYLLIUM = 3;
313 const int ipBORON = 4;
314 const int ipCARBON = 5;
315 const int ipNITROGEN = 6;
316 const int ipOXYGEN = 7;
317 const int ipFLUORINE = 8;
318 const int ipNEON = 9;
319 const int ipSODIUM = 10;
320 const int ipMAGNESIUM = 11;
321 const int ipALUMINIUM = 12;
322 const int ipSILICON = 13;
323 const int ipPHOSPHORUS = 14;
324 const int ipSULPHUR = 15;
325 const int ipCHLORINE = 16;
326 const int ipARGON = 17;
327 const int ipPOTASSIUM = 18;
328 const int ipCALCIUM = 19;
329 const int ipSCANDIUM = 20;
330 const int ipTITANIUM = 21;
331 const int ipVANADIUM = 22;
332 const int ipCHROMIUM = 23;
333 const int ipMANGANESE = 24;
334 const int ipIRON = 25;
335 const int ipCOBALT = 26;
336 const int ipNICKEL = 27;
337 const int ipCOPPER = 28;
338 const int ipZINC = 29;
339 const int ipKRYPTON = 35;
340 
341 /***************************************************************************
342  * the following are prototypes for some routines that are part of the
343  * debugging process - they come and go in any particular sub.
344  * it is not necessary to declare them when used since they are defined here
345  **************************************************************************/
346 
355 double fudge(long int ipnt);
356 
360 void broken(void);
361 
364 void fixit(void);
365 
367 void CodeReview(void);
368 
370 void TestCode(void);
371 
377 void *MyMalloc(size_t size, const char *file, int line);
378 
383 void *MyCalloc(size_t num, size_t size);
384 
389 void *MyRealloc(void *p, size_t size);
390 
395 void MyAssert(const char *file, int line, const char *comment);
396 
399 
401 {
402  const char* p_routine;
403  const char* p_file;
404  long p_line;
406 public:
407  cloudy_exit(const char* routine, const char* file, long line, exit_type exit_code)
408  {
409  p_routine = routine;
410  p_file = file;
411  p_line = line;
412  p_exit = exit_code;
413  }
414  virtual ~cloudy_exit() throw()
415  {
416  p_routine = NULL;
417  p_file = NULL;
418  }
419  const char* routine() const throw()
420  {
421  return p_routine;
422  }
423  const char* file() const throw()
424  {
425  return p_file;
426  }
427  long line() const
428  {
429  return p_line;
430  }
432  {
433  return p_exit;
434  }
435 };
436 
437 // workarounds for __func__ are defined in cpu.h
438 #define cdEXIT( FAIL ) throw cloudy_exit( __func__, __FILE__, __LINE__, FAIL )
439 
440 // calls like puts( "[Stop in MyRoutine]" ) have been integrated in cdEXIT above
441 #define puts( STR ) Using_puts_before_cdEXIT_is_no_longer_needed
442 
444 void ShowMe(void);
445 
447 NORETURN void TotalInsanity(void);
448 
449 /* TotalInsanityAsStub always calls TotalInsanity(), but in such a way that
450  * it can be used as a stub for another routine without generating warnings
451  * about unreachable code after the stub. Hence this should NOT be NORETURN */
452 template<class T>
454 {
455  // this is always true...
456  if( ZeroNum == 0. )
457  TotalInsanity();
458  else
459  return T();
460 }
461 
463 NORETURN void BadRead(void);
464 
468 int dbg_printf(int debug, const char *fmt, ...);
469 
471 int dprintf(FILE *fp, const char *format, ...);
472 
481 char *read_whole_line( char *chLine , int nChar , FILE *ioIN );
482 
483 /**************************************************************************
484  *
485  * various macros used by the code
486  *
487  **************************************************************************/
488 
492 #ifndef NDEBUG
493 # define DEBUG
494 #else
495 # undef DEBUG
496 #endif
497 
499 #if defined(malloc)
500 /* ...but if malloc is a macro, assume it is instrumented by a memory debugging tool
501  * (e.g. dmalloc) */
502 # define MALLOC(exp) (malloc(exp))
503 #else
504 /* Otherwise instrument and protect it ourselves */
505 # define MALLOC(exp) (MyMalloc(exp,__FILE__, __LINE__))
506 #endif
507 
509 #if defined(calloc)
510 /* ...but if calloc is a macro, assume it is instrumented by a memory debugging tool */
511 # define CALLOC calloc
512 #else
513 /* Otherwise instrument and protect it ourselves */
514 # define CALLOC MyCalloc
515 #endif
516 
518 #if defined(realloc)
519 /* ...but if calloc is a macro, assume it is instrumented by a memory debugging tool */
520 # define REALLOC realloc
521 #else
522 /* Otherwise instrument and protect it ourselves */
523 # define REALLOC MyRealloc
524 #endif
525 
527 {
528  int p_sig;
529 public:
530  explicit bad_signal(int sig)
531  {
532  p_sig = sig;
533  }
534  virtual ~bad_signal() throw() {}
535  int sig() const throw()
536  {
537  return p_sig;
538  }
539 };
540 
542 {
543  const char* p_file;
544  long p_line;
545  const char* p_comment;
546 public:
547  bad_assert(const char* file, long line, const char* comment);
548  void print(void) const
549  {
550  fprintf(ioQQQ,"DISASTER Assertion failure at %s:%ld\n%s\n",
551  p_file, p_line, p_comment);
552  }
553  virtual ~bad_assert() throw()
554  {
555  p_file = NULL;
556  }
557  const char* file() const throw()
558  {
559  return p_file;
560  }
561  long line() const throw()
562  {
563  return p_line;
564  }
565  const char *comment() const throw()
566  {
567  return p_comment;
568  }
569 };
570 
571 /* the do { ... } while ( 0 ) construct prevents bugs in code like this:
572  * if( test )
573  * ASSERT( n == 10 );
574  * else
575  * do something else...
576  */
577 #undef ASSERT
578 #ifndef OLD_ASSERT
579 # if NDEBUG
580 # define ASSERT(exp) ((void)0)
581 # else
582 # define ASSERT(exp) \
583  do { \
584  if (UNLIKELY(!(exp))) \
585  { \
586  bad_assert aa(__FILE__,__LINE__,"Failed: " #exp); \
587  if( cpu.i().lgAssertAbort() ) \
588  { \
589  aa.print(); \
590  abort(); \
591  } \
592  else \
593  throw aa; \
594  } \
595  } while( 0 )
596 # endif
597 #else
598 
599 # ifdef NDEBUG
600 # define ASSERT(exp) ((void)0)
601 # else
602 # define ASSERT(exp) \
603  do { \
604  if (!(exp)) \
605  MyAssert(__FILE__, __LINE__, "Failed: " #exp); \
606  } while( 0 )
607 # endif
608 #endif
609 
610 #define MESSAGE_ASSERT(msg, exp) ASSERT( (msg) ? (exp) : false )
611 
612 inline NORETURN void OUT_OF_RANGE(const char* str)
613 {
614  if( cpu.i().lgAssertAbort() )
615  abort();
616  else
617  throw out_of_range( str );
618 }
619 
620 /* Windows does not define isnan */
621 /* use our version on all platforms since the isnanf
622  * function does not exist under Solaris 9 either */
623 #undef isnan
624 #define isnan MyIsnan
625 
628 class t_debug : public Singleton<t_debug>
629 {
630  friend class Singleton<t_debug>;
631  FILE *p_fp;
633 protected:
634  t_debug() : p_fp(stderr)
635  {
636  p_callLevel = 0;
637  }
638 public:
639  void enter(const char *name)
640  {
641  ++p_callLevel;
642  fprintf(p_fp,"%*c%s\n",p_callLevel,'>',name);
643  }
644  void leave(const char *name)
645  {
646  fprintf(p_fp,"%*c%s\n",p_callLevel,'<',name);
647  --p_callLevel;
648  }
649 };
650 
653 class t_nodebug : public Singleton<t_nodebug>
654 {
655  friend class Singleton<t_nodebug>;
656 protected:
658 public:
659  void enter(const char *) const {}
660  void leave(const char *) const {}
661 };
662 
663 template<class Trace>
665 {
666  const char *p_name;
667 public:
668  explicit debugtrace(const char *funcname)
669  {
670  p_name = funcname;
671  Trace::Inst().enter(p_name);
672  }
674  {
675  Trace::Inst().leave(p_name);
676  p_name = NULL;
677  }
678  const char* name() const
679  {
680  return p_name;
681  }
682 };
683 
684 #ifdef DEBUG_FUN
685 #define DEBUG_ENTRY( funcname ) debugtrace<t_debug> DEBUG_ENTRY( funcname )
686 #else
687 #ifdef HAVE_FUNC
688 #define DEBUG_ENTRY( funcname ) ((void)0)
689 #else
690 #define DEBUG_ENTRY( funcname ) debugtrace<t_nodebug> DEBUG_ENTRY( funcname )
691 #endif
692 #endif
693 
694 // overload the character manipulation routines
695 inline char tolower(char c)
696 {
697  return static_cast<char>( tolower( static_cast<int>(c) ) );
698 }
699 inline unsigned char tolower(unsigned char c)
700 {
701  return static_cast<unsigned char>( tolower( static_cast<int>(c) ) );
702 }
703 
704 inline char toupper(char c)
705 {
706  return static_cast<char>( toupper( static_cast<int>(c) ) );
707 }
708 inline unsigned char toupper(unsigned char c)
709 {
710  return static_cast<unsigned char>( toupper( static_cast<int>(c) ) );
711 }
712 
713 /* TorF(l) returns a 'T' or 'F' depending on the 'logical' expr 'l' */
714 inline char TorF( bool l ) { return l ? 'T' : 'F'; }
715 /* */
716 
718 inline bool is_odd( int j ) { return (j&1) == 1; }
719 inline bool is_odd( long j ) { return (j&1L) == 1L; }
720 /* */
721 
723 inline long nint( double x ) { return static_cast<long>( (x < 0.) ? x-0.5 : x+0.5 ); }
724 /* */
725 
726 /* define min for mixed arguments, the rest already exists */
727 inline long min( int a, long b ) { long c = a; return ( (c < b) ? c : b ); }
728 inline long min( long a, int b ) { long c = b; return ( (a < c) ? a : c ); }
729 inline double min( sys_float a, double b ) { double c = a; return ( (c < b) ? c : b ); }
730 inline double min( double a, sys_float b ) { double c = b; return ( (a < c) ? a : c ); }
731 
732 /* want to define this only if no native os support exists */
733 #ifndef HAVE_POWI
734 
735 double powi( double , long int );
736 #endif
737 
738 /* avoid ambiguous overloads */
739 #ifndef HAVE_POW_DOUBLE_INT
740 inline double pow( double x, int i ) { return powi( x, long(i) ); }
741 #endif
742 
743 #ifndef HAVE_POW_DOUBLE_LONG
744 inline double pow( double x, long i ) { return powi( x, i ); }
745 #endif
746 
747 #ifndef HAVE_POW_FLOAT_INT
748 inline sys_float pow( sys_float x, int i ) { return sys_float( powi( double(x), long(i) ) ); }
749 #endif
750 
751 #ifndef HAVE_POW_FLOAT_LONG
752 inline sys_float pow( sys_float x, long i ) { return sys_float( powi( double(x), i ) ); }
753 #endif
754 
755 #ifndef HAVE_POW_FLOAT_DOUBLE
756 inline double pow( sys_float x, double y ) { return pow( double(x), y ); }
757 #endif
758 
759 #ifndef HAVE_POW_DOUBLE_FLOAT
760 inline double pow( double x, sys_float y ) { return pow( x, double(y) ); }
761 #endif
762 
763 #undef MIN2
764 
765 #define MIN2 min
766 /* */
767 
768 #undef MIN3
769 
770 #define MIN3(a,b,c) (min(min(a,b),c))
771 /* */
772 
773 #undef MIN4
774 
775 #define MIN4(a,b,c,d) (min(min(a,b),min(c,d)))
776 /* */
777 
778 /* define max for mixed arguments, the rest already exists */
779 inline long max( int a, long b ) { long c = a; return ( (c > b) ? c : b ); }
780 inline long max( long a, int b ) { long c = b; return ( (a > c) ? a : c ); }
781 inline double max( sys_float a, double b ) { double c = a; return ( (c > b) ? c : b ); }
782 inline double max( double a, sys_float b ) { double c = b; return ( (a > c) ? a : c ); }
783 
784 #undef MAX2
785 
786 #define MAX2 max
787 /* */
788 
789 #undef MAX3
790 
791 #define MAX3(a,b,c) (max(max(a,b),c))
792 /* */
793 
794 #undef MAX4
795 
796 #define MAX4(a,b,c,d) (max(max(a,b),max(c,d)))
797 /* */
798 
803 template<class T>
804 inline T sign( T x, T y )
805 {
806  return ( y < T() ) ? -abs(x) : abs(x);
807 }
808 /* */
809 
811 template<class T>
812 inline int sign3( T x ) { return ( x < T() ) ? -1 : ( ( x > T() ) ? 1 : 0 ); }
813 /* */
814 
816 inline bool fp_equal( sys_float x, sys_float y, int n=3 )
817 {
818 #ifdef _MSC_VER
819  /* disable warning that conditional expression is constant, true or false in if */
820 # pragma warning( disable : 4127 )
821 #endif
822  ASSERT( n >= 1 );
823  // mimic IEEE behavior
824  if( isnan(x) || isnan(y) )
825  return false;
826  int sx = sign3(x);
827  int sy = sign3(y);
828  // treat zero cases first to avoid division by zero below
829  if( sx == 0 && sy == 0 )
830  return true;
831  // either x or y is zero (but not both), or x and y have different sign
832  if( sx*sy != 1 )
833  return false;
834  x = abs(x);
835  y = abs(y);
836  return ( 1.f - min(x,y)/max(x,y) < ((sys_float)n+0.1f)*FLT_EPSILON );
837 }
838 
839 inline bool fp_equal( double x, double y, int n=3 )
840 {
841  ASSERT( n >= 1 );
842  // mimic IEEE behavior
843  if( isnan(x) || isnan(y) )
844  return false;
845  int sx = sign3(x);
846  int sy = sign3(y);
847  // treat zero cases first to avoid division by zero below
848  if( sx == 0 && sy == 0 )
849  return true;
850  // either x or y is zero (but not both), or x and y have different sign
851  if( sx*sy != 1 )
852  return false;
853  x = abs(x);
854  y = abs(y);
855  return ( 1. - min(x,y)/max(x,y) < ((double)n+0.1)*DBL_EPSILON );
856 }
857 
858 inline bool fp_equal_tol( sys_float x, sys_float y, sys_float tol )
859 {
860  ASSERT( tol > 0.f );
861  // mimic IEEE behavior
862  if( isnan(x) || isnan(y) )
863  return false;
864  // make sure the tolerance is not too stringent
865  ASSERT( tol >= FLT_EPSILON*max(abs(x),abs(y)) );
866  return ( abs( x-y ) <= tol );
867 }
868 
869 inline bool fp_equal_tol( double x, double y, double tol )
870 {
871  ASSERT( tol > 0. );
872  // mimic IEEE behavior
873  if( isnan(x) || isnan(y) )
874  return false;
875  // make sure the tolerance is not too stringent
876  ASSERT( tol >= DBL_EPSILON*max(abs(x),abs(y)) );
877  return ( abs( x-y ) <= tol );
878 }
879 
881 inline bool fp_bound( sys_float lo, sys_float x, sys_float hi, int n=3 )
882 {
883  ASSERT( n >= 1 );
884  // mimic IEEE behavior
885  if( isnan(x) || isnan(lo) || isnan(hi) )
886  return false;
887  if( fp_equal(lo,hi,n) )
888  return fp_equal(0.5f*(lo+hi),x,n);
889  if( ((hi-x)/(hi-lo))*((x-lo)/(hi-lo)) < -((sys_float)n+0.1f)*FLT_EPSILON )
890  return false;
891  return true;
892 }
893 inline bool fp_bound( double lo, double x, double hi, int n=3 )
894 {
895  ASSERT( n >= 1 );
896  // mimic IEEE behavior
897  if( isnan(x) || isnan(lo) || isnan(hi) )
898  return false;
899  if( fp_equal(lo,hi,n) )
900  return fp_equal(0.5*(lo+hi),x,n);
901  if( ((hi-x)/(hi-lo))*((x-lo)/(hi-lo)) < -((double)n+0.1)*DBL_EPSILON )
902  return false;
903  return true;
904 }
905 inline bool fp_bound_tol( sys_float lo, sys_float x, sys_float hi, sys_float tol )
906 {
907  ASSERT( tol > 0.f );
908  // mimic IEEE behavior
909  if( isnan(x) || isnan(lo) || isnan(hi) )
910  return false;
911  if( fp_equal_tol(lo,hi,tol) )
912  return fp_equal_tol(0.5f*(lo+hi),x,tol);
913  if( ((hi-x)/(hi-lo))*((x-lo)/(hi-lo)) < -tol )
914  return false;
915  return true;
916 }
917 inline bool fp_bound_tol( double lo, double x, double hi, double tol )
918 {
919  ASSERT( tol > 0. );
920  // mimic IEEE behavior
921  if( isnan(x) || isnan(lo) || isnan(hi) )
922  return false;
923  if( fp_equal_tol(lo,hi,tol) )
924  return fp_equal_tol(0.5*(lo+hi),x,tol);
925  if( ((hi-x)/(hi-lo))*((x-lo)/(hi-lo)) < -tol )
926  return false;
927  return true;
928 }
929 
930 
931 #undef POW2
932 
933 #define POW2 pow2
934 template<class T>
935 inline T pow2(T a) { return a*a; }
936 /* */
937 
938 #undef POW3
939 
940 #define POW3 pow3
941 template<class T>
942 inline T pow3(T a) { return a*a*a; }
943 /* */
944 
945 #undef POW4
946 
947 #define POW4 pow4
948 template<class T>
949 inline T pow4(T a) { T b = a*a; return b*b; }
950 /* */
951 
952 #undef SDIV
953 
956 inline sys_float SDIV( sys_float x ) { return ( fabs((double)x) < (double)SMALLFLOAT ) ? (sys_float)SMALLFLOAT : x; }
957 /* \todo should we use SMALLDOUBLE here ? it produces overflows now... PvH */
958 inline double SDIV( double x ) { return ( fabs(x) < (double)SMALLFLOAT ) ? (double)SMALLFLOAT : x; }
959 // inline double SDIV( double x ) { return ( fabs(x) < SMALLDOUBLE ) ? SMALLDOUBLE : x; }
960 /* */
961 
966 {
967  // this should crash...
968  if( isnan(x) || isnan(y) )
969  return x/y;
970  int sx = sign3(x);
971  int sy = sign3(y);
972  // 0/0 -> NaN, this should crash as well...
973  if( sx == 0 && sy == 0 )
974  {
975  if( isnan(res_0by0) )
976  return x/y;
977  else
978  return res_0by0;
979  }
980  if( sx == 0 )
981  return 0.;
982  if( sy == 0 )
983  return ( sx < 0 ) ? -FLT_MAX : FLT_MAX;
984  // at this stage x != 0. and y != 0.
985  sys_float ay = abs(y);
986  if( ay >= 1.f )
987  return x/y;
988  else
989  {
990  // multiplication is safe since ay < 1.
991  if( abs(x) < ay*FLT_MAX )
992  return x/y;
993  else
994  return ( sx*sy < 0 ) ? -FLT_MAX : FLT_MAX;
995  }
996 }
997 
999 {
1000  return safe_div( x, y, numeric_limits<sys_float>::quiet_NaN() );
1001 }
1002 
1006 inline double safe_div(double x, double y, double res_0by0)
1007 {
1008  // this should crash...
1009  if( isnan(x) || isnan(y) )
1010  return x/y;
1011  int sx = sign3(x);
1012  int sy = sign3(y);
1013  // 0/0 -> NaN, this should crash as well...
1014  if( sx == 0 && sy == 0 )
1015  {
1016  if( isnan(res_0by0) )
1017  return x/y;
1018  else
1019  return res_0by0;
1020  }
1021  if( sx == 0 )
1022  return 0.;
1023  if( sy == 0 )
1024  return ( sx < 0 ) ? -DBL_MAX : DBL_MAX;
1025  // at this stage x != 0. and y != 0.
1026  double ay = abs(y);
1027  if( ay >= 1. )
1028  return x/y;
1029  else
1030  {
1031  // multiplication is safe since ay < 1.
1032  if( abs(x) < ay*DBL_MAX )
1033  return x/y;
1034  else
1035  return ( sx*sy < 0 ) ? -DBL_MAX : DBL_MAX;
1036  }
1037 }
1038 
1039 inline double safe_div(double x, double y)
1040 {
1041  return safe_div( x, y, numeric_limits<double>::quiet_NaN() );
1042 }
1043 
1044 #undef HMRATE
1045 /*HMRATE compile molecular rates using Hollenbach and McKee fits */
1046 /* #define HMRATE(a,b,c) ( ((b) == 0 && (c) == 0) ? (a) : \
1047  * ( ((c) == 0) ? (a)*pow(phycon.te/300.,(b)) : \
1048  * ( ((c)/phycon.te > 50.) ? 0. : ( ((b) == 0) ? (a)*exp(-(c)/phycon.te) : \
1049  * (a)*pow(phycon.te/300.,(b))*exp(-(c)/phycon.te) ) ) ) ) */
1050 #define HMRATE(a,b,c) hmrate4(a,b,c,phycon.te)
1051 
1052 inline double hmrate4( double a, double b, double c, double te )
1053 {
1054  if( b == 0. && c == 0. )
1055  return a;
1056  else if( c == 0. )
1057  return a*pow(te/300.,b);
1058  else if( b == 0. )
1059  return ( c/te <= 50. ) ? a*exp(-c/te) : 0.;
1060  else
1061  return ( c/te <= 50. ) ? a*pow(te/300.,b)*exp(-c/te) : 0.;
1062 }
1063 
1064 template<class T>
1065 inline void invalidate_array(T* p, size_t size)
1066 {
1067  if( size > 0 )
1068  memset( p, -1, size );
1069 }
1070 
1071 inline void invalidate_array(double* p, size_t size)
1072 {
1073  set_NaN( p, (long)(size/sizeof(double)) );
1074 }
1075 
1076 inline void invalidate_array(sys_float* p, size_t size)
1077 {
1078  set_NaN( p, (long)(size/sizeof(sys_float)) );
1079 }
1080 
1083 template<class T> inline T* get_ptr(T *v)
1084 {
1085  return v;
1086 }
1087 template<class T> inline T* get_ptr(valarray<T> &v)
1088 {
1089  return &v[0];
1090 }
1091 template<class T> inline T* get_ptr(vector<T> &v)
1092 {
1093  return &v[0];
1094 }
1095 template<class T> inline const T* get_ptr(const valarray<T> &v)
1096 {
1097  return const_cast<const T*>(&const_cast<valarray<T>&>(v)[0]);
1098 }
1099 template<class T> inline const T* get_ptr(const vector<T> &v)
1100 {
1101  return const_cast<const T*>(&const_cast<vector<T>&>(v)[0]);
1102 }
1103 
1129 template<class T>
1131 {
1132  T* ptr;
1133 
1134  template<class U>
1136  {
1137  U* ptr;
1138 
1139  explicit auto_vec_ref( U* p )
1140  {
1141  ptr = p;
1142  }
1143  };
1144 
1145 public:
1146  typedef T element_type;
1147 
1148  // 20.4.5.1 construct/copy/destroy:
1149 
1150  explicit auto_vec( element_type* p = NULL ) throw()
1151  {
1152  ptr = p;
1153  }
1154  auto_vec( auto_vec& p ) throw()
1155  {
1156  ptr = p.release();
1157  }
1158  auto_vec& operator= ( auto_vec& p ) throw()
1159  {
1160  reset( p.release() );
1161  return *this;
1162  }
1163  ~auto_vec() throw()
1164  {
1165  delete[] ptr;
1166  }
1167 
1168  // 20.4.5.2 members:
1169 
1170  element_type& operator[] ( ptrdiff_t n ) const throw()
1171  {
1172  return *(ptr+n);
1173  }
1174  element_type* get() const throw()
1175  {
1176  return ptr;
1177  }
1178  // for consistency with other container classes
1179  element_type* data() const throw()
1180  {
1181  return ptr;
1182  }
1184  {
1185  element_type* p = ptr;
1186  ptr = NULL;
1187  return p;
1188  }
1189  void reset( element_type* p = NULL ) throw()
1190  {
1191  if( p != ptr )
1192  {
1193  delete[] ptr;
1194  ptr = p;
1195  }
1196  }
1197 
1198  // 20.4.5.3 conversions:
1199 
1201  {
1202  ptr = r.ptr;
1203  }
1204  auto_vec& operator= ( auto_vec_ref<element_type> r ) throw()
1205  {
1206  if( r.ptr != ptr )
1207  {
1208  delete[] ptr;
1209  ptr = r.ptr;
1210  }
1211  return *this;
1212  }
1213  operator auto_vec_ref<element_type>() throw()
1214  {
1215  return auto_vec_ref<element_type>( this->release() );
1216  }
1217 };
1218 
1219 #include "container_classes.h"
1220 #include "iter_track.h"
1221 
1222 /*Many structure were introduced by Humeshkar B Nemala as a part of his Thesis
1223  *The structures were designed to read in transition,radiative and collisional data
1224  *from two major databases:LEIDEN and CHIANTI
1225 
1226  * these structures define the emission, collision, state, and transition classes*/
1227 
1228 typedef struct t_species species;
1229 
1230 #include "lines_service.h"
1231 
1232 /*The species structure is used to hold information about a particular atom,ion or molecule
1233 mentioned in the species.ini file.The name of the atom/ion/molecule is used to obtain the density
1234 of molecules in the case of the Leiden Database and along with atomic number and ion stage the
1235 density of atoms/ions in the case of the CHIANTI database */
1237 {
1238  /*Name of the atom/ion/ molecule*/
1239  char *chLabel;
1240  // index in chmeistry
1241  long index;
1242  /*Actual Number of energy levels in the data file*/
1244  /*Number of energy levels used locally*/
1246  /*Molecular weight*/
1248  /* is molecular? */
1250  // intrepret data as LAMDA or CHIANTI?
1251  bool lgLAMDA;
1252  /* fraction in this "type" (e.g. para, ortho) */
1254  /* chemical fractionation */
1257  double CoolTotal;
1259  bool lgActive;
1260  /* maximum wavenumber in chianti */
1261  double maxWN;
1263  bool lgLTE;
1264 };
1265 
1266 /*This structure is specifically used to hold the collision data in the format given in the LEIDEN Database
1267 The data is available as collision rate coefficients(cm3 s-1) over different temperatures*/
1268 typedef struct t_CollRatesArray
1269 {
1270  /*Array of temps*/
1271  vector<double> temps;
1272  /*Matrix of collision rates(temp,up,lo)*/
1274 
1276 
1277 /*This structure is specifically used to hold the collision data in the format given in the CHIANTI Database
1278 The data is available as spline fits to the Maxwellian averaged collision strengths */
1279 typedef struct t_CollSplinesArray
1280 {
1281  /*Matrix of spline fits(hi,lo,spline index)*
1282  *The first five columns gives the no of spline pts,transition type,gf value,delta E
1283  *& Scaling parameter ,in the specified order*/
1284  /*The transition type basically tells how the temperature and collision
1285  strengths have been scaled*/
1286  double *collspline;
1287  double *SplineSecDer;
1288 
1289  long nSplinePts;
1291  double EnergyDiff;
1293 
1294 } CollSplinesArray ;
1295 
1296 /*This structure is specifically used to hold the collision data in the format given in the STOUT Database
1297 The data are available as collision strengths and rates over different temperatures*/
1298 typedef struct t_StoutColls
1299 {
1300  /*Number of temps*/
1301  long ntemps;
1302  /*Array of temps*/
1303  double *temps;
1304  /*Array of collision strengths*/
1305  double *collstrs;
1306  /*Is this a deexcitation rate or collision strength*/
1307  bool lgIsRate;
1308 
1309 } StoutColls ;
1310 
1311 #include "physconst.h"
1312 
1313 /***************************************************************************
1314  *
1315  * a series of Cloudy service routines, used throughout code,
1316  *
1317  **************************************************************************/
1318 
1326 
1328 void Split(const string& str, // input string
1329  const string& sep, // separator, may be multiple characters
1330  vector<string>& lst, // the separated items will be appended here
1331  split_mode mode); // see above
1332 
1335 inline bool FindAndReplace(string& str,
1336  const string& substr,
1337  const string& newstr)
1338 {
1339  string::size_type ptr = str.find( substr );
1340  if( ptr != string::npos )
1341  str.replace( ptr, substr.length(), newstr );
1342  return ptr != string::npos;
1343 }
1344 
1347 inline bool FindAndErase(string& str,
1348  const string& substr)
1349 {
1350  return FindAndReplace( str, substr, "" );
1351 }
1352 
1358 double csphot(long int inu, long int ithr, long int iofset);
1359 
1364 double RandGauss(double xMean, double s );
1365 
1369 double MyGaussRand( double PctUncertainty );
1370 
1372 double AnuUnit(realnum energy);
1373 
1378 void cap4(char *chCAP , const char *chLab);
1379 
1382 void uncaps(char *chCard );
1383 
1386 void caps(char *chCard );
1387 
1390 double e2(
1391  double t );
1392 
1395 double ee1(double x);
1396 
1400 double ee1_safe(double x);
1401 
1408 double FFmtRead(const char *chCard,
1409  long int *ipnt,
1410  long int last,
1411  bool *lgEOL);
1412 
1418 long nMatch(const char *chKey,
1419  const char *chCard);
1420 
1430 int GetQuote( char *chLabel, char *chCard, char *chCardRaw, bool lgABORT );
1431 
1432 // these are safe versions of strstr, strchr, etc to work around a deficiency in glibc
1433 inline const char *strstr_s(const char *haystack, const char *needle)
1434 {
1435  return const_cast<const char *>(strstr(haystack, needle));
1436 }
1437 
1438 inline char *strstr_s(char *haystack, const char *needle)
1439 {
1440  return const_cast<char *>(strstr(haystack, needle));
1441 }
1442 
1443 inline const char *strchr_s(const char *s, int c)
1444 {
1445  return const_cast<const char *>(strchr(s, c));
1446 }
1447 
1448 inline char *strchr_s(char *s, int c)
1449 {
1450  return const_cast<char *>(strchr(s, c));
1451 }
1452 
1455 long int ipow( long, long );
1456 
1459 void PrintE82( FILE*, double );
1460 
1462 void PrintE71( FILE*, double );
1463 
1465 void PrintE93( FILE*, double );
1466 
1472 // prevent compiler warnings on non-MS systems
1473 #ifdef _MSC_VER
1474 char *PrintEfmt(const char *fmt, double val );
1475 #else
1476 #define PrintEfmt( F, V ) F, V
1477 #endif
1478 
1480 const double SEXP_LIMIT = 84.;
1482 const double DSEXP_LIMIT = 680.;
1483 
1486 double sexp(double x);
1487 
1492 double dsexp(double x);
1493 
1498 double plankf(long int ip);
1499 
1500 // safe version of getline() that correctly handles all types of EOL lf, crlf and cr...
1501 istream& SafeGetline(istream& is, string& t);
1502 
1503 // Define integration methods
1504 typedef enum { Gaussian32, Legendre } methods;
1505 
1506 // define an integrator class. Currently hard-wired to 32-point Gaussian
1507 template<typename Integrand, methods Method>
1509 {
1510 public:
1511  double numPoints, weights[16], c[16];
1512 
1513  Integrator( void )
1514  {
1515  numPoints = 16;
1516  double weights_temp[16] = {
1517  .35093050047350483e-2, .81371973654528350e-2, .12696032654631030e-1, .17136931456510717e-1,
1518  .21417949011113340e-1, .25499029631188088e-1, .29342046739267774e-1, .32911111388180923e-1,
1519  .36172897054424253e-1, .39096947893535153e-1, .41655962113473378e-1, .43826046502201906e-1,
1520  .45586939347881942e-1, .46922199540402283e-1, .47819360039637430e-1, .48270044257363900e-1};
1521 
1522  double c_temp[16] = {
1523  .498631930924740780, .49280575577263417, .4823811277937532200, .46745303796886984000,
1524  .448160577883026060, .42468380686628499, .3972418979839712000, .36609105937014484000,
1525  .331522133465107600, .29385787862038116, .2534499544661147000, .21067563806531767000,
1526  .165934301141063820, .11964368112606854, .7223598079139825e-1, .24153832843869158e-1};
1527 
1528  for( long i=0; i<numPoints; i++ )
1529  {
1530  weights[i] = weights_temp[i];
1531  c[i] = c_temp[i];
1532  }
1533  return;
1534  };
1535  double sum(double min, double max, Integrand func)
1536  {
1537  ASSERT( Method == Gaussian32 );
1538  double a = 0.5*(max+min),
1539  b = max-min,
1540  total = 0.;
1541 
1542  for( long i=0; i< numPoints; i++ )
1543  total += b * weights[i] * ( func(a+b*c[i]) + func(a-b*c[i]) );
1544 
1545  return total;
1546  }
1547 };
1548 
1555 double qg32( double, double, double(*)(double) );
1556 /* declar of optimize_func, the last arg, changed from double(*)() to above,
1557  * seemed to fix flags that were raised */
1558 
1559 
1569 void spsort( realnum x[], long int n, long int iperm[], int kflag, int *ier);
1570 
1571 /**************************************************************************
1572  *
1573  * disable some bogus errors in the ms c compiler
1574  *
1575  **************************************************************************/
1576 
1577 /* */
1578 #ifdef _MSC_VER
1579  /* disable warning that conditional expression is constant, true or false in if */
1580 # pragma warning( disable : 4127 )
1581  /* disable strcat warning */
1582 # pragma warning( disable : 4996 )
1583  /* disable bogus underflow warning in MS VS*/
1584 # pragma warning( disable : 4056 )
1585  /* disable "inline function removed since not used", MS VS*/
1586 # pragma warning( disable : 4514 )
1587  /* disable "assignment operator could not be generated", cddefines.h
1588  * line 126 */
1589 # pragma warning( disable : 4512 )
1590 #endif
1591 #ifdef __INTEL_COMPILER
1592 # pragma warning( disable : 1572 )
1593 #endif
1594 /* */
1595 
1596 /*lint +e129 these resolve several issues pclint has with my system headers */
1597 /*lint +e78 */
1598 /*lint +e830 */
1599 /*lint +e38 */
1600 /*lint +e148 */
1601 /*lint +e114 */
1602 /*lint +e18 */
1603 /*lint +e49 */
1604 
1605 #endif /* CDDEFINES_H_ */
1606 
const char * p_name
Definition: cddefines.h:666
multi_arr< double, 3 > collrates
Definition: cddefines.h:1273
T pow4(T a)
Definition: cddefines.h:949
FILE * ioMAP
Definition: cdinit.cpp:9
void leave(const char *name)
Definition: cddefines.h:644
const char * file() const
Definition: cddefines.h:557
const int ipBERYLLIUM
Definition: cddefines.h:312
void leave(const char *) const
Definition: cddefines.h:660
FILE * p_fp
Definition: cddefines.h:631
t_debug()
Definition: cddefines.h:634
void PrintE93(FILE *, double)
Definition: service.cpp:838
const int ipMAGNESIUM
Definition: cddefines.h:320
int p_callLevel
Definition: cddefines.h:632
bool is_odd(int j)
Definition: cddefines.h:718
virtual ~bad_signal()
Definition: cddefines.h:534
exit_type exit_status() const
Definition: cddefines.h:431
const int FILENAME_PATH_LENGTH_2
Definition: cddefines.h:253
#define NORETURN
Definition: cpu.h:370
istream & SafeGetline(istream &is, string &t)
Definition: service.cpp:1770
T * get_ptr(T *v)
Definition: cddefines.h:1083
NORETURN void TotalInsanity(void)
Definition: service.cpp:886
Integrator(void)
Definition: cddefines.h:1513
void set_NaN(sys_float &x)
Definition: cpu.cpp:673
const int ipARGON
Definition: cddefines.h:326
const int ipTITANIUM
Definition: cddefines.h:330
const char * file() const
Definition: cddefines.h:423
struct t_CollRatesArray CollRateCoeffArray
const realnum SMALLFLOAT
Definition: cpu.h:178
t_cpu_i & i()
Definition: cpu.h:334
virtual ~cloudy_exit()
Definition: cddefines.h:414
const int NISO
Definition: cddefines.h:265
const char * routine() const
Definition: cddefines.h:419
bool FindAndErase(string &str, const string &substr)
Definition: cddefines.h:1347
char TorF(bool l)
Definition: cddefines.h:714
const int ipOXYGEN
Definition: cddefines.h:316
const int ipCHLORINE
Definition: cddefines.h:325
#define PrintEfmt(F, V)
Definition: cddefines.h:1476
void enter(const char *) const
Definition: cddefines.h:659
void invalidate_array(T *p, size_t size)
Definition: cddefines.h:1065
long nMatch(const char *chKey, const char *chCard)
Definition: service.cpp:451
T sign(T x, T y)
Definition: cddefines.h:804
int sig() const
Definition: cddefines.h:535
char * chLabel
Definition: cddefines.h:1239
const char * name() const
Definition: cddefines.h:678
bool fp_equal_tol(sys_float x, sys_float y, sys_float tol)
Definition: cddefines.h:858
T TotalInsanityAsStub()
Definition: cddefines.h:453
const char * strstr_s(const char *haystack, const char *needle)
Definition: cddefines.h:1433
void * MyMalloc(size_t size, const char *file, int line)
Definition: service.cpp:1448
sys_float sexp(sys_float x)
Definition: service.cpp:914
const int ipRecNetEsc
Definition: cddefines.h:285
long line() const
Definition: cddefines.h:561
void * MyCalloc(size_t num, size_t size)
Definition: service.cpp:1533
double hmrate4(double a, double b, double c, double te)
Definition: cddefines.h:1052
int dbg_printf(int debug, const char *fmt,...)
Definition: service.cpp:1031
T pow3(T a)
Definition: cddefines.h:942
bad_signal(int sig)
Definition: cddefines.h:530
double fudge(long int ipnt)
Definition: service.cpp:481
double ee1_safe(double x)
Definition: service.cpp:356
const int ipCOBALT
Definition: cddefines.h:335
FILE * ioQQQ
Definition: cddefines.cpp:7
void * MyRealloc(void *p, size_t size)
Definition: service.cpp:1569
NORETURN void OUT_OF_RANGE(const char *str)
Definition: cddefines.h:612
long int nzone
Definition: cddefines.cpp:14
const int ipNICKEL
Definition: cddefines.h:336
const int ipZINC
Definition: cddefines.h:338
exit_type
Definition: cddefines.h:119
void cap4(char *chCAP, const char *chLab)
Definition: service.cpp:240
const char * p_file
Definition: cddefines.h:543
double dsexp(double x)
Definition: service.cpp:953
void CodeReview(void)
Definition: service.cpp:1000
const int ipSULPHUR
Definition: cddefines.h:324
bool fp_bound_tol(sys_float lo, sys_float x, sys_float hi, sys_float tol)
Definition: cddefines.h:905
const double MAX_DENSITY
Definition: cddefines.h:273
static T & Inst()
Definition: cddefines.h:179
bool lgAssertAbort() const
Definition: cpu.h:305
void uncaps(char *chCard)
Definition: service.cpp:263
long index
Definition: cddefines.h:1241
char toupper(char c)
Definition: cddefines.h:704
void print(void) const
Definition: cddefines.h:548
element_type * data() const
Definition: cddefines.h:1179
long int iteration
Definition: cddefines.cpp:16
const double DSEXP_LIMIT
Definition: cddefines.h:1482
int GetQuote(char *chLabel, char *chCard, char *chCardRaw, bool lgABORT)
Definition: service.cpp:513
bool fp_equal(sys_float x, sys_float y, int n=3)
Definition: cddefines.h:816
void broken(void)
Definition: service.cpp:982
double maxWN
Definition: cddefines.h:1261
debugtrace(const char *funcname)
Definition: cddefines.h:668
int dprintf(FILE *fp, const char *format,...)
Definition: service.cpp:1009
const int ipDEST_SIMPL
Definition: cddefines.h:306
const int ipVANADIUM
Definition: cddefines.h:331
const int ipIRON
Definition: cddefines.h:334
void PrintE71(FILE *, double)
Definition: service.cpp:788
void Split(const string &str, const string &sep, vector< string > &lst, split_mode mode)
Definition: service.cpp:106
char tolower(char c)
Definition: cddefines.h:695
element_type * release()
Definition: cddefines.h:1183
long numLevels_local
Definition: cddefines.h:1245
const char * p_routine
Definition: cddefines.h:402
const int ipSCANDIUM
Definition: cddefines.h:329
double * collspline
Definition: cddefines.h:1286
auto_vec(element_type *p=NULL)
Definition: cddefines.h:1150
bool lgActive
Definition: cddefines.h:1259
const double ZeroNum
Definition: cdinit.cpp:13
const int ipCRD
Definition: cddefines.h:296
void enter(const char *name)
Definition: cddefines.h:639
virtual ~bad_assert()
Definition: cddefines.h:553
long p_line
Definition: cddefines.h:404
float realnum
Definition: cddefines.h:107
float sys_float
Definition: cddefines.h:110
const int ipLY_A
Definition: cddefines.h:300
const int ipPHOSPHORUS
Definition: cddefines.h:323
const int INPUT_LINE_LENGTH
Definition: cddefines.h:258
long max(int a, long b)
Definition: cddefines.h:779
int sign3(T x)
Definition: cddefines.h:812
double qg32(double, double, double(*)(double))
Definition: service.cpp:1053
const char * p_file
Definition: cddefines.h:403
const int ipNEON
Definition: cddefines.h:318
const int ipCHROMIUM
Definition: cddefines.h:332
double powi(double, long int)
Definition: service.cpp:604
const int ipRecRad
Definition: cddefines.h:287
long min(int a, long b)
Definition: cddefines.h:727
bool fp_bound(sys_float lo, sys_float x, sys_float hi, int n=3)
Definition: cddefines.h:881
long p_line
Definition: cddefines.h:544
const char * strchr_s(const char *s, int c)
Definition: cddefines.h:1443
sys_float safe_div(sys_float x, sys_float y, sys_float res_0by0)
Definition: cddefines.h:965
const int ipRecEsc
Definition: cddefines.h:283
bool lgLAMDA
Definition: cddefines.h:1251
exit_type p_exit
Definition: cddefines.h:405
double RandGauss(double xMean, double s)
Definition: service.cpp:1643
void reset(element_type *p=NULL)
Definition: cddefines.h:1189
const int ipKRYPTON
Definition: cddefines.h:339
double sum(double min, double max, Integrand func)
Definition: cddefines.h:1535
double AnuUnit(realnum energy)
Definition: service.cpp:173
void MyAssert(const char *file, int line, const char *comment)
Definition: service.cpp:153
auto_vec(auto_vec &p)
Definition: cddefines.h:1154
bool lgTestCodeEnabled
Definition: cddefines.cpp:12
const int ipSILICON
Definition: cddefines.h:322
const char * comment() const
Definition: cddefines.h:565
realnum fracIsotopologue
Definition: cddefines.h:1255
long int ipow(long, long)
Definition: service.cpp:639
double CoolTotal
Definition: cddefines.h:1257
double * SplineSecDer
Definition: cddefines.h:1287
split_mode
Definition: cddefines.h:1325
#define ASSERT(exp)
Definition: cddefines.h:582
struct t_CollSplinesArray CollSplinesArray
FILE * ioPrnErr
Definition: cddefines.cpp:9
const int ipALUMINIUM
Definition: cddefines.h:321
const char * p_comment
Definition: cddefines.h:545
const int ipCALCIUM
Definition: cddefines.h:328
const int ipNITROGEN
Definition: cddefines.h:315
bool lgMolecular
Definition: cddefines.h:1249
double csphot(long int inu, long int ithr, long int iofset)
Definition: service.cpp:1602
const int LIMELM
Definition: cddefines.h:262
T pow2(T a)
Definition: cddefines.h:935
const int ipFLUORINE
Definition: cddefines.h:317
long numLevels_max
Definition: cddefines.h:1243
auto_vec(auto_vec_ref< element_type > r)
Definition: cddefines.h:1200
#define isnan
Definition: cddefines.h:624
bool lgLTE
Definition: cddefines.h:1263
const int ipHELIUM
Definition: cddefines.h:310
const int ipMANGANESE
Definition: cddefines.h:333
realnum fracType
Definition: cddefines.h:1253
double ee1(double x)
Definition: service.cpp:312
long line() const
Definition: cddefines.h:427
bool lgTestCodeCalled
Definition: cddefines.cpp:11
realnum fmolweight
Definition: cddefines.h:1247
const int FILENAME_PATH_LENGTH
Definition: cddefines.h:250
const int ipDEST_K2
Definition: cddefines.h:302
const int ipPRD
Definition: cddefines.h:294
sys_float SDIV(sys_float x)
Definition: cddefines.h:956
bool lgPrnErr
Definition: cddefines.cpp:13
const int ipCARBON
Definition: cddefines.h:314
bool FindAndReplace(string &str, const string &substr, const string &newstr)
Definition: cddefines.h:1335
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
Definition: service.cpp:70
double * collstrs
Definition: cddefines.h:1305
cloudy_exit(const char *routine, const char *file, long line, exit_type exit_code)
Definition: cddefines.h:407
long nint(double x)
Definition: cddefines.h:723
double * temps
Definition: cddefines.h:1303
double MyGaussRand(double PctUncertainty)
Definition: service.cpp:1683
void caps(char *chCard)
Definition: service.cpp:280
static t_cpu cpu
Definition: cpu.h:342
double fnzone
Definition: cddefines.cpp:15
struct t_StoutColls StoutColls
void ShowMe(void)
Definition: service.cpp:181
void PrintE82(FILE *, double)
Definition: service.cpp:739
vector< double > temps
Definition: cddefines.h:1271
const double SEXP_LIMIT
Definition: cddefines.h:1480
double e2(double t)
Definition: service.cpp:299
double plankf(long int ip)
Definition: service.cpp:1707
const int ipHYDROGEN
Definition: cddefines.h:309
void fixit(void)
Definition: service.cpp:991
const int ipLITHIUM
Definition: cddefines.h:311
void cdPrepareExit(exit_type)
Definition: cdinit.cpp:202
const double DEPTH_OFFSET
Definition: cddefines.h:276
void TestCode(void)
Definition: service.cpp:972
const int ipPOTASSIUM
Definition: cddefines.h:327
const int NHYDRO_MAX_LEVEL
Definition: cddefines.h:270
methods
Definition: cddefines.h:1504
NORETURN void BadRead(void)
Definition: service.cpp:901
T element_type
Definition: cddefines.h:1146
const int ipDEST_INCOM
Definition: cddefines.h:304
const int ipBORON
Definition: cddefines.h:313
bool lgAbort
Definition: cddefines.cpp:10
const int ipCRDW
Definition: cddefines.h:298
const int ipSODIUM
Definition: cddefines.h:319
void spsort(realnum x[], long int n, long int iperm[], int kflag, int *ier)
Definition: service.cpp:1100
FILE * ioStdin
Definition: cddefines.cpp:8
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)
Definition: service.cpp:381
const int ipCOPPER
Definition: cddefines.h:337