{"id":165,"date":"2017-09-13T10:42:17","date_gmt":"2017-09-13T13:42:17","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=165"},"modified":"2017-09-13T10:42:17","modified_gmt":"2017-09-13T13:42:17","slug":"speed-f","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/speed-f\/","title":{"rendered":"speed.f"},"content":{"rendered":"<pre>c&lt;html&gt;\r\nc&lt;head&gt;&lt;title&gt;speed.f&lt;\/title&gt;&lt;\/head&gt;\r\nc&lt;body&gt;\r\nc&lt;pre&gt;\r\n      program speed\r\nc\r\nc    program to time 3 different methods of calculating\r\nc    the dot product of long vectors\r\nc\r\n      parameter (nc=1000)\r\n      dimension a(nc),b(nc),c(nc)\r\nc\r\nc    Use the Fortran 90 Intrinsic Subroutine to load\r\nc    the vectors with random numbers\r\nc\r\n      dotpro=0.\r\n      call random_number (a)\r\n      call random_number(b)\r\nc\r\nc    Use the Fortran 90 Intrinsic Subroutine to determine\r\nc    the current time in clock ticks (icount2), the clock\r\nc    rate in clicks per second, and the largest possible\r\nc    count before the clock resets.\r\nc\r\nc    CAUTION:  On this and probably most Unix work stations\r\nc    this clock is measuring real time, not time your program\r\nc    spends running.  If you are sharing the machine with others\r\nc    you will count the time they have the CPU also.  USE the\r\nc    unix \"users\" command to check for a situation when you are\r\nc    the only user on the machine before running the program.\r\nc    To filter out system activity run the program many times\r\nc    and select results with the lowest total times.\r\nc\r\n      call system_clock(icount2,irate,icmax)\r\nc\r\n      print *, 'clock rate = ',irate, ' ticks per second'\r\nc\r\nc     The \"1000\" loop just makes sure that I do lots of work\r\nc     to get good statistics.  Note that coding is set so\r\nc     results of each pass through the loop are a little\r\nc     different.  Without the \"+.00001*dotpro\" optimization\r\nc     features on many compilers will only execute the loop\r\nc     once.\r\nc\r\n      do 1000 i = 1,10000\r\nc     &lt;a name=4&gt;&lt;font color=FF0000&gt;\r\n         dotpro = dot_product(a,b)+.00001*dotpro\r\nc     &lt;\/font&gt;\r\n 1000 continue\r\n      call system_clock(icount3,irate,icmax)\r\n      time = real(icount3-icount2)\/real(irate)\r\n      print *, 'Time for DOT_PRODUCT(a,b) = ', time,\r\n     $ ' seconds'\r\n      do 1001 i = 1,10000\r\nc     &lt;a name=3&gt;&lt;font color=FF0000&gt;\r\n         dotpro = sum(a*b) +.00001*dotpro\r\nc     &lt;\/font&gt;\r\n 1001    continue\r\n      call system_clock(icount4,irate,icmax)\r\n      time = real(icount4-icount3)\/real(irate)\r\n      print *, 'Time for SUM(a*b) = ', time,\r\n     $ ' seconds'\r\nc&lt;a name=\"do\"&gt;&lt;font color=\"FF0000\"&gt;\r\n      do 1002 i = 1,10000\r\nc&lt;\/a&gt;&lt;\/font&gt;\r\n         do 100 j=1,nc\r\n  100       dotpro=dotpro+a(j)*b(j)\r\nc        dotpro=dotpro+.00001*dotpro\r\n 1002 continue\r\nc     &lt;a name=1&gt;&lt;font color=FF0000&gt;\r\n      call system_clock(icount5,irate,icmax)\r\nc     &lt;\/font&gt; &lt;\/a&gt;\r\n      time = real(icount5-icount4)\/real(irate)\r\n      print *, 'DO Loop dot product = ', time,\r\n     $ ' seconds'\r\n      print *, dotpro\r\n      stop\r\n      end\r\nc&lt;\/pre&gt;\r\nc&lt;\/body&gt;\r\nc&lt;\/html&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>c&lt;html&gt; c&lt;head&gt;&lt;title&gt;speed.f&lt;\/title&gt;&lt;\/head&gt; c&lt;body&gt; c&lt;pre&gt; program speed c c program to time 3 different methods of calculating c the dot product of long vectors c parameter (nc=1000) dimension a(nc),b(nc),c(nc) c c Use the Fortran 90 Intrinsic Subroutine to load c the vectors with random numbers c dotpro=0. call random_number (a) call random_number(b) c c Use the [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-165","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=165"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/165\/revisions"}],"predecessor-version":[{"id":166,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/165\/revisions\/166"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}