473,763 Members | 7,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert 'C' code to 'Fortran'

sam
Hi,
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?

Thanks in advance.

Sam.
Nov 14 '05
26 13569
Chris Barts <ch************ @gmail.com> wrote in message news:<S9******* *************@o newest.net>...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Mair wrote:
| sam wrote:
|
|> Hi,
|> Can anyone help me find a software that can convert a code in 'C'
|> to 'Fortran77/90' automatically?
|
|
| This is not really on-topic.
| However, there is a slightly more topical version: Why fix something
| that is not broken?

Maybe because the Fortran compiler's optimization is better than the
platform's C compiler. Or to make calling the code from Fortran easier.
Or a small number of other possible reasons.

Obviously, going the other way is a lot more common. The Fortran FAQ
I'll link to later says that there aren't any tools to automate the c2f
conversion.


That FAQ at http://www.faqs.org/faqs/fortran-faq/
is almost 8 years old and is thus out of date. The OP posted the same
message to comp.lang.fortr an (a breach of etiquette), where I
mentioned a Fortran 90 program C2F at
http://home.cfl.rr.com/davegemini/c2f.f90 as a PARTIAL translator from
C to Fortran. I earlier wrote about it at
http://groups.google.com/groups?q=be...gle.com&rnum=1
..

The c.l.f crowd agrees with the c.l.c crowd that translation (as
opposed to linking) is probably not the way to go.
Nov 14 '05 #11
Chris Barts <ch************ @gmail.com> writes:
Michael Mair wrote:
|> Can anyone help me find a software that can convert a code in 'C'
|> to 'Fortran77/90' automatically?
|
| This is not really on-topic.
| However, there is a slightly more topical version: Why fix something
| that is not broken?

Maybe because the Fortran compiler's optimization is better than the
platform's C compiler. Or to make calling the code from Fortran easier.
Or a small number of other possible reasons.


I'm skeptical that optimization is a good reason to convert C to
Fortran. Leaving pointer issues aside (and I think recent versions of
Fortran have something similar to pointers), automatically generated
Fortran is likely to be ugly and difficult to optimize.

If you want to be able to maintain the Fortran code, the best tool for
the job is probably a programmer who knows both C and Fortran and is
willing to do it for what you can afford to pay.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #12
In <e3************ **************@ posting.google. com> at*****@gmail.c om (sam) writes:
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?


Converting from a lower level language to a higher level language is
seldom possible. Only a subset of C could be converted to Fortran
automatically.

The comp.lang.fortr an FAQ might have some pointers.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union
Nov 14 '05 #13
In <ln************ @nuthaus.mib.or g> Keith Thompson <ks***@mib.or g> writes:
Chris Barts <ch************ @gmail.com> writes:
Michael Mair wrote:
|> Can anyone help me find a software that can convert a code in 'C'
|> to 'Fortran77/90' automatically?
|
| This is not really on-topic.
| However, there is a slightly more topical version: Why fix something
| that is not broken?

Maybe because the Fortran compiler's optimization is better than the
platform's C compiler. Or to make calling the code from Fortran easier.
Or a small number of other possible reasons.
I'm skeptical that optimization is a good reason to convert C to
Fortran. Leaving pointer issues aside (and I think recent versions of
Fortran have something similar to pointers),


Not quite. It's similar to Pascal pointers: you can't perform pointer
arithmetic on them.
automaticall y generated
Fortran is likely to be ugly and difficult to optimize.


Ugly to the human eye doesn't necessarily imply difficult to optimize for
the Fortran compiler. It is basically the strict aliasing rules of
Fortran that allow Fortran optimisers to be (significantly) more
aggressive than C optimisers.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union
Nov 14 '05 #14
at*****@gmail.c om (sam) wrote in message news:<e3******* *************** ****@posting.go ogle.com>...
Hi,
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?

Thanks in advance.

Sam.


This is why God created interns.
Nov 14 '05 #15
In <2v************ *@uni-berlin.de> Michael Mair <Mi**********@i nvalid.invalid> writes:
sam wrote:
Hi,
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?


This is not really on-topic.
However, there is a slightly more topical version: Why fix something
that is not broken?
C modules can communicate with fortran modules.
Now the problem is just how to fit the two together.
Google for "mix fortran and C". It basically comes down to
providing interfaces, creating the right headers and intelligent
makefiles.


The real problem is that the solution is not portable. The details of
interfacing C and Fortran are highly system specific. Everything could
just work by "magic", as was the case under VAX/VMS, but many other
platforms require the C code to have inside knowledge about the workings
of the Fortran compiler and/or vice versa.

The best attempt at hiding these details was made by the cfortran.h
project: http://www-zeus.desy.de/~burow/cfortran/

IIRC, it is only the last Fortran standard that addresses the issue.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union
Nov 14 '05 #16
Keith Thompson wrote:
Chris Barts <ch************ @gmail.com> writes:
Michael Mair wrote:
|> Can anyone help me find a software that can convert a code in 'C'
|> to 'Fortran77/90' automatically?
|
| This is not really on-topic.
| However, there is a slightly more topical version: Why fix something
| that is not broken?

Maybe because the Fortran compiler's optimization is better than the
platform's C compiler. Or to make calling the code from Fortran easier.
Or a small number of other possible reasons.


I'm skeptical that optimization is a good reason to convert C to
Fortran. Leaving pointer issues aside (and I think recent versions of
Fortran have something similar to pointers), automatically generated
Fortran is likely to be ugly and difficult to optimize.

If you want to be able to maintain the Fortran code, the best tool for
the job is probably a programmer who knows both C and Fortran and is
willing to do it for what you can afford to pay.


If he does it himself, it will be a good way to learn Fortran ?
Nov 14 '05 #17
On Thu, 11 Nov 2004 00:15:38 -0700, Chris Barts wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Mair wrote:
| sam wrote:
|
|> Hi,
|> Can anyone help me find a software that can convert a code in 'C'
|> to 'Fortran77/90' automatically?
|
|
| This is not really on-topic.
| However, there is a slightly more topical version: Why fix something
| that is not broken?

Maybe because the Fortran compiler's optimization is better than the
platform's C compiler.


However the comparison isn't between the Fortran compiler's optimiser and
rhe C compiler's optimiser, it is between the C compiler's optimiser and
the combined effects of the 2 compilers' translations. C compilers can
be pretty good at optimising C code. That can still result in slower code
than a Fortran compiler compiling Fortran code because the C language
semantics can be harder to optimise. A C to F compiler will have to
preserve the C language semantics of the code it translates and probably
generate pretty nasty Fortran code as a result. It is a reasonable bet
that a Fortran compiler will be less good at optimising C language
semantics than a C compiler, especially from an intermediate language that
doesn't express those semantics naturally.

Lawrence

Nov 14 '05 #18
Da*****@cern.ch (Dan Pop) writes:
[...]
The real problem is that the solution is not portable. The details of
interfacing C and Fortran are highly system specific. Everything could
just work by "magic", as was the case under VAX/VMS, but many other
platforms require the C code to have inside knowledge about the workings
of the Fortran compiler and/or vice versa.


C doesn't define an interface to Fortran, but Ada defines interfaces
to both C and Fortran, so one solution might be to write the main
program in Ada. (Assuming an Ada compiler is available on the system,
and that it defines interfaces to the particular C and Fortran
implementations .)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #19
In <ln************ @nuthaus.mib.or g> Keith Thompson <ks***@mib.or g> writes:
Da*****@cern.c h (Dan Pop) writes:
[...]
The real problem is that the solution is not portable. The details of
interfacing C and Fortran are highly system specific. Everything could
just work by "magic", as was the case under VAX/VMS, but many other
platforms require the C code to have inside knowledge about the workings
of the Fortran compiler and/or vice versa.


C doesn't define an interface to Fortran, but Ada defines interfaces
to both C and Fortran, so one solution might be to write the main
program in Ada. (Assuming an Ada compiler is available on the system,
and that it defines interfaces to the particular C and Fortran
implementation s.)


It's not the main program you want to write in Ada, but the interface
between the C and the Fortran code. I.e. if the Fortran code needs to
call a C function, provide an Ada wrapper that is Fortran callable and
that knows how to call the C function. Then again, it is not clear how
portable the solution would be in the real world (see your own
parenthetical remark).

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union
Nov 14 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1714
by: Graham Feeley | last post by:
Hi I have data resembling like this Clearing, The Italian Job, The Final Cut, The Manson Family, The I would like some code to convert the data to The Clearing The Italian Job The Final Cut
1
3451
by: Diego | last post by:
Hi, Anyone can help to convert this code to C#? Public Class MonImageConverter Inherits System.Windows.Forms.AxHost Public Sub New() MyBase.New("59EE46BA-677D-4d20-BF10-8D8067CB8B33") 'note the GUID here has no meaning. End Sub
8
1628
by: Mike | last post by:
is there a tool that will convert cold fusion code to C#? Or anything out there to help in this process? thx
15
2807
by: Tanzim Saqib | last post by:
I've been trying to learn VB.NET. I know VB6. I can not convert the following VB6 code segment to VB.NET In VB 6: ' In a module starts here: Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Public Declare Function GetAsyncKeyState Lib...
3
1663
by: Dushyant | last post by:
Hello everyone, I am working on converting one code from VB to VB.NET. I am stuck at some point, please help me how to convert following code from VB to VB.NET : Dim xImage As System.Windows.Forms.ImageList xImage = xImageLst.ListImages.Add(, "Open", LoadPicture(xPath & File_File_Open)) Regards,
2
1310
by: shapper | last post by:
Hello, Could someone, please, convert the following code line to VB.NET? bool containsValue = myList.Any(item =item.NameParameter == nameParameterValue); (This is .NET 3.5. I couldn't find a converter that does this) Thanks,
1
1214
by: shapper | last post by:
Hello, I am having problems in converting the following code line to VB.NET: Control list = MyFun(myControl, delegate(Control ctl) { ctl.ID == "MyControl"; }); Could someone please help me out? Thanks,
4
1699
by: Sam | last post by:
I am new in software development, and need some help. Please help me convert a class written in c# to vb.net. Thanks, Sam
3
1634
mshmyob
by: mshmyob | last post by:
I am new to vb.net and would like to be able to convert the following code to it's own function - either inside the current module or better yet in a seperate class. This code currently runs in the KEYPRESS event and ensures only numbers, decimal point, 2 decimals etc. are entered and not letters. Works exactly how I want it but would now like it in a function. I need this code in numerous text box controls but I would rather just call it...
2
2455
by: royhoja | last post by:
How do i convert the following code into a function? What parameters would be in the function? printingform(???,???) #include <stdio.h> #include <string.h> int main() { int i;
0
9997
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...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6642
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
5270
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
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.