NCEPLIBS-bufr 11.7.1
arallocc.c
Go to the documentation of this file.
1
5#include "bufrlib.h"
6#define IN_ARALLOCC
7#include "cread.h"
8#include "mstabs.h"
9
36void arallocc( void )
37{
38
39 char brtstr[50] = "BUFRLIB: ARALLOCC FAILED ALLOCATING ";
40
41 f77int nfiles;
42
43 f77int mxmtbb;
44 f77int mxmtbd;
45 f77int maxcd;
46
47/*
48** cread arrays
49*/
50
51 nfiles = igetprm( "NFILES", 6 );
52
53 if ( ( pb = malloc( (nfiles+1) * sizeof(FILE *) ) ) == NULL ) {
54 strcat( brtstr, "PB" );
55 bort( brtstr, ( f77int ) strlen( brtstr ) );
56 }
57
58 if ( ( lstpos = malloc( (nfiles+1) * sizeof(fpos_t) ) ) == NULL ) {
59 strcat( brtstr, "LSTPOS" );
60 bort( brtstr, ( f77int ) strlen( brtstr ) );
61 }
62
63/*
64** mstabs arrays
65*/
66
67 mxmtbb = igetprm( "MXMTBB", 6 );
68 mxmtbd = igetprm( "MXMTBD", 6 );
69 maxcd = igetprm( "MAXCD", 5 );
70
71 if ( ( MSTABS_BASE(ibfxyn) = malloc( mxmtbb * sizeof(f77int) ) ) == NULL ) {
72 strcat( brtstr, "IBFXYN" );
73 bort( brtstr, ( f77int ) strlen( brtstr ) );
74 }
75
76 if ( ( MSTABS_BASE(cbscl) = malloc( mxmtbb * 4 * sizeof(char) ) ) == NULL ) {
77 strcat( brtstr, "CBSCL" );
78 bort( brtstr, ( f77int ) strlen( brtstr ) );
79 }
80
81 if ( ( MSTABS_BASE(cbsref) = malloc( mxmtbb * 12 * sizeof(char) ) ) == NULL ) {
82 strcat( brtstr, "CBSREF" );
83 bort( brtstr, ( f77int ) strlen( brtstr ) );
84 }
85
86 if ( ( MSTABS_BASE(cbbw) = malloc( mxmtbb * 4 * sizeof(char) ) ) == NULL ) {
87 strcat( brtstr, "CBBW" );
88 bort( brtstr, ( f77int ) strlen( brtstr ) );
89 }
90
91 if ( ( MSTABS_BASE(cbunit) = malloc( mxmtbb * 24 * sizeof(char) ) ) == NULL ) {
92 strcat( brtstr, "CBUNIT" );
93 bort( brtstr, ( f77int ) strlen( brtstr ) );
94 }
95
96 if ( ( MSTABS_BASE(cbmnem) = malloc( mxmtbb * 8 * sizeof(char) ) ) == NULL ) {
97 strcat( brtstr, "CBMNEM" );
98 bort( brtstr, ( f77int ) strlen( brtstr ) );
99 }
100
101 if ( ( MSTABS_BASE(cbelem) = malloc( mxmtbb * 120 * sizeof(char) ) ) == NULL ) {
102 strcat( brtstr, "CBELEM" );
103 bort( brtstr, ( f77int ) strlen( brtstr ) );
104 }
105
106 if ( ( MSTABS_BASE(idfxyn) = malloc( mxmtbd * sizeof(f77int) ) ) == NULL ) {
107 strcat( brtstr, "IDFXYN" );
108 bort( brtstr, ( f77int ) strlen( brtstr ) );
109 }
110
111 if ( ( MSTABS_BASE(cdseq) = malloc( mxmtbd * 120 * sizeof(char) ) ) == NULL ) {
112 strcat( brtstr, "CDSEQ" );
113 bort( brtstr, ( f77int ) strlen( brtstr ) );
114 }
115
116 if ( ( MSTABS_BASE(cdmnem) = malloc( mxmtbd * 8 * sizeof(char) ) ) == NULL ) {
117 strcat( brtstr, "CDMNEM" );
118 bort( brtstr, ( f77int ) strlen( brtstr ) );
119 }
120
121 if ( ( MSTABS_BASE(ndelem) = malloc( mxmtbd * sizeof(f77int) ) ) == NULL ) {
122 strcat( brtstr, "NDELEM" );
123 bort( brtstr, ( f77int ) strlen( brtstr ) );
124 }
125
126 if ( ( MSTABS_BASE(idefxy) = malloc( mxmtbd * maxcd * sizeof(f77int) ) ) == NULL ) {
127 strcat( brtstr, "IDEFXY" );
128 bort( brtstr, ( f77int ) strlen( brtstr ) );
129 }
130
131}
void arallocc(void)
This subroutine is called internally during the first call to subroutine openbf() from an application...
Definition: arallocc.c:36
subroutine bort(STR)
This subroutine calls subroutine errwrt() to log an error message, then calls subroutine bort_exit() ...
Definition: bort.f:23
Define signatures to enable a number of BUFRLIB subprograms to be called directly from C application ...
Define signatures and declare variables for reading or writing BUFR messages via a C language interfa...
FILE ** pb
File pointers.
fpos_t * lstpos
Byte positions of last successful reads from files corresponding to pb, for files that were opened fo...
integer function igetprm(CPRMNM)
This function returns the current value of a parameter used for allocating one or more internal array...
Definition: igetprm.f:84
Define signatures and declare variables for internal storage of master Table B and Table D entries.
integer, dimension(:), allocatable ndelem
Numbers of child descriptors corresponding to idfxyn.
Definition: moda_mstabs.F:72
integer, dimension(:), allocatable idfxyn
Bit-wise representations of FXY numbers for master Table D.
Definition: moda_mstabs.F:69
character, dimension(:,:), allocatable cdseq
Sequence names corresponding to idfxyn.
Definition: moda_mstabs.F:70
integer, dimension(:), allocatable idefxy
Bit-wise representations of child descriptors corresponding to idfxyn.
Definition: moda_mstabs.F:73
character, dimension(:,:), allocatable cbscl
Scale factors corresponding to ibfxyn.
Definition: moda_mstabs.F:63
character, dimension(:,:), allocatable cbmnem
Mnemonics corresponding to ibfxyn.
Definition: moda_mstabs.F:67
character, dimension(:,:), allocatable cbsref
Reference values corresponding to ibfxyn.
Definition: moda_mstabs.F:64
character, dimension(:,:), allocatable cbelem
Element names corresponding to ibfxyn.
Definition: moda_mstabs.F:68
character, dimension(:,:), allocatable cbunit
Units corresponding to ibfxyn.
Definition: moda_mstabs.F:66
character, dimension(:,:), allocatable cdmnem
Mnemonics corresponding to idfxyn.
Definition: moda_mstabs.F:71
integer, dimension(:), allocatable ibfxyn
Bit-wise representations of FXY numbers for master Table B.
Definition: moda_mstabs.F:62
character, dimension(:,:), allocatable cbbw
Bit widths corresponding to ibfxyn.
Definition: moda_mstabs.F:65
integer, public maxcd
Maximum number of child descriptors that can be included within the sequence definition of a Table D ...
Definition: modv_MAXCD.f90:18
integer mxmtbb
Maximum number of entries in a master BUFR Table B.
Definition: modv_MXMTBB.f:18
integer mxmtbd
Maximum number of entries in a master BUFR Table D.
Definition: modv_MXMTBD.f:18
integer, public nfiles
Maximum number of BUFR files that can be connected to the BUFRLIB software (for reading or writing) a...
Definition: modv_NFILES.f90:17