! Program Example from "Essential Fortran 90 & 95" by Loren P. Meissner
! Copyright 1996. Copying for sale requires permission from the author.
! Otherwise, distribution is permitted if these three lines are included.

  module G01M
    implicit none
    public :: A
    integer, parameter, private :: K = 3
    character (len = K), save, private :: X = "ABCDE"   ! Fixed-length string
  contains
    function A( N, B ) result( A_R )
      integer, intent (in) :: N
      character (len = *), intent (in) :: B  ! Assumed-length
      character (len = len( B )) :: A_R   ! Automatic-length function result
      character (len = len( B )) :: Y   ! Automatic-length local string
      character (len = *), parameter :: WORD = "Praseodymium"
  ! start function A
      A_R = B
      Y = WORD      ! Praseody
      Y(: K) = X    ! ABCseody
      A_R(3: N) = Y   ! ..ABCse. if N is 7
      return
    end function A
  end module G01M
