c     Den følgende fortrankode er i F77. Tegnet & er her brukt
c     forlengelsestegn av linjen og plassert i kolonne 6. Dette 
c     gjelder for F77, men gjøres anderledes i F90.

	  program analytical

c	**real variables in double precision
c	b: volume factor, stb/rb
c	conv: conversion factor, Darcy's law
c	dbdp: derivative of b with respect to p, stb/rb/psi
c	dy: block height, ft
c	dz: block width, ft
c	en: 1.d0
c	eps: tolerance for adding summation terms
c	fpb: conversion factor, ft3/bbl
c	k: permeability, md
c	length: half-length of reservoir, ft	
c	p: pressure, psi at x,t
c	phi: porosity, dimensionless
c	pi: pi
c	porig: original oil pressure, psi
c	qs: surface rate, stb/d	
c	sum: sum of terms
c	t: time, days
c	to: 2.d0
c	vis: viscosity, cp
c	x: pressure points, ft
		double precision b, conv, dbdp, dy,                     
     & 			dz, en, eps, fpb, k, length, p, phi, pi, 
     &			porig, qs, sum, time,                    
     & 			to, vis, x
c
c	***other double precision variables used for intermediate
c	calculation
		double precision term, xfac, teller, xnevner, frac, 
     &		exparg, ee, toxl
c		
c	**integers
c	n: summation variable
c	nmx: number of terms in summation before cutoff
      		integer n, nmx
c
c	the open-close-open sequence for the file 'utdat' is to delete
c	old version. Otherwise, the last part of the largest 'utfil' 
c	would never be deleted.			
      		open (5,file='inndat', status='old')
      		open (10,file='utdat')
		close (10,status='delete')
      		open (10,file='utdat')
c
c     ** read and write input data.
      		read  (5,*) k, phi, x, porig, b
      		read  (5,*) vis, dbdp, t, dz, dy
      		read  (5,*) qs, length, eps
      		write (10,3020) k, phi, x, porig, b, vis,
     &          	dbdp, t, dz, dy, qs, length, eps
      		write (10,3080)
c
c	***begin calculations
c
c	**universal constants    
		conv = 0.00632827d0	
		fpb = 5.6146d0
		en = 1.d0
		to = 2.d0
     		pi  = 3.1415926d0
c
c	**other constants
		c1i2 = conv*k*b/phi/vis/dbdp
		q = qs*vis*fpb/(conv*k*dy*dz*b)
c
c	*****start summation loop
		sum = 0.d0
		toxl = to*length
c		
		do 10 n = 0, 100
			xfac = (to*n + en)*pi/toxl
			teller = dcos(xfac*x)
			xnevner = ((to*n + en)*pi)**to
			frac = teller/xnevner
c
c	then the argument of the exponential
c
			exparg = -xfac**2*c1i2*t
			term = frac*dexp(exparg)
c
c	sjekker om vi har tatt med nok ledd
c			
			sum = sum + term
			if (dabs(term).lt.eps) goto 11
   10		continue
c
c	slutt pŒ summering
c
   11		continue						
c
c	sŒ regner vi ut trykket	
		p = porig - q*(x-length) - 8*length*q*sum				
c
c	utskrifter
		write (10,*) 'tiden er  ', t
		write (10,*) 'x-verdien er  ', x
		write (10,*) 'trykket er  ', p
		write (10,*) 'antall ledd i sum ble  ', n
c     	** close files
      		close (5)
      		close (10)
c
c     	** format statements
c
 3020 		format (
     z  '  permeability, k, md  ......................... :', f12.4/
     z  '  porosity, phi, fraction ...................... :', f8.4 /
     z  '  pressur point, x, ft ......................... :', f10.2/
     z  '  original oil pressure, porig, psia ........... :', f10.1/
     z  '  volume factor, b, std vol / res vol .......... :', f10.4/
     z  '  oil viscosity, vis, cp ....................... :', f10.4/
     z  '  dbdp, std vol / res vol / psi................. :', f10.8/
     z  '  time, t, days ................................ :', f10.6/
     z  '  block width, dz, ft .......................... :', f8.1 /
     z  '  block thickness, dy, ft ...................... :', f8.1 /
     z	'  oil rate, qs, stb/d ...........................:', f8.1 /
     z	'  half-length of reservoir, l, ft ...............:', f8.1/
     z	'  summation term tolerance, eps .................:', e14.6//)
c
 3080 		format (/)
c 
      		end
c
c	end of main program
c
