; This function is for use with multi-processing (i.e. splitting an job ; over multiple CPUs). It is meant to be used in conjunction with ; mp_get_procnum. ; ; The function takes the process number (from mp_get_procnum), the total number of processes ; (same as what was given to mp_get_procnum), the total entries that need to be split up ; over the processes (i.e. the number of elements in an array that's being split up). ; ; The function modifies the variables start_index and end_index, setting them to indicate an ; a range of the array that this process should work on. ; ; See the example in mp_get_procnum.pro. function mp_get_entries_to_process, my_procnum, total_procs, total_entries, start_index, end_index num_to_crank = intarr(total_procs) remaining_obsv = total_entries remaining_procs = total_procs ; Figure out how many observations each process should crank. ; Splitting this up evenly will speed things up. for proc_index=0,total_procs-1 do begin num_to_crank[proc_index] = ceil(remaining_obsv / remaining_procs) remaining_obsv = remaining_obsv - num_to_crank[proc_index] remaining_procs = remaining_procs - 1 endfor my_num_to_crank = num_to_crank[my_procnum-1] if (my_procnum eq 1) then begin start_index = 0 endif else begin start_index = total(num_to_crank[0:my_procnum-2]) endelse end_index = MIN([start_index + my_num_to_crank - 1, total_entries - 1]) end