Silverfrost Forums

Welcome to our forums

Problem DATA/EQUIVALENCE Statement

18 May 2017 10:34 #19643

When using the DATA and EQUIVALENCE statement twice with respect to 2 strings and 2 integer arrays the contents of the second integer array does not correspond to the contents of the data statement.

      CHARACTER*16
     *MYTXT1,     
     *MYTXT2
     
      INTEGER*4    
     *MYIARRAY1(4), 
     *MYIARRAY2(4)
                                                  
      EQUIVALENCE(MYTXT1,MYIARRAY1)                           
      EQUIVALENCE(MYTXT2,MYIARRAY2)                           
      
      DATA MYIARRAY1 /
     *11 ,  12 ,  13 ,  14 /
      DATA MYIARRAY2 /
     *21 ,  22 ,  23 ,  24 /
      
      write(2,'(A13,I16,2X,A16,I32)') 'MYIARRAY1(1)=',MYIARRAY1(1),
     *'LOC(MYIARRAY1(1))=',LOC(MYIARRAY1(1))
      write(2,'(A13,I16,2X,A16,I32)') 'MYIARRAY2(1)=',MYIARRAY2(1),
     *'LOC(MYIARRAY2(1))=',LOC(MYIARRAY2(1))
      stop
      end

The 64 bit executable prints the lines

MYIARRAY1(1)=21 LOC(MYIARRAY1(1))= 4214896 MYIARRAY2(1)=21 LOC(MYIARRAY2(1))= 4214896

However, we expect both the values of MYIARRAY1(1) and MYIARRAY2(1) and their locations to be different, respectively.

The 32 bit version of the code printes then lines

MYIARRAY1(1)=11 LOC(MYIARRAY1(1))= 4210704 MYIARRAY2(1)=21 LOC(MYIARRAY2(1))= 4210688

which matches my expectations.

If commenting/deactivating the second EQIVALENCE statement and creating the corresponding 64 bit executable, the 64 bit executable prints

MYIARRAY1(1)=11 LOC(MYIARRAY1(1))= 4214896 MYIARRAY2(1)=21 LOC(MYIARRAY2(1))= 4214912

which again matches my expectations.

Regards, Dietmar

19 May 2017 12:23 #19646

There is definitely a problem with /64. I tested in Plato with Debug x64. I initially tried to separate the definitions, but that did not fix the problem. Commenting out the data definition on lines 4 and 8 removes the reported error for /64 ( or the data statements in the original post)

c  equiv.for
c
       CHARACTER*16 MYTXT1
       INTEGER*4 :: MYIARRAY1(4)  = (/ 11 ,  12 ,  13 ,  14 /)
       EQUIVALENCE (MYTXT1,MYIARRAY1)
c
       CHARACTER*16 MYTXT2
       INTEGER*4 :: MYIARRAY2(4)  = (/ 21 ,  22 ,  23 ,  24 /)
       EQUIVALENCE (MYTXT2,MYIARRAY2)
c       
       write (*,*) 'mytxt1   ',loc (mytxt1)
       write (*,*) 'mytxt2   ',loc (mytxt2)
       write (*,*) 'MYIARRAY1',loc (MYIARRAY1)
       write (*,*) 'MYIARRAY2',loc (MYIARRAY2)
c
       MYIARRAY1 = (/ 11 ,  12 ,  13 ,  14 /)
       MYIARRAY2 = (/ 21 ,  22 ,  23 ,  24 /)
c
       write (2,'(A13,I16,2X,A16,I32)') 'MYIARRAY1(1)=',MYIARRAY1(1),
     *  'LOC(MYIARRAY1(1))=',LOC(MYIARRAY1(1)) 
       write (2,'(A13,I16,2X,A16,I32)') 'MYIARRAY2(1)=',MYIARRAY2(1), 
     *  'LOC(MYIARRAY2(1))=',LOC(MYIARRAY2(1)) 
       stop 
c
       end
19 May 2017 8:05 #19648

I have made a note that this needs fixing.

5 Jun 2017 2:46 #19715

This has now been fixed for the next release of FTN95.

Please login to reply.