libsim Versione 7.2.6
|
◆ index_sorted_timerange()
Cerca l'indice del primo o ultimo elemento di vect uguale a search. Definizione alla linea 1291 del file vol7d_timerange_class.F90. 1293! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
1294! authors:
1295! Davide Cesari <dcesari@arpa.emr.it>
1296! Paolo Patruno <ppatruno@arpa.emr.it>
1297
1298! This program is free software; you can redistribute it and/or
1299! modify it under the terms of the GNU General Public License as
1300! published by the Free Software Foundation; either version 2 of
1301! the License, or (at your option) any later version.
1302
1303! This program is distributed in the hope that it will be useful,
1304! but WITHOUT ANY WARRANTY; without even the implied warranty of
1305! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1306! GNU General Public License for more details.
1307
1308! You should have received a copy of the GNU General Public License
1309! along with this program. If not, see <http://www.gnu.org/licenses/>.
1310#include "config.h"
1311
1312!> Classe per la gestione degli intervalli temporali di osservazioni
1313!! meteo e affini.
1314!! Questo modulo definisce una classe in grado di rappresentare
1315!! l'intervallo di tempo a cui si riferisce un'osservazione meteo,
1316!! ad es. valore istantaneo, cumulato, medio, ecc., prendendo in prestito
1317!! concetti dal formato grib.
1318!! \ingroup vol7d
1323IMPLICIT NONE
1324
1325!> Definisce l'intervallo temporale di un'osservazione meteo.
1326!! I membri di \a vol7d_timerange sono pubblici e quindi liberamente
1327!! accessibili e scrivibili, ma è comunque consigliato assegnarli tramite
1328!! il costruttore ::init.
1330 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
1331 INTEGER :: p1 !< termine del periodo di validità del dato, in secondi, a partire dall'istante di riferimento (0 per dati osservati o analizzati)
1332 INTEGER :: p2 !< durata del periodo di validità del dato, in secondi (0 per dati istantanei)
1334
1335!> Valore mancante per vol7d_timerange.
1336TYPE(vol7d_timerange),PARAMETER :: vol7d_timerange_miss= &
1337 vol7d_timerange(imiss,imiss,imiss)
1338
1339!> Costruttore per la classe vol7d_timerange.
1340!! Deve essere richiamato
1341!! per tutti gli oggetti di questo tipo definiti in un programma.
1343 MODULE PROCEDURE vol7d_timerange_init
1344END INTERFACE
1345
1346!> Distruttore per la classe vol7d_timerange.
1347!! Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
1349 MODULE PROCEDURE vol7d_timerange_delete
1350END INTERFACE
1351
1352!> Logical equality operator for objects of \a vol7d_timerange class.
1353!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1354!! of any shape.
1355INTERFACE OPERATOR (==)
1356 MODULE PROCEDURE vol7d_timerange_eq
1357END INTERFACE
1358
1359!> Logical inequality operator for objects of \a vol7d_timerange class.
1360!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1361!! of any shape.
1362INTERFACE OPERATOR (/=)
1363 MODULE PROCEDURE vol7d_timerange_ne
1364END INTERFACE
1365
1366!> Logical greater-than operator for objects of \a vol7d_timerange class.
1367!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1368!! of any shape.
1369INTERFACE OPERATOR (>)
1370 MODULE PROCEDURE vol7d_timerange_gt
1371END INTERFACE
1372
1373!> Logical less-than operator for objects of \a vol7d_timerange class.
1374!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1375!! of any shape.
1376INTERFACE OPERATOR (<)
1377 MODULE PROCEDURE vol7d_timerange_lt
1378END INTERFACE
1379
1380!> Logical greater-equal operator for objects of \a vol7d_timerange class.
1381!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1382!! of any shape.
1383INTERFACE OPERATOR (>=)
1384 MODULE PROCEDURE vol7d_timerange_ge
1385END INTERFACE
1386
1387!> Logical less-equal operator for objects of \a vol7d_timerange class.
1388!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1389!! of any shape.
1390INTERFACE OPERATOR (<=)
1391 MODULE PROCEDURE vol7d_timerange_le
1392END INTERFACE
1393
1394!> Logical almost equality operator for objects of \a vol7d_timerange class.
1395!! If one component is missing it is not used in comparison.
1396INTERFACE OPERATOR (.almosteq.)
1397 MODULE PROCEDURE vol7d_timerange_almost_eq
1398END INTERFACE
1399
1400
1401! da documentare in inglese assieme al resto
1402!> to be documented
1404 MODULE PROCEDURE vol7d_timerange_c_e
1405END INTERFACE
1406
1407#define VOL7D_POLY_TYPE TYPE(vol7d_timerange)
1408#define VOL7D_POLY_TYPES _timerange
1409#define ENABLE_SORT
1410#include "array_utilities_pre.F90"
1411
1412!>Print object
1414 MODULE PROCEDURE display_timerange
1415END INTERFACE
1416
1417!>Represent timerange object in a pretty string
1419 MODULE PROCEDURE to_char_timerange
1420END INTERFACE
1421
1422#define ARRAYOF_ORIGTYPE TYPE(vol7d_timerange)
1423#define ARRAYOF_TYPE arrayof_vol7d_timerange
1424#define ARRAYOF_ORIGEQ 1
1425#include "arrayof_pre.F90"
1426
1427
1428type(vol7d_timerange) :: almost_equal_timeranges(2)=(/&
1429 vol7d_timerange(254,0,imiss),&
1430 vol7d_timerange(3,0,3600)/)
1431
1432
1433! from arrayof
1435PUBLIC insert_unique, append_unique
1436PUBLIC almost_equal_timeranges
1437
1438CONTAINS
1439
1440
1441!> Inizializza un oggetto \a vol7d_timerange con i parametri opzionali forniti.
1442!! Questa è la versione \c FUNCTION, in stile F2003, del costruttore, da preferire
1443!! rispetto alla versione \c SUBROUTINE \c init.
1444!! Se non viene passato nessun parametro opzionale l'oggetto è
1445!! inizializzato a valore mancante.
1446FUNCTION vol7d_timerange_new(timerange, p1, p2) RESULT(this)
1447INTEGER,INTENT(IN),OPTIONAL :: timerange !< tipo di intervallo temporale
1448INTEGER,INTENT(IN),OPTIONAL :: p1 !< valore per il primo istante temporale
1449INTEGER,INTENT(IN),OPTIONAL :: p2 !< valore per il secondo istante temporale
1450
1451TYPE(vol7d_timerange) :: this !< oggetto da inizializzare
1452
1454
1455END FUNCTION vol7d_timerange_new
1456
1457
1458!> Inizializza un oggetto \a vol7d_timerange con i parametri opzionali forniti.
1459!! Se non viene passato nessun parametro opzionale l'oggetto è
1460!! inizializzato a valore mancante.
1461SUBROUTINE vol7d_timerange_init(this, timerange, p1, p2)
1462TYPE(vol7d_timerange),INTENT(INOUT) :: this !< oggetto da inizializzare
1463INTEGER,INTENT(IN),OPTIONAL :: timerange !< tipo di intervallo temporale
1464INTEGER,INTENT(IN),OPTIONAL :: p1 !< valore per il primo istante temporale
1465INTEGER,INTENT(IN),OPTIONAL :: p2 !< valore per il secondo istante temporale
1466
1467IF (PRESENT(timerange)) THEN
1468 this%timerange = timerange
1469ELSE
1470 this%timerange = imiss
1471 this%p1 = imiss
1472 this%p2 = imiss
1473 RETURN
1474ENDIF
1475!!$IF (timerange == 1) THEN ! p1 sempre 0
1476!!$ this%p1 = 0
1477!!$ this%p2 = imiss
1478!!$ELSE IF (timerange == 0 .OR. timerange == 10) THEN ! solo p1
1479!!$ IF (PRESENT(p1)) THEN
1480!!$ this%p1 = p1
1481!!$ ELSE
1482!!$ this%p1 = 0
1483!!$ ENDIF
1484!!$ this%p2 = imiss
1485!!$ELSE ! tutti gli altri
1486 IF (PRESENT(p1)) THEN
1487 this%p1 = p1
1488 ELSE
1489 this%p1 = imiss
1490 ENDIF
1491 IF (PRESENT(p2)) THEN
1492 this%p2 = p2
1493 ELSE
1494 this%p2 = imiss
1495 ENDIF
1496!!$END IF
1497
1498END SUBROUTINE vol7d_timerange_init
1499
1500
1501!> Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
1502SUBROUTINE vol7d_timerange_delete(this)
1503TYPE(vol7d_timerange),INTENT(INOUT) :: this
1504
1505this%timerange = imiss
1506this%p1 = imiss
1507this%p2 = imiss
1508
1509END SUBROUTINE vol7d_timerange_delete
1510
1511
1512SUBROUTINE display_timerange(this)
1513TYPE(vol7d_timerange),INTENT(in) :: this
1514
1515print*,to_char_timerange(this)
1516
1517END SUBROUTINE display_timerange
1518
1519
1520FUNCTION to_char_timerange(this)
1521#ifdef HAVE_DBALLE
1522USE dballef
1523#endif
1524TYPE(vol7d_timerange),INTENT(in) :: this
1525CHARACTER(len=80) :: to_char_timerange
1526
1527#ifdef HAVE_DBALLE
1528INTEGER :: handle, ier
1529
1530handle = 0
1531ier = idba_messaggi(handle,"/dev/null", "w", "BUFR")
1532ier = idba_spiegat(handle,this%timerange,this%p1,this%p2,to_char_timerange)
1533ier = idba_fatto(handle)
1534
1535to_char_timerange="Timerange: "//to_char_timerange
1536
1537#else
1538
1541
1542#endif
1543
1544END FUNCTION to_char_timerange
1545
1546
1547ELEMENTAL FUNCTION vol7d_timerange_eq(this, that) RESULT(res)
1548TYPE(vol7d_timerange),INTENT(IN) :: this, that
1549LOGICAL :: res
1550
1551
1552res = &
1553 this%timerange == that%timerange .AND. &
1554 this%p1 == that%p1 .AND. (this%p2 == that%p2 .OR. &
1555 this%timerange == 254)
1556
1557END FUNCTION vol7d_timerange_eq
1558
1559
1560ELEMENTAL FUNCTION vol7d_timerange_almost_eq(this, that) RESULT(res)
1561TYPE(vol7d_timerange),INTENT(IN) :: this, that
1562LOGICAL :: res
1563
1564IF (.not. c_e(this%timerange) .or. .not. c_e(that%timerange) .or. this%timerange == that%timerange .AND. &
1565 this%p1 == that%p1 .AND. &
1566 this%p2 == that%p2) THEN
1567 res = .true.
1568ELSE
1569 res = .false.
1570ENDIF
1571
1572END FUNCTION vol7d_timerange_almost_eq
1573
1574
1575ELEMENTAL FUNCTION vol7d_timerange_ne(this, that) RESULT(res)
1576TYPE(vol7d_timerange),INTENT(IN) :: this, that
1577LOGICAL :: res
1578
1579res = .NOT.(this == that)
1580
1581END FUNCTION vol7d_timerange_ne
1582
1583
1584ELEMENTAL FUNCTION vol7d_timerange_gt(this, that) RESULT(res)
1585TYPE(vol7d_timerange),INTENT(IN) :: this, that
1586LOGICAL :: res
1587
1588IF (this%timerange > that%timerange .OR. &
1589 (this%timerange == that%timerange .AND. this%p1 > that%p1) .OR. &
1590 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
1591 this%p2 > that%p2)) THEN
1592 res = .true.
1593ELSE
1594 res = .false.
1595ENDIF
1596
1597END FUNCTION vol7d_timerange_gt
1598
1599
1600ELEMENTAL FUNCTION vol7d_timerange_lt(this, that) RESULT(res)
1601TYPE(vol7d_timerange),INTENT(IN) :: this, that
1602LOGICAL :: res
1603
1604IF (this%timerange < that%timerange .OR. &
1605 (this%timerange == that%timerange .AND. this%p1 < that%p1) .OR. &
1606 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
1607 this%p2 < that%p2)) THEN
1608 res = .true.
1609ELSE
1610 res = .false.
1611ENDIF
1612
1613END FUNCTION vol7d_timerange_lt
1614
1615
1616ELEMENTAL FUNCTION vol7d_timerange_ge(this, that) RESULT(res)
1617TYPE(vol7d_timerange),INTENT(IN) :: this, that
1618LOGICAL :: res
1619
1620IF (this == that) THEN
1621 res = .true.
1622ELSE IF (this > that) THEN
1623 res = .true.
1624ELSE
1625 res = .false.
1626ENDIF
1627
1628END FUNCTION vol7d_timerange_ge
1629
1630
1631ELEMENTAL FUNCTION vol7d_timerange_le(this, that) RESULT(res)
1632TYPE(vol7d_timerange),INTENT(IN) :: this, that
1633LOGICAL :: res
1634
1635IF (this == that) THEN
1636 res = .true.
1637ELSE IF (this < that) THEN
1638 res = .true.
1639ELSE
1640 res = .false.
1641ENDIF
1642
1643END FUNCTION vol7d_timerange_le
1644
1645
1646ELEMENTAL FUNCTION vol7d_timerange_c_e(this) RESULT(c_e)
1647TYPE(vol7d_timerange),INTENT(IN) :: this
1648LOGICAL :: c_e
1649c_e = this /= vol7d_timerange_miss
1650END FUNCTION vol7d_timerange_c_e
1651
1652
1653#include "array_utilities_inc.F90"
1654
1655#include "arrayof_post.F90"
1656
1657
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 |