econ2008
Programmer
- Jul 26, 2010
- 9
Hello!
I have a question concerning the combination of scalars and arrays. In the code i am working with the following is defined (in parentheses of what dimension i think those are):
REAL(WP), DIMENSION), INTENT(IN) :: a (vector)
INTEGER, ALLOCATABLE, DIMENSION, :: hmax (2D matrix)
REAL(WP), ALLOCATABLE, DIMENSION) :: b (vector)
REAL(WP), ALLOCATABLE, DIMENSION, :: f,pv (2D matrix)
INTEGER :: hmin, imax(1)
REAL :: MU
Later in the code it is set: hmin=1 and hmax(j,i)=count(a<f(j,i) then the following is used with i=1,n and j=1,m.
b(hmin:hmax(j,i))=(f(j,i)-a(hmin:hmax(j,i)))**(1-MU)/(1-MU)+pv(j,hmin:hmax(j,i))
As far as i understood, when i use count(), the result is a scalar of type integer. But hmax(j,i) is a matrix, isn't it? So do I understand right that hmax() becomes a matrix filled with the same scalar in every row and coloummn? But then I do not understand of what size b is (vector or matrix)?
I am still a new to fortran, although i have learned a lot in the last months, this one really confuses me. I hope someone can help me!
Thanks in advance.
econ
I have a question concerning the combination of scalars and arrays. In the code i am working with the following is defined (in parentheses of what dimension i think those are):
REAL(WP), DIMENSION), INTENT(IN) :: a (vector)
INTEGER, ALLOCATABLE, DIMENSION, :: hmax (2D matrix)
REAL(WP), ALLOCATABLE, DIMENSION) :: b (vector)
REAL(WP), ALLOCATABLE, DIMENSION, :: f,pv (2D matrix)
INTEGER :: hmin, imax(1)
REAL :: MU
Later in the code it is set: hmin=1 and hmax(j,i)=count(a<f(j,i) then the following is used with i=1,n and j=1,m.
b(hmin:hmax(j,i))=(f(j,i)-a(hmin:hmax(j,i)))**(1-MU)/(1-MU)+pv(j,hmin:hmax(j,i))
As far as i understood, when i use count(), the result is a scalar of type integer. But hmax(j,i) is a matrix, isn't it? So do I understand right that hmax() becomes a matrix filled with the same scalar in every row and coloummn? But then I do not understand of what size b is (vector or matrix)?
I am still a new to fortran, although i have learned a lot in the last months, this one really confuses me. I hope someone can help me!
Thanks in advance.
econ