Finds the first valid block, inclusive from the current position. If there is no valid block, pos is set to 0
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout) | :: | pos |
input: current position; output: next valid position or 0 |
||
integer, | intent(in) | :: | maxpos |
maximal allowed position |
||
integer, | intent(in), | DIMENSION(:) | :: | blk_p |
block pointers, used to check validity |
PURE SUBROUTINE find_first_valid_block(pos, maxpos, blk_p) !! Finds the first valid block, inclusive from the current position. !! If there is no valid block, pos is set to 0 INTEGER, INTENT(INOUT) :: pos !! input: current position; output: next valid position or 0 INTEGER, INTENT(IN) :: maxpos !! maximal allowed position INTEGER, DIMENSION(:), INTENT(IN) :: blk_p !! block pointers, used to check validity ! --------------------------------------------------------------------------- !IF (pos .LT. 1) pos = 1 DO WHILE (pos .LE. maxpos) IF (blk_p(pos) .EQ. 0) THEN pos = pos + 1 ELSE EXIT END IF END DO IF (pos .GT. maxpos) pos = 0 END SUBROUTINE find_first_valid_block