19 integer,
intent(in) :: dmax(:), dsum
22 integer :: ifirst, iremaining
24 call
assert(sum(dmax) >= dsum)
28 if (
size(dmax) == 1)
then
36 do ifirst = min(dmax(1), dsum), 0, -1
37 iremaining = dsum - ifirst
38 if ( sum(dmax(2:)) < iremaining )
exit
46 integer,
intent(in) :: dmax(:), dsum, ccounttotal
47 integer :: comb(ccounttotal, size(dmax))
50 integer :: ifirst, ccount, csubcount, iremaining
54 if (
size(dmax) == 1)
then
63 do ifirst = min(dmax(1), dsum), 0, -1
64 iremaining = dsum - ifirst
65 if ( sum(dmax(2:)) < iremaining )
exit
67 comb(ccount + 1 : ccount + csubcount, 1) = ifirst
69 ccount = ccount + csubcount
72 call
assert( ccount == ccounttotal )
78 integer,
intent(in) :: dmax(:), dsum
79 integer,
allocatable :: comb(:, :)
85 allocate( comb(ccount,
size(dmax)) )