/[MITgcm]/MITgcm_contrib/heimbach/OpenAD/OAD_support/OAD_active.F90
ViewVC logotype

Annotation of /MITgcm_contrib/heimbach/OpenAD/OAD_support/OAD_active.F90

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


Revision 1.6 - (hide annotations) (download)
Fri Feb 26 23:46:02 2010 UTC (16 years, 6 months ago) by utke
Branch: MAIN
Changes since 1.5: +508 -432 lines
identical to OpenAD/runtimeSupport/genBase

1 utke 1.5 !#########################################################
2     ! This file is part of OpenAD released under the LGPL. #
3     ! The full COPYRIGHT notice can be found in the top #
4     ! level directory of the OpenAD distribution #
5     !#########################################################
6 utke 1.1 module OAD_active
7     use w2f__types
8     implicit none
9 utke 1.6 private :: runTimeErrorStop, shapeChange
10     public :: active
11     #ifndef TRACE
12     public :: saxpy, sax, zero_deriv, setderiv
13     public :: set_neg_deriv, inc_deriv, dec_deriv
14     #endif
15     public :: oad_convert, oad_allocateMatching, oad_shapeTest
16     #ifndef TRACE
17     integer :: count_mult = 0
18     integer :: count_add = 0
19     #endif
20     integer, parameter :: shapeChange=0
21     #ifdef VECTOR
22     integer :: max_deriv_vec_len
23     parameter ( max_deriv_vec_len = 100 )
24     # define VECTOR_DIM , dimension(max_deriv_vec_len)
25     # define VECTOR_LOOP_VAR integer :: i
26     # define VECTOR_LOOP_BEGIN do i=1,max_deriv_vec_len
27     # define VECTOR_LOOP_END end do
28     # define DELEM d(i)
29     #else
30     # define VECTOR_DIM
31     # define VECTOR_LOOP_VAR
32     # define VECTOR_LOOP_BEGIN
33     # define VECTOR_LOOP_END
34     # define DELEM d
35     #endif
36     #ifdef SCALARNDI
37     # define DINIT
38     #else
39     # define DINIT =0.0d0
40     #endif
41 utke 1.1
42     !
43     ! active needs to be a sequence type
44     ! with no initialization
45     !
46     type active
47     sequence
48     real(w2f__8) :: v
49 utke 1.6 #ifndef TRACE
50 utke 1.1 ! initialization does not work for active variables
51     ! inside of common block, such as in boxmodel
52     ! initialization is required for correct adjoint
53 utke 1.6 real(w2f__8) VECTOR_DIM :: d DINIT
54     #endif
55     end type
56     #ifndef TRACE
57 utke 1.1 interface saxpy
58 utke 1.6 module procedure saxpy_d0_a0_a0, saxpy_l0_a0_a0, saxpy_i0_a0_a0
59     module procedure saxpy_d1_a1_a1, saxpy_l1_a1_a1, saxpy_i1_a1_a1
60 utke 1.1 end interface
61    
62     interface setderiv
63 utke 1.6 module procedure setderiv_a0_a0
64     module procedure setderiv_a1_a1
65 utke 1.1 end interface
66    
67 utke 1.3 interface set_neg_deriv
68 utke 1.6 module procedure set_neg_deriv_a0_a0
69     module procedure set_neg_deriv_a1_a1
70 utke 1.3 end interface set_neg_deriv
71    
72     interface inc_deriv
73 utke 1.6 module procedure inc_deriv_a0_a0
74     module procedure inc_deriv_a1_a1
75 utke 1.3 end interface inc_deriv
76    
77     interface dec_deriv
78 utke 1.6 module procedure dec_deriv_a0_a0
79     module procedure dec_deriv_a1_a1
80 utke 1.3 end interface dec_deriv
81    
82 utke 1.1 interface zero_deriv
83 utke 1.6 module procedure zero_deriv_a0
84     module procedure zero_deriv_a1
85     module procedure zero_deriv_a2
86     module procedure zero_deriv_a3
87     module procedure zero_deriv_a4
88 utke 1.1 end interface
89 utke 1.6
90 utke 1.1 interface sax
91 utke 1.6 module procedure sax_d0_a0_a0, sax_l0_a0_a0, sax_i0_a0_a0
92     module procedure sax_d1_a1_a1, sax_l1_a1_a1, sax_i1_a1_a1
93 utke 1.1 end interface
94    
95 utke 1.2 #endif
96 utke 1.6 interface oad_convert
97     module procedure convert_d0_a0
98     module procedure convert_d1_a1
99     module procedure convert_d2_a2
100     module procedure convert_d3_a3
101     module procedure convert_d4_a4
102     module procedure convert_d5_a5
103     module procedure convert_d6_a6
104     module procedure convert_d7_a7
105     module procedure convert_a0_d0
106     module procedure convert_a1_d1
107     module procedure convert_a2_d2
108     module procedure convert_a3_d3
109     module procedure convert_a4_d4
110     module procedure convert_a5_d5
111     module procedure convert_a6_d6
112     module procedure convert_a7_d7
113     #ifndef DEFAULT_R8
114     module procedure convert_r0_a0
115     module procedure convert_r1_a1
116     module procedure convert_r2_a2
117     module procedure convert_r3_a3
118     module procedure convert_r4_a4
119     module procedure convert_r5_a5
120     module procedure convert_r6_a6
121     module procedure convert_r7_a7
122     module procedure convert_a0_r0
123     module procedure convert_a1_r1
124     module procedure convert_a2_r2
125     module procedure convert_a3_r3
126     module procedure convert_a4_r4
127     module procedure convert_a5_r5
128     module procedure convert_a6_r6
129     module procedure convert_a7_r7
130 utke 1.2 #endif
131 utke 1.1 end interface
132    
133 utke 1.6 interface oad_allocateMatching
134     module procedure allocateMatching_a1_d1
135     module procedure allocateMatching_a1_a1
136     module procedure allocateMatching_d1_a1
137     module procedure allocateMatching_a2_a2
138     module procedure allocateMatching_d2_a2
139     module procedure allocateMatching_a4_a4
140     module procedure allocateMatching_d4_a4
141     module procedure allocateMatching_a5_a5
142     module procedure allocateMatching_d5_a5
143     #ifndef DEFAULT_R8
144     module procedure allocateMatching_r1_a1
145     module procedure allocateMatching_r2_a2
146 utke 1.2 #endif
147 utke 1.6 end interface
148 utke 1.1
149 utke 1.6 interface oad_shapeTest
150     module procedure shapeTest_a1_d1
151     module procedure shapeTest_a1_a1
152     module procedure shapeTest_d1_a1
153     module procedure shapeTest_a2_a2
154     module procedure shapeTest_d2_a2
155     module procedure shapeTest_a4_a4
156     module procedure shapeTest_d4_a4
157     module procedure shapeTest_a5_a5
158     module procedure shapeTest_d5_a5
159     #ifndef DEFAULT_R8
160     module procedure shapeTest_r1_a1
161     module procedure shapeTest_r2_a2
162 utke 1.3 #endif
163     end interface
164    
165 utke 1.6 interface runTimeErrorStop
166     module procedure runTimeErrorStopI
167 utke 1.5 end interface
168    
169 utke 1.1 contains
170 utke 1.6 #ifndef TRACE
171 utke 1.1 !
172     ! chain rule saxpy to be used in forward and reverse modes
173     !
174    
175 utke 1.6 subroutine saxpy_d0_a0_a0(a,x,y)
176 utke 1.1 real(w2f__8), intent(in) :: a
177     type(active), intent(in) :: x
178     type(active), intent(inout) :: y
179 utke 1.6 VECTOR_LOOP_VAR
180     VECTOR_LOOP_BEGIN
181     y%DELEM = y%DELEM + x%DELEM*a
182     VECTOR_LOOP_END
183     end subroutine
184    
185     subroutine saxpy_i0_a0_a0(a,x,y)
186     integer(kind=w2f__i4), intent(in) :: a
187     type(active), intent(in) :: x
188     type(active), intent(inout) :: y
189     VECTOR_LOOP_VAR
190     VECTOR_LOOP_BEGIN
191     y%DELEM = y%DELEM + x%DELEM*a
192     VECTOR_LOOP_END
193     end subroutine
194 utke 1.1
195 utke 1.6 subroutine saxpy_l0_a0_a0(a,x,y)
196     integer(kind=w2f__i8), intent(in) :: a
197     type(active), intent(in) :: x
198     type(active), intent(inout) :: y
199     VECTOR_LOOP_VAR
200     VECTOR_LOOP_BEGIN
201     y%DELEM = y%DELEM + x%DELEM*a
202     VECTOR_LOOP_END
203     end subroutine
204    
205     subroutine saxpy_d1_a1_a1(a,x,y)
206     real(w2f__8), dimension(:), intent(in) :: a
207     type(active), dimension(:), intent(in) :: x
208     type(active), dimension(:), intent(inout) :: y
209     VECTOR_LOOP_VAR
210     VECTOR_LOOP_BEGIN
211     y%DELEM=y%DELEM+x%DELEM*a
212     VECTOR_LOOP_END
213     end subroutine
214    
215     subroutine saxpy_i1_a1_a1(a,x,y)
216     integer(kind=w2f__i4), dimension(:), intent(in) :: a
217     type(active), dimension(:), intent(in) :: x
218     type(active), dimension(:), intent(inout) :: y
219     VECTOR_LOOP_VAR
220     VECTOR_LOOP_BEGIN
221     y%DELEM=y%DELEM+x%DELEM*a
222     VECTOR_LOOP_END
223     end subroutine
224    
225     subroutine saxpy_l1_a1_a1(a,x,y)
226     integer(kind=w2f__i8), dimension(:), intent(in) :: a
227     type(active), dimension(:), intent(in) :: x
228     type(active), dimension(:), intent(inout) :: y
229     VECTOR_LOOP_VAR
230     VECTOR_LOOP_BEGIN
231     y%DELEM=y%DELEM+x%DELEM*a
232     VECTOR_LOOP_END
233     end subroutine
234    
235 utke 1.1 !
236     ! chain rule saxpy to be used in forward and reverse modes
237     ! derivative component of y is equal to zero initially
238     ! note: y needs to be inout as otherwise value component gets
239     ! zeroed out
240     !
241    
242 utke 1.6 subroutine sax_d0_a0_a0(a,x,y)
243 utke 1.1 real(w2f__8), intent(in) :: a
244     type(active), intent(in) :: x
245     type(active), intent(inout) :: y
246 utke 1.6 VECTOR_LOOP_VAR
247     VECTOR_LOOP_BEGIN
248     y%DELEM = x%DELEM*a
249     VECTOR_LOOP_END
250     end subroutine
251    
252     subroutine sax_i0_a0_a0(a,x,y)
253     integer(kind=w2f__i4), intent(in) :: a
254     type(active), intent(in) :: x
255     type(active), intent(inout) :: y
256     VECTOR_LOOP_VAR
257     VECTOR_LOOP_BEGIN
258     y%DELEM = x%DELEM*a
259     VECTOR_LOOP_END
260     end subroutine
261 utke 1.1
262 utke 1.6 subroutine sax_l0_a0_a0(a,x,y)
263 utke 1.1 integer(kind=w2f__i8), intent(in) :: a
264     type(active), intent(in) :: x
265     type(active), intent(inout) :: y
266 utke 1.6 VECTOR_LOOP_VAR
267     VECTOR_LOOP_BEGIN
268     y%DELEM = x%DELEM*a
269     VECTOR_LOOP_END
270     end subroutine
271    
272     subroutine sax_d1_a1_a1(a,x,y)
273     real(w2f__8), dimension(:), intent(in) :: a
274     type(active), dimension(:), intent(in) :: x
275     type(active), dimension(:), intent(inout) :: y
276     VECTOR_LOOP_VAR
277     VECTOR_LOOP_BEGIN
278     y%DELEM=x%DELEM*a
279     VECTOR_LOOP_END
280     end subroutine
281    
282     subroutine sax_i1_a1_a1(a,x,y)
283     integer(kind=w2f__i4), dimension(:), intent(in) :: a
284     type(active), dimension(:), intent(in) :: x
285     type(active), dimension(:), intent(inout) :: y
286     VECTOR_LOOP_VAR
287     VECTOR_LOOP_BEGIN
288     y%DELEM=x%DELEM*a
289     VECTOR_LOOP_END
290     end subroutine
291    
292     subroutine sax_l1_a1_a1(a,x,y)
293     integer(kind=w2f__i8), dimension(:), intent(in) :: a
294     type(active), dimension(:), intent(in) :: x
295     type(active), dimension(:), intent(inout) :: y
296     VECTOR_LOOP_VAR
297     VECTOR_LOOP_BEGIN
298     y%DELEM=x%DELEM*a
299     VECTOR_LOOP_END
300     end subroutine
301    
302 utke 1.1 !
303     ! set derivative of y to be equal to derivative of x
304     ! note: making y inout allows for already existing active
305     ! variables to become the target of a derivative assignment
306     !
307    
308 utke 1.6 subroutine setderiv_a0_a0(y,x)
309 utke 1.1 type(active), intent(inout) :: y
310     type(active), intent(in) :: x
311 utke 1.6 VECTOR_LOOP_VAR
312     VECTOR_LOOP_BEGIN
313     y%DELEM = x%DELEM
314     VECTOR_LOOP_END
315     end subroutine
316    
317     subroutine setderiv_a1_a1(y,x)
318     type(active), intent(inout), dimension(:) :: y
319     type(active), intent(in), dimension(:) :: x
320     VECTOR_LOOP_VAR
321     VECTOR_LOOP_BEGIN
322     y%DELEM = x%DELEM
323     VECTOR_LOOP_END
324     end subroutine
325 utke 1.1
326     !
327 utke 1.3 ! set the derivative of y to be the negated derivative of x
328     ! note: making y inout allows for already existing active
329     ! variables to become the target of a derivative assignment
330     !
331    
332 utke 1.6 subroutine set_neg_deriv_a0_a0(y,x)
333 utke 1.3 type(active), intent(inout) :: y
334     type(active), intent(in) :: x
335 utke 1.6 VECTOR_LOOP_VAR
336     VECTOR_LOOP_BEGIN
337     y%DELEM = -x%DELEM
338     VECTOR_LOOP_END
339     end subroutine
340    
341     subroutine set_neg_deriv_a1_a1(y,x)
342     type(active), intent(inout), dimension(:) :: y
343     type(active), intent(in), dimension(:) :: x
344     VECTOR_LOOP_VAR
345     VECTOR_LOOP_BEGIN
346     y%DELEM = -x%DELEM
347     VECTOR_LOOP_END
348     end subroutine
349 utke 1.3
350     !
351     ! increment the derivative of y by the derivative of x
352     ! note: making y inout allows for already existing active
353     ! variables to become the target of a derivative assignment
354     !
355    
356 utke 1.6 subroutine inc_deriv_a0_a0(y,x)
357 utke 1.3 type(active), intent(inout) :: y
358     type(active), intent(in) :: x
359 utke 1.6 VECTOR_LOOP_VAR
360     VECTOR_LOOP_BEGIN
361     y%DELEM = y%DELEM + x%DELEM
362     VECTOR_LOOP_END
363     end subroutine
364    
365     subroutine inc_deriv_a1_a1(y,x)
366     type(active), intent(inout), dimension(:) :: y
367     type(active), intent(in), dimension(:) :: x
368     VECTOR_LOOP_VAR
369     VECTOR_LOOP_BEGIN
370     y%DELEM = y%DELEM + x%DELEM
371     VECTOR_LOOP_END
372     end subroutine
373 utke 1.3
374     !
375     ! decrement the derivative of y by the derivative of x
376     ! note: making y inout allows for already existing active
377     ! variables to become the target of a derivative assignment
378     !
379    
380 utke 1.6 subroutine dec_deriv_a0_a0(y,x)
381 utke 1.3 type(active), intent(inout) :: y
382     type(active), intent(in) :: x
383 utke 1.6 VECTOR_LOOP_VAR
384     VECTOR_LOOP_BEGIN
385     y%DELEM = y%DELEM - x%DELEM
386     VECTOR_LOOP_END
387     end subroutine
388 utke 1.3
389 utke 1.6 subroutine dec_deriv_a1_a1(y,x)
390     type(active), intent(inout), dimension(:) :: y
391     type(active), intent(in), dimension(:) :: x
392     VECTOR_LOOP_VAR
393     VECTOR_LOOP_BEGIN
394     y%DELEM = y%DELEM - x%DELEM
395     VECTOR_LOOP_END
396     end subroutine
397    
398 utke 1.3 !
399 utke 1.1 ! set derivative components to 0.0
400     !
401 utke 1.6 subroutine zero_deriv_a0(x)
402 utke 1.1 type(active), intent(inout) :: x
403 utke 1.6 VECTOR_LOOP_VAR
404     VECTOR_LOOP_BEGIN
405     x%DELEM=0.0d0
406     VECTOR_LOOP_END
407     end subroutine
408 utke 1.1
409 utke 1.6 subroutine zero_deriv_a1(x)
410     type(active), dimension(:), intent(inout) :: x
411     VECTOR_LOOP_VAR
412     VECTOR_LOOP_BEGIN
413     x%DELEM=0.0d0
414     VECTOR_LOOP_END
415     end subroutine
416    
417     subroutine zero_deriv_a2(x)
418     type(active), dimension(:,:), intent(inout) :: x
419     VECTOR_LOOP_VAR
420     VECTOR_LOOP_BEGIN
421     x%DELEM=0.0d0
422     VECTOR_LOOP_END
423     end subroutine
424    
425     subroutine zero_deriv_a3(x)
426     type(active), dimension(:,:,:), intent(inout) :: x
427     VECTOR_LOOP_VAR
428     VECTOR_LOOP_BEGIN
429     x%DELEM=0.0d0
430     VECTOR_LOOP_END
431     end subroutine
432    
433     subroutine zero_deriv_a4(x)
434     type(active), dimension(:,:,:,:), intent(inout) :: x
435     VECTOR_LOOP_VAR
436     VECTOR_LOOP_BEGIN
437     x%DELEM=0.0d0
438     VECTOR_LOOP_END
439     end subroutine
440    
441     #endif
442 utke 1.1 !
443 utke 1.6 ! conversions
444 utke 1.1 !
445 utke 1.6 subroutine convert_d0_a0(convertTo, convertFrom)
446     real(w2f__8), intent(out) :: convertTo
447 utke 1.1 type(active), intent(in) :: convertFrom
448     convertTo=convertFrom%v
449     end subroutine
450 utke 1.6 subroutine convert_d1_a1(convertTo, convertFrom)
451     real(w2f__8), dimension(:), intent(out) :: convertTo
452     type(active), dimension(:), intent(in) :: convertFrom
453 utke 1.1 convertTo=convertFrom%v
454     end subroutine
455 utke 1.6 subroutine convert_d2_a2(convertTo, convertFrom)
456     real(w2f__8), dimension(:,:), intent(out) :: convertTo
457     type(active), dimension(:,:), intent(in) :: convertFrom
458 utke 1.1 convertTo=convertFrom%v
459     end subroutine
460 utke 1.6 subroutine convert_d3_a3(convertTo, convertFrom)
461     real(w2f__8), dimension(:,:,:), intent(out) :: convertTo
462     type(active), dimension(:,:,:), intent(in) :: convertFrom
463 utke 1.1 convertTo=convertFrom%v
464     end subroutine
465 utke 1.6 subroutine convert_d4_a4(convertTo, convertFrom)
466     real(w2f__8), dimension(:,:,:,:), intent(out) :: convertTo
467     type(active), dimension(:,:,:,:), intent(in) :: convertFrom
468     convertTo=convertFrom%v
469 utke 1.1 end subroutine
470 utke 1.6 subroutine convert_d5_a5(convertTo, convertFrom)
471     real(w2f__8), dimension(:,:,:,:,:), intent(out) :: convertTo
472     type(active), dimension(:,:,:,:,:), intent(in) :: convertFrom
473     convertTo=convertFrom%v
474 utke 1.1 end subroutine
475 utke 1.6 subroutine convert_d6_a6(convertTo, convertFrom)
476     real(w2f__8), dimension(:,:,:,:,:,:), intent(out) :: convertTo
477     type(active), dimension(:,:,:,:,:,:), intent(in) :: convertFrom
478 utke 1.1 convertTo=convertFrom%v
479     end subroutine
480 utke 1.6 subroutine convert_d7_a7(convertTo, convertFrom)
481     real(w2f__8), dimension(:,:,:,:,:,:,:), intent(out) :: convertTo
482     type(active), dimension(:,:,:,:,:,:,:), intent(in) :: convertFrom
483 utke 1.1 convertTo=convertFrom%v
484     end subroutine
485    
486 utke 1.6 subroutine convert_a0_d0(convertTo, convertFrom)
487     type(active), intent(inout) :: convertTo
488     real(w2f__8), intent(in) :: convertFrom
489     convertTo%v=convertFrom
490     end subroutine
491     subroutine convert_a1_d1(convertTo, convertFrom)
492     type(active), dimension(:), intent(inout) :: convertTo
493     real(w2f__8), dimension(:), intent(in) :: convertFrom
494     convertTo%v=convertFrom
495     end subroutine
496     subroutine convert_a2_d2(convertTo, convertFrom)
497 utke 1.2 type(active), dimension(:,:), intent(inout) :: convertTo
498 utke 1.6 real(w2f__8), dimension(:,:), intent(in) :: convertFrom
499 utke 1.2 convertTo%v=convertFrom
500     end subroutine
501 utke 1.6 subroutine convert_a3_d3(convertTo, convertFrom)
502     type(active), dimension(:,:,:), intent(inout) :: convertTo
503     real(w2f__8), dimension(:,:,:), intent(in) :: convertFrom
504 utke 1.1 convertTo%v=convertFrom
505     end subroutine
506 utke 1.6 subroutine convert_a4_d4(convertTo, convertFrom)
507     type(active), dimension(:,:,:,:), intent(inout) :: convertTo
508     real(w2f__8), dimension(:,:,:,:), intent(in) :: convertFrom
509     convertTo%v=convertFrom
510 utke 1.1 end subroutine
511 utke 1.6 subroutine convert_a5_d5(convertTo, convertFrom)
512     type(active), dimension(:,:,:,:,:), intent(inout) :: convertTo
513     real(w2f__8), dimension(:,:,:,:,:), intent(in) :: convertFrom
514     convertTo%v=convertFrom
515 utke 1.1 end subroutine
516 utke 1.6 subroutine convert_a6_d6(convertTo, convertFrom)
517     type(active), dimension(:,:,:,:,:,:), intent(inout) :: convertTo
518     real(w2f__8), dimension(:,:,:,:,:,:), intent(in) :: convertFrom
519 utke 1.1 convertTo%v=convertFrom
520     end subroutine
521 utke 1.6 subroutine convert_a7_d7(convertTo, convertFrom)
522     type(active), dimension(:,:,:,:,:,:,:), intent(inout) :: convertTo
523     real(w2f__8), dimension(:,:,:,:,:,:,:), intent(in) :: convertFrom
524 utke 1.1 convertTo%v=convertFrom
525     end subroutine
526 utke 1.6 #ifndef DEFAULT_R8
527     subroutine convert_r0_a0(convertTo, convertFrom)
528     real(w2f__4), intent(out) :: convertTo
529     type(active), intent(in) :: convertFrom
530 utke 1.1 convertTo=convertFrom%v
531     end subroutine
532 utke 1.6 subroutine convert_r1_a1(convertTo, convertFrom)
533     real(w2f__4), dimension(:), intent(out) :: convertTo
534     type(active), dimension(:), intent(in) :: convertFrom
535 utke 1.1 convertTo=convertFrom%v
536     end subroutine
537 utke 1.6 subroutine convert_r2_a2(convertTo, convertFrom)
538     real(w2f__4), dimension(:,:), intent(out) :: convertTo
539     type(active), dimension(:,:), intent(in) :: convertFrom
540     convertTo=convertFrom%v
541 utke 1.1 end subroutine
542 utke 1.6 subroutine convert_r3_a3(convertTo, convertFrom)
543     real(w2f__4), dimension(:,:,:), intent(out) :: convertTo
544     type(active), dimension(:,:,:), intent(in) :: convertFrom
545     convertTo=convertFrom%v
546 utke 1.1 end subroutine
547 utke 1.6 subroutine convert_r4_a4(convertTo, convertFrom)
548     real(w2f__4), dimension(:,:,:,:), intent(out) :: convertTo
549     type(active), dimension(:,:,:,:), intent(in) :: convertFrom
550 utke 1.1 convertTo=convertFrom%v
551     end subroutine
552 utke 1.6 subroutine convert_r5_a5(convertTo, convertFrom)
553     real(w2f__4), dimension(:,:,:,:,:), intent(out) :: convertTo
554 utke 1.1 type(active), dimension(:,:,:,:,:), intent(in) :: convertFrom
555     convertTo=convertFrom%v
556     end subroutine
557 utke 1.6 subroutine convert_r6_a6(convertTo, convertFrom)
558     real(w2f__4), dimension(:,:,:,:,:,:), intent(out) :: convertTo
559 utke 1.3 type(active), dimension(:,:,:,:,:,:), intent(in) :: convertFrom
560     convertTo=convertFrom%v
561     end subroutine
562 utke 1.6 subroutine convert_r7_a7(convertTo, convertFrom)
563     real(w2f__4), dimension(:,:,:,:,:,:,:), intent(out) :: convertTo
564     type(active), dimension(:,:,:,:,:,:,:), intent(in) :: convertFrom
565 utke 1.3 convertTo=convertFrom%v
566     end subroutine
567    
568 utke 1.6 subroutine convert_a0_r0(convertTo, convertFrom)
569     type(active), intent(inout) :: convertTo
570     real(w2f__4), intent(in) :: convertFrom
571     convertTo%v=convertFrom
572     end subroutine
573     subroutine convert_a1_r1(convertTo, convertFrom)
574     type(active), dimension(:), intent(inout) :: convertTo
575     real(w2f__4), dimension(:), intent(in) :: convertFrom
576     convertTo%v=convertFrom
577     end subroutine
578     subroutine convert_a2_r2(convertTo, convertFrom)
579     type(active), dimension(:,:), intent(inout) :: convertTo
580     real(w2f__4), dimension(:,:), intent(in) :: convertFrom
581 utke 1.3 convertTo%v=convertFrom
582     end subroutine
583 utke 1.6 subroutine convert_a3_r3(convertTo, convertFrom)
584     type(active), dimension(:,:,:), intent(inout) :: convertTo
585     real(w2f__4), dimension(:,:,:), intent(in) :: convertFrom
586 utke 1.3 convertTo%v=convertFrom
587     end subroutine
588 utke 1.6 subroutine convert_a4_r4(convertTo, convertFrom)
589     type(active), dimension(:,:,:,:), intent(inout) :: convertTo
590     real(w2f__4), dimension(:,:,:,:), intent(in) :: convertFrom
591     convertTo%v=convertFrom
592 utke 1.3 end subroutine
593 utke 1.6 subroutine convert_a5_r5(convertTo, convertFrom)
594     type(active), dimension(:,:,:,:,:), intent(inout) :: convertTo
595     real(w2f__4), dimension(:,:,:,:,:), intent(in) :: convertFrom
596     convertTo%v=convertFrom
597 utke 1.3 end subroutine
598 utke 1.6 subroutine convert_a6_r6(convertTo, convertFrom)
599     type(active), dimension(:,:,:,:,:,:), intent(inout) :: convertTo
600     real(w2f__4), dimension(:,:,:,:,:,:), intent(in) :: convertFrom
601 utke 1.3 convertTo%v=convertFrom
602     end subroutine
603 utke 1.6 subroutine convert_a7_r7(convertTo, convertFrom)
604 utke 1.3 type(active), dimension(:,:,:,:,:,:,:), intent(inout) :: convertTo
605 utke 1.6 real(w2f__4), dimension(:,:,:,:,:,:,:), intent(in) :: convertFrom
606 utke 1.3 convertTo%v=convertFrom
607     end subroutine
608 utke 1.6 #endif
609     !
610     ! allocations
611     !
612     subroutine allocateMatching_a1_d1(toBeAllocated,allocateMatching)
613 utke 1.5 implicit none
614     type(active), dimension(:), allocatable :: toBeAllocated
615     real(w2f__8), dimension(:) :: allocateMatching
616     if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching)))
617     end subroutine
618 utke 1.6 subroutine allocateMatching_a1_a1(toBeAllocated,allocateMatching)
619 utke 1.3 implicit none
620     type(active), dimension(:), allocatable :: toBeAllocated
621     type(active), dimension(:) :: allocateMatching
622 utke 1.4 if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching)))
623     end subroutine
624 utke 1.6 subroutine allocateMatching_d1_a1(toBeAllocated,allocateMatching)
625 utke 1.4 implicit none
626     real(w2f__8), dimension(:), allocatable :: toBeAllocated
627     type(active), dimension(:) :: allocateMatching
628     if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching)))
629     end subroutine
630 utke 1.6 subroutine allocateMatching_a2_a2(toBeAllocated,allocateMatching)
631 utke 1.4 implicit none
632     type(active), dimension(:,:), allocatable :: toBeAllocated
633     type(active), dimension(:,:) :: allocateMatching
634     if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching,1), &
635     size(allocateMatching,2)))
636     end subroutine
637 utke 1.6 subroutine allocateMatching_d2_a2(toBeAllocated,allocateMatching)
638 utke 1.4 implicit none
639     real(w2f__8), dimension(:,:), allocatable :: toBeAllocated
640     type(active), dimension(:,:) :: allocateMatching
641     if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching,1), &
642     size(allocateMatching,2)))
643     end subroutine
644 utke 1.6 subroutine allocateMatching_a4_a4(toBeAllocated,allocateMatching)
645 utke 1.4 implicit none
646     type(active), dimension(:,:,:,:), allocatable :: toBeAllocated
647     type(active), dimension(:,:,:,:) :: allocateMatching
648     if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching,1), &
649     size(allocateMatching,2),&
650     size(allocateMatching,3),&
651     size(allocateMatching,4)))
652 utke 1.3 end subroutine
653 utke 1.6 subroutine allocateMatching_d4_a4(toBeAllocated,allocateMatching)
654 utke 1.4 implicit none
655     real(w2f__8), dimension(:,:,:,:), allocatable :: toBeAllocated
656     type(active), dimension(:,:,:,:) :: allocateMatching
657     if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching,1), &
658     size(allocateMatching,2),&
659     size(allocateMatching,3),&
660     size(allocateMatching,4)))
661     end subroutine
662 utke 1.6 subroutine allocateMatching_a5_a5(toBeAllocated,allocateMatching)
663 utke 1.4 implicit none
664     type(active), dimension(:,:,:,:,:), allocatable :: toBeAllocated
665     type(active), dimension(:,:,:,:,:) :: allocateMatching
666     if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching,1), &
667     size(allocateMatching,2),&
668     size(allocateMatching,3),&
669     size(allocateMatching,4),&
670     size(allocateMatching,5)))
671     end subroutine
672 utke 1.6 subroutine allocateMatching_d5_a5(toBeAllocated,allocateMatching)
673 utke 1.4 implicit none
674     real(w2f__8), dimension(:,:,:,:,:), allocatable :: toBeAllocated
675     type(active), dimension(:,:,:,:,:) :: allocateMatching
676     if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching,1), &
677     size(allocateMatching,2),&
678     size(allocateMatching,3),&
679     size(allocateMatching,4),&
680     size(allocateMatching,5)))
681     end subroutine
682 utke 1.6 #ifndef DEFAULT_R8
683     subroutine allocateMatching_r1_a1(toBeAllocated,allocateMatching)
684     implicit none
685     real(w2f__4), dimension(:), allocatable :: toBeAllocated
686     type(active), dimension(:) :: allocateMatching
687     if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching)))
688     end subroutine
689     subroutine allocateMatching_r2_a2(toBeAllocated,allocateMatching)
690     implicit none
691     real(w2f__4), dimension(:,:), allocatable :: toBeAllocated
692     type(active), dimension(:,:) :: allocateMatching
693     if (.not. allocated(toBeAllocated)) allocate(toBeAllocated(size(allocateMatching,1), &
694     size(allocateMatching,2)))
695     end subroutine
696     #endif
697     !
698     ! shape tests
699     !
700     subroutine shapeTest_a1_d1(allocatedVar,origVar)
701 utke 1.5 implicit none
702     type(active), dimension(:), allocatable :: allocatedVar
703     real(w2f__8), dimension(:) :: origVar
704 utke 1.6 if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
705 utke 1.5 end subroutine
706 utke 1.6 subroutine shapeTest_a1_a1(allocatedVar,origVar)
707 utke 1.5 implicit none
708     type(active), dimension(:), allocatable :: allocatedVar
709     type(active), dimension(:) :: origVar
710 utke 1.6 if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
711 utke 1.5 end subroutine
712 utke 1.6 subroutine shapeTest_d1_a1(allocatedVar,origVar)
713 utke 1.5 implicit none
714     real(w2f__8), dimension(:), allocatable :: allocatedVar
715     type(active), dimension(:) :: origVar
716 utke 1.6 if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
717 utke 1.5 end subroutine
718 utke 1.6 subroutine shapeTest_a2_a2(allocatedVar,origVar)
719 utke 1.5 implicit none
720     type(active), dimension(:,:), allocatable :: allocatedVar
721     type(active), dimension(:,:) :: origVar
722 utke 1.6 if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
723 utke 1.5 end subroutine
724 utke 1.6 subroutine shapeTest_d2_a2(allocatedVar,origVar)
725 utke 1.5 implicit none
726     real(w2f__8), dimension(:,:), allocatable :: allocatedVar
727     type(active), dimension(:,:) :: origVar
728 utke 1.6 if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
729 utke 1.5 end subroutine
730 utke 1.6 subroutine shapeTest_a4_a4(allocatedVar,origVar)
731 utke 1.5 implicit none
732     type(active), dimension(:,:,:,:), allocatable :: allocatedVar
733     type(active), dimension(:,:,:,:) :: origVar
734 utke 1.6 if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
735 utke 1.5 end subroutine
736 utke 1.6 subroutine shapeTest_d4_a4(allocatedVar,origVar)
737 utke 1.5 implicit none
738     real(w2f__8), dimension(:,:,:,:), allocatable :: allocatedVar
739     type(active), dimension(:,:,:,:) :: origVar
740 utke 1.6 if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
741 utke 1.5 end subroutine
742 utke 1.6 subroutine shapeTest_a5_a5(allocatedVar,origVar)
743 utke 1.5 implicit none
744     type(active), dimension(:,:,:,:,:), allocatable :: allocatedVar
745     type(active), dimension(:,:,:,:,:) :: origVar
746 utke 1.6 if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
747 utke 1.5 end subroutine
748 utke 1.6 subroutine shapeTest_d5_a5(allocatedVar,origVar)
749 utke 1.5 implicit none
750     real(w2f__8), dimension(:,:,:,:,:), allocatable :: allocatedVar
751     type(active), dimension(:,:,:,:,:) :: origVar
752 utke 1.6 if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
753     end subroutine
754     #ifndef DEFAULT_R8
755     subroutine shapeTest_r1_a1(allocatedVar,origVar)
756     implicit none
757     real(w2f__4), dimension(:), allocatable :: allocatedVar
758     type(active), dimension(:) :: origVar
759     if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
760     end subroutine
761     subroutine shapeTest_r2_a2(allocatedVar,origVar)
762     implicit none
763     real(w2f__4), dimension(:,:), allocatable :: allocatedVar
764     type(active), dimension(:,:) :: origVar
765     if (.not. all(shape(allocatedVar)==shape(origVar))) call runTimeErrorStop(shapeChange)
766     end subroutine
767     #endif
768     subroutine runTimeErrorStopI(mesgId)
769     implicit none
770     integer mesgId
771     select case (mesgId)
772     case (shapeChange)
773     stop "ERROR: OAD run time library: detected shape change"
774     end select
775 utke 1.5 end subroutine
776 utke 1.1
777 utke 1.6 end module

  ViewVC Help
Powered by ViewVC 1.1.22