-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprogram_utils.f90
More file actions
33 lines (25 loc) · 944 Bytes
/
Copy pathprogram_utils.f90
File metadata and controls
33 lines (25 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
! Small helpers for standalone main programs.
module program_utils_mod
use kind_mod, only: dp
implicit none
private
public :: read_integer_arg, elapsed_since
contains
subroutine read_integer_arg(iarg, value)
! Read command argument iarg as a positive default integer.
integer, intent(in) :: iarg
integer, intent(out) :: value
character(len=64) :: arg
integer :: io
call get_command_argument(iarg, arg)
read(arg, *, iostat=io) value
if (io /= 0 .or. value < 1) error stop "read_integer_arg: expected positive integer"
end subroutine read_integer_arg
real(dp) function elapsed_since(t_start)
! CPU seconds elapsed since t_start from cpu_time.
real(dp), intent(in) :: t_start
real(dp) :: t_now
call cpu_time(t_now)
elapsed_since = t_now - t_start
end function elapsed_since
end module program_utils_mod