!
!  This code integrates the Gompertz differential equation 
!  with a simple Euler scheme
!
!  dN      1
!  -- = - --- N * Log (N/N_inf)
!  dt     tau
!
!  we use non-dimensional variables:
!
!  - x = N/N_inf
!  - t = t/tau 
!============================================================
! Declarations
!
  integer, parameter :: kdp = kind(0.d0)
  real (kind=kdp) dt, T_tot, x, xt, ts, tk, L0
  integer N
!
! Parameters
!
  dt    = 0.001             ! Integrattion step
  dt2   = dt / 2.d0         ! half step
  T_tot = 10.               ! Total integration time (units of tau)
  N     = int ( T_tot/dt )  ! Number of integration steps
  ts    = 0.1               ! Sampling time (units of tau)
  x     = 0.000001          ! Initial value
  L0    = log(x)
  tk    = 0.0               ! Initial value of running sampling time
  
  !=====================================
  do i=1, N
     t = i*dt
     xt = x - x*log(x) * dt
     x = x - (x*log(x) + xt*log(xt))*dt2
     if ( t > tk ) then
         print*, t, x, exp(L0*exp(-t))
         tk = tk + ts
     end if 
  end do
  !=====================================
   
  end program






