version 1.01: fixed bug in find_dir - pushd without popd version 1.02: fixed multiple directory delimiter bug, showing up in mac paths all, this is a long note which i will give an "executive summary" of here at start- problem: various sets of software routines are being created at various institutions by many people in the CRIS and SIS teams. We want this software to be as easily portable and trackable as possible from place to place. My discussion focuses on IDL software, but can be applied to other languages as well. how do we keep some sort of idea about what software is doing what and where it came from and how to do clean upgrades of other people's software after we have all started mixing and matching each-other's routines? a possible solution: my suggestion is for people to distribute "packages" of code which are as self-contained as possible, and which are stored in entirely separate locations from the code/databases in some other package. i highly recommend *not* just dumping everything into one large working directory. i have written some utilities which make it possible for a routine sitting in a directory separate from the working directory (but in the IDLPATH), to find directories and databases which the routine expects to find in the same directory as it is sitting in itself. what this means is that we should all be able to set up idl environments that are more clear and modular. you can place the packages others provide for you anywhere on your system that makes sense to you (likely as a subdirectory under your working directory) and the routines in said package will be able to find databases inside their own directories. another problem of porting code from OS to OS (mac to pc to unix) in IDL is in the construction of paths because the directory delimiters are different for each. routines to help solve that problem are also discussed here. This note has been archived on the ACE Memo board, along with links to the package of utilities discussed here. ------ details follow ------- In order to ease the incorporation of routines I have written for CRIS/SIS into other people's work, I have written some utilities in IDL (which could also be ported to C for those who would rather use C) to overcome a few problems which would otherwise call for 1) people having to go into the code to change things like paths and directory delimiters, and 2) people having to dump all procedures and databases into one huge, working directory, which would become confusing to follow what software/databases were from where, and make upgrading this or that package more tedious and difficult. I have created a set of IDL routines that I'm distributing as a "package" called "idlUtilities_bs". It contains the routines: find_dir, dirName, path find_file, fileName, path get_directory_delimiter, dirDelim make_path, invalidPath, validPath The first two are the most important. They allow you to find directories and non-executable files (such as databases) that are anywhere in your IDLPATH. The problem is that IDL (and C) will search their paths for executable routines, but not for anything else. If your routine needs to access a database that's sitting right in the same directory as the routine itself, IDL will not find it (unless you've dumped everything in one big working directory, which is what I think people should avoid doing.) For example, I have a routine called "get_sis_thickness" which needs to access a database called "absThickAt00.db" and I want to keep both the routine (and its several helper routines), and the databases it uses in a directory of it's own, called "sis_thickness_maps": sis_thickness_maps/ [ primary directory for package ] absThickAt00.db [ a database ] get_sis_thickness.pro [ primary routine ] interferometerData/ [ secondary directory containing databases ] interpolate_dt.pro [ helper routine ] read_base_thickness.pro [ helper routine ] read_interfer_dt_map.pro[ helper routine ] etc. First, I must place the directory sis_thickness_maps in my IDLPATH. This will allow IDL to find the routines therein and allows you to place the directory sis_thickness_maps anywhere on your system that makes the most sense to you. IDLPATH can be defined/added to in several ways. I use a routine I run before doing anything else to set up the path I want: pro sis_setup !path = '/home/darkalf1/msu96/sis/thicknessMaps:' + !path !path = '/home/darkalf/bruce/ace/idlUtilities_bs:' + !path end Now IDL will find any routines in my working directory and in the directories /home/darkalf1/msu96/sis/thicknessMaps and /home/darkalf/bruce/ace/idlUtilities_bs (as well as the standard IDL libraries). Now, in order for my routine "read_base_thickness" to find the database "absThickAt00.db", i call the utility routine find_file, 'absThickAt00.db', path which returns path = '/home/darkalf1/msu96/sis/thicknessMaps/absThickAt00.db' I also might want to find the directory "interferometerData" to get at the database files in there: find_dir, 'interferometerData', path returning path = '/home/darkalf1/msu96/sis/thicknessMaps/interferometerData' Remember, these directories and files can only be found if they lie in a directory which is in the IDLPATH. I could also do this: find_file, 'interferometerData/ACE012.db', file [unix] find_file, 'interferometerData:ACE012.db', file [mac] find_file, 'interferometerData\ACE012.db', file [windows '95] to get directly to a database file inside the "interferometerData" subdirectory. Just in case you've lost sight of the reason for all this, it is to create a directory (a "package") of routines and databases which are completely self-contained. Be aware that 2 files/directories having the same names will be a problem here, i.e., if I had /home/darkalf1/msu96/sis/thicknessMaps/absThickAt00.db and /home/darkalf/bruce/ace/idlUtilities_bs/absThickAt00.db and I made a call: find_file, 'absThickAt00.db', path then there would be a problem. Give descriptive names to your procedures and databases, and this will not likely be a problem. The other 2 utility routines: get_directory_delimiter, dirDelim make_path, invalidPath, validPath are for attempting to create cross-platform IDL code. After calling get_directory_delimiter, dirDelim dirDelim will contain "/", ":", or "\" dependent on the current system IDL is being run on. I use it like so to create platform independent paths in my code: detName = 'ace216' get_directory_delimiter, dd ; unix = /, pc = \, mac = : interferometer_map_file = 'interferometerData' + dd + detName + '.map' find_file, interferometer_map_file, path interferometer_map_file = path get_lun, unit1 openr, unit1, interferometer_map_file I now have access to the database I want to read, independent of which OS I'm working on. Annoying, but useful perhaps... Finally, "make_path" will take a relative path from mac, pc, or unix, and turn it into the format needed by the currently running platform. make_path, 'interferometerData/ace216.map', validPath returns one of the following, dependent on where the code is running: validPath = 'interferometerData/ace216.map' [ current system is unix ] validPath = 'interferometerData:ace216.map' [ current system is mac ] validPath = 'interferometerData\ace216.map' [ current system is pc ] if there are any questions about these utilities, just send me some mail. bruce