NCEPLIBS-ip 5.3.0
All Data Structures Namespaces Files Functions Variables Pages
gdswzd_c.F90
Go to the documentation of this file.
1!> @file
2!> @brief C wrapper for routine gdswzd().
3!> @author JOVIC @date 2016-04-10
4
5!> @brief Module that contains C wrapper for routine gdswzd().
6!> @author JOVIC @date 2016-04-10
8 use gdswzd_mod
9 implicit none
10
11contains
12
13 !> C wrapper for routine gdswzd().
14 !>
15 !> Use this routine to call gdswzd() from a C or C++ program. Takes
16 !> advantage of the fortran/c interoperability standard.
17 !>
18 !> ### Program History Log
19 !> Date | Programmer | Comments
20 !> -----|------------|---------
21 !> 2016-04-10 | Jovic | initial version.
22 !> 2016-04-26 | G. Gayno | update for grib 2
23 !>
24 !> ### Example: Mixed precsion iplib call
25 !>
26 !> @code
27 !> include "iplib.h"
28 !>
29 !> int *igdtmpl;
30 !> int igdtnum, igdtlen, iopt, npts, nret;
31 !> double fill;
32 !> double *xpts, *ypts, *rlon, *rlat;
33 !> double *crot, *srot, *xlon, *xlat, *ylon, *ylat, *area;
34 !>
35 !> gdswzd(igdtnum, igdtmpl, igdtlen, iopt, npts,
36 !> fill, xpts, ypts, rlon, rlat,
37 !> &nret, crot, srot, xlon,
38 !> xlat, ylon, ylat, area);
39 !> @endcode
40 !>
41 !> @param[in] igdtnum grid definition template number. Corresponds
42 !> to the gfld%igdtnum component of the ncep g2 library gridmod data
43 !> structure.
44 !> - 00 equidistant cylindrical
45 !> - 01 rotated equidistant cylindrical. "e" and non-"e" staggered
46 !> - 10 mercator cyclindrical
47 !> - 20 polar stereographic azimuthal
48 !> - 30 lambert conformal conical
49 !> - 40 gaussian equidistant cyclindrical
50 !> @param[in] igdtmpl (igdtlen) grid definition template array.
51 !> corresponds to the gfld%igdtmpl component of the ncep g2 library
52 !> gridmod data structure for section three.
53 !> all projections:
54 !> - 1 shape of earth, octet 15
55 !> - 2 scale factor of spherical earth radius, octet 16
56 !> - 3 scaled value of radius of spherical earth, octets 17-20
57 !> - 4 scale factor of major axis of elliptical earth, octet 21
58 !> - 5 scaled value of major axis of elliptical earth, octets 22-25
59 !> - 6 scale factor of minor axis of elliptical earth, octet 26
60 !> - 7 scaled value of minor axis of elliptical earth, octets 27-30
61 !> equidistant cyclindrical:
62 !> - 8 number of points along a parallel, octs 31-34
63 !> - 9 number of points along a meridian, octs 35-38
64 !> - 10 basic angle of initial production domain, octets 39-42.
65 !> - 11 subdivisions of basic angle, octets 43-46
66 !> - 12 latitude of first grid point, octets 47-50
67 !> - 13 longitude of first grid point, octets 51-54
68 !> - 14 resolution and component flags, octet 55
69 !> - 15 latitude of last grid point, octets 56-59
70 !> - 16 longitude of last grid point, octets 60-63
71 !> - 17 i-direction increment, octets 64-67
72 !> - 18 j-direction increment, octets 68-71
73 !> - 19 scanning mode, octet 72
74 !> mercator cyclindrical:
75 !> - 8 number of points along a parallel, octs 31-34
76 !> - 9 number of points along a meridian, octs 35-38
77 !> - 10 latitude of first point, octets 39-42
78 !> - 11 longitude of first point, octets 43-46
79 !> - 12 resolution and component flags, octet 47
80 !> - 13 tangent latitude, octets 48-51
81 !> - 14 latitude of last point, octets 52-55
82 !> - 15 longitude of last point, octets 56-59
83 !> - 16 scanning mode flags, octet 60
84 !> - 17 orientation of grid, octets 61-64
85 !> - 18 longitudinal grid length, octets 65-68
86 !> - 19 latitudinal grid length, octets 69-72
87 !> Lambert conformal conical:
88 !> - 8 number of points along x-axis, octs 31-34
89 !> - 9 number of points along y-axis, octs 35-38
90 !> - 10 latitude of first point, octets 39-42
91 !> - 11 longitude of first point, octets 43-46
92 !> - 12 resolution of component flag, octet 47
93 !> - 13 latitude where grid lengths specified, octets 48-51
94 !> - 14 longitude of meridian that is parallel to y-axis, octets 52-55
95 !> - 15 x-direction grid length, octets 56-59
96 !> - 16 y-direction grid length, octets 60-63
97 !> - 17 projection center flag, octet 64
98 !> - 18 scanning mode, octet 65
99 !> - 19 first tangent latitude from pole, octets 66-69
100 !> - 20 second tangent latitude from pole, octets 70-73
101 !> - 21 latitude of south pole of projection, octets 74-77
102 !> - 22 longitude of south pole of projection, octets 78-81
103 !> gaussian cylindrical:
104 !> - 8 number of points along a parallel, octs 31-34
105 !> - 9 number of points along a meridian, octs 35-38
106 !> - 10 basic angle of initial production domain, octets 39-42
107 !> - 11 subdivisions of basic angle, octets 43-46
108 !> - 12 latitude of first grid point, octets 47-50
109 !> - 13 longitude of first grid point, octets 51-54
110 !> - 14 resolution and component flags, octet 55
111 !> - 15 latitude of last grid point, octets 56-59
112 !> - 16 longitude of last grid point, octets 60-63
113 !> - 17 i-direction increment, octets 64-67
114 !> - 18 number of parallels between pole and equator, octets 68-71
115 !> - 19 scanning mode, octet 72
116 !> polar stereographic azimuthal:
117 !> - 8 number of points along x-axis, octets 31-34
118 !> - 9 number of points along y-axis, octets 35-38
119 !> - 10 latitude of first grid point, octets 39-42
120 !> - 11 longitude of first grid point, octets 43-46
121 !> - 12 resolution and component flags, octet 47
122 !> - 13 true latitude, octets 48-51
123 !> - 14 orientation longitude, octets 52-55
124 !> - 15 x-direction grid length, octets 56-59
125 !> - 16 y-direction grid length, octets 60-63
126 !> - 17 projection center flag, octet 64
127 !> - 18 scanning mode flags, octet 65
128 !> rotated equidistant cyclindrical:
129 !> - 8 number of points along a parallel, octs 31-34
130 !> - 9 number of points along a meridian, octs 35-38
131 !> - 10 basic angle of initial production domain, octets 39-42
132 !> - 11 subdivisions of basic angle, octets 43-46
133 !> - 12 latitude of first grid point, octets 47-50
134 !> - 13 longitude of first grid point, octets 51-54
135 !> - 14 resolution and component flags, octet 55
136 !> - 15 latitude of last grid point, octets 56-59
137 !> - 16 longitude of last grid point, octets 60-63
138 !> - 17 i-direction increment, octets 64-67
139 !> - 18 j-direction increment, octets 68-71
140 !> - 19 scanning mode, octet 72
141 !> - 20 latitude of southern pole of projection, octets 73-76
142 !> - 21 longitude of southern pole of projection, octets 77-80
143 !> - 22 angle of rotation of projection, octs 81-84
144 !> @param[in] igdtlen number of elements of the grid definition
145 !> template array. Corresponds to the gfld%igdtlen component of the
146 !> ncep g2 library gridmod data structure.
147 !> @param[in] iopt option flag
148 !> - 0 to compute earth coords of all the grid points
149 !> - 1 to compute earth coords of selected grid coords
150 !> - -1 to compute grid coords of selected earth coords
151 !> @param[in] npts integer maximum number of coordinates
152 !> @param[in] fill real fill value to set invalid output data (must
153 !> be impossible value; suggested value: -9999.)
154 !> @param[inout] xpts real (npts) grid x point coordinates if iopt>0
155 !> @param[inout] ypts real (npts) grid y point coordinates if iopt>0
156 !> @param[inout] rlon real (npts) earth longitudes in degrees e if
157 !> iopt<0 (acceptable range: -360. to 360.)
158 !> @param[inout] rlat real (npts) earth latitudes in degrees n if
159 !> iopt<0 (acceptable range: -90. to 90.)
160 !> @param[out] nret number of valid points computed (-1 if
161 !> projection unrecognized)
162 !> @param[out] crot (npts) clockwise vector rotation cosines
163 !> @param[out] srot (npts) clockwise vector rotation sines
164 !> (ugrid=crot*uearth-srot*vearth, vgrid=srot*uearth+crot*vearth)
165 !> @param[out] xlon (npts) dx/dlon in 1/degrees
166 !> @param[out] xlat (npts) dx/dlat in 1/degrees
167 !> @param[out] ylon (npts) dy/dlon in 1/degrees
168 !> @param[out] ylat (npts) dy/dlat in 1/degrees
169 !> @param[out] AREA (npts) area weights in m**2 (Proportional to the
170 !> square of the map factor in the case of conformal projections.)
171 !>
172 !> @author JOVIC @date 2016-04-10
173 SUBROUTINE gdswzd_c(IGDTNUM,IGDTMPL,IGDTLEN,IOPT,NPTS,FILL, &
174 XPTS,YPTS,RLON,RLAT,NRET,CROT,SROT, &
175 XLON,XLAT,YLON,YLAT,AREA) bind(C, NAME='gdswzd')
176 use, INTRINSIC :: iso_c_binding
177
178 USE gdswzd_mod
179
180 IMPLICIT NONE
181
182#if (LSIZE==8)
183 INTEGER(KIND=C_LONG), INTENT(IN) :: IGDTMPL(IGDTLEN)
184 INTEGER(KIND=C_LONG), VALUE, INTENT(IN) :: IGDTNUM, IGDTLEN
185 INTEGER(KIND=C_LONG), VALUE, INTENT(IN) :: IOPT, NPTS
186 INTEGER(KIND=C_LONG), INTENT(OUT) :: NRET
187#else
188 INTEGER(KIND=C_INT), INTENT(IN) :: IGDTMPL(IGDTLEN)
189 INTEGER(KIND=C_INT), VALUE, INTENT(IN) :: IGDTNUM, IGDTLEN
190 INTEGER(KIND=C_INT), VALUE, INTENT(IN) :: IOPT, NPTS
191 INTEGER(KIND=C_INT), INTENT(OUT) :: NRET
192#endif
193
194#if (LSIZE==4)
195 REAL(KIND=c_float), VALUE, INTENT(IN) :: fill
196 REAL(KIND=c_float), INTENT(INOUT) :: xpts(npts),ypts(npts),rlon(npts),rlat(npts)
197 REAL(KIND=c_float), INTENT(OUT) :: crot(npts),srot(npts),xlon(npts),xlat(npts)
198 REAL(KIND=c_float), INTENT(OUT) :: ylon(npts),ylat(npts),area(npts)
199#else
200 REAL(KIND=c_double), VALUE, INTENT(IN) :: fill
201 REAL(KIND=c_double), INTENT(INOUT) :: xpts(npts),ypts(npts),rlon(npts),rlat(npts)
202 REAL(KIND=c_double), INTENT(OUT) :: crot(npts),srot(npts),xlon(npts),xlat(npts)
203 REAL(KIND=c_double), INTENT(OUT) :: ylon(npts),ylat(npts),area(npts)
204#endif
205
206 CALL gdswzd(igdtnum,igdtmpl,igdtlen,iopt,npts,fill, &
207 xpts,ypts,rlon,rlat,nret, &
208 crot,srot,xlon,xlat,ylon,ylat,area)
209
210 END SUBROUTINE gdswzd_c
211
212 !> C wrapper for routine gdswzd.
213 !> Use this routine to call 'gdswzd' from a C or C++ program.
214 !> Takes advantage of the fortran/c interoperability standard.
215 !>
216 !> ### Example: mixed precsion iplib call
217 !>@code
218 !> include "iplib.h"
219 !>
220 !> int kgds[200];
221 !> int iopt, npts, nret;
222 !> double fill;
223 !> double *xpts, *ypts, *rlon, *rlat;
224 !> double *crot, *srot, *xlon, *xlat, *ylon, *ylat, *area;
225 !>
226 !> gdswzd(kgds, iopt, npts, fill,
227 !> xpts, ypts, rlon, rlat,
228 !> &nret, crot, srot, xlon,
229 !> xlat, ylon, ylat, area);
230 !> @endcode
231 !>
232 !> @param kgds (200) gds parameters as decoded by [w3fi63](https://noaa-emc.github.io/NCEPLIBS-w3emc/w3fi63_8f.html).
233 !> @param iopt option flag
234 !> - 0 to compute earth coords of all the grid points
235 !> - 1 to compute earth coords of selected grid coords
236 !> - -1 to compute grid coords of selected earth coords
237 !> @param npts maximum number of coordinates
238 !> @param fill fill value to set invalid output data (must be
239 !> impossible value; suggested value: -9999.)
240 !> @param xpts (npts) grid x point coordinates if iopt>0
241 !> @param ypts (npts) grid y point coordinates if iopt>0
242 !> @param[out] rlon (npts) earth longitudes in degrees e if iopt<0
243 !> (acceptable range: -360. to 360.)
244 !> @param[out] rlat (npts) earth latitudes in degrees n if iopt<0
245 !> (acceptable range: -90. to 90.)
246 !> @param[out] nret number of valid points computed (-1 if
247 !> projection unrecognized)
248 !> @param[out] crot (npts) clockwise vector rotation cosines
249 !> @param[out] srot (npts) clockwise vector rotation sines
250 !> (ugrid=crot*uearth-srot*vearth; vgrid=srot*uearth+crot*vearth)
251 !> @param[out] xlon (npts) dx/dlon in 1/degrees
252 !> @param[out] xlat (npts) dx/dlat in 1/degrees
253 !> @param[out] ylon (npts) dy/dlon in 1/degrees
254 !> @param[out] ylat (npts) dy/dlat in 1/degrees
255 !> @param[out] area (npts) area weights in m**2 (proportional to the
256 !> square of the map factor in the case of conformal projections.)
257 !>
258 !> @author JOVIC @date 2016-04-10
259 SUBROUTINE gdswzd_c_grib1(KGDS,IOPT,NPTS,FILL,XPTS,YPTS,RLON,RLAT,NRET, &
260 CROT,SROT,XLON,XLAT,YLON,YLAT,AREA) bind(C, NAME='gdswzd_grib1')
261 use, INTRINSIC :: iso_c_binding
262
263 USE gdswzd_mod
264
265 IMPLICIT NONE
266
267#if (LSIZE==8)
268 INTEGER(KIND=C_LONG), INTENT(IN) :: KGDS(200)
269 INTEGER(KIND=C_LONG), VALUE, INTENT(IN) :: IOPT
270 INTEGER(KIND=C_LONG), VALUE, INTENT(IN) :: NPTS
271 INTEGER(KIND=C_LONG), INTENT(OUT) :: NRET
272#else
273 INTEGER(KIND=C_INT), INTENT(IN) :: KGDS(200)
274 INTEGER(KIND=C_INT), VALUE, INTENT(IN) :: IOPT
275 INTEGER(KIND=C_INT), VALUE, INTENT(IN) :: NPTS
276 INTEGER(KIND=C_INT), INTENT(OUT) :: NRET
277#endif
278
279#if (LSIZE==4)
280 REAL(KIND=c_float), VALUE, INTENT(IN) :: fill
281 REAL(KIND=c_float), INTENT(INOUT) :: xpts(npts),ypts(npts),rlon(npts),rlat(npts)
282 REAL(KIND=c_float), INTENT(OUT) :: crot(npts),srot(npts),xlon(npts),xlat(npts)
283 REAL(KIND=c_float), INTENT(OUT) :: ylon(npts),ylat(npts),area(npts)
284#else
285 REAL(KIND=c_double), VALUE, INTENT(IN) :: fill
286 REAL(KIND=c_double), INTENT(INOUT) :: xpts(npts),ypts(npts),rlon(npts),rlat(npts)
287 REAL(KIND=c_double), INTENT(OUT) :: crot(npts),srot(npts),xlon(npts),xlat(npts)
288 REAL(KIND=c_double), INTENT(OUT) :: ylon(npts),ylat(npts),area(npts)
289#endif
290
291 CALL gdswzd(kgds,iopt,npts,fill,xpts,ypts,rlon,rlat,nret, &
292 crot,srot,xlon,xlat,ylon,ylat,area)
293
294 END SUBROUTINE gdswzd_c_grib1
295
296end module gdswzd_c_mod
Module that contains C wrapper for routine gdswzd().
Definition gdswzd_c.F90:7
subroutine gdswzd_c(igdtnum, igdtmpl, igdtlen, iopt, npts, fill, xpts, ypts, rlon, rlat, nret, crot, srot, xlon, xlat, ylon, ylat, area)
C wrapper for routine gdswzd().
Definition gdswzd_c.F90:176
subroutine gdswzd_c_grib1(kgds, iopt, npts, fill, xpts, ypts, rlon, rlat, nret, crot, srot, xlon, xlat, ylon, ylat, area)
C wrapper for routine gdswzd.
Definition gdswzd_c.F90:261
Driver module for gdswzd routines.