libsim Versione 7.2.6

◆ vdc()

elemental logical function vdc ( character(len=vol7d_cdatalen), intent(in) flag)
private

Data validity check for confidence.

Parametri
[in]flagconfidenza

Definizione alla linea 1236 del file modqc.F90.

1237! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
1238! authors:
1239! Davide Cesari <dcesari@arpa.emr.it>
1240! Paolo Patruno <ppatruno@arpa.emr.it>
1241
1242! This program is free software; you can redistribute it and/or
1243! modify it under the terms of the GNU General Public License as
1244! published by the Free Software Foundation; either version 2 of
1245! the License, or (at your option) any later version.
1246
1247! This program is distributed in the hope that it will be useful,
1248! but WITHOUT ANY WARRANTY; without even the implied warranty of
1249! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1250! GNU General Public License for more details.
1251
1252! You should have received a copy of the GNU General Public License
1253! along with this program. If not, see <http://www.gnu.org/licenses/>.
1254#include "config.h"
1255!> \defgroup qc Libsim package, qc library.
1256!! Procedures for data quality control.
1257!! At the moment only climatological quality control is implemented
1258
1259!> Utilities and defines for quality control.
1260!!
1261!! Concise, high-value definitions of Data Quality by expert users,
1262!! analysts, implementers and journalists. This is a great starting point
1263!! to learn about Data Quality.
1264!!
1265!! Data Quality: The Accuracy Dimension
1266!!
1267!! "Data quality is defined as follows: data has quality if it satisfies
1268!! the requirements of its intended use. It lacks quality to the extent
1269!! that it does not satisfy the requirement. In other words, data quality
1270!! depends as much on the intended use as it does on the data itself. To
1271!! satisfy the intended use, the data must be accurate, timely, relevant,
1272!! complete, understood, and trusted." Jack E. Olson
1273!!
1274!! No Data Left Behind: Federal Student Aid - A Case History
1275!!
1276!! "Data quality institutionalizes a set of repeatable processes to
1277!! continuously monitor data and improve data accuracy, completeness,
1278!! timeliness and relevance." Holly Hyland and Lisa Elliott, Federal
1279!! Student Aid
1280!!
1281!! Data Quality: It's a Family Affair
1282!!
1283!! Data Quality definition: "The state of completeness, consistency,
1284!! timeliness and accuracy that makes data appropriate for a specific
1285!! use." Wim Helmer, Dun & Bradstreet
1286!!
1287!! Data Quality and Quality Management - Examples of Quality Evaluation
1288!! Procedures and Quality Management in European National Mapping
1289!! Agencies
1290!!
1291!! "Quality is defined as the totality of characteristics of a product
1292!! that bear on its ability to satisfy stated and implied needs (ISO
1293!! 8402, 1994). In the new ISO/DIS 9000:2000 standard (2000) the
1294!! definition of quality is: 'Ability of a set of inherent
1295!! characteristics of a product, system or process to fulfill
1296!! requirements of customers and other interested parties.' This
1297!! indicates that data quality and quality management are very closely
1298!! related. Data quality is part of the organisation's total quality
1299!! management." Antti Jakobsson
1300!!
1301!! text below from Wikipedia
1302!! http://it.wikipedia.org/wiki/Test_di_verifica_d%27ipotesi
1303!! http://creativecommons.org/licenses/by-sa/3.0/deed.it
1304!! L'ambito statistico
1305!!
1306!! Nel secondo caso la situazione è modificata in quanto interviene un
1307!! elemento nuovo, ovvero il caso. Si supponga di avere una moneta
1308!! recante due facce contrassegnate con testa e croce. Volendo verificare
1309!! l'ipotesi di bilanciamento della moneta si eseguono 20 lanci e si
1310!! contano quelli che danno esito testa. La conseguenza del bilanciamento
1311!! consiste nell'osservare un valore di teste attorno a 10. Tuttavia
1312!! anche in ipotesi di bilanciamento non si può escludere di osservare 20
1313!! teste. D'altronde, l'ipotesi di bilanciamento è logicamente
1314!! compatibile con un numero di teste variante da 0 a 20. In tale
1315!! contesto una qualsiasi decisione in merito all'ipotesi da verificare
1316!! comporta un rischio di errore. Ad esempio rigettare l'ipotesi di
1317!! bilanciamento della moneta avendo osservato 20 teste su 20 lanci
1318!! comporta il rischio di prendere una decisione errata. Nel procedere
1319!! alla verifica dell'ipotesi di bilanciamento della moneta, si ricorre a
1320!! una variabile casuale X. Tale variabile casuale X è una variabile
1321!! aleatoria discreta con distribuzione binomiale B(20; 0,5), dove 20
1322!! indica il numero di lanci e 0,5 la probabilità che si verifichi
1323!! l'evento "testa".
1324!!
1325!! Il risultato sperimentale si deve quindi confrontare con tale
1326!! distribuzione: quanto è distante tale risultato dal valore medio della
1327!! distribuzione B(20; 0,5)? Per rispondere alla domanda si deve
1328!! individuare un valore caratteristico della distribuzione B(20;
1329!! 0,5). Nel nostro caso tale valore caratteristico è il valore medio
1330!! 20/2 = 10. Per valutare la distanza tra il valore sperimentale e
1331!! quello atteso si valuta la probabilità di ottenere un valore
1332!! sperimentale lontano dal valore medio di B(20; 0,5), ossia nel caso
1333!! che dal nostro esperimento risulti X=15 (15 teste dopo 20 lanci), si
1334!! calcola P{|X-10|>=15-10} quindi P{X<=5 oppure X>=15}=0,041.
1335!!
1336!! Quindi, usando una moneta ben bilanciata, la probabilità di ottenere
1337!! un numero di teste X >= 15 (oppure X <= 5) dopo 20 lanci è pari a
1338!! 0,041 ossia al 4,1%. Giudicando bassa tale probabilità si rifiuterà
1339!! l'ipotesi di bilanciamento della moneta in esame, accettando quindi il
1340!! rischio del 4,1% di compiere un errore nel rifiutarla. Di solito, il
1341!! valore della probabilità adottato per rifiutare l'ipotesi nulla è <
1342!! 0,05. Tale valore è detto livello di significatività ed è definibile
1343!! come segue: il livello di significatività sotto l'ipotesi nulla è la
1344!! probabilità di cadere nella zona di rifiuto quando l'ipotesi nulla è
1345!! vera. Tale livello di significatività si indica convenzionalmente con
1346!! α. Il livello di significatività osservato α del test per il quale si
1347!! rifiuterebbe l'ipotesi nulla è detto valore-p (p-value). Riprendendo
1348!! l'esempio sopra riportato il valore-p è pari a 0,041. Adottando
1349!! nell'esempio α = 0,05, si rifiuterà l'ipotesi se
1350!! P{|X-10|>=x}<0,05. Tale condizione si raggiunge appunto se X<6 oppure
1351!! X>14. Tale insieme di valori si definisce convenzionalmente come
1352!! regione di rifiuto. Viceversa l'insieme { 6,7...14} si definisce regione
1353!! di accettazione. In questo modo si è costruita una regola di
1354!! comportamento per verificare l'ipotesi di bilanciamento della
1355!! moneta. Tale regola definisce il test statistico.
1356!!
1357!! In termini tecnici l'ipotesi da verificare si chiama ipotesi nulla e
1358!! si indica con H0, mentre l'ipotesi alternativa con H1. Nel caso della
1359!! moneta, se p è la probabilità di ottenere testa in un lancio la
1360!! verifica di ipotesi si traduce nel seguente sistema:
1361!!
1362!! H_0: p = \frac{1}{2}
1363!! H_1: p \ne \frac{1}{2}
1364!!
1365!! Come già osservato, il modo di condurre un test statistico comporta un
1366!! rischio di errore. Nella pratica statistica si individuano due tipi di
1367!! errori:
1368!!
1369!! 1. rifiutare H0 quando è vera, errore di primo tipo (α) (o errore di prima specie);
1370!! 2. accettare H0 quando è falsa, errore di secondo tipo (β) (o errore di seconda specie).
1371!!
1372!! Tornando all'esempio della moneta in cui la regione di accettazione è
1373!! data dall'insieme di valori {6..14}, la probabilità di rifiutare H0
1374!! quando è vera è stato calcolato pari a 0,041.Tale probabilità
1375!! rappresenta il rischio di incorrere in un errore di primo tipo e si
1376!! indica con α. Per valutare la probabilità di un errore di secondo tipo
1377!! è necessario specificare un valore di p in caso di verità di H1. Si
1378!! supponga che p=0,80, in tal caso la distribuzione di X è una
1379!! B(20;0,80)
1380!!
1381!! Con tale distribuzione di probabilità, l'errore di tipo 2 si calcola
1382!! sommando le probabilità relative ai valori di X della zona di
1383!! accettazione. Si trova quindi che la probabilità cercata è pari a
1384!! circa 0,20. Tale probabilità quantifica il rischio di incorrere
1385!! nell'errore di tipo 2. e si indica convenzionalmente con β. La
1386!! quantità 1-β si chiama potenza del test ed esprime quindi la capacità
1387!! di un test statistico riconoscere la falsità di H0 quando questa è
1388!! effettivamente falsa. La potenza del test trova applicazione nella
1389!! pratica statistica in fase di pianificazione di un esperimento.
1390!!
1391!!Scope of quality checks on observation values
1392!!Checks applied to determine the quality of an observation can range from the very simple to the
1393!!very complex. In roughly increasing order of complexity they can include:
1394!! * Syntactic checks (e.g. an air temperature must be a number to at most 1 decimal
1395!! place);
1396!! * Numeric ranges (e.g. the temperature must fall in the range -90 to +70);
1397!! * Climate range checks (i.e. is the datum consistent with climatology?)
1398!! * Intra-record consistency (e.g. the air temperature must not be less than the dew
1399!! point);
1400!! * Time-series consistency (e.g. the difference between two successive temperatures at
1401!! a site must be 'plausible'); and
1402!! * Spatial consistency (e.g. the station-dependent limits of plausible difference between
1403!! the temperatures at a station and its neighbours must not be violated).
1404!!\ingroup qc
1405module modqc
1406use kinds
1409use vol7d_class
1410
1411
1412implicit none
1413
1414
1415!> Definisce il livello di attendibilità per i dati validi
1416type :: qcpartype
1417 integer (kind=int_b):: att !< confidence for "*B33192" "*B33193" "*B33194"
1418 integer (kind=int_b):: gross_error ! special valuer for "*B33192" when gross error check failed
1419 integer (kind=int_b):: invalidated ! special valuer for "*B33196" when manual invalidation happen
1420end type qcpartype
1421
1422!> Default: data with confidence less or equal 10 are rejected
1423type(qcpartype) :: qcpar=qcpartype(10_int_b,0_int_b,1_int_b)
1424
1425integer, parameter :: nqcattrvars=4
1426CHARACTER(len=10),parameter :: qcattrvarsbtables(nqcattrvars)=(/"*B33196","*B33192","*B33193","*B33194"/)
1427
1428type :: qcattrvars
1429 TYPE(vol7d_var) :: vars(nqcattrvars)
1430 CHARACTER(len=10) :: btables(nqcattrvars)
1431end type qcattrvars
1432
1433!> Variables user in Quality Control
1434interface init
1435 module procedure init_qcattrvars
1436end interface
1437
1438!> Remove data under a defined grade of confidence.
1439interface peeled
1440 module procedure peeledrb, peeleddb, peeledbb, peeledib, peeledcb &
1441 ,peeledri, peeleddi, peeledbi, peeledii, peeledci &
1442 ,peeledrr, peeleddr, peeledbr, peeledir, peeledcr &
1443 ,peeledrd, peeleddd, peeledbd, peeledid, peeledcd &
1444 ,peeledrc, peeleddc, peeledbc, peeledic, peeledcc
1445end interface
1446
1447
1448!> Check data validity based on single confidence
1449interface vd
1450 module procedure vdi,vdb,vdr,vdd,vdc
1451end interface
1452
1453!> Check data validity based on gross error check
1454interface vdge
1455 module procedure vdgei,vdgeb,vdger,vdged,vdgec
1456end interface
1457
1458!> Test di dato invalidato
1459interface invalidated
1460 module procedure invalidatedi,invalidatedb,invalidatedr,invalidatedd,invalidatedc
1461end interface
1462
1463private
1464
1465public vd, vdge, init, qcattrvars_new, invalidated, peeled, vol7d_peeling
1466public qcattrvars, nqcattrvars, qcattrvarsbtables
1467public qcpar, qcpartype, qcsummaryflagb ! ,qcsummaryflagi
1468
1469contains
1470
1471
1472! peeled routines
1473#undef VOL7D_POLY_SUBTYPE
1474#undef VOL7D_POLY_SUBTYPES
1475#undef VOL7D_POLY_ISC
1476#define VOL7D_POLY_SUBTYPE REAL
1477#define VOL7D_POLY_SUBTYPES r
1478
1479#undef VOL7D_POLY_TYPE
1480#undef VOL7D_POLY_TYPES
1481#undef VOL7D_POLY_ISC
1482#undef VOL7D_POLY_TYPES_SUBTYPES
1483#define VOL7D_POLY_TYPE REAL
1484#define VOL7D_POLY_TYPES r
1485#define VOL7D_POLY_TYPES_SUBTYPES rr
1486#include "modqc_peeled_include.F90"
1487#include "modqc_peel_util_include.F90"
1488#undef VOL7D_POLY_TYPE
1489#undef VOL7D_POLY_TYPES
1490#undef VOL7D_POLY_TYPES_SUBTYPES
1491#define VOL7D_POLY_TYPE DOUBLE PRECISION
1492#define VOL7D_POLY_TYPES d
1493#define VOL7D_POLY_TYPES_SUBTYPES dr
1494#include "modqc_peeled_include.F90"
1495#include "modqc_peel_util_include.F90"
1496#undef VOL7D_POLY_TYPE
1497#undef VOL7D_POLY_TYPES
1498#undef VOL7D_POLY_TYPES_SUBTYPES
1499#define VOL7D_POLY_TYPE INTEGER
1500#define VOL7D_POLY_TYPES i
1501#define VOL7D_POLY_TYPES_SUBTYPES ir
1502#include "modqc_peeled_include.F90"
1503#include "modqc_peel_util_include.F90"
1504#undef VOL7D_POLY_TYPE
1505#undef VOL7D_POLY_TYPES
1506#undef VOL7D_POLY_TYPES_SUBTYPES
1507#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1508#define VOL7D_POLY_TYPES b
1509#define VOL7D_POLY_TYPES_SUBTYPES br
1510#include "modqc_peeled_include.F90"
1511#include "modqc_peel_util_include.F90"
1512#undef VOL7D_POLY_TYPE
1513#undef VOL7D_POLY_TYPES
1514#undef VOL7D_POLY_TYPES_SUBTYPES
1515#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1516#define VOL7D_POLY_TYPES c
1517#define VOL7D_POLY_ISC = 1
1518#define VOL7D_POLY_TYPES_SUBTYPES cr
1519#include "modqc_peeled_include.F90"
1520#include "modqc_peel_util_include.F90"
1521
1522
1523#undef VOL7D_POLY_SUBTYPE
1524#undef VOL7D_POLY_SUBTYPES
1525#undef VOL7D_POLY_ISC
1526#define VOL7D_POLY_SUBTYPE DOUBLE PRECISION
1527#define VOL7D_POLY_SUBTYPES d
1528
1529#undef VOL7D_POLY_TYPE
1530#undef VOL7D_POLY_TYPES
1531#undef VOL7D_POLY_TYPES_SUBTYPES
1532#define VOL7D_POLY_TYPE REAL
1533#define VOL7D_POLY_TYPES r
1534#define VOL7D_POLY_TYPES_SUBTYPES rd
1535#include "modqc_peeled_include.F90"
1536#undef VOL7D_POLY_TYPE
1537#undef VOL7D_POLY_TYPES
1538#undef VOL7D_POLY_TYPES_SUBTYPES
1539#define VOL7D_POLY_TYPE DOUBLE PRECISION
1540#define VOL7D_POLY_TYPES d
1541#define VOL7D_POLY_TYPES_SUBTYPES dd
1542#include "modqc_peeled_include.F90"
1543#undef VOL7D_POLY_TYPE
1544#undef VOL7D_POLY_TYPES
1545#undef VOL7D_POLY_TYPES_SUBTYPES
1546#define VOL7D_POLY_TYPE INTEGER
1547#define VOL7D_POLY_TYPES i
1548#define VOL7D_POLY_TYPES_SUBTYPES id
1549#include "modqc_peeled_include.F90"
1550#undef VOL7D_POLY_TYPE
1551#undef VOL7D_POLY_TYPES
1552#undef VOL7D_POLY_TYPES_SUBTYPES
1553#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1554#define VOL7D_POLY_TYPES b
1555#define VOL7D_POLY_TYPES_SUBTYPES bd
1556#include "modqc_peeled_include.F90"
1557#undef VOL7D_POLY_TYPE
1558#undef VOL7D_POLY_TYPES
1559#undef VOL7D_POLY_TYPES_SUBTYPES
1560#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1561#define VOL7D_POLY_TYPES c
1562#define VOL7D_POLY_TYPES_SUBTYPES cd
1563#include "modqc_peeled_include.F90"
1564
1565
1566#undef VOL7D_POLY_SUBTYPE
1567#undef VOL7D_POLY_SUBTYPES
1568#undef VOL7D_POLY_ISC
1569#define VOL7D_POLY_SUBTYPE INTEGER
1570#define VOL7D_POLY_SUBTYPES i
1571
1572#undef VOL7D_POLY_TYPE
1573#undef VOL7D_POLY_TYPES
1574#undef VOL7D_POLY_TYPES_SUBTYPES
1575#define VOL7D_POLY_TYPE REAL
1576#define VOL7D_POLY_TYPES r
1577#define VOL7D_POLY_TYPES_SUBTYPES ri
1578#include "modqc_peeled_include.F90"
1579#undef VOL7D_POLY_TYPE
1580#undef VOL7D_POLY_TYPES
1581#undef VOL7D_POLY_TYPES_SUBTYPES
1582#define VOL7D_POLY_TYPE DOUBLE PRECISION
1583#define VOL7D_POLY_TYPES d
1584#define VOL7D_POLY_TYPES_SUBTYPES di
1585#include "modqc_peeled_include.F90"
1586#undef VOL7D_POLY_TYPE
1587#undef VOL7D_POLY_TYPES
1588#undef VOL7D_POLY_TYPES_SUBTYPES
1589#define VOL7D_POLY_TYPE INTEGER
1590#define VOL7D_POLY_TYPES i
1591#define VOL7D_POLY_TYPES_SUBTYPES ii
1592#include "modqc_peeled_include.F90"
1593#undef VOL7D_POLY_TYPE
1594#undef VOL7D_POLY_TYPES
1595#undef VOL7D_POLY_TYPES_SUBTYPES
1596#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1597#define VOL7D_POLY_TYPES b
1598#define VOL7D_POLY_TYPES_SUBTYPES bi
1599#include "modqc_peeled_include.F90"
1600#undef VOL7D_POLY_TYPE
1601#undef VOL7D_POLY_TYPES
1602#undef VOL7D_POLY_TYPES_SUBTYPES
1603#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1604#define VOL7D_POLY_TYPES c
1605#define VOL7D_POLY_ISC = 1
1606#define VOL7D_POLY_TYPES_SUBTYPES ci
1607#include "modqc_peeled_include.F90"
1608
1609
1610#undef VOL7D_POLY_SUBTYPE
1611#undef VOL7D_POLY_SUBTYPES
1612#undef VOL7D_POLY_ISC
1613#define VOL7D_POLY_SUBTYPE INTEGER(kind=int_b)
1614#define VOL7D_POLY_SUBTYPES b
1615
1616#undef VOL7D_POLY_TYPE
1617#undef VOL7D_POLY_TYPES
1618#undef VOL7D_POLY_TYPES_SUBTYPES
1619#define VOL7D_POLY_TYPE REAL
1620#define VOL7D_POLY_TYPES r
1621#define VOL7D_POLY_TYPES_SUBTYPES rb
1622#include "modqc_peeled_include.F90"
1623#undef VOL7D_POLY_TYPE
1624#undef VOL7D_POLY_TYPES
1625#undef VOL7D_POLY_TYPES_SUBTYPES
1626#define VOL7D_POLY_TYPE DOUBLE PRECISION
1627#define VOL7D_POLY_TYPES d
1628#define VOL7D_POLY_TYPES_SUBTYPES db
1629#include "modqc_peeled_include.F90"
1630#undef VOL7D_POLY_TYPE
1631#undef VOL7D_POLY_TYPES
1632#undef VOL7D_POLY_TYPES_SUBTYPES
1633#define VOL7D_POLY_TYPE INTEGER
1634#define VOL7D_POLY_TYPES i
1635#define VOL7D_POLY_TYPES_SUBTYPES ib
1636#include "modqc_peeled_include.F90"
1637#undef VOL7D_POLY_TYPE
1638#undef VOL7D_POLY_TYPES
1639#undef VOL7D_POLY_TYPES_SUBTYPES
1640#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1641#define VOL7D_POLY_TYPES b
1642#define VOL7D_POLY_TYPES_SUBTYPES bb
1643#include "modqc_peeled_include.F90"
1644#undef VOL7D_POLY_TYPE
1645#undef VOL7D_POLY_TYPES
1646#undef VOL7D_POLY_TYPES_SUBTYPES
1647#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1648#define VOL7D_POLY_TYPES c
1649#define VOL7D_POLY_ISC = 1
1650#define VOL7D_POLY_TYPES_SUBTYPES cb
1651#include "modqc_peeled_include.F90"
1652
1653
1654#undef VOL7D_POLY_SUBTYPE
1655#undef VOL7D_POLY_SUBTYPES
1656#undef VOL7D_POLY_ISC
1657#define VOL7D_POLY_SUBTYPE CHARACTER(len=vol7d_cdatalen)
1658#define VOL7D_POLY_SUBTYPES c
1659
1660#undef VOL7D_POLY_TYPE
1661#undef VOL7D_POLY_TYPES
1662#undef VOL7D_POLY_TYPES_SUBTYPES
1663#define VOL7D_POLY_TYPE REAL
1664#define VOL7D_POLY_TYPES r
1665#define VOL7D_POLY_TYPES_SUBTYPES rc
1666#include "modqc_peeled_include.F90"
1667#undef VOL7D_POLY_TYPE
1668#undef VOL7D_POLY_TYPES
1669#undef VOL7D_POLY_TYPES_SUBTYPES
1670#define VOL7D_POLY_TYPE DOUBLE PRECISION
1671#define VOL7D_POLY_TYPES d
1672#define VOL7D_POLY_TYPES_SUBTYPES dc
1673#include "modqc_peeled_include.F90"
1674#undef VOL7D_POLY_TYPE
1675#undef VOL7D_POLY_TYPES
1676#undef VOL7D_POLY_TYPES_SUBTYPES
1677#define VOL7D_POLY_TYPE INTEGER
1678#define VOL7D_POLY_TYPES i
1679#define VOL7D_POLY_TYPES_SUBTYPES ic
1680#include "modqc_peeled_include.F90"
1681#undef VOL7D_POLY_TYPE
1682#undef VOL7D_POLY_TYPES
1683#undef VOL7D_POLY_TYPES_SUBTYPES
1684#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1685#define VOL7D_POLY_TYPES b
1686#define VOL7D_POLY_TYPES_SUBTYPES bc
1687#include "modqc_peeled_include.F90"
1688#undef VOL7D_POLY_TYPE
1689#undef VOL7D_POLY_TYPES
1690#undef VOL7D_POLY_TYPES_SUBTYPES
1691#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1692#define VOL7D_POLY_TYPES c
1693#define VOL7D_POLY_ISC = 1
1694#define VOL7D_POLY_TYPES_SUBTYPES cc
1695#include "modqc_peeled_include.F90"
1696
1697
1698subroutine init_qcattrvars(this)
1699
1700type(qcattrvars),intent(inout) :: this
1701integer :: i
1702
1703this%btables(:) =qcattrvarsbtables
1704do i =1, nqcattrvars
1705 call init(this%vars(i),this%btables(i))
1706end do
1707
1708end subroutine init_qcattrvars
1709
1710
1711type(qcattrvars) function qcattrvars_new()
1712
1713call init(qcattrvars_new)
1714
1715end function qcattrvars_new
1716
1717
1718!> Remove data under the predefined grade of confidence.
1719!! If neither \a keep_attr nor \a delete_attr are passed, all the
1720!! attributes will be deleted after peeling; if \a keep_attr is
1721!! provided, only attributed listed in \a keep_attr will be kept in
1722!! output, (\a delete_attr will be ignored); if \a delete_attr is
1723!! provided, attributed listed in \a delete_attr will be deleted from
1724!! output.
1725SUBROUTINE vol7d_peeling(this, data_id, keep_attr, delete_attr, preserve, purgeana)
1726TYPE(vol7d),INTENT(INOUT) :: this !< object that has to be peeled
1727integer,INTENT(inout),pointer,OPTIONAL :: data_id(:,:,:,:,:) !< data ID to use with dballe DB (for fast write of attributes)
1728CHARACTER(len=*),INTENT(in),OPTIONAL :: keep_attr(:) !< Btable of attributes that should be kept after removing data
1729CHARACTER(len=*),INTENT(in),OPTIONAL :: delete_attr(:) !< Btable of attributes that should be deleted after removing data
1730logical,intent(in),optional :: preserve !< preserve all attributes if true (alternative to keep_attr and delete_attr)
1731logical,intent(in),optional :: purgeana !< if true remove ana with all data missing
1732
1733integer :: inddativar,inddatiattrinv,inddatiattrcli,inddatiattrtem,inddatiattrspa,inddativarattr
1734type(qcattrvars) :: attrvars
1735
1736INTEGER(kind=int_b),pointer :: invbb(:,:,:,:,:),clibb(:,:,:,:,:),tembb(:,:,:,:,:),spabb(:,:,:,:,:)
1737INTEGER,pointer :: invbi(:,:,:,:,:),clibi(:,:,:,:,:),tembi(:,:,:,:,:),spabi(:,:,:,:,:)
1738REAL,pointer :: invbr(:,:,:,:,:),clibr(:,:,:,:,:),tembr(:,:,:,:,:),spabr(:,:,:,:,:)
1739DOUBLE PRECISION,pointer :: invbd(:,:,:,:,:),clibd(:,:,:,:,:),tembd(:,:,:,:,:),spabd(:,:,:,:,:)
1740CHARACTER(len=vol7d_cdatalen),pointer :: invbc(:,:,:,:,:),clibc(:,:,:,:,:),tembc(:,:,:,:,:),spabc(:,:,:,:,:)
1741
1742call l4f_log(l4f_info,'starting peeling')
1743
1744call init(attrvars)
1745
1746! generate code per i vari tipi di dati di v7d
1747! tramite un template e il preprocessore
1748
1749
1750#undef VOL7D_POLY_SUBTYPE
1751#undef VOL7D_POLY_SUBTYPES
1752#define VOL7D_POLY_SUBTYPE REAL
1753#define VOL7D_POLY_SUBTYPES r
1754
1755#undef VOL7D_POLY_TYPE
1756#undef VOL7D_POLY_TYPES
1757#define VOL7D_POLY_TYPE REAL
1758#define VOL7D_POLY_TYPES r
1759#include "modqc_peeling_include.F90"
1760#undef VOL7D_POLY_TYPE
1761#undef VOL7D_POLY_TYPES
1762#define VOL7D_POLY_TYPE DOUBLE PRECISION
1763#define VOL7D_POLY_TYPES d
1764#include "modqc_peeling_include.F90"
1765#undef VOL7D_POLY_TYPE
1766#undef VOL7D_POLY_TYPES
1767#define VOL7D_POLY_TYPE INTEGER
1768#define VOL7D_POLY_TYPES i
1769#include "modqc_peeling_include.F90"
1770#undef VOL7D_POLY_TYPE
1771#undef VOL7D_POLY_TYPES
1772#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1773#define VOL7D_POLY_TYPES b
1774#include "modqc_peeling_include.F90"
1775#undef VOL7D_POLY_TYPE
1776#undef VOL7D_POLY_TYPES
1777#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1778#define VOL7D_POLY_TYPES c
1779#include "modqc_peeling_include.F90"
1780
1781
1782#undef VOL7D_POLY_SUBTYPE
1783#undef VOL7D_POLY_SUBTYPES
1784#define VOL7D_POLY_SUBTYPE DOUBLE PRECISION
1785#define VOL7D_POLY_SUBTYPES d
1786
1787#undef VOL7D_POLY_TYPE
1788#undef VOL7D_POLY_TYPES
1789#define VOL7D_POLY_TYPE REAL
1790#define VOL7D_POLY_TYPES r
1791#include "modqc_peeling_include.F90"
1792#undef VOL7D_POLY_TYPE
1793#undef VOL7D_POLY_TYPES
1794#define VOL7D_POLY_TYPE DOUBLE PRECISION
1795#define VOL7D_POLY_TYPES d
1796#include "modqc_peeling_include.F90"
1797#undef VOL7D_POLY_TYPE
1798#undef VOL7D_POLY_TYPES
1799#define VOL7D_POLY_TYPE INTEGER
1800#define VOL7D_POLY_TYPES i
1801#include "modqc_peeling_include.F90"
1802#undef VOL7D_POLY_TYPE
1803#undef VOL7D_POLY_TYPES
1804#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1805#define VOL7D_POLY_TYPES b
1806#include "modqc_peeling_include.F90"
1807#undef VOL7D_POLY_TYPE
1808#undef VOL7D_POLY_TYPES
1809#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1810#define VOL7D_POLY_TYPES c
1811#include "modqc_peeling_include.F90"
1812
1813
1814#undef VOL7D_POLY_SUBTYPE
1815#undef VOL7D_POLY_SUBTYPES
1816#define VOL7D_POLY_SUBTYPE INTEGER
1817#define VOL7D_POLY_SUBTYPES i
1818
1819#undef VOL7D_POLY_TYPE
1820#undef VOL7D_POLY_TYPES
1821#define VOL7D_POLY_TYPE REAL
1822#define VOL7D_POLY_TYPES r
1823#include "modqc_peeling_include.F90"
1824#undef VOL7D_POLY_TYPE
1825#undef VOL7D_POLY_TYPES
1826#define VOL7D_POLY_TYPE DOUBLE PRECISION
1827#define VOL7D_POLY_TYPES d
1828#include "modqc_peeling_include.F90"
1829#undef VOL7D_POLY_TYPE
1830#undef VOL7D_POLY_TYPES
1831#define VOL7D_POLY_TYPE INTEGER
1832#define VOL7D_POLY_TYPES i
1833#include "modqc_peeling_include.F90"
1834#undef VOL7D_POLY_TYPE
1835#undef VOL7D_POLY_TYPES
1836#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1837#define VOL7D_POLY_TYPES b
1838#include "modqc_peeling_include.F90"
1839#undef VOL7D_POLY_TYPE
1840#undef VOL7D_POLY_TYPES
1841#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1842#define VOL7D_POLY_TYPES c
1843#include "modqc_peeling_include.F90"
1844
1845
1846#undef VOL7D_POLY_SUBTYPE
1847#undef VOL7D_POLY_SUBTYPES
1848#define VOL7D_POLY_SUBTYPE INTEGER(kind=int_b)
1849#define VOL7D_POLY_SUBTYPES b
1850
1851#undef VOL7D_POLY_TYPE
1852#undef VOL7D_POLY_TYPES
1853#define VOL7D_POLY_TYPE REAL
1854#define VOL7D_POLY_TYPES r
1855#include "modqc_peeling_include.F90"
1856#undef VOL7D_POLY_TYPE
1857#undef VOL7D_POLY_TYPES
1858#define VOL7D_POLY_TYPE DOUBLE PRECISION
1859#define VOL7D_POLY_TYPES d
1860#include "modqc_peeling_include.F90"
1861#undef VOL7D_POLY_TYPE
1862#undef VOL7D_POLY_TYPES
1863#define VOL7D_POLY_TYPE INTEGER
1864#define VOL7D_POLY_TYPES i
1865#include "modqc_peeling_include.F90"
1866#undef VOL7D_POLY_TYPE
1867#undef VOL7D_POLY_TYPES
1868#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1869#define VOL7D_POLY_TYPES b
1870#include "modqc_peeling_include.F90"
1871#undef VOL7D_POLY_TYPE
1872#undef VOL7D_POLY_TYPES
1873#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1874#define VOL7D_POLY_TYPES c
1875#include "modqc_peeling_include.F90"
1876
1877
1878
1879#undef VOL7D_POLY_SUBTYPE
1880#undef VOL7D_POLY_SUBTYPES
1881#define VOL7D_POLY_SUBTYPE CHARACTER(len=vol7d_cdatalen)
1882#define VOL7D_POLY_SUBTYPES c
1883
1884#undef VOL7D_POLY_TYPE
1885#undef VOL7D_POLY_TYPES
1886#define VOL7D_POLY_TYPE REAL
1887#define VOL7D_POLY_TYPES r
1888#include "modqc_peeling_include.F90"
1889#undef VOL7D_POLY_TYPE
1890#undef VOL7D_POLY_TYPES
1891#define VOL7D_POLY_TYPE DOUBLE PRECISION
1892#define VOL7D_POLY_TYPES d
1893#include "modqc_peeling_include.F90"
1894#undef VOL7D_POLY_TYPE
1895#undef VOL7D_POLY_TYPES
1896#define VOL7D_POLY_TYPE INTEGER
1897#define VOL7D_POLY_TYPES i
1898#include "modqc_peeling_include.F90"
1899#undef VOL7D_POLY_TYPE
1900#undef VOL7D_POLY_TYPES
1901#define VOL7D_POLY_TYPE INTEGER(kind=int_b)
1902#define VOL7D_POLY_TYPES b
1903#include "modqc_peeling_include.F90"
1904#undef VOL7D_POLY_TYPE
1905#undef VOL7D_POLY_TYPES
1906#define VOL7D_POLY_TYPE CHARACTER(len=vol7d_cdatalen)
1907#define VOL7D_POLY_TYPES c
1908#include "modqc_peeling_include.F90"
1909
1910
1911
1912IF (.NOT.PRESENT(keep_attr) .AND. .NOT.PRESENT(delete_attr) .and. .not. optio_log(preserve)) THEN ! destroy all attributes
1913 IF (ASSOCIATED(this%voldatiattrr)) DEALLOCATE(this%voldatiattrr)
1914 IF (ASSOCIATED(this%voldatiattrd)) DEALLOCATE(this%voldatiattrd)
1915 IF (ASSOCIATED(this%voldatiattri)) DEALLOCATE(this%voldatiattri)
1916 IF (ASSOCIATED(this%voldatiattrb)) DEALLOCATE(this%voldatiattrb)
1917 IF (ASSOCIATED(this%voldatiattrc)) DEALLOCATE(this%voldatiattrc)
1918
1919 CALL delete(this%datiattr)
1920 CALL delete(this%dativarattr)
1921END IF
1922
1923IF (PRESENT(keep_attr)) THEN ! set to missing non requested attributes and reform
1924
1925 if (optio_log(preserve)) call l4f_log(l4f_warn,"preserve parameter ignored: keep_attr passed")
1926 CALL keep_var(this%datiattr%r)
1927 CALL keep_var(this%datiattr%d)
1928 CALL keep_var(this%datiattr%i)
1929 CALL keep_var(this%datiattr%b)
1930 CALL keep_var(this%datiattr%c)
1931 CALL qc_reform(this,data_id, miss=.true., purgeana=purgeana)
1932
1933ELSE IF (PRESENT(delete_attr)) THEN ! set to missing requested attributes and reform
1934
1935 if (optio_log(preserve)) call l4f_log(l4f_warn,"preserve parameter ignored: delete_attr passed")
1936 CALL delete_var(this%datiattr%r)
1937 CALL delete_var(this%datiattr%d)
1938 CALL delete_var(this%datiattr%i)
1939 CALL delete_var(this%datiattr%b)
1940 CALL delete_var(this%datiattr%c)
1941 CALL qc_reform(this,data_id, miss=.true., purgeana=purgeana)
1942
1943ELSE IF (PRESENT(purgeana)) THEN
1944
1945 CALL qc_reform(this,data_id, purgeana=purgeana)
1946
1947ENDIF
1948
1949
1950CONTAINS
1951
1952
1953!> Like vol7d_reform but manage data_id and have less options
1954subroutine qc_reform(this,data_id,miss, purgeana)
1955TYPE(vol7d),INTENT(INOUT) :: this !< object that has to be reformed
1956integer,INTENT(inout),pointer,OPTIONAL :: data_id(:,:,:,:,:) !< data ID to use with dballe DB (for fast write of attributes)
1957logical,intent(in),optional :: miss !< remove everithing related with missing position in description vector
1958logical,intent(in),optional :: purgeana !< if true remove ana with all data missing
1959
1960integer,pointer :: data_idtmp(:,:,:,:,:)
1961logical,allocatable :: llana(:)
1962integer,allocatable :: anaind(:)
1963integer :: i,j,nana
1964
1965if (optio_log(purgeana)) then
1966 allocate(llana(size(this%ana)))
1967 llana =.false.
1968 do i =1,size(this%ana)
1969 if (associated(this%voldatii)) llana(i)= llana(i) .or. any(c_e(this%voldatii(i,:,:,:,:,:)))
1970 if (associated(this%voldatir)) llana(i)= llana(i) .or. any(c_e(this%voldatir(i,:,:,:,:,:)))
1971 if (associated(this%voldatid)) llana(i)= llana(i) .or. any(c_e(this%voldatid(i,:,:,:,:,:)))
1972 if (associated(this%voldatib)) llana(i)= llana(i) .or. any(c_e(this%voldatib(i,:,:,:,:,:)))
1973 if (associated(this%voldatic)) llana(i)= llana(i) .or. any(c_e(this%voldatic(i,:,:,:,:,:)))
1974
1975#ifdef DEBUG
1976 if (.not. llana(i)) call l4f_log(l4f_debug,"remove station"//t2c(i))
1977#endif
1978
1979 end do
1980
1981 nana=count(llana)
1982
1983
1984 allocate(anaind(nana))
1985
1986 j=0
1987 do i=1,size(this%ana)
1988 if (llana(i)) then
1989 j=j+1
1990 anaind(j)=i
1991 end if
1992 end do
1993
1994
1995 if(present(data_id)) then
1996 allocate(data_idtmp(nana,size(data_id,2),size(data_id,3),size(data_id,4),size(data_id,5)))
1997 data_idtmp=data_id(anaind,:,:,:,:)
1998 if (associated(data_id))deallocate(data_id)
1999 data_id=>data_idtmp
2000 end if
2001
2002 call vol7d_reform(this,miss=miss,lana=llana)
2003
2004 deallocate(llana,anaind)
2005
2006else
2007
2008 call vol7d_reform(this,miss=miss)
2009
2010end if
2011
2012end subroutine qc_reform
2013
2014
2015SUBROUTINE keep_var(var)
2016TYPE(vol7d_var),intent(inout),POINTER :: var(:)
2017
2018INTEGER :: i
2019
2020IF (ASSOCIATED(var)) THEN
2021 if (size(var) == 0) then
2022 var%btable = vol7d_var_miss%btable
2023 else
2024 DO i = 1, SIZE(var)
2025 IF (all(var(i)%btable /= keep_attr(:))) THEN ! n.b. ALL((//)) = .TRUE.
2026 var(i)%btable = vol7d_var_miss%btable
2027 ENDIF
2028 ENDDO
2029 end if
2030ENDIF
2031
2032END SUBROUTINE keep_var
2033
2034SUBROUTINE delete_var(var)
2035TYPE(vol7d_var),intent(inout),POINTER :: var(:)
2036
2037INTEGER :: i
2038
2039IF (ASSOCIATED(var)) THEN
2040 if (size(var) == 0) then
2041 var%btable = vol7d_var_miss%btable
2042 else
2043 DO i = 1, SIZE(var)
2044 IF (any(var(i)%btable == delete_attr(:))) THEN ! n.b. ANY((//)) = .FALSE.
2045 var(i) = vol7d_var_miss
2046 ENDIF
2047 ENDDO
2048 end if
2049ENDIF
2050
2051END SUBROUTINE delete_var
2052
2053END SUBROUTINE vol7d_peeling
2054
2055
2056end module modqc
Variables user in Quality Control.
Definition modqc.F90:386
Test di dato invalidato.
Definition modqc.F90:411
Remove data under a defined grade of confidence.
Definition modqc.F90:391
Check data validity based on single confidence.
Definition modqc.F90:401
Check data validity based on gross error check.
Definition modqc.F90:406
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.
Utilities and defines for quality control.
Definition modqc.F90:357
Module for quickly interpreting the OPTIONAL parameters passed to a subprogram.
Classe per la gestione di un volume completo di dati osservati.
Definisce il livello di attendibilità per i dati validi.
Definition modqc.F90:368

Generated with Doxygen.