10
0
mirror of https://gitlab.com/scemama/irpf90.git synced 2024-07-26 20:57:35 +02:00

Corrected irp_stack bug

This commit is contained in:
Anthony Scemama 2016-05-29 15:56:27 +02:00
parent 12ee88261a
commit 1c1f989f36
2 changed files with 37 additions and 25 deletions

View File

@ -85,9 +85,9 @@ subroutine irp_enter(irp_where)
nthread = 1 nthread = 1
""" """
txt += """ txt += """
print *, 'Allocating irp_stack(',STACKMAX,',',nthread,')' print *, 'Allocating irp_stack(',STACKMAX,',',0:nthread,')'
print *, 'Allocating irp_cpu(',STACKMAX,',',nthread,')' print *, 'Allocating irp_cpu(',STACKMAX,',',0:nthread,')'
print *, 'Allocating stack_index(',nthread,')' print *, 'Allocating stack_index(',0:nthread,')'
endif""" endif"""
txt +=""" txt +="""
$2 $2
@ -128,9 +128,9 @@ $1
nthread = 1 nthread = 1
""" """
txt +=""" txt +="""
print *, 'Allocating irp_stack(',STACKMAX,',',nthread,')' print *, 'Allocating irp_stack(',STACKMAX,',',0:nthread,')'
print *, 'Allocating irp_cpu(',STACKMAX,',',nthread,')' print *, 'Allocating irp_cpu(',STACKMAX,',',0:nthread,')'
print *, 'Allocating stack_index(',nthread,')' print *, 'Allocating stack_index(',0:nthread,')'
endif endif
""" """
txt += """ txt += """
@ -172,16 +172,16 @@ end subroutine
!$OMP END PARALLEL !$OMP END PARALLEL
!$OMP CRITICAL !$OMP CRITICAL
if (.not.alloc) then if (.not.alloc) then
allocate(irp_stack(0:STACKMAX,nthread)) allocate(irp_stack(0:STACKMAX,0:nthread))
allocate(irp_cpu(0:STACKMAX,nthread)) allocate(irp_cpu(0:STACKMAX,0:nthread))
allocate(stack_index(nthread)) allocate(stack_index(0:nthread))
stack_index = 0 stack_index = 0
alloc = .True. alloc = .True.
endif endif
!$OMP END CRITICAL !$OMP END CRITICAL
endif endif
stack_index(ithread+1) = mod(stack_index(ithread+1)+1,STACKMAX) stack_index(ithread) = min(stack_index(ithread)+1,STACKMAX)
irp_stack(stack_index(ithread+1),ithread+1) = irp_where""" irp_stack(stack_index(ithread),ithread) = irp_where"""
else: else:
s += """ s += """
nthread = 1 nthread = 1
@ -193,13 +193,13 @@ end subroutine
alloc = .True. alloc = .True.
endif endif
endif endif
stack_index(1) = mod(stack_index(1)+1,STACKMAX) stack_index(1) = min(stack_index(1)+1,STACKMAX)
irp_stack(stack_index(1),1) = irp_where""" irp_stack(stack_index(1),1) = irp_where"""
if do_memory: if do_memory:
txt+=""" txt+="""
print *, 'Allocating irp_stack(',STACKMAX,','nthread,')' print *, 'Allocating irp_stack(',STACKMAX,','0:nthread,')'
print *, 'Allocating irp_cpu(',STACKMAX,','nthread,')' print *, 'Allocating irp_cpu(',STACKMAX,','0:nthread,')'
print *, 'Allocating stack_index(',nthread,')'""" print *, 'Allocating stack_index(',0:nthread,')'"""
else: else:
s = "" s = ""
txt = txt.replace("$1",s) txt = txt.replace("$1",s)
@ -207,8 +207,8 @@ end subroutine
# $2 # $2
if do_debug: if do_debug:
txt = txt.replace("$2",""" txt = txt.replace("$2","""
print *, ithread, ':', white(1:stack_index(ithread+1))//'-> ', trim(irp_where) print *, ithread, ':', white(1:stack_index(ithread))//'-> ', trim(irp_where)
call cpu_time(irp_cpu(stack_index(ithread+1),ithread+1))""") call cpu_time(irp_cpu(stack_index(ithread),ithread))""")
else: else:
txt = txt.replace("$2","") txt = txt.replace("$2","")
@ -216,16 +216,16 @@ end subroutine
if do_debug: if do_debug:
txt = txt.replace("$3",""" txt = txt.replace("$3","""
call cpu_time(cpu) call cpu_time(cpu)
print *, ithread, ':', white(1:stack_index(ithread+1))//'<- ', & print *, ithread, ':', white(1:stack_index(ithread))//'<- ', &
trim(irp_stack(stack_index(ithread+1),ithread+1)), & trim(irp_stack(stack_index(ithread),ithread)), &
cpu-irp_cpu(stack_index(ithread+1),ithread+1)""") cpu-irp_cpu(stack_index(ithread),ithread)""")
else: else:
txt = txt.replace("$3","") txt = txt.replace("$3","")
# $4 # $4
if do_debug or do_assert: if do_debug or do_assert:
txt = txt.replace("$4",""" txt = txt.replace("$4","""
stack_index(ithread+1) = stack_index(ithread+1)-1""") stack_index(ithread) = max(0,stack_index(ithread)-1)""")
else: else:
txt = txt.replace("$4","") txt = txt.replace("$4","")
@ -248,8 +248,8 @@ subroutine irp_trace
if (.not.alloc) return if (.not.alloc) return
print *, 'Stack trace: ', ithread print *, 'Stack trace: ', ithread
print *, '-------------------------' print *, '-------------------------'
do i=1,stack_index(ithread+1) do i=1,stack_index(ithread)
print *, trim(irp_stack(i,ithread+1)) print *, trim(irp_stack(i,ithread))
enddo enddo
print *, '-------------------------' print *, '-------------------------'
end subroutine end subroutine

View File

@ -681,5 +681,17 @@ if __name__ == '__main__':
from variables import variables from variables import variables
#for v in variables.keys(): #for v in variables.keys():
# print v # print v
for line in variables['e_loc'].parents: def print_dot(x,done):
print line if x.children == []:
return
for i in x.needs:
pair = (x.name, i)
if pair not in done:
print "%s -> %s"%( x.name, i )
done[pair] = None
print_dot(variables[i],done)
print "digraph G { "
# print_dot(variables['e_loc'], {})
print_dot(variables['psi_value'], {})
print "}"