## 3. Contours, Raster Maps and Surfaces

This section illustrates the use of plotmtv in viewing data sets of the form z = f(x,y) where x and y range over a rectangular mesh. The following code, cont.f illustrates the construction of an MTV data file containing the information necessary to plot the function over the region 0 < x,y < 5.

### Code 2:

program cont parameter(mmax=25,nmax=25) parameter(xmin=0.0,ymin=0.0,xmax=5.0,ymax=5.0) parameter(dx=(xmax-xmin)/mmax,dy=(ymax-ymin)/nmax) dimension u(0:mmax,0:nmax) write(6,*)'Available contour styles are:' write(6,*)'normal contours -- contstyle = 1' write(6,*)'gradated colors -- contstyle = 2' write(6,*)'3D surface mesh -- contstyle = 3' write(6,*)'Please enter a value for contstyle' read*,i open(4,file='test1.dat',status='unknown') c Specify that data are to be contoured write(4,*)'\$DATA=CONTOUR' c Specify the style of the contour map write(4,*)'%contstyle=',i c Set the number of data points in the x and y directions write(4,*)'%nx=',mmax+1 write(4,*)'%ny=',nmax+1 c Set the maximum and minimum x and y-values write(4,*)'%xmin=',xmin write(4,*)'%ymin=',ymin write(4,*)'%xmax=',xmax write(4,*)'%ymax=',ymax c Set the number of contours to display write(6,*)' ' write(6,*)'Enter the number of contours to display' read*,nsteps write(4,*)'%nsteps=',nsteps y = ymin do 1 n = 0,nmax x = xmin do 2 m = 0,mmax u(m,n) = x*x - y*y x = x + dx 2 continue y = y + dy 1 continue do 3 n = 0,nmax write(4,100)(u(m,n),m=0,mmax) 3 continue 100 format(100f10.2) close(4) end
Compile and run Code 2, then experiment with different choices of values for contstyle and number of contours.