Changes between Version 1 and Version 2 of FortranApps


Ignore:
Timestamp:
Apr 25, 2007, 12:01:49 PM (17 years ago)
Author:
Nicolas
Comment:

Required manual changes to automatic conversion.

Legend:

Unmodified
Added
Removed
Modified
  • FortranApps

    v1 v2  
    33
    44== F2X ==
    5  One option is to use f2c to convert your FORTRAN program to C. M.F. Somers has created a [http://boinc.gorlaeus.net/F2c.php BOINC-enabled f2c library] that simplifies this process.
     5One option is to use f2c to convert your FORTRAN program to C. M.F. Somers has created a [http://boinc.gorlaeus.net/F2c.php BOINC-enabled f2c library] that simplifies this process.
     6
    67== Windows: cygwin ==
    7  Include the file 'boinc_api_fortran.C' in the api/Makefile.am, but comment out the 'zip' calls, to avoid the linking with 'libboinc_zip.a'
     8
     9Include the file 'boinc_api_fortran.C' in the api/Makefile.am, but comment out the 'zip' calls, to avoid the linking with 'libboinc_zip.a'
    810
    911To link it is necessary to include the 'winmm.dll' library (-lwinmm).
    1012
     13== Windows: Visual Studio ==
    1114
    12 == Windows: Visual Studio ==
    13   2004-06-16 note: this page is outdated; will update     (functions are now declared `extern"C"` so      no C++ mangling is done; there is a boinc_api_fortran.C wrapper) -- quarl@ssl
     15'''''2004-06-16 note: this page is outdated; will update (functions are now declared `extern "C"` so no C++ mangling is done; there is a boinc_api_fortran.C wrapper) -- quarl@ssl'''''
    1416
    15   Note: a working example similar to the following (based on outdated BOINC code) is [http://boinc.berkeley.edu/TestLibs.zip here]; see also its [http://boinc.berkeley.edu/taufer.txt README].
     17Note: a working example similar to the following (based on outdated BOINC code) is [http://boinc.berkeley.edu/TestLibs.zip here]; see also its [http://boinc.berkeley.edu/taufer.txt README].
    1618
    1719Start by creating a new FORTRAN project. Add all the FORTRAN specific files, then add all the files needed for the BOINC library (e.g. boinc_api.C). Make sure that BOINC and the FORTRAN files are compiled using the same type of standard libraries. i.e. if the BOINC is compiled with the debug multithreaded DLL libraries, make sure the FORTRAN files are compiled with the DLL setting.
    1820
    1921For every BOINC function you want to call from fortran you must add an interface and subroutine:
    20 
    2122
    2223{{{
     
    2627END INTERFACE
    2728}}}
    28   Remember to declare the type of arguments. INTEGER status
     29
     30Remember to declare the type of arguments. INTEGER status
    2931
    3032You must then tell the compiler that the function you are interfacing is a C routine. You do this by adding the statement:
    31 
    3233
    3334{{{
    3435 !DEC$ ATTRIBUTES C :: boinc_finish
    3536}}}
    36  Because BOINC is compiled as C++ files the FORTRAN compiler will not be able to find the standard function name in the object file, you therefore have to add an alias for the function giving the real function name:
     37
     38Because BOINC is compiled as C++ files the FORTRAN compiler will not be able to find the standard function name in the object file, you therefore have to add an alias for the function giving the real function name:
     39
    3740{{{
    3841 !DEC$ ATTRIBUTES ALIAS : '?boinc_finish@@YAHH@Z' :: boinc__finish
    3942}}}
    40  This function name can be found in the object file. Go to your compile directory and run dumpbin.
    4143
     44This function name can be found in the object file. Go to your compile directory and run dumpbin.
    4245
    4346{{{
    4447c:\fortranproject\Release>dumpbin /symbols boinc_api.obj
    4548}}}
    46   this will give you a list of symbols, where you can find the real functionname.  The interface will end up looking like this:
    47 
     49this will give you a list of symbols, where you can find the real functionname.  The interface will end up looking like this:
    4850
    4951{{{
     
    5557  END SUBROUTINE boinc_finish
    5658END INTERFACE
     59}}}
    5760
    58 }}}
    59  You can now call the BOINC function in FORTRAN.
     61You can now call the BOINC function in FORTRAN.
     62
    6063{{{
    6164call boinc_finish(0)