15 const char* s= chLine;
20 fprintf (
ioQQQ,
" PROBLEM: The LAMDA data file '%s' appears to be corrupt\n",
22 fprintf (
ioQQQ,
" Expected line starting '!', found\n%s\n",chLine);
35 realnum fstatwt,fenergyWN,fenergy,feinsteina;
41 static const int MAX_NUM_LEVELS = 999;
48 printf(
"The name of the %li species is %s \n",intNS+1,
dBaseSpecies[intNS].chLabel);
52 fprintf(
ioQQQ,
" moldat_readin opening %s:",chEFilename);
54 ioLevData =
open_data( chEFilename,
"r" );
60 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
62 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
67 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
69 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
75 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
77 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
85 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
87 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
90 long nMolLevs = (long)atoi(chLine);
92 long HighestIndexInFile = nMolLevs;
103 fprintf(
ioQQQ,
"The number of energy levels is non-positive in datafile %s.\n", chEFilename );
110 fprintf(
ioQQQ,
"Using LAMDA model %s with %li levels of %li available.\n",
111 dBaseSpecies[intNS].chLabel , nMolLevs , HighestIndexInFile );
118 fprintf(
ioQQQ,
"Using LAMDA model %s with %li requested, only %li energy levels available.\n",
120 nMolLevs = HighestIndexInFile;
135 for(
long ipHi = 1; ipHi < nMolLevs; ipHi++)
144 for(
long ipHi = 1; ipHi < nMolLevs; ipHi++)
146 for(
long ipLo = 0; ipLo < ipHi; ipLo++)
156 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
158 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
165 for(
long ipLev=0; ipLev<HighestIndexInFile; ipLev++)
167 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
169 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
174 if( ipLev >= nMolLevs )
179 long index = (long)
FFmtRead( chLine, &i,
sizeof(chLine), &lgEOL );
183 if( index != ipLev + 1 )
185 fprintf(
ioQQQ,
"internal error in file %s\n", chEFilename );
188 dBaseStates[intNS][ipLev].energy().set(fenergy,
"cm^-1");
199 fprintf(
ioQQQ,
" The energy levels are not in order in species %s at index %li.\n",
207 printf(
"The value of g is %f \n",
dBaseStates[intNS][ipLev].g());
215 int ipHi = (*tr).ipHi();
216 int ipLo = (*tr).ipLo();
220 (*tr).EnergyWN() = fenergyWN;
228 (*tr).WLAng() = 1e30f;
231 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
233 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
238 fprintf(
ioQQQ,
" The number of energy levels in file %s is not correct, expected to find line starting with!.\n",chEFilename);
242 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
244 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
247 long intgrtct = atoi(chLine);
251 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
256 printf(
"The number of radiative transitions is %li \n",intgrtct);
258 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
260 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
265 for(
long intrtct=0; intrtct<intgrtct; intrtct++)
267 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
269 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
276 long index = (long)
FFmtRead( chLine, &i,
sizeof(chLine), &lgEOL );
277 long ipHiInFile = (long)
FFmtRead( chLine, &i,
sizeof(chLine), &lgEOL );
278 long ipLoInFile = (long)
FFmtRead( chLine, &i,
sizeof(chLine), &lgEOL );
279 long ipHi = ipHiInFile - 1;
280 long ipLo = ipLoInFile - 1;
282 if( ! ( ipHi >= 0 && ipLo >= 0 && ipHi > ipLo && index == intrtct + 1 ) )
284 fprintf(
ioQQQ,
"internal error in file %s\n", chEFilename );
289 if( ipLo >= nMolLevs || ipHi >= nMolLevs )
294 FFmtRead( chLine, &i,
sizeof(chLine), &lgEOL );
296 fenergyWN =
MAX2( fenergyWN, 1.01 * RYD_INF *
rfield.
emm() );
300 (*tr).AddLine2Stack();
301 (*tr).Emis().Aul() = feinsteina;
303 (*tr).EnergyWN() = fenergyWN;
306 (*tr).Emis().gf() = (
realnum)
GetGF((*tr).Emis().Aul(),(*tr).EnergyWN(), (*(*tr).Hi()).g());
312 printf(
"The upper level is %ld \n",ipHi+1);
313 printf(
"The lower level is %ld \n",ipLo+1);
314 printf(
"The Einstein A is %E \n",(*tr).Emis().Aul());
315 printf(
"The Energy of the transition is %E \n",(*tr).EnergyK());
319 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
321 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
327 fprintf(
ioQQQ,
" The number of radiative transitions in file %s is not correct.\n",chEFilename);
331 long nCollPartners = -1;
333 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
335 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
340 nCollPartners = atoi(chLine);
343 if (nCollPartners < 0)
348 fprintf(
ioQQQ,
" The number of colliders is greater than what is expected in file %s.\n", chEFilename );
354 for(
long ipPartner = 0; ipPartner < nCollPartners; ++ ipPartner )
356 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
358 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
364 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
366 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
375 char *chCollName = strtok(chLine,
" ");
377 int intLColliderIndex = atoi(chCollName);
378 int intCollIndex = -1;
382 if(intLColliderIndex == 1)
386 else if(intLColliderIndex == 2)
390 else if(intLColliderIndex == 3)
394 else if(intLColliderIndex == 4)
398 else if(intLColliderIndex == 5)
402 else if(intLColliderIndex == 6)
415 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
417 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
423 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
425 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
429 long nCollTrans = atoi(chLine);
431 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
433 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
439 if(
read_whole_line( chLine , (
int)
sizeof(chLine) , ioLevData ) == NULL )
441 fprintf(
ioQQQ,
" The data file %s is corrupted .\n",chEFilename);
445 long intCollTemp = atoi(chLine);
449 ioLevData, func, nMolLevs, intCollTemp, nCollTrans );
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
const int FILENAME_PATH_LENGTH_2
NORETURN void TotalInsanity(void)
vector< multi_arr< int, 2 > > ipdBaseTrans
double RefIndex(double EnergyWN)
multi_arr< CollRateCoeffArray, 2 > AtmolCollRateCoeff
static void check_LAMDA_comment(const char *chLine, char *chEFilename)
static const bool DEBUGSTATE
double energy(const genericState &gs)
void setProperties(species &sp)
double GetGF(double trans_prob, double enercm, double gup)
string db_comment_tran_levels(long ipLoFile, long ipHiFile)
void atmdat_LAMDA_readin(long intNS, char *chFileName)
#define DEBUG_ENTRY(funcname)
vector< qList > dBaseStates
vector< species > dBaseSpecies
int fprintf(const Output &stream, const char *format,...)
char * read_whole_line(char *chLine, int nChar, FILE *ioIN)
vector< TransitionList > dBaseTrans
void ReadCollisionRateTable(CollRateCoeffArray &coll_rate_table, FILE *io, FunctPtr GetIndices, long nMolLevs, long nTemps, long nTrans)
double FFmtRead(const char *chCard, long int *ipnt, long int last, bool *lgEOL)