Show
Ignore:
Timestamp:
02/16/08 10:57:45 (9 months ago)
Author:
rjrw
Message:

Merged from trunk r1779:1799.

Location:
branches/newmole/source
Files:
1 removed
53 modified

Legend:

Unmodified
Added
Removed
  • branches/newmole/source/cddefines.h

    r1780 r1800  
    445445}; 
    446446 
    447 #define cdEXIT( FAIL ) throw cloudy_exit( DEBUG_ENTRY.name(), __FILE__, __LINE__, FAIL ) 
     447// workarounds for __func__ are defined in cpu.h 
     448#define cdEXIT( FAIL ) throw cloudy_exit( __func__, __FILE__, __LINE__, FAIL ) 
    448449 
    449450// calls like puts( "[Stop in MyRoutine]" ) have been integrated in cdEXIT above 
     
    580581                return p_line; 
    581582        } 
     583}; 
     584 
     585class bad_mpi { 
     586        long p_failMode; 
     587public: 
     588        bad_mpi(long failMode) : p_failMode(failMode) {} 
     589        long failMode() const { return p_failMode; } 
    582590}; 
    583591 
     
    599607                                { \ 
    600608                                        if( cpu.lgAssertAbort() ) \ 
    601                                                 raise( SIGABRT ); \ 
     609                                                abort();          \ 
    602610                                        else \ 
    603611                                                throw bad_assert(__FILE__,__LINE__); \ 
     
    609617#endif 
    610618 
     619NORETURN inline void OUT_OF_RANGE(const char* str) 
     620{ 
     621        if( cpu.lgAssertAbort() ) 
     622                abort(); 
     623        else 
     624                throw out_of_range( str ); 
     625} 
     626 
    611627/* Windows does not define isnan */ 
    612628/* use our version on all platforms since the isnanf 
     
    673689 
    674690#ifdef DEBUG_FUN 
    675 typedef debugtrace<true> debuginfo; 
     691#define DEBUG_ENTRY( funcname ) debugtrace<true> DEBUG_ENTRY( funcname ) 
    676692#else 
    677 typedef debugtrace<false> debuginfo; 
    678 #endif 
    679  
    680 #define DEBUG_ENTRY( funcname ) debuginfo DEBUG_ENTRY( funcname ) 
     693#ifdef __GNUC__ 
     694#define DEBUG_ENTRY( funcname ) ((void)0) 
     695#else 
     696#define DEBUG_ENTRY( funcname ) debugtrace<false> DEBUG_ENTRY( funcname ) 
     697#endif 
     698#endif 
    681699 
    682700/* TorF(l) returns a 'T' or 'F' depending on the 'logical' expr 'l' */ 
  • branches/newmole/source/cddrive.cpp

    r1780 r1800  
    128128                if( trace.lgTrace ) 
    129129                        fprintf( ioQQQ, "cdDrive: calling cloudy\n"); 
    130                 /* optimize did not occur, only compute one model, call cloudy */ 
    131                 lgBAD = cloudy(); 
     130                try { 
     131 
     132                        /* optimize did not occur, only compute one model, call cloudy */ 
     133                        lgBAD = cloudy(); 
     134                } 
     135                catch( bad_mpi &bad_info ) 
     136                { 
     137                        fprintf( ioQQQ, "An MPI run failed.  The fail mode is %li\n", bad_info.failMode() ); 
     138                        ClosePunchFiles( false ); 
     139                        lgAbort = true; 
     140                        lgBAD = true; 
     141                } 
    132142        } 
    133143 
  • branches/newmole/source/cdinit.cpp

    r1780 r1800  
    8282#include "mewecoef.h" 
    8383#include "mole.h"  
    84 #include "neutrn.h" 
    8584#include "nitro.h" 
    8685#include "noexec.h" 
     
    251250                fprintf(ioQQQ," cdExit called\n"); 
    252251 
    253         /* close any open units */ 
    254         ClosePunchFiles( true ); 
    255  
    256         /* this routine must be called upon exit or machine will appear to "hang", 
    257          * but must not be called on MPI machine when used in serial mode, 
    258          * or it will drop core */ 
     252        /* if doing an MPI run, just throw an exception 
     253         * so that cddrive can report the problem and continue 
     254         * computing other grid points */ 
    259255        if( lgMPI ) 
    260256        { 
    261 #               ifdef MPI_ENABLED 
    262                 MPI_Finalize(); 
    263 #               endif 
    264         } 
    265         exit( iexit ); 
     257                throw bad_mpi(-1); 
     258        } 
     259        else 
     260        { 
     261                /* close any open units */ 
     262                ClosePunchFiles( true ); 
     263                exit( iexit ); 
     264        } 
    266265} 
    267266 
  • branches/newmole/source/container_classes.h

    r1780 r1800  
    5757                { 
    5858                        if( t < p_p[1] || t >= p_p[2] ) 
    59                                 throw out_of_range( "basic_pntr::p_index_checked()" ); 
     59                                OUT_OF_RANGE( "basic_pntr::p_index_checked()" ); 
    6060                } 
    6161                return t; 
     
    627627        { 
    628628                if( i >= v->n ) 
    629                         throw out_of_range( "n_pointer::n_pointer()" ); 
     629                        OUT_OF_RANGE( "n_pointer::n_pointer()" ); 
    630630                p_p = *((T**)p + i); 
    631631                p_v = &v->d[i];          
     
    647647        { 
    648648                if( i >= v->n ) 
    649                         throw out_of_range( "n_pointer::n_pointer()" ); 
     649                        OUT_OF_RANGE( "n_pointer::n_pointer()" ); 
    650650                p_p = p + i*st[d-N]; 
    651651                p_v = &v->d[i]; 
     
    667667        { 
    668668                if( i >= v->n ) 
    669                         throw out_of_range( "n_pointer::n_pointer()" ); 
     669                        OUT_OF_RANGE( "n_pointer::n_pointer()" ); 
    670670                p_p = *((T**)p + i); 
    671671                p_v = &v->d[i]; 
     
    674674        { 
    675675                if( i >= p_v->n ) 
    676                         throw out_of_range( "n_pointer::operator[]" ); 
     676                        OUT_OF_RANGE( "n_pointer::operator[]" ); 
    677677                return *(p_p + i); 
    678678        } 
     
    689689        { 
    690690                if( i >= v->n ) 
    691                         throw out_of_range( "n_pointer::n_pointer()" ); 
     691                        OUT_OF_RANGE( "n_pointer::n_pointer()" ); 
    692692                p_p = p + i*st[d-1]; 
    693693                p_v = &v->d[i]; 
     
    696696        { 
    697697                if( i >= p_v->n ) 
    698                         throw out_of_range( "n_pointer::operator[]" ); 
     698                        OUT_OF_RANGE( "n_pointer::operator[]" ); 
    699699                return *(p_p + i); 
    700700        } 
     
    779779        { 
    780780                if( i >= v->n ) 
    781                         throw out_of_range( "const_n_pointer::const_n_pointer()" ); 
     781                        OUT_OF_RANGE( "const_n_pointer::const_n_pointer()" ); 
    782782                p_p = *((const T**)p + i); 
    783783                p_v = &v->d[i];          
     
    799799        { 
    800800                if( i >= v->n ) 
    801                         throw out_of_range( "const_n_pointer::const_n_pointer()" ); 
     801                        OUT_OF_RANGE( "const_n_pointer::const_n_pointer()" ); 
    802802                p_p = p + i*st[d-N]; 
    803803                p_v = &v->d[i]; 
     
    819819        { 
    820820                if( i >= v->n ) 
    821                         throw out_of_range( "const_n_pointer::const_n_pointer()" ); 
     821                        OUT_OF_RANGE( "const_n_pointer::const_n_pointer()" ); 
    822822                p_p = *((const T**)p + i); 
    823823                p_v = &v->d[i]; 
     
    826826        { 
    827827                if( i >= p_v->n ) 
    828                         throw out_of_range( "const_n_pointer::operator[]" ); 
     828                        OUT_OF_RANGE( "const_n_pointer::operator[]" ); 
    829829                return *(p_p + i); 
    830830        } 
     
    841841        { 
    842842                if( i >= v->n ) 
    843                         throw out_of_range( "const_n_pointer::const_n_pointer()" ); 
     843                        OUT_OF_RANGE( "const_n_pointer::const_n_pointer()" ); 
    844844                p_p = p + i*st[d-1]; 
    845845                p_v = &v->d[i]; 
     
    848848        { 
    849849                if( i >= p_v->n ) 
    850                         throw out_of_range( "const_n_pointer::operator[]" ); 
     850                        OUT_OF_RANGE( "const_n_pointer::operator[]" ); 
    851851                return *(p_p + i); 
    852852        } 
     
    11961196                        multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this); 
    11971197                        size_type n = p_g.v.getvec( 1, index ).n; 
    1198                         T* s = &(*t)[i1][0]; 
     1198                        T* s = ( n > 0 ) ? &(*t)[i1][0] : NULL; 
    11991199                        if( i2 == npos ) 
    12001200                                return iterator( s+n, s, s+n ); 
     
    12031203                } 
    12041204                else 
    1205                         throw out_of_range( "multi_arr::p_iterator()" ); 
     1205                        OUT_OF_RANGE( "multi_arr::p_iterator()" ); 
    12061206        } 
    12071207        iterator p_iterator(size_type i1, size_type i2, size_type i3) const 
     
    12261226                        multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this); 
    12271227                        size_type n = p_g.v.getvec( 2, index ).n; 
    1228                         T* s = &(*t)[i1][i2][0]; 
     1228                        T* s = ( n > 0 ) ? &(*t)[i1][i2][0] : NULL; 
    12291229                        if( i3 == npos ) 
    12301230                                return iterator( s+n, s, s+n ); 
     
    12331233                } 
    12341234                else 
    1235                         throw out_of_range( "multi_arr::p_iterator()" ); 
     1235                        OUT_OF_RANGE( "multi_arr::p_iterator()" ); 
    12361236        } 
    12371237        iterator p_iterator(size_type i1, size_type i2, size_type i3, size_type i4) const 
     
    12561256                        multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this); 
    12571257                        size_type n = p_g.v.getvec( 3, index ).n; 
    1258                         T* s = &(*t)[i1][i2][i3][0]; 
     1258                        T* s = ( n > 0 ) ? &(*t)[i1][i2][i3][0] : NULL; 
    12591259                        if( i4 == npos ) 
    12601260                                return iterator( s+n, s, s+n ); 
     
    12631263                } 
    12641264                else 
    1265                         throw out_of_range( "multi_arr::p_iterator()" ); 
     1265                        OUT_OF_RANGE( "multi_arr::p_iterator()" ); 
    12661266        } 
    12671267        iterator p_iterator(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5) const 
     
    12861286                        multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this); 
    12871287                        size_type n = p_g.v.getvec( 4, index ).n; 
    1288                         T* s = &(*t)[i1][i2][i3][i4][0]; 
     1288                        T* s = ( n > 0 ) ? &(*t)[i1][i2][i3][i4][0] : NULL; 
    12891289                        if( i5 == npos ) 
    12901290                                return iterator( s+n, s, s+n ); 
     
    12931293                } 
    12941294                else 
    1295                         throw out_of_range( "multi_arr::p_iterator()" ); 
     1295                        OUT_OF_RANGE( "multi_arr::p_iterator()" ); 
    12961296        } 
    12971297        iterator p_iterator(size_type i1, size_type i2, size_type i3, size_type i4, size_type i5, size_type i6) const 
     
    13161316                        multi_arr<T,d,ALLOC,lgBC>* t = const_cast<multi_arr<T,d,ALLOC,lgBC>*>(this); 
    13171317                        size_type n = p_g.v.getvec( 5, index ).n; 
    1318                         T* s = &(*t)[i1][i2][i3][i4][i5][0]; 
     1318                        T* s = ( n > 0 ) ? &(*t)[i1][i2][i3][i4][i5][0] : NULL; 
    13191319                        if( i6 == npos ) 
    13201320                                return iterator( s+n, s, s+n ); 
     
    13231323                } 
    13241324                else 
    1325                         throw out_of_range( "multi_arr::p_iterator()" ); 
     1325                        OUT_OF_RANGE( "multi_arr::p_iterator()" ); 
    13261326        } 
    13271327 
     
    13401340                size_type index[] = { i1, i2 }; 
    13411341                if( !p_g.lgInbounds( 2, index ) ) 
    1342                         throw out_of_range( "multi_arr::at()" ); 
     1342                        OUT_OF_RANGE( "multi_arr::at()" ); 
    13431343                return (*this)[i1][i2]; 
    13441344        } 
     
    13471347                size_type index[] = { i1, i2 }; 
    13481348                if( !p_g.lgInbounds( 2, index ) ) 
    1349                         throw out_of_range( "multi_arr::at()" ); 
     1349                        OUT_OF_RANGE( "multi_arr::at()" ); 
    13501350                return (*this)[i1][i2]; 
    13511351        } 
     
    13541354                size_type index[] = { i1, i2, i3 }; 
    13551355                if( !p_g.lgInbounds( 3, index ) ) 
    1356                         throw out_of_range( "multi_arr::at()" ); 
     1356                        OUT_OF_RANGE( "multi_arr::at()" ); 
    13571357                return (*this)[i1][i2][i3]; 
    13581358        } 
     
    13611361                size_type index[] = { i1, i2, i3 }; 
    13621362                if( !p_g.lgInbounds( 3, index ) ) 
    1363                         throw out_of_range( "multi_arr::at()" ); 
     1363                        OUT_OF_RANGE( "multi_arr::at()" ); 
    13641364                return (*this)[i1][i2][i3]; 
    13651365        } 
     
    13681368                size_type index[] = { i1, i2, i3, i4 }; 
    13691369                if( !p_g.lgInbounds( 4, index ) ) 
    1370                         throw out_of_range( "multi_arr::at()" ); 
     1370                        OUT_OF_RANGE( "multi_arr::at()" ); 
    13711371                return (*this)[i1][i2][i3][i4]; 
    13721372        } 
     
    13751375                size_type index[] = { i1, i2, i3, i4 }; 
    13761376                if( !p_g.lgInbounds( 4, index ) ) 
    1377                         throw out_of_range( "multi_arr::at()" ); 
     1377                        OUT_OF_RANGE( "multi_arr::at()" ); 
    13781378                return (*this)[i1][i2][i3][i4]; 
    13791379        } 
     
    13821382                size_type index[] = { i1, i2, i3, i4, i5 }; 
    13831383                if( !p_g.lgInbounds( 5, index ) ) 
    1384                         throw out_of_range( "multi_arr::at()" ); 
     1384                        OUT_OF_RANGE( "multi_arr::at()" ); 
    13851385                return (*this)[i1][i2][i3][i4][i5]; 
    13861386        } 
     
    13891389                size_type index[] = { i1, i2, i3, i4, i5 }; 
    13901390                if( !p_g.lgInbounds( 5, index ) ) 
    1391                         throw out_of_range( "multi_arr::at()" ); 
     1391                        OUT_OF_RANGE( "multi_arr::at()" ); 
    13921392                return (*this)[i1][i2][i3][i4][i5]; 
    13931393        } 
     
    13961396                size_type index[] = { i1, i2, i3, i4, i5, i6 }; 
    13971397                if( !p_g.lgInbounds( 6, index ) ) 
    1398                         throw out_of_range( "multi_arr::at()" ); 
     1398                        OUT_OF_RANGE( "multi_arr::at()" ); 
    13991399                return (*this)[i1][i2][i3][i4][i5][i6]; 
    14001400        } 
     
    14031403                size_type index[] = { i1, i2, i3, i4, i5, i6 }; 
    14041404                if( !p_g.lgInbounds( 6, index ) ) 
    1405                         throw out_of_range( "multi_arr::at()" ); 
     1405                        OUT_OF_RANGE( "multi_arr::at()" ); 
    14061406                return (*this)[i1][i2][i3][i4][i5][i6]; 
    14071407        } 
     
    19701970                { 
    19711971                        if( ! p_lgInbounds( i ) ) 
    1972                                 throw out_of_range( "flex_arr::p_index()" ); 
     1972                                OUT_OF_RANGE( "flex_arr::p_index()" ); 
    19731973                } 
    19741974                return *p_pointer(i); 
     
    19881988        { 
    19891989                if( ! p_lgInbounds(i) ) 
    1990                         throw out_of_range( "flex_arr::at()" ); 
     1990                        OUT_OF_RANGE( "flex_arr::at()" ); 
    19911991                return (*this)[i]; 
    19921992        } 
     
    19941994        { 
    19951995                if( ! p_lgInbounds(i) ) 
    1996                         throw out_of_range( "flex_arr::at()" ); 
     1996                        OUT_OF_RANGE( "flex_arr::at()" ); 
    19971997                return (*this)[i]; 
    19981998        } 
  • branches/newmole/source/continuum.h

    r1780 r1800  
    8686          lgCoStarInterpolationCaution; 
    8787 
    88         /** TotalLumin is total luminosity in incident continuum */ 
     88        /** TotalLumin is total intensity in incident continuum erg cm-2 s-1 */ 
    8989        double TotalLumin,  
    9090          totlsv; 
  • branches/newmole/source/cont_createpointers.cpp

    r1780 r1800  
    985985        /* first MALLOC LIMELM dimension of space */ 
    986986        /* >>chng 02 jun 28, malloc this NISO instead of 2.     */ 
    987         iso.ipSym2nu = (long ***)MALLOC(sizeof(long **)*(unsigned)NISO ); 
    988  
    989         iso.As2nu = (realnum ***)MALLOC(sizeof(realnum **)*(unsigned)NISO ); 
     987        iso.ipSym2nu.reserve( NISO ); 
    990988 
    991989        /* now loop over the two iso-sequences with two photon continua */ 
    992990        for( ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
    993991        { 
    994                 iso.ipSym2nu[ipISO] = (long **)MALLOC(sizeof(long *)*(unsigned)LIMELM ); 
    995                 iso.As2nu[ipISO] = (realnum **)MALLOC(sizeof(realnum *)*(unsigned)LIMELM ); 
     992                iso.ipSym2nu.reserve( ipISO, LIMELM ); 
    996993 
    997994                /* set up two photon emission */ 
     
    1001998                        { 
    1002999                                double E2nu = Transitions[ipISO][nelem][TwoS][0].EnergyWN * WAVNRYD; 
    1003                                 double Aul = Transitions[ipISO][nelem][TwoS][0].Emis->Aul; 
    1004                                 double SumShapeFunction = 0., Renorm= 0.; 
    10051000 
    10061001                                /* pointer to the Lya energy */ 
     
    10171012                                } 
    10181013 
    1019                                 iso.ipSym2nu[ipISO][nelem] = (long *)MALLOC(sizeof(long)*(unsigned)iso.ipTwoPhoE[ipISO][nelem] ); 
    1020                                 iso.As2nu[ipISO][nelem] = (realnum *)MALLOC(sizeof(realnum)*(unsigned)iso.ipTwoPhoE[ipISO][nelem] ); 
     1014                                iso.ipSym2nu.reserve( ipISO, nelem, iso.ipTwoPhoE[ipISO][nelem] ); 
     1015                        } 
     1016                } 
     1017        } 
     1018 
     1019        iso.ipSym2nu.alloc(); 
     1020        iso.As2nu.alloc( iso.ipSym2nu.clone() ); 
     1021 
     1022        /* now loop over the two iso-sequences with two photon continua */ 
     1023        for( ipISO=ipH_LIKE; ipISO<NISO; ++ipISO ) 
     1024        { 
     1025                /* set up two photon emission */ 
     1026                for( nelem=ipISO; nelem<LIMELM; ++nelem ) 
     1027                { 
     1028                        if( dense.lgElmtOn[nelem] ) 
     1029                        { 
     1030                                double E2nu = Transitions[ipISO][nelem][TwoS][0].EnergyWN * WAVNRYD; 
     1031                                double Aul = Transitions[ipISO][nelem][TwoS][0].Emis->Aul; 
     1032