470,614 Members | 1,572 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,614 developers. It's quick & easy.

Convert Fortran to C#

Hello.

I have one small program which I need to convert in C#.
The original source codes are written in Fortran 77.
Can anybody advice me what is the easy way to do this task?
Or may be there is some tools for it?

Thank you.
Nov 17 '05 #1
3 10856
> I have one small program which I need to convert in C#.

Csharp is object oriented.
The original source codes are written in Fortran 77.
This is a procedural language
Can anybody advice me what is the easy way to do this task?


There is no easy way but it should not be too hard since you can test
your program versus the Fortran compiled one..

--
----
http://michael.moreno.free.fr/

Nov 17 '05 #2
My suggestion: create a procedural C# app by creating an app with a single
class. In your fortran app, each function call becomes a public method of
the class. The global variables become class-level variables (that you
create in your constructor). Create a 'main' method for the main function
in your Fortran app.

Then, if your project is a win-form app, have one of your controls create
this object and run the main method. If your project is a console app, have
the console app simply create the object and run the main method.

Input and output will be your biggest issues. Depending on how flexible you
want your app to be, I'd suggest you create a pair of interfaces, for an
Input object and an Output object. In your constructor, pass in objects
that implement the input and output interfaces. That way, you can change
how the input and output works by changing the object you pass in, without
affecting the Fortran app.

Note that Fortran was pretty specific about the way it performed math
operations. If your particular Fortran app does math operations, test
carefully (especially boundary conditions) to make sure that your C# app
operates in the same way. Look carefully at the data types that you use to
represent the values you are calculating. That can change the semantics of
math functions.

Hope this helps,
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"David Dvali" <da*********@hotmail.com> wrote in message
news:u3**************@TK2MSFTNGP14.phx.gbl...
Hello.

I have one small program which I need to convert in C#.
The original source codes are written in Fortran 77.
Can anybody advice me what is the easy way to do this task?
Or may be there is some tools for it?

Thank you.

Nov 17 '05 #3
A lot depends on how the FORTRAN application was written. If is used
multiple entry or exit points for functions, it is going to be pretty rough
going.

Your best be is using a CLR version of FORTRAN. For example:
http://www.silverfrost.com/11/ftn95/overview.asp

--
Jonathan Allen
"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:jN********************@comcast.com...
My suggestion: create a procedural C# app by creating an app with a single
class. In your fortran app, each function call becomes a public method of
the class. The global variables become class-level variables (that you
create in your constructor). Create a 'main' method for the main function
in your Fortran app.

Then, if your project is a win-form app, have one of your controls create
this object and run the main method. If your project is a console app,
have the console app simply create the object and run the main method.

Input and output will be your biggest issues. Depending on how flexible
you want your app to be, I'd suggest you create a pair of interfaces, for
an Input object and an Output object. In your constructor, pass in
objects that implement the input and output interfaces. That way, you can
change how the input and output works by changing the object you pass in,
without affecting the Fortran app.

Note that Fortran was pretty specific about the way it performed math
operations. If your particular Fortran app does math operations, test
carefully (especially boundary conditions) to make sure that your C# app
operates in the same way. Look carefully at the data types that you use
to represent the values you are calculating. That can change the
semantics of math functions.

Hope this helps,
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Al | last post: by
26 posts views Thread by sam | last post: by
11 posts views Thread by redefined.horizons | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.