File: cmdline.f90

package info (click to toggle)
lfortran 0.59.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 56,736 kB
  • sloc: cpp: 168,052; f90: 74,272; python: 17,537; ansic: 7,705; yacc: 2,345; sh: 1,334; fortran: 895; makefile: 37; javascript: 15
file content (19 lines) | stat: -rw-r--r-- 610 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
program cmdline
integer, parameter :: dp = kind(0.d0)
integer :: x
character(len=32) :: arg
real :: err
if (command_argument_count() /= 1) error stop "Must provide exactly 1 argument"
call get_command_argument(1, arg)
print *, "Got argument:", arg
read(arg,*) x
print *, "Converted value:", x
print *, "sin(x) = ", sin(real(x, dp))
print *, "sin(1) = ", sin(1._dp)
err = abs(sin(real(x, dp)) - 8.41470984807896505e-01_dp)
print *, "err =", err
if (err > 1e-12) then
    print *, "Make sure you call cmdline with the argument: 1"
    error stop "The sin(x) does not agree with the reference"
end if
end program