Copyright (C) 2000-2012 |
GNU Info (g77-300.info)REAL() and AIMAG() of Complex`REAL()' and `AIMAG()' of Complex --------------------------------- The GNU Fortran language disallows `REAL(EXPR)' and `AIMAG(EXPR)', where EXPR is any `COMPLEX' type other than `COMPLEX(KIND=1)', except when they are used in the following way: REAL(REAL(EXPR)) REAL(AIMAG(EXPR)) The above forms explicitly specify that the desired effect is to convert the real or imaginary part of EXPR, which might be some `REAL' type other than `REAL(KIND=1)', to type `REAL(KIND=1)', and have that serve as the value of the expression. The GNU Fortran language offers clearly named intrinsics to extract the real and imaginary parts of a complex entity without any conversion: REALPART(EXPR) IMAGPART(EXPR) To express the above using typical extended FORTRAN 77, use the following constructs (when EXPR is `COMPLEX(KIND=2)'): DBLE(EXPR) DIMAG(EXPR) The FORTRAN 77 language offers no way to explicitly specify the real and imaginary parts of a complex expression of arbitrary type, apparently as a result of requiring support for only one `COMPLEX' type (`COMPLEX(KIND=1)'). The concepts of converting an expression to type `REAL(KIND=1)' and of extracting the real part of a complex expression were thus "smooshed" by FORTRAN 77 into a single intrinsic, since they happened to have the exact same effect in that language (due to having only one `COMPLEX' type). _Note:_ When `-ff90' is in effect, `g77' treats `REAL(EXPR)', where EXPR is of type `COMPLEX', as `REALPART(EXPR)', whereas with `-fugly-complex -fno-f90' in effect, it is treated as `REAL(REALPART(EXPR))'. Note: Ugly Complex Part Extraction, for more information. |