 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Mon Mar 30, 2015 10:53 am Post subject: |
|
|
Intel ifort defines 3 source forms; fixed, free and tab.
The tab form appears to be an adaptation of the fixed form and describes a special interpretation of the tab character in columns 1 to 5 then subsequent tabs appear to be associated with columns 9, 18, 27 etc, using an 8 space field. (can't guarantee I have this correct as I have never used this approach.)
I have found when receiving tab form source, other IDE's and compilers do not recognise this source form and so it must have limited portability.
In the old Lahey F95 compiler I have, I can't find any reference to the use of tab characters in source. It may treat it as any number of spaces.
If tabs were interpreted as 3 spaces, I probably would have adopted it for DO loop indentation many years ago, but 8 spaces is too much.
They simply cause confusion when skipping between IDE's, so my old line editor that I used in 80's removes them.
I am certainly not recommending FTN95 adopts this form, which I can't find in any Fortran standard.
John |
|
Back to top |
|
 |
IanLambley
Joined: 17 Dec 2006 Posts: 506 Location: Sunderland
|
Posted: Mon Mar 30, 2015 12:44 pm Post subject: |
|
|
Tabs are dangerous - I never use them. I nearly always use fixed format due to my advancing age and use the following scheme:
1. Statement and format numbers have 4 digits: type <space> and the number then <space> and carry on with the line
2. Continuation lines: 5*<space> <apersand>
3. Indentation +-2 spaces per level.
4. Normal lines: 6*<space> then the indentation then the line.
I posted a fix for tabbed files some years ago, see:
http://forums.silverfrost.com/viewtopic.php?t=785&highlight=untab
Ian |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2403 Location: Yateley, Hants, UK
|
Posted: Mon Mar 30, 2015 12:56 pm Post subject: |
|
|
Mecej4, thanks for the clarification. So, if you have IMPLICIT NONE (implicitly or explicitly) then all your function names that are provided in separate source files need to have their type declared somehow? How do you know what is in scope until linking if you have separately compiled files? I'm too old a dog for this new trick.
Dan, TABs were always an extension. On IBM model 26 and 29 card punches, you could press the TAB key, but it always gave you spaces by advancing the card in the punch.
My recollection is that Hollerith cards used a 6-bit code, thus excluding many control characters in the resulting 64-character set. The TAB character wasn't part of the character set. We Brits often used 8-hole punched tape, giving us a 7-bit code allowing 128 characters (the 8th hole was used for a parity check as the punches weren't reliable). This opened up a whole range of extra characters, including control characters, and the adoption of terminal-based systems allowed 256-character codes with even more.
Thus, TAB is original sin, no matter how useful it has been.
Eddie |
|
Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Mon Mar 30, 2015 1:13 pm Post subject: Re: |
|
|
Eddie wrote: | So, if you have IMPLICIT NONE (implicitly or explicitly) then all your function names that are provided in separate source files need to have their type declared somehow? How do you know what is in scope until linking if you have separately compiled files? |
The IMPLICIT statement was added in Fortran-77. Most F77 compilers also supported the MIL-STD-1753 extensions, which included IMPLICIT NONE.
The scope of variables in F77 is the program unit (main program, subroutine, function, block data). This is also true of Fortran 90 and later versions if we do not use modules. Whether the program units are in the same or different files does not matter since, unlike in C, variables are declared inside a program unit and do not have file scope.
Here is an example. Try it as is and then try it after commenting out the type declaration of the function SQR in the main program.
Code: |
program ximp
implicit none
real :: x,y,sqr
!
x=2.0
y=sqr(x)
write(*,*)x,y
end program ximp
!
function sqr(x)
implicit none
real :: x,sqr
!
sqr=x*x
return
end function |
Eddie wrote: | On IBM model 26 and 29 card punches, you could press the TAB key, but it always gave you spaces by advancing the card in the punch. | Indeed. You could punch a tab control card with holes in the columns where you wanted tab stops, mount that card on the drum in the keypunch machine (see http://www.columbia.edu/cu/computinghistory/029-drum.jpg ), and from then on each press of the SKIP (=tab) key would advance the punch head to the next tab stop. We used to carry a set of these curled-up cards, one for Fortran, another for Algol, etc. With the Fortran tabs card mounted, after a new card was fed you would press SKIP, and the punch head would then be in column-7 -- a lot quicker than typing six blanks. When you wanted something in columns 1-6, you typed that in instead of pressing SKIP.
Last edited by mecej4 on Tue Mar 31, 2015 1:51 am; edited 2 times in total |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2403 Location: Yateley, Hants, UK
|
Posted: Mon Mar 30, 2015 1:54 pm Post subject: |
|
|
OK, I see how it reports the error. An education for me.
I can't help but feel that with every passing iteration, Fortran looks more like Algol, but never quite gets there.
Thanks for the reminder about how the tabs were set, I'd forgotten. I preferred the modernist look of the 029 to the Art Deco Cinema look of the 026, but I expect that the guts were the same.
Eddie |
|
Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Mon Mar 30, 2015 5:22 pm Post subject: |
|
|
The Generic utility that John Silver referred to has no bearing on the FTN95 error message regarding the colon. To see that, change the code of the loop to the following:
Code: | DO i = 1, NUMBlevsZ (izs)
C_Sum = 0
Do j = 1, NUMBlevsZ (izs+1)
C_Sum = C_Sum + Ct_Hull(j,i,IZSp1) (RELAB(IZSp1,iii)+1e-7)
enddo
enddo
| I have simplified the expression, and shortened the variable names, so no continuation line is needed and there is no line that is longer than 72 characters. However, as in Dan's example code, wherein tab expansion moved the '/' operator to a position beyond column 72, I have left out the '/' operator that should have been present between the adjacent parentheses.
The compiler again gives the error message involving the mysterious colon. This is simply another instance of a compiler not quite giving a clear diagnosis when the input code is in error, and I do not think that we should complain loudly in such instances. |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Mon Mar 30, 2015 11:44 pm Post subject: |
|
|
Dan,
I downloaded your file defect.for and listed it with my utility to expose control characters. It lists as: Code: | [31] integer NUMBlevsZ (100)<CR><LF>
[36] real*4 RELABex (100,100,100)<CR><LF>
[36] real*4 Ct_Hull (100,100,100)<CR><LF>
[ 1] <CR><LF>
[27] <HT>DO i = 1, NUMBlevsZ (izs)<CR><LF>
[16] <HT> Ctbr_Sum = 0<CR><LF>
[31] <HT> Do j = 1, NUMBlevsZ (izs+1)<CR><LF>
[66] <HT> Ctbr_Sum = Ctbr_Sum + RELABex(j,IZSp1,III)* Ct_Hull(j,i,IZSp1)/<CR><LF>
[39] * (RELABexSUM(IZSp1,iii)+1.e-7)<CR><LF>
[ 8] <HT> enddo<CR><LF>
[ 6] <HT>enddo<CR><LF>
[ 4] <HT>end
|
If I replace all <HT> with 8 spaces, I get Code: | integer NUMBlevsZ (100)
real*4 RELABex (100,100,100)
real*4 Ct_Hull (100,100,100)
DO i = 1, NUMBlevsZ (izs)
Ctbr_Sum = 0
Do j = 1, NUMBlevsZ (izs+1)
Ctbr_Sum = Ctbr_Sum + RELABex(j,IZSp1,III)* Ct_Hull(j,i,IZSp1)/
* (RELABexSUM(IZSp1,iii)+1.e-7)
enddo
enddo
end
|
Note that the / on line 8 is in column 73 so the expanded line 8 really looks like Code: | Ctbr_Sum = Ctbr_Sum + RELABex(j,IZSp1,III)* Ct_Hull(j,i,IZSp1)
* (RELABexSUM(IZSp1,iii)+1.e-7)
|
Including compile option /WIDE removes the error message, confirming the interpretation of <HT> replacement.
I tried the compile option /no_truncate but the colon error was again reported.
The devilry is in the "hidden" code, those dastardly tabs
John |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Tue Mar 31, 2015 12:51 am Post subject: |
|
|
Eddie,
From memory the 029 was much preferred to the 026, as it had more capabilities. I just can't remember what those capabilities were !
Just about every day, I would catch the bus to uni, go to the physics building, pick up the overnight run, go to the card punch room in the basement and look to see if there were any 029 desks free. It almost never happened ! Always too late. Never a thought about indenting do loops in those days, just hoping there were no typing errors, or another day lost.
Back to tabs; there are two possible interpretations. FTN95 appears to replace the tab with 8 spaces, while other interpretations move the next character to the size 8 grid or what ever the spacing is.
I just tried notepad, which has the grid approach, but the column count in the status bar does not agree.
Further, I opened Dan's defect.for in PLATO and it does not display the tabs in a way that FTN95 interprets. This is a problem ?
John |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2927 Location: South Pole, Antarctica
|
Posted: Tue Mar 31, 2015 10:39 am Post subject: |
|
|
You are right, guys, this / is in column 73. But how this happened? I checked that twice and saw it at reliably below of that (and i always care about that limit with the eagle eye) ? Don't understand that...Still a damn devilry. I feel bad like aging Dersu Uzala when he for first time missed his bullet into Siberian tiger. |
|
Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Tue Mar 31, 2015 11:53 am Post subject: |
|
|
DanRRight wrote: | You are right, guys, this / is in column 73. But how this happened? I checked that twice and saw it at reliably below of that (and i always care about that limit with the eagle eye) ? | That depends on how you did the checking. If you used a text editor or used the TYPE <filename> at the console, the transformation of tabs done by the editor or CMD would have probably been different from the transformation that FTN95 applies, so your eagle eye could have been viewing the code through grandma's glasses.
Since your code-base is large, you need to use a more reliable system to check your source code than relying upon mere visual checking of small samples of the code. Obtaining/building filters to do the checking is quite easy, but you need to summon the will and take the initiative.
I think that the design decision to have FTN95 treat a tab as equivalent to eight spaces is regrettable. It would have been better if FTN95 rejected tabs completely instead of applying an interpretation that is different from the interpretations given by other Fortran compilers that allow tabs in source input, and different from the well-known response of typewriters, teletypes and line printers to tab keys/characters. The FTN95 interpretation of tabs is not even consistent with Plato's treatment of tabs, and it is impossible to check by viewing in Plato whether a source file with tabs goes beyond column 72/132. |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2927 Location: South Pole, Antarctica
|
Posted: Tue Mar 31, 2015 1:25 pm Post subject: |
|
|
Mecej4 - We discussed here limit checking few times before, both 72 and 132.
1) First my shield is editor, it shows cursor position, there is no discrepancy between editor and FTN95
2) i made 73 character barrier width of editor for fixed code and larger for 132 one as it has two panels each for different types of sources. But recently i had desktop shuffling and probably changed the sizes
3) i periodically use built into the code source limit checking subprogram i wrote hell decades ago. Basically the code checks itself. Seems I have to make it working automatically every hour by default
4) i strongly advocated for the use of /no_truncate compiler option as default but it was buggy few times and only recently fixed as Paul reported. If this option worked fine this thread would not exist! No tab hatred would be here either. I have nothing against of use of tabs.
That was why i was so sure that this was some kind of devilry because i believed in all my not breakable shields and setups not in the compiler diagnostics. |
|
Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Tue Mar 31, 2015 1:53 pm Post subject: |
|
|
Which editor do you use? |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2927 Location: South Pole, Antarctica
|
Posted: Tue Mar 31, 2015 1:57 pm Post subject: |
|
|
NoteTab
(awards from PC Magazine, PC World and WUGNET, 3 times Shareware Industry Awards) |
|
Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Tue Mar 31, 2015 2:46 pm Post subject: |
|
|
I did not know about this editor. I downloaded a trial version, opened your file defect.for in it, set the tab size to 8 ( to match FTN95 ) and tab type to 'fixed'. The slash in line-8 was shown in column 73. This is as things should be, but without a visual aid it can be hard to look for that specific column. Other editors show a dotted line at a specified right margin (such as column 72). Perhaps Notetab can do so, too, but I have not found the menu to make that setting effective.
If you are going to rely on your source checker, perhaps you should investigate why it failed in this rather simple case. |
|
Back to top |
|
 |
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Tue Mar 31, 2015 3:30 pm Post subject: |
|
|
I personally use SPFLite as my source editor. If you have some experience with ISPF or have to edit a lot of old fixed format source files, then its a great tool.
On SPFLite, the visual column markers could be defined, but you could also type a command:
Code: | EX ALL; F P'=' 73 132 |
This would hide all the lines in the source file and then show only the lines that have something between columns 73-132. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|