- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd like to know what if the value of a loop variable after the loop is defined. I'd like to determine if a loop was terminated by exit or not. Currently I use the following code, which works fine:
do iDim=1, size(STRDIM,1)
if (STRDIM(iDim)==strTokBuf(1)) exit
end do
if (iDim==4) then
call Panic("unsupported keyword: $VAL1$", strTokBuf(1))
end if
were STRDIM is a global variable defined as:
character(LEN=*), parameter :: STRDIM(3) = (/"COLUMN", &
"ROW ", &
"LAYER "/)
If the loop did not exit prematurely the value of the loop variable is size(STRDIM,1)+1.
Is this always true according to the fortran standard?
do iDim=1, size(STRDIM,1)
if (STRDIM(iDim)==strTokBuf(1)) exit
end do
if (iDim==4) then
call Panic("unsupported keyword: $VAL1$", strTokBuf(1))
end if
were STRDIM is a global variable defined as:
character(LEN=*), parameter :: STRDIM(3) = (/"COLUMN", &
"ROW ", &
"LAYER "/)
If the loop did not exit prematurely the value of the loop variable is size(STRDIM,1)+1.
Is this always true according to the fortran standard?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the f77 standard introduced this requirement. http://www.fortran.com/fortran/F77_std/f77_std.html
I have not seen a compiler in 15 years which did not implement it.
I have not seen a compiler in 15 years which did not implement it.

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