14 int main(
int argc,
char *argv[] )
17 long int NumberWarnings,
66 fprintf(stderr,
"%s: argument %d `%s' not understood\n",argv[0],i,s);
71 while (s != NULL && *(++s)) {
84 if(++i == argc || argv[i][0] ==
'-') {
85 fprintf(stderr,
"%s: no argument given for -p flag\n",
95 fprintf(stderr,
"%s: argument %d, `%s': flag -%c not understood\n",
96 argv[0],i,argv[i],*s);
114 if( (ioOut = fopen(
"c:\\projects\\cloudy\\tests\\CallCloudy.txt",
"w" ))==NULL)
120 leno = (int)strlen(outtag);
121 leni = (int)strlen(intag);
122 lenp = (int)strlen(prefix);
127 filename = (
char *)
MALLOC((
unsigned)lena*
sizeof(char));
130 fprintf(stderr,
"%s: can't allocate memory\n",argv[0]);
133 strcpy(filename,prefix);
134 strcpy(filename+lenp,outtag);
135 if( (ioOut = fopen(filename,
"w" ))==NULL)
138 strcpy(filename+lenp,intag);
139 if( (ioInp = fopen(filename,
"r" ))==NULL)
157 if( chLine[0] ==
'\n' || chLine[0] ==
'\r' ||
158 ( chLine[0] ==
' ' && chLine[23] !=
'*' ) )
165 if( (chChar = strchr(chLine ,
'\"' ) ) ==NULL )
168 while( (chChar = strchr(chLine ,
'_' ) ) !=NULL )
179 while( (chChar = strchr(chLine ,
'[' ) ) !=NULL )
185 while( (chChar = strchr(chLine ,
']' ) ) !=NULL )
194 if( strncmp(chLine,
" * ",25) == 0 )
197 nread =
cdRead( chLine+25 );
214 fprintf(
ioQQQ,
" Warning: limit to number of lines exceeded, %i\n", nread);
245 " Cloudy ends:%4ld zone" ,
263 ", ABORT DISASTER PROBLEM" );
266 if( NumberWarnings > 0 )
273 if( NumberWarnings > 1 )
281 if( NumberCautions > 0 )
288 if( NumberCautions > 1 )
298 fprintf(
ioQQQ,
"BIG ");
299 fprintf(
ioQQQ,
"BOTCHED ASSERTS!!!");
304 if( NumberTempFailures+NumberPresFailures +NumberIonFailures+NumberNeFailures >0 )
307 ". Failures:%3ld thermal,%3ld pressure,%3ld ionization,%3ld electron density",
324 fprintf(
ioQQQ,
"\n");
335 fprintf(
ioQQQ,
" DISASTER - A memory allocation has failed. Bailing out...\n" );
338 catch( out_of_range& e )
340 fprintf(
ioQQQ,
" DISASTER - An out_of_range exception was caught, what() = %s. Bailing out...\n",
354 if( e.
sig() == SIGINT )
355 fprintf(
ioQQQ,
" User interrupt request. Bailing out...\n" );
356 else if( e.
sig() == SIGTERM )
357 fprintf(
ioQQQ,
" Termination request. Bailing out...\n" );
358 else if( e.
sig() == SIGILL )
359 fprintf(
ioQQQ,
" DISASTER - An illegal instruction was found. Bailing out...\n" );
360 else if( e.
sig() == SIGFPE )
361 fprintf(
ioQQQ,
" DISASTER - A floating point exception occurred. Bailing out...\n" );
362 else if( e.
sig() == SIGSEGV )
363 fprintf(
ioQQQ,
" DISASTER - A segmentation violation occurred. Bailing out...\n" );
365 else if( e.
sig() == SIGBUS )
366 fprintf(
ioQQQ,
" DISASTER - A bus error occurred. Bailing out...\n" );
369 fprintf(
ioQQQ,
" DISASTER - A signal %d was caught. Bailing out...\n", e.
sig() );
380 oss <<
" [Stop in " << e.
routine();
381 oss <<
" at " << e.
file() <<
":" << e.
line();
383 oss <<
", Cloudy exited OK]";
385 oss <<
", something went wrong]";
386 fprintf(
ioQQQ,
"%s\n", oss.str().c_str() );
390 catch( std::exception& e )
392 fprintf(
ioQQQ,
" DISASTER - An unknown exception was caught, what() = %s. Bailing out...\n",
399 fprintf(
ioQQQ,
" DISASTER - An unknown exception was caught. Bailing out...\n" );