Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7855891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:31:09+00:00 2026-06-02T20:31:09+00:00

I have a function in a Fortran executable and I need to make it

  • 0

I have a function in a Fortran executable and I need to make it a dll file so I can call it’s functions from a C# program

      FUNCTION TSAT11(P) 
C     ** IGNORE IMPLEMENTATION **
      TSAT11 = SX*TSAT2(X) + SXL1*TSAT3-273.15 
      RETURN 
      END 

P is a float and the function returns a float

The thing here that I don’t know anything in fortran nor calling dlls from C#, so please explain a little more.

I’m using Compaq Visual Fortran and C# 2008.

Thank you for your time.

(If you like you can see the full code Here [It’s a program to calculate water and steam properties])

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:31:11+00:00Added an answer on June 2, 2026 at 8:31 pm

    Here is an example using single precision floats.

    Fortran library contains:

    FUNCTION TSAT11(P) 
    !DEC$ ATTRIBUTES ALIAS:'TSAT11' :: TSAT11
    !DEC$ ATTRIBUTES DLLEXPORT :: TSAT11
    !DEC$ ATTRIBUTES VALUE :: P
    REAL, INTENT(IN) :: P   
    REAL :: TSAT11
        ! Examle calculation
        TSAT11 = P - 273.15
    RETURN 
    END FUNCTION
    

    With the calling function

    class Program
    {
        [DllImport("calc.dll")]
        static extern float TSAT11(float P);
    
        static void Main(string[] args)
        {
            float p = 300f;
            float t = TSAT11(p);
            // returns 26.8500061
        } 
     }
    

    Similarly for an array (must declare the size)

    FUNCTION TSAT12(P,N) 
    !DEC$ ATTRIBUTES ALIAS:'TSAT12' :: TSAT12
    !DEC$ ATTRIBUTES DLLEXPORT :: TSAT12
    !DEC$ ATTRIBUTES VALUE :: N
    INTEGER, INTENT(IN) :: N
    REAL, INTENT(IN) :: P(N)
    REAL :: TSAT12
        ! Examle calculation
        TSAT12 = SQRT( DOT_PRODUCT(P,P) )
    RETURN 
    END FUNCTION
    

    with calling C# code

    class Program
    {
        [DllImport("calc.dll")]
        static extern float TSAT12(float[] P, int N);
    
        static void Main(string[] args)
        {
            float[] p2=new float[] { 0.5f, 1.5f, 3.5f };
            float t2=TSAT12(p2, p2.Length);
            //returns 3.84057283
        } 
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing code that will call a C function from Fortran using Fortran's C
I have this old Fortran executable that can only be accessed through its GUI,
Can anyone help with writing a semaphore function in fortran? I have multiple processes
I have function LoadTempMovieList(), and need to load movies from sessionStorage. But it seems
I have function getCartItems in cart.js and I want to call that function in
I have a problem with passing of an array from Fortran to a c
I am new in Fortan and have a question regarding using make callback-functions available
I am writing a program in Fortran and I need a way of calculating
I have one question with mixing C-string and fortran-string in one file. Supposed I
I have an old Fortran77 program that calls a C++ function and passes several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.