count_cell Subroutine

public subroutine count_cell(msk, long, larg, nbr_cell, med_cell)

Calculate the number of cells in a mask, as well as the cell median size

Arguments

Type IntentOptional Attributes Name
integer(kind=I4), intent(inout), dimension(1:long, 1:larg) :: msk

mask

integer(kind=I4), intent(in) :: long

2D array length

integer(kind=I4), intent(in) :: larg

2D array height

integer(kind=I4), intent(out) :: nbr_cell

number of cells

real(kind=R8), intent(out), optional :: med_cell

median size of the cells


Calls

proc~~count_cell~~CallsGraph proc~count_cell count_cell proc~calc_median calc_median proc~count_cell->proc~calc_median proc~flood flood proc~count_cell->proc~flood sort_array2 sort_array2 proc~calc_median->sort_array2

Called by

proc~~count_cell~~CalledByGraph proc~count_cell count_cell proc~topology topology proc~topology->proc~count_cell program~test_morpho test_morpho program~test_morpho->proc~count_cell

Source Code

   subroutine count_cell(msk, long, larg, nbr_cell, med_cell)
   !================================================================================================
   !! Calculate the number of cells in a mask, as well as the cell median size
   !------------------------------------------------------------------------------------------------
   implicit none
   integer(kind=I4), intent(in   )                            :: long         !! *2D array length*
   integer(kind=I4), intent(in   )                            :: larg         !! *2D array height*
   integer(kind=I4), intent(out  )                            :: nbr_cell     !! *number of cells*
   real   (kind=R8), intent(out  ), optional                  :: med_cell     !! *median size of the cells*
   integer(kind=I4), intent(inout), dimension(1:long, 1:larg) :: msk          !! *mask*

      integer(kind=I4) :: i, j, k, nb

      real(kind=R8), dimension(1:long*larg) :: cell

      cell(1:long*larg) = 0

      k = 1
      do

         call flood( masque = msk(1:long, 1:larg),       &  ! INOUT
                     taille = nb,                        &  ! OUT
                     nx     = long,                      &  ! IN
                     ny     = larg,                      &  ! IN
                     niv    = k + 1)                        ! IN

         if ( nb == 0 ) exit

         cell(k) = nb

         k = k + 1

      enddo

      nbr_cell = k - 1
      med_cell = 0._R8

      if (.not.present(med_cell)) return

      if (k > 0) then

         call calc_median(  tab = cell(1:nbr_cell),   &  ! IN
                             md = med_cell )             ! OUT

         med_cell = 100*med_cell/(long*larg)

      else

         med_cell = 0

      endif

   return
   endsubroutine count_cell