libsim Versione 7.2.1
example_vg6d_4.f90

Programma esempio semplice per la elaborazione di file grib.

Programma esempio semplice per la elaborazione di file grib. Programma che legge uno ad uno i grid contenuti in un file e li elabora producendo un file di output contenente ancora grib

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 demo4
19
21use grid_class
27
28implicit none
29
30integer :: category,ier
31character(len=512):: a_name,infile='../data/in.grb',outfile='out.grb'
32type (gridinfo_def) :: gridinfo
33type(grid_file_id) :: ifile,ofile
34type(grid_id) :: gaid
35
36doubleprecision :: ilon=0.,ilat=30.,flon=30.,flat=60.
37REAL, ALLOCATABLE :: field(:,:,:),fieldz(:,:,:)
38type(griddim_def) :: griddim_out
39type(transform_def) :: trans
40type(grid_transform) :: grid_trans
41
42integer :: nx=30,ny=30,component_flag=0
43doubleprecision :: xmin=0., xmax=30., ymin=30., ymax=60.
44doubleprecision :: latitude_south_pole=-32.5,longitude_south_pole=10.,angle_rotation=0.
45character(len=80) :: type='regular_ll',trans_type='inter',sub_type='near'
46
47
48!questa chiamata prende dal launcher il nome univoco
49call l4f_launcher(a_name,a_name_force="demo4")
50
51!init di log4fortran
52ier=l4f_init()
53
54!imposta a_name
55category=l4f_category_get(a_name//".main")
56
57call l4f_category_log(category,l4f_info,"transforming from file:"//trim(infile))
58call l4f_category_log(category,l4f_info,"transforming to file:"//trim(outfile))
59if(trans_type == 'inter')then
60
61 call init(griddim_out,&
62 proj_type=type,nx=nx,ny=ny, &
63 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, component_flag=component_flag, &
64 latitude_south_pole=latitude_south_pole,longitude_south_pole=longitude_south_pole,angle_rotation=angle_rotation, &
65 categoryappend="regular_ll")
66
67 call griddim_unproj(griddim_out)
68
69 print*,'grid di interpolazione >>>>>>>>>>>>>>>>>>>>'
70 call display(griddim_out)
71
72end if
73
74call init(trans, trans_type=trans_type,sub_type=sub_type, &
75 ilon=ilon,ilat=ilat,flon=flon,flat=flat,&
76 categoryappend="trasformation")
77
78ifile = grid_file_id_new(trim(infile),'r')
79ofile = grid_file_id_new(trim(outfile),'w')
80
81! Loop on all the messages in a file.
82DO WHILE (.true.)
83 gaid = grid_id_new(ifile)
84 IF (.NOT.c_e(gaid)) EXIT
85
86 call l4f_category_log(category,l4f_info,"import gridinfo")
87
88 call init (gridinfo,gaid=gaid,categoryappend="importato")
89 call import(gridinfo)
90
91 call display(gridinfo,namespace="")
92
93 call l4f_category_log(category,l4f_info,"import")
94
95 ALLOCATE (field(gridinfo%griddim%dim%nx,gridinfo%griddim%dim%ny,1))
96
97 field(:,:,1)=decode_gridinfo(gridinfo)
98
99 call init(grid_trans, trans, in=gridinfo%griddim,out=griddim_out,categoryappend="gridtrasformato")
100
101 call display(griddim_out)
102
103 ALLOCATE (fieldz(griddim_out%dim%nx,griddim_out%dim%ny,1))
104
105 call compute(grid_trans, field, fieldz)
106
107 call delete(gridinfo%griddim)
108 call copy(griddim_out,gridinfo%griddim,categoryappend="clonato")
109
110! oppure per mantenere il vecchio gridinfo
111! call clone(gridinfo , gridinfo_out)
112! call delete(gridinfo_out%griddim)
113! call copy(griddim_out,gridinfo_out%griddim)
114
115 call encode_gridinfo(gridinfo,fieldz(:,:,1))
116 call export (gridinfo)
117 call display(gridinfo,namespace="")
118
119 call export(gridinfo%gaid,ofile)
120
121 call delete (grid_trans)
122 call delete (gridinfo)
123 deallocate (field,fieldz)
124
125end do
126
127call delete (trans)
128call delete(griddim_out)
129
130call delete(ifile)
131call delete(ofile)
132
133call l4f_category_log(category,l4f_info,"terminato")
134
135!chiudo il logger
136call l4f_category_delete(category)
137ier=l4f_fini()
138
139end program demo4
140
Destructor for the line_split class.
Copy an object, creating a fully new instance.
Definition: grid_class.F90:302
Print a brief description on stdout.
Definition: grid_class.F90:349
Export griddim object to grid_id.
Definition: grid_class.F90:344
Import griddim object from grid_id.
Definition: grid_class.F90:339
Constructors of the corresponding objects.
Definition: grid_class.F90:292
Check whether the corresponding object has been correctly associated.
Compute the output data array from input data array according to the defined transformation.
Decode and return the data array from a grid_id object associated to a gridinfo object.
Encode a data array into a grid_id object associated to a gridinfo object.
Emit log message for a category with specific priority.
log4fortran destructor
Global log4fortran constructor.
Utilities for CHARACTER variables.
Module for describing geographically referenced regular grids.
Definition: grid_class.F90:237
This module defines an abstract interface to different drivers for access to files containing gridded...
Module for defining transformations between rectangular georeferenced grids and between grids and spa...
Class for managing information about a single gridded georeferenced field, typically imported from an...
classe per la gestione del logging
This module defines objects and methods for managing data volumes on rectangular georeferenced grids.

Generated with Doxygen.