| 1 | c========================================================== |
|---|
| 2 | c getimes.F |
|---|
| 3 | c========================================================== |
|---|
| 4 | c Pack de routines pour calculer des temps d'execution. |
|---|
| 5 | c |
|---|
| 6 | c UTILISATION : |
|---|
| 7 | c L'appel a la routine initimes() doit se faire en |
|---|
| 8 | c début de programme. |
|---|
| 9 | c Pour calculer le temps d'execution d'une portion de |
|---|
| 10 | c code il suffit de placer la routine begintime devant |
|---|
| 11 | c la portion et la routine endtime après la portion. |
|---|
| 12 | c |
|---|
| 13 | c L'argument tps de la routine endtime retourne le |
|---|
| 14 | c temps d'execution en seconde de la portion de code. |
|---|
| 15 | c========================================================== |
|---|
| 16 | |
|---|
| 17 | ************************************************** |
|---|
| 18 | * routine begintime * |
|---|
| 19 | * Retourne dans la variable nb_ini, le nombre de* |
|---|
| 20 | * cycle au moment de l'appel a begintime. * |
|---|
| 21 | * * |
|---|
| 22 | * ARGUMENTS : * |
|---|
| 23 | * nb_ini (output) : nombre de cycle au lancement* |
|---|
| 24 | * de la routine. * |
|---|
| 25 | ************************************************** |
|---|
| 26 | subroutine begintime(nb_ini) |
|---|
| 27 | integer nb_ini |
|---|
| 28 | CALL SYSTEM_CLOCK(COUNT=nb_ini) |
|---|
| 29 | return |
|---|
| 30 | end |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | ************************************************** |
|---|
| 34 | * routine endtime * |
|---|
| 35 | * Retourne dans la variable tps, le temps entre * |
|---|
| 36 | * l'appel a begintime et endtime. * |
|---|
| 37 | * * |
|---|
| 38 | * ARGUMENTS : * |
|---|
| 39 | * nb_ini (input) : nombre de cycle au lancement * |
|---|
| 40 | * de la routine begintime * |
|---|
| 41 | * tps (output) : temps en secondes ecoules * |
|---|
| 42 | * entre begintime et endtime * |
|---|
| 43 | ************************************************** |
|---|
| 44 | subroutine endtime(nb_ini,tps) |
|---|
| 45 | implicit none |
|---|
| 46 | integer nb_max,nb_sec |
|---|
| 47 | common/horloge/nb_max,nb_sec |
|---|
| 48 | integer nb_ini |
|---|
| 49 | integer nb_fin,tmp |
|---|
| 50 | real tps |
|---|
| 51 | CALL SYSTEM_CLOCK(COUNT=nb_fin) |
|---|
| 52 | tmp =nb_fin-nb_ini |
|---|
| 53 | if (nb_fin.lt.nb_ini) tmp=tmp+nb_max |
|---|
| 54 | tps = FLOAT(tmp)/ nb_sec |
|---|
| 55 | return |
|---|
| 56 | end |
|---|
| 57 | |
|---|
| 58 | ************************************************** |
|---|
| 59 | * routine initimes * |
|---|
| 60 | * Initialise le compteur * |
|---|
| 61 | * Cette routine doit se positionnee en debut de * |
|---|
| 62 | * programme * |
|---|
| 63 | ************************************************** |
|---|
| 64 | subroutine initimes() |
|---|
| 65 | #include "itemps.h" |
|---|
| 66 | integer nb_max,nb_sec |
|---|
| 67 | common/horloge/nb_max,nb_sec |
|---|
| 68 | CALL SYSTEM_CLOCK(COUNT_RATE=nb_sec, |
|---|
| 69 | & COUNT_MAX=nb_max) |
|---|
| 70 | * initialisation variables de stockage |
|---|
| 71 | ttdynt = 0. |
|---|
| 72 | ttadvtr = 0. |
|---|
| 73 | ttphys = 0. |
|---|
| 74 | ttmuphys = 0. |
|---|
| 75 | tthaze = 0. |
|---|
| 76 | ttcclds = 0. |
|---|
| 77 | ttsclds = 0. |
|---|
| 78 | ttrad = 0. |
|---|
| 79 | ttphytra = 0. |
|---|
| 80 | |
|---|
| 81 | return |
|---|
| 82 | end |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | ************************************************** |
|---|
| 86 | * routine printimes * |
|---|
| 87 | * affiche des temps d'execution. * |
|---|
| 88 | * iout : sortie dans un fichier. * |
|---|
| 89 | * iout = 0 ---> sortie ecran * |
|---|
| 90 | * iout = 1 ---> sortie dans temps.out * |
|---|
| 91 | ************************************************** |
|---|
| 92 | subroutine printimes(iout) |
|---|
| 93 | #include "itemps.h" |
|---|
| 94 | integer iunit |
|---|
| 95 | logical ok |
|---|
| 96 | ok = .true. |
|---|
| 97 | iunit = 9 |
|---|
| 98 | if (iout.eq.0) then |
|---|
| 99 | iunit = 6 |
|---|
| 100 | else |
|---|
| 101 | do while (ok) |
|---|
| 102 | iunit = iunit+1 |
|---|
| 103 | inquire(unit=iunit,OPENED=ok) |
|---|
| 104 | if (iunit.eq.100) exit |
|---|
| 105 | enddo |
|---|
| 106 | if (iunit.eq.100) then |
|---|
| 107 | print*,"Je n'ai pas trouve d'unite logique libre." |
|---|
| 108 | print*,"J'affiche les temps a l'ecran." |
|---|
| 109 | iunit = 6 |
|---|
| 110 | endif |
|---|
| 111 | endif |
|---|
| 112 | if (iunit.ne.6) open(iunit,file="tpsprog") |
|---|
| 113 | write(iunit,*) "#############################################" |
|---|
| 114 | write(iunit,*) "ttdynt :",ttdynt |
|---|
| 115 | write(iunit,*) " ttdyn :",ttdynt-ttphys |
|---|
| 116 | write(iunit,*) " ttadvtr :",ttdyntr |
|---|
| 117 | write(iunit,*) " ttphys :",ttphys |
|---|
| 118 | write(iunit,*) " ttrad :",tthaze |
|---|
| 119 | write(iunit,*) " ttphytra :",ttphytra |
|---|
| 120 | write(iunit,*) " ttmuphys :",ttmuphys |
|---|
| 121 | write(iunit,*) " tthaze :",tthaze |
|---|
| 122 | write(iunit,*) " ttcclds :",ttcclds |
|---|
| 123 | write(iunit,*) " ttsclds :",ttsclds |
|---|
| 124 | write(iunit,*) "#############################################" |
|---|
| 125 | if (iunit.ne.6) close(iunit) |
|---|
| 126 | return |
|---|
| 127 | end |
|---|
| 128 | |
|---|