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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18program demo4
19
27
28implicit none
29
30integer :: ier
31type(l4f_handle) :: category
32character(len=512):: a_name,infile='../data/in.grb',outfile='out.grb'
33type (gridinfo_def) :: gridinfo
34type(grid_file_id) :: ifile,ofile
35type(grid_id) :: gaid
36
37doubleprecision :: ilon=0.,ilat=30.,flon=30.,flat=60.
38REAL, ALLOCATABLE :: field(:,:,:),fieldz(:,:,:)
39type(griddim_def) :: griddim_out
40type(transform_def) :: trans
41type(grid_transform) :: grid_trans
42
43integer :: nx=30,ny=30,component_flag=0
44doubleprecision :: xmin=0., xmax=30., ymin=30., ymax=60.
45doubleprecision :: latitude_south_pole=-32.5,longitude_south_pole=10.,angle_rotation=0.
46character(len=80) :: type='regular_ll',trans_type='inter',sub_type='near'
47
48
49
50call l4f_launcher(a_name,a_name_force="demo4")
51
52
54
55
56category=l4f_category_get_handle(a_name//".main")
57
58call l4f_category_log(category,l4f_info,
"transforming from file:"//trim(infile))
59call l4f_category_log(category,l4f_info,
"transforming to file:"//trim(outfile))
60if(trans_type == 'inter')then
61
62 call init(griddim_out,&
63 proj_type=type,nx=nx,ny=ny, &
64 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, component_flag=component_flag, &
65 latitude_south_pole=latitude_south_pole,longitude_south_pole=longitude_south_pole,angle_rotation=angle_rotation, &
66 categoryappend="regular_ll")
67
68 call griddim_unproj(griddim_out)
69
70 print*,'grid di interpolazione >>>>>>>>>>>>>>>>>>>>'
72
73end if
74
75call init(trans, trans_type=trans_type,sub_type=sub_type, &
76 ilon=ilon,ilat=ilat,flon=flon,flat=flat,&
77 categoryappend="trasformation")
78
79ifile = grid_file_id_new(trim(infile),'r')
80ofile = grid_file_id_new(trim(outfile),'w')
81
82
83DO WHILE (.true.)
84 gaid = grid_id_new(ifile)
85 IF (.NOT.
c_e(gaid))
EXIT
86
88
89 call init (gridinfo,gaid=gaid,categoryappend=
"importato")
91
92 call display(gridinfo,namespace=
"")
93
95
96 ALLOCATE (field(gridinfo%griddim%dim%nx,gridinfo%griddim%dim%ny,1))
97
99
100 call init(grid_trans, trans, in=gridinfo%griddim,out=griddim_out,categoryappend=
"gridtrasformato")
101
103
104 ALLOCATE (fieldz(griddim_out%dim%nx,griddim_out%dim%ny,1))
105
106 call compute(grid_trans, field, fieldz)
107
108 call delete(gridinfo%griddim)
109 call copy(griddim_out,gridinfo%griddim,categoryappend=
"clonato")
110
111
112
113
114
115
118 call display(gridinfo,namespace=
"")
119
120 call export(gridinfo%gaid,ofile)
121
124 deallocate (field,fieldz)
125
126end do
127
130
133
135
136
137call l4f_category_delete(category)
139
140end program demo4
141
Destructor for the line_split class.
Copy an object, creating a fully new instance.
Print a brief description on stdout.
Export griddim object to grid_id.
Import griddim object from grid_id.
Constructors of the corresponding objects.
Check whether the corresponding object has been correctly associated.
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.
Global log4fortran destructor.
Global log4fortran constructor.
Utilities for CHARACTER variables.
Module for describing geographically referenced regular grids.
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
This module defines objects and methods for managing data volumes on rectangular georeferenced grids.