Rose2xaif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StateManager.cpp
Go to the documentation of this file.
1 
13 #include <iostream>
14 #include <fstream>
15 #include <sstream>
16 #include <algorithm>
17 
18 #include "boost/tokenizer.hpp" // use local boost subset
19 //#include "util/Filer.hpp"
20 #include "util/StateManager.hpp"
21 #include "util/Messages.hpp"
22 #include "Version.hpp"
23 //#include "util/FindAppHome.hpp"
24 
25 #include <sys/stat.h>
26 
27 namespace rose2xaif
28 {
29 
51 
52  // Initialize static singleton instance
53  StateManager* StateManager::p_instance = NULL;
54 
55 #ifndef AD_FORTRAN_SPECIFIC
56  const char* StateManager::ourValWrapperName = "DERIV_val";
57  const char* StateManager::ourDerivWrapperName = "DERIV_TYPE_ref";
58 #else
59  const char* StateManager::ourValWrapperName = "__value__";
60  const char* StateManager::ourDerivWrapperName = "__deriv__";
61 #endif
62 
63  StateManager*
64  StateManager::getInstance(const char* argv0)
65  {
66  if (StateManager::p_instance == NULL) {
67  StateManager::p_instance = new StateManager(std::string(argv0));
68  }
70  }
71 
72  /* Section: Constructor (protected)
73  */
74  StateManager::StateManager(const std::string& argv0) :
75  flags(0), nDerivOrder(0), prefix("ad_"), debugLevel(0), quiet(false),
76  msgContext("ADIC"), openMPflag(false), sparsehandlingflag(false),
77  myStaticAnnotationsFlag(false), max_axpy(0),myTemplateSgFile_p(0), adolcflag(false)
78  {
79  leaveTempFiles = false;
80  }
81 
83  void
84  StateManager::init(int a_flags, StringList& a_derivNames,
85  std::string a_mapModel, std::string a_headerFileName,
86  StringList& a_defines, StringList& a_inclDirs, //StringList& a_cntrlFiles,
87  int a_derivOrder)
88 
89  {
90  nDerivOrder = a_derivOrder;
91  flags = a_flags;
92  mapModel = a_mapModel;
93  headerFileName = a_headerFileName;
94  return;
95  }
96 
97 
98  /* Section: getDerivOrder
99  ***********************************************************************
100 
101  Description
102  Get the default value for the derivative order.
103  */
104  int
106  {
107  return nDerivOrder;
108  }
109 
110  /**********************************************************************
111  Section: Query functions
112  **********************************************************************/
113 
114  StringList&
116  {
117  return activeFuncNames;
118  }
119 
120  StringList&
122  {
123  return inactiveFuncNames;
124  }
125 
126  bool
128  {
129  return (find(activeFuncNames.begin(), activeFuncNames.end(), str)
130  != activeFuncNames.end());
131  }
132  /*
133  * Returns
134  *
135  */
136  bool
138  {
139  return (find(inactiveFuncNames.begin(), inactiveFuncNames.end(), str)
140  != inactiveFuncNames.end());
141  }
142 
143  StringList&
145  {
146  return activeVarNames;
147  }
148 
149  StringList&
151  {
152  return inactiveVarNames;
153  }
154 
155  bool
157  {
158  return (find(intrinsicNames.begin(), intrinsicNames.end(), str)
159  != intrinsicNames.end());
160  }
161 
162  /*
163  * Returns
164  *
165  */
166  bool
168  {
169  return (find(noPrefixFuncNames.begin(), noPrefixFuncNames.end(), str)
170  != noPrefixFuncNames.end());
171  }
172  void
174  {
175  intrinsicNames.push_back(str);
176  }
177 
178  StringList&
180  {
181  return noPrefixFuncNames;
182  }
183 
184  StringList&
186  {
187  return uninlinedIncludeNames;
188  }
189 
190  StringList&
192  {
193  return inactiveTypeNames;
194  }
195 
196  bool
198  {
199  StringList::iterator iter;
200  for (iter = includeDirs.begin(); iter!= includeDirs.end(); ++iter) {
201  if((fname.find(*iter)!=std::string::npos ))
202  return TRUE;
203  }
204  return FALSE;
205  }
206 
207  bool
209  {
210 
211  return TRUE ;
212  //debugMsg(5, " In StateManager::isInactiveTypeName for typename " << psz);
213  /*StringList::iterator iter;
214  debugMsg(1, "New inactive type lists are ");
215  for (iter = inactiveTypeNames.begin(); iter!= inactiveTypeNames.end(); ++iter) {
216  debugMsg(1, *iter);
217  }
218  debugMsg(1, "New inactive type lists are BASIC");
219  for (iter = inactiveBasicTypeNames.begin(); iter!= inactiveBasicTypeNames.end(); ++iter) {
220  debugMsg(1, *iter);
221  }
222  debugMsg(1, "New inactive type lists are STRUCTURE");
223  for (iter = inactiveStructureTypeNames.begin(); iter!= inactiveStructureTypeNames.end(); ++iter) {
224  debugMsg(1, *iter);
225  }
226  debugMsg(1, "New inactive type lists are CLASS");
227  for (iter = inactiveClassTypeNames.begin(); iter!= inactiveClassTypeNames.end(); ++iter) {
228  debugMsg(1, *iter);
229  }*/
230  return (find(inactiveTypeNames.begin(), inactiveTypeNames.end(), psz)
231  != inactiveTypeNames.end());
232  /*return (find(inactiveTypeNames.begin(), inactiveTypeNames.end(), psz)
233  != inactiveTypeNames.end());
234  return (find(inactiveTypeNames.begin(), inactiveTypeNames.end(), psz)
235  != inactiveTypeNames.end());
236  */
237  }
238 
239  bool
241  {
242  std::string str(psz);
243  return (str == DERIV_TYPE_STR || isInactiveTypeName(psz));
244  }
245 
246  StringList&
248  {
249  return standardIncludeNames;
250  }
251 
252  StringList&
254  {
255  return includeDirs;
256  }
257 
258  StringList&
260  {
261  return controlFiles;
262  }
263 
268  /* std::string
269  StateManager::getTempFileName(int bStore, const char* pszExtension)
270  {
271  static int count = 0;
272  char buf[1000];
273  if (!pszExtension)
274  pszExtension = "";
275 
276  sprintf(buf, ".adic.tmp.%s%d", pszExtension, count++);
277  std::string& str = *(new std::string(buf));
278  if (bStore) {
279  tempFileNames.push_back(str);
280  }
281  return str;
282  }
283 */
284 
285 
290  std::string
292  {
293  std::string disclaimer;
294  std::ostringstream disc;
295  time_t t = time(0);
296  struct tm* ptm = localtime(&t);
297  char szTodayDate[50];
298  strftime(szTodayDate, 50, "%m/%d/%y %H:%M:%S", ptm);
299 
300  disc
301 #ifndef AD_FORTRAN_SPECIFIC
302  << "/************************** DISCLAIMER ********************************/\n"
303  << "/* */\n"
304  << "/* This file was generated on " << szTodayDate
305  << " by */\n" << "/* ADIC version "
306 // << ADIC_VERSION_MAJOR << "." << ADIC_VERSION_MINOR << "."
307 // << ADIC_VERSION_SUBMINOR << "." << ADIC_VERSION_PATCH << " */\n"
308  << "/* */\n"
309  << "/* ADIC was prepared as an account of work sponsored by an */\n"
310  << "/* agency of the United States Government and the University of */\n"
311  << "/* Chicago. NEITHER THE AUTHOR(S), THE UNITED STATES GOVERNMENT */\n"
312  << "/* NOR ANY AGENCY THEREOF, NOR THE UNIVERSITY OF CHICAGO, INCLUDING */\n"
313  << "/* ANY OF THEIR EMPLOYEES OR OFFICERS, MAKES ANY WARRANTY, EXPRESS */\n"
314  << "/* OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR */\n"
315  << "/* THE ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION OR */\n"
316  << "/* PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE */\n"
317  << "/* PRIVATELY OWNED RIGHTS. */\n"
318  << "/* */\n"
319  << "/**********************************************************************/\n";
320 #else
321  << "! ************************** DISCLAIMER *************************\n"
322  << "! This file was generated on " << szTodayDate << " by something \n"
323  << "! ***************************************************************\n";
324 #endif
325 
326  disclaimer = disc.str();
327  return disclaimer;
328  }
329 
330 #ifdef AD_FORTRAN_SPECIFIC
331  SgType* StateManager::makeActiveSgTypeP(SgFile* aFileP) {
332  static SgType* ourActiveType_p(0);
333  if (ourActiveType_p)
334  return ourActiveType_p;
335  SgGlobal* scope = globalScope(aFileP);
336  const char * name="active";
337  // BEGIN: logic copied from fortran_support.C : buildDerivedTypeStatementAndDefinition
338  SgClassDefinition* classDefinition = new SgClassDefinition();
339  classDefinition->setCaseInsensitive(true);
340  SgDerivedTypeStatement* classDeclaration = new SgDerivedTypeStatement(name,SgClassDeclaration::e_struct,NULL,classDefinition);
341  classDeclaration->set_definingDeclaration(classDeclaration);
342  SgDerivedTypeStatement* nondefiningClassDeclaration = new SgDerivedTypeStatement(name,SgClassDeclaration::e_struct,NULL,NULL);
343  nondefiningClassDeclaration->set_parent(scope);
344  if (nondefiningClassDeclaration->get_type () == NULL)
345  nondefiningClassDeclaration->set_type (SgClassType::createType(nondefiningClassDeclaration));
346  classDeclaration->set_type(nondefiningClassDeclaration->get_type());
347  classDeclaration->set_firstNondefiningDeclaration(nondefiningClassDeclaration);
348  nondefiningClassDeclaration->set_firstNondefiningDeclaration(nondefiningClassDeclaration);
349  nondefiningClassDeclaration->set_definingDeclaration(classDeclaration);
350  nondefiningClassDeclaration->setForward();
351  classDefinition->set_declaration(classDeclaration);
352  classDeclaration->set_scope(scope);
353  nondefiningClassDeclaration->set_scope(scope);
354  classDeclaration->set_parent(scope);
355  SgClassSymbol* classSymbol = new SgClassSymbol(nondefiningClassDeclaration);
356  scope->insert_symbol(name,classSymbol);
357  // END: logic copied from fortran_support.C : buildDerivedTypeStatementAndDefinition
358  return ourActiveType_p=classDeclaration->get_type();
359  }
360 #endif
361 
366  void
368  {
369  std::ostringstream buf;
370  std::ofstream hfile;
371  int i, j;
372 
373  // Beginning of header file
374 
375  buf << getDisclaimer() << std::endl;
376 
377  buf << "/*! \\file\n"
378  << "\n"
379  << " \\brief Preaccumulation macros for dense gradient arrays.\n"
380  << "\n"
381  << " Copyright (c) 2004--2011, UChicago Argonne, LLC <br>\n"
382  << " All rights reserved. <br>\n"
383  << " See $ROSE2XAIF_DIR/Copyright.txt for details. <br>\n"
384  << "\n"
385  << " */\n"
386  << "#ifndef __AD_GRAD_SAXPY_N_DENSE_H\n"
387  << "#define __AD_GRAD_SAXPY_N_DENSE_H\n"
388  << "\n#ifndef ADIC_GRAD_LENGTH";
389  if(getDifferentiationMode()=="forward")
390  buf <<"\n#include \"ad_types.h\"";
391  else
392  buf <<"\n#include \"ad_types.hpp\"";
393  buf <<"\n#else"
394  <<"\n#include \"ad_grad_length_types.h\""
395  <<"\n#endif"
396 // << "#include \"ad_grad.h\"\n"
397  << "\n"
398  << "#ifdef __cplusplus\n"
399  << "extern \"C\" {\n"
400  << "#endif\n";
401 
402  for (i = 1; i <= this->max_axpy; ++i) {
403  // Macro header
404  buf << "#define ADIC_Sax_" << i << "( \\" << std::endl;
405  for (j = 1; j <= i; ++j) {
406  buf << "\t\t\t__adic_a" << j << ", __adic_x" << j;
407  if (j < i) buf << ", \\" << std::endl;
408  }
409  buf << ", __adic_tgt) {\\" << std::endl;
410  // Type casts
411  buf << "\tint __adic_iCtr; double *__adic_gradz = DERIV_grad(__adic_tgt), \\" << std::endl;
412  for (j = 1; j <= i; ++j) {
413  buf << "\t\t\t*__adic_grad" << j << " = DERIV_grad(__adic_x" << j << ")";
414  if (j < i) buf << ", \\" << std::endl;
415  else buf << "; \\" << std::endl;
416  }\
417  // Loop
418  buf << "\tfor (__adic_iCtr = 0; __adic_iCtr < __ADIC_GradSize(); __adic_iCtr++) { \\" << std::endl;
419  buf << "\t\t__adic_gradz[__adic_iCtr] = ";
420  for (j = 1; j <= i; ++j) {
421  buf << "(__adic_a" << j << ") * __adic_grad" << j << "[__adic_iCtr]";
422  if (j < i) buf << " + \\" << std::endl << "\t\t\t";
423  else buf << "; \\" << std::endl;
424  }
425  buf << "\t} \\" << std::endl;
426  // End of macro
427  buf << "}" << std::endl << std::endl;
428 
429  }
430 
431  // End of file
432  buf << "#ifdef __cplusplus" << std::endl << "} /* closing brace for extern \"C\" */" << std::endl;
433  buf << "#endif" << std::endl << "#endif /* #ifndef __AD_GRAD_SAXPY_N_DENSE_H */" << std::endl;
434 
435  hfile.open("ad_grad_saxpy-n_dense.h");
436  hfile << buf.str();
437  hfile.close();
438  }
439 
444  void
446  {
447  std::ostringstream buf;
448  std::ofstream hfile;
449  int i, j;
450 
451  // Beginning of header file
452 
453  buf << getDisclaimer() << std::endl;
454 
455  buf << "/*! \\file\n"
456  << "\n"
457  << " \\brief Preaccumulation macros for dense gradient arrays.\n"
458  << "\n"
459  << " Copyright (c) 2004--2011, UChicago Argonne, LLC <br>\n"
460  << " All rights reserved. <br>\n"
461  << " See $ROSE2XAIF_DIR/Copyright.txt for details. <br>\n"
462  << "\n"
463  << " */\n"
464  << "#ifndef __AD_GRAD_SAXPY_N_SPARSE_H\n"
465  << "#define __AD_GRAD_SAXPY_N_SPARSE_H\n"
466  << "\n#ifdef ADIC_SPARSE_NO_GRAD"
467  <<"\n#include \"noderiv_sparslinc.h\""
468  <<"\n#include \"noderiv_sparsderiv.hpp\""
469  <<"\n#endif"
470  << "\n#ifdef ADIC_SPARSE"
471  <<"\n#include \"sparslinc.h\""
472  <<"\n#include \"sparsderiv.hpp\""
473  <<"\n#endif"
474  << "\n"
475  << "#ifdef __cplusplus\n"
476  << "extern \"C\" {\n"
477  << "#endif\n";
478 
479  for (i = 1; i <= this->max_axpy; ++i) {
480  // Macro header
481  buf << "#define ADIC_Sax_" << i << "( \\" << std::endl;
482  for (j = 1; j <= i; ++j) {
483  buf << "\t\t\t__adic_a" << j << ", __adic_x" << j;
484  if (j < i) buf << ", \\" << std::endl;
485  }
486  buf << ", __adic_tgt) {\\" << std::endl;
487  // Type casts
488  buf<<"\t(__adic_tgt).indexSet = (__adic_x1).indexSet; \\" << std::endl;
489  // Loop
490  if(i>1){
491  buf<<"\tstd::set<int>::iterator srcSetIter; \\" << std::endl;
492  }
493  for (j = 2; j <= i; ++j) {
494  buf << "\tsrcSetIter = (__adic_x" << j << ").indexSet.begin(); \\" << std::endl;
495  buf << "\tfor (; srcSetIter != (__adic_x" << j << ").indexSet.end(); srcSetIter++) { \\" << std::endl;
496  buf << "\t\t(__adic_tgt).indexSet.insert(*srcSetIter); \\" << std::endl;
497  buf << "\t} \\" << std::endl;
498  }
499  // End of macro
500  buf << "}" << std::endl << std::endl;
501  }
502 
503  // End of file
504  buf << "#ifdef __cplusplus" << std::endl << "} /* closing brace for extern \"C\" */" << std::endl;
505  buf << "#endif" << std::endl << "#endif /* #ifndef __AD_GRAD_SAXPY_N_SPARSE_H */" << std::endl;
506 
507  hfile.open("ad_grad_saxpy-n_sparse.h");
508  hfile << buf.str();
509  hfile.close();
510  }
511 
512  void
514  {
515  std::ostringstream buf;
516  std::ofstream hfile;
517  int i, j;
518 
519  // Beginning of header file
520 
521  buf << getDisclaimer() << std::endl;
522 
523  buf << "/*! \\file\n"
524  << "\n"
525  << " \\brief Registration of ADOL-C external functions.\n"
526  << "\n"
527  << " Copyright (c) 2004--2011, UChicago Argonne, LLC <br>\n"
528  << " All rights reserved. <br>\n"
529  << " See $ROSE2XAIF_DIR/Copyright.txt for details. <br>\n"
530  << "\n"
531  << " */\n"
532  << "#ifndef __AD_REGISTER_EXTERNAL_FUNCTIONS_H\n"
533  << "#define __AD_REGISTER_EXTERNAL_FUNCTIONS_H\n"
534  << "\n#include <adolc/externfcts.h>"
535  << "\n#include \"ad_types.hpp\""
536  << "\n";
537 
538  for (std::list<std::string>::iterator iter = this->ADOLCExternalFunctionNames.begin(); iter != this->ADOLCExternalFunctionNames.end(); iter++) {
539  buf << "int "<<(*iter)<<"(int n,double *yin,int m,double *yout); " << std::endl;
540  buf << "int ad_"<<(*iter)<<"(int n,DERIV_TYPE *yin,int m,DERIV_TYPE *yout); " << std::endl;
541  buf << "ADOLC_ext_fct zosf_"<<(*iter)<<"; " << std::endl;
542  buf << "ADOLC_ext_fct_fos_forward fosf_"<<(*iter)<<"; " << std::endl;
543  buf << "ADOLC_ext_fct_fov_forward fovf_"<<(*iter)<<"; " << std::endl;
544 
545  buf << "ext_diff_fct* reg_ext_fct_"<<(*iter)<<"(int n, int m);" << std::endl;
546  }
547 
548  // End of file
549  buf << "#endif /* #ifndef __AD_REGISTER_EXTERNAL_FUNCTIONS_H */" << std::endl;
550 
551  hfile.open("ad_register_external_functions.h");
552  hfile << buf.str();
553  hfile.close();
554  }
555 
556  std::string
557  StateManager::getZosfString(std::string functionname)
558  {
559  std::ostringstream buf;
560  buf << "int zosf_"<<functionname<<"(int n, double *x, int m, double *y){ " << std::endl;
561  buf << "\t"<<"return "<<functionname<<"(n, x, m, y);"<< std::endl;
562  buf << "}" << std::endl << std::endl;
563  return buf.str();
564  }
565 
566  std::string
567  StateManager::getFosfString(std::string functionname)
568  {
569  std::ostringstream buf;
570  buf << "int fosf_"<<functionname<<"(int n, double *dp_x, double *dp_X, int m, double *dp_y, double *dp_Y){ " << std::endl;
571  buf << "\t"<<"double **dpp_X = &dp_X;"<< std::endl;
572  buf << "\t"<<"double **dpp_Y = &dp_Y;"<< std::endl;
573  buf << "\t"<<"fovf_"<<functionname<<"(n, dp_x, 1, dpp_X, m, dp_y, dpp_Y);"<< std::endl;
574  buf << "\t"<<"return 0;"<< std::endl;
575  buf << "}" << std::endl << std::endl;
576  return buf.str();
577  }
578 
579  std::string
580  StateManager::getFovfString(std::string functionname)
581  {
582  std::ostringstream buf;
583  buf << "int fovf_"<<functionname<<"(int n, double *dp_x, int p, double **dpp_X, int m, double *dp_y, double **dpp_Y){ " << std::endl;
584  buf << "\t"<<"int i,j;" << std::endl;
585  buf << "\t"<<"ADIC_Init(p);" << std::endl;
586  buf << "\t"<<"DERIV_TYPE *ad_x, *ad_y;" << std::endl;
587  buf << "\t"<<"ad_x = new DERIV_TYPE[n]; " << std::endl;
588  buf << "\t"<<"ad_y = new DERIV_TYPE[m]; " << std::endl;
589  buf << "\t"<<"// Set indpendent variables " << std::endl;
590  buf << "\t"<<"ADIC_SetForwardMode();" << std::endl;
591  buf << "\t"<<"ADIC_SetIndepArrayFromSeed(ad_x,n,dpp_X);" << std::endl;
592  buf << "\t"<<"ADIC_SetDepArray(ad_y,m);" << std::endl;
593  buf << "\t"<<"ADIC_SetIndepDone();" << std::endl;
594  buf << "\t"<<"// Initialize the value of the independent variable ad_x" << std::endl;
595  buf << "\t"<<"for(i = 0; i < n; i++)" << std::endl;
596  buf << "\t"<<"\tDERIV_val(ad_x[i]) = dp_x[i];" << std::endl;
597  buf << "\t"<<"for(i = 0; i < m; i++)" << std::endl;
598  buf << "\t"<<"\tDERIV_val(ad_y[i]) = 0.0;" << std::endl;
599  buf << "\t"<<"// Invoke AD function " << std::endl;
600  buf << "\t"<<"ad_"<<functionname<<"(n, ad_x, m, ad_y);" << std::endl;
601  buf << "\t"<<"for(i = 0; i < m; i++)" << std::endl;
602  buf << "\t"<<"\tdp_y[i] = DERIV_val(ad_y[i]);" << std::endl;
603  buf << "\t"<<"for(i = 0; i < m; i++)" << std::endl;
604  buf << "\t"<<"\tfor(j = 0; j < p ; j++)" << std::endl;
605  buf << "\t"<<"\t\tdpp_Y[i][j] = DERIV_grad(ad_y[i])[j];" << std::endl;
606  buf << "\t"<<"delete []ad_y;" << std::endl;
607  buf << "\t"<<"delete []ad_x;" << std::endl;
608  buf << "\t"<<"ADIC_Finalize();" << std::endl;
609  buf << "\t"<<"return 0;" << std::endl;
610  buf << "}" << std::endl << std::endl;
611  return buf.str();
612  }
613 
614  std::string
616  {
617  std::ostringstream buf;
618  buf << "ext_diff_fct * reg_ext_fct_"<<functionname<<"(int n, int m){ " << std::endl;
619  buf << "\tdouble *yp, *ynewp, *ydp, *ynewdp, **ydpp, **ynewdpp;" << std::endl;
620  buf << "\t// register external function and set up pointers" << std::endl;
621  buf << "\text_diff_fct *edf = reg_ext_fct("<<functionname<<");"<< std::endl;
622  buf << "\t// information for Zero-Order-Scalar (=zos) forward"<< std::endl;
623  buf << "\t// allocate memory for edf structure from n and m"<< std::endl;
624  buf << "\typ = myalloc1(n);"<< std::endl;
625  buf << "\tynewp = myalloc1(m);"<< std::endl;
626 
627  buf << "\tydp = myalloc1(n);"<< std::endl;
628  buf << "\tynewdp = myalloc1(m);"<< std::endl;
629 
630  buf << "\tydpp = myalloc2(n,n); // second number is number of tangent directions"<< std::endl;
631  buf << "\tynewdpp = myalloc2(m,n);"<< std::endl;
632 
633  buf << "\tedf->zos_forward = zosf_"<<functionname<<";"<< std::endl;
634  buf << "\tedf->dp_x = yp;"<< std::endl;
635  buf << "\tedf->dp_y = ynewp;"<< std::endl;
636  buf << "\t// information for First-Order-Scalar (=fos) forward"<< std::endl;
637  buf << "\tedf->fos_forward = fosf_"<<functionname<<";"<< std::endl;
638  buf << "\tedf->dp_X = ydp;"<< std::endl;
639  buf << "\tedf->dp_Y = ynewdp;"<< std::endl;
640  buf << "\t// information for First-Order-Vector (=fov) forward"<< std::endl;
641  buf << "\tedf->fov_forward = fovf_"<<functionname<<";"<< std::endl;
642  buf << "\tedf->dpp_X = ydpp;"<< std::endl;
643  buf << "\tedf->dpp_Y = ynewdpp;"<< std::endl;
644  buf << "\treturn edf;"<< std::endl;
645  buf << "}" << std::endl << std::endl;
646  return buf.str();
647  }
648 
649  void
651  {
653  std::ostringstream buf;
654  std::ofstream hfile;
655  int i, j;
656 
657  // Beginning of header file
658 
659  buf << getDisclaimer() << std::endl;
660 
661  buf << "/*! \\file\n"
662  << "\n"
663  << " \\brief Registration of ADOL-C external functions.\n"
664  << "\n"
665  << " Copyright (c) 2004--2011, UChicago Argonne, LLC <br>\n"
666  << " All rights reserved. <br>\n"
667  << " See $ROSE2XAIF_DIR/Copyright.txt for details. <br>\n"
668  << "\n"
669  << " */\n"
670  << "\n";
671 
672  buf <<"#include \"ad_types.hpp\"" <<std::endl;
673  buf <<"#include \"ad_register_external_functions.h\"" <<std::endl;
674  buf <<"#include <adolc/adalloc.h>" <<std::endl;
675 
676  for (std::list<std::string>::iterator iter = this->ADOLCExternalFunctionNames.begin(); iter != this->ADOLCExternalFunctionNames.end(); iter++) {
677  buf << getZosfString(*iter);
678  buf << getFosfString(*iter);
679  buf << getFovfString(*iter);
680  buf << getRegistrationFunctionString(*iter);
681  }
682  // End of file
683  hfile.open("ad_register_external_functions.c");
684  hfile << buf.str();
685  hfile.close();
686  }
687 } // namespace rose2xaif