Sunday, December 20, 2009

Fortran GDX support

Although there are a few Fortran support files in the \apifiles subdirectory of recent GAMS systems, the actual usage is not always completely straightforward as I found out by some experiences of a client. This is probably foremost a documentation issue. Here are my notes.

  1. The example example1.f90 in apifiles\examples is for Visual Fortran (some versions) and Microsoft C compiler. The example works ok with with my versions:
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
    Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update C)

    Y:\doe\ftn\ftn>type compile.cmd
    cl -DAPIWRAP_LCASE_NODECOR -c gdxf9glu.c
    f90 -c gamsglobals_mod.f90
    f90 -c gdxf9def.f90
    f90 test.f90 gdxf9def.obj gdxf9glu.obj

    Y:\doe\ftn\ftn>compile

    Y:\doe\ftn\ftn>cl -DAPIWRAP_LCASE_NODECOR -c gdxf9glu.c
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
    Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

    gdxf9glu.c

    Y:\doe\ftn\ftn>f90 -c gamsglobals_mod.f90
    Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update C)
    Copyright 2003 Compaq Computer Corp. All rights reserved.

    gamsglobals_mod.f90

    Y:\doe\ftn\ftn>f90 -c gdxf9def.f90
    Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update C)
    Copyright 2003 Compaq Computer Corp. All rights reserved.

    gdxf9def.f90

    Y:\doe\ftn\ftn>f90 test.f90 gdxf9def.obj gdxf9glu.obj
    Compaq Visual Fortran Optimizing Compiler Version 6.6 (Update C)
    Copyright 2003 Compaq Computer Corp. All rights reserved.

    test.f90
    Microsoft (R) Incremental Linker Version 6.00.8447
    Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

    /subsystem:console
    /entry:mainCRTStartup
    /debugtype:cv
    /pdb:none
    C:\DOCUME~1\HP_Owner\LOCALS~1\Temp\objEC.tmp
    gdxf9def.obj
    gdxf9glu.obj
    dfor.lib
    libc.lib
    dfconsol.lib
    dfport.lib
    kernel32.lib
    /out:test.exe

    Y:\doe\ftn\ftn>

  2. Visual fortran 6.0 does not work (no support for integer(kind=8); that could be implemented differently if needed).
  3. It would be easier to have some 100% fortran interfaces instead of only this Fortran+C thing. It would be simpler to use and could be a little bit faster (no extra indirection).
  4. There is some Lahey code (100% fortran code). More direct support for other compilers would be good.
  5. It can be made to work with Intel Fortran + MS Visual C by added libc.lib to the link step.
  6. It can be made to work with Mingw gcc+g95 as follows:

    Install MINGW from http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/
    Install g95 from http://ftp.g95.org/g95-MinGW.exe

    Compile as:

    C:\projects\doe\ftn\ftn2>type compile.cmd
    gcc -DAPIWRAP_LCASE_NODECOR -c gdxf9glu.c
    g95 -c -fno-underscoring gamsglobals_mod.f90
    g95 -c -fno-underscoring -w gdxf9def.f90
    g95 -w -fno-underscoring test.f90 gdxf9def.o gdxf9glu.o -o test.exe -Xlinker --enable-stdcall-fixup

    C:\projects\doe\ftn\ftn2>compile

    C:\projects\doe\ftn\ftn2>gcc -DAPIWRAP_LCASE_NODECOR -c gdxf9glu.c

    C:\projects\doe\ftn\ftn2>g95 -c -fno-underscoring gamsglobals_mod.f90

    C:\projects\doe\ftn\ftn2>g95 -c -fno-underscoring -w gdxf9def.f90

    C:\projects\doe\ftn\ftn2>g95 -w -fno-underscoring test.f90 gdxf9def.o gdxf9glu.o -o test.exe -Xlinker --enable-stdcall-fixup

    C:\projects\doe\ftn\ftn2>test
    done

    C:\projects\doe\ftn\ftn2>




    The –fno_underscoring flag may cause problems with precompiled fortran libraries. Better support for this compiler would be good so we don’t need these compilation flags.


  7. The interface code could benefit from some comments.


  8. Some documentation about what compilers are supported and how would be good.


  9. May be some more explicit support+documentation for the (currently) leading fortran compilers. E.g. Visual Fortran is no longer available, so that is not a very good platform for the examples. Probably on Windows the following are the most popular compilers: Lahey/Fujitsu, Intel, g95, gfortran. I also suspect g77 is still used a lot.

No comments:

Post a Comment