Projet mkd/fortran.c

De Wiki EELL.

(Différences entre les versions)
m (Analyse du test konsole : Ajouté un chapitre)
m (Fichiers sources des tests : Ajout du contenu)
Ligne 504 : Ligne 504 :
{{Boîte déroulante/début|titre=Stats.f (F77) et Degrad.f F(90) Avril 2013}}
{{Boîte déroulante/début|titre=Stats.f (F77) et Degrad.f F(90) Avril 2013}}
 +
 +
'''Stats.f (Fortran 77)'''
<pre>
<pre>
 +
cO**********************************************************************
 +
C
 +
C O  STATS.FOR
 +
C
 +
C O        Calculates simple statistics (minimum, maximum, mean, median,
 +
C O        variance, and standard deviation) of up to 50 values.
 +
C
 +
C O        Reads one value at a time from unit 5.  Echoes values and
 +
C O        writes results to unit 6.
 +
C
 +
C O        All calculations are done in single precision.
 +
C
 +
C
 +
cO*********************************************************************
 +
* Bloc de tête 14 lignes commentées suivent 17 lignes commentées avec O
 +
* et 1 avec T en fin de fichier
 +
 +
 +
      DIMENSION DAT(50)
 +
      OPEN(5,FILE=' ')
 +
 +
      N=0
 +
      DO 10 I=1,50
 +
      READ(5,99999,END=20) DAT(I)
 +
      N=I
 +
10  CONTINUE
 +
 +
C O Too many values.  Write error message and die.
 +
 +
      WRITE(6,99998) N
 +
      STOP
 +
 
 +
C O Test to see if there's more than one value.  We don't want to divide
 +
C O by zero.
 +
 +
20    IF(N.LE.1) THEN
 +
 +
C O Too few values. Print message and die.
 +
 +
        WRITE(6,99997)
 +
 +
      ELSE
 +
 +
C O Echo input values to output.
 +
 +
        WRITE(6,99996)
 +
        WRITE(6,99995) (DAT(I),I=1,N)
 +
 +
C O Calculate mean, standard deviation, and median.
 +
 +
        CALL MEAN (DAT,N,DMEAN)
 +
        CALL STDEV (DAT,N,DMEAN,DSTDEV,DSTVAR)
 +
        CALL MEDIAN (DAT,N,DMEDN,DMIN,DMAX)
 +
 +
        WRITE(6,99994) N,DMEAN,DMIN,DMAX,DMEDN,DSTVAR,DSTDEV
 +
 +
      ENDIF
 +
 +
      STOP
 +
 +
99999 FORMAT(E14.6)
 +
99998 FORMAT('0 ********STAT: TOO MANY VALUES-- ',I5)
 +
99997 FORMAT('0 ********STAT: TOO FEW VALUES (1 OR LESS) ')
 +
99996 FORMAT(//,10X,
 +
    +' ******************SAMPLE DATA VALUES*****************'//)
 +
99995 FORMAT(5(1X,1PE14.6))
 +
99994 FORMAT(///,10X,
 +
    +' ******************SAMPLE STATISTICS******************',//,
 +
    +15X,'          Sample size = ',I5,/,
 +
    +15X,'          Mean        = ',1PE14.6,/,
 +
    +15X,'          Minimum    = ',E14.6,/,
 +
    +15X,'          Maximum    = ',E14.6,/
 +
    +15X,'          Median      = ',E14.6,/
 +
    +15X,'          Variance    = ',E14.6,/
 +
    +15X,'          St deviation= ',E14.6////)
 +
 +
      END
 +
 +
C O Calculate the mean (XMEAN) of the N values in array X.
 +
 +
      SUBROUTINE  MEAN (X,N,XMEAN)
 +
      DIMENSION X(N)
 +
 +
      SUM=0.0
 +
      DO 10 I=1,N
 +
        SUM=SUM+X(I)
 +
  10 CONTINUE
 +
 +
      XMEAN=SUM/FLOAT(N)
 +
 +
      RETURN
 +
      END
 +
 +
C O Calculate the standard deviation (XSTDEV) and variance (XVAR)
 +
C O of the N values in X using the mean (XMEAN).
 +
C O This divides by zero when N = 1.
 +
 +
      SUBROUTINE STDEV (X,N,XMEAN,XSTDEV,XVAR)
 +
      DIMENSION X(N)
 +
 +
      SUMSQ=0.0
 +
      DO 10 I=1,N
 +
        XDIFF=X(I)-XMEAN
 +
        SUMSQ=SUMSQ+XDIFF*XDIFF
 +
  10 CONTINUE
 +
 +
      XVAR=SUMSQ/FLOAT(N-1)
 +
      XSTDEV=SQRT(XVAR)
 +
 +
      RETURN
 +
      END
 +
 +
 +
C O Calculate the median (XMEDN), minimum (XMIN), and maximum (XMAX) of
 +
C O the N values in X.
 +
C O MEDIAN sorts the array and then calculates the median value.
 +
 +
      SUBROUTINE MEDIAN (X,N,XMEDN,XMIN,XMAX)
 +
      DIMENSION X(N)
 +
 +
      CALL SORT (X,N)
 +
 +
      IF(MOD(N,2).EQ.0) THEN
 +
        K=N/2
 +
        XMEDN=(X(K)+X(K+1))/2.0
 +
      ELSE
 +
        K=(N+1)/2
 +
        XMEDN=X(K)
 +
      ENDIF
 +
 +
      XMIN=X(1)
 +
      XMAX=X(N)
 +
 +
      END
 +
 +
C O Sort the N values in array X.  SORT uses a bubble sort
 +
C O that quits when no values were exchanged on the last pass.
 +
C O Each pass goes from the first element to where the last
 +
C O exchange occurred on the previous pass.
 +
 +
      SUBROUTINE SORT (X,N)
 +
      DIMENSION X(N)
 +
 +
      IBND=N
 +
  20  IXCH=0
 +
   
 +
      DO 100 J=1,IBND-1
 +
          IF(X(J).GT.X(J+1))THEN
 +
              TEMP=X(J)
 +
              X(J)=X(J+1)
 +
              X(J+1)=TEMP
 +
              IXCH=J
 +
          ENDIF
 +
100  CONTINUE
 +
 +
      IF (IXCH.EQ.0) RETURN
 +
      IBND=IXCH
 +
      GO TO 20
 +
 
 +
      END
 +
CT Fin
 +
</pre>
 +
 +
'''Degrad.f (Fortran 90)'''
 +
<pre>
 +
      PROGRAM DEGRAD  !S Début de programme
 +
!                                                                     
 +
!S Imprime une table de conversion degrés -> radians                   
 +
!S =================================================                   
 +
!                                                                     
 +
!S Déclaration des variables                                           
 +
      INTEGER DEG
 +
      REAL RAD, COEFF
 +
!                                                                     
 +
!S En-tête de programme                                               
 +
      WRITE ( *, 10)
 +
  10 FORMAT      (' ',20('*') /                                        &
 +
    &            ' * Degres * Radians *' /                            &
 +
    &            ' ', 20('*') )                                     
 +
!                                                                     
 +
!S Corps de programme                                                 
 +
      COEFF = (2.0 * 3.1416) / 360.0
 +
      DO DEG = 0, 90
 +
        RAD = DEG * COEFF
 +
        WRITE ( *, 20) DEG, RAD
 +
  20 FORMAT        (' *  ',I4,'  * ',F7.5,' *')
 +
      END DO
 +
!                                                                     
 +
!S Fin du tableau                                                     
 +
      WRITE ( *, 30)
 +
  30 FORMAT      (' ',20('*') )
 +
!                                                                     
 +
!S Fin de programme                                                   
 +
      STOP
 +
      END PROGRAM DEGRAD
 +
CS Fin
 +
!S Fin
</pre>
</pre>
{{boîte déroulante/fin}}
{{boîte déroulante/fin}}
[[Catégorie:Générateurs de documentation]]
[[Catégorie:Générateurs de documentation]]

Version du 30 avril 2013 à 10:02

Retour aux fichiers en développement →

Sommaire

Fichiers fortran

  • Testé:
fortran.c pour Konsole
  • Non testé:
fortran.cc pour versions c++ indépendante
fortran.inc.cc pour inclusion dans le source c++ avec gtkmm

Fichier de commande de tests Konsole

  • Fichier: Make_Tests_U_f77

Analyse du test konsole

Fichier: Analyse.txt

Fichiers sources des tests

Outils personnels