/[MITgcm]/MITgcm_contrib/heimbach/OpenAD/OAD_support/ad_template.joint.f
ViewVC logotype

Annotation of /MITgcm_contrib/heimbach/OpenAD/OAD_support/ad_template.joint.f

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Tue Nov 20 15:19:43 2007 UTC (18 years, 9 months ago) by utke
Branch: MAIN
common runtime support

1 utke 1.1 C ========== begin copyright notice ==============
2     C This file is part of
3     C ---------------
4     C xaifBooster
5     C ---------------
6     C Distributed under the BSD license as follows:
7     C Copyright (c) 2005, The University of Chicago
8     C All rights reserved.
9     C
10     C Redistribution and use in source and binary forms,
11     C with or without modification, are permitted provided that the following conditions are met:
12     C
13     C - Redistributions of source code must retain the above copyright notice,
14     C this list of conditions and the following disclaimer.
15     C - Redistributions in binary form must reproduce the above copyright notice,
16     C this list of conditions and the following disclaimer in the documentation
17     C and/or other materials provided with the distribution.
18     C - Neither the name of The University of Chicago nor the names of its contributors
19     C may be used to endorse or promote products derived from this software without
20     C specific prior written permission.
21     C
22     C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
23     C EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24     C OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25     C SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26     C INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27     C PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28     C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29     C LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30     C OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31     C
32     C General Information:
33     C xaifBooster is intended for the transformation of
34     C numerical programs represented as xml files according
35     C to the XAIF schema. It is part of the OpenAD framework.
36     C The main application is automatic
37     C differentiation, i.e. the generation of code for
38     C the computation of derivatives.
39     C The following people are the principal authors of the
40     C current version:
41     C Uwe Naumann
42     C Jean Utke
43     C Additional contributors are:
44     C Andrew Lyons
45     C Peter Fine
46     C
47     C For more details about xaifBooster and its use in OpenAD please visit:
48     C http://www.mcs.anl.gov/openad
49     C
50     C This work is partially supported by:
51     C NSF-ITR grant OCE-0205590
52     C ========== end copyright notice ==============
53     subroutine template()
54     use OAD_tape
55     use OAD_rev
56     use OAD_cp
57    
58    
59     ! original arguments get inserted before version
60     ! and declared here together with all local variables
61     ! generated by xaifBooster
62    
63     !$TEMPLATE_PRAGMA_DECLARATIONS
64    
65    
66     ! checkpointing stacks and offsets
67     integer :: cp_loop_variable_1,cp_loop_variable_2,
68     +cp_loop_variable_3,cp_loop_variable_4
69     ! floats 'F'
70     double precision, dimension(:), allocatable, save ::
71     +theArgFStack
72     integer, save :: theArgFStackoffset=0, theArgFStackSize=0
73     double precision, dimension(:), allocatable, save ::
74     +theResFStack
75     integer, save :: theResFStackoffset=0, theResFStackSize=0
76     ! integers 'I'
77     integer, dimension(:), allocatable, save ::
78     +theArgIStack
79     integer, save :: theArgIStackoffset=0, theArgIStackSize=0
80     integer, dimension(:), allocatable, save ::
81     +theResIStack
82     integer, save :: theResIStackoffset=0, theResIStackSize=0
83     ! booleans 'B'
84     logical, dimension(:), allocatable, save ::
85     +theArgBStack
86     integer, save :: theArgBStackoffset=0, theArgBStackSize=0
87     logical, dimension(:), allocatable, save ::
88     +theResBStack
89     integer, save :: theResBStackoffset=0, theResBStackSize=0
90     ! strings 'S'
91     character*(80), dimension(:), allocatable, save ::
92     +theArgSStack
93     integer, save :: theArgSStackoffset=0, theArgSStackSize=0
94     character*(80), dimension(:), allocatable, save ::
95     +theResSStack
96     integer, save :: theResSStackoffset=0, theResSStackSize=0
97    
98     type(modeType) :: our_orig_mode
99    
100     ! call external C function used in inlined code
101     integer iaddr
102     external iaddr
103    
104     C write(*,'(A,I6,A,I6,A,I6,A,I6,A,I5,A,I5)')
105     C +"b:AF:", theArgFStackoffset,
106     C +" AI:",theArgIStackoffset,
107     C +" RF:",theResFStackoffset,
108     C +" RI:",theResIStackoffset,
109     C +" DT:",double_tape_pointer,
110     C +" IT:",integer_tape_pointer
111     if (our_rev_mode%arg_store) then
112     C print*, " arg_store ", our_rev_mode
113     C store arguments
114     !$PLACEHOLDER_PRAGMA$ id=4
115     end if
116     if (our_rev_mode%arg_restore) then
117     C print*, " arg_restore", our_rev_mode
118     C restore arguments
119     !$PLACEHOLDER_PRAGMA$ id=6
120     end if
121     if (our_rev_mode%plain) then
122     C print*, " plain ", our_rev_mode
123     our_orig_mode=our_rev_mode
124     our_rev_mode%arg_store=.FALSE.
125     C original function
126     !$PLACEHOLDER_PRAGMA$ id=1
127     our_rev_mode=our_orig_mode
128     end if
129     if (our_rev_mode%tape) then
130     C print*, " tape ", our_rev_mode
131     our_rev_mode%arg_store=.TRUE.
132     our_rev_mode%arg_restore=.FALSE.
133     our_rev_mode%res_store=.FALSE.
134     our_rev_mode%res_restore=.FALSE.
135     our_rev_mode%plain=.TRUE.
136     our_rev_mode%tape=.FALSE.
137     our_rev_mode%adjoint=.FALSE.
138     C taping
139     !$PLACEHOLDER_PRAGMA$ id=2
140     our_rev_mode%arg_store=.FALSE.
141     our_rev_mode%arg_restore=.FALSE.
142     our_rev_mode%res_store=.FALSE.
143     our_rev_mode%res_restore=.FALSE.
144     our_rev_mode%plain=.FALSE.
145     our_rev_mode%tape=.FALSE.
146     our_rev_mode%adjoint=.TRUE.
147     end if
148     if (our_rev_mode%res_restore) then
149     C restore results
150     !$PLACEHOLDER_PRAGMA$ id=7
151     end if
152     if (our_rev_mode%adjoint) then
153     C print*, " adjoint ", our_rev_mode
154     our_rev_mode%arg_store=.FALSE.
155     our_rev_mode%arg_restore=.TRUE.
156     our_rev_mode%res_store=.FALSE.
157     our_rev_mode%res_restore=.FALSE.
158     our_rev_mode%plain=.FALSE.
159     our_rev_mode%tape=.TRUE.
160     our_rev_mode%adjoint=.FALSE.
161     C adjoint
162     !$PLACEHOLDER_PRAGMA$ id=3
163     our_rev_mode%arg_store=.FALSE.
164     our_rev_mode%arg_restore=.TRUE.
165     our_rev_mode%res_store=.FALSE.
166     our_rev_mode%res_restore=.FALSE.
167     our_rev_mode%plain=.FALSE.
168     our_rev_mode%tape=.TRUE.
169     our_rev_mode%adjoint=.FALSE.
170     end if
171     if (our_rev_mode%res_store) then
172     C store results
173     C print*, " res_store ", our_rev_mode
174     !$PLACEHOLDER_PRAGMA$ id=5
175     end if
176     C write(*,'(A,I6,A,I6,A,I6,A,I6,A,I5,A,I5)')
177     C +"a:AF:", theArgFStackoffset,
178     C +" AI:",theArgIStackoffset,
179     C +" RF:",theResFStackoffset,
180     C +" RI:",theResIStackoffset,
181     C +" DT:",double_tape_pointer,
182     C +" IT:",integer_tape_pointer
183     end subroutine template

  ViewVC Help
Powered by ViewVC 1.1.22