V3FIT
init_saddle_currents.f
1  SUBROUTINE init_saddle_currents (nvariables, xvariables)
2 !-----------------------------------------------
3 ! M o d u l e s
4 !-----------------------------------------------
5  USE saddle_coils
6  IMPLICIT NONE
7 !-----------------------------------------------
8 ! L o c a l V a r i a b l e s
9 !-----------------------------------------------
10  INTEGER :: i, nsv, nc
11  INTEGER :: nvariables
12  REAL(rprec) :: xvariables(*)
13 !-----------------------------------------------
14 
15  nc = nsad_coils_per_period
16  nsad_currents = 0
17  nvariables = 0
18 
19  IF (nc .le. 0) RETURN
20 
21  num_cursad = maxval(nsad_group(1:nsmid))
22 
23 ! initialize the variables to values of unique coil parameters
24 ! and count the number of variables
25 
26  nsv = 0
27 
28  IF (lsadcur) THEN
29  DO i=1, num_cursad
30  IF (ls_cur(i)) THEN
31  nsv = nsv + 1
32  xvariables(nsv) = cursad(i)
33  END IF
34  END DO
35  END IF
36 
37  nsad_currents = nsv
38  nvariables = nsv
39 
40  END SUBROUTINE init_saddle_currents