SURFEX v8.1
General documentation of Surfex
rtoi.F
Go to the documentation of this file.
1  SUBROUTINE rtoi(REAL_V, INT_V, N)
2 !
3 !**** SUBROUTINE rtoi - To convert from 64-bit REAL to INTEGER
4 !
5 ! S.Saarinen ECMWF 27/6/95
6 !
7 !** INTERFACE
8 ! ---------
9 !
10 ! CALL rtoi(real_v, int_v, n)
11 ! WHERE:
12 ! real_v = 64-bit REAL-vector (INPUT) of n elements
13 ! each holding one integer value
14 ! int_v = Integer vector (OUTPUT) of n elements:
15 ! Only 32-bit range is accepted i.e.
16 ! [-2147483648 ... 2147483647] which is the same as
17 ! [-2**31 ... 2**31 - 1]
18 ! n = length of the vectors
19 !
20 !
21 !-----------------------------------------------------------------------
22 !
23  USE parkind1, ONLY : jpim
24  IMPLICIT NONE
25  INTEGER(KIND=JPIM) :: N
26 !-- The following MUST be 64-bit REALs [i.e. REAL(8) on Fortran-90]
27  REAL(KIND=8) :: REAL_V(n)
28  INTEGER(KIND=JPIM) :: INT_V(n)
29  INTEGER(KIND=JPIM) :: I
30 
31  DO i=1,n
32 !J int_v(i) = min(max(-2147483647,int(real_v(i))),2147483647)
33  int_v(i)=int(min(max(-2000000000.0_8,real_v(i)),2000000000.0_8))
34  ENDDO
35 
36  RETURN
37  ENDSUBROUTINE rtoi
integer, parameter jpim
Definition: parkind1.F90:13
subroutine rtoi(REAL_V, INT_V, N)
Definition: rtoi.F:2