-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ncdispatch.h needs to be split into an installed, public header, and an uninstalled private header #1426
Comments
This is clearly an error. I assume that netcdf.h is making references |
No, it's not an error. In order to use the user-defined format feature, the user must have access to the definition of the dispatch table. However, this is not referenced from netcdf.h. It's only needed for users (like me, with PIO) who are writing a dispatch layer and using nc_def_user_format() to use it. Yes, I can and will separate the minimum items that need to be in the public file. |
I see. You are correct, sorry. For consistency, |
OK, will do. |
OK, we now have a netcdf_dispatch.h and it seems to be working well. But there is a problem in that the open and create calls both use pointers to NC (the final parameter for both calls):
The code in dfile.c is:
So the code is written to allow dispatch layers to modify the contents of NC. But do they? The HDF5 layer only sets int_ncid (which may not be necessary) and check the value of (nc->model->iosp == NC_IOSP_HTTP) in open. I think without too much trouble, we could remove the NC from the open/create call, and just use ncid. That way, we would not have to expose the NC struct to people using the dispatch layer. @DennisHeimbigner what do you think? Shall I give this a whack and see how it looks? |
The design is this. It is assumed that the NC structure The goal was to centralize as much of the NC manipulation as possible. |
Questions remain:
|
Another way to look at it is that the dispatch->open function |
1 - If the function parameter is ncid (from ext_ncid) then any dispatch layer that needs to can look up the NC. But those that don't need to, don't have to know about NC. Surprisingly (for me) I think this includes libhdf5, so perhaps no dispatch layer has to know about NC. 2 - Not sure what you mean by dispatch-specific state. You mean all the other values in NC? Seems like we are not really setting them in the dispatch layer much. 3 - int_ncid is used by libsrc. When built with --disable-netcdf-4, then int_ncid is all there is. But when netCDF-4 is used, int_ncid is the internal ID of classic files (which also get a different ext_ncid). This is so that the user can open a netCDF-4 file, then open a classic file, and not have conflicting ncids. I am going to investigate whether it even needs to be set for libhdf5 code. I believe it does not. (Also int_ncid is used by the pnetcdf layer, libsrcp. It's for the same reason as it is used by the classic C layer. Pnetcdf assigns its own IDs and we must keep them separate from the IDs assigned by the netCDF-4 code, to prevent conflicts.) |
I have examined the code and indeed setting int_ncid by the libhdf5 layer is unnecessary. I have removed it. PR up shortly. This is worth doing independently from the dispatch work, just to reduce code complexity and confusion... |
WRT int_ncid, it is set in most of the dispatchers |
I believe int_ncid is not necessary for most dispatch layers, but it certainly is for pnetcdf and libsrc. My ides is not to eliminate it, or move it, but simply to first remove it wherever it is not really needed. This will simplify the situation. It is set (but not used, apparently) in libdap2 and libdap4. Can it be removed there too? |
OK, removing int_ncid worked fine. Now we have one remaining use of NC on libhdf5. In nc4_open_file() we have this code:
(I have asked some questions about --ebable-byterange in #1446.) One immediate thought is that the flag checking can probably be done in libdispatch in this case (with the rest of the flag checking that occurs there). Parameters should not silently be set to NULL. If the user attempts this with parallel I/O they should get an error (parallel programming is already too hard!). This too can probably be checked in libdispatch. As for the setting of iosp, I have looked at how this is used, but can't yet figure out if this could be set at the libdispatch layer. |
OK, I see how NC * can be easily taken out of the create/open dispatch functions. Create the NC object, but instead of passing a pointer to it, pass the ncid that has been assigned to the file (the ext_ncid). If the code needs it (as the open does for HDF5, due to the enable-byterange stuff, or as the pnetcdf open and create need to), then either find_nc_h5() or NC_check_id() is used to find the NC from the ncid. In this way, the NC struct can be hidden within netCDF internals, and not exposed in the dispatch layer. |
@DennisHeimbigner when you say "dispatch state" do you mean the dispatchdata field in NC? Seems like only the pnetcdf layer uses that. |
I do not believe that is accurate. All of the dispatch directories use it |
As I try to use the user-defined format feature to support PIO/netCDF integration, I see that user-defined formats will not work unless the ncdispatch.h file is installed with netcdf.h.
This is not a big deal, but the ncdispatch.h file contains a bunch of internal stuff too - stuff that should not be exposed in a public header.
I will submit a PR shortly.
The text was updated successfully, but these errors were encountered: