slcs-jsc / mptrac

Massive-Parallel Trajectory Calculations (MPTRAC) is a Lagrangian particle dispersion model for the analysis of atmospheric transport processes in the free troposphere and stratosphere.
GNU General Public License v3.0
35 stars 14 forks source link

bug in netCDF grid output? #33

Closed lars2015 closed 6 months ago

lars2015 commented 7 months ago

Hi Mingzhao,

there is a bug in the netCDF grid output, I think.

When you use strcat() to build the netCDF variable names, it will overwrite the original data of the ctl struct. So the code crashes here with a netCDF error message:

https://github.com/slcs-jsc/mptrac/blob/8dee3a1775f66c95e8afaf3b671f3f9fb5fdadfa/src/libtrac.c#L6736

You need to create a new string to make this work, e.g.

char varname[LEN];
sprintf(varname, "%s_mean", ctl->qnt_name[...]);
NC_PUT_DOUBLE(varname, help, 0); 

Can you please take a look?

Thanks Lars

lars2015 commented 6 months ago

Fixed this.