FV3 Bundle
adStack.c
Go to the documentation of this file.
1 static char adSid[]="$Id: adStack.c,v 1.1 2017/07/24 21:18:32 drholdaw Exp $";
2 
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
6 
7 /* The size of a BLOCK in characters */
8 #define ONE_BLOCK_SIZE 16384
9 #ifndef STACK_SIZE_TRACING
10 #define STACK_SIZE_TRACING 1
11 #endif
12 /* The main stack is a double-chain of DoubleChainedBlock objects.
13  * Each DoubleChainedBlock holds an array[ONE_BLOCK_SIZE] of char. */
14 typedef struct _doubleChainedBlock{
16  char *contents ;
19 
20 /* Globals that define the current position in the stack: */
22 static char *curStackTop = NULL ;
23 /* Globals that define the current LOOKing position in the stack: */
25 static char *lookStackTop = NULL ;
26 
27 static long int mmctraffic = 0 ;
28 static long int mmctrafficM = 0 ;
29 #ifdef STACK_SIZE_TRACING
30 long int bigStackSize = 0;
31 #endif
32 
33 int chcksum(char *contents, int len) {
34  int sum = 0 ;
35  int i ;
36  for (i=0 ; i<len ; ++i) sum += *(contents++) ;
37  return sum ;
38 }
39 
40 /* PUSHes "nbChars" consecutive chars from a location starting at address "x".
41  * Resets the LOOKing position if it was active.
42  * Checks that there is enough space left to hold "nbChars" chars.
43  * Otherwise, allocates the necessary space. */
44 void pushNarray(char *x, unsigned int nbChars) {
45  unsigned int nbmax = (curStack)?ONE_BLOCK_SIZE-(curStackTop-(curStack->contents)):0 ;
46 #ifdef STACK_SIZE_TRACING
47  bigStackSize += nbChars;
48 #endif
49 
50  mmctraffic += nbChars ;
51  while (mmctraffic >= 1000000) {
52  mmctraffic -= 1000000 ;
53  mmctrafficM++ ;
54  }
55 
56  lookStack = NULL ;
57  if (nbChars <= nbmax) {
58  memcpy(curStackTop,x,nbChars) ;
59  curStackTop+=nbChars ;
60  } else {
61  char *inx = x+(nbChars-nbmax) ;
62  if (nbmax>0) memcpy(curStackTop,inx,nbmax) ;
63  while (inx>x) {
64  if ((curStack == NULL) || (curStack->next == NULL)) {
65  /* Create new block: */
66  DoubleChainedBlock *newStack ;
67  char *contents = (char *)malloc(ONE_BLOCK_SIZE*sizeof(char)) ;
68  newStack = (DoubleChainedBlock*)malloc(sizeof(DoubleChainedBlock)) ;
69  if ((contents == NULL) || (newStack == NULL)) {
70  DoubleChainedBlock *stack = curStack ;
71  int nbBlocks = (stack?-1:0) ;
72  while(stack) {
73  stack = stack->prev ;
74  nbBlocks++ ;
75  }
76  printf("Out of memory (allocated %i blocks of %i bytes)\n",
77  nbBlocks, ONE_BLOCK_SIZE) ;
78  exit(0);
79  }
80  if (curStack != NULL) curStack->next = newStack ;
81  newStack->prev = curStack ;
82  newStack->next = NULL ;
83  newStack->contents = contents ;
84  curStack = newStack ;
85  /* new block created! */
86  } else
88 /* if (curStack->prev) {printf("+BLOCK sum:%i\n",chcksum(curStack->prev->contents,ONE_BLOCK_SIZE));} */
89  inx -= ONE_BLOCK_SIZE ;
90  if(inx>x)
91  memcpy(curStack->contents,inx,ONE_BLOCK_SIZE) ;
92  else {
93  unsigned int nbhead = (inx-x)+ONE_BLOCK_SIZE ;
95  memcpy(curStackTop,x,nbhead) ;
96  curStackTop += nbhead ;
97  }
98  }
99  }
100 }
101 
102 /* POPs "nbChars" consecutive chars to a location starting at address "x".
103  * Resets the LOOKing position if it was active.
104  * Checks that there is enough data to fill "nbChars" chars.
105  * Otherwise, pops as many blocks as necessary. */
106 void popNarray(char *x, unsigned int nbChars) {
107  unsigned int nbmax = curStackTop-(curStack->contents) ;
108 #ifdef STACK_SIZE_TRACING
109  bigStackSize -= nbChars;
110 #endif
111  lookStack = NULL ;
112  if (nbChars <= nbmax) {
113  curStackTop-=nbChars ;
114  memcpy(x,curStackTop,nbChars);
115  } else {
116  char *tlx = x+nbChars ;
117  if (nbmax>0) memcpy(x,curStack->contents,nbmax) ;
118  x+=nbmax ;
119  while (x<tlx) {
120 /* if (curStack->prev) {printf("-BLOCK sum:%i\n",chcksum(curStack->prev->contents,ONE_BLOCK_SIZE)) ;} */
121  curStack = curStack->prev ;
122  if (curStack==NULL) printf("Popping from an empty stack!!!\n") ;
123  if (x+ONE_BLOCK_SIZE<tlx) {
124  memcpy(x,curStack->contents,ONE_BLOCK_SIZE) ;
125  x += ONE_BLOCK_SIZE ;
126  } else {
127  unsigned int nbtail = tlx-x ;
129  memcpy(x,curStackTop,nbtail) ;
130  x = tlx ;
131  }
132  }
133  }
134 }
135 
136 /* LOOKs "nbChars" consecutive chars to a location starting at address "x".
137  * Activates the LOOKing position if it was reset.
138  * LOOKing is just like POPping, except that the main pointer
139  * remains in place, so that the value is not POPped.
140  * Further PUSHs or POPs will start from the same place as if
141  * no LOOK had been made. */
142 void lookNarray(char *x, unsigned int nbChars) {
143  unsigned int nbmax ;
144  if (lookStack == NULL) {
145  lookStack = curStack ;
147  }
148  nbmax = lookStackTop-(lookStack->contents) ;
149  if (nbChars <= nbmax) {
150  lookStackTop-=nbChars ;
151  memcpy(x,lookStackTop,nbChars);
152  } else {
153  char *tlx = x+nbChars ;
154  if (nbmax>0) memcpy(x,lookStack->contents,nbmax) ;
155  x+=nbmax ;
156  while (x<tlx) {
158  if (lookStack==NULL) printf("Looking into an empty stack!!!") ;
159  if (x+ONE_BLOCK_SIZE<tlx) {
160  memcpy(x,lookStack->contents,ONE_BLOCK_SIZE) ;
161  x += ONE_BLOCK_SIZE ;
162  } else {
163  unsigned int nbtail = tlx-x ;
165  memcpy(x,lookStackTop,nbtail) ;
166  x = tlx ;
167  }
168  }
169  }
170 }
171 
173  lookStack=NULL ;
174 }
175 
176 /****** Exported PUSH/POP/LOOK functions for ARRAYS: ******/
177 /* --> Called from FORTRAN: */
178 
179 void pushcharacterarray_(char *x, unsigned int *n) {
180  pushNarray(x,*n) ;
181 }
182 void popcharacterarray_(char *x, unsigned int *n) {
183  popNarray(x,*n) ;
184 }
185 void lookcharacterarray_(char *x, unsigned int *n) {
186  lookNarray(x,*n) ;
187 }
188 
189 void pushbooleanarray_(char *x, unsigned int *n) {
190  pushNarray(x,(*n*4)) ;
191 }
192 void popbooleanarray_(char *x, unsigned int *n) {
193  popNarray(x,(*n*4)) ;
194 }
195 void lookbooleanarray_(char *x, unsigned int *n) {
196  lookNarray(x,(*n*4)) ;
197 }
198 
199 void pushinteger4array_(void *x, unsigned int *n) {
200  pushNarray((char *)x,(*n*4)) ;
201 }
202 void popinteger4array_(void *x, unsigned int *n) {
203  popNarray((char *)x,(*n*4)) ;
204 }
205 void lookinteger4array_(void *x, unsigned int *n) {
206  lookNarray((char *)x,(*n*4)) ;
207 }
208 
209 void pushinteger8array_(void *x, unsigned int *n) {
210  pushNarray((char *)x,(*n*8)) ;
211 }
212 void popinteger8array_(void *x, unsigned int *n) {
213  popNarray((char *)x,(*n*8)) ;
214 }
215 void lookinteger8array_(void *x, unsigned int *n) {
216  lookNarray((char *)x,(*n*8)) ;
217 }
218 
219 void pushinteger16array_(void *x, unsigned int *n) {
220  pushNarray((char *)x,(*n*16)) ;
221 }
222 void popinteger16array_(void *x, unsigned int *n) {
223  popNarray((char *)x,(*n*16)) ;
224 }
225 void lookinteger16array_(void *x, unsigned int *n) {
226  lookNarray((char *)x,(*n*16)) ;
227 }
228 
229 void pushreal4array_(void *x, unsigned int *n) {
230  pushNarray((char *)x,(*n*4)) ;
231 }
232 void popreal4array_(void *x, unsigned int *n) {
233  popNarray((char *)x,(*n*4)) ;
234 }
235 void lookreal4array_(void *x, unsigned int *n) {
236  lookNarray((char *)x,(*n*4)) ;
237 }
238 
239 void pushreal8array_(void *x, unsigned int *n) {
240  pushNarray((char *)x,(*n*8)) ;
241 }
242 void popreal8array_(void *x, unsigned int *n) {
243  popNarray((char *)x,(*n*8)) ;
244 }
245 void lookreal8array_(void *x, unsigned int *n) {
246  lookNarray((char *)x,(*n*8)) ;
247 }
248 
249 void pushreal16array_(void *x, unsigned int *n) {
250  pushNarray((char *)x,(*n*16)) ;
251 }
252 void popreal16array_(void *x, unsigned int *n) {
253  popNarray((char *)x,(*n*16)) ;
254 }
255 void lookreal16array_(void *x, unsigned int *n) {
256  lookNarray((char *)x,(*n*16)) ;
257 }
258 
259 void pushreal32array_(void *x, unsigned int *n) {
260  pushNarray((char *)x,(*n*32)) ;
261 }
262 void popreal32array_(void *x, unsigned int *n) {
263  popNarray((char *)x,(*n*32)) ;
264 }
265 void lookreal32array_(void *x, unsigned int *n) {
266  lookNarray((char *)x,(*n*32)) ;
267 }
268 
269 void pushcomplex4array_(void *x, unsigned int *n) {
270  pushNarray((char *)x,(*n*4)) ;
271 }
272 void popcomplex4array_(void *x, unsigned int *n) {
273  popNarray((char *)x,(*n*4)) ;
274 }
275 void lookcomplex4array_(void *x, unsigned int *n) {
276  lookNarray((char *)x,(*n*4)) ;
277 }
278 
279 void pushcomplex8array_(void *x, unsigned int *n) {
280  pushNarray((char *)x,(*n*8)) ;
281 }
282 void popcomplex8array_(void *x, unsigned int *n) {
283  popNarray((char *)x,(*n*8)) ;
284 }
285 void lookcomplex8array_(void *x, unsigned int *n) {
286  lookNarray((char *)x,(*n*8)) ;
287 }
288 
289 void pushcomplex16array_(void *x, unsigned int *n) {
290  pushNarray((char *)x,(*n*16)) ;
291 }
292 void popcomplex16array_(void *x, unsigned int *n) {
293  popNarray((char *)x,(*n*16)) ;
294 }
295 void lookcomplex16array_(void *x, unsigned int *n) {
296  lookNarray((char *)x,(*n*16)) ;
297 }
298 
299 void pushcomplex32array_(void *x, unsigned int *n) {
300  pushNarray((char *)x,(*n*32)) ;
301 }
302 void popcomplex32array_(void *x, unsigned int *n) {
303  popNarray((char *)x,(*n*32)) ;
304 }
305 void lookcomplex32array_(void *x, unsigned int *n) {
306  lookNarray((char *)x,(*n*32)) ;
307 }
308 
309 
310 /* --> Called from C: */
311 
312 void pushcharacterarray(char *x, int n) {
313  pushNarray(x,(unsigned int)n) ;
314 }
315 void popcharacterarray(char *x, int n) {
316  popNarray(x,(unsigned int)n) ;
317 }
318 void lookcharacterarray(char *x, int n) {
319  lookNarray(x,(unsigned int)n) ;
320 }
321 
322 void pushbooleanarray(char *x, int n) {
323  pushNarray(x,(unsigned int)(n*4)) ;
324 }
325 void popbooleanarray(char *x, int n) {
326  popNarray(x,(unsigned int)(n*4)) ;
327 }
328 void lookbooleanarray(char *x, int n) {
329  lookNarray(x,(unsigned int)(n*4)) ;
330 }
331 
332 void pushinteger4array(int *x, int n) {
333  pushNarray((char *)x,(unsigned int)(n*4)) ;
334 }
335 void popinteger4array(int *x, int n) {
336  popNarray((char *)x,(unsigned int)(n*4)) ;
337 }
338 void lookinteger4array(int *x, int n) {
339  lookNarray((char *)x,(unsigned int)(n*4)) ;
340 }
341 
342 void pushinteger8array(long int *x, int n) {
343  pushNarray((char *)x,(unsigned int)(n*8)) ;
344 }
345 void popinteger8array(long int *x, int n) {
346  popNarray((char *)x,(unsigned int)(n*8)) ;
347 }
348 void lookinteger8array(long int *x, int n) {
349  lookNarray((char *)x,(unsigned int)(n*8)) ;
350 }
351 
352 void pushinteger16array(long long int *x, int n) {
353  pushNarray((char *)x,(unsigned int)(n*16)) ;
354 }
355 void popinteger16array(long long int *x, int n) {
356  popNarray((char *)x,(unsigned int)(n*16)) ;
357 }
358 void lookinteger16array(long long int *x, int n) {
359  lookNarray((char *)x,(unsigned int)(n*16)) ;
360 }
361 
362 void pushreal4array(float *x, int n) {
363  pushNarray((char *)x, (unsigned int)(n*4)) ;
364 }
365 void popreal4array(float *x, int n) {
366  popNarray((char *)x, (unsigned int)(n*4)) ;
367 }
368 void lookreal4array(float *x, int n) {
369  lookNarray((char *)x, (unsigned int)(n*4)) ;
370 }
371 
372 void pushreal8array(double *x, int n) {
373  pushNarray((char *)x,(unsigned int)(n*8)) ;
374 }
375 void popreal8array(double *x, int n) {
376  popNarray((char *)x,(unsigned int)(n*8)) ;
377 }
378 void lookreal8array(double *x, int n) {
379  lookNarray((char *)x,(unsigned int)(n*8)) ;
380 }
381 
382 void pushreal16array(void *x, int n) {
383  pushNarray((char *)x,(unsigned int)(n*16)) ;
384 }
385 void popreal16array(void *x, int n) {
386  popNarray((char *)x,(unsigned int)(n*16)) ;
387 }
388 void lookreal16array(void *x, int n) {
389  lookNarray((char *)x,(unsigned int)(n*16)) ;
390 }
391 
392 void pushreal32array(void *x, int n) {
393  pushNarray((char *)x,(unsigned int)(n*32)) ;
394 }
395 void popreal32array(void *x, int n) {
396  popNarray((char *)x,(unsigned int)(n*32)) ;
397 }
398 void lookreal32array(void *x, int n) {
399  lookNarray((char *)x,(unsigned int)(n*32)) ;
400 }
401 
402 void pushcomplex4array(void *x, int n) {
403  pushNarray((char *)x,(unsigned int)(n*4)) ;
404 }
405 void popcomplex4array(void *x, int n) {
406  popNarray((char *)x,(unsigned int)(n*4)) ;
407 }
408 void lookcomplex4array(void *x, int n) {
409  lookNarray((char *)x,(unsigned int)(n*4)) ;
410 }
411 
412 void pushcomplex8array(void *x, int n) {
413  pushNarray((char *)x,(unsigned int)(n*8)) ;
414 }
415 void popcomplex8array(void *x, int n) {
416  popNarray((char *)x,(unsigned int)(n*8)) ;
417 }
418 void lookcomplex8array(void *x, int n) {
419  lookNarray((char *)x,(unsigned int)(n*8)) ;
420 }
421 
422 void pushcomplex16array(void *x, int n) {
423  pushNarray((char *)x,(unsigned int)(n*16)) ;
424 }
425 void popcomplex16array(void *x, int n) {
426  popNarray((char *)x,(unsigned int)(n*16)) ;
427 }
428 void lookcomplex16array(void *x, int n) {
429  lookNarray((char *)x,(unsigned int)(n*16)) ;
430 }
431 
432 void pushcomplex32array(void *x, int n) {
433  pushNarray((char *)x,(unsigned int)(n*32)) ;
434 }
435 void popcomplex32array(void *x, int n) {
436  popNarray((char *)x,(unsigned int)(n*32)) ;
437 }
438 void lookcomplex32array(void *x, int n) {
439  lookNarray((char *)x,(unsigned int)(n*32)) ;
440 }
441 
442 void pushpointer4array(void *x, int n) {
443  pushNarray((char *)x, (unsigned int)(n*4)) ;
444 }
445 void poppointer4array(void *x, int n) {
446  popNarray((char *)x, (unsigned int)(n*4)) ;
447 }
448 void lookpointer4array(void *x, int n) {
449  lookNarray((char *)x, (unsigned int)(n*4)) ;
450 }
451 
452 void pushpointer8array(void *x, int n) {
453  pushNarray((char *)x,(unsigned int)(n*8)) ;
454 }
455 void poppointer8array(void *x, int n) {
456  popNarray((char *)x,(unsigned int)(n*8)) ;
457 }
458 void lookpointer8array(void *x, int n) {
459  lookNarray((char *)x,(unsigned int)(n*8)) ;
460 }
461 
462 /************* Debug displays of the state of the stack: ***********/
463 
464 void printbigbytes(long int nbblocks, long int blocksz, long int nbunits) {
465  long int a3, b3, res3, res6, res9, res12 ;
466  int a0, b0, res0 ;
467  int printzeros = 0 ;
468  a0 = (int)nbblocks%1000 ;
469  a3 = nbblocks/1000 ;
470  b0 = (int)blocksz%1000 ;
471  b3 = blocksz/1000 ;
472  res0 = ((int)(nbunits%1000)) + a0*b0 ;
473  res3 = nbunits/1000 + a3*b0 + a0*b3 ;
474  res6 = a3*b3 ;
475  res3 += ((long int)(res0/1000)) ;
476  res0 = res0%1000 ;
477  res6 += res3/1000 ;
478  res3 = res3%1000 ;
479  res9 = res6/1000 ;
480  res6 = res6%1000 ;
481  res12 = res9/1000 ;
482  res9 = res9%1000 ;
483  if (res12>0) {
484  printf("%li ", res12) ;
485  printzeros = 1 ;
486  }
487  if ((res9/100)>0 || printzeros) {
488  printf("%li",res9/100) ;
489  printzeros = 1 ;
490  res9 = res9%100 ;
491  }
492  if ((res9/10)>0 || printzeros) {
493  printf("%li",res9/10) ;
494  printzeros = 1 ;
495  res9 = res9%10 ;
496  }
497  if (res9>0 || printzeros) {
498  printf("%li ",res9) ;
499  printzeros = 1 ;
500  }
501  if ((res6/100)>0 || printzeros) {
502  printf("%li",res6/100) ;
503  printzeros = 1 ;
504  res6 = res6%100 ;
505  }
506  if ((res6/10)>0 || printzeros) {
507  printf("%li",res6/10) ;
508  printzeros = 1 ;
509  res6 = res6%10 ;
510  }
511  if (res6>0 || printzeros) {
512  printf("%li ",res6) ;
513  printzeros = 1 ;
514  }
515  if ((res3/100)>0 || printzeros) {
516  printf("%li",res3/100) ;
517  printzeros = 1 ;
518  res3 = res3%100 ;
519  }
520  if ((res3/10)>0 || printzeros) {
521  printf("%li",res3/10) ;
522  printzeros = 1 ;
523  res3 = res3%10 ;
524  }
525  if (res3>0 || printzeros) {
526  printf("%li ",res3) ;
527  printzeros = 1 ;
528  }
529  if ((res0/100)>0 || printzeros) {
530  printf("%i",res0/100) ;
531  printzeros = 1 ;
532  res0 = res0%100 ;
533  }
534  if ((res0/10)>0 || printzeros) {
535  printf("%i",res0/10) ;
536  printzeros = 1 ;
537  res0 = res0%10 ;
538  }
539  printf("%i",res0) ;
540 }
541 
543  printf(" C Traffic: ") ;
545  printf(" bytes\n") ;
546 }
547 
548 void printftrafficinc_(long int *mmfM, int *mmfsz, int *mmf) {
549  printf(" F Traffic: ") ;
550  printbigbytes(*mmfM, (long int)*mmfsz, (long int)*mmf) ;
551  printf(" bytes\n") ;
552 }
553 
554 void printtotaltraffic_(long int *mmfM, int *mmfsz, int *mmf) {
555  printf(" C+F Traffic: ") ;
557  printf(" + ");
558  printbigbytes(*mmfM, (long int)*mmfsz, (long int)*mmf) ;
559  printf(" bytes\n") ;
560 }
561 
563  DoubleChainedBlock *stack = curStack ;
564  int nbBlocks = (stack?-1:0) ;
565  int remainder = 0;
566  while(stack) {
567  stack = stack->prev ;
568  nbBlocks++ ;
569  }
570  if (curStack && curStackTop) remainder = curStackTop-(curStack->contents) ;
571  printf(" Stack size: ") ;
572  printbigbytes((long int)nbBlocks, ONE_BLOCK_SIZE, (long int)remainder) ;
573  printf(" bytes\n") ;
574 }
575 
576 void printtopplacenum_(int *n) {
577  DoubleChainedBlock *stack = curStack ;
578  int nbBlocks = (stack?-1:0) ;
579  int remainder = 0;
580  while(stack) {
581  stack = stack->prev ;
582  nbBlocks++ ;
583  }
584  if (curStack && curStackTop) remainder = curStackTop-(curStack->contents) ;
585  printf(" Stack size at location %i : ", *n) ;
586  printbigbytes((long int)nbBlocks, ONE_BLOCK_SIZE, (long int)remainder) ;
587  printf(" bytes\n") ;
588 }
589 
591  DoubleChainedBlock *stack = curStack ;
592  int nbBlocks = (stack?-2:0) ;
593  int remainder = 0;
594  long int totalsz ;
595  while(stack) {
596  stack = stack->prev ;
597  nbBlocks++ ;
598  }
599  stack = curStack ;
600  while(stack) {
601  stack = stack->next ;
602  nbBlocks++ ;
603  }
604 
605  printf(" Max Stack size (%i blocks): ", nbBlocks) ;
606  printbigbytes((long int)nbBlocks, ONE_BLOCK_SIZE, (long int)0) ;
607  printf(" bytes\n") ;
608 }
609 
611  if (lookStack == NULL)
612  printtopplace_() ;
613  else {
614  DoubleChainedBlock *stack = lookStack ;
615  int nbBlocks = (stack?-1:0) ;
616  while(stack) {
617  stack = stack->prev ;
618  nbBlocks++ ;
619  }
620  printf(" Stack look at: ") ;
621  printbigbytes((long int)nbBlocks, ONE_BLOCK_SIZE,
622  ((long int)(lookStackTop-(lookStack->contents)))) ;
623  printf(" bytes\n") ;
624  }
625 }
626 
628  if (curStack && curStackTop) {
629  int totalNumChars = 60 ;
630  DoubleChainedBlock *stack = curStack ;
631  char *stackTop = curStackTop ;
632  unsigned short int *st1 ;
633  printf("TOP OF C STACK : ") ;
634  while (totalNumChars>0 && stackTop>(stack->contents)) {
635  stackTop-- ;
636 /* ATTENTION!! en 64 bits, unsigned short int fait 2 octets, donc ce print est un peu faux */
637  st1 = (unsigned short int *)stackTop ;
638  printf("%02X,",*st1%256) ;
639  totalNumChars-- ;
640  }
641  while (totalNumChars>0 && stack->prev) {
642  printf(" || ") ;
643  stack = stack->prev ;
644  stackTop = (stack->contents)+ONE_BLOCK_SIZE ;
645  while (totalNumChars>0 && stackTop>(stack->contents)) {
646  stackTop-- ;
647  st1 = (unsigned short int *)stackTop ;
648  printf("%02X,",*st1%256) ;
649  totalNumChars-- ;
650  }
651  }
652  if (stack->prev || stackTop>(stack->contents))
653  printf(" ...\n") ;
654  else
655  printf(" || BOTTOM\n") ;
656  } else {
657  printf("NOTHING IN C STACK.\n") ;
658  }
659 }
660 
661 void getnbblocksinstack_(int *nbblocks) {
662  DoubleChainedBlock *stack = curStack ;
663  *nbblocks = 0 ;
664  while(stack) {
665  stack = stack->prev ;
666  (*nbblocks)++ ;
667  }
668 }
669 
670 /* Computes (and returns into its args) the number of blocks below the current
671  * stack top (resp. look) position, and the number of bytes below
672  * the current top (resp. look) position in the topmost block of the current
673  * top (resp. look) position. */
674 void getbigcsizes_(int *nbblocks, int *remainder, int *nbblockslook, int *lookremainder) {
675  DoubleChainedBlock *stack ;
676 
677  stack = curStack ;
678  *nbblocks = (stack?-1:0) ;
679  while(stack) {
680  stack = stack->prev ;
681  (*nbblocks)++ ;
682  }
683  if (curStack && curStackTop)
684  *remainder = curStackTop-(curStack->contents) ;
685  else
686  *remainder = 0 ;
687 
688  if (lookStack == NULL) {
689  *nbblockslook = -999 ;
690  *lookremainder = -999 ;
691  } else {
692  stack = lookStack ;
693  *nbblockslook = (stack?-1:0) ;
694  while(stack) {
695  stack = stack->prev ;
696  (*nbblockslook)++ ;
697  }
698  *lookremainder = lookStackTop-(lookStack->contents) ;
699  }
700 }
void popbooleanarray(char *x, int n)
Definition: adStack.c:325
l_size ! loop over number of fields ke do je do i
void lookbooleanarray(char *x, int n)
Definition: adStack.c:328
void popinteger16array_(void *x, unsigned int *n)
Definition: adStack.c:222
void pushbooleanarray_(char *x, unsigned int *n)
Definition: adStack.c:189
void printlookingplace_()
Definition: adStack.c:610
void showrecentcstack_()
Definition: adStack.c:627
void printftrafficinc_(long int *mmfM, int *mmfsz, int *mmf)
Definition: adStack.c:548
void lookpointer4array(void *x, int n)
Definition: adStack.c:448
void poppointer4array(void *x, int n)
Definition: adStack.c:445
void lookcomplex4array(void *x, int n)
Definition: adStack.c:408
void popreal8array_(void *x, unsigned int *n)
Definition: adStack.c:242
void popcomplex16array_(void *x, unsigned int *n)
Definition: adStack.c:292
void popcomplex4array(void *x, int n)
Definition: adStack.c:405
static long int mmctrafficM
Definition: adStack.c:28
void popinteger4array(int *x, int n)
Definition: adStack.c:335
void pushcomplex4array(void *x, int n)
Definition: adStack.c:402
void popbooleanarray_(char *x, unsigned int *n)
Definition: adStack.c:192
void pushpointer4array(void *x, int n)
Definition: adStack.c:442
void popreal8array(double *x, int n)
Definition: adStack.c:375
void lookreal8array_(void *x, unsigned int *n)
Definition: adStack.c:245
void lookNarray(char *x, unsigned int nbChars)
Definition: adStack.c:142
void lookcomplex16array(void *x, int n)
Definition: adStack.c:428
#define ONE_BLOCK_SIZE
Definition: adStack.c:8
void resetadlookstack_()
Definition: adStack.c:172
void printctraffic_()
Definition: adStack.c:542
void pushinteger4array_(void *x, unsigned int *n)
Definition: adStack.c:199
void pushbooleanarray(char *x, int n)
Definition: adStack.c:322
void pushcomplex32array_(void *x, unsigned int *n)
Definition: adStack.c:299
void popcharacterarray_(char *x, unsigned int *n)
Definition: adStack.c:182
void lookcomplex32array_(void *x, unsigned int *n)
Definition: adStack.c:305
void lookcharacterarray(char *x, int n)
Definition: adStack.c:318
void pushcharacterarray(char *x, int n)
Definition: adStack.c:312
*f90 *************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************! this routine is used to retrieve scalar boundary data for symmetric domain. subroutine MPP_GET_BOUNDARY_2D_(field, domain, ebuffer, sbuffer, wbuffer, nbuffer, flags, &position, complete, tile_count) type(domain2D), intent(in) ::domain MPP_TYPE_, intent(in) ::field(:,:) MPP_TYPE_, intent(inout), optional ::ebuffer(:), sbuffer(:), wbuffer(:), nbuffer(:) integer, intent(in), optional ::flags, position, tile_count logical, intent(in), optional ::complete MPP_TYPE_ ::field3D(size(field, 1), size(field, 2), 1) MPP_TYPE_, allocatable, dimension(:,:) ::ebuffer2D, sbuffer2D, wbuffer2D, nbuffer2D integer ::xcount, ycount integer ::ntile logical ::need_ebuffer, need_sbuffer, need_wbuffer, need_nbuffer integer(LONG_KIND), dimension(MAX_DOMAIN_FIELDS, MAX_TILES), save ::f_addrs=-9999 integer(LONG_KIND), dimension(4, MAX_DOMAIN_FIELDS, MAX_TILES), save ::b_addrs=-9999 integer, save ::bsize(4)=0, isize=0, jsize=0, ksize=0, pos, list=0, l_size=0, upflags integer ::buffer_size(4) integer ::max_ntile, tile, update_position, ishift, jshift logical ::do_update, is_complete, set_mismatch character(len=3) ::text MPP_TYPE_ ::d_type type(overlapSpec), pointer ::bound=> NULL() ntile
void lookinteger4array(int *x, int n)
Definition: adStack.c:338
static char * lookStackTop
Definition: adStack.c:25
void lookpointer8array(void *x, int n)
Definition: adStack.c:458
void popinteger4array_(void *x, unsigned int *n)
Definition: adStack.c:202
void popinteger16array(long long int *x, int n)
Definition: adStack.c:355
void pushinteger4array(int *x, int n)
Definition: adStack.c:332
void lookinteger16array(long long int *x, int n)
Definition: adStack.c:358
void lookreal8array(double *x, int n)
Definition: adStack.c:378
void lookcomplex8array_(void *x, unsigned int *n)
Definition: adStack.c:285
real, parameter b3
Definition: sw_core_nlm.F90:66
void pushcharacterarray_(char *x, unsigned int *n)
Definition: adStack.c:179
void pushpointer8array(void *x, int n)
Definition: adStack.c:452
void pushreal8array(double *x, int n)
Definition: adStack.c:372
void popinteger8array(long int *x, int n)
Definition: adStack.c:345
void lookreal32array_(void *x, unsigned int *n)
Definition: adStack.c:265
void pushreal4array(float *x, int n)
Definition: adStack.c:362
void pushreal32array_(void *x, unsigned int *n)
Definition: adStack.c:259
void printtopplace_()
Definition: adStack.c:562
void popcomplex16array(void *x, int n)
Definition: adStack.c:425
void popreal16array_(void *x, unsigned int *n)
Definition: adStack.c:252
void lookcomplex8array(void *x, int n)
Definition: adStack.c:418
void pushcomplex16array_(void *x, unsigned int *n)
Definition: adStack.c:289
void pushinteger16array(long long int *x, int n)
Definition: adStack.c:352
int chcksum(char *contents, int len)
Definition: adStack.c:33
void popNarray(char *x, unsigned int nbChars)
Definition: adStack.c:106
void pushcomplex4array_(void *x, unsigned int *n)
Definition: adStack.c:269
void pushreal32array(void *x, int n)
Definition: adStack.c:392
static DoubleChainedBlock * lookStack
Definition: adStack.c:24
void pushcomplex32array(void *x, int n)
Definition: adStack.c:432
struct _doubleChainedBlock DoubleChainedBlock
void popreal32array(void *x, int n)
Definition: adStack.c:395
void lookcomplex16array_(void *x, unsigned int *n)
Definition: adStack.c:295
void popcomplex8array_(void *x, unsigned int *n)
Definition: adStack.c:282
void popcomplex32array(void *x, int n)
Definition: adStack.c:435
void pushinteger8array_(void *x, unsigned int *n)
Definition: adStack.c:209
void printtotaltraffic_(long int *mmfM, int *mmfsz, int *mmf)
Definition: adStack.c:554
void pushreal4array_(void *x, unsigned int *n)
Definition: adStack.c:229
void popreal16array(void *x, int n)
Definition: adStack.c:385
struct _doubleChainedBlock * prev
Definition: adStack.c:15
void pushinteger16array_(void *x, unsigned int *n)
Definition: adStack.c:219
void pushcomplex16array(void *x, int n)
Definition: adStack.c:422
void pushreal8array_(void *x, unsigned int *n)
Definition: adStack.c:239
void popcomplex32array_(void *x, unsigned int *n)
Definition: adStack.c:302
void pushinteger8array(long int *x, int n)
Definition: adStack.c:342
void getnbblocksinstack_(int *nbblocks)
Definition: adStack.c:661
void pushreal16array(void *x, int n)
Definition: adStack.c:382
void pushcomplex8array(void *x, int n)
Definition: adStack.c:412
void lookreal16array(void *x, int n)
Definition: adStack.c:388
void pushNarray(char *x, unsigned int nbChars)
Definition: adStack.c:44
void popinteger8array_(void *x, unsigned int *n)
Definition: adStack.c:212
void popreal32array_(void *x, unsigned int *n)
Definition: adStack.c:262
void lookinteger8array(long int *x, int n)
Definition: adStack.c:348
static long int mmctraffic
Definition: adStack.c:27
void lookcomplex32array(void *x, int n)
Definition: adStack.c:438
void lookreal16array_(void *x, unsigned int *n)
Definition: adStack.c:255
void lookinteger16array_(void *x, unsigned int *n)
Definition: adStack.c:225
long int bigStackSize
Definition: adStack.c:30
void popreal4array_(void *x, unsigned int *n)
Definition: adStack.c:232
void lookreal4array_(void *x, unsigned int *n)
Definition: adStack.c:235
void printstackmax_()
Definition: adStack.c:590
struct _doubleChainedBlock * next
Definition: adStack.c:17
static char * curStackTop
Definition: adStack.c:22
void lookinteger8array_(void *x, unsigned int *n)
Definition: adStack.c:215
void lookreal4array(float *x, int n)
Definition: adStack.c:368
void printtopplacenum_(int *n)
Definition: adStack.c:576
void lookinteger4array_(void *x, unsigned int *n)
Definition: adStack.c:205
void lookcomplex4array_(void *x, unsigned int *n)
Definition: adStack.c:275
static char adSid[]
Definition: adStack.c:1
void popcharacterarray(char *x, int n)
Definition: adStack.c:315
void getbigcsizes_(int *nbblocks, int *remainder, int *nbblockslook, int *lookremainder)
Definition: adStack.c:674
void lookcharacterarray_(char *x, unsigned int *n)
Definition: adStack.c:185
void popcomplex4array_(void *x, unsigned int *n)
Definition: adStack.c:272
void poppointer8array(void *x, int n)
Definition: adStack.c:455
void pushreal16array_(void *x, unsigned int *n)
Definition: adStack.c:249
static DoubleChainedBlock * curStack
Definition: adStack.c:21
void lookreal32array(void *x, int n)
Definition: adStack.c:398
void popcomplex8array(void *x, int n)
Definition: adStack.c:415
void printbigbytes(long int nbblocks, long int blocksz, long int nbunits)
Definition: adStack.c:464
void popreal4array(float *x, int n)
Definition: adStack.c:365
void lookbooleanarray_(char *x, unsigned int *n)
Definition: adStack.c:195
void pushcomplex8array_(void *x, unsigned int *n)
Definition: adStack.c:279