Fortran 嵌套 select case 语句
您可以在另一个 select case 语句中使用一个 select case 语句。
语法
select case(a)case (100)print*, "This is part of outer switch", aselect case(b)case (200)print*, "This is part of inner switch", aend selectend select
实例
program nestedSelectCase! local variable definitioninteger :: a = 100integer :: b = 200select case(a)case (100)print*, "This is part of outer switch", aselect case(b)case (200)print*, "This is part of inner switch", aend selectend selectprint*, "Exact value of a is : ", aprint*, "Exact value of b is : ", bend program nestedSelectCase
结果为:
This is part of outer switch 100This is part of inner switch 100Exact value of a is : 100Exact value of b is : 200