LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing cray pointers to Fortran DLLs

I am building a vi to call a legacy Fortran program compiled as a DLL in order to build a front end in LabVIEW. I have made a snippet of the Fortran code (embedded below) that I can share showing the problem below. The Fortran DLL asks as an argument a pointer (str_ptr) to a structure which is then assigned like a Cray pointer i.e. pointer (str_ptr, Str_Consts). This requires the argument to be passed to the Fortran DLL in the form of an address location. I have passed the variables from a c wrapper code using &str_ptr as an argument while calling the function.

 

If I have a cluster in LabVIEW defining the data that forms the structure Fortran is expecting (say 3 numerical values), how do I pass the memory address location to the Fortran DLL? I am attaching a zip file containing the vi code and compiled dll along with the fortran code. I get an error as I am not able to determine how to send the memory address. Please suggest.

 

Fortran Code:

 

INTEGER FUNCTION LabviewTest  (I_Var, str_ptr) RESULT (DLLresult)

  !DEC$ ATTRIBUTES DLLEXPORT :: LabviewTest
  !DEC$ ATTRIBUTES ALIAS:'LabviewTest' :: LabviewTest

      IMPLICIT NONE

      INTEGER,INTENT(IN) :: I_Var
      REAL*8::Kr, Rho,Cp
      Type StrConsts
        SEQUENCE
            REAL*8 :: Kr  
            REAL*8 :: Rho    
            REAL*8 :: Cp
      END Type StrConsts
      
      pointer (str_ptr, Str_consts)
      type (StrConsts) :: Str_consts  

      Kr = Str_consts.Kr  
      Rho = Str_consts.Rho
      Cp = Str_consts.Cp

       DLLresult=5

END FUNCTION

 

0 Kudos
Message 1 of 1
(2,127 Views)