Silverfrost Forums

Welcome to our forums

Compilation for simple code exaple fails with option /opt

3 Jun 2016 12:28 #17542

Usually I perform FTN95 compilation with the option /check and without /opt. Everything went fine. No, for better performance, I applied /opt without /check. As a consequence some of my files can no longer be compiled. I could reduce the code for one of my files to a rather small code example:

Subroutine Thomas ()
Implicit None

Type Zeile1
     Character (len= 2) :: cnrz
     Character (len=12) :: cbez
     Character (len= 8) :: chhz
     Character (len= 1) :: cvwo(8)
End Type Zeile1

Integer, Parameter   :: WTP_mx_fzz = 18
Character (len=1500) :: VAR
Type (Zeile1)        :: frz(WTP_mx_fzz)
Integer              :: i, j

1001  FORMAT (18(A2,A12,A8,8A1))

var = ' '
read  (var, 1001) (frz(i)%cnrz, &
                   frz(i)%cbez, &
                   frz(i)%chhz, &
                   (frz(i)%cvwo(j),j=1,8),i=1,18)

end

Who can check, what is going wrong? Who made similar experiences?

3 Jun 2016 3:45 (Edited: 3 Jun 2016 9:35) #17545

The 7.20 compiler says:

*** Operand incompatible with opcode 1 ERROR [<THOMAS> FTN95/Win32 v7.20.0] *** Compilation failed

I agree that the compiler has a bug, since the code is fine, and the bug should be fixed.

In the meantime, you may work around the bug by rearranging your internal read statement as

*** Compilation failed

I agree that the compiler has a bug, since the code is fine, and the bug should be fixed.

In the meantime, you may work around the bug by rearranging your internal read statement as [quote:3e0aafd044]read (var, 1001) (frz(i)%cnrz, frz(i)%cbez, frz(i)%chhz, frz(i)%cvwo,i=1,18)

3 Jun 2016 8:48 #17546

Thank you for your quick response and your assistance.

I have been using ftn95 and beforehand ftn77 now for decades with good success. Whenever a problem occured, it was sorted out latest with the next release.

4 Jun 2016 6:05 #17547

Thank you for the feedback. I have logged this for investigation.

Please note that you will get faster code simply by not using /check and similar debugging options. /opt may give improved performance. As a temporary work-around, in the present case, you can use /opt with /inhibit_opt 30.

13 Jun 2016 3:15 #17654

All my code is meanwhile compiled with /optimise except of one subroutine, which end with an runtime error, when compiled with /optimise. I could reduce the source code to a relatively small program to make diagnostic possible:

program Thomas1
character (len=5) :: string
integer           :: ii

string  = '   34'
call priumw (string, ii)

end program

!-------------------------------------------------------------------------------

Subroutine PRIUMW(CC,II)
Character (len=*)  :: CC
Integer            :: II

Integer            :: I, LAENGE
Character (len=25) :: C25
Character (len= 1) :: C(25), SPACE

100   FORMAT(25A1)
200   FORMAT(I25)

SPACE  = ' '
LAENGE = LEN(CC)

READ  (CC,100) (C(I),I=1,LAENGE)
CALL FORPRF(C,LAENGE)

M = 25-LAENGE
WRITE (CC, 100) (C(I),I=1,LAENGE)
WRITE (C25,100) (SPACE,I=1,M),(C(I),I=1,LAENGE)
READ  (C25,200) II

END

!-------------------------------------------------------------------------------

Subroutine FORPRF(A,N)
Integer           :: N
Character (len=1) :: A(N)

Character (len=1) :: B(100),AA
Integer           :: I,JJ,J1

JJ   = N

DO I=1,N
   J1 = N+1-I
   AA = A(J1)
   IF (AA == '1' .or. AA == '2'. or.AA == '3'. or.AA == '4' .or. &
       AA == '5' .or. AA == '6'. or.AA == '7'. or.AA == '8' .or. &
       AA == '9' .or. AA == '0') then
      B(JJ) = AA
      JJ    = JJ-1
   end if
END DO

DO I=1,JJ
   B(I) = ' '
END DO

DO I=1,N
   A(I) = B(I)
END DO

END

The program does not make sense anymore. It's just for demonstration. When comiled with /-optimise, it works well. When comiled with /optimise an run time error 'Error 52, Invalid character in field' appears.

14 Jun 2016 8:13 #17658

Thomas, This does not answer your question, but I have been considering the use of the SCAN intrinsic, which could be used in your FORPRE routine. Typically I would use INDEX, but SCAN appears more suitable. Both alternatives do not have a problem with /opt. Subroutine FORPRF (A,N) Integer :: N Character (len=1) :: A(N) !
Character (len=1) :: AA Integer :: I,J !
J = N

   DO I=N,1,-1
      AA = A(I)
      A(I) = ' ' 
!      IF (INDEX ('1234567890', AA) <= 0) cycle
      IF (SCAN (AA, '1234567890') <= 0) cycle
      A(J) = AA 
      J    = J-1 
   END DO 
!
 END 

John

14 Jun 2016 11:17 #17664

I have made a not of the /opt failure. A work-around is to also use /inhibit_opt 40.

19 Jan 2017 3:55 #18722

This bug has been fixed for the next release.

Please login to reply.