Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!charon!dik From: dik@cwi.nl (Dik T. Winter) Newsgroups: comp.lang.fortran Subject: Re: Tools for porting fortran? Message-ID: <2953@charon.cwi.nl> Date: 15 Feb 91 23:50:02 GMT References: <91044.104254AMB@SLACVM.SLAC.STANFORD.EDU> <23175@well.sf.ca.us> Sender: news@cwi.nl Organization: CWI, Amsterdam Lines: 31 In article <23175@well.sf.ca.us> rchrd@well.sf.ca.us (Richard Friedman) writes: > AMB@SLACVM.SLAC.STANFORD.EDU writes: > >In C, there are compiler directives (#if, #else, etc) for this. > >Anyone have a method, or commercial product, for doing this to fortran? > > On most systems the C preprocessor can be called directly (cpp ...), > to give the same functionality for fortran. For example, on Cray UNICOS: > cpp -P small_mdl.fig source.f > source.x.f > cf77 -o myprog source.x.f > Beware, do not do this on *your* system, unless you are willing to thrash your source files. (Some of the cpp's I know can take two file parameters; it will process the first file and leave the output in the second, so in the example above source.f will be replaced by the result of cpp processing of small_mdl.fig. One of those systems is, surprise, Cray UNICOS.) The behaviour of cpp is extremely ill-defined. If you really want the C preprocessor for your Fortran sources you are entering a machine dependant domain. One of the following may work (or it may not), do some experiments. 1. /lib/cpp src.f | sed -e '/^#/d' > src.x.f 2. cc -E src.f | sed -e '/^#/d' > src.x.f 3. cp src.f src.c; cc -P src.c; mv src.i src.x.f; rm src.c Or perhaps some variation of this. However you will not be satisfied with the result on some systems (most notable: Cray UNICOS with the standard C compiler; it will destroy your program layout). If you want configuration control you should use include files using the C preprocessor syntax. -- dik t. winter, cwi, amsterdam, nederland dik@cwi.nl