Back to home page

MITgcm

 
 

    


File indexing completed on 2023-05-28 05:10:55 UTC

view on githubraw file Latest commit b4daa243 on 2023-05-28 03:53:22 UTC
b4daa24319 Shre*0001 /*
                0002  * TAPENADE Automatic Differentiation Engine
                0003  * Copyright (C) 1999-2021 Inria
                0004  * See the LICENSE.md file in the project root for more information.
                0005  *
                0006  */
                0007 
                0008 #include <string.h>
                0009 #include <stdio.h>
                0010 #include <stdlib.h>
                0011 #include "adContext.h"
                0012 
                0013 /* SPECIAL FOR THE NON-REGRESSION TESTS ON AMPI */
                0014 #include <mpi.h>
                0015 
                0016 static int dbad_mode, dbad_phase ;
                0017 static double dbad_ddeps = 1.e-6 ;
                0018 static double dbad_seed = 0.137 ;
                0019 static double dbad_currentSeed = 0.0 ;
                0020 static double dbad_condensed_val, dbad_condensed_tgt, dbad_condensed_adj ;
                0021 
                0022 double dbad_nextRandom() {
                0023   dbad_currentSeed += dbad_seed ;
                0024   if (dbad_currentSeed>=1.0) dbad_currentSeed-=1.0 ;
                0025   /* Return a value in range [1.0 2.0[ */
                0026   return dbad_currentSeed+1.0 ;
                0027 }
                0028 
                0029 void adContextTgt_init(double epsilon, double seed) {
                0030   int world_rank;
                0031   MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
                0032   dbad_mode = 1 ;
                0033   dbad_ddeps = epsilon ;
                0034   dbad_seed = seed ;
                0035   char* phase = getenv("DBAD_PHASE") ;
                0036   if (phase==NULL) {
                0037     printf("Please set DBAD_PHASE environment variable to 1 (perturbed) or 2 (tangent)\n") ;
                0038     exit(0) ;
                0039   } else if (strcmp(phase,"2")==0) {
                0040     if (world_rank == 0) {
                0041       printf("Tangent code,  seed=%7.1e\n", seed) ;
                0042       printf("=============================================\n") ;
                0043     }
                0044     dbad_phase = 2 ;
                0045     dbad_currentSeed = 0.0 ;
                0046   } else if (strcmp(phase,"1")==0) {
                0047     if (world_rank == 0) {
                0048       printf("Perturbed run, seed=%7.1e, epsilon=%7.1e\n", seed, epsilon) ;
                0049       printf("=============================================\n") ;
                0050     }
                0051     dbad_phase = 1 ;
                0052     dbad_currentSeed = 0.0 ;
                0053   } else if (strcmp(phase,"99")==0) {
                0054     printf("INTERNAL INTERFACE TESTS, seed=%7.1e, epsilon=%7.1e\n", seed, epsilon) ;
                0055     printf("=============================================\n") ;
                0056     dbad_phase = 99 ;
                0057   } else {
                0058     printf("DBAD_PHASE environment variable must be set to 1 or 2\n") ;
                0059     exit(0) ;
                0060   }
                0061 }
                0062 
                0063 void adContextTgt_initReal8(char* varname, double *indep, double *indepd) {
                0064   *indepd = dbad_nextRandom() ;
                0065   if (dbad_phase==1)
                0066     *indep = (*indep)+dbad_ddeps*(*indepd) ;
                0067   else if (dbad_phase==99)
                0068     printf("initReal8 of %s: %24.16e //%24.16e\n", varname, *indep, *indepd) ;
                0069 }
                0070 
                0071 void adContextTgt_initReal8Array(char* varname, double *indep, double *indepd, int length) {
                0072   int i ;
                0073   for (i=0 ; i<length ; ++i) {
                0074     indepd[i] = dbad_nextRandom() ;
                0075   }
                0076   if (dbad_phase==1) {
                0077     for (i=0 ; i<length ; ++i) {
                0078       indep[i] = indep[i]+dbad_ddeps*indepd[i] ;
                0079     }
                0080   } else if (dbad_phase==99) {
                0081     printf("initReal8Array of %s, length=%i:\n", varname, length) ;
                0082     for (i=0 ; i<length ; ++i)
                0083       printf("    %i:%24.16e //%24.16e",i,indep[i],indepd[i]) ;
                0084     printf("\n") ;
                0085   }
                0086 }
                0087 
                0088 void adContextTgt_initReal4(char* varname, float *indep, float *indepd) {
                0089   *indepd = (float)dbad_nextRandom() ;
                0090   if (dbad_phase==1)
                0091     *indep = (*indep)+dbad_ddeps*(*indepd) ;
                0092   else if (dbad_phase==99)
                0093     printf("initReal4 of %s: %24.16e //%24.16e\n", varname, *indep, *indepd) ;
                0094 }
                0095 
                0096 void adContextTgt_initReal4Array(char* varname, float *indep, float *indepd, int length) {
                0097   int i ;
                0098   for (i=0 ; i<length ; ++i) {
                0099     indepd[i] = (float)dbad_nextRandom() ;
                0100   }
                0101   if (dbad_phase==1) {
                0102     for (i=0 ; i<length ; ++i) {
                0103       indep[i] = indep[i]+dbad_ddeps*indepd[i] ;
                0104     }
                0105   } else if (dbad_phase==99) {
                0106     printf("initReal4Array of %s, length=%i:\n", varname, length) ;
                0107     for (i=0 ; i<length ; ++i)
                0108       printf("    %i:%24.16e //%24.16e",i,indep[i],indepd[i]) ;
                0109     printf("\n") ;
                0110   }
                0111 }
                0112 
                0113 void adContextTgt_initComplex16(char* varname, cdcmplx *indep, cdcmplx *indepd) {
                0114   indepd->dr = dbad_nextRandom() ;
                0115   indepd->di = dbad_nextRandom() ;
                0116   if (dbad_phase==1) {
                0117     indep->dr = indep->dr + dbad_ddeps*indepd->dr ;
                0118     indep->di = indep->di + dbad_ddeps*indepd->di ;
                0119   } else if (dbad_phase==99)
                0120     printf("initComplex16 of %s: %24.16e+i%24.16e //%24.16e+i%24.16e\n",
                0121            varname, indep->dr, indep->di, indepd->dr, indepd->di) ;
                0122 }
                0123 
                0124 void adContextTgt_initComplex16Array(char* varname, cdcmplx *indep, cdcmplx *indepd, int length) {
                0125   int i ;
                0126   for (i=0 ; i<length ; ++i) {
                0127     indepd[i].dr = dbad_nextRandom() ;
                0128     indepd[i].di = dbad_nextRandom() ;
                0129   }
                0130   if (dbad_phase==1) {
                0131     for (i=0 ; i<length ; ++i) {
                0132       indep[i].dr = indep[i].dr+dbad_ddeps*indepd[i].dr ;
                0133       indep[i].di = indep[i].di+dbad_ddeps*indepd[i].di ;
                0134     }
                0135   } else if (dbad_phase==99) {
                0136     printf("initComplex16Array of %s, length=%i:\n", varname, length) ;
                0137     for (i=0 ; i<length ; ++i)
                0138       printf("    %i:%24.16e+i%24.16e //%24.16e+i%24.16e",
                0139              i,indep[i].dr,indep[i].di,indepd[i].dr,indepd[i].di) ;
                0140     printf("\n") ;
                0141   }
                0142 }
                0143 
                0144 void adContextTgt_initComplex8(char* varname, ccmplx *indep, ccmplx *indepd) {
                0145   indepd->r = (float)dbad_nextRandom() ;
                0146   indepd->i = (float)dbad_nextRandom() ;
                0147   if (dbad_phase==1) {
                0148     indep->r = indep->r + dbad_ddeps*indepd->r ;
                0149     indep->i = indep->i + dbad_ddeps*indepd->i ;
                0150   } else if (dbad_phase==99)
                0151     printf("initComplex8 of %s: %24.16e+i%24.16e //%24.16e+i%24.16e\n",
                0152            varname, indep->r, indep->i, indepd->r, indepd->i) ;
                0153 }
                0154 
                0155 void adContextTgt_initComplex8Array(char* varname, ccmplx *indep, ccmplx *indepd, int length) {
                0156   int i ;
                0157   for (i=0 ; i<length ; ++i) {
                0158     indepd[i].r = (float)dbad_nextRandom() ;
                0159     indepd[i].i = (float)dbad_nextRandom() ;
                0160   }
                0161   if (dbad_phase==1) {
                0162     for (i=0 ; i<length ; ++i) {
                0163       indep[i].r = indep[i].r+dbad_ddeps*indepd[i].r ;
                0164       indep[i].i = indep[i].i+dbad_ddeps*indepd[i].i ;
                0165     }
                0166   } else if (dbad_phase==99) {
                0167     printf("initComplex8Array of %s, length=%i:\n", varname, length) ;
                0168     for (i=0 ; i<length ; ++i)
                0169       printf("    %i:%24.16e+i%24.16e //%24.16e+i%24.16e",
                0170              i,indep[i].r,indep[i].i,indepd[i].r,indepd[i].i) ;
                0171     printf("\n") ;
                0172   }
                0173 }
                0174 
                0175 void adContextTgt_startConclude() {
                0176   dbad_currentSeed= 0.0 ;
                0177   dbad_condensed_val = 0.0 ;
                0178   dbad_condensed_tgt = 0.0 ;
                0179 }
                0180 
                0181 void adContextTgt_concludeReal8(char* varname, double dep, double depd) {
                0182   double depb = dbad_nextRandom() ;
                0183   dbad_condensed_val += depb*(dep) ;
                0184   if (dbad_phase==2 || dbad_phase==1)
                0185     dbad_condensed_tgt += depb*(depd) ;
                0186   else if (dbad_phase==99)
                0187     printf("concludeReal8 of %s [%24.16e *] %24.16e //%24.16e\n", varname, depb, dep, depd) ;
                0188 }
                0189 
                0190 void adContextTgt_concludeReal8Array(char* varname, double *dep, double *depd, int length) {
                0191   int i ;
                0192   double depb ;
                0193   if (dbad_phase==99) printf("concludeReal8Array of %s, length=%i:\n", varname, length) ;
                0194   for (i=0 ; i<length ; ++i) {
                0195     depb = dbad_nextRandom() ;
                0196     dbad_condensed_val += depb*dep[i] ;
                0197     if (dbad_phase==2 || dbad_phase==1) {
                0198        dbad_condensed_tgt += depb*depd[i] ;
                0199     } else if (dbad_phase==99) {
                0200       printf("    %i:[%24.16e *] %24.16e //%24.16e",i,depb,dep[i],depd[i]) ;
                0201     }
                0202   }
                0203   if (dbad_phase==99) printf("\n") ;
                0204 }
                0205 
                0206 void adContextTgt_concludeReal4(char* varname, float dep, float depd) {
                0207   float depb = (float)dbad_nextRandom() ;
                0208   dbad_condensed_val += depb*(dep) ;
                0209   if (dbad_phase==2 || dbad_phase==1)
                0210     dbad_condensed_tgt += depb*(depd) ;
                0211   else if (dbad_phase==99)
                0212     printf("concludeReal4 of %s [%24.16e *] %24.16e //%24.16e\n", varname, depb, dep, depd) ;
                0213 }
                0214 
                0215 void adContextTgt_concludeReal4Array(char* varname, float *dep, float *depd, int length) {
                0216   int i ;
                0217   float depb ;
                0218   if (dbad_phase==99) printf("concludeReal4Array of %s, length=%i:\n", varname, length) ;
                0219   for (i=0 ; i<length ; ++i) {
                0220     depb = (float)dbad_nextRandom() ;
                0221     dbad_condensed_val += depb*dep[i] ;
                0222     if (dbad_phase==2 || dbad_phase==1) {
                0223        dbad_condensed_tgt += depb*depd[i] ;
                0224     } else if (dbad_phase==99) {
                0225       printf("    %i:[%24.16e *] %24.16e //%24.16e",i,depb,dep[i],depd[i]) ;
                0226     }
                0227   }
                0228   if (dbad_phase==99) printf("\n") ;
                0229 }
                0230 
                0231 void adContextTgt_concludeComplex16(char* varname, cdcmplx *dep, cdcmplx *depd) {
                0232   double depbr = dbad_nextRandom() ;
                0233   double depbi = dbad_nextRandom() ;
                0234   dbad_condensed_val += depbr*(dep->dr) + depbi*(dep->di);
                0235   if (dbad_phase==2 || dbad_phase==1)
                0236     dbad_condensed_tgt += depbr*(depd->dr) + depbi*(depd->di) ;
                0237   else if (dbad_phase==99)
                0238     printf("concludeComplex16 of %s [%24.16e;%24.16e *] %24.16e+i%24.16e //%24.16e+i%24.16e\n",
                0239            varname, depbr, depbi, dep->dr, dep->di, depd->dr, depd->di) ;
                0240 }
                0241 
                0242 void adContextTgt_concludeComplex16Array(char* varname, cdcmplx *dep, cdcmplx *depd, int length) {
                0243   int i ;
                0244   double depbr, depbi ;
                0245   if (dbad_phase==99) printf("concludeComplex16Array of %s, length=%i:\n", varname, length) ;
                0246   for (i=0 ; i<length ; ++i) {
                0247     depbr = dbad_nextRandom() ;
                0248     depbi = dbad_nextRandom() ;
                0249     dbad_condensed_val += depbr*(dep[i].dr) + depbi*(dep[i].di);
                0250     if (dbad_phase==2 || dbad_phase==1) {
                0251       dbad_condensed_tgt += depbr*(depd[i].dr) + depbi*(depd[i].di) ;
                0252     } else if (dbad_phase==99) {
                0253       printf("    %i:[%24.16e;%24.16e *] %24.16e //%24.16e",
                0254              i, depbr, depbi, dep[i].dr, dep[i].di, depd[i].dr, depd[i].di) ;
                0255     }
                0256   }
                0257   if (dbad_phase==99) printf("\n") ;
                0258 }
                0259 
                0260 void adContextTgt_concludeComplex8(char* varname, ccmplx *dep, ccmplx *depd) {
                0261   float depbr = (float)dbad_nextRandom() ;
                0262   float depbi = (float)dbad_nextRandom() ;
                0263   dbad_condensed_val += depbr*(dep->r) + depbi*(dep->i) ;
                0264   if (dbad_phase==2 || dbad_phase==1)
                0265     dbad_condensed_tgt += depbr*(depd->r) + depbi*(depd->i) ;
                0266   else if (dbad_phase==99)
                0267     printf("concludeComplex8 of %s [%24.16e;%24.16e *] %24.16e+i%24.16e //%24.16e+i%24.16e\n",
                0268            varname, depbr, depbi, dep->r, dep->i, depd->r, depd->i) ;
                0269 }
                0270 
                0271 void adContextTgt_concludeComplex8Array(char* varname, ccmplx *dep, ccmplx *depd, int length) {
                0272   int i ;
                0273   float depbr, depbi ;
                0274   if (dbad_phase==99) printf("concludeComplex8Array of %s, length=%i:\n", varname, length) ;
                0275   for (i=0 ; i<length ; ++i) {
                0276     depbr = (float)dbad_nextRandom() ;
                0277     depbi = (float)dbad_nextRandom() ;
                0278     dbad_condensed_val += depbr*(dep[i].r) + depbi*(dep[i].i) ;
                0279     if (dbad_phase==2 || dbad_phase==1) {
                0280       dbad_condensed_tgt += depbr*(depd[i].r) + depbi*(depd[i].i) ;
                0281     } else if (dbad_phase==99) {
                0282       printf("    %i:[%24.16e;%24.16e *] %24.16e+i%24.16e //%24.16e+i%24.16e",
                0283              i, depbr, depbi, dep[i].r, dep[i].i, depd[i].r, depd[i].i) ;
                0284     }
                0285   }
                0286   if (dbad_phase==99) printf("\n") ;
                0287 }
                0288 
                0289 void adContextTgt_conclude() {
                0290   double reducedVal, reducedTgt ;
                0291   MPI_Reduce(&dbad_condensed_val,&reducedVal,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
                0292   if (dbad_phase==2)
                0293     MPI_Reduce(&dbad_condensed_tgt,&reducedTgt,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
                0294   int world_rank;
                0295   MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
                0296   if (world_rank == 0) {
                0297   if (dbad_phase==2) {
                0298       printf("[seed:%7.1e] Reduced Condensed result : %24.16e\n", dbad_seed, reducedVal) ;
                0299       printf("[seed:%7.1e] Reduced Condensed tangent: %24.16e\n", dbad_seed, reducedTgt) ;
                0300   } else if (dbad_phase==1) {
                0301       printf("[seed:%7.1e] Reduced Condensed perturbed result : %24.16e (epsilon:%7.1e)\n",
                0302              dbad_seed, reducedVal, dbad_ddeps) ;
                0303       printf("[seed:%7.1e] Reduced Condensed perturbed tangent : %24.16e (epsilon:%7.1e)\n",
                0304              dbad_seed, reducedTgt, dbad_ddeps) ;
                0305     }
                0306   }
                0307 }
                0308 
                0309 void adContextAdj_init(double seed) {
                0310   int world_rank;
                0311   MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
                0312   dbad_mode = 0 ;
                0313   dbad_seed = seed ;
                0314   char* phase = getenv("DBAD_PHASE") ;
                0315   if (phase==NULL) {
                0316     dbad_phase = 0 ;
                0317   } else if (strcmp(phase,"99")==0) {
                0318     dbad_phase = 99 ;
                0319     printf("INTERNAL INTERFACE TESTS, seed=%7.1e\n", seed) ;
                0320   } else {
                0321     dbad_phase = 0 ;
                0322   }
                0323   if (world_rank == 0) {
                0324   printf("Adjoint code,  seed=%7.1e\n", seed) ;
                0325   printf("===================================\n") ;
                0326   }
                0327   dbad_currentSeed = 0.0 ;
                0328 }
                0329 
                0330 void adContextAdj_initReal8(char* varname, double *dep, double *depb) {
                0331   *depb = dbad_nextRandom() ;
                0332   if (dbad_phase==99)
                0333     printf("initReal8 of %s %24.16e\n", varname, *depb) ;
                0334 }
                0335 
                0336 void adContextAdj_initReal8Array(char* varname, double *dep, double *depb, int length) {
                0337   int i ;
                0338   for (i=0 ; i<length ; ++i) {
                0339     depb[i] = dbad_nextRandom() ;
                0340   }
                0341   if (dbad_phase==99) {
                0342     printf("initReal8Array of %s, length=%i\n", varname, length) ;
                0343     for (i=0 ; i<length ; ++i)
                0344       printf("    %i:%24.16e", i, depb[i]) ;
                0345     printf("\n") ;
                0346   }
                0347 }
                0348 
                0349 void adContextAdj_initReal4(char* varname, float *dep, float *depb) {
                0350   *depb = (float)dbad_nextRandom() ;
                0351   if (dbad_phase==99)
                0352     printf("initReal4 of %s %24.16e\n", varname, *depb) ;
                0353 }
                0354 
                0355 void adContextAdj_initReal4Array(char* varname, float *dep, float *depb, int length) {
                0356   int i ;
                0357   for (i=0 ; i<length ; ++i) {
                0358     depb[i] = (float)dbad_nextRandom() ;
                0359   }
                0360   if (dbad_phase==99) {
                0361     printf("initReal4Array of %s, length=%i\n", varname, length) ;
                0362     for (i=0 ; i<length ; ++i)
                0363       printf("    %i:%24.16e",i, depb[i]) ;
                0364     printf("\n") ;
                0365   }
                0366 }
                0367 
                0368 void adContextAdj_startConclude() {
                0369   dbad_currentSeed= 0.0 ;
                0370   dbad_condensed_adj = 0.0 ;
                0371 }
                0372 
                0373 void adContextAdj_concludeReal8(char* varname, double dep, double depb) {
                0374   double depd = dbad_nextRandom() ;
                0375   dbad_condensed_adj += depd*depb ;
                0376   if (dbad_phase==99)
                0377     printf("concludeReal8 of %s [%24.16e *]%24.16e\n", varname, depd, depb) ;
                0378 }
                0379 
                0380 void adContextAdj_concludeReal8Array(char* varname, double *dep, double *depb, int length) {
                0381   int i ;
                0382   double depd ;
                0383   if (dbad_phase==99) printf("concludeReal8Array of %s, length=%i:\n", varname, length) ;
                0384   for (i=0 ; i<length ; ++i) {
                0385     depd = dbad_nextRandom() ;
                0386     dbad_condensed_adj += depd*depb[i] ;
                0387     if (dbad_phase==99) printf("    %i:[%24.16e *] %24.16e",i,depd,depb[i]) ;
                0388   }
                0389   if (dbad_phase==99) printf("\n") ;
                0390 }
                0391 
                0392 void adContextAdj_concludeReal4(char* varname, float dep, float depb) {
                0393   float depd = (float)dbad_nextRandom() ;
                0394   dbad_condensed_adj += depd*depb ;
                0395   if (dbad_phase==99)
                0396     printf("concludeReal4 of %s [%24.16e *]%24.16e\n", varname, depd, depb) ;
                0397 }
                0398 
                0399 void adContextAdj_concludeReal4Array(char* varname, float *dep, float *depb, int length) {
                0400   int i ;
                0401   float depd ;
                0402   if (dbad_phase==99) printf("concludeReal4Array of %s, length=%i:\n", varname, length) ;
                0403   for (i=0 ; i<length ; ++i) {
                0404     depd = (float)dbad_nextRandom() ;
                0405     dbad_condensed_adj += depd*depb[i] ;
                0406     if (dbad_phase==99) printf("    %i:[%24.16e *] %24.16e",i,depd,depb[i]) ;
                0407   }
                0408   if (dbad_phase==99) printf("\n") ;
                0409 }
                0410 
                0411 void adContextAdj_conclude() {
                0412   double reducedAdj ;
                0413   MPI_Reduce(&dbad_condensed_adj,&reducedAdj,1,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
                0414   int world_rank;
                0415   MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
                0416   if (world_rank == 0) {
                0417     printf("[seed:%7.1e] Reduced Condensed adjoint: %24.16e\n", dbad_seed, reducedAdj) ;
                0418   }
                0419 }
                0420 
                0421 //############## INTERFACE PROCEDURES CALLED FROM FORTRAN ################
                0422 
                0423 void adcontexttgt_init_(double *epsilon, double *seed) {
                0424   adContextTgt_init(*epsilon, *seed) ;
                0425 }
                0426 
                0427 void adcontexttgt_initreal8_(char* varname, double *indep, double *indepd) {
                0428   adContextTgt_initReal8(varname, indep, indepd) ;
                0429 }
                0430 
                0431 void adcontexttgt_initreal8array_(char* varname, double *indep, double *indepd, int *length) {
                0432   adContextTgt_initReal8Array(varname, indep, indepd, *length) ;
                0433 }
                0434 
                0435 void adcontexttgt_initreal4_(char* varname, float *indep, float *indepd) {
                0436   adContextTgt_initReal4(varname, indep, indepd) ;
                0437 }
                0438 
                0439 void adcontexttgt_initreal4array_(char* varname, float *indep, float *indepd, int *length) {
                0440   adContextTgt_initReal4Array(varname, indep, indepd, *length) ;
                0441 }
                0442 
                0443 void adcontexttgt_initcomplex16_(char* varname, cdcmplx *indep, cdcmplx *indepd) {
                0444   adContextTgt_initComplex16(varname, indep, indepd) ;
                0445 }
                0446 
                0447 void adcontexttgt_initcomplex16array_(char* varname, cdcmplx *indep, cdcmplx *indepd, int *length) {
                0448   adContextTgt_initComplex16Array(varname, indep, indepd, *length) ;
                0449 }
                0450 
                0451 void adcontexttgt_initcomplex8_(char* varname, ccmplx *indep, ccmplx *indepd) {
                0452   adContextTgt_initComplex8(varname, indep, indepd) ;
                0453 }
                0454 
                0455 void adcontexttgt_initcomplex8array_(char* varname, ccmplx *indep, ccmplx *indepd, int *length) {
                0456   adContextTgt_initComplex8Array(varname, indep, indepd, *length) ;
                0457 }
                0458 
                0459 void adcontexttgt_startconclude_() {
                0460   adContextTgt_startConclude() ;
                0461 }
                0462 
                0463 void adcontexttgt_concludereal8_(char* varname, double *dep, double *depd) {
                0464   if (dbad_phase==99)
                0465       printf("concludereal8_ of %s: \n", varname);
                0466   adContextTgt_concludeReal8(varname, *dep, *depd) ;
                0467 }
                0468 
                0469 void adcontexttgt_concludereal8array_(char* varname, double *dep, double *depd, int *length) {
                0470   if (dbad_phase==99)
                0471       printf("concludereal8array_ of %s: \n", varname);
                0472   adContextTgt_concludeReal8Array(varname, dep, depd, *length) ;
                0473 }
                0474 
                0475 void adcontexttgt_concludereal4_(char* varname, float *dep, float *depd) {
                0476   adContextTgt_concludeReal4(varname, *dep, *depd) ;
                0477 }
                0478 
                0479 void adcontexttgt_concludereal4array_(char* varname, float *dep, float *depd, int *length) {
                0480   adContextTgt_concludeReal4Array(varname, dep, depd, *length) ;
                0481 }
                0482 
                0483 void adcontexttgt_concludecomplex16_(char* varname, cdcmplx *dep, cdcmplx *depd) {
                0484   adContextTgt_concludeComplex16(varname, dep, depd) ;
                0485 }
                0486 
                0487 void adcontexttgt_concludecomplex16array_(char* varname, cdcmplx *dep, cdcmplx *depd, int *length) {
                0488   adContextTgt_concludeComplex16Array(varname, dep, depd, *length) ;
                0489 }
                0490 
                0491 void adcontexttgt_concludecomplex8_(char* varname, ccmplx *dep, ccmplx *depd) {
                0492   if (dbad_phase==99)
                0493       printf("concludecomplex8_ of %s: \n", varname);
                0494   adContextTgt_concludeComplex8(varname, dep, depd) ;
                0495 }
                0496 
                0497 void adcontexttgt_concludecomplex8array_(char* varname, ccmplx *dep, ccmplx *depd, int *length) {
                0498   if (dbad_phase==99)
                0499       printf("concludecomplex8array_ of %s: \n", varname);
                0500   adContextTgt_concludeComplex8Array(varname, dep, depd, *length) ;
                0501 }
                0502 
                0503 void adcontexttgt_conclude_() {
                0504   adContextTgt_conclude() ;
                0505 }
                0506 
                0507 void adcontextadj_init_(double *seed) {
                0508   adContextAdj_init(*seed) ;
                0509 }
                0510 
                0511 void adcontextadj_initreal8_(char* varname, double *dep, double *depb) {
                0512   if (dbad_phase==99)
                0513     printf("initreal8_ of %s \n", varname) ;
                0514   adContextAdj_initReal8(varname, dep, depb) ;
                0515 }
                0516 
                0517 void adcontextadj_initreal8array_(char* varname, double *dep, double *depb, int *length) {
                0518   if (dbad_phase==99)
                0519     printf("initreal8array_ of %s \n", varname) ;
                0520   adContextAdj_initReal8Array(varname, dep, depb, *length) ;
                0521 }
                0522 
                0523 void adcontextadj_initreal4_(char* varname, float *dep, float *depb) {
                0524   adContextAdj_initReal4(varname, dep, depb) ;
                0525 }
                0526 
                0527 void adcontextadj_initreal4array_(char* varname, float *dep, float *depb, int *length) {
                0528   adContextAdj_initReal4Array(varname, dep, depb, *length) ;
                0529 }
                0530 
                0531 void adcontextadj_startconclude_() {
                0532   adContextAdj_startConclude() ;
                0533 }
                0534 
                0535 void adcontextadj_concludereal8_(char* varname, double *dep, double *depb) {
                0536   if (dbad_phase==99)
                0537     printf("concludereal8_ of %s \n", varname) ;
                0538   adContextAdj_concludeReal8(varname, *dep, *depb) ;
                0539 }
                0540 
                0541 void adcontextadj_concludereal8array_(char* varname, double *dep, double *depb, int *length) {
                0542   if (dbad_phase==99)
                0543     printf("concludereal8array_ of %s \n", varname) ;
                0544   adContextAdj_concludeReal8Array(varname, dep, depb, *length) ;
                0545 }
                0546 
                0547 void adcontextadj_concludereal4_(char* varname, float *dep, float *depb) {
                0548   if (dbad_phase==99)
                0549     printf("concludereal4_ of %s \n", varname) ;
                0550   adContextAdj_concludeReal4(varname, *dep, *depb) ;
                0551 }
                0552 
                0553 void adcontextadj_concludereal4array_(char* varname, float *dep, float *depb, int *length) {
                0554   if (dbad_phase==99)
                0555     printf("concludereal4array_ of %s \n", varname) ;
                0556   adContextAdj_concludeReal4Array(varname, dep, depb, *length) ;
                0557 }
                0558 
                0559 void adcontextadj_conclude_() {
                0560   adContextAdj_conclude() ;
                0561 }