We restrict us here to those features which are necessary to use
this system and to define test problems of your own, as far as we
provide this. Here is a list:
how to fill input fields
dealing with variables
constants and operators
how to code simple functions
how to write a piece of code
JAKEF restrictions
Input fields
There are three types of input fields for data: text, integers and real numbers.
Text:
We sometimes use text for identifying runs: you may run one and the same application
with different parameter settings and may copy the results to your local window.
In this case this text will help you to discern your results. Sometimes this text is used
as title in plots. Hence you should not use spaces in text, use underscore instead.
Integer input
This concerns dimensions of vectors and matrices, number of steps etc.
You write these as you know it from a typewriter. Usually there are restrictions
on the values allowed, these are explicitly mentioned.
Real numbers
On input, any format is allowed for these numbers: you may write
integers here, the format with a decimal point and/or an exponential
part. These exponential parts can be written with the "e" as you
might know it from your pocket calculator but also with a "d" .
Capitals or small letters make no difference. For example you might
write the number 1001 as
1001, 1.001e3, 1.001d3, 10.01e2, 1001.0, ...
There is only one small trap: the "d" denotes "double precision".
Unlike for example to C f77 has as default single precision, i.e. about
7 digits precision, whereas the "d" stands for "double precision" (about 16 digits).
Should you wish as input indeed π to 16 digits, then
you must write
3.1415926535897932d0If a list of numbers is required, then you might always use something like 3*0 instead of 0,0,0,. Separators for numbers are comma, blank and newline.
Variables
If you want to define test cases yourself, then
you will have to know a little bit about variables in f77.
First of all: there is no discern between capital and small letters,
hence whether you write X or x makes no difference.
The names of all variables are preset by us, you never can define variables yourself.
Should you feel that our provisions for these are not sufficient in some
cases, then drop us a note. Read carefully the text in the input forms,
where these names are always listed. The types of variables we allow
are integers (for counting and indices) , boolean variables, which may be
useful as shorthand for evaluations of comparisons like
bool1= ( (x-1.0d0)*(4.0d0-x) .ge. 0.d0 ) .and. ( y*(7.d0-y) .ge. 0.d0 )(for expressing that (x,y) is in the rectangle [1,4] × [0,7]), double precision numbers, vectors and matrices (with two dimensions), written like
X, Y(3), a(1,2), ....If nothing is said explicitly, the smallest index in vectors and matrices is always 1 and the upper index bound is mentioned always explicitly.
Functions
For your ease of use we have a special input form for simple functions,
which can be expressed as one arithmetic expression.
You see this on an input form where the function symbol apprears outside
the input field like
f(x) =
(x+1.d0)/(x**2-1.d0)*2.d0means
z=max(1.d0,min(10.d0,x**2-3.d0))
X=1/3delivers 0 , (the compiler evaluates everything in its own mode, but allows mixed mode. Hence 1/3 is evaluated within the integers but 1.0d0/3 gives what you intended!)
Piece of code
Sometimes, especially in the optimization part, you are allowed to enter a complete
piece of program text to compute some values, may be simple values or vectors as result, for example
the product A*x of a matrix and a vector or a vector f which
represents the right hand side of an ordinary differential equation.
An important hint first: edit this text on a local window (outside the browser) and
move it with ''copy and paste'' into the input form. Since, if you go back to some page other than
exactly the current input form then your input will be lost and you would have to do it all again!
In these cases you must obey the classical f77 formating rules.
Of course our present compiler allows a free format input, but since some
important tool which we use to produce automatically code for the (partial) derivatives of a function from
your code for computing only the function requires this old fashioned standard we stick on this.
We realize that this is a bit nasty, but in order to be consistent with all parts of the
system we prefer this way instead of allowing free form input for some applications but not for all.
It is however not that complicated:
Examples
Computation of a matrix vector product y=A*x:
do 200 i=1,n c**** this computes row i times x sum=0.d0 do 100 j=1,n sum=sum+A(i,j)*x(j) 100 continue y(i)=sum 200 continueSolution of a linear system of equations with upper triangular matrix R*x=b
x(n)=b(n)/R(n,n) do 200 i=n-1,1,-1 sum=b(i) do 100 j=i+1,n sum=sum-R(i,j)*x(j) 100 continue x(i)=sum/R(i,i) 200 continue
goto (100,200,300,400,500,600,700) fallcontinues computation at the label number ''fall''.
goto 200(You better did not use that, this leads fast to ''spaghetti code''.)
do i=1,n { some instructions } enddo(i.e. no label anymore) and
if ( logical value ) then { some instructions } elseif ( another logical value ) then { some instructions } { more instructions } else { some instructions } endif
Have fun!! JAKEF restrictions
JAKEF needs strict ANSI FORTRAN 1977.
JAKEF (from netlib) is our automatic differentiator. Given a subprogram to compute a
function it produces another subprogram for computing the function and its first derivatives.
Hence this is a nice tool to produce analytically evaluable derivatives automatically.
(Meanwhile there are available much more powerful tools for this, but these are not in the public
domain. See under ''Other sources'' , optimization).
JAKEF does not correctly handle calls and function references that
involve the independent variables unless the function is one of the
following: SIN/DSIN, COS/DCOS, ATAN/DATAN, EXP/DEXP, ALOG/DLOG,
SQRT/DSQRT, TAN/DTAN, ASIN/DASIN, ABS/DABS, SINH/DSINH and COSH/DCOSH.
Calls and references to other functions are misinterpreted without
warning by the JAKEF differentiator (and give wrong results).
Note also that except for those
in the above list JAKEF declares with default typing all functions not
explicitly declared in the input program.
JAKEF does not allow the constructs
do i=1,n
{ some instructions }
enddo
and
do while (
and
if ( logical value ) then
{ some instructions }
elseif ( another logical value ) then
{ some instructions }
{ more instructions }
else
{ some instructions }
endif
If you use some construction which is not allowed by the automatic differentiator
JAKEF, then the error message will usually be only ''unrecognized keyword''
or some other even more mysterious messages like ''label ... referenced but not defined ''
whereas you never had in mind to set a label.
Hence in this case use the restricted instruction set only!
29.04.2016