41 #define DEBUGSTATE false
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" );
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" );
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" );
211 strcat( chPath,
"masterlist" );
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 );
259 strcpy( chLabelsOrig[nSpecies], chLabels[nSpecies] );
262 strcpy( chTokenTemp, chToken );
263 chElement = strtok(chTokenTemp,
" \n");
264 chElement = strtok(chTokenTemp,
"_");
271 strcpy( chPaths[nSpecies],
"stout" );
273 strcat( chPaths[nSpecies], chElement );
275 strcat( chPaths[nSpecies], chLabels[nSpecies] );
277 strcat( chPaths[nSpecies], chLabels[nSpecies] );
279 ASSERT( isalpha(chToken[0]) );
282 if( isalpha(chToken[1]) )
293 ASSERT( chToken[cursor++]==
'_' );
294 ASSERT( isdigit(chToken[cursor]) );
296 if( isdigit(chToken[cursor+1]) )
298 chLabels[
nSpecies][2] = chToken[cursor++];
299 chLabels[
nSpecies][3] = chToken[cursor++];
304 chLabels[
nSpecies][3] = chToken[cursor++];
307 ASSERT( chToken[cursor]==
'\0' || chToken[cursor]==
'd' );
315 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) != NULL );
316 fclose(ioMASTERLIST);
331 strcpy( chPath,
"chianti" );
335 strcpy( chPathSave , chPath );
336 strcat(chPath,
"VERSION");
338 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioVERSION ) == NULL )
340 fprintf(
ioQQQ,
" database_readin could not read first line of the Chianti VERSION.\n");
353 strcpy(chPath,chPathSave);
355 strcat( chPath,
"masterlist" );
358 strcpy( chPathSave , chPath );
370 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) == NULL )
372 fprintf(
ioQQQ,
" database_readin could not read first line of CloudyChianti.ini.\n");
378 long int nYrRd = (long)
FFmtRead(chLine,&ip,
sizeof(chLine),&lgEOL);
379 long int nMonRd = (long)
FFmtRead(chLine,&ip,
sizeof(chLine),&lgEOL);
380 long int nDayRd = (long)
FFmtRead(chLine,&ip,
sizeof(chLine),&lgEOL);
382 static long int nYr=11 , nMon = 10, nDay = 3;
383 if( ( nYrRd != nYr ) || ( nMonRd != nMon ) || ( nDayRd != nDay ) )
386 " database_readin: the version of CloudyChianti.ini is not the current version.\n" );
388 " database_readin obtain the current version from the Cloudy web site.\n" );
390 " I expected to find the number %2.2li %2.2li %2.2li and got %2.2li %2.2li %2.2li instead.\n" ,
391 nYr , nMon , nDay , nYrRd , nMonRd , nDayRd );
392 fprintf(
ioQQQ,
"Here is the line image:\n==%s==\n", chLine );
396 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) == NULL )
398 fprintf(
ioQQQ,
" database_readin could not read first line of CHIANTI masterlist.\n");
405 if ((chLine[0]!=
'#') && (chLine[0]!=
'\n')&&(chLine[0]!=
'\t')&&(chLine[0]!=
'\r'))
407 strcpy(chDLine, chLine);
408 chToken = strtok(chDLine,
" \n");
413 if( chToken[3]!=
'd' && chToken[4]!=
'd' && chToken[5]!=
'd' )
416 ASSERT( nSpeciesCHIANTI + 1 <= MAX_NUM_SPECIES );
417 strcpy( chLabels[
nSpecies], chToken );
418 strcpy( chLabelsOrig[nSpecies], chLabels[nSpecies]);
420 bool skipSpecies =
false;
423 for(
int j = nSpeciesLAMDA; j <
nSpecies; j++)
425 if( strcmp( chLabelsOrig[j], chLabelsOrig[nSpecies] ) == 0)
427 printf(
"Skipping the Chianti version of %s, using Stout version\n",chLabels[nSpecies]);
436 strcpy( chTokenTemp, chToken );
437 chElement = strtok(chTokenTemp,
" \n");
438 chElement = strtok(chTokenTemp,
"_");
443 strcpy( chPaths[nSpecies],
"chianti" );
445 strcat( chPaths[nSpecies], chElement );
447 strcat( chPaths[nSpecies], chLabels[nSpecies] );
449 strcat( chPaths[nSpecies], chLabels[nSpecies] );
451 ASSERT( isalpha(chToken[0]) );
454 if( isalpha(chToken[1]) )
465 ASSERT( chToken[cursor++]==
'_' );
466 ASSERT( isdigit(chToken[cursor]) );
468 if( isdigit(chToken[cursor+1]) )
470 chLabels[
nSpecies][2] = chToken[cursor++];
471 chLabels[
nSpecies][3] = chToken[cursor++];
476 chLabels[
nSpecies][3] = chToken[cursor++];
479 ASSERT( chToken[cursor]==
'\0' || chToken[cursor]==
'd' );
488 while(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioMASTERLIST ) != NULL );
490 fclose(ioMASTERLIST);
521 size_t los =
max(4,strlen(chLabels[i]));
522 ASSERT( los >= 4 && los <= 7 );
547 if( i<nSpeciesLAMDA )
552 else if( i < nSpeciesLAMDA + nSpeciesSTOUT )
556 else if( i < nSpeciesLAMDA + nSpeciesSTOUT + nSpeciesCHIANTI )
570 for( intNoSp=0; intNoSp<
nSpecies; intNoSp++ )
590 strncpy( chToken, sp->
chLabel, 2 );
592 if( strcmp(
"p-", chToken )==0 )
594 else if( strcmp(
"o-", chToken )==0 )
596 else if( strcmp(
"e-", chToken )==0 )
598 else if( strcmp(
"a-", chToken )==0 )
634 long nelem = 0, IonStg;
651 strcpy( chLabelChemical, chToken );
652 if( chLabelChemical[1]==
' ' )
653 chLabelChemical[1] =
'\0';
654 for(
long ipElement=0; ipElement<
LIMELM; ipElement++ )
658 nelem = ipElement + 1;
662 ASSERT( nelem > 0 && nelem <= LIMELM );
664 IonStg = atoi(chToken);
665 char chStage[5] = {
'\0'};
667 sprintf( chStage,
"+" );
669 sprintf( chStage,
"+%li", IonStg-1 );
670 strcat( chLabelChemical, chStage );
671 ASSERT( IonStg >= 1 && IonStg <= nelem+1 );
673 if( nelem - IonStg <
NISO )
676 fprintf(
ioQQQ,
" Iso-sequences are handled by our own model.\n");
712 fprintf(
ioQQQ,
" PROBLEM: could not find species %li - %s\n",i,
739 printf(
"The data output is in the following format \n");
740 printf(
"Label Energy St.wt Pop Lifetime\n");
744 printf(
"This is the %ld state \n",j);
745 printf(
"%s %f %f %f %e \n",
dBaseStates[i][j].chLabel(),
764 em !=
dBaseTrans[intSpIndex].Emis().end(); ++em)
766 fsumAs[(*em).Tran().ipHi()] += (*em).Aul();
767 (*em).iRedisFun() =
ipPRD;
773 dBaseStates[intSpIndex][ipHi].lifetime() = 1./fsumAs[ipHi];
STATIC void database_prep(int)
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
const int FILENAME_PATH_LENGTH_2
char chStoutFile[FILENAME_PATH_LENGTH]
NORETURN void TotalInsanity(void)
void set_NaN(sys_float &x)
STATIC void set_fractionation(species *sp)
StoutColls **** StoutCollData
vector< multi_arr< int, 2 > > ipdBaseTrans
void atmdat_STOUT_readin(long intNS, char *chFileName)
double maxWN[LIMELM][LIMELM+1]
multi_arr< CollRateCoeffArray, 2 > AtmolCollRateCoeff
STATIC void states_propprint(void)
char chVersion[iVersionLength]
t_elementnames elementnames
void uncaps(char *chCard)
bool lgIonChiantiOn[LIMELM][LIMELM+1]
static char chElement[NPUNLM][5]
char chCloudyChiantiFile[FILENAME_PATH_LENGTH]
molecule * findspecies(const char buf[])
valarray< class molezone > species
realnum AtomicWeight[LIMELM]
CollSplinesArray **** AtmolCollSplines
STATIC void states_nelemfill(void)
STATIC void SpeciesJunk(species *sp)
char chElementSym[LIMELM][CHARS_ELEMENT_SYM]
bool lgIonStoutOn[LIMELM][LIMELM+1]
void atmdat_LAMDA_readin(long intNS, char *chFileName)
#define DEBUG_ENTRY(funcname)
STATIC void states_popfill(void)
vector< qList > dBaseStates
void database_readin(void)
void atmdat_CHIANTI_readin(long intNS, char *chFileName)
vector< TransitionList > AllTransitions
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
vector< TransitionList > dBaseTrans
static const int iVersionLength
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)