PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
tools.F90
Go to the documentation of this file.
1!MNH_LIC Copyright 2019-2025 CNRS, Meteo-France and Universite Paul Sabatier
2!MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence
3!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4!MNH_LIC for details. version 1.
5!-----------------------------------------------------------------
6!################
8!################
9!
10! Purpose
11! -------
12!
13! The Purpose of this module is to provide useful tools for MesoNH
14!
15! Author
16! ------
17! P. Wautelet 14/02/2019
18!
19! Modifications:
20! P. Wautelet 28/05/2019: move COUNTJV function to tools.f90
21! P. Wautelet 05/06/2019: add Countjv_device
22! P. Wautelet 20/06/2019: add Countjv1d, Countjv1d_device and Countjv2d_device subroutines
23! P. Wautelet 17/01/2020: move Quicksort to tools.f90
24! J. Escobar 25/08/2021: nvhpc21.X bug on 'atomic' in host -> switch to version without atomic on HOST
25
26implicit none
27
28private
29
30public :: countjv
31interface countjv
32 function countjv1d(ltab,i1) result(ic)
33 implicit none
34 logical, dimension(:), intent(in) :: ltab ! Mask
35 integer, dimension(:), intent(out) :: i1 ! Positions of elements with 'true' value
36 integer :: ic ! Total number of 'true' values
37 end function countjv1d
38 function countjv2d(ltab,i1,i2) result(ic)
39 implicit none
40 logical, dimension(:,:), intent(in) :: ltab ! Mask
41 integer, dimension(:), intent(out) :: i1, i2 ! Positions of elements with 'true' value
42 integer :: ic ! Total number of 'true' values
43 end function countjv2d
44 function countjv3d(ltab,i1,i2,i3) result(ic)
45 implicit none
46 logical, dimension(:,:,:), intent(in) :: ltab ! Mask
47 integer, dimension(:), intent(out) :: i1, i2, i3 ! Positions of elements with 'true' value
48 integer :: ic ! Total number of 'true' values
49 end function countjv3d
50end interface countjv
51
52end module mode_tools
53
54function countjv1d(ltab,i1) result(ic)
55 implicit none
56 logical, dimension(:), intent(in) :: ltab ! Mask
57 integer, dimension(:), intent(out) :: i1 ! Positions of elements with 'true' value
58 integer :: ic ! Total number of 'true' values
59
60 integer :: ji
61
62 ic = 0
63
64 do ji = 1, size( ltab, 1 )
65 if ( ltab(ji ) ) then
66 ic = ic +1
67 i1(ic) = ji
68 end if
69 end do
70end function countjv1d
71
72function countjv2d(ltab,i1,i2) result(ic)
73 implicit none
74 logical, dimension(:,:), intent(in) :: ltab ! Mask
75 integer, dimension(:), intent(out) :: i1, i2 ! Positions of elements with 'true' value
76 integer :: ic ! Total number of 'true' values
77
78 integer :: ji, jj
79
80 ic = 0
81
82 do jj = 1, size( ltab, 2 )
83 do ji = 1, size( ltab, 1 )
84 if ( ltab(ji, jj ) ) then
85 ic = ic +1
86 i1(ic) = ji
87 i2(ic) = jj
88 end if
89 end do
90 end do
91end function countjv2d
92
93function countjv3d(ltab,i1,i2,i3) result(ic)
94 implicit none
95 logical, dimension(:,:,:), intent(in) :: ltab ! Mask
96 integer, dimension(:), intent(out) :: i1, i2, i3 ! Positions of elements with 'true' value
97 integer :: ic ! Total number of 'true' values
98
99 integer :: ji, jj, jk
100
101 ic = 0
102
103 do jk = 1, size( ltab, 3 )
104 do jj = 1, size( ltab, 2 )
105 do ji = 1, size( ltab, 1 )
106 if ( ltab(ji, jj, jk ) ) then
107 ic = ic +1
108 i1(ic) = ji
109 i2(ic) = jj
110 i3(ic) = jk
111 end if
112 end do
113 end do
114 end do
115end function countjv3d
integer function countjv2d(ltab, i1, i2)
Definition tools.F90:73
integer function countjv3d(ltab, i1, i2, i3)
Definition tools.F90:94