libsim Versione 7.2.6
vol7d_ana_class.F90
1! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
2! authors:
3! Davide Cesari <dcesari@arpa.emr.it>
4! Paolo Patruno <ppatruno@arpa.emr.it>
5
6! This program is free software; you can redistribute it and/or
7! modify it under the terms of the GNU General Public License as
8! published by the Free Software Foundation; either version 2 of
9! the License, or (at your option) any later version.
10
11! This program is distributed in the hope that it will be useful,
12! but WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14! GNU General Public License for more details.
15
16! You should have received a copy of the GNU General Public License
17! along with this program. If not, see <http://www.gnu.org/licenses/>.
18#include "config.h"
19
20!> Classe per la gestione dell'anagrafica di stazioni meteo e affini.
21!! Questo modulo definisce una classe in grado di rappresentare
22!! le caratteristiche di una stazione meteo fissa o mobile.
23!! \ingroup vol7d
24MODULE vol7d_ana_class
25USE kinds
28IMPLICIT NONE
29
30!> Lunghezza della stringa che indica l'identificativo del volo.
31INTEGER,PARAMETER :: vol7d_ana_lenident=20
32
33!> Definisce l'anagrafica di una stazione.
34!! I membri di \a vol7d_ana sono pubblici e quindi liberamente
35!! accessibili e scrivibili, ma è comunque consigliato assegnarli tramite
36!! il costruttore ::init.
37TYPE vol7d_ana
38 TYPE(geo_coord) :: coord !< coordinata per una stazione fissa
39 CHARACTER(len=vol7d_ana_lenident) :: ident !< identificativo per una stazione mobile (es. aereo)
40END TYPE vol7d_ana
41
42!> Valore mancante per vo7d_ana.
43TYPE(vol7d_ana),PARAMETER :: vol7d_ana_miss=vol7d_ana(geo_coord_miss,cmiss)
44
45!> Costruttore per la classe vol7d_ana.
46!! Deve essere richiamato
47!! per tutti gli oggetti di questo tipo definiti in un programma.
48INTERFACE init
49 MODULE PROCEDURE vol7d_ana_init
50END INTERFACE
51
52!> Distruttore per la classe vol7d_ana.
53!! Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
54INTERFACE delete
55 MODULE PROCEDURE vol7d_ana_delete
56END INTERFACE
57
58!> Logical equality operator for objects of \a vol7d_ana class.
59!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
60!! of any shape.
61INTERFACE OPERATOR (==)
62 MODULE PROCEDURE vol7d_ana_eq
63END INTERFACE
64
65!> Logical inequality operator for objects of \a vol7d_ana class.
66!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
67!! of any shape.
68INTERFACE OPERATOR (/=)
69 MODULE PROCEDURE vol7d_ana_ne
70END INTERFACE
71
72
73!> Logical greater-than operator for objects of \a vol7d_ana class.
74!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
75!! of any shape.
76!! Comparison is performed first on \a ident, then on coord
77INTERFACE OPERATOR (>)
78 MODULE PROCEDURE vol7d_ana_gt
79END INTERFACE
80
81!> Logical less-than operator for objects of \a vol7d_ana class.
82!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
83!! of any shape.
84!! Comparison is performed first on \a ident, then on coord
85INTERFACE OPERATOR (<)
86 MODULE PROCEDURE vol7d_ana_lt
87END INTERFACE
88
89!> Logical greater-equal operator for objects of \a vol7d_ana class.
90!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
91!! of any shape.
92!! Comparison is performed first on \a ident, then on coord
93INTERFACE OPERATOR (>=)
94 MODULE PROCEDURE vol7d_ana_ge
95END INTERFACE
96
97!> Logical less-equal operator for objects of \a vol7d_ana class.
98!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
99!! of any shape.
100!! Comparison is performed first on \a ident, then on coord
101INTERFACE OPERATOR (<=)
102 MODULE PROCEDURE vol7d_ana_le
103END INTERFACE
104
105
106!> check for missing value
107INTERFACE c_e
108 MODULE PROCEDURE vol7d_ana_c_e
109END INTERFACE
110
111!> Legge un oggetto vol7d_ana o un vettore di oggetti vol7d_ana da
112!! un file \c FORMATTED o \c UNFORMATTED.
113INTERFACE read_unit
114 MODULE PROCEDURE vol7d_ana_read_unit, vol7d_ana_vect_read_unit
115END INTERFACE
116
117!> Scrive un oggetto vol7d_ana o un vettore di oggetti vol7d_ana su
118!! un file \c FORMATTED o \c UNFORMATTED.
119INTERFACE write_unit
120 MODULE PROCEDURE vol7d_ana_write_unit, vol7d_ana_vect_write_unit
121END INTERFACE
122
123#define VOL7D_POLY_TYPE TYPE(vol7d_ana)
124#define VOL7D_POLY_TYPES _ana
125#define ENABLE_SORT
126#include "array_utilities_pre.F90"
127
128!> Represent ana object in a pretty string
129INTERFACE to_char
130 MODULE PROCEDURE to_char_ana
131END INTERFACE
132
133!> Print object
134INTERFACE display
135 MODULE PROCEDURE display_ana
136END INTERFACE
137
138CONTAINS
139
140!> Inizializza un oggetto \a vol7d_ana con i parametri opzionali forniti.
141!! Se non viene passato nessun parametro opzionale l'oggetto è
142!! inizializzato a valore mancante.
143SUBROUTINE vol7d_ana_init(this, lon, lat, ident, ilon, ilat)
144TYPE(vol7d_ana),INTENT(INOUT) :: this !< oggetto da inizializzare
145REAL(kind=fp_geo),INTENT(in),OPTIONAL :: lon !< longitudine
146REAL(kind=fp_geo),INTENT(in),OPTIONAL :: lat !< latitudine
147CHARACTER(len=*),INTENT(in),OPTIONAL :: ident !< identificativo del volo
148INTEGER(kind=int_l),INTENT(in),OPTIONAL :: ilon !< integer longitude (nint(lon*1.d5)
149INTEGER(kind=int_l),INTENT(in),OPTIONAL :: ilat !< integer latitude (nint(lat*1.d5)
150
151CALL init(this%coord, lon=lon, lat=lat , ilon=ilon, ilat=ilat)
152IF (PRESENT(ident)) THEN
153 this%ident = ident
154ELSE
155 this%ident = cmiss
156ENDIF
157
158END SUBROUTINE vol7d_ana_init
159
160
161!> Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
162SUBROUTINE vol7d_ana_delete(this)
163TYPE(vol7d_ana),INTENT(INOUT) :: this !< oggetto da distruggre
164
165CALL delete(this%coord)
166this%ident = cmiss
167
168END SUBROUTINE vol7d_ana_delete
169
170
171
172character(len=80) function to_char_ana(this)
173
174TYPE(vol7d_ana),INTENT(in) :: this
175
176to_char_ana="ANA: "//&
177 to_char(getlon(this%coord),miss="Missing lon",form="(f11.5)")//&
178 to_char(getlat(this%coord),miss="Missing lat",form="(f11.5)")//&
179 t2c(this%ident,miss="Missing ident")
180
181return
182
183end function to_char_ana
184
185
186subroutine display_ana(this)
187
188TYPE(vol7d_ana),INTENT(in) :: this
189
190print*, trim(to_char(this))
191
192end subroutine display_ana
193
194
195ELEMENTAL FUNCTION vol7d_ana_eq(this, that) RESULT(res)
196TYPE(vol7d_ana),INTENT(IN) :: this, that
197LOGICAL :: res
198
199res = this%coord == that%coord .AND. this%ident == that%ident
200
201END FUNCTION vol7d_ana_eq
202
203
204ELEMENTAL FUNCTION vol7d_ana_ne(this, that) RESULT(res)
205TYPE(vol7d_ana),INTENT(IN) :: this, that
206LOGICAL :: res
207
208res = .NOT.(this == that)
209
210END FUNCTION vol7d_ana_ne
211
213ELEMENTAL FUNCTION vol7d_ana_gt(this, that) RESULT(res)
214TYPE(vol7d_ana),INTENT(IN) :: this, that
215LOGICAL :: res
216
217res = this%ident > that%ident
218
219if ( this%ident == that%ident) then
220 res =this%coord > that%coord
221end if
222
223END FUNCTION vol7d_ana_gt
224
226ELEMENTAL FUNCTION vol7d_ana_ge(this, that) RESULT(res)
227TYPE(vol7d_ana),INTENT(IN) :: this, that
228LOGICAL :: res
229
230res = .not. this < that
232END FUNCTION vol7d_ana_ge
233
234
235ELEMENTAL FUNCTION vol7d_ana_lt(this, that) RESULT(res)
236TYPE(vol7d_ana),INTENT(IN) :: this, that
237LOGICAL :: res
238
239res = this%ident < that%ident
240
241if ( this%ident == that%ident) then
242 res = this%coord < that%coord
243end if
244
245END FUNCTION vol7d_ana_lt
246
247
248ELEMENTAL FUNCTION vol7d_ana_le(this, that) RESULT(res)
249TYPE(vol7d_ana),INTENT(IN) :: this, that
250LOGICAL :: res
251
252res = .not. (this > that)
253
254END FUNCTION vol7d_ana_le
255
257
258ELEMENTAL FUNCTION vol7d_ana_c_e(this) RESULT(c_e)
259TYPE(vol7d_ana),INTENT(IN) :: this
260LOGICAL :: c_e
261c_e = this /= vol7d_ana_miss
262END FUNCTION vol7d_ana_c_e
263
264
265!> This method reads from a Fortran file unit the contents of the
266!! object \a this. The record to be read must have been written with
267!! the ::write_unit method. The method works both on formatted and
268!! unformatted files.
269SUBROUTINE vol7d_ana_read_unit(this, unit)
270TYPE(vol7d_ana),INTENT(out) :: this !< object to be read
271INTEGER, INTENT(in) :: unit !< unit from which to read, it must be an opened Fortran file unit
272
273CALL vol7d_ana_vect_read_unit((/this/), unit)
274
275END SUBROUTINE vol7d_ana_read_unit
276
277
278!> This method reads from a Fortran file unit the contents of the
279!! object \a this. The record to be read must have been written with
280!! the ::write_unit method. The method works both on formatted and
281!! unformatted files.
282SUBROUTINE vol7d_ana_vect_read_unit(this, unit)
283TYPE(vol7d_ana) :: this(:) !< object to be read
284INTEGER, INTENT(in) :: unit !< unit from which to read, it must be an opened Fortran file unit
285
286CHARACTER(len=40) :: form
287
288CALL read_unit(this%coord, unit)
289INQUIRE(unit, form=form)
290IF (form == 'FORMATTED') THEN
291 READ(unit,'(A)')this(:)%ident
292ELSE
293 READ(unit)this(:)%ident
294ENDIF
296END SUBROUTINE vol7d_ana_vect_read_unit
297
298
299!> This method writes on a Fortran file unit the contents of the
300!! object \a this. The record can successively be read by the
301!! ::read_unit method. The method works both on formatted and
302!! unformatted files.
303SUBROUTINE vol7d_ana_write_unit(this, unit)
304TYPE(vol7d_ana),INTENT(in) :: this !< object to be written
305INTEGER, INTENT(in) :: unit !< unit where to write, it must be an opened Fortran file unit
306
307CALL vol7d_ana_vect_write_unit((/this/), unit)
308
309END SUBROUTINE vol7d_ana_write_unit
310
311
312!> This method writes on a Fortran file unit the contents of the
313!! object \a this. The record can successively be read by the
314!! ::read_unit method. The method works both on formatted and
315!! unformatted files.
316SUBROUTINE vol7d_ana_vect_write_unit(this, unit)
317TYPE(vol7d_ana),INTENT(in) :: this(:) !< object to be written
318INTEGER, INTENT(in) :: unit !< unit where to write, it must be an opened Fortran file unit
319
320CHARACTER(len=40) :: form
321
322CALL write_unit(this%coord, unit)
323INQUIRE(unit, form=form)
324IF (form == 'FORMATTED') THEN
325 WRITE(unit,'(A)')this(:)%ident
326ELSE
327 WRITE(unit)this(:)%ident
328ENDIF
329
330END SUBROUTINE vol7d_ana_vect_write_unit
331
332
333#include "array_utilities_inc.F90"
334
335
336END MODULE vol7d_ana_class
Index method.
check for missing value
Distruttore per la classe vol7d_ana.
Index method with sorted array.
Costruttore per la classe vol7d_ana.
Legge un oggetto vol7d_ana o un vettore di oggetti vol7d_ana da un file FORMATTED o UNFORMATTED.
Represent ana object in a pretty string.
Scrive un oggetto vol7d_ana o un vettore di oggetti vol7d_ana su un file FORMATTED o UNFORMATTED.
Classes for handling georeferenced sparse points in geographical corodinates.
Definition of constants to be used for declaring variables of a desired type.
Definition kinds.F90:245
Definitions of constants and functions for working with missing values.
Classe per la gestione dell'anagrafica di stazioni meteo e affini.
Derived type defining an isolated georeferenced point on Earth in polar geographical coordinates.
Definisce l'anagrafica di una stazione.

Generated with Doxygen.