473,386 Members | 1,693 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,386 software developers and data experts.

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 #1
26 13501
sam wrote:
Hi,
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?

Thanks in advance.

Sam.


Wow, - good luck :)
Nov 14 '05 #2
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.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 14 '05 #3
> Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?


Good luck. You'll need it. C concepts like pointers don't
translate very well into FORTRAN.

Gordon L. Burditt
Nov 14 '05 #4
sam wrote:
Hi,
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?

This is off-topic for this newsgroup. However, I suggest using a search
engine for f2c.

Brian
Nov 14 '05 #5
On Wed, 10 Nov 2004, Default User wrote:
sam wrote:
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?


This is off-topic for this newsgroup. However, I suggest using a search
engine for f2c.


That is in the wrong direction...

Tak-Shing

Nov 14 '05 #6

"Tak-Shing Chan" <es***@city.ac.uk> wrote in message
news:Pine.GSO.4.33.0411102059310.12278-100000@swindon...
On Wed, 10 Nov 2004, Default User wrote:
sam wrote:
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?


This is off-topic for this newsgroup. However, I suggest using a search
engine for f2c.


That is in the wrong direction...

So you can use it to check your result, in the unexpected case that the
original C code fell within the subset of C used by f2c, and your OS gets
along with the f2c conventions.
Nov 14 '05 #7
Jim
On Wed, 10 Nov 2004 21:00:12 +0000, Tak-Shing Chan <es***@city.ac.uk>
wrote:
On Wed, 10 Nov 2004, Default User wrote:
sam wrote:
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?


This is off-topic for this newsgroup. However, I suggest using a search
engine for f2c.


That is in the wrong direction...

Tak-Shing


Try searching for c2f then.

Jim
Nov 14 '05 #8
-----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.

| C modules can communicate with fortran modules.

True, but it isn't always easy. There are more issues involved in this
than I'll go into here, but there is a (long) discussion of it at
section 3.1.3 of the Fortran FAQ at this address:

~ http://www.faqs.org/faqs/fortran-faq/

| Now the problem is just how to fit the two together.

And it is, indeed, a problem. ;)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBkxGaKxatjOtX+j0RArp4AJ9kXvMBB1BHuetZobFJS5 bB9iwkCwCeOCdR
GpWhVHxh1RLZn/JHtRI+rkk=
=Z1NT
-----END PGP SIGNATURE-----
Nov 14 '05 #9
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. Or to make calling the code from Fortran easier.
Or a small number of other possible reasons.
Well, as the OP did not give a _good_ reasons, I assumed (s)he was not
aware of this way.

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.
Yep, this I know. I would rather go for the f2c but the OP seemed
to want to have Fortran.
| C modules can communicate with fortran modules.

True, but it isn't always easy. There are more issues involved in this
than I'll go into here, but there is a (long) discussion of it at
section 3.1.3 of the Fortran FAQ at this address:

~ http://www.faqs.org/faqs/fortran-faq/

| Now the problem is just how to fit the two together.

And it is, indeed, a problem. ;)


*g* Maybe.
Up to now, I only had the dubious pleasure of getting F77 code
to work together with C code, always the C code calling -- and
this went always straight by recipe.

Thanks for the additional information :-)
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 14 '05 #10
Chris Barts <ch************@gmail.com> wrote in message news:<S9********************@onewest.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.fortran (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_Keith) 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.com (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.fortran 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.org> Keith Thompson <ks***@mib.org> 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.
automatically 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.com (sam) wrote in message news:<e3**************************@posting.google. 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**********@invalid.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_Keith) 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.org> Keith Thompson <ks***@mib.org> writes:
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.)


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

In article <e3**************************@posting.google.com >, at*****@gmail.com (sam) writes:
Hi,
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?


I didn't even know there was a fractional Fortran standard. I've only
used the integral ones (well, sometimes their derivatives).

--
Michael Wojcik mi************@microfocus.com
Nov 14 '05 #21
In <cn********@news1.newsguy.com> mw*****@newsguy.com (Michael Wojcik) writes:

In article <e3**************************@posting.google.com >, at*****@gmail.com (sam) writes:
Hi,
Can anyone help me find a software that can convert a code in 'C'
to 'Fortran77/90' automatically?


I didn't even know there was a fractional Fortran standard. I've only
used the integral ones (well, sometimes their derivatives).


F77S was a fraction of the F77 standard (a "subset" in the F77 jargon).

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union
Nov 14 '05 #22
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:

[...]
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.)


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).


If the main program is written in a language other than Ada, it will
have to call a special routine "adainit" to initialize (elaborate) the
Ada runtime. (This was added in Ada 95; Ada 83 didn't have it (which
is probably why I incorrectly assumed the main program would need to
be in Ada).)

--
Keith Thompson (The_Other_Keith) 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 #23
On 11 Nov 2004 15:09:10 GMT, Da*****@cern.ch (Dan Pop) wrote:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:

<snip>
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.

Not just Pascal; outside the C family, I don't know of any HLL that
has pointer arithmetic, except that I hear it has been added (I think
implementation-dependently) to PL/I more recently than the last time I
used it seriously. Ada's primary form of pointers, access types, are
opaque but it has standard syntax for conversion to and from 'address'
types that support some arithmetic.

F90 POINTERs are unusual -- AFAIK unique -- in that for arrays they
are full dope vectors that can designate noncontiguous slices.
- David.Thompson1 at worldnet.att.net
Nov 14 '05 #24

In article <mo********************************@4ax.com>, Dave Thompson <da*************@worldnet.att.net> writes:

Not just Pascal; outside the C family, I don't know of any HLL that
has pointer arithmetic, except that I hear it has been added (I think
implementation-dependently) to PL/I more recently than the last time I
used it seriously.


COBOL added pointer arithmetic (SET [pointer] UP [or DOWN] BY [amount])
in the 2002 standard, and some flavors (eg Micro Focus) have had it for
longer. (The oldest example I have for MF COBOL at hand is from 1997,
but I think pointer arithmetic was added significantly earlier than
that.)

--
Michael Wojcik mi************@microfocus.com
Nov 14 '05 #25
mw*****@newsguy.com (Michael Wojcik) wrote:
In article <mo********************************@4ax.com>, Dave Thompson <da*************@worldnet.att.net> writes:

Not just Pascal; outside the C family, I don't know of any HLL that
has pointer arithmetic, except that I hear it has been added (I think
implementation-dependently) to PL/I more recently than the last time I
used it seriously.


COBOL added pointer arithmetic (SET [pointer] UP [or DOWN] BY [amount])


Ow! My eyes... will you please not do that? It hurts...

Richard
Nov 14 '05 #26

In article <41**************@news.individual.net>, rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
mw*****@newsguy.com (Michael Wojcik) wrote:
COBOL added pointer arithmetic (SET [pointer] UP [or DOWN] BY [amount])


Ow! My eyes... will you please not do that? It hurts...


Not do which? Use block capitals (customary for posting COBOL,
though I use lowercase for actual COBOL source), use square brackets
(standard for editorial insertions in English), or post COBOL (I have
no excuse for that)?

I must admit reading COBOL often pains me too. On the other hand,
the comp.lang.cobol regulars will make the same complaint about C...

--
Michael Wojcik mi************@microfocus.com

HTML is as readable as C. You can take this either way. -- Charlie Gibbs
Nov 14 '05 #27

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

Similar topics

2
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
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...
8
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
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"...
3
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...
2
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...
1
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...
4
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
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...
2
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: 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...
0
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,...
0
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...

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.