Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messagekepler 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 >
Post Follow-up to this messageSorry, 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 > >
Post Follow-up to this message"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
Post Follow-up to this messageIn 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
Post Follow-up to this messageIn 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
Post Follow-up to this messageRichard 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
Post Follow-up to this messageJanne 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*.
Post Follow-up to this messagebv 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
Post Follow-up to this message>> 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
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.