V3FIT
free_mem_ns.f
1  SUBROUTINE free_mem_ns_par(lreset)
2  USE vmec_main
3  USE realspace
4  USE vforces
5  USE xstuff
6  USE csplinx
7  USE fbal
8 
9  IMPLICIT NONE
10 C-----------------------------------------------
11 C D u m m y A r g u m e n t s
12 C-----------------------------------------------
13  LOGICAL, INTENT(in) :: lreset
14 
15 C-----------------------------------------------
16  IF (ALLOCATED(pshalf)) DEALLOCATE(pshalf)
17  IF (ALLOCATED(psqrts)) DEALLOCATE(psqrts)
18  IF (ALLOCATED(pwint)) DEALLOCATE(pwint)
19  IF (ALLOCATED(pfaclam)) DEALLOCATE(pfaclam)
20  IF (ALLOCATED(pchip)) DEALLOCATE(pchip)
21  IF (ALLOCATED(pphip)) DEALLOCATE(pphip)
22  IF (ALLOCATED(pfaclam)) DEALLOCATE(pfaclam)
23 
24  IF (ALLOCATED(pxc) .and. lreset) DEALLOCATE(pxc)
25  IF (ALLOCATED(pscalxc) .and. lreset) DEALLOCATE (pscalxc)
26 
27  IF (ALLOCATED(pxstore)) DEALLOCATE (pxstore)
28  IF (ALLOCATED(pxcdot)) DEALLOCATE (pxcdot)
29  IF (ALLOCATED(pxsave)) DEALLOCATE (pxsave)
30  IF (ALLOCATED(pgc)) DEALLOCATE (pgc)
31  IF (ALLOCATED(pcol_scale)) DEALLOCATE(pcol_scale)
32 
33  END SUBROUTINE free_mem_ns_par
34 
35  SUBROUTINE free_mem_ns(lreset)
36  USE vmec_main
37  USE realspace
38  USE vforces
39  USE xstuff
40  USE csplinx
41  USE fbal
42 
43  IMPLICIT NONE
44 C-----------------------------------------------
45 C D u m m y A r g u m e n t s
46 C-----------------------------------------------
47  LOGICAL, INTENT(in) :: lreset
48 C-----------------------------------------------
49 C L o c a l V a r i a b l e s
50 C-----------------------------------------------
51  INTEGER :: istat1 = 0, istat2 = 0, istat3 = 0, istat4 = 0,
52  1 istat5 = 0, istat6 = 0, istat7 = 0, istat8 = 0,
53  2 istat9 = 0, istat10 = 0
54 C-----------------------------------------------
55 
56  IF (ALLOCATED(phip)) THEN
57  DEALLOCATE(phip, chip, shalf, sqrts, wint, stat=istat1)
58  END IF
59 
60  IF (ALLOCATED(ireflect)) THEN
61  DEALLOCATE(ireflect, stat=istat2)
62  END IF
63 
64  IF (ALLOCATED(ard)) THEN
65  DEALLOCATE(ard, arm, brd, brm, crd, azd, azm, bzd, bzm, sm,
66  & sp, bmin, bmax, stat=istat5)
67  END IF
68 
69  IF (ALLOCATED(iotaf)) THEN
70  DEALLOCATE(iotaf, mass, phi, presf, jcuru, jcurv, jdotb, buco,
71  & bvco, bucof, bvcof, chi,
72 #ifdef _ANIMEC
73  & phot, pmap, pppr, papr, tpotb, pd,
74 #endif
75  & bdotgradv, equif, specw, tcon, psi, yellip, yinden,
76  & ytrian, yshift, ygeo, overr, faclam, iotas, phips,
77  & chips, pres, vp, beta_vol, jperp2, jpar2, bdotb,
78  & clam, blam, dlam, phipf, chipf, rru_fac, rzu_fac,
79  & frcc_fac, fzsc_fac, icurv, vpphi, presgrad, r01,
80  & z01, bdamp, stat=istat6)
81  END IF
82 
83  IF (ALLOCATED(rmidx)) THEN
84  DEALLOCATE(rmidx, hmidx, wmidx, qmidx, tenmidx, ymidx, y2midx,
85  & stat=istat7)
86  END IF
87 
88  IF (ALLOCATED(gc)) THEN
89  DEALLOCATE(gc, xsave, xstore, xcdot, col_scale, stat=istat8)
90  END IF
91  IF (ALLOCATED(xc) .AND. lreset) THEN
92  DEALLOCATE(xc, scalxc)
93  END IF
94 
95  IF ((istat1 + istat2 + istat3 + istat4 + istat5 + istat6 +
96  & istat7 + istat8) .ne. 0) THEN
97  print *,' deallocation problem in free_mem_ns'
98  print *,' istat1 = ',istat1,' istat2 = ',istat2
99  print *,' istat3 = ',istat3,' istat4 = ',istat4
100  print *,' istat5 = ',istat5,' istat6 = ',istat6
101  print *,' istat7 = ',istat7,' istat8 = ',istat8
102  END IF
103 
104  END SUBROUTINE free_mem_ns