Home > Archive > Fortran > December 2005 > Differance between Fortran 90 and C
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Differance between Fortran 90 and C
|
|
| Aleramo 2005-11-21, 7:01 pm |
| I am an university student and i am doing my thesis. I thought to do my
thesis in C with some function in Fortran 90. When is better using
Fortran 90 and when the C? I am studing an Antenna.
Bye bye Marco.
| |
| Michael Wild 2005-11-21, 7:01 pm |
| Hi Marco
This really depends. Fortran is great for numerical code. It has a very
good, matlab like syntax for this kind of programs. Also it has much
better intrinsic support for matrices (arrays) than c. An then there are
tons of libraries for it.
On the other hand, there is not much else you want to do with fortran.
If you're using Fortran 90/95 you'll have trouble with c
interoperability, which at the present state of the standard and most
compilers requires some experience and know-how (or put in another way:
in these areas forget about all the new features :-)).
In the end it's up to you what you like best. Personally I prefer
Fortran for my numerical stuff, but my advisor forces me to rewrite
everything in C at the moment (and yes, numerics in C are a pain).
Michael
| |
| Aleramo 2005-11-21, 7:01 pm |
| Thank u Michael,
i use g95. Has it problems to work with C?
Where do u come from? i come from Italy.
Bye Marco.
| |
| Joe Krahn 2005-11-22, 4:00 am |
| Aleramo wrote:
> I am an university student and i am doing my thesis. I thought to do my
> thesis in C with some function in Fortran 90. When is better using
> Fortran 90 and when the C? I am studing an Antenna.
>
> Bye bye Marco.
>
Fortran is an excellent language to do calculations, but not for
'application programming', which is about 90% user interface. If you are
programming for the sake of math, use Fortran.
As for C, it is definitely a bad choice. However, C++ can be quite good
along with a matrix class. The problem is that there are a lot of matrix
class libraries to pick from, many of which are good, but incompatible
with each other. It's a world driven by people who like learning 10 ways
to program the same thing.
Alternatively, if you want to do some user interface stuff, you could
use a script language, like Python, for the user interface, and Fortran
for the math.
Joe Krahn
| |
| Greg Lindahl 2005-11-22, 4:00 am |
| In article <1132608827.176992.177270@o13g2000cwo.googlegroups.com>,
Aleramo <monferrato2006@yahoo.it> wrote:
>I am an university student and i am doing my thesis. I thought to do my
>thesis in C with some function in Fortran 90. When is better using
>Fortran 90 and when the C? I am studing an Antenna.
It depends.
What languages do you know already? How easy is it for you to learn
new ones? Are you doing graphics or just computing something about the
antenna? What do other students in your department use?
If you don't already know either Fortran 90 or C, you're probably
better off learning just one language, and if you aren't using
graphics, I'd personally recommend Fortran 90. But if the people you
have locally to ask questions all know C and not Fortran 90...
-- greg
| |
| Aleramo 2005-11-22, 4:00 am |
| I know only the C and a bit of Fortran 90. It's the reason of my topic.
I want to know if learning more about Fortran can be useful. In my
laboratory all know the C but none want to help me.
Now i am courious to know when the Python is better than other
lenguage, it means. Why the is python developed? what's his target? i
am interessed but after thesis.
Bye bye Marco.
| |
| David Ham 2005-11-22, 7:59 am |
| Aleramo wrote:
> I know only the C and a bit of Fortran 90. It's the reason of my topic.
> I want to know if learning more about Fortran can be useful. In my
> laboratory all know the C but none want to help me.
> Now i am courious to know when the Python is better than other
> lenguage, it means. Why the is python developed? what's his target? i
> am interessed but after thesis.
> Bye bye Marco.
>
To answer your first question, knowing Fortran is very useful accross
scientific computing. These days it's not used very much outside
scientific computing. That said, getting more experienced at programming
any language will help you a lot in programming other languages.
As for Python, it's an interpreted language which is used a lot for
scripting and increasingly for applications development. It does have
some facility for numerics but it's unlikely to set any speed records
and its numerics syntax is not as handy as Fortran 90's. Personally if
speed is not that much of an issue so you're considering interpreted
languages for a numerical problem, I'd go for Matlab above Python.
Python is utterly brilliant, though, for mucking around with data files
so we use it a lot to mangle the output of one tool to feed it into
another tool.
Regards,
David
| |
| Rich Townsend 2005-11-22, 7:59 am |
| David Ham wrote:
> Aleramo wrote:
>
>
> To answer your first question, knowing Fortran is very useful accross
> scientific computing. These days it's not used very much outside
> scientific computing. That said, getting more experienced at programming
> any language will help you a lot in programming other languages.
>
> As for Python, it's an interpreted language which is used a lot for
> scripting and increasingly for applications development. It does have
> some facility for numerics but it's unlikely to set any speed records
> and its numerics syntax is not as handy as Fortran 90's. Personally if
> speed is not that much of an issue so you're considering interpreted
> languages for a numerical problem, I'd go for Matlab above Python.
> Python is utterly brilliant, though, for mucking around with data files
> so we use it a lot to mangle the output of one tool to feed it into
> another tool.
Getting totally off topic, does Python have significant capabilities not found
in Perl? At the moment, I find Perl fits all of my data-hacking needs, but I'm
keen to hear if Python would be an even-better tool for the job.
cheers,
Rich
| |
| David Ham 2005-11-22, 7:01 pm |
| Rich Townsend wrote:
> David Ham wrote:
>
>
>
> Getting totally off topic, does Python have significant capabilities not
> found in Perl? At the moment, I find Perl fits all of my data-hacking
> needs, but I'm keen to hear if Python would be an even-better tool for
> the job.
I'm not very familiar with Perl so I don't know what the precise
differences in funcitonality are. Basically Python and Perl are direct
competitors which are used to do many of the same things. The usual
comment in favour of Python is that it's syntax has less of a tendency
to descend into a seemingly random string of characters and hence that
it's significantly easier to write maintainable code in Python than in
Perl. Of course it's always possible to code badly in any language :-)
and I'm sure there are many examples around of very readable
maintainable code.
On the other hand the fact that indentation is syntactically significant
in Python drives some people up the wall.
I guess the short answer is that if you know Perl already, there's
probably no killer reason to switch.
Regards,
David
>
> cheers,
>
> Rich
| |
| Pierre Asselin 2005-11-22, 7:01 pm |
| Aleramo <monferrato2006@yahoo.it> wrote:
> I know only the C and a bit of Fortran 90. It's the reason of my topic.
> I want to know if learning more about Fortran can be useful.
In that case you should write in C, profile your code to identify
the bottlenecks, and try to rewrite them in Fortran.
Be aware that mixed-language programming is full of traps. Read
your compiler manuals carefully and keep the C--Fortran interface
simple. If the gains are substantial you can consider rewriting
the whole thing in Fortran.
--
pa at panix dot com
| |
| Jon Harrop 2005-11-22, 7:01 pm |
| Aleramo wrote:
> I am an university student and i am doing my thesis. I thought to do my
> thesis in C with some function in Fortran 90. When is better using
> Fortran 90 and when the C?
Fortran is ideal for a subset of numerical calculations. Specifically, those
that work well with arrays and the numeric types provided by Fortran.
C is good for systems programming (e.g. writing operating systems and device
drivers). It is good for a subset of the subset of numerical calculations
that Fortran is good for.
> I am studing an Antenna.
What algorithms are you going to be writing? How long do you think your
programs will take to run? How long do you think your programs will take to
write?
There is a good chance that both Fortran and C are bad choices...
--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com
| |
| Michael Wild 2005-11-22, 7:01 pm |
| I think the other posters have put it nicely... As for my nationality:
I'm swiss :-)
And as for g95: I gather, it's very strict to the standard, and there's
some weird standard-adhering code which compiles *only* with g95, but
small chance you're going to use such features :-) But on the other
side, its optimization features are rather weak and the code produced is
rather slow. For example, I did an implementation of the Barnes-Hutt
algorithm. Using g95 it took about 30 secs to run on 1e4 particles. The
Intel compiler took about the same time without any optimization.
However, applying aggressive optimization, loop unrolling, prefetching,
vectorization and parallelization yielded a run-time on the same problem
of about a second!
There's no doubt you could write code for g95 which is about as fast as
the one produced by the Intel compiler, but it's going to be a lot of
work (manual unrolling, using sse intrinsics etc.).
So, if you're not earning money with your code and are going for
Fortran, I suggest you go to the Intel homepage and download the free
non-commercial version of the Fortran compiler (and perhaps also the
MKL). Their C++ compiler is also for free for non-commercial purposes.
Michael
| |
| Greg Lindahl 2005-11-22, 7:01 pm |
| In article <438396fc$1@news1.ethz.ch>,
Michael Wild <mwild@student.ethz.ch> wrote:
>So, if you're not earning money with your code and are going for
>Fortran, I suggest you go to the Intel homepage and download the free
>non-commercial version of the Fortran compiler
I think you are possibly mis-stating the terms of this
compiler. Please see this post by Steve Lionel about it:
http://groups.google.com/group/comp...0a4c7f400762e7b
In particular, getting paid to do research is one use that is not
eligible for the free compiler, even if the fruits of your research
are given away for free. In the US, for example, most graduate
students are paid to do their Master's and PhD research.
-- greg
(yes, I work for a competitor to Intel's compiler.)
| |
| Michael Wild 2005-11-22, 7:01 pm |
| Possibly you're right in the sense that I was too sloppy, but then it's
everybody's own responsibility to adhere to the license. But I think
saying, that you're eligible if you're not getting paid and the software
won't be sold is summing it up.
michael
| |
| Gary L. Scott 2005-11-22, 9:57 pm |
| Joe Krahn wrote:
> Aleramo wrote:
>
> Fortran is an excellent language to do calculations, but not for
> 'application programming', which is about 90% user interface. If you are
> programming for the sake of math, use Fortran.
Actually, Fortran is also excellent for "application programming".
There are several graphics bindings/APIs for Fortran that make GUI
programming far easier than direct Win32 API calls whether in C or Fortran.
>
> As for C, it is definitely a bad choice. However, C++ can be quite good
> along with a matrix class. The problem is that there are a lot of matrix
> class libraries to pick from, many of which are good, but incompatible
> with each other. It's a world driven by people who like learning 10 ways
> to program the same thing.
>
> Alternatively, if you want to do some user interface stuff, you could
> use a script language, like Python, for the user interface, and Fortran
> for the math.
>
> Joe Krahn
--
Gary Scott
mailto:garyscott@ev1.net
Fortran Library: http://www.fortranlib.com
Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html
Why are there two? God only knows.
If you want to do the impossible, don't hire an expert because he knows
it can't be done.
-- Henry Ford
| |
| David Ham 2005-11-23, 7:57 am |
| Greg Lindahl wrote:
> In article <438396fc$1@news1.ethz.ch>,
> Michael Wild <mwild@student.ethz.ch> wrote:
>
>
>
>
> I think you are possibly mis-stating the terms of this
> compiler. Please see this post by Steve Lionel about it:
>
> http://groups.google.com/group/comp...0a4c7f400762e7b
>
> In particular, getting paid to do research is one use that is not
> eligible for the free compiler, even if the fruits of your research
> are given away for free. In the US, for example, most graduate
> students are paid to do their Master's and PhD research.
However in some countries (I don't know about the US: this applies in
the UK and Australia), students on scholarships are not by law
considered to be payed to produce their research. This is also the
reason that such students are not considered employees despite being
paid by the university and has important tax and copyright consequences.
Presumably students in those countris are, in Intel's words,
"Non-commercial means that you are not getting compensated in any form
for the products and/or services you develop using these Intel® Software
Products."
On the other hand, PhD students who are engaged as employees to do their
research, as is the case in many European countries, clearly fall
outside the Intel definition of non-commercial.
Usual disclaimer: I have a law degree but I am not a lawyer.
David
| |
| Jon Harrop 2005-11-23, 7:57 am |
| Pierre Asselin wrote:
> Aleramo <monferrato2006@yahoo.it> wrote:
>
> In that case you should write in C, profile your code to identify
> the bottlenecks, and try to rewrite them in Fortran.
Before you consider rewriting anything in another language, you should first
consider algorithmic optimisations and then consider low-level
optimisations. There is no point in rewriting a fundamentally inefficient
algorithm in Fortran...
--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com
| |
| awgreynolds@earthlink.net 2005-11-23, 7:00 pm |
|
Michael Wild wrote:
> And as for g95: I gather, it's very strict to the standard, and there's
> some weird standard-adhering code which compiles *only* with g95, but
> small chance you're going to use such features :-) But on the other
> side, its optimization features are rather weak and the code produced is
> rather slow. For example, I did an implementation of the Barnes-Hutt
> algorithm. Using g95 it took about 30 secs to run on 1e4 particles. The
> Intel compiler took about the same time without any optimization.
> However, applying aggressive optimization, loop unrolling, prefetching,
> vectorization and parallelization yielded a run-time on the same problem
> of about a second!
> There's no doubt you could write code for g95 which is about as fast as
> the one produced by the Intel compiler, but it's going to be a lot of
> work (manual unrolling, using sse intrinsics etc.).
I use the following optimization switches with the latest g95 (uses GCC
4.0.2 backend)
-O3 -malign-double -march=pentium4 -mfpmath=sse -funroll-loops
-ffast-math
and get performance almost identical to the commercial Lahey compiler.
I don't have the Intel compiler at this time but past experience would
indicate it is at most twice as fast as this (not the 30X you see).
Al Greynolds
| |
| Michael Prager 2005-11-25, 7:00 pm |
| Rich,
Rich Townsend <rhdt@barVOIDtol.udel.edu> wrote:
>Getting totally off topic, does Python have significant capabilities not found
>in Perl? At the moment, I find Perl fits all of my data-hacking needs, but I'm
>keen to hear if Python would be an even-better tool for the job.
Python's syntax is much more structured and legible than that of
Perl. Thus it often appeals to those who like Fortran. One can
go back to a Python program months or years later and understand
it.
You can check it out for yourself at
http://www.python.org/
--
Mike Prager, NOAA, Beaufort, NC
Address spam-trapped; remove color to reply.
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.
| |
| Gunnar G 2005-12-05, 7:04 pm |
| > Actually, Fortran is also excellent for "application programming".
> There are several graphics bindings/APIs for Fortran that make GUI
> programming far easier than direct Win32 API calls whether in C or
> Fortran.
Such as? I've never heard of any. Please tell me/us.
| |
| Richard Maine 2005-12-05, 7:04 pm |
| Gunnar G <debian@comhem.se> wrote:
>
> Such as? I've never heard of any. Please tell me/us.
I didn't see the earlier parts of this thread, so perhaps I've just
wandered into the middle of a flame war (in which case I'll duck right
back out). The above sounds like possibly a communication problem
because there are *LOTS* of graphics bindings for things other than
Win32API. It is hard to imagine looking and not being able to find them
unless there is a communication problem in defining what is meant.
Some of them go back 3 or 4 decades. Ok, the CalComp HCBS library isn't
the most sophisticated thing by today's standards, but it is a graphics
API and it has multiple implementations on Windows. Then there are
things like OpenGL. Winteracter and Gino are mentioned here regularly;
they are good current candidates. There are a bunch of others also -
dozens of them.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
|
|
|
|
|