Fortran interface advice

Asked by Chris on 12 Jun 2012
Latest activity Answered by James Tursa on 14 Jun 2012

Hi,

I want to know what would be the best way to interface the following situation: The matlab code has the following data to be passed to a fortran code for calculations:

 TYPE, PUBLIC :: AeroConfig
      TYPE(Marker), ALLOCATABLE  :: Blade(:)
      REAL(ReKi)                 :: BladeLength
      TYPE(Marker)               :: Hub
      TYPE(Marker)               :: RotorFurl
      TYPE(Marker)               :: Nacelle
      TYPE(Marker)               :: TailFin
      TYPE(Marker)               :: Tower
      TYPE(Marker)               :: Substructure
      TYPE(Marker)               :: Foundation
   END TYPE AeroConfig

where type marker is:

   TYPE, PUBLIC :: Marker
      REAL(ReKi)                 :: Position(3)
      REAL(ReKi)                 :: Orientation(3,3)     
      REAL(ReKi)                 :: TranslationVel(3)
      REAL(ReKi)                 :: RotationVel(3)
   END TYPE Marker

The matlab code will pass the above information to the fortran code to be calculated(i.e. the blade component has 4 parts of the 3d vectors position, rotationvel, translationvel, and 3x3 matrix of oreintation) and then pass back the the following loads:

   TYPE, PUBLIC :: AllAeroLoads
      TYPE(Load),  ALLOCATABLE   :: Blade(:,:)
      TYPE(Load),  ALLOCATABLE   :: Hub(:)
      TYPE(Load),  ALLOCATABLE   :: RotorFurl(:)
      TYPE(Load),  ALLOCATABLE   :: Nacelle(:)
      TYPE(Load),  ALLOCATABLE   :: Tower(:)
      TYPE(Load),  ALLOCATABLE   :: Tail(:)
   END TYPE AllAeroLoads

where ,

   TYPE, PUBLIC :: Load
      REAL(ReKi)                 :: Force(3)
      REAL(ReKi)                 :: Moment(3)
   END TYPE Load

The above will be passed back to the matlab code. Any help or ideas is appreciated. Matlab doesn't have the TYPE construct and it seems a little tricky.

1 Comment

James Tursa on 13 Jun 2012

How do you want it on the MATLAB side ... as a struct?

Chris

Products

No products are associated with this question.

1 Answer

Answer by James Tursa on 14 Jun 2012

See this package and use the fpGetPr0, fpGetPr1, and fpGetPr2 functions to copy data into and out of the mxArray:

http://www.mathworks.com/matlabcentral/fileexchange/25934-fortran-95-interface-to-matlab-api-with-extras

0 Comments

James Tursa

Contact us