@@ -351,6 +351,9 @@ export default class EquationGen extends ModelReader {
351351 } else if ( this . mode === 'init-lookups' ) {
352352 // In init mode, create the `Lookup`, passing in a pointer to the static data array declared earlier.
353353 // TODO: Make use of the lookup range
354+ if ( this . var . points . length < 1 ) {
355+ throw new Error ( `ERROR: lookup size = ${ this . var . points . length } in ${ this . lhs } ` )
356+ }
354357 return [ ` ${ this . lhs } = __new_lookup(${ this . var . points . length } , /*copy=*/false, ${ dataName } );` ]
355358 } else {
356359 return [ ]
@@ -445,6 +448,9 @@ export default class EquationGen extends ModelReader {
445448 dataValue = getCellValue ( dataCol , dataRow )
446449 timeValue = getCellValue ( timeCol , timeRow )
447450 }
451+ if ( lookupSize < 1 ) {
452+ throw new Error ( `ERROR: lookup size = ${ lookupSize } in ${ this . lhs } ` )
453+ }
448454 return [ ` ${ this . lhs } = __new_lookup(${ lookupSize } , /*copy=*/true, (double[]){ ${ lookupData } });` ]
449455 }
450456 generateDirectConstInit ( ) {
@@ -541,6 +547,9 @@ export default class EquationGen extends ModelReader {
541547 return `double ${ dataName } [${ data . size * 2 } ] = { ${ points } };`
542548 } else if ( mode === 'init-lookups' ) {
543549 // In init mode, create the `Lookup`, passing in a pointer to the static data array declared in decl mode.
550+ if ( data . size < 1 ) {
551+ throw new Error ( `ERROR: lookup size = ${ data . size } in ${ lhs } ` )
552+ }
544553 return ` ${ lhs } = __new_lookup(${ data . size } , /*copy=*/false, ${ dataName } );`
545554 } else {
546555 return undefined
@@ -620,6 +629,9 @@ export default class EquationGen extends ModelReader {
620629 if ( this . var . isData ( ) && ! R . isEmpty ( this . var . points ) ) {
621630 if ( this . mode === 'init-lookups' ) {
622631 // If the var already has lookup data points, use those instead of reading them from a file.
632+ if ( this . var . points . length < 1 ) {
633+ throw new Error ( `ERROR: lookup size = ${ this . var . points . length } in ${ this . var . refId } ` )
634+ }
623635 let lookupData = R . reduce ( ( a , p ) => listConcat ( a , `${ cdbl ( p [ 0 ] ) } , ${ cdbl ( p [ 1 ] ) } ` , true ) , '' , this . var . points )
624636 this . emit ( `__new_lookup(${ this . var . points . length } , /*copy=*/true, (double[]){ ${ lookupData } });` )
625637 }
0 commit comments