cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
service.cpp File Reference
#include <ctype.h>
#include <stdarg.h>
#include "cddefines.h"
#include "physconst.h"
#include "cddrive.h"
#include "called.h"
#include "opacity.h"
#include "rfield.h"
#include "hextra.h"
#include "hmi.h"
#include "fudgec.h"
#include "broke.h"
#include "trace.h"
#include "input.h"
#include "elementnames.h"
#include "punch.h"
#include "version.h"
#include "warnings.h"
#include "conv.h"
#include "thirdparty.h"
Include dependency graph for service.cpp:

Go to the source code of this file.

Functions

char * read_whole_line (char *chLine, int nChar, FILE *ioIN)
 
void Split (const string &str, const string &sep, vector< string > &lst, split_mode mode)
 
void MyAssert (const char *file, int line)
 
double AnuUnit (realnum energy_ryd)
 
void ShowMe (void)
 
void cap4 (char *chCAP, char *chLab)
 
void uncaps (char *chCard)
 
void caps (char *chCard)
 
double e2 (double t)
 
double ee1 (double x)
 
double ee1_safe (double x)
 
double FFmtRead (const char *chCard, long int *ipnt, long int last, bool *lgEOL)
 
long nMatch (const char *chKey, const char *chCard)
 
double fudge (long int ipnt)
 
long int GetElem (char *chCARD_CAPS)
 
int GetQuote (char *chLabel, char *chCard, bool lgABORT)
 
double powi (double x, long int n)
 
long ipow (long m, long n)
 
char * PrintEfmt (const char *fmt, double val)
 
void PrintE82 (FILE *ioOUT, double value)
 
void PrintE71 (FILE *ioOUT, double value)
 
void PrintE93 (FILE *ioOUT, double value)
 
NORETURN void TotalInsanity (void)
 
NORETURN void BadRead (void)
 
NORETURN void BadOpen (void)
 
NORETURN void NoNumb (char *chCard)
 
sys_float sexp (sys_float x)
 
double sexp (double x)
 
double dsexp (double x)
 
void TestCode (void)
 
void broken (void)
 
void fixit (void)
 
void CodeReview (void)
 
int dprintf (FILE *fp, const char *format,...)
 
int dbg_printf (int debug, const char *fmt,...)
 
double qg32 (double xl, double xu, double(*fct)(double))
 
void spsort (realnum x[], long int n, long int iperm[], int kflag, int *ier)
 
void * MyMalloc (size_t size, const char *chFile, int line)
 
void * MyCalloc (size_t num, size_t size)
 
void * MyRealloc (void *p, size_t size)
 
double csphot (long int inu, long int ithr, long int iofset)
 
double RandGauss (double xMean, double s)
 
double MyGaussRand (double PctUncertainty)
 
double plankf (long int ip)
 

Function Documentation

double AnuUnit ( realnum  energy)

AnuUnit produce continuum energy in arbitrary units, ip is on C scale

Definition at line 168 of file service.cpp.

References cdEXIT, t_punch::chConPunEnr, DEBUG_ENTRY, EVRYD, ioQQQ, t_punch::ipConPun, punch, RYD_INF, RYDLAM, and SPEEDLIGHT.

Referenced by AGN_Hemis(), pun1Line(), punch_opacity(), PunchDo(), and PunchNewContinuum().

NORETURN void BadOpen ( void  )

BadOpen tried to open data files and failed

Definition at line 990 of file service.cpp.

References cdEXIT, DEBUG_ENTRY, ioQQQ, and ShowMe().

Referenced by main().

Here is the call graph for this function:

NORETURN void BadRead ( void  )

BadRead tried to read internal data and failed

Definition at line 976 of file service.cpp.

References cdEXIT, DEBUG_ENTRY, ioQQQ, and ShowMe().

Referenced by H2_Read_hminus_distribution(), H2_ReadDissprob(), H2_ReadEnergies(), H2_ReadTransprob(), and HelikeTransProbSetup().

Here is the call graph for this function:

void broken ( void  )

broken set flag saying that the code is broken

Definition at line 1086 of file service.cpp.

References broke, DEBUG_ENTRY, and t_broke::lgBroke.

Referenced by ion_solver(), IonNitro(), and PresTotCurrent().

void cap4 ( char *  chCAP,
char *  chLab 
)

cap4 convert first 4 char of input line chLab into chCAP all in caps, null termination

Parameters
chCAPoutput string, cap'd first 4 char of chLab,
chLabwith null terminating input string ending with eol

Definition at line 289 of file service.cpp.

References DEBUG_ENTRY.

Referenced by cdDLine(), cdEmis(), cdLine(), GetOptColDen(), lgCheckAsserts(), optimize_func(), ParseDLaw(), ParseElement(), ParseInterp(), ParseNorm(), ParseTLaw(), and PrtFinal().

void caps ( char *  chCard)

caps convert input command line (through eol) to ALL CAPS

Parameters
chCard- line image as string of characters

Definition at line 329 of file service.cpp.

References DEBUG_ENTRY.

Referenced by cdColm(), cdEmis(), cdIonFrac(), cdRead(), cdTemp(), GetOptColDen(), GetOptLineInt(), GetOptTemp(), input_readarray(), Nemala_Start(), ParseAbundances(), ParseCommands(), ParseDynaTime(), ParseElement(), ParseInterp(), PrtFinal(), PrtLineSum(), punch_average(), punch_colden(), punch_line(), Punch_Line_RT(), and punResults().

void CodeReview ( void  )

CodeReview - placed next to code that needs to be checked

Definition at line 1105 of file service.cpp.

References broke, DEBUG_ENTRY, and t_broke::lgCheckit.

Referenced by iso_level().

double csphot ( long int  inu,
long int  ithr,
long int  iofset 
)

csphot returns photoionization cross section from opacity stage using std pointers

Parameters
inuINU is array index pointing to frequency where opacity is to be evaluated on f not c scale
ithrITHR is pointer to threshold
iofsetIOFSET is offset as defined in opac0

Definition at line 1725 of file service.cpp.

References DEBUG_ENTRY, opac, and t_opac::OpacStack.

Referenced by OpacityAddTotal().

int dbg_printf ( int  debug,
const char *  fmt,
  ... 
)

dbg_printf is a debug print routine that was provided by Peter Teuben, as a component from his NEMO package. It offers run-time specification of the level of debugging

Definition at line 1136 of file service.cpp.

References DEBUG_ENTRY, t_trace::debug_level, ioQQQ, and trace.

int dprintf ( FILE *  fp,
const char *  format,
  ... 
)

dprintf – version of fprintf which prepends DEBUG

Definition at line 1114 of file service.cpp.

References DEBUG_ENTRY.

Referenced by iso_radiative_recomb_effective(), and qheat_init().

double dsexp ( double  x)

dsexp safe exponential function for doubles

Parameters
x

Definition at line 1056 of file service.cpp.

References DEBUG_ENTRY.

Referenced by FeIICollRatesBoltzmann(), Hion_coll_ioniz_ratecoef(), iso_collide(), and iso_satellite_update().

double e2 ( double  t)

e2 second exponential integral

Parameters
toptical depth argument

Definition at line 348 of file service.cpp.

References DEBUG_ENTRY, ee1(), max(), and sexp().

Referenced by DrvCaseBHS(), IterRestart(), IterStart(), MakeHCTData(), ParseDrive(), radius_increment(), RT_tau_reset(), and SanityCheckBegin().

Here is the call graph for this function:

double ee1 ( double  x)

ee1 first exponential integral

Parameters
xoptical depth argument, returns e1(tau)

Definition at line 361 of file service.cpp.

References cdEXIT, DEBUG_ENTRY, and ioQQQ.

Referenced by e2(), Hion_coll_ioniz_ratecoef(), Hydcs123(), ParseDrive(), and SanityCheckBegin().

double ee1_safe ( double  x)

this one same as ee1, except is divided by a factor of exp(x), and is only to be used for x>1.

Parameters
xoptical depth argument, returns e1(tau) * exp(x)

Definition at line 405 of file service.cpp.

References ASSERT, and DEBUG_ENTRY.

double FFmtRead ( const char *  chCard,
long int *  ipnt,
long int  last,
bool *  lgEOL 
)

FFmtRead - the free-format number reader

Parameters
*chCardstring giving the line image
*ipntthe index for the character in the string where we shall start
lastthe number of characters in the string - do not search beyond it
*lgEOLtrue if hit end of line with no number

Definition at line 430 of file service.cpp.

References ASSERT, DEBUG_ENTRY, and min().

Referenced by abund_starburst(), atmdat_Chianti_readin(), atmdat_lamda_readin(), atmdat_readin(), Badnell_rec_init(), cdGetLineList(), ContBandsCreate(), dgaunt(), DrvCaseBHS(), DrvEscP(), DrvHyas(), FeIIBandsCreate(), FillGFF(), GetOptColDen(), GetOptLineInt(), GetOptTemp(), GetStandardHeLines(), H2_ParsePunch(), H2_Read_hminus_distribution(), H2_ReadDissprob(), H2_ReadEnergies(), H2_ReadTransprob(), HeCollidSetup(), HelikeTransProbSetup(), HyperfineCreate(), iso_recomb_setup(), ParseAbsMag(), ParseAbundances(), ParseAge(), ParseAgn(), ParseAssertResults(), ParseAtomCO(), ParseAtomFeII(), ParseAtomH2(), ParseAtomISO(), ParseBackgrd(), ParseBlackbody(), ParseCaseB(), ParseCommands(), ParseCompile(), ParseConstant(), ParseCoronal(), ParseCosmicRays(), ParseCrashDo(), ParseDLaw(), ParseDrive(), ParseDynaTime(), ParseDynaWind(), ParseElement(), ParseExtinguish(), ParseF_nu(), ParseFluc(), ParseGlobule(), ParseGrain(), ParseGrid(), ParseHDEN(), ParseInterp(), ParseIonPar(), ParseMagnet(), ParseMap(), ParseMetal(), ParseNorm(), ParseOptimize(), ParsePlotRangeContin(), ParsePlotRangeOption(), ParsePowerlawContinuum(), ParsePrint(), ParsePunch(), ParseRadius(), ParseRangeOption(), ParseRatio(), ParseSet(), ParseSphere(), ParseStop(), ParseTable(), ParseTLaw(), ParseTrace(), PrtLineSum(), ptrcer(), punch_average(), punch_colden(), punch_line(), Punch_Line_RT(), read_continuum_mesh(), and read_hm05().

Here is the call graph for this function:

void fixit ( void  )
double fudge ( long int  ipnt)

fudge enter fudge factors, or some arbitrary number, with fudge command return value is the fudge factor fudge(-1) queries the routine for the number of fudge parameters that were entered, zero returned if none

Parameters
ipntinteger saying which of the possible numbers on the fudge command to use - 0 would be the first

Definition at line 530 of file service.cpp.

References cdEXIT, DEBUG_ENTRY, t_fudgec::fudgea, fudgec, ioQQQ, t_fudgec::lgFudgeUsed, and t_fudgec::nfudge.

Referenced by Fe7Lev8(), GrainChargeTemp(), H2_Cooling(), InitEmissivities(), and PresTotCurrent().

long int GetElem ( char *  chCARD_CAPS)

GetElem scans line image, finds element. returns atomic number j, on C scale. Returns , -1 if no hit. chCARD_CAPS must have been converted to all CAPS by caps() to work

Parameters
chCARD_CAPS

Definition at line 558 of file service.cpp.

References t_elementnames::chElementNameShort, DEBUG_ENTRY, elementnames, LIMELM, and nMatch().

Referenced by ParseAssertResults(), ParseAtomISO(), ParseElement(), ParsePrint(), ParsePunch(), ParseSet(), ParseTrace(), and punch_average().

Here is the call graph for this function:

int GetQuote ( char *  chLabel,
char *  chCard,
bool  lgABORT 
)
GetQuote get any name between double quotes off command line

return string as chLabel, is null terminated returns zero for success, 1 for did not find double quotes

Parameters
*chLabelwe will generate a label and stuff it here
*chCardlocal cap'd line, we will blank this out
lgABORTif true then abort if no double quotes found, if false then return null string in this case

Definition at line 584 of file service.cpp.

References cdEXIT, t_input::chOrgCard, DEBUG_ENTRY, input, and ioQQQ.

Referenced by ParseAssertResults(), ParseCompile(), ParseGrain(), ParseInit(), ParseNorm(), ParseOptimize(), ParsePunch(), ParseSet(), ParseState(), ParseStop(), and ParseTable().

long ipow ( long  ,
long   
)
ipow
Returns
m^n

Definition at line 718 of file service.cpp.

References DEBUG_ENTRY, and is_odd().

Here is the call graph for this function:

void MyAssert ( const char *  file,
int  line 
)
MyAssert a version of assert that fails gracefully
Parameters
*file
line

Definition at line 149 of file service.cpp.

References cdEXIT, conv, DEBUG_ENTRY, fnzone, ioQQQ, iteration, t_conv::lgSearch, nzone, ShowMe(), and TorF().

Referenced by main().

Here is the call graph for this function:

void* MyCalloc ( size_t  num,
size_t  size 
)

MyCalloc wrapper for calloc(). Returns a good pointer or dies.

Parameters
numuse same type as library function CALLOC
size

Definition at line 1652 of file service.cpp.

References ASSERT, cdEXIT, DEBUG_ENTRY, and ioQQQ.

double MyGaussRand ( double  PctUncertainty)

A custom wrapper for RandGauss than truncates at two standard deviations.

Parameters
PctUncertainty

Definition at line 1806 of file service.cpp.

References ASSERT, DEBUG_ENTRY, and RandGauss().

Referenced by iso_error_generation().

Here is the call graph for this function:

void* MyMalloc ( size_t  size,
const char *  file,
int  line 
)

MyMalloc wrapper for malloc(). Returns a good pointer or dies.

Parameters
sizeuse same type as library function malloc
file
line

Definition at line 1571 of file service.cpp.

References ASSERT, cdEXIT, DEBUG_ENTRY, ioQQQ, and set_NaN().

Here is the call graph for this function:

void* MyRealloc ( void *  p,
size_t  size 
)

MyRealloc wrapper for realloc(). Returns a good pointer or dies.

Parameters
numuse same type as library function REALLOC
size

Definition at line 1690 of file service.cpp.

References ASSERT, cdEXIT, DEBUG_ENTRY, and ioQQQ.

long nMatch ( const char *  chKey,
const char *  chCard 
)
NORETURN void NoNumb ( char *  chCard)
double plankf ( long int  ip)

plankf evaluate Planck function for any cell at current electron temperature

Parameters
ip

Definition at line 1831 of file service.cpp.

References t_rfield::anu, t_rfield::ContBoltz, DEBUG_ENTRY, FR1RYD, POW2, and rfield.

Referenced by PunchDo().

double powi ( double  ,
long  int 
)
void PrintE71 ( FILE *  ,
double   
)

print with 1p,e8.1 format onto stream FILE

Definition at line 867 of file service.cpp.

References DEBUG_ENTRY.

Referenced by PrtFinal().

void PrintE82 ( FILE *  ,
double   
)

print with 1p,e8.2 format onto stream FILE all are located in printe82.c

Definition at line 821 of file service.cpp.

References DEBUG_ENTRY.

Referenced by AbundancesSet(), optimize_func(), PrtAllTau(), PrtFinal(), and PrtHeader().

void PrintE93 ( FILE *  ,
double   
)

print with 1p,e9.3 format onto stream FILE

Definition at line 914 of file service.cpp.

References DEBUG_ENTRY.

Referenced by HydroLevel(), PrtAllTau(), PrtFinal(), PrtHeader(), PrtHydroTrace1a(), PrtZone(), and punch_opacity().

char* PrintEfmt ( const char *  fmt,
double  val 
)
create string with val and format, to print with %s,

much faster than above, totally native on non-MS systems

Parameters
*fmt
val

Definition at line 768 of file service.cpp.

References DEBUG_ENTRY.

Referenced by aver(), GammaPrt(), GetModel(), H2_Prt_column_density(), H2_Prt_Zone(), HydroLevel(), InterpolateGridCoStar(), InterpolateRectGrid(), iso_collide(), iso_level(), iso_photo(), iso_radiative_recomb(), map_do(), prme(), PrtAllTau(), PrtFinal(), PrtHeader(), PrtHydroTrace1(), PrtZone(), Punch1LineData(), and RT_tau_init().

double qg32 ( double  ,
double  ,
double(*)(double)   
)

32 point gaussian quadrature integration

Parameters
xllower limit to integration
xu- upper limit to integration
(*fct)- pointer to routine to be integrated, arg is x val

Definition at line 1158 of file service.cpp.

References DEBUG_ENTRY.

Referenced by AngerJ(), collision_strength_VF01(), conpmp(), cont_gaunt_calc(), CS_l_mixing_S62(), CS_l_mixing_VF01(), CS_ThermAve_PR78(), CS_VS80(), DrvContPump(), esccon(), helike_radrecomb_from_cross_section(), hlike_radrecomb_from_cross_section(), and Recomb_Seaton59().

double RandGauss ( double  xMean,
double  s 
)
normal random variate generator 
Parameters
xMeanmean value
sstandard deviation s

Definition at line 1766 of file service.cpp.

References BIGDOUBLE, DEBUG_ENTRY, genrand_real3(), x1, and x2.

Referenced by H2_Create(), ion_recomb(), and MyGaussRand().

Here is the call graph for this function:

char* read_whole_line ( char *  chLine,
int  nChar,
FILE *  ioIN 
)

read_whole_line safe version of fgets - read a line, return null if cannot read line or if input line is too long

Parameters
char*chLine - previously allocated string where the line image will be stored
intnChar size of chLine, we will return NULL if input line is longer than this
FILE*ioIN a previously opened file handle, will read from from here

Definition at line 70 of file service.cpp.

References called, DEBUG_ENTRY, ioQQQ, lgAbort, and t_called::lgTalk.

Referenced by atmdat_Chianti_readin(), atmdat_lamda_readin(), atmdat_readin(), Badnell_rec_init(), cdGetLineList(), ContBandsCreate(), dgaunt(), DrvCaseBHS(), DrvEscP(), DrvHyas(), FeIIBandsCreate(), FeIICreate(), FillGFF(), GetNextLine(), GetStandardHeLines(), H2_CollidRateRead(), H2_He_coll_init(), H2_Read_hminus_distribution(), H2_ReadDissprob(), H2_ReadEnergies(), H2_ReadTransprob(), HeCollidSetup(), HelikeTransProbSetup(), HyperfineCreate(), t_yield::init_yield(), iso_recomb_setup(), lgCompileAtmosphereCoStar(), main(), mie_next_line(), Nemala_Start(), ParseDrive(), ParseInit(), ptrcer(), RauchInitializeSub(), read_continuum_mesh(), read_hm05(), ReadTable(), and StarburstInitialize().

sys_float sexp ( sys_float  x)
double sexp ( double  x)

Definition at line 1036 of file service.cpp.

References DEBUG_ENTRY, and SEXP_LIMIT.

void ShowMe ( void  )
void Split ( const string &  str,
const string &  sep,
vector< string > &  lst,
split_mode  mode 
)

Split: split a string into substrings using "sep" as separator

Definition at line 102 of file service.cpp.

References cdEXIT, DEBUG_ENTRY, ioQQQ, SPM_KEEP_EMPTY, and SPM_STRICT.

Referenced by t_cpu::t_cpu(), and t_version::t_version().

void spsort ( realnum  x[],
long int  n,
long int  iperm[],
int  kflag,
int *  ier 
)

spsort netlib routine to sort array returning sorted indices

Parameters
x[]input array to be sorted
nnumber of values in x
iperm[]permutation output array
kflagflag saying what to do - 1 sorts into increasing order, not changing
kflagthe original routine
*iererror condition, should be 0

Definition at line 1223 of file service.cpp.

References DEBUG_ENTRY.

Referenced by atmdat_Chianti_readin(), CoolPunch(), H2_Create(), H2_PunchDo(), HeatPunch(), PrtFinal(), PrtLinePres(), and SanityCheckBegin().

void TestCode ( void  )

TestCode set flag saying that test code is in place

Definition at line 1075 of file service.cpp.

References DEBUG_ENTRY, and lgTestCodeCalled.

NORETURN void TotalInsanity ( void  )

TotalInsanity general error handler for something that cannot happen, exits

Definition at line 959 of file service.cpp.

References cdEXIT, DEBUG_ENTRY, ioQQQ, and ShowMe().

Referenced by AbundancesPrt(), multi_arr< realnum, 3 >::alloc(), atmdat_Chianti_readin(), atmdat_lamda_readin(), atmdat_readin(), atom_level3(), atom_levelN(), AtomCSInterp(), Badnell_rec_init(), cdInit(), cdLine(), cdRead(), Chianti_Upsilon(), CO_solve(), collision_strength_VF01(), conorm(), ContSetIntensity(), ConvInitSolution(), ConvIterCheck(), ConvTempEdenIoniz(), CoolCarb(), CoolEvaluate(), CoolIron(), CoolNitr(), CoolOxyg(), CoolSili(), CoolSulf(), CS_PercivalRichards78(), DebyeDeriv(), dense_fabden(), DynaPunch(), DynaPunchTimeDep(), Fe7Lev8(), Fe_10_11_13_cs(), multi_geom< d, MEM_LAYOUT_VAL, lgBOUNDSCHECKVAL >::finalize(), ForbiddenAuls(), getAtNo(), GrainChargeTemp(), GridGatherAfterCloudy(), GridGatherInCloudy(), GrnStdDpth(), H2_Create(), H2_LevelPops(), he_1trans(), helike_quantum_defect(), hmole_reactions(), hmole_step(), t_yield::init_yield(), InterpolateGridCoStar(), InterpolateModel(), InterpolateRectGrid(), ion_recom_calculate(), IonCSInterp(), iso_assign_quantum_numbers(), iso_collapsed_Aul_update(), iso_collapsed_bnl_set(), iso_collide(), iso_create(), iso_get_total_num_levels(), iso_level(), iso_radrecomb_from_cross_section(), iter_end_check(), lgCheckAsserts(), lgConvPres(), lgInputComment(), lgMolecAver(), lgOptimize_do(), lines(), lines_setup(), Nemala_Start(), Opacity_iso_photo_cs(), open_data(), ParseAssertResults(), ParseAtomFeII(), ParseAtomISO(), ParseGrain(), ParseOptimize(), ParsePunch(), ParseSet(), ParseTable(), PresTotCurrent(), prme(), PrtColumns(), PrtComment(), PrtFinal(), punch_average(), PunchDo(), radius_first(), radius_increment(), radius_next(), read_hm05(), rfield_opac_malloc(), RT_continuum_shield_fcn(), RT_OTS_ChkSum(), sprt_wl(), state_get_put(), tbl_fun(), tfidle(), timestep_next(), TlustyInterpolate(), and ZoneStart().

Here is the call graph for this function:

void uncaps ( char *  chCard)

uncaps convert input command line (through eol) to all lowercase

Parameters
chCard- line image as string of characters

Definition at line 312 of file service.cpp.

References DEBUG_ENTRY.

Referenced by atmdat_Chianti_readin(), and atmdat_lamda_readin().


Generated for cloudy by doxygen 1.8.4