MODULE m_model

   USE m_vec2d

   implicit none

   TYPE primvar

      real(rp) :: h

      type(vec2d) :: u

   CONTAINS

      procedure, pass( self ) :: equal_primvar
      procedure, pass( self ) :: rot_primvar
      procedure, pass( self ) :: invrot_primvar

      generic :: assignment(=) => equal_primvar

      generic :: operator(.rot.)     => rot_primvar
      generic :: operator(.invrot.)  => invrot_primvar

   END TYPE primvar

   TYPE unk

      type(primvar), allocatable :: var(:)

   END TYPE unk

CONTAINS

   ELEMENTAL SUBROUTINE equal_primvar( self , from )

      class(primvar), intent(inout) :: self

      type(primvar), intent(in) :: from

      self%h   = from%h
      self%u%x = from%u%x
      self%u%y = from%u%y

   END SUBROUTINE equal_primvar

   ELEMENTAL FUNCTION rot_primvar( self , normal ) RESULT( this )

      class(primvar), intent(in) :: self

      type(vec2d), intent(in) :: normal

      type(primvar) :: this

      this%h = self%h
      this%u = self%u .rot. normal

   END FUNCTION rot_primvar

   ELEMENTAL FUNCTION invrot_primvar( self , normal ) RESULT( this )

      class(primvar), intent(in) :: self

      type(vec2d), intent(in) :: normal

      type(primvar) :: this

      this%h = self%h
      this%u = self%u .invrot. normal

   END FUNCTION invrot_primvar

END MODULE m_model