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