PROGRAM main
    USE double
    USE mpi
    IMPLICIT NONE
    INTEGER :: myrank, code, error
    CHARACTER(LEN=100) :: argument
    CHARACTER(LEN=120) :: command
    REAL(KIND=DP) :: before, after

    IF (Command_argument_count() /= 1) THEN
        PRINT *,"Invalid number of arguments specified"
        STOP 1
    END IF
    CALL Get_command_argument(1,argument)
    CALL MPI_Init(error)
    CALL MPI_Comm_rank(MPI_COMM_WORLD,myrank,error)
    WRITE (command,"(A,1X,I0)") TRIM(argument),myrank

    CALL MPI_Barrier(MPI_COMM_WORLD,error)
    before = MPI_Wtime()
    CALL Execute_command_line(command,EXITSTAT=code) ! Fortran 2003
    ! code = System(command)                         ! Old gfortran
    after = MPI_Wtime()
    WRITE (*,"('Command ',A,' terminated with code ',    &
            &    I1,' and took ',F0.2,' seconds')")    &
        TRIM(command),code,after-before
    CALL MPI_Finalize(error)
END PROGRAM main
