On Wednesday,  5 May 2021 at 08:37, pie...@caramail.com wrote:
> Make a function and then run it with different values.

Have a look at the attachment.  Doesn't create a /function/ in the
Fortran sense but shows how you can definitely call some code with
different values.

That's about all I can help with as it's been years since I used Fortran
(although I did cut my teeth on Fortran 66... ;-)).

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.5-395-g82fbdd
* testing ob fortran
#+name: ftest
#+begin_src fortran :var m=20 :var n=30 :results output
  real, dimension(m,n) :: a
  real, dimension(n,m) :: c
  real, dimension(m) :: b
  integer :: i
  print *, m, n
  a = reshape( (/ (real(i), i=1,m*n) /), (/ m, n /) )
  b = (/ (2*i, i=1,m) /)
  c = reshape( a, (/ n, m /) )
  print *, b
#+end_src

#+results: ftest
: 20          30
: 2.00000000       4.00000000       6.00000000       8.00000000       10.0000000       12.0000000       14.0000000       16.0000000       18.0000000       20.0000000       22.0000000       24.0000000       26.0000000       28.0000000       30.0000000       32.0000000       34.0000000       36.0000000       38.0000000       40.0000000

#+results:
: 2.00000000       4.00000000       6.00000000       8.00000000       10.0000000       12.0000000       14.0000000       16.0000000       18.0000000       20.0000000       22.0000000       24.0000000       26.0000000       28.0000000       30.0000000       32.0000000       34.0000000       36.0000000       38.0000000       40.0000000

#+call: ftest(m=10,n=40)

#+results:
: 10          40
: 2.00000000       4.00000000       6.00000000       8.00000000       10.0000000       12.0000000       14.0000000       16.0000000       18.0000000       20.0000000

#+call: ftest(m=20,n=10)

#+results:
: 20          10
: 2.00000000       4.00000000       6.00000000       8.00000000       10.0000000       12.0000000       14.0000000       16.0000000       18.0000000       20.0000000       22.0000000       24.0000000       26.0000000       28.0000000       30.0000000       32.0000000       34.0000000       36.0000000       38.0000000       40.0000000

Reply via email to