Changeset 1891

Show
Ignore:
Timestamp:
03/27/08 12:40:50 (5 months ago)
Author:
peter
Message:

source/service.cpp
source/punch_fits.cpp
source/init_coreload.cpp
source/grains_mie.cpp
source/assert_results.cpp
source/parse_punch.cpp
source/optimize_phymir.cpp
source/version.h
source/parse_commands.cpp
source/prt_final.cpp
source/grid_do.cpp
source/parse_print.cpp
source/cddrive.cpp
source/prt_comment.cpp
tsuite/programs/mpi/mpi.cpp

  • Bug-fix for PR59 - cdVersion, cdDate could cause segfault.
  • Start preparing for the change of the release numbering scheme for the next release.
Location:
trunk
Files:
15 modified

Legend:

Unmodified
Added
Removed
  • trunk/source/assert_results.cpp

    r1857 r1891  
    24722472                if( prt.lgPrintTime ) 
    24732473                { 
    2474                         fprintf( ioQQQ, " %s\n\n", version.chInfo ); 
     2474                        fprintf( ioQQQ, " %s\n\n", version::Inst().chInfo ); 
    24752475                } 
    24762476        } 
  • trunk/source/cddrive.cpp

    r1878 r1891  
    352352 * 
    353353 * cdVersion - puts version number of code into string  
    354  * incoming string must have at least 8 char and will become null 
     354 * incoming string must have sufficient length and will become null 
    355355 * terminated string 
    356356 * 
    357357 ************************************************************************/ 
    358358 
    359 void cdVersion(char chString[] )  
    360 { 
    361         DEBUG_ENTRY( "cdVersion()" ); 
    362  
    363         if( !lgcdInitCalled ) 
    364         { 
    365                 printf(" cdInit was not called first - this must be the first call.\n"); 
    366                 cdEXIT(EXIT_FAILURE); 
    367         } 
    368  
    369         /* version was set by cdInit */ 
    370         strcpy( chString , version.chVersion ); 
     359void cdVersion(char chString[]) 
     360{ 
     361        strcpy( chString , version::Inst().chVersion ); 
    371362        return; 
    372363} 
     
    381372 
    382373/* cdDate - puts date of code into string  */ 
    383 void cdDate(char chString[] )  
    384 { 
    385         /* date was set by cdInit */ 
    386         strcpy( chString , version.chDate ); 
     374void cdDate(char chString[]) 
     375{ 
     376        strcpy( chString , version::Inst().chDate ); 
    387377        return; 
    388378} 
  • trunk/source/grains_mie.cpp

    r1815 r1891  
    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 ); 
  • trunk/source/grid_do.cpp

    r1771 r1891  
    167167        if( strcmp(optimize.chOptRtn,"XSPE") == 0 ) 
    168168        { 
    169                 fprintf( ioQQQ, "                                                           Grid  Driver\n" ); 
     169                fprintf( ioQQQ, "                                                          Grid  Driver\n" ); 
    170170        } 
    171171        else 
     
    173173                fprintf( ioQQQ, "                                                      Optimization  Driver\n" ); 
    174174        } 
    175         fprintf( ioQQQ, "                                                        Cloudy %s\n\n",version.chVersion); 
    176         fprintf( ioQQQ, "                       **************************************%8.87s*************************************\n", version.chDate); 
    177         fprintf( ioQQQ, "                       *                                                                                 *\n"); 
    178  
     175        int indent = (122 - strlen(version::Inst().chVersion))/2; 
     176        fprintf( ioQQQ, "%*cCloudy %s\n\n",indent,' ',version::Inst().chVersion); 
     177        fprintf( ioQQQ, "%23c**************************************%7.7s**************************************\n", ' ', version::Inst().chDate ); 
     178        fprintf( ioQQQ, "%23c*%81c*\n", ' ', ' ' ); 
    179179 
    180180        /* now echo initial input quantities with flag for vary */ 
     
    195195                } 
    196196 
    197                 fprintf( ioQQQ, "               %7.7s * ",chNote); 
    198                 j = 0; 
    199                 /* print actual command */ 
    200                 while( input.chCardSav[i][j] !='\0' ) 
    201                 { 
    202                         fprintf( ioQQQ, "%c", input.chCardSav[i][j] ); 
    203                         ++j; 
    204                 } 
    205                 /* flush out rest of space then * */ 
    206                 while( j<80 ) 
    207                 { 
    208                         fprintf( ioQQQ, "%c", ' ' ); 
    209                         ++j; 
    210                 } 
    211                 /* end the line */ 
    212                 fprintf( ioQQQ, "*\n" ); 
    213         } 
    214         fprintf( ioQQQ, "                       *                                                                                 *\n                       ***********************************************************************************\n\n\n" ); 
     197                fprintf( ioQQQ, "%22.7s * %-80s*\n", chNote, input.chCardSav[i] ); 
     198        } 
     199        fprintf( ioQQQ, "%23c*%81c*\n", ' ', ' ' ); 
     200        fprintf( ioQQQ, "%23c***********************************************************************************\n\n\n", ' ' ); 
    215201 
    216202        /* option to trace logical flow within this sub */ 
  • trunk/source/init_coreload.cpp

    r1842 r1891  
    1111#include "hcmap.h" 
    1212#include "h2.h" 
    13 #include "date.h" 
    1413#include "version.h" 
    1514#include "hextra.h" 
     
    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 ) ); 
  • trunk/source/optimize_phymir.cpp

    r1856 r1891  
    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, 
  • trunk/source/parse_commands.cpp

    r1864 r1891  
    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 
     
    127127        { 
    128128                /* this code prints pretty lines at top of output box */ 
    129                 for( i=0; i<57; i++ )  
    130                 { 
    131                         fprintf(ioQQQ,"%c",' '); 
    132                 } 
    133                 fprintf( ioQQQ, "Cloudy %s\n", version.chVersion); 
    134  
    135                 for( i=0; i<57; i++ )  
    136                 { 
    137                         fprintf(ioQQQ,"%c",' '); 
    138                 } 
    139                 fprintf( ioQQQ, "www.nublado.org\n\n"); 
    140  
    141                 for( i=0; i<23; i++ )  
    142                 { 
    143                         fprintf(ioQQQ,"%c",' '); 
    144                 } 
     129                int indent = (122 - strlen(version::Inst().chVersion))/2; 
     130                fprintf( ioQQQ, "%*cCloudy %s\n", indent, ' ', version::Inst().chVersion ); 
     131 
     132                fprintf( ioQQQ, "%57cwww.nublado.org\n\n", ' ' ); 
    145133 
    146134                /* now print box and date of version, before printing commands */ 
     135                fprintf( ioQQQ, "%23c", ' ' ); 
    147136                fprintf( ioQQQ, "**************************************"); 
    148                 fprintf( ioQQQ, "%8.8s", version.chDate); 
    149                 fprintf( ioQQQ, "*************************************\n"); 
    150  
    151                 for( i=0; i<23; i++ )  
    152                 { 
    153                         fprintf(ioQQQ,"%c",' '); 
    154                 } 
    155                 fprintf( ioQQQ, "*"); 
    156  
    157                 for( i=0; i<81; i++ )  
    158                 { 
    159                         fprintf(ioQQQ,"%c",' '); 
    160                 } 
    161                 fprintf( ioQQQ, "*\n"); 
     137                fprintf( ioQQQ, "%7.7s", version::Inst().chDate); 
     138                fprintf( ioQQQ, "**************************************\n"); 
     139 
     140                fprintf( ioQQQ, "%23c*%81c*\n", ' ', ' ' ); 
    162141        } 
    163142 
     
    194173                /* >>chng 04 jan 21, add HIDE option, mostly for print quiet command */ 
    195174                if( called.lgTalk && !nMatch("HIDE",input.chCARDCAPS) ) 
    196                 { 
    197                         fprintf( ioQQQ, "                       * "); 
    198                         i=0; 
    199                         while( chCard[i]!='\0' ) 
    200                         { 
    201                                 fprintf(ioQQQ,"%c",chCard[i]); 
    202                                 ++i; 
    203                         } 
    204  
    205                         while( i<80 ) 
    206                         { 
    207                                 fprintf(ioQQQ,"%c",' '); 
    208                                 ++i; 
    209                         } 
    210                         fprintf(ioQQQ,"*\n"); 
    211                 } 
     175                        fprintf( ioQQQ, "%23c* %-80s*\n", ' ', chCard ); 
    212176 
    213177                /* change chCard to all caps */ 
     
    18631827        if( called.lgTalk ) 
    18641828        { 
    1865                 fprintf( ioQQQ, "                       * %80.80s*\n",  
    1866                   chCard ); 
    1867                 fprintf( ioQQQ, "                       ***********************************************************************************\n\n\n\n" ); 
     1829                fprintf( ioQQQ, "%23c*%81c*\n", ' ', ' ' ); 
     1830                fprintf( ioQQQ, "%23c***********************************************************************************\n\n\n\n", ' ' ); 
    18681831        } 
    18691832 
  • trunk/source/parse_print.cpp

    r1815 r1891  
    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 
     
    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 
  • trunk/source/parse_punch.cpp

    r1852 r1891  
    203203                sprintf( chHeader,  
    204204                        "# %s %s\n",  
    205                   version.chVersion, input.chTitle ); 
     205                  version::Inst().chVersion, input.chTitle ); 
    206206        } 
    207207 
  • trunk/source/prt_comment.cpp

    r1854 r1891  
    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        } 
     
    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()." ); 
     
    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()." ); 
  • trunk/source/prt_final.cpp

    r1787 r1891  
    136136 
    137137        /* print name and version number */ 
    138         /*lint -e666 expression with side effects */ 
    139138        fprintf( ioQQQ, "\f\n"); 
    140         REPEAT_16( fprintf( ioQQQ, " "); ) 
    141         REPEAT_4( fprintf( ioQQQ, " "); ) 
    142         REPEAT_2( fprintf( ioQQQ, " ");) 
    143         fprintf( ioQQQ, " ");  
    144         for(i=0; i<31; ++i ) 
    145                 fprintf( ioQQQ, "*"); 
    146         fprintf( ioQQQ, "*");  
    147         fprintf( ioQQQ, "> Cloudy %s <", version.chVersion); 
    148         for(i=0; i<32; ++i ) 
    149                 fprintf( ioQQQ, "*"); 
     139        fprintf( ioQQQ, "%23c", ' ' ); 
     140        int len = strlen(version::Inst().chVersion); 
     141        int repeat = (72-len)/2; 
     142        for( i=0; i < repeat; ++i ) 
     143                fprintf( ioQQQ, "*" ); 
     144        fprintf( ioQQQ, "> Cloudy %s <", version::Inst().chVersion ); 
     145        for( i=0; i < 72-repeat-len; ++i ) 
     146                fprintf( ioQQQ, "*" ); 
    150147        fprintf( ioQQQ, "\n" ); 
    151         /*lint +e666 */ 
    152148 
    153149        for( i=0; i <= input.nSave; i++ ) 
     
    165161                /* >>chng 04 jan 21, add hide option */ 
    166162                if( (strcmp(chCKey,"CONT")!= 0) && !nMatch( "HIDE" , input.chCARDCAPS) ) 
    167                 { 
    168                         /* print leading space and first * */ 
    169                         fprintf( ioQQQ, "                       * "); 
    170  
    171                         j = 0; 
    172                         /* print actual command */ 
    173                         while( input.chCardSav[i][j] !='\0' ) 
    174                         { 
    175                                 fprintf( ioQQQ, "%c", input.chCardSav[i][j] ); 
    176                                 ++j; 
    177                         } 
    178  
    179                         /* flush out rest of space then * */ 
    180                         while( j<80 ) 
    181                         { 
    182                                 fprintf( ioQQQ, "%c", ' ' ); 
    183                                 ++j; 
    184                         } 
    185                         /* end the line */ 
    186                         fprintf( ioQQQ, "*\n" ); 
    187                 } 
     163                        fprintf( ioQQQ, "%23c* %-80s*\n", ' ', input.chCardSav[i] ); 
    188164        } 
    189165 
     
    202178          a ); 
    203179 
    204         if( version.nBetaVer > 0 ) 
     180        if( version::Inst().nBetaVer > 0 ) 
    205181        { 
    206182                fprintf( ioQQQ,  
  • trunk/source/punch_fits.cpp

    r1771 r1891  
    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 ); 
  • trunk/source/service.cpp

    r1819 r1891  
    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",  
  • trunk/source/version.h

    • Property svn:keywords set to URL
    r1732 r1891  
    66 
    77/** version.h */ 
     8#include "date.h" 
    89 
    9 #define CITATION        "Ferland, G. J., Korista, K. T., Verner, D. A., Ferguson, J. W., Kingdon, J. B., & Verner, E. M. 1998, PASP, 110, 761"  
    10 #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"  
    11 #define CITATION_SHORT  "Ferland et al. (1998)"  
     10#if 0 
     11static const int CLD_MAJOR = 8; 
     12static const int CLD_MINOR = 0; 
    1213 
    13 EXTERN struct t_version { 
     14#ifdef SVN_REVISION 
     15static const char* svn_revision = SVN_REVISION; 
     16#else 
     17static const char* svn_revision = "unknown"; 
     18#endif 
    1419 
     20static const string Url = "$HeadURL$"; 
     21#endif 
     22 
     23static const char* CITATION = "Ferland, G. J., Korista, K. T., Verner, D. A., Ferguson, J. W., Kingdon, J. B., & Verner, E. M. 1998, PASP, 110, 761"; 
     24static const char* 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"; 
     25static const char* CITATION_SHORT = "Ferland et al. (1998)";             
     26 
     27class version : public Singleton<version>  
     28{ 
     29        friend class Singleton<version>; 
     30protected: 
     31        version() 
     32        { 
     33                /* set date and version - this code will need to be modified in the year 2100 */ 
     34                if( YEAR >= 200 ) 
     35                { 
     36                        fprintf(ioQQQ,"must update formation of chDate in cdInit \n"); 
     37                        TotalInsanity(); 
     38                } 
     39                 
     40                static const char chMonth[12][4] = 
     41                        { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; 
     42                 
     43                /* is this a beta version?  0 for no */ 
     44                nBetaVer = 0; 
     45                 
     46                /* is this a release version? */ 
     47                lgRelease = false; 
     48                 
     49                sprintf( chDate, "%2.2i%3.3s%2.2i",  
     50                         YEAR-100, 
     51                         chMonth[MONTH], 
     52                         DAY ); 
     53 
     54                sprintf( chVersion, "%2.2i.%2.2i.%2.2i",  
     55                         YEAR-100, 
     56                         MONTH+1, 
     57                         DAY ); 
     58                 
     59                char mode[6]; 
     60                if( sizeof(long) == 4 ) 
     61                        strncpy( mode, "ILP32", 6 ); 
     62                else if( sizeof(long) == 8 ) 
     63                        strncpy( mode, "LP64", 6 ); 
     64                else 
     65                        strncpy( mode, "?????", 6 ); 
     66                 
     67                /* now generate info on how we were compiled, including compiler version */ 
     68                sprintf(chInfo ,  
     69                        "cdInit compiled on %s in OS %s using the %s %i compiler in %s mode." , 
     70                        __DATE__  ,__OS , __COMP , __COMP_VER, mode); 
     71 
     72                chCitation = CITATION; 
     73                chCitationLatex = CITATION_LATEX; 
     74                chCitationShort = CITATION_SHORT; 
     75        } 
     76public: 
    1577        /** date of this version of the code as a string, set in cdinit.c, 
    1678         * where space is allocated */ 
    17         char *chDate; 
     79        char chDate[INPUT_LINE_LENGTH]; 
    1880 
    1981        /** version number of this version of the code, as a string, set in cdinit.c  
    2082         * where space is allocated */ 
    21         char *chVersion; 
     83        char chVersion[INPUT_LINE_LENGTH]; 
    2284 
    2385        /** normally zero, non-zero if this is a beta test version */ 
     
    39101        /** string to print latex bibitem with print citation command */ 
    40102        const char *chCitationLatex; 
    41  
    42 }       version; 
     103}; 
    43104 
    44105 
  • trunk/tsuite/programs/mpi/mpi.cpp

    r1806 r1891