OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
alloc_aer.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "aer_struc.h"
5 #include "l12_parms.h"
6 
7 /* --------------------------------------------------------- */
8 /* alloc_aer() - allocates 1 aerosol record to hold data */
9 /* for a single scan of "npix" pixels. */
10 
11 /* --------------------------------------------------------- */
12 int alloc_aer(int32_t npix, int32_t nbands, aestr *rec) {
13  char *p;
14  int32_t len = 2 * sizeof (int32_t) * npix /* model # */
15  + 1 * sizeof (float)*npix /* model ratio */
16  + 1 * nbands * sizeof (float)*npix; /* taua */
17 
18  if ((p = (char *) malloc(len)) == NULL) {
19  fprintf(stderr,
20  "-E- %s line %d: Memory allocation failure.\n",
21  __FILE__, __LINE__);
22  return (0);
23  }
24  memset(p, '\0', len);
25 
26  rec->length = len;
27  rec->npix = npix;
28  rec->data = p;
29 
30  rec->mod_min = (int32_t *) p;
31  p += sizeof (int32_t) * npix;
32  rec->mod_max = (int32_t *) p;
33  p += sizeof (int32_t) * npix;
34  rec->mod_rat = (float *) p;
35  p += sizeof (float)*npix;
36  rec->taua = (float *) p;
37  p += sizeof (float)*npix*nbands;
38 
39  return (len);
40 }
int alloc_aer(int32_t npix, int32_t nbands, aestr *rec)
Definition: alloc_aer.c:12
#define NULL
Definition: decode_rs.h:63
int32_t nbands
int npix
Definition: get_cmp.c:27
float p[MODELMAX]
Definition: atrem_corl1.h:131