V3FIT
All Classes Namespaces Files Functions Variables Enumerations Macros Pages
greenf.f
1  SUBROUTINE greenf (delgr, delgrp, ip)
2  USE vacmod
3  USE vparams, ONLY: one
4  USE parallel_include_module
5  USE timer_sub
6  IMPLICIT NONE
7 C-----------------------------------------------
8 C D u m m y A r g u m e n t s
9 C-----------------------------------------------
10  INTEGER, INTENT(in) :: ip
11  REAL(dp), DIMENSION(nuv), INTENT(OUT) :: delgr, delgrp
12 C-----------------------------------------------
13 C L o c a l V a r i a b l e s
14 C-----------------------------------------------
15  INTEGER, DIMENSION(2) :: ilow, ihigh
16  INTEGER :: ivoff, iskip, iuoff, i, kp, nloop
17  REAL(dp), DIMENSION(:), ALLOCATABLE ::
18  1 ftemp, gsave, htemp, ga1, ga2, dsave
19  REAL(dp):: xip, yip, xper, yper,
20  1 sxsave, sysave, tgreenon, tgreenoff
21 C-----------------------------------------------
22 !
23 ! ON ENTRANCE, IP IS THE INDEX OF THE PRIMED MESH POINT (lies in 1st field period)
24 !
25 ! ON EXIT, DELGR IS THE DIFFERENCE OF "GREEN'S FUNCTION"
26 ! AND ANALYTIC APPROXIMATION, SUMMED OVER ALL FIELD PERIODS
27 ! DELGRP IS DIFFERENCE OF DERIVATIVE OF "GREEN'S FUNCTION"
28 ! AND ANALYTIC APPROXIMATION.
29 !
30 ! BOTH THESE QUANTITIES ARE COMPUTED FOR ALL UNPRIMED U,V POINTS IN ONE FIELD PERIOD,
31 ! FOR THIS FIXED PRIMED POINT (IP).
32 !
33  CALL second0(tgreenon)
34 
35  ALLOCATE (ftemp(nuv), gsave(nuv), htemp(nuv), ga1(nuv), ga2(nuv),
36  1 dsave(nuv), stat=i)
37  IF (i .NE. 0) stop 'allocation error in greenf'
38 
39 !
40 ! COMPUTE OFFSETS FOR U,V ANGLE DIFFERENCES AND CONSTANTS
41 !
42  ilow(1) = 1
43  ilow(2) = ip + 1
44  ihigh(1) = ip - 1
45  ihigh(2) = nuv
46  ivoff = nuv + 1 - ip
47  iskip = (ip - 1)/nv
48  iuoff = nuv - nv*iskip
49  xip = rcosuv(ip) !x == r*COS(ip), in 1st field period
50  yip = rsinuv(ip) !y == r*SIN(ip), in 1st field period
51  delgr = 0
52  delgrp = 0
53 
54 !
55 ! COMPUTE FIELD-PERIOD INVARIANT VECTORS
56 !
57 ! NOTE: |x - x'|**2 = gsave - 2*[x*x' + y*y']
58 !
59  DO i = 1, nuv
60  gsave(i) = rzb2(ip) + rzb2(i) - 2*z1b(ip)*z1b(i)
61  dsave(i) = drv(ip) + z1b(i)*snz(ip)
62  END DO
63 
64 !
65 ! SUM OVER FIELD-PERIODS (NVPER=NFPER) OR INTEGRATE OVER NV (NVPER=64) IF NV == 1
66 !
67 ! NOTE THE SURFACE NORMAL SNORM == Xu cross Xv = NP*[SNR, SNV, SNZ]
68 ! IS PERIODIC ON EACH FIELD PERIOD
69 !
70  DO kp = 1, nvper
71  xper = xip*cosper(kp) - yip*sinper(kp) !x(ip) in field period kp
72  yper = yip*cosper(kp) + xip*sinper(kp) !y(ip) in field period kp
73  sxsave = (snr(ip)*xper - snv(ip)*yper)/r1b(ip)
74  sysave = (snr(ip)*yper + snv(ip)*xper)/r1b(ip)
75 
76  IF (kp.EQ.1 .OR. nv.EQ.1) THEN
77 
78 ! INITIALIZE ANALYTIC APPROXIMATIONS GA1, GA2
79  DO i = 1, nuv
80  ga1(i) = tanu(i+iuoff)*(guu_b(ip)*tanu(i+iuoff)
81  1 + guv_b(ip)*tanv(i+ivoff))
82  2 + gvv_b(ip)*tanv(i+ivoff)*tanv(i+ivoff)
83  ga2(i) = tanu(i+iuoff)*(auu(ip)*tanu(i+iuoff)
84  1 + auv(ip)*tanv(i+ivoff))
85  2 + avv(ip)*tanv(i+ivoff)*tanv(i+ivoff)
86  END DO
87 
88  DO nloop = 1, 2
89  IF (kp.GT.1 .AND. nloop.EQ.2) cycle
90  DO i = ilow(nloop), ihigh(nloop)
91  ga2(i) = ga2(i)/ga1(i)
92  ga1(i) = one/sqrt(ga1(i))
93  ftemp(i) = one/(gsave(i)
94  1 - 2*(xper*rcosuv(i) + yper*rsinuv(i)))
95  htemp(i) = sqrt(ftemp(i))
96  delgrp(i) = delgrp(i) - ga2(i)*ga1(i)
97  1 + ftemp(i)*htemp(i)*
98  2 (rcosuv(i)*sxsave + rsinuv(i)*sysave + dsave(i))
99  delgr(i) = delgr(i) + htemp(i) - ga1(i)
100  END DO
101  END DO
102 
103  IF (kp.EQ.nvper .AND. nv.EQ.1) THEN
104  delgrp = delgrp/nvper
105  delgr = delgr /nvper
106  END IF
107 
108  ivoff = ivoff + 2*nu
109  ihigh(1) = nuv
110 
111  ELSE
112  DO i = 1, nuv
113  ftemp(i) = one/(gsave(i)
114  1 - 2*(xper*rcosuv(i) + yper*rsinuv(i)))
115  htemp(i) = sqrt(ftemp(i))
116  delgrp(i) = delgrp(i) + ftemp(i)*htemp(i)*
117  1 (rcosuv(i)*sxsave + rsinuv(i)*sysave + dsave(i))
118  delgr(i) = delgr(i) + htemp(i)
119  END DO
120  ENDIF
121  END DO
122 
123  DEALLOCATE (ftemp, gsave, htemp, ga1, ga2, dsave, stat=i)
124 
125  CALL second0(tgreenoff)
126  timer_vac(tgreenf) = timer_vac(tgreenf) + (tgreenoff-tgreenon)
127  greenf_time = timer_vac(tgreenf)
128 
129  END SUBROUTINE greenf
130