如何在fortran 90中定义函数 [英] how to define function in fortran 90

查看:528
本文介绍了如何在fortran 90中定义函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的模块代码中定义一个函数,并在main fortran代码中调用它,但是当我想编译我的代码时,我收到了这个错误:


这个实际参数必须是外部用户函数的名称或内部函数的名称。


我的函数是:
$ b $ pre $ 函数func(x)
隐式无
双精度函数,x
func = x
RETURN
结束函数func

并在主代码中

 调用Romberg(dra,func,ra(mm),ra(kk))

我想测量 ra(mm)& ; ra(kk)

解决方案

Add:

 外部函数

in呼叫者,召集者。这告诉调用者func是一个外部过程。你显然已经用Romberg声明了一个明确的接口来指定参数是一个过程。


I'm trying to define a function in my module code and call it in the main fortran code but when I want to compile my code I'm receiving this error :

This actual argument must be the name of an external user function or the name of an intrinsic function.

and my function is :

Function func (x)  
   implicit none  
   double precision func,x  
   func=x  
   RETURN  
end function func

and in the main code

call Romberg (dra,func,ra(mm),ra(kk))

I want to measure the destance between ra(mm) & ra(kk)

解决方案

Add:

external func

in the caller. This tells the caller that "func" is an external procedure. You evidently have Romberg declared with an explicit interface specifying the argument is a procedure.

这篇关于如何在fortran 90中定义函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆