V3FIT
f2test.f
1  subroutine f2test(fun1,fun2,inump,xmin,xmax,ymin,ymax,
2  > name,namex,namey)
3 c
4 c test/compare 2 methods of evaluation of 2d function values and derivatives
5 c
6 c passed:
7 c subroutine fun1(x,y,fget1(1..6))
8 c subroutine fun1(x,y,fget2(1..6))
9 c
10 c (input x,y, return vector of 6 numbers containing, in order:
11 c f,df/dx,df/dy,d2f/dx2,d2f/dy2,d2f/dxdy)
12 c
13  external fun1,fun2
14 c
15  integer inump ! #evals per dimension
16 c
17  real xmin,xmax ! x range
18  real ymin,ymax ! y range
19 c
20  character*(*) name ! name/label for fcns --
21  character*(*) namex,namey ! name/label for x & y dims
22 c
23 c NOTE `name*' should be short with no leading or trailing blanks
24 c
25 c local:
26 c
27  real fget1(6),fget2(6),fmin(6),fmax(6),fdifa(6)
28 c
29 c output of routine: stats written to unit 6
30 c
31 c--------------------------------
32 c
33  data icyc/100000/
34 c
35  do i=1,6
36  fmin(i)=1.0e35
37  fmax(i)=-1.0e35
38  fdifa(i)=0.0
39  enddo
40 c
41  ict=0
42 c
43  do iy=1,inump
44  zy=ymin+float(iy-1)*(ymax-ymin)/float(inump-1)
45  do ix=1,inump
46  zx=xmin+float(ix-1)*(xmax-xmin)/float(inump-1)
47 c
48  ict=ict+1
49  if(icyc*(ict/icyc).eq.ict) then
50  write(6,1001) ix,zx,iy,zy,ict
51  1001 format(' ...f2test: evaluating at x(',i5,')=',1pe11.4,
52  > ', y(',i5,')=',1pe11.4,' #=',i8)
53  endif
54 c
55  call fun1(zx,zy,fget1)
56  call fun2(zx,zy,fget2)
57 c
58  do i=1,6
59  fmin(i)=min(fmin(i),fget1(i),fget2(i))
60  fmax(i)=max(fmax(i),fget1(i),fget2(i))
61  zdifa=abs(fget1(i)-fget2(i))
62  fdifa(i)=max(fdifa(i),zdifa)
63  enddo
64 c
65  enddo
66  enddo
67 c
68  write(6,1002) namex,namey,name,
69  > (name,fmin(i),fmax(i),fdifa(i),i=1,6)
70  1002 format(/
71  >' test function comparison:'/
72  >' x stands for "',a,'"; y stands for "',a,'".'/
73  >' (',a,') min value max value max |diff|'/
74  >' ',a,': ',3(1pe11.3,2x)/
75  >' d',a,'/dx: ',3(1pe11.3,2x)/
76  >' d',a,'/dy: ',3(1pe11.3,2x)/
77  >' d2',a,'/dx2: ',3(1pe11.3,2x)/
78  >' d2',a,'/dy2: ',3(1pe11.3,2x)/
79  >' d2',a,'/dxdy: ',3(1pe11.3,2x)/)
80 c
81  return
82  end