NCEPLIBS-bufr  12.1.0
arallocc.c
Go to the documentation of this file.
1 
6 #include "bufrlib.h"
7 
9 #define IN_ARALLOCC
10 
11 #include "cread.h"
12 #include "mstabs.h"
13 
28 void
29 arallocc(void)
30 {
31  char brtstr[50] = "BUFRLIB: ARALLOCC FAILED ALLOCATING";
32 
33  int nfiles;
34 
35  int mxmtbb;
36  int mxmtbd;
37  int maxcd;
38  int mxnaf;
39 
40  /* cread arrays */
41 
42  nfiles = igetprm_f("NFILES");
43 
44  if (!(pb = malloc((nfiles+1) * sizeof(FILE *)))) bort_f(brtstr);
45 
46  if (!(lstpos = malloc((nfiles+1) * sizeof(fpos_t)))) bort_f(brtstr);
47 
48  /* mstabs arrays */
49 
50  mxmtbb = igetprm_f("MXMTBB");
51  mxmtbd = igetprm_f("MXMTBD");
52  maxcd = igetprm_f("MAXCD");
53  mxnaf = igetprm_f("MXNAF");
54 
55  if (!(ibfxyn_c = malloc(mxmtbb * sizeof(int)))) bort_f(brtstr);
56 
57  if (!(cbscl_c = malloc(mxmtbb * 4 * sizeof(char)))) bort_f(brtstr);
58 
59  if (!(cbsref_c = malloc(mxmtbb * 12 * sizeof(char)))) bort_f(brtstr);
60 
61  if (!(cbbw_c = malloc(mxmtbb * 4 * sizeof(char)))) bort_f(brtstr);
62 
63  if (!(cbunit_c = malloc(mxmtbb * 24 * sizeof(char)))) bort_f(brtstr);
64 
65  if (!(cbmnem_c = malloc(mxmtbb * 8 * sizeof(char)))) bort_f(brtstr);
66 
67  if (!(cbelem_c = malloc(mxmtbb * 120 * sizeof(char)))) bort_f(brtstr);
68 
69  if (!(idfxyn_c = malloc(mxmtbd * sizeof(int)))) bort_f(brtstr);
70 
71  if (!(cdseq_c = malloc(mxmtbd * 120 * sizeof(char)))) bort_f(brtstr);
72 
73  if (!(cdmnem_c = malloc(mxmtbd * 8 * sizeof(char)))) bort_f(brtstr);
74 
75  if (!(ndelem_c = malloc(mxmtbd * sizeof(int)))) bort_f(brtstr);
76 
77  if (!(idefxy_c = malloc(mxmtbd * maxcd * sizeof(int)))) bort_f(brtstr);
78 
79  if (!(iafpk = malloc(mxnaf * sizeof(int)))) bort_f(brtstr);
80 }
81 
89 void
90 ardllocc(void)
91 {
92  /* cread arrays */
93 
94  free( pb );
95  free( lstpos );
96 
97  /* mstabs arrays */
98 
99  free( ibfxyn_c );
100  free( cbscl_c );
101  free( cbsref_c );
102  free( cbbw_c );
103  free( cbunit_c );
104  free( cbmnem_c );
105  free( cbelem_c );
106  free( idfxyn_c );
107  free( cdseq_c );
108  free( cdmnem_c );
109  free( ndelem_c );
110  free( idefxy_c );
111  free( iafpk );
112 }
void arallocc(void)
Dynamically allocate C language arrays.
Definition: arallocc.c:29
void ardllocc(void)
Free all memory that was dynamically allocated during a previous call to subroutine arallocc().
Definition: arallocc.c:90
int igetprm_f(char *cprmnm)
Get the current value of a parameter.
Enable a number of NCEPLIBS-bufr subprograms to be called from within the C part of the library.
void bort_f(char *errstr)
Log one error message and abort application program.
Declare variables for reading or writing BUFR messages via a C language interface.
FILE ** pb
File pointers.
fpos_t * lstpos
Byte positions of last successful reads from files corresponding to pb, for files that were opened fo...
Declare variables for internal storage of master Table B and Table D entries.
int * idefxy_c
WMO bit-wise representations of child descriptors for master Table D sequences; copied from Fortran i...
char(* cbsref_c)[12]
Master Table B reference values; copied from Fortran cbsref array.
char(* cbelem_c)[120]
Master Table B element names; copied from Fortran cbelem array.
int * idfxyn_c
WMO bit-wise representations of master Table D FXY numbers; copied from Fortran idfxyn array.
char(* cdmnem_c)[8]
Master Table D mnemonics; copied from Fortran cdmnem array.
char(* cdseq_c)[120]
Master Table D sequence names; copied from Fortran cdseq array.
char(* cbscl_c)[4]
Master Table B scale factors; copied from Fortran cbscl array.
char(* cbunit_c)[24]
Master Table B units; copied from Fortran cbunit array.
char(* cbmnem_c)[8]
Master Table B mnemonics; copied from Fortran cbmnem array.
char(* cbbw_c)[4]
Master Table B bit widths; copied from Fortran cbbw array.
int * iafpk
WMO bit-wise representations of associated fields within master Table D sequences.
int * ibfxyn_c
WMO bit-wise representations of master Table B FXY numbers; copied from Fortran ibfxyn array.
int * ndelem_c
Number of child descriptors for master Table D sequences; copied from Fortran ndelem array.