forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Debugger improvements
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Suggestions
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Fri Sep 01, 2017 2:28 am    Post subject: Debugger improvements Reply with quote

SDBG has nice feature showing variable value in tiny popup screen when you point on variable with the mouse. Would be great to add the same feature when you point on ENDIFs and ENDDOs. Something like here (on this static image shown all popups at the same time but of course only one will be seen in reality)



That will help us not to be lost in the spaghetti codes
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7912
Location: Salford, UK

PostPosted: Fri Sep 01, 2017 7:55 am    Post subject: Reply with quote

I would often write this as !comment in the code.
Also, don't forget that constructs can be named in Fortran 90.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Fri Sep 01, 2017 9:40 am    Post subject: Reply with quote

I also do comment enddos and endifs. But I started doing this just recently after hundreds of thousands of lines of codes when the mess became unbearable Sad. Because nobody teaches good coding practices so my $10 bet is that most people don't do that. And naming is way too rarely used, and is known and much less used only by very advanced coders.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Sep 01, 2017 3:35 pm    Post subject: Reply with quote

Dan,

When I was programming in Algol-60, back in the 1960s, the use of indenting was essential, and I spent many hours drawing links between the start of a loop and its end using different coloured pens. Can I help by sending you a set, along with a long ruler, down to the South Pole? Can you still get your source codes printed on music-ruled fan-fold paper on a line printer?

At least with traditional Fortran DO loops one automatically gets a connection between the DO statement and the final CONTINUE statement through the statement number of the latter, which in fixed-format source codes is an 'outdent'. It slowly dawned on me that what I had seen as a primitive defect was actually a helpful construct.

But sadly, the past is a foreign country where they do things differently (or so said H. E. Bates in 'The Go Between'). Don't believe people who say the past (or indeed, the primitive) was always worse!

Eddie
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Fri Sep 01, 2017 11:29 pm    Post subject: Reply with quote

Eddie, oh yeah, the indentation is simply a must, I completely forgotten mentioning it, because it is so natural that you don't even notice it. You are dead without it in large codes. As to coloring - here is where I don't have opinion. I tried to convince my editor developer 20 years ago to implement coloring because almost all do that but he refused... I think Plato also has it but I use batch files to compile instead. As a result I have no clue if it actually helps or distracts. What is your opinion?

Last edited by DanRRight on Sat Sep 02, 2017 9:40 am; edited 2 times in total
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2551
Location: Sydney

PostPosted: Sat Sep 02, 2017 12:49 am    Post subject: Reply with quote

Hi Dan,

Plato does have colouring, although the colours don't contrast a lot. I'm sure I could change the colour palette.

To keep track of nested or long DO loops I have always suggested using the DO variable as an alternate DO label, but few have given that support. The alternative I often use is END DO ! DO_variable, eg
Code:
!
      do j = 1,ncb
        c(:,j) = 0
        do k = 1,nca
          c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)
        end do ! k
      end do ! j
!


It is good to see that we are thinking similarly. It is just a shame more on the Fortran committee don't have the same experience.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Sep 02, 2017 1:56 pm    Post subject: Reply with quote

John,

It is intriguing that the content of your do loop is one step further indented than the start and finish. Wouldn't:

Code:
!
      do j = 1,ncb
      c(:,j) = 0
        do k = 1,nca
        c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)
        end do ! k
      end do ! j
!


be more logical?

Eddie
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1884

PostPosted: Sat Sep 02, 2017 6:05 pm    Post subject: Re: Reply with quote

LitusSaxonicum wrote:

It is intriguing that the content of your do loop is one step further indented than the start and finish.

The Fortran style guide at http://www.fortran90.org/src/best-practices.html#indentation would support John's style. That guide uses four spaces for indentation. Others may use fewer or more spaces, or tabs. Having the DO and the matching END DO indented less than the statements in the body of the DO construct (and likewise for IF...ENDIF, etc.) makes it clear where the loop starts and where it ends, and whether a statement is in the loop or not.

I usually don't bother too much about style when editing source code. After I am done, I can use a utility to reformat ("pretty print") the whole code in a standard way.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Sep 02, 2017 11:19 pm    Post subject: Reply with quote

Mecej4,

It doesn't work for me. I prefer no indent at all, blank lines, CONTINUE and statement numbers. It's the 'the way nature intended' as I see it (quote misused from the Silverfrost top page) ;-).

If I had to use indents, then I'm sure that I would find having the content indented differently obfuscated the connection between the beginning, content, and end.

But then I don't indent loops, not since ALGOL days, and they ended, abruptly, in 1970 ! My recollection was that they were indented rather like John's layout, but the interior code began with "BEGIN" and ended with "END" which made it a sort of logical block.

Eddie
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Tue Sep 12, 2017 7:29 pm    Post subject: Reply with quote

it's useful to see various options side-by-side .....

I've added a few lines to indicate where some extra code might be in order to illustrate better.

Which one would you vote for ?

Code:

!

! JohnC's 'starter for 10' version (10)

      some code here
      some more code here
      do j = 1,ncb
        c(:,j) = 0
        do k = 1,nca
          c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)
        end do ! k
      end do ! j
      almost last code here
      last code here
!

! Fortran Style Guide (max(?) 4 spaces version) (10)

      some code here
      some more code here
      do j = 1,ncb
          c(:,j) = 0
          do k = 1,nca
              c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)
          end do ! k
      end do ! j
      almost last code here
      last code here
!

! Eddie's blank lines, No Indent Preference ? (14)

      some code here
      some more code here

      do j = 1,ncb
      c(:,j) = 0

      do k = 1,nca
      c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)
      end do ! k

      end do ! j

      almost last code here
      last code here
!


! John_Silver 2spaces & blank lines version (14+1)

      some code here
      some more code here

        do j = 1,ncb
          c(:,j) = 0

            do k = 1,nca
              c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)
            end do ! k

          a bit more code here
        end do ! j

      almost last code here
      last code here
!

! John_Silver 4spaces & blank lines version (14+1)
      some code here
      some more code here

          do j = 1,ncb                       
              c(:,j) = 0
 
                  do k = 1,nca                                     
                    c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j) 
                  end do ! k                                       

              a bit more code here
          end do ! j

      almost last code here
      last code here
!

! Utopian Style :- 4spaces indent, 'Eddie spaced' & version - the traceability optimum ??? (18+1+1)

      some code here
      some more code here

          do j = 1,ncb   !--------------------------------------------------------
                                                                                  !
              c(:,j) = 0                                                          !
                                                                                  !
                  do k = 1,nca     !---------------------------------             !
                                                                     !            !
                    c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)    !--- k loop  !--- j loop
                                                                     !            !
                  end do ! k       !---------------------------------             !
                                                                                  !
              maybe some more code here                                           !
              a bit more code here                                                !
                                                                                  !
          end do ! j   !----------------------------------------------------------

      almost last code here
      last code here
!



Last edited by John-Silver on Tue Sep 12, 2017 7:33 pm; edited 2 times in total
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Tue Sep 12, 2017 7:30 pm    Post subject: Reply with quote

then there's this possibility, with more continuous, neater (?) 'loop lines' but with the drawback that the '!'s on blank lines are still required within the loops

Code:

!

! Utopian 'Modern' :- 4spaces indent, 'Eddie spaced' & version - the optimum ??? (18+1+1)

      some code here
      some more code here

          do j = 1,ncb   !________________________________________________________
!                                                                                 |
              c(:,j) = 0   !                                                      |
!                                                                                 |
                  do k = 1,nca     !_________________________________             |
!                                                                    |            |
                    stuff                                           !|            |
                    c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)   !|___ k loop  |___ j loop
                    more stuff                                      !|            |
!                                                                    |            |
                  end do ! k       !_________________________________|            |
!                                                                                 |
              maybe some more code here   !                                       |
              a bit more code here   !                                            |
                                                                                  |
          end do ! j     !________________________________________________________|

      almost last code here
      last code here
!


Of course colouring would be even better too Smile
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Tue Sep 12, 2017 8:10 pm    Post subject: Reply with quote

of course, for F77 the latter 2 options are not practical (due to chars per line limit (sorry Eddie ! Smile but for F90 and its 132 char lines , highly possible, providing you have the patience !
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Wed Sep 13, 2017 3:16 pm    Post subject: Reply with quote

I wouldn't indent, but then I'd have statement numbers. They are an 'outdent', akin to a tab on the left. Then it's obvious where the loop ends.

The need for wider layouts is due to longer names and indents. Neither are essential.

Just saying.

Eddie
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Wed Sep 13, 2017 5:47 pm    Post subject: Reply with quote

I liked your comment about drawing the links on lineprinter paper to mark the loops Eddie, it brought back memories that did Smile so I pottered with some examples (the ones above).
The problem with the multi- pen/pencil approach is that it needs to be regularly re-done !
I hadn't actually thought of doing it as I tried above until this post. I may adopt as standard from now on.

At the end of the day it's personal preference (as it should be) but as Dan might say, all the better reason to give all the options !

I also usually differentiate routines , functions , modules etc with lines including a symbol (typically a '*' as this helps quickly locate code blocks too.

The trouble is, I find it difficult to be consistent and thorough when applying all these things, as I'm sure most people do, due to time restraints ... but then again time well spent at the beginning is years saved when a gremlin is found and needs investigation.


Last edited by John-Silver on Wed Sep 13, 2017 11:21 pm; edited 2 times in total
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Wed Sep 13, 2017 6:43 pm    Post subject: Reply with quote

Code:
! JohnC's 'starter for 10' version (10)

      some code here
      some more code here
      do j = 1,ncb
        c(:,j) = 0
        do k = 1,nca
          c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)
        end do ! k
      end do ! j
      almost last code here
      last code here


2 spaces is also my style. I can not afford 4 with free style and 132 places. The editor has to keep open two panes with two files simultaneously. Occupies almost all 3840 pixels of screen width

For better visible separation of subroutines in the files each containing ~20000 lines i use huge banners made using this site below. Here is one for Main program
Code:
!http://patorjk.com/software/taag/#p=display&h=2&v=0&f=Doh&t=Main%20GUI
!MMMMMMMM               MMMMMMMM                    iiii
!M:::::::M             M:::::::M                   i::::i
!M::::::::M           M::::::::M                    iiii
!M:::::::::M         M:::::::::M
!M::::::::::M       M::::::::::M  aaaaaaaaaaaaa   iiiiiii nnnn  nnnnnnnn
!M:::::::::::M     M:::::::::::M  a::::::::::::a  i:::::i n:::nn::::::::nn
!M:::::::M::::M   M::::M:::::::M  aaaaaaaaa:::::a  i::::i n::::::::::::::nn
!M::::::M M::::M M::::M M::::::M           a::::a  i::::i nn:::::::::::::::n
!M::::::M  M::::M::::M  M::::::M    aaaaaaa:::::a  i::::i   n:::::nnnn:::::n
!M::::::M   M:::::::M   M::::::M  aa::::::::::::a  i::::i   n::::n    n::::n
!M::::::M    M:::::M    M::::::M a::::aaaa::::::a  i::::i   n::::n    n::::n
!M::::::M     MMMMM     M::::::Ma::::a    a:::::a  i::::i   n::::n    n::::n
!M::::::M               M::::::Ma::::a    a:::::a i::::::i  n::::n    n::::n
!M::::::M               M::::::Ma:::::aaaa::::::a i::::::i  n::::n    n::::n
!M::::::M               M::::::M a::::::::::aa:::ai::::::i  n::::n    n::::n
!MMMMMMMM               MMMMMMMM  aaaaaaaaaa  aaaaiiiiiiii  nnnnnn nnnnnn 


Last edited by DanRRight on Wed Sep 13, 2017 7:21 pm; edited 1 time in total
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Suggestions All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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