主题:外部函数调用多个返回值问题
下面这个程序是调用imsl里的函数QDAG进行积分的程序,要用到调用外部函数,函数只有一个变量x,返回值是f(这样表述可能不对),
program m324
USE imsl
IMPLICIT NONE
INTEGER IRULE, NOUT
REAL A, ABS, B, ERRABS, ERREST, ERROR, EXACT, EXP, &
F, RESULT,ERRREL
INTRINSIC ABS, EXP
EXTERNAL F
ERRABS=1.0E-3
ERRREL=1.0E-3
A = 0.0
B = 2.0
ERRABS = 0.0
IRULE = 1
CALL QDAG (F, A, B, ERRABS, ERRREL, IRULE, RESULT, ERREST)
EXACT = 1.0 + EXP(2.0)
ERROR = ABS(RESULT-EXACT)
WRITE (*,*) RESULT, EXACT, ERREST, ERROR
END
REAL FUNCTION F (X)
REAL X
REAL EXP
INTRINSIC EXP
F = X*EXP(X)
RETURN
END
我想能否让函数f(x)括号里包含好几个返回值呢?比如几个常数。f(c,x),c要从主函数里调入,然后返回f
REAL FUNCTION F (c,X)
REAL X,c
REAL EXP
INTRINSIC EXP
F =c* X*EXP(X)
RETURN
END
但是这样会提示出错。怎么样做才行呢?我看了下书,形参可以有多个参数的啊。谢谢啦
program m324
USE imsl
IMPLICIT NONE
INTEGER IRULE, NOUT
REAL A, ABS, B, ERRABS, ERREST, ERROR, EXACT, EXP, &
F, RESULT,ERRREL
INTRINSIC ABS, EXP
EXTERNAL F
ERRABS=1.0E-3
ERRREL=1.0E-3
A = 0.0
B = 2.0
ERRABS = 0.0
IRULE = 1
CALL QDAG (F, A, B, ERRABS, ERRREL, IRULE, RESULT, ERREST)
EXACT = 1.0 + EXP(2.0)
ERROR = ABS(RESULT-EXACT)
WRITE (*,*) RESULT, EXACT, ERREST, ERROR
END
REAL FUNCTION F (X)
REAL X
REAL EXP
INTRINSIC EXP
F = X*EXP(X)
RETURN
END
我想能否让函数f(x)括号里包含好几个返回值呢?比如几个常数。f(c,x),c要从主函数里调入,然后返回f
REAL FUNCTION F (c,X)
REAL X,c
REAL EXP
INTRINSIC EXP
F =c* X*EXP(X)
RETURN
END
但是这样会提示出错。怎么样做才行呢?我看了下书,形参可以有多个参数的啊。谢谢啦