PROGRAM ARRAY2SE c c Since you will be pushing your real work out of the main program c into Subprograms, you need to know about passing arrays in and out c of Subroutines. Here is a rewrite of array2.f c c John Mahaffy 12/27/94 c IMPLICIT NONE c INTEGER ND PARAMETER (ND=10) REAL A(ND),B(ND),C(ND) REAL CSUM,CMAX,CMIN,AVERAGE c DATA A/1.,2.,3.,4.,5.,6.,7.,8.,9.,10./,B/3*1.,4*2.,3*3./ c c CALL CPROPS(A,B,C,ND,AVERAGE,CMAX,CMIN) CALL WRITEC(C,ND,AVERAGE,CMAX,CMIN) STOP END SUBROUTINE CPROPS( A, B, C, N , CAVG, CMAX, CMIN) C C By using the array dimension "N" passed through the argument list C in the below array declaration, Fortran 90 is told the size of C arrays and can compile and function. C C REAL A(N),B(N),C(N) REAL CSUM,CMAX,CMIN,CAVG INTEGER I,N c c Begin Executable Statements c C=A+B CMAX=MAXVAL(C) CMIN=MINVAL(C) CSUM=SUM(C) CAVG=CSUM/N RETURN END SUBROUTINE WRITEC( C, N, CAVG, CMAX, CMIN) C C A common practice in Fortran 77 programs is to use a * in the dimension C specification. You are saying "trust me, I know what I'm doing. All C you need to know is that its an array" C REAL C(*) REAL CMAX,CMIN,CAVG INTEGER J,N C c The next write statement illustrates use of * for the unit number. c It represents the default unit, which is the terminal. c WRITE(*,*) ' RESULTS FOR FULL C ARRAY' c c The format associated with the following write spreads the output c of the three values (AVERAGE, CMIN, and CMAX) over 3 output lines. c WRITE(6,2000)CAVG,CMIN,CMAX 2000 FORMAT(' AVERAGE OF ALL ELEMENTS IN C = ', F8.3,/, & ' MINIMUM OF ALL ELEMENTS IN C = ', F8.3,/, & ' MAXIMUM OF ALL ELEMENTS IN C = ', F8.3) c WRITE(6,2001) (C(J),J=1,N) 2001 FORMAT(' C = ',1p,/,(8E10.2)) C RETURN END