- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is the code:
program main implicit none character(:), allocatable :: i write(*,*)["1","1"//"2"] i="2" write(*,*)["1","1"//i] end program
I expect this two write will give the same results. But the first one gives ["1 ","12"] while the second one truncate "1"//i to "1". I know this may due to the fact that at compile time compiler can not estimate the length of "1"//i so it make the length with the longest length it can measure (which is one in this case). I think this is quite unexpected and compiler should warn about it or just raise an error.
Link Copied
- « Previous
-
- 1
- 2
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the links. Both are very interesting.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve Lionel (Intel) wrote:
Um, UDDTIO is just for I/O - it has no other purposes. Ian was just saying that you can treat these "variable string types" as normal variables in READ/WRITE with a suitable UDDTIO procedure.
Steve,
You may also want to point out the acronym UDDTIO is not part of the standard, that any such naming might have been popularized by some on the committee in the internal/external communications but it is not an 'official' term. Based on my check the standard only says "Defined input/output procedures" which is explanatory enough, I suppose.
Separately, you would have long noticed the employment of derived types (DT) to provide a variety of additional string type of functionalities beyond the intrinsic CHARACTER facility is common, including as suggested by IanH in this thread. A common theme among Fortranners is the CHARACTER substring designator syntax with : is very neat and the users would also like to use it with any DT solution for string types.
Would you know if the standard committee aware of this and do you think there is any possibility that such a feature might tabled for consideration for the next revision i.e., the one AFTER Fortran 2015? That is, would the standard committee be open to the idea of DEFINED DESIGNATOR bindings to DTs in a future standard, similar to defined operators which is provided in the current standard? If not, if they have other ideas and proposals to benefit the users. More specifically, I am asking if Intel reps can take this into consideration and bring it up on behalf of users such as me when the time is appropriate?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't recall discussion of an idea such as that. I will pass it on to our other representatives (since my time on the committee is short.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey guys,
I found another strange behaviour that related to variable length character array, here is the code:
program main implicit none character(:), allocatable :: i i="2" write(*,*)["1","1"//i] ! truncated write(*,*)["1",i//i] ! truncated write(*,*)["1",i,i//i] ! not truncated end program
as you can see, the last write actually gives ["1 ","2 ","22"]. Why not give ["1","2","2"] as discussed before?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »