00001 subroutine iteration_peos(iter_count)
00002 use phys_constant, only : long, nnrg, nntg, nnpg
00003 use grid_parameter
00004 use coordinate_grav_r
00005 use coordinate_grav_phi
00006 use coordinate_grav_theta
00007 use weight_midpoint_grav
00008 use make_array_2d
00009 use make_array_3d
00010 use make_array_4d
00011 use def_metric
00012 use def_matter
00013 use def_matter_parameter
00014 use interface_interpo_fl2gr
00015 use interface_poisson_solver
00016 use interface_sourceterm_HaC_peos
00017 use interface_sourceterm_trG_peos
00018 use interface_source_MoC_CF
00019 use interface_sourceterm_MoC_peos
00020 use interface_compute_shift
00021 use interface_compute_alps2alph
00022 use interface_hydrostatic_eq_peos
00023 use interface_calc_surface
00024 use interface_update_grfield
00025 use interface_update_matter
00026 use interface_update_parameter_peos
00027 use interface_update_surface
00028 use interface_error_matter
00029 use interface_error_metric
00030 use interface_error_metric_type0
00031 use interface_error_metric_type2
00032 implicit none
00033 real(long), pointer :: sou(:,:,:), pot(:,:,:), sou2(:,:,:)
00034 real(long), pointer :: potf(:,:,:), emd_bak(:,:,:)
00035 real(long), pointer :: potrs(:,:)
00036 real(long), pointer :: potx(:,:,:), poty(:,:,:), potz(:,:,:)
00037 real(long), pointer :: potx_bak(:,:,:), poty_bak(:,:,:), potz_bak(:,:,:)
00038 real(long), pointer :: souvec(:,:,:,:)
00039 real(long) :: work(0:nnrg,0:nntg,0:nnpg)
00040 real(long) :: error_emd, count
00041 real(long) :: error_psi = 0.0d0, error_alph = 0.0d0, error_tmp = 0.0d0,
00042 error_bvxd = 0.0d0, error_bvyd = 0.0d0, error_bvzd = 0.0d0
00043 real(long) :: error_emd_tmp = 1.0d0, error_metric_tmp = 1.0d0
00044 integer :: iter_count, flag = 0, hydro_iter = 4
00045 integer :: flag_tmp = 0, flag_param = 99,
00046 flag_psi = 0, flag_alph = 0, &
00047 flag_bvxd = 0, flag_bvyd = 0, flag_bvzd = 0
00048 integer :: irf, itf, ipf, irg, itg, ipg, ihy
00049
00050 call alloc_array3d(sou,0,nrg,0,ntg,0,npg)
00051 call alloc_array3d(sou2,0,nrg,0,ntg,0,npg)
00052 call alloc_array3d(potx,0,nrg,0,ntg,0,npg)
00053 call alloc_array3d(poty,0,nrg,0,ntg,0,npg)
00054 call alloc_array3d(potz,0,nrg,0,ntg,0,npg)
00055 call alloc_array3d(pot,0,nrg,0,ntg,0,npg)
00056 call alloc_array3d(potf,0,nrf,0,ntf,0,npf)
00057 call alloc_array3d(emd_bak,0,nrf,0,ntf,0,npf)
00058 call alloc_array3d(potx_bak,0,nrg,0,ntg,0,npg)
00059 call alloc_array3d(poty_bak,0,nrg,0,ntg,0,npg)
00060 call alloc_array3d(potz_bak,0,nrg,0,ntg,0,npg)
00061 call alloc_array2d(potrs,0,ntf,0,npf)
00062 call alloc_array4d(souvec,0,nrg,0,ntg,0,npg,1,3)
00063
00064 iter_count = 0
00065 do
00066 iter_count = iter_count + 1
00067 count = dble(iter_count)
00068 conv_gra = dmin1(conv0_gra,conv_ini*count)
00069 conv_den = dmin1(conv0_den,conv_ini*count)
00070
00071 emdg = 0.0d0
00072 call interpo_fl2gr(emd, emdg)
00073
00074 call calc_vector_x_grav(1)
00075 call calc_vector_x_matter(1)
00076 call calc_vector_phi_grav(1)
00077 call calc_vector_phi_matter(1)
00078 call excurve
00079
00080 call sourceterm_HaC_peos(sou)
00081 call poisson_solver(sou,pot)
00082 pot = pot + 1.0d0
00083 call update_grfield(pot,psi,conv_gra)
00084 call update_parameter_peos(conv_den)
00085
00086
00087 call sourceterm_trG_peos(sou)
00088 call poisson_solver(sou,pot)
00089 pot = pot + 1.0d0
00090 call compute_alps2alph(pot,psi)
00091 call update_grfield(pot,alph,conv_gra)
00092 call update_parameter_peos(conv_den)
00093
00094
00095
00096 call source_MoC_CF(souvec)
00097 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 1)
00098 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00099 call poisson_solver(sou2,potx)
00100 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 2)
00101 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00102 call poisson_solver(sou2,poty)
00103 work(1:nrg, 1:ntg, 1:npg) = souvec(1:nrg, 1:ntg, 1:npg, 3)
00104 sou2(1:nrg, 1:ntg, 1:npg) = work(1:nrg, 1:ntg, 1:npg)
00105 call poisson_solver(sou2,potz)
00106
00107 work( 0:nrg, 0:ntg, 0:npg) = potx(0:nrg, 0:ntg, 0:npg)
00108 souvec(0:nrg, 0:ntg, 0:npg, 1) = work(0:nrg, 0:ntg, 0:npg)
00109 work( 0:nrg, 0:ntg, 0:npg) = poty(0:nrg, 0:ntg, 0:npg)
00110 souvec(0:nrg, 0:ntg, 0:npg, 2) = work(0:nrg, 0:ntg, 0:npg)
00111 work( 0:nrg, 0:ntg, 0:npg) = potz(0:nrg, 0:ntg, 0:npg)
00112 souvec(0:nrg, 0:ntg, 0:npg, 3) = work(0:nrg, 0:ntg, 0:npg)
00113
00114 potx_bak(0:nrg,0:ntg,0:npg) = bvxd(0:nrg,0:ntg,0:npg)
00115 poty_bak(0:nrg,0:ntg,0:npg) = bvyd(0:nrg,0:ntg,0:npg)
00116 potz_bak(0:nrg,0:ntg,0:npg) = bvzd(0:nrg,0:ntg,0:npg)
00117 call update_grfield(potx,bvxd,conv_gra)
00118 call update_grfield(poty,bvyd,conv_gra)
00119 call update_grfield(potz,bvzd,conv_gra)
00120 call update_parameter_peos(conv_den)
00121
00122 call error_metric_type2(bvxd,potx_bak,error_tmp,flag_tmp,'ns')
00123 flag_bvxd = max ( flag_bvxd, flag_tmp)
00124 error_bvxd = dmax1(error_bvxd,error_tmp)
00125 call error_metric_type2(bvyd,poty_bak,error_tmp,flag_tmp,'ns')
00126 flag_bvyd = max ( flag_bvyd, flag_tmp)
00127 error_bvyd = dmax1(error_bvyd,error_tmp)
00128 call error_metric_type2(bvzd,potz_bak,error_tmp,flag_tmp,'ns')
00129 flag_bvzd = max ( flag_bvzd, flag_tmp)
00130 error_bvzd = dmax1(error_bvzd,error_tmp)
00131 call printout_error_metric(iter_count,error_bvxd)
00132 call printout_error_metric(iter_count,error_bvyd)
00133 call printout_error_metric(iter_count,error_bvzd)
00134
00135
00136 if (error_emd_tmp.le.eps*0.1d0.and.error_metric_tmp.gt.eps*2.0d0) then
00137 write(6,*)' ## SKIP HYDRO ##'
00138 else
00139 do ihy = 1, hydro_iter
00140 call hydrostatic_eq_peos(potf)
00141 call calc_surface(potrs, potf)
00142 emd_bak = emd
00143 call update_matter(potf,emd,conv_den)
00144 call update_surface(potrs,rs,conv_den)
00145 call reset_fluid
00146 call update_parameter_peos(conv_den)
00147 call calc_vector_x_matter(1)
00148 call calc_vector_phi_matter(1)
00149
00150 if (ihy.eq.1) then
00151 call error_matter(emd,emd_bak,error_emd,flag)
00152 call printout_error(iter_count,error_emd)
00153 end if
00154 end do
00155 end if
00156
00157
00158
00159
00160 if (flag == 0) exit
00161 if (iter_count >= iter_max) exit
00162
00163 error_emd_tmp = error_emd
00164 error_metric_tmp = dmax1(error_psi,error_alph, &
00165 & error_bvxd,error_bvyd,error_bvzd)
00166
00167 flag = 0
00168 flag_psi = 0
00169 flag_alph = 0
00170 flag_bvxd = 0
00171 flag_bvyd = 0
00172 flag_bvzd = 0
00173 flag_param= 0
00174 error_emd = 0.0d0
00175 error_psi = 0.0d0
00176 error_alph = 0.0d0
00177 error_bvxd = 0.0d0
00178 error_bvyd = 0.0d0
00179 error_bvzd = 0.0d0
00180
00181 end do
00182
00183 deallocate(sou)
00184 deallocate(sou2)
00185 deallocate(potx)
00186 deallocate(poty)
00187 deallocate(potz)
00188 deallocate(pot)
00189 deallocate(potf)
00190 deallocate(emd_bak)
00191 deallocate(potx_bak)
00192 deallocate(poty_bak)
00193 deallocate(potz_bak)
00194 deallocate(potrs)
00195 deallocate(souvec)
00196 end subroutine iteration_peos