Ice Sheet System Model  4.18
Code documentation
PartitionRange.cpp
Go to the documentation of this file.
1 
5 #ifdef HAVE_CONFIG_H
6  #include <config.h>
7 #else
8 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
9 #endif
10 
11 #include <math.h>
12 
13 void PartitionRange(int* pi0,int* pi1, int num_el,int num_threads,int my_thread){
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 }
PartitionRange
void PartitionRange(int *pi0, int *pi1, int num_el, int num_threads, int my_thread)
Definition: PartitionRange.cpp:13