14 USE iso_c_binding,
ONLY : c_int
18 , t_comin_var_handle &
19 , comin_descrdata_get_domain &
20 , t_comin_descrdata_domain &
21 , comin_descrdata_get_global &
22 , t_comin_descrdata_global &
23 , t_comin_setup_version_info &
25 , ep_secondary_constructor &
27 , ep_atm_write_output_before &
29 , comin_parallel_get_host_mpi_rank &
31 , comin_parallel_get_plugin_mpi_comm &
33 , t_comin_plugin_info &
34 , comin_current_get_plugin_info &
39 USE yaxt,
ONLY: xt_redist, xi => xt_int_kind
43 CHARACTER(LEN=*),
PARAMETER ::
pluginname =
"yaxt_fortran_plugin"
46 INTEGER,
PARAMETER ::
wp = selected_real_kind(12,307)
47 TYPE(t_comin_setup_version_info) ::
version
49 TYPE(t_comin_var_handle) ::
temp
51 CHARACTER(LEN=:),
ALLOCATABLE ::
units
58 TYPE(xt_redist) :: yaxt_redist
69 USE yaxt,
ONLY: xt_initialize, xt_idxlist, xt_idxlist_delete &
70 , xt_xmap, xt_xmap_delete, xt_idxstripes_new, xt_idxvec_new &
71 , xt_stripe, xt_idxempty_new, xt_xmap_all2all_new &
72 , xt_redist_p2p_new, xt_initialized
73 USE mpi,
ONLY: mpi_double_precision
75 CHARACTER(LEN=*),
PARAMETER :: substr =
'comin_main (yaxt_fortran_plugin)'
76 TYPE(t_comin_plugin_info) :: this_plugin
78 TYPE(xt_idxlist) :: src_idxlist, tgt_idxlist
80 INTEGER(kind=xi),
DIMENSION(:),
ALLOCATABLE :: idxvec, idxmap
81 INTEGER,
POINTER :: glb_index(:)
85 rank = comin_parallel_get_host_mpi_rank()
86 CALL comin_print_info(
"setup")
90 IF (
version%version_no_major > 1)
THEN
95 CALL comin_current_get_plugin_info(this_plugin)
96 WRITE (
text,
'(a,a,a,i4)')
" plugin " &
97 , trim(this_plugin%name),
" has id: ", this_plugin%id
98 CALL comin_print_info(
text)
112 p_patch = comin_descrdata_get_domain(1)
113 p_global = comin_descrdata_get_global()
116 p_all_comm = comin_parallel_get_plugin_mpi_comm()
117 IF (.NOT. xt_initialized())
THEN
118 CALL comin_print_info(
"Initialize yaxt...")
119 CALL xt_initialize(p_all_comm)
125 idxmap = reshape(
p_patch%cells%get_decomp_domain() &
126 , (/
SIZE(
p_patch%cells%get_decomp_domain()) /))
128 idxvec = int(pack( [(k,k=1,
p_patch%cells%get_ncells())], idxmap == 0 ), xi)
130 glb_index =>
p_patch%cells%get_glb_index()
131 idxvec = glb_index(idxvec)
133 src_idxlist = xt_idxvec_new(idxvec)
136 tgt_idxlist = xt_idxstripes_new( &
137 (/ xt_stripe(1, 1,
p_patch%cells%get_ncells_global()) /))
140 tgt_idxlist = xt_idxempty_new()
144 xmap = xt_xmap_all2all_new(src_idxlist, tgt_idxlist, p_all_comm)
147 yaxt_redist = xt_redist_p2p_new(xmap, mpi_double_precision)
150 CALL xt_xmap_delete(xmap)
151 CALL xt_idxlist_delete(src_idxlist)
152 CALL xt_idxlist_delete(tgt_idxlist)
163 USE yaxt,
ONLY: xt_idxlist, xt_idxlist_delete &
164 , xt_xmap, xt_xmap_delete &
167 CHARACTER(LEN=*),
PARAMETER :: substr =
'yaxt_fortran_constructor (yaxt_fortran_plugin)'
170 CALL comin_print_info(
"secondary constructor")
172 CALL comin_print_info(
"request temperature")
174 CALL comin_var_get([ep_atm_write_output_before], &
175 var_desc, comin_flag_read,
temp)
186 USE yaxt,
ONLY: xt_redist_s_exchange1
187 USE iso_c_binding,
ONLY: c_loc
189 CHARACTER(LEN=*),
PARAMETER :: substr =
'yaxt_fortran_gather (yaxt_fortran_plugin)'
190 TYPE(t_comin_plugin_info) :: this_plugin
192 REAL(kind=
wp),
DIMENSION(:,:),
POINTER :: src
193 REAL(kind=
wp),
DIMENSION(:,:,:),
POINTER :: src3d
194 REAL(kind=
wp),
DIMENSION(:),
POINTER :: tgt, area
196 CALL comin_print_info(
"callback before output")
199 CALL comin_current_get_plugin_info(this_plugin)
203 CALL comin_print_debug(
"currently not in domain loop")
205 WRITE(
text,
'(a,a,i0)')
"currently on domain ", domain_id
206 CALL comin_print_debug(
text)
210 NULLIFY(src, src3d, tgt, area)
212 CALL temp%to_3d(src3d)
216 src(:,:) = src3d(:,
p_patch%get_nlev(),:)
219 ALLOCATE(tgt(
p_patch%cells%get_ncells_global()))
220 ALLOCATE(area(
p_patch%cells%get_ncells_global()))
223 CALL xt_redist_s_exchange1(yaxt_redist, c_loc(src), c_loc(tgt))
224 CALL xt_redist_s_exchange1(yaxt_redist, c_loc(
p_patch%cells%get_area()) &
228 WRITE(0,*) substr,
': global average temperature is ' &
229 , sum(tgt*area)/sum(area), trim(
units)
243 USE yaxt,
ONLY: xt_finalize, xt_redist_delete
245 CALL comin_print_info(
"destructor")
248 CALL xt_redist_delete(yaxt_redist)
void comin_plugin_finish(const char *routine, const char *text)
void comin_setup_get_version(unsigned int *major, unsigned int *minor, unsigned int *patch)
int comin_current_get_domain_id()
integer, parameter, public comin_domain_outside_loop
Return value of comin_current_get_domain_id if there is currently no domain loop.
void comin_callback_register(t_comin_entry_point entry_point, t_comin_callback_function fct_ptr)
Example plugin for the ICON Community Interface (ComIn)
character(len= *), parameter pluginname
integer, parameter wp
working precision (will be compared to ComIn's and ICON's)
character(len=:), allocatable units
type(t_comin_var_handle) temp
type(t_comin_descrdata_domain) p_patch
access descriptive data structures
type(t_comin_descrdata_global) p_global
subroutine yaxt_fortran_destructor()
subroutine yaxt_fortran_gather()
type(t_comin_setup_version_info) version
subroutine yaxt_fortran_constructor()