Configure-time guard: every draft entry is finite and >= 0.
The >= 0 test is written as .not. (z >= 0) so a NaN FAILS it:
every comparison with NaN is false, so the naive z < 0 test
would wave a NaN straight through — the same trap the
NaN-laundering clamp gotcha describes, in its cheap form.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | z_draft(nx,ny) | |||
| integer, | intent(in) | :: | nx | |||
| integer, | intent(in) | :: | ny |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | i | ||||
| integer, | private | :: | j |
pure function cavity_draft_is_finite_nonneg(z_draft, nx, ny) result(ok) !! Configure-time guard: every draft entry is finite and `>= 0`. !! !! The `>= 0` test is written as `.not. (z >= 0)` so a NaN FAILS it: !! every comparison with NaN is false, so the naive `z < 0` test !! would wave a NaN straight through — the same trap the !! NaN-laundering clamp gotcha describes, in its cheap form. integer, intent(in) :: nx, ny real(wp), intent(in) :: z_draft(nx, ny) logical :: ok integer :: i, j ok = .true. do j = 1, ny do i = 1, nx if (.not. (z_draft(i, j) >= 0.0_wp)) ok = .false. if (.not. (z_draft(i, j) < huge(1.0_wp))) ok = .false. end do end do end function cavity_draft_is_finite_nonneg