Sun Studio 12:Fortran 用户指南

4.6.7 VALUE 属性

f95 编译器接受 Fortran 2003 VALUE 类型声明属性。

如果使用此属性指定子程序伪输入参数,则表明“按值”传递实际参数。以下示例说明如何将 VALUE 属性用于一个 C 主程序,该主程序将文字值作为参数来调用 Fortran 95 子程序:


C 代码:
#include <stdlib.h>
int main(int ac, char *av[])
{
    to_fortran(2);
}

Fortran 代码:
       subroutine to_fortran(i)
       integer, value :: i
       print *, i
       end