phys_buffer also provides public access to the derived pbuf field so there is code throughout cam physics that looks like:
real(r8), pointer, dimension(:,:) :: iciwpconv iciwpconv => pbuf(iciwpconv_idx)%fld_ptr(1,1:pcols,1:pver,lchnk, 1) |
The current pbuf API has several limitations that we would like to overcome.
(eaton, 4/5/11) I agree with this.
The functionality of cam_history_buffers is very similar to that of phys_buffers - I would propose that a replacement be created with an eye toward replacing both.
(eaton, 4/5/11) Not sure about this. Do you think that cam_history could directly use the pbuf?
(edwards, 4/8) I did, but the current discussion has moved away from that idea.
(eaton, 4/5/11)
I don't see a need for pbuf_add_dim. That's a cam_history kind of functionality that isn't needed for the pbuf. The user of pbuf should never need to refer to the pbuf dimensions by name, or by an id. Only by size, just like for a Fortran array.
What is the 'decomp' arg of pbuf_add_var for?
I think it's reasonable to assume that pcols will be the first index of the data array. But I'm wondering whether we want to include the begchunk:endchunk dimension as part of the data array, or whether we should allocate the pbuf array with a begchunk:endchunk dimension so that it could be treated more like the physics state.
- if we use pbuf(:)%fld_ptr(...,begchunk:endchunk) then the user needs to supply the chunk index to access the data.
- if we use pbuf(:,begchunk:endchunk)%fld_ptr(...) then we can pass the chunk array sections from a high level (like state), and the user wouldn't need to be constantly accessing the chunk index from state in order to access info in the pbuf. If we do this then pbuf would no longer be a module variable, rather it would be something defined in a high level routine - cam_comp.F90 as is phys_state. But I don't think it should be pbuf(:, begchunk:endchunk) - I think I'd rather see pbuf(begchunk:endchunk)%field(:)%fld_ptr
I'm not sold on pbuf_get_var_copy. I haven't seen any need for this to date. I'd prefer to have a minimal interface and require the user to copy data outside the pbuf interface if that's needed.
I think the pbuf_get method should return a pointer to the entire field by default, but provide optional array args, start/end, to allow access to an array subsection.
(eaton, 4/6/11)
Our discussion today largely focussed on the restart capability. One of the things I really like about the original pbuf design is that the user didn't need to be concerned about restart – as long as the pbuf field was 'global' scope it would end up in the restart file. I'd like to maintain this simplicity which is why I'm not in favor of the pbuf_add_dim method which requires the user to think about something that's only relevant for the restart file.Here's another idea. What about removing all the restart methods from the pbuf module and just passing pbuf as an argument to the restart_physics methods. Let restart_physics be entirely responsible for getting the global pbuf fields to the restart file. This would be similar to what's currently done for the cam_out export fields which are also dealt with directly by the restart_physics methods.
Franis has convinced me that 'physpkg' and 'global' scope are not as obvious as using a terminology that implies fields are persistent or not (like the argument in Jim's proposed pbuf_add_var method). Scope is more a programming concept that most physical scientists aren't familiar with.