Changeset 1178

Show
Ignore:
Timestamp:
06/08/07 22:10:35 (1 year ago)
Author:
gary
Message:

assert_results.cpp - do not do assert checks during middle of optimization run to prevent false detection of failure before optimization is complete.

cloudy.cpp - in BadStart? define final grid parameters in case where grid is being done, so that full grid is produced even for case of aborted models - do not want a "missing" grid point in punch output

conv_init_solution.cpp - minor formatting changes

grid.h - save abort and number of warnings flags for each sim

grid_do.cpp remove large block of init variables, place in preparse default init

init.h rename InitDefaults? to InitDefaultsPreparse?

grid_xspec.cpp - create space for grid abort and number of warnings flags

mole_h2.cpp - minor changes in comments

optimize.h - define lgOptimize - single flag saying whether this is an optimization run

optimize_func.cpp - minor changes in comments

parse_optimize.cpp - define optimize.lgOptimize when doing optimize

parse_set.cpp - trivial comment cleanup

parse_stop.cpp - trival comment cleanup

punch_do.cpp - punch grid command now begins with abort flag and number of warnings

Files:

Legend:

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

    r1142 r1178  
    14821482        /* will be used if there were big botched asserts */ 
    14831483        lgBigBotch = false; 
     1484 
     1485        /* the optimize*.in and stars_oppim*.in tests in the test suite include 
     1486         * asserts while optimizing.  We do not want to  test the asserts during 
     1487         * the optimization process, since we will find blown asserts and report 
     1488         * major problems.  We do want to test asserts on the final model however. 
     1489         * Printout will usually be turned off in all except the final model, 
     1490         * so do not to the assert tests if we are optimizing but not printing */ 
     1491        if( !called.lgTalk && optimize.lgOptimize ) 
     1492        { 
     1493                /* just return */ 
     1494                DEBUG_EXIT( "lgCheckAsserts()" ); 
     1495                return true; 
     1496        } 
    14841497 
    14851498        /*fprintf(ioQQQ , "DEBUG grid %li\n", optimize.nOptimiz );*/ 
  • trunk/source/cloudy.cpp

    r1147 r1178  
    8080         * in a grid, before the parser is called - this must set any values 
    8181         * that may be changed by the command parser */ 
    82         InitDefaults(); 
     82        InitDefaultsPreparse(); 
    8383 
    8484        /* scan in and parse input data */ 
     
    325325                return(true); 
    326326        } 
    327  
    328327} 
    329328 
     
    341340        warnin(chLine); 
    342341 
     342        if( grid.lgGrid ) 
     343        { 
     344                /* save flags indicating quality of this calculation if in grid 
     345                * these will be output with punch grid command */ 
     346                /* nOptimiz is 1 for first model in a grid */ 
     347                grid.lgAbort[optimize.nOptimiz-1] = true; 
     348                /* number of warnings is only defined if we did not abort */ 
     349                grid.nWarn[optimize.nOptimiz-1] = warnings.nwarn; 
     350 
     351                /* possibly punch out some results from this zone when doing grid 
     352                * since grid punch files expect something at this grid point */ 
     353                PunchDo("MIDL"); 
     354                PunchDo("LAST" ); 
     355        } 
     356 
    343357        DEBUG_EXIT( "BadStart()" ); 
    344358        return; 
  • trunk/source/conv_init_solution.cpp

    r889 r1178  
    471471                        { 
    472472                                /* we hit an abort */ 
    473                                 fprintf( ioQQQ, " Search for initial conditions aborted - lgAbort set true.\n" ); 
     473                                fprintf( ioQQQ, "PROBLEM Search for initial conditions aborted - lgAbort set true.\n" ); 
    474474                                ShowMe(); 
    475475                                 
  • trunk/source/grid.h

    r849 r1178  
    2929                **paramData, 
    3030                **interpParameters; 
     31        bool *lgAbort; 
     32        int *nWarn; 
    3133 
    3234        float paramIncrements[LIMPAR]; 
  • trunk/source/grid_do.cpp

    r1147 r1178  
    1616#include "grid.h" 
    1717 
    18 /*grid_do called by cdDrive, calls gridXspec, returns 0 if ok, 1 for disaster */ 
     18/*grid_do called by cdDrive, calls gridXspec, returns false if ok, true for disaster */ 
    1919bool grid_do(void) 
    2020{ 
     
    4343        } 
    4444 
    45         /* this moved here from zerologic */ 
    46         optimize.nIterOptim = 20; 
    47         optimize.ioOptim = NULL; 
    48         optimize.OptGlobalErr = 0.10f; 
    49         optimize.nlobs = 0; 
    50         optimize.nTempObs = 0; 
    51         optimize.ncobs = 0; 
    52         optimize.nRangeSet = 0; 
    53         strcpy( optimize.chOptRtn, "SUBP" ); 
    54  
    55         /* flags says what is to be matched */ 
    56         optimize.lgOptLin = false; 
    57         optimize.lgOptLum = false; 
    58         optimize.lgOptCol = false; 
    59         optimize.lgOptTemp = false; 
    60  
    61         /* trace flag for optimization process */ 
    62         optimize.lgTrOpt = false; 
    63  
    64         optimize.lgOptimFlow = false; 
    65         optimize.optint = 0.; 
    66         optimize.optier = 0.; 
    67 #       ifdef __unix 
    68         optimize.lgParallel = true; 
    69 #       else 
    70         optimize.lgParallel = false; 
    71 #       endif 
    72         optimize.lgOptCont = false; 
    73  
    7445        /* necessary to do this to keep all lines in */ 
    7546        prt.lgFaintOn = false; 
     
    7950        * in a grid, before the parser is called - this must set any values 
    8051        * that may be changed by the command parser */ 
    81         InitDefaults(); 
     52        InitDefaultsPreparse(); 
    8253 
    8354        /* call READR the first time to scan off all variable options */ 
  • trunk/source/grid_xspec.cpp

    r1147 r1178  
    6262 
    6363        grid.interpParameters = (float**)MALLOC(sizeof(float*)*(unsigned)(grid.totNumModels) ); 
     64        /* save abort flag */ 
     65        grid.lgAbort = (bool*)MALLOC(sizeof(bool)*(unsigned)(grid.totNumModels) ); 
     66        /* number of warnings */ 
     67        grid.nWarn = (int*)MALLOC(sizeof(int)*(unsigned)(grid.totNumModels) ); 
    6468 
    6569        for( i=0; i<nInterpVars+grid.naddparm; i++ ) 
  • trunk/source/init.h

    r1147 r1178  
    44 * InitCoreload - one time initialization, called from cdInit 
    55 * InitCoreloadPostparse - one time initialization, called after parser 
    6  * InitDefaults initialization at start of simulation, called from cloudy 
     6 * InitDefaultsPreparse initialization at start of simulation, called from cloudy 
    77 * before parser, will be called one time per sim in grid  
    88 * InitSimPostparse initialization at start of simulation, called from cloudy 
     
    1818/** initialize values that are changed in the parser.  Called just 
    1919 * before parser, will be called one time per core load */ 
    20 void InitDefaults( void ); 
     20void InitDefaultsPreparse( void ); 
    2121 
    2222/** initialization after parser, called one time per core load 
  • trunk/source/init_defaults_preparse.cpp

    r1175 r1178  
    11/* This file is part of Cloudy and is copyright (C) 1978-2005 by Gary J. Ferland 
    22* For conditions of distribution and use, see copyright notice in license.txt */ 
    3 /*InitDefaults initialization at start of simulation, called from cloudy 
     3/*InitDefaultsPreparse initialization at start of simulation, called from cloudy 
    44* before parser, sets initial values of quantities changed by parser */ 
    55#include "cddefines.h"  
     
    88#include "stopcalc.h" 
    99#include "wind.h" 
     10#include "optimize.h" 
    1011#include "punch.h" 
    1112#include "init.h"  
    1213 
    13 /*InitDefaults initialization at start of simulation, called from cloudy 
     14/*InitDefaultsPreparse initialization at start of simulation, called from cloudy 
    1415 * before parser, will now be called one time per sim in grid but long term 
    1516 * goal is to call parser only one time in a grid.  This would be called  
     
    1819 * It does not initialize variables for the start of a calculation.  That 
    1920 * is done by InitSimPostparse */ 
    20 void InitDefaults( void ) 
     21void InitDefaultsPreparse( void ) 
    2122{ 
    2223        long int i, ipISO; 
    2324 
    24         DEBUG_ENTRY( "InitDefaults()" ); 
     25        DEBUG_ENTRY( "InitDefaultsPreparse()" ); 
    2526 
    2627        /* init vars before parsing commands for each sim */ 
     
    191192        } 
    192193 
    193         DEBUG_EXIT( "InitDefaults()" ); 
     194        /* initialize some variables for the optimizer */ 
     195        optimize.nIterOptim = 20; 
     196        optimize.ioOptim = NULL; 
     197        optimize.OptGlobalErr = 0.10f; 
     198        optimize.nlobs = 0; 
     199        optimize.nTempObs = 0; 
     200        optimize.ncobs = 0; 
     201        optimize.nRangeSet = 0; 
     202        strcpy( optimize.chOptRtn, "SUBP" ); 
     203 
     204        /* flags says what is to be matched */ 
     205        optimize.lgOptLin = false; 
     206        optimize.lgOptLum = false; 
     207        optimize.lgOptCol = false; 
     208        optimize.lgOptTemp = false; 
     209        optimize.lgOptimize = false; 
     210 
     211        /* trace flag for optimization process */ 
     212        optimize.lgTrOpt = false; 
     213 
     214        optimize.lgOptimFlow = false; 
     215        optimize.optint = 0.; 
     216        optimize.optier = 0.; 
     217#       ifdef __unix 
     218        optimize.lgParallel = true; 
     219#       else 
     220        optimize.lgParallel = false; 
     221#       endif 
     222        optimize.lgOptCont = false; 
     223 
     224        DEBUG_EXIT( "InitDefaultsPreparse()" ); 
    194225        return; 
    195226} 
  • trunk/source/mole_h2.cpp

    r1176 r1178  
    38933893         * cancel out.  Some dense cosmic ray heated clouds could not find correct 
    38943894         * initial solution due to noise introduced by large net heating which was 
    3895          * the very noisy tiny difference betweeen very large heating and cooling 
     3895         * the very noisy tiny difference between very large heating and cooling 
    38963896         * terms.  Do not include collisions with x as heat/cool during the 
    38973897         * initial search phase */ 
     
    39053905 
    39063906/*cdH2_colden return column density in H2, negative -1 if cannot find state, 
    3907  * header is cddrive */ 
     3907 * header is cdDrive */ 
    39083908double cdH2_colden( long iVib , long iRot ) 
    39093909{ 
  • trunk/source/optimize.h

    r873 r1178  
    141141        FILE *ioOptim; 
    142142        float OptGlobalErr; 
     143 
     144        /* counter for number of models in a grid - is one (not zero) for  
     145         * first simulation */ 
    143146        long int nOptimiz; 
     147 
    144148        bool lgOptimFlow; 
    145149        float optint,  
    146150          optier; 
    147151        long int nTrOpt; 
    148         bool lgTrOpt,  
     152        bool lgTrOpt; 
     153        bool lgOptimize,  
     154          /** these flags say we are optimizing on line intensity, luminosity, 
     155           * column density, or temperature */ 
    149156          lgOptLin,  
    150157          lgOptLum,  
  • trunk/source/optimize_func.cpp

    r1149 r1178  
    99#include "radius.h" 
    1010#include "input.h" 
     11#include "warnings.h" 
    1112#include "cloudy.h" 
    1213#include "cddrive.h" 
     
    6162 
    6263        DEBUG_ENTRY( "optimize_func()" ); 
    63         /* limpar defined in optimize.h */ 
    6464 
    6565        /* This routine is called by optimizer with values of the 
     
    7474         */ 
    7575 
    76         /* initialize the code for this run */ 
    77         /*cdInit();*/ 
    7876        /* zero out lots of variables */ 
    7977        zero(); 
    80  
    81         /* CO_Init() */ 
    82         /* can't call this here, get zero malloc, this happens when Cloudy is called below anyway. */ 
    83         /* CO_zero(); */ 
    8478         
    8579        if( optimize.lgOptimFlow ) 
     
    9892        } 
    9993 
    100         /* allways increment nOptimiz, even if parameters are out of bounds, 
     94        /* always increment nOptimiz, even if parameters are out of bounds, 
    10195         * this prevents optimizer to get stuck in infinite loop */ 
    10296        ++optimize.nOptimiz; 
    10397 
    104         /* call routine to pack /kardsv/ variable with appropriate 
     98        /* call routine to pack variables with appropriate 
    10599         * CLOUDY input lines given the array of variable parameters p(i) */ 
    106100        vary_input(&lgLimOK); 
     
    129123        if( lgBAD ) 
    130124        { 
    131                 fprintf( ioQQQ, " Cloudy returned error condition - what happened?\n" ); 
     125                fprintf( ioQQQ, "PROBLEM Cloudy returned error condition - what happened?\n" ); 
    132126        } 
    133127 
  • trunk/source/parse_optimize.cpp

    r873 r1178  
    11/* This file is part of Cloudy and is copyright (C)1978-2007 by Gary J. Ferland 
    22 * For conditions of distribution and use see copyright notice in license.txt */ 
    3 /*ParseOptimize parse the optimize command line */ 
     3/*ParseOptimize parse the optimize and grid command lines */ 
    44/*GetOptColDen read observed column densities & errors for optimizer */ 
    55/*GetOptLineInt parse observed line intensities for optimization routines */ 
     
    2525static void GetOptTemp(char *chCard ); 
    2626 
     27/* ParseOptimize - called from ParseCommands if GRID or OPTIMIZE command found */ 
    2728void ParseOptimize( 
    2829        /* command line, which was changed to all caps in main parsing routine */ 
     
    4849                         * original version of command line, which preserves case of 
    4950                         * characters.  Also removes string between quotes */ 
    50                         GetQuote( chOptimFileName , chCard , true ); 
     51                        if( GetQuote( chOptimFileName , chCard , true ) ) 
     52                                /* this can't happen since GetQuote exits if quote not 
     53                                 * found, since true sets abort mode */ 
     54                                TotalInsanity(); 
    5155 
    5256                        /* open the file */ 
     
    5862                        } 
    5963                } 
    60  
    61         } 
    62         /*>>chng 07 feb 08m rm optimize optimize_amoeba due to Robin & Peter license 
    63         * concerns - R837 */ 
     64        } 
    6465 
    6566        else if( nMatch("COLU",chCard) ) 
     
    6768                /* optimize column density */ 
    6869                optimize.lgOptCol = true; 
     70                optimize.lgOptimize = true; 
    6971 
    7072                /* read column densities to match */ 
     
    7678                /* set flag saying that optimization should start from continue file */ 
    7779                optimize.lgOptCont = true; 
     80                optimize.lgOptimize = true; 
    7881        } 
    7982 
     
    98101                optimize.optier = (float)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 
    99102                if( lgEOL ) 
    100                 { 
    101103                        optimize.optier = DEFERR; 
    102                 } 
    103104 
    104105                /* set flag to say that intensity or luminosity of line set */ 
    105106                optimize.lgOptLum = true; 
     107                optimize.lgOptimize = true; 
    106108        } 
    107109 
     
    120122                /* set flag saying that something has been set */ 
    121123                optimize.lgOptLin = true; 
     124                optimize.lgOptimize = true; 
    122125        } 
    123126 
     
    200203                /* set flag saying that optimize temps has been set */ 
    201204                optimize.lgOptTemp = true; 
     205                optimize.lgOptimize = true; 
    202206        } 
    203207 
  • trunk/source/parse_set.cpp

    r1099 r1178  
    15951595                        * null terminated string to chDataPath 
    15961596                        * also sets name in OrgCard and chCard to blanks so that 
    1597                         * do not trigger off it later  
    1598                         GetQuote( chTmpHashString , chCard , true );*/ 
     1597                        * do not trigger off it later */ 
    15991598                        if( strcmp( chString_quotes_lowercase , "return" ) == 0 ) 
    16001599                        { 
     
    16631662                        * null terminated string to chDataPath 
    16641663                        * also sets name in OrgCard and chCard to blanks so that 
    1665                         * do not trigger off it later  
     1664                        * do not trigger off it later */ 
    16661665                         
    1667                         GetQuote( punch.chFilenamePrefix , chCard , true );*/ 
    16681666                        strcpy( punch.chFilenamePrefix , chString_quotes_lowercase ); 
    16691667                } 
  • trunk/source/parse_stop.cpp

    r1147 r1178  
    4141                if( lgEOL && nMatch(" OFF",chCard) ) 
    4242                { 
    43                         /* this is ending temperature */ 
     43                        /* this is special case for ending temperature - do not use - 
     44                         * but will still stop if Te falls below TeLowest, the lowest 
     45                         * possible temperature */ 
    4446                        StopCalc.tend = -1.f; 
    45                         /* >>chng 05 aug 15, do not reset StopCalc.TeLowest since this is lowest 
    46                          * possible temperature code can handle, set to 2.7 K */ 
    47                         /*StopCalc.TeLowest = -1.f;*/ 
    4847                } 
    4948                else 
     
    7675                        else 
    7776                        { 
    78                                 /* this is ending temperature */ 
     77                                /* this is ending temperature - we stop if kinetic temperature 
     78                                 * falls below this */ 
    7979                                StopCalc.tend = (float)tread; 
    80                                 /* >>chng 05 aug 15, do not set TeLowest - this is lower temp bound, 
    81                                  * set to 2.7K - cannot go below this */ 
    82                                 /*StopCalc.TeLowest = (float)MIN2(StopCalc.TeLowest,StopCalc.tend);*/ 
    8380                        } 
    8481                } 
  • trunk/source/punch_do.cpp

    r1159 r1178  
    15491549                        else if( strcmp(punch.chPunch[ipPun],"GRID") == 0 ) 
    15501550                        { 
     1551                                /* one time punch of all grid parameters after grid is complete */ 
    15511552                                if( (strcmp(chTime,"LAST") == 0 ) && grid.lgGridDone ) 
    15521553                                { 
     
    15541555                                         * As in "PARAM1 is HDEN"? */ 
    15551556                                        /* print first parameter outside of loop, so that tabs are right. */     
    1556                                         fprintf(punch.ipPnunit[ipPun], "PARAM1" ); 
    1557                                         for( i=2; i<= grid.nintparm; i++ ) 
     1557                                        fprintf(punch.ipPnunit[ipPun], "Abort?\tnWarnings" ); 
     1558                                        for( i=1; i<= grid.nintparm; i++ ) 
    15581559                                        { 
    15591560                                                fprintf(punch.ipPnunit[ipPun], "\tPARAM%li", i ); 
     
    15621563                                        for( i=0; i<grid.totNumModels; i++ ) 
    15631564                                        { 
     1565                                                fprintf(punch.ipPnunit[ipPun], "%c\t%li\t", 
     1566                                                        TorF(grid.lgAbort[i]) , grid.nWarn[i] ); 
    15641567                                                for( j=0; j< grid.nintparm; j++ ) 
    15651568                                                {