++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dcc 0.9 Windows binaries generated under Windows 7 Enterprise with Visual Studio 2010 Uwe Naumann, May 2012 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Getting Started - download dcc_0.9.zip - unpack to get dcc_0.9/dcc_0.9 (dcc executables) - select binary version from Debug Win32 Debug x64 Release Win32 Release x64 - generate test source file f.c in same directory, e.g. void f(double *x, double &y) { y=x[0]*x[1]; } - run dcc in first-order (1) tangent-linear mode (1) dcc_0.9 f.c 1 1 to get t1_f.c: void t1_f(double* x, double* t1_x, double& y, double& t1_y) { double v1_0=0; double t1_v1_0=0; double v1_1=0; double t1_v1_1=0; double v1_2=0; double t1_v1_2=0; t1_v1_0=t1_x[0]; v1_0=x[0]; t1_v1_1=t1_x[1]; v1_1=x[1]; t1_v1_2=v1_1*t1_v1_0+v1_0*t1_v1_1; v1_2=v1_0*v1_1; t1_y=t1_v1_2; y=v1_2; } Refer to "The Art ..." for information on use of the tangent-linear code - run dcc in first-order (1) adjoint mode (2) dcc_0.9 f.c 2 1 to get a1_f.c: int cs[1000000]; int cs_c=0; double fds[1000000]; int fds_c=0; int ids[1000000]; int ids_c=0; #include "declare_checkpoints.inc" #include "f.c" void a1_f(int a1_mode, double* x, double* a1_x, double& y, double& a1_y) { double v1_0=0; double a1_v1_0=0; double v1_1=0; double a1_v1_1=0; double v1_2=0; double a1_v1_2=0; int save_cs_c=0; save_cs_c=cs_c; if (a1_mode==1) { // augmented forward section cs[cs_c]=0; cs_c=cs_c+1; fds[fds_c]=y; fds_c=fds_c+1; y=x[0]*x[1]; #include "f_store_results.inc" // reverse section while (cs_c>save_cs_c) { cs_c=cs_c-1; if (cs[cs_c]==0) { fds_c=fds_c-1; y=fds[fds_c]; v1_0=x[0]; v1_1=x[1]; v1_2=v1_0*v1_1; a1_v1_2=a1_y; a1_y=0; a1_v1_0=v1_1*a1_v1_2; a1_v1_1=v1_0*a1_v1_2; a1_x[1]=a1_x[1]+a1_v1_1; a1_x[0]=a1_x[0]+a1_v1_0; } } #include "f_restore_results.inc" } if (a1_mode==2) { #include "f_store_inputs.inc" a1_mode=a1_mode; } if (a1_mode==3) { #include "f_restore_inputs.inc" a1_mode=a1_mode; } } Refer to "The Art ..." for information on use of the adjoint code - run dcc in second-order (2) tangent-linear mode (1) dcc_0.9 t1_f.c 1 2 to get t2_t1_f.c Refer to "The Art ..." for information on use of the second-order tangent-linear code - run dcc in third-order (3) tangent-linear mode (1) dcc_0.9 t2_t1_f.c 1 3 to get t3_t2_t1_f.c and similar for higher-order tangent-linear code Refer to "The Art ..." for information on use of the third- and higher-order tangent-linear code - prepare a1_f.c for application of dcc in second-order adjoint mode; generate empty files declare_checkpoints.inc f_store_inputs.inc f_restore_inputs.inc f_store_results.inc f_restore_results.inc and run C preprocessor cpp -P a1_f.c -o a1_f_cpp.c to get a1_f_cpp: int cs[1000000]; int cs_c=0; double fds[1000000]; int fds_c=0; int ids[1000000]; int ids_c=0; void f(double *x, double &y) { y=x[0]*x[1]; } void a1_f(int a1_mode, double* x, double* a1_x, double& y, double& a1_y) { double v1_0=0; double a1_v1_0=0; double v1_1=0; double a1_v1_1=0; double v1_2=0; double a1_v1_2=0; int save_cs_c=0; save_cs_c=cs_c; if (a1_mode==1) { cs[cs_c]=0; cs_c=cs_c+1; fds[fds_c]=y; fds_c=fds_c+1; y=x[0]*x[1]; while (cs_c>save_cs_c) { cs_c=cs_c-1; if (cs[cs_c]==0) { fds_c=fds_c-1; y=fds[fds_c]; v1_0=x[0]; v1_1=x[1]; v1_2=v1_0*v1_1; a1_v1_2=a1_y; a1_y=0; a1_v1_0=v1_1*a1_v1_2; a1_v1_1=v1_0*a1_v1_2; a1_x[1]=a1_x[1]+a1_v1_1; a1_x[0]=a1_x[0]+a1_v1_0; } } } if (a1_mode==2) { a1_mode=a1_mode; } if (a1_mode==3) { a1_mode=a1_mode; } } - run dcc in second-order (2) adjoint mode by running tangent-linear mode (1) on the preprocessed first-order adjoint code dcc_0.9 a1_f_cpp.c 1 2 to get t2_a1_f_cpp.c Refer to "The Art ..." for information on use of the second-order tangent-linear code - run dcc in third-order (3) adjoint mode by running tangent-linear mode (1) on the preprocessed first-order adjoint code dcc_0.9 t2_a1_f_cpp.c 1 3 to get t3_t2_a1_f_cpp.c and similar for higher-order adjoint code Refer to "The Art ..." for information on use of the third- and higher-order adjoint code