libsim  Versione6.3.0
example_vg6d_9.f90

Example to create a grib editionNumber = 2 file from data generated in memory using a grib_api template

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 
19 !!!!!!!!!!!!!!!!
20 ! Example to create a grib editionNumber = 2 file from data generated in memory using a grib_api template.
21 !!!!!!!!!!!!!!!!
22 
23 program demo9
24 
25 use log4fortran
27 use grid_class
28 use grid_id_class
29 
34 
35 
36 implicit none
37 
38 integer :: category,ier
39 character(len=512):: a_name,filename="out.grib"
40 TYPE(arrayof_gridinfo) :: gridinfo
41 
42 type(griddim_def) :: griddim
43 
44 integer,parameter :: nx=40, ny=50, component_flag=0
45 type(grid_id) :: gaid_template
46 type(vol7d_level) :: level
47 type(vol7d_timerange) :: timerange
48 type(volgrid6d_var) :: var
49 type(datetime) :: date_time
50 doubleprecision :: xmin=0., xmax=30., ymin=30., ymax=60.
51 !doubleprecision :: latitude_south_pole=-32.5,longitude_south_pole=10.,angle_rotation=0.
52 character(len=80) :: type='regular_ll'
53 real :: field(nx,ny)=5.
54 
55 ! get launcher name
56 call l4f_launcher(a_name,a_name_force="demo9")
57 
58 ! log4fortran init
59 ier=l4f_init()
60 
61 ! set a_name
62 category=l4f_category_get(a_name//".main")
63 
64 call l4f_category_log(category,l4f_info,"start")
65 
66 call init(griddim,&
67  proj_type=type,nx=nx,ny=ny, &
68  xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, component_flag=component_flag, &
69  !latitude_south_pole=latitude_south_pole,longitude_south_pole=longitude_south_pole,angle_rotation=angle_rotation, &
70  categoryappend="generated")
71 gaid_template = grid_id_new(grib_api_template="regular_ll_sfc_grib2")
72 call init(date_time,year=2011, month=04, day=12, hour=12, minute=00, msec=00)
73 call init(timerange, timerange=4, p1=3600, p2=900)
74 call init(level, level1=105, l1=200, level2=imiss, l2=imiss)
75 call init(var,centre=200, category=3, number=61, discipline=4)
76 CALL insert(gridinfo, nelem=1)
77 call init(gridinfo%array(1), gaid_template, griddim, date_time, timerange, level, var, clone=.false., categoryappend='inventato')
78 
79 ! here you can change the default template
80 call grib_set(grid_id_get_gaid(gridinfo%array(1)%gaid),"generatingProcessIdentifier",178)
81 
82 !encode the data
83 call encode_gridinfo(gridinfo%array(1), field)
84 
85 call display(gridinfo)
86 call l4f_category_log(category,l4f_info,"export to GRIB")
87 
88 CALL export(gridinfo, filename=filename, categoryappend="gridinfo scritto")
89 
90 call l4f_category_log(category,l4f_info,"end")
91 
92 call delete(gridinfo)
93 
94 ! close logger
95 call l4f_category_delete(category)
96 ier=l4f_fini()
97 
98 end program demo9

Generated with Doxygen.