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 

Bug ? %lw + optimise

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Kenneth_Smith



Joined: 18 May 2012
Posts: 361
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Sun Jul 12, 2020 9:34 pm    Post subject: Bug ? %lw + optimise Reply with quote

The code below runs into problems when complied with both win32 and x64 when the optimise compiler switch is applied. The splash window (displayed during a long calculation) is never closed and the program does not terminate.

Code:
!options (optimise)                      !#### Code will fail in both WIN32 and X64 if this line is uncommented
module splash_windows_mod
use clrwin
implicit none
contains
  integer function temp_spinner(txt,control_temp_win)
  integer, intent(in) :: control_temp_win
  character(len=*), intent(in) :: txt
  integer, save :: iw
    iw = winio@('%ww[no_caption,no_maxminbox,topmost]&')
    iw = winio@('%fn[Tahoma]&')
    iw = winio@('%ts&',1.5d0)
    iw = winio@('%tc[white]&')
    iw = winio@('%bg[#BFCDDB]&')
!    iw = winio@('%cn%gi[spinner]&')
    iw = winio@('%nl%cn%ws&',txt)
    iw = winio@('%lw&', control_temp_win)       ! This automatically sets control_temp_win to -1
    iw = winio@(' ')
    temp_spinner = 2
  end function temp_spinner

  integer function do_something()
  integer i
  integer, save :: control_temp_win
  real*8 z1,z2
  character(len=120) :: txt = 'Initialising'
    i = temp_spinner(txt,control_temp_win)
    do i = 1, 32000, 1
      print*, i
      z1 = (dble(i))**2
      z2 = (dble(i))**2
    end do
    print*, 'Calc complete'
    control_temp_win = 1
    print*, 'Control_temp_win updated'
    call window_update@(control_temp_win)
    print*, 'call to window_update@ complete'
    do_something = 1
  end function do_something
end module splash_windows_mod

program main
use splash_windows_mod, only : do_something
implicit none
integer i
i = do_something()
end program main


Ken
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Mon Jul 13, 2020 8:13 am    Post subject: Reply with quote

Ken

Thank you for the feedback. I have logged this problem.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Mon Jul 13, 2020 8:55 am    Post subject: Reply with quote

The fault is in options(optimise) which (at least in this context) does not have the same outcome as using /opt on the command line.

Until this is fixed, it will be necessary to use /opt on the FTN95 command line rather than options(optimise) in the code.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Mon Jul 13, 2020 10:44 am    Post subject: Reply with quote

Ken

Although there appears to be a fault in FTN95 I suspect that the code also needs to be modified. When the following modification is applied, the problem is solved.

The variable control_temp_win should be declared within the scope of the module splash_windows_mod and not passed as an argument...

Code:
module splash_windows_mod
use clrwin
implicit none
integer control_temp_win


As it is, ClearWin+ is getting the wrong address for the control variable.

I don't understand it fully at the moment but part of the problem is that optimising with INTENT(IN) can lead the compiler to generate a local copy of the argument.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 361
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Mon Jul 13, 2020 11:50 am    Post subject: Reply with quote

Thank you Paul, it never occurred to me to use /OPT on the command line (within Plato).

I missed the need for intent(inout) on control_temp_win, when I was starting at the code last night.

There are other issues with options(optimise).

For example I discovered that the code that generates the rotating phasors (based on %pl) I shared a few months back does not work properly with options(optimise), but it will be more challenging to create a simple demo (the code does not need to be optimised but I was curious!).

The coordinates of the some of the rotating vectors and axis are plotted incorrectly. Some of these are produced by updating the data passed to %pl and some are drawn based on %gr drawing primitives. So it will need a bit of careful investigation to replicate – when I have time. There is a mix of local and global variables in this part of the code. As per your last post a possibly is that ClearWin+ is getting the wrong address. Again this is “fixed” if /OPT is used on the command line.

Ken
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Mon Jul 13, 2020 5:39 pm    Post subject: Reply with quote

This bug has now been fixed for the next release of FTN95. The two methods to switch on optimising will work consistently.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



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

PostPosted: Tue Jul 14, 2020 2:32 pm    Post subject: Reply with quote

I wonder how long that bug has been around, and whether or not it was the reason I gave up on optimising well over a decade ago - just building ever faster computers turned out cheaper in the long run!

Eddie
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 -> Support All times are GMT + 1 Hour
Page 1 of 1

 
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