Using complex(x,y)

Steve Kargl sgk@troutmask.apl.washington.edu
Sun Mar 28 22:37:00 GMT 2010


On Mon, Mar 29, 2010 at 12:24:56AM +0200, Angelo Graziosi wrote:
> I have seen that GFortran accepts (at least on Cygwin with GCC-4.3.4) 
> the following code:
> 
> ===========
> program test_complex
>   implicit none
>   real :: x = 1.,y = 2.
>   complex :: z
>   z = complex(x,y)
>   print *, z
> end program test_complex
> =========================
> 
> The above code is built also using the option '-std=f95' or 
> '-std=f2003'. So, the question is: there is some standard to which 'z = 
> complex(x,y)' belongs?

It belongs to -std=gnu for compatibility with g77.  With 4.4.x
and 4.5.x, the above code fails to compile with -std=f95 or
-std=f2003.

> Should we regard 'complex(x,y)' as a 
> "constructor" or an intrinsic?

It's an intrinsic procedure.  See the manual for more
information.

-- 
Steve



More information about the Fortran mailing list