Changeset 1414 for palm/trunk/SOURCE
- Timestamp:
- May 31, 2014 11:19:48 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/init_masks.f90
r1354 r1414 20 20 ! Current revisions: 21 21 ! ----------------- 22 ! 22 ! Bugfix: first and last grid points as they appear in 3D volume data can now 23 ! be included to masked data output 23 24 ! 24 25 ! Former revisions: … … 125 126 ! 126 127 !-- Allocation and initialization 127 ALLOCATE( tmp_array( MAX(nx,ny,nz)+ 1) )128 129 ALLOCATE( mask_i(max_masks,nxr-nxl+ 1), &130 mask_j(max_masks,nyn-nys+ 1), &131 mask_k(max_masks,nzt-nzb+ 1) )128 ALLOCATE( tmp_array( MAX(nx,ny,nz)+2 ) ) 129 130 ALLOCATE( mask_i(max_masks,nxr-nxl+2), & 131 mask_j(max_masks,nyn-nys+2), & 132 mask_k(max_masks,nzt-nzb+2) ) 132 133 ! 133 134 !-- internal mask arrays ("mask,dimension,selection") … … 183 184 !-- Global arrays are required by define_netcdf_header. 184 185 IF ( myid == 0 .OR. netcdf_data_format > 4 ) THEN 185 ALLOCATE( mask_i_global(max_masks,nx+ 1), &186 mask_j_global(max_masks,ny+ 1), &187 mask_k_global(max_masks,nz+ 1) )186 ALLOCATE( mask_i_global(max_masks,nx+2), & 187 mask_j_global(max_masks,ny+2), & 188 mask_k_global(max_masks,nz+2) ) 188 189 mask_i_global = -1; mask_j_global = -1; mask_k_global = -1 189 190 ENDIF … … 469 470 IF ( netcdf_data_format > 4 ) THEN 470 471 471 CALL MPI_BCAST( mask_i_global(mid,:), nx+ 1, MPI_INTEGER, 0, comm2d, &472 CALL MPI_BCAST( mask_i_global(mid,:), nx+2, MPI_INTEGER, 0, comm2d, & 472 473 ierr ) 473 CALL MPI_BCAST( mask_j_global(mid,:), ny+ 1, MPI_INTEGER, 0, comm2d, &474 CALL MPI_BCAST( mask_j_global(mid,:), ny+2, MPI_INTEGER, 0, comm2d, & 474 475 ierr ) 475 CALL MPI_BCAST( mask_k_global(mid,:), nz+ 1, MPI_INTEGER, 0, comm2d, &476 CALL MPI_BCAST( mask_k_global(mid,:), nz+2, MPI_INTEGER, 0, comm2d, & 476 477 ierr ) 477 478 … … 537 538 IF ( dim == 1 .OR. dim == 2 ) THEN 538 539 m = NINT( mask(mid,dim,count) * mask_scale(dim) * ddxyz - 0.5_wp ) 540 IF ( m < 0 ) m = 0 ! avoid negative values 539 541 ELSEIF ( dim == 3 ) THEN 540 542 ind_array = & … … 542 544 m = ind_array(1) - 1 + nzb ! MINLOC uses lower array bound 1 543 545 ENDIF 544 IF ( m > nxyz) THEN546 IF ( m > (nxyz+1) ) THEN 545 547 WRITE ( message_string, '(I3,A,I3,A,I1,3A,I3)' ) & 546 548 m,' in mask ',mid,' along dimension ',dim, & 547 ' exceeds ',nxyz_string,' = ',nxyz549 ' exceeds (',nxyz_string,'+1) = ',nxyz+1 548 550 CALL message( 'init_masks', 'PA0331', 1, 2, 0, 6, 0 ) 549 551 ENDIF 550 IF ( m >= lb .AND. m <= ub ) THEN 552 IF ( ( m >= lb .AND. m <= ub ) .OR. & 553 ( m == (nxyz+1) .AND. ub == nxyz ) ) THEN 551 554 IF ( count_l == 0 ) mask_start_l(mid,dim) = count 552 555 count_l = count_l + 1 … … 575 578 IF ( mask_loop(mid,dim,2) < 0.0_wp ) THEN 576 579 tmp2 = mask_loop(mid,dim,2) 577 mask_loop(mid,dim,2) = nxyz*dxyz / mask_scale(dim) ! (default)580 mask_loop(mid,dim,2) = (nxyz+1)*dxyz / mask_scale(dim) ! (default) 578 581 ENDIF 579 582 IF ( MAXVAL( mask_loop(mid,dim,1:2) ) & 580 > nxyz* dxyz / mask_scale(dim) ) THEN583 > (nxyz+1) * dxyz / mask_scale(dim) ) THEN 581 584 WRITE ( message_string, '(2(A,I3,A,I1,A,F9.3),5A,I1,A,F9.3)' ) & 582 585 'mask_loop(',mid,',',dim,',1)=',mask_loop(mid,dim,1), & 583 586 ' and/or mask_loop(',mid,',',dim,',2)=', & 584 mask_loop(mid,dim,2),'&exceed ', &585 nxyz_string,' *',dxyz_string,'/mask_scale(',dim,')=', &586 nxyz*dxyz/mask_scale(dim)587 mask_loop(mid,dim,2),'&exceed (', & 588 nxyz_string,'+1)*',dxyz_string,'/mask_scale(',dim,')=', & 589 (nxyz+1)*dxyz/mask_scale(dim) 587 590 CALL message( 'init_masks', 'PA0332', 1, 2, 0, 6, 0 ) 588 591 ENDIF … … 593 596 loop_stride = NINT( mask_loop(mid,dim,3) * mask_scale(dim) & 594 597 * ddxyz ) 598 IF ( loop_begin == -1 ) loop_begin = 0 ! avoid negative values 595 599 ELSEIF ( dim == 3 ) THEN 596 600 IF ( mask_loop(mid,dim,2) < 0.0_wp ) THEN 597 601 tmp2 = mask_loop(mid,dim,2) 598 mask_loop(mid,dim,2) = zu(nz ) / mask_scale(dim) ! (default)602 mask_loop(mid,dim,2) = zu(nz+1) / mask_scale(dim) ! (default) 599 603 ENDIF 600 604 IF ( MAXVAL( mask_loop(mid,dim,1:2) ) & 601 > zu(nz ) / mask_scale(dim) ) THEN605 > zu(nz+1) / mask_scale(dim) ) THEN 602 606 WRITE ( message_string, '(2(A,I3,A,I1,A,F9.3),A,I1,A,F9.3)' ) & 603 607 'mask_loop(',mid,',',dim,',1)=',mask_loop(mid,dim,1), & 604 608 ' and/or mask_loop(',mid,',',dim,',2)=', & 605 mask_loop(mid,dim,2),'&exceed zu(nz )/mask_scale(',dim, &606 ')=',zu(nz )/mask_scale(dim)609 mask_loop(mid,dim,2),'&exceed zu(nz+1)/mask_scale(',dim, & 610 ')=',zu(nz+1)/mask_scale(dim) 607 611 CALL message( 'init_masks', 'PA0333', 1, 2, 0, 6, 0 ) 608 612 ENDIF … … 648 652 DO m = loop_begin, loop_end, loop_stride 649 653 count = count + 1 650 IF ( m >= lb .AND. m <= ub ) THEN 654 IF ( ( m >= lb .AND. m <= ub ) .OR. & 655 ( m == (nxyz+1) .AND. ub == nxyz ) ) THEN 651 656 IF ( count_l == 0 ) mask_start_l(mid,dim) = count 652 657 count_l = count_l + 1 … … 662 667 mask_size(mid,dim) = count 663 668 mask_size_l(mid,dim) = count_l 669 664 670 ENDIF 665 671
Note: See TracChangeset
for help on using the changeset viewer.