Projet mkd/fortran.c
De Wiki EELL.
(Différences entre les versions)
JPL (discuter | contributions) m (→Fichiers fortran : mise en couleur) |
JPL (discuter | contributions) m (→Fichiers fortran : !!) |
||
(3 versions intermédiaires masquées) | |||
Ligne 1 : | Ligne 1 : | ||
<small>[[Projet mkd/Fichiers en développement|Retour aux fichiers en développement →]]</small> | <small>[[Projet mkd/Fichiers en développement|Retour aux fichiers en développement →]]</small> | ||
- | == Fichiers fortran == | + | == Fichiers fortran 77 == |
+ | ; See tri.c for fortran_90_&+ | ||
* Testé: | * Testé: | ||
: fortran.c pour Konsole | : fortran.c pour Konsole | ||
Ligne 7 : | Ligne 8 : | ||
: fortran.inc.cc pour inclusion dans le source c++ avec gtkmm | : fortran.inc.cc pour inclusion dans le source c++ avec gtkmm | ||
- | {{Boîte déroulante/début|titre=Fortran | + | {{Boîte déroulante/début|titre=Fortran ; Updated 2013-05-11}} |
+ | * fortran.c f77 | ||
<pre style="color:red"> | <pre style="color:red"> | ||
/*P | /*P | ||
Ligne 106 : | Ligne 108 : | ||
The 'Codes': table of 5 characters: | The 'Codes': table of 5 characters: | ||
extern char codes[]; | extern char codes[]; | ||
- | They must be | + | They must be defined in the calling function: |
char codes[5] = {0,0,0,0,0}; | char codes[5] = {0,0,0,0,0}; | ||
The 'Options': l,n,s,t. | The 'Options': l,n,s,t. | ||
see NOTES for inline ! comment | see NOTES for inline ! comment | ||
extern unsigned char n,s,t; | extern unsigned char n,s,t; | ||
- | They must be | + | They must be defined in the calling function: |
unsigned char n=0,s=0,t=0; | unsigned char n=0,s=0,t=0; | ||
With the options: | With the options: | ||
Ligne 238 : | Ligne 240 : | ||
/*O si option s copier de même à la sortie standard */ | /*O si option s copier de même à la sortie standard */ | ||
if (s && n) printf("%5d ", num ); | if (s && n) printf("%5d ", num ); | ||
- | if (!t) putch(c1); | + | if (s && !t)putch(c1); |
- | + | if (s && t)putch(' '); // colonne 2 | |
} /* Cas 1 copier tous les commentaires ('Code' NULL) */ | } /* Cas 1 copier tous les commentaires ('Code' NULL) */ | ||
Ligne 322 : | Ligne 324 : | ||
{ /*S espaces */ | { /*S espaces */ | ||
putc(' ',pfdoc); | putc(' ',pfdoc); | ||
- | putch(' '); | + | if(s)putch(' '); |
} /*S espaces */ | } /*S espaces */ | ||
} /*S espaces en début de ligne */ | } /*S espaces en début de ligne */ | ||
Ligne 373 : | Ligne 375 : | ||
return; | return; | ||
} /*S fortran */ | } /*S fortran */ | ||
- | |||
</pre> | </pre> | ||
{{boîte déroulante/fin}} | {{boîte déroulante/fin}} | ||
Ligne 380 : | Ligne 381 : | ||
* Fichier: Make_Tests_U_f77 | * Fichier: Make_Tests_U_f77 | ||
+ | * Fichier: Make_Tests_U_f90 | ||
+ | |||
+ | {{Boîte déroulante/début|titre=Fichiers de commandes, Avril 2013}} | ||
- | + | '''Fichier: Make_Tests_U_f77''' | |
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash | ||
Ligne 435 : | Ligne 439 : | ||
rm tst1for.txt tst1.stdout.txt | rm tst1for.txt tst1.stdout.txt | ||
rm tst2for.txt tst2.stdout.txt | rm tst2for.txt tst2.stdout.txt | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | '''Fichier: Make_Tests_U_f90''' | ||
+ | <pre> | ||
+ | #!/bin/bash | ||
+ | #O ../../mkd tests under Linux. | ||
+ | #O Epreuve de vérification de la compilation CD3 = '!' | ||
+ | |||
+ | echo "tous les commentaires avec '**' " > Degrad.doc | ||
+ | ../../mkd -la '**' Degrad.f | ||
+ | ../../mkd -lan '**' Degrad.f | ||
+ | ../../mkd -lvans '**' Degrad.f Degrad.doc > Degrad.scr.txt | ||
+ | |||
+ | echo "" >> Degrad.doc | ||
+ | echo "tous les commentaires avec 'S' " >> Degrad.doc | ||
+ | ../../mkd -la S Degrad.f | ||
+ | ../../mkd -lan S Degrad.f | ||
+ | ../../mkd -lvans S Degrad.f Degrad.doc >> Degrad.scr.txt | ||
+ | |||
+ | echo "" >> Degrad.doc | ||
+ | echo "tous les textes seuls avec 'S' " >> Degrad.doc | ||
+ | ../../mkd -lat S Degrad.f | ||
+ | ../../mkd -lant S Degrad.f | ||
+ | ../../mkd -lvants S Degrad.f Degrad.doc >> Degrad.scr.txt | ||
+ | |||
+ | gedit Degrad.doc Degrad.scr.txt | ||
+ | |||
+ | rm Degrad.doc Degrad.scr.txt | ||
</pre> | </pre> | ||
{{boîte déroulante/fin}} | {{boîte déroulante/fin}} | ||
- | + | == Analyse du test konsole == | |
Fichier: Analyse.txt | Fichier: Analyse.txt | ||
Ligne 490 : | Ligne 523 : | ||
Résultat conforme pour le fortran 77 | Résultat conforme pour le fortran 77 | ||
- | + | ||
FORTRAN 90 avec Degrad.f | FORTRAN 90 avec Degrad.f | ||
+ | |||
L'analyse pour le fortran 90 avec l'option de compilation CD3 = '!' donne des | L'analyse pour le fortran 90 avec l'option de compilation CD3 = '!' donne des | ||
résultats comparables pour toutes les options n,s,t. | résultats comparables pour toutes les options n,s,t. | ||
Ligne 497 : | Ligne 531 : | ||
CEPENDANT: Les commentaires sont cependant décalés à gauche de 2 caractères en | CEPENDANT: Les commentaires sont cependant décalés à gauche de 2 caractères en | ||
cas de texte seul. | cas de texte seul. | ||
- | |||
</pre> | </pre> | ||
+ | |||
{{boîte déroulante/fin}} | {{boîte déroulante/fin}} | ||
+ | == Fichiers sources des tests == | ||
+ | |||
+ | {{Boîte déroulante/début|titre=Stats.f (F77) et Degrad.f F(90) Avril 2013}} | ||
+ | |||
+ | '''Stats.f (Fortran 77)''' | ||
+ | <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> | ||
+ | {{boîte déroulante/fin}} | ||
[[Catégorie:Générateurs de documentation]] | [[Catégorie:Générateurs de documentation]] |
Version actuelle en date du 11 mai 2013 à 14:04
Retour aux fichiers en développement →
Sommaire[masquer] |
Fichiers fortran 77
- See tri.c for fortran_90_&+
- 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
- Fichier: Make_Tests_U_f90
Analyse du test konsole
Fichier: Analyse.txt