X

NV5 Geospatial Blog

Each month, NV5 Geospatial posts new blog content across a variety of categories. Browse our latest posts below to learn about important geospatial information or use the search bar to find a specific topic or author. Stay informed of the latest blog posts, events, and technologies by joining our email list!



NV5 at ESA’s Living Planet Symposium 2025

NV5 at ESA’s Living Planet Symposium 2025

9/16/2025

We recently presented three cutting-edge research posters at the ESA Living Planet Symposium 2025 in Vienna, showcasing how NV5 technology and the ENVI® Ecosystem support innovation across ocean monitoring, mineral exploration, and disaster management. Explore each topic below and access the full posters to learn... Read More >

Monitor, Measure & Mitigate: Integrated Solutions for Geohazard Risk

Monitor, Measure & Mitigate: Integrated Solutions for Geohazard Risk

9/8/2025

Geohazards such as slope instability, erosion, settlement, or seepage pose ongoing risks to critical infrastructure. Roads, railways, pipelines, and utility corridors are especially vulnerable to these natural and human-influenced processes, which can evolve silently until sudden failure occurs. Traditional ground surveys provide only periodic... Read More >

Geo Sessions 2025: Geospatial Vision Beyond the Map

Geo Sessions 2025: Geospatial Vision Beyond the Map

8/5/2025

Lidar, SAR, and Spectral: Geospatial Innovation on the Horizon Last year, Geo Sessions brought together over 5,300 registrants from 159 countries, with attendees representing education, government agencies, consulting, and top geospatial companies like Esri, NOAA, Airbus, Planet, and USGS. At this year's Geo Sessions, NV5 is... Read More >

Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

6/3/2025

Rethinking the Reliability of Type 1a Supernovae   How do astronomers measure the universe? It all starts with distance. From gauging the size of a galaxy to calculating how fast the universe is expanding, measuring cosmic distances is essential to understanding everything in the sky. For nearby stars, astronomers use... Read More >

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

5/26/2025

Whether you’re new to remote sensing or a seasoned expert, there is no doubt that large language models (LLMs) like OpenAI’s ChatGPT or Google’s Gemini can be incredibly useful in many aspects of research. From exploring the electromagnetic spectrum to creating object detection models using the latest deep learning... Read More >

1345678910Last
«September 2025»
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
8033 Rate this article:
4.0

The COMPILE_OPT statement; you should use it!

Anonym

The COMPILE_OPT statement alters IDL’s compile-time behavior. The statement is locally scoped; i.e., it changes IDL’s behavior only within the routine in which it is declared. I use the IDL2 option (a shorthand for the DEFINT32 and STRICTARR options) in all new procedures, functions and methods I write. The DEFINT32 option makes the default IDL integer long (32-bit signed) instead of short (16-bit signed). This is a compatibility measure: it brings IDL into line with just about every other programming language. For example, by IDL's default typing rules, the variable A is a short integer:

IDL> a = 30000 + 10000
IDL> help, a
A               INT       =   -25536

After setting the DEFINT32 option, the same statement produces a long integer:

IDL> compile_opt defint32
IDL> a = 30000 + 10000
IDL> help, a
A               LONG      =        40000

Note that, as a helpful side effect, the use of long integers lessens the chance of an integer overflow. (But why wasn’t A coerced into being a long integer in the first place? This will be a topic for a future post, I promise.) The STRICTARR option enforces the use of square brackets for subscripting. This is an efficiency measure: although you can subscript arrays with parentheses, this creates an ambiguity with respect to function calls, which IDL must disambiguate. For example, is the following statement a function call or an array subscripting operation?

IDL> x = foo(1)

The answer is: we can't tell without context. When IDL encounters such a statement at runtime, it first assumes "foo" is a function and it uses the calling mechanism to attempt to resolve it. If it can't find a match, it then assumes "foo" is an array and it attempts to subscript it. If "foo" is in fact a function, you’ll need to compile it manually (e.g., with .compile) for IDL to recognize it as such; otherwise, IDL will continue to insist that "foo" is an array. The STRICTARR option is particularly useful for writing ENVI batch mode programs in IDL, when IDL may not know about the ENVI library routines called in a program until runtime. The STRICTARR option also eliminates the need for the FORWARD_FUNCTION statement. A helpful side effect of the STRICTARR option is that it makes it easier to distinguish between functions and arrays when reading an IDL or an ENVI program. Note that the COMPILE_OPT statement should be declared at the beginning of a routine; e.g.:

pro foo
   compile_opt idl2

   ; Do something useful here.
end

Any statements declared before COMPILE_OPT won't be addressed by it. I strongly recommend using the COMPILE_OPT statement with the IDL2 option at a minimum (though STRICTARRSUBS and LOGICAL_PREDICATE are also good choices) in all new code that you write. It may seem like a trifle, but I swear it’s helpful – it’s hard to convey the number of times I’ve seen adding a COMPILE_OPT statement solve a problem in class, in a seminar or in talking with Tech Support (Jim Uba came upon another instance this week). I think these options make IDL better behaved and friendlier for new users. I’m considering pushing to make STRICTARR and DEFINT32 the defaults in IDL, with a preference to allow users to revert to IDL’s original behavior.

Please login or register to post comments.