http://stackoverflow.com/questions/13966955/does-fortran-have-a-garbage-collectorgc/13967374#13967374
Modern Fortran has many ways of declaring variables. Items simply declared will exist for the duration of the scope of the entity. So "real, dimension (N) :: array" declared in a procedure will automatically disappear when that procedure returns. Naturally variables declared in the main program or module variables or common (outmoded) will persist for the duration of the program.
allocate -- dynamic allocate
Variables can be dynamically allocated with "allocate" (to do so, they have to be declared with the allocatable attribute). Since Fortran 95 allocatable variables that are local to a procedure are automatically deallocated when the procedure returns! They will not leak memory! (Some programmers might consider it good practice to explicitly deallocate the variables anyway, even though it isn't strictly necessary.) (Of course, you can waste memory in the sense of not explicitly deallocating a variable that you know that you don't need anymore.)
t is possible to leak memory with pointers. You can allocate memory with a pointer, then assign the pointer to to another variable, losing the previous association. If you didn't deallocate that memory you have a leak. The need for pointers is less in Fortran than in some other languages ... many things can be done with allocatable variables, which are safer -- no memory leaks
http://stackoverflow.com/questions/2300199/allocatable-arrays-or-pointer-arrays
Allocatable arrays Vs Pointer arrays?
Allocatable arrays can result in more efficient code because the arrays will be contiguous. Particularly if the array is passed to a subroutine, being contiguous can prevent the need for the compiler creating a temporary copy. For local variables in subroutines (without the SAVE attribute) (for Fortran 95 and higher), allocatable arrays are automatically deallocated upon exit from the subroutine, avoiding a memory leak. Memory leaks aren't possible with allocatables, except in the sense of the programmer not deallocating an array that is no longer need. With pointers, you can reassign a pointer, leaving some memory inaccessible and lost -- one form of a leak. If an allocatable will do the job, I recommend using that method instead of a pointer. Some reasons to use pointers: taking a section of an array, or creating a data structure such as a linked list. For the purpose of creating an array of size determined at run time, I'd use an allocatable.
Showing posts with label Numerical. Show all posts
Showing posts with label Numerical. Show all posts
Thursday, July 18, 2013
Friday, July 12, 2013
Thursday, June 6, 2013
Pade Series
Padé approximant is the "best" approximation of a function by a rational function of given order – under this technique,
The Padé approximant often gives better approximation of the function than truncating its Taylor series, and it may still work where the Taylor series does not converge.
http://en.wikipedia.org/wiki/Pad%C3%A9_approximant
The Padé approximant often gives better approximation of the function than truncating its Taylor series, and it may still work where the Taylor series does not converge.
http://en.wikipedia.org/wiki/Pad%C3%A9_approximant
Wednesday, May 29, 2013
N Dimensional Grid and Grid based Interpolation (MATLAB)
Grid Based Interpolation
http://www.mathworks.com/help/matlab/examples/grid-based-interpolation.html
N Dimensional Grid
ndgrid
http://www.mathworks.com/help/matlab/examples/grid-based-interpolation.html
N Dimensional Grid
ndgrid
Sunday, May 26, 2013
Saturday, November 24, 2012
Polynomial Order
The highest order power in a univariate polynomial is known as its order (or, more properly, its polynomial
degree). For example, the polynomial
is of order
, denoted
.
Sunday, February 19, 2012
What is arithmetic underflow & how to handle the
http://en.wikipedia.org/wiki/Arithmetic_underflow
Further Details: Floating Point Arithmetic:
http://www.netlib.org/lapack/lug/node74.html#secbackgroundfloatingpoint
How to Measure Errors:
http://www.netlib.org/lapack/lug/node75.html#secnormnotation
Further Details: Floating Point Arithmetic:
http://www.netlib.org/lapack/lug/node74.html#secbackgroundfloatingpoint
How to Measure Errors:
http://www.netlib.org/lapack/lug/node75.html#secnormnotation
Saturday, January 14, 2012
Segmentation fault and trouble shooting
From MIT:
Other numerical tips from same course resource:
How to check convergence:
Thursday, December 22, 2011
Parallel Numerical Algorithms
Chapter 10 – Iterative Methods for Linear Systems
UIUC
CS 544
Maybe a good book?
http://www.amazon.com/exec/obidos/ASIN/052143064X/ref=nosim/weisstein-20
UIUC
CS 544
Maybe a good book?
http://www.amazon.com/exec/obidos/ASIN/052143064X/ref=nosim/weisstein-20
Subscribe to:
Comments (Atom)