3

I have this very small example of Fortran code which I would like to understand please.

  subroutine test_iso_c

  use ISO_C_BINDING

  implicit real(c_double) (a-h,o-z)    

  real :: var, expression

  interface
    real(c_double) function test (y) bind( c )
     use ISO_C_BINDING
       real(c_double), value :: y
     end
  end interface


  ! call 
  var = test(expression) ! - expression  is a real declared variable which is calculated using simple  arithmetic operation.   

  end 

Can you explain to me thee following (I assume c_double means double precision in a C code scope?)

1 - What does implicit real(c_double) (a-h,o-z)?

2 - what does value and bind(c) do in the function interface

3 - I saw this of code as part of a larger routine, can you say what this test function provide/do?

francescalus
  • 27,974
  • 11
  • 58
  • 92
A2LBK
  • 1,359
  • 4
  • 15
  • 1
    You can read about these details [here](https://stackoverflow.com/tags/fortran-iso-c-binding/info). Please understand that page and consider whether there's more you want to know. As it is, this is rather a broad question. In particular, we can't answer part 3 as we don't know the details of the function `test`. Behaviour of the `implicit` statement here isn't different from any other (pre-F2018) use. – francescalus Feb 11 '19 at 10:00
  • thanks!, What is the pre-F2018 use w.r.t to the `implicit` satement – A2LBK Feb 11 '19 at 10:18
  • 1
    That `implicit` statement makes any variable with initial letter a, b, c, ..., h, o, p, q, ..., z without an explicit type declaration, of type `real(c_double)`. [This other answer](https://stackoverflow.com/a/49382846/3157076) contains some details of that. – francescalus Feb 11 '19 at 10:22

0 Answers0