jowr / librefprop.so

Create a shared library from the Fortran sources provided by Refprop from NIST. This project provides an alternative to the refprop.dll that comes with the software. Please use the official instructions if possible
https://github.com/usnistgov/REFPROP-cmake
32 stars 8 forks source link

[Fortran libraries on mac OS X 10.8.5 and linked with Matlab 64 bits] #25

Open tonkiplis opened 9 years ago

tonkiplis commented 9 years ago

Fortran

So I managed quite easily to compile the fortran libraries on : Mac OS X 10.8.5.

The important features of my system are:

and I followed the installation instructions indicated on : https://github.com/jowr/librefprop.so everything worked fine until I called make fortest (in order to test the installation), the logs I got are :

make fortest %----------------------------- gfortran -O3 -ffast-math -fPIC -g -o ./src/ex_mix.o -c ./src/ex_mix.for gfortran -g -o ./bin/ex_mix_for ./src/ex_mix.o -lrefprop -lgfortran _Undefined symbols for architecture x86_64: "start", referenced from: -u command line option ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status make: [bin/ex_mixfor] Error 1 %-----------------------------

To make it work, I had to change it to:

%----------------------------- gfortran -O3 -ffast-math -fPIC -g -o ./src/ex_mix.o -c ./src/ex_mix.for gfortran -g -o ./bin/ex_mix_for ./src/ex_mix.o -lrefprop -lgfortran -lcrt1.o %----------------------------- Note: This can be done directly in the Makefile in the line 336.

and then it compiled properly. I don't know exactly why, I found on the web it has to do with some static libraries which are not linked without this option, but I am not a specialist.... Afterward I could execute ./bin/ex_mix_for without any problem.

I hope this can help some users of Mac OS...

Matlab

Then, I wanted to get the Integration with Matlab For sake of completeness I have a 64 bit installation (MATLAB_R2011a). I performed the steps as indicated on: https://github.com/jowr/librefprop.so

  1. The first step of the manual work (as indicated during the make matlab) went w/o problem.
  2. Then the second step:

    Open Matlab, and run: "cd /Users/thierrymeier/Documents/MATLAB/PhD/refProp9.1/librefprop.so-master/matlab;" "run('thunk.m');" proceed by pressing ENTER.

    _rm matlab/refpropm.m.org matlab/rpproto64.m.org

There I had a problem while running thunk.m, as I currently have two gcc compiler installed ( Apple LLVM version 5.1 and gcc4.8.1) but none of them correspond exactly to gcc-4.2. Thus I created a symlink:

sudo ln -s /usr/bin/gcc /usr/bin/gcc4.2

and it worked (I know its a little bit brute force but as a first shot...).

  1. I ran the sudo make matlab-install and the matlab function and the libraries were successfully copied in /opt/refprop as expected.
  2. running path(path, '/opt/refprop') permits to have a system wide use of the refprop functions.
  3. As I run test.m the refpropm function is called and Matlab crashes.... The log I get:

%----------------------------- _Process: MATLAB [2368] Path: /Applications/MATLABR2011a.app/Contents/MacOS/StartMATLAB Identifier: com.mathworks.matlab Version: MATLAB Release 2011a (2.1) Code Type: X86-64 (Native) Parent Process: launchd [127] User ID: 501

Date/Time: 2015-04-22 12:05:40.073 +0200 OS Version: Mac OS X 10.8.5 (12F2518) Report Version: 10

Interval Since Last Report: 149802 sec Crashes Since Last Report: 4 Per-App Interval Since Last Report: 14710 sec Per-App Crashes Since Last Report: 3 Anonymous UUID: 0FA54308-2534-36FE-FC59-4636403F2392

Crashed Thread: 3

Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000002, 0x0000000000000000

_Dyld Error Message: Symbol not found: __gfortran_transfer_character_write Referenced from: /opt/refprop/librefprop.dylib Expected in: /Applications/MATLABR2011a.app/sys/os/maci64/libgfortran.3.dylib %-----------------------------

suggests a problem with the dylib library. To overcome it, I read the thread on w3.mathworks.com (here) where Nathan suggest to rename the DYLIB fil in the MATLAB application directory and create a symlink with the one located in /usr/local/lib: ln -s /usr/local/lib/libgfortran.3.dylib /Applications/MATLAB_R2011a.app/sys/os/maci64/libgfortran.3.dylib

and then everything works. I hope this can help some users of Mac OS... I am not sure whether it is the nicest solution to do it, but who cares?

Cheers,

Tonkiplis

jowr commented 9 years ago

Hi, thank you very much for reporting this. Do you think you could integrate your experience into the readme.md and file a pull request?

tonkiplis commented 9 years ago

Hi, yes I'll try to do it tonight.

jowr commented 9 years ago

Great, let me know if you have any trouble and I can try to help you.

tonkiplis commented 9 years ago

Hello Jorrit, I was just wondering whether there is a procedure to implement the fortran library for the dielectric constant of water. In fact, this property is not directly available in the refpropm.m function. Have a nice weekend,

jowr commented 9 years ago

Hm, I could have a look. How do you get the values out in, let's say, FORTRAN? If you know how to do it, feel free to add it to your pull request. Nice weekend to you too!