subroutine linear_interpolation(x1,x2,f1,f2,x0,f0) implicit none include 'max.inc' c c Purpose: to perform a linear interpolation between two reference values c c Inputs: c + x1, x2: values of x for the two reference points c + f1, f2: f1=f(x1) and f2=f(x2), known values of f at points x1 and x2 c + x0: value of x where interpolation has to be performed c c Output: c + f0: value of f interpolated at x=x0 c c I/O double precision x1,x2 double precision f1,f2 double precision x0,f0 c temp c labem integer strlen character*(Nchar_mx) label label='subroutine linear_interpolation' if (x1.eq.x2) then write(*,*) 'Error from ',label(1:strlen(label)),' :' write(*,*) 'x1=',x1 write(*,*) 'x2=',x2 write(*,*) 'have identical values' stop else f0=f1+(f2-f1)/(x2-x1)*(x0-x1) endif return end