Changeset 1654 in lmdz_wrf


Ignore:
Timestamp:
Sep 25, 2017, 11:28:03 PM (7 years ago)
Author:
lfita
Message:

Fixing:

  • calcualtion of mean weighted-center of the polygon at `polygon_properties'
  • Adding compilation at single resolution
Location:
trunk/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/interpolate.f90

    r1608 r1654  
    7474  difffraclonlat = SQRT((fraclon-lonv)**2. + (fraclat-latv)**2.)
    7575  mindifffracLl = MINVAL(difffraclonlat)
     76!  ilonlatfrac = index2DArrayR_K(difffraclonlat, Nperx, Npery, mindifffracLl)
    7677  ilonlatfrac = index2DArrayR(difffraclonlat, Nperx, Npery, mindifffracLl)
    7778
  • trunk/tools/module_definitions.f90

    r1621 r1654  
    11MODULE module_definitions
    22
    3   INTEGER, PARAMETER                                     :: r_k = KIND(1.d0)
     3!  INTEGER, PARAMETER                                     :: r_k = KIND(1.d0)
     4  INTEGER, PARAMETER                                     :: r_k = KIND(1.)
    45  REAL(r_k), PARAMETER                                   :: zeroRK = 0.
    56  REAL(r_k), PARAMETER                                   :: oneRK = 1.
  • trunk/tools/module_scientific.f90

    r1652 r1654  
    4343  CONTAINS
    4444
    45 
    4645  SUBROUTINE poly_overlap_tracks_area(dbg, dx, dy, dt, minarea, inNallpolys, allpolys, ctrpolys,      &
    4746    areapolys, Nmaxpoly, Nmaxtracks, tracks, finaltracks)
     
    6564    INTEGER                                              :: i, j, ip, it, iip, itt
    6665    INTEGER                                              :: ierr
    67     REAL(r_k), DIMENSION(2,Nmaxpoly,dt)                  :: Actrpolys
    68     REAL(r_k), DIMENSION(Nmaxpoly,dt)                    :: Aareapolys
     66    REAL(r_k), DIMENSION(Nmaxpoly)                       :: Aprevpolys, Acurrpolys
     67    REAL(r_k), DIMENSION(2,Nmaxpoly)                     :: Cprevpolys, Ccurrpolys
    6968    INTEGER, DIMENSION(dt)                               :: Nallpolys
    7069    INTEGER, DIMENSION(dx,dy)                            :: meetpolys, searchpolys
     
    7372    INTEGER, DIMENSION(:), ALLOCATABLE                   :: coins
    7473    INTEGER, DIMENSION(:,:), ALLOCATABLE                 :: coinsNpts
    75     INTEGER, DIMENSION(Nmaxpoly,dt)                      :: polycoincidencies
    76     INTEGER, DIMENSION(Nmaxpoly,Nmaxpoly,dt)             :: coincidenciesNpts
    7774    INTEGER                                              :: Nmeet, Nsearch, Nindep
    7875    INTEGER, DIMENSION(dt)                               :: Nindeppolys
     
    105102    IF (dbg) PRINT *,TRIM(fname)
    106103
    107     polycoincidencies = fillvalI
    108     coincidenciesNpts = fillvalI
    109104    ! Number of independent polygons by time step
    110105    Nindeppolys = 0
     
    131126        SpolysIndep(ip,it) = i
    132127        currID(ip) = i
     128        Acurrpolys(ip) = areapolys(i,it)
     129        Ccurrpolys(1,ip) = ctrpolys(1,i,it)
     130        Ccurrpolys(2,ip) = ctrpolys(2,i,it)
    133131        NpolysIndep(ip,it) = 1
    134132        polysIndep(ip,1,it) = i
    135         Actrpolys(1,ip,it) = ctrpolys(1,i,it)
    136         Actrpolys(2,ip,it) = ctrpolys(2,i,it)
    137         Aareapolys(ip,it) = areapolys(i,it)
    138133      ELSE
    139134        WHERE (meetpolys == i)
     
    167162      prevID = 0
    168163      prevID = currID
     164      Aprevpolys = Acurrpolys
     165      Cprevpolys = Ccurrpolys
    169166      ip = 0
    170167
     
    173170          ip = ip + 1
    174171          currID(ip) = i
    175           Actrpolys(1,ip,it+1) = ctrpolys(1,i,it+1)
    176           Actrpolys(2,ip,it+1) = ctrpolys(2,i,it+1)
    177           Aareapolys(ip,it+1) = areapolys(i,it+1)
     172          Acurrpolys(ip) = areapolys(i,it+1)
     173          Acurrpolys(ip) = areapolys(i,it+1)
     174          Ccurrpolys(1,ip) = ctrpolys(1,i,it+1)
     175          Ccurrpolys(2,ip) = ctrpolys(2,i,it+1)
    178176        ELSE
    179177          WHERE (meetpolys == i)
     
    199197      CALL ErrMsg(msg,fname,ierr)
    200198
    201       CALL coincidence_all_polys_area(dbg, dx,dy, Nmeet, currID, meetpolys, Actrpolys(:,1:Nmeet,it+1),&
    202         Nsearch, prevID, searchpolys, Actrpolys(:,1:Nsearch,it), Aareapolys(1:Nsearch,it), coins,     &
     199      CALL coincidence_all_polys_area(dbg, dx,dy, Nmeet, currID, meetpolys, Acurrpolys(1:Nmeet),      &
     200        Nsearch, prevID, searchpolys, Cprevpolys(:,1:Nsearch), Aprevpolys(1:Nsearch), coins,          &
    203201        coinsNpts)
    204 
    205       polycoincidencies(1:Nmeet,it+1) = coins
    206       coincidenciesNpts(1:Nmeet,1:Nsearch,it+1) = coinsNpts
    207202
    208203      ! Counting the number of times that a polygon has a coincidency
     
    234229            DO j=1, NNprev
    235230              IF (coins(i) == polysIndep(ip,j,it)) THEN
    236                 IF (coincidencies(ip) == 0) THEN
     231                ! Which index corresponds to this coincidence?
     232                iindep = Index1DArrayI(SpolysIndep(1:Nindep,it+1), Nindep, coins(i))
     233                IF (iindep == -1) THEN
    237234                  Nindep = Nindep + 1
    238235                  SpolysIndep(Nindep,it+1) = coins(i)
    239236                END IF
    240                 ! Which index corresponds to this coincidence?
    241                 iindep = Index1DArrayI(SpolysIndep(1:Nmeet,it+1), Nindep, coins(i))
     237                iindep = Index1DArrayI(SpolysIndep(1:Nindep,it+1), Nindep, coins(i))
    242238                IF (iindep < 0) THEN
     239                  PRINT *,'    Looking for:', coins(i)
     240                  PRINT *,'    Within:', SpolysIndep(1:Nindep,it+1)
     241                  PRINT *,'    Might content:', polysIndep(ip,1:NNprev,it)
     242                  PRINT *,'    From an initial list:', coins(1:Nmeet)
    243243                  msg = 'Wrong index! There must be an index here'
    244244                  CALL ErrMsg(msg,fname,iindep)
     
    384384        itrack = INT(tracks(1,1,itt,it))
    385385        Nprev = COUNT(INT(tracks(2,:,itt,it)) /= 0)
    386         PRINT *,'it:', it,'itrack:', itrack, 'Nprev:', Nprev
    387         PRINT *,'  coordinates ix iy _______'
    388         DO i=1,Nprev
    389           PRINT *,'    ',tracks(3,i,itt,it),tracks(4,i,itt,it)
    390         END DO
    391386        finaltracks(1,itrack,it) = itrack*1.
    392387        finaltracks(2,itrack,it) = SUM(tracks(3,:,itt,it))/Nprev
    393388        finaltracks(3,itrack,it) = SUM(tracks(4,:,itt,it))/Nprev
    394389        finaltracks(4,itrack,it) = it*1.
    395         PRINT *,'  finaltrack:', finaltracks(:,itrack,it)
    396390      END DO
    397391    END DO
     392
     393    DEALLOCATE(coins)
     394    DEALLOCATE(coinsNpts)
    398395
    399396    RETURN
     
    12221219  meanvnctr = 0.
    12231220  meanvxctr = 0.
     1221  xcorr = 0.
     1222  ycorr = 0.
    12241223
    12251224  nval = fillval64
     
    12401239          CASE ('lon/lat')
    12411240            ! Area as fixed yres and sinus-lat varying for xres
    1242             xcorr(i,j) = DABS(DSIN(lon(i,j)*DegRad))
     1241!            IF (KIND(xcorr(i,j)) == KIND(1.d0)) THEN
     1242!              xcorr(i,j) = DABS(DSIN(lon(i,j)*DegRad))
     1243!            ELSE
     1244              xcorr(i,j) = ABS(SIN(lon(i,j)*DegRad))
     1245!            END IF
    12431246            ycorr(i,j) = 1.
    12441247          CASE ('nadir-sat')
    12451248            ! Area from nadir resolution and degrading as we get far from satellite's nadir
    12461249            ! GOES-E: 0 N, 75 W
    1247             xcorr(i,j) = DABS(DSIN(lon(i,j)*DegRad))
     1250!            IF (KIND(xcorr(i,j)) == KIND(1.d0)) THEN
     1251!              xcorr(i,j) = DABS(DSIN(lon(i,j)*DegRad))
     1252!            ELSE
     1253              xcorr(i,j) = ABS(SIN(lon(i,j)*DegRad))
     1254!            END IF
    12481255            ycorr(i,j) = 1.
    12491256        END SELECT
     
    12671274
    12681275  IF (dbg) THEN
    1269     PRINT *,'  grdi_coord lon lat value _______ '
     1276    PRINT *,'  grid_coord lon lat value _______ '
    12701277    DO ip=1, Npolypts
    12711278      PRINT *, polypts(ip,:), ';', lon(polypts(ip,1),polypts(ip,2)), lat(polypts(ip,1),polypts(ip,2)),&
     
    12851292    PRINT *,'  mean grid center: ', meanctr, ' weighted mean center: ', meanwctr
    12861293  END IF
    1287  
     1294
    12881295  ! Statistics of the values within the polygon
    12891296  CALL StatsR_K(Npolypts, polyvals, nval, xval, mval, m2val, stdval)
     
    12961303
    12971304  ! Mean center weighted to minimum and maximum values
    1298   distvn = DABS(polyvals - nval)
    1299   distvx = DABS(polyvals - xval)
     1305!  IF (KIND(polyvals(1)) == KIND(1.d0)) THEN
     1306!    distvn = DABS(polyvals - nval)
     1307!    distvx = DABS(polyvals - xval)
     1308!  ELSE
     1309    distvn = ABS(polyvals - nval)
     1310    distvx = ABS(polyvals - xval)
     1311!  END IF
    13001312
    13011313  meanvnctr = 0.
Note: See TracChangeset for help on using the changeset viewer.