{"id":75,"date":"2017-09-11T15:13:49","date_gmt":"2017-09-11T18:13:49","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=75"},"modified":"2017-09-11T15:13:49","modified_gmt":"2017-09-11T18:13:49","slug":"array3c-f","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/array3c-f\/","title":{"rendered":"array3c.f"},"content":{"rendered":"<pre>PROGRAM ARRAY3C\r\nc\r\nc    What if I don't know how much array space I will need when I first\r\nc    write my Fortran Program.  If I don't want to bother with ALLOCATE,\r\nc    or my compiler doesn't support it, I can use a Fortran 77 PARAMETER\r\nc    statement to establish the available array space in one place.  If\r\nc    I need more later, I just change the one parameter value and recompile.\r\nc\r\nc    John Mahaffy\r\nc\r\n      IMPLICIT NONE\r\n      INTEGER I,J,IERR,N,NDAT,NMAX\r\n      PARAMETER (NMAX=10)\r\nc\r\nc    Note: Once declared a PARAMETER, NMAX can never appear on the left\r\nc          side of an equals sign.  Try setting \"NMAX=3\" somewhere below\r\nc          the OPEN(11,... statement.  You can do Fortran arithmetic within\r\nc          a PARAMETER statement as long as only constants and other\r\nc          parameters are involved.  Try replacing the above PARAMETER with:\r\nc          \"      PARAMETER (N2=2, N4=4, NMAX=N2*N4+6)\".  Try breaking this\r\nc          new statement into 2 statements, one setting N2 and N4 and the other\r\nc          setting NMAX.  In either case you will have to declare the type\r\nc          of N2 and N4.\r\nc\r\nc    Dimension A, B, and C to NMAX\r\nc\r\n      REAL   A(NMAX),B(NMAX),C(NMAX)\r\n      REAL CSUM,CMAX,CMIN,AVERAGE,DUMMY\r\nc\r\nc   Get the amount of data and see if there is enough space.\r\nc\r\n      OPEN(11,FILE='array3b.in',ERR=400)\r\n      READ(11,*,END=400) NDAT\r\n      IF(NDAT.GT.NMAX) then\r\n         print *, 'Increase NMAX to at least:', NDAT, ' and recompile'\r\n         stop\r\n      ENDIF\r\nc\r\nc   Set values of A and B\r\nc\r\n      DO 30 I=1,NDAT\r\n      READ(11,*) A(I), B(I)\r\n  30  CONTINUE\r\nc\r\nc   Process as before\r\nc\r\n      C(1:NDAT)=A(1:NDAT)+B(1:NDAT)\r\n      CSUM=SUM(C(1:NDAT))\r\n      CMIN=MINVAL(C(1:NDAT))\r\n      CMAX=MAXVAL(C(1:NDAT))\r\nC\r\n      AVERAGE=CSUM\/NDAT\r\n      WRITE(*,'(\/\/,'' RESULTS FOR ELEMENTS 1 THROUGH '',I3,'' OF C'')')\r\n     &amp; NDAT\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(1:NDAT)\r\n 2003 FORMAT(' C = ',\/,(1P,8E10.2))\r\nc\r\n      STOP\r\n 400  PRINT *,' Empty or missing input file: array3b.in'\r\n      STOP\r\n      END<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PROGRAM ARRAY3C c c What if I don&#8217;t know how much array space I will need when I first c write my Fortran Program. If I don&#8217;t want to bother with ALLOCATE, c or my compiler doesn&#8217;t support it, I can use a Fortran 77 PARAMETER c statement to establish the available array space in [&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-75","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/75","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=75"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/75\/revisions"}],"predecessor-version":[{"id":76,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/75\/revisions\/76"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}