Changeset 2282 in lmdz_wrf
- Timestamp:
- Jan 23, 2019, 9:03:51 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_scientific.f90
r2274 r2282 28 28 ! look_clockwise_borders: Subroutine to look clock-wise for a next point within a collection of borders 29 29 ! (limits of a region) 30 ! multi_index_mat2DRK: Subroutine to provide the indices of the different locations of a value inside a 2D RK matrix 31 ! multi_index_mat3DRK: Subroutine to provide the indices of the different locations of a value inside a 3D RK matrix 32 ! multi_index_mat4DRK: Subroutine to provide the indices of the different locations of a value inside a 4D RK matrix 30 33 ! NcountR: Subroutine to count real values 31 34 ! paths_border: Subroutine to search the paths of a border field. … … 5208 5211 END SUBROUTINE spaceweightstats 5209 5212 5213 5214 SUBROUTINE multi_index_mat2DRK(d1, d2, d12, mat, value, Nindices, indices) 5215 ! Subroutine to provide the indices of the different locations of a value inside a 2D RK matrix 5216 5217 IMPLICIT NONE 5218 5219 INTEGER, INTENT(in) :: d1, d2, d12 5220 REAL(r_k), DIMENSION(d1,d2), INTENT(in) :: mat 5221 REAL(r_k),INTENT(in) :: value 5222 INTEGER, INTENT(out) :: Nindices 5223 INTEGER, DIMENSION(2,d12), INTENT(out) :: indices 5224 5225 ! Local 5226 INTEGER :: i,j 5227 INTEGER :: Ncounts1D, icount1D 5228 REAL(r_k), DIMENSION(d2) :: diffmat1D 5229 5230 !!!!!!! Variables 5231 ! d1, d2: shape of the 2D matrix 5232 ! mat: 2D matrix 5233 ! value: value to be looking for 5234 ! Nindices: number of times value found within matrix 5235 ! indices: indices of the found values 5236 5237 fname = 'multi_index_mat2DRK' 5238 5239 Nindices = 0 5240 indices = 0 5241 DO i=1, d1 5242 diffmat1D = mat(i,:) - value 5243 IF (ANY(diffmat1D == zeroRK)) THEN 5244 Ncounts1D = COUNT(diffmat1D == zeroRK) 5245 icount1D = 0 5246 DO j=1, d2 5247 IF (diffmat1D(j) == zeroRK) THEN 5248 Nindices = Nindices + 1 5249 indices(1,Nindices) = i 5250 indices(2,Nindices) = j 5251 icount1D = icount1D + 1 5252 IF (icount1D == Ncounts1D) EXIT 5253 END IF 5254 END DO 5255 END IF 5256 END DO 5257 5258 END SUBROUTINE multi_index_mat2DRK 5259 5260 SUBROUTINE multi_index_mat3DRK(d1, d2, d3, d123, mat, value, Nindices, indices) 5261 ! Subroutine to provide the indices of the different locations of a value inside a 3D RK matrix 5262 5263 IMPLICIT NONE 5264 5265 INTEGER, INTENT(in) :: d1, d2, d3, d123 5266 REAL(r_k), DIMENSION(d1,d2,d3), INTENT(in) :: mat 5267 REAL(r_k),INTENT(in) :: value 5268 INTEGER, INTENT(out) :: Nindices 5269 INTEGER, DIMENSION(3,d123), INTENT(out) :: indices 5270 5271 ! Local 5272 INTEGER :: i,j,k 5273 INTEGER :: Ncounts1D, icount1D 5274 INTEGER :: Ncounts2D, icount2D 5275 REAL(r_k), DIMENSION(d2,d3) :: diffmat2D 5276 REAL(r_k), DIMENSION(d3) :: diffmat1D 5277 5278 !!!!!!! Variables 5279 ! d1, d2, d3: shape of the 3D matrix 5280 ! mat: 3D matrix 5281 ! value: value to be looking for 5282 ! Nindices: number of times value found within matrix 5283 ! indices: indices of the found values 5284 5285 fname = 'multi_index_mat3DRK' 5286 5287 Nindices = 0 5288 indices = 0 5289 DO i=1, d1 5290 diffmat2D = mat(i,:,:) - value 5291 IF (ANY(diffmat2D == zeroRK)) THEN 5292 Ncounts2D = COUNT(diffmat2D == zeroRK) 5293 icount2D = 0 5294 DO j=1, d2 5295 diffmat1D = mat(i,j,:) - value 5296 IF (ANY(diffmat1D == zeroRK)) THEN 5297 Ncounts1D = COUNT(diffmat1D == zeroRK) 5298 icount1D = 0 5299 DO k=1, d3 5300 IF (diffmat1D(k) == zeroRK) THEN 5301 Nindices = Nindices + 1 5302 indices(1,Nindices) = i 5303 indices(2,Nindices) = j 5304 indices(3,Nindices) = k 5305 icount1D = icount1D + 1 5306 IF (icount1D == Ncounts1D) EXIT 5307 END IF 5308 END DO 5309 icount2D = icount2D + icount1D 5310 IF (icount2D == Ncounts2D) EXIT 5311 END IF 5312 END DO 5313 END IF 5314 END DO 5315 5316 END SUBROUTINE multi_index_mat3DRK 5317 5318 SUBROUTINE multi_index_mat4DRK(d1, d2, d3, d4, d1234, mat, value, Nindices, indices) 5319 ! Subroutine to provide the indices of the different locations of a value inside a 4D RK matrix 5320 5321 IMPLICIT NONE 5322 5323 INTEGER, INTENT(in) :: d1, d2, d3, d4, d1234 5324 REAL(r_k), DIMENSION(d1,d2,d3,d4), INTENT(in) :: mat 5325 REAL(r_k),INTENT(in) :: value 5326 INTEGER, INTENT(out) :: Nindices 5327 INTEGER, DIMENSION(4,d1234), INTENT(out) :: indices 5328 5329 ! Local 5330 INTEGER :: i,j,k,l 5331 INTEGER :: Ncounts1D, icount1D 5332 INTEGER :: Ncounts2D, icount2D 5333 INTEGER :: Ncounts3D, icount3D 5334 REAL(r_k), DIMENSION(d2,d3,d4) :: diffmat3D 5335 REAL(r_k), DIMENSION(d3,d4) :: diffmat2D 5336 REAL(r_k), DIMENSION(d4) :: diffmat1D 5337 5338 !!!!!!! Variables 5339 ! d1, d2, d3, d4: shape of the 4D matrix 5340 ! mat: 4D matrix 5341 ! value: value to be looking for 5342 ! Nindices: number of times value found within matrix 5343 ! indices: indices of the found values 5344 5345 fname = 'multi_index_mat4DRK' 5346 5347 Nindices = 0 5348 indices = 0 5349 DO i=1, d1 5350 diffmat3D = mat(i,:,:,:) - value 5351 IF (ANY(diffmat3D == zeroRK)) THEN 5352 Ncounts3D = COUNT(diffmat3D == zeroRK) 5353 icount3D = 0 5354 DO j=1, d2 5355 diffmat2D = mat(i,j,:,:) - value 5356 IF (ANY(diffmat2D == zeroRK)) THEN 5357 Ncounts2D = COUNT(diffmat2D == zeroRK) 5358 icount2D = 0 5359 DO k=1, d3 5360 diffmat1D = mat(i,j,k,:) - value 5361 IF (ANY(diffmat1D == zeroRK)) THEN 5362 Ncounts1D = COUNT(diffmat1D == zeroRK) 5363 icount1D = 0 5364 DO l=1, d4 5365 IF (diffmat1D(l) == zeroRK) THEN 5366 Nindices = Nindices + 1 5367 indices(1,Nindices) = i 5368 indices(2,Nindices) = j 5369 indices(3,Nindices) = k 5370 indices(4,Nindices) = l 5371 icount1D = icount1D + 1 5372 IF (icount1D == Ncounts1D) EXIT 5373 END IF 5374 END DO 5375 icount2D = icount2D + icount1D 5376 IF (icount2D == Ncounts2D) EXIT 5377 END IF 5378 END DO 5379 icount3D = icount3D + icount1D 5380 IF (icount3D == Ncounts3D) EXIT 5381 END IF 5382 END DO 5383 END IF 5384 END DO 5385 5386 END SUBROUTINE multi_index_mat4DRK 5387 5210 5388 END MODULE module_scientific
Note: See TracChangeset
for help on using the changeset viewer.