 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
AsifArshid
Joined: 13 Mar 2013 Posts: 5
|
Posted: Mon Mar 25, 2013 6:24 am Post subject: Use of function statement |
|
|
Hello,
I am using a Plato SilverFrost Personal version(.f95). I am trying to develop a function for the cross product of two vectors, a very simple function as follows. This program is not running. Can anybody help me, either this is program's issue or the version i am using ???
real :: x(3), y(3), cross_product(3)
do i=1,3
x(i) = i
y(i) = i*2
enddo
print *, x
print *, y
print *, cross_product(x,y)
end
!***********************************************
real function cross_product(a,b)
real :: a(3), b(3), cross_product(3)
cross_product(1) = a(2)*b(3) - a(3)*b(2)
cross_product(2) = a(3)*b(1) - a(1)*b(3)
cross_product(3) = a(1)*b(2) - a(2)*b(1)
end function
!*********************************************** |
|
Back to top |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Mon Mar 25, 2013 7:21 am Post subject: |
|
|
There are two problems here:
You have declared the function twice.
When you use an Array function, you must use an explicit interface.
For example, this should work
Code: |
real :: x(3), y(3)
interface
function cross_product(a,b)
real :: a(3), b(3), cross_product(3)
end function
end interface
do i=1,3
x(i) = i
y(i) = i*2
enddo
print *, x
print *, y
print *, cross_product(x,y)
end
!***********************************************
function cross_product(a,b)
real :: a(3), b(3), cross_product(3)
cross_product(1) = a(2)*b(3) - a(3)*b(2)
cross_product(2) = a(3)*b(1) - a(1)*b(3)
cross_product(3) = a(1)*b(2) - a(2)*b(1)
end function
!***********************************************
|
_________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
 |
AsifArshid
Joined: 13 Mar 2013 Posts: 5
|
Posted: Tue Mar 26, 2013 1:49 pm Post subject: Re: |
|
|
Thanks a lot, its working good.
So, one more suggestion, can I use this silverfrost Plato (personal) version for my huge number of particles in my granular material simulation without any problem ??? Or for this purpose, I need to buy full version of this NTF95 ??? |
|
Back to top |
|
 |
mecej4
Joined: 31 Oct 2006 Posts: 1899
|
Posted: Tue Mar 26, 2013 2:43 pm Post subject: Re: |
|
|
AsifArshid wrote: |
So, one more suggestion, can I use this silverfrost Plato (personal) version for my huge number of particles in my granular material simulation without any problem ??? Or for this purpose, I need to buy full version of this NTF95 ??? |
That depends on how huge "huge number" is. FTN95 is a 32-bit compiler. Whether you use the personal or "full" version is entirely a legal/moral issue. The full compiler and the personal compiler have the same limits, with one exception: the personal version throws up a message box when a program compiled with it is run.
If your program is not fully debugged, don't count on "without any problem" regardless of which compiler you use. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|