[4] | 1 | !> \file minmax-format.f90 |
---|
| 2 | !! Module pour le calcul des min max admissibles a partir du format f. |
---|
| 3 | !< |
---|
| 4 | |
---|
| 5 | !> SUBROUTINE: minmax_format() |
---|
| 6 | !! \author ... |
---|
| 7 | !! \date ... |
---|
| 8 | !! @note Petite routine qui renvoie les valeurs min et max |
---|
| 9 | !! admissibles a partir du format f. |
---|
| 10 | !! @note Pour eviter les ***** |
---|
| 11 | !! le format doit etre sous la forme f6.2 ou e12.4 |
---|
| 12 | !! @note Attention, pour les formats i, renvoie les min max en reel |
---|
| 13 | !! et ne marche pas au dela de i7 |
---|
| 14 | !! @note Pour le format e, renvoie valmin > valmax |
---|
| 15 | !! \param valmin |
---|
| 16 | !! \param valmax |
---|
| 17 | !! \param ff |
---|
| 18 | !< |
---|
| 19 | |
---|
| 20 | subroutine minmax_format(valmin,valmax,ff) |
---|
| 21 | implicit none |
---|
| 22 | |
---|
| 23 | real :: valmin |
---|
| 24 | real :: valmax |
---|
| 25 | character(len=8) :: ff |
---|
| 26 | character(len=3) :: f1 |
---|
[22] | 27 | ! dmr&aurel for gfortran compilation ... |
---|
| 28 | character(len=1) :: dumf1 |
---|
[4] | 29 | |
---|
| 30 | integer :: if1,if2,ipos,ipos2,n1,if3 |
---|
| 31 | integer :: ipr! precision du reel |
---|
| 32 | |
---|
| 33 | ipr=precision(1.) |
---|
| 34 | |
---|
| 35 | print*,ipr |
---|
| 36 | ff=adjustl(ff) ! aligne à gauche au cas ou un blanc aurait ete mis au debut |
---|
| 37 | |
---|
| 38 | if (( ff(1:1).eq.'f').or.(ff(1:1).eq.'F')) then ! format f |
---|
| 39 | |
---|
| 40 | ! recherche du . et de la fin |
---|
| 41 | ipos=index(ff,'.') |
---|
| 42 | ipos2=ipos+2 |
---|
| 43 | !ipos2=index(ff,' ') |
---|
| 44 | !ipos2=max(ipos2,ipos1+2) |
---|
| 45 | |
---|
| 46 | print*,ipos,ipos2 |
---|
| 47 | print*,ff |
---|
| 48 | |
---|
| 49 | f1=ff(2:ipos-1) ! sous string contenant le premier chiffre |
---|
| 50 | |
---|
[22] | 51 | ! dmr&aurel inum is not a std intrinsic |
---|
| 52 | dumf1 = f1(1:2) |
---|
| 53 | if1 = ichar(dumf1)-ichar('0') |
---|
| 54 | ! dmr&aurel if1=inum(f1) ! valeur numerique du premier chiffre |
---|
| 55 | |
---|
[4] | 56 | print*, 'if1=',if1 |
---|
| 57 | f1=ff(ipos+1:ipos+2) ! sous string contenant le deuxieme chiffre |
---|
| 58 | print*, 'f1= ',trim(f1)//'***' |
---|
| 59 | f1=adjustr(f1) |
---|
[22] | 60 | ! dmr&aurel inum is not a std intrinsic |
---|
| 61 | dumf1 = f1(1:2) |
---|
| 62 | if2 = ichar(dumf1)-ichar('0') |
---|
| 63 | ! if2=inum(f1) ! valeur numerique |
---|
[4] | 64 | print*, 'if2=',if2 |
---|
| 65 | |
---|
| 66 | ! valeur minimum |
---|
| 67 | n1=if1-if2-2 |
---|
| 68 | if3=max(-if2,(if1-ipr-3-if2)) |
---|
| 69 | valmin=-(10.**n1-10.**(if3)) |
---|
| 70 | print*, if3 |
---|
| 71 | |
---|
| 72 | ! valeur maximum |
---|
| 73 | n1=n1+1 |
---|
| 74 | if3=max(-if2,(if1-ipr-2-if2)) |
---|
| 75 | print*, if3 |
---|
| 76 | |
---|
| 77 | valmax=10.**n1-10.**(if3) |
---|
| 78 | |
---|
| 79 | else if (( ff(1:1).eq.'e').or.(ff(1:1).eq.'E')) then ! format e |
---|
| 80 | valmin=1.e30 |
---|
| 81 | valmax=-1.e-30 |
---|
| 82 | |
---|
| 83 | else if (( ff(1:1).eq.'i').or.(ff(1:1).eq.'I')) then ! format i |
---|
| 84 | |
---|
| 85 | ipos2=index(ff,' ') |
---|
| 86 | f1=ff(2:ipos2-1) ! sous string contenant le chiffre |
---|
[22] | 87 | ! dmr&aurel inum is not a std intrinsic |
---|
| 88 | dumf1 = f1(1:2) |
---|
| 89 | if1 = ichar(dumf1)-ichar('0') |
---|
| 90 | ! if1=inum(f1) ! valeur numerique du premier chiffre |
---|
[4] | 91 | n1=if1-1 |
---|
| 92 | valmin=int(-(10**n1))+1 |
---|
| 93 | |
---|
| 94 | n1=n1+1 |
---|
| 95 | valmax=int((10**n1))-1 |
---|
| 96 | endif |
---|
| 97 | |
---|
| 98 | end subroutine minmax_format |
---|