converting from microsoft fortran

Tobias Burnus burnus@net-b.de
Sun Jun 30 06:23:00 GMT 2013


Donald Sheriff wrote:
>       9KARK*23(4)/'BS6399-BASIC CODE-SYM  ',
>                      1
> Error: Syntax error in data declaration at (1)
>
> (The error is at the left bracket if the spacing doesn't show)
> The full program is here:
> https://dl.dropboxusercontent.com/u/52473465/wnsndt2.for
>
> Can anyone help me with the gcc syntax?

The code declares a character array as
   CHARACTER KARK*23(4)
which is not permitted. You could replace it by
   CHARACTER*23 KARK(4)

(The latter syntax is according to the Fortran standard (Fortran 77, 90, 
95, 2003, 2008) and should be accepted by all Fortran compilers.)

That modification seems to be sufficient to make the code compile with 
gfortran.

* * *

The code uses also other vendor extensions (which are supported by 
gfortran). To make the code conforming with the ISO/IEC Fortran 
standard, some more modificiations are required; e.g. the initialization 
with /.../ is only permitted with DATA and not in with the variable 
declaration, i.e.
       CHARACTER*1 CLASS(3) /'A','B','C'/
should be
       CHARACTER*1 CLASS(3)
       DATA CLASS/'A','B','C'/
or (since Fortran 90 and later)
       CHARACTER*1 :: CLASS(3) = (/ 'A', 'B', 'C' /)

But if you just want to compile it with gfortran, you don't need those 
as gfortran supports this initialization as vendor extension.

Tobias


--- wnsndt2.for.orig    2013-06-29 16:31:07.258765843 +0200
+++ wnsndt2.for 2013-06-29 16:33:30.034489250 +0200
@@ -101,3 +101,3 @@
       +S3FACT(8),TS3FACT(9),S2MULT(4)
-c      CHARACTER CLASS*1(3) /'A','B','C'/
+      CHARACTER*1 CLASS(3) /'A','B','C'/
        DATA
@@ -194,5 +194,5 @@
       +SBKM(4),RMUL(4),SBB(4),RMD(4),CHKS(4),RMU1(4),DALT(4)
-      CHARACTER
+      CHARACTER*23
  C     9LCA*4(2)/'    ','(CS)'/,
-     9KARK*23(4)/'BS6399-BASIC CODE-SYM  ',
+     9KARK(4)/'BS6399-BASIC CODE-SYM  ',
       9           'BS6399-BASIC CODE-ASYM',



More information about the Gcc-help mailing list