Maybe alternatively, you could flatten the multi loop into a single one going over all required combinations. For the program of Answer 1, that could look like:
program nested implicit none integer :: num_nests, i,j,k integer, dimension(:), allocatable :: nest_limits integer, dimension(:), allocatable :: nests
print *, "Please enter number of nests:"
read(*, *) num_nests
allocate(nest_limits(num_nests))
allocate(nests(num_nests))
print *, "Please enter nest limits:"
read(*, *) nest_limits
do i=0,product(nest_limits)-1
j=i
do k=1,num_nests
nests(k)=1+mod(j,nest_limits(k))
j=j/nest_limits(k)
enddo
print *, nests(:)
enddo
end program nested