Hi Andreas I just wanted to show the code that is now working: thanks again!. ============ module LebedevLaikov export ld ld=Dict() ldsyms=[ "ld0006", "ld0014", "ld0026", "ld0038", "ld0050", "ld0074", "ld0086", "ld0110", "ld0146", "ld0170", "ld0194", "ld0230", "ld0266", "ld0302", "ld0350", "ld0434", "ld0590", "ld07\ 70", "ld0974", "ld1202", "ld1454", "ld1730", "ld2030", "ld2354", "ld2702", "ld3074", "ld3470", "ld3890", "ld4334", "ld4802", "ld5294", "ld5810"] ldfuns=[ :ld0006, :ld0014, :ld0026, :ld0038, :ld0050, :ld0074, :ld0086, :ld0110, :ld0146, :ld0170, :ld0194, :ld0230, :ld0266, :ld0302, :ld0350, :ld0434, :ld0590, :ld0770, :ld0974, :ld1\ 202, :ld1454, :ld1730, :ld2030, :ld2354, :ld2702, :ld3074, :ld3470, :ld3890, :ld4334, :ld4802, :ld5294, :ld5810] ld=Dict() for (sym,fn) in zip(ldsyms,ldfuns) nld=int32(sym[3:end]) @eval begin function $(fn)() X,Y,Z,W=zeros($nld),zeros($nld),zeros($nld),zeros($nld) N=0 ccall( ($(sym*"_"),"Lebedev-Laikov.so"),Void,(Ptr{Float64},Ptr{Float64},Ptr{Float64},Ptr{Float64},Ptr{Int32}),X,Y,Z,W,&N) return X,Y,Z,W,N end ld[$(nld)]=$(fn) end end end
On Wednesday, 1 October 2014 16:12:36 UTC+2, Andreas Noack wrote: > > The error message gives a hint > > ERROR: type: fun: in ccall: first argument not a pointer or valid constant >> expression, expected DataType, got Type{(Any...,)} > > > The symbol name must be constant. Maybe you can get what you want by using > the @eval macro. Have a look in linalg/blas.jl or linalg/lapack.jl where > many fortran function are called. > > Med venlig hilsen > > Andreas Noack > > 2014-10-01 2:12 GMT-04:00 moritz braun <moritz...@gmail.com <javascript:>> > : > >> Dear Friends >> >> I want to wrap a fortran code that provides the Lebedev-Laikov quadrature >> points and weights for >> 32 different orders for 6 to 5810! >> >> I have tried it with the following code >> for a file LebedevLaikov.jl >> =================== >> module LebedevLaikov >> export ldfuns >> ldnames={:ld0006_, :ld0014_, :ld0026_, :ld0038_, :ld0050_, :ld0074_, >> :ld0086_, :ld0110_, :ld0146_, :ld0170_, :ld0194_, :ld0230_, :ld0266_, >> :ld0302_, :ld0350_, :ld0434_, :ld0590_, :ld0770_, :ld0974_, :ld1202_, >> :ld1454_, :ld1730_, :ld2030_, :ld2354_, :ld2702_, :ld3074_, :ld3470_, >> :ld3890_, :ld4334_, :ld4802_, :ld5294_, :ld5810_} >> >> ldns=[6,14,26,38,50,74,86,110,146,170,194,230,266,302,350,434,590,770,974,1202,1454,1730,2030,2354,2702,3074,3470,3890,4334,4802,5294,5810] >> println( length(ldns)," ",length(ldnames)) >> nl=length(ldnames) >> # factory function for creating a function for each case! >> function ldfact() >> funs=Dict() >> for i in [1:nl] >> name=ldnames[i] >> ldn=ldns[i] >> function fun() >> X,Y,Z,W=zeros(ldn),zeros(ldn),zeros(ldn),zeros(ldn) >> N=0 >> ccall( >> (name,"Lebedev-Laikov.so"),Void,(Ptr{Float64},Ptr{Float64},Ptr{Float64},Ptr{Float64},Ptr{Int32}),X,Y,Z,W,&N) >> >> >> return X,Y,Z,W,N >> end >> funs[ldn]=fun >> end >> return funs >> end >> ldfuns=ldfact() >> end >> == >> in the interactive julia session >> using LebedevLaikov >> works >> however >> ldfuins[110]() >> results in the error message >> ERROR: type: fun: in ccall: first argument not a pointer or valid >> constant expression, expected DataType, got Type{(Any...,)} >> in fun at /home/braunm/bfuns/julia/LebedevLaikov.jl:16 >> >> I am somehow stack with supplying the symbol of the function via a >> variable instead of >> in place >> Any help will be very much appreciated! >> >> Thanks a lot to all the magicians that have made julia already so >> amazing! >> >> regards >> >> Moritz >> >> >