Show
Ignore:
Timestamp:
12/11/06 20:18:11 (2 years ago)
Author:
peter
Message:

source/cddefines.h:

  • Modify condition for using standard malloc and calloc.
  • Add definition for Singleton template.

source/parse_set.cpp:

  • Remove SET PATH command, print error message instead.
  • Use modified t_ADfA struct.

source/cdinit.cpp:

  • Pick up path from environment variable CLOUDY_DATA_PATH.
  • Remove call to phfit().

source/Makefile:

  • Use environment variable CLOUDY_DATA_PATH.

source/atmdat.h:
source/atmdat_adfa.cpp:

  • Modify t_ADfA class to use Singleton.
  • Merge global struct PhFitOn? into t_ADfA.

source/punch_do.cpp:
source/grains_mie.cpp:
source/punch_opacity.cpp:
source/zero.cpp:
source/cont_setintensity.cpp:
source/ion_recomb_Badnell.cpp:
source/prt_lines.cpp:
source/cont_gammas.cpp:
source/pressure_total.cpp:
source/helike_cs.cpp:
source/opacity_createall.cpp:
source/hydrorecom.cpp:
source/iso_create.cpp:
source/cont_createpointers.cpp:
source/hydrocollid.cpp:
source/ion_collis.cpp:
source/helike_recom.cpp:
source/punch_linedata.cpp:

  • Use modified t_ADfA struct.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/source/atmdat_adfa.cpp

    r685 r706  
    11/* This file is part of Cloudy and is copyright (C)1978-2006 by Gary J. Ferland 
    22 * For conditions of distribution and use see copyright notice in license.txt */ 
    3 /*atmdat_phfit derive photoionization cross sections for first 30 elements */ 
     3/*phfit derive photoionization cross sections for first 30 elements */ 
    44#include "cddefines.h" 
    55#include "physconst.h" 
     
    77#include "atmdat.h" 
    88 
    9  
    10 static class t_ADfA 
     9/** constructor: read in all the ADfA data files */ 
     10t_ADfA::t_ADfA() 
    1111{ 
    12         /* phfit.dat */ 
    13         long int L[7]; 
    14         long int NINN[30]; 
    15         long int NTOT[30]; 
    16         float PH1[7][30][30][6]; 
    17         float PH2[30][30][7]; 
    18         /* hpfit.dat */ 
    19         float PHH[NHYDRO_MAX_LEVEL][5]; 
    20         /* rec_lines.dat */ 
    21         float P[8][110]; 
    22         float ST[9][405]; 
    23         /* rad_rec.dat */ 
    24         float rrec[30][30][2]; 
    25         float rnew[30][30][4]; 
    26         float fe[13][3]; 
    27         /* h_rad_rec */ 
    28         float HRF[NHYDRO_MAX_LEVEL][9]; 
    29         /* h_phot_cs.dat */ 
    30         /** array of cross sections for photoionization of hydrogen at threshold, 
    31          * 0 is 1s, 1 is 2s, 2 is 2p, up to 400 */ 
    32         float STH[NHYDRO_MAX_LEVEL]; 
    33         /* coll_ion.dat */ 
    34         double CF[30][30][5]; 
    35 public: 
    36         friend float atmdat_ph1(int i, int j, int k, int l); 
    37         friend float atmdat_sth(int i); 
    38         friend double atmdat_phfit(long int nz, long int ne, long int is, double e, int lghs); 
    39         friend double atmdat_hpfit(long int iz, long int n, double e); 
    40         friend void atmdat_rec_lines(double t, float r[][471]); 
    41         friend double atmdat_rad_rec(long int iz, long int in, double t); 
    42         friend double atmdat_H_rad_rec(long int iz, long int n, double t); 
    43         friend double atmdat_coll_ion(long int iz, long int in, double t); 
    44  
    45         /** constructor: read in all the ADfA data files before execution of main program starts */ 
    46         t_ADfA() 
    47         { 
    48                 const long VERSION_MAGIC = 20061204; 
    49                 const static char chFile[] = "phfit.dat"; 
    50                 char chString[FILENAME_PATH_LENGTH_2]; 
    51  
    52                 strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
    53                 strcat( chString, chFile ); 
    54  
    55                 FILE *io; 
    56                 if( (io = fopen(chString,"r")) == NULL ) 
    57                 { 
    58                         printf( " Could not open %s for reading\n", chString ); 
    59                         printf( " Is the path set correctly?\n" ); 
    60                         puts( "[Stop in t_ADfA]" ); 
    61                         cdEXIT(EXIT_FAILURE); 
    62                 } 
    63  
    64                 bool lgErr = false; 
    65                 long i=-1, j=-1, k=-1, n; 
    66  
     12        const long VERSION_MAGIC = 20061204; 
     13        const static char chFile[] = "phfit.dat"; 
     14        char chString[FILENAME_PATH_LENGTH_2]; 
     15 
     16        /* this option, use the new atmdat_rad_rec recombination rates */ 
     17        version = PHFIT_UNDEF; 
     18 
     19        strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
     20        strcat( chString, chFile ); 
     21 
     22        FILE *io; 
     23        if( (io = fopen(chString,"r")) == NULL ) 
     24        { 
     25                fprintf( ioQQQ, " Could not open %s for reading\n", chString ); 
     26                fprintf( ioQQQ, " Is the path set correctly?\n" ); 
     27                puts( "[Stop in t_ADfA]" ); 
     28                cdEXIT(EXIT_FAILURE); 
     29        } 
     30 
     31        bool lgErr = false; 
     32        long i=-1, j=-1, k=-1, n; 
     33 
     34        lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
     35        if( lgErr || i != VERSION_MAGIC ) 
     36        { 
     37                fprintf( ioQQQ, " File %s has incorrect version: %ld\n", chFile, i ); 
     38                fprintf( ioQQQ, " I expected to find version: %ld\n", VERSION_MAGIC ); 
     39                puts( "[Stop in t_ADfA]" ); 
     40                cdEXIT(EXIT_FAILURE); 
     41        } 
     42 
     43        for( n=0; n < 7; n++ ) 
     44                lgErr = lgErr || ( fscanf( io, "%ld", &L[n] ) != 1 ); 
     45        for( n=0; n < 30; n++ ) 
     46                lgErr = lgErr || ( fscanf( io, "%ld", &NINN[n] ) != 1 ); 
     47        for( n=0; n < 30; n++ ) 
     48                lgErr = lgErr || ( fscanf( io, "%ld", &NTOT[n] ) != 1 ); 
     49        while( true ) 
     50        { 
     51                lgErr = lgErr || ( fscanf( io, "%ld %ld %ld", &i, &j, &k ) != 3 ); 
     52                if( i == -1 && j == -1 && k == -1 ) 
     53                        break; 
     54                lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e %e", &PH1[i][j][k][0], &PH1[i][j][k][1], 
     55                                           &PH1[i][j][k][2], &PH1[i][j][k][3], &PH1[i][j][k][4], 
     56                                           &PH1[i][j][k][5] ) != 6 ); 
     57        } 
     58        while( true ) 
     59        { 
     60                lgErr = lgErr || ( fscanf( io, "%ld %ld", &i, &j ) != 2 ); 
     61                if( i == -1 && j == -1 ) 
     62                        break; 
     63                lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e %e %e", &PH2[i][j][0], &PH2[i][j][1], 
     64                                           &PH2[i][j][2], &PH2[i][j][3], &PH2[i][j][4], &PH2[i][j][5], 
     65                                           &PH2[i][j][6] ) != 7 ); 
     66        } 
     67 
     68        fclose( io ); 
     69 
     70        ASSERT( !lgErr ); 
     71 
     72        const static char chFile2[] = "hpfit.dat"; 
     73 
     74        strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
     75        strcat( chString, chFile2 ); 
     76 
     77        if( (io = fopen(chString,"r")) == NULL ) 
     78        { 
     79                fprintf( ioQQQ, " Could not open %s for reading\n", chString ); 
     80                fprintf( ioQQQ, " Is the path set correctly?\n" ); 
     81                puts( "[Stop in t_ADfA]" ); 
     82                cdEXIT(EXIT_FAILURE); 
     83        } 
     84 
     85        lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
     86        if( lgErr || i != VERSION_MAGIC ) 
     87        { 
     88                fprintf( ioQQQ, " File %s has incorrect version: %ld\n", chFile2, i ); 
     89                fprintf( ioQQQ, " I expected to find version: %ld\n", VERSION_MAGIC ); 
     90                puts( "[Stop in t_ADfA]" ); 
     91                cdEXIT(EXIT_FAILURE); 
     92        } 
     93 
     94        for( i=0; i < NHYDRO_MAX_LEVEL; i++ ) 
     95                lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e", &PHH[i][0], &PHH[i][1], &PHH[i][2], 
     96                                           &PHH[i][3], &PHH[i][4] ) != 5 ); 
     97 
     98        fclose( io ); 
     99 
     100        ASSERT( !lgErr ); 
     101 
     102        const static char chFile3[] = "rec_lines.dat"; 
     103 
     104        strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
     105        strcat( chString, chFile3 ); 
     106 
     107        if( (io = fopen(chString,"r")) == NULL ) 
     108        { 
     109                fprintf( ioQQQ, " Could not open %s for reading\n", chString ); 
     110                fprintf( ioQQQ, " Is the path set correctly?\n" ); 
     111                puts( "[Stop in t_ADfA]" ); 
     112                cdEXIT(EXIT_FAILURE); 
     113        } 
     114 
     115        lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
     116        if( lgErr || i != VERSION_MAGIC ) 
     117        { 
     118                fprintf( ioQQQ, " File %s has incorrect version: %ld\n", chFile3, i ); 
     119                fprintf( ioQQQ, " I expected to find version: %ld\n", VERSION_MAGIC ); 
     120                puts( "[Stop in t_ADfA]" ); 
     121                cdEXIT(EXIT_FAILURE); 
     122        } 
     123 
     124        for( i=0; i < 110; i++ ) 
     125                lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e %e %e %e", &P[0][i], &P[1][i], &P[2][i], 
     126                                           &P[3][i], &P[4][i], &P[5][i], &P[6][i], &P[7][i] ) != 8 ); 
     127                                            
     128 
     129        for( i=0; i < 405; i++ ) 
     130                lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e %e %e %e %e", &ST[0][i], &ST[1][i], 
     131                                           &ST[2][i], &ST[3][i], &ST[4][i], &ST[5][i], &ST[6][i], 
     132                                           &ST[7][i], &ST[8][i] ) != 9 ); 
     133 
     134        fclose( io ); 
     135 
     136        ASSERT( !lgErr ); 
     137 
     138        const static char chFile4[] = "rad_rec.dat"; 
     139 
     140        strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
     141        strcat( chString, chFile4 ); 
     142 
     143        if( (io = fopen(chString,"r")) == NULL ) 
     144        { 
     145                fprintf( ioQQQ, " Could not open %s for reading\n", chString ); 
     146                fprintf( ioQQQ, " Is the path set correctly?\n" ); 
     147                puts( "[Stop in t_ADfA]" ); 
     148                cdEXIT(EXIT_FAILURE); 
     149        } 
     150 
     151        lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
     152        if( lgErr || i != VERSION_MAGIC ) 
     153        { 
     154                fprintf( ioQQQ, " File %s has incorrect version: %ld\n", chFile4, i ); 
     155                fprintf( ioQQQ, " I expected to find version: %ld\n", VERSION_MAGIC ); 
     156                puts( "[Stop in t_ADfA]" ); 
     157                cdEXIT(EXIT_FAILURE); 
     158        } 
     159 
     160        while( true ) 
     161        { 
     162                lgErr = lgErr || ( fscanf( io, "%ld %ld", &i, &j ) != 2 ); 
     163                if( i == -1 && j == -1 ) 
     164                        break; 
     165                lgErr = lgErr || ( fscanf( io, "%e %e", &rrec[i][j][0], &rrec[i][j][1] ) != 2 ); 
     166        } 
     167        while( true ) 
     168        { 
     169                lgErr = lgErr || ( fscanf( io, "%ld %ld", &i, &j ) != 2 ); 
     170                if( i == -1 && j == -1 ) 
     171                        break; 
     172                lgErr = lgErr || ( fscanf( io, "%e %e %e %e", &rnew[i][j][0], &rnew[i][j][1], 
     173                                           &rnew[i][j][2], &rnew[i][j][3] ) != 4 ); 
     174        } 
     175        while( true ) 
     176        { 
    67177                lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
    68                 if( lgErr || i != VERSION_MAGIC ) 
    69                 { 
    70                         printf( " File %s has incorrect version: %ld\n", chFile, i ); 
    71                         printf( " I expected to find version: %ld\n", VERSION_MAGIC ); 
    72                         puts( "[Stop in t_ADfA]" ); 
    73                         cdEXIT(EXIT_FAILURE); 
    74                 } 
    75  
    76                 for( n=0; n < 7; n++ ) 
    77                         lgErr = lgErr || ( fscanf( io, "%ld", &L[n] ) != 1 ); 
    78                 for( n=0; n < 30; n++ ) 
    79                         lgErr = lgErr || ( fscanf( io, "%ld", &NINN[n] ) != 1 ); 
    80                 for( n=0; n < 30; n++ ) 
    81                         lgErr = lgErr || ( fscanf( io, "%ld", &NTOT[n] ) != 1 ); 
    82                 while( true ) 
    83                 { 
    84                         lgErr = lgErr || ( fscanf( io, "%ld %ld %ld", &i, &j, &k ) != 3 ); 
    85                         if( i == -1 && j == -1 && k == -1 ) 
    86                                 break; 
    87                         lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e %e", &PH1[i][j][k][0], &PH1[i][j][k][1], 
    88                                                    &PH1[i][j][k][2], &PH1[i][j][k][3], &PH1[i][j][k][4], 
    89                                                    &PH1[i][j][k][5] ) != 6 ); 
    90                 } 
    91                 while( true ) 
    92                 { 
    93                         lgErr = lgErr || ( fscanf( io, "%ld %ld", &i, &j ) != 2 ); 
    94                         if( i == -1 && j == -1 ) 
    95                                 break; 
    96                         lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e %e %e", &PH2[i][j][0], &PH2[i][j][1], 
    97                                                    &PH2[i][j][2], &PH2[i][j][3], &PH2[i][j][4], &PH2[i][j][5], 
    98                                                    &PH2[i][j][6] ) != 7 ); 
    99                 } 
    100  
    101                 fclose( io ); 
    102  
    103                 ASSERT( !lgErr ); 
    104  
    105                 const static char chFile2[] = "hpfit.dat"; 
    106  
    107                 strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
    108                 strcat( chString, chFile2 ); 
    109  
    110                 if( (io = fopen(chString,"r")) == NULL ) 
    111                 { 
    112                         printf( " Could not open %s for reading\n", chString ); 
    113                         printf( " Is the path set correctly?\n" ); 
    114                         puts( "[Stop in t_ADfA]" ); 
    115                         cdEXIT(EXIT_FAILURE); 
    116                 } 
    117  
    118                 lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
    119                 if( lgErr || i != VERSION_MAGIC ) 
    120                 { 
    121                         printf( " File %s has incorrect version: %ld\n", chFile2, i ); 
    122                         printf( " I expected to find version: %ld\n", VERSION_MAGIC ); 
    123                         puts( "[Stop in t_ADfA]" ); 
    124                         cdEXIT(EXIT_FAILURE); 
    125                 } 
    126  
    127                 for( i=0; i < NHYDRO_MAX_LEVEL; i++ ) 
    128                         lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e", &PHH[i][0], &PHH[i][1], &PHH[i][2], 
    129                                                    &PHH[i][3], &PHH[i][4] ) != 5 ); 
    130  
    131                 fclose( io ); 
    132  
    133                 ASSERT( !lgErr ); 
    134  
    135                 const static char chFile3[] = "rec_lines.dat"; 
    136  
    137                 strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
    138                 strcat( chString, chFile3 ); 
    139  
    140                 if( (io = fopen(chString,"r")) == NULL ) 
    141                 { 
    142                         printf( " Could not open %s for reading\n", chString ); 
    143                         printf( " Is the path set correctly?\n" ); 
    144                         puts( "[Stop in t_ADfA]" ); 
    145                         cdEXIT(EXIT_FAILURE); 
    146                 } 
    147  
    148                 lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
    149                 if( lgErr || i != VERSION_MAGIC ) 
    150                 { 
    151                         printf( " File %s has incorrect version: %ld\n", chFile3, i ); 
    152                         printf( " I expected to find version: %ld\n", VERSION_MAGIC ); 
    153                         puts( "[Stop in t_ADfA]" ); 
    154                         cdEXIT(EXIT_FAILURE); 
    155                 } 
    156  
    157                 for( i=0; i < 110; i++ ) 
    158                         lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e %e %e %e", &P[0][i], &P[1][i], &P[2][i], 
    159                                                    &P[3][i], &P[4][i], &P[5][i], &P[6][i], &P[7][i] ) != 8 ); 
    160                                                     
    161  
    162                 for( i=0; i < 405; i++ ) 
    163                         lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e %e %e %e %e", &ST[0][i], &ST[1][i], 
    164                                                    &ST[2][i], &ST[3][i], &ST[4][i], &ST[5][i], &ST[6][i], 
    165                                                    &ST[7][i], &ST[8][i] ) != 9 ); 
    166  
    167                 fclose( io ); 
    168  
    169                 ASSERT( !lgErr ); 
    170  
    171                 const static char chFile4[] = "rad_rec.dat"; 
    172  
    173                 strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
    174                 strcat( chString, chFile4 ); 
    175  
    176                 if( (io = fopen(chString,"r")) == NULL ) 
    177                 { 
    178                         printf( " Could not open %s for reading\n", chString ); 
    179                         printf( " Is the path set correctly?\n" ); 
    180                         puts( "[Stop in t_ADfA]" ); 
    181                         cdEXIT(EXIT_FAILURE); 
    182                 } 
    183  
    184                 lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
    185                 if( lgErr || i != VERSION_MAGIC ) 
    186                 { 
    187                         printf( " File %s has incorrect version: %ld\n", chFile4, i ); 
    188                         printf( " I expected to find version: %ld\n", VERSION_MAGIC ); 
    189                         puts( "[Stop in t_ADfA]" ); 
    190                         cdEXIT(EXIT_FAILURE); 
    191                 } 
    192  
    193                 while( true ) 
    194                 { 
    195                         lgErr = lgErr || ( fscanf( io, "%ld %ld", &i, &j ) != 2 ); 
    196                         if( i == -1 && j == -1 ) 
    197                                 break; 
    198                         lgErr = lgErr || ( fscanf( io, "%e %e", &rrec[i][j][0], &rrec[i][j][1] ) != 2 ); 
    199                 } 
    200                 while( true ) 
    201                 { 
    202                         lgErr = lgErr || ( fscanf( io, "%ld %ld", &i, &j ) != 2 ); 
    203                         if( i == -1 && j == -1 ) 
    204                                 break; 
    205                         lgErr = lgErr || ( fscanf( io, "%e %e %e %e", &rnew[i][j][0], &rnew[i][j][1], 
    206                                                    &rnew[i][j][2], &rnew[i][j][3] ) != 4 ); 
    207                 } 
    208                 while( true ) 
    209                 { 
    210                         lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
    211                         if( i == -1 ) 
    212                                 break; 
    213                         lgErr = lgErr || ( fscanf( io, "%e %e %e", &fe[i][0], &fe[i][1], &fe[i][2] ) != 3 ); 
    214                 } 
    215  
    216                 fclose( io ); 
    217  
    218                 ASSERT( !lgErr ); 
    219  
    220                 const static char chFile5[] = "h_rad_rec.dat"; 
    221  
    222                 strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
    223                 strcat( chString, chFile5 ); 
    224  
    225                 if( (io = fopen(chString,"r")) == NULL ) 
    226                 { 
    227                         printf( " Could not open %s for reading\n", chString ); 
    228                         printf( " Is the path set correctly?\n" ); 
    229                         puts( "[Stop in t_ADfA]" ); 
    230                         cdEXIT(EXIT_FAILURE); 
    231                 } 
    232  
    233                 lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
    234                 if( lgErr || i != VERSION_MAGIC ) 
    235                 { 
    236                         printf( " File %s has incorrect version: %ld\n", chFile5, i ); 
    237                         printf( " I expected to find version: %ld\n", VERSION_MAGIC ); 
    238                         puts( "[Stop in t_ADfA]" ); 
    239                         cdEXIT(EXIT_FAILURE); 
    240                 } 
    241  
    242                 for( i=0; i < NHYDRO_MAX_LEVEL; i++ ) 
    243                         lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e %e %e %e %e", &HRF[i][0], &HRF[i][1], 
    244                                                    &HRF[i][2], &HRF[i][3], &HRF[i][4], &HRF[i][5], &HRF[i][6], 
    245                                                    &HRF[i][7], &HRF[i][8] ) != 9 ); 
    246  
    247                 fclose( io ); 
    248  
    249                 ASSERT( !lgErr ); 
    250  
    251                 const static char chFile6[] = "h_phot_cs.dat"; 
    252  
    253                 strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
    254                 strcat( chString, chFile6 ); 
    255  
    256                 if( (io = fopen(chString,"r")) == NULL ) 
    257                 { 
    258                         printf( " Could not open %s for reading\n", chString ); 
    259                         printf( " Is the path set correctly?\n" ); 
    260                         puts( "[Stop in t_ADfA]" ); 
    261                         cdEXIT(EXIT_FAILURE); 
    262                 } 
    263  
    264                 lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
    265                 if( lgErr || i != VERSION_MAGIC ) 
    266                 { 
    267                         printf( " File %s has incorrect version: %ld\n", chFile6, i ); 
    268                         printf( " I expected to find version: %ld\n", VERSION_MAGIC ); 
    269                         puts( "[Stop in t_ADfA]" ); 
    270                         cdEXIT(EXIT_FAILURE); 
    271                 } 
    272  
    273                 for( i=0; i < NHYDRO_MAX_LEVEL; i++ ) 
    274                         lgErr = lgErr || ( fscanf( io, "%e", &STH[i] ) != 1 ); 
    275  
    276                 fclose( io ); 
    277  
    278                 ASSERT( !lgErr ); 
    279  
    280                 const static char chFile7[] = "coll_ion.dat"; 
    281  
    282                 strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
    283                 strcat( chString, chFile7 ); 
    284  
    285                 if( (io = fopen(chString,"r")) == NULL ) 
    286                 { 
    287                         printf( " Could not open %s for reading\n", chString ); 
    288                         printf( " Is the path set correctly?\n" ); 
    289                         puts( "[Stop in t_ADfA]" ); 
    290                         cdEXIT(EXIT_FAILURE); 
    291                 } 
    292  
    293                 lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
    294                 if( lgErr || i != VERSION_MAGIC ) 
    295                 { 
    296                         printf( " File %s has incorrect version: %ld\n", chFile7, i ); 
    297                         printf( " I expected to find version: %ld\n", VERSION_MAGIC ); 
    298                         puts( "[Stop in t_ADfA]" ); 
    299                         cdEXIT(EXIT_FAILURE); 
    300                 } 
    301  
    302                 while( true ) 
    303                 { 
    304                         lgErr = lgErr || ( fscanf( io, "%ld %ld", &i, &j ) != 2 ); 
    305                         if( i == -1 && j == -1 ) 
    306                                 break; 
    307                         lgErr = lgErr || ( fscanf( io, "%le %le %le %le %le", &CF[i][j][0], &CF[i][j][1], 
    308                                                    &CF[i][j][2], &CF[i][j][3], &CF[i][j][4] ) != 5 ); 
    309                 } 
    310  
    311                 fclose( io ); 
    312  
    313                 ASSERT( !lgErr ); 
    314         } 
    315 } ADfA; 
    316  
    317  
    318 float atmdat_ph1(int i, int j, int k, int l) 
    319 { 
    320         return ADfA.PH1[i][j][k][l]; 
     178                if( i == -1 ) 
     179                        break; 
     180                lgErr = lgErr || ( fscanf( io, "%e %e %e", &fe[i][0], &fe[i][1], &fe[i][2] ) != 3 ); 
     181        } 
     182 
     183        fclose( io ); 
     184 
     185        ASSERT( !lgErr ); 
     186 
     187        const static char chFile5[] = "h_rad_rec.dat"; 
     188 
     189        strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
     190        strcat( chString, chFile5 ); 
     191 
     192        if( (io = fopen(chString,"r")) == NULL ) 
     193        { 
     194                fprintf( ioQQQ, " Could not open %s for reading\n", chString ); 
     195                fprintf( ioQQQ, " Is the path set correctly?\n" ); 
     196                puts( "[Stop in t_ADfA]" ); 
     197                cdEXIT(EXIT_FAILURE); 
     198        } 
     199 
     200        lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
     201        if( lgErr || i != VERSION_MAGIC ) 
     202        { 
     203                fprintf( ioQQQ, " File %s has incorrect version: %ld\n", chFile5, i ); 
     204                fprintf( ioQQQ, " I expected to find version: %ld\n", VERSION_MAGIC ); 
     205                puts( "[Stop in t_ADfA]" ); 
     206                cdEXIT(EXIT_FAILURE); 
     207        } 
     208 
     209        for( i=0; i < NHYDRO_MAX_LEVEL; i++ ) 
     210                lgErr = lgErr || ( fscanf( io, "%e %e %e %e %e %e %e %e %e", &HRF[i][0], &HRF[i][1], 
     211                                           &HRF[i][2], &HRF[i][3], &HRF[i][4], &HRF[i][5], &HRF[i][6], 
     212                                           &HRF[i][7], &HRF[i][8] ) != 9 ); 
     213 
     214        fclose( io ); 
     215 
     216        ASSERT( !lgErr ); 
     217 
     218        const static char chFile6[] = "h_phot_cs.dat"; 
     219 
     220        strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
     221        strcat( chString, chFile6 ); 
     222 
     223        if( (io = fopen(chString,"r")) == NULL ) 
     224        { 
     225                fprintf( ioQQQ, " Could not open %s for reading\n", chString ); 
     226                fprintf( ioQQQ, " Is the path set correctly?\n" ); 
     227                puts( "[Stop in t_ADfA]" ); 
     228                cdEXIT(EXIT_FAILURE); 
     229        } 
     230 
     231        lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
     232        if( lgErr || i != VERSION_MAGIC ) 
     233        { 
     234                fprintf( ioQQQ, " File %s has incorrect version: %ld\n", chFile6, i ); 
     235                fprintf( ioQQQ, " I expected to find version: %ld\n", VERSION_MAGIC ); 
     236                puts( "[Stop in t_ADfA]" ); 
     237                cdEXIT(EXIT_FAILURE); 
     238        } 
     239 
     240        for( i=0; i < NHYDRO_MAX_LEVEL; i++ ) 
     241                lgErr = lgErr || ( fscanf( io, "%e", &STH[i] ) != 1 ); 
     242 
     243        fclose( io ); 
     244 
     245        ASSERT( !lgErr ); 
     246 
     247        const static char chFile7[] = "coll_ion.dat"; 
     248 
     249        strcpy( chString, ( lgDataPathSet ? chDataPath : "" ) ); 
     250        strcat( chString, chFile7 ); 
     251 
     252        if( (io = fopen(chString,"r")) == NULL ) 
     253        { 
     254                fprintf( ioQQQ, " Could not open %s for reading\n", chString ); 
     255                fprintf( ioQQQ, " Is the path set correctly?\n" ); 
     256                puts( "[Stop in t_ADfA]" ); 
     257                cdEXIT(EXIT_FAILURE); 
     258        } 
     259 
     260        lgErr = lgErr || ( fscanf( io, "%ld", &i ) != 1 ); 
     261        if( lgErr || i != VERSION_MAGIC ) 
     262        { 
     263                fprintf( ioQQQ, " File %s has incorrect version: %ld\n", chFile7, i ); 
     264                fprintf( ioQQQ, " I expected to find version: %ld\n", VERSION_MAGIC ); 
     265                puts( "[Stop in t_ADfA]" ); 
     266                cdEXIT(EXIT_FAILURE); 
     267        } 
     268 
     269        while( true ) 
     270        { 
     271                lgErr = lgErr || ( fscanf( io, "%ld %ld", &i, &j ) != 2 ); 
     272                if( i == -1 && j == -1 ) 
     273                        break; 
     274                lgErr = lgErr || ( fscanf( io, "%le %le %le %le %le", &CF[i][j][0], &CF[i][j][1], 
     275                                           &CF[i][j][2], &CF[i][j][3], &CF[i][j][4] ) != 5 ); 
     276        } 
     277 
     278        fclose( io ); 
     279 
     280        ASSERT( !lgErr ); 
    321281} 
    322282 
    323 float atmdat_sth(int i) 
    324 { 
    325         return ADfA.STH[i]; 
    326 } 
    327  
    328 double atmdat_phfit(long int nz,  
    329                     long int ne, 
    330                     long int is,  
    331                     double e,  
    332                     int lghs) 
     283double t_ADfA::phfit(long int nz,  
     284                     long int ne, 
     285                     long int is,  
     286                     double e) 
    333287{ 
    334288        long int nint,  
     
    345299 
    346300#       ifdef DEBUG_FUN 
    347         fputs( "<+>atmdat_phfit()\n", debug_fp ); 
     301        fputs( "<+>phfit()\n", debug_fp ); 
    348302#       endif 
    349303        /*** Version 3. October 8, 1996. 
     
    352306         *** improved to fit smoothly the experimental inner-shell ionization energies  
    353307         *** of neutral atoms. 
    354          *** New logical argument lghs 
    355308         ****************************************************************************** 
    356309         *** This subroutine calculates partial photoionization cross sections 
     
    365318         ***          is - shell number (integer) 
    366319         ***          e - photon energy, eV  
    367          ***          lghs - logical, "FALSE" (default) calculates  
    368          ***                 new cross sections, "TRUE" calculates 
     320         ***          version - enum, PHFIT96 (default): calculates  
     321         ***                 new cross sections, PHFIT95: calculates 
    369322         ***                 only old Hartree-Slater cross sections 
    370          *** Output parameter:  s - photoionization cross section, Mb 
     323         *** Output parameter:  photoionization cross section, Mb 
    371324         *** Shell numbers: 
    372325         *** 1 - 1s, 2 - 2s, 3 - 2p, 4 - 3s, 5 - 3p, 6 - 3d, 7 - 4s.  
    373326         *** If a species in the ground state has no electrons on the given shell, 
    374