source: trunk/SOURCES/minmax-format.f90 @ 111

Last change on this file since 111 was 22, checked in by roche, 8 years ago

Petites adaptations diverses du code pour compilation en gfortran. Ajout d un Makefile flexible a option pour choisir ifort ou gfortran.

File size: 2.2 KB
Line 
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
20subroutine minmax_format(valmin,valmax,ff)
21implicit none
22
23real :: valmin
24real :: valmax
25character(len=8) :: ff
26character(len=3) :: f1
27! dmr&aurel for gfortran compilation ...
28character(len=1) :: dumf1
29
30integer  ::  if1,if2,ipos,ipos2,n1,if3
31integer :: ipr! precision du reel
32
33ipr=precision(1.)
34
35print*,ipr
36ff=adjustl(ff) ! aligne à gauche au cas ou un blanc aurait ete mis au debut
37
38if (( ff(1:1).eq.'f').or.(ff(1:1).eq.'F')) then ! format f
39
40! recherche du . et de la fin
41ipos=index(ff,'.')
42ipos2=ipos+2
43!ipos2=index(ff,' ')
44!ipos2=max(ipos2,ipos1+2)
45
46print*,ipos,ipos2
47print*,ff
48
49f1=ff(2:ipos-1) ! sous string contenant le premier chiffre
50
51! dmr&aurel inum is not a std intrinsic
52dumf1 = f1(1:2)
53if1 = ichar(dumf1)-ichar('0')
54! dmr&aurel if1=inum(f1)    ! valeur numerique du premier chiffre
55
56print*, 'if1=',if1
57f1=ff(ipos+1:ipos+2) ! sous string contenant le deuxieme chiffre
58print*, 'f1= ',trim(f1)//'***' 
59f1=adjustr(f1)
60! dmr&aurel inum is not a std intrinsic
61dumf1 = f1(1:2)
62if2 = ichar(dumf1)-ichar('0')
63! if2=inum(f1)       ! valeur numerique
64print*, 'if2=',if2
65
66! valeur minimum
67n1=if1-if2-2
68if3=max(-if2,(if1-ipr-3-if2)) 
69valmin=-(10.**n1-10.**(if3))
70print*, if3
71
72! valeur maximum
73n1=n1+1
74if3=max(-if2,(if1-ipr-2-if2)) 
75print*, if3
76
77valmax=10.**n1-10.**(if3)
78
79else if (( ff(1:1).eq.'e').or.(ff(1:1).eq.'E')) then ! format e
80valmin=1.e30
81valmax=-1.e-30
82
83else if  (( ff(1:1).eq.'i').or.(ff(1:1).eq.'I')) then ! format i
84
85ipos2=index(ff,' ')
86f1=ff(2:ipos2-1) ! sous string contenant le  chiffre
87! dmr&aurel inum is not a std intrinsic
88dumf1 = f1(1:2)
89if1 = ichar(dumf1)-ichar('0')
90! if1=inum(f1)    ! valeur numerique du premier chiffre
91n1=if1-1
92valmin=int(-(10**n1))+1
93
94n1=n1+1
95valmax=int((10**n1))-1
96endif
97
98end subroutine minmax_format
Note: See TracBrowser for help on using the repository browser.