I need to call a DLL coded in C++ from my Fortran. The methods I need to call are object-oriented, and described in .h files. Here is the first 50 or so lines from one of the .h files:
#ifndef BBE_PVTT_BLACK_OIL_FLUID_H #define BBE_PVTT_BLACK_OIL_FLUID_H #include <PVTT/API/Model/Dll.h> #include <PVTT/API/Common/PVTTEnum.h> #include <PVTT/API/Common/PVTTBlackOilEnum.h> #include <PVTT/API/Common/BlackOilImpurities.h> #include <PVTT/API/Common/BlackOilComposition.h> #include <string> namespace BBE { namespace PVTT { namespace Common { class ErrorReport; } } } namespace BBE { namespace PVTT { namespace Impl { namespace Command { class BlackOilFluidCommand; } } } } namespace BBE { namespace PVTT { namespace Model { class BBE_PVTT_API_MODEL_DECL BlackOilFluid { public: BlackOilFluid(const std::string& name=""); BlackOilFluid(const BlackOilFluid&); BlackOilFluid& operator=(const BlackOilFluid&); ~BlackOilFluid(); bool operator==(const BlackOilFluid&) const; bool operator!=(const BlackOilFluid&) const; std::string GetName() const; void SetName(const std::string& name); // Set properties void SetOilAPI(double OilAPI); // setting oil API sets oil specific gravity and vice versa void SetOilSpecificGravity(double OilSpecificGravity); void SetGasSpecificGravity(double value, BBE::PVTT::Common::pvtEnumGasSpecGravCondition conditions= BBE::PVTT::Common::pvtCONDITION_STD); void SetSeparatorConditions(double separatorPressure, double separatorTemperature); void SetWaterSpecificGravity(double waterSpecificGravity); void SetWaterSalinity(double weightPercent); void SetImpurities(const BBE::PVTT::Common::BlackOilImpurities& impurities); void SetGasComposition(const BBE::PVTT::Common::BlackOilComposition& composition); void SetGasPpcTpc(double Ppc, double Tpc); void SetStockTankRelativeVolumes( double gas, double oil, double water ); void SetDeadOilViscosityCoefficientA( double coeffA ); void SetDeadOilViscosityCoefficientB( double coeffB ); void SetGasSpecificHeatCapacity( double gasCp ); void SetOilSpecificHeatCapacity( double oilCp ); void SetWaterSpecificHeatCapacity( double waterCp ); void SetGasThermalConductivity( double gasTc ); void SetOilThermalConductivity( double oilTc ); void SetWaterThermalConductivity( double waterTc ); void SetSpecificLatentHeatOfVaporization( double specificLatentHeatOfVaporization );
Ideally, I would like to wind up with Object-oriented Fortran code, where a call to one of the above methods uses standard Fortran 2003 syntax, somethig like
call fluid%SetOilApi(35.0d0) call fluid%SetSeparatorConditions(1d6,320d0)
To make this happen, I realize I need to create a Fortran INTERFACE definition to describe all the methods I need to call. But I have no real idea what this would look like ... or even if it is possible at all. Any pointers and/or advice to get me started, please?
Qolin