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
30 integer :: category,ier
31 character(len=512):: a_name,infile=
'../data/in.grb',outfile=
'out.grb'
32 type (gridinfo_def) :: gridinfo
33 type(grid_file_id) :: ifile,ofile
36 doubleprecision :: ilon=0.,ilat=30.,flon=30.,flat=60.
37 REAL,
ALLOCATABLE :: field(:,:,:),fieldz(:,:,:)
38 type(griddim_def) :: griddim_out
39 type(transform_def) :: trans
40 type(grid_transform) :: grid_trans
42 integer :: nx=30,ny=30,component_flag=0
43 doubleprecision :: xmin=0., xmax=30., ymin=30., ymax=60.
44 doubleprecision :: latitude_south_pole=-32.5,longitude_south_pole=10.,angle_rotation=0.
45 character(len=80) :: type=
'regular_ll',trans_type=
'inter',sub_type=
'near'
49 call l4f_launcher(a_name,a_name_force=
"demo4")
55 category=l4f_category_get(a_name//
".main")
57 call l4f_category_log(category,l4f_info,
"transforming from file:"//trim(infile))
58 call l4f_category_log(category,l4f_info,
"transforming to file:"//trim(outfile))
59 if(trans_type ==
'inter')
then
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")
67 call griddim_unproj(griddim_out)
69 print*,
'grid di interpolazione >>>>>>>>>>>>>>>>>>>>'
74 call init(trans, trans_type=trans_type,sub_type=sub_type, &
75 ilon=ilon,ilat=ilat,flon=flon,flat=flat,&
76 categoryappend=
"trasformation")
78 ifile = grid_file_id_new(trim(infile),
'r')
79 ofile = grid_file_id_new(trim(outfile),
'w')
83 gaid = grid_id_new(ifile)
84 IF (.NOT.
c_e(gaid))
EXIT
88 call init (gridinfo,gaid=gaid,categoryappend="importato
")
91 call display(gridinfo,namespace="")
93 call l4f_category_log(category,L4F_INFO,"import")
95 ALLOCATE (field(gridinfo%griddim%dim%nx,gridinfo%griddim%dim%ny,1))
97 field(:,:,1)=decode_gridinfo(gridinfo)
99 call init(grid_trans, trans, in=gridinfo%griddim,out=griddim_out,categoryappend="gridtrasformato
")
101 call display(griddim_out)
103 ALLOCATE (fieldz(griddim_out%dim%nx,griddim_out%dim%ny,1))
105 call compute(grid_trans, field, fieldz)
107 call delete(gridinfo%griddim)
108 call copy(griddim_out,gridinfo%griddim,categoryappend="clonato
")
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)
115 call encode_gridinfo(gridinfo,fieldz(:,:,1))
116 call export (gridinfo)
117 call display(gridinfo,namespace="")
119 call export(gridinfo%gaid,ofile)
121 call delete (grid_trans)
122 call delete (gridinfo)
123 deallocate (field,fieldz)
128 call delete(griddim_out)
133 call l4f_category_log(category,L4F_INFO,"terminato
")
136 call l4f_category_delete(category)
Display on standard output a description of the gridinfo object provided.
Import information from a file or grid_id object into the gridinfo descriptors.
Constructor, it creates a new instance of the object.
Emit log message for a category with specific priority.
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.