Fortran3

From SourceWiki
Revision as of 17:10, 14 July 2009 by GethinWilliams (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
module type_stuff

  implicit none

  !! private?

  integer, parameter :: maxstr = 50

  type station
     real                  :: frequency   ! MHz
     character(len=maxstr) :: name        ! str
   contains
     procedure :: init => init_station
     procedure :: str => str_station
  end type station
  
contains
  
  subroutine init_station(user_type, freq, stat_name)

    implicit none
    
    !! dummy args
    type(station),         intent(out :: user_type
    real,                  intent(in) :: freq
    character(len=maxstr), intent(in) :: stat_name

    user_type%frequency = freq
    user_type%name      = stat_name
    
  end subroutine init_station

  subroutine str_station(user_type)

    implicit none

    !! dummy args
    type station, intent(in) :: user_type

    write(6,*) "station name: ", user_type%name
    write(6,*) "frequency is: ", user_type%frequency

  end subroutine str_station
     
end module type_stuff


! program encapsulation

!   use type_suff

!   implicit none

!   type(station) :: radio2

!   radio2%init(89.9,"radio 2")
!   radio2%str

! end program encapsulation