nano_exit

基礎的なことこそ、簡単な例が必要だと思うのです。

fortran のオプショナル引数

練習として、オプショナル引数を使ったサンプルプログラムを作った。

Fortran 入門: サブルーチンと関数(自作手続)

program ex

call ex_sub( 1, z = 3 )

contains

subroutine ex_sub( x, y, z )
implicit none
!integer, intent( in ) :: x, y, z
integer, optional :: x, y, z

if ( .not. present( x ) ) x = 0
if ( .not. present( y ) ) y = 0
if ( .not. present( z ) ) z = 0

print *, x, y, z

return
end subroutine ex_sub

end program ex

省略された引数の値を初期化したいので、引数を変更することを禁止するintentとは相性が悪いと思われる。