Better way to mask a Fortran array?

I am wanting to mask a Fortran array. Here's the way I am currently doing it...

where (my_array <=15.0)
    mask_array = 1
    mask_array = 0
end where

So then I get my masked array with:

masked = my_array * mask_array

Is there a more concise way to do this?


  • Use the MERGE intrinsic function:

    masked = my_array * merge(1,0,my_array<=15.0)