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.h"
00011 #include "helike_recom.h"
00012 #include "grains.h"
00013 #include "rfield.h"
00014 #include "stars.h"
00015 #include "parse.h"
00016 #include "input.h"
00017
00018 void ParseCompile(char *chCard )
00019 {
00020 bool lgEOL;
00021 long int i , ncell;
00022 char chRead[FILENAME_PATH_LENGTH_2],
00023 chRFI[FILENAME_PATH_LENGTH_2],
00024 chSZD[FILENAME_PATH_LENGTH_2],
00025 chSTB99[FILENAME_PATH_LENGTH_2],
00026 *ptr;
00027
00028
00029 DEBUG_ENTRY( "ParseCompile()" );
00030
00031
00032 # if 0
00033
00034 if( nMatch("OPAC",chCard) )
00035 {
00036
00037
00038 ContCreateMesh();
00039
00040
00041 atmdat_readin();
00042
00043
00044 ContCreatePointers();
00045
00046
00047 opac.lgCompileOpac = true;
00048
00049
00050
00051 OpacityCreateAll();
00052
00053 fprintf(ioQQQ,
00054 "Success!! Created file opacity.opc\nMake sure this is on the path.\n" );
00055 puts( "[Stop in ParseCompile]" );
00056 cdEXIT(EXIT_SUCCESS);
00057 }
00058 # endif
00059
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 if( nMatch("GRAI",chCard) )
00093 {
00094
00095
00096
00097 ContCreateMesh();
00098
00099
00100
00101
00102
00103 chRFI[0] = '\0';
00104 chSZD[0] = '\0';
00105
00106
00107 if( strchr( chCard,'\"' ) != NULL )
00108 {
00109 GetQuote(chRead,chCard, true );
00110 if( strstr(chRead,".rfi") != NULL || strstr(chRead,".mix") != NULL )
00111 {
00112 strcpy(chRFI,chRead);
00113 }
00114 else if( strstr(chRead,".szd") != NULL )
00115 {
00116 strcpy(chSZD,chRead);
00117 }
00118 else
00119 {
00120 fprintf( ioQQQ, " filename %s has unknown extension, sorry\n" , chRead );
00121 puts( "[Stop in ParseCompile]" );
00122 cdEXIT(EXIT_FAILURE);
00123 }
00124 }
00125
00126
00127 if( strchr( chCard,'\"' ) != NULL )
00128 {
00129 GetQuote(chRead,chCard, true );
00130 if( strstr(chRead,".rfi") != NULL || strstr(chRead,".mix") != NULL )
00131 {
00132 strcpy(chRFI,chRead);
00133 }
00134 else if( strstr(chRead,".szd") != NULL )
00135 {
00136 strcpy(chSZD,chRead);
00137 }
00138 else
00139 {
00140 fprintf( ioQQQ, " filename %s has unknown extension, sorry\n" , chRead );
00141 puts( "[Stop in ParseCompile]" );
00142 cdEXIT(EXIT_FAILURE);
00143 }
00144 }
00145
00146
00147 if( chRFI[0] == '\0' )
00148 {
00149
00150 if( (ptr = strstr(chCard,"AC1-")) != NULL )
00151 {
00152
00153 strcpy(chRFI , "ac1-amcarb.rfi" );
00154
00155 strncpy(ptr," ",4);
00156 }
00157 else if( (ptr = strstr(chCard,"BE1-")) != NULL )
00158 {
00159
00160 strcpy(chRFI , "be1-amcarb.rfi" );
00161
00162 strncpy(ptr," ",4);
00163 }
00164 else if( nMatch( "GRAP" , chCard ) )
00165 {
00166
00167 strcpy(chRFI , "graphite.rfi" );
00168 }
00169 else if( nMatch( "SILI" , chCard ) )
00170 {
00171
00172 strcpy(chRFI , "silicate.rfi" );
00173 }
00174 else if( nMatch( " PAH" , chCard ) )
00175 {
00176
00177 strcpy(chRFI , "pah1.rfi" );
00178 }
00179 else if( nMatch( "GREY" , chCard ) || nMatch( "GRAY" , chCard ))
00180 {
00181 strcpy(chRFI , "grey.rfi" );
00182 }
00183 }
00184
00185
00186 if( chSZD[0] == '\0' )
00187 {
00188
00189 if( (ptr = strstr(chCard,"0M010")) != NULL )
00190 {
00191 strcpy(chSZD , "0m010.szd" );
00192
00193 strncpy(ptr," ",5);
00194 }
00195 else if( (ptr = strstr(chCard,"0M100")) != NULL )
00196 {
00197 strcpy(chSZD , "0m100.szd" );
00198
00199 strncpy(ptr," ",5);
00200 }
00201 else if( (ptr = strstr(chCard,"1M000")) != NULL )
00202 {
00203 strcpy(chSZD , "1m000.szd" );
00204
00205 strncpy(ptr," ",5);
00206 }
00207 else if( nMatch( "ORIO" , chCard ) )
00208 {
00209 strcpy(chSZD , "orion.szd" );
00210 }
00211 else if( nMatch( " ISM" , chCard ) )
00212 {
00213 strcpy(chSZD , "ism.szd" );
00214 }
00215 else if( (ptr = strstr(chCard,"BT94")) != NULL )
00216 {
00217
00218 strcpy(chSZD , "bt94.szd" );
00219 strncpy(ptr," ",4);
00220 }
00221 else if( (ptr = strstr(chCard,"0N341")) != NULL )
00222 {
00223
00224 strcpy(chSZD , "0n341.szd" );
00225 strncpy(ptr," ",5);
00226 }
00227 else if( (ptr = strstr(chCard,"0N682")) != NULL )
00228 {
00229
00230 strcpy(chSZD , "0n682.szd" );
00231 strncpy(ptr," ",5);
00232 }
00233 }
00234
00235
00236
00237 if( chRFI[0] == '\0' && chSZD[0] != '\0' )
00238 {
00239 fprintf(ioQQQ,"Sorry, but I did not recognize a refractive index file.\n");
00240 fprintf(ioQQQ,"Supply a file name between quotes or one of the following ");
00241 fprintf(ioQQQ,"keywords: ac1-amcarb, be1-amcarb, graphite, silicate, grey, pah\n");
00242 cdEXIT(EXIT_FAILURE);
00243 }
00244
00245 if( chSZD[0] == '\0' && chRFI[0] != '\0' )
00246 {
00247 fprintf(ioQQQ,"Sorry, but I did not recognize a size distribution file.\n");
00248 fprintf(ioQQQ,"Supply a file name between quotes or one of the following ");
00249 fprintf(ioQQQ,"keywords: 0m010, 0m100, 1m000, ism, orion, on341, 0n682, bt94\n");
00250 cdEXIT(EXIT_FAILURE);
00251 }
00252
00253
00254 if( chRFI[0] == '\0' && chSZD[0] == '\0' )
00255 {
00256
00257 mie_write_opc( "graphite.rfi" , "ism.szd" , 1 );
00258
00259
00260 mie_write_opc( "silicate.rfi" , "ism.szd" , 1 );
00261
00262
00263 mie_write_opc( "graphite.rfi" , "ism.szd" , 10 );
00264
00265
00266 mie_write_opc( "silicate.rfi" , "ism.szd" , 10 );
00267
00268
00269 mie_write_opc( "graphite.rfi" , "orion.szd" , 1 );
00270
00271
00272 mie_write_opc( "silicate.rfi" , "orion.szd" , 1 );
00273
00274
00275 mie_write_opc( "graphite.rfi" , "orion.szd" , 10 );
00276
00277
00278 mie_write_opc( "silicate.rfi" , "orion.szd" , 10 );
00279
00280
00281 mie_write_opc( "silicate.rfi" , "0m010.szd" , 1 );
00282
00283
00284 mie_write_opc( "silicate.rfi" , "0m100.szd" , 1 );
00285
00286
00287 mie_write_opc( "silicate.rfi" , "1m000.szd" , 1 );
00288
00289
00290 mie_write_opc( "graphite.rfi" , "0m010.szd" , 1 );
00291
00292
00293 mie_write_opc( "graphite.rfi" , "0m100.szd" , 1 );
00294
00295
00296 mie_write_opc( "graphite.rfi" , "1m000.szd" , 1 );
00297
00298
00299 mie_write_opc( "grey.rfi" , "ism.szd" , 1 );
00300
00301
00302 mie_write_opc( "grey.rfi" , "ism.szd" , 10 );
00303
00304
00305 mie_write_opc( "pah1.rfi" , "0n341.szd" , 1 );
00306
00307
00308 mie_write_opc( "pah1.rfi" , "0n682.szd" , 1 );
00309
00310
00311 mie_write_opc( "pah1.rfi" , "bt94.szd" , 10 );
00312
00313
00314 mie_write_opc( "pah1.rfi" , "bt94.szd" , 1 );
00315 }
00316
00317 else
00318 {
00319 i = 5;
00320 ncell = (long)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00321 if( lgEOL )
00322 {
00323
00324 ncell = 10;
00325 }
00326 if( ncell <= 0 )
00327 {
00328 fprintf(ioQQQ,"Number of bins must be positive. Sorry.\n");
00329 cdEXIT(EXIT_FAILURE);
00330 }
00331
00332 mie_write_opc( chRFI , chSZD , ncell );
00333 }
00334
00335 fprintf(ioQQQ,
00336 "Success!! Created grain opacity file(s).\nMake sure this directory is on the path.\n" );
00337 puts( "[Stop in ParseCompile]" );
00338 cdEXIT(EXIT_SUCCESS);
00339 }
00340
00341 else if( nMatch("HE-L",chCard) )
00342 {
00343 int nelem;
00344
00345 helike.lgCompileRecomb = true;
00346
00347
00348
00349 for( nelem = ipHELIUM; nelem < LIMELM; nelem++)
00350 {
00351 dense.lgElmtOn[nelem] = true;
00352 iso.nTopOff[ipHE_LIKE][nelem] = 0;
00353 iso.nCollapsed_max[ipHE_LIKE][nelem] = 0;
00354
00355 if( nelem == ipHELIUM )
00356 {
00357 iso.numLevels_max[ipHE_LIKE][nelem] = ( ( 1 + HE_RREC_MAXN ) * HE_RREC_MAXN + 1 );
00358 iso.n_HighestResolved_max[ipHE_LIKE][nelem] = HE_RREC_MAXN;
00359 }
00360 else
00361 {
00362 iso.numLevels_max[ipHE_LIKE][nelem] = ( ( 1 + HE_LIKE_RREC_MAXN ) * HE_LIKE_RREC_MAXN + 1 );
00363 iso.n_HighestResolved_max[ipHE_LIKE][nelem] = HE_LIKE_RREC_MAXN;
00364 }
00365 }
00366 }
00367
00368 else if( nMatch("GAUN",chCard) )
00369 {
00370
00371 rfield.lgCompileGauntFF = true;
00372 }
00373
00374 else if( nMatch("STAR",chCard) )
00375 {
00376 bool lgProblems = false;
00377
00378
00379
00380 ContCreateMesh();
00381
00382
00383
00384
00385
00386 if( strchr( input.chOrgCard,'\"' ) != NULL )
00387 {
00388
00389
00390
00391
00392
00393 GetQuote( chRead, chCard, true );
00394
00395 if( ( ptr = strstr( 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
00432 lgProblems = lgProblems || AtlasCompile();
00433
00434 lgProblems = lgProblems || CoStarCompile();
00435
00436 lgProblems = lgProblems || Kurucz79Compile();
00437
00438 lgProblems = lgProblems || MihalasCompile();
00439
00440 lgProblems = lgProblems || RauchCompile();
00441
00442 lgProblems = lgProblems || StarburstCompile();
00443
00444 lgProblems = lgProblems || TlustyCompile();
00445
00446 lgProblems = lgProblems || WernerCompile();
00447
00448 lgProblems = lgProblems || WMBASICCompile();
00449 }
00450
00451 if( lgProblems )
00452 {
00453 fprintf( ioQQQ, " \n Problems occurred during the compilation - check output.\n" );
00454 }
00455 else
00456 {
00457 fprintf( ioQQQ, " \n The compilation was successful!\n" );
00458 fprintf( ioQQQ,
00459 " The portable ascii files are no longer needed and may be deleted to save space.\n" );
00460 fprintf( ioQQQ, "\n Good Luck!!\n\n\n" );
00461 }
00462
00463 puts( "[Stop in ParseCompile]" );
00464 cdEXIT(EXIT_SUCCESS);
00465 }
00466 else
00467 {
00468 fprintf( ioQQQ, " One of the keywords, GRAINS, HE-LIKE, GAUNT, or STARS, must appear.\n" );
00469 fprintf( ioQQQ, " Sorry.\n" );
00470 puts( "[Stop in ParseCompile]" );
00471 cdEXIT(EXIT_FAILURE);
00472 }
00473
00474 DEBUG_EXIT( "ParseCompile()" );
00475
00476 return;
00477 }