Re: Problem running functions [message #85803 is a reply to message #85801] |
Tue, 10 September 2013 08:51   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Hello,
I'm running 8.2.2 on RHEL6
Here's the IDL portion of my ".bash_profile" file:
# Setup idl v8.x
. /usr/local/exelis/idl82/bin/idl_setup.bash
export IDL_PATH="<IDL_DEFAULT>"
export IDL_PATH="${IDL_PATH}:+\${CRTM_SCRIPTS_ROOT}/idl:+\${HOME}/idl "
export IDL_STARTUP="${CRTM_SCRIPTS_ROOT}/idl/idl_startup.pro"
(Don't worry about that "CRTM_SCRIPTS_ROOT" envar - that just points to
my repo current working copy.)
After making the above change you'll have to open a new terminal session
so they take. But from that point on all new terminal sessions will have
that setup.
With apologies if you already know this, but the important thing here is
the "+" - that indicates that all of the subdirectories are recursively
included in the IDL_PATH.
This is the only place I define IDL_PATH. I don't do it in the
IDL_STARTUP file like DavidF suggested (although there's nothing wrong
with doing it that way either)
So because I put ALL my IDL code under a directory of the above
"${CRTM_SCRIPTS_ROOT}/idl" and "${HOME}/idl", it is all available for
use in IDL. You also do the same thing so setting your IDL_PATH in your
.bash_profile/.profile/.whatever should solve the problem (he says with
confidence! Ha.) Maybe something like:
# Setup idl v8.x
. /usr/local/wherever-idl-is-installed-directory/idl_setup.bas h
export IDL_PATH="<IDL_DEFAULT>"
export IDL_PATH="${IDL_PATH}:+\${HOME}/margaret/idl"
export IDL_STARTUP="${HOME}/margaret/idl/idl_startup.pro"
?
But I think you will need to remove the paths you've inserted in the files.
I definitely *do not* put paths in individual files. That makes things
very non-portable (e.g. if you get a new machine, or give your code to
someone else).
cheers,
paulv
On 09/09/13 21:20, laura.hike@gmail.com wrote:
> If it matters, I'm running IDL Version 8.2.1 (linux x86_64 m64) with
> Debian linux.
>
>
> On Monday, September 9, 2013 6:15:57 PM UTC-7, laura...@gmail.com
> wrote:
>> This is a problem I've had before several times that has caused me
>> to change all my functions to procedures. This time I refuse! The
>> basic problem is that I write a function, test it, have it work
>> fine, then try to use it in a real program and it fails, generally
>> with "Variable is undefined". Here are the details:
>>
>>
>>
>> I have a directory for IDL functions and procedures I have written.
>> Every new code I write starts out with the line adding this
>> directory to my path: !path = '/home/disk/margaret/idl:' + !path
>>
>>
>>
>> I wrote two new and very short functions in this directory. I
>> tested them using a little program in a completely different
>> directory: /home/dingo/2/snowmelt/MODIS.SW/data I ran this from
>> the IDL command line, not IDLDE. They ran fine and gave the
>> answers I expected.
>>
>>
>>
>> Then I switched to a different directory
>> (/home/dingo/2/ceres.syn/ed3a) and started writing the full program
>> I intended. I included use of one of the functions. When I tested
>> the new program, I got the "Variable is undefined" error. WTF??
>> I checked the path, I checked the spelling and case of the function
>> name, etc., but no luck. The typical error I read about on line is
>> an order of compilation error, but I don't see where there should
>> be any issue if the function worked fine in the test program. I
>> mean, the new code just loads some variables from a file, then
>> calls the function to linearly interpolate two of the values. How
>> can the order be incorrect?
>>
>>
>>
>> Interestingly, I went back and tried to rerun the test program. I
>> moved a copy to the second work directory (ceres etc.) and got an
>> all-new error message: "Only 8 subscripts allowed." Huh?? I then
>> tried running the test program in the directory where I had written
>> it and it had previously worked fine and now also got the "Only 8
>> subscripts allowed." message. Note: I restart IDL _every_ time I
>> run a program, so the memory is cleared.
>>
>>
>>
>> (Don't ask me why I wrote the test code in a different directory.
>> I must have just confused my terminal windows.)
>>
>>
>>
>> Should I just give up again?? I was so careful and methodical....
>
|
|
|