Re: fortran source file renamed when using preprocessor directives



On 30 okt, 08:44, ravi <gototh...@xxxxxxxxx> wrote:
Dear all,

I have written a simple FORTRAN program which include some header
files.

like:

$> cat test.F
program test
include 'test.h'
print *,"Hello World"
end

and test.h
print *,"This is test.h"

i have compiled as

$> g77 -ffree-form -g test.F -o test

and tried to debug with gdb:

(gdb) file test
Reading symbols from /home/ssdg_gridhra/tempdir/test/LibTest/
test...done.
Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) b main
Breakpoint 1 at 0x804a4e6
(gdb) r
Starting program: /home/ssdg_gridhra/tempdir/test/LibTest/fsrl.deb

Breakpoint 1, 0x0804a4e6 in main ()
(gdb) where
#0 0x0804a4e6 in main ()
(gdb) l
1 /tmp/ccjXFIn1.f: No such file or directory.
in /tmp/ccjXFIn1.f

Why is it showing the file name "tmp/ccjXFIn1.f " instead of
test.F ??
I have supplied the -g option too.

When I write the file as test.f ( small f extention ) it is showing
correctly.
Can't we retain the same file name even after the preprocessing *.F
files ??

Thanks a lot for any replies.

--
Ravi.T

This type of preprocessing uses the C preprocessor which
does not "know" anything about Fortran. So there are
certain things (like macro expansion) that won't work
properly.

g77 itself seems to handle preprocessing by:
- running the C preprocessor, thus generating a temporary
file in /tmp
- compiling this temporary file instead of the original
source code.

I do not think it has much choice there: due to preprocessing
the number of lines may change and the contents as well,
so that there is very little relation between the original
file and the preprocessed one.

One solution I can think of is, that you preprocess the files yourself
and keep the preprocessed source around:

cpp test.F pp/test.f
g77 -o test.o -c pp/test.f

(keep them in a separate directory to avoid confusion)

If all you need is to INCLUDE files, then there is no
need for this preprocessing. The Fortran compiler will
take care of it.

Regards,

Arjen

.



Relevant Pages