Re: Create custom output file

From: Yves Revaz <yves.revaz_at_epfl.ch>
Date: Mon, 27 Feb 2017 08:48:43 +0100

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
---------------------------------------------------------------------
Received on 2017-02-27 08:48:48

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