| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | module psi_transform | ||
| 2 | use, intrinsic :: iso_fortran_env, only: dp => real64 | ||
| 3 | use binsrc_sub | ||
| 4 | use plag_coeff_sub | ||
| 5 | implicit none | ||
| 6 | |||
| 7 | contains | ||
| 8 | |||
| 9 | 3 | subroutine grid_r_to_psi(rmin, rmax, psi_inner, psi_outer, & | |
| 10 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | psi_of_x, Aph_of_x, hth_of_x, hph_of_x, Bmod_of_x, & |
| 11 |
9/18✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 3 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 3 times.
|
3 | r_of_xc, Aph_of_xc, hth_of_xc, hph_of_xc, Bmod_of_xc) |
| 12 | |||
| 13 | real(dp), intent(in) :: rmin, rmax, psi_inner, psi_outer | ||
| 14 | real(dp), dimension(:,:,:), intent(in) :: & | ||
| 15 | psi_of_x, Aph_of_x, hth_of_x, hph_of_x, Bmod_of_x | ||
| 16 | real(dp), dimension(:,:,:), intent(out) :: & | ||
| 17 | r_of_xc, Aph_of_xc, hth_of_xc, hph_of_xc, Bmod_of_xc | ||
| 18 | |||
| 19 | integer :: n_r, n_th, n_phi | ||
| 20 | ! ***** This should be an input variable: | ||
| 21 | ! integer, intent(in) :: n_psi | ||
| 22 | ! in case n_psi is different from n_r, n_r should be replaced | ||
| 23 | ! with n_psi in the above declaration of output arrays | ||
| 24 | real(dp) :: h_psi | ||
| 25 | integer :: n_psi | ||
| 26 | ! | ||
| 27 | integer, parameter :: nder = 0 !(no derivatives) | ||
| 28 | ! ***** This should be the input variable: | ||
| 29 | ! integer, intent(in) :: nplagr | ||
| 30 | ! ***** For the moment it is a local parameter: | ||
| 31 | integer, parameter :: nplagr = 6 !(4 points - cubic polynomial, 6: quintic) | ||
| 32 | ! | ||
| 33 | logical :: reverse | ||
| 34 | integer :: i_r, i_psi, ibeg, iend, nshift | ||
| 35 | integer :: i_th, i_phi | ||
| 36 | real(dp) :: psi_fix | ||
| 37 | 3 | real(dp), dimension(:), allocatable :: xp, psi_loc, r | |
| 38 | 3 | real(dp), dimension(:,:), allocatable :: coef | |
| 39 | ! | ||
| 40 | 3 | n_r = size(psi_of_x,1) | |
| 41 | 3 | n_th = size(psi_of_x,2) | |
| 42 | 3 | n_phi = size(psi_of_x,3) | |
| 43 | ! | ||
| 44 |
12/24✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 3 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 3 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 3 times.
✓ Branch 22 taken 3 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 3 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 3 times.
|
12 | allocate(xp(nplagr),coef(0:nder,nplagr),psi_loc(n_r),r(n_r)) |
| 45 | 3 | nshift = nplagr/2 | |
| 46 | |||
| 47 |
2/2✓ Branch 0 taken 31 times.
✓ Branch 1 taken 3 times.
|
34 | do i_r = 1, n_r |
| 48 | 34 | r(i_r) = rmin + dble(i_r-1)*(rmax-rmin)/dble(n_r-1) | |
| 49 | enddo | ||
| 50 | ! | ||
| 51 | ! Equidistant grid in psi: | ||
| 52 | ! | ||
| 53 | 3 | n_psi = n_r !This needs not to be the same***** | |
| 54 | ! | ||
| 55 | 3 | i_phi = n_phi/2 | |
| 56 | 3 | i_th = n_th/2 | |
| 57 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if(psi_of_x(n_r,i_th,i_phi).gt.psi_of_x(1,i_th,i_phi)) then |
| 58 | reverse = .false. | ||
| 59 | else | ||
| 60 | ✗ | reverse = .true. | |
| 61 | endif | ||
| 62 | ! | ||
| 63 | 3 | h_psi=(psi_outer-psi_inner)/dble(n_psi-1) | |
| 64 | ! | ||
| 65 |
2/2✓ Branch 0 taken 37 times.
✓ Branch 1 taken 3 times.
|
40 | do i_phi = 1,n_phi |
| 66 |
2/2✓ Branch 0 taken 468 times.
✓ Branch 1 taken 37 times.
|
508 | do i_th = 1,n_th |
| 67 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 468 times.
|
468 | if(reverse) then |
| 68 | ✗ | psi_loc = psi_of_x(n_r:1:-1, i_th, i_phi) | |
| 69 | else | ||
| 70 |
4/10✓ Branch 0 taken 468 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 6120 times.
✓ Branch 9 taken 468 times.
|
7056 | psi_loc = psi_of_x(:, i_th, i_phi) |
| 71 | endif | ||
| 72 |
2/2✓ Branch 0 taken 6120 times.
✓ Branch 1 taken 468 times.
|
6625 | do i_psi = 1,n_psi |
| 73 | 6120 | psi_fix = psi_inner+h_psi*dble(i_psi-1) | |
| 74 | ! | ||
| 75 | 6120 | call binsrc(psi_loc,1,n_r,psi_fix,i_r) | |
| 76 | ! | ||
| 77 | 6120 | ibeg = i_r - nshift | |
| 78 | 6120 | iend = ibeg+nplagr-1 | |
| 79 |
2/2✓ Branch 0 taken 5652 times.
✓ Branch 1 taken 468 times.
|
6120 | if(ibeg.lt.1) then |
| 80 | 6120 | ibeg = 1 | |
| 81 | 6120 | iend = min(ibeg+nplagr-1,n_r) | |
| 82 |
2/2✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 4530 times.
|
5652 | elseif(iend.gt.n_r) then |
| 83 | 1122 | iend = n_r | |
| 84 | 1122 | ibeg = max(1, iend-nplagr+1) | |
| 85 | endif | ||
| 86 | ! | ||
| 87 | 6120 | call plag_coeff(nplagr,nder,psi_fix,psi_loc(ibeg:iend),coef) | |
| 88 | ! | ||
| 89 |
1/2✓ Branch 0 taken 6120 times.
✗ Branch 1 not taken.
|
6588 | if(reverse) then |
| 90 | ✗ | ibeg = n_r - ibeg +1 | |
| 91 | ✗ | iend = n_r - iend +1 | |
| 92 | ✗ | r_of_xc(i_psi, i_th, i_phi) = sum(coef(0,:)*r(ibeg:iend:-1)) | |
| 93 | ✗ | Aph_of_xc(i_psi, i_th, i_phi) = sum(coef(0,:)*Aph_of_x(ibeg:iend:-1, i_th, i_phi)) | |
| 94 | ✗ | hth_of_xc(i_psi, i_th, i_phi) = sum(coef(0,:)*hth_of_x(ibeg:iend:-1, i_th, i_phi)) | |
| 95 | ✗ | hph_of_xc(i_psi, i_th, i_phi) = sum(coef(0,:)*hph_of_x(ibeg:iend:-1, i_th, i_phi)) | |
| 96 | ✗ | Bmod_of_xc(i_psi, i_th, i_phi) = sum(coef(0,:)*Bmod_of_x(ibeg:iend:-1, i_th, i_phi)) | |
| 97 | else | ||
| 98 |
2/2✓ Branch 0 taken 36720 times.
✓ Branch 1 taken 6120 times.
|
42840 | r_of_xc(i_psi, i_th, i_phi) = sum(coef(0,:)*r(ibeg:iend)) |
| 99 |
2/2✓ Branch 0 taken 36720 times.
✓ Branch 1 taken 6120 times.
|
42840 | Aph_of_xc(i_psi, i_th, i_phi) = sum(coef(0,:)*Aph_of_x(ibeg:iend, i_th, i_phi)) |
| 100 |
2/2✓ Branch 0 taken 36720 times.
✓ Branch 1 taken 6120 times.
|
42840 | hth_of_xc(i_psi, i_th, i_phi) = sum(coef(0,:)*hth_of_x(ibeg:iend, i_th, i_phi)) |
| 101 |
2/2✓ Branch 0 taken 36720 times.
✓ Branch 1 taken 6120 times.
|
42840 | hph_of_xc(i_psi, i_th, i_phi) = sum(coef(0,:)*hph_of_x(ibeg:iend, i_th, i_phi)) |
| 102 |
2/2✓ Branch 0 taken 36720 times.
✓ Branch 1 taken 6120 times.
|
42840 | Bmod_of_xc(i_psi, i_th, i_phi) = sum(coef(0,:)*Bmod_of_x(ibeg:iend, i_th, i_phi)) |
| 103 | endif | ||
| 104 | enddo | ||
| 105 | enddo | ||
| 106 | enddo | ||
| 107 | ! | ||
| 108 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
|
3 | deallocate(xp,coef,psi_loc) |
| 109 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | end subroutine grid_r_to_psi |
| 110 | |||
| 111 | end module psi_transform | ||
| 112 |