Thanks guys, and I will switch over to binary.  Just saying, that's what 2013b 
is doing.

-gideon

On Nov 30, 2013, at 4:12 PM, Jed Brown <[email protected]> wrote:

> Gideon Simpson <[email protected]> writes:
> 
>> If each realization generated a size n output, is there something slicker 
>> than this:
>> 
>> VecGetOwnershipRange(sim_data, &local_start, &local_end);
>> 
>> VecGetArray(sim_data,& sim_data_local);
>> k=0;
>> 
>> m_local = (local_end - local_start-1)/n;
> 
> local_end is one past the last owned entry.
> 
>> for(i=0;i< m_local;i++){
>> 
>>   mc_sim_cod(mc_args, &sim_result);
>> 
>>   for(k = 0;k<n;k++){
>> 
>>      sim_data_local[i * n + k] = sim_result[k];
>>   }
>> 
>> }
> 
> You can drop the result directly into the array:
> 
>  for (i=local_start; i<local_end; i+=n) {
>    mc_sim_cod(mc_args, sim_data_local+(i-local_start));
>  }
> 
>>> Did MATLAB change their ASCII format?
>> 
>> Here's a quick test on 2013b:
>> v = linspace(0,1,5);
>> save('test.out', 'v', '-ascii');
>> 
>> test.out looks like:
>>   0.0000000e+00   2.5000000e-01   5.0000000e-01   7.5000000e-01   
>> 1.0000000e+00
> 
> ASCII_MATLAB output is meant to be sourced:
> 
> v = [
> 0.0000000e+00
> 2.5000000e-01
> 5.0000000e-01
> 7.5000000e-01
> 1.0000000e+00
> ];
> 
>>> Anyway, it is much better to write binary output and read with
>>> PetscBinaryRead (bin/matlab/PetscBinaryRead.m).
> 
> But seriously, use binary.

Reply via email to