libsim  Versione 7.1.8
esempio_v7ddballe_import_export.f90

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/>.
18 PROGRAM v7ddballe_import_export
19 ! Programma di esempio di estrazione e scrittura dall'archivio DB-all.e
21 USE vol7d_class
23 
24 IMPLICIT NONE
25 
26 TYPE(vol7d_dballe) :: v7d,v7d_exp
27 TYPE(datetime) :: ti, tf
28 integer :: sh(5)
29 
30 TYPE(vol7d_ana) :: ana
31 TYPE(datetime) :: time
32 TYPE(vol7d_level) :: level
33 TYPE(vol7d_timerange) :: timerange
34 TYPE(vol7d_network) :: network
35 TYPE(vol7d_var) :: dativar,attrvar
36 CHARACTER(len=vol7d_ana_lenident) :: ident
37 REAL(kind=fp_geo) :: lat,lon
38 
39 integer :: indana,indtime,indlevel,indtimerange,inddativar,indnetwork
40 integer :: inddatiattr,inddativarattr
41 
42 
43 ! Definisco le date iniziale e finale
44 CALL init(ti, year=2007, month=3, day=18, hour=12)
45 CALL init(tf, year=2007, month=3, day=21, hour=00)
46 
47 call init(network,"generic")
48 
49 ! Chiamo il costruttore della classe vol7d_dballe per il mio oggetto in import
50 CALL init(v7d)
51 
52 ! Chiamo il costruttore della classe vol7d_dballe per il mio oggetto in export
53 CALL init(v7d_exp,dsn="test",user="test",write=.true.,wipe=.false.)
54 
55 ! Importo i dati
56 
57 CALL 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 
72 print *,"Fine estrazione dati"
73 
74 call 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 
80 if (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
86 end if
87 
88 v7d_exp%vol7d = v7d%vol7d
89 !v7d_exp%data_id => v7d%data_id
90 
91 
92 lat=45.8875d0
93 lon=8.51111d0
94 ident=cmiss
95 
96 call init(ana,lat=lat,lon=lon,ident=ident)
97 call init(time, year=2007, month=3, day=18, hour=00,minute=30)
98 call init(level, 105,2,0)
99 call init(timerange, 0, 0, 0)
100 call init(network, 'rete50')
101 call init(dativar,"B12101" )
102 call init(attrvar,"*B33192" )
103 
104 
105 indana = index(v7d%vol7d%ana, ana)
106 indtime = index(v7d%vol7d%time, time)
107 indtimerange = index(v7d%vol7d%timerange, timerange)
108 indlevel = index(v7d%vol7d%level, level)
109 indnetwork = index(v7d%vol7d%network, network)
110 inddativar = index(v7d%vol7d%dativar%r, dativar)
111 
112 print *,"modifico questo dato ", indana,indtime,indlevel,indtimerange,indnetwork
113 
114 if (indana == 0 .or. indtime == 0 .or. indlevel == 0 .or. indtimerange == 0 .or. indnetwork == 0) then
115  call raise_error("data not found")
116 end if
117 
118 if (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 
126 else
127  call raise_error("all attribute are missing")
128 end if
129 
130 
131 
132 v7d_exp%vol7d%voldatiattrb(indana,indtime,indlevel,indtimerange,&
133  inddativarattr,indnetwork,inddatiattr) = 96
134 
135 
136 if (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)
139 end if
140 
141 print *,"Scrivo i dati"
142 
143 CALL export(v7d_exp)
144 !CALL export(v7d_exp,attr_only=.true.)
145 
146 CALL delete (v7d_exp)
147 
148 END 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.