Ice Sheet System Model  4.18
Code documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Functions
PartitionRange.cpp File Reference

: return i0,i1, range of local thread. More...

#include <math.h>

Go to the source code of this file.

Functions

void PartitionRange (int *pi0, int *pi1, int num_el, int num_threads, int my_thread)
 

Detailed Description

: return i0,i1, range of local thread.

Definition in file PartitionRange.cpp.

Function Documentation

◆ PartitionRange()

void PartitionRange ( int *  pi0,
int *  pi1,
int  num_el,
int  num_threads,
int  my_thread 
)

Definition at line 13 of file PartitionRange.cpp.

13  {
14 
15  /*output: */
16  int i0=-1;
17  int i1=-1;
18 
19  int step;
20  int i;
21 
22  /*distribute elements across threads :*/
23  step=(int)floor((double)num_el/(double)num_threads);
24  for(i=0;i<(my_thread+1);i++){
25  i0=i*step;
26  if(i==(num_threads-1))i1=num_el;
27  else i1=i0+step;
28  }
29 
30  /*Assign output pointers:*/
31  *pi0=i0;
32  *pi1=i1;
33 }