I have array and I want to compare elements,how many 100.3 10.0 pairs do I have
100.3 10.0
110.0 10.0
100.3 10.0
I have tried this:
program pck
implicit none
real,dimension(10,2) :: a
integer,dimension(10) :: b
integer :: i,check
open(10,file='pic.txt')
do i=1,10
read(10,*)a(i,:)
end do...
I am translating some code form matlab to fortran90,I need to generate random numbers for matrix.
This is how MATLAB code looks like,and gives me the same values all the time.
rand('state',0)
v = 2*(ones(c,1)*aa).*(rand(c,n)-0.5) + ones(c,1)*mm;
Is there any idea how to solve this in FORTRAN?
No, take a look:
do x=1,n
read(30,*)a(x)
end do
forall(x=1:n, i=1:33,b(i)==a(x))
c(i+x-x)=i
end forall
do i=1,33
write(31,88)c(i)
88 format(i8)
I got exactly the same 33 instead of 27 values.
STILL I HAVE PROBLEMS
module m4
contains
subroutine mm(iter,n,b)
integer,intent(in) :: iter,n
integer,dimension(33),intent(in) :: b
integer :: id1,id2,i,x
integer,dimension(:),allocatable :: a
integer,dimension(33) :: c
character(6) :: tfile=" .nmf"...
Thanks,I have done it this way.
program comp
implicit none
integer :: i,n
real,dimension(17) :: a
real,dimension(29) :: b,c
open(10,file='01.txt',status='old')
open(11,file='frekvencije.dat',status='old')
read(10,*)a
read(11,*)b
do 20 n=1,17
do i=1,29
if (b(i)==a(n)) then
c(i)=i
end if
end...
ok.For example a=(/2,5,6,7,9/) and b=(/1,2,3,4,5,6,7,8,9) What I want is to get c=(/0,2,0,0,5,6,7,0,9,/).
I had tried with nested do looped but it didn't work well.
I have program like this
program comp
implicit none
integer :: i
real,dimension(17) :: a
real,dimension(29) :: b,c
open(10,file='01.txt',status='old')
open(11,file='frekvencije.dat',status='old')
read(10,*)a
read(11,*)b
do i=1,29
if (b(i)==a(1)) then
c(i)=i
end if
end do
write(*,*)c
end...
Well it does not work.
program cz
implicit none
integer :: i
integer,dimension(240) :: x
real,dimension(240) :: y
open(10,file='s1.dat',status='old')
open(11,file='time01.dat',status='unknown')
do i=1,240
read (10,50) x(i),y(i)
50 format(2x,i3,2x,f9.6)
end do
write(11,*)y
end
forrtl: severe...
< 1| 255.33 |
< 2| 32.233353 |
< 3| 27.115475 |
< 4| 24.594143 |
< 5| 32.685696 |
< 6| 21.042452 |
< 7| 47.647877 |
< 8| 92.553001 |
< 9| 96.665306 |
How to format < and |.I have tried with a2 like character but it does not work.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.