Changeset 2359 in lmdz_wrf


Ignore:
Timestamp:
Feb 21, 2019, 8:10:14 PM (6 years ago)
Author:
lfita
Message:

Adding `Flike' in different subroutines to take into account indices from non-Fortran origins

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/module_generic.f90

    r2357 r2359  
    991991  END SUBROUTINE get_xyconlimits
    992992
    993   SUBROUTINE from_ptlist_2DRKmatrix(Npts, pts, vals, dx, dy, NOval, matrix)
     993  SUBROUTINE from_ptlist_2DRKmatrix(Npts, pts, Flike, vals, dx, dy, NOval, matrix)
    994994  ! Subroutine to construct a 2D RK matrix from a list of values accompaigned by a list of grid-point
    995995  !   coordinates
     
    998998
    999999    INTEGER, INTENT(in)                                  :: Npts, dx, dy
     1000    LOGICAL, INTENT(in)                                  :: Flike
    10001001    REAL(r_k), INTENT(in)                                :: NOval
    10011002    INTEGER, DIMENSION(Npts,2), INTENT(in)               :: pts
     
    10091010! Npts: Number of values of the list
    10101011! pts: 2D matrix coordinates of the values
     1012! Flike: whether input is Fortran-like (1: x, 2: y) or not (0-based; 1: y, 2: x)
    10111013! vals: list of values correspondant to the coordinates
    10121014! dx, dy: shape of the 2D matrix
     
    10181020    matrix = NOval
    10191021
    1020     DO iv=1, Npts
    1021       i = pts(iv,1)
    1022       j = pts(iv,2)
    1023       matrix(i,j) = vals(iv)
    1024     END DO
     1022    IF (Flike) THEN
     1023      DO iv=1, Npts
     1024        i = pts(iv,1)
     1025        j = pts(iv,2)
     1026        matrix(i,j) = vals(iv)
     1027      END DO
     1028    ELSE
     1029      DO iv=1, Npts
     1030        i = pts(iv,2)+1
     1031        j = pts(iv,1)+1
     1032        matrix(i,j) = vals(iv)
     1033      END DO
     1034    END IF
    10251035
    10261036    RETURN
     
    10281038  END SUBROUTINE from_ptlist_2DRKmatrix
    10291039
    1030   SUBROUTINE from_ptlist_2DRKNmatrix(Npts, pts, Nvals, vals, dx, dy, NOval, Nmatrix)
     1040  SUBROUTINE from_ptlist_2DRKNmatrix(Npts, pts, Flike, Nvals, vals, dx, dy, NOval, Nmatrix)
    10311041  ! Subroutine to construct N 2D RK matrix from a list of values accompaigned by a list of grid-point
    10321042  !   coordinates
     
    10351045
    10361046    INTEGER, INTENT(in)                                  :: Npts, dx, dy, Nvals
     1047    LOGICAL, INTENT(in)                                  :: Flike
    10371048    REAL(r_k), INTENT(in)                                :: NOval
    10381049    INTEGER, DIMENSION(Npts,2), INTENT(in)               :: pts
     
    10461057! Npts: Number of values of the list
    10471058! pts: 2D matrix coordinates of the values
     1059! Flike: whether input is Fortran-like (1: x, 2: y) or not (0-based; 1: y, 2: x)
    10481060! Nvals: number of different values
    10491061! vals: list of N-values correspondant to the coordinates
     
    10561068    Nmatrix = NOval
    10571069
    1058     DO iv=1, Npts
    1059       i = pts(iv,1)
    1060       j = pts(iv,2)
    1061       Nmatrix(i,j,:) = vals(iv,:)
    1062     END DO
     1070    IF (Flike) THEN
     1071      DO iv=1, Npts
     1072        i = pts(iv,1)
     1073        j = pts(iv,2)
     1074        Nmatrix(i,j,:) = vals(iv,:)
     1075      END DO
     1076    ELSE
     1077      DO iv=1, Npts
     1078        i = pts(iv,2)+1
     1079        j = pts(iv,1)+1
     1080        Nmatrix(i,j,:) = vals(iv,:)
     1081      END DO
     1082    END IF
    10631083
    10641084    RETURN
     
    10661086  END SUBROUTINE from_ptlist_2DRKNmatrix
    10671087
    1068   SUBROUTINE from_coordlist_2DRKmatrix(Npts, coords, xcoord, ycoord, vals, dx, dy, NOval, matrix)
     1088  SUBROUTINE from_coordlist_2DRKmatrix(Npts, coords, Flike, xcoord, ycoord, vals, dx, dy, NOval,      &
     1089    matrix)
    10691090  ! Subroutine to construct a 2D RK matrix from a list of values accompaigned by a list of coordinates
    10701091  !   to find i,j grid-point coordinates by minimum distance
     
    10731094
    10741095    INTEGER, INTENT(in)                                  :: Npts, dx, dy
     1096    LOGICAL, INTENT(in)                                  :: Flike
    10751097    REAL(r_k), INTENT(in)                                :: NOval
    10761098    REAL(r_k), DIMENSION(Npts,2), INTENT(in)             :: coords
     
    10881110! Npts: Number of values of the list
    10891111! coords: 2D coordinates of the values
     1112! Flike: whether input is Fortran-like (1: x, 2: y) or not (0-based; 1: y, 2: x)
    10901113! vals: list of values correspondant to the coordinates
    10911114! xcoord, ycoord: matrix of values correspondant to the each coordinate
     
    10981121    matrix = NOval
    10991122
    1100     DO iv=1, Npts
    1101       xi = coords(iv,1)
    1102       yi = coords(iv,2)
    1103       diff = SQRT((xcoord-xi)**2+(ycoord-yi)**2)
    1104       minpt = MINLOC(diff)
    1105       matrix(minpt(1),minpt(2)) = vals(iv)
    1106     END DO
     1123    IF (Flike) THEN
     1124      DO iv=1, Npts
     1125        xi = coords(iv,1)
     1126        yi = coords(iv,2)
     1127        diff = SQRT((xcoord-xi)**2+(ycoord-yi)**2)
     1128        minpt = MINLOC(diff)
     1129        matrix(minpt(1),minpt(2)) = vals(iv)
     1130      END DO
     1131    ELSE
     1132      DO iv=1, Npts
     1133        xi = coords(iv,2)
     1134        yi = coords(iv,1)
     1135        diff = SQRT((xcoord-xi)**2+(ycoord-yi)**2)
     1136        minpt = MINLOC(diff)
     1137        matrix(minpt(1),minpt(2)) = vals(iv)
     1138      END DO
     1139    END IF
    11071140
    11081141    RETURN
Note: See TracChangeset for help on using the changeset viewer.