FORTRAN - Assigning an array value to variable

clueless_programmer

Is there a way to get the value of an array to the shape of a variable? Even when I select a single value of an array, say A(1:1, 1:1), it still complains when I compile and want to assign this to a variable:

Error: Incompatible ranks 0 and 1 in assignment at (1)

The goal in the end is something like this:

H = MAXVAL(matrix) - epsilon
IF ( matrix(i:i, i:i) >= H ) THEN

... but I cannot make this comparison because H is a variable and matrix(i:i, i:i) a 1x1 array. Is the only possibility for this to work to make H and array, too?

Thank you for your help!

Alexander Vogt

Do not specify a range, use a single element:

A(1,1)=1

Your statement would then read:

H = MAXVAL(matrix) - epsilon
IF ( matrix(i, i) >= H ) THEN

Background:

Fortran allows you to work on sub-arrays like:

A(1:10,2:5)

which would be a 10x4 array. So A(1:1,1:1) is in fact an array (1x1) (as you noted). A(1,1), on the other hand, is a scalar and can be treated as such.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Assigning Array Value to variable PHP

From Dev

Assigning a character array in Fortran

From Dev

Temp variable not assigning right value from array

From Dev

Assigning value to element in array changes other variable

From Dev

Assigning a DataTable value to a Variable

From Dev

Assigning value for a class variable

From Dev

Assigning a Variable and a Column to a Value

From Dev

condition is not assigning value to the variable

From Dev

Assigning value to global variable

From Dev

Assigning ArrayList value into a Variable

From Dev

jQuery assigning value to array giving error Undefined variable

From Dev

assigning a value to a variable from an array with a sorting like conditions

From Dev

Why assigning new array to variable changes its reference not value?

From Dev

assigning value to an array

From Dev

Assigning a random value to an array

From Dev

Awk not assigning value of field to variable

From Dev

Assigning a value in SQLite cursor to a variable

From Dev

Assigning a value to a variable randomly, but not working

From Dev

Webpack not assigning value to environment variable

From Dev

assigning variable value using return

From Dev

Assigning array reference to session variable

From Dev

Assigning PHP variable to PHP array

From Dev

Assigning a value to a structs flexible array

From Dev

Assigning value to array at certain index

From Dev

Assigning a priority value to objects in an array

From Dev

Fortran variable has different value

From Dev

Fortran variable has different value

From Dev

Assigning value of static variable to a class variable

From Dev

Assigning value of a variable to another variable in TCL

Related Related

HotTag

Archive