/* -------------------------------------------------------------------- *\ DDI_Create(idim,jdim,handle) ============================ [IN] idim - Number of rows in the array to be created. [IN] jdim - Number of columns in the array to be created. [OUT] handle - Handle given to the newly created array. Creates a distributed array with the columns evenly divided amongst the processors. \* -------------------------------------------------------------------- */ void DDI_Create(int idim,int jdim,int *handle) { /* --------------- *\ Local Variables \* --------------- */ int i,np,me; int icol,mincol,lftcol; int jcols[MAX_PROCESSORS]; const DDI_Comm *comm = (const DDI_Comm *) Comm_find(DDI_WORKING_COMM); DEBUG_ROOT(LVL1,(stdout," DDI: Entering DDI_Create.\n")) DEBUG_OUT(LVL3,(stdout,"%s: Entering DDI_Create.\n",DDI_Id())) np = comm->np; me = comm->me; /* if(jdim < np && me == 0) { fprintf(stdout," DDI Error: Trying to create an array with fewer columns than processors.\n"); fprintf(stdout," DDI Error: Reduce the number of processors and try again.\n"); Fatal_error(911); } */ mincol = jdim / np; lftcol = jdim % np; for(i=0,icol=0; i<np; i++) { jcols[i] = icol; icol += mincol; if(i<lftcol) icol++; } DDI_Create_custom(idim,jdim,jcols,handle); DEBUG_ROOT(LVL2,(stdout," DDI: Array[%i] successfully created.\n",*handle)) }
/* ------------------------------------- *\ FORTRAN Wrapper for DDI_Create_custom \* ------------------------------------- */ void F77_Create_custom(int_f77 *idim, int_f77 *jdim, int_f77 *jcols, int_f77 *handle) { int ihandle,i,np,me; int ijcols[MAX_PROCESSORS]; DDI_NProc(&np,&me); for(i=0; i<np; i++) ijcols[i] = (int) *jcols; DDI_Create_custom( (int) *idim, (int) *jdim, ijcols, &ihandle ); *handle = (int_f77) ihandle; }