File indexing completed on 2018-03-02 18:45:05 UTC
view on githubraw file Latest commit 29190957 on 2014-09-05 21:10:32 UTC
48dac89262 Jean*0001 subroutine template()
0002 use OAD_cp
0003 use OAD_tape
0004 use OAD_rev
0005
0006
0007
0008 integer :: cp_loop_variable_1,cp_loop_variable_2,
0009 + cp_loop_variable_3,cp_loop_variable_4
0010
0011 type(modeType) :: our_orig_mode
0012
0013 integer iaddr
0014 external iaddr
0015
0016 Real*8 cg_Uin_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
0017 Real*8 cg_Vin_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
0018 Real*8 cg_Bu_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
0019 Real*8 cg_Bv_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
0020 Real*8 A_uu_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
0021 Real*8 A_vu_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
0022 Real*8 A_uv_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
0023 Real*8 A_vv_p (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
0024 Real*8 cg_Uin_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
0025 Real*8 cg_Vin_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
0026 Real*8 cg_Bu_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
0027 Real*8 cg_Bv_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
0028 Real*8 A_uu_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
0029 Real*8 A_vu_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
0030 Real*8 A_uv_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
0031 Real*8 A_vv_d (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy,-1:1,-1:1)
0032
0033 #ifdef OAD_DEBUG_JOINT
0034 character*(80):: indentation='
0035 + '
0036 our_indent=our_indent+1
0037
0038 write(standardmessageunit, '(A,A,A)', ADVANCE='NO')
0039 +'OAD:',indentation(1:our_indent), 'enter __SRNAME__:'
0040 call oad_dump_revmod(); call oad_dump_tapestats()
0041 write(standardmessageunit,*)
0042 #endif
0043 if (our_rev_mode%plain) then
0044 #ifdef OAD_DEBUG_JOINT
0045 write(standardmessageunit,'(A,A,A)')
0046 +'OAD:',indentation(1:our_indent),
0047 +' __SRNAME__: entering plain'
0048 #endif
0049
0050 our_orig_mode=our_rev_mode
0051 our_rev_mode%arg_store=.FALSE.
0052 our_rev_mode%arg_restore=.FALSE.
0053 our_rev_mode%plain=.TRUE.
0054 our_rev_mode%tape=.FALSE.
0055 our_rev_mode%adjoint=.FALSE.
0056 #ifdef OAD_DEBUG_JOINT
0057 write(standardmessageunit,'(A,A,A)')
0058 +'OAD:',indentation(1:our_indent),
0059 +' __SRNAME__: runninng plain / down plain'
0060 #endif
0061 cg_Uin_p = cg_Uin%v
0062 cg_Vin_p = cg_Vin%v
0063 cg_Bu_p = cg_Bu%v
0064 cg_Bv_p = cg_Bv%v
0065 A_uu_p = A_uu%v
0066 A_uv_p = A_uv%v
0067 A_vu_p = A_vu%v
0068 A_vv_p = A_vv%v
0069 call STREAMICE_CG_SOLVE(
0070 U cg_Uin_p,
0071 U cg_Vin_p,
0072 I cg_Bu_p,
0073 I cg_Bv_p,
0074 I A_uu_p,
0075 I A_uv_p,
0076 I A_vu_p,
0077 I A_vv_p,
0078 I tolerance,
0079 O iters,
29190957c7 Dani*0080 I maxIter,
48dac89262 Jean*0081 I myThid )
0082 cg_Uin%v = cg_Uin_p
0083 cg_Vin%v = cg_Vin_p
0084
0085 our_rev_mode=our_orig_mode
0086 end if
0087 if (our_rev_mode%tape) then
0088
0089 #ifdef OAD_DEBUG_JOINT
0090 write(standardmessageunit,'(A,A,A)')
0091 +'OAD:',indentation(1:our_indent),
0092 +' __SRNAME__: entering tape'
0093 #endif
0094
0095 our_orig_mode=our_rev_mode
0096 our_rev_mode%arg_store=.FALSE.
0097 our_rev_mode%arg_restore=.FALSE.
0098 our_rev_mode%plain=.TRUE.
0099 our_rev_mode%tape=.FALSE.
0100 our_rev_mode%adjoint=.FALSE.
0101 #ifdef OAD_DEBUG_JOINT
0102 write(standardmessageunit,'(A,A,A)')
0103 +'OAD:',indentation(1:our_indent),
0104 +' __SRNAME__: runninng plain / down plain'
0105 #endif
0106 cg_Uin_p = cg_Uin%v
0107 cg_Vin_p = cg_Vin%v
0108 cg_Bu_p = cg_Bu%v
0109 cg_Bv_p = cg_Bv%v
0110 A_uu_p = A_uu%v
0111 A_uv_p = A_uv%v
0112 A_vu_p = A_vu%v
0113 A_vv_p = A_vv%v
0114 call oad_tape_push(cg_Bu_p)
0115 call oad_tape_push(cg_Bv_p)
0116 call oad_tape_push(A_uu_p)
0117 call oad_tape_push(A_uv_p)
0118 call oad_tape_push(A_vu_p)
0119 call oad_tape_push(A_vv_p)
d0538d9e95 Jean*0120 call oad_tape_push(tolerance)
48dac89262 Jean*0121 call oad_tape_push(mythid)
0122 call STREAMICE_CG_SOLVE(
0123 U cg_Uin_p,
0124 U cg_Vin_p,
0125 I cg_Bu_p,
0126 I cg_Bv_p,
0127 I A_uu_p,
0128 I A_uv_p,
0129 I A_vu_p,
0130 I A_vv_p,
0131 I tolerance,
0132 O iters,
29190957c7 Dani*0133 I maxIter,
48dac89262 Jean*0134 I myThid )
0135 call oad_tape_push(cg_Uin_p)
0136 call oad_tape_push(cg_Vin_p)
0137 cg_Uin%v = cg_Uin_p
0138 cg_Vin%v = cg_Vin_p
0139
0140 our_rev_mode=our_orig_mode
0141 end if
0142 if (our_rev_mode%adjoint) then
0143 #ifdef OAD_DEBUG_JOINT
0144 write(standardmessageunit,'(A,A,A)')
0145 +'OAD:',indentation(1:our_indent),
0146 +' __SRNAME__: entering adjoint'
0147 #endif
0148 call oad_tape_pop(cg_Vin_p)
0149 call oad_tape_pop(cg_Uin_p)
0150 call oad_tape_pop(mythid)
d0538d9e95 Jean*0151 call oad_tape_pop(tolerance)
48dac89262 Jean*0152 call oad_tape_pop(A_vv_p)
0153 call oad_tape_pop(A_vu_p)
0154 call oad_tape_pop(A_uv_p)
0155 call oad_tape_pop(A_uu_p)
0156 call oad_tape_pop(cg_Bv_p)
0157 call oad_tape_pop(cg_Bu_p)
0158
0159 our_orig_mode=our_rev_mode
0160 our_rev_mode%arg_store=.FALSE.
0161 our_rev_mode%arg_restore=.FALSE.
0162 our_rev_mode%plain=.TRUE.
0163 our_rev_mode%tape=.FALSE.
0164 our_rev_mode%adjoint=.FALSE.
0165 #ifdef OAD_DEBUG_JOINT
0166 write(standardmessageunit,'(A,A,A)')
0167 +'OAD:',indentation(1:our_indent),
0168 +' __SRNAME__: runninng self adjoint / down plain'
0169 #endif
0170 cg_Uin_d = cg_Uin%d
0171 cg_Vin_d = cg_Vin%d
0172 cg_Bu_d = cg_Bu%d
0173 cg_Bv_d = cg_Bv%d
0174 A_uu_d = A_uu%d
0175 A_uv_d = A_uv%d
0176 A_vu_d = A_vu%d
0177 A_vv_d = A_vv%d
0178 call ADSTREAMICE_CG_SOLVE(
0179 U cg_Uin_p,
7a007583db Dani*0180 I cg_Uin_d,
48dac89262 Jean*0181 U cg_Vin_p,
7a007583db Dani*0182 I cg_Vin_d,
48dac89262 Jean*0183 I cg_Bu_p,
7a007583db Dani*0184 U cg_Bu_d,
48dac89262 Jean*0185 I cg_Bv_p,
7a007583db Dani*0186 U cg_Bv_d,
48dac89262 Jean*0187 I A_uu_p,
0188 U A_uu_d,
0189 I A_uv_p,
0190 U A_uv_d,
0191 I A_vu_p,
0192 U A_vu_d,
0193 I A_vv_p,
0194 U A_vv_d,
0195 I tolerance,
29190957c7 Dani*0196 I maxIter,
48dac89262 Jean*0197 I myThid )
0198
0199 cg_Uin%d = cg_Uin_d
0200 cg_Vin%d = cg_Vin_d
0201 cg_Bu%d = cg_Bu_d
0202 cg_Bv%d = cg_Bv_d
0203 A_uu%d = A_uu_d
0204 A_uv%d = A_uv_d
0205 A_vu%d = A_vu_d
0206 A_vv%d = A_vv_d
0207 our_rev_mode=our_orig_mode
0208 end if
0209 #ifdef OAD_DEBUG_JOINT
0210 write(standardmessageunit,'(A,A,A)', ADVANCE='NO')
0211 +'OAD:',indentation(1:our_indent), 'leave __SRNAME__:'
0212 call oad_dump_revmod(); call oad_dump_tapestats()
0213 write(standardmessageunit,*)
0214
0215 our_indent=our_indent-1
0216 #endif
0217
0218 end subroutine template