forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compilation for simple code exaple fails with option /opt

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Thomas



Joined: 18 Feb 2005
Posts: 56
Location: Gummersbach, Germany

PostPosted: Fri Jun 03, 2016 1:28 pm    Post subject: Compilation for simple code exaple fails with option /opt Reply with quote

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:

Code:

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?
_________________
Thomas
Back to top
View user's profile Send private message Visit poster's website
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Fri Jun 03, 2016 4:45 pm    Post subject: Reply with quote

The 7.20 compiler says:
Quote:
*** 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
Quote:
read (var, 1001) (frz(i)%cnrz, frz(i)%cbez, frz(i)%chhz, frz(i)%cvwo,i=1,18)


Last edited by mecej4 on Fri Jun 03, 2016 10:35 pm; edited 1 time in total
Back to top
View user's profile Send private message
Thomas



Joined: 18 Feb 2005
Posts: 56
Location: Gummersbach, Germany

PostPosted: Fri Jun 03, 2016 9:48 pm    Post subject: Reply with quote

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.
_________________
Thomas
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Jun 04, 2016 7:05 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Thomas



Joined: 18 Feb 2005
Posts: 56
Location: Gummersbach, Germany

PostPosted: Mon Jun 13, 2016 4:15 pm    Post subject: Runtime error with /optimise Reply with quote

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:
Code:

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.
_________________
Thomas
Back to top
View user's profile Send private message Visit poster's website
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Jun 14, 2016 9:13 am    Post subject: Reply with quote

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.
Code:
 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
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Jun 14, 2016 12:17 pm    Post subject: Reply with quote

I have made a not of the /opt failure. A work-around is to also use /inhibit_opt 40.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Thu Jan 19, 2017 4:55 pm    Post subject: Reply with quote

This bug has been fixed for the next release.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group