Changeset 1997

Show
Ignore:
Timestamp:
04/30/08 09:59:27 (2 weeks ago)
Author:
peter
Message:

source/parse_commands.cpp:

  • Bug-fix: Using DLAW command would lead to bogus error message that
    "Hydrogen density MUST be specified."
  • Bug-fix: The code would continue a model despite the fact that it
    thought that no hydrogen density was entered.
  • Bug-fix: When combining the DLAW command and a wind model, the
    hydrogen density would be initialized after it was already used in
    wind.emdot.

source/parse_hden.cpp:
source/parse_dlaw.cpp:
source/parse_fluc.cpp:
source/parse_globule.cpp:

  • Make dense.gas_phase[ipHYDROGEN] linear immediately.
  • Disallow multiple density commands in one script.

source/zero.cpp:

  • Remove initialization of dense.gas_phase[ipHYDROGEN] to -99.

source/helike_einsta.cpp:
source/hydroeinsta.cpp:

  • Fix: Replace NULL -> 0.f.

tsuite/slow/checkall.pl:
tsuite/auto/checkall.pl:

  • Pick up DISASTER statements in output and include in serious.txt.

tsuite/auto/func_dlaw.in:

  • Bug-fix: remove duplicate density statement.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/source/helike_einsta.cpp

    r1986 r1997  
    10321032                        } 
    10331033                        else 
    1034                                 iso.CachedAs[ipISO][nelem][ N_(ipHi)-iso.n_HighestResolved_max[ipISO][nelem]-1 ][ ipLo ][1] = NULL
     1034                                iso.CachedAs[ipISO][nelem][ N_(ipHi)-iso.n_HighestResolved_max[ipISO][nelem]-1 ][ ipLo ][1] = 0.f
    10351035 
    10361036                        iso_put_error(ipHE_LIKE,nelem,ipHi,ipLo,IPRAD,0.01f); 
  • trunk/source/hydroeinsta.cpp

    r1986 r1997  
    8282                        } 
    8383                        else 
    84                                 iso.CachedAs[ipISO][nelem][ N_(ipHi)-iso.n_HighestResolved_max[ipISO][nelem]-1 ][ ipLo ][1] = NULL
     84                                iso.CachedAs[ipISO][nelem][ N_(ipHi)-iso.n_HighestResolved_max[ipISO][nelem]-1 ][ ipLo ][1] = 0.f
    8585 
    8686                        iso_put_error(ipISO,nelem,ipHi,ipLo,IPRAD,0.01f); 
  • trunk/source/parse_commands.cpp

    r1960 r1997  
    18371837        } 
    18381838 
    1839         /* check whether hydrogen density has been set - this value was 
    1840          * set to -99 in zero - density is log of hydrogen density at this 
    1841          * point */ 
    1842         /**\todo        0       why not set to 0 and insist on positive value? */ 
    1843         if( dense.gas_phase[ipHYDROGEN] == -99. ) 
    1844         { 
    1845                 fprintf( ioQQQ, " Hydrogen density MUST be specified.\n" ); 
    1846                 lgStop_not_enough_info = true; 
    1847                 lgStop = true; 
    1848         } 
    1849  
    1850         /* set hydrogen density to linear density - was log up to now */ 
    1851         dense.gas_phase[ipHYDROGEN] = (realnum)pow((realnum)10.f,dense.gas_phase[ipHYDROGEN]); 
    1852  
    1853         radius.rinner = radius.Radius; 
    1854  
    1855         /* mass flux for wind model - used for mass conservation */ 
    1856         wind.emdot = dense.gas_phase[ipHYDROGEN]*wind.windv0; 
    1857  
    1858         /* set converge criteria - limit number of iterations and zones */ 
    1859         if( iterations.lgConverge_set) 
    1860         { 
    1861                 iterations.itermx = MIN2( iterations.itermx , iterations.lim_iter ); 
    1862                 for( j=0; j < iterations.iter_malloc; j++ ) 
    1863                 { 
    1864                         geometry.nend[j] = MIN2( geometry.nend[j] , iterations.lim_zone ); 
    1865                 } 
    1866         } 
    1867  
    1868         /* find density in these special cases where set externally to this routine 
    1869          *>>chng 07 feb 25, BUGFIX - had been log10 - error - PvH */ 
     1839        /* set density from DLAW command, must be done here since it may depend on later input commands */ 
    18701840        if( strcmp(dense.chDenseLaw,"DLW1") == 0 ) 
    18711841        { 
    18721842                dense.gas_phase[ipHYDROGEN] = (realnum)dense_fabden(radius.Radius,radius.depth); 
     1843 
     1844                if( dense.gas_phase[ipHYDROGEN] <= 0. ) 
     1845                { 
     1846                        fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density set by DLAW must be > 0.\n" ); 
     1847                        cdEXIT(EXIT_FAILURE); 
     1848                } 
    18731849        } 
    18741850        else if( strcmp(dense.chDenseLaw,"DLW2") == 0 ) 
    18751851        { 
    1876                 /* >>chng 96 nov 29, added dense_tabden, based on Kevin Volk code */ 
    1877                 dense.gas_phase[ipHYDROGEN] =(realnum)dense_tabden(radius.Radius,radius.depth); 
     1852                dense.gas_phase[ipHYDROGEN] = (realnum)dense_tabden(radius.Radius,radius.depth); 
     1853 
     1854                if( dense.gas_phase[ipHYDROGEN] <= 0. ) 
     1855                { 
     1856                        fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density set by DLAW must be > 0.\n" ); 
     1857                        cdEXIT(EXIT_FAILURE); 
     1858                } 
    18781859        } 
    18791860 
     
    18841865        lgStop_not_enough_info = false; 
    18851866        lgStop = false; 
     1867 
     1868        /* check whether hydrogen density has been set - this value was set to 0 in zero */ 
     1869        if( dense.gas_phase[ipHYDROGEN] <= 0. ) 
     1870        { 
     1871                fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density MUST be specified.\n" ); 
     1872                lgStop_not_enough_info = true; 
     1873                lgStop = true; 
     1874        } 
     1875 
     1876        radius.rinner = radius.Radius; 
     1877 
     1878        /* mass flux for wind model - used for mass conservation */ 
     1879        wind.emdot = dense.gas_phase[ipHYDROGEN]*wind.windv0; 
     1880 
     1881        /* set converge criteria - limit number of iterations and zones */ 
     1882        if( iterations.lgConverge_set) 
     1883        { 
     1884                iterations.itermx = MIN2( iterations.itermx , iterations.lim_iter ); 
     1885                for( j=0; j < iterations.iter_malloc; j++ ) 
     1886                { 
     1887                        geometry.nend[j] = MIN2( geometry.nend[j] , iterations.lim_zone ); 
     1888                } 
     1889        } 
    18861890 
    18871891        /* NSAVE is number of lines saved, =0 if no commands entered */ 
     
    20242028        } 
    20252029 
    2026         /* dense.gas_phase[ipHYDROGEN] is linear hydrogen density (cm-3) unless not set and so zero */ 
    2027         /**\todo        0       this cannot trip since var init to -99 and already tested, 
    2028          * but then 10**x so 1e-99 - should change to init gas_phase to zero 
    2029          * init is in zero.cpp */ 
    2030         if( called.lgTalk && dense.gas_phase[ipHYDROGEN] == 0 ) 
    2031         { 
    2032                 fprintf( ioQQQ, " PROBLEM DISASTER The hydrogen density has not been specified - use the HDEN command to do this.\n"); 
    2033                 lgStop_not_enough_info = true; 
    2034         } 
    2035         else if( called.lgTalk && dense.gas_phase[ipHYDROGEN] < 1e-4 ) 
     2030        /* dense.gas_phase[ipHYDROGEN] is linear hydrogen density (cm-3) */ 
     2031        /* test for hydrogen density properly set has already been done above */ 
     2032        if( called.lgTalk && dense.gas_phase[ipHYDROGEN] < 1e-4 ) 
    20362033        { 
    20372034                fprintf( ioQQQ, " NOTE Is the entered value of the hydrogen density (%.2e) reasonable?\n", 
  • trunk/source/parse_dlaw.cpp

    r1771 r1997  
    77#include "abund.h" 
    88#include "input.h" 
     9#include "radius.h" 
    910#include "parse.h" 
    1011 
     
    1819 
    1920        DEBUG_ENTRY( "ParseDLaw()" ); 
     21 
     22        if( dense.gas_phase[ipHYDROGEN] > 0. ) 
     23        { 
     24                fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" ); 
     25                cdEXIT(EXIT_FAILURE); 
     26        } 
    2027 
    2128        /* call fcn dense_fabden(RADIUS) which uses the ten parameters 
     
    113120                } 
    114121        } 
     122 
     123        /* set fake density to signal that density command was entered */ 
     124        /* real density will be set once all input commands have been read */ 
     125        /* this is necessary since density may depend on subsequent commands */ 
     126        dense.gas_phase[ipHYDROGEN] = 1.f; 
     127 
    115128        return; 
    116129} 
  • trunk/source/parse_fluc.cpp

    r1771 r1997  
    4848        temp = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 
    4949 
     50        /* check size of density - will we crash? */ 
     51        if( temp > log10(FLT_MAX) || temp < log10(FLT_MIN) ) 
     52        { 
     53                fprintf(ioQQQ, 
     54                        " DISASTER - the log of the entered max hydrogen density is %.3f - too extreme for this processor.\n", 
     55                        temp); 
     56                if( temp > 0. ) 
     57                        fprintf(ioQQQ, 
     58                                " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n", 
     59                                log10(FLT_MAX) ); 
     60                else 
     61                        fprintf(ioQQQ, 
     62                                " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n", 
     63                                log10(FLT_MIN) ); 
     64                fprintf(ioQQQ," Sorry.\n" ); 
     65                cdEXIT(EXIT_FAILURE); 
     66        } 
     67 
    5068        /* 2nd number log of max hydrogen density */ 
    5169        flmax = pow(10.,temp); 
    5270 
     71        temp = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 
     72 
     73        /* check size of density - will we crash? */ 
     74        if( temp > log10(FLT_MAX) || temp < log10(FLT_MIN) ) 
     75        { 
     76                fprintf(ioQQQ, 
     77                        " DISASTER - the log of the entered min hydrogen density is %.3f - too extreme for this processor.\n", 
     78                        temp); 
     79                if( temp > 0. ) 
     80                        fprintf(ioQQQ, 
     81                                " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n", 
     82                                log10(FLT_MAX) ); 
     83                else 
     84                        fprintf(ioQQQ, 
     85                                " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n", 
     86                                log10(FLT_MIN) ); 
     87                fprintf(ioQQQ," Sorry.\n" ); 
     88                cdEXIT(EXIT_FAILURE); 
     89        } 
     90 
    5391        /* 3rd number log of min hydrogen density */ 
    54         flmin = pow(10.,FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL)); 
     92        flmin = pow(10.,temp); 
     93 
    5594        if( flmax/flmin > 100. ) 
    5695        { 
     
    65104                fprintf( ioQQQ, "There MUST be three numbers on this line.\n" ); 
    66105                fprintf( ioQQQ, "These must be the period(cm), max, min densities, all logs, in that order.\n" ); 
     106                if( flmin > flmax ) 
     107                        fprintf( ioQQQ, "The max density must be greater or equal than the min density.\n" ); 
    67108                cdEXIT(EXIT_FAILURE); 
    68109        } 
     
    93134                strcpy( dense.chDenseLaw, "SINE" ); 
    94135 
     136                if( dense.gas_phase[ipHYDROGEN] > 0. ) 
     137                { 
     138                        fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" ); 
     139                        cdEXIT(EXIT_FAILURE); 
     140                } 
     141 
    95142                /* depth is zero for first zone */ 
    96143                dense.gas_phase[ipHYDROGEN] = dense.cfirst*(realnum)cos(dense.flcPhase) + dense.csecnd; 
    97                 dense.gas_phase[ipHYDROGEN] = (realnum)log10(dense.gas_phase[ipHYDROGEN]); 
     144 
     145                if( dense.gas_phase[ipHYDROGEN] <= 0. ) 
     146                { 
     147                        fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density must be > 0.\n" ); 
     148                        cdEXIT(EXIT_FAILURE); 
     149                } 
    98150        } 
    99151        return; 
  • trunk/source/parse_globule.cpp

    r1732 r1997  
    1616        DEBUG_ENTRY( "ParseGlobule()" ); 
    1717 
     18        if( dense.gas_phase[ipHYDROGEN] > 0. ) 
     19        { 
     20                fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" ); 
     21                cdEXIT(EXIT_FAILURE); 
     22        } 
     23 
    1824        /* globule with density increasing inward 
    1925         * parameters are outer density, radius of globule, and density power */ 
    2026        i = 5; 
    2127        radius.glbden = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 
    22         if( lgEOL ) 
     28        radius.glbden = lgEOL ? 1. : (realnum)pow((realnum)10.f,radius.glbden); 
     29        dense.gas_phase[ipHYDROGEN] = radius.glbden; 
     30 
     31        if( dense.gas_phase[ipHYDROGEN] <= 0. ) 
    2332        { 
    24                 radius.glbden = 1.; 
    25                 dense.gas_phase[ipHYDROGEN] = 0.; 
    26         } 
    27  
    28         else 
    29         { 
    30                 dense.gas_phase[ipHYDROGEN] = radius.glbden; 
    31                 radius.glbden = (realnum)pow((realnum)10.f,radius.glbden); 
     33                fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density must be > 0.\n" ); 
     34                cdEXIT(EXIT_FAILURE); 
    3235        } 
    3336 
  • trunk/source/parse_hden.cpp

    r1771 r1997  
    1515        DEBUG_ENTRY( "ParseHDEN()" ); 
    1616 
     17        if( dense.gas_phase[ipHYDROGEN] > 0. ) 
     18        { 
     19                fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" ); 
     20                cdEXIT(EXIT_FAILURE); 
     21        } 
     22 
    1723        /* log of hydrogen density */ 
    1824        i = 5; 
     
    2026        if( lgEOL ) 
    2127        { 
    22                 fprintf( ioQQQ, " log(n) MUST be entered with this command. STOP\n" ); 
     28                fprintf( ioQQQ, " DISASTER The density MUST be entered with this command. STOP\n" ); 
    2329                cdEXIT(EXIT_FAILURE); 
    2430        } 
    2531 
    2632        /* check for further options */ 
    27         if( nMatch("LINE",chCard) ) 
     33        if( ! nMatch("LINE",chCard) ) 
    2834        { 
    29                 /* linear option */ 
    30                 if( dense.gas_phase[ipHYDROGEN] <= 0. ) 
     35                /* check size of density - will we crash? */ 
     36                if( dense.gas_phase[ipHYDROGEN] > log10(FLT_MAX) || 
     37                    dense.gas_phase[ipHYDROGEN] < log10(FLT_MIN) )       
    3138                { 
    32                         fprintf( ioQQQ, " A negative density is not physical.\n" ); 
     39                        fprintf(ioQQQ, 
     40                                " DISASTER - the log of the entered hydrogen density is %.3f - too extreme for this processor.\n", 
     41                                dense.gas_phase[ipHYDROGEN]); 
     42                        if( dense.gas_phase[ipHYDROGEN] > 0. ) 
     43                                fprintf(ioQQQ, 
     44                                        " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n", 
     45                                        log10(FLT_MAX) ); 
     46                        else 
     47                                fprintf(ioQQQ, 
     48                                        " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n", 
     49                                        log10(FLT_MIN) ); 
     50                        fprintf(ioQQQ," Sorry.\n" ); 
     51                         
    3352                        cdEXIT(EXIT_FAILURE); 
    3453                } 
    35                 else 
    36                 { 
    37                         dense.gas_phase[ipHYDROGEN] = (realnum)log10(dense.gas_phase[ipHYDROGEN]); 
    38                 } 
     54 
     55                dense.gas_phase[ipHYDROGEN] = (realnum)pow((realnum)10.f,dense.gas_phase[ipHYDROGEN]); 
    3956        } 
    4057 
    41         /* check size of density - will we crash? */ 
    42         if( fabs(dense.gas_phase[ipHYDROGEN]) > log10(FLT_MAX) ) 
     58        if( dense.gas_phase[ipHYDROGEN] <= 0. ) 
    4359        { 
    44                 fprintf(ioQQQ, 
    45                         " DISASTER - the log of the entered hydrogen density is %.3f - too large for this processor.\n", 
    46                         dense.gas_phase[ipHYDROGEN]); 
    47                 fprintf(ioQQQ, 
    48                         " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n", 
    49                         log10(FLT_MAX) ); 
    50                 fprintf(ioQQQ," Sorry.\n" ); 
    51  
     60                fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density must be > 0.\n" ); 
    5261                cdEXIT(EXIT_FAILURE); 
    5362        } 
    5463 
    5564        /* this is the linear initial density */ 
    56         dense.den0 = (realnum)pow((realnum)10.f,dense.gas_phase[ipHYDROGEN])
     65        dense.den0 = dense.gas_phase[ipHYDROGEN]
    5766 
    5867        /* check if exponent entered */ 
     
    99108                /*  pointer to where to write */ 
    100109                optimize.nvfpnt[optimize.nparm] = input.nRead; 
    101                 optimize.vparm[0][optimize.nparm] = (realnum)dense.gas_phase[ipHYDROGEN]
     110                optimize.vparm[0][optimize.nparm] = (realnum)log10(dense.gas_phase[ipHYDROGEN])
    102111                optimize.vincr[optimize.nparm] = 1.; 
    103112 
  • trunk/source/zero.cpp

    r1960 r1997  
    900900 
    901901        dense.eden = 1.; 
    902         /* >>chng 02 feb 28, this was set to 1 here, and to -99 in zerologic, so that 
    903          * check whether hden was specified was defeated.  Reset to correct -99. here.*/ 
    904         dense.gas_phase[ipHYDROGEN] = -99.; 
    905902 
    906903        /* now set physical conditions array  
  • trunk/tsuite/auto/checkall.pl

    r1779 r1997  
    5959        while( <OUTP> ) 
    6060        { 
    61 # find "BOTCH " and "W-" strings in all the output file and write 
     61# find "DISASTER", "Botched" and "W-" strings in all the output files and write 
    6262# corresponding line into serious.txt file. 
    63             if( /Botched/ || /W-/ ) 
     63            if( /DISASTER/ || /Botched/ || /W-/ ) 
    6464            { 
    6565                print SERIOUS "$output: $_"; 
     
    7272# now look for string PROBLEM, which indicates an internal problem 
    7373# during the calculation - this is not a serious problem 
    74             if( /PROBLEM/
     74            if( /PROBLEM/ && ! /DISASTER/
    7575            { 
    7676                print MINOR "$output: $_"; 
  • trunk/tsuite/auto/func_dlaw.in

    r1092 r1997  
    66c 
    77c commands for density & abundances ========= 
    8 hden 7 -4 
    98dlaw table radius 
    109continue 16 9 
  • trunk/tsuite/slow/checkall.pl

    r1883 r1997  
    5959        while( <OUTP> ) 
    6060        { 
    61 # find "BOTCH " and "W-" strings in all the output file and write 
     61# find "DISASTER", "Botched" and "W-" strings in all the output files and write 
    6262# corresponding line into serious.txt file. 
    63             if( /Botched/ || /W-/ ) 
     63            if( /DISASTER/ || /Botched/ || /W-/ ) 
    6464            { 
    6565                print SERIOUS "$output: $_"; 
     
    7272# now look for string PROBLEM, which indicates an internal problem 
    7373# during the calculation - this is not a serious problem 
    74             if( /PROBLEM/
     74            if( /PROBLEM/ && ! /DISASTER/
    7575            { 
    7676                print MINOR "$output: $_";