program calculatepay

!-- the variable NumberCalcsDone has global scope

  implicit none
  real :: pay, tax, delta
  integer :: NumberCalcsDone = 0
  
  pay = 7.25; tax = 0.08; delta = 0.1

  call printpay(pay, tax)
  tax = newtax(tax, delta)
  write(*,*) 'NumberCalcsDone = ',NumberCalcsDone
  
  contains

!-----------------------------------------------------------

  subroutine printpay(pay, tax)
  
  real, intent(in) :: pay, tax
  real :: taxpaid
  
  taxpaid = pay * tax
  print *, 'tax paid = ',tax
  NumberCalcsDone = NumberCalcsDone + 1
  
  end subroutine printpay

!-----------------------------------------------------------
  
  real function newtax(tax, delta) 
  
  real, intent(in) :: tax, delta
  
  newtax = tax + delta*tax
  NumberCalcsDone = NumberCalcsDone + 1
  
  end function newtax
    
end program calculatepay