Changeset 1614 in lmdz_wrf
- Timestamp:
- Sep 1, 2017, 12:21:34 AM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/Makefile.llamp
r1613 r1614 25 25 diagsrcs = module_definitions.f90 module_generic.f90 module_scientific.f90 module_ForDiagnosticsVars.f90 module_ForDiagnostics.f90 26 26 intsrcs = module_definitions.f90 module_generic.f90 module_scientific.f90 module_ForInterpolate.f90 27 scisrcs = module_definitions.f90 module_generic.f90 module_scientific.f90 module_ForInterpolate.f9027 scisrcs = module_definitions.f90 module_generic.f90 module_scientific.f90 28 28 29 29 ####### ###### ##### #### ### ## # -
trunk/tools/module_scientific.f90
r1612 r1614 52 52 53 53 polys = -1 54 Npoly = 0 54 55 55 56 DO it=1,dt 56 IF (dbg) THEN 57 PRINT *,' it:', it, ' bool _______' 58 DO i=1,dx 59 PRINT *,boolmatt(:,:,it) 60 END DO 61 END IF 62 CALL polygons(dbg, dx, dy, boolmatt(:,:,it), polys(:,:,it), Npoly(it)) 57 IF (ANY(boolmatt(:,:,it))) THEN 58 IF (dbg) THEN 59 PRINT *,' it:', it, ' num. TRUE:', COUNT(boolmatt(:,:,it)), 'bool _______' 60 DO i=1,dx 61 PRINT *,boolmatt(i,:,it) 62 END DO 63 END IF 64 CALL polygons(dbg, dx, dy, boolmatt(:,:,it), polys(:,:,it), Npoly(it)) 65 ELSE 66 IF (dbg) THEN 67 PRINT *,' it:', it, " without '.TRUE.' values skipiing it!!" 68 END IF 69 END IF 63 70 END DO 64 71 … … 80 87 INTEGER :: ierr 81 88 INTEGER, DIMENSION(:,:), ALLOCATABLE :: borders 82 LOGICAL, DIMENSION(dx,dy) :: isborder 89 LOGICAL, DIMENSION(dx,dy) :: isborder, isbordery 83 90 INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: paths 84 91 INTEGER :: Npath 85 92 INTEGER, DIMENSION(:), ALLOCATABLE :: Nptpaths 86 93 INTEGER, DIMENSION(2) :: xtrx, xtry, meanpth 87 INTEGER :: Nvertx 94 INTEGER :: Nvertx, Npts 88 95 INTEGER, DIMENSION(:,:), ALLOCATABLE :: vertxs, points 89 96 LOGICAL, DIMENSION(:), ALLOCATABLE :: isin … … 99 106 polys = -1 100 107 101 Nppt = dx*dy 108 Nppt = dx*dy/10 109 Npts = dx*dy 110 102 111 IF (ALLOCATED(borders)) DEALLOCATE(borders) 103 112 ALLOCATE(borders(Nppt,2), STAT=ierr) … … 117 126 ! Filling with the points of all the space 118 127 IF (ALLOCATED(points)) DEALLOCATE(points) 119 ALLOCATE(points(Np pt,2), STAT=ierr)128 ALLOCATE(points(Npts,2), STAT=ierr) 120 129 msg = "Problems allocating matrix 'points'" 121 130 CALL ErrMsg(msg, fname, ierr) … … 130 139 END DO 131 140 132 CALL borders_matrixL(dx, dy, Nppt, boolmat, borders, isborder )141 CALL borders_matrixL(dx, dy, Nppt, boolmat, borders, isborder, isbordery) 133 142 CALL paths_border(dbg, dx, dy, isborder, Nppt, borders, paths, Npath, Nptpaths) 134 143 … … 142 151 143 152 IF (ALLOCATED(isin)) DEALLOCATE(isin) 144 ALLOCATE(isin(Np pt), STAT=ierr)153 ALLOCATE(isin(Npts), STAT=ierr) 145 154 msg = "Problems allocating matrix 'isin'" 146 155 CALL ErrMsg(msg, fname, ierr) … … 164 173 END IF 165 174 166 CALL gridpoints_InsidePolygon(dx, dy, boolmat, Nptpaths(ip), paths(ip,1:Nptpaths(ip),:), Nvertx,&167 xtrx, xtry, vertxs, Np pt, points, isin)175 CALL gridpoints_InsidePolygon(dx, dy, isbordery, Nptpaths(ip), paths(ip,1:Nptpaths(ip),:), Nvertx,& 176 xtrx, xtry, vertxs, Npts, points, isin) 168 177 169 178 ! Filling polygons … … 175 184 END DO 176 185 END DO 186 187 IF (dbg) THEN 188 PRINT *,' boolmat isborder isbordery polygon (',xtrx(1),',',xtry(1),')x(',xtrx(2),',',xtry(2), & 189 ') _______' 190 DO i=xtrx(1), xtrx(2) 191 PRINT *,i,':',boolmat(i,xtry(1):xtry(2)), ' border ', isborder(i,xtry(1):xtry(2)), & 192 ' isbordery ', isbordery(i,xtry(1):xtry(2)), ' polygon ', polys(i,xtry(1):xtry(2)) 193 END DO 194 END IF 177 195 178 196 END DO … … 306 324 ! Local 307 325 INTEGER :: i,j,ip,ix,iy 308 INTEGER :: Nintersecs, isvertex 326 INTEGER :: Nintersecs, isvertex, ispath 309 327 INTEGER :: ierr 310 328 LOGICAL, DIMENSION(:,:), ALLOCATABLE :: halo_brdr 329 INTEGER :: Nbrbrdr 311 330 312 331 !!!!!!! Variables … … 316 335 ! isbrdr: boolean matrix of the space wqith .T. on polygon border 317 336 ! Nvrtx: number of vertexs of the path 337 ! [x/y]pathxtrm extremes of the path 318 338 ! vrtxs: vertexs of the path along y-axis 319 339 ! Npts: number of points … … 345 365 346 366 ! It is a border point? 347 IF (isbrdr(ix,iy)) THEN 367 ispath = index_list_coordsI(Npath, path, (/ix,iy/)) 368 IF (isbrdr(ix,iy) .AND. (ispath /= -1)) THEN 348 369 inside(ip) = .TRUE. 349 370 CYCLE … … 351 372 352 373 ! Looking along y-axis 353 DO j=1,iy 374 ! Accounting for consecutives borders 375 Nbrbrdr = 0 376 DO j=MAX(1,ypathxtrm(1)-1),iy-1 354 377 ! Only counting that borders that are not vertexs 378 ispath = index_list_coordsI(Npath, path, (/ix,j/)) 355 379 isvertex = index_list_coordsI(Npath, vrtxs, (/ix,j/)) 356 IF (halo_brdr(ix+1,j+1) .AND. ( isvertex == -1)) Nintersecs = Nintersecs + 1 380 381 IF (halo_brdr(ix+1,j+1) .AND. (ispath /= -1) .AND. (isvertex == -1) ) Nintersecs = Nintersecs + 1 382 IF (halo_brdr(ix+1,j+1) .AND. (ispath /= -1) .AND. (halo_brdr(ix+1,j+1) .EQV. halo_brdr(ix+1,j+2))) THEN 383 Nbrbrdr = Nbrbrdr + 1 384 ELSE 385 ! Will remove that consecutive borders above 2 386 IF (Nbrbrdr /= 0) THEN 387 Nintersecs = Nintersecs - MAX(Nbrbrdr-1, 0) 388 Nbrbrdr = 0 389 END IF 390 END IF 357 391 END DO 358 392 IF (MOD(Nintersecs,2) /= 0) inside(ip) = .TRUE. … … 398 432 399 433 ! Label of the search 400 lclock = (/ ' N ', 'NE', 'E ', 'SE', 'S ', 'SW', 'W ', 'NW' /)434 lclock = (/ 'W ', 'NW', 'N ', 'NE', 'E ', 'SE', 'S ', 'SW' /) 401 435 ! Transformation to apply 402 !spt = (/ (/ 0,1/), (/1,1/), (/1,0/), (/1,-1/), (/0,-1/), (/-1,-1/), (/-1,0/), (/-1,1/) /)403 spt(:,1) = (/ 0, 1, 1, 1, 0, -1, -1, -1 /)404 spt(:,2) = (/ 1, 1, 0, -1, -1, -1, 0,1 /)436 !spt = (/ (/-1,0/), (/-1,1/), (/0,1/), (/1,1/), (/1,0/), (/1,-1/), (/0,-1/), (/-1,-1/) /) 437 spt(:,1) = (/ -1, -1, 0, 1, 1, 1, 0, -1 /) 438 spt(:,2) = (/ 0, 1, 1, 1, 0, -1, -1, -1 /) 405 439 406 440 xf = -1 … … 434 468 END SUBROUTINE look_clockwise_borders 435 469 436 SUBROUTINE borders_matrixL(dx,dy,dxy,Lmat,brdrs,isbrdr )470 SUBROUTINE borders_matrixL(dx,dy,dxy,Lmat,brdrs,isbrdr,isbrdry) 437 471 ! Subroutine to provide the borders of a logical array (interested in .TRUE.) 438 472 … … 442 476 LOGICAL, DIMENSION(dx,dy), INTENT(in) :: Lmat 443 477 INTEGER, DIMENSION(dxy,2), INTENT(out) :: brdrs 444 LOGICAL, DIMENSION(dx,dy), INTENT(out) :: isbrdr 478 LOGICAL, DIMENSION(dx,dy), INTENT(out) :: isbrdr, isbrdry 445 479 446 480 ! Local … … 453 487 ! brdrs: list of coordinates of the borders 454 488 ! isbrdr: matrix with .T./.F. wether the given matrix point is a border or not 489 ! isbrdry: matrix with .T./.F. wether the given matrix point is a border or not only along y-axis 455 490 456 491 fname = 'borders_matrixL' … … 491 526 END IF 492 527 END DO 528 529 isbrdry = isbrdr 493 530 494 531 ! Border as that when looking on x-axis points with Lmat(i) /= Lmat(i+1) … … 514 551 brdrs(ib,2) = j 515 552 isbrdr(i,j) = .TRUE. 553 isbrdry(i,j) = .TRUE. 516 554 ib=ib+1 517 555 ELSE IF (Lmat(i,j+1) .AND. .NOT.isbrdr(i,j+1)) THEN … … 519 557 brdrs(ib,2) = j+1 520 558 isbrdr(i,j+1) = .TRUE. 559 isbrdry(i,j+1) = .TRUE. 521 560 ib=ib+1 561 END IF 562 END IF 563 END DO 564 END DO 565 566 DO i=1, dx-1 567 DO j=1, dy-1 568 ! y-axis 569 IF ( Lmat(i,j) .NEQV. Lmat(i,j+1) ) THEN 570 IF (Lmat(i,j)) THEN 571 isbrdry(i,j) = .TRUE. 572 ELSE IF (Lmat(i,j+1)) THEN 573 isbrdry(i,j+1) = .TRUE. 574 END IF 575 END IF 576 END DO 577 END DO 578 ! only y-axis adding bands of 2 grid points 579 DO i=1, dx-1 580 DO j=2, dy-2 581 IF ( (Lmat(i,j) .EQV. Lmat(i,j+1)) .AND. (Lmat(i,j).NEQV.Lmat(i,j-1)) .AND. (Lmat(i,j).NEQV.Lmat(i,j+2)) ) THEN 582 IF (Lmat(i,j)) THEN 583 isbrdry(i,j) = .TRUE. 584 isbrdry(i,j+1) = .TRUE. 522 585 END IF 523 586 END IF … … 578 641 579 642 IF (dbg) THEN 580 PRINT *,' isborder ______'581 DO i=1,dx582 PRINT *,isborder(i,:)583 END DO584 585 643 PRINT *,' borders _______' 586 644 DO i=1,Nbrdr … … 651 709 ELSE 652 710 Nptpaths(ipath) = Nptspath 653 ! Let's have a look if the next point would be someone already in the path654 CALL look_clockwise_borders(dx,dy,Nppt,borders,gotbrdr,isborder,iip,ijp,.FALSE.,iif,jjf, &655 i ff)656 iff = index_list_coordsI(Nptspath, paths(ipath,:,:),(/iif,jjf/))657 IF (iff /= -1) THEN658 IF (dbg) THEN659 PRINT *,' point already in Path!'660 PRINT *,' path:', ipath, '_____'661 DO i=1, Nptspath662 PRINT *,' ',i,':',paths(ipath,i,:)663 E ND DO711 ! Let's have a look if the previous points in the path have already some 'non-located' neighbourgs 712 DO i=Nptspath,1,-1 713 iip = paths(ipath,i,1) 714 ijp = paths(ipath,i,2) 715 CALL look_clockwise_borders(dx,dy,Nppt,borders,gotbrdr,isborder,iip,ijp,.FALSE., iif, & 716 jjf,iff) 717 IF (iif /= -1 .AND. iff /= -1) THEN 718 IF (dbg) PRINT *,' re-take path from point:', iif,',',jjf,' n-path:', iff 719 found = .TRUE. 720 iipth = index_list_coordsI(Nppt, borders, (/iip,ijp/)) 721 EXIT 664 722 END IF 665 ! Continung unfinished path 666 iip = paths(ipath,Nptspath,1) 667 ijp = paths(ipath,Nptspath,2) 668 iipth = index_list_coordsI(Nppt, borders, (/iip,ijp/)) 669 ELSE 723 END DO 724 IF (.NOT.found) THEN 670 725 ! Looking for the next available border point for the new path 671 726 DO i=1,Nbrdr
Note: See TracChangeset
for help on using the changeset viewer.