Fortran-nested-select-case-construct

提供:Dev Guides
移動先:案内検索

Fortran-ネストされた選択ケース構造

ある select case ステートメントを別の select case ステートメント内で使用できます。

構文

select case(a)

   case (100)
      print*, "This is part of outer switch", a

   select case(b)
      case (200)
         print*, "This is part of inner switch", a

   end select

end select

program nestedSelectCase
   ! local variable definition
   integer :: a = 100
   integer :: b = 200

   select case(a)
      case (100)
         print*, "This is part of outer switch", a

      select case(b)
         case (200)
            print*, "This is part of inner switch", a
      end select

   end select

   print*, "Exact value of a is : ", a
   print*, "Exact value of b is : ", b

end program nestedSelectCase

上記のコードをコンパイルして実行すると、次の結果が生成されます-

This is part of outer switch 100
This is part of inner switch 100
Exact value of a is : 100
Exact value of b is : 200