Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reshape problem

Status
Not open for further replies.

milenko76

Technical User
Mar 26, 2010
100
PT
My module:
module kstep
implicit none
contains

subroutine kpr(iter,l,lt,koef)
integer:: i,j
real,allocatable,dimension:)),intent(in) :: l
real,allocatable,dimension:)),intent(in) :: lt
real,allocatable,dimension:)),intent(out) :: koef
integer,intent(in) :: iter
real,dimension(21:1) :: l1
real,dimension(21:1) :: lt1
real,dimension(1:21) :: tlt
real,dimension(80:1) :: a
real,dimension(21:1) :: b
integer,dimension(21,21) :: wm
integer,dimension(80,80) :: wd
real, dimension(80,21) :: sens
real :: norm2a, norm2b,z1,z2

l1=reshape(l,shape=shape(l1))
lt1=reshape(lt,shape=shape(lt1))
tlt=transpose(lt1)
z1=tlt*l1

do j=1,21
do i=1,80
read(114,*)sens(i,j)
end do
end do

do j=1,80
do i=1,80
read(17,*)wd(i,j)
end do
end do

swd=matmul(wd,sens)
a=matmul(swd,lt1)
norm2a=(sum(a(1:80,1:1)**2))

do i=1,21
read(18,*)(wm1(i,j),j=1,21)
end do

x=iter-1
alpha=300*(0.92)**x

b=matmul(wm,lt1)
norm2b=(sum(b(1:21,1:1)**2))
z2=norm2a+alpha*norm2b
koef=z1/z2

end subroutine
end module
I got this:
kstep.for(24): error #6373: Two-dimensional array-valued arguments are required in this context. [TRANSPOSE]
tlt=transpose(lt1)
--------------------^
kstep.for(24): error #6366: The shapes of the array expressions do not conform. [TLT]
tlt=transpose(lt1)
So I didn't manage to reshape rank1 to rank2 array.Why?
 
Not sure what the following does
Code:
real, dimension(21:1):: lt1
Transpose needs a 2D array. You've only given it a 1D array (I think). It should be (21,1).
 
Also, it does not look like you have allocated any memory to some of your arrays.
 
Code:
real, dimension(21:1):: lt1

As xwb mentioned, this declaration does not do what you expect. it just generates a 1D array of size 0

Demonstration :

Code:
program test
  real :: a(21:1)
  write(*,*) size(a),lbound(a),ubound(a)
end program

Code:
[lcoul@localhost test]$ ifort t40.f90
[lcoul@localhost test]$ ./a.out
           0           1           0



François Jacq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top