File: example_process_3.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (22 lines) | stat: -rw-r--r-- 592 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
! Process example 3: Run with many arguments, and check runtime
program run_with_args
    use stdlib_system, only: process_type, run, elapsed, wait
    implicit none

    type(process_type) :: p
    character(len=15), allocatable :: args(:)

    ! Define arguments for the `echo` command
    allocate(args(2))
    args(1) = "echo"
    args(2) = "Hello, Fortran!"

    ! Run the command with arguments (synchronous)
    p = run(args)

    ! Print the runtime of the process
    print *, "Process runtime:", elapsed(p), "seconds."

    ! Clean up
    deallocate(args)
end program run_with_args