Fortran 77 call
时间: 2024-05-16 12:12:37 浏览: 14
In Fortran 77, you can call a subroutine or function by using the CALL statement followed by the subroutine or function name and any arguments in parentheses.
For example, consider the following subroutine:
```
SUBROUTINE MY_SUB(A, B, C)
INTEGER A, B, C
C = A + B
RETURN
END
```
To call this subroutine from within your main program, you would use the following code:
```
INTEGER A, B, C
A = 1
B = 2
CALL MY_SUB(A, B, C)
```
After the CALL statement, you pass the variables A and B as arguments to the subroutine MY_SUB. The subroutine adds A and B together and returns the result in the variable C. In this example, C will be set to 3.
相关问题
Fortran 77 call的用法
在Fortran 77中,CALL语句用于调用子程序或函数。下面是CALL语句的一般形式:
```
CALL subprogram-name(argument-list)
```
其中,subprogram-name是子程序或函数的名称,argument-list是传递给子程序或函数的参数列表。下面是一个示例:
```
PROGRAM MAIN
INTEGER A, B, C
A = 10
B = 20
CALL ADD(A, B, C)
WRITE(*,*) 'The sum of A and B is', C
STOP
END PROGRAM MAIN
SUBROUTINE ADD(X, Y, Z)
INTEGER X, Y, Z
Z = X + Y
RETURN
END SUBROUTINE ADD
```
在上面的示例中,CALL语句调用名为ADD的子程序,传递了A和B作为参数。ADD子程序将A和B相加,并将结果存储在变量C中。然后,主程序使用WRITE语句输出变量C的值。
fortran中call的用法
在Fortran中,CALL是一个关键字,用于调用子程序或函数。CALL语句的基本语法如下:
CALL subprogram_name(argument_list)
其中,subprogram_name是要调用的子程序或函数的名称。argument_list是传递给子程序或函数的参数列表。
例如,假设有一个名为my_subroutine的子程序,它需要两个整数参数,那么调用该子程序的语句如下所示:
CALL my_subroutine(10, 20)
在这个例子中,my_subroutine被调用,并传递了两个参数10和20。
另外,CALL语句也可以用于调用系统级函数或子程序,例如:
CALL SYSTEM('ls -l')
这个语句将调用系统级函数ls -l来列出当前目录下的文件和目录。