00001
00002
00003 module legendre_fn_grav_plmex
00004 use phys_constant, only : long
00005 implicit none
00006 real(long), pointer :: plm_ex(:,:,:,:,:,:)
00007 contains
00008
00009 subroutine allocate_legendre_plmex
00010 use phys_constant, only : long
00011 use grid_parameter, only : nrg,ntg,npg, nlg
00012 use make_array_6d
00013 implicit none
00014 real(long) :: leg_mem
00015
00016 leg_mem = 2.0d0*dble(nrg)*dble(ntg)*dble(npg)*dble(nlg)*dble(nlg)*8.0d0
00017 leg_mem = leg_mem/1024.0d0/1024.0d0/1024.0d0
00018 write(6,'(a50)') "++++++++++++++++++++++++++++++++++++++++++++++++++"
00019 write(6,'(a28,e15.3,a3)') "Memory allocation of plm_ex:", leg_mem, " GB"
00020 write(6,'(a50)') "++++++++++++++++++++++++++++++++++++++++++++++++++"
00021
00022 call alloc_array6d(plm_ex, 1,2, 0,nrg, 0,ntg, 0,npg, 0,nlg, 0,nlg)
00023
00024 end subroutine allocate_legendre_plmex
00025
00026 SUBROUTINE legendre_plmex(impt)
00027 use phys_constant, only : nnlg, long, pi
00028 use grid_parameter, only : nrg, ntg, npg, nlg
00029
00030 use grid_parameter_binary_excision, only : ex_radius
00031 use grid_points_binary_excision, only : rb, thb, phib, irg_exin, irg_exout
00032 use make_array_1d
00033 implicit none
00034 integer :: irg,itg,ipg, mm, nn, il, kk, impt
00035 real(long) :: fmm, fnn
00036 real(long) :: q1, q2, cc1, ss1, fkk
00037 real(long) :: rra1, rra1l
00038 real(long), pointer :: fac(:)
00039
00040
00041
00042 call alloc_array1d(fac, 0, nlg)
00043 fac(0) = 1.0d0
00044 do mm = 1, nlg
00045 fmm = dble(mm)
00046 fac(mm) = (2.0d0*fmm-1.0d0) * fac(mm-1)
00047 end do
00048
00049 do ipg = 0, npg
00050 do itg = 0, ntg
00051 do irg = 0, nrg
00052 if (irg.gt.irg_exin(itg,ipg).and. irg.lt.irg_exout(itg,ipg)) then
00053 plm_ex(impt,irg,itg,ipg,0:nlg,0:nlg) = 0.0d0
00054 else
00055 plm_ex(impt,irg,itg,ipg,0:nlg,0:nlg) = 0.0d0
00056 cc1 = dcos(thb(irg,itg,ipg))
00057 ss1 = dsin(thb(irg,itg,ipg))
00058
00059 plm_ex(impt,irg,itg,ipg,0,0) = 1.0d0
00060 do mm = 1, nlg
00061 plm_ex(impt,irg,itg,ipg,mm,mm) = fac(mm) * (-ss1)**mm
00062 end do
00063
00064 do mm = 0, nlg-1
00065 fmm = dble(mm)
00066 plm_ex(impt,irg,itg,ipg,mm+1,mm) = (2.d0*fmm + 1.d0)*cc1*plm_ex(impt,irg,itg,ipg,mm,mm)
00067 end do
00068
00069 do mm = 0, nlg-2
00070 fmm = dble(mm)
00071 do kk = 2, nlg-mm
00072 fkk = dble(kk)
00073 q1 = ( 2.0d0 * fmm + 2.0d0 * fkk - 1.0d0 ) / fkk
00074 q2 = ( 2.0d0 * fmm + fkk - 1.0d0 ) / fkk
00075 plm_ex(impt,irg,itg,ipg,mm+kk,mm) = q1 * cc1 * plm_ex(impt,irg,itg,ipg,mm+kk-1,mm) &
00076 & - q2 * plm_ex(impt,irg,itg,ipg,mm+kk-2,mm)
00077 end do
00078 end do
00079
00080 rra1 = ex_radius/rb(irg,itg,ipg)
00081 rra1l = 1.0d0
00082 do il = 0, nlg
00083 rra1l = rra1l*rra1
00084 plm_ex(impt,irg,itg,ipg, il,0:nlg) = plm_ex(impt,irg,itg,ipg, il,0:nlg)*rra1l
00085 end do
00086
00087
00088
00089 end if
00090 end do
00091 end do
00092 end do
00093
00094 deallocate(fac)
00095
00096 end subroutine legendre_plmex
00097
00098 end module legendre_fn_grav_plmex