26 type(model_state_type),
target,
intent(inout) :: current_state
27 type (str_socrates_options),
intent(in) :: socrates_opt
28 type (str_socrates_derived_fields),
intent(in) :: socrates_derived_fields
29 type (str_mcc_profiles),
intent(in) :: mcc
30 type (str_merge_atm),
intent(inout) :: merge_fields
32 type(vertical_grid_configuration_type) :: vertical_grid
41 integer :: k_top, icol, jcol
46 k_top = current_state%local_grid%size(z_index)
47 icol=current_state%column_local_x
48 jcol=current_state%column_local_y
50 vertical_grid=current_state%global_grid%configuration%vertical
59 merge_fields%pres_level(1:mcc%cut) = mcc%p_level(1:mcc%cut)
60 merge_fields%pres_n(1:mcc%cut) = mcc%p_n(1:mcc%cut)
61 merge_fields%o3_n(1:mcc%cut) = mcc%o3_n(1:mcc%cut)
62 merge_fields%t_level(1:mcc%cut) = mcc%t_level(1:mcc%cut)
63 merge_fields%t_n(1:mcc%cut) = mcc%t_n(1:mcc%cut)
64 merge_fields%qv_n(1:mcc%cut) = mcc%q_n(1:mcc%cut)
65 merge_fields%ql_n(:) = 0.0
66 merge_fields%qi_n(:) = 0.0
67 merge_fields%total_cloud_fraction(:) = 0.0
68 merge_fields%liquid_cloud_fraction(:) = 0.0
69 merge_fields%ice_cloud_fraction(:) = 0.0
75 merge_fields%t_n_loc(k) = (current_state%th%data(k, jcol, icol) &
76 + current_state%global_grid%configuration%vertical%thref(k)) &
77 * current_state%global_grid%configuration%vertical%rprefrcp(k)
83 merge_fields%pres_n(k+mcc%cut)= &
84 current_state%global_grid%configuration%vertical%prefn(k_top+2-k)
86 merge_fields%t_n(k+mcc%cut) = merge_fields%t_n_loc(k_top+2-k)
88 merge_fields%qv_n(k+mcc%cut) = current_state%q(socrates_opt%iqv)%data(k_top+2-k, jcol, icol)
89 if ( socrates_opt%cloud_representation == 2)
then
90 if (socrates_opt%mphys_nq_l > 0)
then
91 merge_fields%ql_n(k+mcc%cut) = &
92 current_state%q(socrates_opt%iql)%data(k_top+2-k, jcol, icol)
93 if (.not. socrates_opt%l_fix_re)
then
94 if (socrates_opt%mphys_nd_l > 0)
then
97 if (socrates_opt%inl > 0)
then
98 merge_fields%cloudnumber_n(k+mcc%cut) = &
99 current_state%q(socrates_opt%inl)%data(k_top+2-k, jcol, icol)
101 merge_fields%cloudnumber_n(k+mcc%cut) = &
102 socrates_opt%fixed_cloud_number*1.e6
110 if (socrates_opt%mphys_nq_r > 0)
then
111 merge_fields%ql_n(k+mcc%cut) = merge_fields%ql_n(k+mcc%cut) + &
112 merge_fields%rainfac* &
113 (current_state%q(socrates_opt%iqr)%data(k_top+2-k, jcol, icol))
115 if (socrates_opt%mphys_nq_i > 0)
then
116 merge_fields%qi_n(k+mcc%cut) = &
117 current_state%q(socrates_opt%iqi)%data(k_top+2-k, jcol, icol)
123 if (socrates_opt%mphys_nq_s > 0)
then
124 merge_fields%qi_n(k+mcc%cut) = merge_fields%qi_n(k+mcc%cut) + &
125 merge_fields%snowfac* &
126 (current_state%q(socrates_opt%iqs)%data(k_top+2-k, jcol, icol))
128 if (socrates_opt%mphys_nq_g > 0)
then
129 merge_fields%qi_n(k+mcc%cut) = merge_fields%qi_n(k+mcc%cut) + &
130 merge_fields%graupfac* &
131 (current_state%q(socrates_opt%iqg)%data(k_top+2-k, jcol, icol))
134 cloud_total = merge_fields%ql_n(k+mcc%cut) + merge_fields%qi_n(k+mcc%cut)
135 if (cloud_total > epsilon(cloud_total) )
then
136 merge_fields%total_cloud_fraction(k+mcc%cut) = 1.0_default_precision
137 merge_fields%liquid_cloud_fraction(k+mcc%cut) = &
138 merge_fields%ql_n(k+mcc%cut)/(cloud_total)
139 merge_fields%ice_cloud_fraction(k+mcc%cut) = &
140 (1.0_default_precision - merge_fields%liquid_cloud_fraction(k+mcc%cut))
142 merge_fields%total_cloud_fraction(k+mcc%cut) = 0.0_default_precision
143 merge_fields%liquid_cloud_fraction(k+mcc%cut) = 0.0_default_precision
144 merge_fields%ice_cloud_fraction(k+mcc%cut) = 0.0_default_precision
152 merge_fields%pres_n(mcc%cut+1)= &
153 (current_state%global_grid%configuration%vertical%prefn(k_top) + &
154 mcc%p_n(mcc%cut))/2.0
156 merge_fields%t_n(mcc%cut+1)= &
157 (merge_fields%t_n_loc(k_top) + mcc%t_n(mcc%cut))/2.0
159 merge_fields%qv_n(mcc%cut+1)= &
160 (current_state%q(socrates_opt%iqv)%data(k_top, jcol, icol) + mcc%q_n(mcc%cut))/2.0
164 merge_fields%pres_level(mcc%irad_levs) = current_state%surface_pressure
165 merge_fields%t_level(mcc%irad_levs) = socrates_derived_fields%srf_temperature
167 merge_fields%pres_level(0) = 0.0
168 merge_fields%t_level(0) = merge_fields%t_level(1)
173 do k = 1, mcc%irad_levs-1
174 merge_fields%pres_level(k) = 0.5_default_precision * &
175 (merge_fields%pres_n(k) + merge_fields%pres_n(k+1))
177 merge_fields%t_level(k) = 0.5_default_precision * &
178 (merge_fields%t_n(k) + merge_fields%t_n(k+1))
185 do k=k_top+mcc%cut,mcc%cut,-1
186 if (merge_fields%pres_level(k).gt.mcc%p_level(mcc%levs))
then
187 merge_fields%o3_n(k) = mcc%o3_n(mcc%levs)
190 if (merge_fields%pres_level(k).gt.mcc%p_level(j))
then
191 merge_fields%o3_n(k) = mcc%o3_n(j)
199 do k=1, mcc%irad_levs
200 merge_fields%mass(k) = &
201 (merge_fields%pres_level(k)-merge_fields%pres_level(k-1))/gravity