Fortran guide - Windows

This section takes you through compiling and linking csWMPI II applications for three different Fortran compilers/IDEs. Namely, Compaq Visual Fortran, Lahey-Fujitsu Fortran, and Absoft Pro Fortran.

Fortran include files for the csWMPI II are different in order to allow for maximum support of particular features in each of the compilers.

Using other Fortran compilers:
In case you want to use csWMPI II with a compiler different from the three directly supported, you should also try to include each of the mpif.h files found in the directories include\vf, include\lh, and include\as (subdirectories of the installation directory). You might have to customize one of the mpif.h files to make it work with your compiler. Moreover, you should try to link with csWMPI II2.lib. There is a good chance that it should work for your compiler. In case you have a Fortran compiler not supported by csWMPI II and none of this works; please contact csWMPI II Support.


Important for Fortran 77

In order to use csWMPI II in Fortran 77 programs you MUST include the file mpi_init.f before the program statement. Moreover, you should include the file mpif.h after program statement. See the example below:

      ...
      include "mpi_init.f"

      program main
      implicit none
      include 'mpif.h'
      ...
      

In case you do not include mpi_init.f you will experience link errors.


Cross Compilation

In order to do cross compilation, e.g. compiling in Windows 32-bit for a 64-bit platform, all csWMPI II distributions for Windows contain lib files for all 3 windows platforms. In the base [install dir] directory, one can find the distribution platform lib files in [install dir]\lib directory.
csWMPI II lib files for each platform can be found in the following subdirs:

  • [install dir]\libi32 - for 32-bit systems
  • [install dir]\libx86_64 - for 64-bit Extended Systems
  • Include files are common for all platforms and can be found in [install dir]\include.
    To do cross-compilation, start the development environment for the target platform and use the platform specific lib directory instead of the default one.


    Compaq Visual Fortran

    This section takes you through the steps necessary for compiling and linking programs using csWMPI II in Compaq Visual Fortran applications:

    1. Set the INCLUDE and USE path
    2. Enable Use Multi-Threaded Library
    3. Link with the library: csWMPI II2.lib

    The procedure described below is for Compaq Visual Fortran version 6.1A. If you are using a different version the steps and the dialogs might be slightly different.

    Step 1: Set the INCLUDE and USE path
    In order to use csWMPI II you will need to include the file mpif.h in Fortran 77 applications and include a "use mpi" statement in Fortran 90 programs. The module and the mpif.h for Compaq Visual Fortran are found in the directory:

    [install dir]\include\vf

    (e.g. "C:\Program Files\csWMPI II\include\vf"), and can be referenced in a portable manner by using the environment variable MPI2_ROOT, which contains the path to the installation directory of csWMPI II.

    Example:
    Go to "Project|Settings" select the "Fortran" tab pane and choose category "Preprocessor" add $(MPI2_ROOT)\include\vf to the "INCLUDE and USE Paths".



    Step 2: Enable Use Multi-Threaded Libraries
    To avoid link warnings and errors it is necessary to configure your Fortran application to use "Multi-Threaded Libraries". Go to "Project|Settings" select the "Fortran" tab pane and choose category "Libraries". Now check the "Use Multi-Threaded Library" box. Reentrancy support should be set to "Threaded" and the "Use Fortran Rum-time Libraries" should be set to "DLL", as shown below:



    Step 3: Link with csWMPI II library
    In order to use csWMPI II it is necessary that your project link with the library csWMPI II2.lib. To configure this go to "Project | Settings" select the "Link" tab pane, choose category "Input", and do the following:

    1. Add csWMPI II2.lib to the list of "Object/library modules"
    2. Add the path $(MPI2_ROOT)\lib to "Additional library path"



    Lahey-Fujitsu Fortran

    This section takes you through the steps necessary for compiling and linking programs using csWMPI II from Lahey-Fujitsu Fortran. In case you are using the Driver (LF95.EXE) directly simply invoke it using the following switches:

    -I "[install dir]\include\lh"
    -LIBPath "[install dir]\lib"
    -LIB "csWMPI II2.lib"

    Where [install dir] denotes the path to the directory in which csWMPI II is installed (the default location is "C:\Program Files\csWMPI II").

    Alternatively, if you are using the automake utility (AMEDIT.EXE) you can create a Driver Configuration File (.FIG) for your csWMPI II application by the steps listed below:

    1. Create a new project
    2. Setup include path
    3. Setup library path
    4. Link with the library: csWMPI II2.lib

    The procedure described below is for Lahey-Fujitsu Fortran version 5.6. If you are using a different version the steps and the dialogs might be slightly different.

    Step 1: Create a new project
    Start the "LF95 Console Prompt", usually found in "Lahey Fujitsu Fortran" program folder in the Start menu. Go to the directory in which you want to create a csWMPI II application (e.g. "md myapp" followed by "cd myapp"). Now from this directory start "amedit".

    A dialog similar to the one shown below appears:


    Press "Editor" and continue to step 2.

    Step 2: Setup include path
    In order to use csWMPI II you will need to include the file mpif.h in Fortran 77 applications and include a "use mpi" statement in Fortran 90 programs. The module and the mpif.h for Lahey-Fujitsu Fortran is found in the directory:

    [install dir]\include\lh

    (e.g. "C:\Program Files\csWMPI II\include\lh")

    To setup the include directory choose "Compilation 1" (or the name of the compilation to which you want to add csWMPI II support), and add "-I %id" to the "Compile command" string and add [install dir]\include\lh to the "Include files" line as shown below:


    Step 3: Setup library path
    Choose "Link" and add a path option for the path [install dir]\lib to the "Link command" line as shown below:


    Step 4: Link with csWMPI II library
    In order to link to with the csWMPI II2.lib add a lib option to the "Link command" line as shown below:



    Absoft Pro Fortran

    This section takes you through the steps necessary for compiling and linking programs using csWMPI II in Absoft Pro Fortran Compiler Interface:

    1. Create a new project
    2. Setting F77 Compiler Option - ONLY for F77 projects
    3. Add csWMPI II2.lib to your project
    4. Set the include path

    The procedure described below is for Absoft Pro Fortran version 7.0. If you are using a different version the steps and the dialogs might be slightly different.

    Step 1: Create a new project
    Start the "Compiler Interface" from the Start menu in the programs folder "Absoft Pro Fortran". Create a new project (File|New). Type the name and the location of the project in the appropriate fields of the "New Project" dialog box. When you are done, press OK and continue to step 2.

    Step 2: Setting F77 Compiler Option - ONLY for F77 projects
    In the "Project Options" dialog, select the "F77" tab and the "Compatibility" option subset, and set the "Fold to Upper Case" checkbox, as shown below:

    Specify any other options applicable to your project, press "OK" and continue to step 3.

    Step 3: Add the csWMPI II library to your project
    From the "Configure" menu select "Add/Remove file(s)" (shortcut CTRL-F). And add the library csWMPI II2.lib, to the project. The library is found under the sub-directory lib of the installation directory. The default location is:

    C:\Program Files\csWMPI II\lib

    See the example below:


    Step 4: Set the include path
    Finally, you have to setup the include path for the compiler to be able to locate mpif.h. Go to the "Configure" menu and select "Set include path(s)" (shortcut CTRL+P). Now browse to the sub-directory include\as of the installation directory and press "Add". The default location of the include directory is:

    C:\Program Files\csWMPI II\include\as

    See the example below:



    Intel Fortran Compiler

    This section takes you through the steps of compiling and linking programs using csWMPI II and the Intel Fortran Compiler under the command line.
    After starting the Build Environment for the target platform, to use csWMPI II you need to follow these steps:

    1. Set the INCLUDE and USE path: [install dir]\include\ifc
    2. Link with the library: csWMPI II2.lib

    Step 1: Set the INCLUDE and USE path
    In order to use csWMPI II you will need to include the file mpif.h in Fortran 77 applications and include a "use mpi" statement in Fortran 90 programs. The module and the mpif.h for Intel Fortran Compiler are found in the directory:

    [install dir]\include\ifc

    (e.g. "C:\Program Files\csWMPI II\include\ifc"), and can be referenced in a portable manner by using the environment variable MPI2_ROOT, which contains the path to the installation directory of csWMPI II.
    For the Intel Fortran Compiler you have to specify the option:

    /I "%MPI2_ROOT%\include\ifc"

    Example for I32 platform:
    To compile hello_world.f and produce a compiled object, hello_world.obj, run the following command:

    D:\hello_world> ifl /I "%MPI2_ROOT%\include\ifc" /c hello_world.f

    Step 2: Link Settings
    In order to use csWMPI II you will need to link with csWMPI II2.lib. This file can be found in the directory [install dir]\lib and can be referenced in a portable manner by using the environment variable MPI2_ROOT.
    For the Intel Fortran Compiler you have to include the following options:

    /libpath:"%MPI2_ROOT%\lib" csWMPI II2.lib

    Example:
    To link the previous compiled object, hello_world.obj, and produce the final executable, one can execute the following command:

    D:\hello_world> xilink /out:hello_world.exe /libpath:"%MPI2_ROOT%\lib" csWMPI II2.lib hello_world.obj




    © 2009 Critical Software SA. All trademarks and copyrights on this page are owned by their respective owners.
    csWMPI II™, csWMPI II™ and PatentMPI™ are trademarks of Critical Software SA. All Rights Reserved.