args Subroutine

subroutine args()

Arguments

None

Variables

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: argument
integer, public :: argument_length
integer, public :: i
integer, public :: istat

Source Code

subroutine args()
implicit none
integer                      :: i
integer                      :: istat
integer                      :: argument_length
character(len=:),allocatable :: argument
   do i=1,icount
       call get_command_argument(number=i,length=argument_length)
       ! allocate string array big enough to hold command line argument
       if(allocated(argument))deallocate(argument)
       allocate(character(len=argument_length) :: argument)
       ! read the argument 
       call get_command_argument(i, argument,status=istat)
       expanded = attr(trim(argument))
       write(*,'(a)') expanded
   enddo
   end subroutine args