Hello everyone,
I am creating some 'generic' subroutines using transfer to move data between actual data type and an array of 1 byte characters.
I found that the use of the transfer function highlighted with a comment (***Error) in the following code doesn't work when I compile in CHECKMATE WIN32 mode, but works fine in DEBUG WIN32 mode.
I get a run time error that the character array is not defined when I run this in Plato. (In the FTN95 Express GUI it just crashes).
Is this a bug or am I missing something? Any help or information would be appreciated. I'm using Version 5.4 of FTN95 (as 5.5 doesn't seem to be available for download yet).
module increments
type Composite
integer :: i
real :: r
end type Composite
contains
subroutine incrementComposite(data)
character(len=1),intent(inout) :: data(:)
type(Composite) :: b
b = transfer(data, b)
b%r = b%r + 1.0
b%i = b%i + 1
print *, b%r, b%i
data = transfer(b,data) ! ***Error here when in CHECKMATE mode
end subroutine incrementComposite
subroutine incrementTenTimes(func, data)
character(len=1) :: data(:)
interface
subroutine func(data)
character(len=1),intent(inout) :: data(:)
end subroutine func
end interface
integer :: i
do i=1,10
call func(data)
end do
end subroutine incrementTenTimes
end module increments
program anon
use increments
type(Composite) :: b
character(len=1), allocatable :: data(:)
integer :: lengthData
b%i = 0
b%r = 0.0
lengthData = size(transfer(b,data))
allocate(data(lengthData))
data = transfer(b,data)
call incrementTenTimes(incrementComposite,data)
b = transfer(data,b)
deallocate(data)
pause
end program anon