传递给 fortran 函数的参数数量是否有限制? [英] Is there a limit to the number of arguments passed to a fortran function?

查看:32
本文介绍了传递给 fortran 函数的参数数量是否有限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一些 Fortran 90 代码,其中向函数传递了 68 个参数.在网上搜索时,我只发现了一些与 CUDA Fortran 相关的东西传递 256 字节的限制(http://www.pgroup.com/userforum/viewtopic.php?t=2235&sid=f241ca3fd406ef89d0ba08a361acd962).

I came across some Fortran 90 code where 68 arguments are passed to a function. Upon searching the web I only found something about a limit of passing 256 bytes for some CUDA Fortran related stuff (http://www.pgroup.com/userforum/viewtopic.php?t=2235&sid=f241ca3fd406ef89d0ba08a361acd962).

所以我想知道:对于 Intel/Visual/GNU fortran 编译器,可以传递给函数的参数数量是否有限制?

So I wonder: is there a limit to the number of arguments that may be passed to a function for Intel/Visual/GNU fortran compilers?

推荐答案

我遇到了有关 Fortran 90 标准的讨论:

I came across this discussion of the Fortran 90 standards:

http://www.nag.co.uk/sc22wg5/Guidelines_for_Bindings-b.html

相关部分在下面以斜体显示:

The relevant section is in italics below:

3.4 声明

对 Fortran 语句长度的限制对过程调用的长度施加了上限.尽管不太可能是严重的强加,但自由格式的单个 Fortran 语句的上限为 5241 个字符,包括可能的标签(F90 部分 3.3.1、3.3.1.4);在固定格式中,上限为 1320 个字符加上一个可能的标签(F90 第 3.3.2 节).这些限制受制于默认类型"的字符,即实际上是单字节字符;对于双字节字符(例如用于表意语言),限制取决于处理器,但大小可能相同.

Fortran 标准对过程的最大参数数量没有限制.

我在研究中开发了一个用于分析二进制文件的安全工具.我知道 C 语言对参数数量有限制(在 C90 标准中为 31,在 C99 标准中为 127),所以我认为我可以定义一个向量来保存与传入参数相关的 128 个项目.我遇到了一个 FORTRAN 派生的二进制文件,它传递了 290 个参数,这让我进行了这个讨论.二进制文件来自 SPEC CPU2006 基准测试套件,基准测试 481.wrf,在那里我看到一个名为(在二进制文件中)solve_interface_"的过程,它在堆栈上设置 290 个参数,然后调用实际处理这些参数的solve_em_".毫无疑问,您可以在线找到这些过程的 FORTRAN 源代码.该二进制文件由 GNU 编译器工具为 x86/Linux/ELF 系统生成.

I have a security tool that I am developing in my research that analyzes binaries. I knew that the C language has limits on number of arguments (31 in the C90 standard, 127 in the C99 standard), so I thought that I could dimension a vector to hold 128 items pertaining to incoming arguments. I encountered a FORTRAN-derived binary that had 290 arguments passed, which led me to this discussion. The binary is from the SPEC CPU2006 benchmark suite, benchmark 481.wrf, where I see a procedure that is named (in the binary) "solve_interface_" which sets up 290 arguments on the stack and then calls "solve_em_" which actually processes these arguments. You can no doubt find the FORTRAN source code for these procedures online. The binary was produced by the GNU compiler tools for an x86/Linux/ELF system.

这篇关于传递给 fortran 函数的参数数量是否有限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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