usnistgov / REFPROP-cmake

Small repo with CMake build system for building REFPROP shared library
49 stars 27 forks source link

Problems with cmake on Centos and calling refmatpy function in Matlab #102

Open hohiroki opened 3 weeks ago

hohiroki commented 3 weeks ago

I carried out cmake according to the instructions. The result was shown to be completed, and.so and.h files were generated under the ‘build’ folder. However, some warnings appeared during the compilation process. I am not sure if these warnings are normal.

After the compilation ends, I copied the FLUID and MIXTURE folders in REPPROP10 to the ‘build’ folder. And I tried to call REFPROP in Matlab.

However, when I opened the Matlab software and conducted a test, some problems occurred. Calling the reefmatpy file does not give the correct result. The program does not report an error, but instead gives NAN.

Below are the information about my compilation process and the process of calling Matlab.

OS:Centos7 Python3.10 Matlab2024

The matlab problem

RP = py.ctREFPROP.ctREFPROP.REFPROPFunctionLibrary('/public3/home/sc54911/software/REFPROP10/build') RP.RPVersion() ans = Python str with no properties. 10.0 setGlobalrefmatpy [h1] = refmatpy('ammonia','TP','H',290,4500e3,{1}) h1 = NaN [h1] = refmatpy('CO2','TP','H',290,4500e3,{1}) h1 = NaN

The cmake info

cd /public3/home/sc54911/software/REFPROP10
[sc54911@o1715 build]$ module load cmake/3.20.2-public3
[sc54911@o1715 build]$ cmake .. -DCMAKE_BUILD_TYPE=Release
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 4.8.5
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /usr/bin/gfortran - skipped
CMake Warning (dev) at CMakeLists.txt:6 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found PythonInterp: /public3/home/sc54911/.conda/envs/mtpy/bin/python (found version "3.10.15")
-- DEFSYM_FLAG: --using-defsym
-- Configuring done (12.4s)
-- Generating done (0.1s)
-- Build files have been written to: /public3/home/sc54911/software/REFPROP10/build
(mtpy) [sc54911@o1715 build]$ cmake --build .
[  6%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/CORE_ANC.FOR.o
/public3/home/sc54911/software/REFPROP10/FORTRAN/CORE_ANC.FOR:832.4:

 500  if (ierr.gt.0) P=0d0                                              
    1
Warning: Label 500 at (1) defined but not used
[ 12%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/CORE_FEQ.FOR.o
[ 18%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/CORE_PR.FOR.o
[ 25%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/FLSH_SUB.FOR.o
/public3/home/sc54911/software/REFPROP10/FORTRAN/FLSH_SUB.FOR:1116.4:

 223  call ERRNUM (223,0,ab//'FLSH',herr1,0d0,0d0,0d0,ierr,herr)        
    1
Warning: Label 223 at (1) defined but not used
[ 31%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/MIX_HMX.FOR.o
/public3/home/sc54911/software/REFPROP10/FORTRAN/MIX_HMX.FOR:384.4:

 400  if (iModMx2(i,j).eq.iMxTr) then                                   
    1
Warning: Label 400 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/MIX_HMX.FOR:1170.4:

 907  call ERRNUM (-907,0,' ',' ',0d0,0d0,0d0,ierr,herr)                
    1
Warning: Label 907 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/MIX_HMX.FOR:1319.72:

        hIDijk=LTRIM(h255(:i-1))                                        
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (15/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/MIX_HMX.FOR:1678.4:

 118  call ERRNUM (118,0,'RDBNC',' ',0d0,0d0,0d0,ierr,herr)!Abnormal ter
    1
Warning: Label 118 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/MIX_HMX.FOR:2144.72:

      hmodij=hmodMx(i,j)                                                
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (3/255) at (1)
[ 37%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/PROP_SUB.FOR.o
/public3/home/sc54911/software/REFPROP10/FORTRAN/PROP_SUB.FOR:4343.72:

          h7oper(n1)=hb      !The array h7oper is used only for debuggin
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (15/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/PROP_SUB.FOR:4559.72:

 605  her='Unknown input:  '//hb                                        
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (255/271) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/PROP_SUB.FOR:4571.72:

 632  her='Missing or incorrect entry in coefficients:  '//ha           
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (255/300) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/PROP_SUB.FOR:309.30:

      character*255 herr,herr2                                          
                              1
Warning: Unused variable 'herr2' declared at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/PROP_SUB.FOR:310.26:

      dimension z(ncmax),y(ncmax)                                       
                          1
Warning: Unused variable 'y' declared at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/PROP_SUB.FOR:359.30:

      character*255 herr,herr2                                          
                              1
Warning: Unused variable 'herr2' declared at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/PROP_SUB.FOR:360.26:

      dimension z(ncmax),y(ncmax)                                       
                          1
Warning: Unused variable 'y' declared at (1)
[ 43%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/REFPROP.FOR.o
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:5589.72:

         if (ABS(iErrPrnt).eq.3) pause           !If your compiler compl
                                                                        1
Warning: Deleted feature: PAUSE statement at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:2726.4:

 500  iPass=1                                                           
    1
Warning: Label 500 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:2564.4:

 100  if (iIn.eq.4 .or. iIn.eq.5) then                                  
    1
Warning: Label 100 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:4812.14:

      iUUnits=0d0                                                       
              1
Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:4105.4:

 100  RETURN                                                            
    1
Warning: Label 100 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:3545.72:

      hTpe=UCASE(hUnitType)                                             
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (3/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:4151.12:

      iEnum=xerr                                                        
            1
Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1616.4:

 853  if (ip.ne.0) call ERRNUM (853,0,ha,' ',0d0,0d0,0d0,ierr1,herr1)!Er
    1
Warning: Label 853 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1364.10:

      icl=xnotc    !Component index for when a single component property
          1
Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1391.18:

              icl=xnotd                                                 
                  1
Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1442.72:

        hUnitsArray(n)=ha              !Save the property name.         
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1446.16:

            icl=xnotd                  !Say goodbye to icl.             
                1
Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1510.72:

        if (ip.eq.iprpNAME)         hUnitsArray(n)=hname(ij)            
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1511.72:

        if (ip.eq.iprpLONGNAME)     hUnitsArray(n)=hnam80(ij)           
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1512.72:

        if (ip.eq.iprpSYNONYM)      hUnitsArray(n)=hsyn(ij)             
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1513.72:

        if (ip.eq.iprpFAMILY)       hUnitsArray(n)=hfamily(ij)          
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1517.72:

        if (ip.eq.iprpSAFETY)       hUnitsArray(n)=hSafety(ij)          
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1518.72:

        if (ip.eq.iprpUNNUMBER)     hUnitsArray(n)=hUNNumb(ij)          
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1520.72:

        if (ip.eq.iprpINCHIKEY)     hUnitsArray(n)=hInChiKey(ij)        
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1521.72:

        if (ip.eq.iprpCHEMFORM)     hUnitsArray(n)=hChemF2(ij)          
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1522.72:

        if (ip.eq.iprpFULLCHEMFORM) hUnitsArray(n)=hChemF1(ij)          
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1523.72:

        if (ip.eq.iprpFLDNAME)      hUnitsArray(n)=hFldFileName(ij)     
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1528.72:

            hUnitsArray(n)=hSwap                                        
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1533.72:

            hUnitsArray(n)=hSwap                                        
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1539.72:

          hUnitsArray(n)=hSwap                    !Send back the directo
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1544.72:

          hUnitsArray(n)=hSwap                                          
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1561.72:

          hUnitsArray(n)=LTRIM(herr(i+1:))       !Remove the part up to 
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:2216.4:

 900  ierr=ierr1                                                        
    1
Warning: Label 900 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:1600.72:

            hUnitsArray(k)=ha                                           
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (50/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:5377.4:

 100  if (iPReos.ne.iPRold) then                                        
    1
Warning: Label 100 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:5347.72:

      hFl=hFldOld                                                       
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (255/10000) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:2879.4:

 998  if (nc.gt.1) then                                                 
    1
Warning: Label 998 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:2872.4:

 555  iFlg=555                                                          
    1
Warning: Label 555 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:5086.72:

        hPhase='Error code missing: '//hPhase                           
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (255/275) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:2746.41:

      subroutine REFSET2 (io,iMass,x,y,x3,q,Output,hU,ierr,herr)        
                                         1
Warning: Unused dummy argument 'x3' at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/REFPROP.FOR:5156.41:

      character herr*255,hFldIn*(*),UCASE                               
                                         1
Warning: Unused variable 'ucase' declared at (1)
[ 50%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/SAT_SUB.FOR.o
/public3/home/sc54911/software/REFPROP10/FORTRAN/SAT_SUB.FOR:370.4:

 220      itx1=itx1+1                                                   
    1
Warning: Label 220 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/SAT_SUB.FOR:2428.3:

 25     if (D.lt.Dinc/10d0 .and. idir.eq.1) then                        
   1
Warning: Label 25 at (1) defined but not used
[ 56%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/SETUP.FOR.o
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:1438.72:

      hrf2=UCASE(hrf)                                                   
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (3/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:1283.72:

      htype2=UCASE(htype)                                               
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (3/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:1284.72:

      hmix2=UCASE(hmix)                                                 
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (3/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:1286.72:

        hcomp2(i)=UCASE(hcomp(i))                                       
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (3/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:721.72:

                hAltID(i)  =hstr                 !Alternate fluid ID num
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (15/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:725.72:

                hash(i)=hstr                                            
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (10/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:746.72:

      if (hash(i).eq.' ') hash(i)=hcas(i)                               
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (10/12) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:758.72:

        hflag=UCASE(hflag)                                              
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (3/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:759.72:

        htype=UCASE(htype)                                              
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (3/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:2503.72:

          h15=LTRIM(h15)                                                
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (15/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/SETUP.FOR:1905.72:

      htyp=UCASE(htype)                                                 
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (3/255) at (1)
[ 62%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/TRNSP.FOR.o
[ 68%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/TRNS_TCX.FOR.o
[ 75%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/TRNS_VIS.FOR.o
[ 81%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/UTILITY.FOR.o
/public3/home/sc54911/software/REFPROP10/FORTRAN/UTILITY.FOR:184.72:

        hnam=hname(ABS(icomp))                                          
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (12/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/UTILITY.FOR:186.72:

        hn80=hnam80(ABS(icomp))                                         
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (80/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/UTILITY.FOR:943.72:

              herr=ha        !String contains more information than the 
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (255/10000) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/UTILITY.FOR:4440.72:

      htyp1=UCASE(htyp)                                                 
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (3/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/UTILITY.FOR:2495.4:

 500  if (iFlags(1).eq.1 .or. iFlags(6).eq.1) then         !Move slots 2
    1
Warning: Label 500 at (1) defined but not used
/public3/home/sc54911/software/REFPROP10/FORTRAN/UTILITY.FOR:3538.72:

      ab2=UCASE(ab)                                                     
                                                                        1
Warning: CHARACTER expression will be truncated in assignment (2/255) at (1)
/public3/home/sc54911/software/REFPROP10/FORTRAN/UTILITY.FOR:4152.4:

 520  if (INDEX(UCASE(hFl),'.FLD').eq.0) then                           
    1
Warning: Label 520 at (1) defined but not used
[ 87%] Building Fortran object CMakeFiles/refprop.dir/FORTRAN/DLLFILES/PASS_FTN.FOR.o
[ 93%] Linking Fortran shared library librefprop.so
[ 93%] Built target refprop
[100%] About to build the REFPROP.h header file w/ /public3/home/sc54911/.conda/envs/mtpy/bin/python;-u;/public3/home/sc54911/software/REFPROP10/externals/REFPROP-headers/generate_header.py;--FORTRAN-path;/public3/home/sc54911/software/REFPROP10/FORTRAN/DLLFILES;--python-exe;/public3/home/sc54911/.conda/envs/mtpy/bin/python
Writing the .pyf file with numpy.f2py, please be patient...
About to run: /public3/home/sc54911/.conda/envs/mtpy/bin/python -m numpy.f2py --quiet --no-lower -h REFPROP.pyf /public3/home/sc54911/software/REFPROP10/FORTRAN/DLLFILES/PASS_FTN.FOR
numpy version: 1.21.6
Deleting REFPROP.pyf
[100%] Built target REFPROP_H
(mtpy) [sc54911@o1715 build]$ 
ianhbell commented 3 weeks ago

The warnings are benign. But the NaN are not. Can you try with the native python interface to make sure that works?

hohiroki commented 1 week ago

The warnings are benign. But the NaN are not. Can you try with the native python interface to make sure that works?

Thank you for your suggestion.

I think I've found the cause of the problem.

Following your suggestion, I conducted tests using Python and found that the compiled Refprop could be normally called through Python and output results. image

Comparing with the code in setGlobalrefmatpy.m, it seems that there is a line of statement defining the dynamic link path missing. RP.SETPATHdll('/public3/home/sc54911/software/REFPROP10/build')

After adding this line to the code, the above code can output results normally. It should be noted that the installation address of REFPROP needs to be replaced. image

Thanks again!

ianhbell commented 6 days ago

Yes, that is true, a hard-coded path should not be used. Better would have been to read an environment variable called RPPREFIX.

ianhbell commented 5 days ago

Or even better, to allow the path to be an argument to the global setter, with default argument of what it is currently.

ianhbell commented 3 days ago

My colleague made the necessary changes and I pushed them: https://github.com/usnistgov/REFPROP-wrappers/commit/dbb216637dbda2c65abdf9447308785a33545652