Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

"14 % 8" for example...
Hi,

I'm trying to translate a piece of fortran code into Perl. I was able to
understand all the functions in the code, except for this one; what
operation is c = a % b ? Is it the same of int(a/b)?

Please - someone - answer as soon as possible.

Best regards,

Kepler


Report this thread to moderator Post Follow-up to this message
Old Post
kepler
09-28-04 02:01 AM


Re: "14 % 8" for example...

kepler wrote:

> Hi,
>
> I'm trying to translate a piece of fortran code into Perl. I was able to
> understand all the functions in the code, except for this one; what
> operation is c = a % b ? Is it the same of int(a/b)?

No, it's not an arithmetic operation, it's a structure
selector.  Someplace you'll find "b" declared with
something like
type (some_type_name)  ::  b
and if you look in the definition of some_type_name
you'll see that it has a component named "c".
The syntax selects that component.

Dick Hendrickson
>
> Please - someone - answer as soon as possible.
>
> Best regards,
>
> Kepler
>


Report this thread to moderator Post Follow-up to this message
Old Post
Dick Hendrickson
09-28-04 02:01 AM


Re: "14 % 8" for example...
Sorry, I've got the b's and c's in the wrong order ;(

Dick Hendrickson wrote:

>
>
> kepler wrote:
> 
>
>
> No, it's not an arithmetic operation, it's a structure
> selector.  Someplace you'll find "b" declared with
> something like
>     type (some_type_name)  ::  b
That should be                   a
> and if you look in the definition of some_type_name
> you'll see that it has a component named "c".
That should be                              b
> The syntax selects that component.
>
> Dick Hendrickson
> 
>


Report this thread to moderator Post Follow-up to this message
Old Post
Dick Hendrickson
09-28-04 02:01 AM


Re: "14 % 8" for example...
"kepler" <ruifernandes@tvtel.pt> writes:

> I'm trying to translate a piece of fortran code into Perl. I was able to
> understand all the functions in the code, except for this one; what
> operation is c = a % b ? Is it the same of int(a/b)?

If the code is actually Fortran, then a%b means the component b of the
derived type object (structure) a.  However....

1. I find it hard to imagine that you would understand everything other
than this in a Fortran code that uses it.  That would mean that
you would have understood the derived type definition and declarations.
Sort of hard to understand derived type definitions and declarations
without understanding at least something about how one would use a
derived type (and a%b is about as basic as such usage gets).

2. Neither a nor b can be numbers - they are names.  Although you use
names in the text of the posting, you use numbers in the subject
line.

The above 2 points make me suspicious that what you have might be some
vendor extension to F77 instead of being standard Fortran of any
variety. If that's the case, then I have no idea what it means.

--
Richard Maine                       |  Good judgment comes from experience;
email: my first.last at org.domain  |  experience comes from bad judgment.
org: nasa, domain: gov              |        -- Mark Twain

Report this thread to moderator Post Follow-up to this message
Old Post
Richard E Maine
09-28-04 02:01 AM


Re: "14 % 8" for example...
In article <m1hdpj8mjx.fsf@MLMCE0000L22801.local>, Richard E Maine wrote:
> "kepler" <ruifernandes@tvtel.pt> writes:
> 
>
> If the code is actually Fortran, then a%b means the component b of the
> derived type object (structure) a.  However....
>
> 1. I find it hard to imagine that you would understand everything other
>    than this in a Fortran code that uses it.  That would mean that
>    you would have understood the derived type definition and declarations.
>    Sort of hard to understand derived type definitions and declarations
>    without understanding at least something about how one would use a
>    derived type (and a%b is about as basic as such usage gets).
>
> 2. Neither a nor b can be numbers - they are names.  Although you use
>    names in the text of the posting, you use numbers in the subject
>    line.
>
> The above 2 points make me suspicious that what you have might be some
> vendor extension to F77 instead of being standard Fortran of any
> variety. If that's the case, then I have no idea what it means.

Some (popular) languages use "a % b" to mean modulo(a,b), i.e. the
remainder of a/b. Perhaps some vendor decided to borrow this from C?


--
Janne Blomqvist

Report this thread to moderator Post Follow-up to this message
Old Post
Janne Blomqvist
09-28-04 02:01 AM


Re: "14 % 8" for example...
In article <m1hdpj8mjx.fsf@MLMCE0000L22801.local>, Richard E Maine wrote:
> "kepler" <ruifernandes@tvtel.pt> writes:
> 
>
> If the code is actually Fortran, then a%b means the component b of the
> derived type object (structure) a.  However....
>
> 1. I find it hard to imagine that you would understand everything other
>    than this in a Fortran code that uses it.  That would mean that
>    you would have understood the derived type definition and declarations.
>    Sort of hard to understand derived type definitions and declarations
>    without understanding at least something about how one would use a
>    derived type (and a%b is about as basic as such usage gets).
>
> 2. Neither a nor b can be numbers - they are names.  Although you use
>    names in the text of the posting, you use numbers in the subject
>    line.
>
> The above 2 points make me suspicious that what you have might be some
> vendor extension to F77 instead of being standard Fortran of any
> variety. If that's the case, then I have no idea what it means.

Some (popular) languages use "a % b" to mean mod(a,b), i.e. the
remainder of a/b. Perhaps some vendor decided to borrow this from C?


--
Janne Blomqvist

Report this thread to moderator Post Follow-up to this message
Old Post
Janne Blomqvist
09-28-04 02:01 AM


Re: "14 % 8" for example...
Richard E Maine wrote:

> "kepler" <ruifernandes@tvtel.pt> writes:
 

> If the code is actually Fortran, then a%b means the component b of the
> derived type object (structure) a.  However....

> 1. I find it hard to imagine that you would understand everything other
>    than this in a Fortran code that uses it.  That would mean that
>    you would have understood the derived type definition and declarations.
>    Sort of hard to understand derived type definitions and declarations
>    without understanding at least something about how one would use a
>    derived type (and a%b is about as basic as such usage gets).

I might believe it.  Lately I have been working on a project in verilog,
but sometimes I have to read files in VHDL.  I don't know VHDL,
but usually I can figure out the important part, the equivalent
of the executable statements.   I can imagine reading Fortran without
knowing the meaning of the declaration statements.  Fortran is similar
enough to some other languages that it wouldn't take too long.

If you are used to Fortran and don't know Perl, it would probably be
about the same level of understanding.

-- glen


Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
09-28-04 02:01 AM


Re: "14 % 8" for example...
Janne Blomqvist wrote:
>
> Some (popular) languages use "a % b" to mean mod(a,b), i.e. the
> remainder of a/b. Perhaps some vendor decided to borrow this from C?

No, this syntactic eyesore was decided on by the misguided committee
even though all principal vendors supported (and still do) the *dot*.


Report this thread to moderator Post Follow-up to this message
Old Post
bv
09-29-04 02:28 AM


Re: "14 % 8" for example...
bv wrote:

> Janne Blomqvist wrote:
 

> No, this syntactic eyesore was decided on by the misguided committee
> even though all principal vendors supported (and still do) the *dot*.

I was guessing that it would be ambiguous with certain operators
that are dot delimited.


X=A.GE.B

-- glen


Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
09-29-04 10:00 AM


Re: "14 % 8" for example...
>> No, this syntactic eyesore was decided on by the misguided committee 
> I was guessing that it would be ambiguous with certain operators
> that are dot delimited.

Yes. And even Steve & Co., who had been supporting this extension for two
decades now at least, had to fix a bug in the compiler's context-dependant
guessing of the dot's meaning quite recently. But all that has been explaine
d
to bv multiple times in the past, and he just refuses to acknowledge reality
.

Jan

Report this thread to moderator Post Follow-up to this message
Old Post
Jan Vorbrüggen
09-29-04 10:00 AM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:31 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.