{"id":56,"date":"2017-09-11T13:14:15","date_gmt":"2017-09-11T16:14:15","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=56"},"modified":"2017-09-11T13:25:16","modified_gmt":"2017-09-11T16:25:16","slug":"array2-f","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/array2-f\/","title":{"rendered":"array2.f"},"content":{"rendered":"<pre>      PROGRAM ARRAY2\r\nc\r\nc    Simple exercises in using arrays for data analysis using Fortran 90\r\nc\r\nc    John Mahaffy 12\/27\/95\r\nc\r\n      IMPLICIT NONE\r\n      INTEGER I,J\r\nc\r\nc    Declare A, B, and C to be arrays each containing 10 elements. At\r\nc    the same time initialize A using an implied DO loop.\r\nc\r\n      REAL, DIMENSION (10) :: A=(\/(J,J=1,10)\/), B, C\r\n      REAL CSUM,CMAX,CMIN,AVERAGE\r\n      DATA B\/3*1.,4*2.,3*3.\/\r\nC\r\nc    DO loops are not needed with Fortran 90 for many basic operations\r\nc    using arrays.  Compare what happens below to the loop in \"array1.f\".\r\nc    The compiler has no problem adapting these statements to any vector\r\nc    or parallel capabilities that are available to you.\r\nc\r\n      C=A+B\r\n      CSUM=SUM(C)\r\n      CMIN=MINVAL(C)\r\n      CMAX=MAXVAL(C)\r\nC\r\n      AVERAGE=CSUM\/10\r\nC\r\n      WRITE(*,*) ' RESULTS FOR FULL C ARRAY'\r\n      WRITE(6,2000)AVERAGE,CMIN,CMAX\r\n 2000 FORMAT(' AVERAGE OF ALL ELEMENTS IN C = ', F8.3,\/,\r\n     &amp;       ' MINIMUM OF ALL ELEMENTS IN C = ', F8.3,\/,\r\n     &amp;       ' MAXIMUM OF ALL ELEMENTS IN C = ', F8.3)\r\n      WRITE(6,2001) C\r\n 2001 FORMAT(' C = ',\/,(8E10.2))\r\nc\r\nc    Limiting the portion of arrays that you use in Fortran 90, is\r\nc    relatively simple once you learn the use of \":\" to specify a\r\nc    range of elements.  Here we operate on elements 2 through 9.\r\nc\r\n      C(1)=0.\r\n      C(10)=0.\r\n      C(2:9)=A(2:9)+B(2:9)\r\n      CSUM=SUM(C(2:9))\r\n      CMIN=MINVAL(C(2:9))\r\n      CMAX=MAXVAL(C(2:9))\r\nC\r\n      AVERAGE=CSUM\/8\r\n      WRITE(*,'(\/\/,'' RESULTS FOR ELEMENTS 2 THROUGH 9 OF C'')')\r\n      WRITE(6,2002)AVERAGE,CMIN,CMAX\r\n 2002 FORMAT(' AVERAGE OF SELECTED ELEMENTS IN C = ', F8.3,\/,\r\n     &amp;       ' MINIMUM OF SELECTED ELEMENTS IN C = ', F8.3,\/,\r\n     &amp;       ' MAXIMUM OF SELECTED ELEMENTS IN C = ', F8.3)\r\n      WRITE(6,2003) C(2:9)\r\n 2003 FORMAT(' C = ',\/,(1P,8E10.2))\r\nc\r\nc   Handling conditional branches in vector processing is generally \r\nc   difficult.  However, situations where one of two possible options\r\nc   is chosen can be handled relatively simply (uses something called\r\nc   a vector mask).  Fortran 90 provides a special construct for these\r\nc   situations involving the WHERE, ELSE WHERE, and END WHERE statements.\r\nc   Any number of Fortran 90 statements may be placed between a WHERE and\r\nc   an END WHERE statement.  However, if the ELSEWHERE is used, only\r\nc   one may be used with a given WHERE to cover what happens if the \r\nc   condition associated with the WHERE is false.  If you make the \r\nc   analogy to the IF THEN construct, ELSEWHERE is equivalent to a\r\nc   simple ELSE statement.  There isn't an equivalent to the ELSE IF\r\nc   construct.\r\nc\r\n      A(4)=-1.0\r\n      WHERE (A.GT.0)\r\n         C=LOG(A)\r\n      ELSE WHERE\r\n         C=0.\r\n      END WHERE\r\nC\r\n      PRINT *\r\n      WRITE(6,*) ' RESULTS OF LOG(A)'\r\n            WRITE(6,2004) C\r\n 2004 FORMAT(' C = ',\/,(1P,8E10.2))\r\n      STOP\r\n      END<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PROGRAM ARRAY2 c c Simple exercises in using arrays for data analysis using Fortran 90 c c John Mahaffy 12\/27\/95 c IMPLICIT NONE INTEGER I,J c c Declare A, B, and C to be arrays each containing 10 elements. At c the same time initialize A using an implied DO loop. c REAL, DIMENSION (10) [&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-56","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/56","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=56"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/56\/revisions"}],"predecessor-version":[{"id":57,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/56\/revisions\/57"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}