libsim Versione 7.2.6
|
◆ arrayof_vol7d_timerange_insert_unique()
Method for inserting an element of the array at a desired position only if it is not present in the array yet. If necessary, the array is reallocated to accomodate the new element.
Definizione alla linea 1952 del file vol7d_timerange_class.F90. 1953! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
1954! authors:
1955! Davide Cesari <dcesari@arpa.emr.it>
1956! Paolo Patruno <ppatruno@arpa.emr.it>
1957
1958! This program is free software; you can redistribute it and/or
1959! modify it under the terms of the GNU General Public License as
1960! published by the Free Software Foundation; either version 2 of
1961! the License, or (at your option) any later version.
1962
1963! This program is distributed in the hope that it will be useful,
1964! but WITHOUT ANY WARRANTY; without even the implied warranty of
1965! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1966! GNU General Public License for more details.
1967
1968! You should have received a copy of the GNU General Public License
1969! along with this program. If not, see <http://www.gnu.org/licenses/>.
1970#include "config.h"
1971
1972!> Classe per la gestione degli intervalli temporali di osservazioni
1973!! meteo e affini.
1974!! Questo modulo definisce una classe in grado di rappresentare
1975!! l'intervallo di tempo a cui si riferisce un'osservazione meteo,
1976!! ad es. valore istantaneo, cumulato, medio, ecc., prendendo in prestito
1977!! concetti dal formato grib.
1978!! \ingroup vol7d
1983IMPLICIT NONE
1984
1985!> Definisce l'intervallo temporale di un'osservazione meteo.
1986!! I membri di \a vol7d_timerange sono pubblici e quindi liberamente
1987!! accessibili e scrivibili, ma è comunque consigliato assegnarli tramite
1988!! il costruttore ::init.
1990 INTEGER :: timerange !< proprietà statistiche del dato (es. 0=media, 1=cumulazione, 2=massimo, 3=minimo, 4=differenza... 254=dato istantaneo) tratte dalla code table 4.10 del formato WMO grib edizione 2, vedi http://www.wmo.int/pages/prog/www/WMOCodes/WMO306_vI2/LatestVERSION/WMO306_vI2_GRIB2_CodeFlag_en.pdf
1991 INTEGER :: p1 !< termine del periodo di validità del dato, in secondi, a partire dall'istante di riferimento (0 per dati osservati o analizzati)
1992 INTEGER :: p2 !< durata del periodo di validità del dato, in secondi (0 per dati istantanei)
1994
1995!> Valore mancante per vol7d_timerange.
1996TYPE(vol7d_timerange),PARAMETER :: vol7d_timerange_miss= &
1997 vol7d_timerange(imiss,imiss,imiss)
1998
1999!> Costruttore per la classe vol7d_timerange.
2000!! Deve essere richiamato
2001!! per tutti gli oggetti di questo tipo definiti in un programma.
2003 MODULE PROCEDURE vol7d_timerange_init
2004END INTERFACE
2005
2006!> Distruttore per la classe vol7d_timerange.
2007!! Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
2009 MODULE PROCEDURE vol7d_timerange_delete
2010END INTERFACE
2011
2012!> Logical equality operator for objects of \a vol7d_timerange class.
2013!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
2014!! of any shape.
2015INTERFACE OPERATOR (==)
2016 MODULE PROCEDURE vol7d_timerange_eq
2017END INTERFACE
2018
2019!> Logical inequality operator for objects of \a vol7d_timerange class.
2020!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
2021!! of any shape.
2022INTERFACE OPERATOR (/=)
2023 MODULE PROCEDURE vol7d_timerange_ne
2024END INTERFACE
2025
2026!> Logical greater-than operator for objects of \a vol7d_timerange class.
2027!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
2028!! of any shape.
2029INTERFACE OPERATOR (>)
2030 MODULE PROCEDURE vol7d_timerange_gt
2031END INTERFACE
2032
2033!> Logical less-than operator for objects of \a vol7d_timerange class.
2034!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
2035!! of any shape.
2036INTERFACE OPERATOR (<)
2037 MODULE PROCEDURE vol7d_timerange_lt
2038END INTERFACE
2039
2040!> Logical greater-equal operator for objects of \a vol7d_timerange class.
2041!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
2042!! of any shape.
2043INTERFACE OPERATOR (>=)
2044 MODULE PROCEDURE vol7d_timerange_ge
2045END INTERFACE
2046
2047!> Logical less-equal operator for objects of \a vol7d_timerange class.
2048!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
2049!! of any shape.
2050INTERFACE OPERATOR (<=)
2051 MODULE PROCEDURE vol7d_timerange_le
2052END INTERFACE
2053
2054!> Logical almost equality operator for objects of \a vol7d_timerange class.
2055!! If one component is missing it is not used in comparison.
2056INTERFACE OPERATOR (.almosteq.)
2057 MODULE PROCEDURE vol7d_timerange_almost_eq
2058END INTERFACE
2059
2060
2061! da documentare in inglese assieme al resto
2062!> to be documented
2064 MODULE PROCEDURE vol7d_timerange_c_e
2065END INTERFACE
2066
2067#define VOL7D_POLY_TYPE TYPE(vol7d_timerange)
2068#define VOL7D_POLY_TYPES _timerange
2069#define ENABLE_SORT
2070#include "array_utilities_pre.F90"
2071
2072!>Print object
2074 MODULE PROCEDURE display_timerange
2075END INTERFACE
2076
2077!>Represent timerange object in a pretty string
2079 MODULE PROCEDURE to_char_timerange
2080END INTERFACE
2081
2082#define ARRAYOF_ORIGTYPE TYPE(vol7d_timerange)
2083#define ARRAYOF_TYPE arrayof_vol7d_timerange
2084#define ARRAYOF_ORIGEQ 1
2085#include "arrayof_pre.F90"
2086
2087
2088type(vol7d_timerange) :: almost_equal_timeranges(2)=(/&
2089 vol7d_timerange(254,0,imiss),&
2090 vol7d_timerange(3,0,3600)/)
2091
2092
2093! from arrayof
2095PUBLIC insert_unique, append_unique
2096PUBLIC almost_equal_timeranges
2097
2098CONTAINS
2099
2100
2101!> Inizializza un oggetto \a vol7d_timerange con i parametri opzionali forniti.
2102!! Questa è la versione \c FUNCTION, in stile F2003, del costruttore, da preferire
2103!! rispetto alla versione \c SUBROUTINE \c init.
2104!! Se non viene passato nessun parametro opzionale l'oggetto è
2105!! inizializzato a valore mancante.
2106FUNCTION vol7d_timerange_new(timerange, p1, p2) RESULT(this)
2107INTEGER,INTENT(IN),OPTIONAL :: timerange !< tipo di intervallo temporale
2108INTEGER,INTENT(IN),OPTIONAL :: p1 !< valore per il primo istante temporale
2109INTEGER,INTENT(IN),OPTIONAL :: p2 !< valore per il secondo istante temporale
2110
2111TYPE(vol7d_timerange) :: this !< oggetto da inizializzare
2112
2114
2115END FUNCTION vol7d_timerange_new
2116
2117
2118!> Inizializza un oggetto \a vol7d_timerange con i parametri opzionali forniti.
2119!! Se non viene passato nessun parametro opzionale l'oggetto è
2120!! inizializzato a valore mancante.
2121SUBROUTINE vol7d_timerange_init(this, timerange, p1, p2)
2122TYPE(vol7d_timerange),INTENT(INOUT) :: this !< oggetto da inizializzare
2123INTEGER,INTENT(IN),OPTIONAL :: timerange !< tipo di intervallo temporale
2124INTEGER,INTENT(IN),OPTIONAL :: p1 !< valore per il primo istante temporale
2125INTEGER,INTENT(IN),OPTIONAL :: p2 !< valore per il secondo istante temporale
2126
2127IF (PRESENT(timerange)) THEN
2128 this%timerange = timerange
2129ELSE
2130 this%timerange = imiss
2131 this%p1 = imiss
2132 this%p2 = imiss
2133 RETURN
2134ENDIF
2135!!$IF (timerange == 1) THEN ! p1 sempre 0
2136!!$ this%p1 = 0
2137!!$ this%p2 = imiss
2138!!$ELSE IF (timerange == 0 .OR. timerange == 10) THEN ! solo p1
2139!!$ IF (PRESENT(p1)) THEN
2140!!$ this%p1 = p1
2141!!$ ELSE
2142!!$ this%p1 = 0
2143!!$ ENDIF
2144!!$ this%p2 = imiss
2145!!$ELSE ! tutti gli altri
2146 IF (PRESENT(p1)) THEN
2147 this%p1 = p1
2148 ELSE
2149 this%p1 = imiss
2150 ENDIF
2151 IF (PRESENT(p2)) THEN
2152 this%p2 = p2
2153 ELSE
2154 this%p2 = imiss
2155 ENDIF
2156!!$END IF
2157
2158END SUBROUTINE vol7d_timerange_init
2159
2160
2161!> Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
2162SUBROUTINE vol7d_timerange_delete(this)
2163TYPE(vol7d_timerange),INTENT(INOUT) :: this
2164
2165this%timerange = imiss
2166this%p1 = imiss
2167this%p2 = imiss
2168
2169END SUBROUTINE vol7d_timerange_delete
2170
2171
2172SUBROUTINE display_timerange(this)
2173TYPE(vol7d_timerange),INTENT(in) :: this
2174
2175print*,to_char_timerange(this)
2176
2177END SUBROUTINE display_timerange
2178
2179
2180FUNCTION to_char_timerange(this)
2181#ifdef HAVE_DBALLE
2182USE dballef
2183#endif
2184TYPE(vol7d_timerange),INTENT(in) :: this
2185CHARACTER(len=80) :: to_char_timerange
2186
2187#ifdef HAVE_DBALLE
2188INTEGER :: handle, ier
2189
2190handle = 0
2191ier = idba_messaggi(handle,"/dev/null", "w", "BUFR")
2192ier = idba_spiegat(handle,this%timerange,this%p1,this%p2,to_char_timerange)
2193ier = idba_fatto(handle)
2194
2195to_char_timerange="Timerange: "//to_char_timerange
2196
2197#else
2198
2201
2202#endif
2203
2204END FUNCTION to_char_timerange
2205
2206
2207ELEMENTAL FUNCTION vol7d_timerange_eq(this, that) RESULT(res)
2208TYPE(vol7d_timerange),INTENT(IN) :: this, that
2209LOGICAL :: res
2210
2211
2212res = &
2213 this%timerange == that%timerange .AND. &
2214 this%p1 == that%p1 .AND. (this%p2 == that%p2 .OR. &
2215 this%timerange == 254)
2216
2217END FUNCTION vol7d_timerange_eq
2218
2219
2220ELEMENTAL FUNCTION vol7d_timerange_almost_eq(this, that) RESULT(res)
2221TYPE(vol7d_timerange),INTENT(IN) :: this, that
2222LOGICAL :: res
2223
2224IF (.not. c_e(this%timerange) .or. .not. c_e(that%timerange) .or. this%timerange == that%timerange .AND. &
2225 this%p1 == that%p1 .AND. &
2226 this%p2 == that%p2) THEN
2227 res = .true.
2228ELSE
2229 res = .false.
2230ENDIF
2231
2232END FUNCTION vol7d_timerange_almost_eq
2233
2234
2235ELEMENTAL FUNCTION vol7d_timerange_ne(this, that) RESULT(res)
2236TYPE(vol7d_timerange),INTENT(IN) :: this, that
2237LOGICAL :: res
2238
2239res = .NOT.(this == that)
2240
2241END FUNCTION vol7d_timerange_ne
2242
2243
2244ELEMENTAL FUNCTION vol7d_timerange_gt(this, that) RESULT(res)
2245TYPE(vol7d_timerange),INTENT(IN) :: this, that
2246LOGICAL :: res
2247
2248IF (this%timerange > that%timerange .OR. &
2249 (this%timerange == that%timerange .AND. this%p1 > that%p1) .OR. &
2250 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
2251 this%p2 > that%p2)) THEN
2252 res = .true.
2253ELSE
2254 res = .false.
2255ENDIF
2256
2257END FUNCTION vol7d_timerange_gt
2258
2259
2260ELEMENTAL FUNCTION vol7d_timerange_lt(this, that) RESULT(res)
2261TYPE(vol7d_timerange),INTENT(IN) :: this, that
2262LOGICAL :: res
2263
2264IF (this%timerange < that%timerange .OR. &
2265 (this%timerange == that%timerange .AND. this%p1 < that%p1) .OR. &
2266 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
2267 this%p2 < that%p2)) THEN
2268 res = .true.
2269ELSE
2270 res = .false.
2271ENDIF
2272
2273END FUNCTION vol7d_timerange_lt
2274
2275
2276ELEMENTAL FUNCTION vol7d_timerange_ge(this, that) RESULT(res)
2277TYPE(vol7d_timerange),INTENT(IN) :: this, that
2278LOGICAL :: res
2279
2280IF (this == that) THEN
2281 res = .true.
2282ELSE IF (this > that) THEN
2283 res = .true.
2284ELSE
2285 res = .false.
2286ENDIF
2287
2288END FUNCTION vol7d_timerange_ge
2289
2290
2291ELEMENTAL FUNCTION vol7d_timerange_le(this, that) RESULT(res)
2292TYPE(vol7d_timerange),INTENT(IN) :: this, that
2293LOGICAL :: res
2294
2295IF (this == that) THEN
2296 res = .true.
2297ELSE IF (this < that) THEN
2298 res = .true.
2299ELSE
2300 res = .false.
2301ENDIF
2302
2303END FUNCTION vol7d_timerange_le
2304
2305
2306ELEMENTAL FUNCTION vol7d_timerange_c_e(this) RESULT(c_e)
2307TYPE(vol7d_timerange),INTENT(IN) :: this
2308LOGICAL :: c_e
2309c_e = this /= vol7d_timerange_miss
2310END FUNCTION vol7d_timerange_c_e
2311
2312
2313#include "array_utilities_inc.F90"
2314
2315#include "arrayof_post.F90"
2316
2317
Quick method to append an element to the array. Definition vol7d_timerange_class.F90:425 Distruttore per la classe vol7d_timerange. Definition vol7d_timerange_class.F90:244 Costruttore per la classe vol7d_timerange. Definition vol7d_timerange_class.F90:238 Method for inserting elements of the array at a desired position. Definition vol7d_timerange_class.F90:416 Method for packing the array object reducing at a minimum the memory occupation, without destroying i... Definition vol7d_timerange_class.F90:448 Method for removing elements of the array at a desired position. Definition vol7d_timerange_class.F90:431 Represent timerange object in a pretty string. Definition vol7d_timerange_class.F90:369 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. Definition missing_values.f90:50 Classe per la gestione degli intervalli temporali di osservazioni meteo e affini. Definition vol7d_timerange_class.F90:215 Definisce l'intervallo temporale di un'osservazione meteo. Definition vol7d_timerange_class.F90:225 |