libsim Versione 7.1.11
|
◆ 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 1958 del file vol7d_timerange_class.F90. 1959! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
1960! authors:
1961! Davide Cesari <dcesari@arpa.emr.it>
1962! Paolo Patruno <ppatruno@arpa.emr.it>
1963
1964! This program is free software; you can redistribute it and/or
1965! modify it under the terms of the GNU General Public License as
1966! published by the Free Software Foundation; either version 2 of
1967! the License, or (at your option) any later version.
1968
1969! This program is distributed in the hope that it will be useful,
1970! but WITHOUT ANY WARRANTY; without even the implied warranty of
1971! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1972! GNU General Public License for more details.
1973
1974! You should have received a copy of the GNU General Public License
1975! along with this program. If not, see <http://www.gnu.org/licenses/>.
1976#include "config.h"
1977
1989IMPLICIT NONE
1990
1996 INTEGER :: timerange
1997 INTEGER :: p1
1998 INTEGER :: p2
2000
2002TYPE(vol7d_timerange),PARAMETER :: vol7d_timerange_miss= &
2003 vol7d_timerange(imiss,imiss,imiss)
2004
2009 MODULE PROCEDURE vol7d_timerange_init
2010END INTERFACE
2011
2015 MODULE PROCEDURE vol7d_timerange_delete
2016END INTERFACE
2017
2021INTERFACE OPERATOR (==)
2022 MODULE PROCEDURE vol7d_timerange_eq
2023END INTERFACE
2024
2028INTERFACE OPERATOR (/=)
2029 MODULE PROCEDURE vol7d_timerange_ne
2030END INTERFACE
2031
2035INTERFACE OPERATOR (>)
2036 MODULE PROCEDURE vol7d_timerange_gt
2037END INTERFACE
2038
2042INTERFACE OPERATOR (<)
2043 MODULE PROCEDURE vol7d_timerange_lt
2044END INTERFACE
2045
2049INTERFACE OPERATOR (>=)
2050 MODULE PROCEDURE vol7d_timerange_ge
2051END INTERFACE
2052
2056INTERFACE OPERATOR (<=)
2057 MODULE PROCEDURE vol7d_timerange_le
2058END INTERFACE
2059
2062INTERFACE OPERATOR (.almosteq.)
2063 MODULE PROCEDURE vol7d_timerange_almost_eq
2064END INTERFACE
2065
2066
2067! da documentare in inglese assieme al resto
2070 MODULE PROCEDURE vol7d_timerange_c_e
2071END INTERFACE
2072
2073#define VOL7D_POLY_TYPE TYPE(vol7d_timerange)
2074#define VOL7D_POLY_TYPES _timerange
2075#define ENABLE_SORT
2076#include "array_utilities_pre.F90"
2077
2080 MODULE PROCEDURE display_timerange
2081END INTERFACE
2082
2085 MODULE PROCEDURE to_char_timerange
2086END INTERFACE
2087
2088#define ARRAYOF_ORIGTYPE TYPE(vol7d_timerange)
2089#define ARRAYOF_TYPE arrayof_vol7d_timerange
2090#define ARRAYOF_ORIGEQ 1
2091#include "arrayof_pre.F90"
2092
2093
2094type(vol7d_timerange) :: almost_equal_timeranges(2)=(/&
2095 vol7d_timerange(254,0,imiss),&
2096 vol7d_timerange(3,0,3600)/)
2097
2098
2099! from arrayof
2101PUBLIC insert_unique, append_unique
2102PUBLIC almost_equal_timeranges
2103
2104CONTAINS
2105
2106
2112FUNCTION vol7d_timerange_new(timerange, p1, p2) RESULT(this)
2113INTEGER,INTENT(IN),OPTIONAL :: timerange
2114INTEGER,INTENT(IN),OPTIONAL :: p1
2115INTEGER,INTENT(IN),OPTIONAL :: p2
2116
2117TYPE(vol7d_timerange) :: this
2118
2120
2121END FUNCTION vol7d_timerange_new
2122
2123
2127SUBROUTINE vol7d_timerange_init(this, timerange, p1, p2)
2128TYPE(vol7d_timerange),INTENT(INOUT) :: this
2129INTEGER,INTENT(IN),OPTIONAL :: timerange
2130INTEGER,INTENT(IN),OPTIONAL :: p1
2131INTEGER,INTENT(IN),OPTIONAL :: p2
2132
2133IF (PRESENT(timerange)) THEN
2134 this%timerange = timerange
2135ELSE
2136 this%timerange = imiss
2137 this%p1 = imiss
2138 this%p2 = imiss
2139 RETURN
2140ENDIF
2141!!$IF (timerange == 1) THEN ! p1 sempre 0
2142!!$ this%p1 = 0
2143!!$ this%p2 = imiss
2144!!$ELSE IF (timerange == 0 .OR. timerange == 10) THEN ! solo p1
2145!!$ IF (PRESENT(p1)) THEN
2146!!$ this%p1 = p1
2147!!$ ELSE
2148!!$ this%p1 = 0
2149!!$ ENDIF
2150!!$ this%p2 = imiss
2151!!$ELSE ! tutti gli altri
2152 IF (PRESENT(p1)) THEN
2153 this%p1 = p1
2154 ELSE
2155 this%p1 = imiss
2156 ENDIF
2157 IF (PRESENT(p2)) THEN
2158 this%p2 = p2
2159 ELSE
2160 this%p2 = imiss
2161 ENDIF
2162!!$END IF
2163
2164END SUBROUTINE vol7d_timerange_init
2165
2166
2168SUBROUTINE vol7d_timerange_delete(this)
2169TYPE(vol7d_timerange),INTENT(INOUT) :: this
2170
2171this%timerange = imiss
2172this%p1 = imiss
2173this%p2 = imiss
2174
2175END SUBROUTINE vol7d_timerange_delete
2176
2177
2178SUBROUTINE display_timerange(this)
2179TYPE(vol7d_timerange),INTENT(in) :: this
2180
2181print*,to_char_timerange(this)
2182
2183END SUBROUTINE display_timerange
2184
2185
2186FUNCTION to_char_timerange(this)
2187#ifdef HAVE_DBALLE
2188USE dballef
2189#endif
2190TYPE(vol7d_timerange),INTENT(in) :: this
2191CHARACTER(len=80) :: to_char_timerange
2192
2193#ifdef HAVE_DBALLE
2194INTEGER :: handle, ier
2195
2196handle = 0
2197ier = idba_messaggi(handle,"/dev/null", "w", "BUFR")
2198ier = idba_spiegat(handle,this%timerange,this%p1,this%p2,to_char_timerange)
2199ier = idba_fatto(handle)
2200
2201to_char_timerange="Timerange: "//to_char_timerange
2202
2203#else
2204
2207
2208#endif
2209
2210END FUNCTION to_char_timerange
2211
2212
2213ELEMENTAL FUNCTION vol7d_timerange_eq(this, that) RESULT(res)
2214TYPE(vol7d_timerange),INTENT(IN) :: this, that
2215LOGICAL :: res
2216
2217
2218res = &
2219 this%timerange == that%timerange .AND. &
2220 this%p1 == that%p1 .AND. (this%p2 == that%p2 .OR. &
2221 this%timerange == 254)
2222
2223END FUNCTION vol7d_timerange_eq
2224
2225
2226ELEMENTAL FUNCTION vol7d_timerange_almost_eq(this, that) RESULT(res)
2227TYPE(vol7d_timerange),INTENT(IN) :: this, that
2228LOGICAL :: res
2229
2230IF (.not. c_e(this%timerange) .or. .not. c_e(that%timerange) .or. this%timerange == that%timerange .AND. &
2231 this%p1 == that%p1 .AND. &
2232 this%p2 == that%p2) THEN
2233 res = .true.
2234ELSE
2235 res = .false.
2236ENDIF
2237
2238END FUNCTION vol7d_timerange_almost_eq
2239
2240
2241ELEMENTAL FUNCTION vol7d_timerange_ne(this, that) RESULT(res)
2242TYPE(vol7d_timerange),INTENT(IN) :: this, that
2243LOGICAL :: res
2244
2245res = .NOT.(this == that)
2246
2247END FUNCTION vol7d_timerange_ne
2248
2249
2250ELEMENTAL FUNCTION vol7d_timerange_gt(this, that) RESULT(res)
2251TYPE(vol7d_timerange),INTENT(IN) :: this, that
2252LOGICAL :: res
2253
2254IF (this%timerange > that%timerange .OR. &
2255 (this%timerange == that%timerange .AND. this%p1 > that%p1) .OR. &
2256 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
2257 this%p2 > that%p2)) THEN
2258 res = .true.
2259ELSE
2260 res = .false.
2261ENDIF
2262
2263END FUNCTION vol7d_timerange_gt
2264
2265
2266ELEMENTAL FUNCTION vol7d_timerange_lt(this, that) RESULT(res)
2267TYPE(vol7d_timerange),INTENT(IN) :: this, that
2268LOGICAL :: res
2269
2270IF (this%timerange < that%timerange .OR. &
2271 (this%timerange == that%timerange .AND. this%p1 < that%p1) .OR. &
2272 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
2273 this%p2 < that%p2)) THEN
2274 res = .true.
2275ELSE
2276 res = .false.
2277ENDIF
2278
2279END FUNCTION vol7d_timerange_lt
2280
2281
2282ELEMENTAL FUNCTION vol7d_timerange_ge(this, that) RESULT(res)
2283TYPE(vol7d_timerange),INTENT(IN) :: this, that
2284LOGICAL :: res
2285
2286IF (this == that) THEN
2287 res = .true.
2288ELSE IF (this > that) THEN
2289 res = .true.
2290ELSE
2291 res = .false.
2292ENDIF
2293
2294END FUNCTION vol7d_timerange_ge
2295
2296
2297ELEMENTAL FUNCTION vol7d_timerange_le(this, that) RESULT(res)
2298TYPE(vol7d_timerange),INTENT(IN) :: this, that
2299LOGICAL :: res
2300
2301IF (this == that) THEN
2302 res = .true.
2303ELSE IF (this < that) THEN
2304 res = .true.
2305ELSE
2306 res = .false.
2307ENDIF
2308
2309END FUNCTION vol7d_timerange_le
2310
2311
2312ELEMENTAL FUNCTION vol7d_timerange_c_e(this) RESULT(c_e)
2313TYPE(vol7d_timerange),INTENT(IN) :: this
2314LOGICAL :: c_e
2315c_e = this /= vol7d_timerange_miss
2316END FUNCTION vol7d_timerange_c_e
2317
2318
2319#include "array_utilities_inc.F90"
2320
2321#include "arrayof_post.F90"
2322
2323
Quick method to append an element to the array. Definition: vol7d_timerange_class.F90:431 Distruttore per la classe vol7d_timerange. Definition: vol7d_timerange_class.F90:250 Costruttore per la classe vol7d_timerange. Definition: vol7d_timerange_class.F90:244 Method for inserting elements of the array at a desired position. Definition: vol7d_timerange_class.F90:422 Method for packing the array object reducing at a minimum the memory occupation, without destroying i... Definition: vol7d_timerange_class.F90:454 Method for removing elements of the array at a desired position. Definition: vol7d_timerange_class.F90:437 Represent timerange object in a pretty string. Definition: vol7d_timerange_class.F90:375 Definition of constants to be used for declaring variables of a desired type. Definition: kinds.F90:251 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:221 Definisce l'intervallo temporale di un'osservazione meteo. Definition: vol7d_timerange_class.F90:231 |