Changeset 1615 in lmdz_wrf for trunk


Ignore:
Timestamp:
Sep 3, 2017, 12:28:45 AM (8 years ago)
Author:
lfita
Message:

Adding

  • `Index1DArrayI': Function to provide the first index of a given value inside a 1D integer array
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/module_generic.f90

    r1612 r1615  
    66! ErrWarnMsg: Function to print error/warning message
    77! index_list_coordsI: Function to provide the index of a given coordinate within a list of integer coordinates
     8! Index1DArrayI: Function to provide the first index of a given value inside a 1D integer array
    89! Index1DArrayR: Function to provide the first index of a given value inside a 1D real array
    910! Index1DArrayR_K: Function to provide the first index of a given value inside a 1D real(r_k) array
     
    104105
    105106END FUNCTION Nstrings
     107
     108  INTEGER FUNCTION Index1DArrayI(array1D, d1, val)
     109! Function to provide the first index of a given value inside a 1D integer array
     110
     111    IMPLICIT NONE
     112
     113    INTEGER, INTENT(in)                                  :: d1
     114    INTEGER, INTENT(in)                                  :: val
     115    INTEGER, DIMENSION(d1), INTENT(in)                   :: array1D
     116
     117! Local
     118    INTEGER                                              :: i
     119
     120    fname = 'Index1DArrayI'
     121
     122    Index1DArrayI = -1
     123
     124    DO i=1,d1
     125      IF (array1d(i) == val) THEN
     126        Index1DArrayI = i
     127        EXIT
     128      END IF
     129    END DO
     130
     131  END FUNCTION Index1DArrayI
    106132
    107133  INTEGER FUNCTION Index1DArrayR(array1D, d1, val)
Note: See TracChangeset for help on using the changeset viewer.