Foortran Toolkit

Fortran toolkit
Borja Petit


Download toolkit

Back to index

multiplo

function multiplo(num,xx) result(mul)
  implicit none
  integer :: num,xx
  logical :: mul

This function checks whether an integer num is a multiple of xx. The result mul is a logical variable taking value .TRUE. if num is a multiple of xx, and .FALSE. otherwise. If xx = 0, the function prints an error message and returns .FALSE..

Internal dependencies: error


Example

We have an iterative code and we want to print a message every 50 iterations

do i = 1,1000
  ! ... some code ...
  if (multiplo(i,50)) print * , 'Iterations = ', i
end do