Silverfrost Forums

Welcome to our forums

Use of function statement

25 Mar 2013 5:24 #11877

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 !*****************************************

25 Mar 2013 6:21 #11879

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

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 
!***********************************************
26 Mar 2013 12:49 #11888

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 ???

26 Mar 2013 1:43 #11889

Quoted from AsifArshid

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.

Please login to reply.