Finalization
This page describes the finalization phase of the Shallow-Water example. The source can be found in the ./Tolosa-lib/examples/sw/ directory (See Download).
Overview
Section titled “Overview”After the main computation loop, the program optionally checks mass conservation, deallocates the model arrays, and finalizes the library:
s(2) = sum( mesh%cell(1:mesh%nc)%surf * dof%var(1:mesh%nc)%h ) / mesh%surf
call mpi_world%sum( s(2) )
if ( proc == 0 .and. verbose > 0 ) then write(6,'(A,ES23.15)') 'Initial h sum = ' , s(1) write(6,'(A,ES23.15)') 'Final h sum = ' , s(2) write(6,'(A,ES23.15)') 'Realtive diff = ' , abs(s(1)-s(2))/s(1)end if
call dof%dealloc
call Final_Tolosa( mesh , timing_file=T )Mass Conservation Check
Section titled “Mass Conservation Check”Before deallocation, the program computes the final domain-averaged water depth:
s(2) = sum( mesh%cell(1:mesh%nc)%surf * dof%var(1:mesh%nc)%h ) / mesh%surfcall mpi_world%sum( s(2) )This is compared to the initial value s(1) computed before the time loop. The relative difference should be at machine precision for conservative schemes with reflecting boundary conditions.
Deallocation
Section titled “Deallocation”The model degrees of freedom are freed by calling:
call dof%deallocLibrary Finalization
Section titled “Library Finalization”The Tolosa-lib finalization is handled by Final_Tolosa (see Finalization):
call Final_Tolosa( mesh , timing_file=T )This stops all timers, prints the timing report, writes the performance file (timing_file=T), and deallocates the mesh.
Next Steps
Section titled “Next Steps”- Tolosa-sw Presentation - Full production implementation
- Getting Started - Run more Tolosa-lib examples