! Sample Fortran 2008 program — samplefiles.com
module customers_mod
  implicit none
  type :: customer
    integer :: id
    character(len=16) :: name
    real(8) :: balance
  end type customer
contains
  logical function is_vip(c)
    type(customer), intent(in) :: c
    is_vip = c%balance >= 10000.0d0
  end function is_vip
end module customers_mod

program sample
  use customers_mod
  implicit none
  type(customer) :: customers(3)
  integer :: i

  customers(1) = customer(1, 'Ada', 12500.0d0)
  customers(2) = customer(2, 'Grace', 830.5d0)
  customers(3) = customer(3, 'Linus', 10000.0d0)

  do i = 1, size(customers)
    write(*, '(A6, 1X, F10.2, 1X, A)') customers(i)%name, customers(i)%balance, &
      merge('VIP', '   ', is_vip(customers(i)))
  end do
  write(*, '(A, F0.2)') 'Total: ', sum(customers%balance)
end program sample
