The following code demonstrates a failure of the X64 compiler where the definition of an allocatable derived type (which itself contains an allocatable element) is present.
The fault occurs in the subroutine initial. After XMIN is allocated, the content of A from the module FIT is copied over to XMIN. This copy fails and the contents of XMIN are incorrect as can be seen by running the code complied with both WIN32 and X64 and comparing the printed terminal output.
If one of the two lines indicated are commented out, the code runs correctly with both WIN32 and X64, i.e. the presence of an allocatable derived type with an allocable element is removed. In the much larger code, all the unallocated arrays were actually allocated, but adding the copy operation caused all the numerical results to go awry.
Note that the presence of the protected attribute on variable A in module FIT has no impact on this – but is one of the reasons for the required copy.
module fit
implicit none
integer, parameter, private :: dp=kind(1.d0)
integer, parameter :: n = 2
real(dp), protected :: a(1:n) = [-1.d0,2.d0]
end module fit
module casper_mod
use fit
implicit none
integer, parameter :: dp = kind(1.d0)
type mytype
integer(2), allocatable :: intVal(:) ! Comment out this line
real(dp) :: fit
end type mytype
real(dp), allocatable :: xmin(:)
type(mytype), allocatable :: pop(:) ! Comment out this line
integer :: probSize
contains
subroutine casper
probSize = n
call initial
end subroutine casper
subroutine initial
allocate(xmin(1:probSize))
xmin = a !Copy from minx to xmin fails
print*, xmin !Does not return -1.0, 2.0 when compiled with X64
end subroutine initial
end module Casper_mod
program t
use Casper_mod
implicit none
call casper
end program t