libsim Versione 7.2.6
|
◆ index_timerange()
Cerca l'indice del primo o ultimo elemento di vect uguale a search. Definizione alla linea 1214 del file vol7d_timerange_class.F90. 1216! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
1217! authors:
1218! Davide Cesari <dcesari@arpa.emr.it>
1219! Paolo Patruno <ppatruno@arpa.emr.it>
1220
1221! This program is free software; you can redistribute it and/or
1222! modify it under the terms of the GNU General Public License as
1223! published by the Free Software Foundation; either version 2 of
1224! the License, or (at your option) any later version.
1225
1226! This program is distributed in the hope that it will be useful,
1227! but WITHOUT ANY WARRANTY; without even the implied warranty of
1228! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1229! GNU General Public License for more details.
1230
1231! You should have received a copy of the GNU General Public License
1232! along with this program. If not, see <http://www.gnu.org/licenses/>.
1233#include "config.h"
1234
1235!> Classe per la gestione degli intervalli temporali di osservazioni
1236!! meteo e affini.
1237!! Questo modulo definisce una classe in grado di rappresentare
1238!! l'intervallo di tempo a cui si riferisce un'osservazione meteo,
1239!! ad es. valore istantaneo, cumulato, medio, ecc., prendendo in prestito
1240!! concetti dal formato grib.
1241!! \ingroup vol7d
1246IMPLICIT NONE
1247
1248!> Definisce l'intervallo temporale di un'osservazione meteo.
1249!! I membri di \a vol7d_timerange sono pubblici e quindi liberamente
1250!! accessibili e scrivibili, ma è comunque consigliato assegnarli tramite
1251!! il costruttore ::init.
1253 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
1254 INTEGER :: p1 !< termine del periodo di validità del dato, in secondi, a partire dall'istante di riferimento (0 per dati osservati o analizzati)
1255 INTEGER :: p2 !< durata del periodo di validità del dato, in secondi (0 per dati istantanei)
1257
1258!> Valore mancante per vol7d_timerange.
1259TYPE(vol7d_timerange),PARAMETER :: vol7d_timerange_miss= &
1260 vol7d_timerange(imiss,imiss,imiss)
1261
1262!> Costruttore per la classe vol7d_timerange.
1263!! Deve essere richiamato
1264!! per tutti gli oggetti di questo tipo definiti in un programma.
1266 MODULE PROCEDURE vol7d_timerange_init
1267END INTERFACE
1268
1269!> Distruttore per la classe vol7d_timerange.
1270!! Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
1272 MODULE PROCEDURE vol7d_timerange_delete
1273END INTERFACE
1274
1275!> Logical equality operator for objects of \a vol7d_timerange class.
1276!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1277!! of any shape.
1278INTERFACE OPERATOR (==)
1279 MODULE PROCEDURE vol7d_timerange_eq
1280END INTERFACE
1281
1282!> Logical inequality operator for objects of \a vol7d_timerange class.
1283!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1284!! of any shape.
1285INTERFACE OPERATOR (/=)
1286 MODULE PROCEDURE vol7d_timerange_ne
1287END INTERFACE
1288
1289!> Logical greater-than operator for objects of \a vol7d_timerange class.
1290!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1291!! of any shape.
1292INTERFACE OPERATOR (>)
1293 MODULE PROCEDURE vol7d_timerange_gt
1294END INTERFACE
1295
1296!> Logical less-than operator for objects of \a vol7d_timerange class.
1297!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1298!! of any shape.
1299INTERFACE OPERATOR (<)
1300 MODULE PROCEDURE vol7d_timerange_lt
1301END INTERFACE
1302
1303!> Logical greater-equal operator for objects of \a vol7d_timerange class.
1304!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1305!! of any shape.
1306INTERFACE OPERATOR (>=)
1307 MODULE PROCEDURE vol7d_timerange_ge
1308END INTERFACE
1309
1310!> Logical less-equal operator for objects of \a vol7d_timerange class.
1311!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1312!! of any shape.
1313INTERFACE OPERATOR (<=)
1314 MODULE PROCEDURE vol7d_timerange_le
1315END INTERFACE
1316
1317!> Logical almost equality operator for objects of \a vol7d_timerange class.
1318!! If one component is missing it is not used in comparison.
1319INTERFACE OPERATOR (.almosteq.)
1320 MODULE PROCEDURE vol7d_timerange_almost_eq
1321END INTERFACE
1322
1323
1324! da documentare in inglese assieme al resto
1325!> to be documented
1327 MODULE PROCEDURE vol7d_timerange_c_e
1328END INTERFACE
1329
1330#define VOL7D_POLY_TYPE TYPE(vol7d_timerange)
1331#define VOL7D_POLY_TYPES _timerange
1332#define ENABLE_SORT
1333#include "array_utilities_pre.F90"
1334
1335!>Print object
1337 MODULE PROCEDURE display_timerange
1338END INTERFACE
1339
1340!>Represent timerange object in a pretty string
1342 MODULE PROCEDURE to_char_timerange
1343END INTERFACE
1344
1345#define ARRAYOF_ORIGTYPE TYPE(vol7d_timerange)
1346#define ARRAYOF_TYPE arrayof_vol7d_timerange
1347#define ARRAYOF_ORIGEQ 1
1348#include "arrayof_pre.F90"
1349
1350
1351type(vol7d_timerange) :: almost_equal_timeranges(2)=(/&
1352 vol7d_timerange(254,0,imiss),&
1353 vol7d_timerange(3,0,3600)/)
1354
1355
1356! from arrayof
1358PUBLIC insert_unique, append_unique
1359PUBLIC almost_equal_timeranges
1360
1361CONTAINS
1362
1363
1364!> Inizializza un oggetto \a vol7d_timerange con i parametri opzionali forniti.
1365!! Questa è la versione \c FUNCTION, in stile F2003, del costruttore, da preferire
1366!! rispetto alla versione \c SUBROUTINE \c init.
1367!! Se non viene passato nessun parametro opzionale l'oggetto è
1368!! inizializzato a valore mancante.
1369FUNCTION vol7d_timerange_new(timerange, p1, p2) RESULT(this)
1370INTEGER,INTENT(IN),OPTIONAL :: timerange !< tipo di intervallo temporale
1371INTEGER,INTENT(IN),OPTIONAL :: p1 !< valore per il primo istante temporale
1372INTEGER,INTENT(IN),OPTIONAL :: p2 !< valore per il secondo istante temporale
1373
1374TYPE(vol7d_timerange) :: this !< oggetto da inizializzare
1375
1377
1378END FUNCTION vol7d_timerange_new
1379
1380
1381!> Inizializza un oggetto \a vol7d_timerange con i parametri opzionali forniti.
1382!! Se non viene passato nessun parametro opzionale l'oggetto è
1383!! inizializzato a valore mancante.
1384SUBROUTINE vol7d_timerange_init(this, timerange, p1, p2)
1385TYPE(vol7d_timerange),INTENT(INOUT) :: this !< oggetto da inizializzare
1386INTEGER,INTENT(IN),OPTIONAL :: timerange !< tipo di intervallo temporale
1387INTEGER,INTENT(IN),OPTIONAL :: p1 !< valore per il primo istante temporale
1388INTEGER,INTENT(IN),OPTIONAL :: p2 !< valore per il secondo istante temporale
1389
1390IF (PRESENT(timerange)) THEN
1391 this%timerange = timerange
1392ELSE
1393 this%timerange = imiss
1394 this%p1 = imiss
1395 this%p2 = imiss
1396 RETURN
1397ENDIF
1398!!$IF (timerange == 1) THEN ! p1 sempre 0
1399!!$ this%p1 = 0
1400!!$ this%p2 = imiss
1401!!$ELSE IF (timerange == 0 .OR. timerange == 10) THEN ! solo p1
1402!!$ IF (PRESENT(p1)) THEN
1403!!$ this%p1 = p1
1404!!$ ELSE
1405!!$ this%p1 = 0
1406!!$ ENDIF
1407!!$ this%p2 = imiss
1408!!$ELSE ! tutti gli altri
1409 IF (PRESENT(p1)) THEN
1410 this%p1 = p1
1411 ELSE
1412 this%p1 = imiss
1413 ENDIF
1414 IF (PRESENT(p2)) THEN
1415 this%p2 = p2
1416 ELSE
1417 this%p2 = imiss
1418 ENDIF
1419!!$END IF
1420
1421END SUBROUTINE vol7d_timerange_init
1422
1423
1424!> Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
1425SUBROUTINE vol7d_timerange_delete(this)
1426TYPE(vol7d_timerange),INTENT(INOUT) :: this
1427
1428this%timerange = imiss
1429this%p1 = imiss
1430this%p2 = imiss
1431
1432END SUBROUTINE vol7d_timerange_delete
1433
1434
1435SUBROUTINE display_timerange(this)
1436TYPE(vol7d_timerange),INTENT(in) :: this
1437
1438print*,to_char_timerange(this)
1439
1440END SUBROUTINE display_timerange
1441
1442
1443FUNCTION to_char_timerange(this)
1444#ifdef HAVE_DBALLE
1445USE dballef
1446#endif
1447TYPE(vol7d_timerange),INTENT(in) :: this
1448CHARACTER(len=80) :: to_char_timerange
1449
1450#ifdef HAVE_DBALLE
1451INTEGER :: handle, ier
1452
1453handle = 0
1454ier = idba_messaggi(handle,"/dev/null", "w", "BUFR")
1455ier = idba_spiegat(handle,this%timerange,this%p1,this%p2,to_char_timerange)
1456ier = idba_fatto(handle)
1457
1458to_char_timerange="Timerange: "//to_char_timerange
1459
1460#else
1461
1464
1465#endif
1466
1467END FUNCTION to_char_timerange
1468
1469
1470ELEMENTAL FUNCTION vol7d_timerange_eq(this, that) RESULT(res)
1471TYPE(vol7d_timerange),INTENT(IN) :: this, that
1472LOGICAL :: res
1473
1474
1475res = &
1476 this%timerange == that%timerange .AND. &
1477 this%p1 == that%p1 .AND. (this%p2 == that%p2 .OR. &
1478 this%timerange == 254)
1479
1480END FUNCTION vol7d_timerange_eq
1481
1482
1483ELEMENTAL FUNCTION vol7d_timerange_almost_eq(this, that) RESULT(res)
1484TYPE(vol7d_timerange),INTENT(IN) :: this, that
1485LOGICAL :: res
1486
1487IF (.not. c_e(this%timerange) .or. .not. c_e(that%timerange) .or. this%timerange == that%timerange .AND. &
1488 this%p1 == that%p1 .AND. &
1489 this%p2 == that%p2) THEN
1490 res = .true.
1491ELSE
1492 res = .false.
1493ENDIF
1494
1495END FUNCTION vol7d_timerange_almost_eq
1496
1497
1498ELEMENTAL FUNCTION vol7d_timerange_ne(this, that) RESULT(res)
1499TYPE(vol7d_timerange),INTENT(IN) :: this, that
1500LOGICAL :: res
1501
1502res = .NOT.(this == that)
1503
1504END FUNCTION vol7d_timerange_ne
1505
1506
1507ELEMENTAL FUNCTION vol7d_timerange_gt(this, that) RESULT(res)
1508TYPE(vol7d_timerange),INTENT(IN) :: this, that
1509LOGICAL :: res
1510
1511IF (this%timerange > that%timerange .OR. &
1512 (this%timerange == that%timerange .AND. this%p1 > that%p1) .OR. &
1513 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
1514 this%p2 > that%p2)) THEN
1515 res = .true.
1516ELSE
1517 res = .false.
1518ENDIF
1519
1520END FUNCTION vol7d_timerange_gt
1521
1522
1523ELEMENTAL FUNCTION vol7d_timerange_lt(this, that) RESULT(res)
1524TYPE(vol7d_timerange),INTENT(IN) :: this, that
1525LOGICAL :: res
1526
1527IF (this%timerange < that%timerange .OR. &
1528 (this%timerange == that%timerange .AND. this%p1 < that%p1) .OR. &
1529 (this%timerange == that%timerange .AND. this%p1 == that%p1 .AND. &
1530 this%p2 < that%p2)) THEN
1531 res = .true.
1532ELSE
1533 res = .false.
1534ENDIF
1535
1536END FUNCTION vol7d_timerange_lt
1537
1538
1539ELEMENTAL FUNCTION vol7d_timerange_ge(this, that) RESULT(res)
1540TYPE(vol7d_timerange),INTENT(IN) :: this, that
1541LOGICAL :: res
1542
1543IF (this == that) THEN
1544 res = .true.
1545ELSE IF (this > that) THEN
1546 res = .true.
1547ELSE
1548 res = .false.
1549ENDIF
1550
1551END FUNCTION vol7d_timerange_ge
1552
1553
1554ELEMENTAL FUNCTION vol7d_timerange_le(this, that) RESULT(res)
1555TYPE(vol7d_timerange),INTENT(IN) :: this, that
1556LOGICAL :: res
1557
1558IF (this == that) THEN
1559 res = .true.
1560ELSE IF (this < that) THEN
1561 res = .true.
1562ELSE
1563 res = .false.
1564ENDIF
1565
1566END FUNCTION vol7d_timerange_le
1567
1568
1569ELEMENTAL FUNCTION vol7d_timerange_c_e(this) RESULT(c_e)
1570TYPE(vol7d_timerange),INTENT(IN) :: this
1571LOGICAL :: c_e
1572c_e = this /= vol7d_timerange_miss
1573END FUNCTION vol7d_timerange_c_e
1574
1575
1576#include "array_utilities_inc.F90"
1577
1578#include "arrayof_post.F90"
1579
1580
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 |