libsim Versione 7.2.1
esempio_v7ddballe_import_export.f90

Esempio di utilizzo della classe vol7d_dballe_class.

Esempio di utilizzo della classe vol7d_dballe_class

Vengono estratti i dati e riscritti in un nuovo DSN

1! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
2! authors:
3! Davide Cesari <dcesari@arpa.emr.it>
4! Paolo Patruno <ppatruno@arpa.emr.it>
5
6! This program is free software; you can redistribute it and/or
7! modify it under the terms of the GNU General Public License as
8! published by the Free Software Foundation; either version 2 of
9! the License, or (at your option) any later version.
10
11! This program is distributed in the hope that it will be useful,
12! but WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14! GNU General Public License for more details.
15
16! You should have received a copy of the GNU General Public License
17! along with this program. If not, see <http://www.gnu.org/licenses/>.
18PROGRAM v7ddballe_import_export
19! Programma di esempio di estrazione e scrittura dall'archivio DB-all.e
23
24IMPLICIT NONE
25
26TYPE(vol7d_dballe) :: v7d,v7d_exp
27TYPE(datetime) :: ti, tf
28integer :: sh(5)
29
30TYPE(vol7d_ana) :: ana
31TYPE(datetime) :: time
32TYPE(vol7d_level) :: level
33TYPE(vol7d_timerange) :: timerange
34TYPE(vol7d_network) :: network
35TYPE(vol7d_var) :: dativar,attrvar
36CHARACTER(len=vol7d_ana_lenident) :: ident
37REAL(kind=fp_geo) :: lat,lon
38
39integer :: indana,indtime,indlevel,indtimerange,inddativar,indnetwork
40integer :: inddatiattr,inddativarattr
41
42
43! Definisco le date iniziale e finale
44CALL init(ti, year=2007, month=3, day=18, hour=12)
45CALL init(tf, year=2007, month=3, day=21, hour=00)
46
47call init(network,"generic")
48
49! Chiamo il costruttore della classe vol7d_dballe per il mio oggetto in import
50CALL init(v7d)
51
52! Chiamo il costruttore della classe vol7d_dballe per il mio oggetto in export
53CALL init(v7d_exp,dsn="test",user="test",write=.true.,wipe=.false.)
54
55! Importo i dati
56
57CALL import(v7d,var=(/"B13003","B13011","B12101"/),varkind=(/"d","r","r"/), network=network, timei=ti, timef=tf&
58 ,attr=(/"*B33192","*B33007"/),attrkind=(/"i","b"/))
59
60
61! Esempi:
62!CALL import(v7d)
63!CALL import(v7d,(/"B13011","B12101"/), 255, ti, tf, timerange=vol7d_timerange(4,-1800,0), attr=(/"*B33192","*B33007"/))
64!CALL import(v7d,(/"B13011","B12101"/), 255, ti, tf, attr=(/"*B33192","*B33007"/))
65!CALL import(v7d,var=(/"B13003","B13011","B12101"/))
66!CALL import(v7d,var=(/"B13003","B13011","B12101"/),varkind=(/"d","r","r"/), network=255, timei=ti, timef=tf&
67! ,attr=(/"*B33192","*B33007"/),attrkind=(/"i","b"/))
68! ,attr=(/"*B33192","*B33007"/))
69
70!CALL import(v7d,var=(/"B12101"/),varkind=(/"r"/),attr=(/"*B33195","*B33192"/),attrkind=(/"i","b"/))
71
72print *,"Fine estrazione dati"
73
74call display(v7d%vol7d)
75
76!call vol7d_copy(v7d%vol7d,v7d_exp%vol7d)
77!call vol7d_diff_only(v7d%vol7d,v7d_exp%vol7d,data_only=.true.)
78!CALL delete (v7d)
79
80if (associated(v7d%data_id))then
81 sh=shape(v7d%data_id)
82 print *,"data id shape",sh
83
84 allocate (v7d_exp%data_id(sh(1),sh(2),sh(3),sh(4),sh(5)))
85 v7d_exp%data_id=imiss
86end if
87
88v7d_exp%vol7d = v7d%vol7d
89!v7d_exp%data_id => v7d%data_id
90
91
92lat=45.8875d0
93lon=8.51111d0
94ident=cmiss
95
96call init(ana,lat=lat,lon=lon,ident=ident)
97call init(time, year=2007, month=3, day=18, hour=00,minute=30)
98call init(level, 105,2,0)
99call init(timerange, 0, 0, 0)
100call init(network, 'rete50')
101call init(dativar,"B12101" )
102call init(attrvar,"*B33192" )
103
104
105indana = index(v7d%vol7d%ana, ana)
106indtime = index(v7d%vol7d%time, time)
107indtimerange = index(v7d%vol7d%timerange, timerange)
108indlevel = index(v7d%vol7d%level, level)
109indnetwork = index(v7d%vol7d%network, network)
110inddativar = index(v7d%vol7d%dativar%r, dativar)
111
112print *,"modifico questo dato ", indana,indtime,indlevel,indtimerange,indnetwork
113
114if (indana == 0 .or. indtime == 0 .or. indlevel == 0 .or. indtimerange == 0 .or. indnetwork == 0) then
115 call raise_error("data not found")
116end if
117
118if (any(shape(v7d%vol7d%datiattr)>0)) then
119 inddativarattr = index(v7d%vol7d%dativarattr%b, dativar)
120 inddatiattr = index(v7d%vol7d%datiattr%b, attrvar)
121
122 if (inddativarattr == 0 .or. inddatiattr == 0) then
123 call raise_error("attribute not found")
124 end if
125
126else
127 call raise_error("all attribute are missing")
128end if
129
130
131
132v7d_exp%vol7d%voldatiattrb(indana,indtime,indlevel,indtimerange,&
133 inddativarattr,indnetwork,inddatiattr) = 96
134
135
136if (associated(v7d_exp%data_id))then
137 v7d_exp%data_id(indana,indtime,indlevel,indtimerange,indnetwork)=&
138 v7d%data_id(indana,indtime,indlevel,indtimerange,indnetwork)
139end if
140
141print *,"Scrivo i dati"
142
143CALL export(v7d_exp)
144!CALL export(v7d_exp,attr_only=.true.)
145
146CALL delete (v7d_exp)
147
148END PROGRAM v7ddballe_import_export
Distruttori per le 2 classi.
Costruttori per le classi datetime e timedelta.
Index method.
Scrittura su file.
Lettura da file.
Classi per la gestione delle coordinate temporali.
Classe per la gestione di un volume completo di dati osservati.
classe per import ed export di volumi da e in DB-All.e

Generated with Doxygen.