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!

allocate issue

Status
Not open for further replies.

milenko76

Technical User
Mar 26, 2010
100
PT
I have problems with my code.As a result of calculation I got rank2 l(21,1) array.Due to the THE ITERATIVE PROCESS I will get the same array in every iteration.How to allocate values and use them later.Should I create new array
like lbig(iter,nmax,1)=l(nmax,1)?
 
First of all a question : why do you get such strange matrix of rankb2 l(21,1), i.e. a single column ? Why not simply a vector l(21) ?

If you want to store all iterative results, then you have several possibilities :
- writing the successive results in a file,
- storing the results in a large matrix like lbig(nmax,nitermax). I prefer to use the last index for the iteration but this is mainly a question of taste... You don't need to use 3 dimensions for the array lbig.
=> lbig:),iter)=l:),1)
- using a linked list to allocate only the needed memory when a new iteration is performed.

François Jacq
 
Well I have done this but:
lmat=p+q
l=reshape(lmat,shape=shape(l))
lbig:),iter)=l
write(*,*)l
ircg.for(156): error #6366: The shapes of the array expressions do not conform. [LBIG]
lbig:),iter)=l
-------^
real*4 lbig(nmax,itermax) and l(21)
lbig:),iter) is which rank 2 or 1?
 
lbig:),iter) is a vector (rank 1)

Notice that I wrote, in my example : lbig:),iter)=l:),1) and not lbig:),iter)=l

François Jacq
 
No,doesn't work either.
ircg.for(156): error #6351: The number of subscripts is incorrect. [L]
lbig:),iter)=l:),1)
--------------------^
Well I have reshaped l with l=reshape(lmat,shape=shape(l)) and l(21).
 
Show us the actual declarations of all arrays please (especially lbig and l). Without them, we cannot explain the error.

François Jacq
 
integer*4 n1,i,j,icd,ivarprd,k,iper,is,fa,fb,iter,x
integer*4 iprd,iprd0,isite,ico
character fexpdat*200,fmodel*200,fout*200
real*4 prunit,period
real:: g,g1,e,e1
real:: zxy_re_e,zxy_im_e,zxy_re_h,zxy_im_h
real:: sens_zxy_ree,sens_zxy_ime,sens_zxy_reh,sens_zxy_imh
real:: ro_e,ro_h,phase_e,phase_h
real:: sens_ro_e,sens_phase_e,sens_ro_h,sens_phase_h
real:: ro_ed, phase_ed,ro_hd,phase_hd
real:: dmro_e,dmphase_e,dmro_h,dmphase_h
real*4 norm20,norm21
real:: zag21,zag22,koefnumero,dmfnorm
real,dimension(21) :: l
real, dimension(80,21) :: sens,wfm
real, dimension(21,80) :: ist,ftw
integer,dimension(80,80) :: wd,wd2
real,dimension(80,1):: d,zag1
real,dimension(1,21):: trlt
real,dimension(21,1):: l0,p,q,lmat,dlm
integer,dimension(21,21) :: wm,wm2,wm3
lbig is declared in module :
module mt2ddat
c ==============
c Further parameters of the 2D model related to the output data of the
c modeling
use params
c
implicit none
c
c Actual number of periods, number of sites on the surface we are
c interested in
integer*4 np,nsites
c
c Periods of the EM field
real*4 per(npmax)
c
c Positions of the sites of interest in terms of the horizontal
c mesh index (1 is the left margin, N is the right margin);
c IRCPR is a flag indicating that the reciprocity approach will (1)
c or will not (0) used in the sensitivity evaluations
integer*4 isit(nmax),ircpr
c
c MT transfer functions for one single period at all surface mesh
c nodes and MT transfer functions aggregated for all periods computed
real*4 zmd1p(nmax,nfmax),zmd(npmax,nmax,nfmax)
real*4 zmd2p(nmax,nfmax),zmd2(npmax,nmax,nfmax)
real*4 aprph1d(nmax,nfmax)
real*4 sens1p(nmax,nfmax)
real*4 data(nmax,nfmax)
real*4 dmf(nmax,nfmax)
real*4 alpha

c all calculation arrays for inversion
real*4 lbig(nmax,itermax)

end module
c
 
Parameters in this module:
module params
c =============
c Maximum values of parameters of the 2D model
implicit none
c
c Maximum number of mesh lines (including the margins) in the
c horizontal and vertical direction
integer*4 nmax,mmax
parameter(nmax=41,mmax=35)
c
c Maximum number of periods and of various MT transfer functions
integer*4 npmax,nfmax
parameter(npmax=20,nfmax=4)
c
c Maximum number of uniform conductivity domains in the 2D model
integer*4 ncmax
parameter(ncmax=(nmax-1)*(mmax-1))
c Maximum number of iterations
integer*4 itermax
parameter(itermax=50)
end module
 
It works now I have mdae changes ito parameters file.
 
You have a problem because of lbig(nmax,itermax) and l(21) with nmax=41

You should declare either l(nmax) or lbig(21,itermax).

Of course, in setting nmax=21, you solve also your trouble but your code would be a little bit cleaner in declaring the same way all related arrays.

François Jacq
 
Well I have introduced new variable nnmax=21,you are right the second version should be cleaner.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top