|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Kenneth_Smith
Joined: 18 May 2012 Posts: 711 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Tue Apr 25, 2023 10:37 am Post subject: z%re and z%im where z is an array |
|
|
The following code shows that the recently introduced z%re and z%im for working directly with the REAL and AIMAG parts of complex Z, does not work as expected when Z is an array.
Code: | program t
implicit none
complex z(2)
real :: d(2) = [1.0,2.0]
z = 0.0
z(1)%re = d(1)
z(1)%im = d(2)
print*, z ! Should return (1.0 + j*2.0) and (0.0 + j*0.0)
end program t |
FTN95 reports: error 378 - The '%' operator can only be applied to objects which are a derived type, which is not correct in this context. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8017 Location: Salford, UK
|
Posted: Tue Apr 25, 2023 2:05 pm Post subject: |
|
|
Ken
Thank you for the bug report. This particular usage has now been fixed for the next release of FTN95 but I guess that this issue needs more extensive testing and that other failures will come to light. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 711 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Wed Apr 26, 2023 4:04 pm Post subject: |
|
|
Thanks Paul.
Below is a small test program that uses these new features where the complex variables are in an array embedded within a defined type which you might like to test with your current version of FTN95.
Code: | program t
implicit none
type cw
complex, allocatable :: z(:)
end type
type(cw) :: z
allocate(z%z(2))
z%z(1) = ( 1.0, 2.0)
z%z(2) = (-1.0,-2.0)
print*, z%z%re ! Should return 1, -1
print*, z%z%im ! 2, -2
print*
z%z = 0.0
z%z%re = [ 10.0, 20.0]
z%z%im = [-10.0,-20.0]
print*, z%z%re ! Should return 10, 20
print*, z%z%im ! -10, -20
print*
deallocate(z%z)
z%z = [(1.0,2.0),(2.0,1.0)]
print*, z%z%re ! Should return 1, 2
print*, z%z%im ! 2, 1
end program t |
PS This one is interesting as only Ifort can run the code correctly:
Code: | program t
implicit none
type cw
complex, allocatable :: z(:)
end type
type(cw) :: z
z%z%re = [10.0,20.0,30.0] !Works with Ifort (allocate on assignment fails with gFortran)
print*, z%z%re ! should return 10, 20, 30
print*, z%z%im ! Undefined
end program t |
Last edited by Kenneth_Smith on Wed Apr 26, 2023 11:19 pm; edited 1 time in total |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8017 Location: Salford, UK
|
Posted: Wed Apr 26, 2023 7:00 pm Post subject: |
|
|
Thanks Ken.
I will make a note that this needs investigating. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8017 Location: Salford, UK
|
Posted: Fri May 05, 2023 11:45 am Post subject: |
|
|
These failures have now been fixed for the next release of FTN95.
At the moment I am assuming that "allocate on assignment" for z%z%re is not valid Standard Fortran. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|