File: cmdline.f90

package info (click to toggle)
lfortran 0.48.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 20,580 kB
  • sloc: cpp: 276,406; python: 12,336; ansic: 3,769; yacc: 2,311; f90: 649; sh: 37; makefile: 29
file content (19 lines) | stat: -rw-r--r-- 610 bytes parent folder | download | duplicates (2)
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