|
|
 |
 |
 |
 |
Fortran Programming Language
|
 |
 |
 |
 |
 |
 |
 |
 |
IF statements
Hey guys, I have a grid, and using an IF statement, I want to trigger a series of commands if the variable 'result' is within the grid cell 'square1'. I am able to achieve this using an IF statement for if a value is equal to, less or greater than a given number for example, but how would I create a statement to trigger the rest of the code if 'result' is simply present within the cell? Many thanks for any suggestions, smurray444
On May 29, 10:35 am, smurray444 <smurray@gmail.com> wrote: > Hey guys, > I have a grid, and using an IF statement, I want to trigger a series > of commands if the variable 'result' is within the grid cell > 'square1'. I am able to achieve this using an IF statement for if a > value is equal to, less or greater than a given number for example, > but how would I create a statement to trigger the rest of the code if > 'result' is simply present within the cell?
I am not sure I understand your question, but maybe you are looking for a construct such as if (x >= xlow .and. x <= xhi) then ! do something end if
On May 29, 11:46 am, Beliavsky <beliav@aol.com> wrote:
> On May 29, 10:35 am, smurray444 <smurray @gmail.com> wrote: > > Hey guys, > > I have a grid, and using an IF statement, I want to trigger a series > > of commands if the variable 'result' is within the grid cell > > 'square1'. I am able to achieve this using an IF statement for if a > > value is equal to, less or greater than a given number for example, > > but how would I create a statement to trigger the rest of the code if > > 'result' is simply present within the cell? > I am not sure I understand your question, but maybe you are looking > for a construct such as > if (x >= xlow .and. x <= xhi) then > ! do something > end if
I interpret the OP's question as asking for something like IF_EXIST (x(1)) or If_not_NaN (x(1)), neither of which holds much promise of portability, I guess.
On May 29, 9:46 am, Beliavsky <beliav@aol.com> wrote:
> On May 29, 10:35 am, smurray444 <smurray @gmail.com> wrote: > > Hey guys, > > I have a grid, and using an IF statement, I want to trigger a series > > of commands if the variable 'result' is within the grid cell > > 'square1'. I am able to achieve this using an IF statement for if a > > value is equal to, less or greater than a given number for example, > > but how would I create a statement to trigger the rest of the code if > > 'result' is simply present within the cell? > I am not sure I understand your question, but maybe you are looking > for a construct such as > if (x >= xlow .and. x <= xhi) then > ! do something > end if
Given the discussion of a square, I'm wondering if it would be more like if((x >= xlow .and. x <= xhi) .and. (y >= ylow .and. y <= yhi)) then ! do something end if although I, like Gus, wonder whether the meaning of "simply present" is somehow different than the above test...
Hi guys - thanks for your replies so far. Just to clarify, by being 'present' in the cell, I mean, if the variable 'result' exists in a given cell - as I think Gus suggests. However, his code looks suitable only for Fortran 90, whereas I'm using Fortran 77, so I was wondering if there's a F77 equivalent? Many thanks, smurray444
In a previous article, smurray444 <smurray@gmail.com> wrote: >Hi guys - thanks for your replies so far. >Just to clarify, by being 'present' in the cell, I mean, if the >variable 'result' exists in a given cell - as I think Gus suggests. >However, his code looks suitable only for Fortran 90, whereas I'm >using Fortran 77, so I was wondering if there's a F77 equivalent? >Many thanks, >smurray444
First fill all the cells with a number you will regard as a gap. If the cell remains that number, then its value does "not exist". I usually use 1.e7 for similar purposes ... depends on your actual values. Chris
On May 30, 1:02 am, m@skyway.usask.ca wrote:
> In a previous article, smurray444 <smurray @gmail.com> wrote:>Hi guys - thanks for your replies so far. > >Just to clarify, by being 'present' in the cell, I mean, if the > >variable 'result' exists in a given cell - as I think Gus suggests. > >However, his code looks suitable only for Fortran 90, whereas I'm > >using Fortran 77, so I was wondering if there's a F77 equivalent? > >Many thanks, > >smurray444 > First fill all the cells with a number you will regard as a gap. > If the cell remains that number, then its value does "not exist". > I usually use 1.e7 for similar purposes ... depends on your > actual values. > Chris
I use a bit table to decide if a cell contains a value or is empty. The bit table is set to all zeros as an integer 2 or 4 zeroing. Frnm the coordinates of the cell I easily form a byte index and a bit number. As the table is filled I set the cell bit. On processing I can check the bit. This is the heart of survey processing of truth values to count responses where the cell might contain a quantity.
I use a bit table to decide if a cell contains a value or is empty. The bit table is set to all zeros as an integer 2 or 4 zeroing. Frnm the coordinates of the cell I easily form a byte index and a bit number. As the table is filled I set the cell bit. On processing I can check the bit. This is the heart of survey processing of truth values to count responses where the cell might contain a quantity.
Sorry, The Google Forum said there was an error and to try again later, so I posted the message later and that time got confirmation. I see it went in the first time anyhow! It seems to take 3 minutes to accept a posting in all Forums recently - very curious.
Thanks for your replies. As a novice I'd be most comfortable using the EXIST statement - but how would I go about doing this? Would I first need to use INQUIRE? Many thanks for any help offered. smurray444
On May 31, 12:14 pm, smurray444 <smurray@gmail.com> wrote: > Thanks for your replies. As a novice I'd be most comfortable using the > EXIST statement - but how would I go about doing this? Would I first > need to use INQUIRE? > Many thanks for any help offered. > smurray444
I think as a novice it would be easiest to follow meek's advice. When you first set up the array, fill it with a value you know to be nonsensical. For instance, put -1 if you know that all the genuine values must be nonnegative. Then you can test existence by IF (array(i) .ge. 0) then ...
smurray444 <smurray @gmail.com> wrote: > Thanks for your replies. As a novice I'd be most comfortable using the > EXIST statement - but how would I go about doing this? Would I first > need to use INQUIRE? You might be "confortable" using EXIST and/or INQUIRE, but since they have absolutely nothing to do with your problem, they aren't likely to be helpful. For that matter, there isn't an EXIST statement at all; it is just a part of an INQUIRE statement. INQUIRE relates *ONLY* to input/output, which has nothing to do with your problem. The other suggestions already posted are more likely to do the trick. -- Richard Maine | Good judgement comes from experience; email: last name at domain . net | experience comes from bad judgement. domain: summertriangle | -- Mark Twain
smurray444 wrote: > Hi guys - thanks for your replies so far. > Just to clarify, by being 'present' in the cell, I mean, if the > variable 'result' exists in a given cell - as I think Gus suggests. > However, his code looks suitable only for Fortran 90, whereas I'm > using Fortran 77, so I was wondering if there's a F77 equivalent? > Many thanks, > smurray444
The FORTRAN 77 equivalent would be if((x .GE. xlow .and. x .LE. xhi) .and. (y .GE. ylow .and. y .LE. yhi)) then ! do something end if Dick Hendrickson
|
 |
 |
 |
 |
|