wiki:FortranApps

Version 5 (modified by Nicolas, 17 years ago) (diff)

Use server-relative links, formatted the list of processor codes

FORTRAN applications

F2X

One option is to use f2c to convert your FORTRAN program to C. M.F. Somers has created a BOINC-enabled f2c library that simplifies this process.

Windows: cygwin

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'

To link it is necessary to include the 'winmm.dll' library (-lwinmm).

Windows: Visual Studio

Note: a working example similar to the following (based on outdated BOINC code) is here; see also its README.

Start 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.

For every BOINC function you want to call from fortran you must add an interface and subroutine:

INTERFACE
  SUBROUTINE boinc_finish(status)
  END SUBROUTINE boinc_finish
END INTERFACE

Remember to declare the type of arguments. INTEGER status

You must then tell the compiler that the function you are interfacing is a C routine. You do this by adding the statement:

 !DEC$ ATTRIBUTES C :: boinc_finish

The interface will end up looking like this:

INTERFACE
  SUBROUTINE boinc_finish(status)
    !DEC$ ATTRIBUTES C :: boinc_finish
    !DEC$ ATTRIBUTES ALIAS : '?boinc_finish@@YAHH@Z' :: boinc__finish
    INTEGER status
  END SUBROUTINE boinc_finish
END INTERFACE

You can now call the BOINC function in FORTRAN.

call boinc_finish(0)

Intel FORTRAN compiler

-ax<codes> generate codes specialized for processors specified by <codes> while also generating generic IA-32 code. <codes>` includes one or more of the following characters:

K
Intel Pentium III and compatible Intel processors
W
Intel Pentium 4 and compatible Intel processors
N
Intel Pentium 4 and compatible Intel processors. Enables new optimizations in addition to Intel processor-specific optimizations
P
Intel Core(TM) Duo processors, Intel Core(TM) Solo processors, Intel Pentium 4 and compatible Intel processors with Streaming SIMD Extensions 3 (SSE3) instruction support
B
Intel Pentium M and compatible Intel processors

You should not use the -x options!

Attachments (1)

Download all attachments as: .zip