cloudy trunk
Loading...
Searching...
No Matches
service.cpp File Reference
#include "cdstd.h"
#include <cstdarg>
#include "cddefines.h"
#include "physconst.h"
#include "cddrive.h"
#include "called.h"
#include "opacity.h"
#include "rfield.h"
#include "hextra.h"
#include "struc.h"
#include "hmi.h"
#include "fudgec.h"
#include "broke.h"
#include "trace.h"
#include "input.h"
#include "save.h"
#include "version.h"
#include "warnings.h"
#include "conv.h"
#include "thirdparty.h"
#include "mole.h"
#include "atmdat.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, const char *comment)
double AnuUnit (realnum energy_ryd)
void ShowMe (void)
void cap4 (char *chCAP, const 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)
int GetQuote (char *chStringOut, char *chCard, char *chCardRaw, bool lgAbort)
double powi (double x, long int n)
long ipow (long m, long n)
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)
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)
void CloudyPrintReference ()
void DatabasePrintReference ()
istream & SafeGetline (istream &is, string &t)

Function Documentation

◆ AnuUnit()

double AnuUnit ( realnum energy)

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

Definition at line 173 of file service.cpp.

References DEBUG_ENTRY, Energy::get(), and save.

Referenced by AGN_Hemis(), Save1Line(), Save1LineData(), save_opacity(), SaveDo(), SaveNewContinuum(), and SaveSpeciesOne().

Here is the call graph for this function:

◆ BadRead()

NORETURN void BadRead ( void )

BadRead tried to read internal data and failed

Definition at line 901 of file service.cpp.

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

Referenced by diatomics::H2_Read_hminus_distribution(), and HelikeTransProbSetup().

Here is the call graph for this function:

◆ broken()

void broken ( void )

broken set flag saying that the code is broken

Definition at line 982 of file service.cpp.

References broke, and DEBUG_ENTRY.

Referenced by fill_array(), and PresTotCurrent().

◆ cap4()

void cap4 ( char * chCAP,
const 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 240 of file service.cpp.

References DEBUG_ENTRY, and toupper().

Referenced by cdEmis(), cdLine(), lgCheckMonitors(), optimize_func(), ParseNorm(), and PrtFinal().

Here is the call graph for this function:

◆ caps()

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 280 of file service.cpp.

References DEBUG_ENTRY, and toupper().

Referenced by cdColm(), cdEmis(), cdIonFrac(), cdRead(), cdTemp(), t_input::echo(), Parser::newlineProcess(), and PrtFinal().

Here is the call graph for this function:

◆ CloudyPrintReference()

void CloudyPrintReference ( )

CloudyPrintReference print preferred citation to Cloudy

Definition at line 1728 of file service.cpp.

References AS_DATA_ONLY, Singleton< t_version >::Inst(), ioQQQ, mode_r, open_data(), and SafeGetline().

Referenced by PrtHeader().

Here is the call graph for this function:

◆ CodeReview()

void CodeReview ( void )

CodeReview - placed next to code that needs to be checked

Definition at line 1000 of file service.cpp.

References broke, and DEBUG_ENTRY.

◆ csphot()

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 1602 of file service.cpp.

References DEBUG_ENTRY, and opac.

Referenced by OpacityAddTotal().

◆ DatabasePrintReference()

void DatabasePrintReference ( )

DatabasePrintReference print some database references

Definition at line 1745 of file service.cpp.

References AS_DATA_ONLY, atmdat, ioQQQ, mode_r, open_data(), and SafeGetline().

Referenced by PrtFinal(), and PrtHeader().

Here is the call graph for this function:

◆ dbg_printf()

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 1031 of file service.cpp.

References DEBUG_ENTRY, ioQQQ, and trace.

◆ dprintf()

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

dprintf – version of fprintf which prepends DEBUG

Definition at line 1009 of file service.cpp.

References DEBUG_ENTRY.

Referenced by atmdat_readin(), CoolCarb(), CoolNitr(), CoolOxyg(), CoolSili(), CoolSulf(), DumpCoolStack(), DumpHeatStack(), iso_radiative_recomb_effective(), iter_track::print_status(), and qheat_init().

◆ dsexp()

double dsexp ( double x)

◆ e2()

double e2 ( double t)

e2 second exponential integral

Parameters
toptical depth argument

Definition at line 299 of file service.cpp.

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

Referenced by DrvCaseBHS(), humlik(), IterRestart(), IterStart(), MakeHCTData(), newton_step(), my_Integrand_escConE2::operator()(), ParseDrive(), RT_continuum(), RT_tau_reset(), and SanityCheckBegin().

Here is the call graph for this function:

◆ ee1()

double ee1 ( double x)

ee1 first exponential integral

Parameters
xoptical depth argument, returns e1(tau)

Definition at line 312 of file service.cpp.

References cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, and ioQQQ.

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

◆ ee1_safe()

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 356 of file service.cpp.

References ASSERT, and DEBUG_ENTRY.

◆ FFmtRead()

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 381 of file service.cpp.

References ASSERT, DEBUG_ENTRY, ioQQQ, and min().

Referenced by atmdat_LAMDA_readin(), atmdat_readin(), atmdat_STOUT_readin(), Badnell_rec_init(), ContBandsCreate(), database_readin(), dgaunt(), DrvCaseBHS(), DrvEscP(), DrvHyas(), FeIIBandsCreate(), FillGFF(), diatomics::GetIndices(), GetStandardHeLines(), diatomics::H2_Read_hminus_distribution(), diatomics::H2_ReadDissocEnergies(), diatomics::H2_ReadDissprob(), diatomics::H2_ReadEnergies(), diatomics::H2_ReadTransprob(), HeCollidSetup(), HelikeTransProbSetup(), HyperfineCreate(), iso_recomb_setup(), FunctLAMDA::operator()(), ParseDrive(), ptrcer(), read_continuum_mesh(), read_Helike_cross_sections(), read_hm05(), read_SH98_He1_cross_sections(), ReadCollisionRateTable(), and ReadIsotopeFractions().

Here is the call graph for this function:

◆ fixit()

void fixit ( void )

fixit set flag saying that this code needs attention, but is not broken, code is in service.cpp

Definition at line 991 of file service.cpp.

References broke, and DEBUG_ENTRY.

Referenced by AbundChange(), atmdat_CHIANTI_readin(), atmdat_readin(), atom_oi_calc(), ChargTranSumHeat(), ContCreatePointers(), ConvBase(), CoolEvaluate(), create_isotopologues_one(), database_readin(), diatomics::diatomics(), DynaCreateArrays(), FndLineHt(), ForbiddenAuls(), GetAveVelocity(), GetDensity(), gridXspec(), diatomics::H2_CollidRateEvalAll(), diatomics::H2_LevelPops(), diatomics::H2_X_sink_and_source(), HeatSum(), HomogeneousSource(), diatomics::init(), IonCSInterp(), IonHydro(), iso_collide(), iso_cool(), iso_ionize_recombine(), iso_level(), iso_satellite(), lgNetEdenSrcSmall(), lines(), lines_helium(), lines_hydro(), t_mole_global::make_species(), mole_check_reverse_reactions(), mole_create_react(), mole_generate_isotopologue_reactions(), diatomics::mole_H2_form(), mole_h2_grain_form(), mole_h_reactions(), mole_partition_function(), mole_solve(), OpacityAddTotal(), OpacityCreateAll(), ParseAtomH2(), ParseCosmology(), ParseDont(), pressureZone(), PresTotCurrent(), PrtZone(), punchFITS_PrimaryHeader(), radius_next(), read_data(), ReadIsotopeFractions(), RT_iso_integrate_RRC(), RT_line_all(), RT_line_escape(), RT_line_one_tauinc(), RT_OTS_Update(), RT_tau_init(), SaveNewContinuum(), set_fractionation(), SetDeuteriumIonization(), diatomics::SolveExcitedElectronicLevels(), state_get_put(), states_nelemfill(), store_new_densities(), zero(), and zoneDensity().

◆ fudge()

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 481 of file service.cpp.

References cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, fudgec, and ioQQQ.

Referenced by atmdat_readin(), GrainChargeTemp(), InitEmissivities(), and PresTotCurrent().

◆ GetQuote()

int GetQuote ( char * chLabel,
char * chCard,
char * chCardRaw,
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
*chLabelnull terminated string between quotes
*chCardinput line, imagae, we set string between quotes to spaces
lgABORTif true then abort if no double quotes found, if false then return null string in this case,
Returns
0 if found double quotes, 1 if did not, string between quotes set to spaces

Definition at line 513 of file service.cpp.

References cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, ioQQQ, lgAbort, strchr_s(), and TotalInsanity().

Referenced by cdRead().

Here is the call graph for this function:

◆ ipow()

long ipow ( long m,
long n )

ipow

Returns
m^n

Definition at line 639 of file service.cpp.

References DEBUG_ENTRY, and is_odd().

Here is the call graph for this function:

◆ MyAssert()

void MyAssert ( const char * file,
int line,
const char * comment )

MyAssert a version of assert that fails gracefully

Parameters
*file
line

Definition at line 153 of file service.cpp.

References cdEXIT, conv, DEBUG_ENTRY, EXIT_FAILURE, fnzone, ioQQQ, iteration, nzone, ShowMe(), and TorF().

Referenced by cdMain().

Here is the call graph for this function:

◆ MyCalloc()

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 1533 of file service.cpp.

References ASSERT, cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, and ioQQQ.

◆ MyGaussRand()

double MyGaussRand ( double PctUncertainty)

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

Parameters
PctUncertainty

Definition at line 1683 of file service.cpp.

References ASSERT, DEBUG_ENTRY, and RandGauss().

Referenced by iso_error_generation().

Here is the call graph for this function:

◆ MyMalloc()

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 1448 of file service.cpp.

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

Here is the call graph for this function:

◆ MyRealloc()

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 1569 of file service.cpp.

References ASSERT, cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, and ioQQQ.

◆ nMatch()

long nMatch ( const char * chKey,
const char * chCard )

nMatch determine whether match to a keyword occurs on command line, return value is 0 if no match, and position of match within string if hit

Parameters
*chKey
*chCard

Definition at line 451 of file service.cpp.

References ASSERT, DEBUG_ENTRY, and strstr_s().

Referenced by atmdat_CHIANTI_readin(), atmdat_LAMDA_readin(), atmdat_STOUT_readin(), Badnell_rec_init(), cdRead(), t_input::echo(), mie_read_mix(), mie_read_rfi(), mie_read_szd(), ParseGrain(), ParseSave(), PrtFinal(), SaveDo(), StandardEnergyUnit(), StandardFluxUnit(), and vary_input().

Here is the call graph for this function:

◆ plankf()

double plankf ( long int ip)

plankf evaluate Planck function for any cell at current electron temperature

Parameters
ip

Definition at line 1707 of file service.cpp.

References DEBUG_ENTRY, FR1RYD, POW2, and rfield.

Referenced by SaveDo().

◆ powi()

◆ PrintE71()

void PrintE71 ( FILE * ioOUT,
double value )

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

Definition at line 788 of file service.cpp.

References DEBUG_ENTRY.

Referenced by PrtFinal().

◆ PrintE82()

void PrintE82 ( FILE * ioOUT,
double value )

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

Definition at line 739 of file service.cpp.

References DEBUG_ENTRY.

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

◆ PrintE93()

void PrintE93 ( FILE * ioOUT,
double value )

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

Definition at line 838 of file service.cpp.

References DEBUG_ENTRY.

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

◆ qg32()

double qg32 ( double xl,
double xu,
double(* fct )(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 1053 of file service.cpp.

References DEBUG_ENTRY.

Referenced by AngerJ(), cont_gaunt_calc(), CS_ThermAve_PR78(), iso_radrecomb_from_cross_section(), Recomb_Seaton59(), and SanityCheckBegin().

◆ RandGauss()

double RandGauss ( double xMean,
double s )

normal random variate generator

Parameters
xMeanmean value
sstandard deviation s

Definition at line 1643 of file service.cpp.

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

Referenced by Badnell_rec_init(), diatomics::init(), and MyGaussRand().

Here is the call graph for this function:

◆ read_whole_line()

◆ SafeGetline()

istream & SafeGetline ( istream & is,
string & t )

Definition at line 1770 of file service.cpp.

Referenced by CloudyPrintReference(), and DatabasePrintReference().

◆ sexp() [1/2]

double sexp ( double x)

Definition at line 933 of file service.cpp.

References DEBUG_ENTRY, and SEXP_LIMIT.

◆ sexp() [2/2]

◆ ShowMe()

◆ Split()

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 106 of file service.cpp.

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

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

◆ spsort()

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 1100 of file service.cpp.

References DEBUG_ENTRY.

Referenced by atmdat_CHIANTI_readin(), CoolSave(), diatomics::H2_PunchDo(), PrtFinal(), PrtLinePres(), SanityCheckBegin(), and SaveHeat().

◆ TestCode()

void TestCode ( void )

TestCode set flag saying that test code is in place

Definition at line 972 of file service.cpp.

References DEBUG_ENTRY, and lgTestCodeCalled.

Referenced by RT_continuum().

◆ TotalInsanity()

NORETURN void TotalInsanity ( void )

TotalInsanity general error handler for something that cannot happen, exits

Definition at line 886 of file service.cpp.

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

Referenced by AbundancesPrt(), iterator< bool, 2 >::alloc(), atmdat_CHIANTI_readin(), atmdat_LAMDA_readin(), atmdat_readin(), atom_level3(), atom_levelN(), AtomCSInterp(), Badnell_rec_init(), cdInit(), cdLine(), cdMain(), cdRead(), CHIANTI_Upsilon(), t_ADfA::coll_ion_wrapper(), collision_strength_VF01(), conorm(), ContSetIntensity(), ConvInitSolution(), ConvIterCheck(), ConvTempEdenIoniz(), CoolCarb(), CoolEvaluate(), CoolNitr(), CoolOxyg(), CoolSave(), CoolSili(), CoolSulf(), cross_section(), CS_PercivalRichards78(), database_readin(), dawson(), dBase_solve(), DebyeDeriv(), DynaPunchTimeDep(), DynaSave(), multi_geom< d, ALLOC >::finalize(), ForbiddenAuls(), ForcePass(), t_cpu_i::getPathList(), GetQuote(), GrainChargeTemp(), GrainMakeDiffuse(), GravitationalPressure(), GridGatherInCloudy(), GrnStdDpth(), H21_cm_pops(), diatomics::H2_LevelPops(), he_1trans(), helike_quantum_defect(), diatomics::init(), t_yield::init_yield(), InterpolateGridCoStar(), InterpolateModel(), InterpolateRectGrid(), IonCSInterp(), irsl2ind(), iso_assign_quantum_numbers(), iso_collapsed_Aul_update(), iso_collapsed_bnl_set(), iso_collide(), iso_create(), iso_cross_section(), iso_get_total_num_levels(), iso_radrecomb_from_cross_section(), iter_end_check(), lgCheckMonitors(), lgInputComment(), lgOptimize_do(), lines(), lines_setup(), t_mean::MeanIon(), mole_effects(), mole_h_reactions(), Opacity_iso_photo_cs(), phymir_state< X, Y, NP, NSTR >::p_barrier(), phymir_state< X, Y, NP, NSTR >::p_execute_job(), iterator< bool, 2 >::p_setupArray(), pah2_fun(), pah3_fun(), ParseAtomFeII(), ParseAtomISO(), ParseBlackbody(), ParseCosmology(), ParseGrain(), ParseMonitorResults(), ParseSave(), ParseSet(), ParseTable(), PrtColumns(), PrtComment(), PrtFinal(), PrtMeanIon(), radius_first(), radius_next(), read_hm05(), read_SH98_He1_cross_sections(), ReadBadnellAIData(), rfield_opac_malloc(), RT_continuum(), RT_continuum_shield_fcn(), RT_OTS_ChkSum(), save_average(), SaveDo(), sprt_wl(), StarburstInitialize(), state_get_put(), states_nelemfill(), SumDensities(), tbl_fun(), tfidle(), timestep_next(), TlustyInterpolate(), TotalInsanityAsStub(), vary_input(), zoneDensity(), and ZoneStart().

Here is the call graph for this function:

◆ uncaps()

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 263 of file service.cpp.

References DEBUG_ENTRY, and tolower().

Referenced by atmdat_CHIANTI_readin(), atmdat_STOUT_readin(), and database_readin().

Here is the call graph for this function: