Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

This changes everything!

FortranFan
Honored Contributor III
438 Views
module m

   implicit none

   private

   type, public :: t
      private
      integer, allocatable :: m_i(:)
   contains
      private
      procedure, pass(this), public :: set => set_t
      procedure, pass(this), public :: get => get_t
   end type t

   interface

      module subroutine set_t(this, iarr)

         class(t), intent(inout) :: this
         integer, intent(in)     :: iarr(:)

      end subroutine set_t

      module function get_t(this) result(msg)

         class(t), intent(in) :: this
         !.. function result
         character(len=size(this%m_i)) :: msg

      end function get_t

   end interface

end module m
submodule(m) sm

contains

   module subroutine set_t(this, iarr)

      class(t), intent(inout) :: this
         integer, intent(in)  :: iarr(:)

      this%m_i = iarr

      return

   end subroutine set_t

   module function get_t(this) result(msg)

      class(t), intent(in) :: this
      !.. function result
      character(len=size(this%m_i)) :: msg

      integer :: i
      
      forall (i=1:size(this%m_i)) msg(i:i) = achar(this%m_i(i))

      return

   end function get_t

end submodule sm
program p

   use m, only : t

   type(t) :: foo

   integer, parameter :: im(78) = [ 72, 101, 108, 108, 111, 44,   &
                                    32, 87, 111, 114, 108, 100,   &
                                    33, 32, 32, 83, 117, 98,      &
                                    109, 111, 100, 117, 108, 101, &
                                    115, 32, 97, 114, 101, 32,    &
                                    104, 101, 114, 101, 33, 10,   &
                                    84, 104, 105, 115, 32, 99,    &
                                    104, 97, 110, 103, 101, 115,  &
                                    32, 101, 118, 101, 114, 121,  &
                                    116, 104, 105, 110, 103, 33,  &
                                    10, 84, 104, 97, 110, 107,    &
                                    32, 121, 111, 117, 44, 32,    &
                                    73, 110, 116, 101, 108, 33 ]


   call foo%set(im)

   print *, foo%get()

   stop

end program p
Hello, World!  Submodules are here!
This changes everything!
Thank you, Intel!
Press any key to continue . . .

 

0 Kudos
4 Replies
rase
New Contributor I
438 Views

What's exactly the problem or the question?

0 Kudos
Lorri_M_Intel
Employee
438 Views

I think he's happy (at least, that's how I'm reading it! :-) )

           --Lorri

 

0 Kudos
mecej4
Honored Contributor III
438 Views

The four-line pseudo program output in #1 explains the post. Finding true love reciprocated can induce what Dr. Spock would call "irrational responses". See his recent post, https://software.intel.com/en-us/forums/topic/391387 .

For a description of sub-modules, please see http://fortranwiki.org/fortran/show/Submodules .

0 Kudos
FortranFan
Honored Contributor III
438 Views

The program output in the original post is not pseudo, it's actual!  Using 16.0 beta.  I attached the zip file in case anyone else wanted to review it with Visual Studio 2012/2013.

Dr Fortran has urged patience previously on this front and this shows good things do come to those who wait!  Kudos to Intel Fortran team for this major achievement.

 

 

 

 

0 Kudos
Reply