473,699 Members | 2,226 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11461
> 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*********@ho tmail.com> wrote in message
news:u3******** ******@TK2MSFTN GP14.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*******@hotm ail.nospam.com> wrote in message
news:jN******** ************@co mcast.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
3402
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 application in Python without using prebuilt numerical libraries and data objects such as dictionaries and lists. I have been experimenting with numerical algorithms in Python with a heavy use of the Numeric module. My experience is that Python...
15
2091
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: http://www.acmqueue.com/modules.php?name=Content&pa=showpage&pid=271&page=1 The section specifically on white space: http://www.acmqueue.com/modules.php?name=Content&pa=showpage&pid=271&page=3 Cheers,
5
6026
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
6429
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 the array in fortran and then accessing it in my c++ code. Say in my c++ code I have; extern "C" { void foo_(float **, int &, int &); }
2
3319
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 the 3D arrays, the values passed are not all the same. I am also pasting the fortran and c++ codes so that you could have a look at them. ////C++ Code
81
7305
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 be any advantage in having strcat and strcpy return a pointer to the "end" of the destination string rather than returning a
26
13554
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
15188
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 the caller of the function to have to pass floats instead of integers. How do I convert the arguments passed to the function into floats before I do the division? Is this necessary, or is their a better way? Thanks, Scott Huey
2
4432
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 * len(id) # id is a list of strings Id_dat=StringVector() for i in range(len(Id)): ....Id_dat=id
0
8689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7752
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2348
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.