Error: Expected PARAMETER symbol in complex constant at (1)
fortran
Solution
You have to use
v(i) = cmplx(tmp, 0.0)
Your syntax `(re, im)` works only for constant expressions, i.e. when `re` and `im` are real or integer constants.
This means you cannot make a complex constant from a real variable and a real constant. You have to use the intrinsic function `cmplx` which converts `real` variables to `complex` ones, or builds `complex` variables from pairs of `real` variables (or integer).
Problem
I am writing a small piece of Fortran 90 code to compute some quantities using complex variables. I have a subroutine with the following instructions: ``` complex, dimension(3) :: v integer :: i real:: tmp do i = 1,3 tmp = vg(i) v(i) = (tmp, 0.0) enddo ``` `v` is a complex array of length 3. `vg` is an array of length 3 too whose elements are real. When I compile the above code with gfortran 4.7.3 I get the following error: ``` v(i) = (tmp,0.0) Error: Expected PARAMETER symbol in complex constant at (1) ``` I do not understand what's the problem.