Fortran - costrutto select case annidato

Puoi usarne uno select case dichiarazione dentro un'altra select case dichiarazione (i).

Sintassi

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

Esempio

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

Quando il codice precedente viene compilato ed eseguito, produce il seguente risultato:

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