libsim  Versione7.1.6
esempio_v7ddballe_multi.f90

/brief Programma esempio per l'uso di vol7d con DB-All.eVengono estratte più reti

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
19 ! Programma di esempio di estrazione dall'archivio DB-all.e
22 USE vol7d_class
25 
26 IMPLICIT NONE
27 
28 TYPE(vol7d_dballe) :: v7d
29 TYPE(vol7d_network) :: dummy_network,network(8)
30 TYPE(datetime) :: ti, tf, tc
31 TYPE(vol7d) :: vol_cumh, vol_cumd
32 TYPE(timedelta) :: dt_cum
33 CHARACTER(len=12) :: c
34 INTEGER :: i,j, n
35 REAL, POINTER :: vol2d(:,:), vol2d_cum(:,:)
36 INTEGER :: un
37 CHARACTER(len=512) :: filesim
38 TYPE(geo_coordvect),POINTER :: macroa(:)
39 INTEGER, ALLOCATABLE :: in_macroa(:)
40 
41 ! Definisco le date iniziale e finale
42 CALL init(ti, year=2007, month=3, day=18, hour=00)
43 CALL init(tf, year=2007, month=3, day=21, hour=00)
44 CALL init(dummy_network, 'generic')
45 CALL init(network(1), 'rete11')
46 CALL init(network(2), 'rete13')
47 CALL init(network(3), 'rete15')
48 CALL init(network(4), 'rete18')
49 CALL init(network(5), 'rete19')
50 CALL init(network(6), 'rete20')
51 CALL init(network(7), 'rete21')
52 CALL init(network(8), 'rete22')
53 !CALL init(network(9), 'rete12')
54 !CALL init(network(10), 'rete17')
55 
56 
57 ! Chiamo il costruttore della classe vol7d_dballe per il mio oggetto
58 CALL init(v7d,dsn="test",user="test",password="")
59 ! Importo i dati, variabile 'B13011' della btable (precipitazione),
60 ! rete 18 (FIDUPO), 20 (SIMNBO), 21 (SIMNPR)
61 CALL import(v7d, (/'B13011'/), network, timei=ti, timef=tf, set_network=dummy_network,varkind=(/"r"/))
62 
63 print*,shape(v7d%vol7d%voldatir)
64 
65 call export(v7d%vol7d)
66 
67 ! Cumulo i dati su intervalli orari
68 CALL init(dt_cum, hour=1)
69 CALL vol7d_compute_stat_proc(v7d%vol7d, vol_cumh, 1, 1, dt_cum)
70 ! Mi faccio dare una "vista" bidimensionale dei miei dati
71 CALL vol7d_get_voldatir(vol_cumh, (/vol7d_ana_d,vol7d_time_d/), vol2dp=vol2d_cum)
72 ! Stampo la media su tutte le stazioni ora per ora
73 DO i = 1, SIZE(vol_cumh%time)
74  CALL getval(vol_cumh%time(i), simpledate=c)
75  n = count(vol2d_cum(:,i) /= rmiss)
76  IF (n > 0) THEN
77  print'(2A,G12.5)',c,' prec. media (mm): ', &
78  sum(vol2d_cum(:,i), mask=(vol2d_cum(:,i) /= rmiss))/n
79  ENDIF
80 ENDDO
81 
82 ! Cumulo i dati su intervalli giornalieri
83 CALL init(dt_cum, day=1)
84 CALL init(tc, year=2007, month=3, day=17, hour=00)
85 CALL vol7d_compute_stat_proc(vol_cumh, vol_cumd, 1, 1, dt_cum, tc)
86 ! Mi faccio dare una "vista" bidimensionale dei miei dati
87 CALL vol7d_get_voldatir(vol_cumd, (/vol7d_ana_d,vol7d_time_d/), vol2dp=vol2d_cum)
88 
89 ! Importo un file con le macroaree Emilia Romagna
90 un = open_package_file('polipciv4.dat', filetype_data)
91 IF (un < 0) stop 1
92 INQUIRE(unit=un, name=filesim)
93 CLOSE(un)
94 CALL import(macroa, shpfilesim=filesim)
95 ALLOCATE(in_macroa(SIZE(vol_cumd%ana)))
96 in_macroa = 0
97 ! Determino l'appartenenza delle stazioni alle macroaree
98 DO i = 1, SIZE(vol_cumd%ana)
99  DO j = 1, SIZE(macroa)
100  IF (geo_coord_inside(vol_cumd%ana(i)%coord, macroa(j))) THEN
101  in_macroa(i) = j
102  cycle
103  ENDIF
104  ENDDO
105 ENDDO
106 
107 ! Stampo la media su tutte le stazioni di ogni macroarea giorno per giorno
108 DO i = 1, SIZE(vol_cumd%time)
109  CALL getval(vol_cumd%time(i), simpledate=c)
110  DO j = 1, SIZE(macroa)
111  n = count(vol2d_cum(:,i) /= rmiss .AND. in_macroa(:) == j)
112  IF (n > 0) THEN
113  print'(2A,I3,A,G12.5)',c,' macroarea: ',j,' prec media (mm): ', &
114  sum(vol2d_cum(:,i), mask=(vol2d_cum(:,i) /= rmiss &
115  .AND. in_macroa(:) == j))/n
116  ENDIF
117  ENDDO
118 ENDDO
119 
120 END PROGRAM v7ddballe

Generated with Doxygen.