File: elemental_16.f90

package info (click to toggle)
lfortran 0.60.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,416 kB
  • sloc: cpp: 173,406; f90: 80,491; python: 17,586; ansic: 9,610; yacc: 2,356; sh: 1,401; fortran: 895; makefile: 38; javascript: 15
file content (44 lines) | stat: -rw-r--r-- 1,011 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
33
34
35
36
37
38
39
40
41
42
43
44
module elemental_16_mymod
implicit none
private

    public :: sub_1d, sub_elemental

    contains

        pure subroutine sub_1d(xout, xin1, xin2)
            real, intent(out) :: xout(:)
            real, intent(in) :: xin1, xin2
            xout = 1.234*(xin2 - xin1) + xin1
        end subroutine sub_1d

        pure elemental subroutine sub_elemental(xout, xin1, xin2)
            real, intent(out) :: xout
            real, intent(in) :: xin1, xin2
            xout = 1.234*(xin2 - xin1) + xin1
        end subroutine sub_elemental

end module

program main
use, non_intrinsic :: elemental_16_mymod, only: sub_1d, sub_elemental
implicit none

    integer, parameter :: n = 3
    real :: v(n)

    v = -1.0
    write(*,*) 'v: ',v

    call sub_1d(v, 0.0, 1.0)
    write(*,*) 'v: ',v
    if (.not. all(abs(v - 1.234) < 1e-5)) error stop

    v = -1.0
    write(*,*) 'v: ',v

    call sub_elemental(v, 0.0, 1.0)
    write(*,*) 'v: ',v
    if (.not. all(abs(v - 1.234) < 1e-5)) error stop

end program main