libsim Versione 7.1.11
example_vg6d_2.f90

Programma esempio semplice per la lettura di file grib.

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/>.
18program demo2
19
24
25implicit none
26
27integer :: category,ier
28character(len=512):: a_name
29type(arrayof_gridinfo) :: gridinfo
30
31TYPE(grid_file_id) :: ifile
32TYPE(grid_id) :: gaid
33INTEGER :: ngrib
34
35!questa chiamata prende dal launcher il nome univoco
36call l4f_launcher(a_name,a_name_force="demo2")
37
38!imposta a_name
39category=l4f_category_get(a_name//".main")
40
41!init di log4fortran
42ier=l4f_init()
43
44
45ngrib=0
46
47ifile = grid_file_id_new('../data/in.grb','r')
48! Loop on all the messages in a file.
49DO WHILE (.true.)
50 gaid = grid_id_new(ifile)
51 IF (.NOT.c_e(gaid)) EXIT
52
53 ngrib = ngrib + 1
54 CALL delete(gaid)
55ENDDO
56
57CALL delete(ifile)
58
59CALL l4f_category_log(category,l4f_info,&
60 "Numero totale di grib: "//to_char(ngrib))
61
62! aggiungo ngrib elementi vuoti
63CALL insert(gridinfo, nelem=ngrib)
64
65ngrib=0
66
67ifile = grid_file_id_new('../data/in.grb','r')
68! Loop on all the messages in a file.
69DO 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))
77ENDDO
78
79call delete(ifile)
80call display(gridinfo)
81
82CALL delete(gridinfo)
83
84call l4f_category_log(category,l4f_info,"terminato ")
85
86!chiudo il logger
87call l4f_category_delete(category)
88ier=l4f_fini()
89
90end program demo2
Destructor for the line_split class.
Set of functions that return a CHARACTER representation of the input variable.
Check whether the corresponding object has been correctly associated.
Display on standard output a description of the grid_id object provided.
Constructors for the corresponding classes in SUBROUTINE form.
Import information from a file or grid_id object into the gridinfo descriptors.
Method for inserting elements of the array at a desired position.
Emit log message for a category with specific priority.
log4fortran destructor
Global log4fortran constructor.
Utilities for CHARACTER variables.
This module defines an abstract interface to different drivers for access to files containing gridded...
Class for managing information about a single gridded georeferenced field, typically imported from an...
classe per la gestione del logging

Generated with Doxygen.