| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision | :: | x_table(n_table) | ||||
| double precision | :: | y_table(n_table) | ||||
| integer | :: | n_table | ||||
| double precision | :: | x_itp(n_itp) | ||||
| double precision | :: | y_itp(n_itp) | ||||
| integer | :: | n_itp |
subroutine interp_linear(x_table,y_table,n_table,x_itp,y_itp,n_itp) ! linear interpolation ! 1D method integer :: n_table,n_itp double precision :: x_table(n_table),y_table(n_table) double precision :: x_itp(n_itp),y_itp(n_itp) integer :: i,j !if (x_table(1)>x_itp(1) .or. x_table(n_table)<x_itp(n_itp)) then ! call mpistop("out of interpolation table") !endif do i=1,n_itp if(x_itp(i)<x_table(1)) then y_itp(i)=y_table(1) exit end if if(x_itp(i)>=x_table(n_table)) then y_itp(i)=y_table(n_table) exit end if LOOPT: do j=1,n_table-1 if (x_itp(i)>=x_table(j) .and. x_itp(i)<x_table(j+1)) then y_itp(i)=y_table(j) + (x_itp(i)-x_table(j))*(y_table(j+& 1)-y_table(j))/(x_table(j+1)-x_table(j)) exit LOOPT endif enddo LOOPT enddo end subroutine interp_linear