Skip to content

Commit 12b718f

Browse files
committed
Missing TDV file -> UNSET data -> error if probed
Warning re derived weather values when autosizing using ET1 header data
1 parent 382516c commit 12b718f

22 files changed

+311
-223
lines changed

src/ANCREC.CPP

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ basAnc::basAnc() // default c'tor (for derived copy c'tor
410410
memset( (char *)this+SZVFTP, 0, sizeof(*this)-SZVFTP); // SZVFTP: virtFcnTblPtr: cnglob.h.
411411
} // basAnc::basAnc
412412
//---------------------------------------------------------------------------------------------------------------------------
413-
basAnc::basAnc( USI _flags, SFIR * _fir, USI _nFlds, char * _what, USI _eSz, RCT _rt, USI _sOff, SI dontRegister/*=0*/ )
413+
basAnc::basAnc( int flags, SFIR * _fir, USI _nFlds, char * _what, USI _eSz, RCT _rt, USI _sOff, int dontRegister/*=0*/ )
414414
{
415415
memset( (char *)this+SZVFTP, 0, sizeof(basAnc)-SZVFTP); // zero all basAnc members but virtFcnTblPtr at front
416-
flags = _flags;
416+
ba_flags = flags;
417417
fir = _fir;
418418
nFlds =_nFlds;
419419
what = _what; // store non-0 member values
@@ -422,12 +422,13 @@ basAnc::basAnc( USI _flags, SFIR * _fir, USI _nFlds, char * _what, USI _eSz, RCT
422422
sOff = _sOff; // ..
423423
mn = 1; // min record subscript 1 (overwritten with 0 if static)
424424
// ptr() = 0; is done in derived class constructor (deriv vf not avail here; ptr is pure!)
425-
if (!dontRegister) regis(); // conditionally include anchor for nextAnc() iteration
425+
if (!dontRegister)
426+
regis(); // conditionally include anchor for nextAnc() iteration
426427
} // basAnc::basAnc
427428
//--------------------------------------------------------------------------------------------------------------
428429
/*virtual*/ basAnc::~basAnc() // d'tor
429430
{
430-
if (flags & RFTYS)
431+
if (ba_flags & RFTYS)
431432
dmfree( DMPP( what));
432433
} // basAnc::~basAnc
433434
//---------------------------------------------------------------------------------------------------------------------------
@@ -530,7 +531,7 @@ x (char /*far!*/ *)what ); // returns RCBAD
530531
{
531532
nAl = _nAl; // save max alloc'd subscript+1.
532533
mn = 1; // insurance: mn is already 1.
533-
flags |= RFHEAP; // say block is in heap, should be free'd
534+
ba_flags |= RFHEAP; // say block is in heap, should be free'd
534535
// the n record spaces are subscripted 1 to n. The spaces are not "records" till constructed by add().
535536
// allocated but unused space[0] "grounds" unset references and allows using 0 subscript as "unset" indicator.
536537
// set front members in block's space[0] now, as req'd by validate's check when ptr nz.
@@ -539,12 +540,12 @@ x (char /*far!*/ *)what ); // returns RCBAD
539540
ptr()->rt = rt; // ... (rec(0) is not add'd, and anyway validate error would foil add.)
540541
ptr()->b = (BP)this; // .ss is already 0. .gud is left 0.
541542
}
542-
#if 1 // 9-10
543+
543544
// loop all pre-reAl gud records
544545
for (int i=mn; i<=n ; i++)
545546
if (rec( i).gud)
546547
rec( i).FixUp(); // virtual, allow record to fix e.g. link ptrs
547-
#endif
548+
548549
}
549550
return rc;
550551
} // basAnc::reAl
@@ -554,9 +555,9 @@ RC FC basAnc::free() // free (non-static) record memory block for anchor
554555
desRecs(); // destroy any records: calls record-derived class virtual d'tor
555556
n = nAl = 0;
556557
mn = 1; // minimum subscript 1 to be > n; also 1 expected by reAl/add.
557-
if (flags & RFHEAP) // do not free non-heap (static) block
558+
if (ba_flags & RFHEAP) // do not free non-heap (static) block
558559
dmfree( pptr()); // free memory block and set ptr() null
559-
flags &= ~RFHEAP; // clear all flags but non-heap flag
560+
ba_flags &= ~RFHEAP; // clear all flags but non-heap flag
560561
return RCOK;
561562
} // basAnc::free
562563
//---------------------------------------------------------------------------------------------------------------------------
@@ -634,11 +635,11 @@ void basAnc::statSetup( // init anchor with given non-expandable static record
634635
// initialize run-time anc members. eSz and rt are init by constructor.
635636
setPtr( &r);
636637
if (inHeap)
637-
flags |= RFHEAP;
638+
ba_flags |= RFHEAP;
638639
else
639-
flags &= ~RFHEAP; // inHeap arg to flags bit
640-
flags |= RFSTAT; // disable realloc and var data
641-
mn = 0; // minimum subscript is 0 for static (to save space: 1 large record is typical)
640+
ba_flags &= ~RFHEAP; // inHeap arg to flags bit
641+
ba_flags |= RFSTAT; // disable realloc and var data
642+
mn = 0; // minimum subscript is 0 for static (to save space: 1 large record is typical)
642643
nAl = _n;
643644
n = _n - 1;
644645
for (TI i = mn; i <= n; i++)
@@ -701,7 +702,7 @@ RC basAnc::validate( // validate an anchor: check self-consistency of anchor and
701702
|| !(rt & RTBRAT) ) // or base rt not a RAT rt
702703
return err( erOp, (char *)MH_X0055, fcnName); // errMsg "%s() argument not a valid anchor" & abort or return per erOp. rmkerr.cpp.
703704

704-
if (noStat && (flags & RFSTAT) ) // check staticness
705+
if (noStat && (ba_flags & RFSTAT) ) // check staticness
705706
return err( erOp, (char *)MH_X0056, fcnName); // "%s(): illegal use of static-storage anchor"
706707

707708
return RCOK; // if here, all OK

src/ANCREC.H

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ typedef basAnc* BP; // basAnc pointer -- formerly used to localize NEARness
5454
//--- bits for basAnc.flags
5555
#define RFSTAT 0x4000 // "static" record basAnc: not reallocable, min subscr 0 not 1. set ancrec.cpp, tested ancrec,cul,cuprobe.cpp.
5656
#define RFTYS 0x1000 // is in TYPES sub-basAnc (pted to by a basAnc.tys)
57-
#define RFNOEX 0x0800 // don't register exprs in records in this basAnc: appl (e.g. ul\cul.cpp) to ul\exman.cpp:exWalkRecs()
58-
#define RFINP 0x0400 // is an input (not run) records basAnc: ul\cul.cpp to ul\cuparse.cpp:probe. 12-91.
57+
#define RFNOEX 0x0800 // don't register exprs in records in this basAnc: appl (e.g. cul.cpp) to exman.cpp:exWalkRecs()
58+
#define RFINP 0x0400 // is an input (not run) records basAnc: cul.cpp to cuparse.cpp:probe. 12-91.
5959
#define RFPROBED 0x0200 // set if basAnc has been 'probed': do not free (input) basAnc b4 run. cuparse.cpp:probe to cul.cpp:finalClear.
6060
#define RFLOCAL 0x0100 // flag for private local uses 1-92. used in: cuprobe.cpp:showProbeNames, .
6161
#define RFHEAP 0x0080 // set if block is in heap, else don't dmfree. 5-92.
@@ -80,32 +80,32 @@ class basAnc // base class for record anchors: basAnc<recordName>
8080
TI mn, n; // minimum (0 or 1) and max NOT+1 used record subscript (spaces unused if .gud==0)
8181
inline int GetSSRange() const { return n-mn+1; } // count INCLUDING UNUSED
8282
inline int GetSS0() const { return mn; } // subscript of 0th entry
83-
USI flags; // bits, RFxxxx defines above -- also set by user
83+
int ba_flags; // bits, RFxxxx defines above -- also set by user
8484
// members setable by application user language (cul.cpp)
8585
BP tyB; // 0 or ptr to user language TYPES anchor in heap (destructor deletes)
8686
BP ownB; // 0 or ptr to anchor whose objects own this anchor's objects (record.ownTi)
8787
const CULT* an_pCULT; // NULL or associated CULT input table for records of this type
8888
// simplifies back translation of input names
8989

9090
basAnc();
91-
basAnc( USI flags, SFIR * fir, USI nFlds, char * what, USI eSz, RCT rt, USI sOff, SI dontRegister=0 );
91+
basAnc( int flags, SFIR * fir, USI nFlds, char * what, USI eSz, RCT rt, USI sOff, int dontRegister=0 );
9292
void FC regis();
9393
virtual ~basAnc(); // destroyed in deriv classes, to use vf
9494
virtual record* ptr() = 0; // access block ptr (in drv class: typed)
9595
virtual void** pptr() = 0;
9696
virtual void setPtr( record* r) = 0;
9797
virtual record& rec(TI i) = 0; // { return (record)((char *)ptr() + i*eSz); } // access record i
98-
virtual record* GetAtSafe( int i) const = 0; // typed pointer to ith record or NULL
99-
virtual void* recMbr(TI i, USI off) = 0; // point record i member by offset
100-
void * FC recFld(TI i, SI fn); // point record i member by FIELD # 3-92
101-
RC FC al( TI n, int erOp=ABT, BP _ownB=NULL); // allocate records block. destroys old recs.
102-
RC FC reAl( TI n, int erOp=ABT); // (re)allocate records block. keeps old recs <= n.
103-
RC FC free(); // free block
104-
RC add( record **r, int erOp, TI i=0); // add record to block
105-
RC FC del( TI i, int erOp=ABT); // delete record i
106-
void statSetup( record &r, TI n=1, SI noZ=0, SI inHeap=0); // set up with static record(s)
107-
SI FC isNamed() const { return flags & RFNAMED; } // records have .name[]: always on, coding out 7-92
108-
static BP FC anc4n( USI an, int erOp=ABT); // access anchor by anchor #
98+
virtual record* GetAtSafe( int i) const = 0; // typed pointer to ith record or NULL
99+
virtual void* recMbr(TI i, USI off) = 0; // point record i member by offset
100+
void * FC recFld(TI i, SI fn); // point record i member by FIELD # 3-92
101+
RC FC al( TI n, int erOp=ABT, BP _ownB=NULL); // allocate records block. destroys old recs.
102+
RC FC reAl( TI n, int erOp=ABT); // (re)allocate records block. keeps old recs <= n.
103+
RC FC free(); // free block
104+
RC add( record **r, int erOp, TI i=0); // add record to block
105+
RC FC del( TI i, int erOp=ABT); // delete record i
106+
void statSetup( record &r, TI n=1, SI noZ=0, SI inHeap=0); // set up with static record(s)
107+
int isNamed() const { return ba_flags & RFNAMED; } // records have .name[]: always on, coding out 7-92
108+
static BP FC anc4n( USI an, int erOp=ABT); // access anchor by anchor #
109109
static RC FC findAnchorByNm( char *what, BP *b);
110110
static SI FC ancNext( USI &an, BP *_b); // iterate anchors
111111
RC validate( char *fcnName, int erOp=ABT, SI noStat=0); // check for valid anchor
@@ -261,11 +261,11 @@ class record // base class for records
261261

262262
template <class T> class anc : public basAnc
263263
{ public:
264-
anc( char *what, SFIR *sFir, USI nFlds, RCT rt) // cpp'tor used for static instances
264+
anc( char *what, SFIR *sFir, USI nFlds, RCT rt) // cpp'tor used for static instances
265265
: basAnc( RFNAMED|RFOWNED, sFir, nFlds, what, sizeof(T), rt, offsetof( T, sstat) )
266266
{ p = 0; } // soon code out obsolete flags RFNAMED, RFOWNED.
267-
anc( const BP src, USI _flags, char *_what, // like-another constructor,
268-
BP _ownB, SI dontRegister=0 ); // code included only ifdef NEEDLIKECTOR.
267+
anc( const BP src, int flags, char *_what, // like-another constructor,
268+
BP _ownB, int dontRegister=0 ); // code included only ifdef NEEDLIKECTOR.
269269
virtual ~anc(); // destroys records, and types anchor & its recs.
270270

271271
T* p; // typed pointer to record array storage block
@@ -326,7 +326,7 @@ template <class T> class anc : public basAnc
326326
//=============================================================================
327327
#ifdef NEEDLIKECTOR // define where this constructor is USED: avoids generating for classes where not used.
328328

329-
template <class T> anc<T>::anc( const BP src, USI _flags, char *_what, BP _ownB, SI dontRegister/*=0*/)
329+
template <class T> anc<T>::anc( const BP src, int flags, char *_what, BP _ownB, int dontRegister/*=0*/)
330330

331331
// like-another-with-records-deleted constructor.
332332

@@ -337,10 +337,11 @@ template <class T> anc<T>::anc( const BP src, USI _flags, char *_what, BP _ownB,
337337
memcpy( this, src, sizeof(anc<T>) ); // bitwise copy ALL, to incude virt fcn table ptr.
338338
ancN= nAl= n= 0; p= 0; tyB= 0; // clear what don't want: anchor #, records, ul stuff.
339339
mn = 1; // mn = 1 when no records allocated even if will be static
340-
flags = _flags; what = _what; ownB = _ownB; // store members given by caller
341-
if (!dontRegister) regis(); // conditionally include in nextAnc iteration.
342-
/* CAUTION: don't regis() tyB's or any dm anc<T>'s without
343-
adding unregister logic to destructor, 10-93. */
340+
ba_flags = flags; what = _what; ownB = _ownB; // store members given by caller
341+
if (!dontRegister)
342+
regis(); // conditionally include in nextAnc iteration.
343+
// CAUTION: don't regis() tyB's or any dm anc<T>'s without
344+
// adding unregister logic to destructor, 10-93.
344345
} // anc<T>::anc
345346
#endif // NEEDLIKECTOR
346347
//-------------------------------------------------------------------------------------------------------------------------

src/CNAH2.CPP

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,7 @@ RC AH::setMode() // set ahMode per ts sp control method and supply fan schedule
22282228
return RCOK;
22292229
} // AH::setMode
22302230
//-----------------------------------------------------------------------------------------------------------------------------
2231-
/* Notes re AH ZN and ZN2 supply temp control methods, Rob 5-95. Also at start of ul\cncult5.cpp and app\cnah1.cpp.
2231+
/* Notes re AH ZN and ZN2 supply temp control methods, Rob 5-95. Also at start of cncult5.cpp and app\cnah1.cpp.
22322232
*
22332233
* 1. ZN and ZN2 are needed to simulate single zone constant volume systems.
22342234
* VAV is still allowed but could be removed (says Bruce in fax 5-95) if hard-to-fix problems

src/CNCP.CPP

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// cncp.cpp -- COOLPLANTs and CHILLERs runtime code for CSE. Created 10-92.
66

7-
// related code: code used only at setup time: ul\cncult6.cpp
7+
// related code: code used only at setup time: cncult6.cpp
88
// CHW coil model: cncoil.cpp.
99
// class declarations: rccn.h, automatically generated from cnrecs.def.
1010

src/CNCULT.CPP

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
// TYREF's are supposed to be VEOI/VFAZLY, right? A lot were 0, changed to VEOI 10-9-92. cul.cpp doesn't check evf for TYREF.
1313

14-
/* used in: cnr.exe (derived from \dev\ul\hscult.cpp 8-91)
15-
formerly also \dev\ul\hstul.exe (preliminary test for above, not maintained as of 8-91. */
14+
/* used in: cnr.exe (derived from \dev\hscult.cpp 8-91)
15+
formerly also \dev\hstul.exe (preliminary test for above, not maintained as of 8-91. */
1616

1717
/* there are 3 include files for cncult,2,3,4,5,6.cpp (2-92), cuz various inclusions are required first, etc:
1818
cncult.h: use classes, globally used functions
@@ -187,6 +187,13 @@ void FC cnPreInit() // preliminary cncult.cpp initialization [needed before sho
187187
Topi can then be accessed as static structure,
188188
or via gen'l routines that work thru TopiR. lib\ancrec.cpp fcn. */
189189

190+
// say WFDATA records have no members set by via expressions
191+
// prevents exWalkRecs() from msging deliberately UNSET values
192+
// (TDV values are left UNSET if no TDV file is provided and
193+
// and are detected if used in expressions.)
194+
WthrR.ba_flags |= RFNOEX;
195+
WthrNxHrR.ba_flags |= RFNOEX;
196+
190197
// note rats are now 'registered' in cse.cpp so input and run rats can be intermixed.
191198

192199
} // cnPreInit

src/CNCULT2.CPP

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,19 +221,19 @@ LOCAL RC topCkfI( int re)
221221
bad reference or other internal error that might cause many spurious messages in later fcns
222222
out of memory (continuation proliferates errors) */
223223

224+
224225
#ifdef AUTOSIZE
225226
// 're' is TRUE on recall for run after autosize. Pass to called fcns as need found, 6-95.
226227

227228
//--- flag (run) basAncs whose records will persist from autoSizing to main sim if both are performed.
228229
// flag use: exman.cpp: retain expr use info between phases for records in these basAncs 10-95, .
229230
// list of basAncs must match: those not re-setup here if re;
230231
// those not cleared by cnguts:runFazDataFree() (use RFPERSIS there?)
231-
DvriB.flags |= RFPERSIS;
232-
RcolB.flags |= RFPERSIS;
233-
XcolB.flags |= RFPERSIS;
232+
DvriB.ba_flags |= RFPERSIS;
233+
RcolB.ba_flags |= RFPERSIS;
234+
XcolB.ba_flags |= RFPERSIS;
234235

235236
//--- first determine whether autosizing or main simulation will occur next, set $autosize, evaluate FAZLY expressions.
236-
237237
// default or check/fix chAutoSize (input "doAutoSize = YES | NO" or as changed)
238238
if (!re) // on initial call only
239239
{
@@ -246,7 +246,7 @@ LOCAL RC topCkfI( int re)
246246
{
247247
Topi.chAutoSize = C_NOYESCH_NO; // change it to no -- no autosizing will be done
248248
pWarn( "'DOAUTOSIZE = YES' will be disregarded because \n"
249-
" no 'AUTOSIZE <x>' commands found in input." ); // NUMS
249+
" no 'AUTOSIZE <x>' commands found in input." ); // NUMS
250250
}
251251
if (Topi.IsSet( TOPRAT_COOLDSDAY))
252252
// can't specify both coolDsDay and coolDsMo
@@ -541,7 +541,9 @@ RC TOPRAT::tp_Wfile( // find/check weather file / init top members with data fr
541541
if (badAuszWthr)
542542
rc |= per( "'coolDsDay' (not 'coolDsMo') is required"
543543
" when autosizing and weather file is not ET1");
544-
544+
else if (tp_AuszWthrSource()==1)
545+
warn( "Derived weather values (e.g. tGrnd and tMains) are missing when autosizing\n"
546+
" conditions are specified via 'coolDsMo' (as opposed to 'coolDsDay').");
545547
}
546548
}
547549

src/CNGLOB.H

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,11 @@ template< typename T> T& IvlData( T* ivlData, int ivl)
278278

279279
/*---------------------------- dept of NANs: unset, nandles, nchoices ---------------------------*/
280280

281-
/* a NANDLE is a 32-bit quantity that is not a valid IEEE float number nor an expected string pointer value,
282-
used to indicate unset data and to specify the "expression number" of runtime expression entered for the variable
283-
or whose value is to be stored in the variable later. More discussion in exman.h, exman.cpp.
284-
A NANDLE contains 0xFF80 in the hi word and 0 for unset or ffff for autosizing or expression number 1-16383 in the low word.
285-
CAUTION: highly system dependent. CAUTION: keep distinct from NCHOICEs (below) */
281+
// a NANDLE is a 32-bit quantity that is not a valid IEEE float number nor an expected string pointer value,
282+
// used to indicate unset data and to specify the "expression number" of runtime expression entered for the variable
283+
// or whose value is to be stored in the variable later. More discussion in exman.h, exman.cpp.
284+
// A NANDLE contains 0xFF80 in the hi word and 0 for unset or ffff for autosizing or expression number 1-16383 in the low word.
285+
// CAUTION: highly system dependent. CAUTION: keep distinct from NCHOICEs (below)
286286

287287
// type to hold a NANDLE or a datum (ptr if string)
288288
typedef void * NANDAT; // CAUTION: for fcn args use ptr (NANDAT *) to be sure C does not alter arg bit pattern.
@@ -295,13 +295,13 @@ typedef void * NANDAT; // CAUTION: for fcn args use ptr (NANDAT *) to be sure C
295295
#define ASING ((NANDAT)NANDLE(0xffff)) // may be stored in values to be determined by autosizing 6-95
296296
#define NANDLE(h) ((NANDAT)(0xff800000L + h)) // "expr n" ref for float/ptr/LI (or SI in 4 bytes). h = 1..16383.
297297

298-
/* NCHOICEs are values which can represent one of several choices and which can
299-
be stored in a float and distinguished from all numeric values. 2-92.
300-
NCHOICEs are used in CHOICN data types, definable thru rcdef.exe per input file cndtypes.def.
301-
NCHOICES are stored as IEEE NAN's (not-a-number's) in the form 0x7f80 plus the choice number 1-7f in the hi word.
302-
NCHOICES must be kept distinct from UNSET and NANDLES (hi word ff8x) (above/exman.h).
303-
CAUTION: to test a float's bit pattern, cast to a pointer then to ULI.
304-
Casting directly to ULI causes its numeric value to be converted, altering the bit pattern. */
298+
// NCHOICEs are values which can represent one of several choices and which can
299+
// be stored in a float and distinguished from all numeric values. 2-92.
300+
// NCHOICEs are used in CHOICN data types, definable thru rcdef.exe per input file cndtypes.def.
301+
// NCHOICES are stored as IEEE NAN's (not-a-number's) in the form 0x7f80 plus the choice number 1-7f in the hi word.
302+
// NCHOICES must be kept distinct from UNSET and NANDLES (hi word ff8x) (above/exman.h).
303+
// CAUTION: to test a float's bit pattern, cast to a pointer then to ULI.
304+
// Casting directly to ULI causes its numeric value to be converted, altering the bit pattern
305305

306306
#define NCNAN 0x7f80 // bits that make nchoice a nan; is combined with choice index 1-7f to form stored value
307307

@@ -609,7 +609,7 @@ inline float AVFtoAMF( float avf) { return avf * 60.f*.075f; }
609609
const int PTENSIZE = 21; // # of pwrs of 10 in Pten array
610610
const double Pten[PTENSIZE] = {1.,10.,1e2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20};
611611
const int NPTENSIZE = 21; // # of negative pwrs of 10 in NPten array
612-
const double NPten[NPTENSIZE] = {1.,.1,.01,1e-3,1e-4,1e-5,1e-6,1e-7,1e-8,1e-9,1e-10,1e-11,1e-12,1e-13,1e-14,1e-15,1e-16,1e-17,1e-18,1e-19,1e-20 }; // rob 6-92
612+
const double NPten[NPTENSIZE] = {1.,.1,.01,1e-3,1e-4,1e-5,1e-6,1e-7,1e-8,1e-9,1e-10,1e-11,1e-12,1e-13,1e-14,1e-15,1e-16,1e-17,1e-18,1e-19,1e-20 };
613613

614614
const float FHuge = float(1.E38); // Handy large (not strictly largest) value used for x/0,
615615
// search initializations, etc. Single defn for portability and code clarity.

0 commit comments

Comments
 (0)