What are program segments, and which segments are different types of variables stored in?

Memory within a computer is typically made of different portions of memory with specialized attributes called segments.

Note: Program segments are different from the notion of segmented memory.

If you have a Fortran or C program, depending on a number of factors, different segments are used to store your variables (data). Following is a list of common variable types and the segments in which they are stored:

Note: Some of the information below is compiler-specific.

  • Fortran code:
    • A regular Fortran 77 array is in the data region when compiling with xlf77 (and variants thereof, e.g., mpxlf77).
    • A regular array is in the stack region when compiled with xlf90 (and variants thereof, e.g., mpxlf90), unless the array appears in a SAVE statement or a COMMON block, or the -qsave option is used.
    • A Fortran 90 allocatable array is in the data region.
    • A Fortran 90 automatic array is in the stack region.
  • C/C++ code:
    • Static C data is in the data region.
    • Automatic C data is in the stack region.
    • C data allocated through malloc is in the data region.

At Indiana University, to learn more about program segments, email the Scientific Applications and Performance Tuning team, or see Scientific Applications and Performance Tuning.

This is document areb in the Knowledge Base.
Last modified on 2018-04-18 13:41:00.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.