CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   What is the differenc ebetween Fortran and C/C++?? (https://www.cfd-online.com/Forums/main/3403-what-differenc-ebetween-fortran-c-c.html)

J Keays. May 2, 2001 10:10

What is the differenc ebetween Fortran and C/C++??
 
Hi All, A straigh forward question if you, I'm sure. The reason I ask is that i ma oging doing a Ph.D in LES of Combustion...specifically Sub-grid scale models and I will be using Fortran. (Because my professor uses it!!). Anyway, I want to know if it would be in my interest to use C/C++ and if so, is it easy to convert it to Fortran to keep people smiling?? thank you.

Kike May 2, 2001 11:17

Re: What is the differenc ebetween Fortran and C/C
 
Dear John

Simple desicion algorithm

IF(you know FORTRAN) THEN

IF(you will use a code your professor had writen in FORTRAN) use FORTRAN

ELSE

if(you know C)

{

use C;

write your own code according your objectives;

}

else

learn C;

ENDIF

You will have to employ a lot of effort in programming LES and the language u use will be the less relevant part in your PhD. Fix your attention in Turbulent Combustion Physics, from the beggining, and you will have a really nice Thesis even programming in FORTRAN or C/C++. Good luck

Kike

J Keays. May 2, 2001 11:54

Re: What is the differenc ebetween Fortran and C/C
 
Hi Kike,

Thanks for the advise. I,m aware that the language of choice is less relevant than the actual physics. I'm looking at it from the point of view of a skills transfer in IT/Finance when I finish. Its a long way off, but I reckon C++ is more transferable and it would be good to have developed an experts use of the language. thanks again, John.

John C. Chien May 2, 2001 12:10

Re: What is the differenc ebetween Fortran and C/C
 
(1). Try to learn the language as early as possible. It takes time to do so. (2). Fortran is good for CFD. But CFD is becoming a complete process which also includes goemetry modeling, mesh generation, computer graphics. So, the solver part is becoming a smaller portion of the whole process. And C/C++ has been used extensively in those geometry/graphics related field. (3). Now you see, even in CFD, it is a good idea to know C/C++. And if you have to use PC for fluid flow simulation, then VC++ might be necessary in Window environment. (4). The trend is Fortran-> C/C++ -> VC++.

George Bergantz May 2, 2001 12:53

obvious- learn both!
 
Learn them both while you are still young and your mind is fresh. No doubt anything you learn today will be somewhat obsolete in 10 years.

Neither language is especially difficult.

J Keays. May 2, 2001 13:01

Re: obvious- learn both!
 
I guess its a good point. I just feel that 3-4 years using C++ to implement whatever models are necessary would be superior in terms of transferability to other industries and also with regard to what seems to be C++ better capabilities. (I take this on trust from my the guy I share an office with, who has used both for aero and solid acoustics.

andy May 2, 2001 14:12

Re: What is the differenc ebetween Fortran and C/C
 
If you are in a group it is far more important that you work with the group rather than doing your own thing on the side. If the group is using X then use X because your work will not cleanly feed the work of other members or vice-versa. Most group leaders will stop you from using Y anyway if it is going to be a problem for the group.

Having said that:

(1) Fortran is simpler to write and produces faster code than C/C++. This is important for big LES runs.

(2) Most serious numerical code is still in Fortran and likely to remain so in the near future (i.e. the length of a Ph.D.). Beyond that things are not so clear.

(3) It is almost impossible to convert a typical C++ program to Fortran without a complete restructuring/rewrite. This may not be the case for C but C is not so fashionable to use these days.

(4) Fortran is next to useless as a keyword on a CV for general IT/finance.

(5) There is large shift away from C/C++ in general IT/finance towards Java. There are a range of reasons for this but it generally boils down to the fact that a simple, relatively safe language with a massive set of libraries like Java can be used by a succession of relatively unskilled (cheap) programmers to produce reasonably maintainable code. An equivalent C++ programmer needs to be more skilled, more careful/disciplined and will produce more complicated code which is more difficult to maintain. A skilled C++ programmer will effectively use the low level C++ components to produce a custom higher level language to tackle the job in hand. This may work in a committed long term stable environment but not in the low skill, high turn over, general computing environment. (Of course, in the longer term someone will have to maintain the recent crop of C++ codes).

(6) Java is, unfortunately, a non-starter for numerical work because it is too slow. This cannot really be fixed because it is Java's safety which is the root cause. (Custom Java compilers have got within 50% of Fortran speed but it is unlikely they will get much closer - typical Java is around 1% of Fortran).

(7) Although widely used (presumably because of C) C++ is a truly weird programming language. It is a mixture of low level system constructs and an unnecessarily wide range of half implemented high level language features. It does not abstract the machine hence different machines have different primitives and therefore produce different answers. The specification is imprecise and allows, for example, implementation dependent use of temporaries. Since the construction of these can have side-effects it means different compilers that conform to the language and run on the same machine can still produce different answers. The difficulties of programming in C++ are widely recognised by both the believers and normal people. It is hard to believe that the major effort required to master C++ to the point where one can produce reasonably reliable programs is a sensible investment.


John C. Chien May 2, 2001 15:26

Re: What is the differenc ebetween Fortran and C/C
 
(1). It is important to remember that as soon as the code leaves the original author, it will become someone else's problem. So, the idea is to keep it as simple as possible. (2). And even in the C++, one still can use the old procedural approach, and keep the class/object to a minimum when not required. (3). JAVA is completely object-oriented. (4). Anyway, the new trend is to use "component-oriented model", so that component binary codes written in different languages can be packaged into components and used on multi-tier network, in a distributed fashion. The exchange of information is through the specification of the interfaces where the component functionality is exposed(methods or functions) and used. (5). This new trend on three-tier network should bring codes developed in different languages together and make the development and maintainance easier. (6). So, the idea to learn more languages is to know different ways to write codes.

Bubba May 2, 2001 16:32

Re: What is the differenc ebetween Fortran and C/C
 
A point was made that FORTRAN produced faster code than C++. Can you please direct me to your source.

I would be interested in seeing this for myself.

Thanks.

kalyan May 2, 2001 17:44

Re: What is the differenc ebetween Fortran and C/C
 
If you are going to write a C++ code that can be translated (almost line to line) to FORTRAN, it does not serve much purpose. If you are using OOPs or other concepts such as dynamic allocation/deallocation which are not supported by FORTRAN, it is perhaps worth looking into C++. A friend of mine uses FORTRAN 90 and from what I have seen of his work, it seems to be simple enough langauge with additional features like dynamic allocation which F77 does not support. I am stressing dynamic allocation because executables of combustion LES can get really huge and unless you have a big parallel machine, you may run out of space.

I do agree that it is perhaps worthwhile learning C++ when you just starting graduate school (before you start spending most of your work day trying to figure out why your combustion/LES models does not predict stuff as you expect them too). Based on observation, I have a feeling that C++ might help if you are using unstructured meshes (I do not know exactly why). But, as far as I know, the only LES people I know who use C++ for LES are Sandia Labs (MP_Salsa FEM based code), Pletcher's group at Iowa state, Gosman's group at Imperial College. It is perhaps a good idea to ask some one in one of these groups as to why they used C++ if you really need an answer.

Sebastien Perron May 2, 2001 21:21

Re: What is the differenc ebetween Fortran and C/C
 
The First codes for computational software I wrote were done in Fortran (it was about 7 years ago). But, since then, I quickly move to C++. There are many advantages:

1) If you use OOP programming in conjunction with UML modeling, you can quickly desing bug free programs that are easier to transfer to another person. Don't forget, if you PH.D is usefull, the code could possibly be used by another individual.

2) The objects that have been designed for one program can often be used for another project.

3) If the code is very well designed in C++, it can be faster than a Fortran code. With an approriate used of register variables and inline functions, code can be 25% faster than a Fortran code.I made tests with dot products and other vectors operations, the C++ is faster when well designed. It not truth that fortran is faster.

4) If you ever want to have a graphical interface on top of your program, it will be easier to do it with C++ than with fortran.

5) For the past year, I got some contracts with an Industry. Some of these contracts were related to porting old fortran to C++ in order to keep them working. And now, their begging me to work on a crazy project where the engineers did program the numerical stuff with fortran and the computer guys used C++ for the graphical interface. They are now runnig into all kind of troubles and they don't know what's going one.

6) The future is written in C++. Fortran is something of the past. If it wasn't of F90, it would be already dead.

Steve Amphlett May 3, 2001 04:41

Re: What is the differenc ebetween Fortran and C/C
 
Just to clarify, there is no such language as C/C++.

Kike May 3, 2001 05:27

Re: What is the differenc ebetween Fortran and C/C
 
Hi John

I read your messages and now I can see your "far future" interest. In your place I choise C++.

I desagree with Andy with respect to the "higher speed" of FORTRAN compared to C++. As Bubba, I would like to see this code, but you can do some test, as Sebastien did, to see the contrary.

The fact is that approximately the 90% of programmers community is working with C++ and only a few old professors and their students (I was included) still work on FORTRAN. The FORTRAN had became into an University tool to show the functionality of old programs from 80's.

As Sebastien wrote the software industry and almost every engineering company demand C, C++ or Java skills. Here in France and in Spain (where I live) you need to know C++ to contact the actual IT market.

I agree with JCChien and Sebastien; the portability of your code is a point to consider and you should have in mind that your work should be used by other colleagues in the future. I am sure they will program in C++, at least in any OOP language.

I assume that in your Univ. people work in Linux (or Unix), otherwise, try to use it. Windows uses a lot of resources in your machine so it makes the execution slower than in Linux. Besides it, as far as I know, there is no free compiler for FROTRAN or C in Windows, but you have the gcc, g77 or pg77 (all of them free and constantly upgraded) for Linux.

You will probably work in parallel enviroment (now or in a recent future) and MPI is only supported on WindowsNT(2000) with a lot of problems, nevertheless it is widely used in Linux (mostly in C++ than in FORTRAN).

During your PhD. try to forget the VC++, the VJava even the recent C# from Microsoft, after, when you finish, you will employ two weeks to upgrade your skills form C++ to VC++.

I hope it helps you, good luck (not with C++, I am sure it will very easy for you, but with Turbulent Combustion)

Kike

J Keays. May 3, 2001 06:22

Re: What is the differenc ebetween Fortran and C/C
 
Alright guys. Thanks for all the help. I know that C and C++ are different languages!! Anyway, the situation is I will probably have to use Fortran because my professor, his group and several other partners in the project all use it. So, I would like to extend my question to ask you guys what are the employment prospects outside the Engineering world for someone who has worked on parallel LES of Turbulent Combustion, specifically sug-grid scale turbulence? Thanks again, John.

andy May 3, 2001 06:27

Re: What is the differenc ebetween Fortran and C/C
 
My source is common sense and having a small understanding of how computers work. This can be obtained from an enormous range of sources if one damps down one's enthusiasm and questions what one is given (not mentioning any names at this point!).

The speed of Fortran over C/C++ arises because the Fortran optimizer can do a lot more optimising of array based operations than a C/C++ optimizer (i.e. rearrange the order of evaluation, pull things out of loops, tiling, etc...). This is because Fortran does not allow arrays to be invisibly overlapped whereas C does (often referred to aliasing in C) allowing the optimizer to deduce far more about data dependencies.

Note that you require an aggressive optimizer to get speed with Fortran. If your Fortran compiler is a reworked C compiler then Fortan-type optimizations are not going to be present. For example, comparing the speed of g77 and gcc on Linux is a fairly pointless exercise. It is also wise to use native compilers to get speed with Fortran since these tend to make most use of the go-faster goodies in the hardware.

There is some hope for C since C99 (or whatever it is called) has introduced a "not aliased" directive (I cannot recall the precise term). This, potentially, would allow C to achieve Fortran speeds if Fortran-type optimizations are introduced into the C compilers. This will not happen straightaway and not in all compilers but, with luck, the pressure of benchmark figures will force at least the native C99 compilers to improve array handling.

Unfortunately (typically?) the C++ standards committee initially rejected including the directive in the recent C++ standard. There will be pressure for C++ to conform more closely with C99 at the next round (good) but there is also pressure to give up C compatability in a desperate, late attempt to create a semi-sensible higher level language (why bother?).

If you want to know more read any book on optimization that at least considers non-C techniques.

Here is a typical link that someone posted to the forum the last time C/C++ or Fortran was discussed:

http://www.hpcf.cam.ac.uk/C_rant.html


clifford bradford May 3, 2001 13:38

Re: What is the differenc ebetween Fortran and C/C
 
"Skills transfer". Shit! if you're already contemplating that why get your PhD in CFD?

clifford bradford May 3, 2001 13:51

Re: What is the differenc ebetween Fortran and C/C
 
it's been my experience that if you have Fortran and C/C++ codes that do the same thing and they are compiled using similar options that the Fortran code can be optimised to run much faster. As Andy mentioned a good way to test this is to take code in Fortran and C/C++ and on the same machine (say an IBM RS6000) and compile them both with the respective IBM compilers using the same options (I say IBM because for the most part the options have the same names in both the Fortran and C/C++ compiler so you can be sure you're choosing the same thing) for example when I used to use RS6000s for speed I'd go with "-O4 -qstrict" or "-O3 -qstrict" I don't quite recall which. The fortran code would usually run faster. Also anecdotal evidence (including the Microsoft VC++ manual) indicates that using a lot of C++ object oriented features can slow your code. I'm not much of a C++ coder so I can't say.

John C. Chien May 3, 2001 17:33

Re: What is the differenc ebetween Fortran and C/C
 
(1). A degree is a degree, that's all. (2). Outside the engineering world, you don't need a degree, you need experience and knowledge about languages (programming or business). (3). If you start writing codes in C++, I am sure that the chances of getting a good job outside engineering is many many times higher. (4). A Phd dissertation is not very useful once you have the degree. So, try to learn as much as possible the computer related languages,and applications when you are still in the school. (make sure that you do practice the programming skill a lot.)

Sebastien Perron May 3, 2001 20:03

Re: What is the differenc ebetween Fortran and C/C
 
Usually, most of the time is spent in the linear equations solvers which used a lot of vector operations. If the C++ code and the Fortran code are written in the same manner, I agree that the fortran Code will run faster.

But, As I previously said, the C++ allows you to do things (such as function inlining and register variables) that will boost the performances of your code and surpass the Fortran code.

It is also true that if you use heritage with VC++ classes that use system interupts, your code will be slowed in a dramatic way.

Finaly, I must admit that it is science to write C++ code that run faster than a Fortran Code. But it can be done.


Greg Perkins May 3, 2001 20:41

Re: What is the differenc ebetween Fortran and C/C
 
Another thing to consider if you already have large amounts of code you don't want to port to another language is to use mixed language programming - in this case you can write the new parts of your program in C and still use original functions written in Fortran you get from your professor. I think C is generally the way forward, but as others comment, conceptually C and Fortran are 3rd generation languages and semantically almost identical. C++ is different of course being object orientated which uses different concepts - but not that hard.

Mixed mode development is harder to begin with though due to different calling conventions in C/Fortran.

Greg

Bernard Parent May 4, 2001 04:40

Re: What is the differenc ebetween Fortran and C/C
 
But the IBM RS6000 is famous for its great F77 compiler but lousy C compiler. On a x86 platform using gcc/g77, you might get very different trends. My advice on whether to choose C or F77 is as follows: if you really know what you're doing, coding things in C is preferable and will result in a faster executable. On the other hand, if you're a newbie at computer programming and have no intention of looking too deeply into algorithm optimization methods, then sticking to f77 is the best approach.


sylvain May 4, 2001 05:45

Re: What is the differenc ebetween Fortran and C/C
 
g77 only translates fortran to C++ and then compiles it with gcc. So it is NOT a fortran compiler. But, under linux, you can download a free demo of PGF77/PGF90/PGC++ and then compare the cpu time.

For my part, I use F90, because :

it's readable by almost everybody;

it's deal with allocatable memory.

Chears,

Sylvain

andy May 4, 2001 06:45

Re: What is the differenc ebetween Fortran and C/C
 
Sebastien your enthusiasm does you credit but...

Why do you believe the register hint in C will do anything in the presence of a reasonable optimiser? (in the early 80s perhaps but these days?).

Why do you believe that explicit function inlining is relevant to highly optimised Fortran code? (it is obviously relevant to C++ code but this is because the language has inserted vast numbers of function calls which are not present in the "equivalent" Fortran code).

Writing fast C++ code has nothing to do with science. It simply involves understanding all the things that cripple C++ performance and avoiding them. This has everything to do with learning what the compiler is doing in the background and almost nothing to do with the semantics of the language. It takes a very long time to master all this and then, at best, you have a vast amount of almost unreadable code which takes for ever to compile and occasionally matches the speed of Fortran but is generally slower.

Someone earlier suggested contacting the users of C++ in CFD codes (Sebastien would seem to qualify here!). I would modify that and suggest you contact the developers of the C++ numerical libraries/systems on which any serious attempt to use C++ would depend. I did this a few years ago when I had overcome my initial enthusiasm for C++'s obvious attractions and began to recognize its vast number of less obvious problems.


andy May 4, 2001 07:06

Re: What is the differenc ebetween Fortran and C/C
 
Bernard,

Do you seriously suggest that IBM cannot write a very efficient C compiler for their own processors? The suggestion is daft.

> On a x86 platform using gcc/g77, you might get very different trends.

If getting pretty much the same performance qualifies as a very different trend then we are in agreement. But this has little to do with the difference between efficiently compiling C and Fortran codes in general. A CISC processor with a small cache, slow memory access and fast processor clock speed is going to run a large numerical code at pretty much the same speed regardless of language (unless the language does not support arrays of course). This is pretty much guaranteed if the Fortran compiler does not include Fortran-style array optimisations.

Straightforward computation on arrays in C is never going to be faster than Fortran using reasonable optimising compilers.

andy May 4, 2001 07:38

Re: What is the differenc ebetween Fortran and C/C
 
A bit of clarification. There are two gnu Fortran 77 compilers on Linux.

(1) fort77 is based on the f2c Fortran->C translator. This parses Fortran fairly accurately but obviously cannot respect the more subtle requirements of the Fortran language. The resulting C code is slow and usually benefits from a bit of work to remove a few unnecessary overheads.

(2) g77 is a separate Fortran front-end for gccs general back-end. It seems a little less accurate at parsing Fortran but produces a bit faster code. It does not produce code to match a native Fortran compiler. The project has not been particularly active since the main developer gave up a year or two ago.

Which one you get when typing f77 seems to vary between installations but most recent installations will run g77.


Bernard Parent May 4, 2001 08:33

Re: What is the differenc ebetween Fortran and C/C
 
>> Do you seriously suggest that IBM cannot write a very efficient C compiler for their own processors? The suggestion is daft.

Nope it isn't. Why would IBM write an efficient C compiler if most of the AIX users only use Fortran? Besides, the F77 compiler might be optimized for CFD-style computing on the AIX while the cc compiler might be written simply to compile the kernel and apps. I don't know what the reason is, but definitely, cc on AIX is below-par. Our 5 year old RS-6000 using cc is 2 times slower than a 5 year old PC running gcc (and the IBM machine cost at the time 20 times more than the PC..)

>> Straightforward computation on arrays in C is never going to be faster than Fortran using reasonable optimising compilers.

And I see no reason why straightforward computations on arrays in fortran should go any faster than in C, if the programmer _really_ knows what he is doing and optimizes the loop manually. The obvious advantages of using C are (1) the incredible free support out there on the mailing lists, and (2) the assurance that everything can be done in C, since pretty much anything of any importance is coded in C..

I saw a posting on a mailing list once that went along those lines:

LOGO is for children

PASCAL is for students

FORTRAN is for scientists

but C, however, is for programmers.

The fact that fortran is not even taught part of a normal CS curriculum speaks for itself. The language is dead, unsupported; good free compilers are unexistant; good commercial compilers are rare and costy. Plus, there's a bundle of fantastic debugging tools for C/C++ (like Purify or Insure++) that are simply unavailable for other languages. Not to mention that entire operating systems were built in C for C (like UNIX). Using UNIX while not using C is a bit similar to driving a car while refusing to shift gears: you miss out on a lot of functionality.

Once you get used to working with C (and I mean here the entire working environment, not just the language), you realize there's just no comparison possible with other languages: C is in a class of its own.

Just my two cents,

cheers,

bern

andy May 4, 2001 09:49

Re: What is the differenc ebetween Fortran and C/C
 
>> Why would IBM write an efficient C compiler if most of the AIX users only use Fortran?

Ummm, let me guess. Because almost every program on the computer is written in C? Because they want to sell the computer? (and I doubt very much if most users of AIX use Fortran).

>> I don't know what the reason is, but definitely, cc on AIX is below-par. Our 5 year old RS-6000 using cc is 2 times slower than a 5 year old PC running gcc (and the IBM machine cost at the time 20 times more than the PC..).

This is not a persuasive argument. Why not install gcc on your AIX system? Now that would establish if IBM can write a C compiler for their own hardware.

>> And I see no reason why straightforward computations on arrays in fortran should go any faster than in C, if the programmer _really_ knows what he is doing and optimizes the loop manually.

Unless you learn why an array is different in C and Fortran and the consequences for optimizing array expressions then we are agreed: you are not going to see the reason.

>> Once you get used to working with C (and I mean here the entire working environment, not just the language), you realize there's just no comparison possible with other languages: C is in a class of its own.

Now here we have full agreement. C was designed 30 years ago as a systems language and is in a class of its own. It's problems are well recognized by language designers and, as far as I know (excluding derivatives), no-one has suggested a new language that bears much resemblance to it since.


Bernard Parent May 4, 2001 10:27

Re: What is the differenc ebetween Fortran and C/C
 
>> Ummm, let me guess. Because almost every program on the computer is written in C? Because they want to sell the computer? (and I doubt very much if most users of AIX use Fortran).

They don't have any choice: the combo C/AIX sucks big time ;-).

>> Unless you learn why an array is different in C and Fortran and the consequences for optimizing array expressions then we are agreed: you are not going to see the reason.

I admit my ignorance but why don't you tell me: I might learn something from your comments. No matter how Fortran manages its arrays, I'm sure there's a way of implementing the same approach in C somehow, whether this is at compile-time through an optimization flag or in the code directly.

>> Now here we have full agreement. C was designed 30 years ago as a systems language and is in a class of its own. It's problems are well recognized by language designers and, as far as I know (excluding derivatives), no-one has suggested a new language that bears much resemblance to it since.

The fact that it's been around for so long while not being altered significantly and still being used everywhere is an argument in favour of it, not against it.

I think it's quite clear we are both strong believers of different religions, and religious wars are rarely solved through arguing. But let me just clarify slightly my position on the subject: I'm not a die-hard fan of C: my favourite language is actually Pascal which I find to be the most appropriate for scientific programming. But the point I want to make is this: everybody uses C. The best coders in the world are using it. The same best coders wouldn't even know how to write ``hello world'' in fortran. They must have a reason, don't you think? So far, on the x86 patform, I was always able to match and surpass slightly in raw speed a F90 or F77 code, with very little changes to my C coding. I've been delighted with the generality of C and how easy it is to extend the functionality of my program. Even if C would be significantly slower than Fortran, I'd still recommend it if you plan on doing CFD development. A more versatile language leads to the possible implementation of a wider range of algorithms.. Some CFD algorithms I'm implementing now in C would be impossible to implement in F77, for example.

Anyway, that's just my opinion.

andy May 4, 2001 12:29

Re: What is the differenc ebetween Fortran and C/C
 
>> I admit my ignorance but why don't you tell me: I might learn something from your comments.

See earlier posting (the one with the web link) and follow the link.

>> No matter how Fortran manages its arrays, I'm sure there's a way of implementing the same approach in C somehow, whether this is at compile-time through an optimization flag or in the code directly.

See earlier comment on C99 and follow the web link.

>> The fact that it's been around for so long while not being altered significantly and still being used everywhere is an argument in favour of it, not against it.

Partially but in the same way as the wide spread use of Microsoft Windows is an argument in favour of using Micrsoft Windows. It says nothing about the competence of the language/OS except that it provides the minimum to get the job done (some might even dispute that).

>> I think it's quite clear we are both strong believers of different religions, and religious wars are rarely solved through arguing.

No, I would take offence at describing knowledge as religion. Religion requires signing up to a fundamental belief - C++ is the answer so what is the question? I have spent 10 years studying C++ to become a "guru" and now I am going to use it! - this is religion. Poking such people is not religion it is just teasing.

>> But the point I want to make is this: everybody uses C.

Yes.

>> The best coders in the world are using it.

Only when it is the appropriate choice. I would suggest this is not most of the time. (If you want to see the choices of skilled programmers then look at the results of coding competitions - results using C/C++ are poor and there are no entries using Fortran).

>> The same best coders wouldn't even know how to write ``hello world'' in fortran.

They would if a significant part of their task was scientific numerical analysis and the main language did not implement arrays efficiently.

>> They must have a reason, don't you think?

Yes. Scientific programming which once significantly shaped the development of the computing industry is now virtually an irrelevance to it.

>> So far, on the x86 patform, I was always able to match and surpass slightly in raw speed a F90 or F77 code, with very little changes to my C coding.

Yes. Fortran, C, Pascal, ADA, etc... I would expect to perform about the same for array based computing where the bottleneck is waiting for information from memory.

Sebastien Perron May 4, 2001 13:50

Re: What is the differenc ebetween Fortran and C/C
 
>> (1) fort77 is based on the f2c Fortran->C translator. This parses Fortran fairly accurately but obviously cannot respect the more subtle requirements of the

Fortran language. The resulting C code is slow and usually benefits from a bit of work to remove a few unnecessary overheads. <<

I strongly disagree with you on that point. Recently, I had to implement a new solver in a MHD code written in fortran. In order to compile it on my FreeBSD (UNIX) PC, I used f2c with gcc and time the code. My client uses Digital Fortran on a WinNT station, and in order to make sure that the code will always work for his workstation, I always do a compilation with my PC rebooted with win98 and Digital Fortran. For both compilations, I always used the best flags for optimization. Beleive it or not, the computational time on both Systems is the same.

andy May 4, 2001 15:06

Re: What is the differenc ebetween Fortran and C/C
 
Try turning down/off the optimisation. Is the time still the same? Now what do you conclude?

clifford bradford May 4, 2001 23:36

Re: What is the differenc ebetween Fortran and C/C
 
yeah, I'm a C programmer when i program but my limited exposure to Fortran90 has made me realize that it's probably better for number crunching plus it's easier and you can be lazy (and still be efficient) if your writing code to do small things.

clifford bradford May 4, 2001 23:42

Re: What is the differenc ebetween Fortran and C/C
 
when I say "Fortran" I mean F90. I think you could defintely outdo F77 with C or C++. However I think if you matched a C/C++ programmer and fortran programmer of equal skill the C guy would be hard pressed to gain the advantage compilers being roughly equal.

Personally I think the IBM C compiler is quite good and the features are quite similar between it and the F90 compiler. If I'm not mistaken the GNU F77 compiler translated F77 to C then compiles it (?). If that's true then by default the F77 code wouldn't likely be faster


All times are GMT -4. The time now is 19:29.