View previous topic :: View next topic |
Author |
Message |
jjgermis
Joined: 21 Jun 2006 Posts: 404 Location: N�rnberg, Germany
|
Posted: Fri Oct 16, 2009 10:49 am Post subject: Microsoft COM interfaces |
|
|
Does FTN95 support the Microsoft Component Object Model?
I have seen a very simple example of how to use the COM interface with the Intel compiler. And now of course I would like to use FTN95 as well as this will make a lot of other stuff we do a lot easier, i.e. keep our FTN95 code. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8211 Location: Salford, UK
|
Posted: Fri Oct 16, 2009 12:10 pm Post subject: |
|
|
I think you will need to be more speciific.
There is some COM stuff in the library but it is very low level. |
|
Back to top |
|
 |
jjgermis
Joined: 21 Jun 2006 Posts: 404 Location: N�rnberg, Germany
|
Posted: Fri Oct 16, 2009 12:21 pm Post subject: |
|
|
As mentioned, the module I have is from another compiler. Here is a part of it: Code: | MODULE maxwell
USE IFWINTY
USE IFCOM
IMPLICIT NONE
! CLSIDs
TYPE (GUID), PARAMETER :: CLSID_MaxwellAppComInterface = &
GUID(#997B84AF, #0946, #4236, &
CHAR('9A'X)//CHAR('32'X)//CHAR('30'X)//CHAR('37'X)// &
CHAR('E0'X)//CHAR('07'X)//CHAR('02'X)//CHAR('12'X))
! IIDs
TYPE (GUID), PARAMETER :: IID_IMaxwellAppComInterface = &
GUID(#35C06A88, #6BF1, #453E, &
CHAR('B9'X)//CHAR('AD'X)//CHAR('E0'X)//CHAR('4C'X)// &
CHAR('AA'X)//CHAR('7F'X)//CHAR('75'X)//CHAR('A6'X))
TYPE (GUID), PARAMETER :: IID_IMaxwellAppComInterfaceV12 = &
GUID(#9BF2FF5F, #22EC, #4C0F, &
CHAR('BD'X)//CHAR('99'X)//CHAR('DD'X)//CHAR('8E'X)// &
CHAR('5E'X)//CHAR('BA'X)//CHAR('2D'X)//CHAR('7B'X))
! Interfaces
INTERFACE
!method GetAppDesktop
INTEGER(4) FUNCTION IMaxwellAppComInterface_GetAppDesktop($OBJECT, pVal)
INTEGER(INT_PTR_KIND()), INTENT(IN) :: $OBJECT ! Object Pointer
!DEC$ ATTRIBUTES VALUE :: $OBJECT
INTEGER(INT_PTR_KIND()), INTENT(OUT) :: pVal ! IDispatch
!DEC$ ATTRIBUTES REFERENCE :: pVal
!DEC$ ATTRIBUTES STDCALL :: IMaxwellAppComInterface_GetAppDesktop
END FUNCTION IMaxwellAppComInterface_GetAppDesktop
END INTERFACE
POINTER(IMaxwellAppComInterface_GetAppDesktop_PTR, IMaxwellAppComInterface_GetAppDesktop) ! routine pointer
! Module Procedures
CONTAINS
!method GetAppDesktop
!INTEGER(INT_PTR_KIND()) FUNCTION $Application_GetWorkbooks($OBJECT, $STATUS)
INTEGER(4) FUNCTION $IMaxwellAppComInterface_GetAppDesktop($OBJECT, pVal)
IMPLICIT NONE
INTEGER(INT_PTR_KIND()), INTENT(IN) :: $OBJECT ! Object Pointer
!DEC$ ATTRIBUTES VALUE :: $OBJECT
INTEGER(INT_PTR_KIND()), INTENT(OUT) :: pVal ! IDispatch
!DEC$ ATTRIBUTES REFERENCE :: pVal
INTEGER(4) $RETURN
INTEGER(INT_PTR_KIND()) $VTBL ! Interface Function Table
POINTER($VPTR, $VTBL)
$VPTR = $OBJECT ! Interface Function Table
$VPTR = $VTBL + 28 ! Add routine table offset
IMaxwellAppComInterface_GetAppDesktop_PTR = $VTBL
$RETURN = IMaxwellAppComInterface_GetAppDesktop($OBJECT, pVal)
$IMaxwellAppComInterface_GetAppDesktop = $RETURN
END FUNCTION $IMaxwellAppComInterface_GetAppDesktop
END MODULE |
The main code starts with something like this: Code: | ! Initialize object pointers
CALL INITOBJECTS()
CALL COMINITIALIZE(status)
write(*,*) 'Opens the Maxwell script interface'
CALL COMCREATEOBJECT ("AnsoftMaxwell.MaxwellScriptInterface", maxwellapp, status)
IF (maxwellapp == 0) THEN
WRITE (*, '(" Unable to create Excel object; Aborting")')
CALL EXIT()
else
write(*,'(" Maxwell object created")')
END IF
write(*,*) 'Perform some FEA calculations'
write(*,*) maxwellapp
desktop = IMaxwellAppComInterface_GetAppDesktop(maxwellapp, pVal)
read(*,*) |
I would really like to get this working as this would save a lot of time port FTN95 to something else. I would not mind to make an example available if I get it to work. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8211 Location: Salford, UK
|
Posted: Fri Oct 16, 2009 1:05 pm Post subject: |
|
|
I will have a look at this when I get time but I am not hopeful. Problem is that SCC is not geared up to communicate with the relevant libraries. |
|
Back to top |
|
 |
jjgermis
Joined: 21 Jun 2006 Posts: 404 Location: N�rnberg, Germany
|
Posted: Fri Oct 23, 2009 7:48 am Post subject: |
|
|
Hi Paul,
in which module is the COM stuff you mentioned. I would like to make a few experiments. As I understood from what I found on the internet is the GUID that needs to be defined. Unfortunately the example that I have uses symbols that is not allowed in the Salford compiler. Below is how the CLSID is defined in my example.
Quote: | Each COM class is identified by a CLSID, a unique 128-bit GUID, which the server must register. COM uses this CLSID, at the request of a client, to associate specific data with the DLL or EXE containing the code that implements the class, thus creating an instance of the object. |
Code: | ! CLSIDs
TYPE (GUID), PARAMETER :: CLSID_MaxwellAppComInterface = &
GUID(#997B84AF, #0946, #4236, &
CHAR('9A'X)//CHAR('32'X)//CHAR('30'X)//CHAR('37'X)// &
CHAR('E0'X)//CHAR('07'X)//CHAR('02'X)//CHAR('12'X)) |
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8211 Location: Salford, UK
|
Posted: Fri Oct 23, 2009 8:21 am Post subject: |
|
|
From memory I would guess shell32.dll is an example. |
|
Back to top |
|
 |
jjgermis
Joined: 21 Jun 2006 Posts: 404 Location: N�rnberg, Germany
|
Posted: Fri Oct 23, 2009 11:56 am Post subject: |
|
|
Hi Paul,
is there some example in the Salford install directory to create a shell32.dll? I could only find shellapi.ins in the install directory. Before I can do anything it is necessary to get the pointer to the object's interface. It must be something like c200e360-38c5-11ce-ae62-08002b2b79ef. Furthermore, it seems like the implementation depends on the compiler at hand. Thus, the get FTN95 fit for our application a small example will be helpful. On the other hand if you think it is to low level it might be advisable to keep my hands from it. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8211 Location: Salford, UK
|
Posted: Sat Oct 24, 2009 10:18 am Post subject: |
|
|
I will be out of my office for a few days before I can get back to you. |
|
Back to top |
|
 |
jjgermis
Joined: 21 Jun 2006 Posts: 404 Location: N�rnberg, Germany
|
Posted: Wed Nov 04, 2009 4:38 pm Post subject: |
|
|
Hi Paul, still out of office? |
|
Back to top |
|
 |
jjgermis
Joined: 21 Jun 2006 Posts: 404 Location: N�rnberg, Germany
|
Posted: Fri Nov 20, 2009 12:05 pm Post subject: |
|
|
Hi Paul,
I attended the ANSYS user meeting this week. One topic that becomes popular nowadays, especially in machine design, is the use of optimisers. Finding an optimiser is not the problem. The problem is to get the software that calculates the function value to be optimised, to be seen/visible (or controlable) by the optimiser. A very popular optimiser (in Germany) is optiSLANG (http://www.dynardo.de/). Another one is from elmoCAD (http://elmocad.com/). We of course has stuff like as well. However, the software that calculates the function value has a COM (commom object model) interface.
We have both: our optimer in Fortran and our FEM software. However, I cannot communicate with the FEM software since I cannot get the communication done. Did you have some time to look into this issue? I see J�rg Kuthe (QT Software) next week and will ask him for some tipps as well. My problem is that I cannot find any literature/examples for FTN95. Other compilers offer some stuff. Since this is not standard it seems like it does not apply to FTN95. And sinve I have some non-standard stuff from FTN95 I cannot switch compilers in this case - yet another dead end. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8211 Location: Salford, UK
|
Posted: Fri Nov 20, 2009 4:44 pm Post subject: |
|
|
The only place in the library where I know we use a COM interface is for BROWSE_FOR_FOLDER@. This function is written in C and is fairly low level because SCC does not have the higher level functionality that you would normally use in this context. I do not think that you would be interested in this approach.
It is certainly not possible to compile this kind of code using FTN95. If you have working code for another Fortran compiler then you may be able to create a DLL using that compiler and access the DLL from FTN95 code. |
|
Back to top |
|
 |
jjgermis
Joined: 21 Jun 2006 Posts: 404 Location: N�rnberg, Germany
|
Posted: Fri Nov 20, 2009 5:36 pm Post subject: |
|
|
Of course, using a DLL sounds like a good solution. I got somehow stuck with the idea of doing everthing with FTN95 Thanks! |
|
Back to top |
|
 |
DanRRight
Joined: 10 Mar 2008 Posts: 2924 Location: South Pole, Antarctica
|
Posted: Sun Dec 06, 2009 10:08 pm Post subject: Re: |
|
|
jjgermis wrote: | I got somehow stuck with the idea of doing everthing with FTN95 | To me it is distractive a bit and with time annoying to use several compilers. Plus, FTN95 is kind of addictive |
|
Back to top |
|
 |
|