(sid64)root@test:~/fort77-1.15/tests# ../fort77 -c bar.F
Error on line 1: Bad # line: "# 0 "<stdin>""
Error on line 2: Bad # line: "# 0 "<built-in>""
Error on line 3: Bad # line: "# 0 "<command-line>""
Error on line 60: Bad # line: "# 0 "<command-line>" 2"
MAIN mememain:
../fort77: aborting compilation
(sid64)root@test:~/fort77-1.15/tests# cat bar.F
programme memain
write (*,*) 'Hello, world!'
end
foo.f builds just fine.
(sid64)root@test:~/fort77-1.15/tests# diff -u bar.F foo.f
(sid64)root@test:~/fort77-1.15/tests#
hm.
hack fort77 to turn on debug mode
(sid64)root@test:~/fort77-1.15/tests# ../fort77 -v -c bar.F
../fort77: fort77 Version 1.15
../fort77: Running "| /lib/cpp -traditional | /usr/bin/f2c -Nn802 -I. |
/usr/bin/perl -p -e 's|^(#line.*)""|$1"bar.F"|' > /tmp/fort77-16142-1.c"Error
on line 1: Bad # line: "# 0 "<stdin>""
Error on line 2: Bad # line: "# 0 "<built-in>""
Error on line 3: Bad # line: "# 0 "<command-line>""
Error on line 60: Bad # line: "# 0 "<command-line>" 2"
MAIN mememain:
../fort77: Running "gcc" "-c" "-o" "bar.o" "/tmp/fort77-16142-1.c"
../fort77: unlinking /tmp/fort77-16142-1.c
Try that with foo.f
(sid64)root@test:~/fort77-1.15/tests# ../fort77 -v -c foo.f
../fort77: fort77 Version 1.15
../fort77: Running "/usr/bin/f2c -Nn802 -I. < foo.f | /usr/bin/perl -p -e
's|^(#line.*)""|$1"foo.f"|' > /tmp/fort77-16388-1.c"
MAIN mememain:
../fort77: Running "gcc" "-c" "-o" "foo.o" "/tmp/fort77-16388-1.c"
../fort77: unlinking /tmp/fort77-16388-1.c
Baby steps...
(sid64)root@test:~/fort77-1.15/tests# /usr/bin/f2c -Nn802 -I. < bar.F >tmp.c
MAIN mememain:
(sid64)root@test:~/fort77-1.15/tests# gcc -c -o tmp.o tmp.c
(sid64)root@test:~/fort77-1.15/tests# echo $?
0
(sid64)root@test:~/fort77-1.15/tests# cat bar.F | /lib/cpp -traditional
# 0 "<stdin>"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 17 "/usr/include/stdc-predef.h" 3 4
<lots of blank lines>
# 0 "<command-line>" 2
# 1 "<stdin>"
programme memain
write (*,*) 'Hello, world!'
end
To state the obvious, it appears 'cpp -traditional' is blurting out
things that f2c is not expecting.
Repeat with cpp 8.3.0, which f2c is happy with:
$ cat bar.F | /lib/cpp -traditional
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 17 "/usr/include/stdc-predef.h" 3 4
..lots of blanks...
# 32 "<command-line>" 2
# 1 "<stdin>"
programme memain
write (*,*) 'Hello, world!'
end
$ cat bar.F | /lib/cpp -traditional | /usr/bin/f2c -Nn802 -I. >t.c
MAIN mememain:
$ echo $?
0
Comparing the two cpp outputs:
--- bar.gcc8-cpp 2021-11-04 19:07:20.293278111 +1100
+++ bar.gcc11-cpp 2021-11-04 19:07:06.729132792 +1100
@@ -1,7 +1,6 @@
-# 1 "<stdin>"
-# 1 "<built-in>"
-# 1 "<command-line>"
-# 31 "<command-line>"
+# 0 "<stdin>"
+# 0 "<built-in>"
+# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 17 "/usr/include/stdc-predef.h" 3 4
@@ -48,7 +47,7 @@
-# 32 "<command-line>" 2
+# 0 "<command-line>" 2
# 1 "<stdin>"
programme memain
write (*,*) 'Hello, world!'
So that's what f2c seems to be having trouble with.
Not sure what the fix is.