libsim Versione 7.2.1

◆ 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
1213USE kinds
1216IMPLICIT NONE
1217
1218integer, parameter :: network_name_len=20
1219
1224TYPE vol7d_network
1225 character(len=network_name_len) :: name
1226END TYPE vol7d_network
1227
1229TYPE(vol7d_network),PARAMETER :: vol7d_network_miss=vol7d_network(cmiss)
1230
1234INTERFACE init
1235 MODULE PROCEDURE vol7d_network_init
1236END INTERFACE
1237
1240INTERFACE delete
1241 MODULE PROCEDURE vol7d_network_delete
1242END INTERFACE
1243
1247INTERFACE OPERATOR (==)
1248 MODULE PROCEDURE vol7d_network_eq
1249END INTERFACE
1250
1254INTERFACE OPERATOR (/=)
1255 MODULE PROCEDURE vol7d_network_ne
1256END INTERFACE
1257
1261INTERFACE OPERATOR (>)
1262 MODULE PROCEDURE vol7d_network_gt
1263END INTERFACE
1264
1268INTERFACE OPERATOR (<)
1269 MODULE PROCEDURE vol7d_network_lt
1270END INTERFACE
1271
1275INTERFACE OPERATOR (>=)
1276 MODULE PROCEDURE vol7d_network_ge
1277END INTERFACE
1278
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
1292INTERFACE display
1293 MODULE PROCEDURE display_network
1294END INTERFACE
1295
1297INTERFACE c_e
1298 MODULE PROCEDURE c_e_network
1299END INTERFACE
1300
1302INTERFACE to_char
1303 MODULE PROCEDURE to_char_network
1304END INTERFACE
1305
1306CONTAINS
1307
1313FUNCTION vol7d_network_new(name) RESULT(this)
1314CHARACTER(len=*),INTENT(in),OPTIONAL :: name
1315
1316TYPE(vol7d_network) :: this
1317
1318CALL init(this, name)
1319
1320END FUNCTION vol7d_network_new
1321
1322
1326SUBROUTINE vol7d_network_init(this, name)
1327TYPE(vol7d_network),INTENT(INOUT) :: this
1328CHARACTER(len=*),INTENT(in),OPTIONAL :: name
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
1340SUBROUTINE vol7d_network_delete(this)
1341TYPE(vol7d_network),INTENT(INOUT) :: this
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
Check object presence.
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.