subroutine template() C !FUNCTIONS use OAD_tape use OAD_rev use OAD_cp ! original arguments get inserted before version ! ! and declared here together with all local variables ! ! generated by xaifBooster !use mode_variables !$TEMPLATE_PRAGMA_DECLARATIONS type(modeType) :: our_orig_mode integer iaddr external iaddr !LOCAL VARIABLES: CHARACTER*(2) adpref CHARACTER*(80) fname INTEGER il INTEGER myNr LOGICAL useCurrentDir Real*8 active_var_p(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) INTEGER ILNBLNK EXTERNAL ILNBLNK myNr = 1 useCurrentDir = .FALSE. if (our_rev_mode%plain) then our_orig_mode = our_rev_mode ! original function active_var_p = active_var%v ! set up for plain execution our_orig_mode=our_rev_mode our_rev_mode%arg_store=.FALSE. our_rev_mode%arg_restore=.FALSE. our_rev_mode%plain=.TRUE. our_rev_mode%tape=.FALSE. our_rev_mode%adjoint=.FALSE. call ACTIVE_READ_3D_RL( & active_var_file, active_var_p, doglobalread, & useCurrentDir, lAdInit, iRec, myNr, & FORWARD_SIMULATION, myOptimIter, myThid ) ! reset the mode our_rev_mode=our_orig_mode ! copy back active_var%v = active_var_p end if if (our_rev_mode%tape) then ! taping our_orig_mode=our_rev_mode our_rev_mode%arg_store=.FALSE. our_rev_mode%arg_restore=.FALSE. our_rev_mode%plain=.TRUE. our_rev_mode%tape=.FALSE. our_rev_mode%adjoint=.FALSE. call ACTIVE_READ_3D_RL( & active_var_file, active_var, doglobalread, & useCurrentDir, lAdInit, iRec, myNr, & FORWARD_SIMULATION, myOptimIter, myThid ) end if if (our_rev_mode%adjoint) then ! adjoint adpref = 'ad' il = ILNBLNK( active_var_file ) WRITE(fname(1:80),'(A)') ' ' ! WRITE(fname(1:2+il),'(2A)') adpref, active_var_file(1:il) WRITE(fname(1:2+il),'(2A)') adpref, active_var_file active_var_p = active_var%d ! set up for plain execution our_orig_mode=our_rev_mode our_rev_mode%arg_store=.FALSE. our_rev_mode%arg_restore=.FALSE. our_rev_mode%plain=.TRUE. our_rev_mode%tape=.FALSE. our_rev_mode%adjoint=.FALSE. call ACTIVE_READ_3D_RL( & fname, active_var_p, doglobalread, & useCurrentDir, lAdInit, iRec, myNr, & REVERSE_SIMULATION, myOptimIter, myThid ) ! reset the mode our_rev_mode=our_orig_mode ! copy back active_var%d = active_var_p end if end