Update version info for release v4.6.1 (#2122)
[WRF.git] / var / da / da_transfer_model / da_transfer_model.f90
blob94ed01cbdf6280792561cb792c488e7cf780ccd8
1 module da_transfer_model
3 !---------------------------------------------------------------------------
4 ! Purpose: Transfer model states between different models
5 !---------------------------------------------------------------------------
7 use module_configure, only : grid_config_rec_type, model_config_rec
8 use module_date_time, only : geth_julgmt, current_date, start_date
9 use module_domain, only : domain, domain_clock_get, x_type, vp_type, ep_type
10 use module_io_domain, only : open_r_dataset, close_dataset, input_auxinput17, &
11 output_auxinput7, open_w_dataset
12 use module_state_description, only : dyn_em_ad, dyn_em, dyn_em_tl, &
13 p_qv, p_qr, p_qi, p_qs, p_qg, p_qc, param_first_scalar, num_moist, &
14 p_g_qv, p_g_qr, p_g_qi, p_g_qs, p_g_qg, p_g_qc, &
15 p_a_qv, p_a_qr, p_a_qi, p_a_qs, p_a_qg, p_a_qc, num_g_moist, num_a_moist, &
16 f_qc, f_qr, f_qi, f_qs, f_qg, f_g_qc, f_g_qr, f_g_qi, f_g_qs, f_g_qg, &
17 f_a_qc, f_a_qr, f_a_qi, f_a_qs, f_a_qg, warmrain_ad
19 #if (WRF_CHEM == 1)
20 use module_state_description, only : &
21 PARAM_FIRST_SCALAR, num_chem, p_bc2, p_oc2, p_co, p_no2, p_o3, p_so2, &
22 p_p10, p_p25, p_sulf, &
23 p_chem_ic_bc2, p_chem_ic_oc2, p_chem_ic_co, p_chem_ic_no2, p_chem_ic_o3, p_chem_ic_so2, &
24 p_chem_ic_p10, p_chem_ic_p25, p_chem_ic_sulf , &
25 p_bc_a01, p_bc_a02, p_bc_a03, p_oc_a01, p_oc_a02, p_oc_a03, &
26 p_so4_a01, p_so4_a02, p_so4_a03, p_no3_a01, p_no3_a02, p_no3_a03, &
27 p_nh4_a01, p_nh4_a02, p_nh4_a03, p_cl_a01, p_cl_a02, p_cl_a03, &
28 p_na_a01, p_na_a02, p_na_a03, p_oin_a01, p_oin_a02, p_oin_a03, &
29 p_chem_ic_bc_a01, p_chem_ic_bc_a02, p_chem_ic_bc_a03, p_chem_ic_oc_a01, p_chem_ic_oc_a02, p_chem_ic_oc_a03, &
30 p_chem_ic_so4_a01, p_chem_ic_so4_a02, p_chem_ic_so4_a03, p_chem_ic_no3_a01, p_chem_ic_no3_a02, p_chem_ic_no3_a03, &
31 p_chem_ic_nh4_a01, p_chem_ic_nh4_a02, p_chem_ic_nh4_a03, p_chem_ic_cl_a01, p_chem_ic_cl_a02, p_chem_ic_cl_a03, &
32 p_chem_ic_na_a01, p_chem_ic_na_a02, p_chem_ic_na_a03, p_chem_ic_oin_a01, p_chem_ic_oin_a02, p_chem_ic_oin_a03, &
33 p_so4aj, p_so4ai, p_nh4aj, p_nh4ai, & ! aerosols in racm_soa_vbs_kpp
34 p_no3aj, p_no3ai, p_naaj, p_naai, &
35 p_asoa1j, p_asoa1i, p_asoa2j, p_asoa2i, &
36 p_asoa3j, p_asoa3i, p_asoa4j, p_asoa4i, &
37 p_bsoa1j, p_bsoa1i, p_bsoa2j, p_bsoa2i, &
38 p_bsoa3j, p_bsoa3i, p_bsoa4j, p_bsoa4i, &
39 p_orgpaj, p_orgpai, p_ecj, p_eci, &
40 p_p25j, p_p25i, p_antha, p_seas, &
41 p_claj, p_clai, p_soila, &
42 p_chem_ic_so4aj, p_chem_ic_so4ai, p_chem_ic_nh4aj, p_chem_ic_nh4ai, & ! aerosols in racm_soa_vbs_da
43 p_chem_ic_no3aj, p_chem_ic_no3ai, p_chem_ic_naaj, p_chem_ic_naai, &
44 p_chem_ic_asoa1j, p_chem_ic_asoa1i, p_chem_ic_asoa2j, p_chem_ic_asoa2i, &
45 p_chem_ic_asoa3j, p_chem_ic_asoa3i, p_chem_ic_asoa4j, p_chem_ic_asoa4i, &
46 p_chem_ic_bsoa1j, p_chem_ic_bsoa1i, p_chem_ic_bsoa2j, p_chem_ic_bsoa2i, &
47 p_chem_ic_bsoa3j, p_chem_ic_bsoa3i, p_chem_ic_bsoa4j, p_chem_ic_bsoa4i, &
48 p_chem_ic_orgpaj, p_chem_ic_orgpai, p_chem_ic_ecj, p_chem_ic_eci, &
49 p_chem_ic_p25j, p_chem_ic_p25i, p_chem_ic_antha, p_chem_ic_seas, &
50 p_chem_ic_claj, p_chem_ic_clai, p_chem_ic_soila
51 #endif
53 use module_dm, only : wrf_dm_sum_real, wrf_dm_sum_reals
54 #ifdef DM_PARALLEL
55 use module_dm, only : local_communicator, &
56 ntasks_x, ntasks_y, data_order_xyz, mytask, &
57 ntasks, data_order_xy
58 use module_comm_dm, only : halo_xa_sub, halo_init_sub, halo_psichi_uv_adj_sub, &
59 halo_xb_sub, halo_xb_uv_sub, halo_em_c_sub, halo_em_c_tl_sub, &
60 halo_xa_a_sub, halo_x6a_a_sub, halo_em_bdy_sub, halo_em_e_tl_sub, &
61 #if (WRF_CHEM == 1)
62 halo_chem_xb_sub, halo_chem_init_sub, halo_chem_xa_sub, &
63 #endif
64 halo_em_e_sub
65 #endif
67 use da_control, only : cos_xls, sin_xls, cos_xle, sin_xle, trace_use, &
68 coarse_jy, coarse_ix, cone_factor, delt_lon, delt_lat, gas_constant, &
69 map_projection,earth_omega,mix,pi,phic,mkz,start_lon,start_lat, &
70 start_x,xlonc,start_y,mjy, global, rad_to_deg, deg_to_rad, earth_radius, &
71 var4d,var4d_lbc,analysis_date,coarse_ds,analysis_accu,dsm,pole, fg_format_kma_global, &
72 fg_format, fg_format_wrf_arw_regional, fg_format_wrf_nmm_regional, &
73 print_detail_map,stdout,truelat1_3dv, base_pres, fg_format_wrf_arw_global, &
74 truelat2_3dv, periodic_x,write_increments,max_ext_its, gravity, &
75 kappa, print_detail_xa,rd_over_rv,t0, print_detail_xa, check_rh, adj_sens,&
76 print_detail_xb,test_dm_exact,base_lapse,base_temp,vertical_ip,ptop, &
77 use_gpsztdobs, use_ssmitbobs, use_radarobs, use_radar_rf, use_radar_rhv,&
78 dt_cloud_model, cp, use_ssmiretrievalobs, var4d_detail_out, &
79 vertical_ip_sqrt_delta_p, vertical_ip_delta_p,check_rh_simple, check_rh_tpw, &
80 t_kelvin, num_fgat_time, num_pseudo, iso_temp, interval_seconds, trajectory_io, &
81 cv_options, &
82 ids,ide,jds,jde,kds,kde, ims,ime,jms,jme,kms,kme, num_fft_factors, &
83 its,ite,jts,jte,kts,kte, ips,ipe,jps,jpe,kps,kpe, qlimit, &
84 update_sfcdiags, use_wrf_sfcinfo, use_radar_rqv, cloudbase_calc_opt, use_gpsephobs, &
85 cloud_cv_options
86 use da_control, only: base_pres_strat, base_lapse_strat
87 use da_control, only: c1f, c2f, c1h, c2h, c3f, c3h, c4f, c4h
88 use da_define_structures, only : xbx_type, be_type
89 #if (WRF_CHEM == 1)
90 use da_define_structures, only : iv_type, y_type
91 #endif
92 use da_par_util, only : da_patch_to_global
93 use da_physics, only : da_check_rh_simple,da_roughness_from_lanu, &
94 da_sfc_wtq,da_tpq_to_rh,da_trh_to_td,da_wrf_tpq_2_slp,da_integrat_dz, &
95 da_tp_to_qs, da_check_rh,da_transform_xtogpsref, da_transform_xtoztd, &
96 sfclayinit
97 use da_reporting, only : da_error,message, da_message, da_warning
98 use da_setup_structures, only : da_setup_runconstants,da_write_increments, &
99 da_write_kma_increments,da_cloud_model, da_write_increments_for_wrf_nmm_regional
100 use da_ssmi, only : da_transform_xtotb
101 use da_tools, only : map_info, 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
104 use da_tracing, only : da_trace_entry, da_trace_exit, da_trace
105 use da_vtox_transforms, only : da_get_vpoles
106 use da_radar, only : zlcl_mean
107 use da_gpseph, only : da_gpseph_init
108 use da_wrf_interfaces, only : wrf_dm_bcast_real
109 #ifdef VAR4D
110 use da_4dvar, only : model_grid, push_ad_forcing, push_tl_pert, pop_tl_pert, kj_swap, &
111 kj_swap_reverse, model_config_flags, g_couple, g_stuff_bdy, a_couple, a_stuff_bdy, &
112 g_stuff_bdytend, a_stuff_bdytend_old, a_stuff_bdytend_new, decouple, da_calc_2nd_fg, &
113 ubdy3dtemp1 , vbdy3dtemp1 , tbdy3dtemp1 , pbdy3dtemp1 , qbdy3dtemp1, mbdy2dtemp1, &
114 ubdy3dtemp2 , vbdy3dtemp2 , tbdy3dtemp2 , pbdy3dtemp2 , qbdy3dtemp2, mbdy2dtemp2, &
115 wbdy3dtemp1, wbdy3dtemp2, da_bdy_fields_halo
116 use module_bc, only : set_physical_bc2d
117 use module_big_step_utilities_em, only : calc_mu_uv
118 use g_module_big_step_utilities_em, only : g_calc_mu_uv
119 use a_module_big_step_utilities_em, only : a_calc_mu_uv
120 USE module_io_wrf, only : auxinput8_alarm, auxhist8_alarm, auxhist7_alarm
121 #ifdef DM_PARALLEL
122 use mediation_pertmod_io, only : da_halo_em_e_ad
123 #endif
124 #endif
126 implicit none
128 contains
130 #include "da_transfer_wrftoxb.inc"
131 #if (WRF_CHEM == 1)
132 #include "da_transfer_wrftoxb_chem.inc"
133 #endif
134 #include "da_transfer_wrf_nmm_regional_toxb.inc"
135 #include "da_transfer_kmatoxb.inc"
136 #include "da_transfer_xatowrf.inc"
137 #include "da_transfer_xatowrf_nmm_regional.inc"
138 #include "da_transfer_xatokma.inc"
139 #include "da_transfer_wrftltoxa.inc"
140 #include "da_transfer_wrftltoxa_adj.inc"
141 #include "da_transfer_xatowrftl.inc"
142 #include "da_transfer_xatowrftl_lbc.inc"
143 #include "da_transfer_wrftl_lbc_t0.inc"
144 #include "da_transfer_xatowrftl_adj.inc"
145 #include "da_transfer_xatowrftl_adj_lbc.inc"
146 #include "da_transfer_wrftl_lbc_t0_adj.inc"
147 #include "da_transfer_xatoanalysis.inc"
148 #include "da_setup_firstguess.inc"
149 #include "da_setup_firstguess_wrf.inc"
150 #include "da_setup_firstguess_wrf_nmm_regional.inc"
151 #include "da_setup_firstguess_kma.inc"
152 #include "da_get_2nd_firstguess.inc"
154 end module da_transfer_model