File indexing completed on 2024-09-20 05:11:34 UTC
view on githubraw file Latest commit e6e223b2 on 2024-09-19 22:01:15 UTC
279dc77b07 Patr*0001 #include "PACKAGES_CONFIG.h"
0002 #include "OPENAD_OPTIONS.h"
0003
0004 subroutine template()
0005 #ifdef ALLOW_OPENAD_DIVA
0006 use OAD_regular_cp
0007 use OAD_tape
0008 use OAD_rev
0009
0010
0011 use SIZE_mod
0012 use EEPARAMS_mod
0013 use PARAMS_mod
0014 use BAR2_mod
0015 use BARRIER_mod
0016 #ifdef ALLOW_CD_CODE
0017 use CD_CODE_VARS_mod
0018 #endif
0019 use CG2D_mod
0020 use CG3D_mod
0021 use DYNVARS_mod
0022 use EESUPPORT_mod
0023 use EOS_mod
0024 use EXCH_mod
0025 use FC_NAMEMANGLE_mod
0026 use FFIELDS_mod
0027 #ifdef ALLOW_GENERIC_ADVDIFF
0028 use GAD_mod
0029 #endif
0030 use GLOBAL_MAX_mod
0031 use GLOBAL_SUM_mod
0032 #ifdef ALLOW_GMREDI
0033 use GMREDI_mod
0034 use GMREDI_TAVE_mod
0035 #endif
0036 use GRID_mod
0037 #ifdef ALLOW_MOM_COMMON
0038 use MOM_VISC_mod
0039 #endif
0040 use MPI_INFO_mod
0041 #ifdef ALLOW_SHAP_FILT
0042 use SHAP_FILT_mod
0043 #endif
0044 #ifdef ALLOW_STREAMICE
0045 use STREAMICE_mod
0046 use STREAMICE_ADV_mod
0047 use STREAMICE_BDRY_mod
0048 use STREAMICE_CG_mod
0049 #endif
0050 use SURFACE_mod
0051 use cost_mod
0052 use g_cost_mod
4d72283393 Mart*0053 use CTRL_mod
edcd27be69 Mart*0054 use CTRL_DUMMY_mod
65754df434 Mart*0055 use OPTIMCYCLE_mod
444da61630 Mart*0056 use GRDCHK_mod
7c50f07931 Mart*0057
279dc77b07 Patr*0058
0059 integer, save :: currcp, curradjointcp
0060 integer :: cp_loop_variable_1,cp_loop_variable_2,
0061 + cp_loop_variable_3,cp_loop_variable_4,cp_loop_variable_5
0062
0063 double precision, dimension(:), allocatable, save :: theArgFStack
0064 integer, save :: theArgFStackoffset=0, theArgFStackSize=0
0065 integer, dimension(:), allocatable, save :: theArgIStack
0066 integer, save :: theArgIStackoffset=0, theArgIStackSize=0
0067 type(modeType) :: our_orig_mode
0068 integer nt
0069
0070 integer iaddr
0071 external iaddr
7c50f07931 Mart*0072 if (our_rev_mode%arg_store) then
279dc77b07 Patr*0073 call cp_write_open()
0074
0075 call cp_close()
7c50f07931 Mart*0076 end if
279dc77b07 Patr*0077 if (our_rev_mode%arg_restore) then
0078 call cp_read_open()
0079
0080 call cp_close()
0081 end if
0082 if (our_rev_mode%plain) then
0083 do nt=1,nTimeSteps_l2
0084 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
0085 enddo
0086 end if
0087 if (our_rev_mode%tape) then
0088 print *, 'DIVA Running Regular Plain nTimeSteps_l2 ', nTimeSteps
0089 +_l2
0090 currcp = 0
0091 do nt=1,nTimeSteps_l2
0092 print *, 'DIVA Checkpointing currcp and running plain', currc
0093 +p
0094 call cp_write_open(currcp)
0095
0096 call cp_close
0097 currcp=currcp+1
0098 call OAD_revPlain
0099 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
0100 call OAD_revTape
0101 end do
0102 currcp = currcp -1
0103 end if
0104 if (our_rev_mode%adjoint) then
0105 curradjointcp = currcp
0106 print *, 'DIVA Reading plain checkpoint currcp ', currcp
0107 call cp_read_open(currcp)
0108
0109 call cp_close
0110 call OAD_revTape
0111 print *, 'DIVA Running First Tape'
0112 CALL OpenAD_inner_do_loop(nTimeSteps_l2, MYTIME, MYITER, MYTHID)
0113 print *, 'DIVA Running First Adjoint '
0114 call OAD_revAdjoint
0115 CALL OpenAD_inner_do_loop(nTimeSteps_l2, MYTIME, MYITER, MYTHID)
0116 print *, 'DIVA Writing adjoint checkpoint curradjointcp ', curra
0117 +djointcp
0118 call cp_write_open(curradjointcp)
0119
0120 call cp_close
0121 do nt=nTimeSteps_l2-1,1,-1
0122 currcp = currcp -1
0123 print *, 'DIVA Running TA pairs'
0124 print *, 'DIVA Reading plain checkpoint currcp ', currcp
0125 call cp_read_open(currcp)
0126
0127 call cp_close
0128 call OAD_revTape
0129 print *, 'DIVA Running Tape'
0130 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
0131 print *, 'DIVA Reading adjoint checkpoint curradjointcp ', cur
0132 +radjointcp
0133 call cp_read_open(curradjointcp)
0134
0135 call cp_close
0136 print *, 'DIVA Running adjoint '
0137 call OAD_revAdjoint
0138 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
0139 print *, 'DIVA Writing adjoint checkpoint curradjointcp ', cur
0140 +radjointcp-1
0141 call cp_write_open(curradjointcp-1)
0142
0143 curradjointcp = curradjointcp-1
0144 call cp_close
0145 end do
0146 end if
0147 #endif
0148 end subroutine template