V3FIT
getfsq.f
1  SUBROUTINE getfsq_par(gcr, gcz, gnormr, gnormz, gnorm, medge)
2  USE vmec_main, ONLY: rprec, ns, ns1, mnsize
3  USE vmec_params, ONLY: ntmax
4  USE parallel_include_module
5  IMPLICIT NONE
6 !-----------------------------------------------
7 ! D u m m y A r g u m e n t s
8 !-----------------------------------------------
9  INTEGER, INTENT(in) :: medge
10  REAL(dp), INTENT(out) :: gnormr, gnormz
11  REAL(dp), INTENT(in) :: gnorm
12  REAL(dp), DIMENSION(mnsize,ns,ntmax), INTENT(IN) :: gcr, gcz
13 !-----------------------------------------------
14 ! L o c a l V a r i a b l e s
15 !-----------------------------------------------
16  INTEGER :: jsmax, nsmin, nsmax, l
17  REAL(dp) :: tmpgcx(ns,2), totalgcx(2)
18 !-----------------------------------------------
19  IF (.NOT. lactive) RETURN
20 
21  jsmax = ns1 + medge
22  nsmin=tlglob; nsmax=min(trglob,jsmax)
23  IF (trglob .GT. jsmax) tmpgcx(jsmax+1:trglob,1:2) = 0
24 
25  DO l = nsmin, nsmax
26  tmpgcx(l,1) = sum(gcr(:,l,:)**2)
27  tmpgcx(l,2) = sum(gcz(:,l,:)**2)
28  END DO
29  DO l = 1, 2
30  CALL gather1xarray(tmpgcx(:,l))
31  totalgcx(l) = sum(tmpgcx(:,l))
32  END DO
33 
34  gnormr = gnorm * totalgcx(1)
35  gnormz = gnorm * totalgcx(2)
36 
37  END SUBROUTINE getfsq_par
38 
39  SUBROUTINE getfsq(gcr, gcz, gnormr, gnormz, gnorm, medge)
40  USE vmec_main, ONLY: rprec, ns, ns1, mnsize
41  USE vmec_params, ONLY: ntmax
42  USE parallel_include_module
43  IMPLICIT NONE
44 !-----------------------------------------------
45 ! D u m m y A r g u m e n t s
46 !-----------------------------------------------
47  INTEGER, INTENT(in) :: medge
48  REAL(dp), INTENT(out) :: gnormr, gnormz
49  REAL(dp), INTENT(in) :: gnorm
50  REAL(dp), DIMENSION(ns,mnsize*ntmax), INTENT(in) :: gcr, gcz
51 !-----------------------------------------------
52 ! L o c a l V a r i a b l e s
53 !-----------------------------------------------
54  INTEGER :: jsmax
55 !-----------------------------------------------
56  jsmax = ns1 + medge
57  gnormr = gnorm * sum(gcr(:jsmax,:)**2)
58  gnormz = gnorm * sum(gcz(:jsmax,:)**2)
59 
60  END SUBROUTINE getfsq