94 printf(
" cdInit was not called first - this must be the first call.\n");
101 "cdDrive: lgOptimr=%1i lgVaryOn=%1i lgNoVary=%1i input.nSave:%li\n",
151 fprintf(
ioQQQ,
"cdDrive: returning failure during call. \n");
290 fprintf (ioOUT,
"\nActive fixits for this run\n");
294 fprintf(ioOUT,
"%s\n",it->c_str());
426 #if defined(_MSC_VER)
433 #include <sys/time.h>
434 #include <sys/resource.h>
447 #if defined(_MSC_VER)
452 clock_dat->tv_sec = clock_val/CLOCKS_PER_SEC;
453 clock_dat->tv_usec = 1000000*(clock_val-(clock_dat->tv_sec*CLOCKS_PER_SEC))/CLOCKS_PER_SEC;
457 struct rusage rusage;
458 if(getrusage(RUSAGE_SELF,&rusage) != 0)
460 fprintf(
ioQQQ,
"DISASTER cdClock called getrusage with invalid arguments.\n" );
464 clock_dat->tv_sec = rusage.ru_utime.tv_sec;
465 clock_dat->tv_usec = rusage.ru_utime.tv_usec;
482 struct timeval clock_dat;
490 return (
double)(clock_dat.tv_sec-
before.tv_sec)+1e-6*(
double)(clock_dat.tv_usec-
before.tv_usec);
496 fprintf(
ioQQQ,
"DISASTER cdExecTime was called before cdSetExecTime, impossible.\n" );
505 #if defined(_MSC_VER)
509 if(getrusage(RUSAGE_SELF,&usage) != 0)
511 fprintf(
ioQQQ,
"DISASTER cdMemory called getrusage with invalid arguments.\n" );
515 return usage.ru_maxrss;
530 fprintf( ioOUT,
" Input commands follow:\n" );
531 fprintf( ioOUT,
"c ======================\n" );
539 fprintf( ioOUT,
"c ======================\n" );
607 char chLABEL_CAPS[
NCHLAB];
612 if( strlen(chLabel) >
NCHLAB-1 )
614 fprintf(
ioQQQ,
" PROBLEM cdColm called with insane chLabel (between quotes) \"%s\", must be no more than %d characters long.\n",
619 strcpy( chLABEL_CAPS, chLabel );
632 fprintf(
ioQQQ,
" PROBLEM cdColm called with insane ion, =%li\n",
641 if( strcmp( chLABEL_CAPS ,
"H2" )==0 )
646 else if( strcmp( chLABEL_CAPS ,
"H2G" )==0 )
652 else if( strcmp( chLABEL_CAPS ,
"H2*" )==0 )
658 else if( strncmp(chLABEL_CAPS ,
"H2" , 2 ) == 0 &&
659 isdigit(chLABEL_CAPS[2]) && isdigit(chLABEL_CAPS[3]) )
661 long int iVib = chLABEL_CAPS[2] -
'0';
662 long int iRot = chLABEL_CAPS[3] -
'0';
663 if( iVib<0 || iRot < 0 )
665 fprintf(
ioQQQ,
" PROBLEM cdColm called with insane v,J for H2=\"%s\" caps=\"%s\"\n",
666 chLabel , chLABEL_CAPS );
675 else if( strcmp( chLABEL_CAPS ,
"HE1*" )==0 )
688 for (
size_t i=0; i<v.size(); ++i)
712 if( ion >
MAX2(3,nelem + 2) )
715 " cdColm asked to return ionization stage %ld for element \"%s\" but this is not physical.\n",
732 " cdColm did not understand this combination of label \"%s\" and ion %4ld.\n",
762 cdNwcns(&lgAbort_loc,&nw,&nc,&nn,&ns,&nte,&npe, &nIone, &nEdene );
765 if( nw || nc || nte || npe || nIone || nEdene || lgAbort_loc )
771 fprintf(ioOUT,
" Calculation ended with abort!\n");
787 fprintf( ioOUT ,
"Te failures=%4ld\n", nte );
792 fprintf( ioOUT ,
"Pressure failures=%4ld\n", npe );
797 fprintf( ioOUT ,
"Ionization failures=%4ld\n", nte );
802 fprintf( ioOUT ,
"Electron density failures=%4ld\n", npe );
819 for( nz = 0; nz<
nzone; ++nz )
840 double TotalPressure[],
842 double GasPressure[],
844 double RadiationPressure[])
850 for( nz = 0; nz<
nzone; ++nz )
918 const char *chWeight ,
932 strcpy( chCARD, chWeight );
937 if( strcmp(chCARD,
"RADIUS") == 0 )
939 else if( strcmp(chCARD,
"AREA") == 0 )
941 else if( strcmp(chCARD,
"VOLUME") == 0 )
945 fprintf(
ioQQQ,
" cdIonFrac: chWeight=%6.6s makes no sense to me, valid options are RADIUS, AREA, and VOLUME\n",
952 strcpy( chCARD, chLabel );
960 if( strcmp(chCARD,
"H2" ) == 0 )
968 fprintf(
ioQQQ,
" cdIonFrac: ion stage of zero and element %s makes no sense to me\n",
989 fprintf(
ioQQQ,
" cdIonFrac called with unknown element chLabel, =%4.4s\n",
1001 if( (ion > nelem+1 || ion < 0 ) && !(nelem==
ipHYDROGEN&&ion==2))
1003 fprintf(
ioQQQ,
" cdIonFrac asked to return ionization stage %ld for element %4.4s but this is not physical.\n",
1004 IonStage, chLabel );
1015 *fracin =
exp10((
double)aaa[ion]);
1053 printf(
" hits = %li\n", kount );
1068 const char *chLabel,
1077 long int i =
cdLine( chLabel , wavelength , relint , absint, 0 );
1081 const char *chLabel,
1101 cdLine_ip(ipobs,relint,absint,LineType);
1118 cdLine_ip( ipLine , relint , absint , 0 );
1137 if( LineType<0 || LineType>3 )
1139 fprintf(
ioQQQ,
" PROBLEM cdLine_ip called with insane nLineType - it must be between 0 and 3.\n");
1177 long int *NumberWarnings,
1178 long int *NumberCautions,
1179 long int *NumberNotes,
1180 long int *NumberSurprises,
1182 long int *NumberTempFailures,
1184 long int *NumberPresFailures,
1186 long int *NumberIonFailures,
1188 long int *NumberNeFailures )
1209 void cdOutput(
const string& filename,
const char *mode )
1216 if( !filename.empty() )
1229 ioQQQ = ( fp != NULL ) ? fp : stdout;
1232 void cdInput(
const string& filename,
const char *mode )
1239 if( !filename.empty() )
1244 fprintf(
ioQQQ,
" input file \"%s\" not found\n", filename.c_str() );
1313 const char *chLabel,
1320 const char *chWeight )
1332 strcpy( chWGHT, chWeight );
1334 strcpy( chELEM, chLabel );
1340 if( strcmp(chWGHT,
"RADIUS") == 0 )
1342 else if( strcmp(chWGHT,
"AREA") == 0 )
1344 else if( strcmp(chWGHT,
"VOLUME") == 0 )
1348 fprintf(
ioQQQ,
" cdTemp: chWeight=%6.6s makes no sense to me, the options are RADIUS, AREA, and VOLUME.\n",
1357 if( strcmp(chELEM,
"21CM") == 0 )
1366 else if( strcmp(chELEM,
"SPIN") == 0 )
1374 else if( strcmp(chELEM,
"OPTI") == 0 )
1383 else if( strcmp(chELEM,
"H2") == 0 )
1392 else if( strcmp(chELEM,
"TENE") == 0 )
1400 else if( strcmp(chELEM,
"") == 0 )
1409 fprintf(
ioQQQ,
" cdTemp called with ion=0 and unknown quantity, =%4.4s\n",
1429 fprintf(
ioQQQ,
" cdTemp called with unknown element chLabel, =%4.4s\n",
1441 if( ion > nelem+1 || ion < 0 )
1443 fprintf(
ioQQQ,
" cdTemp asked to return ionization stage %ld for element %4.4s but this is not physical.\n",
1444 IonStage, chLabel );
1452 *TeMean =
exp10((
double)aaa[ion]);
1468 const bool COLUMN0 =
true;
1469 const bool KEEP_VISIBLE =
false;
1470 const bool STRIP_VISIBLE =
true;
1478 printf(
" cdInit was not called first - this must be the first call.\n");
1503 fprintf(
ioQQQ,
" Too many line images entered to cdRead. The limit is %d.\n",
NKRD );
1504 fprintf(
ioQQQ,
" This limit is set by the variable NKRD which appears in input.h\n" );
1508 string chLocal( chInputLine );
1514 fprintf(
ioQQQ,
" PROBLEM cdRead, while parsing the following input line:\n %s\n",
1516 fprintf(
ioQQQ,
" found that the line is longer than %i characters, the longest possible line.\n",
1518 fprintf(
ioQQQ,
" Please make the command line no longer than this limit.\n");
1534 chLocal.append( npad,
' ' );
1570 FILE *test = stdout;
1573 fprintf(
ioQQQ,
" cdRead found NO BUFFERING command, redirecting output to stderr now.\n" );
1585 fprintf(
ioQQQ,
" cdRead found NO BUFFERING command, reopening file %s now.\n",
1594 fprintf(
ioQQQ,
" cdRead failed to reopen %s, aborting!\n",
1598 if( setvbuf(
ioQQQ, NULL, _IONBF, 0 ) != 0 )
1599 fprintf(
ioQQQ,
" PROBLEM -- cdRead failed to set NO BUFFERING mode.\n" );
1614 factor =
exp10(factor);
void cdDate(char chString[])
multi_arr< double, 2 > TempH_21cmSpinMean
bool nMatch(const char *chKey) const
void cdNotes(FILE *ioOUT)
void cdLine_ip(long int ipLine, double *relint, double *absint)
bool hasCommand(const char *s2)
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
void cdPrintCommands(FILE *ioOUT)
realnum WavlenErrorGet(realnum wavelength, long sig_figs)
void setline(const char *const card)
long findline(const char *chLabel, realnum wavelength)
void cdPressure_last(double *PresTotal, double *PresGas, double *PresRad)
void cdCautions(FILE *ioOUT)
int cdIonFrac(const char *chLabel, long int IonStage, double *fracin, const char *chWeight, bool lgDensity)
void cdWarnings(FILE *ioPNT)
TransitionList HFLines("HFLines",&AnonStates)
char chWarnln[LIMWCN][INPUT_LINE_LENGTH]
void CloseSaveFiles(bool lgFinal)
void cdTimescales(double *TTherm, double *THRecom, double *TH2)
int cdTemp(const char *chLabel, long int IonStage, double *TeMean, const char *chWeight)
vector< genericState > matchGeneric(const char *chLabel, bool lgValidate)
void cdDepth_depth(double cdDepth[])
molezone * findspecieslocal(const char buf[])
void InitMesh(bool lgUnitCell)
char chRgcln[2][INPUT_LINE_LENGTH]
int cdRead(const char *chInputLine)
STATIC void cdClock(struct timeval *clock_dat)
void setResolutionScaleFactor(double fac)
void trimTrailingWhiteSpace(string &str)
double pres_radiation_lines_curr
static FixitList & Inst()
void cdEmis_ip(long int ipLine, double *emiss, bool lgEmergent)
double time_H2_Dest_longest
void cdInput(const string &filename, const char *mode)
t_elementnames elementnames
t_iso_sp iso_sp[NISO][LIMELM]
long int nflux_with_check
double cdH2_colden(long iVib, long iRot)
multi_arr< double, 2 > TempB_HarMean
char chNoteln[LIMWCN][INPUT_LINE_LENGTH]
char chCaunln[LIMWCN][INPUT_LINE_LENGTH]
EmissionList::reference Emis() const
multi_arr< double, 2 > TempEdenMean
long debugLine(realnum wavelength)
const int INPUT_LINE_LENGTH
void cdPressure_depth(double TotalPressure[], double GasPressure[], double RadiationPressure[])
double column(const genericState &gs)
char chElementNameShort[LIMELM][CHARS_ELEMENT_NAME_SHORT]
TransitionProxy trans(const long ipHi, const long ipLo)
void ParseInit(Parser &p)
void MeanIon(char chType, long nelem, long dim, long *n, realnum arlog[], bool lgDensity) const
void cdEmis(const char *chLabel, realnum wavelength, double *emiss, bool lgEmergent)
long int cdLine(const char *chLabel, realnum wavelength, double *relint, double *absint)
int cdColm(const char *chLabel, long int ion, double *theocl)
multi_arr< double, 4 > TempIonMean
void cdErrors(FILE *ioOUT)
#define DEBUG_ENTRY(funcname)
void cdVersion(char chString[])
static vector< realnum > wavelength
multi_arr< double, 2 > TempMean
double getNumberDefault(const char *chDesc, double fdef)
void cdOutput(const string &filename, const char *mode)
void cdSurprises(FILE *ioOUT)
void cdNwcns(bool *lgAbort_ret, long int *NumberWarnings, long int *NumberCautions, long int *NumberNotes, long int *NumberSurprises, long int *NumberTempFailures, long int *NumberPresFailures, long int *NumberIonFailures, long int *NumberNeFailures)
int fprintf(const Output &stream, const char *format,...)
multi_arr< double, 4 > xIonMean
void cdReasonGeo(FILE *ioOUT)
double time_H2_Form_longest
char chBangln[LIMWCN][INPUT_LINE_LENGTH]
multi_arr< double, 2 > TempHarMean
realnum * pres_radiation_lines_curr
static struct timeval before