- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I want to find the minimum value of an array only from those elements greater than zero. Suppose no elements are greater than zero and there are no values to use when calculating the MINVAL. How do I prevent 2147483647 from being returned? Psuedo code below:
NUM = 999999 !DEFAULT VALUE
NUM = MINVAL(MY_ARRAY, MASK=MY_ARRAY.GT.0)
NUM gets set to 2147483647. I'd like it to retain 999999. How can I do this?
I suppose the following workaround would be sufficient, but I don't want to do this:
I want to find the minimum value of an array only from those elements greater than zero. Suppose no elements are greater than zero and there are no values to use when calculating the MINVAL. How do I prevent 2147483647 from being returned? Psuedo code below:
NUM = 999999 !DEFAULT VALUE
NUM = MINVAL(MY_ARRAY, MASK=MY_ARRAY.GT.0)
NUM gets set to 2147483647. I'd like it to retain 999999. How can I do this?
I suppose the following workaround would be sufficient, but I don't want to do this:
IF(SUM(MY_ARRAY).GT.0)THEN
NUM = MINVAL(MY_ARRAY,MASK=MY_ARRAY.GT.0)
ELSE
NUM = 999999
END IF
Thanks in advance for your help.
Ernie P.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can't prevent MINVAL from returning HUGE(0) when the set of values being tested is empty - that's what the standard requires. It has to return something.
You might do something like this:
NUM = MINVAL(MY_ARRAY,MASK=MY_ARRAY > 0)
IF (NUM == HUGE(NUM) NUM = 999999
You might do something like this:
NUM = MINVAL(MY_ARRAY,MASK=MY_ARRAY > 0)
IF (NUM == HUGE(NUM) NUM = 999999
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can't prevent MINVAL from returning HUGE(0) when the set of values being tested is empty - that's what the standard requires. It has to return something.
You might do something like this:
NUM = MINVAL(MY_ARRAY,MASK=MY_ARRAY > 0)
IF (NUM == HUGE(NUM) NUM = 999999
You might do something like this:
NUM = MINVAL(MY_ARRAY,MASK=MY_ARRAY > 0)
IF (NUM == HUGE(NUM) NUM = 999999

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page