usnistgov / REFPROP-wrappers

Wrappers around NIST REFPROP for languages such as Python, MATLAB, etc.
195 stars 127 forks source link

Patch Mathematica wrapper (RefpropLink) to better locate NIST REFPROP DLL #583

Closed henningjp closed 8 months ago

henningjp commented 8 months ago

Several changes made to the RefpropLink paclet to better locate NIST REFPROP DLLs when installed in a non-standard location. Changes in Mathematica paclet structure caused method of storing path locations as resources was failing.

Changes include:

Testing

Additional Information

Related Issues

Fixes #581

henningjp commented 8 months ago

Hmm...

As in the comment above, the paclet will only load on Windows 64-bit and Mathematica 13+, for now.

Bitness

As of Mathematica 13, which the wrapper is limited to through the paclet, only 64-bit OS versions are supported. So we only need to search for the 64-bit REFPRP64 library.

OS Version

Mathematica 13+ supports Windows, MacOS, and various Linux versions. See MM13 System Requirements and MM14 System Requirements. I have no way to test MacOS or Linux versions (or Mathematica licenses to do so). However,

  1. Care was taken to use the OS independent file operation commands in Mathematica, so that any path operations should work on MacOS and Linux as well. Mathematica handles this nicely.
  2. The only pieces that could be problematic are:
    • The initialization of the $dllPath and $NISTPath variables to a Windows path structure, but this should be overwritten by either the $RPprefix setting or the paths set in the paclet resource file as set by SetDLL[] and/or SetPath[].
    • The inability to search the OS $Path for "REFPRP64.DLL" or "REFPROP64.so" (I'm relying solely on $RPprefix, which may not be set on Linux?)
    • If on Linux, the file needed would have a ".so" extension (I think) and on macOS (some other extension?)

That said, there is a note in the README.md that states (under Prerequisites):

NOTE: Development and testing of this wrapper has been entirely on a Microsoft Windows 
installation using Mathematica 13 and REFPROP 10. This wrapper should work on a Linux 
installation, but will require testing and may require some code modification. Care has been 
taken to ensure that the paclet code uses Mathematica's OS-independent file manipulation tools.  

However, I've actually tested it so far on Mathematica 13/14, Windows 10/11, and with REFPROP 9.1 and REFPROP 10.0.0.x. I'll update the README in a subsequent PR.

ianhbell commented 8 months ago

Shall we stop here with windows support and go for other platforms after?

henningjp commented 8 months ago

Yeah, maybe. If there's another patch needed, Windows is all I got.

I don't have a Linux box or a Mac to build and test it. I can probably set up a Linux box on some spare hardware, but I don't know if I can get a Mathematica license for it ($). I'll dig into it. I'm not getting a Mac anytime soon. We only use Mathematica at work on Windows, so that was the focus. So, unless we can find someone else to help out...

A NIST grant for hardware and licenses? 😆 🤣

ianhbell commented 8 months ago

Ok, I'll merge this one.

I don't think any additional support is forthcoming from my side because I think Mathematica is not one of the most popular interfaces of REFPROP.