Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29283 Discussions

does assigned go to work as it should ?

e745200
Beginner
4,048 Views

Hi,

having said that I am removing all obsolete features from the code I am working on, I think there is something incorrect in how Intel Fortran deals with assigned goto statements: it seems to ignore any list of labels.

According to the documentation, "If a list of labels appears, the statement label assigned to the variable must be one of the labels in the list."

Nevertheless, nothing special happens if this is not the case, and the programs flows as if the list of labels was not specified.

A short example will show it.

$ cat tassgoto.f90
      integer :: j

      assign 10 to j
      go to j , ( 1, 2 ) 
      print *, "d'oh"
      stop   

 1    print *, 1
      stop   
 2    print *, 2
      stop   
 10   print *, 10
      stop   
      end    

$ ifort -V tassgoto.f90
Intel(R) Fortran Intel(R) 64 Compiler for applications running 
on Intel(R) 64, Version 16.0.0.109 Build 20150815
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

 Intel(R) Fortran 16.0-1540
GNU ld version 2.20.51.0.2-5.42.el6 20100205

$ ./a.out
          10

Is there something I'm missing ?

0 Kudos
29 Replies
jimdempseyatthecove
Honored Contributor III
1,180 Views

Steve, is this valid

ASSIGN 10 TO ISOK1 ! 10 is valid label
ASSIGN 20 TO ISOK2 ! 20 is valid label
...
! I is supposed to be assigned to one or the other
IF(.NOT.((I .EQ. ISOK1) .OR. (I .EQ. ISOK2))) STOP "Bug"
GOTO I,(10,20)

IOW perform an IF statement using assigned integers

If this is permitted, then an "assert" could be inserted into the code to verify code is not doing unexpected behavior.

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
1,180 Views

No, not permitted. Quoting FORTRAN 77:

A variable must be defined with a statement label value when referenced in an assigned GO TO statement or as a format identifier in an input/output statement. While defined with a statement label value, the variable must not be referenced in any other way.

The method by which the ASSIGN is done is implementation-dependent. If I recall correctly, VAX FORTRAN-77 would store the address of the labeled statement/format, while DEC Fortran 90 stored some sort of index. We started seeing a small number of customer complaints when their code which assumed an address stopped working - they were saving the address and jumping to it from other locations in the program!

0 Kudos
mecej4
Honored Contributor III
1,180 Views

Just as we have IF(ALLOCATED(VAR))... and IF(ASSOCIATED(PTR))..., they could have provided IF(ASSIGNED(LABEL))..., but they did not. I have faint recollections of similar language design problems in Fortran 90 that were fixed in Fortran 95.

0 Kudos
Steven_L_Intel1
Employee
1,180 Views

Or they could have removed assigned GOTO from the language - which they did.

0 Kudos
e745200
Beginner
1,180 Views

Well, I might seem annoying, but I am keeping on investigating this issue just for my personal curiosity.

I finally found this run-time error message ( https://software.intel.com/en-us/node/525375 ) :

542

severe (542): Label not found in assigned GOTO list

FOR$IOS_F6098. The label assigned to the integer-variable name was not specified in the label list of the assigned GOTO statement.

Is this a residual of a no longer trapped error or there still is a way for activating/implementing the proper run-time-check ?

Was it an intention never implemented ?

I tried using the compiler option -check all but with no result.

0 Kudos
Steven_L_Intel1
Employee
1,180 Views

All I can tell you is that there is no code in the compiler today that will cause this diagnostic to be emitted. Maybe the message definition got brought over from another implementation, though it's not listed in my copy of the VAX Fortran User Manual. Perhaps it was a clue planted by ancient aliens. Dunno.

0 Kudos
e745200
Beginner
1,180 Views

That's ok: being projected towards the future, I think we can happily survive to this.   ;-)

Have a great holiday season !

 

0 Kudos
JVanB
Valued Contributor II
1,180 Views

Does this mean we can read into a Hollerith field in a FORMAT statement, and then use the ASSIGN statement and assigned GOTO to jump into the code we just inserted there? Why does ASSIGN require a default integer when the address size is 64 bits?

      PROGRAM P
      IMPLICIT NONE
      INTEGER I
      INTEGER K(3)
      DATA K/1836216166,840987745,538976304/
10    FORMAT(12HFORMAT 10   )
20    FORMAT(12HFORMAT 20   )
      DECODE(12,20,K)
      ASSIGN 20 TO I
      PRINT 20
      END PROGRAM P

 

0 Kudos
Steven_L_Intel1
Employee
1,180 Views

You cannot GOTO an assigned FORMAT label, but you can use it as a format.

Don't assume what is stored is an address. That's what bit the VAX users when they moved to the 64-bit Alpha platform.

0 Kudos
Reply