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

Generated with Doxygen.