90 printf(
" cdInit was not called first - this must be the first call.\n");
97 "cdDrive: lgOptimr=%1i lgVaryOn=%1i lgNoVary=%1i input.nSave:%li\n",
122 fprintf(
ioQQQ,
"cdDrive: calling grid_do\n");
129 fprintf(
ioQQQ,
"cdDrive: calling cloudy\n");
137 fprintf(
ioQQQ,
"An MPI run failed. The fail mode is %li\n", bad_info.
failMode() );
150 fprintf(
ioQQQ,
"cdDrive: returning failure during call. \n");
195 fprintf( ioOUT ,
"\n" );
198 fprintf( ioOUT ,
"\n" );
223 fprintf( ioPNT,
"\n" );
250 fprintf( ioOUT,
"\n" );
306 fprintf( ioOUT,
"\n" );
333 fprintf( ioOUT,
"\n" );
441 #if defined(_MSC_VER)
449 #include <sys/time.h>
450 #include <sys/resource.h>
463 #if defined(_MSC_VER) || defined(__HP_aCC)
468 clock_dat->tv_sec = clock_val/CLOCKS_PER_SEC;
469 clock_dat->tv_usec = 1000000*(clock_val-(clock_dat->tv_sec*CLOCKS_PER_SEC))/CLOCKS_PER_SEC;
473 struct rusage rusage;
474 if(getrusage(RUSAGE_SELF,&rusage) != 0)
476 fprintf(
ioQQQ,
"DISASTER cdClock called getrusage with invalid arguments.\n" );
477 fprintf(
ioQQQ,
"Sorry.\n" );
480 clock_dat->tv_sec = rusage.ru_utime.tv_sec;
481 clock_dat->tv_usec = rusage.ru_utime.tv_usec;
498 struct timeval clock_dat;
506 return (
double)(clock_dat.tv_sec-
before.tv_sec)+1e-6*(
double)(clock_dat.tv_usec-
before.tv_usec);
512 fprintf(
ioQQQ,
"DISASTER cdExecTime was called before SetExecTime, impossible.\n" );
513 fprintf(
ioQQQ,
"Sorry.\n" );
529 fprintf( ioOUT,
" Input commands follow:\n" );
530 fprintf( ioOUT,
"c ======================\n" );
536 fprintf( ioOUT,
"c ======================\n" );
569 strcpy( chCARD, chLabel );
585 if( fabs(
LineSv[j].wavelength-wavelength) < errorwave && strcmp(chCaps,chCARD) == 0 )
640 char chLABEL_CAPS[20];
647 fprintf(
ioQQQ,
" cdColm called with insane ion label, =%s, must be 4 character + end of string.\n",
652 strcpy( chLABEL_CAPS, chLabel );
661 fprintf(
ioQQQ,
" cdColm called with insane ion, =%li\n",
670 if( strcmp( chLABEL_CAPS ,
"H2 " )==0 )
676 else if( strcmp( chLABEL_CAPS ,
"H- " )==0 )
682 else if( strcmp( chLABEL_CAPS ,
"H2+ " )==0 )
688 else if( strcmp( chLABEL_CAPS ,
"H3+ " )==0 )
694 else if( strcmp( chLABEL_CAPS ,
"H2G " )==0 )
700 else if( strcmp( chLABEL_CAPS ,
"H2* " )==0 )
706 else if( strcmp( chLABEL_CAPS ,
"HEH+" )==0 )
712 else if( strcmp( chLABEL_CAPS ,
"CO " )==0 )
718 else if( strcmp( chLABEL_CAPS ,
"OH " )==0 )
724 else if( strcmp( chLABEL_CAPS ,
"H2O " )==0 )
730 else if( strcmp( chLABEL_CAPS ,
"O2 " )==0 )
736 else if( strcmp( chLABEL_CAPS ,
"SIO " )==0 )
742 else if( strcmp( chLABEL_CAPS ,
"C2 " )==0 )
748 else if( strcmp( chLABEL_CAPS ,
"C3 " )==0 )
754 else if( strcmp( chLABEL_CAPS ,
"CN " )==0 )
760 else if( strcmp( chLABEL_CAPS ,
"CH " )==0 )
766 else if( strcmp( chLABEL_CAPS ,
"CH+ " )==0 )
775 else if( strcmp( chLABEL_CAPS ,
"CII*" )==0 )
779 else if( strcmp( chLABEL_CAPS ,
"C11*" )==0 )
783 else if( strcmp( chLABEL_CAPS ,
"C12*" )==0 )
787 else if( strcmp( chLABEL_CAPS ,
"C13*" )==0 )
791 else if( strcmp( chLABEL_CAPS ,
"O11*" )==0 )
795 else if( strcmp( chLABEL_CAPS ,
"O12*" )==0 )
799 else if( strcmp( chLABEL_CAPS ,
"O13*" )==0 )
804 else if( strcmp( chLABEL_CAPS ,
"C30*" )==0 )
808 else if( strcmp( chLABEL_CAPS ,
"C31*" )==0 )
812 else if( strcmp( chLABEL_CAPS ,
"C32*" )==0 )
816 else if( strcmp( chLABEL_CAPS ,
"SI2*" )==0 )
820 else if( strcmp( chLABEL_CAPS ,
"HE1*" )==0 )
825 else if( strncmp(chLABEL_CAPS ,
"H2" , 2 ) == 0 )
827 long int iVib = chLABEL_CAPS[2] -
'0';
828 long int iRot = chLABEL_CAPS[3] -
'0';
829 if( iVib<0 || iRot < 0 )
831 fprintf(
ioQQQ,
" cdColm called with insane v,J for H2=\"%4.4s\" caps=\"%4.4s\"\n",
832 chLabel , chLABEL_CAPS );
841 fprintf(
ioQQQ,
" cdColm called with unknown element chLabel, org=\"%4.4s \" 0 caps=\"%4.4s\" 0\n",
842 chLabel , chLABEL_CAPS );
864 if( ion >
MAX2(3,nelem + 2) )
867 " cdColm asked to return ionization stage %ld for element %s but this is not physical.\n",
884 " cdColm did not understand this combination of ion %4ld and element %4.4s.\n",
914 cdNwcns(&lgAbort_loc,&nw,&nc,&nn,&ns,&nte,&npe, &nIone, &nEdene );
917 if( nw || nc || nte || npe || nIone || nEdene || lgAbort_loc )
923 fprintf(ioOUT,
" Calculation ended with abort!\n");
939 fprintf( ioOUT ,
"Te failures=%4ld\n", nte );
944 fprintf( ioOUT ,
"Pressure failures=%4ld\n", npe );
949 fprintf( ioOUT ,
"Ionization failures=%4ld\n", nte );
954 fprintf( ioOUT ,
"Electron density failures=%4ld\n", npe );
971 for( nz = 0; nz<
nzone; ++nz )
992 double TotalPressure[],
994 double GasPressure[],
996 double RadiationPressure[])
1002 for( nz = 0; nz<
nzone; ++nz )
1070 const char *chWeight ,
1086 strcpy( chCARD, chWeight );
1092 if( strcmp(chCARD,
"RADIUS") == 0 )
1097 else if( strcmp(chCARD,
"VOLUME") == 0 )
1104 fprintf(
ioQQQ,
" cdIonFrac: chWeight=%6.6s makes no sense to me, valid options are RADIUS and VOLUME\n",
1111 strcpy( chCARD, chLabel );
1118 if( strcmp(chCARD,
"H2 " ) == 0 )
1126 fprintf(
ioQQQ,
" cdIonFrac: ion stage of zero and element %s makes no sense to me\n",
1149 fprintf(
ioQQQ,
" cdIonFrac called with unknown element chLabel, =%4.4s\n",
1163 if( (ion > nelem+1 || ion < 0 ) && !(nelem==
ipHYDROGEN&&ion==2))
1165 fprintf(
ioQQQ,
" cdIonFrac asked to return ionization stage%4ld for element %4.4s but this is not physical.\n",
1166 IonStage, chLabel );
1180 *fracin = pow((
realnum)10.f,aaa[ion]);
1187 *fracin = pow((
realnum)10.f,aaa[ion]);
1219 if( fabs(
LineSv[j].wavelength-wavelength) < errorwave )
1221 printf(
"%s\n",
LineSv[j].chALab);
1225 printf(
" hits = %li\n", kount );
1250 fprintf(io,
"%li\t%s\t",
1284 j, index_of_closest=LONG_MIN,
1285 index_of_closest_w_correct_label=-1;
1287 smallest_error_w_correct_label=
BIGFLOAT;
1305 fprintf(
ioQQQ,
" cdLine called with insane line label, =%s, must be 4 character + end of string.\n",
1311 strcpy( chLabelLoc , chLabel );
1313 cap4(chFind,chLabelLoc);
1317 for( j=0; j<=3; j++ )
1319 if( chFind[j] ==
'\t' )
1330 enum{DEBUG_LOC=
false};
1332 if( DEBUG_LOC && fabs(wavelength-1000.)<0.01 )
1334 fprintf(
ioQQQ,
"cdDrive wl %.4e error %.3e\n",
1335 wavelength, errorwave );
1345 current_error = (
realnum)fabs(
LineSv[j].wavelength-wavelength);
1350 if( current_error < smallest_error )
1352 index_of_closest = j;
1353 smallest_error = current_error;
1356 if( current_error < smallest_error_w_correct_label &&
1357 (strcmp(chCaps,chFind) == 0) )
1359 index_of_closest_w_correct_label = j;
1360 smallest_error_w_correct_label = current_error;
1366 if( current_error < errorwave )
1373 if( strcmp(chCaps,chFind) == 0 )
1407 fprintf(
ioQQQ,
" NOTE cdLine did not find line with label %4s and wavelength ", chFind );
1409 if( index_of_closest >= 0 )
1411 fprintf(
ioQQQ,
".\n The closest line (any label) was \t%4s\t",
LineSv[index_of_closest].chALab );
1414 fprintf(
ioQQQ,
"\n The closest with correct label was\t%4s\t", chFind );
1417 fprintf(
ioQQQ,
"\n" );
1421 fprintf(
ioQQQ,
".\n PROBLEM No close line was found\n" );
1513 cap4(chFind,chLabel);
1530 if( fabs(
LineSv[j].wavelength-wavelength) < errorwave )
1537 if( strcmp(chCaps,chFind) == 0 )
1554 if(
LineSv[ipobs].sumlin[1] > 0. )
1587 long int *NumberWarnings,
1588 long int *NumberCautions,
1589 long int *NumberNotes,
1590 long int *NumberSurprises,
1592 long int *NumberTempFailures,
1594 long int *NumberPresFailures,
1596 long int *NumberIonFailures,
1598 long int *NumberNeFailures )
1726 const char *chWeight )
1740 strcpy( chWGHT, chWeight );
1744 strcpy( chELEM, chLabel );
1748 if( strcmp(chWGHT,
"RADIUS") == 0 )
1752 else if( strcmp(chWGHT,
"VOLUME") == 0 )
1758 fprintf(
ioQQQ,
" cdTemp: chWeight=%6.6s makes no sense to me, the options are RADIUS and VOLUME.\n",
1767 if( strcmp(chELEM,
"21CM") == 0 )
1796 else if( strcmp(chELEM,
"SPIN") == 0 )
1802 else if( strcmp(chELEM,
"OPTI") == 0 )
1810 else if( strcmp(chELEM,
"H2 ") == 0 )
1838 else if( strcmp(chELEM,
" ") == 0 )
1867 fprintf(
ioQQQ,
" cdTemp called with ion=0 and unknown quantity, =%4.4s\n",
1869 fprintf(
ioQQQ,
" I know about 21CM and H2__ \n");
1890 fprintf(
ioQQQ,
" cdTemp called with unknown element chLabel, =%4.4s\n",
1903 if( ion > nelem+1 || ion < 0 || ion >
LIMELM )
1905 fprintf(
ioQQQ,
" cdTemp asked to return ionization stage%4ld for element %4.4s but this is not physical.\n",
1906 IonStage, chLabel );
1916 *TeMean = pow((
realnum)10.f,aaa[ion]);
1921 *TeMean = pow((
realnum)10.f,aaa[ion]);
1938 const char *chInputLine )
1950 printf(
" cdInit was not called first - this must be the first call.\n");
1959 chInputLine[0] ==
'\n' || chInputLine[0] ==
' ' ) &&
1961 ! ( chInputLine[0] ==
'C' || chInputLine[0] ==
'c' ) )
1981 " Too many line images entered to cdRead. The limit is %d\n",
1984 " The limit to the number of allowed input lines is %d. This limit was exceeded. Sorry.\n",
1987 " This limit is set by the variable NKRD which appears in input.h \n" );
1989 " Increase it everywhere it appears.\n" );
1999 fprintf(
ioQQQ,
" PROBLEM cdRead, while parsing the following input line:\n %s\n",
2001 fprintf(
ioQQQ,
" found that the line is longer than %i characters, the longest possible line.\n",
2003 fprintf(
ioQQQ,
" Please make the command line no longer than this limit.\n");
2008 if( (chEOL = strchr(chLocal,
'\n' ) ) != NULL )
2012 if( (chEOL = strchr(chLocal,
'%' ) ) != NULL )
2017 if( (chEOL = strchr(chLocal,
'#' ) ) != NULL )
2021 if( (chEOL = strchr(chLocal,
';' ) ) != NULL )
2025 if( (chEOL = strstr(chLocal,
"//" ) ) != NULL )
2032 if( (chEOL = strchr( chLocal,
'\0' )) == NULL )
2039 strcat( chLocal,
" " );
2046 strcpy( chCARD, chLocal );
2050 if( strncmp(chCARD,
"TRACE",5) == 0 )
2062 if(
nMatch(
"VARY",chCARD) )
2069 if( strncmp(chCARD,
"NO VARY",7) == 0 )
2075 if( strncmp(chCARD,
"GRID",4) == 0 )
2083 if( strncmp(chCARD,
"NO BUFF",7) == 0 )
2088 FILE *test = stdout;
2091 fprintf(
ioQQQ,
" cdRead found NO BUFFERING command, redirecting output to stderr now.\n" );
2102 if( strncmp(chCARD,
"OPTI",4) == 0 || strncmp(chCARD,
"GRID",4) == 0 )
2122 double cdTemp21cmLya(
void )