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!

how to make this authomatically? 1

Status
Not open for further replies.

mikibelavista

Technical User
Jan 18, 2012
32
program col2
implicit none
real,dimension(5,4) :: a
real,dimension(4) :: a1,a2
integer :: i,j

open(10,file='m.dat',status='old')
do i=1,5
read(10,*)(a(i,j),j=1,4)
end do
a1=a(1,:)
call comp(a1,a2)
write(*,*)a2
end program

subroutine comp(b1,b)
real,dimension(4),intent(in) :: b1
real,dimension(4),intent(out) :: b

where (b1 >= 0.32)
b=1
end where
where (b1 >= 0.36)
b=11
end where
where (b1 >= 0.4)
b=111
end where

end subroutine
This is my code,I want sonehow to have more points,so I need extraction process a1=a(1,:) to be done authomatically,but do not know how.Like if i=1
a1 takes first column if i=2 second and so on...
 
Maybe something like this
Code:
do i=1,5
  read(10,*)(a(i,j),j=1,4)
  !
  a1=a(i,:)
  call comp(a1,a2)
  write(*,*)a2
end do
 
Could you give some more information on what you want to achieve ? What do you mean by 'more points' ?

Norbert


The optimist believes we live in the best of all possible worlds - the pessimist fears this might be true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top