/* Generated by TAPENADE (INRIA, Ecuador team) Tapenade 3.12 (r6213) - 13 Oct 2016 10:54 */ /* hand clean-up 2015 Oct 13 WWS */ //#include "GlobalDeclarations_b.c" /* Differentiation of asg_vstep2d in reverse (adjoint) mode: gradient of useful results: **v0 **v1 with respect to varying inputs: **v0 **v1 **buoy **p0 **p1 RW status of diff variables: **v0:in-out **v1:in-out **buoy:out **p0:out **p1:out Plus diff mem management of: v0:in *v0:in v1:in *v1:in buoy:in *buoy:in p0:in *p0:in p1:in *p1:in gradp:in *gradp:in void asg_vstep2d(float ** restrict buoy, float ** restrict p0,float ** restrict p1, float ** restrict v0,float ** restrict v1, float ** restrict ev, float ** restrict evp, float ** restrict gradp, int * gsc_v0, int * gec_v0, int * gsc_v1, int * gec_v1, int * lbc, int * rbc, int maxoff,float ** restrict c, FILE * stream) { */ #include "cstd.h" //#define LOCAL_VERBOSE // signature for tapenade void asg_vstep2d_b(float ** restrict buoy, float ** restrict buoyb, float ** restrict p0, float ** restrict p0b, float ** restrict p1, float ** restrict p1b, float ** restrict v0, float ** restrict v0b, float ** restrict v1, float ** restrict v1b, float ** restrict ev, float ** restrict evp, float ** restrict gradp, float ** restrict gradpb, int *gsc_v0, int *gec_v0, int *gsc_v1, int *gec_v1, int *lbc, int *rbc, int maxoff, float ** restrict c) { int i0, i1; int ioff; float tempb; float tempb0; float tempb1; float tempb2; float tempb3; float tempb4; float tmpb; float tmpb0; float tmpb1; float tmpb2; for (i1 = gsc_v0[1]; i1 < gec_v0[1]+1; ++i1) { for (i0 = gsc_v0[0]; i0 < gec_v0[0]+1; ++i0) { // pushreal4(gradp[0][i0]); gradp[0][i0] = 0; } for (ioff = 0; ioff < maxoff; ++ioff) for (i0 = gsc_v0[0]; i0 < gec_v0[0]+1; ++i0) { // pushreal4(gradp[0][i0]); gradp[0][i0] = gradp[0][i0] + c[0][ioff]*(p0[i1][i0+ioff+1]-p0 [i1][i0-ioff]); } } for (i1 = gsc_v1[1]; i1 < gec_v1[1]+1; ++i1) { for (i0 = gsc_v1[0]; i0 < gec_v1[0]+1; ++i0) { // pushreal4(gradp[1][i0]); gradp[1][i0] = 0; } for (ioff = 0; ioff < maxoff; ++ioff) for (i0 = gsc_v1[0]; i0 < gec_v1[0]+1; ++i0) { // pushreal4(gradp[1][i0]); gradp[1][i0] = gradp[1][i0] + c[1][ioff]*(p1[i1+ioff+1][i0]-p1 [i1-ioff][i0]); } } /* if (lbc[0]) pushcontrol1b(0); else pushcontrol1b(1); if (rbc[0]) pushcontrol1b(0); else pushcontrol1b(1); if (lbc[1]) pushcontrol1b(0); else pushcontrol1b(1); */ if (rbc[1]) for (i0 = gec_v1[0]; i0 > gsc_v1[0]-1; --i0) for (ioff = maxoff-1; ioff > 0; --ioff) { tmpb2 = v1b[gec_v1[1] + ioff][i0]; v1b[gec_v1[1] + ioff][i0] = 0.0; v1b[gec_v1[1] - ioff + 1][i0] = v1b[gec_v1[1] - ioff + 1][i0] + tmpb2; } // popcontrol1b(&branch); // if (branch == 0) if (lbc[1]) for (i0 = gec_v1[0]; i0 > gsc_v1[0]-1; --i0) for (ioff = maxoff-1; ioff > 0; --ioff) { tmpb1 = v1b[gsc_v1[1] - ioff][i0]; v1b[gsc_v1[1] - ioff][i0] = 0.0; v1b[gsc_v1[1] + ioff - 1][i0] = v1b[gsc_v1[1] + ioff - 1][i0] + tmpb1; } // popcontrol1b(&branch); // if (branch == 0) if (rbc[0]) for (i1 = gec_v0[1]; i1 > gsc_v0[1]-1; --i1) for (ioff = maxoff-1; ioff > 0; --ioff) { tmpb0 = v0b[i1][gec_v0[0] + ioff]; v0b[i1][gec_v0[0] + ioff] = 0.0; v0b[i1][gec_v0[0] - ioff + 1] = v0b[i1][gec_v0[0] - ioff + 1] + tmpb0; } // popcontrol1b(&branch); // if (branch == 0) if (lbc[0]) for (i1 = gec_v0[1]; i1 > gsc_v0[1]-1; --i1) for (ioff = maxoff-1; ioff > 0; --ioff) { tmpb = v0b[i1][gsc_v0[0] - ioff]; v0b[i1][gsc_v0[0] - ioff] = 0.0; v0b[i1][gsc_v0[0] + ioff - 1] = v0b[i1][gsc_v0[0] + ioff - 1] + tmpb; } // **buoyb = 0.0; // **p1b = 0.0; // **gradpb = 0.0; for (i1 = gec_v1[1]; i1 > gsc_v1[1]-1; --i1) { for (i0 = gec_v1[0]; i0 > gsc_v1[0]-1; --i0) { tempb3 = evp[1][i1]*v1b[i1][i0]; tempb4 = -(0.5*gradp[1][i0]*tempb3); buoyb[i1][i0] = buoyb[i1][i0] + tempb4; buoyb[i1 + 1][i0] = buoyb[i1 + 1][i0] + tempb4; gradpb[1][i0] = gradpb[1][i0] - 0.5*(buoy[i1][i0]+buoy[i1+1][i0])* tempb3; v1b[i1][i0] = ev[1][i1]*tempb3; } for (ioff = maxoff-1; ioff > -1; --ioff) for (i0 = gec_v1[0]; i0 > gsc_v1[0]-1; --i0) { // popreal4(&gradp[1][i0]); tempb2 = c[1][ioff]*gradpb[1][i0]; p1b[i1 + ioff + 1][i0] = p1b[i1 + ioff + 1][i0] + tempb2; p1b[i1 - ioff][i0] = p1b[i1 - ioff][i0] - tempb2; } for (i0 = gec_v1[0]; i0 > gsc_v1[0]-1; --i0) { // popreal4(&gradp[1][i0]); gradpb[1][i0] = 0.0; } } // **p0b = 0.0; for (i1 = gec_v0[1]; i1 > gsc_v0[1]-1; --i1) { for (i0 = gec_v0[0]; i0 > gsc_v0[0]-1; --i0) { tempb0 = evp[0][i0]*v0b[i1][i0]; tempb1 = -(0.5*gradp[0][i0]*tempb0); buoyb[i1][i0] = buoyb[i1][i0] + tempb1; buoyb[i1][i0 + 1] = buoyb[i1][i0 + 1] + tempb1; gradpb[0][i0] = gradpb[0][i0] - 0.5*(buoy[i1][i0]+buoy[i1][i0+1])* tempb0; v0b[i1][i0] = ev[0][i0]*tempb0; } for (ioff = maxoff-1; ioff > -1; --ioff) for (i0 = gec_v0[0]; i0 > gsc_v0[0]-1; --i0) { // popreal4(&gradp[0][i0]); tempb = c[0][ioff]*gradpb[0][i0]; p0b[i1][i0 + ioff + 1] = p0b[i1][i0 + ioff + 1] + tempb; p0b[i1][i0 - ioff] = p0b[i1][i0 - ioff] - tempb; } for (i0 = gec_v0[0]; i0 > gsc_v0[0]-1; --i0) { // popreal4(&gradp[0][i0]); gradpb[0][i0] = 0.0; } } }