libsim Versione 7.2.6
|
◆ sort_ana()
Sorts inline into ascending order - Quicksort Quicksort chooses a "pivot" in the set, and explores the array from both ends, looking for a value > pivot with the increasing index, for a value <= pivot with the decreasing index, and swapping them when it has found one of each. The array is then subdivided in 2 ([3]) subsets: { values <= pivot} {pivot} {values > pivot} One then call recursively the program to sort each subset. When the size of the subarray is small enough or the maximum level of recursion is gained, one uses an insertion sort that is faster for very small sets.
Definizione alla linea 1275 del file vol7d_ana_class.F90. 1276! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
1277! authors:
1278! Davide Cesari <dcesari@arpa.emr.it>
1279! Paolo Patruno <ppatruno@arpa.emr.it>
1280
1281! This program is free software; you can redistribute it and/or
1282! modify it under the terms of the GNU General Public License as
1283! published by the Free Software Foundation; either version 2 of
1284! the License, or (at your option) any later version.
1285
1286! This program is distributed in the hope that it will be useful,
1287! but WITHOUT ANY WARRANTY; without even the implied warranty of
1288! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1289! GNU General Public License for more details.
1290
1291! You should have received a copy of the GNU General Public License
1292! along with this program. If not, see <http://www.gnu.org/licenses/>.
1293#include "config.h"
1294
1295!> Classe per la gestione dell'anagrafica di stazioni meteo e affini.
1296!! Questo modulo definisce una classe in grado di rappresentare
1297!! le caratteristiche di una stazione meteo fissa o mobile.
1298!! \ingroup vol7d
1303IMPLICIT NONE
1304
1305!> Lunghezza della stringa che indica l'identificativo del volo.
1306INTEGER,PARAMETER :: vol7d_ana_lenident=20
1307
1308!> Definisce l'anagrafica di una stazione.
1309!! I membri di \a vol7d_ana sono pubblici e quindi liberamente
1310!! accessibili e scrivibili, ma è comunque consigliato assegnarli tramite
1311!! il costruttore ::init.
1313 TYPE(geo_coord) :: coord !< coordinata per una stazione fissa
1314 CHARACTER(len=vol7d_ana_lenident) :: ident !< identificativo per una stazione mobile (es. aereo)
1316
1317!> Valore mancante per vo7d_ana.
1319
1320!> Costruttore per la classe vol7d_ana.
1321!! Deve essere richiamato
1322!! per tutti gli oggetti di questo tipo definiti in un programma.
1324 MODULE PROCEDURE vol7d_ana_init
1325END INTERFACE
1326
1327!> Distruttore per la classe vol7d_ana.
1328!! Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
1330 MODULE PROCEDURE vol7d_ana_delete
1331END INTERFACE
1332
1333!> Logical equality operator for objects of \a vol7d_ana class.
1334!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1335!! of any shape.
1336INTERFACE OPERATOR (==)
1337 MODULE PROCEDURE vol7d_ana_eq
1338END INTERFACE
1339
1340!> Logical inequality operator for objects of \a vol7d_ana class.
1341!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1342!! of any shape.
1343INTERFACE OPERATOR (/=)
1344 MODULE PROCEDURE vol7d_ana_ne
1345END INTERFACE
1346
1347
1348!> Logical greater-than operator for objects of \a vol7d_ana class.
1349!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1350!! of any shape.
1351!! Comparison is performed first on \a ident, then on coord
1352INTERFACE OPERATOR (>)
1353 MODULE PROCEDURE vol7d_ana_gt
1354END INTERFACE
1355
1356!> Logical less-than operator for objects of \a vol7d_ana class.
1357!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1358!! of any shape.
1359!! Comparison is performed first on \a ident, then on coord
1360INTERFACE OPERATOR (<)
1361 MODULE PROCEDURE vol7d_ana_lt
1362END INTERFACE
1363
1364!> Logical greater-equal operator for objects of \a vol7d_ana class.
1365!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1366!! of any shape.
1367!! Comparison is performed first on \a ident, then on coord
1368INTERFACE OPERATOR (>=)
1369 MODULE PROCEDURE vol7d_ana_ge
1370END INTERFACE
1371
1372!> Logical less-equal operator for objects of \a vol7d_ana class.
1373!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1374!! of any shape.
1375!! Comparison is performed first on \a ident, then on coord
1376INTERFACE OPERATOR (<=)
1377 MODULE PROCEDURE vol7d_ana_le
1378END INTERFACE
1379
1380
1381!> check for missing value
1383 MODULE PROCEDURE vol7d_ana_c_e
1384END INTERFACE
1385
1386!> Legge un oggetto vol7d_ana o un vettore di oggetti vol7d_ana da
1387!! un file \c FORMATTED o \c UNFORMATTED.
1389 MODULE PROCEDURE vol7d_ana_read_unit, vol7d_ana_vect_read_unit
1390END INTERFACE
1391
1392!> Scrive un oggetto vol7d_ana o un vettore di oggetti vol7d_ana su
1393!! un file \c FORMATTED o \c UNFORMATTED.
1395 MODULE PROCEDURE vol7d_ana_write_unit, vol7d_ana_vect_write_unit
1396END INTERFACE
1397
1398#define VOL7D_POLY_TYPE TYPE(vol7d_ana)
1399#define VOL7D_POLY_TYPES _ana
1400#define ENABLE_SORT
1401#include "array_utilities_pre.F90"
1402
1403!> Represent ana object in a pretty string
1405 MODULE PROCEDURE to_char_ana
1406END INTERFACE
1407
1408!> Print object
1410 MODULE PROCEDURE display_ana
1411END INTERFACE
1412
1413CONTAINS
1414
1415!> Inizializza un oggetto \a vol7d_ana con i parametri opzionali forniti.
1416!! Se non viene passato nessun parametro opzionale l'oggetto è
1417!! inizializzato a valore mancante.
1418SUBROUTINE vol7d_ana_init(this, lon, lat, ident, ilon, ilat)
1419TYPE(vol7d_ana),INTENT(INOUT) :: this !< oggetto da inizializzare
1420REAL(kind=fp_geo),INTENT(in),OPTIONAL :: lon !< longitudine
1421REAL(kind=fp_geo),INTENT(in),OPTIONAL :: lat !< latitudine
1422CHARACTER(len=*),INTENT(in),OPTIONAL :: ident !< identificativo del volo
1423INTEGER(kind=int_l),INTENT(in),OPTIONAL :: ilon !< integer longitude (nint(lon*1.d5)
1424INTEGER(kind=int_l),INTENT(in),OPTIONAL :: ilat !< integer latitude (nint(lat*1.d5)
1425
1427IF (PRESENT(ident)) THEN
1428 this%ident = ident
1429ELSE
1430 this%ident = cmiss
1431ENDIF
1432
1433END SUBROUTINE vol7d_ana_init
1434
1435
1436!> Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
1437SUBROUTINE vol7d_ana_delete(this)
1438TYPE(vol7d_ana),INTENT(INOUT) :: this !< oggetto da distruggre
1439
1441this%ident = cmiss
1442
1443END SUBROUTINE vol7d_ana_delete
1444
1445
1446
1447character(len=80) function to_char_ana(this)
1448
1449TYPE(vol7d_ana),INTENT(in) :: this
1450
1451to_char_ana="ANA: "//&
1454 t2c(this%ident,miss="Missing ident")
1455
1456return
1457
1458end function to_char_ana
1459
1460
1461subroutine display_ana(this)
1462
1463TYPE(vol7d_ana),INTENT(in) :: this
1464
1465print*, trim(to_char(this))
1466
1467end subroutine display_ana
1468
1469
1470ELEMENTAL FUNCTION vol7d_ana_eq(this, that) RESULT(res)
1471TYPE(vol7d_ana),INTENT(IN) :: this, that
1472LOGICAL :: res
1473
1474res = this%coord == that%coord .AND. this%ident == that%ident
1475
1476END FUNCTION vol7d_ana_eq
1477
1478
1479ELEMENTAL FUNCTION vol7d_ana_ne(this, that) RESULT(res)
1480TYPE(vol7d_ana),INTENT(IN) :: this, that
1481LOGICAL :: res
1482
1483res = .NOT.(this == that)
1484
1485END FUNCTION vol7d_ana_ne
1486
1487
1488ELEMENTAL FUNCTION vol7d_ana_gt(this, that) RESULT(res)
1489TYPE(vol7d_ana),INTENT(IN) :: this, that
1490LOGICAL :: res
1491
1492res = this%ident > that%ident
1493
1494if ( this%ident == that%ident) then
1495 res =this%coord > that%coord
1496end if
1497
1498END FUNCTION vol7d_ana_gt
1499
1500
1501ELEMENTAL FUNCTION vol7d_ana_ge(this, that) RESULT(res)
1502TYPE(vol7d_ana),INTENT(IN) :: this, that
1503LOGICAL :: res
1504
1505res = .not. this < that
1506
1507END FUNCTION vol7d_ana_ge
1508
1509
1510ELEMENTAL FUNCTION vol7d_ana_lt(this, that) RESULT(res)
1511TYPE(vol7d_ana),INTENT(IN) :: this, that
1512LOGICAL :: res
1513
1514res = this%ident < that%ident
1515
1516if ( this%ident == that%ident) then
1517 res = this%coord < that%coord
1518end if
1519
1520END FUNCTION vol7d_ana_lt
1521
1522
1523ELEMENTAL FUNCTION vol7d_ana_le(this, that) RESULT(res)
1524TYPE(vol7d_ana),INTENT(IN) :: this, that
1525LOGICAL :: res
1526
1527res = .not. (this > that)
1528
1529END FUNCTION vol7d_ana_le
1530
1531
1532
1533ELEMENTAL FUNCTION vol7d_ana_c_e(this) RESULT(c_e)
1534TYPE(vol7d_ana),INTENT(IN) :: this
1535LOGICAL :: c_e
1536c_e = this /= vol7d_ana_miss
1537END FUNCTION vol7d_ana_c_e
1538
1539
1540!> This method reads from a Fortran file unit the contents of the
1541!! object \a this. The record to be read must have been written with
1542!! the ::write_unit method. The method works both on formatted and
1543!! unformatted files.
1544SUBROUTINE vol7d_ana_read_unit(this, unit)
1545TYPE(vol7d_ana),INTENT(out) :: this !< object to be read
1546INTEGER, INTENT(in) :: unit !< unit from which to read, it must be an opened Fortran file unit
1547
1548CALL vol7d_ana_vect_read_unit((/this/), unit)
1549
1550END SUBROUTINE vol7d_ana_read_unit
1551
1552
1553!> This method reads from a Fortran file unit the contents of the
1554!! object \a this. The record to be read must have been written with
1555!! the ::write_unit method. The method works both on formatted and
1556!! unformatted files.
1557SUBROUTINE vol7d_ana_vect_read_unit(this, unit)
1558TYPE(vol7d_ana) :: this(:) !< object to be read
1559INTEGER, INTENT(in) :: unit !< unit from which to read, it must be an opened Fortran file unit
1560
1561CHARACTER(len=40) :: form
1562
1564INQUIRE(unit, form=form)
1565IF (form == 'FORMATTED') THEN
1566 READ(unit,'(A)')this(:)%ident
1567ELSE
1568 READ(unit)this(:)%ident
1569ENDIF
1570
1571END SUBROUTINE vol7d_ana_vect_read_unit
1572
1573
1574!> This method writes on a Fortran file unit the contents of the
1575!! object \a this. The record can successively be read by the
1576!! ::read_unit method. The method works both on formatted and
1577!! unformatted files.
1578SUBROUTINE vol7d_ana_write_unit(this, unit)
1579TYPE(vol7d_ana),INTENT(in) :: this !< object to be written
1580INTEGER, INTENT(in) :: unit !< unit where to write, it must be an opened Fortran file unit
1581
1582CALL vol7d_ana_vect_write_unit((/this/), unit)
1583
1584END SUBROUTINE vol7d_ana_write_unit
1585
1586
1587!> This method writes on a Fortran file unit the contents of the
1588!! object \a this. The record can successively be read by the
1589!! ::read_unit method. The method works both on formatted and
1590!! unformatted files.
1591SUBROUTINE vol7d_ana_vect_write_unit(this, unit)
1592TYPE(vol7d_ana),INTENT(in) :: this(:) !< object to be written
1593INTEGER, INTENT(in) :: unit !< unit where to write, it must be an opened Fortran file unit
1594
1595CHARACTER(len=40) :: form
1596
1598INQUIRE(unit, form=form)
1599IF (form == 'FORMATTED') THEN
1600 WRITE(unit,'(A)')this(:)%ident
1601ELSE
1602 WRITE(unit)this(:)%ident
1603ENDIF
1604
1605END SUBROUTINE vol7d_ana_vect_write_unit
1606
1607
1608#include "array_utilities_inc.F90"
1609
1610
Legge un oggetto vol7d_ana o un vettore di oggetti vol7d_ana da un file FORMATTED o UNFORMATTED. Definition vol7d_ana_class.F90:301 Scrive un oggetto vol7d_ana o un vettore di oggetti vol7d_ana su un file FORMATTED o UNFORMATTED. Definition vol7d_ana_class.F90:307 Classes for handling georeferenced sparse points in geographical corodinates. Definition geo_coord_class.F90:216 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 dell'anagrafica di stazioni meteo e affini. Definition vol7d_ana_class.F90:212 |