<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Variable number of nested loops in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238078#M153339</link>
    <description>&lt;P&gt;I can't think of a way to do this. Consider an alternate approach - maybe one that uses a list of actions to take.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2020 00:28:10 GMT</pubDate>
    <dc:creator>Steve_Lionel</dc:creator>
    <dc:date>2020-12-17T00:28:10Z</dc:date>
    <item>
      <title>Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238058#M153336</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;How to write a Fortran code with a variable number of nested loops.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2020 22:23:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238058#M153336</guid>
      <dc:creator>roy437</dc:creator>
      <dc:date>2020-12-16T22:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238078#M153339</link>
      <description>&lt;P&gt;I can't think of a way to do this. Consider an alternate approach - maybe one that uses a list of actions to take.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 00:28:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238078#M153339</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2020-12-17T00:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238089#M153341</link>
      <description>&lt;P&gt;In old Fortran, such nested looping would be accomplished using GOTO statements.&lt;/P&gt;
&lt;P&gt;Instead of writing the nested loops explicitly using DO constructs, you can accomplish the same effect by using recursive subroutines or functions. See, for example, &lt;A href="https://www.cesm.ucar.edu/models/atm-cam/docs/cam3.0/cam30fv-browser/html_code/utils/quicksort.F90.html" target="_self"&gt;this implementation of Quicksort&lt;/A&gt;. The recursion can be ended by reaching a count that is computed at run time, or a more general condition may be used.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 01:12:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238089#M153341</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-12-17T01:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238202#M153343</link>
      <description>&lt;P&gt;Could you explain your use case in some detail? Recursion is certainly a versatile tool, but I simply do not understand what you are trying to accomplish &lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt; and there may be other, more appropriate ways. (Also it would satisfy my curiosity)&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 07:12:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238202#M153343</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2020-12-17T07:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238297#M153354</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="roy437_0-1608204368785.png" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/14185i61CF4CE366582E54/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="roy437_0-1608204368785.png" alt="roy437_0-1608204368785.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For m=2 and m = 3 here it is code:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;select case (m)
  case (2)
    do i1 = 0, 9
      do i2 = 0, 9
        do i3 = 0, 9
          e = v - n(2)*(p(2)+0.1*i2+0.01*i3)
          t = 10.0*(e/n(1)-p(1))-0.1*i1
          if(dabs(t-dnint(t))&amp;lt;1.0d-8.and.(-0.0001&amp;lt;=t.and.t&amp;lt;9.0001)) then  ! if t = 0, 1, 2, 3, ...9
            r(1) = p(1)+0.1* t+0.01*i1
            r(2) = p(2)+0.1*i2+0.01*i3
            go to 91
          end if
        end do
      end do
    end do
  case (3)
    do i1 = 0, 9
      do i2 = 0, 9
        do i3 = 0, 9
          do i4 = 0, 9
            do i5 = 0, 9
              e = v - n(2)*(p(2)+0.1*i2+0.01*i3) - n(3)*(p(3)+0.1*i4+0.01*i5)
              t = 10.0*(e/n(1)-p(1))-0.1*i1
              if(dabs(t-dnint(t))&amp;lt;1.0d-8.and.(-0.0001&amp;lt;=t.and.t&amp;lt;9.0001)) then  ! if t = 0, 1, 2, 3, ...9
                r(1) = p(1)+0.1* t+0.01*i1
                r(2) = p(2)+0.1*i2+0.01*i3
                r(3) = p(3)+0.1*i4+0.01*i5
                go to 91
              end if
            end do
          end do
        end do
      end do
    end do
end select
91 continue&lt;/LI-CODE&gt;
&lt;P&gt;I would like a code for some m.&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 11:33:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238297#M153354</guid>
      <dc:creator>roy437</dc:creator>
      <dc:date>2020-12-17T11:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238323#M153356</link>
      <description>&lt;P&gt;Well, for that sort of situations a solution using recursion is certainly useful. Your current code is a brute-force approach, nothing wrong with that. I would do the recursion on m: the sum up to and including m-1 (for particular choices of ji, ki and li) would provide a new value for V (Vnew = V - sum(i = 1...m-1)) and then you try and find values for jm, km and lm using the nested loop. If you find a solution, print it and be done with it (or continue the search). Once the search space for this level is exhausted, return and proceed with the next iteration. Something like:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;recursive subroutine searc( v, m, ... )
do j(i) = 1,9
    do k(i) = 1,9
        do l(i) = 1,9
            vnew = v - ...
            if ( vnew &amp;gt; 0 .and. m &amp;gt; 1 ) then
                call search( vnew, m-1, ... )
            else 
                print the solution ...
            endif
       enddo
    enddo 
enddo  &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp; Mind you: just a sketch!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 12:09:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238323#M153356</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2020-12-17T12:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238329#M153357</link>
      <description>&lt;P&gt;Arjen Markus is spot on, and I hope that his question gets you to think about methods other than blind brute force. The assignment appears to be a rather effective homework assignment, and it presents you with an opportunity to think/learn about the properties of modular arithmetic, and exploit that knowledge to make the program short, general and efficient.&lt;/P&gt;
&lt;P&gt;You do not need the arbitrarily-deep DO loop capability for this problem. You should not use a CASE construct for m = 2, 3, .... Instead, make m a variable and write code that will work for any input m, perhaps up to a limit. Unless you have a valid reason to use floating point arithmetic, do not use it for a Diophantine problem.&lt;/P&gt;
&lt;P&gt;Here is a hint to get you started. Find the answer by thinking and using pencil-and-paper:&lt;/P&gt;
&lt;P&gt;What is the value of V mod 10 ?&lt;/P&gt;
&lt;P&gt;If this is a homework assignment, you may be doing us as well as yourself a disservice by asking us to provide you with the code itself.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 12:50:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238329#M153357</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-12-17T12:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238342#M153360</link>
      <description>&lt;P&gt;This is not a homework assignment, it is a real problem that I face every day in my accounting work. Finding the solution with pencil and paper for m greater than 2 takes a long time.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 13:14:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238342#M153360</guid>
      <dc:creator>roy437</dc:creator>
      <dc:date>2020-12-17T13:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238344#M153361</link>
      <description>&lt;P&gt;Thanks, I'll try.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 13:22:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238344#M153361</guid>
      <dc:creator>roy437</dc:creator>
      <dc:date>2020-12-17T13:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238355#M153362</link>
      <description>&lt;P&gt;Your problem statement does not contain the array p(:), which your code does. Please state what it is, and whether it is an input array, part of the solution, or just a temporary array.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 13:54:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238355#M153362</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-12-17T13:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238385#M153365</link>
      <description>&lt;P&gt;p(i) is j(i) from equation, is known.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 15:40:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238385#M153365</guid>
      <dc:creator>roy437</dc:creator>
      <dc:date>2020-12-17T15:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238416#M153366</link>
      <description>&lt;P&gt;Roy, I have a solution that I am testing, and it has worked on a small problem that I made up.&lt;/P&gt;
&lt;P&gt;Please provide a couple of sample problems that you have solved, but don't give me the solution yet. That is, provide values for m, n(), j() and V.&lt;/P&gt;
&lt;P&gt;I am asking you for such problems because I may have chosen a rather trivial case.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 17:49:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238416#M153366</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-12-17T17:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238467#M153373</link>
      <description>&lt;P&gt;mecej4,&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;m = 2
n()  j()  V = 101646
20   46
 3   31

m = 3
n()  j()  V = 227444
12   78
25   46
 6   29&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 17 Dec 2020 21:28:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238467#M153373</guid>
      <dc:creator>roy437</dc:creator>
      <dc:date>2020-12-17T21:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238512#M153381</link>
      <description>&lt;P&gt;In your problem definition (your second post in this thread), you have an inconsistency:&lt;/P&gt;
&lt;P&gt;"i, j, k, l, m, n, V are integers &amp;gt; 0" versus "k_i, l_i are integers between [0,9]".&lt;/P&gt;
&lt;P&gt;Assuming that k, l are allowed to have 0 as a value, I obtained these two solutions (yes, there can be multiple solutions) for your m = 3 case.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Solution A:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;i&lt;/TD&gt;
&lt;TD width="25%"&gt;1&lt;/TD&gt;
&lt;TD width="25%"&gt;2&lt;/TD&gt;
&lt;TD width="25%"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;k_i&lt;/TD&gt;
&lt;TD width="25%"&gt;9&lt;/TD&gt;
&lt;TD width="25%"&gt;1&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;l_i&lt;/TD&gt;
&lt;TD width="25%"&gt;5&lt;/TD&gt;
&lt;TD width="25%"&gt;0&lt;/TD&gt;
&lt;TD width="25%"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Solution B:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="27px"&gt;i&lt;/TD&gt;
&lt;TD width="25%" height="27px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="27px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="27px"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="24px"&gt;k_i&lt;/TD&gt;
&lt;TD width="25%" height="24px"&gt;0&lt;/TD&gt;
&lt;TD width="25%" height="24px"&gt;3&lt;/TD&gt;
&lt;TD width="25%" height="24px"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="24px"&gt;l_i&lt;/TD&gt;
&lt;TD width="25%" height="24px"&gt;0&lt;/TD&gt;
&lt;TD width="25%" height="24px"&gt;4&lt;/TD&gt;
&lt;TD width="25%" height="24px"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If these are acceptable solutions, I'd like to try a problem for a larger m, say, m = 7 or 11. Do you have one?&lt;/P&gt;
&lt;P&gt;[I may have made some errors in transcribing the values from my calculation into the tables. If you spot an error, please let me know and I'll rectify.]&lt;/P&gt;
&lt;P&gt;By the way, this type of problem is closely related to &lt;A href="https://en.wikipedia.org/wiki/Verbal_arithmetic" target="_self"&gt;Cryptarithmetic Problems&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 01:07:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238512#M153381</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-12-18T01:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238683#M153384</link>
      <description>&lt;P&gt;Thank you mecej4,&lt;BR /&gt;I wanted to say: i,j(),m,n(),V are integers &amp;gt; 0, and k(), l() are integers between [0,9]&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;The solutions are correct and I found solution C:

i    1  2  3
------------
k_i  2  3  5
l_i  1  4  7

**************************************************************************************

Here are two other cases:

m = 7
 n()  j()   V = 187321251
  98  465
 550  269
 354  720
 806  524
 610  328
 413  780
 642  745
-------------------------
 m = 11
 n()  j()  V = 268177985
 811  178
 263  630
 715  434
   3  327
 534  858
 286  389
  37  141
 568  671
  99  202
 851  954
 382  706&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 18 Dec 2020 09:55:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238683#M153384</guid>
      <dc:creator>roy437</dc:creator>
      <dc:date>2020-12-18T09:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238690#M153385</link>
      <description>&lt;P&gt;Here are the solutions (two, for each problem) for your m=7 and m=11 problems.&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;STRONG&gt;Problem for m = 7, Solution A&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="12.5%"&gt;i&lt;/TD&gt;
&lt;TD width="12.5%"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%"&gt;3&lt;/TD&gt;
&lt;TD width="12.5%"&gt;4&lt;/TD&gt;
&lt;TD width="12.5%"&gt;5&lt;/TD&gt;
&lt;TD width="12.5%"&gt;6&lt;/TD&gt;
&lt;TD width="12.5%"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%"&gt;k_i&lt;/TD&gt;
&lt;TD width="12.5%"&gt;7&lt;/TD&gt;
&lt;TD width="12.5%"&gt;9&lt;/TD&gt;
&lt;TD width="12.5%"&gt;9&lt;/TD&gt;
&lt;TD width="12.5%"&gt;9&lt;/TD&gt;
&lt;TD width="12.5%"&gt;5&lt;/TD&gt;
&lt;TD width="12.5%"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%"&gt;l_i&lt;/TD&gt;
&lt;TD width="12.5%"&gt;8&lt;/TD&gt;
&lt;TD width="12.5%"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%"&gt;5&lt;/TD&gt;
&lt;TD width="12.5%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;STRONG&gt;Problem for m = 7, Solution B&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="12.5%"&gt;i&lt;/TD&gt;
&lt;TD width="12.5%"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%"&gt;2&lt;/TD&gt;
&lt;TD width="12.5%"&gt;3&lt;/TD&gt;
&lt;TD width="12.5%"&gt;4&lt;/TD&gt;
&lt;TD width="12.5%"&gt;5&lt;/TD&gt;
&lt;TD width="12.5%"&gt;6&lt;/TD&gt;
&lt;TD width="12.5%"&gt;7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%"&gt;k_i&lt;/TD&gt;
&lt;TD width="12.5%"&gt;8&lt;/TD&gt;
&lt;TD width="12.5%"&gt;9&lt;/TD&gt;
&lt;TD width="12.5%"&gt;8&lt;/TD&gt;
&lt;TD width="12.5%"&gt;8&lt;/TD&gt;
&lt;TD width="12.5%"&gt;5&lt;/TD&gt;
&lt;TD width="12.5%"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%"&gt;l_i&lt;/TD&gt;
&lt;TD width="12.5%"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%"&gt;0&lt;/TD&gt;
&lt;TD width="12.5%"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%"&gt;1&lt;/TD&gt;
&lt;TD width="12.5%"&gt;7&lt;/TD&gt;
&lt;TD width="12.5%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;STRONG&gt;Problem for m = 11, Solution A&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE border="1" width="62.087066705600996%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="10%"&gt;i&lt;/TD&gt;
&lt;TD width="5%"&gt;1&lt;/TD&gt;
&lt;TD width="5%"&gt;2&lt;/TD&gt;
&lt;TD width="5%"&gt;3&lt;/TD&gt;
&lt;TD width="5%"&gt;4&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5%"&gt;5&lt;/TD&gt;
&lt;TD width="5%"&gt;6&lt;/TD&gt;
&lt;TD width="5%"&gt;7&lt;/TD&gt;
&lt;TD width="5%"&gt;8&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;10&lt;/TD&gt;
&lt;TD width="5%"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%"&gt;k_i&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;TD width="5%"&gt;4&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;8&lt;/TD&gt;
&lt;TD width="5%"&gt;3&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%"&gt;l_i&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;7&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-center"&gt;&lt;STRONG&gt;Problem for m = 11, Solution B&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE border="1" width="62.087066705600996%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="10%"&gt;i&lt;/TD&gt;
&lt;TD width="5%"&gt;1&lt;/TD&gt;
&lt;TD width="5%"&gt;2&lt;/TD&gt;
&lt;TD width="5%"&gt;3&lt;/TD&gt;
&lt;TD width="5%"&gt;4&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5%"&gt;5&lt;/TD&gt;
&lt;TD width="5%"&gt;6&lt;/TD&gt;
&lt;TD width="5%"&gt;7&lt;/TD&gt;
&lt;TD width="5%"&gt;8&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;10&lt;/TD&gt;
&lt;TD width="5%"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%"&gt;k_i&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="10%"&gt;l_i&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;1&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;1&lt;/TD&gt;
&lt;TD width="5%"&gt;5&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;TD width="5%"&gt;0&lt;/TD&gt;
&lt;TD width="5%"&gt;9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I obtained these solutions using the &lt;A href="https://ampl.com" target="_self"&gt;AMPL solver&lt;/A&gt; . The "model" file for m = 11:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# Roy437 test problem.
param M integer := 11;
param V integer := 268177985;
set IDX = 1..M;
var k {IDX} integer &amp;gt;= 0 &amp;lt;= 9;
var l {IDX} integer &amp;gt;= 0 &amp;lt;= 9;
param n {IDX} integer &amp;gt;= 1;
param j {IDX} integer &amp;gt;= 1;

subj to C: sum{i in IDX} (100*j[i]+10*k[i]+l[i])*n[i] = V;

data ;
param: n :=  1 811 2 263 3 715 4 3 5 534 6 286 7 37 8 568 9 99 10 851 11 382 ;
param: j :=  1 178 2 630 3 434 4 327 5 858 6 389 7 141 8 671 9 202 10 954 11 706 ;

option solver ilogcp; solve;
display {i in IDX} (k[i],l[i]);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may use the online &lt;A href="https://neos-server.org/neos/solvers/milp:Gurobi/AMPL.html" target="_self"&gt;NEOS server&lt;/A&gt; if you do not wish to obtain the AMPL demo package and install it on your machine. If you use the server, use the three files in the attached zip.&lt;/P&gt;
&lt;P&gt;If obtaining the solution is sufficient, you may use AMPL on your PC or on the NEOS server. If you wish to call the AMPL solver from a Fortran or C program, a number of methods may be tried, but mating a Fortran program to the AMPL solvers is non-trivial.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 10:57:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238690#M153385</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-12-18T10:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238716#M153386</link>
      <description>&lt;P&gt;Thank you very much &lt;STRONG&gt;mecej4&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;The solutions are good, I checked them. I installed the &lt;STRONG&gt;AMPL Command Line download for Windows&lt;/STRONG&gt;&amp;nbsp;program, but it gives me an error. Please, can you tell me what commands to give or&amp;nbsp;how to proceed with the three files royM11.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ampl.jpg" style="width: 355px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/14219i9C417D6280517FF9/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="ampl.jpg" alt="ampl.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 12:29:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238716#M153386</guid>
      <dc:creator>roy437</dc:creator>
      <dc:date>2020-12-18T12:29:58Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238719#M153387</link>
      <description>&lt;P&gt;There are a number of tutorials for running AMPL from the command line, or using the Eclipse-based IDE, and the AMPL language itself. For now, since you have AMPL installed locally, the following is the simplest approach:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;open a CMD window, and set the path to include the directory containing AMPL.EXE.&lt;/LI&gt;
&lt;LI&gt;in your working directory,&amp;nbsp; copy the code in the box in my post above (not the the files in the zip, which are for NEOS) to, say, M11.mod .&lt;/LI&gt;
&lt;LI&gt;enter the command&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;LI-CODE lang="markup"&gt;ampl M11.mod
&lt;/LI-CODE&gt;
&lt;P&gt;You will see the results displayed at the console.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 12:48:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238719#M153387</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-12-18T12:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238726#M153388</link>
      <description>&lt;P&gt;Thanks &lt;STRONG&gt;mecej4,&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I did it. Can I redirect the result to a file?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 13:03:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238726#M153388</guid>
      <dc:creator>roy437</dc:creator>
      <dc:date>2020-12-18T13:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Variable number of nested loops</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238729#M153389</link>
      <description>&lt;P&gt;Of course. The command can be&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;ampl M11.mod &amp;gt; M11.out&lt;/LI-CODE&gt;
&lt;P&gt;You can then type the M11.out file, open it in Notepad or another editor, Word, etc.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 13:14:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Variable-number-of-nested-loops/m-p/1238729#M153389</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-12-18T13:14:01Z</dc:date>
    </item>
  </channel>
</rss>

