Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 85 additions & 85 deletions c_fms/c_fms.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,176 +64,176 @@ extern int cFMS_pe();
extern void cFMS_set_current_pelist(int* npes, int* pelist, bool* no_sync);

extern int cFMS_define_domains(int* global_indices, int* layout, int* npes, int* pelist,
int* xflags, int* yflags, int* xhalo, int* yhalo, int* xextent, int* yextent,
bool* maskmap, char* name, bool* symmetry, int* memory_size,
int* whalo, int* ehalo, int* shalo, int* nhalo, bool* is_mosaic,
int* tile_count, int* tile_id, bool* complete, int* x_cyclic_offset,
int* y_cyclic_offset);
int* xflags, int* yflags, int* xhalo, int* yhalo, int* xextent, int* yextent,
bool* maskmap, char* name, bool* symmetry, int* memory_size,
int* whalo, int* ehalo, int* shalo, int* nhalo, bool* is_mosaic,
int* tile_count, int* tile_id, bool* complete, int* x_cyclic_offset,
int* y_cyclic_offset);

extern void cFMS_define_io_domain(int* io_layout, int* domain_id);

extern void cFMS_define_layout(int* global_indices, int* ndivs, int* layout);

extern int cFMS_define_nest_domains(int* num_nest, int* ntiles, int* nest_level, int* tile_fine, int* tile_course,
int* istart_coarse, int* icount_coarse, int* jstart_coarse, int* jcount_coarse,
int* npes_nest_tile, int* x_refine, int* y_refine, int* domain_id,
int* extra_halo, char* name);
int* istart_coarse, int* icount_coarse, int* jstart_coarse, int* jcount_coarse,
int* npes_nest_tile, int* x_refine, int* y_refine, int* domain_id,
int* extra_halo, char* name);

extern bool cFMS_domain_is_initialized(int* domain_id);

extern void cFMS_gather_1d_cint(int* sbuf_size, int* rbuf_size, int* sbuf, int* rbuf, int* pelist, int* npes);
extern void cFMS_gather_1d_cint(int* sbuf_size, int* sbuf, int* rbuf, int* pelist, int* rbuf_size, int* npes);

extern void cFMS_gather_1d_cfloat(int* sbuf_size, int* rbuf_size, float* sbuf, float* rbuf, int* pelist, int* npes);
extern void cFMS_gather_1d_cfloat(int* sbuf_size, float* sbuf, float* rbuf, int* pelist, int* rbuf_size, int* npes);

extern void cFMS_gather_1d_cdouble(int* sbuf_size, int* rbuf_size, double* sbuf, double* rbuf, int* pelist, int* npes);
extern void cFMS_gather_1d_cdouble(int* sbuf_size, double* sbuf, double* rbuf, int* pelist, int* rbuf_size, int* npes);

extern void cFMS_gatherv_1d_cint(int* npes, int* sbuf_size, int* rbuf_size, int* sbuf, int* ssize,
int* rbuf, int* rsize, int* pelist);
extern void cFMS_gatherv_1d_cint(int* sbuf_size, int* sbuf, int* ssize,
int* rbuf, int* rsize, int* pelist, int* npes);

extern void cFMS_gatherv_1d_cfloat(int* npes, int* sbuf_size, int* rbuf_size, float* sbuf, int* ssize,
float* rbuf, int* rsize, int* pelist);
extern void cFMS_gatherv_1d_cfloat(int* sbuf_size, float* sbuf, int* ssize,
float* rbuf, int* rsize, int* pelist, int* npes);

extern void cFMS_gatherv_1d_cdouble(int* npes, int* sbuf_size, int* rbuf_size, double* sbuf, int* ssize,
double* rbuf, int* rsize, int* pelist);
extern void cFMS_gatherv_1d_cdouble(int* sbuf_size, double* sbuf, int* ssize,
double* rbuf, int* rsize, int* pelist, int* npes);

extern void cFMS_gather_pelist_2d_cint(int* is, int* ie, int* js, int* je, int* npes, int* pelist,
int* array_seg, int* gather_data_c_shape, int* gather_data,
bool* is_root_pe, int* ishift, int* jshift, bool* convert_cf_order);
int* array_seg, int* gather_data, bool* is_root_pe,
int* gather_data_c_shape, int* ishift, int* jshift, bool* convert_cf_order);

extern void cFMS_gather_pelist_2d_cfloat(int* is, int* ie, int* js, int* je, int* npes, int* pelist,
float* array_seg, int* gather_data_c_shape, float* gather_data,
bool* is_root_pe, int* ishift, int* jshift, bool* convert_cf_order);
float* array_seg, float* gather_data, bool* is_root_pe,
int* gather_data_c_shape, int* ishift, int* jshift, bool* convert_cf_order);

extern void cFMS_gather_pelist_2d_cdouble(int* is, int* ie, int* js, int* je, int* npes, int* pelist,
double* array_seg, int* gather_data_c_shape, double* gather_data,
bool* is_root_pe, int* ishift, int* jshift, bool* convert_cf_order);
double* array_seg, double* gather_data, bool* is_root_pe,
int* gather_data_c_shape, int* ishift, int* jshift, bool* convert_cf_order);

extern void cFMS_get_compute_domain(int* domain_id, int* xbegin, int* xend, int* ybegin, int* yend,
int* xsize, int* xmax_size, int* ysize, int* ymax_size,
bool* x_is_global, bool* y_is_global, int* tile_count, int* position,
int* whalo, int* shalo);
int* xsize, int* xmax_size, int* ysize, int* ymax_size,
bool* x_is_global, bool* y_is_global, int* tile_count, int* position,
int* whalo, int* shalo);

extern void cFMS_get_data_domain(int* domain_id, int* xbegin, int* xend, int* ybegin, int* yend,
int* xsize, int* xmax_size, int* ysize, int* ymax_size,
bool* x_is_global, bool* y_is_global, int* tile_count, int* position,
int* whalo, int* shalo);
int* xsize, int* xmax_size, int* ysize, int* ymax_size,
bool* x_is_global, bool* y_is_global, int* tile_count, int* position,
int* whalo, int* shalo);

extern void cFMS_get_domain_name(char* domain_name_c, int* domain_id);

extern void cFMS_get_domain_pelist(int* npes, int* pelist, int* domain_id);

extern void cFMS_get_global_domain(int* domain_id, int* xbegin, int* xend, int* ybegin, int* yend,
int* xsize, int* xmax_size, int* ysize, int* ymax_size,
int* tile_count, int* position, int* whalo, int* shalo);
int* xsize, int* xmax_size, int* ysize, int* ymax_size,
int* tile_count, int* position, int* whalo, int* shalo);

extern void cFMS_get_layout(int* layout, int* domain_id);

extern int cFMS_root_pe();

extern void cFMS_set_compute_domain(int* domain_id, int* xbegin, int* xend, int* ybegin, int* yend,
int* xsize, int* ysize, bool* x_is_global, bool* y_is_global, int* tile_count,
int* whalo, int* shalo);
int* xsize, int* ysize, bool* x_is_global, bool* y_is_global, int* tile_count,
int* whalo, int* shalo);

extern void cFMS_set_current_domain(int* domain_id);

extern void cFMS_set_data_domain(int* domain_id, int* xbegin, int* xend, int* ybegin, int* yend,
int* xsize, int* ysize, bool* x_is_global, bool* y_is_global, int* tile_count,
int* whalo, int* shalo);
int* xsize, int* ysize, bool* x_is_global, bool* y_is_global, int* tile_count,
int* whalo, int* shalo);

extern void cFMS_set_global_domain(int* domain_id, int* xbegin, int* xend, int* ybegin, int* yend,
int* xsize, int* ysize, int* tile_count);
int* xsize, int* ysize, int* tile_count);

extern void cFMS_update_domains_double_2d(int* field_shape, double* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_double_3d(int* field_shape, double* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_double_4d(int* field_shape, double* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_double_5d(int* field_shape, double* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_float_2d(int* field_shape, float* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_float_3d(int* field_shape, float* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_float_4d(int* field_shape, float* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_float_5d(int* field_shape, float* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_int_2d(int* field_shape, int* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_int_3d(int* field_shape, int* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_int_4d(int* field_shape, int* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_update_domains_int_5d(int* field_shape, int* field, int* domain_id, int* flags, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_v_update_domains_double_2d(int* fieldx_shape, double* fieldx, int* fieldy_shape, double* fieldy,
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_v_update_domains_double_3d(int* fieldx_shape, double* fieldx, int* fieldy_shape, double* fieldy,
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_v_update_domains_double_4d(int* fieldx_shape, double* fieldx, int* fieldy_shape, double* fieldy,
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_v_update_domains_double_5d(int* fieldx_shape, double* fieldx, int* fieldy_shape, double* fieldy,
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_v_update_domains_float_2d(int* fieldx_shape, float* fieldx, int* fieldy_shape, float* fieldy,
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_v_update_domains_float_3d(int* fieldx_shape, float* fieldx, int* fieldy_shape, float* fieldy,
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_v_update_domains_float_4d(int* fieldx_shape, float* fieldx, int* fieldy_shape, float* fieldy,
int* domain_id, int* flags, int* gridtype, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* domain_id, int* flags, int* gridtype, int* complete,
int* position, int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_v_update_domains_float_5d(int* fieldx_shape, float* fieldx, int** fieldy_shape, float* fieldy,
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);
int* domain_id, int* flags, int* gridtype, int* complete,
int* whalo, int* ehalo, int* shalo, int* nhalo,
char* name, int* tile_count, bool* convert_cf_order);

extern void cFMS_sync();

extern int cFMS_define_cubic_mosaic(int* ni, int* nj, int* global_indices, int* layout, int* ntiles,
int* halo, bool* use_memsize);
int* halo, bool* use_memsize);

#endif
68 changes: 48 additions & 20 deletions c_fms/include/c_mpp_gather.inc
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
subroutine CFMS_GATHER_1D_(sbuf_size, rbuf_size, sbuf, rbuf, pelist, npes) &
subroutine CFMS_GATHER_1D_(sbuf_size, sbuf, rbuf, pelist, rbuf_size, npes) &
bind(C, name=CFMS_GATHER_1D_BINDC_)

implicit none
integer, intent(in) :: sbuf_size
integer, intent(in) :: rbuf_size
CFMS_GATHER_TYPE_, intent(in) :: sbuf(sbuf_size)
CFMS_GATHER_TYPE_, intent(inout) :: rbuf(rbuf_size)
type(c_ptr), intent(in), value :: rbuf
type(c_ptr), intent(in), value :: pelist
integer, intent(in), optional :: rbuf_size
integer, intent(in), optional :: npes

integer, pointer :: pelist_f(:) => NULL()
CFMS_GATHER_TYPE_, pointer :: rbuf_f(:) => NULL()

if(present(npes)) then
if(c_associated(pelist)) then
allocate(pelist_f(npes))
if(c_associated(rbuf)) then
if(present(rbuf_size)) then
call c_f_pointer(rbuf, rbuf_f, [rbuf_size])
end if
end if

if(c_associated(pelist)) then
if(present(npes)) then
call c_f_pointer(pelist, pelist_f, [npes])
end if
end if

call fms_mpp_gather(sbuf, rbuf, pelist=pelist_f)
call fms_mpp_gather(sbuf, rbuf_f, pelist=pelist_f)

nullify(pelist_f)
nullify(rbuf_f)

end subroutine CFMS_GATHER_1D_


subroutine CFMS_GATHER_PELIST_2D_(is, ie, js, je, npes, pelist, array_seg, gather_data_c_shape, gather_data, &
is_root_pe, ishift, jshift, convert_cf_order) bind(C, name=CFMS_GATHER_PELIST_2D_BINDC_)
subroutine CFMS_GATHER_PELIST_2D_(is, ie, js, je, npes, pelist, array_seg, gather_data, is_root_pe, &
gather_data_c_shape, ishift, jshift, convert_cf_order) bind(C, name=CFMS_GATHER_PELIST_2D_BINDC_)

implicit none
integer, intent(in) :: is, ie, js, je
integer, intent(in) :: npes
integer, intent(in) :: pelist(npes)
type(c_ptr), value, intent(in) :: array_seg
integer, intent(in) :: gather_data_c_shape(2)
type(c_ptr), value, intent(in) :: gather_data
logical(c_bool), intent(in) :: is_root_pe
integer, intent(in), optional :: gather_data_c_shape(2)
integer, intent(in), optional :: ishift
integer, intent(in), optional :: jshift
logical(c_bool), intent(in), optional :: convert_cf_order
Expand All @@ -54,8 +61,6 @@ subroutine CFMS_GATHER_PELIST_2D_(is, ie, js, je, npes, pelist, array_seg, gathe
end if
allocate(gather_data_f(gather_data_f_shape(1), gather_data_f_shape(2)))
call cfms_pointer_to_array(gather_data, gather_data_f_shape, gather_data_f, convert_cf_order)
else
allocate(gather_data_f(1,1)) !dummy
end if

call fms_mpp_gather(is+1, ie+1, js+1, je+1, pelist, array_seg_f, gather_data_f, logical(is_root_pe), ishift, jshift)
Expand All @@ -64,24 +69,47 @@ subroutine CFMS_GATHER_PELIST_2D_(is, ie, js, je, npes, pelist, array_seg, gathe
call cFMS_array_to_pointer(gather_data_f, gather_data_f_shape, gather_data, convert_cf_order)
end if

deallocate(gather_data_f)
if(allocated(gather_data_f)) deallocate(gather_data_f)

end subroutine CFMS_GATHER_PELIST_2D_

subroutine CFMS_GATHERV_1D_(npes, sbuf_size, rbuf_size, sbuf, ssize, rbuf, rsize, pelist) &

subroutine CFMS_GATHERV_1D_(sbuf_size, sbuf, ssize, rbuf, rsize, pelist, npes) &
bind(C, name=CFMS_GATHERV_1D_BINDC_)

implicit none
integer, intent(in) :: npes
integer, intent(in) :: sbuf_size
integer, intent(in) :: rbuf_size
CFMS_GATHER_TYPE_, intent(in) :: sbuf(sbuf_size)
integer, intent(in) :: ssize
CFMS_GATHER_TYPE_, intent(inout) :: rbuf(rbuf_size)
integer, intent(in) :: rsize(npes)
integer, intent(in), optional :: pelist(npes)
type(c_ptr), intent(in), value :: rbuf
type(c_ptr), intent(in), value :: rsize
type(c_ptr), intent(in), value :: pelist
integer, intent(in), optional :: npes

call fms_mpp_gather(sbuf, ssize, rbuf, rsize, pelist)
CFMS_GATHER_TYPE_, pointer :: rbuf_f(:) => NULL()
integer, pointer :: rsize_f(:) => NULL()
integer, pointer :: pelist_f(:) => NULL()
logical :: npes_defined

npes_defined = present(npes)

if(c_associated(rbuf)) then
if(.not.c_associated(rsize)) call fms_mpp_error(FATAL, "must specify receiving sizes for receiving pe")
if(.not.npes_defined) call fms_mpp_error(FATAL, "must specify number of receiving/sending pe's")
call c_f_pointer(rsize, rsize_f, [npes])
call c_f_pointer(rbuf, rbuf_f, [sum(rsize_f)])
end if

if(c_associated(pelist)) then
if(.not.npes_defined) call fms_mpp_error(FATAL, "must specify the number of pe's when specifying pelist")
call c_f_pointer(pelist, pelist_f, [npes])
end if

call fms_mpp_gather(sbuf, ssize, rbuf_f, rsize_f, pelist_f)

nullify(rbuf_f)
nullify(rsize_f)
nullify(pelist_f)

end subroutine CFMS_GATHERV_1D_

Expand Down
Loading
Loading