Re: Going outside the interger limits [message #40955 is a reply to message #40953] |
Tue, 21 September 2004 06:25   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Lloyd Watkin writes:
> Have been muddling about with this problem for the past weeek, and I'm
> hoping someone can help.
>
> I'm creating an atmospheric transmission model for the sub-mm/far
> infrared region. If I try to calculate the spectrum between 1 and 500
> wavenumbers (numbers are not important) and I set a high resolution,
> the end of the spectrum does not seem to have had spectral line data
> applied to it.
>
> Having looked at where this is happening (at about point number
> 32700), it lies at the point where an integer runs outside it's
> limits. Inside the code, if a spectral line value is negative then it
> gets ignored, hence why I'm assuming (well guessing really) that this
> is the problem.
>
> I have been through my code and converted as much as I can see into
> either a long or a float depending on what it needs to be.
>
> Still getting problems!
>
> I was wondering whether there is anyway to tell in IDL if an integer
> is trying to go outside it's limits? Such as !except = 2, or is there
> a compiler switch which would break the execution if this problem was
> encountered (the latter would be very handy).
>
> Thanks for any help,
I think I would put this inside the program module:
Compile_Opt defint32
Then, *all* your integers will be long enough to avoid overflow.
More commonly, we use:
Compile_Opt idl2
which sets long integers and enforces strict array subscripting,
another great idea. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
|
|
|