@m_b_metcalf , in case this has not been noted already, FIgure A.4 in the Eighth Edition of Modern Fortran Explained has typos related to pivotptr
variable since Figure A.3 in indicated as the basis: the following is suggested.
Figure A.4 Huge unreadable nested if constructs
if ( allocated(worka) ) then
if ( allocated(workb1) then
if ( allocated(workb2) ) then
if ( associated(pivotptr) ) then
call process_work( x, worka, workb1, workbb2, pivotptr )
else
call process_work( x, worka, workb1, worbk2 )
end if
else if ( associated(pivotptr) ) then
call process_work( x, worka, workb1, pivot=pivotptr )
else
call process_work( x, worka, workb1 )
end if
.
. ( Remainder of large nested if coonstruct elided
.