Fortran Coder

标题: 关于函数中数组的问题 [打印本页]

作者: xxdw    时间: 2021-11-2 19:38
标题: 关于函数中数组的问题
[Fortran] 纯文本查看 复制代码
 Module LegendreSeries
    USE set_parameter
    IMPLICIT NONE
   
    INTEGER*4::Degree,DegreeCount !count是勒让德多项式的维度

    REAL*8,private::t1
    REAL*8,private::t2
    REAL*8,private::y1
    REAL*8,private::y2
    REAL*8 by1,by2,tmp
    INTEGER*4 m,n,i
   
    contains
    FUNCTION xdw_LegendreFunction(theta1,theta2,Degree) RESULT(LendrendIntegration)
    USE set_parameter
    IMPLICIT NONE
    REAL*8            ::theta1,theta2
    INTEGER*4         ::Degree,DegreeCount
    !REAL*8,ALLOCATABLE::LendrendIntegration(:,:)
    !REAL*8,ALLOCATABLE::Lendrend1(:,:)
    !REAL*8,ALLOCATABLE::Lendrend2(:,:)
    REAL*8::LendrendIntegration(DegreeCount,1)
    REAL*8::Lendrend1(DegreeCount,1)
    REAL*8::Lendrend2(DegreeCount,1)
    DegreeCount = (Degree*Degree+Degree)/2+Degree+1
    !ALLOCATE(LendrendIntegration(DegreeCount,1))
    !ALLOCATE(Lendrend1(DegreeCount,1))
    !ALLOCATE(Lendrend2(DegreeCount,1))
     
    t1 = cos(theta1)
    t1 = cos(theta1)
    y1=sqrt(1d0-t1**2)
    y2=sqrt(1d0-t2**2)
    Legendre1(1)=1d0
    Legendre1(2)=sqrt(3d0)*t1
    Legendre1(3)=sqrt(3d0)*y1
    Legendre1(4)=sqrt(5d0)*(3d0*t1**2-1d0)/2d0
    Legendre1(5)=sqrt(15d0)*t1*y1
    Legendre1(6)=sqrt(15d0)*y1**2/2d0
Legendre2(1)=1d0
    Legendre2(2)=sqrt(3d0)*t2
    Legendre2(3)=sqrt(3d0)*y2
    Legendre2(4)=sqrt(5d0)*(3d0*t2**2-1d0)/2d0
    Legendre2(5)=sqrt(15d0)*t2*y2
    Legendre2(6)=sqrt(15d0)*y2**2/2d0
    LegendreIntegration(1)=t2-t1
    LegendreIntegration(2)=sqrt(3d0)*(t2**2-t1**2)/2d0
    LegendreIntegration(3)=sqrt(3d0)*(t2*y2-theta2-t1*y1+theta1)/2d0
    LegendreIntegration(4)=sqrt(5d0)*(t1*y1**2-t2*y2**2)/2d0
    LegendreIntegration(5)=sqrt(5d0/3d0)*(y1**3-y2**3)
    LegendreIntegration(6)=sqrt(5d0/12d0)*(3d0*t2-t2**3-3d0*t1+t1**3)


这是写的一个勒让德函数的前边的一部分代码,
报错说
[Fortran] 纯文本查看 复制代码
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(35): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(36): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(37): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(38): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(39): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(40): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(42): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(43): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(44): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(45): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(46): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(47): error #6410: This name has not been declared as an array or a function.   [LEGENDRE2]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(48): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(49): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(50): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(51): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(52): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(53): error #6410: This name has not been declared as an array or a function.   [LEGENDREINTEGRATION]
D:\01 AOD\AODFortran\xdw_CalAOD\xdw_CalAOD\xdw_LegendreFunction.f90(56): error #6410: This name has not been declared as an array or a function.   [LEGENDRE1]




可是不是已经声明了数组的大小了么,之前写的是ALLOCATE的写法,不行之后改成了直接赋值数组大小的,还是有错误,这个怎么办呢?

作者: xxdw    时间: 2021-11-2 20:00
太蠢了,名字输错了、

见笑了属于是
作者: fcode    时间: 2021-11-2 21:09
好的,你写了 implicit none ,这个问题就比较容易找了。如果没写,那可能更隐蔽。
作者: xxdw    时间: 2021-11-3 22:29
fcode 发表于 2021-11-2 21:09
好的,你写了 implicit none ,这个问题就比较容易找了。如果没写,那可能更隐蔽。 ...


难受住了





欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2