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.