[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A problem with case of filenames
ORTAL Alpert writes:
> On Thu, 10 Jul 1997, Tuvik Beker wrote:
>
> > Hi,
> >
> > I have a huge and ancient application (a 200M source tree) that I want
> > to port to linux (something technical in fortran).
> > The most basic problem is the following: it was originally written on
> > VAX, and the programmer/s refer to the various filesfrom within the
> > sources in lower- upper- and mixed-case. No problem on a stupid VAX, but
> >
> or an more simple not so elegant solution change all your open commands to
> myopen or something and have this one change the filename to lowercase
>
This wouldn't work - you can't implement a myopen in Fortran which
accepts the same syntax as open. Consider the fact that open can have
arguments such as ERR=209 which cause it to jump to line 209 on an
error. But there is a variant which would work (see point 7 below).
Here are a few possibilities:
1. If the file names are short enough, run it under linux on your
MSDOS partition. The FAT file system is not case sensitive.
This might even work if the file names are too long, as long as
they are unique in the 8.3 msdos version, and/or depending on how
Linux treats the long file names. On the minus side, the FAT
file system is slower than the ext2fs file system.
2. I vaguely recall hearing about an experimental VMS file system
which you could use, but I can't seem to locate any references
to it off hand.
3. If you don't need to preserve case in the operation of your
program (i.e. - in arbitrary strings and characters in the
source code), then just downcase all the source code. If the
source code uses hollerith strings you might run into problems.
If the program reads and processes text you might run into
problems.
4. If the filenames themselves occur only in the open commands, it
wouldn't be *too* hard to write a regular expression to match
open(...) & upper case all the arguments. This could be
done in bigloo, sed, emacs, lex&yacc, awk, bigloo, perl ... This
would miss things like:
x = 'asDf'
open(UNIT=5, FILE=x)
5. A version of 3 that might work more generally (I'm not sure if
it's legal Fortran) would be to write a string downcase
function, and use sed, emacs, lex&yacc, awk, bigloo, perl ... to
convert things like:
open(UNIT=5, FILE=x)
to
open(UNIT=5, FILE=downcase(x))
6. There are various companies which sell Fortran code
parsing/manipulation tools. There are also free tools. Check
http://www.sunsite.unc.edu/pub/Linux/devel/lang/fortran/!INDEX.html,
http://studbolt.physast.uga.edu/templon/fortran.html, etc.
7. Use f2c to compile the code & write your own version of f_open
which you link in before the -lf2c. Just copy f_open out of the
source code for libf2c & modify it to downcase the file name
before opening it. f2c converts open(...) to setting up a
structure & then calling f_open on the structure.
8. Use f2c to comple the code and do something like 3, 4, or 5 on
the C code. This might be easier because a) it's C code and b),
f2c generates very specific code for opening files. It might
just be a matter of searching for things like:
f_open(&x);
and adding something like:
downcase(x.ofnm);
in front of the call.
9. Something similar to 7 might be possible even if you're using
g77.
--
Harvey J. Stein
Berger Financial Research
abel@netvision.net.il
Follow-Ups:
References: