00001
00002
00003
00004
00005 #include "cddefines.h"
00006 #include "continuum.h"
00007 #include "atmdat.h"
00008 #include "dense.h"
00009 #include "iso.h"
00010 #include "helike_recom.h"
00011 #include "grains.h"
00012 #include "rfield.h"
00013 #include "stars.h"
00014 #include "parse.h"
00015 #include "input.h"
00016 #include "parser.h"
00017
00018 void ParseCompile(Parser &p)
00019 {
00020 long int ncell;
00021 char chRead[FILENAME_PATH_LENGTH_2],
00022 chRFI[FILENAME_PATH_LENGTH_2],
00023 chSZD[FILENAME_PATH_LENGTH_2],
00024 chSTB99[FILENAME_PATH_LENGTH_2];
00025
00026
00027 DEBUG_ENTRY( "ParseCompile()" );
00028
00029
00030
00031 if( p.nMatch("OPAC") )
00032 {
00033 fprintf( ioQQQ, "The COMPILE OPACITIES command is currently not supported\n" );
00034 cdEXIT(EXIT_FAILURE);
00035
00036 # if 0
00037
00038
00039 ContCreateMesh();
00040
00041
00042 atmdat_readin();
00043
00044
00045 ContCreatePointers();
00046
00047 Badnell_rec_init();
00048
00049
00050 opac.lgCompileOpac = true;
00051
00052
00053
00054 OpacityCreateAll();
00055
00056 fprintf(ioQQQ,
00057 "Success!! Created file opacity.opc\nMake sure this is on the path.\n" );
00058 cdEXIT(EXIT_SUCCESS);
00059 # endif
00060 }
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 if( p.nMatch("GRAI") )
00095 {
00096
00097
00098
00099 ContCreateMesh();
00100
00101
00102
00103
00104
00105 chRFI[0] = '\0';
00106 chSZD[0] = '\0';
00107
00108
00109 if( p.nMatch( "\"" ) )
00110 {
00111 p.GetQuote(chRead, true );
00112 if( strstr_s(chRead,".rfi") != NULL || strstr_s(chRead,".mix") != NULL )
00113 {
00114 strcpy(chRFI,chRead);
00115 }
00116 else if( strstr_s(chRead,".szd") != NULL )
00117 {
00118 strcpy(chSZD,chRead);
00119 }
00120 else
00121 {
00122 fprintf( ioQQQ, " filename %s has unknown extension, sorry\n" , chRead );
00123 cdEXIT(EXIT_FAILURE);
00124 }
00125 }
00126
00127
00128 if( p.nMatch( "\"" ) )
00129 {
00130 p.GetQuote(chRead, true );
00131 if( strstr_s(chRead,".rfi") != NULL || strstr_s(chRead,".mix") != NULL )
00132 {
00133 strcpy(chRFI,chRead);
00134 }
00135 else if( strstr_s(chRead,".szd") != NULL )
00136 {
00137 strcpy(chSZD,chRead);
00138 }
00139 else
00140 {
00141 fprintf( ioQQQ, " filename %s has unknown extension, sorry\n" , chRead );
00142 cdEXIT(EXIT_FAILURE);
00143 }
00144 }
00145
00146
00147 if( chRFI[0] == '\0' )
00148 {
00149
00150 if( p.nMatchErase("AC1-") )
00151 {
00152
00153 strcpy(chRFI , "ac1-amcarb.rfi" );
00154
00155 }
00156 else if( p.nMatchErase("BE1-"))
00157 {
00158
00159 strcpy(chRFI , "be1-amcarb.rfi" );
00160
00161 }
00162 else if( p.nMatch( "GRAP") )
00163 {
00164
00165 strcpy(chRFI , "graphite.rfi" );
00166 }
00167 else if( p.nMatch( "SILI" ) )
00168 {
00169
00170 strcpy(chRFI , "silicate.rfi" );
00171 }
00172 else if( p.nMatch( " PAH" ) )
00173 {
00174
00175 strcpy(chRFI , "pah1.rfi" );
00176 }
00177 else if( p.nMatch( "GREY" ) || p.nMatch( "GRAY" ))
00178 {
00179 strcpy(chRFI , "grey.rfi" );
00180 }
00181 }
00182
00183
00184 if( chSZD[0] == '\0' )
00185 {
00186
00187 if( p.nMatchErase("0M010") )
00188 {
00189 strcpy(chSZD , "0m010.szd" );
00190 }
00191 else if( p.nMatchErase("0M100") )
00192 {
00193 strcpy(chSZD , "0m100.szd" );
00194 }
00195 else if( p.nMatchErase("1M000") )
00196 {
00197 strcpy(chSZD , "1m000.szd" );
00198 }
00199 else if( p.nMatch( "ORIO" ) )
00200 {
00201 strcpy(chSZD , "orion.szd" );
00202 }
00203 else if( p.nMatch( " ISM" ) )
00204 {
00205 strcpy(chSZD , "ism.szd" );
00206 }
00207 else if( p.nMatchErase("AB08") )
00208 {
00209
00210 strcpy(chSZD , "ab08.szd" );
00211 }
00212 else if( p.nMatchErase("C15") )
00213 {
00214
00215 strcpy(chSZD , "c15.szd" );
00216 }
00217 else if( p.nMatchErase("C120") )
00218 {
00219
00220 strcpy(chSZD , "c120.szd" );
00221 }
00222 }
00223
00224
00225
00226 if( chRFI[0] == '\0' && chSZD[0] != '\0' )
00227 {
00228 fprintf(ioQQQ,"Sorry, but I did not recognize a refractive index file.\n");
00229 fprintf(ioQQQ,"Supply a file name between quotes or one of the following ");
00230 fprintf(ioQQQ,"keywords: ac1-amcarb, be1-amcarb, graphite, silicate, grey, pah\n");
00231 cdEXIT(EXIT_FAILURE);
00232 }
00233
00234 if( chSZD[0] == '\0' && chRFI[0] != '\0' )
00235 {
00236 fprintf(ioQQQ,"Sorry, but I did not recognize a size distribution file.\n");
00237 fprintf(ioQQQ,"Supply a file name between quotes or one of the following ");
00238 fprintf(ioQQQ,"keywords: 0m010, 0m100, 1m000, ism, orion, c15, c120, ab08\n");
00239 cdEXIT(EXIT_FAILURE);
00240 }
00241
00242
00243 if( chRFI[0] == '\0' && chSZD[0] == '\0' )
00244 {
00245
00246 mie_write_opc( "graphite.rfi" , "ism.szd" , 1 );
00247
00248
00249 mie_write_opc( "silicate.rfi" , "ism.szd" , 1 );
00250
00251
00252 mie_write_opc( "graphite.rfi" , "ism.szd" , 10 );
00253
00254
00255 mie_write_opc( "silicate.rfi" , "ism.szd" , 10 );
00256
00257
00258 mie_write_opc( "graphite.rfi" , "orion.szd" , 1 );
00259
00260
00261 mie_write_opc( "silicate.rfi" , "orion.szd" , 1 );
00262
00263
00264 mie_write_opc( "graphite.rfi" , "orion.szd" , 10 );
00265
00266
00267 mie_write_opc( "silicate.rfi" , "orion.szd" , 10 );
00268
00269
00270 mie_write_opc( "silicate.rfi" , "0m010.szd" , 1 );
00271
00272
00273 mie_write_opc( "silicate.rfi" , "0m100.szd" , 1 );
00274
00275
00276 mie_write_opc( "silicate.rfi" , "1m000.szd" , 1 );
00277
00278
00279 mie_write_opc( "graphite.rfi" , "0m010.szd" , 1 );
00280
00281
00282 mie_write_opc( "graphite.rfi" , "0m100.szd" , 1 );
00283
00284
00285 mie_write_opc( "graphite.rfi" , "1m000.szd" , 1 );
00286
00287
00288 mie_write_opc( "grey.rfi" , "ism.szd" , 1 );
00289
00290
00291 mie_write_opc( "grey.rfi" , "ism.szd" , 10 );
00292
00293
00294 mie_write_opc( "pah1.rfi" , "c15.szd" , 1 );
00295
00296
00297 mie_write_opc( "pah1.rfi" , "c120.szd" , 1 );
00298
00299
00300 mie_write_opc( "pah1.rfi" , "ab08.szd" , 10 );
00301
00302
00303 mie_write_opc( "pah1.rfi" , "ab08.szd" , 1 );
00304 }
00305
00306 else
00307 {
00308 ncell = (long)p.FFmtRead();
00309 if( p.lgEOL() )
00310 {
00311
00312 ncell = 10;
00313 }
00314 if( ncell <= 0 )
00315 {
00316 fprintf(ioQQQ,"Number of bins must be positive. Sorry.\n");
00317 cdEXIT(EXIT_FAILURE);
00318 }
00319
00320 mie_write_opc( chRFI , chSZD , ncell );
00321 }
00322
00323 fprintf(ioQQQ,
00324 "Success!! Created grain opacity file(s).\nMake sure this directory is on the path.\n" );
00325 cdEXIT(EXIT_SUCCESS);
00326 }
00327
00328
00329 else if( p.nMatch("RECO") && p.nMatch("COEF") )
00330 {
00331 long ipISO;
00332 int nelem;
00333
00334 if( p.nMatch("H-LI") )
00335 ipISO = ipH_LIKE;
00336 else if( p.nMatch("HE-L") )
00337 ipISO = ipHE_LIKE;
00338 else
00339 {
00340 fprintf(ioQQQ,"Sorry, but I did not recognize an iso sequence.\n");
00341 fprintf(ioQQQ,"The available options are H-like and He-like.\nSorry.\n");
00342 cdEXIT(EXIT_FAILURE);
00343 }
00344
00345
00346 iso.lgCompileRecomb[ipISO] = true;
00347
00348
00349
00350 for( nelem = ipISO; nelem < LIMELM; nelem++)
00351 {
00352 long maxN;
00353 dense.lgElmtOn[nelem] = true;
00354 iso.nCollapsed_max[ipISO][nelem] = 0;
00355
00356 if( nelem == ipISO )
00357 maxN = RREC_MAXN;
00358 else
00359 maxN = LIKE_RREC_MAXN( nelem );
00360
00361 iso.n_HighestResolved_max[ipISO][nelem] = maxN;
00362
00363 iso_update_num_levels( ipISO, nelem );
00364 }
00365 }
00366
00367 else if( p.nMatch("GAUN") )
00368 {
00369
00370 rfield.lgCompileGauntFF = true;
00371 }
00372
00373 else if( p.nMatch("STAR") )
00374 {
00375 bool lgProblems = false;
00376
00377
00378
00379 ContCreateMesh();
00380
00381
00382
00383
00384
00385 if( p.nMatch( "\"" ))
00386 {
00387
00388
00389
00390
00391
00392 p.GetQuote( chRead, true );
00393
00394 char *ptr;
00395 if( ( ptr = strstr_s( chRead, "." ) ) != NULL )
00396 {
00397 if( strncmp( ptr, ".asc", 4 ) == 0 )
00398 {
00399 lgProblems = GridCompile( chRead );
00400 }
00401 else if( strncmp( ptr, ".stb", 4 ) == 0 )
00402 {
00403 strncpy( chSTB99, chRead, FILENAME_PATH_LENGTH_2 );
00404 strncpy( ptr, ".ascii", FILENAME_PATH_LENGTH_2 - (ptr-chRead) );
00405 lgProblems = StarburstInitialize( chSTB99, chRead );
00406 lgProblems = lgProblems || GridCompile( chRead );
00407 }
00408 else
00409 {
00410 fprintf( ioQQQ, " I did not recognize this file extension: %s\n", ptr );
00411 lgProblems = true;
00412 }
00413 }
00414 else
00415 {
00416 fprintf( ioQQQ, " I did not find any file extension: %s\n", chRead );
00417 lgProblems = true;
00418 }
00419 }
00420 else
00421 {
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431 process_counter pc;
00432
00433
00434 lgProblems = lgProblems || AtlasCompile(pc);
00435
00436 lgProblems = lgProblems || CoStarCompile(pc);
00437
00438 lgProblems = lgProblems || Kurucz79Compile(pc);
00439
00440 lgProblems = lgProblems || MihalasCompile(pc);
00441
00442 lgProblems = lgProblems || RauchCompile(pc);
00443
00444 lgProblems = lgProblems || StarburstCompile(pc);
00445
00446 lgProblems = lgProblems || TlustyCompile(pc);
00447
00448 lgProblems = lgProblems || WernerCompile(pc);
00449
00450 lgProblems = lgProblems || WMBASICCompile(pc);
00451
00452 if( pc.nFound == 0 )
00453 {
00454 fprintf( ioQQQ, "\n PROBLEM - No ascii files were found!\n" );
00455 fprintf( ioQQQ, " Did you change directory to where the stellar atmosphere files are?\n" );
00456 fprintf( ioQQQ, " This command will only work on files in the local directory. Sorry.\n" );
00457 lgProblems = true;
00458 }
00459 else
00460 {
00461 fprintf( ioQQQ, "\n %d ascii file(s) found", pc.nFound );
00462 if( pc.notProcessed > 0 )
00463 fprintf( ioQQQ, ", %d file(s) up to date", pc.notProcessed );
00464 if( pc.nOK > 0 )
00465 fprintf( ioQQQ, ", %d update(s) OK", pc.nOK );
00466 if( pc.nFail > 0 )
00467 fprintf( ioQQQ, ", %d update(s) failed", pc.nFail );
00468 int nSkip = pc.nFound - pc.notProcessed - pc.nOK - pc.nFail;
00469 if( nSkip > 0 )
00470 fprintf( ioQQQ, ", %d file(s) skipped after failure", nSkip );
00471 fprintf( ioQQQ, ".\n" );
00472 }
00473 }
00474
00475 if( lgProblems )
00476 {
00477 fprintf( ioQQQ, "\n Problems occurred during the compilation - check output.\n" );
00478 }
00479 else
00480 {
00481 fprintf( ioQQQ, "\n The compilation was successful!\n" );
00482 fprintf( ioQQQ,
00483 " The portable ascii files are no longer needed and may be deleted to save space.\n" );
00484 fprintf( ioQQQ, "\n Good Luck!!\n\n\n" );
00485 }
00486
00487 cdEXIT(lgProblems);
00488 }
00489 else
00490 {
00491 fprintf( ioQQQ, " One of the keywords, GRAINS, HE-LIKE, GAUNT, or STARS, must appear.\n" );
00492 fprintf( ioQQQ, " Sorry.\n" );
00493 cdEXIT(EXIT_FAILURE);
00494 }
00495
00496 return;
00497 }