I'm writing my first numerical optimization program (Newton's method) and my first Fortran program too. I started with Python to understand the first problem and now I'm porting to Fortran to work on the other. (One thing at a time, right?)
In Python, there's a handy way of passing arguments to a function: unpacking a list, like so:
def f(x_1, x_2):
"""Just a function with two arguments."""
return math.sqrt(x_1 ** 2 + x_2 ** 2)
...
f(*[4, 3]) # calls f with parameters 4 and 3
# output: 5
Does Fortran have something resembling this star operator? I put my 2-dimensional points into a matrix, and I'm trying to learn the most conventional way of passing one of my 2D point "vectors" to a function to be evaluated. It looks a little like this:
! "double precision", using SELECTED_REAL_KIND
REAL(KIND=dp), DIMENSION(100, 2) :: iterates = 0.0_dp
! f expects two REALs
REAL(KIND=dp) :: first_value = f(iterates(1, :))