Fortran IMSL COM / 1 Fortran IMSL COM Fortran IMSL COM, COM 1 IMSL /, StatLib Applied Statistics Algorithms NIST(National Institute of Standards and Technology) GAMS(Guide to Available Mathematical Software) (non-objected Oriented Programming Language) Fortran Digital Visual Fortran(MS Fortran PowerStation MS Digital Fortran ) Visual Fortran IMSL/STAT, IMSL/MATH (Professional Edition) Professional Edition IMSL MS Visual Studio Fortran, C++, J++
2 / Fortran IMSL COM, Fortran Module Wizard COM/OLE Fortran,, DLL C C++ COM Fortran Fortran Fortran 2 Static Library Dynamic-Link Library Static Library 11 Digital Visual Fortran Visual Fortran "Visual Fortran" "Developer Studio" Visual Studio 97 Visual Studio 60
Fortran IMSL COM / 3 Fortran Developer Studio 1-1 1 2 3 4 5 6 1 Developer Studio menu bar 2 InfoViewer tool bar 3 Standard tool bar 4 ClassView, FileView, InfoView 5 6 Build, Debug 12 Static Library, Workspace
4 / Fortran IMSL COM Fortran IMSL/STAT 1 [File ] [New] 2 [Project] [Win32 Static Library]
Fortran IMSL COM / 5 3 [Location] \WORK\StatComp \ 4 [Project name] COMLib 5 [OK] FileView COMLib workspace project
6 / Fortran IMSL COM 13 Source File 1 [File ] [New] 2 [Files] [Fortran Fixed Format Source File] Fixed Format Source File Fortran 77 FileNamefor Visual Fortran Free Format Source File FileNamef90 3 [File] ComDemo 4 [OK] [FileView] ComDemof90
Fortran IMSL COM / 7 5 Subroutine ChiSquareDF (ChiSquare, DF, PV) REAL ChiSquare, DF, PV PV = 1 - CHIDF(ChiSquare, DF) End Subroutine ChiSquareDF IMSL/STAT CHIDF Visual Fortran Fortran 14 IMSL/STAT IMSL/STAT IMSL/STAT
8 / Fortran IMSL COM 1 [Project] [Add To Project] [Files] 2 [Insert Files into project] IMSL Digital Fortran/Imsl/Lib 3 [ ] [Library Files (lib)] 4 [Sstatslib]
Fortran IMSL COM / 9 5 [OK] Fortran IMSL sstatslib - single precision IMSL/STAT sstatdlib - double precision IMSL/STAT smathslib - single precision IMSL/MATH smathdlib - double precision IMSL/MATH sf90mplib - Fortran 90MP IMSL 15 C++ Fortran COM C++ C++ Visual Fortran Visual C++, Visual Basic, Assembly Language calling convention Stack considerations Does a routine receive a varying or fixed number of arguments? Which routine clears the stack after a call? Naming conventions Is lowercase or uppercase significant or not significant?
10 / Fortran IMSL COM Are names decorated (as in Visual C++)? Argument passing protocol Are arguments passed by value or by reference? What are the equivalent data types and data structures among languages? Calling convention Visual Fortran Help Programming with Mixed Languages Fortran C++ Subroutine ChiSquareDF (ChiSquare, DF, PValue)!DEC$ ATTRIBUTES C, ALIAS: '_ChiSquareDF' :: ChiSquareDF REAL ChiSquare, DF, PV POINTER (PValue, PV) PV = 1 - CHIDF(ChiSquare, DF) End Subroutine ChiSquareDF!DEC$ ATTRIBUTE (calling convention) (alias) Fortran Fortran C STDCALL Fortran C++ ALIAS array return value POINTER 16 Build Build 1 [Ctrl+F7] [Build] [Compile]
Fortran IMSL COM / 11 [Build] error warning 2 [F7] [Build] [Build]
12 / Fortran IMSL COM error warnig [Build]
2 Visual C++ ATL COM Fortran IMSL COM / 13 Visual C++ COM ATL(ATL COM Active Template Library) MFC(Microsoft Foundation Class) ATL COM COM / COM COM, COM COM COM COM COM In-process Out-ofprocess In-process DLL COM Out-of-process EXE COM Local Remote Local : COM COM Remo te : COM COM COM COM COM Out-of-process remote, In-process ASP Out-of-process /
14 / Fortran IMSL COM 21 COM COM Visual C++ ATL Visual C++, Fortran 1 [File ] [New] 2 [ATL COM AppWizard ]
Fortran IMSL COM / 15 3 [Location] 4 [Project name] Demo 5 [OK] 6 [Server Type] Dynamic Link Library[DLL] 7 [Finish]
16 / Fortran IMSL COM [ATL COM AppWizard] COM [New Project Information] 8 [OK] ATL COM Application Wizard COM In-process DllMain 4 cpp Out-of-process WinMain
def In-process idl Interface Definition Language rc Resource Resourceh StdAfxcpp StdAdxh Resource StdAfxh Atlimplcpp ATL Fortran IMSL COM / 17 22 Fortran Fortran 1 [Project] [Add To Project] [Files] 2
18 / Fortran IMSL COM Fortran Debug 3 [ ] [Library Files (lib)] 4 COMLiblib 5 [OK] COMLiblib
Fortran IMSL COM / 19 23 ATL COM ATL COM AppWizard COM ATL COM ATL Object Wizard ATL 1 [Insert] [New ATL Object] 2 [ATL Object Wizard ] [Category] [Object] 3 [ATL Object Wizard ] [Objects] [Simple Object]
20 / Fortran IMSL COM ATL Object Wizard COM Category Objects Objects Simple Object Internet Explorer Object ActiveX Server Component Microsoft T ransaction Server AddIn Object Component Register Object Microsoft Internet Explorer COM Microsoft Internet Information Server Active Server Page COM Microsoft Transaction Server COM Microsoft Developer Studio Controls MMC SnapIn Full Control Property Page HTML Control Microsoft Management Console ActiveX ActiveX Dynamic HTML Composite Control Lite Control Lite HTML Control Lite Composite Control Mixcellaneous Dialog Microsoft Internet Explorer ActiveX Dynamic HTML, Int ernet Explorer Internet Explorer, Data Access Provider OLE DB Consumer OLE DB
Fortran IMSL COM / 21 4 [Next ] 5 [ATL Object Wizard Properties] [Names] COM [Names] COM C++ COM C++ [Short Name] COM [Prog ID] 6 [ATL Object Wizard Properties] [Attribute] Threading Model, Interface, Aggregation COM Threading Model Single Single -Threading Model COM STA Apartment Single Thread Apartment (STA) Model Both COM STA STA, MTA Mixed-Threading Model
22 / Fortran IMSL COM Free Apartment? STA COM STA MTA COM MTA Multiple Thread Apartment (MTA) Model COM MTA, STA COM COM COM COM COM COM COM Interface Dual Custom Aggregation Visual Basic C++ COM COM COM COM COM
COM Fortran IMSL COM / 23 COM COM COM COM COM COM COM COM Threading Model, Interface, Aggregation Apartment, Dual, Yes 7 [ ] COM, 24 COM (interface) COM (method, ) COM IUnknown, COM
24 / Fortran IMSL COM COM COM,, COM COM COM IUnknown COM, COM Visual C++ ATL MFC COM COM IUnknown UUID(Universally Unique Identifier) GUID(Globally Unique Identifier) 128, GUID IID(Interface Identifier), COM GUID CLSID(Class Identifier) GUID COM, Visual C++ UUIDGENEXE GUIDGENEXE COM HRESURT HRES ULT 16 Return Code, 15 Facility, 1 Severity 32 S_OK NOERROR S_FALSE E_UNEXPECTED true 0 S_OK false 1
Fortran IMSL COM / 25 E_NOTIMPL E_NOINTERFACE E_OUTOFMEMORY E_FAIL COM 1 [ClassView] [Add Member Variable ] 2 [Add Member Variable ] [Variable Type] [Variable Name] [Access]
26 / Fortran IMSL COM 3 [ ] [ClassView] Variable Type Variable Name Access Float ChiSqrProb Protected Float ChiSqrStat Protected Float Degree Protected (property) COM COM, COM
Fortran IMSL COM / 27 1 [ClassView] [Add Property] 2 [Add Property to Interface] Property, Parameters, Function Type
28 / Fortran IMSL COM Return Type HRESULT Property, Property Parameters Function Type Get Function Put Function Get Function COM, Put Function COM Put Function ProgPut ProgPutRef 3 [OK] [ClassView] (IChiDF) (IChiDF), COM
Fortran IMSL COM / 29 Property Property Parameters Function Type Float SetChiSqrStat Put Function [ProgPut] Float SetDegree Put Function [ProgPut] Float GetChiSqrProb Get Function (method) COM COM 1 [ClassView] [Add Method]
30 / Fortran IMSL COM 2 [Add Method to Interface] Method Name Parameters Return Type HRESULT Method Name, Parameters Implementation 3 [OK] [ClassView]
Fortran IMSL COM / 31 FindChiSqrProb COM, ClassView (ChiDFcpp) // ChiDFcpp : Implementation of CChiDF #include "stdafxh" #include "Demoh" #include "ChiDFh" //////////////////////////////////////////////////////////////// // CChiDF STDMETHODIMP CChiDF::put_SetChiSqrStat(float newval) { // TODO: Add your implementation code here
32 / Fortran IMSL COM } return S_OK; STDMETHODIMP CChiDF::put_SetDegree(float newval) { // TODO: Add your implementation code here } return S_OK; STDMETHODIMP CChiDF::get_GetChiSqrProb(float *pval) { // TODO: Add your implementation code here } return S_OK; STDMETHODIMP CChiDF::FindChiSqrProb() { // TODO: Add your implementation code here } return S_OK; Put Function newval, Get Function *pval // ChiDFcpp : Implementation of CChiDF #include "stdafxh" #include "Demoh" #include "ChiDFh" extern "C" void ChiSquareDF( float ChiSquare, float DF, float *PValue ); //////////////////////////////////////////////////////////////// //////// // CChiDF STDMETHODIMP CChiDF::put_SetChiSqrStat(float newval) { ChiSqrStat = newval;
Fortran IMSL COM / 33 } return S_OK; STDMETHODIMP CChiDF::put_SetDegree(float newval) { Degree = newval; } return S_OK; STDMETHODIMP CChiDF::get_GetChiSqrProb(float *pval) { *pval = ChiSqrProb; } return S_OK; STDMETHODIMP CChiDF::FindChiSqrProb() { ChiSquareDF( ChiSqrStat, Degree, &ChiSqrProb ); } return S_OK; Fortran COM extern "C" void ChiSquareDF ( float ChiSquare, float DF, float * PValue ); Fortran calling convention, parameter type, ClassNameh ClassNamecpp 25 COM COM COM (compile) (build)
34 / Fortran IMSL COM 1 [FileView] ProjectNameidl 2 [Build] [Compile] COM,
3 [Build ] [Bu ild] Fortran IMSL COM / 35, COM COM (DLL EXE) COM libclib(crt0datobj) : error LNK2005:???? already defined in LIBCMTDlib(crt0datobj) 1 [Project] [Settings]
36 / Fortran IMSL COM 2 [Link] [Object/library modules] LIBCLIB
/NODEFAULTLIB:"LIBClib" Fortran IMSL COM / 37 3 [OK] 4 23 COM [Build] 26 COM COM COM COM (regeditexe) HKEY_CLASSES_ROOT DemoChiDF DemoChiDF1
38 / Fortran IMSL COM COM COM Visual C++ Visual Basic Visual C++ 1 [File] [New] 2 [Project] [Win32 Console Application]
Fortran IMSL COM / 39 3 [Location], [Project name] (ComTest) 4 [OK] 5 [Win32 Console Application] [An empty project] 6 [Finish]
40 / Fortran IMSL COM 7 [New Project Information] [OK] 8 [File] [New] 9 [Files] [C++ Source File] 10 [Files] (ComTest)
11 [OK] 12 Fortran IMSL COM / 41 // ComTestcpp // A simple console application for COM Demo component testing #include <iostreamh> #include "\Demo\Demoh" #include "\Demo\Demo_ic" int main( void ) { IUnknown *punk = 0; IClassFactory *pcf; HRESULT hr; // COM CoInitialize( 0 ); // COM IClassFactory Interface hr = CoGetClassObject( CLSID_ChiDF, CLSCTX_SERVER, 0, IID_IClassFactory, (void **) &pcf ); if( SUCCEEDED( hr ) ) { // COM IUnknown Interface hr = pcf->createinstance( 0, IID_IUnknown, (void **) &punk ); if( FAILED( hr ) ) cout << "CreateInstance Failed"; pcf->release(); } else cout << "CoGetClassObject Failed"; if (SUCCEEDED(hr)) { IChiDF *pchidf; hr = punk->queryinterface( IID_IChiDF, (void **) &pchidf ); if( SUCCEEDED( hr ) ) { float ChiSqrStat = (float) 221; float Degree = (float) 16; float ChiSqrProb; hr = pchidf->put_setchisqrstat( ChiSqrStat ); hr = pchidf->put_setdegree( Degree ); hr = pchidf->findchisqrprob( ); hr = pchidf->get_getchisqrprob( &ChiSqrProb );
42 / Fortran IMSL COM if( SUCCEEDED( hr ) ) cout << ChiSqrProb << '\n'; } } CoFreeUnusedLibraries(); CoUninitialize(); } return 0; 13 14 15 COM, 27 COM COM COM COM COM, COM In-process server regsvr32 ServerNameDLL regsvr32 ServerNameOCX, regsvr32 /u ServerNameDLL regsvr32 /u ServerNameOCX COM Put-of process server ServerNameEXE /RegServer ServerNameEXE RegServer
Fortran IMSL COM / 43 ServerNameEXE /UnregServer ServerNameEXE -UnregServer REGSVR32EXE in-process server COM Visual C++ in-process COM COM COM COM Visual Basic, ASP
44 / Fortran IMSL COM 3 COM COM COM 1 COM 2 COM COM ID 3 COM (instance) 4 COM COM COM 5 COM COM COM COM Visual Basic Visual C++ COM COM COM COM Visual Basic 31 Visual Basic Visual Basic, Visual Basic COM COM (business logic) (presentation layer)
Fortran IMSL COM / 45 Visual Basic COM / COM Visual Basic 60 1 Visual Basic 2 [ ] [ ] 3 [ ] [ EXE] 4 [ ] Visual Basic [Form1]
46 / Fortran IMSL COM 1 2 5 6 3 4 5 1 Visual Basic 2 Visual Basic 3 4 5 6 Caption Text Label Label Label
TextBox txtchisqrstat txtchisqrstat TextBox txtdegree txtdegree TextBox txtchisqrprob txtchisqrprob CommandButton btnsubmit Fortran IMSL COM / 47 [ ] [ ] 6 [ ] 7 [ ] ' Private Sub Form_Load() txtchisqrstattext = "" txtdegreetext = "" txtchisqrprob = "" End Sub Private Sub btnsubmit_click() ' Dim ChiDF As Object Dim ChiSqrStat As Single Dim ChiSqrProb As Single Dim Degree As Single ' ChiSqrStat = CSng(txtChiSqrStatText) Degree = CSng(txtDegreeText)
48 / Fortran IMSL COM ' COM Set ChiDF = CreateObject("DemoChiDF1") ChiDFSetChiSqrStat = ChiSqrStat ChiDFSetDegree = Degree ChiDFFindChiSqrProb ChiSqrProb = ChiDFGetChiSqrProb ' ChiSqrStat ' Degree ' ' ChiSqrProb ' COM Set ChiDF = Nothing txtchisqrprobtext = CStr(ChiSqrProb) ' End Sub Visual Basic, COM, COM, COM Visual C++ COM COM, COM Visual C++ 8 [ ] [ ], 1 [ ] [Project1] 2 [ ] [ ] VBClient 3 [ ] [Form1] 4 [ ] [ ] ComClient, [Caption] VBClient 5 [ ] [ ]
Fortran IMSL COM / 49 6 [ ] [ ] 7 [ ] [ ] 8 [ ] [VBClientexe ] 9 [ ] [ ]
50 / Fortran IMSL COM VBClientexe Visual Basic Visual Basic COM 32 ASP ASP(Active Server Page) ASP HTML ActiveX ASP asp asp, ASP ASP
Fortran IMSL COM / 51 HTTP Active Server Page HTTP ASP asp HTML ASP ASP HTML htm html asp ASP, HTML, ASP HTML < > HTML <% %> HTML Microsoft FrontPage FrontPage FrontPage HTML [ ] ASP COM
52 / Fortran IMSL COM 1 COM (Demodll) 2 FrontPage 3 [Getting Started] [More Webs] 4 [Open FrontPage Web] [Select a Web server or disk location] [List Webs]
Fortran IMSL COM / 53 5 [Open FrontPage Web] [FrontPage Webs found at location] [OK] FrontPage [ ], 1 2 3 4 5 1 FrontPage MenuBar 2 FrontPage ToolBar
54 / Fortran IMSL COM 3 FrontPage View 4 5 6 [File] [New] [Folder] Demo 7 Demo [File] [New] [Page] HTML Defaulthtm ASP Resultasp 8 HTML 9 [HTML] <html> <head> <title> </title> </head> <body> <form method="post" action="resultasp"> <p> <input type="text" name="txtchisqrstat" size="10"></p>
Fortran IMSL COM / 55 <p> <input type="text" name="txtdegree" size="10"></p> <p><input type="submit" value=" " name="btnsubmit"></p> </form> </body> </html> <form> </form> action="resultasp" Resultasp 10 ASP 11 [HTML] <html> <head> <title> </title> </head> <% ' Dim ChiSqrStat, Degree, ChiSqrProb, ChiDF 'Defaulthtm ChiSqrStat, Degree ChiSqrStat = RequestForm( "txtchisqrstat" ) Degree = RequestForm( "txtdegree" ) ' COM Set ChiDF = ServerCreateObject( "DemoChiDF1" ) 'COM ChiDFSetChiSqrStat = ChiSqrStat ChiDFSetDegree = Degree ChiDFFindChiSqrProb ChiSqrProb = ChiDFGetChiSqrProb ' COM Set ChiDF = Nothing %> <body> <p> = <% =ChiSqrStat %></p> <p> = <% =Degree %></p> <p> = <% =ChiSqrProb %></p> </body>
56 / Fortran IMSL COM </html> ASP <% %>,, COM, COM, COM COM Visual Basic CreateObject ASP ServerCreateObject RequestForm <% %> 12 Defaulthtm Resultasp COM Visual Basic Visual Basic Script Visual Basic