-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpoint.f90
146 lines (81 loc) · 3.36 KB
/
point.f90
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
module point_m
use assert_m, only: assert
implicit none
interface point
! Returns the element of an array, given the vector of its
! indices. That is, you can write:
! point(array, location)
! instead of :
! array(location(1), location(2), location(3))
! for example. The difference between the procedures is the rank
! and type of the first argument.
module procedure point_1, point_1_dble, point_2, point_2_dble, point_3, &
point_3_dble, point_4, point_4_dble
end interface point
private
public point
contains
real function point_1(array, location)
real, intent(in):: array(:)
integer, intent(in):: location(:)
!---------------------------------
call assert(size(location) == 1, "point_1")
point_1 = array(location(1))
end function point_1
!***************************************************
double precision function point_1_dble(array, location)
double precision, intent(in):: array(:)
integer, intent(in):: location(:)
!---------------------------------
call assert(size(location) == 1, "point_1_dble")
point_1_dble = array(location(1))
end function point_1_dble
!***************************************************
real function point_2(array, location)
real, intent(in):: array(:, :)
integer, intent(in):: location(:)
!---------------------------------
call assert(size(location) == 2, "point_2")
point_2 = array(location(1), location(2))
end function point_2
!***************************************************
double precision function point_2_dble(array, location)
double precision, intent(in):: array(:, :)
integer, intent(in):: location(:)
!---------------------------------
call assert(size(location) == 2, "point_2_dble")
point_2_dble = array(location(1), location(2))
end function point_2_dble
!***************************************************
real function point_3(array, location)
real, intent(in):: array(:, :, :)
integer, intent(in):: location(:)
!---------------------------------
call assert(size(location) == 3, "point_3")
point_3 = array(location(1), location(2), location(3))
end function point_3
!***************************************************
double precision function point_3_dble(array, location)
double precision, intent(in):: array(:, :, :)
integer, intent(in):: location(:)
!---------------------------------
call assert(size(location) == 3, "point_3_dble")
point_3_dble = array(location(1), location(2), location(3))
end function point_3_dble
!***************************************************
real function point_4(array, location)
real, intent(in):: array(:, :, :, :)
integer, intent(in):: location(:)
!---------------------------------
call assert(size(location) == 4, "point_4")
point_4 = array(location(1), location(2), location(3), location(4))
end function point_4
!***************************************************
double precision function point_4_dble(array, location)
double precision, intent(in):: array(:, :, :, :)
integer, intent(in):: location(:)
!---------------------------------
call assert(size(location) == 4, "point_4_dble")
point_4_dble = array(location(1), location(2), location(3), location(4))
end function point_4_dble
end module point_m