Re: Create custom output file

From: Jesus <jesusms_at_astro.ucla.edu>
Date: Tue, 28 Feb 2017 15:50:38 -0800

Thank you Yves, your suggestion worked like a charm.


-Jesus



On Feb 26, 2017, at 11:48 PM, Yves Revaz wrote:

> On 25/02/17 03:48, Jesus wrote:
>>
>> Hello all,
>> I have created a function in Gadget2 that calculates a velocity increment (dv), and I add this increment on the file timestep.c every 100 timesteps.
>> However, I'd like to know if my function is actually doing what I want, so I want to output a file that writes "dv1, dv2, dv3".
>> What I did was to add this immediately after I calculate dv on timestep.c, on the advance_and_find_timesteps function:
>>
>> if (ThisTask ==0)
>> {
>> fprintf( t_out, "%e, %e, %e, %e, %e, %e\n", P[i].Pos[0], P[i].Pos[1], P[i].Pos[2], dv1, dv2, dv3 ) ;
>> }
>
> Dear Jesus,
>
> As you wrote it, only the particles hosted on the master task will be written (ThisTask ==0).
> You can avoid this problem by opening one file by task, adding for example .n at the end of the
> filename (where n=ThisTask) to differentiate them, and then remove the if (ThisTask ==0).
>
> Cheers,
>
> yves
>
>>
>> The file is created and the values are written, but it only writes 1400 values (out of 20,000 particles). I am not sure how to fix this so that all the 20,000 values are written. If I remove the if statement, the code crashes, saying "Segmentation fault: 11. Signal code: Address not mapped"
>>
>> If anyone has any suggestions, please let me know.
>> Thank you very much.
>>
>> -Jesus
>>
>
>
> --
>
> ---------------------------------------------------------------------
> Dr. Yves Revaz
> Laboratory of Astrophysics
> Ecole Polytechnique Fédérale de Lausanne (EPFL)
> Observatoire de Sauverny Tel : +41 22 379 24 28
> 51. Ch. des Maillettes Fax : +41 22 379 22 05
> 1290 Sauverny e-mail : Yves.Revaz_at_epfl.ch
> SWITZERLAND Web : http://people.epfl.ch/yves.revaz
> ---------------------------------------------------------------------
>
> -----------------------------------------------------------
>
> If you wish to unsubscribe from this mailing, send mail to
> minimalist_at_MPA-Garching.MPG.de with a subject of: unsubscribe gadget-list
> A web-archive of this mailing list is available here:
> http://www.mpa-garching.mpg.de/gadget/gadget-list
Received on 2017-03-01 00:50:19

This archive was generated by hypermail 2.3.0 : 2023-01-10 10:01:32 CET