Power Programming Languages

Power Programming Languages

IBM Power, including the AIX, IBM i, and Linux operating systems, support a wide range of programming languages, catering to both traditional enterprise applications and modern development needs.


#Power

 View Only

Using complex part designators (Fortran 2008 new)

By Archive User posted Wed March 13, 2013 09:17 PM

  

Originally posted by: Ka_Lin


In the past, the intrinsic procedures REAL(z) and AIMAG(z) (where z is of type complex) were used to get the real part and imaginary part of z. For example,

COMPLEX :: z = (3.2, 2.1)

REAL(z) has the value 3.2.
AIMAG(z) has the value 2.1.


In Fortran 2008, you can use the complex part designators with the %RE and %IM selectors instead; that is,

z % RE has the value 3.2.
z % IM has the value 2.1.

You might benefit from the direct access to the real or imaginary part of complex entities by using the complex part designators as variables in assignment statements; typically when you want to directly set the real or imaginary part of a complex variable to a specific value. For example,

z % IM = 0.0 sets the imaginary part of z to zero.
 
(Authors: Ka Lin, Bardia Mahjour) 

#Fortran-Cafe-for-AIX
#C/C++andFortran
0 comments
0 views

Permalink