-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObservatory_class.f90
315 lines (223 loc) · 7.25 KB
/
Observatory_class.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
!====================================================================!
! !
! Copyright 2002,2003,2004,2005,2006,2007,2008,2009 !
! Mikael Granvik, Jenni Virtanen, Karri Muinonen, Teemu Laakso, !
! Dagmara Oszkiewicz !
! !
! This file is part of OpenOrb. !
! !
! OpenOrb is free software: you can redistribute it and/or modify it !
! under the terms of the GNU General Public License as published by !
! the Free Software Foundation, either version 3 of the License, or !
! (at your option) any later version. !
! !
! OpenOrb is distributed in the hope that it will be useful, but !
! WITHOUT ANY WARRANTY; without even the implied warranty of !
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU !
! General Public License for more details. !
! !
! You should have received a copy of the GNU General Public License !
! along with OpenOrb. If not, see <http://www.gnu.org/licenses/>. !
! !
!====================================================================!
!
!! *Class*description*:
!!
!! Type and routines for an observatory.
!!
!! @author MG
!! @version 2008-08-12
!!
MODULE Observatory_cl
USE Base_cl
IMPLICIT NONE
PRIVATE :: new_Obsy
PRIVATE :: nullify_Obsy
PRIVATE :: copy_Obsy
PRIVATE :: exist_Obsy
PRIVATE :: equal_Obsy
PRIVATE :: getCode_Obsy
PRIVATE :: getName_Obsy
PRIVATE :: getPosition_Obsy
TYPE Observatory
PRIVATE
CHARACTER(len=96) :: name = ""
CHARACTER(len=OBSY_CODE_LEN) :: code = ""
REAL(bp), DIMENSION(3) :: position = 0.0_bp
LOGICAL :: is_initialized = .FALSE.
END TYPE Observatory
INTERFACE NEW
MODULE PROCEDURE new_Obsy
END INTERFACE
INTERFACE NULLIFY
MODULE PROCEDURE nullify_Obsy
END INTERFACE
INTERFACE copy
MODULE PROCEDURE copy_Obsy
END INTERFACE
INTERFACE exist
MODULE PROCEDURE exist_Obsy
END INTERFACE
INTERFACE equal
MODULE PROCEDURE equal_Obsy
END INTERFACE
INTERFACE getCode
MODULE PROCEDURE getCode_Obsy
END INTERFACE
INTERFACE getName
MODULE PROCEDURE getName_Obsy
END INTERFACE
INTERFACE getPosition
MODULE PROCEDURE getPosition_Obsy
END INTERFACE
CONTAINS
!! *Description*:
!!
!! Initializes a new object based on given information. The position
!! contains the body-fixed Cartesian geocentric equatorial
!! coordinates of the observatory given in AUs.
!!
!! Returns error.
!!
SUBROUTINE new_Obsy(this, code, name, position)
IMPLICIT NONE
TYPE (Observatory), INTENT(out) :: this
CHARACTER(len=*), INTENT(in) :: code
CHARACTER(len=*), INTENT(in) :: name
REAL(bp), DIMENSION(3), INTENT(in) :: position
IF (this%is_initialized) THEN
error = .TRUE.
CALL errorMessage("Observatory / new", &
"Object has already been initialized.", 1)
RETURN
END IF
IF (LEN_TRIM(code) > OBSY_CODE_LEN) THEN
error = .TRUE.
CALL errorMessage("Observatory / new", &
"Observatory code ("// TRIM(code) // &
")too long.", 1)
RETURN
END IF
this%code = code
this%name = name
this%position = position
this%is_initialized = .TRUE.
END SUBROUTINE new_Obsy
!! *Description*:
!!
!! Nullifies this object.
!!
SUBROUTINE nullify_Obsy(this)
IMPLICIT NONE
TYPE (Observatory), INTENT(inout) :: this
this%code = ""
this%name = ""
this%position = 0.0_bp
this%is_initialized = .FALSE.
END SUBROUTINE nullify_Obsy
!! *Description*:
!!
!! Returns a copy of this object.
!!
FUNCTION copy_Obsy(this)
IMPLICIT NONE
TYPE (Observatory), INTENT(in) :: this
TYPE (Observatory) :: copy_Obsy
copy_Obsy%code = this%code
copy_Obsy%name = this%name
copy_Obsy%position = this%position
copy_Obsy%is_initialized = this%is_initialized
END FUNCTION copy_Obsy
!! *Description*:
!!
!! Returns the status of this object, i.e. whether
!! it exists or not.
!!
LOGICAL FUNCTION exist_Obsy(this)
IMPLICIT NONE
TYPE (Observatory), INTENT(in) :: this
exist_Obsy = this%is_initialized
END FUNCTION exist_Obsy
LOGICAL FUNCTION equal_Obsy(this, that)
IMPLICIT NONE
TYPE (Observatory), INTENT(in) :: this
TYPE (Observatory), INTENT(in) :: that
IF (.NOT. this%is_initialized) THEN
error = .TRUE.
CALL errorMessage("Observatory / equal", &
"1st object has not yet been initialized.", 1)
RETURN
END IF
IF (.NOT. that%is_initialized) THEN
error = .TRUE.
CALL errorMessage("Observatory / equal", &
"2nd object has not yet been initialized.", 1)
RETURN
END IF
! Observatory code:
IF (.NOT.(this%code == that%code)) THEN
equal_Obsy = .FALSE.
RETURN
END IF
! Position wrt. the geocenter:
IF (ANY(ABS(this%position - that%position) > EPSILON(this%position(1)))) THEN
equal_Obsy = .FALSE.
RETURN
END IF
! Assuming that all of the above comparisons are true,
! it can be concluded that the two objects are the same:
equal_Obsy = .TRUE.
END FUNCTION equal_Obsy
!! *Description*:
!!
!! Returns observatory code as a character string.
!!
!! Returns error.
!!
CHARACTER(len=OBSY_CODE_LEN) FUNCTION getCode_Obsy(this)
IMPLICIT NONE
TYPE (Observatory), INTENT(in) :: this
IF (.NOT. this%is_initialized) THEN
error = .TRUE.
CALL errorMessage("Observatory / getCode", &
"Object has not yet been initialized.", 1)
RETURN
END IF
getCode_Obsy = this%code
END FUNCTION getCode_Obsy
!! *Description*:
!!
!! Returns name of observatory as a character string.
!!
!! Returns error.
!!
CHARACTER(len=128) FUNCTION getName_Obsy(this)
IMPLICIT NONE
TYPE (Observatory), INTENT(in) :: this
IF (.NOT. this%is_initialized) THEN
error = .TRUE.
CALL errorMessage("Observatory / getName", &
"Object has not yet been initialized.", 1)
RETURN
END IF
getName_Obsy = this%name
END FUNCTION getName_Obsy
!! *Description*:
!!
!! Returns geocentric coordinates of the observatory.
!!
!! Returns error.
!!
FUNCTION getPosition_Obsy(this)
IMPLICIT NONE
TYPE (Observatory), INTENT(in) :: this
REAL(bp), DIMENSION(3) :: getPosition_Obsy
IF (.NOT. this%is_initialized) THEN
error = .TRUE.
CALL errorMessage("Observatory / getPosition", &
"Object has not yet been initialized.", 1)
RETURN
END IF
getPosition_Obsy = this%position
END FUNCTION getPosition_Obsy
END MODULE Observatory_cl