billgray1234
Programmer
- Mar 14, 2011
- 39
all REAL variables need to be given a value (i.e. initialised) if they are to be either 1) written to the screen, or 2) written to a file, or 3) used in calculations. for example, a common way to initialise such variables is to set them equal to zero.
such variables include "CUMULATIVE SUM Variables (CSV's)", and "DIRECT CALCULATION SUM Variables (DCSV's)". an example of each (as applied to a scalar variable) is given below.
CUMULATIVE SUM Variables
------------------------
SUM = 0.0
DO I = 1 , N
SUM = SUM + REAL(I) + 3.0
END DO
the important line is "SUM = 0.0" (i.e. it initialises SUM to be equal to zero)
DIRECT CALCULATION SUM Variables
--------------------------------
DO I = 1 , N
SUM = REAL(I) + 3.0
END DO
note that the line "SUM = 0.0" is not included here
my question is:- like CSV's, do DCSV's also always need to be set equal to zero (i.e. initialised) first, before they are manipulated ? i.e. is the line "SUM = 0.0" also needed (before the DO loop) in the "DIRECT CALCULATION SUM variables" example above ? or is the "DIRECT CALCULATION SUM variables" example above correct "as it is" ?
another example (as applied to a matrix variable) is as follows.
say i have a matrix A. the matrix is, say, 1000 x 1000, and is "partitioned" into the equal-size blocks A1, A2, A3 and A4, such that A1 = upper left block, ... , A4 = lower right block. say i only ever manipulate block A1 in my calculations. also, i only ever want to write block A1 (and not any of the other blocks) to either the screen or a file. my questions are:-
1) do i need to initialise (i.e. set equal to zero) the ENTIRE CONTENT of matrix A (i.e. ALL blocks) during my calculations ? or do i only need to initialise block A1 ?
2) do i need to initialise (i.e. set equal to zero) block A1 if it is only ever used as a DIRECT CALCULATION SUM variable ? or only if it is used as a CUMULATIVE SUM variable ? or both ?
in summary, my questions are saying :- it helps to initialise (i.e. set equal to zero) variables. but, is it always NECESSARY ?
such variables include "CUMULATIVE SUM Variables (CSV's)", and "DIRECT CALCULATION SUM Variables (DCSV's)". an example of each (as applied to a scalar variable) is given below.
CUMULATIVE SUM Variables
------------------------
SUM = 0.0
DO I = 1 , N
SUM = SUM + REAL(I) + 3.0
END DO
the important line is "SUM = 0.0" (i.e. it initialises SUM to be equal to zero)
DIRECT CALCULATION SUM Variables
--------------------------------
DO I = 1 , N
SUM = REAL(I) + 3.0
END DO
note that the line "SUM = 0.0" is not included here
my question is:- like CSV's, do DCSV's also always need to be set equal to zero (i.e. initialised) first, before they are manipulated ? i.e. is the line "SUM = 0.0" also needed (before the DO loop) in the "DIRECT CALCULATION SUM variables" example above ? or is the "DIRECT CALCULATION SUM variables" example above correct "as it is" ?
another example (as applied to a matrix variable) is as follows.
say i have a matrix A. the matrix is, say, 1000 x 1000, and is "partitioned" into the equal-size blocks A1, A2, A3 and A4, such that A1 = upper left block, ... , A4 = lower right block. say i only ever manipulate block A1 in my calculations. also, i only ever want to write block A1 (and not any of the other blocks) to either the screen or a file. my questions are:-
1) do i need to initialise (i.e. set equal to zero) the ENTIRE CONTENT of matrix A (i.e. ALL blocks) during my calculations ? or do i only need to initialise block A1 ?
2) do i need to initialise (i.e. set equal to zero) block A1 if it is only ever used as a DIRECT CALCULATION SUM variable ? or only if it is used as a CUMULATIVE SUM variable ? or both ?
in summary, my questions are saying :- it helps to initialise (i.e. set equal to zero) variables. but, is it always NECESSARY ?