-
Notifications
You must be signed in to change notification settings - Fork 17
Auto-allocating processor messages #160
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
Comments
Uncharacteristically for Fortran, this proposal would change the behavior of some current conforming programs. I suggested at the J3 meeting that the change be restricted to only automatically allocate deferred-length The case that worries me the most is that of internal writes to allocatable EDIT: sample program whose behavior will change:
|
@klausler wrote:
Can you please cross-check again with the relevant committee folks about this? My understanding is different from yours, that the internal write to an already allocated allocatable character scalar will retain its length when the number of transferred characters during said write is less than the allocated length of the scalar variable. So I expect the output of your sample program to remain as 10. Please note the following, especially the bullet starting with 'otherwise', from paper https://j3-fortran.org/doc/year/20/20-122r1.txt:
|
It's the first bullet point that's relevant. |
I think the authors in paper 20-122r1 meant to state in the first bullet, "If the internal file is an unallocated allocatable, deferred-length character scalar variable, it becomes defined as if by intrinsic assignment of the record." This aspect was discussed in the previous paper they referenced, https://j3-fortran.org/doc/year/18/18-279r1.txt:
|
That would be better, but I asked specifically in the plenary meeting on Friday whether the proposal that was passed from JOR would invalidate current Fortran programs in the case of allocated deferred-length allocatable |
@klausler this is what I recall from plenary as well. Personally I'm ok with this behavior, as it's what happens with intrinsic assignment already, but I'd be curious to hear from the community if they consider it undesirable. |
The "as if by intrinsic assignment" means that yes, the variable would be reallocated. And as @klausler says, the committee said that it was intended for that to be the case. Their contention was that in the majority of cases, it probably wouldn't outwardly change behavior because the use cases probably are already reallocating it immediately afterward as workaround to the fact that it isn't done automatically already. If you know of any cases where the intended behavior is to allocate a character and use internal IO to write into it without it being reallocated, now is the time to speak up, because this will cause a change in behavior. Personally, I agree with the committee, that the new behavior is probably always what was desired anyway. |
I'm really uncomfortable with changing this behavior for internal writes because it breaks a long-standing correspondence between internal writes and fixed-length I/O. Internal writes to |
My view on this is that it is very unusual for current programs to use deferred-length allocatable character variables for this. Most will use fixed-length character and those will not change. We had many, many requests for this feature in the 202X survey. Please also note that for the internal WRITE case, the new behavior applies to scalars only, since Fortran doesn't have "ragged arrays". |
The feature should be limited for internal |
This feature is to address certain cases which require programmers to provide already-allocated strings of sufficient length, but the standard provides no mechanism to determine that length.
The text was updated successfully, but these errors were encountered: