File indexing completed on 2023-11-05 05:11:08 UTC
view on githubraw file Latest commit 65754df4 on 2023-11-04 17:55:24 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 SOLVE_FOR_PRESSURE3D_mod
0051 use SOLVE_FOR_PRESSURE_mod
0052 use SURFACE_mod
0053 use cost_mod
0054 use g_cost_mod
4d72283393 Mart*0055 use CTRL_mod
edcd27be69 Mart*0056 use CTRL_DUMMY_mod
65754df434 Mart*0057 use OPTIMCYCLE_mod
444da61630 Mart*0058 use GRDCHK_mod
7c50f07931 Mart*0059
279dc77b07 Patr*0060
0061 integer, save :: currcp, curradjointcp
0062 integer :: cp_loop_variable_1,cp_loop_variable_2,
0063 + cp_loop_variable_3,cp_loop_variable_4,cp_loop_variable_5
0064
0065 double precision, dimension(:), allocatable, save :: theArgFStack
0066 integer, save :: theArgFStackoffset=0, theArgFStackSize=0
0067 integer, dimension(:), allocatable, save :: theArgIStack
0068 integer, save :: theArgIStackoffset=0, theArgIStackSize=0
0069 type(modeType) :: our_orig_mode
0070 integer nt
0071
0072 integer iaddr
0073 external iaddr
7c50f07931 Mart*0074 if (our_rev_mode%arg_store) then
279dc77b07 Patr*0075 call cp_write_open()
0076
0077 call cp_close()
7c50f07931 Mart*0078 end if
279dc77b07 Patr*0079 if (our_rev_mode%arg_restore) then
0080 call cp_read_open()
0081
0082 call cp_close()
0083 end if
0084 if (our_rev_mode%plain) then
0085 do nt=1,nTimeSteps_l2
0086 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
0087 enddo
0088 end if
0089 if (our_rev_mode%tape) then
0090 print *, 'DIVA Running Regular Plain nTimeSteps_l2 ', nTimeSteps
0091 +_l2
0092 currcp = 0
0093 do nt=1,nTimeSteps_l2
0094 print *, 'DIVA Checkpointing currcp and running plain', currc
0095 +p
0096 call cp_write_open(currcp)
0097
0098 call cp_close
0099 currcp=currcp+1
0100 call OAD_revPlain
0101 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
0102 call OAD_revTape
0103 end do
0104 currcp = currcp -1
0105 end if
0106 if (our_rev_mode%adjoint) then
0107 curradjointcp = currcp
0108 print *, 'DIVA Reading plain checkpoint currcp ', currcp
0109 call cp_read_open(currcp)
0110
0111 call cp_close
0112 call OAD_revTape
0113 print *, 'DIVA Running First Tape'
0114 CALL OpenAD_inner_do_loop(nTimeSteps_l2, MYTIME, MYITER, MYTHID)
0115 print *, 'DIVA Running First Adjoint '
0116 call OAD_revAdjoint
0117 CALL OpenAD_inner_do_loop(nTimeSteps_l2, MYTIME, MYITER, MYTHID)
0118 print *, 'DIVA Writing adjoint checkpoint curradjointcp ', curra
0119 +djointcp
0120 call cp_write_open(curradjointcp)
0121
0122 call cp_close
0123 do nt=nTimeSteps_l2-1,1,-1
0124 currcp = currcp -1
0125 print *, 'DIVA Running TA pairs'
0126 print *, 'DIVA Reading plain checkpoint currcp ', currcp
0127 call cp_read_open(currcp)
0128
0129 call cp_close
0130 call OAD_revTape
0131 print *, 'DIVA Running Tape'
0132 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
0133 print *, 'DIVA Reading adjoint checkpoint curradjointcp ', cur
0134 +radjointcp
0135 call cp_read_open(curradjointcp)
0136
0137 call cp_close
0138 print *, 'DIVA Running adjoint '
0139 call OAD_revAdjoint
0140 CALL OpenAD_inner_do_loop(nt, MYTIME, MYITER, MYTHID)
0141 print *, 'DIVA Writing adjoint checkpoint curradjointcp ', cur
0142 +radjointcp-1
0143 call cp_write_open(curradjointcp-1)
0144
0145 curradjointcp = curradjointcp-1
0146 call cp_close
0147 end do
0148 end if
0149 #endif
0150 end subroutine template