473,378 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 11417
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: Carl | last post by:
"Nine Language Performance Round-up: Benchmarking Math & File I/O" http://www.osnews.com/story.php?news_id=5602 I think this is an unfair comparison! I wouldn't dream of developing a numerical...
15
by: Nick Coghlan | last post by:
Thought some folks here might find this one interesting. No great revelations, just a fairly sensible piece on writing readable code :) The whole article:...
5
by: Al | last post by:
I am about to start rewriting a fortran program to ansi C++. Would it be best to convert the variables that are 'real' to float? double? long double?
1
by: Sam | last post by:
Hello all I have a two dimensional array (the dimensions are not known) that needs to be passed to fortran from c++, allocate the dimensions of the array in fortran code, do some filling up of...
2
by: NM | last post by:
Hello all, I am supposed to do some mixed programming with c++ and fortran. I was succeeful in exchanging the 2D arrays from fortran to c++ and the other way, but was unable to that same with...
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
26
by: sam | last post by:
Hi, Can anyone help me find a software that can convert a code in 'C' to 'Fortran77/90' automatically? Thanks in advance. Sam.
11
by: redefined.horizons | last post by:
I'm still pretty new to Python. I'm writing a function that accepts thre integers as arguments. I need to divide the first integer by te second integer, and get a float as a result. I don't want...
2
by: luis | last post by:
I'm using ctypes to call a fortran dll from python. I have no problems passing integer and double arryas, but I have an error with str arrys. For example: ..... StringVector = c_char_p *...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.