Changeset 2297 in lmdz_wrf for trunk/tools/module_scientific.f90
- Timestamp:
- Jan 29, 2019, 5:29:33 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_scientific.f90
r2295 r2297 5634 5634 END SUBROUTINE spaceweightstats 5635 5635 5636 SUBROUTINE multi_spacewightstats_in3DRK3_slc3v(varin, rundim, Ngridsin, gridsin, percentages, & 5637 varout, di1, di2, di3, ds1, ds2, ds3, ds4, ds5, ds6, maxNgridsin, Lstats) 5638 ! Subroutine to compute an spatial statistics value from a 3D RK matrix using 3rd dimension as 5639 ! running one into a matrix of slices using spatial weights 5640 5641 IMPLICIT NONE 5642 5643 INTEGER, INTENT(in) :: di1, di2, di3, ds1, ds2, ds3, ds4, ds5, ds6 5644 INTEGER, INTENT(in) :: rundim, maxNgridsin 5645 CHARACTER(len=*), INTENT(in) :: stats 5646 INTEGER, DIMENSION(ds1,ds2,ds3,ds4,ds5,ds6), & 5647 INTENT(in) :: Ngridsin 5648 INTEGER, INTENT(in) & 5649 DIMENSION(ds1,ds2,ds3,ds4,ds5,ds6,maxNgridsin,2) :: gridsin 5650 REAL(r_k), DIMENSION(di1,di2,di3), INTENT(in) :: varin 5651 REAL(r_k), INTENT(in) & 5652 DIMENSION(ds1,ds2,ds3,ds4,ds5,ds6,maxNgridsin) :: percentages 5653 REAL(r_k), DIMENSION(ds1,ds2,ds3,ds4,ds5,ds6,di3,7), & 5654 INTENT(out) :: varout 5655 5656 ! Local 5657 INTEGER :: i1, i2, i3, s1, s2, s3, s4, s5, s6 5658 INTEGER :: Ncounts, Nin 5659 CHARACTER(len=3) :: val1S, val2S 5660 CHARACTER(len=30) :: val3S 5661 REAL(r_k) :: val1, val2 5662 REAL(r_k), DIMENSION(Lstats) :: icounts 5663 INTEGER, DIMENSION(:), ALLOCATABLE :: pin 5664 INTEGER, DIMENSION(:,:), ALLOCATABLE :: gin 5665 5666 !!!!!!! Variables 5667 ! di1, di2, di3: length of dimensions of the 3D matrix of values 5668 ! ds[1-6]: length of dimensions of matrix with the slices 5669 ! maxNgridsin: maximum number of grid points from the 3D matrix in any slice 5670 ! varin: 3D RK variable to be used 5671 ! Ngridsin: number of grids from 3D RK matrix for each slice 5672 ! gridsin: coordinates of grids of the 3D RK matrix B to matrix of slices 5673 ! percentages: weights as percentages of space of 3D RK matrix for each slice 5674 ! stats: name of the spatial statistics to compute inside each slice using values from 3D RK matrix 5675 ! Avaialbe ones: 5676 ! 'min': minimum value 5677 ! 'max': maximum value 5678 ! 'mean': space weighted mean value 5679 ! 'mean2': space weighted quadratic mean value 5680 ! 'stddev': space weighted standard deviation value 5681 ! 'median': median value 5682 ! 'count': percentage of the space of matrix A covered by each different value of matrix B 5683 ! varout: output statistical variable 5684 5685 fname = 'multi_spacewightstats_in3DRK3_slc3v' 5686 5687 ! Let's be efficient? 5688 varout = fillVal64 5689 DO s1 =1, ds1 5690 DO s2 =1, ds2 5691 DO s3 =1, ds3 5692 DO s4 =1, ds4 5693 DO s5 =1, ds5 5694 DO s5 =1, ds6 5695 Nin = Ngridsin(s1,s2,s3,s4,s5,s6) 5696 IF (ALLOCATED(gin)) DEALLOCATE(gin) 5697 ALLOCATE(gin(Nin,2)) 5698 IF (ALLOCATED(pin)) DEALLOCATE(pin) 5699 ALLOCATE(pin(Nin)) 5700 gin = gridsin(s1,s2,s3,s4,s5,s6,1:Nin,:) 5701 pin = percentages(s1,s2,s3,s4,s5,s6,1:Nin) 5702 5703 DO i1=1, di1 5704 DO i2=1, di2 5705 5706 DO iv=1, Ngridsin(ix,iy) 5707 ii = gridsin(ix,iy,iv,1) 5708 jj = gridsin(ix,iy,iv,2) 5709 IF (varin(ii,jj) < varout(ix,iy,Lstats)) varout(ix,iy,1) = varin(ii,jj) 5710 END DO 5711 END DO 5712 END DO 5713 5714 CASE DEFAULT 5715 msg = "statisitcs '" // TRIM(stats) // "' not ready !!" // CHAR(44) // " available ones: " // & 5716 "'min', 'max', 'mean', 'mean2', 'stddev', 'count'" 5717 CALL ErrMsg(msg, fname, -1) 5718 END SELECT statn 5719 5720 5721 END SUBROUTINE multi_spacewightstats_in3DRK3_slc3v 5722 5636 5723 SUBROUTINE multi_index_mat2DI(d1, d2, d12, mat, value, Nindices, indices) 5637 5724 ! Subroutine to provide the indices of the different locations of a value inside a 2D integer matrix
Note: See TracChangeset
for help on using the changeset viewer.