Back to home page

MITgcm

 
 

    


File indexing completed on 2018-03-02 18:45:03 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
6f5d7c9095 Patr*0001 #include "OPENAD_OPTIONS.h"
                0002 
                0003       subroutine template()
                0004 C     !FUNCTIONS
                0005       use OAD_tape
                0006       use OAD_rev
                0007       use OAD_cp
                0008 
                0009 
                0010 ! original arguments get inserted before version
                0011 !         ! and declared here together with all local variables
                0012 !         ! generated by xaifBooster
                0013 
                0014 !use mode_variables
                0015 
                0016 !$TEMPLATE_PRAGMA_DECLARATIONS
                0017       type(modeType) :: our_orig_mode
                0018 
                0019       integer iaddr
                0020       external iaddr
                0021 
                0022 !LOCAL VARIABLES:
                0023       CHARACTER*(2) adpref
                0024       CHARACTER*(80) fname
                0025       INTEGER il
                0026       INTEGER myNr
                0027       LOGICAL useCurrentDir
                0028       Real*8  active_var_p(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
                0029       INTEGER  ILNBLNK
                0030       EXTERNAL ILNBLNK
                0031 
                0032 #ifdef ALLOW_OPENAD_ACTIVE_READ_XYZ
                0033 
                0034       myNr = Nr
                0035       useCurrentDir = .FALSE.
                0036 
                0037       if (our_rev_mode%plain) then
                0038          our_orig_mode = our_rev_mode
                0039 ! original function
                0040          active_var_p = active_var%v
                0041 ! set up for plain execution
                0042          our_rev_mode%arg_store=.FALSE.
                0043          our_rev_mode%arg_restore=.FALSE.
                0044          our_rev_mode%plain=.TRUE.
                0045          our_rev_mode%tape=.FALSE.
                0046          our_rev_mode%adjoint=.FALSE.
                0047          call ACTIVE_READ_3D_RL(
                0048      &        active_var_file, active_var_p, doglobalread,
                0049      &        useCurrentDir, lAdInit, iRec, myNr,
                0050      &        FORWARD_SIMULATION, myOptimIter, myThid )
                0051 ! reset the mode
                0052          our_rev_mode=our_orig_mode
                0053 ! copy back
                0054          active_var%v = active_var_p
                0055       end if
                0056 
                0057       if (our_rev_mode%tape) then
                0058 ! taping
                0059          our_orig_mode=our_rev_mode
                0060          our_rev_mode%arg_store=.FALSE.
                0061          our_rev_mode%arg_restore=.FALSE.
                0062          our_rev_mode%plain=.TRUE.
                0063          our_rev_mode%tape=.FALSE.
                0064          our_rev_mode%adjoint=.FALSE.
                0065          if (oad_st_sz.lt.oad_st_ptr) call oad_st_grow()
                0066          oad_st(oad_st_ptr) = active_var_file 
                0067          oad_st_ptr = oad_st_ptr+1 
                0068          if (oad_it_sz.lt.oad_it_ptr) call oad_it_grow()
                0069          oad_it(oad_it_ptr) = iRec
                0070          oad_it_ptr = oad_it_ptr+1 
                0071          call ACTIVE_READ_3D_RL(
                0072      &        active_var_file, active_var, doglobalread,
                0073      &        useCurrentDir, lAdInit, iRec, myNr,
                0074      &        FORWARD_SIMULATION, myOptimIter, myThid )
                0075          our_rev_mode=our_orig_mode
                0076       end if
                0077 
                0078       if (our_rev_mode%adjoint) then
                0079 ! adjoint
                0080          oad_st_ptr = oad_st_ptr-1
                0081          active_var_file = oad_st(oad_st_ptr) 
                0082          oad_it_ptr = oad_it_ptr-1
                0083          iRec = oad_it(oad_it_ptr) 
                0084          adpref = 'ad'
                0085          il   = ILNBLNK( active_var_file )
                0086          WRITE(fname(1:80),'(A)') ' '
                0087          WRITE(fname(1:2+il),'(2A)') adpref, active_var_file(1:il)
                0088 !         WRITE(fname(1:2+il),'(2A)') adpref, active_var_file
                0089          active_var_p = active_var%d
                0090 ! set up for plain execution
                0091          our_orig_mode=our_rev_mode
                0092          our_rev_mode%arg_store=.FALSE.
                0093          our_rev_mode%arg_restore=.FALSE.
                0094          our_rev_mode%plain=.TRUE.
                0095          our_rev_mode%tape=.FALSE.
                0096          our_rev_mode%adjoint=.FALSE.
                0097          call ACTIVE_READ_3D_RL(
                0098      &        fname, active_var_p, doglobalread,
                0099      &        useCurrentDir, lAdInit, iRec, myNr,
                0100      &        REVERSE_SIMULATION, myOptimIter, myThid )
                0101 ! reset the mode
                0102          our_rev_mode=our_orig_mode
                0103 ! copy back
                0104          active_var%d = active_var_p
                0105       end if
                0106 
                0107 #endif /* ALLOW_OPENAD_ACTIVE_READ_XYZ */
                0108 
                0109       end