ADflow  v1.0
ADflow is a finite volume RANS solver tailored for gradient-based aerodynamic design optimization.
adStack.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include "adStack.h"
5 
6 #include "adComplex.h"
7 
8 // Set to 0 to hide trace.
9 static int traceOn = 0 ;
10 static int freeemptyblocks = 1 ;
11 
12 char* pushBlock() ;
13 char* popBlock() ;
14 
15 /**************** block sizes for all data types *************/
16 
17 /* The size of a BLOCK in bytes. */
18 #define BLOCK_SIZE 65536
19 // #define BLOCK_SIZE 17 // A very small BLOCK_SIZE allows for stronger testing!
20 
21 /**************** data structures for stack ******************/
22 
23 /* The main stack is a double-chain of DoubleChainedBlock objects.
24  * Each DoubleChainedBlock holds an array[BLOCK_SIZE] of char. */
25 typedef struct _DoubleChainedBlock{
26  unsigned int rank ;
31 
34 typedef struct _RepetitionLevel {
35  int hasBackPop ;
36  int active ;
38  int backPop ;
42  int freePush ;
43  unsigned int storedadbitbuf ;
47 
48 /* A block and an integer to keep the current top in the block. When the block
49  is full, it is added to the double-chain list and a fresh block is used for
50  pushing. During popping, empty blocks are replenished with data from the
51  double-chain list. */
52 static int tappos = BLOCK_SIZE ;
53 static char* tapblock = NULL ;
54 static DoubleChainedBlock *curStack = NULL ;
55 
58 
59 /* Pushing single bits is different from the rest: we collect
60  32 bits in the integer below, before pushing that to the stack. */
61 static unsigned int adbitbuf = 0 ;
62 static int adbitibuf = 0 ;
63 
65 static u_int64_t pushPopTraffic = 0 ;
66 
68 static u_int64_t maxBlocks = 0 ;
69 
70 //[llh] Don't know how to manage pushPopTraffic and maxBlocks in the OpenMP case ?
71 
72 /* All data structures must be threadprivate, so that each OpenMP thread has
73  its own stack. If the stack is compiled with OpenMP support and then used
74  in a program with no OpenMP parallel regions, the stack will work as
75  expected without using any extra resources. */
76 #pragma omp threadprivate(tappos, tapblock, curStack, adbitbuf, adbitibuf, topRepetitionPoint)
77 
78 /***************** repeated access mechanism *************/
79 
80 // Possible improvements:
81 // - replace tappos with tapblock+tappos, saving a few "+" ?
82 // - find a faster currentLocationStrictBelowFreePush and currentLocationEqualsFreePush
83 
84 // Notice: Algorithm for "nested" repetition level seems wrong (should be corrected)
85 // when the deeper repetition level is started after new pushes.
86 
87 // We call "current location" the pair of
88 // (DoubleChainedBlock *) curStack // the current top stack block.
89 // (int) tappos // the offset of the current top in the current top stack block.
90 
92  repetitionLevel->hasBackPop = 1 ;
93  repetitionLevel->backPopBlock = curStack ;
94  repetitionLevel->backPop = tappos ;
95 }
96 
98  curStack = repetitionLevel->backPopBlock ;
99  tapblock = curStack->contents ;
100  tappos = repetitionLevel->backPop ;
101 }
102 
104  repetitionLevel->resumePointBlock = curStack ;
105  repetitionLevel->resumePoint = tappos ;
106 }
107 
109  curStack = repetitionLevel->resumePointBlock ;
110  tapblock = curStack->contents ;
111  tappos = repetitionLevel->resumePoint ;
112 }
113 
115  repetitionLevel->freePushBlock = curStack ;
116  repetitionLevel->freePush = tappos ;
117 }
118 
120  curStack = repetitionLevel->freePushBlock ;
121  tapblock = curStack->contents ;
122  tappos = repetitionLevel->freePush ;
123 }
124 
125 //TODO: try inline this function for efficiency:
127  // Not as simple as it could be, because N;BLOCK_SIZE <=> N+1;0 and both happen due to initial NULL curStack...
128  int curL1 = curStack->rank ;
129  int curL2 = tappos ;
130  int fpL1 = repetitionLevel->freePushBlock->rank ;
131  int fpL2 = repetitionLevel->freePush ;
132  if (curL2==BLOCK_SIZE) {++curL1 ; curL2=0 ;}
133  if (fpL2==BLOCK_SIZE) {++fpL1 ; fpL2=0 ;}
134  return (curL1<fpL1 || (curL1==fpL1 && curL2<fpL2)) ;
135 }
136 
137 //TODO: try inline this function for efficiency:
139  // Not as simple as it could be, because N;BLOCK_SIZE <=> N+1;0 and both happen due to initial NULL curStack...
140  int curL1 = curStack->rank ;
141  int curL2 = tappos ;
142  int fpL1 = repetitionLevel->freePushBlock->rank ;
143  int fpL2 = repetitionLevel->freePush ;
144  if (curL2==BLOCK_SIZE) {++curL1 ; curL2=0 ;}
145  if (fpL2==BLOCK_SIZE) {++fpL1 ; fpL2=0 ;}
146  return (curL1==fpL1 && curL2==fpL2) ;
147 }
148 
149 void showLocation(DoubleChainedBlock *locBlock, int loc) {
150  printf("%1i.%05i", (locBlock ? locBlock->rank : 0), loc) ;
151 }
152 
154  RepetitionLevel *repetitionPoint = topRepetitionPoint ;
155  while (repetitionPoint) {
156  printf(" REPETITION LEVEL ACTIVE:%s BP:%s",
157  (repetitionPoint->active?"yes":"no"),
158  (repetitionPoint->hasBackPop?"yes":"no")) ;
159  if (repetitionPoint->hasBackPop)
160  {printf(" BP:") ; showLocation(repetitionPoint->backPopBlock, repetitionPoint->backPop) ;}
161  if (repetitionPoint->resumePointBlock)
162  {printf(" RP:") ; showLocation(repetitionPoint->resumePointBlock, repetitionPoint->resumePoint) ;}
163  if (repetitionPoint->freePushBlock)
164  {printf(" FP:") ; showLocation(repetitionPoint->freePushBlock, repetitionPoint->freePush) ;}
165  printf("\n") ;
166  repetitionPoint = repetitionPoint->previous ;
167  if (repetitionPoint) printf(" ...in") ;
168  }
169 }
170 
171 int locstrb_() {return (curStack ? curStack->rank : 0) ;}
172 int locstro_() {return tappos;}
173 
177  RepetitionLevel *topActive = topRepetitionPoint ;
178  while (topActive && !topActive->active) {
179  topActive = topActive->previous ;
180  }
181  if (topActive && currentLocationStrictBelowFreePush(topActive)) {
182  setBackPopToCurrentLocation(topActive) ;
183  setCurrentLocationToFreePush(topActive) ;
184  if (traceOn) {
185  printf("BEFORE PUSH AT ") ;
187  printf(" WITH REPETITION LEVELS:\n") ;
189  printf(" MOVE TO FREE PUSH LOCATION ") ;
191  printf("\n") ;
192  }
193  }
194 }
195 
199  RepetitionLevel *repetitionPoint = topRepetitionPoint ;
200  int moves = (repetitionPoint->hasBackPop && currentLocationEqualsFreePush(repetitionPoint)) ;
201  if (traceOn && moves) {
202  printf("AFTER POP, LOCATION WAS ") ;
203  showLocation(curStack, tappos) ;
204  printf(" WITH REPETITION LEVELS:\n") ;
206  }
207  int canEraseInactive = 1 ;
208  int canRemoveBackPop = 1 ;
209  do {
210  RepetitionLevel *oldCell = repetitionPoint ;
211  if (oldCell->hasBackPop && oldCell->active && currentLocationEqualsFreePush(oldCell)) {
212  setCurrentLocationToBackPop(oldCell) ;
213  if (canRemoveBackPop) oldCell->hasBackPop = 0 ;
214  }
215  repetitionPoint = oldCell->previous ;
216  if (!oldCell->active && canEraseInactive) {
217  free(oldCell) ;
218  topRepetitionPoint = repetitionPoint ;
219  } else {
220  canEraseInactive = 0 ;
221  canRemoveBackPop = 0 ;
222  }
223  } while (repetitionPoint) ;
224  if (traceOn && moves) {
225  printf(" MOVED TO BACK POP LOCATION:") ;
226  showLocation(curStack, tappos) ;
227  printf("\n") ;
228  }
229 }
230 
236  if (traceOn) {
237  printf("BEFORE START REPEAT AT ") ;
238  showLocation(curStack, tappos) ;
239  printf("\n") ;
241  }
242  // Create a new repetition level and push it onto topRepetitionPoint
243  RepetitionLevel *newRepetitionLevel = (RepetitionLevel *)malloc(sizeof(RepetitionLevel)) ;
244  newRepetitionLevel->previous = topRepetitionPoint ;
245  newRepetitionLevel->hasBackPop = 0 ;
246  newRepetitionLevel->active = 1 ;
247  newRepetitionLevel->backPopBlock = NULL ;
248  newRepetitionLevel->backPop = 0 ;
249  newRepetitionLevel->resumePointBlock = NULL ;
250  newRepetitionLevel->resumePoint = 0 ;
251  newRepetitionLevel->freePushBlock = NULL ;
252  newRepetitionLevel->freePush = 0 ;
253  // Copy the bits buffer:
254  newRepetitionLevel->storedadbitbuf = adbitbuf ;
255  newRepetitionLevel->storedadbitibuf = adbitibuf ;
256  // In the very weird case where current stack is empty, make it explicit:
257  if (curStack==NULL) {
258  tapblock = pushBlock() ;
259  tappos = 0 ;
260  }
261  // Store current location as the "resumePoint" location:
262  setResumePointToCurrentLocation(newRepetitionLevel) ;
263  // Set the "freePush" location to current location OR to
264  // the "freePush" of the "enclosing" repetition level,
265  // (if there is one and it is higher)
267  newRepetitionLevel->freePushBlock = topRepetitionPoint->freePushBlock ;
268  newRepetitionLevel->freePush = topRepetitionPoint->freePush ;
269  } else {
270  setFreePushToCurrentLocation(newRepetitionLevel) ;
271  }
272  // Make this new repetition level the current repetition level:
273  topRepetitionPoint = newRepetitionLevel ;
274  if (traceOn) {
275  printf(">AFTER START REPEAT AT:") ;
276  showLocation(curStack, tappos) ;
277  printf("\n") ;
279  }
280 }
281 
286  if (traceOn) {
287  printf("BEFORE RESET REPEAT AT ") ;
288  showLocation(curStack, tappos) ;
289  printf("\n") ;
291  }
292  // Remove (pop) all passive deeper repetition levels:
296  free(oldTop) ;
297  }
298  // Reset current location to "resumePoint" location:
300  // Reset the bits buffer:
301  adbitbuf = topRepetitionPoint->storedadbitbuf ;
302  adbitibuf = topRepetitionPoint->storedadbitibuf ;
303  if (traceOn) {
304  printf(">AFTER RESET REPEAT AT ") ;
305  showLocation(curStack, tappos) ;
306  printf("\n") ;
308  }
309 }
310 
313  if (traceOn) {
314  printf("BEFORE END REPEAT AT ") ;
315  showLocation(curStack, tappos) ;
316  printf("\n") ;
318  }
319  // Set to inactive the topmost active repetition level:
320  RepetitionLevel *topActive = topRepetitionPoint ;
321  while (!topActive->active) {
322  topActive = topActive->previous ;
323  }
324  topActive->active = 0 ;
325  // current location may have moved back ; check if we must move further back:
327  if (traceOn) {
328  printf(">AFTER END REPEAT AT ") ;
329  showLocation(curStack, tappos) ;
330  printf("\n") ;
332  }
333 }
334 
335 /***************** double-linked list management *************/
336 
338 char* pushBlock() {
339  if (curStack && curStack->next) {
340  curStack = curStack->next ;
341  } else {
342  DoubleChainedBlock *newStack = (DoubleChainedBlock*)malloc(sizeof(DoubleChainedBlock)) ;
343  if (newStack == NULL) {
344  /* We ran out of memory, print an error message and give up. */
345  printf("Out of memory in AD Stack.\n") ;
346  exit(0) ;
347  }
348  if(curStack != NULL) {
349  curStack->next = newStack ;
350  newStack->rank = curStack->rank + 1 ;
351  } else {
352  newStack->rank = 1 ;
353  }
354 
355  newStack->prev = curStack ;
356  newStack->next = NULL ;
357  curStack = newStack ;
358  }
359 #ifdef _ADSTACKPROFILE
360  if (curStack->rank > maxBlocks) maxBlocks = curStack->rank ;
361 #endif
362  return curStack->contents ;
363 }
364 
366 char* popBlock() {
367  DoubleChainedBlock *oldTopStack = curStack ;
368  curStack = curStack->prev ;
369  if (freeemptyblocks) {
370  // Not necessary. Only needed if we want to free when the stack goes down:
371  // We must not free if we are in a repetition level and below its freePush point.
372  if (!(topRepetitionPoint && oldTopStack->rank <= topRepetitionPoint->freePushBlock->rank)) {
373  free(oldTopStack) ;
374  if (curStack) curStack->next = NULL ;
375  }
376  // end "Not necessary"
377  }
378  return (curStack ? curStack->contents : NULL) ;
379 }
380 
381 /********************* push/pop arrays ***********************/
382 
383 /* pushNArray/popNArray are used not only to store arrays of various data
384  types. These functions are also the only ones that interact with the dynamic
385  memory management, e.g. requesting new blocks. If one of the scalar push/pop
386  functions (e.g. pushReal4) encounters the end of a block, it will ask
387  pushNArray to do all the work, i.e. start a new block and push the real4
388  value to it. */
389 void pushNArray(char *x, int nbChars) {
390  do {
391  int wsize = tappos+nbChars<BLOCK_SIZE?nbChars:BLOCK_SIZE-tappos ;
392  if(wsize > 0) {
393  memcpy(tapblock+tappos,x,wsize) ;
394  nbChars -= wsize ;
395  x += wsize ;
396  tappos += wsize ;
397  }
398  else if (nbChars > 0) {
399  tapblock = pushBlock() ;
400  tappos = 0 ;
401  }
402  } while(nbChars > 0) ; //=> lazy push: if finishes at the top of block contents, does not push a new block.
403 }
404 
405 void popNArray(char *x, int nbChars) {
406  x += nbChars ;
407  do {
408  int wsize = (nbChars<tappos)?nbChars:tappos ;
409  if(wsize > 0) {
410  memcpy(x-wsize,tapblock+tappos-wsize,wsize) ;
411  nbChars -= wsize ;
412  x -= wsize ;
413  tappos -= wsize ;
414  }
415  else if (nbChars > 0) {
416  tapblock = popBlock() ;
417  tappos = BLOCK_SIZE ;
418  }
419  } while(nbChars > 0) ; //=> lazy pop: if finishes at the bottom of block contents, does not pop block.
420 }
421 
422 void pushInteger4Array(int *x, int n) {
424  pushNArray((char *)x,(int)(n*4)) ;
425 #ifdef _ADSTACKPROFILE
426  pushPopTraffic += (int)(n*4) ;
427 #endif
428 }
429 
430 void popInteger4Array(int *x, int n) {
431  popNArray((char *)x,(int)(n*4)) ;
433 #ifdef _ADSTACKPROFILE
434  pushPopTraffic += (int)(n*4) ;
435 #endif
436 }
437 
438 void pushInteger8Array(long *x, int n) {
440  pushNArray((char *)x,(int)(n*8)) ;
441 #ifdef _ADSTACKPROFILE
442  pushPopTraffic += (int)(n*8) ;
443 #endif
444 }
445 
446 void popInteger8Array(long *x, int n) {
447  popNArray((char *)x,(int)(n*8)) ;
449 #ifdef _ADSTACKPROFILE
450  pushPopTraffic += (int)(n*8) ;
451 #endif
452 }
453 
454 void pushReal4Array(float *x, int n) {
456  pushNArray((char *)x,(int)(n*4)) ;
457 #ifdef _ADSTACKPROFILE
458  pushPopTraffic += (int)(n*4) ;
459 #endif
460 }
461 
462 void popReal4Array(float *x, int n) {
463  popNArray((char *)x,(int)(n*4)) ;
465 #ifdef _ADSTACKPROFILE
466  pushPopTraffic += (int)(n*4) ;
467 #endif
468 }
469 
470 void pushReal8Array(double *x, int n) {
472  pushNArray((char *)x,(int)(n*8)) ;
473 #ifdef _ADSTACKPROFILE
474  pushPopTraffic += (int)(n*8) ;
475 #endif
476 }
477 
478 void popReal8Array(double *x, int n) {
479  popNArray((char *)x,(int)(n*8)) ;
481 #ifdef _ADSTACKPROFILE
482  pushPopTraffic += (int)(n*8) ;
483 #endif
484 }
485 
486 void pushReal16Array(long double *x, int n) {
488  pushNArray((char *)x,(int)(n*16)) ;
489 #ifdef _ADSTACKPROFILE
490  pushPopTraffic += (int)(n*16) ;
491 #endif
492 }
493 
494 void popReal16Array(long double *x, int n) {
495  popNArray((char *)x,(int)(n*16)) ;
497 #ifdef _ADSTACKPROFILE
498  pushPopTraffic += (int)(n*16) ;
499 #endif
500 }
501 
502 void pushComplex8Array(ccmplx *x, int n) {
504  pushNArray((char *)x,(int)(n*8)) ;
505 #ifdef _ADSTACKPROFILE
506  pushPopTraffic += (int)(n*8) ;
507 #endif
508 }
509 
510 void popComplex8Array(ccmplx *x, int n) {
511  popNArray((char *)x,(int)(n*8)) ;
513 #ifdef _ADSTACKPROFILE
514  pushPopTraffic += (int)(n*8) ;
515 #endif
516 }
517 
518 void pushComplex16Array(double complex *x, int n) {
520  pushNArray((char *)x,(int)(n*16)) ;
521 #ifdef _ADSTACKPROFILE
522  pushPopTraffic += (int)(n*16) ;
523 #endif
524 }
525 
526 void popComplex16Array(double complex *x, int n) {
527  popNArray((char *)x,(int)(n*16)) ;
529 #ifdef _ADSTACKPROFILE
530  pushPopTraffic += (int)(n*16) ;
531 #endif
532 }
533 
534 void pushCharacterArray(char *x, int n) {
536  pushNArray(x,(int)n) ;
537 #ifdef _ADSTACKPROFILE
538  pushPopTraffic += (int)n ;
539 #endif
540 }
541 
542 void popCharacterArray(char *x, int n) {
543  popNArray(x,(int)n) ;
545 #ifdef _ADSTACKPROFILE
546  pushPopTraffic += (int)n ;
547 #endif
548 }
549 
550 /***************** scalar push/pop functions *****************/
551 
552 void pushCharacter(char val) {
554  if(tappos + 1 > BLOCK_SIZE) {
555  pushNArray((char*)&val, 1) ;
556  }
557  else {
558  *(char*)(tapblock+tappos) = val;
559  tappos = tappos + 1 ;
560  }
561 #ifdef _ADSTACKPROFILE
562  pushPopTraffic += 1 ;
563 #endif
564 }
565 
566 void popCharacter(char * val) {
567  if(tappos - 1 < 0) {
568  popNArray((char*)val, 1) ;
569  }
570  else {
571  tappos = tappos - 1 ;
572  *val = *(char*)(tapblock+tappos);
573  }
575 #ifdef _ADSTACKPROFILE
576  pushPopTraffic += 1 ;
577 #endif
578 }
579 
580 void pushReal4(float val) {
582  if(tappos + 4 > BLOCK_SIZE) {
583  pushNArray((char*)&val, 4) ;
584  }
585  else {
586  *(float*)(tapblock+tappos) = val;
587  tappos = tappos + 4 ;
588  }
589 #ifdef _ADSTACKPROFILE
590  pushPopTraffic += 4 ;
591 #endif
592 }
593 
594 void popReal4(float * val) {
595  if(tappos - 4 < 0) {
596  popNArray((char*)val, 4) ;
597  }
598  else {
599  tappos = tappos - 4 ;
600  *val = *(float*)(tapblock+tappos);
601  }
603 #ifdef _ADSTACKPROFILE
604  pushPopTraffic += 4 ;
605 #endif
606 }
607 
608 void pushReal8(double val) {
610  if(tappos + 8 > BLOCK_SIZE) {
611  pushNArray((char*)&val, 8) ;
612  }
613  else {
614  *(double*)(tapblock+tappos) = val;
615  tappos = tappos + 8 ;
616  }
617 #ifdef _ADSTACKPROFILE
618  pushPopTraffic += 8 ;
619 #endif
620 }
621 
622 void popReal8(double * val) {
623  if(tappos - 8 < 0) {
624  popNArray((char*)val, 8) ;
625  }
626  else {
627  tappos = tappos - 8 ;
628  *val = *(double*)(tapblock+tappos);
629  }
631 #ifdef _ADSTACKPROFILE
632  pushPopTraffic += 8 ;
633 #endif
634 }
635 
636 void pushReal16(long double *val) {
638  if(tappos + 16 > BLOCK_SIZE) {
639  pushNArray((char*)val, 16) ;
640  }
641  else {
642  memcpy(tapblock+tappos, (void *)val, 16);
643  tappos = tappos + 16 ;
644  }
645 #ifdef _ADSTACKPROFILE
646  pushPopTraffic += 16 ;
647 #endif
648 }
649 
650 void popReal16(long double *val) {
651  if(tappos - 16 < 0) {
652  popNArray((char*)val, 16) ;
653  }
654  else {
655  tappos = tappos - 16 ;
656  memcpy((void *)val, tapblock+tappos, 16) ;
657  }
659 #ifdef _ADSTACKPROFILE
660  pushPopTraffic += 16 ;
661 #endif
662 }
663 
664 void pushInteger4(int val) {
666  if(tappos + 4 > BLOCK_SIZE) {
667  pushNArray((char*)&val, 4) ;
668  }
669  else {
670  *(int*)(tapblock+tappos) = val;
671  tappos = tappos + 4 ;
672  }
673 #ifdef _ADSTACKPROFILE
674  pushPopTraffic += 4 ;
675 #endif
676 }
677 
678 void popInteger4(int * val) {
679  if(tappos - 4 < 0) {
680  popNArray((char*)val, 4) ;
681  }
682  else {
683  tappos = tappos - 4 ;
684  *val = *(int*)(tapblock+tappos);
685  }
687 #ifdef _ADSTACKPROFILE
688  pushPopTraffic += 4 ;
689 #endif
690 }
691 
692 void pushInteger8(long val) {
694  if(tappos + 8 > BLOCK_SIZE) {
695  pushNArray((char*)&val, 8) ;
696  }
697  else {
698  *(long*)(tapblock+tappos) = val;
699  tappos = tappos + 8 ;
700  }
701 #ifdef _ADSTACKPROFILE
702  pushPopTraffic += 8 ;
703 #endif
704 }
705 
706 void popInteger8(long * val) {
707  if(tappos - 8 < 0) {
708  popNArray((char*)val, 8) ;
709  }
710  else {
711  tappos = tappos - 8 ;
712  *val = *(long*)(tapblock+tappos);
713  }
715 #ifdef _ADSTACKPROFILE
716  pushPopTraffic += 8 ;
717 #endif
718 }
719 
720 void pushComplex8(ccmplx val) {
722  if(tappos + 8 > BLOCK_SIZE) {
723  pushNArray((char*)&val, 8) ;
724  }
725  else {
726  *(ccmplx*)(tapblock+tappos) = val;
727  tappos = tappos + 8 ;
728  }
729 #ifdef _ADSTACKPROFILE
730  pushPopTraffic += 8 ;
731 #endif
732 }
733 
734 void popComplex8(ccmplx * val) {
735  if(tappos - 8 < 0) {
736  popNArray((char*)val, 8) ;
737  }
738  else {
739  tappos = tappos - 8 ;
740  *val = *(ccmplx*)(tapblock+tappos);
741  }
743 #ifdef _ADSTACKPROFILE
744  pushPopTraffic += 8 ;
745 #endif
746 }
747 
748 void pushComplex16(double complex val) {
750  if(tappos + 16 > BLOCK_SIZE) {
751  pushNArray((char*)&val, 16) ;
752  }
753  else {
754  *(double complex *)(tapblock+tappos) = val;
755  tappos = tappos + 16 ;
756  }
757 #ifdef _ADSTACKPROFILE
758  pushPopTraffic += 16 ;
759 #endif
760 }
761 
762 void popComplex16(double complex *val) {
763  if(tappos - 16 < 0) {
764  popNArray((char*)val, 16) ;
765  }
766  else {
767  tappos = tappos - 16 ;
768  *val = *(double complex *)(tapblock+tappos);
769  }
771 #ifdef _ADSTACKPROFILE
772  pushPopTraffic += 16 ;
773 #endif
774 }
775 
776 void pushPointer4(void * val) {
778  if(tappos + 4 > BLOCK_SIZE) {
779  pushNArray((char*)&val, 4) ;
780  }
781  else {
782  *(void**)(tapblock+tappos) = val;
783  tappos = tappos + 4 ;
784  }
785 #ifdef _ADSTACKPROFILE
786  pushPopTraffic += 4 ;
787 #endif
788 }
789 
790 void popPointer4(void ** val) {
791  if(tappos - 4 < 0) {
792  popNArray((char*)val, 4) ;
793  }
794  else {
795  tappos = tappos - 4 ;
796  *val = *(void**)(tapblock+tappos);
797  }
799 #ifdef _ADSTACKPROFILE
800  pushPopTraffic += 4 ;
801 #endif
802 }
803 
804 void pushPointer8(void * val) {
806  if(tappos + 8 > BLOCK_SIZE) {
807  pushNArray((char*)&val, 8) ;
808  }
809  else {
810  *(void**)(tapblock+tappos) = val;
811  tappos = tappos + 8 ;
812  }
813 #ifdef _ADSTACKPROFILE
814  pushPopTraffic += 8 ;
815 #endif
816 }
817 
818 void popPointer8(void ** val) {
819  if(tappos - 8 < 0) {
820  popNArray((char*)val, 8) ;
821  }
822  else {
823  tappos = tappos - 8 ;
824  *val = *(void**)(tapblock+tappos);
825  }
827 #ifdef _ADSTACKPROFILE
828  pushPopTraffic += 8 ;
829 #endif
830 }
831 
832 /******************* bit (hidden primitives) ***************/
833 
834 void pushBit(int x) {
835  adbitbuf<<=1 ;
836  if (x) ++adbitbuf ;
837  if (adbitibuf>=31) {
838  pushNArray((char *)&adbitbuf, 4) ;
839  adbitbuf = 0 ;
840  adbitibuf = 0 ;
841 #ifdef _ADSTACKPROFILE
842  pushPopTraffic += 4 ;
843 #endif
844  } else
845  ++adbitibuf ;
846 }
847 
848 int popBit() {
849  if (adbitibuf<=0) {
850  popNArray((char *)&adbitbuf, 4) ;
851  adbitibuf = 31 ;
852 #ifdef _ADSTACKPROFILE
853  pushPopTraffic += 4 ;
854 #endif
855  } else
856  --adbitibuf ;
857  int result = adbitbuf%2 ;
858  adbitbuf>>=1 ;
859  return result ;
860 }
861 
862 /*************************** boolean *************************/
863 
864 void pushBoolean(int x) {
866  pushBit(x) ;
867 }
868 
869 //[llh] I have a bug here: the boolean returned to Fortran is bizarre!
870 void popBoolean(int *x) {
871  *x = popBit() ;
873 }
874 
875 /************************* control ***********************/
876 
877 void pushControl1b(int cc) {
879  pushBit(cc) ;
880 }
881 
882 void popControl1b(int *cc) {
883  *cc = popBit() ;
885 }
886 
887 void pushControl2b(int cc) {
889  pushBit(cc%2) ;
890  cc>>=1 ;
891  pushBit(cc) ;
892 }
893 
894 void popControl2b(int *cc) {
895  *cc = (popBit()?2:0) ;
896  if (popBit()) (*cc)++ ;
898 }
899 
900 void pushControl3b(int cc) {
902  pushBit(cc%2) ;
903  cc>>=1 ;
904  pushBit(cc%2) ;
905  cc>>=1 ;
906  pushBit(cc) ;
907 }
908 
909 void popControl3b(int *cc) {
910  *cc = (popBit()?2:0) ;
911  if (popBit()) (*cc)++ ;
912  (*cc) <<= 1 ;
913  if (popBit()) (*cc)++ ;
915 }
916 
917 void pushControl4b(int cc) {
919  pushBit(cc%2) ;
920  cc>>=1 ;
921  pushBit(cc%2) ;
922  cc>>=1 ;
923  pushBit(cc%2) ;
924  cc>>=1 ;
925  pushBit(cc) ;
926 }
927 
928 void popControl4b(int *cc) {
929  *cc = (popBit()?2:0) ;
930  if (popBit()) (*cc)++ ;
931  (*cc) <<= 1 ;
932  if (popBit()) (*cc)++ ;
933  (*cc) <<= 1 ;
934  if (popBit()) (*cc)++ ;
936 }
937 
938 void pushControl5b(int cc) {
940  pushBit(cc%2) ;
941  cc>>=1 ;
942  pushBit(cc%2) ;
943  cc>>=1 ;
944  pushBit(cc%2) ;
945  cc>>=1 ;
946  pushBit(cc%2) ;
947  cc>>=1 ;
948  pushBit(cc) ;
949 }
950 
951 void popControl5b(int *cc) {
952  *cc = (popBit()?2:0) ;
953  if (popBit()) (*cc)++ ;
954  (*cc) <<= 1 ;
955  if (popBit()) (*cc)++ ;
956  (*cc) <<= 1 ;
957  if (popBit()) (*cc)++ ;
958  (*cc) <<= 1 ;
959  if (popBit()) (*cc)++ ;
961 }
962 
963 void pushControl6b(int cc) {
965  pushBit(cc%2) ;
966  cc>>=1 ;
967  pushBit(cc%2) ;
968  cc>>=1 ;
969  pushBit(cc%2) ;
970  cc>>=1 ;
971  pushBit(cc%2) ;
972  cc>>=1 ;
973  pushBit(cc%2) ;
974  cc>>=1 ;
975  pushBit(cc) ;
976 }
977 
978 void popControl6b(int *cc) {
979  *cc = (popBit()?2:0) ;
980  if (popBit()) (*cc)++ ;
981  (*cc) <<= 1 ;
982  if (popBit()) (*cc)++ ;
983  (*cc) <<= 1 ;
984  if (popBit()) (*cc)++ ;
985  (*cc) <<= 1 ;
986  if (popBit()) (*cc)++ ;
987  (*cc) <<= 1 ;
988  if (popBit()) (*cc)++ ;
990 }
991 
992 void pushControl7b(int cc) {
994  pushBit(cc%2) ;
995  cc>>=1 ;
996  pushBit(cc%2) ;
997  cc>>=1 ;
998  pushBit(cc%2) ;
999  cc>>=1 ;
1000  pushBit(cc%2) ;
1001  cc>>=1 ;
1002  pushBit(cc%2) ;
1003  cc>>=1 ;
1004  pushBit(cc%2) ;
1005  cc>>=1 ;
1006  pushBit(cc) ;
1007 }
1008 
1009 void popControl7b(int *cc) {
1010  *cc = (popBit()?2:0) ;
1011  if (popBit()) (*cc)++ ;
1012  (*cc) <<= 1 ;
1013  if (popBit()) (*cc)++ ;
1014  (*cc) <<= 1 ;
1015  if (popBit()) (*cc)++ ;
1016  (*cc) <<= 1 ;
1017  if (popBit()) (*cc)++ ;
1018  (*cc) <<= 1 ;
1019  if (popBit()) (*cc)++ ;
1020  (*cc) <<= 1 ;
1021  if (popBit()) (*cc)++ ;
1023 }
1024 
1025 void pushControl8b(int cc) {
1027  pushBit(cc%2) ;
1028  cc>>=1 ;
1029  pushBit(cc%2) ;
1030  cc>>=1 ;
1031  pushBit(cc%2) ;
1032  cc>>=1 ;
1033  pushBit(cc%2) ;
1034  cc>>=1 ;
1035  pushBit(cc%2) ;
1036  cc>>=1 ;
1037  pushBit(cc%2) ;
1038  cc>>=1 ;
1039  pushBit(cc%2) ;
1040  cc>>=1 ;
1041  pushBit(cc) ;
1042 }
1043 
1044 void popControl8b(int *cc) {
1045  *cc = (popBit()?2:0) ;
1046  if (popBit()) (*cc)++ ;
1047  (*cc) <<= 1 ;
1048  if (popBit()) (*cc)++ ;
1049  (*cc) <<= 1 ;
1050  if (popBit()) (*cc)++ ;
1051  (*cc) <<= 1 ;
1052  if (popBit()) (*cc)++ ;
1053  (*cc) <<= 1 ;
1054  if (popBit()) (*cc)++ ;
1055  (*cc) <<= 1 ;
1056  if (popBit()) (*cc)++ ;
1057  (*cc) <<= 1 ;
1058  if (popBit()) (*cc)++ ;
1060 }
1061 
1062 /****************** Profiling and debugging *******************/
1063 
1065  printf("Peak stack size (%1li blocks): %1llu bytes\n",
1066  maxBlocks, maxBlocks*((long int)BLOCK_SIZE)) ;
1067 }
1068 
1070  printf("Total push/pop traffic %1lu bytes\n", pushPopTraffic) ;
1071 }
1072 
1073 void adStack_showStackSize(int label) {
1074  printf(" %i--> <",label) ;
1075  showLocation(curStack, tappos) ;
1076  printf(">") ;
1077 }
1078 
1079 void adStack_showStack(char *locationName) {
1080  if (!curStack || (tappos==0 && !curStack->prev)) {
1081  printf ("Stack at %s is empty\n", locationName) ;
1082  } else {
1083  printf ("Stack top at %s is %1i.%05i :\n", locationName, curStack->rank, tappos) ;
1084  int bytesToShow = 20 ;
1085  int blocksToShow = 3 ;
1086  DoubleChainedBlock *inStack = curStack ;
1087  int inPos = tappos ;
1088  while (blocksToShow>0 && inStack) {
1089  printf(" Block %d:", inStack->rank) ;
1090  while (bytesToShow>0 && inPos>0) {
1091  printf(" %02x", (unsigned char)inStack->contents[--inPos]) ;
1092  --bytesToShow ;
1093  }
1094  if (inPos>0)
1095  printf(" ...<%d more bytes>...", inPos) ;
1096  printf(" |\n") ;
1097  --blocksToShow ;
1098  inStack = inStack->prev ;
1099  inPos = BLOCK_SIZE ;
1100  }
1101  if (inStack)
1102  printf(" %d more blocks below\n", inStack->rank) ;
1103  }
1104  if (adbitibuf==0) {
1105  printf("Bit buffer is empty\n") ;
1106  } else {
1107  printf("Bit buffer:%1i in %08x\n", adbitibuf, adbitbuf) ;
1108  }
1109  if (topRepetitionPoint) {
1110  printf("Repetition levels:\n ") ;
1112  }
1113  printf("----------------\n") ;
1114 }
1115 
1116 /******* query if this stack was compiled with OpenMP ******/
1118  #ifdef _OPENMP
1119  return 1 ;
1120  #else
1121  return 0 ;
1122  #endif
1123 }
1124 
1125 /****************** INTERFACE CALLED FROM FORTRAN *******************/
1126 
1129 }
1130 
1133 }
1134 
1136  adStack_endRepeat() ;
1137 }
1138 
1139 void pushinteger4array_(int *ii, int *ll) {
1140  pushInteger4Array(ii, *ll) ;
1141 }
1142 
1143 void popinteger4array_(int *ii, int *ll) {
1144  popInteger4Array(ii, *ll) ;
1145 }
1146 
1147 void pushinteger8array_(long *ii, int *ll) {
1148  pushInteger8Array(ii, *ll) ;
1149 }
1150 
1151 void popinteger8array_(long *ii, int *ll) {
1152  popInteger8Array(ii, *ll) ;
1153 }
1154 
1155 void pushreal4array_(float *ii, int *ll) {
1156  pushReal4Array(ii, *ll) ;
1157 }
1158 
1159 void popreal4array_(float *ii, int *ll) {
1160  popReal4Array(ii, *ll) ;
1161 }
1162 
1163 void pushreal8array_(double *ii, int *ll) {
1164  pushReal8Array(ii, *ll) ;
1165 }
1166 
1167 void popreal8array_(double *ii, int *ll) {
1168  popReal8Array(ii, *ll) ;
1169 }
1170 
1171 void pushreal16array_(long double *ii, int *ll) {
1172  pushReal16Array(ii, *ll) ;
1173 }
1174 
1175 void popreal16array_(long double *ii, int *ll) {
1176  popReal16Array(ii, *ll) ;
1177 }
1178 
1179 void pushcomplex8array_(ccmplx *ii, int *ll) {
1180  pushComplex8Array(ii, *ll) ;
1181 }
1182 
1183 void popcomplex8array_(ccmplx *ii, int *ll) {
1184  popComplex8Array(ii, *ll) ;
1185 }
1186 
1187 void pushcomplex16array_(cdcmplx *ii, int *ll) {
1188  pushComplex16Array((double complex *)ii, *ll) ;
1189 }
1190 
1191 void popcomplex16array_(cdcmplx *ii, int *ll) {
1192  popComplex16Array((double complex *)ii, *ll) ;
1193 }
1194 
1195 void pushcharacterarray_(char *ii, int *ll) {
1196  pushCharacterArray(ii, *ll) ;
1197 }
1198 
1199 void popcharacterarray_(char *ii, int *ll) {
1200  popCharacterArray(ii, *ll) ;
1201 }
1202 
1203 void pushbooleanarray_(char *x, int *n) {
1205  pushNArray(x,(*n*4)) ;
1206 #ifdef _ADSTACKPROFILE
1207  pushPopTraffic += *n*4 ;
1208 #endif
1209 }
1210 
1211 void popbooleanarray_(char *x, int *n) {
1212  popNArray(x,(*n*4)) ;
1214 #ifdef _ADSTACKPROFILE
1215  pushPopTraffic += *n*4 ;
1216 #endif
1217 }
1218 
1219 void pushcharacter_(char* val) {
1220  pushCharacter(*val) ;
1221 }
1222 
1223 void popcharacter_(char* val) {
1224  popCharacter(val) ;
1225 }
1226 
1227 void pushreal4_(float* val) {
1228  pushReal4(*val) ;
1229 }
1230 
1231 void popreal4_(float* val) {
1232  popReal4(val) ;
1233 }
1234 
1235 void pushreal8_(double* val) {
1236  pushReal8(*val) ;
1237 }
1238 
1239 void popreal8_(double* val) {
1240  popReal8(val) ;
1241 }
1242 
1243 void pushreal16_(long double *val) {
1244  pushReal16(val) ;
1245 }
1246 
1247 void popreal16_(long double *val) {
1248  popReal16(val) ;
1249 }
1250 
1251 void pushinteger4_(int* val) {
1252  pushInteger4(*val) ;
1253 }
1254 
1255 void popinteger4_(int* val) {
1256  popInteger4(val) ;
1257 }
1258 
1259 void pushinteger8_(long* val) {
1260  pushInteger8(*val) ;
1261 }
1262 
1263 void popinteger8_(long* val) {
1264  popInteger8(val) ;
1265 }
1266 
1267 void pushcomplex8_(ccmplx* val) {
1268  pushComplex8(*val) ;
1269 }
1270 
1271 void popcomplex8_(ccmplx* val) {
1272  popComplex8(val) ;
1273 }
1274 
1276  pushComplex16(*((double complex *)val)) ;
1277 }
1278 
1280  popComplex16((double complex *)val) ;
1281 }
1282 
1283 void pushpointer4_(void** val) {
1284  pushPointer4(*val) ;
1285 }
1286 
1287 void poppointer4_(void** val) {
1288  popPointer4(val) ;
1289 }
1290 
1291 void pushpointer8_(void** val) {
1292  pushPointer8(*val) ;
1293 }
1294 
1295 void poppointer8_(void** val) {
1296  popPointer8(val) ;
1297 }
1298 
1299 void pushcontrol1b_(int* cc) {
1300  pushControl1b(*cc) ;
1301 }
1302 
1303 void popcontrol1b_(int *cc) {
1304  popControl1b(cc) ;
1305 }
1306 
1307 void pushcontrol2b_(int *cc) {
1308  pushControl2b(*cc) ;
1309 }
1310 
1311 void popcontrol2b_(int *cc) {
1312  popControl2b(cc) ;
1313 }
1314 
1315 void pushcontrol3b_(int *cc) {
1316  pushControl3b(*cc) ;
1317 }
1318 
1319 void popcontrol3b_(int *cc) {
1320  popControl3b(cc) ;
1321 }
1322 
1323 void pushcontrol4b_(int *cc) {
1324  pushControl4b(*cc) ;
1325 }
1326 
1327 void popcontrol4b_(int *cc) {
1328  popControl4b(cc) ;
1329 }
1330 
1331 void pushcontrol5b_(int *cc) {
1332  pushControl5b(*cc) ;
1333 }
1334 
1335 void popcontrol5b_(int *cc) {
1336  popControl5b(cc) ;
1337 }
1338 
1339 void pushcontrol6b_(int *cc) {
1340  pushControl6b(*cc) ;
1341 }
1342 
1343 void popcontrol6b_(int *cc) {
1344  popControl6b(cc) ;
1345 }
1346 
1347 void pushcontrol7b_(int *cc) {
1348  pushControl7b(*cc) ;
1349 }
1350 
1351 void popcontrol7b_(int *cc) {
1352  popControl7b(cc) ;
1353 }
1354 
1355 void pushcontrol8b_(int *cc) {
1356  pushControl8b(*cc) ;
1357 }
1358 
1359 void popcontrol8b_(int *cc) {
1360  popControl8b(cc) ;
1361 }
1362 
1365 }
1366 
1369 }
1370 
1371 void adstack_showstacksize_(int *label) {
1372  adStack_showStackSize(*label) ;
1373 }
1374 
1375 void adstack_showstack_(char *locationName) {
1376  adStack_showStack(locationName) ;
1377 }
1378 
1379 void pushboolean_(int *x) {
1380  pushBoolean(*x) ;
1381 }
1382 
1383 void popboolean_(int *x) {
1384  popBoolean(x) ;
1385 }
1386 
1388  return stackIsThreadSafe() ;
1389 }
void adStack_showStackSize(int label)
Definition: adStack.c:1073
void popReal16Array(long double *x, int n)
Definition: adStack.c:494
void pushControl6b(int cc)
Definition: adStack.c:963
void popNArray(char *x, int nbChars)
Definition: adStack.c:405
void popreal4array_(float *ii, int *ll)
Definition: adStack.c:1159
int stackIsThreadSafe()
Definition: adStack.c:1117
void popcontrol1b_(int *cc)
Definition: adStack.c:1303
void popReal8(double *val)
Definition: adStack.c:622
void pushreal16_(long double *val)
Definition: adStack.c:1243
RepetitionLevel * topRepetitionPoint
Definition: adStack.c:57
void pushInteger8Array(long *x, int n)
Definition: adStack.c:438
void adStack_resetRepeat()
Definition: adStack.c:285
void setCurrentLocationToResumePoint(RepetitionLevel *repetitionLevel)
Definition: adStack.c:108
void pushcharacter_(char *val)
Definition: adStack.c:1219
void pushbooleanarray_(char *x, int *n)
Definition: adStack.c:1203
void setCurrentLocationToBackPop(RepetitionLevel *repetitionLevel)
Definition: adStack.c:97
void pushReal8Array(double *x, int n)
Definition: adStack.c:470
void pushinteger4_(int *val)
Definition: adStack.c:1251
void adstack_resetrepeat_()
Definition: adStack.c:1131
void pushReal4(float val)
Definition: adStack.c:580
void pushControl7b(int cc)
Definition: adStack.c:992
void adStack_endRepeat()
Definition: adStack.c:312
void pushComplex16(double complex val)
Definition: adStack.c:748
void popcomplex16_(cdcmplx *val)
Definition: adStack.c:1279
char * pushBlock()
Definition: adStack.c:338
void adstack_showstack_(char *locationName)
Definition: adStack.c:1375
void setResumePointToCurrentLocation(RepetitionLevel *repetitionLevel)
Definition: adStack.c:103
void pushReal16Array(long double *x, int n)
Definition: adStack.c:486
void popcontrol6b_(int *cc)
Definition: adStack.c:1343
void poppointer4_(void **val)
Definition: adStack.c:1287
void popControl1b(int *cc)
Definition: adStack.c:882
void popinteger8_(long *val)
Definition: adStack.c:1263
void pushpointer8_(void **val)
Definition: adStack.c:1291
void popcontrol4b_(int *cc)
Definition: adStack.c:1327
void pushboolean_(int *x)
Definition: adStack.c:1379
void popreal8_(double *val)
Definition: adStack.c:1239
void popPointer8(void **val)
Definition: adStack.c:818
void adStack_showStack(char *locationName)
Definition: adStack.c:1079
void pushcomplex8array_(ccmplx *ii, int *ll)
Definition: adStack.c:1179
void popComplex16Array(double complex *x, int n)
Definition: adStack.c:526
void adStack_showTotalTraffic()
Definition: adStack.c:1069
void pushinteger8_(long *val)
Definition: adStack.c:1259
void popcontrol8b_(int *cc)
Definition: adStack.c:1359
struct _RepetitionLevel RepetitionLevel
int currentLocationEqualsFreePush(RepetitionLevel *repetitionLevel)
Definition: adStack.c:138
void pushComplex16Array(double complex *x, int n)
Definition: adStack.c:518
int locstro_()
Definition: adStack.c:172
void checkPushInReadOnly()
Definition: adStack.c:176
int locstrb_()
Definition: adStack.c:171
struct _DoubleChainedBlock DoubleChainedBlock
void pushComplex8Array(ccmplx *x, int n)
Definition: adStack.c:502
void pushcontrol5b_(int *cc)
Definition: adStack.c:1331
void pushcharacterarray_(char *ii, int *ll)
Definition: adStack.c:1195
void pushcomplex16_(cdcmplx *val)
Definition: adStack.c:1275
void poppointer8_(void **val)
Definition: adStack.c:1295
void pushBit(int x)
Definition: adStack.c:834
void adstack_showpeaksize_()
Definition: adStack.c:1363
void pushcontrol6b_(int *cc)
Definition: adStack.c:1339
void pushPointer8(void *val)
Definition: adStack.c:804
void popInteger8Array(long *x, int n)
Definition: adStack.c:446
void pushCharacter(char val)
Definition: adStack.c:552
void popComplex8(ccmplx *val)
Definition: adStack.c:734
void popcomplex16array_(cdcmplx *ii, int *ll)
Definition: adStack.c:1191
void popComplex16(double complex *val)
Definition: adStack.c:762
void adStack_startRepeat()
Definition: adStack.c:235
void pushInteger4Array(int *x, int n)
Definition: adStack.c:422
void popControl8b(int *cc)
Definition: adStack.c:1044
void popControl3b(int *cc)
Definition: adStack.c:909
void pushControl8b(int cc)
Definition: adStack.c:1025
void pushReal8(double val)
Definition: adStack.c:608
void popreal16_(long double *val)
Definition: adStack.c:1247
void showRepetitionLevels()
Definition: adStack.c:153
int stackisthreadsafe_()
Definition: adStack.c:1387
void popInteger4(int *val)
Definition: adStack.c:678
void pushcontrol7b_(int *cc)
Definition: adStack.c:1347
void popReal16(long double *val)
Definition: adStack.c:650
void pushControl3b(int cc)
Definition: adStack.c:900
void pushInteger8(long val)
Definition: adStack.c:692
void popcontrol2b_(int *cc)
Definition: adStack.c:1311
void pushcontrol3b_(int *cc)
Definition: adStack.c:1315
void pushControl4b(int cc)
Definition: adStack.c:917
void pushreal4_(float *val)
Definition: adStack.c:1227
void popreal4_(float *val)
Definition: adStack.c:1231
void popcontrol5b_(int *cc)
Definition: adStack.c:1335
void pushreal8array_(double *ii, int *ll)
Definition: adStack.c:1163
void popControl2b(int *cc)
Definition: adStack.c:894
void popReal4Array(float *x, int n)
Definition: adStack.c:462
void pushreal16array_(long double *ii, int *ll)
Definition: adStack.c:1171
void pushReal4Array(float *x, int n)
Definition: adStack.c:454
void pushcontrol2b_(int *cc)
Definition: adStack.c:1307
void pushpointer4_(void **val)
Definition: adStack.c:1283
void popcharacterarray_(char *ii, int *ll)
Definition: adStack.c:1199
void pushinteger4array_(int *ii, int *ll)
Definition: adStack.c:1139
void popControl7b(int *cc)
Definition: adStack.c:1009
void popControl5b(int *cc)
Definition: adStack.c:951
void popCharacter(char *val)
Definition: adStack.c:566
void pushinteger8array_(long *ii, int *ll)
Definition: adStack.c:1147
void adstack_endrepeat_()
Definition: adStack.c:1135
void pushNArray(char *x, int nbChars)
Definition: adStack.c:389
void adStack_showPeakSize()
Definition: adStack.c:1064
void pushPointer4(void *val)
Definition: adStack.c:776
void pushBoolean(int x)
Definition: adStack.c:864
void popInteger4Array(int *x, int n)
Definition: adStack.c:430
void adstack_showstacksize_(int *label)
Definition: adStack.c:1371
void popBoolean(int *x)
Definition: adStack.c:870
void pushControl2b(int cc)
Definition: adStack.c:887
void popInteger8(long *val)
Definition: adStack.c:706
void pushReal16(long double *val)
Definition: adStack.c:636
void popinteger4array_(int *ii, int *ll)
Definition: adStack.c:1143
void pushcontrol4b_(int *cc)
Definition: adStack.c:1323
void popreal16array_(long double *ii, int *ll)
Definition: adStack.c:1175
void popcomplex8_(ccmplx *val)
Definition: adStack.c:1271
void setCurrentLocationToFreePush(RepetitionLevel *repetitionLevel)
Definition: adStack.c:119
void popComplex8Array(ccmplx *x, int n)
Definition: adStack.c:510
void pushcomplex16array_(cdcmplx *ii, int *ll)
Definition: adStack.c:1187
void popcharacter_(char *val)
Definition: adStack.c:1223
void popinteger8array_(long *ii, int *ll)
Definition: adStack.c:1151
void popReal8Array(double *x, int n)
Definition: adStack.c:478
void popcomplex8array_(ccmplx *ii, int *ll)
Definition: adStack.c:1183
void pushControl5b(int cc)
Definition: adStack.c:938
void pushreal4array_(float *ii, int *ll)
Definition: adStack.c:1155
void pushcomplex8_(ccmplx *val)
Definition: adStack.c:1267
int popBit()
Definition: adStack.c:848
void popcontrol3b_(int *cc)
Definition: adStack.c:1319
void popReal4(float *val)
Definition: adStack.c:594
int currentLocationStrictBelowFreePush(RepetitionLevel *repetitionLevel)
Definition: adStack.c:126
void popcontrol7b_(int *cc)
Definition: adStack.c:1351
void showLocation(DoubleChainedBlock *locBlock, int loc)
Definition: adStack.c:149
void popreal8array_(double *ii, int *ll)
Definition: adStack.c:1167
void popPointer4(void **val)
Definition: adStack.c:790
void popControl6b(int *cc)
Definition: adStack.c:978
char * popBlock()
Definition: adStack.c:366
#define BLOCK_SIZE
Definition: adStack.c:18
void pushControl1b(int cc)
Definition: adStack.c:877
void popCharacterArray(char *x, int n)
Definition: adStack.c:542
void popControl4b(int *cc)
Definition: adStack.c:928
void pushcontrol8b_(int *cc)
Definition: adStack.c:1355
void pushComplex8(ccmplx val)
Definition: adStack.c:720
void adstack_showtotaltraffic_()
Definition: adStack.c:1367
void popinteger4_(int *val)
Definition: adStack.c:1255
void pushCharacterArray(char *x, int n)
Definition: adStack.c:534
void checkPopToReadOnly()
Definition: adStack.c:198
void pushreal8_(double *val)
Definition: adStack.c:1235
void setBackPopToCurrentLocation(RepetitionLevel *repetitionLevel)
Definition: adStack.c:91
void pushInteger4(int val)
Definition: adStack.c:664
void popboolean_(int *x)
Definition: adStack.c:1383
void pushcontrol1b_(int *cc)
Definition: adStack.c:1299
void popbooleanarray_(char *x, int *n)
Definition: adStack.c:1211
void adstack_startrepeat_()
Definition: adStack.c:1127
void setFreePushToCurrentLocation(RepetitionLevel *repetitionLevel)
Definition: adStack.c:114
integer(kind=inttype) ii
Definition: blockette.F90:21
real(kind=realtype), dimension(:, :, :, :), pointer x
char contents[BLOCK_SIZE]
Definition: adStack.c:29
unsigned int rank
Definition: adStack.c:26
struct _DoubleChainedBlock * next
Definition: adStack.c:28
struct _DoubleChainedBlock * prev
Definition: adStack.c:27
DoubleChainedBlock * backPopBlock
Definition: adStack.c:37
int storedadbitibuf
Definition: adStack.c:44
DoubleChainedBlock * freePushBlock
Definition: adStack.c:41
unsigned int storedadbitbuf
Definition: adStack.c:43
DoubleChainedBlock * resumePointBlock
Definition: adStack.c:39
struct _RepetitionLevel * previous
Definition: adStack.c:45