错误:参数列表中的语法错误(1)

时间:2016-11-08 12:53:30

标签: fortran gfortran

       implicit none
       character*20 fflname, oflname, oflname2
       integer      i, length, rn, s(100)
       real*8       phase_shift
       parameter    ( length = 32768, phase_shift = 0.02 )
       real*8       num, real_coeff, imag_coeff
       real*8       amplitude(length), phase(length)
      &            ,imag_coeff_ps(length), real_coeff_ps(length)

       oflname = "wvlt_coeff.data"
       oflname2 = "selection.data"
       fflname = "wvlt_coeff_ps.data"
       open(12, file = oflname)
       do i=1, length
          read(12, *) num, real_coeff, imag_coeff
          real_coeff_ps(i) = real_coeff
          imag_coeff_ps(i) = imag_coeff
       enddo
       close(12)
       open(13, file = oflname2)
       do i=1, 100
          read(13, *) rn
          s(i) = rn
       enddo   
       close(13)    

       do i=1, 100
          amplitude(i) = sqrt( real_coeff(s(i))**2 + imag_coeff(s(i))**2 )
          phase(i) = atan( imag_coeff(s(i))/real_coeff(s(i)) ) + phase_shift
          real_coeff_ps(s(i)) = amplitude(i) * cos( phase(i) )
          imag_coeff_ps(s(i)) = amplitude(i) * sin( phase(i) )
       enddo

       open(15, file = fflname)
       do i=1, length
          write(15, *) i, real_coeff_ps(i), imag_coeff_ps(i)
       enddo
       close(15)

       stop
       end

错误:

hyxie@ubuntu:~$ gfortran '/home/hyxie/Documents/20161012/phase_shift2.f' 
/home/hyxie/Documents/20161012/phase_shift2.f:35:40:

          amplitude(i) = sqrt( real_coeff(s(i))**2 + imag_coeff(s(i))**2 )
                                        1
Error: Syntax error in argument list at (1)
/home/hyxie/Documents/20161012/phase_shift2.f:36:36:

          phase(i) = atan( imag_coeff(s(i))/real_coeff(s(i)) ) + phase_shift
                                    1
Error: Syntax error in argument list at (1)

我的编码出了什么问题?

1 个答案:

答案 0 :(得分:0)

real_coeffimage_coeff不是数组,但您正在访问它们,就像它们一样。这会导致语法错误。也许您打算使用real_coeff_psimage_coeff_ps代替。