109. Setting the values of an array section#

topic: Arrays

Note

This tip is a draft1.

Fortran array indices must be integers, so you cannot write

v(v<0) = -1

as in R, but alternatives are

where (v<0) v = -1 v = merge(-1,v,v<0) v(truloc(v<0)) = -1

where truloc is a user function that creates a vector subscript from a logical mask.



1

From the perspective of FortranTip Browser, “draft” means that it hasn’t been edited for formatting, hasn’t had corresponding Fortran programs added, the text content hasn’t been enhanced, etc. Draft texts are extracted from the corresponding Tweet using the Twitter API.