| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | module simple_coordinates | ||
| 2 | |||
| 3 | use, intrinsic :: iso_fortran_env, only: dp => real64 | ||
| 4 | use vmec_coordinates, only: vmec_to_cyl_lib => vmec_to_cyl, & | ||
| 5 | vmec_to_cart_lib => vmec_to_cart, & | ||
| 6 | cyl_to_cart_lib => cyl_to_cart | ||
| 7 | |||
| 8 | implicit none | ||
| 9 | |||
| 10 | abstract interface | ||
| 11 | subroutine transform_i(xfrom, xto, dxto_dxfrom) | ||
| 12 | import :: dp | ||
| 13 | real(dp), intent(in) :: xfrom(3) | ||
| 14 | real(dp), intent(out) :: xto(3) | ||
| 15 | real(dp), intent(out), optional :: dxto_dxfrom(3,3) | ||
| 16 | end subroutine transform_i | ||
| 17 | end interface | ||
| 18 | |||
| 19 | contains | ||
| 20 | |||
| 21 | ✗ | subroutine transform_vmec_to_cyl(xfrom, xto, dxto_dxfrom) | |
| 22 | real(dp), intent(in) :: xfrom(3) | ||
| 23 | real(dp), intent(out) :: xto(3) | ||
| 24 | real(dp), intent(out), optional :: dxto_dxfrom(3,3) | ||
| 25 | |||
| 26 | ✗ | call vmec_to_cyl_lib(xfrom, xto, dxto_dxfrom) | |
| 27 | ✗ | end subroutine transform_vmec_to_cyl | |
| 28 | |||
| 29 | |||
| 30 | ✗ | subroutine transform_vmec_to_cart(xfrom, xto, dxto_dxfrom) | |
| 31 | real(dp), intent(in) :: xfrom(3) | ||
| 32 | real(dp), intent(out) :: xto(3) | ||
| 33 | real(dp), intent(out), optional :: dxto_dxfrom(3,3) | ||
| 34 | |||
| 35 | ✗ | call vmec_to_cart_lib(xfrom, xto, dxto_dxfrom) | |
| 36 | ✗ | end subroutine transform_vmec_to_cart | |
| 37 | |||
| 38 | |||
| 39 | 17 | subroutine transform_cyl_to_cart(xfrom, xto, dxto_dxfrom) | |
| 40 | real(dp), intent(in) :: xfrom(3) | ||
| 41 | real(dp), intent(out) :: xto(3) | ||
| 42 | real(dp), intent(out), optional :: dxto_dxfrom(3,3) | ||
| 43 | |||
| 44 | 17 | call cyl_to_cart_lib(xfrom, xto, dxto_dxfrom) | |
| 45 | 17 | end subroutine transform_cyl_to_cart | |
| 46 | |||
| 47 | |||
| 48 | 4 | function get_transform(from, to) | |
| 49 | procedure(transform_i), pointer :: get_transform | ||
| 50 | character(*), intent(in) :: from, to | ||
| 51 | |||
| 52 | 4 | get_transform => null() | |
| 53 | |||
| 54 | 6 | select case (trim(from)) | |
| 55 | case('cyl') | ||
| 56 | 4 | select case (trim(to)) | |
| 57 | case ('cart') | ||
| 58 | ✗ | get_transform => transform_cyl_to_cart | |
| 59 | case default | ||
| 60 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | call handle_transform_error(from, to) |
| 61 | end select | ||
| 62 | case ('vmec') | ||
| 63 | 2 | select case (trim(to)) | |
| 64 | case ('cart') | ||
| 65 | 1 | get_transform => transform_vmec_to_cart | |
| 66 | case ('cyl') | ||
| 67 | 1 | get_transform => transform_vmec_to_cyl | |
| 68 | case default | ||
| 69 |
2/3✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
2 | call handle_transform_error(from, to) |
| 70 | end select | ||
| 71 | case default | ||
| 72 | ✗ | print *, "get_transform: Unknown transform from ", from | |
| 73 |
2/3✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | error stop |
| 74 | end select | ||
| 75 | 4 | end function get_transform | |
| 76 | |||
| 77 | |||
| 78 | ✗ | subroutine handle_transform_error(from, to) | |
| 79 | character(*), intent(in) :: from | ||
| 80 | character(*), intent(in), optional :: to | ||
| 81 | |||
| 82 | ✗ | if (present(to)) then | |
| 83 | ✗ | print *, "Unknown transform from ", from, " to ", to | |
| 84 | else | ||
| 85 | ✗ | print *, "Unknown transform from ", from | |
| 86 | end if | ||
| 87 | ✗ | error stop | |
| 88 | end subroutine handle_transform_error | ||
| 89 | |||
| 90 | end module simple_coordinates | ||
| 91 |