File: read_19.f90

package info (click to toggle)
lfortran 0.60.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,412 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 37; javascript: 15
file content (32 lines) | stat: -rw-r--r-- 765 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
23
24
25
26
27
28
29
30
31
32
program read_19
    ! Test D exponent notation in READ
    use iso_fortran_env, only: dp => real64
    implicit none
    real(dp) :: x
    integer :: u

    open(newunit=u, status='scratch')

    ! Test D+xx notation
    write(u, '(A)') "1.5D+02"
    rewind(u)
    read(u, *) x
    if (abs(x - 150.0_dp) > 1.0e-10_dp) error stop "D+02 failed"

    ! Test D-xx notation
    rewind(u)
    write(u, '(A)') "2.5D-03"
    rewind(u)
    read(u, *) x
    if (abs(x - 0.0025_dp) > 1.0e-15_dp) error stop "D-03 failed"

    ! Test d (lowercase) notation
    rewind(u)
    write(u, '(A)') "3.0d+01"
    rewind(u)
    read(u, *) x
    if (abs(x - 30.0_dp) > 1.0e-10_dp) error stop "d+01 failed"

    close(u)
    print *, "PASS: D exponent notation works"
end program read_19