Parallel operations
This is an example of cs_user_extra_operations which performs parallel operations.
Local variables to be added
integer          iel    , ifac
integer          ii     , nbr    , irangv
integer          itab(3)
double precision rrr
double precision xyz(3)
Example 1
Sum of an integer counter 'ii', here the number of cells.
endif
 5020 format(' cs_user_extra_operations: total number of cells = ', i10)
  
Example 2
Maximum of an integer counter 'ii', here the number of cells.
endif
 5010 format(' cs_user_extra_operations: max. number of cells per process = ', i10)
  
Example 3
Sum of a real 'rrr', here the volume.
rrr = 0.d0
enddo
endif
 5030 format(' cs_user_extra_operations: total domain volume = ', e14.5)
  
Example 4
Minimum of a real 'rrr', here the volume.
rrr = 0.d0
enddo
endif
 5040 format(' cs_user_extra_operations: max volume per process = ', e14.5)
  
Example 5
Minimum of a real 'rrr', here the volume.
enddo
endif
 5050 format(' cs_user_extra_operations: min volume per process = ', e14.5)
  
Example 6
Maximum of a real and associated real values; here the volume and its location (3 coordinates).
nbr = 3
rrr  = -1.d0
xyz(1) = 0.d0
xyz(2) = 0.d0
xyz(3) = 0.d0
  endif
enddo
endif
write(
nfecra,5060) rrr, xyz(1), xyz(2), xyz(3)
 
 5060 format(' Cs_user_extra_operations: Max. volume =      ', e14.5, /,  &
             '         Location (x,y,z) = ', 3e14.5)
Example 7
Minimum of a real and associated real values; here the volume and its location (3 coordinates).
nbr = 3
rrr  = 1.d+30
xyz(1) = 0.d0
xyz(2) = 0.d0
xyz(3) = 0.d0
  endif
enddo
endif
write(
nfecra,5070) rrr, xyz(1), xyz(2), xyz(3)
 
 5070 format(' Cs_user_extra_operations: Min. volume =      ', e14.5, /,  &
             '         Location (x,y,z) = ', 3e14.5)
Example 8
Sum of an array of integers; here, the number of cells, faces, and boundary faces.
local values; note that to avoid counting interior faces on parallel boundaries twice, we check if 'ifacel(1,ifac) .le. ncel', as on a parallel boundary, this is always true for one domain and false for the other.
nbr = 3
itab(2) = 0
  if (
ifacel(1, ifac).le.
ncel) itab(2) = itab(2) + 1
 
enddo
endif
write(
nfecra,5080) itab(1), itab(2), itab(3)
 
 5080 format(' cs_user_extra_operations: Number of cells =          ', i10, /,  &
             '         Number of interior faces = ', i10, /,  &
             '         Number of boundary faces = ', i10)
Example 9
Maxima from an array of integers; here, the number of cells, faces, and boundary faces.
nbr = 3
endif
write(
nfecra,5090) itab(1), itab(2), itab(3)
 
 5090 format(' cs_user_extra_operations: Max. number of cells per proc. =          ', i10, /,  &
             '         Max. number of interior faces per proc. = ', i10, /,  &
             '         Max. number of boundary faces per proc. = ', i10)
  
Example 10
Minima from an array of integers; here, the number of cells, faces, and boundary faces.
nbr = 3
endif
write(
nfecra,5100) itab(1), itab(2), itab(3)
 
 5100 format(' cs_user_extra_operations: Min. number of cells per proc. =          ', i10, /,  &
             '         Min. number of interior faces per proc. = ', i10, /,  &
             '         Min. number of boundary faces per proc. = ', i10)
  
Example 11
Sum of an array of reals; here, the 3 velocity components (so as to compute a mean for example).
nbr = 3
xyz(1) = 0.d0
xyz(2) = 0.d0
xyz(3) = 0.d0
  xyz(1) = xyz(1)+rtp(iel,
iu)
  xyz(2) = xyz(2)+rtp(iel,
iv)
  xyz(3) = xyz(3)+rtp(iel,
iw)
enddo
endif
write(
nfecra,5110) xyz(1), xyz(2), xyz(3)
 
 5110 format(' cs_user_extra_operations: Sum of U on the domain = ', e14.5, /,   &
             '         Sum of V on the domain = ', e14.5, /,   &
             '         Sum of V on the domain = ', e14.5)
Example 12
Maximum of an array of reals; here, the 3 velocity components.
nbr = 3
  xyz(1) = max(xyz(1),rtp(iel,
iu))
  xyz(2) = max(xyz(2),rtp(iel,
iv))
  xyz(3) = max(xyz(3),rtp(iel,
iw))
enddo
endif
write(
nfecra,5120) xyz(1), xyz(2), xyz(3)
 
 5120 format(' cs_user_extra_operations: Maximum of U on the domain = ', e14.5, /,   &
             '         Maximum of V on the domain = ', e14.5, /,   &
             '         Maximum of V on the domain = ', e14.5)
Example 13
Maximum of an array of reals; here, the 3 velocity components.
nbr = 3
  xyz(1) = min(xyz(1),rtp(iel,
iu))
  xyz(2) = min(xyz(2),rtp(iel,
iv))
  xyz(3) = min(xyz(3),rtp(iel,
iw))
enddo
endif
write(
nfecra,5130) xyz(1), xyz(2), xyz(3)
 
 5130 format(' cs_user_extra_operations: Minimum of U on the domain = ', e14.5, /,   &
             '         Minimum of V on the domain = ', e14.5, /,   &
             '         Minimum of V on the domain = ', e14.5)
  
Example 14
Broadcast an array of local integers to other ranks; in this example, we use the number of cells, interior faces, and boundary faces from process rank 0 (irangv).
irangv = 0
nbr = 3
  call 
parbci(irangv, nbr, itab)
endif
write(
nfecra,5140) irangv, itab(1), itab(2), itab(3)
 
 5140 format(' cs_user_extra_operations: On rank ', i10 , /,                     &
             '         Number of cells          = ', i10, /,   &
             '         Number of interior faces = ', i10, /,   &
             '         Number of boundary faces = ', i10)
  
Example 15
Broadcast an array of local reals to other ranks; in this example, we use 3 velocity values from process rank 0 (irangv).
irangv = 0
nbr = 3
endif
write(
nfecra,5150) irangv, xyz(1), xyz(2), xyz(3)
 
 5150 format(' cs_user_extra_operations: On rank ', i10 , /,                       &
             '         Velocity U in first cell = ', e14.5, /,   &
             '         Velocity V in first cell = ', e14.5, /,   &
             '         Velocity W in first cell = ', e14.5)