Photran的用法(转载自eclipse官网)

Viktor posted @ Nov 12, 2008 06:46:55 PM in FORTRAN with tags photran fortran make makefile 编译 Eclipse ide , 4613 阅读

Getting Started with Managed Make

If your system has the GNU gfortran compiler installed, try this.

  1. File | New | Fortran Project
  2. Call it whatever
  3. Choose the Executable (Gnu Fortran) from the project type list   注:对于Ubuntu 8.10系统已经不再提供G77支持了,因此,编译器一定要选gfortran,即GNU Fortran
  4. Choose GCC Toolchain from the toolchain list (you may need to uncheck the "Show project types..." check box at the bottom of the window)
  5. Click Next
  6. Click on Advanced Settings
  7. Expand C/C++ Build in the list on the left, and click on Settings
  8. Click on the Binary Parsers tab.  Check the appropriate parsers for your platform. If you are using Windows, check PE Windows Parser and/or Cygwin PE Parser; if you are using Linux, check Elf Parser; if you are using Mac, check Mach-O parser.
  9. Click on the Error Parsers tab. Check the error parser(s) for the Fortran compiler(s) you will use.
  10. Click OK
  11. Click Finish
  12. Click File | New | Source File
  13. Call it hello.f90; click Finish
  14. Type the standard "Hello, World" program, and click File | Save.

    program hello
        print *, "Hello World"
        stop
    end program hello
  15. Open the Console view, and make sure "make" ran OK and compiled your program
  16. In the Fortran Projects view, expand the Binaries entry, and click on your executable (e.g., "whatever - [x86le]") 这个设计很好很强大到让人摸不着头脑,因为用M$的V$已经用惯了。。。
  17. Run | Run As | Run Local C/C++ Application (yeah, I know, it should say "Fortran Application", but it doesn't)
  18. Choose GDB Debugger (Cygwin GDB Debugger if you're under Windows)
  19. Check the Console view, and make sure Hello World appeared.

Getting Started with Standard Make

To get started, try this.  If you're under Windows, you need to be running Cygwin, c:\cygwin\bin and c:\cygwin\usr\bin should be in your system path, and the g95 libraries need to be copied into /usr/lib (to make things easier for yourself, at least).

  1. File | New | Fortran Project
  2. Call it whatever
  3. Choose Makefile Project from the project type list (it has a folder icon; do not expand it)
  4. Choose "-- Other Toolchain --" from the toolchain list <--li>Click Next
  5. Click on Advanced Settings
  6. Expand C/C++ Build in the list on the left, and click on Settings
  7. Click on the Binary Parsers tab.  Check the appropriate parsers for your platform. If you are using Windows, check PE Windows Parser and/or Cygwin PE Parser; if you are using Linux, check Elf Parser; if you are using Mac, check Mach-O parser.
  8. Click on the Error Parsers tab. Check the error parser(s) for the Fortran compiler(s) you will use.
  9. Click OK
  10. Click Finish
  11. File | New | File
  12. Call it Makefile
  13. Click Finish
  14. We assume you're familiar with how to format a Makefile.  Something like this will work for now.  Remember to start the g95 line with a tab, not spaces.  The -g switch instructs g95 to include debugging symbols in the generated executable so that it can be debugged later.

    all:
        g95 -g hello.f90

    clean:

  15. File | New | Source File
  16. Call it hello.f90
  17. Click Finish
  18. Type the standard "Hello, World" program.

    program hello
        print *, "Hello World"
        stop
    end program hello
  19. Project | Clean; then click OK
  20. Open the Console view, and make sure "make" ran OK and compiled your program
  21. In the Fortran Projects view, expand the Binaries entry, and click on your executable (e.g., "whatever - [x86le]")
  22. Run | Run As | Run Local C/C++ Application (yeah, I know, it should say "Fortran Application", but it doesn't)
  23. Choose GDB Debugger (Cygwin GDB Debugger if you're under Windows)
  24. Check the Console view, and make sure Hello World appeared.

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter