主题:请各位老师来改改程序
我刚学FORTRAN,编了个小程序,怎么也搞不定,希望各位前辈指点下怎么改
MODULE INTEGRAL
IMPLICIT NONE
CONTAINS
REAL FUNCTION WSVSP_Integral(PP,H)
IMPLICIT NONE
REAL::S,S1,K,H,W,N
REAL::PP(:),A(:)
N=SIZE(PP)
A=0
DO K=1,N
A(2*K-1)=A(2*K-1)+1
A(2*K)=A(2*K)+4
A(2*K+1)=A(2*K+1)+1
ENDDO
DO K=1,N
S1=A(K)*PP(K)
S=S+S1
ENDDO
W=H/6*S
RETURN
END FUNCTION WSVSP_Integral
END MODULE INTEGRAL
PROGRAM TEST1401
USE INTEGRAL
IMPLICIT NONE
REAL,ALLOCATABLE :: PP(:)
REAL,ALLOCATABLE :: X(:)
REAL,ALLOCATABLE :: A(:)
REAL::H,P,Q,M,S
INTEGER::N,K
PRINT*,'输入开始,结束点'
READ(*,*)P,Q
PRINT*,'输入N值'
READ(*,*)N
PRINT*,'GENERATE DATA:'
M=(N-1)/2
H=(Q-P)/M
DO K=1,N
X(K)=P+(K-1)*H/2
PP(K)=SIN(X(K))
ENDDO
S=WSVSP_Integral(PP,H)
PRINT*,'输出结果'
READ(*,*)S
END PROGRAM TEST1401
F:\diyige\Text1.f90
F:\diyige\Text1.f90(23): warning FOR4291: function WSVSP_INTEGRAL has not been assigned a value
F:\diyige\Text1.f90(53): warning FOR4280: unused local variable A
F:\diyige\Text1.f90(7): error FOR3099: deferred-shape specification for non-POINTER or non-ALLOCATABLE array A
Errors in declarations, no further processing for INTEGRAL
Error executing fl32.exe.
Text1.obj - 1 error(s), 2 warning(s)
MODULE INTEGRAL
IMPLICIT NONE
CONTAINS
REAL FUNCTION WSVSP_Integral(PP,H)
IMPLICIT NONE
REAL::S,S1,K,H,W,N
REAL::PP(:),A(:)
N=SIZE(PP)
A=0
DO K=1,N
A(2*K-1)=A(2*K-1)+1
A(2*K)=A(2*K)+4
A(2*K+1)=A(2*K+1)+1
ENDDO
DO K=1,N
S1=A(K)*PP(K)
S=S+S1
ENDDO
W=H/6*S
RETURN
END FUNCTION WSVSP_Integral
END MODULE INTEGRAL
PROGRAM TEST1401
USE INTEGRAL
IMPLICIT NONE
REAL,ALLOCATABLE :: PP(:)
REAL,ALLOCATABLE :: X(:)
REAL,ALLOCATABLE :: A(:)
REAL::H,P,Q,M,S
INTEGER::N,K
PRINT*,'输入开始,结束点'
READ(*,*)P,Q
PRINT*,'输入N值'
READ(*,*)N
PRINT*,'GENERATE DATA:'
M=(N-1)/2
H=(Q-P)/M
DO K=1,N
X(K)=P+(K-1)*H/2
PP(K)=SIN(X(K))
ENDDO
S=WSVSP_Integral(PP,H)
PRINT*,'输出结果'
READ(*,*)S
END PROGRAM TEST1401
F:\diyige\Text1.f90
F:\diyige\Text1.f90(23): warning FOR4291: function WSVSP_INTEGRAL has not been assigned a value
F:\diyige\Text1.f90(53): warning FOR4280: unused local variable A
F:\diyige\Text1.f90(7): error FOR3099: deferred-shape specification for non-POINTER or non-ALLOCATABLE array A
Errors in declarations, no further processing for INTEGRAL
Error executing fl32.exe.
Text1.obj - 1 error(s), 2 warning(s)