libsim Versione 7.1.11

◆ 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 1192 del file vol7d_network_class.F90.

1193! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
1194! authors:
1195! Davide Cesari <dcesari@arpa.emr.it>
1196! Paolo Patruno <ppatruno@arpa.emr.it>
1197
1198! This program is free software; you can redistribute it and/or
1199! modify it under the terms of the GNU General Public License as
1200! published by the Free Software Foundation; either version 2 of
1201! the License, or (at your option) any later version.
1202
1203! This program is distributed in the hope that it will be useful,
1204! but WITHOUT ANY WARRANTY; without even the implied warranty of
1205! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1206! GNU General Public License for more details.
1207
1208! You should have received a copy of the GNU General Public License
1209! along with this program. If not, see <http://www.gnu.org/licenses/>.
1210#include "config.h"
1211
1219USE kinds
1222IMPLICIT NONE
1223
1224integer, parameter :: network_name_len=20
1225
1230TYPE vol7d_network
1231 character(len=network_name_len) :: name
1232END TYPE vol7d_network
1233
1235TYPE(vol7d_network),PARAMETER :: vol7d_network_miss=vol7d_network(cmiss)
1236
1240INTERFACE init
1241 MODULE PROCEDURE vol7d_network_init
1242END INTERFACE
1243
1246INTERFACE delete
1247 MODULE PROCEDURE vol7d_network_delete
1248END INTERFACE
1249
1253INTERFACE OPERATOR (==)
1254 MODULE PROCEDURE vol7d_network_eq
1255END INTERFACE
1256
1260INTERFACE OPERATOR (/=)
1261 MODULE PROCEDURE vol7d_network_ne
1262END INTERFACE
1263
1267INTERFACE OPERATOR (>)
1268 MODULE PROCEDURE vol7d_network_gt
1269END INTERFACE
1270
1274INTERFACE OPERATOR (<)
1275 MODULE PROCEDURE vol7d_network_lt
1276END INTERFACE
1277
1281INTERFACE OPERATOR (>=)
1282 MODULE PROCEDURE vol7d_network_ge
1283END INTERFACE
1284
1288INTERFACE OPERATOR (<=)
1289 MODULE PROCEDURE vol7d_network_le
1290END INTERFACE
1291
1292#define VOL7D_POLY_TYPE TYPE(vol7d_network)
1293#define VOL7D_POLY_TYPES _network
1294#define ENABLE_SORT
1295#include "array_utilities_pre.F90"
1296
1298INTERFACE display
1299 MODULE PROCEDURE display_network
1300END INTERFACE
1301
1303INTERFACE c_e
1304 MODULE PROCEDURE c_e_network
1305END INTERFACE
1306
1308INTERFACE to_char
1309 MODULE PROCEDURE to_char_network
1310END INTERFACE
1311
1312CONTAINS
1313
1319FUNCTION vol7d_network_new(name) RESULT(this)
1320CHARACTER(len=*),INTENT(in),OPTIONAL :: name
1321
1322TYPE(vol7d_network) :: this
1323
1324CALL init(this, name)
1325
1326END FUNCTION vol7d_network_new
1327
1328
1332SUBROUTINE vol7d_network_init(this, name)
1333TYPE(vol7d_network),INTENT(INOUT) :: this
1334CHARACTER(len=*),INTENT(in),OPTIONAL :: name
1335
1336IF (PRESENT(name)) THEN
1337 this%name = lowercase(name)
1338ELSE
1339 this%name = cmiss
1340END IF
1341
1342END SUBROUTINE vol7d_network_init
1343
1344
1346SUBROUTINE vol7d_network_delete(this)
1347TYPE(vol7d_network),INTENT(INOUT) :: this
1348
1349this%name = cmiss
1350
1351END SUBROUTINE vol7d_network_delete
1352
1353
1354subroutine display_network(this)
1355
1356TYPE(vol7d_network),INTENT(in) :: this
1357
1358print*,to_char_network(this)
1359
1360end subroutine display_network
1361
1362
1363elemental function c_e_network(this) result(res)
1364
1365TYPE(vol7d_network),INTENT(in) :: this
1366logical :: res
1367
1368res = .not. this == vol7d_network_miss
1369
1370end function c_e_network
1371
1372
1373elemental character(len=20) function to_char_network(this)
1374
1375TYPE(vol7d_network),INTENT(in) :: this
1376
1377to_char_network="Network: "//trim(this%name)
1378
1379return
1380
1381end function to_char_network
1382
1383
1384ELEMENTAL FUNCTION vol7d_network_eq(this, that) RESULT(res)
1385TYPE(vol7d_network),INTENT(IN) :: this, that
1386LOGICAL :: res
1387
1388res = (this%name == that%name)
1389
1390END FUNCTION vol7d_network_eq
1391
1392
1393ELEMENTAL FUNCTION vol7d_network_ne(this, that) RESULT(res)
1394TYPE(vol7d_network),INTENT(IN) :: this, that
1395LOGICAL :: res
1396
1397res = .NOT.(this == that)
1398
1399END FUNCTION vol7d_network_ne
1400
1401
1402ELEMENTAL FUNCTION vol7d_network_gt(this, that) RESULT(res)
1403TYPE(vol7d_network),INTENT(IN) :: this, that
1404LOGICAL :: res
1405
1406res = this%name > that%name
1407
1408END FUNCTION vol7d_network_gt
1409
1410ELEMENTAL FUNCTION vol7d_network_lt(this, that) RESULT(res)
1411TYPE(vol7d_network),INTENT(IN) :: this, that
1412LOGICAL :: res
1413
1414res = this%name < that%name
1415
1416END FUNCTION vol7d_network_lt
1417
1418
1419ELEMENTAL FUNCTION vol7d_network_ge(this, that) RESULT(res)
1420TYPE(vol7d_network),INTENT(IN) :: this, that
1421LOGICAL :: res
1422
1423res = this%name >= that%name
1424
1425END FUNCTION vol7d_network_ge
1426
1427ELEMENTAL FUNCTION vol7d_network_le(this, that) RESULT(res)
1428TYPE(vol7d_network),INTENT(IN) :: this, that
1429LOGICAL :: res
1430
1431res = this%name <= that%name
1432
1433END FUNCTION vol7d_network_le
1434
1435
1436#include "array_utilities_inc.F90"
1437
1438
1439END 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:251
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.