Friday 15 February 2013

fortran test memory overflow -



fortran test memory overflow -

i running fortran programme allocates memory dynamically rather big arrays, , not fit memory.

thus allocation

allocate(my_array(really big_number))

will give error

operating scheme error: cannot allocate memory allocation exceed memory limit

and programme exit. know if there way capture or test memory available, can take appropriate measures if i'm not allowed allocate such big array?

use: allocate(my_array(really big_number),stat=ierror)

with stat= specifier, status of allocation stored in specified variable (ierror in example). 0 means allocation succeeded, non-zero means failed.

from fortran 90 standard (ftp://ftp.nag.co.uk/sc22wg5/n001-n1100/n692.pdf) on allocate statement:

if stat= specifier present, successful execution of allocate statement causes stat-variable become defined value of zero.

if error status occurs during execution of allocate statement, stat-variable becomes defined processor-dependent positive integer value. if error status occurs during execution of allocate statement not contain stat= specifier, execution of executable programme terminated.

memory-management fortran

No comments:

Post a Comment