Ticket #59: patch

File patch, 14.6 kB (added by rjrw, 6 months ago)

Attached patch fixes the problem for me

  • service.cpp

     
    254254 
    255255 
    256256                        fprintf( ioQQQ, " Cloudy version number is %s\n",  
    257                                 version.chVersion ); 
    258                         fprintf( ioQQQ, " %s\n\n", version.chInfo ); 
     257                                version::Inst().chVersion ); 
     258                        fprintf( ioQQQ, " %s\n\n", version::Inst().chInfo ); 
    259259 
    260260                        fprintf( ioQQQ, "%5ld warnings,%3ld cautions,%3ld temperature failures.  Messages follow.\n",  
    261261                          warnings.nwarn, warnings.ncaun, conv.nTeFail ); 
  • punch_fits.cpp

     
    754754        strcpy( tempString, "Generated by Cloudy version " ); 
    755755        strcat( tempString, chVer ); 
    756756        bytesAdded += addComment( tempString ); 
    757         bytesAdded += addComment( version.chInfo ); 
     757        bytesAdded += addComment( version::Inst().chInfo ); 
    758758        strcpy( tempString, "--- " ); 
    759759        strcat( tempString, timeString ); 
    760760        bytesAdded += addComment( tempString ); 
  • init_coreload.cpp

     
    1010#include "dense.h" 
    1111#include "hcmap.h" 
    1212#include "h2.h" 
    13 #include "date.h" 
    1413#include "version.h" 
    1514#include "hextra.h" 
    1615#include "mole.h" 
     
    158157        hcmap.nmap = 0; 
    159158        hcmap.lgMapBeingDone = false; 
    160159 
    161         /* set the date saved in date.h into version.chDate  
    162          * this is the decade part of the year counted after 2000 */ 
    163         int nDecade = (YEAR-100)/10; 
    164         char chDecade[2]; 
    165  
    166         /* create space for these strings */ 
    167         version.chDate = (char *)MALLOC( sizeof(char)*INPUT_LINE_LENGTH ); 
    168         version.chVersion = (char *)MALLOC( sizeof(char)*INPUT_LINE_LENGTH ); 
    169  
    170         static char chMonth[12][4] ={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" }; 
    171         static char chMonthInt[12][3] ={"01","02","03","04","05","06","07","08","09","10","11","12" }; 
    172  
    173         sprintf(chDecade,"%i", nDecade ); 
    174         /* set date and version - this code will need to be modified in the year 2110 */ 
    175         if( nDecade > 9 ) 
    176         { 
    177                 fprintf(ioQQQ,"must update formation of chDate in cdInit \n"); 
    178                 TotalInsanity(); 
    179         } 
    180         if( DAY < 10 ) 
    181         { 
    182                 sprintf( version.chDate , "%s%1i%s0%1i",  
    183                         chDecade, 
    184                         YEAR-100-nDecade*10, 
    185                         chMonth[MONTH], 
    186                         DAY ); 
    187                 sprintf( version.chVersion , "%s%1i.%s.0%1i",  
    188                         chDecade, 
    189                         YEAR-100-nDecade*10, 
    190                         chMonthInt[MONTH], 
    191                         DAY ); 
    192         } 
    193         else 
    194         { 
    195                 sprintf( version.chDate , "%s%1i%s%2i",  
    196                         chDecade, 
    197                         YEAR-100-nDecade*10, 
    198                         chMonth[MONTH], 
    199                         DAY ); 
    200                 sprintf( version.chVersion , "%s%1i.%s.%2i",  
    201                         chDecade, 
    202                         YEAR-100-nDecade*10, 
    203                         chMonthInt[MONTH], 
    204                         DAY ); 
    205         } 
    206  
    207         version.chCitation = CITATION; 
    208         version.chCitationLatex = CITATION_LATEX; 
    209         version.chCitationShort = CITATION_SHORT; 
    210  
    211         /* is this a release version? */ 
    212         version.lgRelease = false; 
    213  
    214         /* is this a beta version?  0 for no */ 
    215         version.nBetaVer = 0; 
    216  
    217         /* optional letter could come here for updates to branched version */ 
    218         /*strcat( version.chVersion , "a" );*/ 
    219         /* change following from * to letter when letters are used */ 
    220         strcat( version.chDate , "*" ); 
    221  
    222         char mode[6]; 
    223         if( sizeof(long) == 4 ) 
    224                 strncpy( mode, "ILP32", 6 ); 
    225         else if( sizeof(long) == 8 ) 
    226                 strncpy( mode, "LP64", 6 ); 
    227         else 
    228                 strncpy( mode, "?????", 6 ); 
    229  
    230         /* now generate info on how we were compiled, including compiler version */ 
    231         sprintf(version.chInfo ,  
    232                 "cdInit compiled on %s in OS %s using the %s %i compiler in %s mode." , 
    233                 __DATE__  ,__OS , __COMP , __COMP_VER, mode); 
    234  
    235160        /* name of output file from optimization run */ 
    236161        strncpy( chOptimFileName , "optimal.in" , sizeof( chOptimFileName ) ); 
    237162 
  • grains_mie.cpp

     
    376376 
    377377        (void)time(&timer); 
    378378        lgErr = lgErr || ( fprintf(fdes,"# this file was created by Cloudy %s (%s) on %s", 
    379                                    version.chVersion,version.chDate,ctime(&timer)) < 0 ); 
     379                                                                                                                 version::Inst().chVersion,version::Inst().chDate,ctime(&timer)) < 0 ); 
    380380        lgErr = lgErr || ( fprintf(fdes,"# ===========================================\n#\n") < 0 ); 
    381381        lgErr = lgErr || ( fprintf(fdes,"%12ld # magic number opacity file\n",MAGIC_OPC) < 0 ); 
    382382        lgErr = lgErr || ( fprintf(fdes,"%12ld # magic number rfi/mix file\n",gd.magic) < 0 ); 
  • assert_results.cpp

     
    24712471                /* explain how we were compiled, but only if printing time */ 
    24722472                if( prt.lgPrintTime ) 
    24732473                { 
    2474                         fprintf( ioQQQ, " %s\n\n", version.chInfo ); 
     2474                        fprintf( ioQQQ, " %s\n\n", version::Inst().chInfo ); 
    24752475                } 
    24762476        } 
    24772477        return lgAssertsOK; 
  • parse_punch.cpp

     
    202202        { 
    203203                sprintf( chHeader,  
    204204                        "# %s %s\n",  
    205                   version.chVersion, input.chTitle ); 
     205                  version::Inst().chVersion, input.chTitle ); 
    206206        } 
    207207 
    208208        /* usually results for each iteration are followed by a series of 
  • optimize_phymir.cpp

     
    227227        } 
    228228        else 
    229229        { 
    230                 strcpy(chDum1,version.chDate); 
    231                 strcpy(chDum2,version.chVersion); 
     230                strcpy(chDum1,version::Inst().chDate); 
     231                strcpy(chDum2,version::Inst().chVersion); 
    232232                strcpy(chDum3,cpu.host_name()); 
    233233                wr_continue(VRSNEW,LIMPAR,a2,c1,c2,xc,xcold,dmax,dold,*ymin,nvarPhymir,optimize.nOptimiz, 
    234234                            optimize.varmax,optimize.varmin,chDum1,chDum2,chDum3,CNTFILE); 
  • version.h

     
    55#define _VERSION_H_ 
    66 
    77/** version.h */ 
    8  
     8#include "date.h" 
    99#define CITATION        "Ferland, G. J., Korista, K. T., Verner, D. A., Ferguson, J. W., Kingdon, J. B., & Verner, E. M. 1998, PASP, 110, 761"  
    1010#define CITATION_LATEX  "\\bibitem[Ferland et al.(1998)]{1998PASP..110..761F} Ferland, G.~J., Korista, K.~T., Verner, D.~A., Ferguson, J.~W., Kingdon, J.~B., \\& Verner, E.~M.\\ 1998, \\pasp, 110, 761"  
    1111#define CITATION_SHORT  "Ferland et al. (1998)"  
    1212 
    13 EXTERN struct t_version { 
    14  
     13class version : public Singleton<version>  
     14{ 
     15        friend class Singleton<version>; 
     16protected: 
     17        version() 
     18        { 
     19                /* set the date saved in date.h into version.chDate  
     20                 * this is the decade part of the year counted after 2000 */ 
     21                int nDecade = (YEAR-100)/10; 
     22                char chDecade[2]; 
     23                 
     24                /* create space for these strings */ 
     25                chDate = (char *)MALLOC( sizeof(char)*INPUT_LINE_LENGTH ); 
     26                chVersion = (char *)MALLOC( sizeof(char)*INPUT_LINE_LENGTH ); 
     27                 
     28                static char chMonth[12][4] ={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" }; 
     29                static char chMonthInt[12][3] ={"01","02","03","04","05","06","07","08","09","10","11","12" }; 
     30                 
     31                sprintf(chDecade,"%i", nDecade ); 
     32                /* set date and version - this code will need to be modified in the year 2110 */ 
     33                if( nDecade > 9 ) 
     34                { 
     35                        fprintf(ioQQQ,"must update formation of chDate in cdInit \n"); 
     36                        TotalInsanity(); 
     37                } 
     38                if( DAY < 10 ) 
     39                { 
     40                        sprintf( chDate , "%s%1i%s0%1i",  
     41                                                         chDecade, 
     42                                                         YEAR-100-nDecade*10, 
     43                                                         chMonth[MONTH], 
     44                                                         DAY ); 
     45                        sprintf( chVersion , "%s%1i.%s.0%1i",  
     46                                                         chDecade, 
     47                                                         YEAR-100-nDecade*10, 
     48                                                         chMonthInt[MONTH], 
     49                                                         DAY ); 
     50                } 
     51                else 
     52                { 
     53                        sprintf( chDate , "%s%1i%s%2i",  
     54                                                         chDecade, 
     55                                                         YEAR-100-nDecade*10, 
     56                                                         chMonth[MONTH], 
     57                                                         DAY ); 
     58                        sprintf( chVersion , "%s%1i.%s.%2i",  
     59                                                         chDecade, 
     60                                                         YEAR-100-nDecade*10, 
     61                                                         chMonthInt[MONTH], 
     62                                                         DAY ); 
     63                } 
     64                 
     65                chCitation = CITATION; 
     66                chCitationLatex = CITATION_LATEX; 
     67                chCitationShort = CITATION_SHORT; 
     68                 
     69                /* is this a release version? */ 
     70                lgRelease = false; 
     71                 
     72                /* is this a beta version?  0 for no */ 
     73                nBetaVer = 0; 
     74                 
     75                /* optional letter could come here for updates to branched version */ 
     76                /*strcat( chVersion , "a" );*/ 
     77                /* change following from * to letter when letters are used */ 
     78                strcat( chDate , "*" ); 
     79                char mode[6]; 
     80                if( sizeof(long) == 4 ) 
     81                        strncpy( mode, "ILP32", 6 ); 
     82                else if( sizeof(long) == 8 ) 
     83                        strncpy( mode, "LP64", 6 ); 
     84                else 
     85                        strncpy( mode, "?????", 6 ); 
     86                 
     87                /* now generate info on how we were compiled, including compiler version */ 
     88                sprintf(chInfo ,  
     89                                                "cdInit compiled on %s in OS %s using the %s %i compiler in %s mode." , 
     90                                                __DATE__  ,__OS , __COMP , __COMP_VER, mode); 
     91        } 
     92public: 
    1593        /** date of this version of the code as a string, set in cdinit.c, 
    1694         * where space is allocated */ 
    1795        char *chDate; 
     
    39117        /** string to print latex bibitem with print citation command */ 
    40118        const char *chCitationLatex; 
    41119 
    42 }       version; 
     120}; 
    43121 
    44122 
    45123#endif /* _VERSION_H_ */ 
  • parse_commands.cpp

     
    116116        } 
    117117 
    118118        /* say this is a beta version if we are talking and it is the truth */ 
    119         if( version.nBetaVer > 0 && called.lgTalk ) 
     119        if( version::Inst().nBetaVer > 0 && called.lgTalk ) 
    120120        { 
    121121                fprintf( ioQQQ,  
    122122                        "\n                             This is %s (beta %ld) of Cloudy, and is intended for testing only.\n\n",  
    123                         version.chVersion, version.nBetaVer ); 
     123                        version::Inst().chVersion, version::Inst().nBetaVer ); 
    124124        } 
    125125 
    126126        if( called.lgTalk ) 
     
    130130                { 
    131131                        fprintf(ioQQQ,"%c",' '); 
    132132                } 
    133                 fprintf( ioQQQ, "Cloudy %s\n", version.chVersion); 
     133                fprintf( ioQQQ, "Cloudy %s\n", version::Inst().chVersion); 
    134134 
    135135                for( i=0; i<57; i++ )  
    136136                { 
     
    145145 
    146146                /* now print box and date of version, before printing commands */ 
    147147                fprintf( ioQQQ, "**************************************"); 
    148                 fprintf( ioQQQ, "%8.8s", version.chDate); 
     148                fprintf( ioQQQ, "%8.8s", version::Inst().chDate); 
    149149                fprintf( ioQQQ, "*************************************\n"); 
    150150 
    151151                for( i=0; i<23; i++ )  
  • prt_final.cpp

     
    144144        for(i=0; i<31; ++i ) 
    145145                fprintf( ioQQQ, "*"); 
    146146        fprintf( ioQQQ, "*");  
    147         fprintf( ioQQQ, "> Cloudy %s <", version.chVersion); 
     147        fprintf( ioQQQ, "> Cloudy %s <", version::Inst().chVersion); 
    148148        for(i=0; i<32; ++i ) 
    149149                fprintf( ioQQQ, "*"); 
    150150        fprintf( ioQQQ, "\n" ); 
     
    201201                "                       *********************************> Log(U):%6.2f <*********************************\n",  
    202202          a ); 
    203203 
    204         if( version.nBetaVer > 0 ) 
     204        if( version::Inst().nBetaVer > 0 ) 
    205205        { 
    206206                fprintf( ioQQQ,  
    207207                        "\n                        This is a beta test version of the code, and is intended for testing only.\n\n" ); 
  • grid_do.cpp

     
    172172        { 
    173173                fprintf( ioQQQ, "                                                      Optimization  Driver\n" ); 
    174174        } 
    175         fprintf( ioQQQ, "                                                        Cloudy %s\n\n",version.chVersion); 
    176         fprintf( ioQQQ, "                       **************************************%8.87s*************************************\n", version.chDate); 
     175        fprintf( ioQQQ, "                                                        Cloudy %s\n\n",version::Inst().chVersion); 
     176        fprintf( ioQQQ, "                       **************************************%8.87s*************************************\n", version::Inst().chDate); 
    177177        fprintf( ioQQQ, "                       *                                                                                 *\n"); 
    178178 
    179179 
  • parse_print.cpp

     
    7171                        " efforts of many people.  It should be cited as follows:\n" ); 
    7272                fprintf( ioQQQ, "Calculations were performed with version %s of Cloudy," 
    7373                        " last described by %s.\n\n", 
    74                         version.chVersion, 
    75                         version.chCitationShort); 
    76                 fprintf( ioQQQ, "The reference is:\n%s\n\n", version.chCitation ); 
    77                 fprintf( ioQQQ, "In Latex this is:\n%s\n\n", version.chCitationLatex  ); 
     74                        version::Inst().chVersion, 
     75                        version::Inst().chCitationShort); 
     76                fprintf( ioQQQ, "The reference is:\n%s\n\n", version::Inst().chCitation ); 
     77                fprintf( ioQQQ, "In Latex this is:\n%s\n\n", version::Inst().chCitationLatex  ); 
    7878        } 
    7979 
    8080        else if( nMatch("COLU",chCARD_CAPS) && nMatch("DENS",chCARD_CAPS) ) 
     
    9595        { 
    9696                /* print compiler and code version information */ 
    9797                fprintf( ioQQQ, "\nThis is Cloudy, version %s\n%s\n\n" ,  
    98                         version.chVersion, 
    99                         version.chInfo ); 
     98                        version::Inst().chVersion, 
     99                        version::Inst().chInfo ); 
    100100        } 
    101101 
    102102        /* option to print departure coefficients in addition to level pops  
  • cddrive.cpp

     
    367367        } 
    368368 
    369369        /* version was set by cdInit */ 
    370         strcpy( chString , version.chVersion ); 
     370        strcpy( chString , version::Inst().chVersion ); 
    371371        return; 
    372372} 
    373373 
     
    383383void cdDate(char chString[] )  
    384384{ 
    385385        /* date was set by cdInit */ 
    386         strcpy( chString , version.chDate ); 
     386        strcpy( chString , version::Inst().chDate ); 
    387387        return; 
    388388} 
    389389 
  • prt_comment.cpp

     
    159159        /* initialize the line saver */ 
    160160        wcnint(); 
    161161 
    162         if( version.nBetaVer > 0 ) 
     162        if( version::Inst().nBetaVer > 0 ) 
    163163        { 
    164164                sprintf( chLine,  
    165165                        "  !This is beta test version%4ld and is intended for testing only.",  
    166                   version.nBetaVer ); 
     166                  version::Inst().nBetaVer ); 
    167167                bangin(chLine); 
    168168        } 
    169169 
    170170        /* this flag set by call to fixit routine, 
    171171         * to show that parts of the code need repair.  
    172172         * lgRelease is true if this is release version */ 
    173         if( broke.lgFixit && !version.lgRelease ) 
     173        if( broke.lgFixit && !version::Inst().lgRelease ) 
    174174        { 
    175175                sprintf( chLine, "  !The code needs to be fixed - search for fixit()." ); 
    176176                bangin(chLine); 
     
    179179        /* this flag set by call to CodeReview routine, 
    180180        * to show that parts of the code need to be reviewed.  
    181181        * lgRelease is true if this is release version */ 
    182         if( broke.lgCheckit  && !version.lgRelease ) 
     182        if( broke.lgCheckit  && !version::Inst().lgRelease ) 
    183183        { 
    184184                sprintf( chLine, "  !New code needs to be reviewed - search for CodeReview()." ); 
    185185                bangin(chLine);