pmontgom@euphemia.math.ucla.edu (Peter Montgomery) (02/06/91)
Is this the proper newsgroup for reports like the following?
#! /bin/csh -f
#
# Using f77 version 2.10 under ULTRIX V4.0 on a DEC 5000,
# I have experienced many problems while using source files which
# pass through the C preprocessor (.F suffix) and which have
# conditional compilation (#if or #ifdef or #ifndef) directives
# which cause source code to be skipped.
# Some problems are dependent upon the precise file name.
# This script demonstrates some of them.
#
# Problems reported February, 1991 by
#
# Peter L. Montgomery
# Department of Mathematics
# University of California
# Los Angeles, CA 90024-1555
#
# pmontgom@math.ucla.edu
#
#**********************************************************************
set dir = /tmp/UCLAtests
/bin/rm -r -f $dir
mkdir $dir
cd $dir # Test files go there
cat << End_file > verylongname.F
C Call this source file "verylongname.F".
C Compile with "f77 -g". Then run "dbx a.out".
C The debugger immediately prints registers and dies.
C With some other file names, such as ",1.F", the
C program works OK. It is also OK if we change the "#if 0" to "#if 1".
program test
end
#if 0
#endif
End_file
echo "***** Debugger prints registers and dies *****"
f77 -g verylongname.F
echo "quit" | dbx a.out
echo "***** With different source file name, debugger is OK *****"
mv verylongname.F ,1.F
f77 -g ,1.F
echo "quit" | dbx a.out
#**********************************************************************
cat << End_file > outrange.F
C
C Using f77 -c -g, this source gets
C
C libmld: Internal: st_psym_ifd_isym: ifd (0) or isym (2) out of range
C
C if we specify exactly one of -DCHARACTER and -DENTRY,
C but works OK if we use both or neither of those.
C
subroutine ONE(name)
#ifdef CHARACTER
character*(*) name
#endif
#ifdef ENTRY
entry TWO(name)
#endif
end
End_file
echo "***** Two libmld: Internal: st_psym_ifd_isym: *****"
echo "***** ifd (0) or isym (2) out of range *****"
f77 -c -g -DCHARACTER outrange.F
f77 -c -g -DENTRY outrange.F
echo "***** Next two compile OK *****"
f77 -c -g outrange.F
f77 -c -g -DCHARACTER -DENTRY outrange.F
#**********************************************************************
cat << End_file > prof1.F
C Subject: Wrong file name in profile listing using C preprocessor
C
C Compile this source using the C preprocessor and -p (profile).
C After executing a.out, run "prof" to get an profile listing.
C The profile has the proper source file name for ZERO and ONE,
C but not for TWO and THREE.
program ZERO
do i = 1, 100000
call ONE
end do
end
subroutine ONE
do i = 1, 2
call TWO
end do
end
#if 0
The wrong file name is used hereafter.
#endif
subroutine TWO
do i = 1, 2
call THREE
end do
end
subroutine THREE
end
End_file
echo "***** Prof lists wrong file name for TWO and THREE *****"
/bin/rm -f a.out mon.out core
f77 -p prof1.F
a.out
prof
#**********************************************************************
cat << End_file > x.F
#if 0
C Subject: Profiler says "Unknown language"
C
C Call this "x.F" and compile with "f77 -p".
C Then run "a.out" and "prof".
C Prof terminates abnormally with the message
C "Unknown language in symbol table (4)".
C
C If we call this "prof2.F", the problem does not occur.
#endif
program main
end
subroutine ONE
entry TWO
end
End_file
/bin/rm -f core a.out mon.out
echo "***** Unknown language in symbol table (4) *****"
f77 -p x.F
a.out; prof
cp x.F prof2.F
/bin/rm -f core a.out mon.out
echo "***** With file name changed, problem does not occur *****"
f77 -p prof2.F
a.out; prof
#**********************************************************************
exit
--
Peter L. Montgomery
pmontgom@MATH.UCLA.EDU
Department of Mathematics, UCLA, Los Angeles, CA 90024-1555
If I spent as much time on my dissertation as I do reading news, I'd graduate.