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!

Need help putting data in a 3d array Part 2

Status
Not open for further replies.

doggod22

Technical User
Jun 16, 2010
4
US
I need help with my program. I changed x y and z to integer
and my concentration value is back to the value it is supposed to be. The problem I have is that the concentration is supposed to get stored in the array g but all the values of the array is just 0.



! This program will calculate pollutant concentration profile
! in x direction based on down wind distance from the source

Real q, u, s, t, h, w, i, j, k, l, o
Character p, a, b, c, d, e, f
Real g(21,21,7)
Integer n, m, x, y, z

! The variables used are as follows:
! q=Emission Rate (g/s) ,u= wind velocity, s=sigma y (m),
! t=sigma z calculation (m), i=Ry, j=ry k=Rz, l=rz coefficient
! w=concentration (g/m^3), o= placeholder variable in w calc
! (a-f) = stability estimate p=placeholder (ph) coefficient
! n= ph for intensity of solar radiation, m= ph for day/night
! x= dist in plume direction (m), y= horiz dist off plume axis (m)
! z=height (m), h= emission height (m)

Print*, 'This will calculate concentration by Gaussian Model.'
Print*, 'Some parameters are needed for the calculation'
Print*, 'What is the emmission rate?'
Read*, q
Print*, 'Next what is the wind velocity?'
Read*, u
Print*, ' Is there daylight or is it at night?'
Print*, ' Please enter 1 for day or 2 for n.'
Read*, m

IF (m == 1) THEN

Print*, 'How intense is solar radiation? Enter 1 for strong,'
Print*, '2 for moderate, and 3 for weak.'
Read*, n
IF (n == 1) THEN

IF (u < 2.5) THEN
p='a'
Print*, 'What is the emmission height?'
Read*, h
ELSE IF (u < 5) THEN
p='b'
Print*, 'What is the emmission height?'
Read*, h

ELSE
p='c'
Print*, 'What is the emmission height?'
Read*, h
END IF
END IF

IF (n == 2) THEN

IF (u < 2) THEN
p='a'
Print*, 'What is the emmission height?'
Read*, h

ELSE IF (u < 4) THEN

p='b'
Print*, 'What is the emmission height?'
Read*, h

ELSE IF (u<5.5) THEN
p='c'
Print*, 'What is the emmission height?'
Read*, h

ELSE
p='d'
Print*, 'What is the emmission height?'
Read*, h

END IF

ELSE IF (n == 3) THEN
IF (u < 2) THEN
p='b'
Print*, 'What is the emmission height?'

Read*, h

ELSE IF (u < 5) THEN
p='c'
Print*, 'What is the emmission height?'
Read*, h

ELSE
p='d'
Print*, 'What is the emmission height?'
Read*, h

END IF
END IF

IF (m == 2) THEN
IF (u < 3.5) THEN
p='f'
Print*, 'What is the emmission height?'
Read*, h


ELSE IF (u < 5) THEN
p='e'
Print*, 'What is the emmission height?'
Read*, h

ELSE
p='d'
Print*, 'What is the emmission height?'
Read*, h

END IF

END IF


IF (p == 'a') THEN
l=.469
i=.903
j=.017

k=1.380

ELSE IF (p == 'b') THEN
l=.306
i=.885
j=.072
k=1.021

ELSE IF (p == 'c') THEN
l=.230
i=.885
j=.076
k=.879

ELSE IF (p == 'd') THEN
l=.219
i=.764
j=.140
k=.727

ELSE IF (p == 'e') THEN
h=.237
i=.691
j=.217
k=.610

ELSE
l=.273
i=.594
j=.262
k=.500
END IF

Write(3,*), ' Xdist Ydist Zdist Pollutant Conc '
do 5000 x = 1, 21
do 5001 y = 1, 21
do 5002 z = 1, 7
s=l*x**i
t=j*x**k
o=(exp(-(z-h)**2/(2*t**2))-exp(-(z+h)**2/(2*t**2)))

w=q/(2*pi*u*s*t)*exp(-y**2/(2*s**2))*o
Write(3,*), ' ',x,' ',y, ' ',z, ' ', w
g(x,y,z)=w
Write(4,*), 'The array value is ...', g(x,y,w)
Print*, g(x,y,z), x, y, z, w


5002 CONTINUE
5001 CONTINUE
5000 CONTINUE

END IF
END



 
You can't use the same variable for the indices in the array as for the content (in general). Your content is real and depends on x,y, and z which are supposed to be reals as well.

You should make separate integer vaiables for the indices of g. For example: g(igx,igy,igz)=some real value, in which igx, igy and igz are integers.

I advice you to read some book on fortran, because knowing the fundamental difference between reals and integers is essential.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top