I am using F2C (FORTRAN 77 TO C) to convert a huge FORTRAN code to C. One of my source FORTRAN files has an include file that F2C does not like for some reasons. Here is the include file (TAGLINE.INS) with the extension .INS (I doubt if the extension matters) :
C
C
C*** SCRATCH INPUT DATA FROM FILE FNAM (.RTV = RAW INPUT TAG VALUE)
C
STRUCTURE /STAGRICL/
CHARACTER*76 UFN !! U72 FILENAME.UP.CASE INIT BLANK
CHARACTER*76 RFN ! R72 FILENAME.RAWCASE INIT BLANK
INTEGER*4 LFN ! I4 FILENAME.LENGTH INIT 0
CHARACTER*32 USN !! U32 SECTION-NAME-UP.CASE INIT BLANK
CHARACTER*32 RSN ! R32 SECTION-NAME RAWCASE INIT BLANK
INTEGER*4 LSN ! I4 SECTION-NAME-LENGTH INIT 0
CHARACTER*32 UTN !! U32 TAG-NAME-UP.CASE INIT BLANK
CHARACTER*32 RTN ! R32 TAG-NAME-RAWCASE INIT BLANK
INTEGER*4 LTN ! I4 TAG-NAME-LENGTH INIT 0
CHARACTER*80 UTV ! U80 TAG-VALUE.UP.CASE.IN INIT BLANK
CHARACTER*80 RTV !! R80 TAG-VALUE.RAWCASE.IN INIT BLANK
INTEGER*4 LTV ! I4 TAG-VALUE-LENGTH INIT 0
CHARACTER*80 RWL ! R80 TAG-RAW.WHOLE.LINE INIT BLANK
INTEGER*4 LWL ! I4 TAG-RAW.WHOLE.LENGTH INIT 0
INTEGER*4 NWL ! I4 LIN.#.IN.ORIG.FILE INIT 0
LOGICAL*4 SET ! L4 TAGRICL SET YET ? INIT FALSE
LOGICAL*4 USE ! L4 TAGRICL USED YET ? INIT FALSE
END STRUCTURE
C
C
PARAMETER (N1000=200)
RECORD /STAGRICL/ TAGRICL(N1000) ! 1000.MAX TAG.NAMES.PER.FILE
COMMON /CTAGRICL/ TAGRICL ! RETURNED TAG.NAMES+TAG.VALUES
When trying to convert the source code to C using F2C, I get the following errors :
Error on line 5 of TAGLINE.INS: unclassifiable statement (starts "structure/")
Error on line 34 of TAGLINE.INS: unclassifiable statement (starts "record/sta")
Obviously, F2C complains about the structure inside include file (STRUCTURE /STAGRICL/). Fortran 77 comment lines start with character c at the beginning.
My source code is including the .INS file as following :
SUBROUTINE FINDSEC (SECTION, ISEC1,ISEC2)
C
c------no.mo.$debug.no.no.no
C
INCLUDE 'TAGLINE.INS'
C
C
CHARACTER*(*) SECTION
......rest of the subroutine
Thank you for your help
RECORD
and STRUCTURE
are not standard Fortran and not even a widely supported extension (at least in the days when f2c
was really relevant). It is a peculiar extension developed by DEC and hence kept in the later development of the DEC compiler (Compaq and Intel).
These extension have been ported to Gfortran a few years ago but are not supported in the very old compilers like g77
or f2c
or even in some current compilers. When compiling using gfortran, these extensions must by allowed by a special flag.
Your options are to rewrite the Fortran code to something that that f2c
understands or to translate the code yourself. Or, as people often do in this century, keep your Fortran (+DEC extensions) code, compile it using a current Fortran (+extensions) compiler and call the binary from C.