• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created about 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A translator from Fortran to C++. We provide statement-wise translation to improve readability.

CFortranTranslator

A translator from Fortran90/Fortran77(ISO/IEC 1539:1991) to C++

Fortran is an efficient tool in scientific calculation. However sometimes translating old fortran codes to C++ will enable more programming abstraction, better GUI framework support, higher performance IDE and easier interaction.

This translator is not intended to improve existing codes, but to make convenience for those who need features of C++ and remain fortran traits and performance as much as possible.

Build Status Coverage Status

Features

  1. Convert Fortran90/Fortran77 code to C++14

  2. Parse codes mixed with fixed form and free form automaticlly

  3. C++ implemetation of some Fortran's type and functions

  4. Generated C++ code remains abstract level of the origin code

    e.g. implied-do will not expand to a for-loop directly, but to a ImpliedDo struct

License

The whole project, including both the translator itself and fortran standrad library implementation is distributed under GNU GENERAL PUBLIC LICENSE Version 2

                    GNU GENERAL PUBLIC LICENSE
                       Version 2, June 1991

Calvin Neo
Copyright (C) 2016  Calvin Neo

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Install

Build project in Windows

Dependencies

  1. MSVC(e.g. Visual Studio 2015)
  2. win_flex(win_flex_bison 2.4.5, flex 2.5.37)
  3. win_bison(win_flex_bison 2.4.5, bison 2.7)
  4. boost(1.60)

Configure boost

  • build boost
bjam --toolset=msvc-14.0 address-model=64
  • configure boost
    1. Add boost_dir directory to additional include library
    2. Add boost_dir/libs and boost_dir/stage/lib to additional library directory

Configure winflex and winbison

  1. On the Project menu, choose Project Dependencies.
  2. Select Custom Build Tools
  3. Add /src/grammar/custom_build_rules/win_flex_bison_custom_build.props

Build by MSBuild

Run /build/vcbuild.cmd

You can get Visual C++ Build Tools here(Not available now) or here

All built production will be in /bin

Build by NMake

Run /build/winmake.cmd to get a x64 Release binary

Build By Visual Studio

Open /vsbuild/CFortranTranslator.sln

Build project in Ubuntu

Dependencies

  1. g++(e.g. g++ 5.4.0)
  2. bison
  3. boost

Configure boost

Install boost by

sudo apt-get install libboost-all-dev

Configure bison

Install bison by

sudo apt-get install bison

Make

cd build && make
make install

Fortran standard library(for90std)

for90std is a simple implementation of fortran's library and is yet to be done

for90std requires compiler support at least C++14 standard(with several C++17 std functions)

With the following statement to include for90std module

#include "for90std/for90std.h"

cpptest

cpptest is a C++ project template for you to test for90std.

Run CFortranTranslator with arguments

-f file_name : translate file_name into C++
    **Currently, Unicode encoding is not supported**
-d : use debug mode
-C : use c-style array
-F 90/77 : specify Fortran standard, by default the translator accept a mixed Fortran77/90 codes

Demo

The "hello world" demo

  1. Use the following command to generate target C++ code
    CFortranTranslator.exe -Ff demos/helloworld.f90 > target.cpp
    
  2. Build target.cpp, modify #include "../for90std/for90std.h" to ensure you include the right path of for90std library. You can either use /cpptest/winmake.cmd to build your code, or build them in cpptest project.

More demos

Translator Demos

Several demos are provided in /demos. Run /demos/merge_test.py to generate a *.form.test file by merging codes from all .for/.f90 files in a certain folder. Then you can convert the merged Fortran code into C++.

for90std Demos

Several demos are provided in /demos/for90std. Make sure you have google-test library before test.

Debug

Only fatal errors hindering parsing will be reported by translator.

Debuging origin fortran code or generated C++ code is recommended.

Docs

see /docs/brief.md

Develop details guide

see /docs/Develop.md to have an general understanding of implementation of this project.

More Repositories

1

ATP

A transmission protocol implementation based on UDP, inspired by libutp
C++
28
star
2

Nuft

Nuft is an C++17 implementation of the Raft consensus algorithm.
C++
27
star
3

EasyMLPlatform

DEPRECATED-an easy distributed machine learning platform
JavaScript
12
star
4

PolyClip

A fast solution cropping lines and circles through a polygon window
C
6
star
5

LeetCode

Solutions in http://www.calvinneo.com/2017/02/09/LeetCode%E8%A7%A3%E9%A2%98%E6%8A%A5%E5%91%8A/
Python
3
star
6

TraceSimilarity

Trace Similarity Compare
CSS
3
star
7

ARPC

C++
3
star
8

PyGeo

geotechnical utilities
Python
3
star
9

NuCut

NuCut is a streaming graph partitioning and storage framework
C++
3
star
10

gpucut

using CUDA to clip lines and circles through polygons
C++
3
star
11

Citation4Word

国内论文引用文献样式,将xsl文件导入%APPDATA%\Microsoft\Bibliography\Style即可
XSLT
2
star
12

CSAPP

CSAPP 2e Lab Solutions
C
2
star
13

Nuke

A Personal C++ Library
C++
2
star
14

Melotation

An easy, open source notation tool
Python
2
star
15

PCDanmakuFlameMaster

[deferred][ugly]PC port of DanmakuFlameMaster
C++
1
star
16

DataWasher

A scala tool to wash dataset
1
star
17

ProjectEuler

Project Euler Solutions
Haskell
1
star
18

AliSalesMining

Mining from Alibaba's sales database IJCAI-17(this is lab of Cloud Computing)
Python
1
star
19

SQLMath

Use SQL for math problems
1
star
20

KVStore

This is lab1 of Course Bigdata
Java
1
star
21

calvinneo.github.io

calvin's blog
HTML
1
star
22

calvinneo-com-source

HTML
1
star
23

MobaPredict

Predict result of moba games
Python
1
star
24

DBuf

A Lockfree Sizable Buffer
1
star
25

Age-of-Empires-Crusher

An Age of Empires AI
Python
1
star
26

brainfuck

bf interpreter and bf source codes
Python
1
star
27

EasyPendant

Make life easier
Python
1
star
28

sudoku_solver

A 9x9 sudoku solver
Python
1
star