Seems easy - doesn't this work?
integer N = 5, M = 5 ! or whatever
integer SpecifiedValue = -1 ! or whatever
real RealArray(1 : N, 1: M)
! set the whole int array to SpecifiedValue; most of it will get covered up anyway
integer IntArray(0 : N + 1, 0 : M + 1) = SpecifiedValue
..
read [or otherwise set up] RealArray
IntArray(0 : N + 1 , 0 : M + 1) = RealArray(1 : N , 1 : M) ! OR ... = RealArray
..
= Loren P Meissner
-----Original Message-----
From: Fortran 90 List [mailto:[log in to unmask]] On Behalf Of Craig Shirley
Sent: Monday, February 23, 2004 2:02 PM
To: [log in to unmask]
Subject: Array help requested
Hi,
I a simple problem that I haven't been able to solve:
I want to create a (zero to n+1 by zero to m+1 integer array) from a (1 to
n by 1 to m real array) = that is, = (IntArray(0:n+1,0:m+1) from RealArray(1:n,1:m).
The real array consists of zeros and minus 1 values. The resulting
integer array should have the integer transformed real values surrounded
by a frame of specified values (-1 in the following example).
Example real array input:
0.0 -1.0 0.0 -1.0 0.0
-1.0 0.0 0.0 -1.0 0.0
0.0 -1.0 -1.0 0.0 0.0
-1.0 0.0 0.0 -1.0 0.0
0.0 -1.0 -1.0 0.0 0.0
Desire Result
-1 -1 -1 -1 -1 -1 -1
-1 0 -1 0 -1 0 -1
-1 -1 0 0 -1 0 -1
-1 0 -1 -1 0 0 -1
-1 -1 0 0 -1 0 -1
-1 0 -1 -1 0 0 -1
-1 -1 -1 -1 -1 -1 -1
I initially tried a nested set of do loops like
Do j = 1, m
Do i = 1, n
IntArray(i,j) = Int(RealArray(i,j))
Enddo
Enddo
IntArray was incorrect.
Then I tried IntArray(1:n,1:m) = RealArray(1:n,1:m)
IntArray was still incorrect.
Any suggestions?
Craig Shirley
Desert Research Institute
755 East Flamingo
Las Vegas, Nevada USA 89119
Voice: (702) 862-5454
Fax: (702) 862-0427
"Without deviation from the norm, progress is not possible." -- Frank
Zappa
|