46 FILE *ioMASTERLIST, *ioVERSION;
54 const int MAX_NUM_SPECIES = 1000;
60 static int nCalled = 0;
61 long nSpeciesLAMDA, nSpeciesSTOUT, nSpeciesCHIANTI;
89 long numModelsNotUsed = 0;
90 strcpy( chPath,
"lamda" );
91 strcat( chPath,
input.chDelimiter );
92 strcat( chPath,
"masterlist" );
95 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) == NULL )
97 fprintf(
ioQQQ,
" database_readin could not read first line of LAMDA masterlist.\n");
103 if ((chLine[0]!=
'#') && (chLine[0]!=
'\n')&&(chLine[0]!=
'\t')&&(chLine[0]!=
'\r'))
105 strcpy(chDLine, chLine);
106 chToken = strtok(chDLine,
" \t\n");
111 ASSERT( nSpeciesLAMDA + 1 <= MAX_NUM_SPECIES );
113 strcpy( chLabels[
nSpecies], chToken );
117 strcpy( chPaths[
nSpecies],
"lamda" );
119 chToken = strtok( NULL,
" \t\n" );
120 strcat( chPaths[
nSpecies], chToken );
128 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) != NULL );
134 fclose(ioMASTERLIST);
147 long numModelsNotUsed = 0;
148 strcpy( chPath,
"cdms+jpl" );
149 strcat( chPath,
input.chDelimiter );
150 strcat( chPath,
"masterlist" );
153 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) == NULL )
155 fprintf(
ioQQQ,
" database_readin could not read first line of CDMS/JPL masterlist.\n");
161 if ((chLine[0]!=
'#') && (chLine[0]!=
'\n')&&(chLine[0]!=
'\t')&&(chLine[0]!=
'\r'))
163 strcpy(chDLine, chLine);
164 chToken = strtok(chDLine,
" \t\n");
166 if( strcmp( chToken,
"SH" ) == 0 )
167 strcpy( chToken,
"HS" );
168 if( strcmp( chToken,
"SH+" ) == 0 )
169 strcpy( chToken,
"HS+" );
170 if( strcmp( chToken,
"CCH" ) == 0 )
171 strcpy( chToken,
"C2H" );
176 ASSERT( nSpeciesLAMDA + 1 <= MAX_NUM_SPECIES );
177 strcpy( chLabels[
nSpecies], chToken );
180 strcpy( chPaths[
nSpecies],
"cdms+jpl" );
182 chToken = strtok( NULL,
" \t\n" );
183 strcat( chPaths[
nSpecies], chToken );
191 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) != NULL );
197 fclose(ioMASTERLIST);
209 strcpy( chPath,
"stout" );
210 strcat( chPath,
input.chDelimiter );
211 strcat( chPath,
"masterlist" );
212 strcat( chPath,
input.chDelimiter );
214 strcat( chPath,
atmdat.chStoutFile );
217 if( (ioMASTERLIST = fopen(
atmdat.chStoutFile ,
"r" ) ) == NULL )
223 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) == NULL )
225 fprintf(
ioQQQ,
" database_readin could not read first line of stout.ini.\n");
231 long int nYrRdST = (long)
FFmtRead(chLine,&ipST,
sizeof(chLine),&lgEOLST);
232 long int nMonRdST = (long)
FFmtRead(chLine,&ipST,
sizeof(chLine),&lgEOLST);
233 long int nDayRdST = (long)
FFmtRead(chLine,&ipST,
sizeof(chLine),&lgEOLST);
235 static long int nYrST =11 , nMonST = 10, nDayST = 25;
236 if( ( nYrRdST != nYrST ) || ( nMonRdST != nMonST ) || ( nDayRdST != nDayST ) )
239 " I expected to find the number %2.2li %2.2li %2.2li and got %2.2li %2.2li %2.2li instead.\n" ,
240 nYrST , nMonST , nDayST , nYrRdST , nMonRdST , nDayRdST );
241 fprintf(
ioQQQ,
"Here is the line image:\n==%s==\n", chLine );
244 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) == NULL )
246 fprintf(
ioQQQ,
" database_readin could not read first line of CHIANTI masterlist.\n");
252 strcpy(chDLine, chLine);
253 chToken = strtok(chDLine,
" \n");
254 if ((chLine[0]!=
'#') && (chLine[0]!=
'\n')&&(chLine[0]!=
'\t')&&(chLine[0]!=
'\r'))
257 ASSERT( nSpeciesSTOUT + 1 <= MAX_NUM_SPECIES );
258 strcpy( chLabels[
nSpecies], chToken );
262 strcpy( chTokenTemp, chToken );
271 strcpy( chPaths[
nSpecies],
"stout" );
279 ASSERT( isalpha(chToken[0]) );
282 if( isalpha(chToken[1]) )
293 ASSERT( chToken[cursor]==
'_' );
295 ASSERT( isdigit(chToken[cursor]) );
297 if( isdigit(chToken[cursor+1]) )
299 chLabels[
nSpecies][2] = chToken[cursor++];
300 chLabels[
nSpecies][3] = chToken[cursor++];
305 chLabels[
nSpecies][3] = chToken[cursor++];
308 ASSERT( chToken[cursor]==
'\0' || chToken[cursor]==
'd' );
316 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) != NULL );
317 fclose(ioMASTERLIST);
332 strcpy( chPath,
"chianti" );
333 strcat( chPath,
input.chDelimiter );
336 strcpy( chPathSave , chPath );
337 strcat(chPath,
"VERSION");
339 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioVERSION ) == NULL )
341 fprintf(
ioQQQ,
" database_readin could not read first line of the Chianti VERSION.\n");
348 long len = strlen(
atmdat.chVersion);
349 if(
atmdat.chVersion[len-1] ==
'\n' )
350 atmdat.chVersion[len-1] =
'\0';
354 strcpy(chPath,chPathSave);
356 strcat( chPath,
"masterlist" );
357 strcat( chPath,
input.chDelimiter );
359 strcpy( chPathSave , chPath );
362 strcat( chPath,
atmdat.chCloudyChiantiFile );
365 if( (ioMASTERLIST = fopen(
atmdat.chCloudyChiantiFile ,
"r" ) ) == NULL )
371 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) == NULL )
373 fprintf(
ioQQQ,
" database_readin could not read first line of CloudyChianti.ini.\n");
379 long int nYrRd = (long)
FFmtRead(chLine,&ip,
sizeof(chLine),&lgEOL);
380 long int nMonRd = (long)
FFmtRead(chLine,&ip,
sizeof(chLine),&lgEOL);
381 long int nDayRd = (long)
FFmtRead(chLine,&ip,
sizeof(chLine),&lgEOL);
383 static long int nYr=11 , nMon = 10, nDay = 3;
384 if( ( nYrRd != nYr ) || ( nMonRd != nMon ) || ( nDayRd != nDay ) )
387 " database_readin: the version of CloudyChianti.ini is not the current version.\n" );
389 " database_readin obtain the current version from the Cloudy web site.\n" );
391 " I expected to find the number %2.2li %2.2li %2.2li and got %2.2li %2.2li %2.2li instead.\n" ,
392 nYr , nMon , nDay , nYrRd , nMonRd , nDayRd );
393 fprintf(
ioQQQ,
"Here is the line image:\n==%s==\n", chLine );
397 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) == NULL )
399 fprintf(
ioQQQ,
" database_readin could not read first line of CHIANTI masterlist.\n");
406 if ((chLine[0]!=
'#') && (chLine[0]!=
'\n')&&(chLine[0]!=
'\t')&&(chLine[0]!=
'\r'))
408 strcpy(chDLine, chLine);
409 chToken = strtok(chDLine,
" \n");
414 if( chToken[3]!=
'd' && chToken[4]!=
'd' && chToken[5]!=
'd' )
417 ASSERT( nSpeciesCHIANTI + 1 <= MAX_NUM_SPECIES );
418 strcpy( chLabels[
nSpecies], chToken );
421 bool skipSpecies =
false;
424 for(
int j = nSpeciesLAMDA; j <
nSpecies; j++)
426 if( strcmp( chLabelsOrig[j], chLabelsOrig[
nSpecies] ) == 0)
428 printf(
"Skipping the Chianti version of %s, using Stout version\n",chLabels[
nSpecies]);
437 strcpy( chTokenTemp, chToken );
444 strcpy( chPaths[
nSpecies],
"chianti" );
452 ASSERT( isalpha(chToken[0]) );
455 if( isalpha(chToken[1]) )
466 ASSERT( chToken[cursor]==
'_' );
468 ASSERT( isdigit(chToken[cursor]) );
470 if( isdigit(chToken[cursor+1]) )
472 chLabels[
nSpecies][2] = chToken[cursor++];
473 chLabels[
nSpecies][3] = chToken[cursor++];
478 chLabels[
nSpecies][3] = chToken[cursor++];
481 ASSERT( chToken[cursor]==
'\0' || chToken[cursor]==
'd' );
490 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) != NULL );
492 fclose(ioMASTERLIST);
523 size_t los =
max(4,strlen(chLabels[i]));
524 ASSERT( los >= 4 && los <= 7 );
549 if( i<nSpeciesLAMDA )
554 else if( i < nSpeciesLAMDA + nSpeciesSTOUT )
558 else if( i < nSpeciesLAMDA + nSpeciesSTOUT + nSpeciesCHIANTI )
572 for( intNoSp=0; intNoSp<
nSpecies; intNoSp++ )
636 long nelem = 0, IonStg;
653 strcpy( chLabelChemical, chToken );
654 if( chLabelChemical[1]==
' ' )
655 chLabelChemical[1] =
'\0';
656 for(
long ipElement=0; ipElement<
LIMELM; ipElement++ )
658 if( strcmp(
elementnames.chElementSym[ipElement], chToken )==0 )
660 nelem = ipElement + 1;
666 IonStg = atoi(chToken);
667 char chStage[5] = {
'\0'};
669 sprintf( chStage,
"+" );
671 sprintf( chStage,
"+%li", IonStg-1 );
672 strcat( chLabelChemical, chStage );
673 ASSERT( IonStg >= 1 && IonStg <= nelem+1 );
675 if( nelem - IonStg <
NISO )
677 fprintf(
ioQQQ,
" PROBLEM: Cannot use Chianti model for %s%li\n",
elementnames.chElementSym[nelem-1],IonStg);
678 fprintf(
ioQQQ,
" Iso-sequences are handled by our own model.\n");
686 dense.lgIonChiantiOn[nelem-1][IonStg-1] =
true;
690 dense.lgIonStoutOn[nelem-1][IonStg-1] =
true;
705 dense.maxWN[nelem-1][IonStg-1] = 0.;
714 fprintf(
ioQQQ,
" PROBLEM: could not find species %li - %s\n",i,