libsim Versione 7.2.6

◆ sort_network()

subroutine sort_network ( type(vol7d_network), 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 1186 del file vol7d_network_class.F90.

1187! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
1188! authors:
1189! Davide Cesari <dcesari@arpa.emr.it>
1190! Paolo Patruno <ppatruno@arpa.emr.it>
1191
1192! This program is free software; you can redistribute it and/or
1193! modify it under the terms of the GNU General Public License as
1194! published by the Free Software Foundation; either version 2 of
1195! the License, or (at your option) any later version.
1196
1197! This program is distributed in the hope that it will be useful,
1198! but WITHOUT ANY WARRANTY; without even the implied warranty of
1199! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1200! GNU General Public License for more details.
1201
1202! You should have received a copy of the GNU General Public License
1203! along with this program. If not, see <http://www.gnu.org/licenses/>.
1204#include "config.h"
1205
1206!> Classe per la gestione delle reti di stazioni per osservazioni meteo e affini.
1207!! Questo modulo definisce una classe per identificare la rete
1208!! a cui appartiene una stazione. Per rete si intende un insieme di stazioni
1209!! omogenee per tipo di sensori, tipo di variabili osservate,
1210!! frequenza delle osservazioni, formato dei dati.
1211!! \ingroup vol7d
1213USE kinds
1216IMPLICIT NONE
1217
1218integer, parameter :: network_name_len=20
1219
1220!> Definisce la rete a cui appartiene una stazione.
1221!! I membri di \a vol7d_network sono pubblici e quindi liberamente
1222!! accessibili e scrivibili, ma è comunque consigliato assegnarli tramite
1223!! il costruttore ::init.
1224TYPE vol7d_network
1225 character(len=network_name_len) :: name !< Mnemonic alias for type of report
1226END TYPE vol7d_network
1227
1228!> Valore mancante per vol7d_network.
1229TYPE(vol7d_network),PARAMETER :: vol7d_network_miss=vol7d_network(cmiss)
1230
1231!> Costruttore per la classe vol7d_network.
1232!! Deve essere richiamato
1233!! per tutti gli oggetti di questo tipo definiti in un programma.
1234INTERFACE init
1235 MODULE PROCEDURE vol7d_network_init
1236END INTERFACE
1237
1238!> Distruttore per la classe vol7d_network.
1239!! Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
1240INTERFACE delete
1241 MODULE PROCEDURE vol7d_network_delete
1242END INTERFACE
1243
1244!> Logical equality operator for objects of \a vol7d_network class.
1245!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1246!! of any shape.
1247INTERFACE OPERATOR (==)
1248 MODULE PROCEDURE vol7d_network_eq
1249END INTERFACE
1250
1251!> Logical inequality operator for objects of \a vol7d_network class.
1252!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1253!! of any shape.
1254INTERFACE OPERATOR (/=)
1255 MODULE PROCEDURE vol7d_network_ne
1256END INTERFACE
1257
1258!> Logical greater-than operator for objects of \a vol7d_network class.
1259!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1260!! of any shape.
1261INTERFACE OPERATOR (>)
1262 MODULE PROCEDURE vol7d_network_gt
1263END INTERFACE
1264
1265!> Logical less-than operator for objects of \a vol7d_network class.
1266!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1267!! of any shape.
1268INTERFACE OPERATOR (<)
1269 MODULE PROCEDURE vol7d_network_lt
1270END INTERFACE
1271
1272!> Logical greater-equal operator for objects of \a vol7d_network class.
1273!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1274!! of any shape.
1275INTERFACE OPERATOR (>=)
1276 MODULE PROCEDURE vol7d_network_ge
1277END INTERFACE
1278
1279!> Logical less-equal operator for objects of \a vol7d_network class.
1280!! It is defined as \a ELEMENTAL thus it works also with conformal arrays
1281!! of any shape.
1282INTERFACE OPERATOR (<=)
1283 MODULE PROCEDURE vol7d_network_le
1284END INTERFACE
1285
1286#define VOL7D_POLY_TYPE TYPE(vol7d_network)
1287#define VOL7D_POLY_TYPES _network
1288#define ENABLE_SORT
1289#include "array_utilities_pre.F90"
1290
1291!>Print object
1292INTERFACE display
1293 MODULE PROCEDURE display_network
1294END INTERFACE
1295
1296!>Check object presence
1297INTERFACE c_e
1298 MODULE PROCEDURE c_e_network
1299END INTERFACE
1300
1301!>return network object in a pretty string
1302INTERFACE to_char
1303 MODULE PROCEDURE to_char_network
1304END INTERFACE
1305
1306CONTAINS
1307
1308!> Inizializza un oggetto \a vol7d_network con i parametri opzionali forniti.
1309!! Questa è la versione \c FUNCTION, in stile F2003, del costruttore, da preferire
1310!! rispetto alla versione \c SUBROUTINE \c init.
1311!! Se non viene passato nessun parametro opzionale l'oggetto è
1312!! inizializzato a valore mancante.
1313FUNCTION vol7d_network_new(name) RESULT(this)
1314CHARACTER(len=*),INTENT(in),OPTIONAL :: name !< Mnemonic alias for type of report
1315
1316TYPE(vol7d_network) :: this !< oggetto da inizializzare
1317
1318CALL init(this, name)
1319
1320END FUNCTION vol7d_network_new
1321
1322
1323!> Inizializza un oggetto \a vol7d_network con i parametri opzionali forniti.
1324!! Se non viene passato nessun parametro opzionale l'oggetto è
1325!! inizializzato a valore mancante.
1326SUBROUTINE vol7d_network_init(this, name)
1327TYPE(vol7d_network),INTENT(INOUT) :: this !< oggetto da inizializzare
1328CHARACTER(len=*),INTENT(in),OPTIONAL :: name !< Mnemonic alias for type of report
1329
1330IF (PRESENT(name)) THEN
1331 this%name = lowercase(name)
1332ELSE
1333 this%name = cmiss
1334END IF
1335
1336END SUBROUTINE vol7d_network_init
1337
1338
1339!> Distrugge l'oggetto in maniera pulita, assegnandogli un valore mancante.
1340SUBROUTINE vol7d_network_delete(this)
1341TYPE(vol7d_network),INTENT(INOUT) :: this !< oggetto da distruggre
1342
1343this%name = cmiss
1344
1345END SUBROUTINE vol7d_network_delete
1346
1347
1348subroutine display_network(this)
1349
1350TYPE(vol7d_network),INTENT(in) :: this
1351
1352print*,to_char_network(this)
1353
1354end subroutine display_network
1355
1356
1357elemental function c_e_network(this) result(res)
1358
1359TYPE(vol7d_network),INTENT(in) :: this
1360logical :: res
1361
1362res = .not. this == vol7d_network_miss
1363
1364end function c_e_network
1365
1366
1367elemental character(len=20) function to_char_network(this)
1368
1369TYPE(vol7d_network),INTENT(in) :: this
1370
1371to_char_network="Network: "//trim(this%name)
1372
1373return
1374
1375end function to_char_network
1376
1377
1378ELEMENTAL FUNCTION vol7d_network_eq(this, that) RESULT(res)
1379TYPE(vol7d_network),INTENT(IN) :: this, that
1380LOGICAL :: res
1381
1382res = (this%name == that%name)
1383
1384END FUNCTION vol7d_network_eq
1385
1386
1387ELEMENTAL FUNCTION vol7d_network_ne(this, that) RESULT(res)
1388TYPE(vol7d_network),INTENT(IN) :: this, that
1389LOGICAL :: res
1390
1391res = .NOT.(this == that)
1392
1393END FUNCTION vol7d_network_ne
1394
1395
1396ELEMENTAL FUNCTION vol7d_network_gt(this, that) RESULT(res)
1397TYPE(vol7d_network),INTENT(IN) :: this, that
1398LOGICAL :: res
1399
1400res = this%name > that%name
1401
1402END FUNCTION vol7d_network_gt
1403
1404ELEMENTAL FUNCTION vol7d_network_lt(this, that) RESULT(res)
1405TYPE(vol7d_network),INTENT(IN) :: this, that
1406LOGICAL :: res
1407
1408res = this%name < that%name
1409
1410END FUNCTION vol7d_network_lt
1411
1412
1413ELEMENTAL FUNCTION vol7d_network_ge(this, that) RESULT(res)
1414TYPE(vol7d_network),INTENT(IN) :: this, that
1415LOGICAL :: res
1416
1417res = this%name >= that%name
1418
1419END FUNCTION vol7d_network_ge
1420
1421ELEMENTAL FUNCTION vol7d_network_le(this, that) RESULT(res)
1422TYPE(vol7d_network),INTENT(IN) :: this, that
1423LOGICAL :: res
1424
1425res = this%name <= that%name
1426
1427END FUNCTION vol7d_network_le
1428
1429
1430#include "array_utilities_inc.F90"
1431
1432
1433END MODULE vol7d_network_class
Distruttore per la classe vol7d_network.
Costruttore per la classe vol7d_network.
return network object in a pretty string
Utilities for CHARACTER variables.
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 delle reti di stazioni per osservazioni meteo e affini.
Definisce la rete a cui appartiene una stazione.

Generated with Doxygen.