File: example_math_swap.F90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (57 lines) | stat: -rw-r--r-- 1,077 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
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "macros.inc"
program example_math_swap
    use stdlib_math, only: swap
    implicit none
    
    block
        integer :: x, y
        x = 9
        y = 18
        call swap(x,y)
    end block

    block
        real :: x, y
        x = 4.0
        y = 8.0
        call swap(x,y)
    end block

    block
        real :: x(3), y(3)
        x = [1.0,2.0,3.0]
        y = [4.0,5.0,6.0]
        call swap(x,y)
    end block

    block
        character(4) :: x
        character(6) :: y
        x = 'abcd'
        y = 'efghij'
        call swap(x,y)      ! x=efgh,  y=abcd

        x = 'abcd'
        y = 'efghij'
        call swap(x,y(1:4)) ! x=efgh,  y=abcdij
    end block

    block
        use stdlib_string_type
        type(string_type) :: x, y
        x = 'abcde'
        y = 'fghij'
        call swap(x,y)
    end block

#if STDLIB_BITSETS == 1
    block
        use stdlib_bitsets
        type(bitset_64) :: x, y
        call x%from_string('0000')
        call y%from_string('1111')
        call swap(x,y)
    end block
#endif

end program example_math_swap