forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

z%re and z%im where z is an array

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Kenneth_Smith



Joined: 18 May 2012
Posts: 697
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Tue Apr 25, 2023 10:37 am    Post subject: z%re and z%im where z is an array Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Tue Apr 25, 2023 2:05 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 697
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Wed Apr 26, 2023 4:04 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Wed Apr 26, 2023 7:00 pm    Post subject: Reply with quote

Thanks Ken.

I will make a note that this needs investigating.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7924
Location: Salford, UK

PostPosted: Fri May 05, 2023 11:45 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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