Re: Help please with a small code conversion
From: Dave Seaman (dseaman_at_no.such.host)
Date: 10/19/04
- Next message: Dave Seaman: "Re: Installing g95 on OS X"
- Previous message: Madhusudan Singh: "Re: Which Fortran editor do you prefer to work with, in Linux?"
- In reply to: Jason: "Help please with a small code conversion"
- Next in thread: John Harper: "Re: Help please with a small code conversion"
- Reply: John Harper: "Re: Help please with a small code conversion"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 19 Oct 2004 19:17:12 +0000 (UTC)
On 19 Oct 2004 10:36:02 -0700, Jason wrote:
> I am trying to convert a piece of FORTRAN code to C++.
> write(ifile,*) h(i,j)
> Does this simply write to a file a entry from a Ith by Jth entry of a
> matrix?
Probably, but there's an outside chance that it could mean to call a
function named 'h' with arguments i and j. In Fortran you can't tell the
difference except by looking to see how (or whether) h is declared. If h
is not declared at all in that program unit, then it's a function.
>If so what does (ifile, *) do? Does this make the entry
> added to a file called (ifile)?
Not quite; ifile is an integer variable whose value is the unit number
associated with the file (sort of like file descriptors in C). The "*"
means that instead of specifying a format for the write, the program is
using "list directed output", which is somewhat similar in spirit to
using the "<<" output operator in C++, since the format is dictated by
the type of the item being written.
> Also there is another line that has me stuck
> implicit double precision(a-h,o-z)
The default specification in Fortran is
implicit real (a-h,o-z)
implicit integer (i-n)
which means you are allowed to have undeclared variables in Fortran, and
their types are inferred from the first letter of the name (hence the
saying: "God is REAL, unless declared INTEGER."). The purpose of the
implicit statement is to change the default type mapping.
> I am not sure the significance of implicit. How could I get the same
> effect using c++?
You can't. All variables must be given explicit types in C++. Think of
it as insurance againt typos.
-- Dave Seaman Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling. <http://www.commoncouragepress.com/index.cfm?action=book&bookid=228>
- Next message: Dave Seaman: "Re: Installing g95 on OS X"
- Previous message: Madhusudan Singh: "Re: Which Fortran editor do you prefer to work with, in Linux?"
- In reply to: Jason: "Help please with a small code conversion"
- Next in thread: John Harper: "Re: Help please with a small code conversion"
- Reply: John Harper: "Re: Help please with a small code conversion"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|