FV3 Bundle
gsw_util_interp1q_int.f90
Go to the documentation of this file.
1 !==========================================================================
2 pure function gsw_util_interp1q_int (x, iy, x_i) result(y_i)
3 !==========================================================================
4 ! Returns the value of the 1-D function iy (integer) at the points of column
5 ! vector x_i using linear interpolation. The vector x specifies the
6 ! coordinates of the underlying interval.
7 !
8 ! Assumes x is monotonically increasing. If x_i is also monotonically
9 ! increasing then this function is even more efficient through the use of
10 ! kstart option to function gsw_util_indx (G.B.Hyland 10/8/2017).
11 !==========================================================================
12 
14 
15 use gsw_mod_kinds
16 
17 implicit none
18 
19 integer, intent(in) :: iy(:)
20 real (r8), intent(in) :: x(:), x_i(:)
21 
22 real (r8) :: y_i(size(x_i))
23 
24 integer :: i, nx, k
25 real (r8) :: r
26 
27 nx = size(x)
28 
29 k = 1
30 do i = 1, size(x_i)
31 
32  if (x_i(i) .le. x(1)) then
33 
34  y_i(i) = real(iy(1),r8)
35 
36  else if (x_i(i) .ge. x(nx)) then
37 
38  y_i(i) = real(iy(nx),r8)
39 
40  else
41 
42  if (i .gt. 1) then
43  if (x_i(i) .lt. x_i(i-1)) k = 1
44  end if
45  k = gsw_util_indx(x,x_i(i),kstart=k)
46 
47  r = (x_i(i)-x(k))/(x(k+1)-x(k))
48  y_i(i) = real(iy(k),r8) + r*real(iy(k+1)-iy(k),r8)
49 
50  end if
51 end do
52 
53 return
54 
55 end function
56 
57 !--------------------------------------------------------------------------
integer, parameter r8
pure real(r8) function, dimension(size(x_i)) gsw_util_interp1q_int(x, iy, x_i)
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE size(field%axes(:)) axsiz(i)