libsim  Versione8.0.0
example_vg6d_2.f90

Programma esempio semplice per la lettura di file grib. Programma che legge i grib contenuti in un file e li organizza in un vettore di oggetti gridinfo

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 demo2
19 
22 use log4fortran
23 use grid_id_class
24 
25 implicit none
26 
27 integer :: ier
28 type(l4f_handle) :: category
29 character(len=512):: a_name
30 type(arrayof_gridinfo) :: gridinfo
31 
32 TYPE(grid_file_id) :: ifile
33 TYPE(grid_id) :: gaid
34 INTEGER :: ngrib
35 
36 !questa chiamata prende dal launcher il nome univoco
37 call l4f_launcher(a_name,a_name_force="demo2")
38 
39 !imposta a_name
40 category=l4f_category_get_handle(a_name//".main")
41 
42 !init di log4fortran
43 ier=l4f_init()
44 
45 
46 ngrib=0
47 
48 ifile = grid_file_id_new('../data/in.grb','r')
49 ! Loop on all the messages in a file.
50 DO WHILE (.true.)
51  gaid = grid_id_new(ifile)
52  IF (.NOT.c_e(gaid)) EXIT
53 
54  ngrib = ngrib + 1
55  CALL delete(gaid)
56 ENDDO
57 
58 CALL delete(ifile)
59 
60 CALL l4f_category_log(category,l4f_info,&
61  "Numero totale di grib: "//to_char(ngrib))
62 
63 ! aggiungo ngrib elementi vuoti
64 CALL insert(gridinfo, nelem=ngrib)
65 
66 ngrib=0
67 
68 ifile = grid_file_id_new('../data/in.grb','r')
69 ! Loop on all the messages in a file.
70 DO WHILE (.true.)
71  gaid = grid_id_new(ifile)
72  IF (.NOT.c_e(gaid)) EXIT
73 
74  CALL l4f_category_log(category,l4f_info,"import grib")
75  ngrib = ngrib + 1
76  CALL init (gridinfo%array(ngrib), gaid=gaid)
77  CALL import(gridinfo%array(ngrib))
78 ENDDO
79 
80 call delete(ifile)
81 call display(gridinfo)
82 
83 CALL delete(gridinfo)
84 
85 call l4f_category_log(category,l4f_info,"terminato ")
86 
87 !chiudo il logger
88 call l4f_category_delete(category)
89 ier=l4f_fini()
90 
91 end program demo2

Generated with Doxygen.