-
Notifications
You must be signed in to change notification settings - Fork 166
Array Types Design
Ondřej Čertík edited this page Mar 11, 2022
·
34 revisions
-
We need to be able to represent roughly what Fortran allows, as it is know that the Fortran design allows compilers to deliver excellent performance. However we can go beyond Fortran and try to simplify / abstract some of the concepts, but we need to do at least what Fortran does.
-
We should follow Python's canonical approach where possible, using Python's typing and be consistent with the following documents:
Examples of Fortran and Python side by side. These examples show all that Fortran allows, and we try to come up the most natural Python equivalent.
subroutine f(n, r)
integer, intent(in) :: n
real(dp), intent(out) :: r(n)
integer :: i
do i = 1, n
r(i) = 1.0_dp / i**2
enddo
end subroutine
subroutine g(m, n, A)
integer, intent(in) :: m, n
real(dp), intent(in) :: A(m, n)
...
end subroutine
subroutine f(r)
real(dp), intent(out) :: r(:)
integer :: n, i
n = size(r)
do i = 1, n
r(i) = 1.0_dp / i**2
enddo
end subroutine
subroutine g(A)
real(dp), intent(in) :: A(:, :)
...
end subroutine
subroutine print_eigenvalues(kappa_min, kappa_max, lam)
integer, intent(in) :: kappa_min, kappa_max
real(dp), intent(in) :: lam(kappa_min:kappa_max)
integer :: kappa
do kappa = kappa_min, ubound(lam, 1)
print *, kappa, lam(kappa)
end do
end subroutine
subroutine print_eigenvalues(kappa_min, lam)
integer, intent(in) :: kappa_min
real(dp), intent(in) :: lam(kappa_min:)
integer :: kappa
do kappa = kappa_min, ubound(lam, 1)
print *, kappa, lam(kappa)
end do
end subroutine
- How to design Python syntax / typing
- How to design ASR in the most natural and abstract way
- Should ASR allow custom lower bounds?