RefProp C# Interface – IRefProp64 Open Source Project

Background
Our company had an internal need to develop a RefProp C# interface that would enable calling the RefProp native FORTRAN methods from a Windows C# program. Discussions with the RefProp development team at NIST met with great enthusiasm and they helped guide us in the development of an open source project named IRefProp64, programs to quickly and easily call RefProp methods.

Overview
The IRefProp64 open source project consists of a .Net Assembly DLL (IRefProp64.dll) that can be added as a reference to Windows C# program to gain access to RefProp methods.
In addition, the project contains an example Windows C# program RefProp_CS_Examples.exe that contains three RefProp sample programs.

C# Source Code using IRefProp64 to Call RefProp Method SETPATHdll().

The following C# sample program with three tabs illustrates using the IRefProp64 C# interface to call RefProp methods.

RefProp_CS_Examples.exe – R404A Analysis (1 of 3)

 

RefProp_CS_Examples.exe – Natural Gas (2 of 3)

 

RefProp_CS_Examples.exe – Ex-Mix-Fortran (3 of 3)

Why the IRefProp64 C#/.Net Interface is Necessary
RefProp was initially written and is presently maintained in FORTRAN (since the 1970’s). It uses the Microsoft C-Runtime library to provide an interface for the FORTRAN routines to be called by native  C/C++ code.  However, C# (.Net) programs can not directly or easily interface to RefProp.

The diagram below shows the architecture of the C# interface to RefProp.

IRefProp64 – Block Diagram

The main difference between a C#/.Net program which runs in a “managed” environment, and an unmanaged native code program which runs in “unmanaged” environment (RefProp) is in how memory is allocated, released and formatted internally.  Each environment requires the data such as (such as strings, integers and doubles) be converted and managed in their own internal format. The process of converting the internal memory from a managed to unmanaged (and vice versa) is known as “marshaling”. Fortunately, IRefProp64 handles the task of marshaling of data via the Microsoft COM interface. For a more technical discussion, please see the Microsoft MSDN article Interoperating with Unmanaged Code.

Next Steps in Getting Started using the RefProp C# Interface…

  1. Download/run the sample RefProp_CS_Demo C# Windows programs binaries click here.
    (Visual Studio is not required)
  2. Watch our short quick start video C# Interface for REFPROP using IRefProp64.dll (below)
  3. Download the IRefProp64/RefProp_CS_Demo C# source code from NIST’s RefProp GitHub site and begin creating your C#/RefProp program

RefProp C# Tutorial Video
For a quick start tutorial on creating your own C#/.Net program that calls the native RefProp methods, please watch the following YouTube video:

 

If You Need Help
Mill Creek Systems, Inc. provides software development services and can help with your software project needs with including a RefProp C# interface (and in other areas). Please contact us for a complimentary discussion of your needs.

Comments are closed.

MENU