NCEPLIBS-bufr  12.2.0
All Data Structures Namespaces Files Functions Variables Macros Pages
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 #include "rpseqs.h"
14 
29 void
30 arallocc(void)
31 {
32  char brtstr[50] = "BUFRLIB: ARALLOCC FAILED ALLOCATING";
33 
34  int nfiles;
35 
36  int mxmtbb;
37  int mxmtbd;
38  int maxcd;
39  int mxnaf;
40 
41  /* cread arrays */
42 
43  nfiles = igetprm_f("NFILES");
44 
45  if (!(pb = malloc((nfiles+1) * sizeof(FILE *)))) bort_f(brtstr);
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  if (!(cbscl_c = malloc(mxmtbb * 4 * sizeof(char)))) bort_f(brtstr);
57  if (!(cbsref_c = malloc(mxmtbb * 12 * sizeof(char)))) bort_f(brtstr);
58  if (!(cbbw_c = malloc(mxmtbb * 4 * sizeof(char)))) bort_f(brtstr);
59  if (!(cbunit_c = malloc(mxmtbb * 24 * sizeof(char)))) bort_f(brtstr);
60  if (!(cbmnem_c = malloc(mxmtbb * 8 * sizeof(char)))) bort_f(brtstr);
61  if (!(cbelem_c = malloc(mxmtbb * 120 * sizeof(char)))) bort_f(brtstr);
62  if (!(idfxyn_c = malloc(mxmtbd * sizeof(int)))) bort_f(brtstr);
63  if (!(cdseq_c = malloc(mxmtbd * 120 * sizeof(char)))) bort_f(brtstr);
64  if (!(cdmnem_c = malloc(mxmtbd * 8 * sizeof(char)))) bort_f(brtstr);
65  if (!(ndelem_c = malloc(mxmtbd * sizeof(int)))) bort_f(brtstr);
66  if (!(idefxy_c = malloc(mxmtbd * maxcd * sizeof(int)))) bort_f(brtstr);
67  if (!(iafpk = malloc(mxnaf * sizeof(int)))) bort_f(brtstr);
68 
69  /* rpseqs arrays */
70 
71  if (!(cdescs = malloc(MAX_RPSQ * maxcd * sizeof(int)))) bort_f(brtstr);
72  if (!(iafpks = malloc(MAX_RPSQ * mxnaf * sizeof(int)))) bort_f(brtstr);
73 }
74 
82 void
83 ardllocc(void)
84 {
85  /* cread arrays */
86 
87  free( pb );
88  free( lstpos );
89 
90  /* mstabs arrays */
91 
92  free( ibfxyn_c );
93  free( cbscl_c );
94  free( cbsref_c );
95  free( cbbw_c );
96  free( cbunit_c );
97  free( cbmnem_c );
98  free( cbelem_c );
99  free( idfxyn_c );
100  free( cdseq_c );
101  free( cdmnem_c );
102  free( ndelem_c );
103  free( idefxy_c );
104  free( iafpk );
105 
106  /* rpseqs arrays */
107 
108  free( cdescs );
109  free( iafpks );
110 
111  /* master Code/Flag table entries */
112 
113  dlloctbf();
114 }
void arallocc(void)
Dynamically allocate C language arrays.
Definition: arallocc.c:30
void ardllocc(void)
Free all memory that was dynamically allocated during a previous call to subroutine arallocc().
Definition: arallocc.c:83
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.
void dlloctbf(void)
Free all dynamically-allocated memory for internal storage of master Code/Flag table entries.
Definition: cfe.c:81
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.
Declare variables for internal storage of replication sequences.
int * cdescs
Child descriptors for each entry.
#define MAX_RPSQ
Maximum number of entries in internal replication sequences cache.
Definition: rpseqs.h:15
int * iafpks
Associated fields in effect for each entry.