comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: newbie wants to call IDL from shell
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: newbie wants to call IDL from shell [message #61289] Fri, 11 July 2008 19:02
biophys is currently offline  biophys
Messages: 68
Registered: July 2004
Member
Make a file, let's say regrid_mozt42_tlr

public1:/home/tlr/idl>cat regrid_mozt42_tlr
> regrid_mozt42_tlr
> exit
public1:/home/tlr/idl> idl regrid_mozt42_tlr

> IDL Version 7.0 (linux x86 m32). (c) 2007, ITT Visual Information Solutions
> ...
> IDL> regrid_mozt42_tlr
> % Compiled module: REGRID_MOZT42_TLR.
> ...
> Done.
public1:/home/tlr/idl>

You can also include commands like .compile etc in the file
regrid_mozt42_tlr in case it can not resolve all dependencies.
public1:/home/tlr/idl>cat regrid_mozt42_tlr
> .compile 'myfunc1.pro'
...
> .compile 'mypro1.pro'
...
> .compile 'regrid_mozt42_tlr.pro'
> regrid_mozt42_tlr
> exit


cheers,
bp
Re: newbie wants to call IDL from shell [message #61290 is a reply to message #61289] Fri, 11 July 2008 18:59 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Jul 11, 8:36 pm, Tom Roche <tlro...@gmail.com> wrote:
> How to exec IDL procedures from a shell or other programming
> environment? (Correctly: see failed attempt below.) Note that I'm not
> talking about creating a runtime distribution; I just want to be able
> to call a procedure from the OS commandline, not from the IDL
> commandline, on a box with IDL installed. Why I ask:
>
> My group mostly uses IDL to interact with netCDF files. I'm noticing
> that, in scripts I've been given, we do a lotta code where we type in
> literals to specify files on which to operate, e.g.
>
> indir = '/path/to'
> files = ['foo' , 'bar' , 'baz']
> FOR i = 0, n_elements(files)-1 DO BEGIN
>   filename = files[i]
>   infile = indir+'/'+filename
>   doSomethingWith, infile
> ENDFOR
>
> I'd prefer to use IDL for things it does well, and use something more
> general-purpose (e.g. bash, perl, python) (i.e. something I already
> know how to use :-) to drive it, e.g.
>
> # bash
> for INFILE in $(bash fu) ; do
>   idl < doSomethingWith $INFILE
> done
>
> So I thought I'd start simple: I have a script (my first script that
> does something useful!)
>
> public1:/home/tlr/idl> ls -al regrid_mozt42_tlr.pro> -rw-r--r--  1 tlr m 755 Jul 10 16:11 regrid_mozt42_tlr.pro
>
> public1:/home/tlr/idl> cat regrid_mozt42_tlr.pro
>
>> COMPILE_OPT IDL2
>> PRO regrid_mozt42_tlr
> ...
>> END
>
> done in the deprecated style above, which works from the IDL shell
> with no args (because everything is literal within the *.pro):
>
> public1:/home/tlr/idl> idl
>
>> IDL Version 7.0 (linux x86 m32). (c) 2007, ITT Visual Information Solutions
>> ...
>> IDL> regrid_mozt42_tlr
>> % Compiled module: REGRID_MOZT42_TLR.
>> ...
>> Done.
>
> Now I just want to run it from the commandline, in the same directory
> as above (which is in my IDL_DIR):
>
> public1:/home/tlr/idl> idl < regrid_mozt42_tlr.pro
>
>> IDL Version 7.0 (linux x86 m32). (c) 2007, ITT Visual Information Solutions
>> ...
>> PRO regrid_mozt42_tlr
>>                      ^
>> % Programs can't be compiled from single statement mode.
>
> What do I need to do to make that work? Or how else should I do this?
> Apologies if this is a FAQ but I haven't found any answers either
> googling or in the online help. If I should RTFM, please pass pointer.
>
> TIA, Tom Roche <Tom_Ro...@pobox.com>

Here's what I do:

1- make a .sav file.
IDL> .comp regrid_mozt42_tlr
IDL> resolve_all
IDL> save, /routines, file='regrid_mozt42_tlr.sav'

2- make a shell script to call it.
!#/bin/bash

<get command line args etc.
store them in environment variables, and export them
use GETENV() to get them in the idl routine.>

idl -rt=regrid_mozt42_tlr.sav
exit

You can also pass the cmd-line args to the idl command, but I've been
doing it the Env Variable way for so long...

Your mileage may vary.

Cheers,
Vince
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: newbie wants to call IDL from shell
Next Topic: Re: x*x versus x^2

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:28:49 PDT 2025

Total time taken to generate the page: 0.00191 seconds