Silverfrost Forums

Welcome to our forums

FORTRAN not compiling

30 Jan 2012 12:55 #9535

Hi folks,

I have an old FORTRAN program for Markov Chain analysis, it was written in FORTRAN77. I've tried to run it in FORTRAN77 but it hasn't worked so I tried to run it in free format FORTRAN, however I get the following errors:

C:\Users...: error 32 - Statement no recognised C:\Users...: error 399 - Unrecognised statement, did you forget to add /FIXED_FORMAT?

Here's some of the FORTRAN code I'm using:

      PROGRAM ORDER
c
c  PROGRAM FOR FINDING DEGREE OF ORDER IN EMPRICAL TRANSITION TALLEY MATRIX,
c     USING CONCEPTS FROM INFORMATION THEORY
c  SUBROUTINE CONVG POWERS INITIAL HY(X) PROB. MATRIX TO EQUILIBRIUM FOR REGULAR
c     MATRICES ONLY
c  SUBROUTINE MARKOV PRODUCES -2LOGE VALUE FOR TESTING MARKOV TENDENCY  OF HY(X)
c      MATRIX WITH NO ZERO ELEMENTS.  IF ZERO ELEMENTS, D.F. ADJUSTED BY
c     KRUMBEINS METHOD (1967).
c
      DIMENSION TOTJ(11),TOTI(11)
      DIMENSION HYX2(11),B(11),C(11),BR(11),CR(11),RXR(11),HYX1(11)
      DIMENSION RES(11,11),CTOT(11,11),RET(11),ROT(11)
      DIMENSION PRTO(11,11),PCTO(11,11)
      COMMON RTOT(11,11),AB(11,11)
      COMMON/MARK/ TM(11,11),XR(11,11),CXR(11),jo(11,11)
c  Input file (1) has OTM data. But note that a new line 1 has to be inserted.
c  leave a single space between following variables
c NS=NUMBER OF MATRICES TO BE ASSESSED
c ICONV  0=CONVERGENCE REQUIRED, 1=NOT REQUIRED
c IMARK  0=MATRIX ORDER, 1=MATRIX ORDER PLUS MARKOV TEST
c IN= MATRIX POWER FOR CONVERGENCE
c N=NUMBER OF STATES IN (NS) MATRIX
c
c  Output (2) is a screen file of OTM and Markov tests
c
      open(1,file='mh4otm.58-01',status='old',form='formatted')
      open(2,file='mh4order.58-01',status='new',form='formatted')
      READ(1,*)NS,ICONV,IMARK,in,n
      DO 100 KI=1,NS
      Write(2,22)ki
22    FORMAT(1h ,10x,i3,1x,15hSTEP TRANSITION/)
C
C FINDING MAX ENTROPY OF VECTOR AND MATRIX OF (N) STATES
C
      ZT=FLOAT(N)
      XT=ZT**2
      HT=ALOG2(XT)
      HM=ALOG2(ZT)
C
C AA(I)=INPUT FORMAT OF MATRIX, BY VECTORS
C
      DO 21 I=1,N
21    READ(1,*)(jo(I,J),J=1,N)
      do 211, i=1,n
      do 211, j=1,n
211   tm(i,j)=float(jo(i,j))
      DO 101 J=1,N
      DO 101 I=1,N
      TOTI(I)=0.0
      TOTJ(J)=0.0
      RXR(I)=0.0
      CXR(J)=0.0
      HYX1(I)=0.0
101   HYX2(I)=0.0
C
C DERIVE H(X,Y) PROB. MATRIX
C
      DO 5 J=1,N
      DO 5 I=1,N
      TOTJ(J)=TOTJ(J)+TM(I,J)
5     TOTI(I)=TOTI(I)+TM(I,J)
      MN=0
      DO 102 I=1,N
102   MN=MN+TOTI(I)
      DO 3 J=1,N
      DO 3 I=1,N
4     XR(I,J)=TM(I,J)/MN
3     CONTINUE
C
C ACTUAL ENTROPY OF H(X,Y) MATRIX
C
      HXY=0.0
      DO 11 J=1,N
      DO 11 I=1,N
      IF(XR(I,J))112,112,111
112   RES(I,J)=0.0
      GOTO 11
111   RES(I,J)=XR(I,J)*(ALOG2(1.0/XR(I,J)))
11    HXY=HXY+RES(I,J)
      HXY=ABS(HXY)
C
C DERIVATION  OF ROW AND COLUMN CONDITIONAL PROBS.
C     HY(X) AND HX(Y)
C
      DO 7 J=1,N
      DO 7 I=1,N
      IF(TOTI(I))703,703,70
703   RTOT(I,J)=0.0
      GOTO 701
70    RTOT(I,J)=TM(I,J)/TOTI(I)
701   IF(TOTJ(J))704,704,702
704   CTOT(I,J)=0.0
      GOTO 7
702   CTOT(I,J)=TM(I,J)/TOTJ(J)
7     CONTINUE
C
C ENTROPY AND REDUNDANCY OF EQUILIBRIUM HY(X)
C
      IF(ICONV)72,72,71
72    CALL CONVG(N,IN,K,HIND,RIND)
30 Jan 2012 1:41 #9536

The code that you included (incomplete, possibly truncated because of limits imposed by the forum software) is not valid free-form Fortran. For instance, comments come after '!', not with 'C' or 'c' in column-1.

Give the source file an extension of .f or .for and compile.

When you report problems, state which compiler options you used and state the compiler and OS versions.

30 Jan 2012 6:11 #9537

This will never compile in free format - not without lots of editing.

My advice: get it working in fixed format first. It looks like it should compile (well, the fragment that we can see from the forum).

You will get into some minor difficulties with units 1 and 2 for input and output.

Now I'm a dinosaur even by Fortran standards, but this code has stuff in it that goes back to the 1960's - arithmetic IF statements, Hollerith character constants etc. It looks more like Fortran 66 than Fortran 77. Send me a private message for an e mail if you want me to sort it out for you - I should have the time, I'm retiring tomorrow, and it looks like a 10 minute job!

Eddie

30 Jan 2012 8:56 #9540

Quoted from LitusSaxonicum This will never compile in free format - not without lots of editing.

My advice: get it working in fixed format first. It looks like it should compile (well, the fragment that we can see from the forum).

You will get into some minor difficulties with units 1 and 2 for input and output.

Now I'm a dinosaur even by Fortran standards, but this code has stuff in it that goes back to the 1960's - arithmetic IF statements, Hollerith character constants etc. It looks more like Fortran 66 than Fortran 77. Send me a private message for an e mail if you want me to sort it out for you - I should have the time, I'm retiring tomorrow, and it looks like a 10 minute job!

Eddie

PM sent.

31 Jan 2012 6:54 #9541

look at the /convert option in FTN95

Please login to reply.