trouble with initializing array of complex type
- From: "qsc" <qingshan.chen@xxxxxxxxx>
- Date: 24 Jan 2007 06:44:55 -0800
Hi,
This problem seems strange to me. Hope I can get some help or hint from
you.
Let's first look at this following code:
************************CODE
1******************************************
program cmpx_init
complex, dimension(1:9):: a0
integer:: i
do i = 1,9
a0(i) = (0.1*i, 0.1*i)
end do
write(*,*) a0
end program cmpx_init
*************************************************************************
When compiled with g95, it gives me this error message:
In file cmpx_init.f90:6
a0(i) = (0.1*i, 0.1*i)
1
Error: Expected a right parenthesis in expression at (1)
With PGI Fortran 90 compiler, it also gives an error at this step.
I found out that the problem is with the variable "i" in the
initialization
expression, that is, when that expression is replaced by "a0(i) = (0.1,
0.1)",
the code will compile. What strikes me most is that the following code,
for a
real type array, compiles without any error or warning message. How can
a real array and a
complex array be treated so differently?
*****************************CODE
2****************************************
program real_init
real, dimension(1:9):: a0
integer:: i
do i = 1,9
a0(i) = 0.1*i
end do
write(*,*) a0
end program real_init
******************************************************************************
Any input is welcome. Programming with Fortran is really a hard thing,
to me.
Best regards,
Qingshan
.
- Follow-Ups:
- Re: trouble with initializing array of complex type
- From: Les
- Re: trouble with initializing array of complex type
- From: Paul van Delst
- Re: trouble with initializing array of complex type
- From: Steve Lionel
- Re: trouble with initializing array of complex type
- Prev by Date: Re: What is the option for ifort to stop at first statement in IF
- Next by Date: Re: trouble with initializing array of complex type
- Previous by thread: Where to place IMPLICIT NONE
- Next by thread: Re: trouble with initializing array of complex type
- Index(es):
Relevant Pages
|