[fortran] program divisors ! This program finds the divisors of an integer input by the user. ! The divisors are printed to a file. integer n, k, d(10) open (unit = 1, file = "divisors") print *, "Enter a positive integer :" read *, n write (1,*) "Here are the divisors of ", n, " :" k = 0 do i = 1, n if (mod(n,i) .eq. 0) then k = k + 1 d(k) = i end if if (k .eq. 10) then write (1,5) (d(j), j = 1, 10) k = 0 end if end do write (1,5) (d(j), j = 1, k) 5 format (10i7) close (1) print *, "The divisors are listed in the file 'divisors'. Bye." end[/fortran]
Link Copied
Thanks for your test program.
I'm using Inspector XE 2011 Update 5, build 180252
I'm using Intel Visual Fortran Composer XE 2011, Update 4.
I used "mi1", "mi2", "mi3" to get different results.
"mi3" - it reported, kernel resource leak at malloc.c; it located at getenv.c:83 when doing _heap_alloc_base. Such kind of issues can be ignored in my view
"mi2" - no probelm was reported.
"mi1" - it reported 3 memory leaks, which were called by mainCRTStartup, initializing stage. They could be are Inspector XE's bugs or can be ignored
It also reported 5 kernel resource leak; onewas heapinit related, onewas ioinit related, other 3 kernel resource leaks locates at divisor.f90 source - which locates at linescontaining "open", "printf", "read" statements.
I will talk with developer about these, and get back as soon as I can.
Thanks, Peter
======================================================
C:\zwang\temp\divisors\Debug>inspxe-cl -collect mi3 -- divisors.exe
Used suppression file(s): []
Enter a positive integer :
128
The divisors are listed in the file 'divisors'. Bye.
1 new problem(s) found
1 Kernel resource leak problem(s) detected
C:\zwang\temp\divisors\Debug>inspxe-cl -collect mi2 -- divisors.exe
Used suppression file(s): []
Enter a positive integer :
128
The divisors are listed in the file 'divisors'. Bye.
0 new problem(s) found
C:\zwang\temp\divisors\Debug>inspxe-cl -collect mi1 -- divisors.exe
Used suppression file(s): []
Enter a positive integer :
128
The divisors are listed in the file 'divisors'. Bye.
8 new problem(s) found
5 Kernel resource leak problem(s) detected
3 Memory leak problem(s) detected
C:\zwang\temp\divisors\Debug>inspxe-cl -collect mi1 -module-filter-mode=include
-module-filter=.\divisors.exe -- divisors.exe
Used suppression file(s): []
Enter a positive integer :
128
The divisors are listed in the file 'divisors'. Bye.
0 new problem(s) found
Please attach modified code - I will investigate why Inspector XE can't detect memory leak(s) when using Add divisors.exe into "Include only the following module(s)".
Thanks, Peter
[bash] program divisors ! This program finds the divisors of an integer input by the user. ! The divisors are printed to a file. real(8),allocatable :: x(:) integer n, k, d(10) open (unit = 1, file = "divisors") print *, "Enter a positive integer :" read *, n write (1,*) "Here are the divisors of ", n, " :" k = 0 do i = 1, n if (mod(n,i) .eq. 0) then k = k + 1 d(k) = i end if if (k .eq. 10) then write (1,5) (d(j), j = 1, 10) k = 0 end if end do write (1,5) (d(j), j = 1, k) 5 format (10i7) close (1) print *, "The divisors are listed in the file 'divisors'. Bye." allocate (x(2048)) ! deallocate (x) end[/bash]
Yes. This is an additional concern.
I will get back to you if we found a solution.
Thanks, Peter
For more complete information about compiler optimizations, see our Optimization Notice.