Changeset 2354 in lmdz_wrf
- Timestamp:
- Feb 19, 2019, 10:07:39 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_scientific.f90
r2353 r2354 44 44 ! multi_index_mat3DRK: Subroutine to provide the indices of the different locations of a value inside a 3D RK matrix 45 45 ! multi_index_mat4DRK: Subroutine to provide the indices of the different locations of a value inside a 4D RK matrix 46 ! multi_spaceweightcount_in3DRK3_slc3v3: Subroutine to compute an spatial percentage of coverture of 47 ! categories from a 3D RK matrix using 3rd dimension as running one into a matrix of 3-variables 48 ! slices of rank 3 using spatial weights 46 49 ! multi_spaceweightstats_in1DRKno_slc3v3: Subroutine to compute an spatial statistics value from a 1D RK matrix without 47 50 ! running one into a matrix of 3-variables slices of rank 3 using spatial weights … … 84 87 ! SortR_K*: Subroutine receives an array x() r_K and sorts it into ascending order. 85 88 ! spacepercen: Subroutine to compute the space-percentages of a series of grid cells (B) into another series of grid-cells (A) 89 ! spaceweight_Icount: Subroutine to compute the percentage of a series of categories using weights 86 90 ! spaceweightstats: Subroutine to compute an spatial statistics value from a matrix B into a matrix A using weights 87 91 ! StatsR_K: Subroutine to provide the minmum, maximum, mean, the quadratic mean, and the standard deviation of a … … 5671 5675 ! percentages: weights as percentages of space of grid in matrix A covered by grid of matrix B 5672 5676 ! stats: name of the spatial statistics to compute inside each grid of matrix A using values from 5673 ! matrix B. Avai albe ones:5677 ! matrix B. Available ones: 5674 5678 ! 'min': minimum value 5675 5679 ! 'max': maximum value … … 5780 5784 END SUBROUTINE spaceweightstats 5781 5785 5786 SUBROUTINE spaceweight_Icount(Ncat, cats, varin, Ngridsin, percentages, varout) 5787 ! Subroutine to compute the percentage of a series of categories using weights 5788 5789 IMPLICIT NONE 5790 5791 INTEGER, INTENT(in) :: Ncat, Ngridsin 5792 INTEGER, DIMENSION(Ncat), INTENT(in) :: cats 5793 INTEGER, DIMENSION(Ngridsin), INTENT(in) :: varin 5794 REAL(r_k), DIMENSION(Ngridsin), INTENT(in) :: percentages 5795 REAL(r_k), DIMENSION(Ncat), INTENT(out) :: varout 5796 5797 ! Local 5798 INTEGER :: iv, ic 5799 5800 !!!!!!! Variables 5801 ! Ncat: number of categories 5802 ! cats: categories to use 5803 ! varin: variable with the integer values 5804 ! Ngridsin: number of grids 5805 ! percentages: weights as percentages of the grids to use 5806 ! varout: output statistical variable 5807 5808 fname = 'spaceweight_Icount' 5809 5810 varout = zeroRK 5811 DO iv=1, Ngridsin 5812 DO ic=1, Ncat 5813 IF (varin(iv) == cats(ic)) THEN 5814 varout(ic) = varout(ic) + percentages(iv) 5815 END IF 5816 END DO 5817 END DO 5818 5819 END SUBROUTINE spaceweight_Icount 5820 5782 5821 SUBROUTINE multi_spaceweightstats_in1DRKno_slc3v3(varin, idv, Ngridsin, gridsin, percentages, & 5783 5822 varout, di1, ds1, ds2, ds3, maxNgridsin) … … 5831 5870 5832 5871 fname = 'multi_spaceweightstats_in1DRKno_slc3v3' 5833 5834 varout = fillval645835 5872 5836 5873 ss1 = 8 + 1 … … 5979 6016 fname = 'multi_spaceweightstats_in2DRKno_slc3v3' 5980 6017 5981 varout = fillval645982 5983 6018 ss1 = 8 + 1 5984 6019 ss2 = 5 + 1 … … 6115 6150 6116 6151 fname = 'multi_spaceweightstats_in3DRK3_slc3v3' 6117 6118 varout = fillval646119 6152 6120 6153 ss1 = 8 + 1 … … 6255 6288 6256 6289 fname = 'multi_spaceweightstats_in4DRK3_4_slc3v3' 6257 6258 varout = fillval646259 6290 6260 6291 ! Let's be efficient? … … 6392 6423 fname = 'multi_spaceweightstats_in3DRK3_slc3v4' 6393 6424 6394 varout = fillval646395 6396 6425 ! Let's be efficient? 6397 6426 varout = fillVal64 … … 7018 7047 END SUBROUTINE coincident_gridsin2D 7019 7048 7049 SUBROUTINE multi_spaceweightcount_in3DRK3_slc3v3(varin, Ngridsin, gridsin, percentages, Ncat, & 7050 categories, varout, di1, di2, di3, ds1, ds2, ds3, maxNgridsin) 7051 ! Subroutine to compute an spatial percentage of coverture of categories from a 3D RK matrix using 7052 ! 3rd dimension as running one into a matrix of 3-variables slices of rank 3 using spatial weights 7053 7054 IMPLICIT NONE 7055 7056 INTEGER, INTENT(in) :: di1, di2, di3, ds1, ds2, ds3 7057 INTEGER, INTENT(in) :: Ncat, maxNgridsin 7058 INTEGER, DIMENSION(ds1,ds2,ds3), INTENT(in) :: Ngridsin 7059 INTEGER, DIMENSION(ds1,ds2,ds3,maxNgridsin,2), & 7060 INTENT(in) :: gridsin 7061 INTEGER, DIMENSION(di1,di2,di3), INTENT(in) :: varin 7062 REAL(r_k), INTENT(in), & 7063 DIMENSION(ds1,ds2,ds3,maxNgridsin) :: percentages 7064 INTEGER, DIMENSION(Ncat), INTENT(in) :: categories 7065 REAL(r_k), DIMENSION(ds1,ds2,ds3,di3,Ncat), & 7066 INTENT(out) :: varout 7067 7068 ! Local 7069 INTEGER :: i1, i2, i3, s1, s2, s3, iv 7070 INTEGER :: ii3, ss1, ss2, ss3, Nin 7071 REAL(r_k), DIMENSION(:), ALLOCATABLE :: pin 7072 INTEGER, DIMENSION(:,:), ALLOCATABLE :: gin 7073 REAL(r_k), DIMENSION(:), ALLOCATABLE :: svin 7074 INTEGER, DIMENSION(:,:), ALLOCATABLE :: vin 7075 7076 !!!!!!! Variables 7077 ! di1, di2, di3: length of dimensions of the 3D matrix of values 7078 ! ds[1-3]: length of dimensions of matrix with the slices 7079 ! maxNgridsin: maximum number of grid points from the 3D matrix in any slice 7080 ! varin: 3D RK variable to be used 7081 ! Ngridsin: number of grids from 3D RK matrix for each slice 7082 ! gridsin: coordinates of grids of the 3D RK matrix B to matrix of slices 7083 ! percentages: weights as percentages of space of 3D RK matrix for each slice 7084 ! Ncat: number of categories 7085 ! categories: category values to classify with 7086 ! varout: percentage of each category at each point along d3 7087 7088 fname = 'multi_spaceweightcount_in3DRK3_slc3v3' 7089 7090 ! Let's be efficient? 7091 varout = fillVal64 7092 DO s1 =1, ds1 7093 DO s2 =1, ds2 7094 DO s3 =1, ds3 7095 Nin = Ngridsin(s1,s2,s3) 7096 ! Computing along d3 7097 IF (Nin >= 1) THEN 7098 IF (ALLOCATED(gin)) DEALLOCATE(gin) 7099 ALLOCATE(gin(Nin,2)) 7100 IF (ALLOCATED(pin)) DEALLOCATE(pin) 7101 ALLOCATE(pin(Nin)) 7102 IF (ALLOCATED(vin)) DEALLOCATE(vin) 7103 ALLOCATE(vin(Nin,di3)) 7104 IF (ALLOCATED(svin)) DEALLOCATE(svin) 7105 ALLOCATE(svin(Nin)) 7106 gin = gridsin(s1,s2,s3,1:Nin,:) 7107 pin = percentages(s1,s2,s3,1:Nin) 7108 7109 ! Getting the values 7110 DO iv=1, Nin 7111 i1 = gin(iv,1) 7112 i2 = gin(iv,2) 7113 vin(iv,:) = varin(i1,i2,:) 7114 END DO 7115 DO i3=1, di3 7116 CALL spaceweight_Icount(Ncat, categories, vin(:,i3), Nin, pin, varout(s1,s2,s3,i3,:)) 7117 END DO 7118 ELSE 7119 varout(s1,s2,s3,:,1) = fillval64 7120 END IF 7121 END DO 7122 END DO 7123 END DO 7124 7125 IF (ALLOCATED(gin)) DEALLOCATE(gin) 7126 IF (ALLOCATED(pin)) DEALLOCATE(pin) 7127 IF (ALLOCATED(vin)) DEALLOCATE(vin) 7128 IF (ALLOCATED(svin)) DEALLOCATE(svin) 7129 7130 RETURN 7131 7132 END SUBROUTINE multi_spaceweightcount_in3DRK3_slc3v3 7133 7020 7134 END MODULE module_scientific
Note: See TracChangeset
for help on using the changeset viewer.