Turtleworld
Programmer
Hi,
I have started to learn this language to work on some math/physics oriented programs. Being new to the language, I have some rather 'newbie' questions. Your help would be appreciated.
1) I want to output several things to the screen on one line. I have been using write(*,*) which seems to act similar to
print "<statement>\n" or system.out.println, or cout << "<statement>" << endl, in other languages. Is there a way I can print things without ending the line?
2) To declare large reals, I have used real*8 to reserve 8 bytes of memory for my real variable. Is there a way to reserve more memory for variables? (I need this for sensitive calculations with many iterations). For example, something like real*128 myrealvariable.
3)I made a quick program to test subroutines. The code is as follows (please skim it.. it's not very long),
c Tests the dot product program (main)
program vtest
integer n = 9
real*8 v1(*), v2(*)
do i=1, n
v1(i)=1
v2(i)=1
enddo
real*8 dotp
dotp = vectordot(n, v1, v2)
write(*,*) dotp
AND the subroutine
c Dot product of two vectors.
subroutine vectordot(n, v1, v2)
integer i, n
real*8 v1(*), v2(*)
real*8 dot
dot = 0
do i=1, n
dot = dot + v1(i)*v2(i)
enddo
return dot
end
When I compile I get -->
f77 -g vtest.f vectordot.f -o vtest
vtest.f:
MAIN vtest:
"vtest.f", line 7: Error: declaration among executables
"vtest.f", line 14: Error: declaration among executables
vectordot.f:
vectordot:
What am I doing wrong?
Also, why can't I declare the vectors in the main program as say, real*8 v1, v2?
Thanks for your time.
I have started to learn this language to work on some math/physics oriented programs. Being new to the language, I have some rather 'newbie' questions. Your help would be appreciated.
1) I want to output several things to the screen on one line. I have been using write(*,*) which seems to act similar to
print "<statement>\n" or system.out.println, or cout << "<statement>" << endl, in other languages. Is there a way I can print things without ending the line?
2) To declare large reals, I have used real*8 to reserve 8 bytes of memory for my real variable. Is there a way to reserve more memory for variables? (I need this for sensitive calculations with many iterations). For example, something like real*128 myrealvariable.
3)I made a quick program to test subroutines. The code is as follows (please skim it.. it's not very long),
c Tests the dot product program (main)
program vtest
integer n = 9
real*8 v1(*), v2(*)
do i=1, n
v1(i)=1
v2(i)=1
enddo
real*8 dotp
dotp = vectordot(n, v1, v2)
write(*,*) dotp
AND the subroutine
c Dot product of two vectors.
subroutine vectordot(n, v1, v2)
integer i, n
real*8 v1(*), v2(*)
real*8 dot
dot = 0
do i=1, n
dot = dot + v1(i)*v2(i)
enddo
return dot
end
When I compile I get -->
f77 -g vtest.f vectordot.f -o vtest
vtest.f:
MAIN vtest:
"vtest.f", line 7: Error: declaration among executables
"vtest.f", line 14: Error: declaration among executables
vectordot.f:
vectordot:
What am I doing wrong?
Also, why can't I declare the vectors in the main program as say, real*8 v1, v2?
Thanks for your time.