00001 subroutine iteration_irbns_WL(iter_count)
00002 use phys_constant, only : long, nnrg, nntg, nnpg
00003 use def_formulation, only : chgra, chope
00004 use def_metric_hij, only : hxxd, hxyd, hxzd, hyyd, hyzd, hzzd
00005 use grid_parameter
00006 use coordinate_grav_r
00007 use coordinate_grav_phi
00008 use coordinate_grav_theta
00009 use weight_midpoint_grav
00010 use make_array_2d
00011 use make_array_3d
00012 use make_array_4d
00013 use def_metric
00014 use def_matter
00015 use interface_interpo_fl2gr
00016 use interface_poisson_solver
00017
00018
00019
00020 use interface_compute_shift
00021 use interface_compute_alps2alph
00022 use interface_hydrostatic_eq_WL_peos
00023 use interface_calc_surface
00024 use interface_update_grfield
00025 use interface_update_matter
00026 use interface_update_parameter_WL_peos
00027 use interface_update_surface
00028 use interface_error_matter
00029 use interface_source_HaC_WL
00030 use interface_source_MoC_WL
00031 use interface_source_trfreeG_WL
00032 use interface_source_trG_WL
00033 implicit none
00034 real(long), pointer :: sou(:,:,:), pot(:,:,:), sou2(:,:,:)
00035 real(long), pointer :: potf(:,:,:), emd_bak(:,:,:)
00036 real(long), pointer :: potrs(:,:)
00037 real(long), pointer :: potx(:,:,:), poty(:,:,:), potz(:,:,:)
00038 real(long), pointer :: souvec(:,:,:,:), souten(:,:,:,:)
00039 real(long), pointer :: pot1(:,:,:), pot2(:,:,:), pot3(:,:,:)
00040 real(long), pointer :: pot4(:,:,:), pot5(:,:,:), pot6(:,:,:)
00041 real(long), pointer :: bk1(:,:,:), bk2(:,:,:), bk3(:,:,:)
00042 real(long), pointer :: bk4(:,:,:), bk5(:,:,:), bk6(:,:,:)
00043 real(long), pointer :: work(:,:,:)
00044
00045 real(long) :: error_emd, count
00046 integer :: iter_count, flag = 0, hydro_iter = 4
00047 integer :: irf, itf, ipf, irg, itg, ipg, ihy
00048
00049 call alloc_array3d(sou,0,nrg,0,ntg,0,npg)
00050 call alloc_array3d(pot,0,nrg,0,ntg,0,npg)
00051 call alloc_array3d(sou2,0,nrg,0,ntg,0,npg)
00052 call alloc_array3d(potf,0,nrf,0,ntf,0,npf)
00053 call alloc_array3d(emd_bak,0,nrf,0,ntf,0,npf)
00054 call alloc_array2d(potrs,0,ntf,0,npf)
00055 call alloc_array3d(potx,0,nrg,0,ntg,0,npg)
00056 call alloc_array3d(poty,0,nrg,0,ntg,0,npg)
00057 call alloc_array3d(potz,0,nrg,0,ntg,0,npg)
00058 call alloc_array4d(souvec,0,nrg,0,ntg,0,npg,1,3)
00059 call alloc_array4d(souten,0,nrg,0,ntg,0,npg,1,6)
00060 call alloc_array3d(pot1,0,nrg,0,ntg,0,npg)
00061 call alloc_array3d(pot2,0,nrg,0,ntg,0,npg)
00062 call alloc_array3d(pot3,0,nrg,0,ntg,0,npg)
00063 call alloc_array3d(pot4,0,nrg,0,ntg,0,npg)
00064 call alloc_array3d(pot5,0,nrg,0,ntg,0,npg)
00065 call alloc_array3d(pot6,0,nrg,0,ntg,0,npg)
00066 call alloc_array3d(bk1,0,nrg,0,ntg,0,npg)
00067 call alloc_array3d(bk2,0,nrg,0,ntg,0,npg)
00068 call alloc_array3d(bk3,0,nrg,0,ntg,0,npg)
00069 call alloc_array3d(bk4,0,nrg,0,ntg,0,npg)
00070 call alloc_array3d(bk5,0,nrg,0,ntg,0,npg)
00071 call alloc_array3d(bk6,0,nrg,0,ntg,0,npg)
00072 call alloc_array3d(work,0,nrg,0,ntg,0,npg)
00073
00074 iter_count = 0
00075 do
00076 iter_count = iter_count + 1
00077 count = dble(iter_count)
00078 conv_gra = dmin1(conv0_gra,conv_ini*count)
00079 conv_den = dmin1(conv0_den,conv_ini*count)
00080
00081 emdg = 0.0d0
00082 call interpo_fl2gr(emd, emdg)
00083
00084 call calc_vector_x_grav(1)
00085 call calc_vector_x_matter(1)
00086 call calc_vector_phi_grav(1)
00087 call calc_vector_phi_matter(1)
00088 call calc_shift_down2up
00089 call calc_shift2rotshift
00090
00091
00092 if (chgra == 'i') call cleargeometry
00093 if (chgra /= 'i') then
00094 call cristoffel_midpoint
00095 call cristoffel_gridpoint
00096 call riccitensor_midpoint
00097 end if
00098 if (chgra == 'h'.or.chgra == 'c'.or.chgra == 'C' &
00099 &.or.chgra == 'H'.or.chgra == 'W') then
00100 call liegmab_midpoint
00101 call liegmab_gridpoint
00102 end if
00103
00104 call excurve_WL_midpoint
00105 call excurve_WL_gridpoint
00106 call ap2alps
00107
00108
00109 call source_HaC_WL(sou)
00110
00111 call poisson_solver(sou,pot)
00112 pot = pot + 1.0d0
00113 call update_grfield(pot,psi,conv_gra)
00114 call update_parameter_WL_peos(conv_den)
00115
00116
00117 call source_trG_WL(sou)
00118 call poisson_solver(sou,pot)
00119 pot = pot + 1.0d0
00120 call compute_alps2alph(pot,psi)
00121 call update_grfield(pot,alph,conv_gra)
00122 call update_parameter_WL_peos(conv_den)
00123
00124 call source_MoC_WL(souvec,sou)
00125 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 1)
00126 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00127 call poisson_solver(sou2,potx)
00128 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 2)
00129 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00130 call poisson_solver(sou2,poty)
00131 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 3)
00132 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00133 call poisson_solver(sou2,potz)
00134 call poisson_solver(sou,pot)
00135 work( 0:nrg, 0:ntg, 0:npg) = potx(0:nrg, 0:ntg, 0:npg)
00136 souvec(0:nrg, 0:ntg, 0:npg, 1) = work(0:nrg, 0:ntg, 0:npg)
00137 work( 0:nrg, 0:ntg, 0:npg) = poty(0:nrg, 0:ntg, 0:npg)
00138 souvec(0:nrg, 0:ntg, 0:npg, 2) = work(0:nrg, 0:ntg, 0:npg)
00139 work( 0:nrg, 0:ntg, 0:npg) = potz(0:nrg, 0:ntg, 0:npg)
00140 souvec(0:nrg, 0:ntg, 0:npg, 3) = work(0:nrg, 0:ntg, 0:npg)
00141 call compute_shift(potx, poty, potz, souvec, pot)
00142 call update_grfield(potx,bvxd,conv_gra)
00143 call update_grfield(poty,bvyd,conv_gra)
00144 call update_grfield(potz,bvzd,conv_gra)
00145 call update_parameter_WL_peos(conv_den)
00146
00147
00148
00149
00150
00151
00152
00153 if (chgra == 'i') go to 9000
00154
00155
00156
00157
00158 call source_trfreeG_WL(souten)
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 bk1(0:nrg,0:ntg,0:npg) = hxxd(0:nrg,0:ntg,0:npg)
00169 bk2(0:nrg,0:ntg,0:npg) = hxyd(0:nrg,0:ntg,0:npg)
00170 bk3(0:nrg,0:ntg,0:npg) = hxzd(0:nrg,0:ntg,0:npg)
00171 bk4(0:nrg,0:ntg,0:npg) = hyyd(0:nrg,0:ntg,0:npg)
00172 bk5(0:nrg,0:ntg,0:npg) = hyzd(0:nrg,0:ntg,0:npg)
00173 bk6(0:nrg,0:ntg,0:npg) = hzzd(0:nrg,0:ntg,0:npg)
00174 hxxd(0:nrg,0:ntg,0:npg) = 0.0d0
00175 hxyd(0:nrg,0:ntg,0:npg) = 0.0d0
00176 hxzd(0:nrg,0:ntg,0:npg) = 0.0d0
00177 hyyd(0:nrg,0:ntg,0:npg) = 0.0d0
00178 hyzd(0:nrg,0:ntg,0:npg) = 0.0d0
00179 hzzd(0:nrg,0:ntg,0:npg) = 0.0d0
00180
00181
00182
00183 if (chope == 'L') then
00184
00185 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,1)
00186 call poisson_solver(sou,pot1)
00187 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,2)
00188 call poisson_solver(sou,pot2)
00189 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,3)
00190 call poisson_solver(sou,pot3)
00191 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,4)
00192 call poisson_solver(sou,pot4)
00193 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,5)
00194 call poisson_solver(sou,pot5)
00195 sou(0:nrg,0:ntg,0:npg) = souten(0:nrg,0:ntg,0:npg,6)
00196 call poisson_solver(sou,pot6)
00197
00198 end if
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212 hxxd(0:nrg,0:ntg,0:npg) = pot1(0:nrg,0:ntg,0:npg)
00213 hxyd(0:nrg,0:ntg,0:npg) = pot2(0:nrg,0:ntg,0:npg)
00214 hxzd(0:nrg,0:ntg,0:npg) = pot3(0:nrg,0:ntg,0:npg)
00215 hyyd(0:nrg,0:ntg,0:npg) = pot4(0:nrg,0:ntg,0:npg)
00216 hyzd(0:nrg,0:ntg,0:npg) = pot5(0:nrg,0:ntg,0:npg)
00217 hzzd(0:nrg,0:ntg,0:npg) = pot6(0:nrg,0:ntg,0:npg)
00218
00219
00220
00221
00222
00223
00224 call gauge
00225 call adjusthij
00226
00227
00228
00229 pot1(0:nrg,0:ntg,0:npg) = hxxd(0:nrg,0:ntg,0:npg)
00230 pot2(0:nrg,0:ntg,0:npg) = hxyd(0:nrg,0:ntg,0:npg)
00231 pot3(0:nrg,0:ntg,0:npg) = hxzd(0:nrg,0:ntg,0:npg)
00232 pot4(0:nrg,0:ntg,0:npg) = hyyd(0:nrg,0:ntg,0:npg)
00233 pot5(0:nrg,0:ntg,0:npg) = hyzd(0:nrg,0:ntg,0:npg)
00234 pot6(0:nrg,0:ntg,0:npg) = hzzd(0:nrg,0:ntg,0:npg)
00235
00236 hxxd(0:nrg,0:ntg,0:npg) = bk1(0:nrg,0:ntg,0:npg)
00237 hxyd(0:nrg,0:ntg,0:npg) = bk2(0:nrg,0:ntg,0:npg)
00238 hxzd(0:nrg,0:ntg,0:npg) = bk3(0:nrg,0:ntg,0:npg)
00239 hyyd(0:nrg,0:ntg,0:npg) = bk4(0:nrg,0:ntg,0:npg)
00240 hyzd(0:nrg,0:ntg,0:npg) = bk5(0:nrg,0:ntg,0:npg)
00241 hzzd(0:nrg,0:ntg,0:npg) = bk6(0:nrg,0:ntg,0:npg)
00242
00243 call update_grfield(pot1,hxxd,conv_gra)
00244 call update_grfield(pot2,hxyd,conv_gra)
00245 call update_grfield(pot3,hxzd,conv_gra)
00246 call update_grfield(pot4,hyyd,conv_gra)
00247 call update_grfield(pot5,hyzd,conv_gra)
00248 call update_grfield(pot6,hzzd,conv_gra)
00249
00250 call invhij
00251
00252 call update_parameter_WL_peos(conv_den)
00253
00254
00255
00256
00257
00258 9000 continue
00259
00260
00261
00262
00263
00264 call interpo_gr2fl_metric_WL
00265 do ihy = 1, hydro_iter
00266 if (ihy.eq.1) emd_bak = emd
00267 call hydro_irbns_1stint_WL_peos(potf)
00268 call calc_surface(potrs, potf)
00269 call update_matter(potf,emd,conv_den)
00270 call update_surface(potrs,rs,conv_den)
00271 call reset_fluid
00272 call update_parameter_WL_peos(conv_den)
00273 call calc_vector_x_matter(1)
00274 call calc_vector_phi_matter(1)
00275
00276 call hydro_irbns_vep_WL_peos(potf)
00277 call update_matter(potf,vep,conv_vep)
00278 call reset_fluid_vep
00279 call update_parameter_WL_peos(conv_den)
00280
00281 if (ihy.eq.hydro_iter) then
00282 call error_matter(emd,emd_bak,error_emd,flag)
00283 call printout_error(iter_count,error_emd)
00284 end if
00285 end do
00286
00287 if (flag == 0) exit
00288 if (iter_count >= iter_max) exit
00289 flag = 0
00290
00291 end do
00292
00293 deallocate(sou)
00294 deallocate(pot)
00295 deallocate(sou2)
00296 deallocate(potf)
00297 deallocate(emd_bak)
00298 deallocate(potrs)
00299 deallocate(potx)
00300 deallocate(poty)
00301 deallocate(potz)
00302 deallocate(souvec)
00303 deallocate(souten)
00304 deallocate(pot1)
00305 deallocate(pot2)
00306 deallocate(pot3)
00307 deallocate(pot4)
00308 deallocate(pot5)
00309 deallocate(pot6)
00310 deallocate(bk1)
00311 deallocate(bk2)
00312 deallocate(bk3)
00313 deallocate(bk4)
00314 deallocate(bk5)
00315 deallocate(bk6)
00316 deallocate(work)
00317 end subroutine iteration_irbns_WL