-
Notifications
You must be signed in to change notification settings - Fork 14
/
adj_control.f
185 lines (155 loc) · 6.72 KB
/
adj_control.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
subroutine adjint(ientry)
use kind_spec
implicit none
c-----input
integer ientry
include 'param.i'
include 'adj.i'
c-----locals
integer thpp0,icurdr,iswchi
integer :: nw, nthp, ns, js, jp, jps ,nthpp0
cSm070625
integer iadj
real(kind=dp) :: zef1
integer nmax,imax,lmax
integer myrank !In serial run: myrank=0; In MPI run: myrank=rank
common/mpimyrank/myrank !In serial run: myrank=0; In MPI run: myrank=rank
select case (ientry)
case default
c----------------
c assume nthp0,npsi0,psimx,psimn already known
c
icurdr=1
c write(*,*)'adj_control.f in adjint ientry=',ientry
c write(*,*)'adj_control.f before op_file 0 icurdr=',icurdr
c if(myrank.eq.0) then ! MPI ! YuP[2018-09-10] added
call op_file(0,icurdr)
c write(*,*)'adj_control.f adjint after op_file 0'
c write(*,*)'adj_control.f adjint before op_file 3 icurdr=',icurdr
call op_file(3,icurdr)
c write(*,*)'adj_control.f adjint after op_file 3'
c write(*,*)'adj_control.f adjint before op_file 4 icurdr=',icurdr
call op_file(4,icurdr)
c write(*,*)'adj_control.f adjint after op_file 4'
c write(*,*)'adj_control.f adjint before op_file 5 icurdr=',icurdr
call op_file(5,icurdr)
c write(*,*)'adj_control.f adjint after op_file 5'
c write(*,*)'adj_control.f adjint before op_file 6 icurdr=',icurdr
call op_file(6,icurdr)
c write(*,*)'adj_control.f adjint after op_file 6'
!YuP[2018-09-12](not accessed in op_file) call op_file(7,icurdr)
!YuP[2018-09-12](not accessed in op_file) call op_file(8,icurdr)
c write(*,*)'adj_control.f in sub adjint'
c write(*,*)'iout3,iout4,iout5,iout6,iout7,iout8',
c &iout3,iout4,iout5,iout6,iout7,iout8
c write(*,*)'adj_control.f adjint after op_file 7, 8'
c endif !On myrank=0 ! myrank=0
nthpp0=nthp0
c--------------------------------------------------------------
c calculate
c &thetas(nthpp0+1), !poloidal angle mesh for b line integration
c &dla(0:nthpp0-1), !length along b line
c &ba(0:nthpp0-1), !b/b0 along b line
c &thetae(0:nthpp0-1) !poloidal angle mesh for b line integration
c---------------------------------------------------------------------------
cSm070625
c write(*,*)'adj_control.f adjint before bavorbt nthp0,npsi0',
c & nthp0,npsi0
call bavorbt( nthp0,npsi0)
c write(*,*)'adj_control.f adjint after bavorbt'
c write(*,*)'adj_control.f adjint after bavorbt1'
c write(*,*)'in sub adjint thetas',thetas
c write(*,*)'in sub adjint thetae',thetae
write(*,*)'in adj_control in adjint before end case 1'
write(*,*)'adj_control.f in sub adjint'
write(*,*)'iout3,iout4,iout5,iout6,iout7,iout8',
&iout3,iout4,iout5,iout6,iout7,iout8
!pause
return
case (2)
c----------------
c get Spitzer-function table
c chi(theta,ua)=chi(0:imax1 - 1,0:nmax - 1) and output to adjout
c At each radial point (np=1,npsi0) write chi and other variables
c to the file with file number: iout5 and file name: 'adjout
iswchi=0
nmax=nmax_chi
imax=imax_chi
lmax=lmax_chi
write(*,*)'adj_control.f in adjint subadj nmax,imax,lmax',
& nmax,imax,lmax
write(*,*)'umax,nthp0,dt',umax,nthp0,dt
write(*,*)'tmax,alpha,ze,t,rho_',tmax,alpha,ze,t,rho_
write(*,*)'iswchi,aerrmx,rerrmx',iswchi,aerrmx,rerrmx
write(*,*)' iout3, iout5, iout4, iout7, iout8',
& iout3, iout5, iout4, iout7, iout8
write(*,*)'adj_control.f in sub adjint before subadj'
!WRITE(*,*)'adjint104 before subadj', myrank
call subadj(nmax,umax,imax,nthp0,dt,tmax,alpha,ze,t,
& rho_, lmax, iout3, iout5, iout4, iout7, iout8, iswchi, aerrmx
& , rerrmx,
& npsi0,dens_averaged_ar)
!WRITE(*,*)'adjint109 after subadj', myrank
write(*,*)'adj_control.f adjint after subadj'
write(*,*)'dens_averaged_ar',dens_averaged_ar
return
case (3)
c get j/p table
c
cSm070625
c iadj = 1
c call curadj (nthp0, npsi0, psimx, psimn, nmax, umax1, imax,
c 1 lmax, psis(1), eden(1), etem(1), zefi(1), sjop(1), nwp, wpmx
c 2 , wpmn, dwp, wp(1), nthp1, thetp(1), iout4, iout5, iadj,
c 3 gwk2, gwk3, npnta)
c if(myrank.eq.0) then ! MPI ! YuP[2018-09-10] added
c write (iout6, 1000) jopid
c write (iout6, 1010) nwp, nthp0, npsi0, nthp1
c write (iout6, 1020) psimx, psimn, wpmx, wpmn, dwp
c write (iout6, 1030) (wp(nw),nw=1,nwp)
c write (iout6, 1030) (thetp(nthp),nthp=1,nthp1)
c write (iout6, 1030) (psis(ns),ns=1,npsi0)
c write (iout6, 1030) (eden(ns),ns=1,npsi0)
c write (iout6, 1030) (etem(ns),ns=1,npsi0)
c write (iout6, 1030) (zefi(ns),ns=1,npsi0)
c do js = 1, npsi0
c do jp = 1, nthp1
c jps = (js - 1)*nthp1*nwp + (jp - 1)*nwp + 1
c write (iout6, 1030) (sjop(nw),nw=jps,jps + nwp - 1)
c end do
c end do
c endif !On myrank=0 ! myrank=0
c--------------------------------
1000 format(1x,1a40)
1010 format(1x,4i8)
1020 format(5(1x,e18.10))
1030 format(5(1x,e18.10))
c------------------------
return
end select
end subroutine adjint
subroutine adj_chi_function
c------------------------------------------------------------------
c calculate adj chi function using Karney subroutins from Curray code
c-------------------------------------------------------------------
c open output files, calculate
c &thetas(nthpp0+1), !poloidal angle mesh for b line integration
c &dla(0:nthpp0-1), !length along b line
c &ba(0:nthpp0-1), !b/b0 along b line
c &thetae(0:nthpp0-1) !poloidal angle mesh for b line integration
c---------------------------------------------------------------------------
c write(*,*)'adj_chi_function before call adjint(1)'
call adjint(1)
c write(*,*)'adj_chi_function after call adjint(1)'
c----------------------------------------------------------------------------
c get Spitzer-function table
c chi(theta,ua)=chi(0:imax1 - 1,0:nmax - 1) and output to adjout
c At each radial point (np=1,npsi0) write chi and other variables
c to the file with file number: iout5 and file name: 'adjout
c----------------------------------------------------------------------------
c write(*,*)'adj_chi_function before call adjint(2)'
call adjint(2)
c write(*,*)'adj_chi_function after call adjint(2)'
c--------------------------------------------------------------------------
return
end