Giter VIP home page Giter VIP logo

Comments (5)

giordano avatar giordano commented on May 27, 2024

What's the API of the REFPROPdll function (is it really called like that?)? What are the types of hFld, hIn, hOut, iUnits, iMass, iFlag, a, b, z? Also, did you read https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/ including all the caveats about Fortran?

from julia.

sgaure avatar sgaure commented on May 27, 2024

I don't know the dll, but generally Fortran expects arguments to be passed by reference. I.e. a pointer to the data. So Cint, Cdouble etc. might be inappropriate. I would try to specify the type as Ptr{Cint} and pass it as Ref(iUnits) etc. What it does about strings I do not know. It depends, I suspect.

from julia.

inkydragon avatar inkydragon commented on May 27, 2024

It looks like the main problem is the lack of necessary parameters.

Doc for REFPROPdll

https://refprop-docs.readthedocs.io/en/latest/DLL/high_level.html#f/_/REFPROPdll

#define RP_SIZE_T std::size_t
#define REFPROPdll_ARGS \
    char *,char *,char *,INT_REF,INT_REF,INT_REF,DOUBLE_REF,DOUBLE_REF,\
    double *,double *,char *,INT_REF,double *,double *,double *,DOUBLE_REF,INT_REF,char *,\
    RP_SIZE_T,RP_SIZE_T,RP_SIZE_T,RP_SIZE_T,RP_SIZE_T

https://github.com/CoolProp/REFPROP-headers/blob/2f206de280a71752e163e4fa6aff2ff358f464ac/REFPROP_lib.h#L438

There are some wrappers written in other languages for reference:
https://github.com/usnistgov/REFPROP-wrappers

from julia.

eric-hintz avatar eric-hintz commented on May 27, 2024

What's the API of the REFPROPdll function (is it really called like that?)? What are the types of hFld, hIn, hOut, iUnits, iMass, iFlag, a, b, z? Also, did you read https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/ including all the caveats about Fortran?

The (Fortran) types of those parameters are char*, char*, char*, int, int, int, double, double, array(double)* respectively. I have read the docs, thanks for the link.

I don't know the dll, but generally Fortran expects arguments to be passed by reference. I.e. a pointer to the data. So Cint, Cdouble etc. might be inappropriate. I would try to specify the type as Ptr{Cint} and pass it as Ref(iUnits) etc. What it does about strings I do not know. It depends, I suspect.

Thanks for this advice, I messed around with parameter types and which to send as pointers and that got me past the error. I'm still having another error (read-only memory), but this was definitely an improvement.

It looks like the main problem is the lack of necessary parameters.

Doc for REFPROPdll

https://refprop-docs.readthedocs.io/en/latest/DLL/high_level.html#f/_/REFPROPdll

#define RP_SIZE_T std::size_t
#define REFPROPdll_ARGS \
    char *,char *,char *,INT_REF,INT_REF,INT_REF,DOUBLE_REF,DOUBLE_REF,\
    double *,double *,char *,INT_REF,double *,double *,double *,DOUBLE_REF,INT_REF,char *,\
    RP_SIZE_T,RP_SIZE_T,RP_SIZE_T,RP_SIZE_T,RP_SIZE_T

https://github.com/CoolProp/REFPROP-headers/blob/2f206de280a71752e163e4fa6aff2ff358f464ac/REFPROP_lib.h#L438

There are some wrappers written in other languages for reference: https://github.com/usnistgov/REFPROP-wrappers

I am confident I have the input parameters correct (except for type conversion), as I have worked with this DLL extensively in other languages. Most of those parameters you see in the #define result are outputs, not inputs.

Apologies for the screenshot, but here are the parameters defined in the documentation:
image

from julia.

Keno avatar Keno commented on May 27, 2024

As pointed out by @inkydragon, the ABI appears incorrect. This isn't really the kind of thing you can't just guess at. In particular different fortran compilers will sometimes implement ABIs differently, so the documention is not sufficient to determine the ABI. @inkydragon's reference to the C headers is likely your best bet for translation. Regardless, this is not a bug, so future discussion on this is best had at https://discourse.julialang.org/.

from julia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.