Fortran Coder

定义外部函数要怎么调用?

查看数: 13900 | 评论数: 5 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2021-8-11 14:15

正文摘要:

各位大佬,我在主程序main外定义了一个外部函数,然后在主程序中调用,但是出现这个错误,这是咋回事??球球了!!感谢!! 以下是部分代码: [Fortran] 纯文本查看 复制代码program main     implicit n ...

回复

Proteus 发表于 2021-8-13 09:43:09
necrohan 发表于 2021-8-12 08:12
用参数传递返回值吧,比较简单

好的,我试一试,谢谢!!!!
Proteus 发表于 2021-8-13 09:40:26
li913 发表于 2021-8-11 17:33
函数返回值为数组,需要interface. 看《interface功能详解》http://fcode.cn/guide-61-1.html ...

感谢感谢!!!
necrohan 发表于 2021-8-12 08:12:20
用参数传递返回值吧,比较简单
li913 发表于 2021-8-11 17:33:58
函数返回值为数组,需要interface. 看《interface功能详解》http://fcode.cn/guide-61-1.html
Proteus 发表于 2021-8-11 14:54:33
我把外部函数定义改为:
[Fortran] 纯文本查看 复制代码
program main
    implicit none
    real,external::vvmat(2,2)
    real dh0(2,2),v1(2)
    integer n
    n=2
    dh0=vvmat(v1,v1,n)
end program main

function vvmat(a,b,n)
implicit none
    integer n,i,j
    real(kind=dp) a(n),b(n),vvmat(n,n)
    do i=1,n
        do j=1,n
            vvmat(i,j)=a(i)*b(j)
        end do
    end do
end function vvmat

出现了这样的错误:
错误        1         error #8099: The rank of the function reference does not match the rank of the function definition.   [VVMAT]

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-4 01:34

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表