/[MITgcm]/MITgcm_contrib/heimbach/OpenAD/code_shallow_openad/ad_inline.f
ViewVC logotype

Annotation of /MITgcm_contrib/heimbach/OpenAD/code_shallow_openad/ad_inline.f

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


Revision 1.2 - (hide annotations) (download)
Wed Jan 11 06:24:34 2006 UTC (20 years, 10 months ago) by utke
Branch: MAIN
Changes since 1.1: +201 -0 lines
add missing stores/restores for tensors

1 heimbach 1.1 C taping --------------------------------------------
2    
3    
4     subroutine push(x)
5     C $OpenAD$ INLINE DECLS
6     double precision :: x
7     C $OpenAD$ END DECLS
8     if(double_tape_size .lt. double_tape_pointer) then
9     allocate(double_tmp_tape(double_tape_size),
10     +STAT=cp_loop_variable_1)
11     if (cp_loop_variable_1 .gt. 0 ) then
12     print *,'allocation failed with', cp_loop_variable_1
13     stop
14     end if
15     double_tmp_tape=double_tape
16     deallocate(double_tape)
17     allocate(double_tape(double_tape_size*2))
18     print *, "DT+"
19     double_tape(1:double_tape_size) = double_tmp_tape
20     deallocate(double_tmp_tape)
21     double_tape_size=double_tape_size*2
22     end if
23     double_tape(double_tape_pointer)=x
24     double_tape_pointer=double_tape_pointer+1
25     end subroutine
26    
27    
28     subroutine pop(x)
29     C $OpenAD$ INLINE DECLS
30     double precision :: x
31     C $OpenAD$ END DECLS
32     double_tape_pointer=double_tape_pointer-1
33     x=double_tape(double_tape_pointer)
34     end subroutine
35    
36    
37     subroutine push_i(x)
38     C $OpenAD$ INLINE DECLS
39     integer :: x
40     C $OpenAD$ END DECLS
41     if(integer_tape_size .lt. integer_tape_pointer) then
42     allocate(integer_tmp_tape(integer_tape_size))
43     integer_tmp_tape=integer_tape
44     deallocate(integer_tape)
45     allocate(integer_tape(integer_tape_size*2))
46     print *, "IT+"
47     integer_tape(1:integer_tape_size) = integer_tmp_tape
48     deallocate(integer_tmp_tape)
49     integer_tape_size=integer_tape_size*2
50     end if
51     integer_tape(integer_tape_pointer)=x
52     integer_tape_pointer=integer_tape_pointer+1
53     end subroutine
54    
55     subroutine pop_i(x)
56     C $OpenAD$ INLINE DECLS
57     use OpenAD_tape
58     implicit none
59     integer :: x
60     C $OpenAD$ END DECLS
61     integer_tape_pointer=integer_tape_pointer-1
62     x=integer_tape(integer_tape_pointer)
63     end subroutine
64    
65     subroutine saxpy(a,x,y)
66     C $OpenAD$ INLINE DECLS
67     double precision, intent(in) :: a
68     type(active), intent(in) :: x
69     type(active), intent(inout) :: y
70     C $OpenAD$ END DECLS
71     y%d=y%d+x%d*a
72     end subroutine
73    
74     subroutine zeroderiv(x)
75     C $OpenAD$ INLINE DECLS
76     type(active), intent(out) :: x
77     C $OpenAD$ END DECLS
78     x%d=0.0d0
79     end subroutine
80    
81     subroutine setderiv(y,x)
82     C $OpenAD$ INLINE DECLS
83     type(active), intent(out) :: x
84     type(active), intent(in) :: y
85     C $OpenAD$ END DECLS
86     x%d=y%d
87     end subroutine
88    
89    
90     subroutine incderiv(y,x)
91     C $OpenAD$ INLINE DECLS
92     type(active), intent(out) :: x
93     type(active), intent(in) :: y
94     C $OpenAD$ END DECLS
95     x%d=x%d+y%d
96     end subroutine
97    
98     subroutine condinczeroderiv(y,x)
99     C $OpenAD$ INLINE DECLS
100     type(active), intent(out) :: x
101     type(active), intent(in) :: y
102     C $OpenAD$ END DECLS
103     if (iaddr(y).ne.iaddr(x)) then
104     x%d=x%d+y%d
105     y%d=0
106     end if
107     end subroutine
108    
109     C Checkpointing stuff ---------------------------------------
110    
111     C reals -----------------------------------------------------
112     subroutine cp_arg_store_real_scalar(x)
113     C $OpenAD$ INLINE DECLS
114     double precision :: x
115     C $OpenAD$ END DECLS
116     if(cp_double_size .lt. cp_double_pointer+1) then
117     allocate(cp_double_tmp(cp_double_size))
118     cp_double_tmp=cp_double
119     deallocate(cp_double)
120     allocate(cp_double(cp_double_size*2))
121     print *,'CPD+'
122     cp_double(1:cp_double_size) = cp_double_tmp
123     deallocate(cp_double_tmp)
124     cp_double_size=cp_double_size*2
125     end if
126     cp_double_pointer=cp_double_pointer+1
127     cp_double(cp_double_pointer)=x
128     end subroutine
129    
130     subroutine cp_arg_restore_real_scalar(x)
131     C $OpenAD$ INLINE DECLS
132     implicit none
133     double precision :: x
134     C $OpenAD$ END DECLS
135     x=cp_double(cp_double_pointer)
136     cp_double_pointer=cp_double_pointer-1
137     end subroutine
138    
139     subroutine cp_arg_store_real_scalar_a(x)
140     C $OpenAD$ INLINE DECLS
141     double precision :: x
142     C $OpenAD$ END DECLS
143     if(cp_double_size .lt. cp_double_pointer+1) then
144     allocate(cp_double_tmp(cp_double_size))
145     cp_double_tmp=cp_double
146     deallocate(cp_double)
147     allocate(cp_double(cp_double_size*2))
148     print *,'CPD+'
149     cp_double(1:cp_double_size) = cp_double_tmp
150     deallocate(cp_double_tmp)
151     cp_double_size=cp_double_size*2
152     end if
153     cp_double_pointer=cp_double_pointer+1
154     cp_double(cp_double_pointer)=x%v
155     end subroutine
156    
157     subroutine cp_arg_restore_real_scalar_a(x)
158     C $OpenAD$ INLINE DECLS
159     implicit none
160     double precision :: x
161     C $OpenAD$ END DECLS
162     x%v=cp_double(cp_double_pointer)
163     cp_double_pointer=cp_double_pointer-1
164     end subroutine
165    
166     subroutine cp_arg_store_real_vector(x,cp_loop_variable_1)
167     C $OpenAD$ INLINE DECLS
168     implicit none
169     double precision, dimension(:) :: x
170     C $OpenAD$ END DECLS
171     do while (cp_double_size .lt.
172     +cp_double_pointer+ubound(x,1)-lbound(x,1))
173     allocate(cp_double_tmp(cp_double_size))
174     cp_double_tmp=cp_double
175     deallocate(cp_double)
176     allocate(cp_double(cp_double_size*2))
177     print *,'CPD+'
178     cp_double(1:cp_double_size) = cp_double_tmp
179     deallocate(cp_double_tmp)
180     cp_double_size=cp_double_size*2
181     end do
182     do cp_loop_variable_1=lbound(x,1), ubound(x,1), 1
183     cp_double_pointer=cp_double_pointer+1
184     cp_double(cp_double_pointer)=
185     +x(cp_loop_variable_1)
186     end do
187     end subroutine
188    
189     subroutine cp_arg_restore_real_vector(x,cp_loop_variable_1)
190     C $OpenAD$ INLINE DECLS
191     implicit none
192     double precision, dimension(:) :: x
193     C $OpenAD$ END DECLS
194     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
195     x(cp_loop_variable_1)=cp_double(cp_double_pointer)
196     cp_double_pointer=cp_double_pointer-1
197     C write(*,'(A,EN26.16E3)') "restore(v) ",
198     C +x(cp_loop_variable_1)%v
199     end do
200     end subroutine
201    
202     subroutine cp_arg_store_real_vector_a(x,cp_loop_variable_1)
203     C $OpenAD$ INLINE DECLS
204     implicit none
205     double precision, dimension(:) :: x
206     C $OpenAD$ END DECLS
207     do while (cp_double_size .lt.
208     +cp_double_pointer+ubound(x,1)-lbound(x,1))
209     allocate(cp_double_tmp(cp_double_size))
210     cp_double_tmp=cp_double
211     deallocate(cp_double)
212     allocate(cp_double(cp_double_size*2))
213     print *,'CPD+'
214     cp_double(1:cp_double_size) = cp_double_tmp
215     deallocate(cp_double_tmp)
216     cp_double_size=cp_double_size*2
217     end do
218     do cp_loop_variable_1=lbound(x,1), ubound(x,1), 1
219     cp_double_pointer=cp_double_pointer+1
220     cp_double(cp_double_pointer)=
221     +x(cp_loop_variable_1)%v
222     end do
223     end subroutine
224    
225     subroutine cp_arg_restore_real_vector_a(x,cp_loop_variable_1)
226     C $OpenAD$ INLINE DECLS
227     implicit none
228     double precision, dimension(:) :: x
229     C $OpenAD$ END DECLS
230     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
231     x(cp_loop_variable_1)%v=cp_double(cp_double_pointer)
232     cp_double_pointer=cp_double_pointer-1
233     C write(*,'(A,EN26.16E3)') "restore(v) ",
234     C +x(cp_loop_variable_1)%v
235     end do
236     end subroutine
237    
238     subroutine cp_arg_store_real_matrix(x,cp_loop_variable_1,
239     +cp_loop_variable_2)
240     C $OpenAD$ INLINE DECLS
241     implicit none
242     double precision, dimension(::) :: x
243     C $OpenAD$ END DECLS
244     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
245     do while (cp_double_size .lt.
246     +cp_double_pointer+ubound(x,2)-lbound(x,2))
247     allocate(cp_double_tmp(cp_double_size))
248     cp_double_tmp=cp_double
249     deallocate(cp_double)
250     allocate(cp_double(cp_double_size*2))
251     print *,'CPD+'
252     cp_double(1:cp_double_size) = cp_double_tmp
253     deallocate(cp_double_tmp)
254     cp_double_size=cp_double_size*2
255     end do
256     do cp_loop_variable_2=lbound(x,2), ubound(x,2), 1
257     cp_double_pointer=cp_double_pointer+1
258     cp_double(cp_double_pointer)=
259     +x(cp_loop_variable_1,cp_loop_variable_2)
260     end do
261     end do
262     end subroutine
263    
264     subroutine cp_arg_restore_real_matrix(x,cp_loop_variable_1,
265     +cp_loop_variable_2)
266     C $OpenAD$ INLINE DECLS
267     implicit none
268     double precision, dimension(::) :: x
269     C $OpenAD$ END DECLS
270     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
271     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
272     x(cp_loop_variable_1,cp_loop_variable_2)=
273     +cp_double(cp_double_pointer)
274     cp_double_pointer=cp_double_pointer-1
275     end do
276     end do
277     end subroutine
278    
279     subroutine cp_arg_store_real_matrix_a(x,cp_loop_variable_1,
280     +cp_loop_variable_2)
281     C $OpenAD$ INLINE DECLS
282     implicit none
283     double precision, dimension(::) :: x
284     C $OpenAD$ END DECLS
285     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
286     do while (cp_double_size .lt.
287     +cp_double_pointer+ubound(x,2)-lbound(x,2))
288     allocate(cp_double_tmp(cp_double_size))
289     cp_double_tmp=cp_double
290     deallocate(cp_double)
291     allocate(cp_double(cp_double_size*2))
292     print *,'CPD+'
293     cp_double(1:cp_double_size) = cp_double_tmp
294     deallocate(cp_double_tmp)
295     cp_double_size=cp_double_size*2
296     end do
297     do cp_loop_variable_2=lbound(x,2), ubound(x,2), 1
298     cp_double_pointer=cp_double_pointer+1
299     cp_double(cp_double_pointer)=
300     +x(cp_loop_variable_1,cp_loop_variable_2)%v
301     end do
302     end do
303     end subroutine
304    
305     subroutine cp_arg_restore_real_matrix_a(x,cp_loop_variable_1,
306     +cp_loop_variable_2)
307     C $OpenAD$ INLINE DECLS
308     implicit none
309     double precision, dimension(::) :: x
310     C $OpenAD$ END DECLS
311     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
312     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
313     x(cp_loop_variable_1,cp_loop_variable_2)%v=
314     +cp_double(cp_double_pointer)
315     cp_double_pointer=cp_double_pointer-1
316     end do
317     end do
318     end subroutine
319    
320     subroutine cp_arg_store_real_three_tensor(x,
321     +cp_loop_variable_1,
322     +cp_loop_variable_2,
323     +cp_loop_variable_3
324     +)
325     C $OpenAD$ INLINE DECLS
326     implicit none
327     double precision, dimension(::) :: x
328     C $OpenAD$ END DECLS
329     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
330     do cp_loop_variable_2=lbound(x,2),ubound(x,2)
331     do while (cp_double_size .lt.
332     +cp_double_pointer+ubound(x,3)-lbound(x,3))
333     allocate(cp_double_tmp(cp_double_size))
334     cp_double_tmp=cp_double
335     deallocate(cp_double)
336     allocate(cp_double(cp_double_size*2))
337     print *,'CPD+'
338     cp_double(1:cp_double_size) = cp_double_tmp
339     deallocate(cp_double_tmp)
340     cp_double_size=cp_double_size*2
341     end do
342     do cp_loop_variable_3=lbound(x,3),ubound(x,3)
343     cp_double_pointer=cp_double_pointer+1
344     cp_double(cp_double_pointer)=
345     +x(
346     + cp_loop_variable_1,
347     + cp_loop_variable_2,
348     + cp_loop_variable_3
349     + )
350     end do
351     end do
352     end do
353     end subroutine
354    
355 utke 1.2 subroutine cp_arg_store_real_three_tensor_a(x,
356     +cp_loop_variable_1,
357     +cp_loop_variable_2,
358     +cp_loop_variable_3
359     +)
360     C $OpenAD$ INLINE DECLS
361     implicit none
362     double precision, dimension(::) :: x
363     C $OpenAD$ END DECLS
364     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
365     do cp_loop_variable_2=lbound(x,2),ubound(x,2)
366     do while (cp_double_size .lt.
367     +cp_double_pointer+ubound(x,3)-lbound(x,3))
368     allocate(cp_double_tmp(cp_double_size))
369     cp_double_tmp=cp_double
370     deallocate(cp_double)
371     allocate(cp_double(cp_double_size*2))
372     print *,'CPD+'
373     cp_double(1:cp_double_size) = cp_double_tmp
374     deallocate(cp_double_tmp)
375     cp_double_size=cp_double_size*2
376     end do
377     do cp_loop_variable_3=lbound(x,3),ubound(x,3)
378     cp_double_pointer=cp_double_pointer+1
379     cp_double(cp_double_pointer)=
380     +x(
381     + cp_loop_variable_1,
382     + cp_loop_variable_2,
383     + cp_loop_variable_3
384     + )%v
385     end do
386     end do
387     end do
388     end subroutine
389    
390 heimbach 1.1 subroutine cp_arg_restore_real_three_tensor(x,
391     +cp_loop_variable_1,
392     +cp_loop_variable_2,
393     +cp_loop_variable_3
394     +)
395     C $OpenAD$ INLINE DECLS
396     implicit none
397     double precision, dimension(::) :: x
398     C $OpenAD$ END DECLS
399     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
400     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
401     do cp_loop_variable_3=ubound(x,3),lbound(x,3),-1
402     x(
403     + cp_loop_variable_1,
404     + cp_loop_variable_2,
405     + cp_loop_variable_3
406     + )=
407     +cp_double(cp_double_pointer)
408     cp_double_pointer=cp_double_pointer-1
409     end do
410     end do
411     end do
412     end subroutine
413    
414 utke 1.2 subroutine cp_arg_restore_real_three_tensor_a(x,
415     +cp_loop_variable_1,
416     +cp_loop_variable_2,
417     +cp_loop_variable_3
418     +)
419     C $OpenAD$ INLINE DECLS
420     implicit none
421     double precision, dimension(::) :: x
422     C $OpenAD$ END DECLS
423     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
424     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
425     do cp_loop_variable_3=ubound(x,3),lbound(x,3),-1
426     x(
427     + cp_loop_variable_1,
428     + cp_loop_variable_2,
429     + cp_loop_variable_3
430     + )%v=
431     +cp_double(cp_double_pointer)
432     cp_double_pointer=cp_double_pointer-1
433     end do
434     end do
435     end do
436     end subroutine
437    
438 heimbach 1.1 subroutine cp_arg_store_real_four_tensor(x,
439     +cp_loop_variable_1,
440     +cp_loop_variable_2,
441     +cp_loop_variable_3,
442     +cp_loop_variable_4
443     +)
444     C $OpenAD$ INLINE DECLS
445     implicit none
446     double precision, dimension(::) :: x
447     C $OpenAD$ END DECLS
448     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
449     do cp_loop_variable_2=lbound(x,2),ubound(x,2)
450     do cp_loop_variable_3=lbound(x,3),ubound(x,3)
451     do while (cp_double_size .lt.
452     +cp_double_pointer+ubound(x,4)-lbound(x,4))
453     allocate(cp_double_tmp(cp_double_size))
454     cp_double_tmp=cp_double
455     deallocate(cp_double)
456     allocate(cp_double(cp_double_size*2))
457     print *,'CPD+'
458     cp_double(1:cp_double_size) = cp_double_tmp
459     deallocate(cp_double_tmp)
460     cp_double_size=cp_double_size*2
461     end do
462     do cp_loop_variable_4=lbound(x,4),ubound(x,4)
463     cp_double_pointer=cp_double_pointer+1
464     cp_double(cp_double_pointer)=
465     +x(
466     + cp_loop_variable_1,
467     + cp_loop_variable_2,
468     + cp_loop_variable_3,
469     + cp_loop_variable_4
470     + )
471     end do
472     end do
473     end do
474     end do
475     end subroutine
476    
477 utke 1.2 subroutine cp_arg_store_real_four_tensor_a(x,
478     +cp_loop_variable_1,
479     +cp_loop_variable_2,
480     +cp_loop_variable_3,
481     +cp_loop_variable_4
482     +)
483     C $OpenAD$ INLINE DECLS
484     implicit none
485     double precision, dimension(::) :: x
486     C $OpenAD$ END DECLS
487     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
488     do cp_loop_variable_2=lbound(x,2),ubound(x,2)
489     do cp_loop_variable_3=lbound(x,3),ubound(x,3)
490     do while (cp_double_size .lt.
491     +cp_double_pointer+ubound(x,4)-lbound(x,4))
492     allocate(cp_double_tmp(cp_double_size))
493     cp_double_tmp=cp_double
494     deallocate(cp_double)
495     allocate(cp_double(cp_double_size*2))
496     print *,'CPD+'
497     cp_double(1:cp_double_size) = cp_double_tmp
498     deallocate(cp_double_tmp)
499     cp_double_size=cp_double_size*2
500     end do
501     do cp_loop_variable_4=lbound(x,4),ubound(x,4)
502     cp_double_pointer=cp_double_pointer+1
503     cp_double(cp_double_pointer)=
504     +x(
505     + cp_loop_variable_1,
506     + cp_loop_variable_2,
507     + cp_loop_variable_3,
508     + cp_loop_variable_4
509     + )%v
510     end do
511     end do
512     end do
513     end do
514     end subroutine
515    
516 heimbach 1.1 subroutine cp_arg_restore_real_four_tensor(x,
517     +cp_loop_variable_1,
518     +cp_loop_variable_2,
519     +cp_loop_variable_3,
520     +cp_loop_variable_4
521     +)
522     C $OpenAD$ INLINE DECLS
523     implicit none
524     double precision, dimension(::) :: x
525     C $OpenAD$ END DECLS
526     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
527     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
528     do cp_loop_variable_3=ubound(x,3),lbound(x,3),-1
529     do cp_loop_variable_4=ubound(x,4),lbound(x,4),-1
530     x(
531     + cp_loop_variable_1,
532     + cp_loop_variable_2,
533     + cp_loop_variable_3,
534     + cp_loop_variable_4
535     + )=
536     +cp_double(cp_double_pointer)
537     cp_double_pointer=cp_double_pointer-1
538     end do
539     end do
540     end do
541     end do
542     end subroutine
543    
544 utke 1.2 subroutine cp_arg_restore_real_four_tensor_a(x,
545     +cp_loop_variable_1,
546     +cp_loop_variable_2,
547     +cp_loop_variable_3,
548     +cp_loop_variable_4
549     +)
550     C $OpenAD$ INLINE DECLS
551     implicit none
552     double precision, dimension(::) :: x
553     C $OpenAD$ END DECLS
554     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
555     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
556     do cp_loop_variable_3=ubound(x,3),lbound(x,3),-1
557     do cp_loop_variable_4=ubound(x,4),lbound(x,4),-1
558     x(
559     + cp_loop_variable_1,
560     + cp_loop_variable_2,
561     + cp_loop_variable_3,
562     + cp_loop_variable_4
563     + )%v=
564     +cp_double(cp_double_pointer)
565     cp_double_pointer=cp_double_pointer-1
566     end do
567     end do
568     end do
569     end do
570     end subroutine
571    
572 heimbach 1.1 subroutine cp_arg_store_real_five_tensor(x,
573     +cp_loop_variable_1,
574     +cp_loop_variable_2,
575     +cp_loop_variable_3,
576     +cp_loop_variable_4,
577     +cp_loop_variable_5
578     +)
579     C $OpenAD$ INLINE DECLS
580     implicit none
581     double precision, dimension(::) :: x
582     C $OpenAD$ END DECLS
583     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
584     do cp_loop_variable_2=lbound(x,2),ubound(x,2)
585     do cp_loop_variable_3=lbound(x,3),ubound(x,3)
586     do cp_loop_variable_4=lbound(x,4),ubound(x,4)
587     do while (cp_double_size .lt.
588     +cp_double_pointer+ubound(x,5)-lbound(x,5))
589     allocate(cp_double_tmp(cp_double_size))
590     cp_double_tmp=cp_double
591     deallocate(cp_double)
592     allocate(cp_double(cp_double_size*2))
593     print *,'CPD+'
594     cp_double(1:cp_double_size) = cp_double_tmp
595     deallocate(cp_double_tmp)
596     cp_double_size=cp_double_size*2
597     end do
598     do cp_loop_variable_5=lbound(x,5),ubound(x,5)
599     cp_double_pointer=cp_double_pointer+1
600     cp_double(cp_double_pointer)=
601     +x(
602     + cp_loop_variable_1,
603     + cp_loop_variable_2,
604     + cp_loop_variable_3,
605     + cp_loop_variable_4,
606     + cp_loop_variable_5
607     + )
608     end do
609     end do
610     end do
611     end do
612     end do
613     end subroutine
614    
615 utke 1.2 subroutine cp_arg_store_real_five_tensor_a(x,
616     +cp_loop_variable_1,
617     +cp_loop_variable_2,
618     +cp_loop_variable_3,
619     +cp_loop_variable_4,
620     +cp_loop_variable_5
621     +)
622     C $OpenAD$ INLINE DECLS
623     implicit none
624     double precision, dimension(::) :: x
625     C $OpenAD$ END DECLS
626     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
627     do cp_loop_variable_2=lbound(x,2),ubound(x,2)
628     do cp_loop_variable_3=lbound(x,3),ubound(x,3)
629     do cp_loop_variable_4=lbound(x,4),ubound(x,4)
630     do while (cp_double_size .lt.
631     +cp_double_pointer+ubound(x,5)-lbound(x,5))
632     allocate(cp_double_tmp(cp_double_size))
633     cp_double_tmp=cp_double
634     deallocate(cp_double)
635     allocate(cp_double(cp_double_size*2))
636     print *,'CPD+'
637     cp_double(1:cp_double_size) = cp_double_tmp
638     deallocate(cp_double_tmp)
639     cp_double_size=cp_double_size*2
640     end do
641     do cp_loop_variable_5=lbound(x,5),ubound(x,5)
642     cp_double_pointer=cp_double_pointer+1
643     cp_double(cp_double_pointer)=
644     +x(
645     + cp_loop_variable_1,
646     + cp_loop_variable_2,
647     + cp_loop_variable_3,
648     + cp_loop_variable_4,
649     + cp_loop_variable_5
650     + )%v
651     end do
652     end do
653     end do
654     end do
655     end do
656     end subroutine
657    
658 heimbach 1.1 subroutine cp_arg_restore_real_five_tensor(x,
659     +cp_loop_variable_1,
660     +cp_loop_variable_2,
661     +cp_loop_variable_3,
662     +cp_loop_variable_4,
663     +cp_loop_variable_5
664     +)
665     C $OpenAD$ INLINE DECLS
666     implicit none
667     double precision, dimension(::) :: x
668     C $OpenAD$ END DECLS
669     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
670     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
671     do cp_loop_variable_3=ubound(x,3),lbound(x,3),-1
672     do cp_loop_variable_4=ubound(x,4),lbound(x,4),-1
673     do cp_loop_variable_5=ubound(x,5),lbound(x,5),-1
674     x(
675     + cp_loop_variable_1,
676     + cp_loop_variable_2,
677     + cp_loop_variable_3,
678     + cp_loop_variable_4,
679     + cp_loop_variable_5
680     + )=
681     +cp_double(cp_double_pointer)
682     cp_double_pointer=cp_double_pointer-1
683     end do
684     end do
685     end do
686     end do
687     end do
688     end subroutine
689    
690 utke 1.2 subroutine cp_arg_restore_real_five_tensor_a(x,
691     +cp_loop_variable_1,
692     +cp_loop_variable_2,
693     +cp_loop_variable_3,
694     +cp_loop_variable_4,
695     +cp_loop_variable_5
696     +)
697     C $OpenAD$ INLINE DECLS
698     implicit none
699     double precision, dimension(::) :: x
700     C $OpenAD$ END DECLS
701     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
702     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
703     do cp_loop_variable_3=ubound(x,3),lbound(x,3),-1
704     do cp_loop_variable_4=ubound(x,4),lbound(x,4),-1
705     do cp_loop_variable_5=ubound(x,5),lbound(x,5),-1
706     x(
707     + cp_loop_variable_1,
708     + cp_loop_variable_2,
709     + cp_loop_variable_3,
710     + cp_loop_variable_4,
711     + cp_loop_variable_5
712     + )%v=
713     +cp_double(cp_double_pointer)
714     cp_double_pointer=cp_double_pointer-1
715     end do
716     end do
717     end do
718     end do
719     end do
720     end subroutine
721    
722 heimbach 1.1
723     C integers -----------------------------------------------------
724     subroutine cp_arg_store_integer_scalar(i)
725     C $OpenAD$ INLINE DECLS
726     implicit none
727     integer :: i
728     C $OpenAD$ END DECLS
729     if(cp_integer_size .lt. cp_integer_pointer+1) then
730     allocate(cp_integer_tmp(cp_integer_size))
731     cp_integer_tmp=cp_integer
732     deallocate(cp_integer)
733     allocate(cp_integer(cp_integer_size*2))
734     print *,'CPI+'
735     cp_integer(1:cp_integer_size) = cp_integer_tmp
736     deallocate(cp_integer_tmp)
737     cp_integer_size=cp_integer_size*2
738     end if
739     cp_integer_pointer=cp_integer_pointer+1
740     cp_integer(cp_integer_pointer)=i
741     end subroutine
742    
743     subroutine cp_arg_restore_integer_scalar(i)
744     C $OpenAD$ INLINE DECLS
745     implicit none
746     integer :: i
747     C $OpenAD$ END DECLS
748     i=cp_integer(cp_integer_pointer)
749     cp_integer_pointer=cp_integer_pointer-1
750     end subroutine
751    
752     subroutine cp_arg_store_integer_vector(x,cp_loop_variable_1)
753     C $OpenAD$ INLINE DECLS
754     implicit none
755     integer, dimension(:) :: x
756     C $OpenAD$ END DECLS
757     do while (cp_integer_size .lt.
758     +cp_integer_pointer+ubound(x,1)-lbound(x,1))
759     allocate(cp_integer_tmp(cp_integer_size))
760     cp_integer_tmp=cp_integer
761     deallocate(cp_integer)
762     allocate(cp_integer(cp_integer_size*2))
763     print *,'CPI+'
764     cp_integer(1:cp_integer_size) = cp_integer_tmp
765     deallocate(cp_integer_tmp)
766     cp_integer_size=cp_integer_size*2
767     end do
768     do cp_loop_variable_1=lbound(x,1), ubound(x,1), 1
769     cp_integer_pointer=cp_integer_pointer+1
770     cp_integer(cp_integer_pointer)=
771     +x(cp_loop_variable_1)
772     end do
773     end subroutine
774    
775     subroutine cp_arg_restore_integer_vector(x,cp_loop_variable_1)
776     C $OpenAD$ INLINE DECLS
777     implicit none
778     integer, dimension(:) :: x
779     C $OpenAD$ END DECLS
780     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
781     x(cp_loop_variable_1)=cp_integer(cp_integer_pointer)
782     cp_integer_pointer=cp_integer_pointer-1
783     end do
784     end subroutine
785    
786     subroutine cp_arg_store_integer_three_tensor(x,
787     +cp_loop_variable_1,
788     +cp_loop_variable_2,
789     +cp_loop_variable_3
790     +)
791     C $OpenAD$ INLINE DECLS
792     implicit none
793     integer, dimension(::) :: x
794     C $OpenAD$ END DECLS
795     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
796     do cp_loop_variable_2=lbound(x,2),ubound(x,2)
797     do while (cp_integer_size .lt.
798     +cp_integer_pointer+ubound(x,3)-lbound(x,3))
799     allocate(cp_integer_tmp(cp_integer_size))
800     cp_integer_tmp=cp_integer
801     deallocate(cp_integer)
802     allocate(cp_integer(cp_integer_size*2))
803     print *,'CPD+'
804     cp_integer(1:cp_integer_size) = cp_integer_tmp
805     deallocate(cp_integer_tmp)
806     cp_integer_size=cp_integer_size*2
807     end do
808     do cp_loop_variable_3=lbound(x,3),ubound(x,3)
809     cp_integer_pointer=cp_integer_pointer+1
810     cp_integer(cp_integer_pointer)=
811     +x(
812     + cp_loop_variable_1,
813     + cp_loop_variable_2,
814     + cp_loop_variable_3
815     + )
816     end do
817     end do
818     end do
819     end subroutine
820    
821     subroutine cp_arg_restore_integer_three_tensor(x,
822     +cp_loop_variable_1,
823     +cp_loop_variable_2,
824     +cp_loop_variable_3
825     +)
826     C $OpenAD$ INLINE DECLS
827     implicit none
828     integer, dimension(::) :: x
829     C $OpenAD$ END DECLS
830     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
831     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
832     do cp_loop_variable_3=ubound(x,3),lbound(x,3),-1
833     x(
834     + cp_loop_variable_1,
835     + cp_loop_variable_2,
836     + cp_loop_variable_3
837     + )=
838     +cp_integer(cp_integer_pointer)
839     cp_integer_pointer=cp_integer_pointer-1
840     end do
841     end do
842     end do
843     end subroutine
844    
845     subroutine cp_arg_store_integer_four_tensor(x,
846     +cp_loop_variable_1,
847     +cp_loop_variable_2,
848     +cp_loop_variable_3,
849     +cp_loop_variable_4
850     +)
851     C $OpenAD$ INLINE DECLS
852     implicit none
853     integer, dimension(::) :: x
854     C $OpenAD$ END DECLS
855     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
856     do cp_loop_variable_2=lbound(x,2),ubound(x,2)
857     do cp_loop_variable_3=lbound(x,3),ubound(x,3)
858     do while (cp_integer_size .lt.
859     +cp_integer_pointer+ubound(x,4)-lbound(x,4))
860     allocate(cp_integer_tmp(cp_integer_size))
861     cp_integer_tmp=cp_integer
862     deallocate(cp_integer)
863     allocate(cp_integer(cp_integer_size*2))
864     print *,'CPD+'
865     cp_integer(1:cp_integer_size) = cp_integer_tmp
866     deallocate(cp_integer_tmp)
867     cp_integer_size=cp_integer_size*2
868     end do
869     do cp_loop_variable_4=lbound(x,4),ubound(x,4)
870     cp_integer_pointer=cp_integer_pointer+1
871     cp_integer(cp_integer_pointer)=
872     +x(
873     + cp_loop_variable_1,
874     + cp_loop_variable_2,
875     + cp_loop_variable_3,
876     + cp_loop_variable_4
877     + )
878     end do
879     end do
880     end do
881     end do
882     end subroutine
883    
884     subroutine cp_arg_restore_integer_four_tensor(x,
885     +cp_loop_variable_1,
886     +cp_loop_variable_2,
887     +cp_loop_variable_3,
888     +cp_loop_variable_4
889     +)
890     C $OpenAD$ INLINE DECLS
891     implicit none
892     integer, dimension(::) :: x
893     C $OpenAD$ END DECLS
894     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
895     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
896     do cp_loop_variable_3=ubound(x,3),lbound(x,3),-1
897     do cp_loop_variable_4=ubound(x,4),lbound(x,4),-1
898     x(
899     + cp_loop_variable_1,
900     + cp_loop_variable_2,
901     + cp_loop_variable_3,
902     + cp_loop_variable_4
903     + )=
904     +cp_integer(cp_integer_pointer)
905     cp_integer_pointer=cp_integer_pointer-1
906     end do
907     end do
908     end do
909     end do
910     end subroutine
911    
912     subroutine cp_arg_store_integer_five_tensor(x,
913     +cp_loop_variable_1,
914     +cp_loop_variable_2,
915     +cp_loop_variable_3,
916     +cp_loop_variable_4,
917     +cp_loop_variable_5
918     +)
919     C $OpenAD$ INLINE DECLS
920     implicit none
921     integer, dimension(::) :: x
922     C $OpenAD$ END DECLS
923     do cp_loop_variable_1=lbound(x,1),ubound(x,1)
924     do cp_loop_variable_2=lbound(x,2),ubound(x,2)
925     do cp_loop_variable_3=lbound(x,3),ubound(x,3)
926     do cp_loop_variable_4=lbound(x,4),ubound(x,4)
927     do while (cp_integer_size .lt.
928     +cp_integer_pointer+ubound(x,5)-lbound(x,5))
929     allocate(cp_integer_tmp(cp_integer_size))
930     cp_integer_tmp=cp_integer
931     deallocate(cp_integer)
932     allocate(cp_integer(cp_integer_size*2))
933     print *,'CPD+'
934     cp_integer(1:cp_integer_size) = cp_integer_tmp
935     deallocate(cp_integer_tmp)
936     cp_integer_size=cp_integer_size*2
937     end do
938     do cp_loop_variable_5=lbound(x,5),ubound(x,5)
939     cp_integer_pointer=cp_integer_pointer+1
940     cp_integer(cp_integer_pointer)=
941     +x(
942     + cp_loop_variable_1,
943     + cp_loop_variable_2,
944     + cp_loop_variable_3,
945     + cp_loop_variable_4,
946     + cp_loop_variable_5
947     + )
948     end do
949     end do
950     end do
951     end do
952     end do
953     end subroutine
954    
955     subroutine cp_arg_restore_integer_five_tensor(x,
956     +cp_loop_variable_1,
957     +cp_loop_variable_2,
958     +cp_loop_variable_3,
959     +cp_loop_variable_4,
960     +cp_loop_variable_5
961     +)
962     C $OpenAD$ INLINE DECLS
963     implicit none
964     integer, dimension(::) :: x
965     C $OpenAD$ END DECLS
966     do cp_loop_variable_1=ubound(x,1),lbound(x,1),-1
967     do cp_loop_variable_2=ubound(x,2),lbound(x,2),-1
968     do cp_loop_variable_3=ubound(x,3),lbound(x,3),-1
969     do cp_loop_variable_4=ubound(x,4),lbound(x,4),-1
970     do cp_loop_variable_5=ubound(x,5),lbound(x,5),-1
971     x(
972     + cp_loop_variable_1,
973     + cp_loop_variable_2,
974     + cp_loop_variable_3,
975     + cp_loop_variable_4,
976     + cp_loop_variable_5
977     + )=
978     +cp_integer(cp_integer_pointer)
979     cp_integer_pointer=cp_integer_pointer-1
980     end do
981     end do
982     end do
983     end do
984     end do
985     end subroutine
986    
987     C strings -----------------------------------------------------
988     subroutine cp_arg_store_string_scalar(s)
989     C $OpenAD$ INLINE DECLS
990     implicit none
991     character*(80) :: s
992     C $OpenAD$ END DECLS
993     if(cp_string_size .lt. cp_string_pointer+1) then
994     allocate(cp_string_tmp(cp_string_size))
995     cp_string_tmp=cp_string
996     deallocate(cp_string)
997     allocate(cp_string(cp_string_size*2))
998     print *,'CPS+'
999     cp_string(1:cp_string_size) = cp_string_tmp
1000     deallocate(cp_string_tmp)
1001     cp_string_size=cp_string_size*2
1002     end if
1003     cp_string_pointer=cp_string_pointer+1
1004     cp_string(cp_string_pointer)=s
1005     end subroutine
1006    
1007     subroutine cp_arg_restore_string_scalar(s)
1008     C $OpenAD$ INLINE DECLS
1009     implicit none
1010     character*(80) :: s
1011     C $OpenAD$ END DECLS
1012     s=cp_string(cp_string_pointer)
1013     cp_string_pointer=cp_string_pointer-1
1014     end subroutine
1015    
1016     C bools -----------------------------------------------------
1017     subroutine cp_arg_store_bool_scalar(b)
1018     C $OpenAD$ INLINE DECLS
1019     implicit none
1020     logical :: b
1021     C $OpenAD$ END DECLS
1022     if(cp_boolean_size .lt. cp_boolean_pointer+1) then
1023     allocate(cp_boolean_tmp(cp_boolean_size))
1024     cp_boolean_tmp=cp_boolean
1025     deallocate(cp_boolean)
1026     allocate(cp_boolean(cp_boolean_size*2))
1027     print *,'CPB+'
1028     cp_boolean(1:cp_boolean_size) = cp_boolean_tmp
1029     deallocate(cp_boolean_tmp)
1030     cp_boolean_size=cp_boolean_size*2
1031     end if
1032     cp_boolean_pointer=cp_boolean_pointer+1
1033     cp_boolean(cp_boolean_pointer)=b
1034     end subroutine
1035    
1036     subroutine cp_arg_restore_bool_scalar(b)
1037     C $OpenAD$ INLINE DECLS
1038     implicit none
1039     logical :: b
1040     C $OpenAD$ END DECLS
1041     b=cp_boolean(cp_boolean_pointer)
1042     cp_boolean_pointer=cp_boolean_pointer-1
1043     end subroutine

  ViewVC Help
Powered by ViewVC 1.1.22