| 1 | module point_m |
|---|
| 2 | |
|---|
| 3 | implicit none |
|---|
| 4 | |
|---|
| 5 | interface point |
|---|
| 6 | ! The difference between the procedures is the rank and type of |
|---|
| 7 | ! the first argument. |
|---|
| 8 | module procedure point_2, point_2_dble, point_3, point_3_dble, point_4, & |
|---|
| 9 | point_4_dble |
|---|
| 10 | end interface |
|---|
| 11 | |
|---|
| 12 | private |
|---|
| 13 | public point |
|---|
| 14 | |
|---|
| 15 | contains |
|---|
| 16 | |
|---|
| 17 | real function point_2(array, location) |
|---|
| 18 | |
|---|
| 19 | use nr_util, only: assert |
|---|
| 20 | |
|---|
| 21 | real, intent(in):: array(:, :) |
|---|
| 22 | integer, intent(in):: location(:) |
|---|
| 23 | |
|---|
| 24 | !--------------------------------- |
|---|
| 25 | |
|---|
| 26 | call assert(size(location) == 2, "point_2") |
|---|
| 27 | |
|---|
| 28 | point_2 = array(location(1), location(2)) |
|---|
| 29 | |
|---|
| 30 | end function point_2 |
|---|
| 31 | |
|---|
| 32 | !*************************************************** |
|---|
| 33 | |
|---|
| 34 | double precision function point_2_dble(array, location) |
|---|
| 35 | |
|---|
| 36 | use nr_util, only: assert |
|---|
| 37 | |
|---|
| 38 | double precision, intent(in):: array(:, :) |
|---|
| 39 | integer, intent(in):: location(:) |
|---|
| 40 | |
|---|
| 41 | !--------------------------------- |
|---|
| 42 | |
|---|
| 43 | call assert(size(location) == 2, "point_2_dble") |
|---|
| 44 | |
|---|
| 45 | point_2_dble = array(location(1), location(2)) |
|---|
| 46 | |
|---|
| 47 | end function point_2_dble |
|---|
| 48 | |
|---|
| 49 | !*************************************************** |
|---|
| 50 | |
|---|
| 51 | real function point_3(array, location) |
|---|
| 52 | |
|---|
| 53 | use nr_util, only: assert |
|---|
| 54 | |
|---|
| 55 | real, intent(in):: array(:, :, :) |
|---|
| 56 | integer, intent(in):: location(:) |
|---|
| 57 | |
|---|
| 58 | !--------------------------------- |
|---|
| 59 | |
|---|
| 60 | call assert(size(location) == 3, "point_3") |
|---|
| 61 | |
|---|
| 62 | point_3 = array(location(1), location(2), location(3)) |
|---|
| 63 | |
|---|
| 64 | end function point_3 |
|---|
| 65 | |
|---|
| 66 | !*************************************************** |
|---|
| 67 | |
|---|
| 68 | double precision function point_3_dble(array, location) |
|---|
| 69 | |
|---|
| 70 | use nr_util, only: assert |
|---|
| 71 | |
|---|
| 72 | double precision, intent(in):: array(:, :, :) |
|---|
| 73 | integer, intent(in):: location(:) |
|---|
| 74 | |
|---|
| 75 | !--------------------------------- |
|---|
| 76 | |
|---|
| 77 | call assert(size(location) == 3, "point_3_dble") |
|---|
| 78 | |
|---|
| 79 | point_3_dble = array(location(1), location(2), location(3)) |
|---|
| 80 | |
|---|
| 81 | end function point_3_dble |
|---|
| 82 | |
|---|
| 83 | !*************************************************** |
|---|
| 84 | |
|---|
| 85 | real function point_4(array, location) |
|---|
| 86 | |
|---|
| 87 | use nr_util, only: assert |
|---|
| 88 | |
|---|
| 89 | real, intent(in):: array(:, :, :, :) |
|---|
| 90 | integer, intent(in):: location(:) |
|---|
| 91 | |
|---|
| 92 | !--------------------------------- |
|---|
| 93 | |
|---|
| 94 | call assert(size(location) == 4, "point_4") |
|---|
| 95 | |
|---|
| 96 | point_4 = array(location(1), location(2), location(3), location(4)) |
|---|
| 97 | |
|---|
| 98 | end function point_4 |
|---|
| 99 | |
|---|
| 100 | !*************************************************** |
|---|
| 101 | |
|---|
| 102 | double precision function point_4_dble(array, location) |
|---|
| 103 | |
|---|
| 104 | use nr_util, only: assert |
|---|
| 105 | |
|---|
| 106 | double precision, intent(in):: array(:, :, :, :) |
|---|
| 107 | integer, intent(in):: location(:) |
|---|
| 108 | |
|---|
| 109 | !--------------------------------- |
|---|
| 110 | |
|---|
| 111 | call assert(size(location) == 4, "point_4_dble") |
|---|
| 112 | |
|---|
| 113 | point_4_dble = array(location(1), location(2), location(3), location(4)) |
|---|
| 114 | |
|---|
| 115 | end function point_4_dble |
|---|
| 116 | |
|---|
| 117 | end module point_m |
|---|