Listing 1: Mass-Conservative Adaptive Time Stepping Method c calculate until last time, tl, incrementing # time steps, nt do while (t .lt. tl) nt = nt + 1 if ((t+dt) .gt. tl) dt = tl-t 10 continue t = t + dt rxx = dt/(dx*dx) ! reset finite difference scale factor c store essential time step restart information (press. heads) do i = 1, np-1 hj(i) = h(i) end do do it = 1, maxit+1 ! Newton's iteration loop tin = tin + 1.d0 ! count iterations c set up and calculate time step, size dt c ... c calculate convergence test variable c ... c if test variable meets criterion, jump to 100 if (dabs(rmb) .le. rmbtol) go to 100 end do it = it - 1 100 continue c save current time step size dtl = dt if (it .le. (maxit-2)) then ! if iterations low dt = 1.062d0*dt ! increase time step if (dt .gt. dtt) dt = dtt ! limit time step to dtt else if (it .eq. (maxit-1)) then dt = 1.001d0*dt ! maintain time step if (dt .gt. dtt) dt = dtt else if (it. eq. maxit) then dt = 0.619d0*dt ! reduce time step else if (it .ge. (maxit+1)) then write (*, *) write (*, *) 'restart iteration' write (*, *) c discard time step calculations and start over t = t - dt c with smaller dt dt = 0.619d0*dt do i = 1, np-1 h(i) = hj(i) end do c reset other necessary variables c ... if (dt .le. 1.d-100) then write (*, *) 'endless loop', t write (1, *) 'endless loop', t close (1) stop end if go to 10 end if c track cumulative variables here ... end do