da_wrfvar_finalize.inc
References to this file elsewhere.
1 subroutine da_wrfvar_finalize
2
3 !-------------------------------------------------------------------------
4 ! Purpose: Tidy up at the end
5 !-------------------------------------------------------------------------
6
7 implicit none
8
9 integer :: i
10 type(domain), pointer :: grid
11
12 if (trace_use) call da_trace_entry ("da_wrfvar_finalize")
13
14 ! output wrfvar analysis
15
16 if ((config_flags%real_data_init_type == 1) .or. &
17 (config_flags%real_data_init_type == 3)) then
18 call da_med_initialdata_output (head_grid, config_flags)
19 call med_shutdown_io (head_grid, config_flags)
20 end if
21
22 grid => head_grid
23
24 deallocate (grid%parents)
25 deallocate (grid%nests)
26 deallocate (grid%domain_clock)
27 deallocate (grid%alarms)
28 deallocate (grid%alarms_created)
29
30 deallocate (grid%i_start)
31 deallocate (grid%i_end)
32 deallocate (grid%j_start)
33 deallocate (grid%j_end)
34
35 #include "em_deallocs.inc"
36
37 deallocate (grid)
38
39 if (allocated(num_tovs_before)) deallocate (num_tovs_before)
40 if (allocated(num_tovs_after)) deallocate (num_tovs_after)
41 if (allocated(tovs_copy_count)) deallocate (tovs_copy_count)
42 if (allocated(tovs_send_pe)) deallocate (tovs_send_pe)
43 if (allocated(tovs_recv_pe)) deallocate (tovs_recv_pe)
44 if (allocated(tovs_send_start)) deallocate (tovs_send_start)
45 if (allocated(tovs_send_count)) deallocate (tovs_send_count)
46 if (allocated(tovs_recv_start)) deallocate (tovs_recv_start)
47
48 if (rootproc) then
49 close (cost_unit)
50 close (grad_unit)
51 close (stats_unit)
52 close (jo_unit)
53 close (check_max_iv_unit)
54 call da_free_unit (cost_unit)
55 call da_free_unit (grad_unit)
56 call da_free_unit (stats_unit)
57 call da_free_unit (jo_unit)
58 call da_free_unit (check_max_iv_unit)
59 end if
60
61 #ifdef CRTM
62 if (use_rad .and. rtm_option == rtm_option_crtm) then
63 ierr = CRTM_Destroy(ChannelInfo)
64 deallocate(Sensor_Descriptor)
65 end if
66 #endif
67
68 do i=unit_start,unit_end
69 if (unit_used(i)) then
70 write(unit=stderr,FMT=*) "unit",i,"still used"
71 end if
72 end do
73
74 call da_message ((/"SUCCESS COMPLETE WRFVAR"/))
75
76 if (trace_use) call da_trace_exit ("da_wrfvar_finalize")
77
78 end subroutine da_wrfvar_finalize
79
80