  ! fortranconsole.f90

  program Console

  use MyLib

  implicit none


  !character(:), allocatable ::                             taskId
  character(len=36) :: taskId
  procedure(ProgressUpdateAction), pointer :: progressUpdate

  ! Print splash line
  print *, 'Analysis Console'

  call ProcessCommandLine(taskId)

  ! Print the task id to the command line
  print *, taskId

  call DoWork(progressUpdate)


  contains


  subroutine ProcessCommandLine(taskId)

  character(len=36), intent(out) :: taskId

  integer :: myArgLength
  integer ::myStat

  ! Check command line for supplied arguments
  if (Command_argument_count() == 0) then
    stop "Error: There were no command line arguments."
  end if

  call Get_command_argument(1, length=myArgLength, status=myStat)
  if (0 < myStat) then
    stop "Error: Could not retrieve the first command argument."
  end if
  if (36 < myArgLength) then
    stop "Error: Argument more than 36 characters long."
  end if

  ! Get first argument
  call Get_command_argument(1, value=taskId, status=myStat)

  if (myStat /= 0) then
    stop "Error GET_COMMAND_ARGUMENT failed unexpectedly."
  end if

  end subroutine

  end program