Ruby on Rails
Monday, July 21, 2014
Hi,
I used DL to call intel fortran .dylib file successfully before, but DL is removed from
latest Ruby version. I tried to use fiddle and got error message "unknown symbol
'samplesize'", could anyone help to see where I did wrong? Thanks!
Liz
my fortran function is below (our_int is compatible with long in C, our_double is compatible with
double in C):
integer(our_int) function samplesize( maxn, delta, conf, errmsg ) result( answer )
!DEC$ ATTRIBUTES DLLEXPORT :: samplesize
!
! OUTPUT
! N: sample size
!
! EXAMPLE
! samplesize4(3000, .2, .90);
!
implicit none
integer(our_int), intent(in) :: maxn
real(our_dble), intent(in) :: delta, conf
character(len=err_msg_width), intent(out) :: errmsg
....
and I used DL to call it like this before:
require 'dl'
require 'pathname'
sspath = Pathname.new( "#{RAILS_ROOT}/lib/libsamplesize.dylib" )
ss = DL.dlopen( sspath )
samplesize = ss[ "samplesize_", "iiddS" ]
session[:errmsg] = " ";
session[:n], args = samplesize[ session[:nmax], session[:delta],
session[:conf], session[:errmsg] ]
Now I tried to use fiddle as below:
require 'fiddle'
libm = Fiddle.dlopen( "/Library/WebServer/smart/lib/libsamplesize.dylib" )
# samplesize = ss[ "samplesize_", "iiddS" ]
samplesize=Fiddle::Function.new(libm['samplesize'],[Fiddle::TYPE_LONG,Fiddle::TYPE_DOUBLE,Fiddle::TYPE_DOUBLE,Fiddle::TYPE_VOIDP],Fiddle::TYPE_LONG)
session[:errmsg] = " ";
# session[:n], args = samplesize[ session[:nmax], session[:sigma_sq],
# session[:delta], session[:conf], session[:errmsg] ]
session[:n] = samplesize.call( session[:nmax], session[:delta],
session[:conf], session[:errmsg] )
but I got error:
unknown symbol "samplesize"
Extracted source (around line #34):
32 33 34 35 36 37 |
|
Rails.root: /Library/WebServer/smart
app/controllers/samplesize_controller.rb:34:in `[]' app/controllers/samplesize_controller.rb:34:in `compute' You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e23666a0-451d-4e90-a7e6-e1463748dade%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment