[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20050202: netCDF C++ - Why is static valiable used in NcVar::put function?



Hello Russ Rew san.

Thank you for your quick answer.

Russ Rew <address@hidden> wrote:

>|>To: address@hidden
>|>From: "Masahiro Miiyaki" <address@hidden>
>|>Subject: netCDF C++ - Why is static variable used in NcVar::put function?
>|>Organization: WeatherNews Inc.
>|>Keywords: 200502021156.j12BuUFh022284 netCDF C++
>|
>|Hi Masahiro Miiyaki,

-<cut>-

>|> Why is the static variable used in this macro?
>|
>|There is no good reason, it looks like a mistake.  If you delete the
>|"static" and the initialization to {0, 0, 0, 0, 0}, I think it will
>|still work as intended:
>|
>|    long start[5];                                                          \
>|    for (int j = 0; j < 5; j++) {                                           \
>|     start[j] = the_cur[j];                                                 \
>|    }                                                                       \
>|
>|Thanks for pointing out the error.  Please let us know if this fix
>|works.

I see. I promise you to report whether there is a problem
in this fix.

>|There may be other problems with trying to make the C library
>|thread-safe, since there are several global data structures, e.g. the
>|list of open netCDF files declared in libsrc/nc.c:
>|
>|  /* list of open netcdf's */
>|  static NC *NClist = NULL;

Thanks. I know. I added the mutex_lock code into nc_open,nc_create
and nc_close. And also locked in the NC_ckeck_id function.

>|Also, you should not expect to be able to do multiple concurrent
>|writes on the same open file.

I don't expect multiple concurrent writes. I will be inhibit the
cocurrent access to the same file. 

The requirement of the program which I am making now is that many
of thread can access the different netCDF file at the same time.

>|I would be interested in whether you have success making it work for
>|multiple threads.

I will report you that this plan succeeded.

Regards,
Masahiro Miyaki.