-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmpnum.f
More file actions
29 lines (29 loc) · 750 Bytes
/
cmpnum.f
File metadata and controls
29 lines (29 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
program cmpnum
implicit none
real*8 a,b,diff
integer linnum,tmp,best
open(17,file='cmpnum.log',status='unknown')
best=-22
99 read(*,*,end=70,err=60) linnum,a,b
diff=0.5*(abs(a)+abs(b))
c print *,a,b,diff,abs(a-b)/diff
c if (diff.gt.1.e-12) then
if (diff.gt.0.) then
diff=abs(a-b)/diff
if (diff.gt.0.) then
c print *,int(log10(diff)),diff
tmp=nint(log10(diff))
else
tmp=-16;
endif
best=max(best,tmp)
else
tmp =-22
endif
write(17,'(I4,1P2E22.14,A,I4)') linnum,a,b,' :',-tmp
goto 99
60 stop 'cmpnum: An error occured reading a,b'
70 continue
close(17)
print *,-best
end