Sergey Kucher
Sergey Kucher

Reputation: 4180

Call fortran code from c#

A have a lot of code written in FORTRAN 77. I want start developing with c# using that code. What should I do?

  1. Import FORTRAN DLLs into managed code
  2. Convert the code

For each of the options, could you please tell me how to do it. Is there any performance problem with first one?

Thank you.

Upvotes: 5

Views: 930

Answers (4)

GregC
GregC

Reputation: 8007

I side with Achim. For example, AMD is developing and supporting a linear algebra toolkit, written in FORTRAN 90, with a C-style interface available. With FORTRAN 77 YMMV

Upvotes: 3

Darin Dimitrov
Darin Dimitrov

Reputation: 1038780

Option 1 is good if you have a lot of unmanaged code that you don't have time to migrate. If you go that route, make sure to perform as few calls to unmanaged methods as possible, even if those calls involve sending larger arguments/results as marshaling between managed/unmanaged world could harm performance.

Option 2 is fine, you will end up converting everything to managed code. Assuming this code is written properly, it could perform at least as fast as the unmanaged code.

Upvotes: 2

Achim
Achim

Reputation: 15702

See http://msdn.microsoft.com/en-us/library/26thfadc.aspx. I would go for option 1. In most cases it will be less work and produce better performance, assuming that you use Fortran for number crunching.

Upvotes: 5

pm100
pm100

Reputation: 50170

there is a commercial Fortran .net compiler

Upvotes: 3

Related Questions