Silverfrost Forums

Welcome to our forums

possible bug

5 Jun 2012 11:54 #10277

Hi:

I've found a possible bug in ftn95 v6.2 (personal edition) regarding sizes and shapes of arrays of derived data types. I'm running on cygwin under Win7 (output of uname is CYGWIN_NT-6.1-WOW64). Here's some code that prints out the output of the SIZE function from various references to an array of derived data types:

PROGRAM prog1
!
! Declare variables.
!
IMPLICIT NONE

INTEGER, PARAMETER :: VN=6
TYPE vel_pt_1Dstncl
  REAL, DIMENSION(-VN/2+1:VN/2) :: alpha_a
  CHARACTER(LEN=2), DIMENSION(-VN/2+1:VN/2-1) :: FL_code2_aph
END TYPE

INTEGER, PARAMETER :: NN=25
TYPE(vel_pt_1Dstncl), DIMENSION(NN) :: u_stncl
!
! Print out sizes of various arrays/ways of referring to arrays.
!
print*
print*, 'NN = ', NN
print*
WRITE(*,'(A,I19)') 'SIZE(u_stncl) = ', SIZE(u_stncl)
WRITE(*,'(A,I8)') 'SIZE(u_stncl%alpha_a(0)) = ', SIZE(u_stncl%alpha_a(0))
WRITE(*,'(A,I3)') 'SIZE(u_stncl%FL_code2_aph(0)) = ', SIZE(u_stncl%FL_code2_aph(0))
WRITE(*,'(A,I8)') 'SIZE(u_stncl(1)%alpha_a) = ', SIZE(u_stncl(1)%alpha_a)
WRITE(*,'(A,I3)') 'SIZE(u_stncl(1)%FL_code2_aph) = ', SIZE(u_stncl(1)%FL_code2_aph)
WRITE(*,'(A,I8)') 'SIZE(u_stncl(1:NN)%alpha_a(0)) = ', SIZE(u_stncl(1:NN)%alpha_a(0))
WRITE(*,'(A,I3)') 'SIZE(u_stncl(1:NN)%FL_code2_aph(0)) = ', SIZE(u_stncl(1:NN)%FL_code2_aph(0))

print*
print*, 'Done'

END

I used the following command to compile this code:

ftn95 /DREAL /BOUNDS_CHECK /ERROR_NUMBERS prog1.f90

Running the executable generates the following output:

NN = 25

SIZE(u_stncl) = 25 SIZE(u_stncl%alpha_a(0)) = 6 SIZE(u_stncl%FL_code2_aph(0)) = 5 SIZE(u_stncl(1)%alpha_a) = 6 SIZE(u_stncl(1)%FL_code2_aph) = 5 SIZE(u_stncl(1:NN)%alpha_a(0)) = 6 SIZE(u_stncl(1:NN)%FL_code2_aph(0)) = 5

I also compiled and ran this code with Intel's ifort compiler (version 10.0, 64bit) under linux. The output of that run is as follows:

NN = 25

SIZE(u_stncl) = 25 SIZE(u_stncl%alpha_a(0)) = 25 SIZE(u_stncl%FL_code2_aph(0)) = 25 SIZE(u_stncl(1)%alpha_a) = 6 SIZE(u_stncl(1)%FL_code2_aph) = 5 SIZE(u_stncl(1:NN)%alpha_a(0)) = 25 SIZE(u_stncl(1:NN)%FL_code2_aph(0)) = 25

Done

We can see that the second, third, sixth, and seventh SIZE commands give different results with ftn95 vs. with ifort. I think ifort is correct in this case since according to my understanding, e.g. u_stncl%alpha_a(0) represents the alpha_a(0) member of all elements of the array u_stncl, and since u_stncl has dimension 25, u_stncl%alpha_a(0) should also have dimension 25 (regardless of the dimension of alpha_a). I also used gfortran on cygwin to test out this code, and the results were identical to those of ifort.

This bug of course causes other problems in the code. I found this bug while trying to create a mask in a WHERE statement.

I'm not sure if this bug is fixed in ftn95 version 6.3 because I was not able to download the personal edition of v6.3 (the latest available for download is v6.2).

Thanks for your help.

6 Jun 2012 6:55 #10278

I have logged this for investigation.

6 May 2019 4:15 #23582

This bug has finally been fixed. The fix will be in the next release of FTN95.

7 May 2019 2:13 #23583

Paul, the example code made be curious, and I find that the 8.40 compiler fails to compile the following variation of the same code:

PROGRAM prog1
IMPLICIT NONE
!
INTEGER, PARAMETER :: VN=6
TYPE vel_pt_1Dstncl
  REAL, DIMENSION(-VN/2+1:VN/2) :: alpha_a
END TYPE
!
INTEGER, PARAMETER :: NN=5
TYPE(vel_pt_1Dstncl), DIMENSION(NN) :: u_stncl
integer i
!
u_stncl%alpha_a(0)=[ (i*0.5,i=1,size(u_stncl%alpha_a(0))) ]
WRITE(*,'(ES12.4)') u_stncl%alpha_a(0)
!
END

The expected output is

  5.0000E-01
  1.0000E+00
  1.5000E+00
  2.0000E+00
  2.5000E+00

FTN95 says

[FTN95/Win32 Ver. 8.40.1 Copyright (c) Silverfrost Ltd 1993-2018]
0013) u_stncl%alpha_a(0)=[ (i*0.5,i=1,size(u_stncl%alpha_a(0))) ]
*** Compilation abandoned
7 May 2019 6:55 #23584

Thanks. I will see if this now works with the latest fix.

7 May 2019 2:05 #23585

For a moment I thought 'Wow, this guy is using really old stuff!', then I realised that the original post was 7 years ago. Some bugs really do take some tracking down.

Is this a record?

Eddie

7 May 2019 7:39 #23586

In some way it could be.

7 May 2019 8:38 #23587

As to record, the crash of property sheet could be one. Crash disappearing when you run the program under debugger, if i make a small demo, and if you give the code to somebody else. Go figure what it is and how to debug...

23 May 2019 9:17 #23619

mecej4

Your code runs successfully under v8.50.

Dan

The list of bugs that need fixing makes no reference to property sheets. Please send me some sample code so that I can confirm that it is a ClearWin+ bug and (if it is) add it on the list.

Please login to reply.