Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
29306 Discussions

MINVAL, Mask Condition Not Met, 2147483647

Ernie_P_1
Beginner
1,398 Views
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:


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.

0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,398 Views
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

View solution in original post

0 Kudos
1 Reply
Steven_L_Intel1
Employee
1,399 Views
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
0 Kudos
Reply