I'm following the "Fortran 95/2003 for Scientists and Engineers"
textbook and I got at the WHERE statement. The book present the
following sample:
WHERE ( value> O. )
logval LOG(value)
ELSEWHERE
logval = -99999.
END WHERE
whith 'logval' and 'value' two matrices of the same dimension. I copied
the example "as is" in a .f90:
PROGRAM wheretest
implicit none
real, dimension(2,2) :: matrix
real, dimension(2,2) :: log
matrix(1,1) = 23
matrix(1,2) = -1
matrix(2,1) = -1
matrix(2,2) = 17
WHERE (matrix > 0.)
log = LOG(matrix)
ELSEWHERE
log = -99999.
END WHERE
END PROGRAM wheretest
I have the following two compilation errors:
D:\>gfortran-4.exe wheretest.f90
wheretest.f90:19.15:
log = LOG(matrix)
1
Warning: Extension: REAL array index at (1)
wheretest.f90:19.15:
log = LOG(matrix)
1
Error: Array index at (1) is an array of rank 2
I have the following list of newbie-questions:
1. is there any reference where I can search for such error messages to
get what is happening?
2. I noticed that changing the matricex into one-dimensional arrays
everything works fine... is it a difference between f90 and f95? Could
you link me any reference to this issue?
Thanks,
Giulio
p.s. I'm using this compiler on Cygwin on WinXP:
D:>gfortran-4.exe --version
GNU Fortran (GCC) 4.3.2 20080827 (beta) 2
Copyright (C) 2008 Free Software Foundation, Inc.
--
Short of reading the standard document - but:
LOG() is an intrinsic function , but the wheretest program is defining an
array variable with the same name.
Change the definition of log to something else like mlog.
Remove NOREPLY. from Email address.
Joseph Huber, http://www.huber-joseph.de
On 7/29/2011 12:49 PM, Joseph Huber wrote:
> LOG() is an intrinsic function , but the wheretest program is defining an
> array variable with the same name.
> Change the definition of log to something else like mlog.
OMG... Fortran is case insensitive!
I completely forgot this issue. :-/
thanks,
Giulio
--
No, I won't start the which-is-better argument...
-Ken
> I'm following the "Fortran 95/2003 for Scientists and Engineers"
> textbook and I got at the WHERE statement. The book present the
> following sample:
> WHERE ( value> O. )
> logval LOG(value)
> ELSEWHERE
> logval = -99999.
> END WHERE
> whith 'logval' and 'value' two matrices of the same dimension. I copied
> the example "as is" in a .f90:
I presume you want the log element by element. The exponential (exp) of
a matrix can be done, though not so obviously its inverse.
I have a calculator that will do matrix exponential
(not element by element).
-- glen
Just for in case you really want to take the LOG of a matrix:
-> Do you really want to have the LOG of every element?
Or are you looking for a matrix that gives you the infinitesimal rate
of change
needed during integration to yield "MATRIX"?
If you e.g. have a vector equation d/dt X_i = A_ij X_j with unknown
matrix A,
but with known matrix B such that X(t)_i = B_ij X(t=0)_j,
then you would be looking for a different type of "LOG":
-transform the matrix to eigen-system,
-take the LOG of the eigenvalues, and
-transform back to your original system.
Regards,
A.