|
|
||||||
|
#1
|
|
|
|
|
Hello everyone,
season greetings! I'm not sure if this is the right group for this topic, but you guys here seem to be relatively friendly towards newbies, so I'll take my chances. I've been using fortran for some time, but only for "simple programs" (exe file as a result of subroutines). I compiled it from command line, and it has covered my needs. I'm using CVF 6.6.c under Windows XP, with Office 2007 installed. Now I'm trying to compile/build a dll file which I will be able to call in excel as a function. After reading the manual (which still confuses me), and some tutorials off the net (http://newtonexcelbach.wordpress.com...s-fortran-dll/) and some youtube videos (youtube: excel fortran - 4 part video), I'm still having trouble doing it in my case. I'm trying to make a simple example work !******************************************* ! FUNCTIONS/SUBROUTINES exported from zbroj.dll: ! zbroj - subroutine PURE FUNCTION zbroj(X) ! Expose subroutine zbroj to users of this DLL !DEC$ ATTRIBUTES DLLEXPORT::zbroj REAL, INTENT(IN) :: X zbroj = 2 * X *100 END FUNCTION zbroj !******************************************* (it is an example from CVF manual book) which in excel I can call. I compiled and builded it as DLL and copied it into \win\system32 directory, but still, excel doesn't recognize it. Please, I know this is "homework" and trivial work to some of you, but if you could give me a few pointers as to what I'm doing wrong, just to get me started with this one, I'd be really grateful. Regards, Matjaz |
|
|
|
#2
|
|
|
|
|
On Jan 3, 11:49 am, Matjaz Pecovnik <matjazpecov>
wrote: [..] > > which in excel I can call. I compiled and builded it as DLL and copied > it into \win\system32 directory, but still, excel doesn't recognize > it. > > Please, I know this is "homework" and trivial work to some of you, but > if you could give me a few pointers as to what I'm doing wrong, just > to get me started with this one, I'd be really grateful. > > Regards, Matjaz This is a FAQ. You have not shown the declarations section from the VBA (Visual Basic for Applications) module which must be inserted into your workbook. I compiled my DLL from the command line (using DVF 5) df /dll zbroj.f90 CVF and DVF use the STDCALL convention by default. This changes the name exported by the routine to _ZBROJ@4 The @4 suffix corresponds to a single argument (4 bytes of pointer) passed on the stack. If you declare your function as follows: Declare Function zbroj Lib "zbroj.dll" Alias "_ZBROJ@4" (x As Single) As Single It then works properly. Note that I have placed my copy of the dll in the "Documents" folder with the workbook. YMMV. Otherwise you can take care of the name mangling from the Fortran side: .... !DEC$ ATTRIBUTES DLLEXPORT, ALIAS:'zbroj' ::zbroj .... and on the VBA side Declare Function zbroj Lib "zbroj.dll" (x As Single) As Single In a cell place =zbroj(1) and see 200 Also note that you have to change your security settings to allow macros OR enable macros manually after opening the workbook. HTH --- e |
|
#3
|
|
|
|
|
Matjaz Pecovnik wrote:
> Hello everyone, > season greetings! > > I'm not sure if this is the right group for this topic, but you guys > here seem to be relatively friendly towards newbies, so I'll take my > chances. > I've been using fortran for some time, but only for "simple programs" > (exe file as a result of subroutines). I compiled it from command > line, and it has covered my needs. I'm using CVF 6.6.c under Windows > XP, with Office 2007 installed. The mixed language programming documentation in CVF is excellent. I would strongly recommend Ring TFM. |
|
#4
|
|
|
|
|
Craig Powers wrote:
> Matjaz Pecovnik wrote: >> Hello everyone, >> season greetings! >> >> I'm not sure if this is the right group for this topic, but you guys >> here seem to be relatively friendly towards newbies, so I'll take my >> chances. >> I've been using fortran for some time, but only for "simple programs" >> (exe file as a result of subroutines). I compiled it from command >> line, and it has covered my needs. I'm using CVF 6.6.c under Windows >> XP, with Office 2007 installed. > > The mixed language programming documentation in CVF is excellent. I > would strongly recommend Ring TFM. That's R-ing TFM. Sorry for any confusion. |
|
#5
|
|
|
|
|
On Mon, 05 Jan 2009 15:02:29 -0500, Craig Powers wrote:
> Craig Powers wrote: > > That's R-ing TFM. Sorry for any confusion. Matjaz, likely a person for whom English is not his first language, has quoted the manual already. He might not know that we mean "The Fortran Manual" around here. Maybe someone with cvf could give him a reference therein. I'd sure like to have an implementation that had a manual worthy of it. |
|
|
| Similar Threads | |
| Thread | Thread Starter |
| Does anybody know a way to convert Matlab code into Fortran and then compile Fortran mex dll file for Matlab 2006a? Hi all, I want to ask three questions regarding Fortran and Matlab interface. The two tools I am using are: Intel Visual Fortran 10.1 and Matlab 2006a. Q1. What is the best... |
Linus Utopia |
| Conversion of Fortran File unit to C File stream Hello I am using a data file which is opened in FORTRAN and the same file goes inside the C code for writing. I send the file unit in the fortran part and the same needs to... |
abarun22 |
| Controlling excel from fortran Hello, I saw it somewhere, but my computer froze before I was able to bookmark it. There was an example of using FORTRAN to produce some data and.. then (still from... |
tuli |
| Open Excel file through Fortran? Hello all! A quick question. I have a workbook (Vtec.xls) that has macro buttons and custom create menus and stuff performing different tasks. I would like to call/invoke... |
aiyer |
| Help needed! Fortran Dll works for compaq fortran not for Intel Fortran Dear all, I am porting a compaq fortran project (version 6.x) over to the intel fortran compiler (version 8.0). However, crash always happens at the internal write statement... |
David |
|
Privacy Policy | All times are GMT. The time now is 05:32 PM.
|
|
|