Posted to tcl by arjen at Fri Jun 05 09:14:39 GMT 2026view raw

  1. ! bessel --
  2. ! Wrapper for the Fortran J0 Bessel function
  3. !
  4. ! Arguments:
  5. ! clientdata Any data registered for the command
  6. ! interp Tcl interpreter that is running the command
  7. ! nobj Number of arguments
  8. ! objv Array of argument objects
  9. !
  10. !
  11. integer function tcl_bessel_j0( clientdata, interp, nobj, objv ) bind(c)
  12. type(c_ptr), value :: clientdata
  13. type(tcl_interp), value :: interp
  14. integer(c_int), value :: nobj
  15. type(tcl_obj), dimension(*) :: objv
  16.  
  17. real(c_double) :: arg1, result
  18. integer(c_int) :: rc
  19.  
  20. tcl_bessel_j0 = tcl_error
  21.  
  22. !
  23. ! The name of the command is the first argument, so correct for that
  24. !
  25. if ( nobj-1 /= 1 ) then
  26. call tcl_setresult( interp, "Wrong number of arguments" // c_null_char, c_null_funptr )
  27. return
  28. endif
  29.  
  30. call ftcl_getdoublefromobj( interp, objv(2), arg1, rc )
  31. if ( rc /= tcl_ok ) then
  32. return
  33. endif
  34.  
  35. tcl_bessel_j0 = tcl_ok
  36.  
  37. result = bessel_j0( arg1 )
  38.  
  39. call ftcl_setresult( interp, result )
  40. end function tcl_bessel_j0

Add a comment

Please note that this site uses the meta tags nofollow,noindex for all pages that contain comments.
Items are closed for new comments after 1 week