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 

Deallocate 64bit /checkmate

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



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

PostPosted: Sat Apr 18, 2020 1:00 pm    Post subject: Deallocate 64bit /checkmate Reply with quote

I recompiled some code from a few years back and ran into some problems with 64bit /checkmate.

The following cut down code reproduces the problem. This runs fine with
Win32 /Checkmate
Win32 /Debug
Win32 /Release
X64 /Debug
X64 /Release

It fails with X64 /Checkmate

I have the latest debuggers, plato, and ftn on my machine.

Ken


Code:
module asymmetric_wave_mod
implicit none
private

public asymmetric_wave_cb

integer, parameter :: dp = kind(1.d0)
integer, parameter :: npoints_max = 1     !#####  This value was originally much larger.  Problem does not appear to be
                                          !       related to the dimension of the allocated arrays
real(kind=dp), allocatable :: idc_plot(:), iac_plot(:), iinst_plot(:), ienv1_plot(:), ienv2_plot(:), time_plot(:), &
                              iinstsq_plot(:), iinstsqtime_plot(:), irms_plot(:)
 
contains

  integer function asymmetric_wave_cb()
  include<windows.ins>
  integer, save :: iw
   allocate (idc_plot(npoints_max),   iac_plot(npoints_max),   iinst_plot(npoints_max), &
              ienv1_plot(npoints_max), ienv2_plot(npoints_max), time_plot(npoints_max),  &
              iinstsq_plot(npoints_max), iinstsqtime_plot(npoints_max), irms_plot(npoints_max) )
    idc_plot       = 1.d0 ;     iac_plot     = 2.d0
    iinst_plot     = 3.d0 ;     ienv1_plot   = 4.d0
    ienv2_plot   = 5.d0 ;     time_plot     = 6.d0
    iinstsq_plot  = 7.d0 ;     iinstsqtime_plot = 7.d0
    irms_plot     = 8.d0
    print*,'Contents of allocated arrays'
    print*,idc_plot,iac_plot, iinst_plot, ienv1_plot, ienv2_plot, time_plot, &
                              iinstsq_plot, iinstsqtime_plot, irms_plot
   
    iw = winio@('%ww[no_maxminbox,no_sysmenu]&')
    iw = winio@('%mn[Exit]&','exit')
    iw = winio@('Click on EXIT menu to generate error when compiled X64 /Checkmate&')
   
    iw = winio@(' ')

!   ##########  dellocate below runs into problems when compiled with /checkmate X64
    print*,'At line before deallocate'
    deallocate (idc_plot, iac_plot, iinst_plot, ienv1_plot, ienv2_plot, time_plot, iinstsq_plot, iinstsq_plot, &
                iinstsqtime_plot, irms_plot)
    print*, 'At line after deallocate'
    asymmetric_wave_cb = 1
  end function asymmetric_wave_cb

end module asymmetric_wave_mod

program main
use asymmetric_wave_mod, only : asymmetric_wave_cb
implicit none
integer, save :: iw
iw = winio@('%ww[no_maxminbox,no_sysmenu]&')
iw = winio@('%mn[Exit]&','exit')
iw = winio@('%fn[Tahoma]%bg[grey]&')
iw = winio@('Click on button below&')
iw = winio@('%bc[white]%2nl%28^bt[Asymmetric wave]&', asymmetric_wave_cb)
iw = winio@(' ')

end program main


Last edited by Kenneth_Smith on Sat Apr 18, 2020 1:27 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Kenneth_Smith



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

PostPosted: Sat Apr 18, 2020 1:24 pm    Post subject: Reply with quote

With only a single allocated array, everything is OK.

Code:
module asymmetric_wave_mod
implicit none
private

public asymmetric_wave_cb

integer, parameter :: dp = kind(1.d0)
integer, parameter :: npoints_max = 1     !#####  This value was originally much larger.  Problem does not appear to be
                                          !       related to the dimension of the allocated arrays
real(kind=dp), allocatable :: idc_plot(:)
 
contains

  integer function asymmetric_wave_cb()
  include<windows.ins>
  integer, save :: iw
   allocate (idc_plot(npoints_max) )
    idc_plot         = 1.d0
    print*,'Contents of allocated arrays'
    print*,idc_plot
   
    iw = winio@('%ww[no_maxminbox,no_sysmenu]&')
    iw = winio@('%mn[Exit]&','exit')
    iw = winio@('Click on EXIT menu to generate error when compiled X64 /Checkmate&')
   
    iw = winio@(' ')

!   ##########  dellocate below runs into problems when compiled with /checkmate X64
    print*,'At line before deallocate'
    deallocate (idc_plot)
    print*, 'At line after deallocate'
    asymmetric_wave_cb = 1
  end function asymmetric_wave_cb

end module asymmetric_wave_mod

program main
use asymmetric_wave_mod, only : asymmetric_wave_cb
implicit none
integer, save :: iw
iw = winio@('%ww[no_maxminbox,no_sysmenu]&')
iw = winio@('%mn[Exit]&','exit')
iw = winio@('%fn[Tahoma]%bg[grey]&')
iw = winio@('Click on button below&')
iw = winio@('%bc[white]%2nl%28^bt[Asymmetric wave]&',                      asymmetric_wave_cb)
iw = winio@(' ')

end program main
Back to top
View user's profile Send private message Visit poster's website
Kenneth_Smith



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

PostPosted: Sat Apr 18, 2020 1:40 pm    Post subject: Reply with quote

The problem appears to be related to the number of allocated arrays, for example with just 5 allocated arrays, everything is also ok.

Code:
module asymmetric_wave_mod
implicit none
private

public asymmetric_wave_cb

integer, parameter :: dp = kind(1.d0)
integer, parameter :: npoints_max = 1     !#####  This value was originally much larger.  Problem does not appear to be
                                          !       related to the dimension of the allocated arrays
real(kind=dp), allocatable :: idc_plot(:), iac_plot(:), iinst_plot(:), ienv1_plot(:), ienv2_plot(:)
 
contains

  integer function asymmetric_wave_cb()
  include<windows.ins>
  integer, save :: iw
   allocate (idc_plot(npoints_max),   iac_plot(npoints_max),   iinst_plot(npoints_max), &
              ienv1_plot(npoints_max), ienv2_plot(npoints_max))
    idc_plot       = 1.d0 ;     iac_plot     = 2.d0
    iinst_plot     = 3.d0 ;     ienv1_plot   = 4.d0
    ienv2_plot   = 5.d0
   
    print*,'Contents of allocated arrays'
    print*,idc_plot,iac_plot, iinst_plot, ienv1_plot, ienv2_plot
   
    iw = winio@('%ww[no_maxminbox,no_sysmenu]&')
    iw = winio@('%mn[Exit]&','exit')
    iw = winio@('Click on EXIT menu to generate error when compiled X64 /Checkmate&')
   
    iw = winio@(' ')

!   ##########  dellocate below runs into problems when compiled with /checkmate X64
    print*,'At line before deallocate'
    deallocate ( idc_plot,iac_plot, iinst_plot, ienv1_plot, ienv2_plot )
    print*, 'At line after deallocate'
    asymmetric_wave_cb = 1
  end function asymmetric_wave_cb

end module asymmetric_wave_mod

program main
use asymmetric_wave_mod, only : asymmetric_wave_cb
implicit none
integer, save :: iw
iw = winio@('%ww[no_maxminbox,no_sysmenu]&')
iw = winio@('%mn[Exit]&','exit')
iw = winio@('%fn[Tahoma]%bg[grey]&')
iw = winio@('Click on button below&')
iw = winio@('%bc[white]%2nl%28^bt[Asymmetric wave]&', asymmetric_wave_cb)
iw = winio@(' ')

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


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

PostPosted: Sun Apr 19, 2020 8:07 am    Post subject: Reply with quote

I have made a note of this.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2227
Location: Sydney

PostPosted: Sun Apr 19, 2020 2:29 pm    Post subject: Reply with quote

Ken,

Check your first post; you have "iinstsq_plot, iinstsq_plot, &"

allocate 9 arrays, deallocate 10 arrays

I was modifying your program as:
allocate (idc_plot(npoints_max), stat=stat) ; call report_alloc ( 'idc_plot', stat)
deallocate (idc_plot, stat=stat) ; call report_dealloc ( 'idc_plot', stat)

and found the repeat. Is this your original problem ?

I must admit, I try to use stat=stat on allocate and deallocate for a single array

John
Back to top
View user's profile Send private message
Kenneth_Smith



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

PostPosted: Sun Apr 19, 2020 3:45 pm    Post subject: Reply with quote

John,

You are correct. Very well spotted, the benefit of a fresh pair of eyes! That error has been in the original code for sometime, and never caused any issues until recompiled with X64 /checkmate.

I did go through a phase where I was using stat=stat on allocate / deallocate, with separate sequential statements for each allocable array in turn but found that for the relatively small arrays I generally work with I was not running into memory management problems - so I perhaps I have got a bit lazy.

Thanks

Ken
Back to top
View user's profile Send private message Visit poster's website
JohnCampbell



Joined: 16 Feb 2006
Posts: 2227
Location: Sydney

PostPosted: Mon Apr 20, 2020 1:06 am    Post subject: Reply with quote

Ken,

I wouldn't describe my eyes as "fresh" !

Interesting the use of stat=stat. It's easy to be lazy as it's been a long time since I got a non-zero response. Can't recall since moving to /64.

The bigger problem is I develop a program on my newer pc, then forget and run it on my older pc, which has only 8gb memory. If I have a few "apps" open it can take a long time to recover from requesting more memory than installed.

John
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 -> 64-bit 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