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!

writing to array again!

Status
Not open for further replies.

milenko76

Technical User
Mar 26, 2010
100
PT
Well I have already posted before,but even with much help from other collegues it didn't work.
do i=1,nsites
do ico=1,nc
if(ivarp(ico).ne.0)then
iprd=ivarp(ico)
apr4sens(1,i,iprd)=apr1dsens(i,iprd)
apr4sens(2,i,iprd)=apr2dsens(i,iprd)
apr4sens(3,i,iprd)=apr3dsens(i,iprd)
apr4sens(4,i,iprd)=apr4dsens(i,iprd)
endif
enddo
enddo

do i=1,nsites
do ico=1,nc
if(ivarp(ico).ne.0)then
iprd=ivarp(ico)
do k=1,4
write(128,*)apr4sens(k,i,iprd)
enddo
endif
enddo
enddo
I am giving relevant part of the code.I write apr4sens into file.Works fine.But how to write it to new array?I need new array which I could reshape,transpose and so on.Idea from Jaques:
group(1,:,:)= apr1dsens
group(2,:,:)= apr2dsens
group(3,:,:)= apr3dsens
group(4,:,:)= apr4dsens
IT DOESN'T WORK HERE!
 
You always says IT DOESN'T WORK but instead of saying that, give us the exact errors you get.

François Jacq
 
group(1,:,:)=apr4sens(1,:,:)
group(2,:,:)=apr4sens(2,:,:)
group(3,:,:)=apr4sens(3,:,:)
group(4,:,:)=apr4sens(4,:,:)
write(129,*)group(1,:,:)
So look at the 129:
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00 0.0000000E+00
1.1146036E-18 1.0013734E-17 9.7208492E-17 1.1153194E-14 6.4194106E-14
3.0180556E-13 -2.2681663E-13 -1.1817485E-12 -1.0094252E-11 -1.4589319E-11
-1.8142579E-11 -4.0421073E-11 -6.1167571E-11 -3.2316261E-11 -7.4088574E-12
-1.2522965E-13 -9.7353689E-15 -3.4710390E-15 9.3333629E-16 1.1046225E-16
First comes 220 zeros,why?
This is just part of the file,instead of 420 it gives me 27200 numerical values.
I have deifined group here:
c Sensitivities of the MT functions for one period of the EM filed
c at all surface nodes and for all domains which have been flagged
c for the sensitivity evaluation. In the present version, only MT
c impedances are considered, not the induction arrows!
real*4 zmd1psens(nmax,nfmax,ncmax)
real*4 zmd1psens2(nmax,nfmax,ncmax)
real*4 apr1dsens(npmax,ncmax)
real*4 apr2dsens(npmax,ncmax)
real*4 apr3dsens(npmax,ncmax)
real*4 apr4dsens(npmax,ncmax)
c
c Aggregate version of the above array for all periods. May become
c pretty huge!!!
real*4 zmdsens(npmax,nmax,nfmax,ncmax)
real*4 zmdsens2(npmax,nmax,nfmax,ncmax)
c Aggregate version od sensitivity matrix which need to be reshaped
real*4 apr4sens(nfmax,npmax,ncmax)
real*4 group(nfmax,npmax,ncmax)
params.for:
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)
integer*4 ndmax
parameter(ndmax=4)
integer*4 ngmax
parameter(ngmax=1680)
c
c Maximum number of uniform conductivity domains in the 2D model
integer*4 ncmax
parameter(ncmax=(nmax-1)*(mmax-1))
c domains for which sensiticity is calculated
integer*4 ncs
parameter(ncs=100)
c Maximum number of iterations
integer*4 itermax
parameter(itermax=50)
integer*4 nnmax
parameter(nnmax=21)
integer*4 nvmax
parameter(nvmax=57)
integer*4 ntmax
parameter(ntmax=3)
integer*4 n4mat
parameter(n4mat=21)

end module
 
Sorry but there is no guaranty that the array apr4sens has been entirely set. I even remember that the first column (iprd=1) was never used in a previous version of the code.

To demonstrate that, print apr4sens instead of group. You should get exactly the same answer. You should also initialize the array apr4sens to a predefined value not used by your code, -1 for instance.

In addition, instead of 4 assignments instructions, only one is needed :

group=apr4sens

So, for me, there is no problem but you clearly don't understand the exact contents of your arrays.

François Jacq
 
apr4sens is written into 128,I get 1680 numerical values all of them all rihgt.
do i=1,nsites
do ico=1,nc
if(ivarp(ico).ne.0)then
iprd=ivarp(ico)
do k=1,4
write(128,*)apr4sens(k,i,iprd)
enddo
endif
enddo
enddo
k=4,i=20,iprd=21
where should I put group=apr4dsens?
Outside of the loop?
 
[quote}
apr4sens is written into 128,I get 1680 numerical values all of them all rihgt.
[/quote]

No ! This is not true ! You write on the file 128 only a PART of the array apr4sens. This is why you need a complicate way to determine what part you want to write.

As you have constructed the array apr4sens using the same similar set of instructions applied to print it onto the file 128, I strongly suspect that a part of that array has never been defined.

So please, to convince you :
- add the instruction apr4sens=-1 BEFORE the loops initializing that array
- replace "group" by "apr4sens" when writing on the file 128

You should see many values -1 in the file 128 (all the elements of the array which have never been initialized).

where should I put group=apr4dsens?
Outside of the loop?
[/quote}

Obviously !


François Jacq
 
You are right!I have followed your instructions,get file with many values -1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top