Determining a library version

(I’ve been out for a week, so today’s post is short. I’ll return shortly to the sunspot number data from last week’s post.)

What’s the version number of the GRIB library in the current IDL release? I should probably know this off the top of my head, but I don’t. Ray Sterner (JHU/APL) suggested it would be nice if there was a way to quickly get library information without searching through the docs.

Most of the external libraries included in IDL are dynamically linked; we call them DLMs (and everything I know about them I learned from Ronn Kling’s book). Jim Pendleton used this fact to write a program to parse the output of

IDL> help, /dlm

into a data structure using built-in IDL string processing routines. Here’s a modified version of Jim’s program:

function dlmversions
   compile_opt idl2
   on_error, 2

   help, /dlm, output=out

   h = hash()

   for i=0, n_elements(out)-1, 3 do begin
      module = (strsplit(out[i], ' ', /extract))[1]
      pos_colon = strpos(out[i+1], ':')
      pos_comma = strpos(out[i+1], ',')
      version = strmid(out[i+1], pos_colon+1, pos_comma-(pos_colon+1))
      h[module] = strtrim(version, 2)
   endfor

   return, h.tostruct()
end

So, what is the version of the GRIB library included in the current IDL release?

IDL> .compile dlmversions
IDL> v = dlmversions()
IDL> print, v.grib
1.9.0

Now I know!

I’d like to include a routine like this in the IDL distribution. Would you use it?

About these ads

About Mark

I solve scientific programming and visualization problems with IDL.
This entry was posted in language, programming and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s