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 );
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" );
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");
354 strcpy(chPath,chPathSave);
356 strcat( chPath,
"masterlist" );
359 strcpy( chPathSave , chPath );
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++ )
592 strncpy( chToken, sp->
chLabel, 2 );
594 if( strcmp(
"p-", chToken )==0 )
596 else if( strcmp(
"o-", chToken )==0 )
598 else if( strcmp(
"e-", chToken )==0 )
600 else if( strcmp(
"a-", chToken )==0 )
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++ )
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 )
678 fprintf(
ioQQQ,
" Iso-sequences are handled by our own model.\n");
714 fprintf(
ioQQQ,
" PROBLEM: could not find species %li - %s\n",i,
741 printf(
"The data output is in the following format \n");
742 printf(
"Label Energy St.wt Pop Lifetime\n");
746 printf(
"This is the %ld state \n",j);
747 printf(
"%s %f %f %f %e \n",
dBaseStates[i][j].chLabel(),
766 em !=
dBaseTrans[intSpIndex].Emis().end(); ++em)
768 fsumAs[(*em).Tran().ipHi()] += (*em).Aul();
769 (*em).iRedisFun() =
ipPRD;
775 dBaseStates[intSpIndex][ipHi].lifetime() = 1./fsumAs[ipHi];
void atmdat_STOUT_readin(long intNS, char *chFileName)
void atmdat_CHIANTI_readin(long intNS, char *chFileName)
void atmdat_LAMDA_readin(long intNS, char *chFileName)
const int FILENAME_PATH_LENGTH_2
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
NORETURN void TotalInsanity(void)
#define DEBUG_ENTRY(funcname)
void uncaps(char *chCard)
valarray< class molezone > species
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
void set_NaN(sys_float &x)
UNUSED const realnum BIGFLOAT
t_elementnames elementnames
molecule * findspecies(const char buf[])
static char chElement[NPUNLM][5]
STATIC void states_nelemfill(void)
STATIC void database_prep(int)
STATIC void set_fractionation(species *sp)
STATIC void states_propprint(void)
void database_readin(void)
STATIC void states_popfill(void)
STATIC void SpeciesJunk(species *sp)
char chStoutFile[FILENAME_PATH_LENGTH]
static const int iVersionLength
char chCloudyChiantiFile[FILENAME_PATH_LENGTH]
char chVersion[iVersionLength]
double maxWN[LIMELM][LIMELM+1]
bool lgIonStoutOn[LIMELM][LIMELM+1]
realnum AtomicWeight[LIMELM]
bool lgIonChiantiOn[LIMELM][LIMELM+1]
char chElementSym[LIMELM][CHARS_ELEMENT_SYM]
vector< qList > dBaseStates
vector< TransitionList > dBaseTrans
vector< multi_arr< int, 2 > > ipdBaseTrans
multi_arr< CollRateCoeffArray, 2 > AtmolCollRateCoeff
StoutColls **** StoutCollData
CollSplinesArray **** AtmolCollSplines
vector< TransitionList > AllTransitions