70 USE yaxt,
ONLY: xt_initialize, xt_idxlist, xt_idxlist_delete &
71 , xt_xmap, xt_xmap_delete, xt_idxstripes_new, xt_idxvec_new &
72 , xt_stripe, xt_idxempty_new, xt_xmap_dist_dir_new &
73 , xt_redist_p2p_new, xt_initialized, xi => xt_int_kind
74 USE mpi,
ONLY: mpi_double_precision
76 CHARACTER(LEN=*),
PARAMETER :: substr =
'comin_main (yaxt_nest_fortran_plugin)'
77 TYPE(t_comin_plugin_info) :: this_plugin
80 TYPE(xt_idxlist) :: src_idxlist, tgt_idxlist
82 INTEGER,
POINTER :: child_id(:)
83 INTEGER :: ii, ic, cid
84 INTEGER,
DIMENSION(:),
ALLOCATABLE :: src_indices, parent_indices, tgt_indices
87 rank = comin_parallel_get_host_mpi_rank()
88 CALL comin_print_info(
"setup")
92 IF (
version%version_no_major > 1)
THEN
97 CALL comin_current_get_plugin_info(this_plugin)
98 WRITE (
text,
'(a,a,a,i4)')
" plugin " &
99 , trim(this_plugin%name),
" has id: ", this_plugin%id
100 CALL comin_print_info(
text)
114 p_global = comin_descrdata_get_global()
122 p_patch(ii) = comin_descrdata_get_domain(ii)
126 p_all_comm = comin_parallel_get_plugin_mpi_comm()
127 IF (.NOT. xt_initialized())
THEN
128 CALL comin_print_info(
"Initialize yaxt...")
129 CALL xt_initialize(p_all_comm)
133 ALLOCATE (yaxt_redist(
n_dom))
135 child_id =>
p_patch(ii)%get_child_id()
136 DO ic = 1,
p_patch(ii)%get_n_childdom()
138 ALLOCATE (src_indices(count(
p_patch(ii)%cells%get_decomp_domain() == 0)))
139 ALLOCATE (parent_indices(
SIZE(
p_patch(cid)%cells%get_parent_glb_idx())))
140 ALLOCATE (tgt_indices(count(
p_patch(cid)%cells%get_decomp_domain() >= 0)))
143 src_indices = merge(
p_patch(ii)%cells%get_glb_index(), -1_xi &
144 & , reshape(
p_patch(ii)%cells%get_child_id() &
145 & , (/
p_patch(ii)%cells%get_ncells()/)) == cid)
147 parent_indices =
idx_1d(reshape(
p_patch(cid)%cells%get_parent_glb_idx() &
148 & , (/
SIZE(
p_patch(cid)%cells%get_parent_glb_idx())/)) &
149 & , reshape(
p_patch(cid)%cells%get_parent_glb_blk() &
150 & , (/
SIZE(
p_patch(cid)%cells%get_parent_glb_blk())/)))
152 tgt_indices = pack(parent_indices &
153 & , reshape(
p_patch(cid)%cells%get_decomp_domain() &
154 & , (/
SIZE(
p_patch(cid)%cells%get_decomp_domain())/)) >= 0)
156 src_idxlist = xt_idxvec_new(src_indices,
SIZE(src_indices, 1))
157 tgt_idxlist = xt_idxvec_new(tgt_indices,
SIZE(tgt_indices, 1))
160 xmap = xt_xmap_dist_dir_new(src_idxlist, tgt_idxlist, p_all_comm)
163 yaxt_redist(cid) = xt_redist_p2p_new(xmap, mpi_double_precision)
166 CALL xt_xmap_delete(xmap)
167 CALL xt_idxlist_delete(src_idxlist)
168 CALL xt_idxlist_delete(tgt_idxlist)
169 DEALLOCATE (src_indices, parent_indices, tgt_indices)
174 CALL comin_metadata_set(temp_d,
"zaxis_id", comin_zaxis_2d)
175 CALL comin_metadata_set(temp_d,
"tracer", .false.)
176 CALL comin_metadata_set(temp_d,
"restart", .false.)
177 CALL comin_metadata_set(temp_d,
"units",
"K")
187 USE yaxt,
ONLY: xt_idxlist, xt_idxlist_delete &
188 , xt_xmap, xt_xmap_delete &
193 CALL comin_print_info(
"secondary constructor")
197 CALL comin_print_info(
"request temperature")
198 CALL comin_var_get([ep_atm_integrate_end], &
200 CALL comin_print_info(
"request diagnostic temperature")
201 pid =
p_patch(ii)%get_parent_id()
203 CALL comin_var_get([ep_atm_integrate_end], &
213 USE yaxt,
ONLY: xt_redist_s_exchange1
214 USE iso_c_binding,
ONLY: c_loc
216 INTEGER :: domain_id, pid
217 REAL(kind=
wp),
DIMENSION(:,:),
POINTER :: src
218 REAL(kind=
wp),
DIMENSION(:, :, :),
POINTER :: temp3d, tgt
220 CALL comin_print_info(
"callback before output")
224 CALL comin_print_debug(
"currently not in domain loop")
227 WRITE (
text,
'(a,a,i0)')
"currently on domain ", domain_id
228 CALL comin_print_debug(
text)
231 pid =
p_patch(domain_id)%get_parent_id()
237 CALL temp(pid)%to_3d(temp3d)
240 src(:,:) = temp3d(:,
p_patch(pid)%get_nlev(),:)
243 CALL xt_redist_s_exchange1(yaxt_redist(domain_id), c_loc(src), c_loc(tgt))
245 WRITE(
text,
'(a,2(1x,f7.3))')
': min/max temperature src' &
246 , minval(pack(src, src > 0._wp)), maxval(pack(src, src > 0._wp))
247 CALL comin_print_info(
text)
248 WRITE(
text,
'(a,2(1x,f7.3))')
': min/max temperature tgt' &
249 , minval(pack(tgt, tgt > 0._wp)), maxval(pack(tgt, tgt > 0._wp))
250 CALL comin_print_info(
text)