NCEPLIBS-ip 5.2.0
Loading...
Searching...
No Matches
ip_grid_factory_mod.F90
Go to the documentation of this file.
1
6
13 use ip_grids_mod
14 use ip_grid_mod
15 implicit none
16
17 private
18 public :: init_grid
19
20 interface init_grid
21 module procedure init_grid_generic
22 end interface init_grid
23
24contains
25
33 subroutine init_grid_generic(grid, grid_desc)
34 class(ip_grid_descriptor), intent(in) :: grid_desc
35 class(ip_grid), allocatable, intent(out) :: grid
36
37 select type(grid_desc)
38 type is(grib1_descriptor)
39 call init_grid_grib1(grid, grid_desc)
40 type is(grib2_descriptor)
41 call init_grid_grib2(grid, grid_desc)
42 end select
43 end subroutine init_grid_generic
44
53 subroutine init_grid_grib1(grid, g1_desc)
54 type(grib1_descriptor), intent(in) :: g1_desc
55 class(ip_grid), allocatable, intent(out) :: grid
56
57 select case(g1_desc%grid_num)
58 case(:-1)
59 allocate(ip_station_points_grid::grid)
61 allocate(ip_equid_cylind_grid::grid)
63 allocate(ip_mercator_grid::grid)
65 allocate(ip_lambert_conf_grid::grid)
67 allocate(ip_gaussian_grid::grid)
69 allocate(ip_polar_stereo_grid::grid)
71 allocate(ip_rot_equid_cylind_egrid::grid)
73 allocate(ip_rot_equid_cylind_grid::grid)
74 end select
75
76 call grid%init(g1_desc)
77 allocate(grid%descriptor, source = g1_desc)
78 end subroutine init_grid_grib1
79
80
89 subroutine init_grid_grib2(grid, g2_desc)
90 type(grib2_descriptor), intent(in) :: g2_desc
91 class(ip_grid), allocatable, intent(out) :: grid
92
93 integer :: i_offset_odd, i_offset_even
94
95 select case(g2_desc%grid_num)
96 case(:-1)
97 allocate(ip_station_points_grid::grid)
99 allocate(ip_equid_cylind_grid::grid)
101 i_offset_odd = mod(g2_desc%gdt_tmpl(19) / 8, 2)
102 i_offset_even = mod(g2_desc%gdt_tmpl(19) / 4, 2)
103 if (i_offset_odd /= i_offset_even) then
104 allocate(ip_rot_equid_cylind_egrid::grid)
105 else
106 allocate(ip_rot_equid_cylind_grid::grid)
107 end if
109 allocate(ip_mercator_grid::grid)
111 allocate(ip_polar_stereo_grid::grid)
113 allocate(ip_lambert_conf_grid::grid)
115 allocate(ip_gaussian_grid::grid)
117 allocate(ip_rot_equid_cylind_egrid::grid)
119 allocate(ip_rot_equid_cylind_grid::grid)
120 case default
121 print *, "gdt_num: ", g2_desc%gdt_num, " not recognized"
122 error stop
123 end select
124
125 call grid%init(g2_desc)
126 allocate(grid%descriptor, source = g2_desc)
127 end subroutine init_grid_grib2
128
129end module ip_grid_factory_mod
Users derived type grid descriptor objects to abstract away the raw GRIB1 and GRIB2 grid definitions.
Routines for creating an ip_grid given a Grib descriptor.
subroutine init_grid_generic(grid, grid_desc)
Initializes a polymorphic ip_grid object from an ip_grid_descriptor.
subroutine init_grid_grib2(grid, g2_desc)
Initializes a polymorphic ip_grid from a grib2_descriptor.
subroutine init_grid_grib1(grid, g1_desc)
Initializes a polymorphic ip_grid from a grib1_descriptor.
Abstract ip_grid type.
integer, parameter, public rot_equid_cylind_e_grid_id_grib2
Integer grid number for rotated equidistant cylindrical E-stagger grid (grib2)
integer, parameter, public lambert_conf_grid_id_grib2
Integer grid number for Lambert conformal grid in grib2.
integer, parameter, public gaussian_grid_id_grib2
Integer grid number for Gaussian grid in grib2.
integer, parameter, public equid_cylind_grid_id_grib2
Integer grid number for equidistant cylindrical grid in grib2.
integer, parameter, public gaussian_grid_id_grib1
Integer grid number for Gaussian grid in grib1.
integer, parameter, public rot_equid_cylind_e_grid_id_grib1
Integer grid number for rotated equidistant cylindrical E-stagger grid.
integer, parameter, public polar_stereo_grid_id_grib2
Integer grid number for polar stereo grid in grib2.
integer, parameter, public lambert_conf_grid_id_grib1
Integer grid number for Lambert Conformal grid in grib1.
integer, parameter, public mercator_grid_id_grib1
Integer grid number for Mercator grid in grib1.
integer, parameter, public equid_cylind_grid_id_grib1
Integer grid number for equidistant cylindrical grid in grib1.
integer, parameter, public rot_equid_cylind_b_grid_id_grib1
Integer grid number for rotated equidistant cylindrical B-stagger grid.
integer, parameter, public rot_equid_cylind_b_grid_id_grib2
Integer grid number for rotated equidistant cylindrical B-stagger grid (grib2)
integer, parameter, public rot_equid_cylind_grid_id_grib2
Integer grid number for rotated equidistant cylindrical grid in grib2.
integer, parameter, public mercator_grid_id_grib2
Integer grid number for Mercator grid in grib2.
integer, parameter, public polar_stereo_grid_id_grib1
Integer grid number for polar stereo grid in grib1.
Re-export the individual grids.
Descriptor representing a grib1 grib descriptor section (GDS) with an integer array.
Grib-2 descriptor containing a grib2 GDT represented by an integer array.
Abstract descriptor object which represents a grib1 or grib2 descriptor.
Abstract grid that holds fields and methods common to all grids.