Mountain glacier driver routine

From Interactive System for Ice sheet Simulation
Jump to: navigation, search
program driver_all
 
use kees1_variables
implicit none
 
real(8), dimension(int(xend/dx)+1) :: xx, g_xx, adxx
real(8) :: fc, g_fc, adfc, fdfc
real(8) :: fc_0, fc_pert
real(8) :: accuracy
real(8), parameter :: eps = 1.d-7
integer :: ii
 
! initialize	
        fc    = 0.
        xx    = 0.
        adfc  = 1.
        adxx  = 0.
 
print *, '                                    position       dfc/dM [TLM]', &
         '            dfc/dM [ADM]           dfc/dM [f.d.]            relative accuracy'
print *, '----------------------------------------------------------------', &
         '-----------------------------------------------------------------------------'
 
! call adjoint model
        call adkees1(xx,adxx,fc,adfc)
        fc_0 = fc
 
! loop over each directional derivative
        do ii = 1, size(xx)
!
! initialize
           fc = 0.
           xx = 0.
           g_xx = 0.
           g_xx(ii) = 1.
!
! call TLM
           call g_kees1(xx,g_xx,fc,g_fc)
!
! do a finite-difference run
           fc = 0.
           xx = 0.
           xx(ii) = eps
           call kees1(xx,fc)
           fdfc = (fc - fc_0)/eps
           if ( fdfc .NE. 0. ) then
              accuracy = 1.d0 - g_fc/fdfc
           else
              accuracy = 0.
           end if
!
! write output
           print *, 'ph: ii, g_fc, adfc, fdfc, acc = ', &
                    ii, g_fc, adxx(ii), fdfc, accuracy
        end do
 
	end program