-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdmrpkgc2.c
67 lines (56 loc) · 2.68 KB
/
dmrpkgc2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "geminc.h"
#include "gemprm.h"
void dm_rpkgc2_ ( int *iflno, int *iiword, int *lendat,
int *iarray, float *rarray, int *kxky,
float *rdata, int *iret )
/************************************************************************
* dm_rpkgc2 *
* *
* This is a subfunction to the DM library function DM_RPKG which reads *
* packed gridded data from a file and unpacks the data according to *
* the GRIB2 packing type. *
* This functionality has been isolated and written in 'C' *
* to allow for the dynamic allocation of buffer memory. *
* *
* dm_rpkgc2 ( iflno, iiword, lendat, iarray, rarray, kxky, *
* rdata, iret ) *
* *
* Input parameters: *
* *iflno int File number (from FORTRAN) *
* *iiword int Starting word *
* *lendat int Number of words *
* *iarray int int type packing information *
* *rarray float float type packing information *
* *
* Output parameters: *
* *kxky int Number of grid points unpacked *
* *rdata float Grid data *
* *iret int Return code *
* = 0 - normal *
* = -31 - unknown packing type *
* = -35 - problem w/ mem alloc *
** *
* Log: *
* D.W.Plummer/NCEP 9/06 Created *
* S. Chiswell/Unidata 12/06 Modified from DM_RPKGC *
************************************************************************/
{
int *ksgrid;
/*---------------------------------------------------------------------*/
*iret = 0;
G_MALLOC ( ksgrid, int, *lendat, "Error allocating ksgrid in dm_rpkgc2" );
if ( ksgrid == (int *)NULL ) {
*iret = -35;
}
else {
/*
* Read the packed data from the file.
*/
dm_rint_ ( iflno, iiword, lendat, ksgrid, iret );
/*
* Unpack the data
*/
dp_ugb2_ ( ksgrid, iarray, rarray, kxky, rdata, iret );
G_FREE ( ksgrid, int );
}
}