Closed mathrack closed 5 years ago
This seems slightly better:
function cs_notebook_parameter_value_by_name(name) result(val) &
bind(C, name='cs_notebook_parameter_value_by_name')
use, intrinsic :: iso_c_binding
implicit none
character(kind=c_char, len=1), dimension(*), intent(in) :: name
real(kind=c_double) :: val
end function cs_notebook_parameter_value_by_name
Then
function notebook_parameter_value_by_name(name) result(val)
use, intrinsic :: iso_c_binding
implicit none
! Arguments
character(len=*), intent(in) :: name
double precision :: val
! Local variables
character(len=len_trim(name)+1, kind=c_char) :: c_name
real(kind=c_double) :: c_val
c_name = trim(name)//c_null_char
c_val = cs_notebook_parameter_value_by_name(c_name)
val = c_val
end function notebook_parameter_value_by_name
Thank you for that, it was included in commit 88a57c6 and merged on v6.0 branch.
It would be interesting to have the possibility to obtain notebook parameters in fortran. The following addition to cs_c_bindings.f90 could do the job. It seems to work, but might need improvements as I have to trim the variable name when calling it.