...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
forall (i=1:10)
where (a(i,:) == a(i,:))
check=check+1
check=b(i)
end where
end forall
end program
But:
pck.f90:16.1...
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.
...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 do
20 continue
write(*,*)c
end program
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
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 program
How to solve this,I want to compare b with a,but how...
...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 (64): input conversion error, unit 10, file /home/milenko/futog/s1.dat
I have to put i3 because file has 240 rows.
< 232| 940.52 |
< 233| 982.62 |
<...
< 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.
Well,just to explain the code is not mine,I am using it for my Phd thesis.So to rewrite it FORTRAN90 does not make sense.The problem is that some parameters are within the code,so the code is compiled with them,the other ones are read from numerous input files.it is a little bit tricky to find...
Ok, I have problem with later results.I have so far used only od -h to check vel.mod file.
My question is for example if my programme can be written somehow in different way using do loops but to read these 7 data files?
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.