Changeset 1653 in lmdz_wrf


Ignore:
Timestamp:
Sep 21, 2017, 8:20:40 PM (7 years ago)
Author:
lfita
Message:

Adding:

  • `Index2DArrayR_K': Function to provide the first index of a given value inside a 2D real(r_k) array
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/module_generic.f90

    r1619 r1653  
    1010! Index1DArrayR_K: Function to provide the first index of a given value inside a 1D real(r_k) array
    1111! Index2DArrayR: Function to provide the first index of a given value inside a 2D real array
     12! Index2DArrayR_K: Function to provide the first index of a given value inside a 2D real(r_k) array
    1213! mat2DPosition: Function to provide the i, j indices of a given value inside a 2D matrix
    1314! Nstrings: Function to repeat a number of times a given string
     
    139140    IMPLICIT NONE
    140141
    141     INTEGER, PARAMETER                                   :: r_k = KIND(1.d0)
    142     INTEGER, INTENT(in)                                  :: d1
    143     REAL(r_k), INTENT(in)                                :: val
    144     REAL(r_k), DIMENSION(d1), INTENT(in)                 :: array1D
     142    INTEGER, INTENT(in)                                  :: d1
     143    REAL, INTENT(in)                                     :: val
     144    REAL, DIMENSION(d1), INTENT(in)                      :: array1D
    145145
    146146! Local
     
    190190    IMPLICIT NONE
    191191
    192     INTEGER, PARAMETER                                   :: r_k = KIND(1.d0)
    193192    INTEGER, INTENT(in)                                  :: d1, d2
    194     REAL(r_k), INTENT(in)                                :: val
    195     REAL(r_k), DIMENSION(d1,d2), INTENT(in)              :: array2D
     193    REAL, INTENT(in)                                     :: val
     194    REAL, DIMENSION(d1,d2), INTENT(in)                   :: array2D
    196195    INTEGER, DIMENSION(2)                                :: Index2DArrayR
    197196
     
    214213
    215214  END FUNCTION Index2DArrayR
     215
     216  FUNCTION Index2DArrayR_K(array2D, d1, d2, val)
     217! Function to provide the first index of a given value inside a 2D real array
     218
     219    IMPLICIT NONE
     220
     221    INTEGER, INTENT(in)                                  :: d1, d2
     222    REAL(r_k), INTENT(in)                                :: val
     223    REAL(r_k), DIMENSION(d1,d2), INTENT(in)              :: array2D
     224    INTEGER, DIMENSION(2)                                :: Index2DArrayR_K
     225
     226! Local
     227    INTEGER                                              :: i, j
     228
     229    fname = 'Index2DArrayR_K'
     230
     231    Index2DArrayR_K = -1
     232
     233    DO i=1,d1
     234      DO j=1,d2
     235        IF (array2d(i,j) == val) THEN
     236          Index2DArrayR_K(1) = i
     237          Index2DArrayR_K(2) = j
     238          EXIT
     239        END IF
     240      END DO
     241    END DO
     242
     243  END FUNCTION Index2DArrayR_K
    216244
    217245  FUNCTION RangeI(d1, iniv, endv)
Note: See TracChangeset for help on using the changeset viewer.