The Fortran 2000 Standard
by Dan Nagle 


Listing One
!  define parameterized derived type
type :: matrix_t( k, d)
   integer, kind :: k                       ! k is a kind parameter
   real( kind= k), dimension( d, d) :: a    ! d is a nonkind parameter
end type matrix_t
!  declare variable
type( matrix_t( double_k, 100)) :: field     ! field%a is ( 100, 100) of
                                             !              kind= double_k
type( matrix_t( single_k, 50) :: potential   ! potential%a is (50, 50) of
                                             !              kind= single_k


Listing Two
!  define an extensible derived type
type, extensible :: vector_3d
   real( kind= double_k), dimension( 3) :: point   ! a point in three space
end type matrix_t
!  define type which extends vector_3d
type, extends( vector_3d) :: vector_4d              ! a point in 3 space
   real( kind= double_k) :: time                    ! at a time
end type vector_4d


Listing Three
!  Use a simple name in place of a complicated name
associate( a => foo%bar( i, j, k)%element, b => sna%fu%last( i, j) )
! use a, b
end associate


Listing Four
! Choose execution based on type
select type( p_ptr)
type( foo_t)
! use a foo_t object
type( bar_t)
! use a bar_t object
end select type


Listing Five
! C prototype: void c_func( int i, double * a)
interface, bind( c) :: c_func
   subroutine c_func( i, a)
      integer( kind= c_int), value :: i
      real( kind= c_double), dimension( 100) :: a
   end subroutine c_func
end interface c_func
! and the call appears to be a normal call
call c_func( i, a)





