gfortran, ncar and blockdata_test failures
Walter Spector
w6ws@earthlink.net
Sat Nov 17 14:38:00 GMT 2007
Jack Howarth wrote:
> Has anyone looked at the blockdata_test suite that the NCL/NCAR
> developers have posted...
>
> http://www.ncl.ucar.edu/Download/build_from_src.shtml#CompilersNeeded
>
> I find on powerpc-apple-darwin9 that both gcc 4.2.2 and the current
> gcc 4.3 snapshots fail this test....
Ah - the old "put block data in a library, and use EXTERNAL to make sure
it gets linked in" trick. Many compilers have gotten this wrong over
the years, because it is kinda on the edge of being required by the
Standard (any of them).
On my cygwin system, g77 and g95 get it right and gfortran gets it wrong.
See below.
While F90 modules fixed this problem by obsoleting BLOCK DATA and
COMMON, quite a number of older library packages depend on this working.
Walter
$ cat testsub.f
SUBROUTINE TESTSUB
EXTERNAL BDTEST
COMMON/TEST/WK
INTEGER WK
PRINT *,'TESTSUB: WK = ',WK, '...it should be 20'
RETURN
END
$ g77 -c testsub.f
$ nm testsub.o
00000000 b .bss
00000000 d .data
00000000 r .rdata
00000000 t .text
00000004 d ___g77_cilist_0.1
00000000 d ___g77_forceload_0.0
U _bdtest_ <<<< This references the BLOCK DATA
U _do_lio
U _e_wsle
U _s_wsle
00000010 C _test_
00000000 T _testsub_
$ gfortran -c testsub.f
$ nm testsub.o
00000000 b .bss
00000000 d .data
00000000 r .rdata
00000000 t .text <<<< Missing a reference to _bdtest_ here
U __gfortran_st_write
U __gfortran_st_write_done
U __gfortran_transfer_character
U __gfortran_transfer_integer
00000010 C _test_
00000000 T _testsub_
$
More information about the Fortran
mailing list