|
****JavaScript based drop down DHTML menu generated by NavStudio. (OpenCube Inc. - http://www.opencube.com)****
| Search |
|||||||||||||
|
Putting Mega-Byte Memory to Work by Thomas M. Lahey
In today’s programming world, memory size (really, memory available to execute a program) is no longer a consideration. This statement is based on two facts:
It’s true virtual memory affects execution time, but if that is a problem, buy some of that affordable memory! The most important consequence of memory size no longer being a constraint: Applications should be coded using techniques that
The following code outlines one technique (linked list, a.k.a., thread) for making a program independent of the size of a user’s data set. ! Declare structure: TYPE :: Derived_Type TYPE(Derived_Type), POINTER :: Next ! Link list pointer ... ! Other components END TYPE Derived_Type ! Declare variables: TYPE(Derived_Type), POINTER :: Head, Tail, Current ... ! Other declarations ! Initialize linked list & process first element ALLOCATE( Head ) ! Head is ALWAYS list's beginning Tail => Head ! Tail is ALWAYS list's last element ... ! Code to define Head component(s) ! Loop; create list; count members DO Number_in_List = 1, HUGE( 1 ) ALLOCATE( Current ) READ(Unit_No, FORMAT, IOSTAT=iostatus) Current%Component IF( iostatus /= 0 ) EXIT ! Hopefully EOF, not error ... ! Code defines Current component(s) Current%Next => NULL( ) ! NULL terminates thread Tail%Next => Current ! Thread Current Tail => Current ! Tail points to last element END DO ! Loop to create & read next line ... ! Data set read, begin to process
Each time it is necessary to loop through the code, either of the following fragments will work as the outermost control structure:
Current => Head DO Number_in_List = 1, Number_in_List ... ! Process link elements Current => Current%Next END DO Number_in_List = Number_in_List – 1 Or Current => Head DO WHILE( ASSOCIATED( Current%Next ) ) ... ! Process link elements Current => Current%Next END DO
Note: The above loops replace indexed DO loops
|