Dear Users,
I would like to find out what causes this error (during calculating Keetch-Byram index), also, how to fix this simple calculation.
The error message is BAD variable definition. Repetition until L=7 works fine, when an important variable becomes negative (-9), it defines during a calculation a BAD variable (the changing basic variable), and the next iteration stops.
When I removed the quotes(let kbdix=`kbdi`), naturally came stack overflow.
Here is what I used, and the bottom lines are the results of the script.
Thanks for you help and enjoy August wherever you are,
-------
yes? let kbdi=0
yes? repeat/l=2:365 (let kbdix=`kbdi`; let tempy=var15[d=2,l=`l-1`,k=1]-273.15; let lr=if var202[d=1,l=`l`,k=1] lt 0.05 then 0 else var202[d=1,l=`l`,k=1]; let dkbdi_5=if (dslr[l=`l`] eq 0) and (lr[l=`l`] ge 5) then (-1*lr[l=`l`]+5) else 0; let dkbdi=if (dslr[l=`l`] gt 0) then ((kbdix-800)*(-1)*(.968*Exp(.0486*(tempy*9/5+32))-8.3)*.001/(1+10.88*Exp(-.0441*annrf/25.4))*.254) else dkbdi_5; let kbdi=kbdix+dkbdi; list/nohead dslr,lr,dkbdi_5,dkbdi,kbdi)
---
!-> REPEAT: L=7
!-> DEFINE VARIABLE kbdix=0
!-> DEFINE VARIABLE tempy=var15[d=2,l=6,k=1]-273.15
!-> DEFINE VARIABLE lr=if var202[d=1,l=7,k=1] lt 0.05 then 0 else var202[d=1,l=7,k=1]
!-> DEFINE VARIABLE dkbdi_5=if (dslr[l=7] eq 0) and (lr[l=7] ge 5) then (-1*lr[l=7]+5) else 0
!-> DEFINE VARIABLE dkbdi=if (dslr[l=7] gt 0) then ((kbdix-800)*(-1)*(.968*Exp(.0486*(tempy*9/5+32))-8.3)*.001/(1+10.88*Exp(-.0441*annrf/25.4))*.254) else dkbdi_5
I / *: 0.0000 14.70 -9.696 -9.696 -9.696
!-> REPEAT: L=8
!-> DEFINE VARIABLE kbdix=-9.696305
!-> DEFINE VARIABLE tempy=var15[d=2,l=7,k=1]-273.15
!-> DEFINE VARIABLE lr=if var202[d=1,l=8,k=1] lt 0.05 then 0 else var202[d=1,l=8,k=1]
!-> DEFINE VARIABLE dkbdi_5=if (dslr[l=8] eq 0) and (lr[l=8] ge 5) then (-1*lr[l=8]+5) else 0
!-> DEFINE VARIABLE dkbdi=if (dslr[l=8] gt 0) then ((kbdix-800)*(-1)*(.968*Exp(.0486*(tempy*9/5+32))-8.3)*.001/(1+10.88*Exp(-.0441*annrf/25.4))*.254) else dkbdi_5
I / *: 1.000 0.0000 0.0000 .... ....
!-> REPEAT: L=9
!-> DEFINE VARIABLE kbdix=bad
!-> DEFINE VARIABLE tempy=var15[d=2,l=8,k=1]-273.15
!-> DEFINE VARIABLE lr=if var202[d=1,l=9,k=1] lt 0.05 then 0 else var202[d=1,l=9,k=1]
!-> DEFINE VARIABLE dkbdi_5=if (dslr[l=9] eq 0) and (lr[l=9] ge 5) then (-1*lr[l=9]+5) else 0
!-> DEFINE VARIABLE dkbdi=if (dslr[l=9] gt 0) then ((kbdix-800)*(-1)*(.968*Exp(.0486*(tempy*9/5+32))-8.3)*.001/(1+10.88*Exp(-.0441*annrf/25.4))*.254) else dkbdi_5
**ERROR: variable unknown or not in data set: BAD
list/nohead dslr,lr,dkbdi_5,dkbdi,kbdi
Command file, command group, or REPEAT execution aborted