92 printf(
" cdInit was not called first - this must be the first call.\n");
99 "cdDrive: lgOptimr=%1i lgVaryOn=%1i lgNoVary=%1i input.nSave:%li\n",
149 fprintf(
ioQQQ,
"cdDrive: returning failure during call. \n");
292 fprintf (ioOUT,
"\nActive fixits for this run\n");
296 fprintf(ioOUT,
"%s\n",it->c_str());
431 #if defined(_MSC_VER)
438 #include <sys/time.h>
439 #include <sys/resource.h>
452 #if defined(_MSC_VER)
457 clock_dat->tv_sec = clock_val/CLOCKS_PER_SEC;
458 clock_dat->tv_usec = 1000000*(clock_val-(clock_dat->tv_sec*CLOCKS_PER_SEC))/CLOCKS_PER_SEC;
462 struct rusage rusage;
463 if(getrusage(RUSAGE_SELF,&rusage) != 0)
465 fprintf(
ioQQQ,
"DISASTER cdClock called getrusage with invalid arguments.\n" );
469 clock_dat->tv_sec = rusage.ru_utime.tv_sec;
470 clock_dat->tv_usec = rusage.ru_utime.tv_usec;
487 struct timeval clock_dat;
495 return (
double)(clock_dat.tv_sec-
before.tv_sec)+1e-6*(
double)(clock_dat.tv_usec-
before.tv_usec);
501 fprintf(
ioQQQ,
"DISASTER cdExecTime was called before SetExecTime, impossible.\n" );
514 if(getrusage(RUSAGE_SELF,&usage) != 0)
516 fprintf(
ioQQQ,
"DISASTER cdClock called getrusage with invalid arguments.\n" );
520 return usage.ru_maxrss;
535 fprintf( ioOUT,
" Input commands follow:\n" );
536 fprintf( ioOUT,
"c ======================\n" );
542 fprintf( ioOUT,
"c ======================\n" );
610 char chLABEL_CAPS[
NCHLAB];
615 if( strlen(chLabel) >
NCHLAB-1 )
617 fprintf(
ioQQQ,
" PROBLEM cdColm called with insane chLabel (between quotes) \"%s\", must be no more than %d characters long.\n",
622 strcpy( chLABEL_CAPS, chLabel );
635 fprintf(
ioQQQ,
" PROBLEM cdColm called with insane ion, =%li\n",
644 if( strcmp( chLABEL_CAPS ,
"H2" )==0 )
649 else if( strcmp( chLABEL_CAPS ,
"H2G" )==0 )
655 else if( strcmp( chLABEL_CAPS ,
"H2*" )==0 )
661 else if( strncmp(chLABEL_CAPS ,
"H2" , 2 ) == 0 &&
662 isdigit(chLABEL_CAPS[2]) && isdigit(chLABEL_CAPS[3]) )
664 long int iVib = chLABEL_CAPS[2] -
'0';
665 long int iRot = chLABEL_CAPS[3] -
'0';
666 if( iVib<0 || iRot < 0 )
668 fprintf(
ioQQQ,
" PROBLEM cdColm called with insane v,J for H2=\"%s\" caps=\"%s\"\n",
669 chLabel , chLABEL_CAPS );
678 else if( strcmp( chLABEL_CAPS ,
"HE1*" )==0 )
691 for (
size_t i=0; i<v.size(); ++i)
715 if( ion >
MAX2(3,nelem + 2) )
718 " cdColm asked to return ionization stage %ld for element \"%s\" but this is not physical.\n",
735 " cdColm did not understand this combination of label \"%s\" and ion %4ld.\n",
765 cdNwcns(&lgAbort_loc,&nw,&nc,&nn,&ns,&nte,&npe, &nIone, &nEdene );
768 if( nw || nc || nte || npe || nIone || nEdene || lgAbort_loc )
774 fprintf(ioOUT,
" Calculation ended with abort!\n");
790 fprintf( ioOUT ,
"Te failures=%4ld\n", nte );
795 fprintf( ioOUT ,
"Pressure failures=%4ld\n", npe );
800 fprintf( ioOUT ,
"Ionization failures=%4ld\n", nte );
805 fprintf( ioOUT ,
"Electron density failures=%4ld\n", npe );
822 for( nz = 0; nz<
nzone; ++nz )
843 double TotalPressure[],
845 double GasPressure[],
847 double RadiationPressure[])
853 for( nz = 0; nz<
nzone; ++nz )
921 const char *chWeight ,
935 strcpy( chCARD, chWeight );
940 if( strcmp(chCARD,
"RADIUS") == 0 )
942 else if( strcmp(chCARD,
"AREA") == 0 )
944 else if( strcmp(chCARD,
"VOLUME") == 0 )
948 fprintf(
ioQQQ,
" cdIonFrac: chWeight=%6.6s makes no sense to me, valid options are RADIUS, AREA, and VOLUME\n",
955 strcpy( chCARD, chLabel );
962 if( strcmp(chCARD,
"H2 " ) == 0 )
970 fprintf(
ioQQQ,
" cdIonFrac: ion stage of zero and element %s makes no sense to me\n",
991 fprintf(
ioQQQ,
" cdIonFrac called with unknown element chLabel, =%4.4s\n",
1003 if( (ion > nelem+1 || ion < 0 ) && !(nelem==
ipHYDROGEN&&ion==2))
1005 fprintf(
ioQQQ,
" cdIonFrac asked to return ionization stage %ld for element %4.4s but this is not physical.\n",
1006 IonStage, chLabel );
1017 *fracin =
exp10((
double)aaa[ion]);
1055 printf(
" hits = %li\n", kount );
1070 const char *chLabel,
1079 long int i =
cdLine( chLabel , wavelength , relint , absint, 0 );
1083 const char *chLabel,
1103 cdLine_ip(ipobs,relint,absint,LineType);
1120 cdLine_ip( ipLine , relint , absint , 0 );
1139 if( LineType<0 || LineType>3 )
1141 fprintf(
ioQQQ,
" PROBLEM cdLine_ip called with insane nLineType - it must be between 0 and 3.\n");
1179 long int *NumberWarnings,
1180 long int *NumberCautions,
1181 long int *NumberNotes,
1182 long int *NumberSurprises,
1184 long int *NumberTempFailures,
1186 long int *NumberPresFailures,
1188 long int *NumberIonFailures,
1190 long int *NumberNeFailures )
1211 void cdOutput(
const char* filename,
const char *mode )
1218 if( *filename !=
'\0' )
1224 void cdInput(
const char* filename,
const char *mode )
1231 if( *filename !=
'\0' )
1298 const char *chLabel,
1305 const char *chWeight )
1317 strcpy( chWGHT, chWeight );
1319 strcpy( chELEM, chLabel );
1324 if( strcmp(chWGHT,
"RADIUS") == 0 )
1326 else if( strcmp(chWGHT,
"AREA") == 0 )
1328 else if( strcmp(chWGHT,
"VOLUME") == 0 )
1332 fprintf(
ioQQQ,
" cdTemp: chWeight=%6.6s makes no sense to me, the options are RADIUS, AREA, and VOLUME.\n",
1341 if( strcmp(chELEM,
"21CM") == 0 )
1350 else if( strcmp(chELEM,
"SPIN") == 0 )
1358 else if( strcmp(chELEM,
"OPTI") == 0 )
1367 else if( strcmp(chELEM,
"H2") == 0 )
1376 else if( strcmp(chELEM,
"TENE") == 0 )
1384 else if( strcmp(chELEM,
"") == 0 )
1393 fprintf(
ioQQQ,
" cdTemp called with ion=0 and unknown quantity, =%4.4s\n",
1413 fprintf(
ioQQQ,
" cdTemp called with unknown element chLabel, =%4.4s\n",
1425 if( ion > nelem+1 || ion < 0 )
1427 fprintf(
ioQQQ,
" cdTemp asked to return ionization stage %ld for element %4.4s but this is not physical.\n",
1428 IonStage, chLabel );
1436 *TeMean =
exp10((
double)aaa[ion]);
1452 const char *chInputLine )
1465 printf(
" cdInit was not called first - this must be the first call.\n");
1474 chInputLine[0] ==
'\n' || chInputLine[0] ==
' ' ) &&
1476 ! ( chInputLine[0] ==
'C' || chInputLine[0] ==
'c' ) )
1496 " Too many line images entered to cdRead. The limit is %d\n",
1499 " The limit to the number of allowed input lines is %d. This limit was exceeded. Sorry.\n",
1502 " This limit is set by the variable NKRD which appears in input.h \n" );
1504 " Increase it everywhere it appears.\n" );
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");
1523 if( (chEOL =
strchr_s(chLocal,
'\n' ) ) != NULL )
1527 if( (chEOL =
strchr_s(chLocal,
'%' ) ) != NULL )
1532 if( (chEOL =
strchr_s(chLocal,
'#' ) ) != NULL )
1536 if( (chEOL =
strchr_s(chLocal,
';' ) ) != NULL )
1540 if( (chEOL =
strstr_s(chLocal,
"//" ) ) != NULL )
1547 if( (chEOL =
strchr_s( chLocal,
'\0' )) == NULL )
1554 strcat( chLocal,
" " );
1561 strcpy( chCARD, chLocal );
1566 if( strncmp(chCARD ,
"C ", 2 )==0 )
1568 bool lgTitle = ( strncmp(chCARD,
"TITL", 4) == 0 );
1571 if( strncmp(chCARD,
"TRACE",5) == 0 )
1583 do {}
while(
GetQuote( chFilename , chCARD , chTemp ,
false ) == 0 );
1586 if( !lgComment && !lgTitle &&
nMatch(
"VARY",chCARD) )
1591 if( strncmp(chCARD,
"NO VARY",7) == 0 )
1595 if( strncmp(chCARD,
"GRID",4) == 0 )
1603 if( strncmp(chCARD,
"NO BUFF",7) == 0 )
1608 FILE *test = stdout;
1611 fprintf(
ioQQQ,
" cdRead found NO BUFFERING command, redirecting output to stderr now.\n" );
1623 fprintf(
ioQQQ,
" cdRead found NO BUFFERING command, reopening file %s now.\n",
1632 fprintf(
ioQQQ,
" cdRead failed to reopen %s, aborting!\n",
1636 if( setvbuf(
ioQQQ, NULL, _IONBF, 0 ) != 0 )
1637 fprintf(
ioQQQ,
" PROBLEM -- cdRead failed to set NO BUFFERING mode.\n" );
1644 if( strncmp(chCARD,
"OPTI",4) == 0 || strncmp(chCARD,
"GRID",4) == 0 )
1648 if( strncmp(chCARD,
"SET ",4) == 0 &&
nMatch(
"CONT",chCARD) &&
nMatch(
"RESO",chCARD) )
1655 factor =
exp10(factor);
void cdDate(char chString[])
multi_arr< double, 2 > TempH_21cmSpinMean
void cdNotes(FILE *ioOUT)
void cdLine_ip(long int ipLine, double *relint, double *absint)
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
void cdPrintCommands(FILE *ioOUT)
realnum WavlenErrorGet(realnum wavelength, long sig_figs)
NORETURN void TotalInsanity(void)
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)
long nMatch(const char *chKey, const char *chCard)
TransitionList HFLines("HFLines",&AnonStates)
void cdInput(const char *filename, const char *mode)
char chWarnln[LIMWCN][INPUT_LINE_LENGTH]
void CloseSaveFiles(bool lgFinal)
const char * strstr_s(const char *haystack, const char *needle)
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
t_elementnames elementnames
t_iso_sp iso_sp[NISO][LIMELM]
long int nflux_with_check
int GetQuote(char *chLabel, char *chCard, char *chCardRaw, bool lgABORT)
double cdH2_colden(long iVib, long iRot)
void cdOutput(const char *filename, const char *mode)
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
const char * strchr_s(const char *s, int c)
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 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
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]
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)
multi_arr< double, 2 > TempHarMean
realnum * pres_radiation_lines_curr
static struct timeval before