19.01.2015 Views

MOLPRO

MOLPRO

MOLPRO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8 VARIABLES 51<br />

The current length of an array can be accessed by preceding # to the variable name. For instance,<br />

in the above examples #R and #METHOD have the values 5 and 4, respectively. If a variable is<br />

not defined, zero is returned but no error occurs. This can be used to test for the existence of a<br />

variable, for example:<br />

IF(#SPIN.EQ.0.AND.#NELEC.EQ.1) SET,SPIN=MOD(NELEC,2)<br />

This defines variable SPIN if it is unknown and if NELEC is a scalar (one dimensional) variable.<br />

8.7 Vector operations<br />

The following simple vector operations are possible:<br />

• Copying or appending a vector to another vector. For instance S=R copies a vector R<br />

to a vector S. S(3)=R copies R to S(3), S(4), .... S(#S+1)=R appends vector<br />

R to vector S. It is also possible to access a range of subsequent elements in a vector:<br />

S=R(2:4) copies elements 2 to 4 of R to S(1), S(2), S(3). Note that R(2:)<br />

denotes elements R(2) to R(#R), but R(2) denotes a single element of R.<br />

• Vector-scalar operations: R=R*2 multiplies each element of R by 2. Instead of the number<br />

2, also scalar (one dimensional) variables or expressions can be used, e.g., R=R*ANG<br />

converts all elements of R from Ångstrøm to bohr, or Z=R*COS(THETA) creates a vector<br />

Z with elements Z(i) = R(i)*COS(THETA). All other algebraic operators can be<br />

used instead of “*”.<br />

• Vector-vector operations: If A and B are vectors of the same length, then A × B is also a<br />

vector of this length. Here × stands for any algebraic operator, and the operation is done<br />

for each pair of corresponding elements. For instance, A + B adds the vectors A and B,<br />

and A * B multiplies their elements. Note that the latter case is not a scalar product. If<br />

an attempt is made to connect two vectors of different lengths by an algebraic operator,<br />

an error occurs.<br />

• Intrinsic functions: Assume THETA=[100,110,120,-130] to be a vector of angles<br />

(in degrees). In this case X=2*COS(THETA) is also a vector containing the cosines of<br />

each element of THETA multiplied by two, i.e., X(i) = 2*COS(THETA(i)). MAX(THETA)<br />

or MIN(THETA) return the maximum and minimum values, respectively, in array THETA.<br />

Vector operations can also be nested, e.g., MAX(ABS(THETA)) returns the maximum<br />

value in array ABS(THETA).<br />

At present, vector operations are not supported with string variables.<br />

8.8 Special variables<br />

8.8.1 Variables set by the program<br />

A number of variables are predefined by the program. The following variables can be used to<br />

convert between atomic units and other units:<br />

EV=1.d0/27.2113961d0 HARTREE<br />

KELVIN=1.d0/3.157733d5 HARTREE<br />

KJOULE=1.d0/2625.500d0 HARTREE<br />

KCAL=1.d0/627.5096d0 HARTREE

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!