libsim Versione 7.2.4

◆ sort_ana()

subroutine sort_ana ( type(vol7d_ana), dimension (:), intent(inout) xdont)

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.

Parametri
[in,out]xdontvector to sort inline

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
1299MODULE vol7d_ana_class
1300USE kinds
1303IMPLICIT NONE
1304
1306INTEGER,PARAMETER :: vol7d_ana_lenident=20
1307
1312TYPE vol7d_ana
1313 TYPE(geo_coord) :: coord
1314 CHARACTER(len=vol7d_ana_lenident) :: ident
1315END TYPE vol7d_ana
1316
1318TYPE(vol7d_ana),PARAMETER :: vol7d_ana_miss=vol7d_ana(geo_coord_miss,cmiss)
1319
1323INTERFACE init
1324 MODULE PROCEDURE vol7d_ana_init
1325END INTERFACE
1326
1329INTERFACE delete
1330 MODULE PROCEDURE vol7d_ana_delete
1331END INTERFACE
1332
1336INTERFACE OPERATOR (==)
1337 MODULE PROCEDURE vol7d_ana_eq
1338END INTERFACE
1339
1343INTERFACE OPERATOR (/=)
1344 MODULE PROCEDURE vol7d_ana_ne
1345END INTERFACE
1346
1347
1352INTERFACE OPERATOR (>)
1353 MODULE PROCEDURE vol7d_ana_gt
1354END INTERFACE
1355
1360INTERFACE OPERATOR (<)
1361 MODULE PROCEDURE vol7d_ana_lt
1362END INTERFACE
1363
1368INTERFACE OPERATOR (>=)
1369 MODULE PROCEDURE vol7d_ana_ge
1370END INTERFACE
1371
1376INTERFACE OPERATOR (<=)
1377 MODULE PROCEDURE vol7d_ana_le
1378END INTERFACE
1379
1380
1382INTERFACE c_e
1383 MODULE PROCEDURE vol7d_ana_c_e
1384END INTERFACE
1385
1388INTERFACE read_unit
1389 MODULE PROCEDURE vol7d_ana_read_unit, vol7d_ana_vect_read_unit
1390END INTERFACE
1391
1394INTERFACE write_unit
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
1404INTERFACE to_char
1405 MODULE PROCEDURE to_char_ana
1406END INTERFACE
1407
1409INTERFACE display
1410 MODULE PROCEDURE display_ana
1411END INTERFACE
1412
1413CONTAINS
1414
1418SUBROUTINE vol7d_ana_init(this, lon, lat, ident, ilon, ilat)
1419TYPE(vol7d_ana),INTENT(INOUT) :: this
1420REAL(kind=fp_geo),INTENT(in),OPTIONAL :: lon
1421REAL(kind=fp_geo),INTENT(in),OPTIONAL :: lat
1422CHARACTER(len=*),INTENT(in),OPTIONAL :: ident
1423INTEGER(kind=int_l),INTENT(in),OPTIONAL :: ilon
1424INTEGER(kind=int_l),INTENT(in),OPTIONAL :: ilat
1425
1426CALL init(this%coord, lon=lon, lat=lat , ilon=ilon, ilat=ilat)
1427IF (PRESENT(ident)) THEN
1428 this%ident = ident
1429ELSE
1430 this%ident = cmiss
1431ENDIF
1432
1433END SUBROUTINE vol7d_ana_init
1434
1435
1437SUBROUTINE vol7d_ana_delete(this)
1438TYPE(vol7d_ana),INTENT(INOUT) :: this
1439
1440CALL delete(this%coord)
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: "//&
1452 to_char(getlon(this%coord),miss="Missing lon",form="(f11.5)")//&
1453 to_char(getlat(this%coord),miss="Missing lat",form="(f11.5)")//&
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
1544SUBROUTINE vol7d_ana_read_unit(this, unit)
1545TYPE(vol7d_ana),INTENT(out) :: this
1546INTEGER, INTENT(in) :: unit
1547
1548CALL vol7d_ana_vect_read_unit((/this/), unit)
1549
1550END SUBROUTINE vol7d_ana_read_unit
1551
1552
1557SUBROUTINE vol7d_ana_vect_read_unit(this, unit)
1558TYPE(vol7d_ana) :: this(:)
1559INTEGER, INTENT(in) :: unit
1560
1561CHARACTER(len=40) :: form
1562
1563CALL read_unit(this%coord, unit)
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
1578SUBROUTINE vol7d_ana_write_unit(this, unit)
1579TYPE(vol7d_ana),INTENT(in) :: this
1580INTEGER, INTENT(in) :: unit
1581
1582CALL vol7d_ana_vect_write_unit((/this/), unit)
1583
1584END SUBROUTINE vol7d_ana_write_unit
1585
1586
1591SUBROUTINE vol7d_ana_vect_write_unit(this, unit)
1592TYPE(vol7d_ana),INTENT(in) :: this(:)
1593INTEGER, INTENT(in) :: unit
1594
1595CHARACTER(len=40) :: form
1596
1597CALL write_unit(this%coord, unit)
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
1611END MODULE vol7d_ana_class
check for missing value
Distruttore per la classe vol7d_ana.
Costruttore per la classe vol7d_ana.
Legge un oggetto vol7d_ana o un vettore di oggetti vol7d_ana da un file FORMATTED o UNFORMATTED.
Represent ana object in a pretty string.
Scrive un oggetto vol7d_ana o un vettore di oggetti vol7d_ana su un file FORMATTED o UNFORMATTED.
Classes for handling georeferenced sparse points in geographical corodinates.
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.
Classe per la gestione dell'anagrafica di stazioni meteo e affini.
Definisce l'anagrafica di una stazione.

Generated with Doxygen.