This is achieved using WHERE:
WHERE (I .NE. 0) A = B/I
the LHS of the assignment must be array valued and the mask, (the logical expression,) and the RHS of the assignment must all conform;
For example, if
and,
then
Only the indicated elements, corresponding to the non-zero elements of I, have been assigned to.
For more information, click here