Merge remote-tracking branch 'origin/release-v4.5.2'
[WRF.git] / var / da / da_main / da_wrfvar_top.f90
blob6205ab539d2693b8dc6dcbc5d67da188a0e34bb3
1 module da_wrfvar_top
3 !-----------------------------------------------------------------------
4 ! Purpose:
5 !-----------------------------------------------------------------------
7 use module_configure, only : grid_config_rec_type,model_config_rec, &
8 model_to_grid_config_rec, get_config_as_buffer,set_config_as_buffer, &
9 initial_config
10 use module_domain, only : domain,alloc_and_configure_domain, head_grid, &
11 program_name, domain_clock_get, domain_clock_set, x_type, dealloc_space_domain, &
12 domain_destroy
13 use module_driver_constants, only : max_comms
14 use module_symbols_util, only : wrfu_finalize, wrfu_initialize, &
15 wrfu_cal_gregorian
16 use module_io_domain, only : close_dataset
17 #ifdef VAR4D
18 use da_4dvar, only : da_nl_model, model_grid, u6_2, v6_2, w6_2, t6_2, ph6_2, p6, &
19 mu6_2, psfc6, moist6, kj_swap, da_finalize_model, da_model_lbc_off
20 !use da_wrfvar_io, only : da_med_initialdata_output_lbc
21 #endif
23 #if defined(RTTOV) || defined(CRTM)
24 use module_radiance, only : satinfo
25 #endif
26 #ifdef RTTOV
27 use module_radiance, only : coefs, opts, sensor_descriptor
28 #endif
30 use module_state_description, only : num_moist, num_a_moist, num_g_moist, &
31 num_scalar, num_a_scalar, num_g_scalar, &
32 #if (WRF_CHEM == 1)
33 num_chem, PARAM_FIRST_SCALAR
34 #else
35 num_chem, PARAM_FIRST_SCALAR, num_tracer
36 #endif
37 use module_tiles, only : set_tiles
40 #ifdef DM_PARALLEL
41 use module_dm, only : local_communicator, local_communicator_x, &
42 local_communicator_y, ntasks_x, ntasks_y, data_order_xyz, mytask, &
43 ntasks, data_order_xy,wrf_dm_initialize
44 use module_comm_dm, only : halo_radar_xa_w_sub,halo_ssmi_xa_sub, &
45 halo_sfc_xa_sub, halo_xa_sub, halo_psichi_uv_adj_sub, halo_bal_eqn_adj_sub, &
46 #if (WRF_CHEM == 1)
47 halo_chem_init_sub, halo_chem_xa_sub, &
48 #endif
49 halo_psichi_uv_sub, halo_init_sub, halo_psichi_uv_adj_sub, halo_2d_work_sub
50 #endif
52 ! too many namelist options to list
53 use da_control
54 use da_define_structures, only : y_type, j_type, iv_type, be_type, &
55 xbx_type,da_deallocate_background_errors,da_initialize_cv, &
56 da_zero_vp_type,da_allocate_y,da_deallocate_observations, &
57 #if (WRF_CHEM == 1)
58 da_zero_xchem_type, &
59 #endif
60 da_deallocate_y, da_zero_x, da_random_seed
61 use da_minimisation, only : da_get_innov_vector,da_minimise_cg, &
62 da_minimise_lz, da_write_diagnostics, da_calculate_residual, &
63 da_calculate_grady, da_sensitivity, da_lanczos_io, da_calculate_j, &
64 da_kmat_mul
65 use da_obs, only : da_transform_xtoy_adj
66 use da_obs_io, only : da_write_filtered_obs, da_write_obs, da_final_write_obs , &
67 #if (WRF_CHEM == 1)
68 da_read_obs_chem_sfc, &
69 #endif
70 da_write_obs_etkf, da_write_modified_filtered_obs
71 use da_par_util, only : da_system,da_copy_tile_dims,da_copy_dims, &
72 da_vv_to_cv, da_cv_to_vv
73 use da_physics, only : da_uvprho_to_w_lin
74 #if defined (CRTM) || defined (RTTOV)
75 use da_radiance, only : da_deallocate_radiance
76 use da_radiance1, only : num_tovs_before, tovs_recv_pe,tovs_copy_count, &
77 tovs_send_pe,tovs_send_count,tovs_recv_start, num_tovs_after, &
78 tovs_send_start, da_oi_stats_rad, da_write_oa_rad_ascii, da_setup_satcv
79 use da_varbc, only : da_varbc_init,da_varbc_update
80 #endif
81 use da_reporting, only : message, da_warning, da_error, da_message
82 use da_setup_structures, only : da_setup_obs_structures, da_write_vp, &
83 da_setup_background_errors,da_setup_flow_predictors, &
84 da_setup_cv, da_scale_background_errors, da_scale_background_errors_cv3
85 use da_setup_structures, only : da_setup_flow_predictors_para_read_opt1
86 use da_setup_structures, only : da_setup_flow_predictors_ep_format2, da_setup_flow_predictors_ep_format3
87 use da_test, only : da_check, da_check_gradient
88 use da_tools_serial, only : da_get_unit, da_free_unit
89 use da_tracing, only : da_trace_entry, da_trace_exit, da_trace, da_trace_report
90 use da_transfer_model, only : da_transfer_xatoanalysis,da_setup_firstguess, &
91 #if (WRF_CHEM == 1)
92 da_transfer_wrftoxb_chem, &
93 #endif
94 da_transfer_wrftltoxa_adj
95 use da_vtox_transforms, only : da_transform_vtox, da_transform_xtoxa, &
96 da_transform_xtoxa_adj, da_copy_xa, da_add_xa, da_transform_vpatox, &
97 da_transform_vtox_inv
98 use da_wrfvar_io, only : da_med_initialdata_input, da_update_firstguess
99 use da_tools, only : da_set_randomcv, da_get_julian_time
101 use da_tools, only : map_info,map_info_ens,proj_merc, proj_ps,proj_lc,proj_latlon, &
102 da_llxy_default,da_llxy_wrf,da_xyll,da_diff_seconds,da_map_set, &
103 da_set_boundary_xb,da_togrid
105 #ifdef CRTM
106 use module_radiance, only : crtm_destroy
107 use da_crtm, only : channelinfo, sensor_descriptor
108 #endif
110 use da_airep, only : da_oi_stats_airep
111 use da_airsr , only : da_oi_stats_airsr
112 use da_bogus, only : da_oi_stats_bogus
113 use da_buoy , only : da_oi_stats_buoy
114 use da_geoamv, only : da_oi_stats_geoamv
115 use da_gpspw, only : da_oi_stats_gpspw
116 use da_gpsref, only : da_oi_stats_gpsref
117 use da_metar, only : da_oi_stats_metar
118 use da_pilot, only : da_oi_stats_pilot
119 use da_polaramv, only : da_oi_stats_polaramv
120 use da_profiler, only : da_oi_stats_profiler
121 use da_qscat, only : da_oi_stats_qscat
122 use da_mtgirs, only : da_oi_stats_mtgirs
123 use da_radar, only : da_oi_stats_radar, da_write_oa_radar_ascii
124 use da_satem, only : da_oi_stats_satem
125 use da_ships, only : da_oi_stats_ships
126 use da_sound, only : da_oi_stats_sound, da_oi_stats_sonde_sfc
127 use da_ssmi, only : da_oi_stats_ssmt1, da_oi_stats_ssmt2, da_oi_stats_ssmi_tb, da_oi_stats_ssmi_rv
128 use da_synop, only : da_oi_stats_synop
129 use da_rain, only : da_oi_stats_rain
130 use da_gpseph, only : da_gpseph_final
132 use da_varbc_tamdar, only : da_varbc_tamdar_init, da_varbc_tamdar_pred, &
133 da_varbc_tamdar_update
135 use da_wrf_interfaces
137 use da_netcdf_interface, only : da_get_var_2d_real_cdf
139 implicit none
141 integer :: loop, levels_to_process
143 type (domain) , pointer :: keep_grid, grid_ptr, null_domain
144 type (domain) , pointer :: another_grid, parent_grid, ensemble_grid, input_grid
145 type (grid_config_rec_type), save :: config_flags
146 integer :: number_at_same_level
147 integer :: time_step_begin_restart
149 integer :: domain_id , fid , oid , idum1 , idum2
151 #ifdef DM_PARALLEL
152 integer :: nbytes
153 #if (WRF_CHEM == 1)
154 integer, parameter :: configbuflen = 6* CONFIG_BUF_LEN
155 #else
156 integer, parameter :: configbuflen = 4* CONFIG_BUF_LEN
157 #endif
158 integer :: configbuf( configbuflen )
159 #endif
161 character (len=80) :: rstname
163 #ifdef RTTOV
164 #include "rttov_dealloc_coefs.interface"
165 #endif
167 contains
169 #include "da_wrfvar_init1.inc"
170 #include "da_wrfvar_init2.inc"
171 #include "da_wrfvar_run.inc"
172 #include "da_wrfvar_interface.inc"
173 #include "da_wrfvar_finalize.inc"
174 #include "da_solve.inc"
175 #include "da_solve_init.inc"
176 #include "da_solve_dual_res_init.inc"
178 end module da_wrfvar_top