80 real(s2_dp),
parameter :: BIANCHI2_CMB_T = 2.725d3
83 real(s2_dp),
parameter :: BIANCHI2_CMB_T = 1d0
94 logical :: init = .false.
96 real(s2_dp) :: omega_matter = 0.0d0
98 real(s2_dp) :: omega_lambda = 0.0d0
102 real(s2_dp) :: h = 0.0d0
104 real(s2_dp) :: zE = 0.0d0
107 real(s2_dp) :: wH = 0.0d0
109 logical :: rhand = .true.
146 use pix_tools
, only: pix2ang_ring, nside2npix, in_ring
148 real(s2_dp),
intent(in) :: omega_matter_in, omega_lambda_in, h, ze_in, wh
149 logical,
intent(in) :: rhand
150 integer,
intent(in) :: nside
153 real(s2_dp) :: thetaob, phiob
154 real(s2_dp) :: theta0, phi0
157 real(s2_dp) :: tstop_use
158 real(s2_dp) :: tau_needed
159 real(s2_dp) :: fact, u10_req, phi1
160 real(s2_dp) :: r_final, rh_final, cos_bit_final, sin_bit_final, other_bit
161 real(s2_dp) :: lambda, final_dens, t0
163 integer :: npix, ipix, fail
164 real(s2_dp),
allocatable :: map(:)
165 real(s2_sp) :: handedness_sign = +1d0
167 real(s2_dp),
parameter :: phi_centre = 0.0d0
168 real(s2_dp),
parameter :: phi_diff = pi
169 integer :: iring, nring, max_pix_per_ring, npixring
170 integer,
allocatable :: ipixring(:)
179 b%omega_matter = omega_matter_in
180 b%omega_lambda = omega_lambda_in
187 npix = nside2npix(nside)
188 allocate(map(0:npix-1), stat=fail)
197 handedness_sign = 1d0
199 handedness_sign = -1d0
214 b2gd_omega_matter = b%omega_matter
215 b2gd_omega_lambda = b%omega_lambda
220 b2gd_alpha = sqrt(b%h)
221 b2gd_rh_start = sqrt(-b2gd_alpha**2/(b%omega_matter+b%omega_lambda-1d0))
223 tstop_use=-tau_needed
224 lambda = 3*b2gd_rh_start**2*b%omega_lambda
228 max_pix_per_ring = 4*nside
231 allocate(ipixring(0:max_pix_per_ring-1), stat=fail)
250 call in_ring(nside, iring, phi_centre, phi_diff, ipixring, &
254 call pix2ang_ring(nside, ipixring(0), thetaob, phiob)
257 theta0 = pi - thetaob
261 b2gd_theta_0 = theta0 - pi/2d0
264 call
get_results(tstop_use,r_final,rh_final,cos_bit_final,sin_bit_final)
265 fact = sqrt(9.d0*b2gd_alpha**2+1.d0)*sqrt(1.d0+b2gd_alpha**2)* &
266 sqrt(1.d0-b%omega_matter-b%omega_lambda)**3.d0/b2gd_alpha**3 &
271 do ipix = 0,npixring-1
274 call pix2ang_ring(nside, ipixring(ipix), thetaob, phiob)
281 phi0 = phi0 * handedness_sign
284 b2gd_phi_0 = phi0 + 3d0/4d0*pi
287 phi1 = u10_req/r_final*(sin_bit_final*sin(b2gd_phi_0)+cos_bit_final*cos(b2gd_phi_0))
288 map(ipixring(ipix)) = -phi1/(1+b2gd_ze)*2d0
291 final_dens = (3d0*rh_final**2-lambda*r_final**2-3d0*b2gd_alpha**2)/(r_final**2)
292 t0 = 3.d0/final_dens/r_final**5*cos((b2gd_phi_0*b2gd_alpha-b2gd_alpha*tstop_use- &
293 dlog(cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0+exp(-2.d0*b2gd_alpha*tstop_use)- &
294 exp(-2.d0*b2gd_alpha*tstop_use)*cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0))/b2gd_alpha)* &
295 exp(b2gd_alpha*tstop_use)*cos(b2gd_theta_0)/(-1.d0-sin(b2gd_theta_0)+ &
296 exp(2.d0*b2gd_alpha*tstop_use)*sin(b2gd_theta_0)-exp(2.d0*b2gd_alpha*tstop_use))*b2gd_alpha+ &
297 1.d0/final_dens/r_final**5*sin((b2gd_phi_0*b2gd_alpha-b2gd_alpha*tstop_use- &
298 dlog(cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0+exp(-2.d0*b2gd_alpha*tstop_use)- &
299 exp(-2.d0*b2gd_alpha*tstop_use)*cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0))/b2gd_alpha)* &
300 exp(b2gd_alpha*tstop_use)*cos(b2gd_theta_0)/(-1.d0-sin(b2gd_theta_0)+ &
301 exp(2.d0*b2gd_alpha*tstop_use)*sin(b2gd_theta_0)-exp(2.d0*b2gd_alpha*tstop_use))
302 other_bit = u10_req*t0
304 map(ipixring(ipix)) = map(ipixring(ipix)) - other_bit/(1+b2gd_ze)*2d0
313 map = handedness_sign * map
316 map = bianchi2_cmb_t * map
319 b%sky = s2_sky_init(
real(map,s2_sp), nside, s2_sky_ring)
367 nside, lmax, ntheta, alpha, beta, gamma, lut) result(b)
370 use s2_dl_mod
, only : s2_dl_beta_operator
372 real(s2_dp),
intent(in) :: omega_matter_in, omega_lambda_in, h, ze_in, wh
373 logical,
intent(in) :: rhand
374 integer,
intent(in) :: nside, lmax, ntheta
378 real(s2_dp) :: tstop_use
379 real(s2_dp) :: tau_needed
380 real(s2_dp) :: fact, u10_req
381 real(s2_dp) :: r_final, rh_final, cos_bit_final, sin_bit_final
382 real(s2_dp) :: lambda, final_dens
384 integer :: npix, ipix, fail
387 complex(s2_spc),
allocatable :: alm(:,:)
388 real(s2_dp) :: handedness_sign = +1d0, lsign = 1d0
390 real(s2_dp),
allocatable :: a_grid(:), b_grid(:)
391 real(s2_dp) :: theta_inc
392 real(s2_dp) :: c_sin, c_cos
393 real(s2_dp) :: ia, ib
396 real(s2_sp),
intent(in),
optional :: alpha, beta, gamma
397 real(s2_sp),
parameter :: zero_tol = 1d-4
398 real(s2_dp),
pointer :: dl(:,:) => null()
400 complex(s2_spc),
allocatable :: alm_rotate(:,:)
401 complex(s2_dpc) :: dm_p1, dm_m1
402 complex(s2_dpc) :: icmpx
405 icmpx = cmplx(0d0,1d0)
414 b%omega_matter = omega_matter_in
415 b%omega_lambda = omega_lambda_in
422 allocate(alm(0:lmax,0:lmax), stat=fail)
423 alm = cmplx(0d0, 0d0)
426 'bianchi2_sky_init_alm')
431 handedness_sign = 1d0
433 handedness_sign = -1d0
438 b2gd_omega_matter = b%omega_matter
439 b2gd_omega_lambda = b%omega_lambda
443 b2gd_alpha = sqrt(b%h)
444 b2gd_rh_start = sqrt(-b2gd_alpha**2/(b%omega_matter+b%omega_lambda-1d0))
446 tstop_use=-tau_needed
449 allocate(a_grid(0:ntheta-1), stat=fail)
450 allocate(b_grid(0:ntheta-1), stat=fail)
454 'bianchi2_sky_init_alm')
459 b2gd_theta_0 = -pi/2d0
460 theta_inc = (pi - 0d0) /
real(ntheta, s2_dp)
466 do itheta = 0, ntheta-1
468 b2gd_theta_0=-pi/2d0+itheta*theta_inc
470 call
get_results(tstop_use,r_final,rh_final,cos_bit_final,sin_bit_final)
471 fact = sqrt(9.d0*b2gd_alpha**2+1.d0)*sqrt(1.d0+b2gd_alpha**2)* &
472 sqrt(1.d0-b%omega_matter-b%omega_lambda)**3.d0/b2gd_alpha**3 &
475 lambda = 3*b2gd_rh_start**2*b%omega_lambda
476 final_dens = (3d0*rh_final**2-lambda*r_final**2-3d0*b2gd_alpha**2)/(r_final**2)
478 c_sin=-u10_req/(1+b2gd_ze)*2d0*( &
479 1d0/r_final*(sin_bit_final*cos(3d0/4d0*pi)-cos_bit_final*sin(3d0/4d0*pi)) &
480 - 3.d0/final_dens/r_final**5 &
481 * exp(b2gd_alpha*tstop_use)*cos(b2gd_theta_0) &
482 / (-1.d0-sin(b2gd_theta_0) &
483 + exp(2.d0*b2gd_alpha*tstop_use)*sin(b2gd_theta_0) &
484 - exp(2.d0*b2gd_alpha*tstop_use)) &
486 * sin((-b2gd_alpha*tstop_use- &
487 dlog(cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0 &
488 + exp(-2.d0*b2gd_alpha*tstop_use) &
489 - exp(-2.d0*b2gd_alpha*tstop_use)*cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0) &
490 )/b2gd_alpha+3d0/4d0*pi) &
491 + 1.d0/final_dens/r_final**5 &
492 * exp(b2gd_alpha*tstop_use)*cos(b2gd_theta_0) &
493 / (-1.d0-sin(b2gd_theta_0) &
494 + exp(2.d0*b2gd_alpha*tstop_use)*sin(b2gd_theta_0) &
495 -exp(2.d0*b2gd_alpha*tstop_use)) &
496 * cos((-b2gd_alpha*tstop_use- &
497 dlog(cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0 &
498 + exp(-2.d0*b2gd_alpha*tstop_use) &
499 - exp(-2.d0*b2gd_alpha*tstop_use)*cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0) &
500 )/b2gd_alpha+3d0/4d0*pi) &
503 c_cos=-u10_req/(1+b2gd_ze)*2d0*( &
504 1d0/r_final*(sin_bit_final*sin(3d0/4d0*pi)+cos_bit_final*cos(3d0/4d0*pi)) &
505 + 3.d0/final_dens/r_final**5 &
506 * exp(b2gd_alpha*tstop_use)*cos(b2gd_theta_0) &
507 / (-1.d0-sin(b2gd_theta_0) &
508 + exp(2.d0*b2gd_alpha*tstop_use)*sin(b2gd_theta_0) &
509 - exp(2.d0*b2gd_alpha*tstop_use)) &
511 * cos((-b2gd_alpha*tstop_use- &
512 dlog(cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0 &
513 + exp(-2.d0*b2gd_alpha*tstop_use) &
514 - exp(-2.d0*b2gd_alpha*tstop_use)*cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0) &
515 )/b2gd_alpha+3d0/4d0*pi) &
516 + 1.d0/final_dens/r_final**5 &
517 * exp(b2gd_alpha*tstop_use)*cos(b2gd_theta_0) &
518 / (-1.d0-sin(b2gd_theta_0) &
519 + exp(2.d0*b2gd_alpha*tstop_use)*sin(b2gd_theta_0) &
520 -exp(2.d0*b2gd_alpha*tstop_use)) &
521 * sin((-b2gd_alpha*tstop_use- &
522 dlog(cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0 &
523 + exp(-2.d0*b2gd_alpha*tstop_use) &
524 - exp(-2.d0*b2gd_alpha*tstop_use)*cos(pi/4.d0+b2gd_theta_0/2.d0)**2.d0) &
525 )/b2gd_alpha+3d0/4d0*pi) &
528 a_grid(itheta) = (c_sin - c_cos) / 2d0
529 b_grid(itheta) = (c_sin + c_cos) / 2d0
545 if (l/2==l/2.d0)
then
557 alm(l,1) = -lsign * pi * cmplx(- handedness_sign * (ib - ia), (ia + ib))
566 alm = bianchi2_cmb_t * alm
569 if(present(alpha) .and. present(beta) .and. present(gamma) &
570 .and. (abs(alpha)+abs(beta)+abs(gamma) > zero_tol) )
then
573 allocate(dl(-lmax:lmax,-lmax:lmax),stat=fail)
574 allocate(alm_rotate(0:lmax,0:lmax), stat=fail)
577 'bianchi_sky_rotate')
579 alm_rotate = (0d0,0d0)
588 call s2_dl_beta_operator(dl,
real(beta,s2_dp), l)
593 dm_p1 = exp(-icmpx*m*alpha) * dl(m, 1) * exp(-icmpx*gamma)
594 dm_m1 = exp(-icmpx*m*alpha) * dl(m,-1) * exp( icmpx*gamma)
597 alm_rotate(l,m) = - dm_m1*conjg(alm(l,1)) + dm_p1*alm(l,1)
603 b%sky = s2_sky_init(alm_rotate, lmax, lmax, nside)
604 deallocate(alm_rotate)
612 b%sky = s2_sky_init(alm, lmax, lmax, nside)
645 if(.not. b%init)
then
650 call s2_sky_free(b%sky)
653 b%omega_matter = 0.0d0
654 b%omega_lambda = 0.0d0
679 write(*,
'(a,e12.5)')
' b%omega_matter: ', b%omega_matter
680 write(*,
'(a,e12.5)')
' b%omega_lambda: ', b%omega_lambda
681 write(*,
'(a,e23.5)')
' b%h: ', b%h
682 write(*,
'(a,e22.5)')
' b%zE: ', b%zE
683 write(*,
'(a,e22.5)')
' b%wH: ', b%wH
684 write(*,
'(a,l19)')
' b%rhand: ', b%rhand
704 integer,
intent(in) :: nside
707 if(.not. b%init)
then
709 'bianchi2_sky_compute_map')
713 call s2_sky_compute_map(b%sky, nside)
734 integer,
intent(in) :: lmax, mmax
737 if(.not. b%init)
then
739 'bianchi2_sky_compute_alm')
743 call s2_sky_compute_alm(b%sky, lmax, mmax)
766 integer,
intent(in) :: lmax
767 real(s2_sp),
dimension(0:lmax),
intent(out) :: cl
769 complex(s2_spc),
dimension(0:lmax,0:lmax) :: alm
773 if(.not. b%init)
then
774 call
bianchi2_error(bianchi2_error_not_init,
'bianchi2_sky_get_Cl')
778 call s2_sky_get_alm(b%sky, alm)
782 cl(l)=
real(alm(l,0)*conjg(alm(l,0)))
784 cl(l)=cl(l)+2*
real(alm(l,m)*conjg(alm(l,m)))
813 if(.not. b%init)
then
814 call s2_error(bianchi2_error_not_init,
'bianchi2_sky_get_sky')
818 sky = s2_sky_init(b%sky)
841 complex(s2_spc),
intent(out) :: alm(:,:)
844 if(.not. b%init)
then
845 call
bianchi2_error(bianchi2_error_not_init,
'bianchi2_sky_get_alm')
849 call s2_sky_get_alm(b%sky, alm)
873 use s2_vect_mod
, only: s2_vect_arcmin_to_rad
876 real(s2_sp),
intent(in) :: fwhm
877 integer,
intent(in) :: lmax
879 real(s2_sp) :: fwhm_rad
883 fwhm_rad = s2_vect_arcmin_to_rad(fwhm)
886 beam = s2_pl_init_guassian(fwhm_rad, lmax)
889 call s2_sky_conv(b%sky, beam)
892 call s2_pl_free(beam)
915 character(len=*),
intent(in) :: filename
916 integer,
intent(in) :: file_type
917 character(len=*),
intent(in),
optional :: comment
920 if(.not. b%init)
then
921 call
bianchi2_error(bianchi2_error_not_init,
'bianchi2_sky_write')
924 select case(file_type)
926 case(s2_sky_file_type_map)
927 call s2_sky_write_map_file(b%sky, filename, comment)
929 case(s2_sky_file_type_alm)
930 call s2_sky_write_alm_file(b%sky, filename, comment)
932 case(s2_sky_file_type_sky)
933 call s2_sky_io_fits_write(filename, b%sky, comment)
936 call s2_error(s2_error_sky_file_invalid,
'bianchi2_sky_write', &
937 comment_add=
'Invalid file type specifier')
959 integer,
intent(in) :: lmax
960 real(s2_sp),
dimension(0:lmax),
intent(inout) :: cl
961 logical,
intent(in) :: rescale_cl
962 character(len=*),
intent(in) :: filename
966 open(11,file=filename)
969 write(11,*) l, cl(l)*l*(l+1)/ (2d0*pi)
1002 use s2_dl_mod
, only: s2_dl_beta_operator
1005 real(s2_sp),
intent(in),
optional :: alpha, beta, gamma
1007 logical,
intent(in) :: rotation_alm
1008 integer,
intent(in) :: lmax, nside
1011 complex(s2_spc),
allocatable :: alm(:,:)
1012 complex(s2_spc),
allocatable :: alm_rotate(:,:)
1013 real(s2_dp),
pointer :: dl(:,:) => null()
1014 complex(s2_dpc) :: dm_p1, dm_m1
1015 real(s2_sp),
parameter :: zero_tol = 1d-4
1016 complex(s2_dpc) :: icmpx
1019 icmpx = cmplx(0d0,1d0)
1022 if(.not. b%init)
then
1023 call
bianchi2_error(bianchi2_error_not_init,
'bianchi2_sky_rotate')
1028 if(present(alpha) .and. present(beta) .and. present(gamma) &
1029 .and. (abs(alpha)+abs(beta)+abs(gamma) > zero_tol) )
then
1032 if (.not. rotation_alm)
then
1034 write(*,
'(a)')
' Rotation pixel by pixel with s2_sky_rotate '
1035 call s2_sky_rotate(b%sky, alpha, beta, gamma)
1039 write(*,
'(a)')
' Rotation of the alm '
1040 allocate(dl(-lmax:lmax,-lmax:lmax),stat=fail)
1041 allocate(alm(0:lmax,0:1), stat=fail)
1042 allocate(alm_rotate(0:lmax,0:lmax), stat=fail)
1045 'bianchi_sky_rotate')
1057 call s2_dl_beta_operator(dl,
real(beta,s2_dp), l)
1063 dm_p1 = exp(-icmpx*m*alpha) * dl(m, 1) * exp(-icmpx*gamma)
1064 dm_m1 = exp(-icmpx*m*alpha) * dl(m,-1) * exp( icmpx*gamma)
1067 alm_rotate(l,m) = - dm_m1*conjg(alm(l,1)) + dm_p1*alm(l,1)
1074 call s2_sky_free(b%sky)
1077 b%sky = s2_sky_init(alm_rotate, lmax, lmax, nside)
1082 deallocate(alm_rotate)
1089 write(*,
'(a)')
' No rotation needed '
1116 cos_bit_final, sin_bit_final)
1123 real(s2_dp),
intent(in) :: tstop_use
1124 real(s2_dp),
intent(out) :: r_final,rh_final,cos_bit_final,sin_bit_final
1126 integer,
parameter :: neq = 4
1128 real(s2_dp) :: vals(b2gd_nvars)
1129 real(s2_dp) :: warr(21*neq+28)
1130 real(s2_dp) :: tstart,tol
1131 real(s2_dp) :: tmin,tmax,t,tend
1134 integer(kind=8) :: neqn,irelab,ifail
1136 integer :: neqn,irelab,ifail=1
1139 character(len=1) :: relabs
1142 b2gd_tstop=tstop_use
1147 b2gd_deltat=(b2gd_tstop-tstart)/(b2gd_nt-1)
1162 vals(2)=b2gd_rh_start
1175 call d02cjf(t,tend,neqn,vals,
fcn,tol,relabs,
out,d02cjw,warr,ifail)
1178 if((ifail/=0).and.(ifail/=1))
then
1179 call
bianchi2_error(bianchi2_error_sky_num_fail,
'get_results', &
1180 comment_add=
'NAG routine d02cjf failed')
1183 do b2gd_it=1,b2gd_nt
1184 b2gd_treal(b2gd_it)=b2gd_tarr(b2gd_it)
1185 r=b2gd_xarr(1,b2gd_it)
1186 rh=b2gd_xarr(2,b2gd_it)
1187 t=b2gd_tarr(b2gd_it)
1188 b2gd_xreal(b2gd_it)=r
1191 r_final=b2gd_xarr(1,b2gd_nt)
1192 rh_final=b2gd_xarr(2,b2gd_nt)
1193 cos_bit_final=b2gd_xarr(3,b2gd_nt)
1194 sin_bit_final=b2gd_xarr(4,b2gd_nt)
1217 integer,
parameter :: neq = 4
1218 integer,
parameter :: nvars = 4
1220 real(s2_dp),
intent(in) :: t
1221 real(s2_dp),
intent(in) :: vars(nvars)
1222 real(s2_dp),
intent(out) :: ff(nvars)
1225 real(s2_dp) :: r,rh,lambda
1226 real(s2_dp) :: arg,fact
1232 lambda=3*b2gd_rh_start**2*b2gd_omega_lambda
1236 ff(2)=-rh**2.d0/2.d0+lambda*r**2.d0/2.d0+b2gd_alpha**2/2.d0
1238 arg=(b2gd_alpha*tau+dlog(cos(0.3141592653589793d1/4.d0+ &
1239 b2gd_theta_0/2.d0)**2.d0+exp(-2.d0*b2gd_alpha*tau)-&
1240 exp(-2.d0*b2gd_alpha*tau)*cos(0.3141592653589793d1/4.d0+ &
1241 b2gd_theta_0/2.d0)**2.d0))/b2gd_alpha
1243 fact=-2.d0/r**2*exp(b2gd_alpha*tau)*cos(b2gd_theta_0)/(-1.d0-sin(b2gd_theta_0)+ &
1244 exp(2.d0*b2gd_alpha*tau)*sin(b2gd_theta_0)-exp(2.d0*b2gd_alpha*tau))**2.d0* &
1245 (1.d0+sin(b2gd_theta_0)+exp(2.d0*b2gd_alpha*tau)*sin(b2gd_theta_0)- &
1246 exp(2.d0*b2gd_alpha*tau))
1274 real(s2_dp),
intent(inout) :: t
1275 real(s2_dp),
intent(in) :: vals(b2gd_nvars)
1277 real(s2_dp) :: deriv(b2gd_nvars)
1278 integer :: iel, ival
1280 iel=b2gd_nt-(b2gd_it+1)
1282 do ival=1,b2gd_nvars
1283 b2gd_xarr(ival,iel)=vals(ival)
1286 call
fcn(t,vals,deriv)
1288 t=b2gd_tstop-b2gd_it*b2gd_deltat
1312 real(s2_dp),
intent(out) :: tau_needed
1314 real(s2_dp) :: aa, abserr, bb, epsabs, epsrel, result_val
1317 integer(kind=8) :: ifail
1318 integer(kind=8),
parameter :: liwork = 10000
1319 integer(kind=8),
parameter :: lwork = 10000
1320 integer(kind=8) :: iwork(liwork)
1323 integer,
parameter :: liwork = 10000
1324 integer,
parameter :: lwork = 10000
1325 integer :: iwork(liwork)
1328 real(s2_dp) :: work(lwork)
1334 aa=1d0/sqrt(1+b2gd_ze)
1336 call d01ajf(
f1r,aa,bb,epsabs,epsrel,result_val,abserr,work,lwork,&
1339 tau_needed=result_val
1362 real(s2_dp),
intent(in) :: a
1366 t0 = -b2gd_alpha**2*(b2gd_omega_lambda*a**6-a**2*b2gd_omega_matter-a**2* &
1367 b2gd_omega_lambda+a**2+b2gd_omega_matter)/(b2gd_omega_matter+b2gd_omega_lambda-1)
1395 integer,
intent(in) :: l,lmax,ntheta
1396 real(s2_dp),
intent(in) :: x_grid(0:)
1400 real(s2_dp) :: integrand, plm1
1402 real(s2_dp) :: dtheta, theta
1406 dtheta = (pi - 0d0) /
Real(ntheta, s2_dp)
1409 if (present(lut))
then
1411 do itheta = 0, ntheta-1
1412 theta = itheta*dtheta
1414 integrand = sin(theta) * x_grid(itheta) * plm1
1415 ix = ix + integrand*dtheta
1420 do itheta = 0, ntheta-1
1421 theta = itheta*dtheta
1423 integrand = sin(theta) * x_grid(itheta) * plm1
1424 ix = ix + integrand*dtheta
1430 ix = ix * sqrt( (2d0*l+1d0) /
real(4d0*PI*l*(l+1d0), s2_dp) )