replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - FTN95 Application Extension error, passing Fortran array
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FTN95 Application Extension error, passing Fortran array

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
ebarbero



Joined: 01 Aug 2012
Posts: 20

PostPosted: Thu Aug 16, 2012 7:29 pm    Post subject: FTN95 Application Extension error, passing Fortran array Reply with quote

I get the error:
"An unhandled exception of type 'System.InvalidProgramException' occurred in Ftn95.dll"
"Additional information: Common Language Runtime detected an invalid program."

I have a C# code:
Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Ftn95.Sub1();
            Console.ReadLine();
        }
               
    }
}


where, in a FTN95 Application Extension, I have

Code:

subroutine Sub1 ()
    implicit none
    ASSEMBLY_INTERFACE (NAME="Sub1")
    double precision A(3,3), B(3,3)
    A = 1.d0
    call Sub2 (A,B)
    write(*,*) B
end subroutine


and
Code:

subroutine Sub2 (A,B)
    implicit none
    ASSEMBLY_INTERFACE (NAME="Sub2")
    double precision A(:,:), B(:,:)
    B = A
end subroutine


What is wrong? Question

Config. Manager:
Debug
CSharp: x86
Ftn95: .NET
_________________
http://www.cadec-online.com/
Back to top
View user's profile Send private message Visit poster's website
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Thu Aug 16, 2012 11:23 pm    Post subject: Reply with quote

I can't comment on your interface between Fortran and C, but you need a fortran definition to define the interface between Sub1 and Sub2, as below:
Code:
subroutine Sub1 ()
    implicit none
    ASSEMBLY_INTERFACE (NAME="Sub1")
    double precision A(3,3), B(3,3)

   interface
     subroutine Sub2 (A,B)
      double precision A(:,:), B(:,:)
     end subroutine Sub2
   end interface

    A = 1.d0
    call Sub2 (A,B)
    write(*,*) B
end subroutine
 
subroutine Sub2 (A,B)
    implicit none
    double precision A(:,:), B(:,:)
    B = A
end subroutine


John
Back to top
View user's profile Send private message
ebarbero



Joined: 01 Aug 2012
Posts: 20

PostPosted: Sat Aug 18, 2012 11:48 am    Post subject: Utility to automatically add Fortran Interface Reply with quote

Yes, of course, and thank you. Sorry for the silly question. I have been working with Intel Interoperative Systems, which I guess does the interfaces in the background for me.

I have many Fortran routines that call each other. I added ASSEMBLY_INTERFACE to some of them to be able to call them from C#. For this, I already changed the old fixed arrays, say A(3,3), for assumed size A(:,: ) if they appeared as dummy arguments. Now I have to go back and add the interfaces manually for any internal arrays (that are not dummy arguments), if they appear in a call to another routine to which I added ASSEMBLY_INTERFACE.

Does anyone know of any utility that would add the interfaces automatically?

Is there any way to set the Fortran95 compiler to treat all arrays as dynamic, thus avoiding having to write an Interface EVERY time one needs to use a Function or Subroutine?
_________________
http://www.cadec-online.com/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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