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