Trouble compiling an old FORTRAN file

Hi. Somebody gave me some code that I need for some of my research. I tried to compile the code with g77 but was unsuccessful. Maybe you know what compiler it should use if not g77. The code was meant to run on windows NT. It was actually written for the WATCOM fortran compiler but I don't know where to get the old compilers of WATCOM. To be specific, the command in the console was "wfl386 mystest.for" to compile such a file. Here is the code for one of the many files I have:

      PROGRAM UNFORMAT_COAST

c     reads    formatted file: coast.fmt
c     writes unformatted file: coast$d.dat

      parameter    (mxp=10650)

      STRUCTURE    /segment/
         integer*2  ndx
         integer*2  nrp
         integer*2  nrc
         integer*2  lat(mxp)
         integer*2  lon(mxp)
      END STRUCTURE
      record       /segment/line

      logical       eof

      OPEN (15,file='coast$d.dat',status='unknown',form='unformatted')
      OPEN (16,file='coast.fmt',  status='old')

      eof=.false.
      do while (.not.eof)

         read  (16,'(3i5/(10i6))')
     &          line.ndx,
     &          line.nrp,
     &          line.nrc,
     &         (line.lat(n),
     &          line.lon(n),n=1,line.nrp)

         write (15)
     &          line.ndx,
     &          line.nrp,
     &          line.nrc,
     &         (line.lat(n),
     &          line.lon(n),n=1,line.nrp)

         if (line.ndx .eq. 9000) go to 19
      end do
19    CLOSE (15)
      CLOSE (16)
      STOP
      END   ! UNFORMAT_COAST

Thank you
Etienne Koen

Re: Trouble compiling an old FORTRAN file

keith's picture

You should ask questions, such as this, on the MinGW-Users mailing list.

This Wiki is not intended as a forum for general problem discussion; please do not treat it as such. Such content is entirely inappropriate here; it will shortly be removed.

Re: Trouble compiling an old FORTRAN file

earnie's picture

Keith, I at first had the same thought and while your statement in general about not treating the wiki as a forum is true, this particular post could become a document explaining the OP's issue. So, rather than delete it, it may be edited to give explanation to the issue.

Re: Trouble compiling an old FORTRAN file

keith's picture

Possibly, Earnie.

However, in this case, the answer is trivial -- the OP's source code is not valid FORTRAN-77. It is littered with vendor specific extensions, which are strongly reminiscent of Digital Equipment Corporation's implementation; I guess WATCOM FORTRAN was similarly non-standard.

Specifically, ANSI X3.9-1978 FORTRAN-77 doesn't support the STRUCTURE or RECORD constructs. If this belongs anywhere other than the mailing list, it may be as a FAQ, with subject "Can GCC F77 (G77) compile WATCOM FORTRAN source?", and the answer is short and sweet: "If the source uses only standard ANSI X3.9-1978 FORTRAN-77 constructs, then yes; if any non-standard constructs, such as STRUCTURE or RECORD are used, then the code will need to be rewritten, to eliminate them."

FWIW, my day job has required me to write a significant volume of DEC FORTRAN-77 code, over the years, but I've never once been tempted to use any non-standard extension, (having previously been bitten by code written with CSTS-UNIVAC extensions -- these of course are completely incompatible with any other vendor's -- which I subsequently needed to port to an IBM host). EQUIVALENCE statements provide a much more portable alternative to STRUCTURE and RECORD.

I've never used any more recent FORTRAN than FORTRAN-77, so I can't say authoritatively: I understand that FORTRAN-90 may have introduced some form of STRUCTURE and RECORD construct, but I do not believe it is directly compatible with the DEC, or WATCOM usage.

Site Status

Site maintenance completed May 25th, 2012 at 12:38 UTC