- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I've updated a code that I'm working on and something caught my attention. I tried to use dot operator to access some data in a custom type (I was working on C++ just before) and the code... just compiled.
I cannot find anything that says that dot operator has the same function as the percentage operator, except in some old non-standard fortran compilers.
There were some changes in the Fortran standard that allows the dot operator as type accessor?
The following code compiled just fine with ifort 19.0.5, x86, Windows 10.
program DotOperatorTest implicit none type :: mytype real(8) :: a, b integer(4) :: i, k end type type(mytype) :: foo foo%a = 1.5 foo.b = 2.0 foo.i = int(foo.a * foo%b * 3) foo%k = foo%i / foo.b write(*,'(A,g0)') 'a equals to ', foo%a write(*,'(A,g0)') 'b equals to ', foo.b write(*,'(A,i0)') 'i equals to ', foo.i write(*,'(A,i0)') 'k equals to ', foo%k pause end program DotOperatorTest
Returning
a equals to 1.500000000000000 b equals to 2.000000000000000 i equals to 9 k equals to 4 Fortran Pause - Enter command<CR> or <CR> to continue.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The use of '.' in place of '%' to demarcate components of derived types is a DEC/Compaq/Intel non-standard extension. Its use can make your code behave in odd ways if the code also employs components named 'EQ', 'AND', etc.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The use of '.' in place of '%' to demarcate components of derived types is a DEC/Compaq/Intel non-standard extension. Its use can make your code behave in odd ways if the code also employs components named 'EQ', 'AND', etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As mecej4 says. Put standards checking on (a good plan with new code) and it will get thrown out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, I see. I was not expecting that new projects have portability options enabled by default.
Thanks.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page