FORTRAN プログラムは唯一の主プログラムB.15 と、複数(0 個のこともある)の副 プログラム(subroutine, function)からなる。
program fem02
...
end
↓
main()
{
...
}
real function max(a,b)
real a,b
if (a .gt b) then
max = a
else
max = b
endif
end
↓
double max(double a, double b)
{
/* 普通は return (a > b) ? a : b; かな */
if (a > b)
return a;
else
return b;
}
call rkf(m,a,sol)
...
subroutine rkf(n,x0,y)
integer n
real x0,y(*)
...
↓
void rkf(int,double,double *); プロトタイプ宣言
...
rkf(m,a,sol); 呼び出し
...
void rkf(int n, double x0, double *y) 関数の定義
{
...