# DOCUMENTATION : matlab2fortran
<a href="https://www.buymeacoffee.com/hTpOQGl" rel="nofollow"><img alt="Donate just a small amount, buy me a coffee!" src="https://warehouse-camo.cmh1.psfhosted.org/1c939ba1227996b87bb03cf029c14821eab9ad91/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d4275792532306d6525323061253230636f666665652d79656c6c6f77677265656e2e737667"></a>
## Brief description:
* matlab2fortran(matlab-to-fortran) : converting matlab code to fortran
* Usage: matlab2fortran(filename);
* Author:Emmanuel Branlard (contributors are welcome)
* Creation Date : December 2012
* Last revision : 2015-08-26
* Version: 1.0-29-g83df194
* Web-Sites:
- http://github.com/elmanuelito/matlab2fortran
- http://emmanuel.branlard.free.fr/work/programming/
* License: None. Thank you for sharing your improvements to me by email.
## DESCRIPTION
matlab2fortran(matlab-to-fortran) is a code that performs an automatic conversion of one or multiple matlab files to fortran format. The script translate some of the main features of matlab to fortran. matlab2fortran performs a quick and dirty conversion on a line-by-line basis (but still supports conditional loops, subroutine). The script allows multiple matlab command per line if these commands are separated by ";", but not by ",".
matlab2fortran does not intend to produce ready-to-compile code, but performs several necessary conversions. The generated code keeps the structure, variables names and comments of the original code.
## INSTALLATION AND REQUIREMENTS
The script is located in the release directory of the repository.
The script matlab2fortran (matlab-to-fortran) is a single script file written in matlab. It does not require a particular installation other than maybe adding this script to your current folder or matlab path.
The script has been tested on linux and windows.
The script has been tested on matlab and octave.
(Octave generates some warnings. Ouputs are the same expect for some replacement of "...")
## REVISIONS
* 14/12/12 : first release
* 15/12/12 : added declaration of variables at beginning of script or subroutines
added handling of intent(inout),
corrected small bug for do loops and number of ":" since they can be in length(a(:,1))
* 18/12/12 :
- Get the function arguments do the decl_stack
- Handling of [] for array constructor and string concanenation
- support for transpose '
- When allocation for zeros, and ones, don't add the line x=x if no operation if present
- when removing duplicates from the stack, don't loose data
- Solved Bug for parenthesis in case like: if (a) && b which needs to give ((a) .and. b)
* 16/10/13 : From now on, revisions will only be listed vith git commits
## FEATURES AND TODOs
### Main Features of matlab2fortran:
- conversion of nested structure: do, if, switch (select), while
- conversion of function to subroutine with recognition of output and input arguments, (output arguments are put at the end)
- perform subroutine list of arguments with intent(in), intent(out), intent(inout)
- make a declaration list for simple variable , sort them by Name or Type
- determines type based on variable name (function fgetVarTypeFromVarName) and some syntax
- does its best to determine array size with things like :, [], zeros
- recognize simple function call and convert them to subroutine calls (syntax [y] = f(x) );
- performs allocation when converting matlab function zeros, ones (linspace possible)
- splitting of lines that contain multiple matlab command separated by ;
- comments
- small support for sprintf and fprintf
- small support for string concatenation
- small support for transpose when written as '
- misc conversions such as logical operators
- few intrinsic functions conversion
- replaces end by size(XXX,XXX)
- Provides Doxygen compatible comments for subroutine and arguments
### TODOs:
- easy: replace also & and | after && and ||
- better printf handling
- better handling of function calls and nested function calls..
- inline ifs?
- isequal
Requests:
- In “do while” construct, it does not put the logical expression in brackets.
- It does not convert “pi” to a real parameter having the value of 3.1415…
- It does not detect some of Matlab’s intrinsic functions (e.g., mean, std, nnz). It considers them as variables.
- It does not convert some intrinsic functions such as “fopen”.
- It considers the variables in array bounds subscript (e.g., t in M(s,t)) real, while they are integers.
### Features that are not intented to be supported
- Ready-to-compile output and perfection...
- Parsing of line and tree-like syntax detection
- Full type detection
- Type detection based on Matlab workspace output
- Detecting all variables
## RUN INSTRUCTIONS and PARAMETERS
The script should run in few seconds for a file a 1000 lines (say 2s). If it takes longer, activate the Debug flag bDebug=1; to see where the script is stuck...
Several parameters are found at the beginning of the script.
## EXAMPLES
example 1: one file
matlab2fortran('tests/test1.m');
example 2: list of files
matlab2fortran('tests/test1.m','tests/test2.m');
example 3: all files in current directory (does not work with subfolders with dir..)
FileList=dir('*.m');
matlab2fortran(FileList.name);
# Contributing
Any contributions to this project are welcome! If you find this project useful, you can also buy me a coffee (donate a small amount) with the link below:
<a href="https://www.buymeacoffee.com/hTpOQGl" rel="nofollow"><img alt="Donate just a small amount, buy me a coffee!" src="https://warehouse-camo.cmh1.psfhosted.org/1c939ba1227996b87bb03cf029c14821eab9ad91/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d4275792532306d6525323061253230636f666665652d79656c6c6f77677265656e2e737667"></a>
没有合适的资源?快使用搜索试试~ 我知道了~
ebranlard-matlab2fortran.zip
共43个文件
m:34个
f90:3个
txt:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 76 浏览量
2023-08-08
12:20:22
上传
评论
收藏 56KB ZIP 举报
温馨提示
ebranlard-matlab2fortran.zip
资源推荐
资源详情
资源评论
收起资源包目录
ebranlard-matlab2fortran.zip (43个子文件)
ebranlard-matlab2fortran
新建文本文档.txt 0B
matlab2fortran-master
Makefile 1KB
tests
fSpectrum.m 2KB
test2.m 6KB
myfunc.f90 287B
test2.f90 5KB
fUi_Vortexline.m 5KB
fUi_QuadSourcePlaneConstantN.m 7KB
test22.m 3KB
test11.m 453B
test1.f90 2KB
test1.m 2KB
fUi_QuadDoubletConstantN.m 2KB
myfunc.m 116B
fStocWind.m 2KB
fPlotCompare.m 567B
LICENSE.TXT 1KB
matlab2fortran.m 43KB
.gitignore 40B
dev
freplaceif.m 1KB
fgetVarTypeFromName.m 701B
fassignement.m 4KB
fremovesinglespace.m 109B
freplaceprintf.m 1KB
freplacezeros.m 2KB
fissurroundedby.m 1KB
freplaceend.m 390B
fsplitmatlablines.m 2KB
freplacefunctioncall.m 1KB
freplacewhile.m 727B
matlab2fortran.m 13KB
fgetDeclaration.m 701B
ffindmatching.m 729B
freplacefor.m 1KB
fremovespaces.m 95B
fmergeDeclarations.m 2KB
freplacefunction.m 3KB
freplacesbracket.m 2KB
README.md 5KB
fstack_push.m 168B
fstack_pop.m 160B
fstack_pop_element.m 173B
README.md 6KB
共 43 条
- 1
资源评论
AbelZ_01
- 粉丝: 893
- 资源: 5441
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Picasso_v3.1 2.ipa
- chromedriver-mac-arm64.zip
- 蓝zapro.apk
- chromedriver-linux64.zip
- UCAS研一深度学习实验-MNIST手写数字识别python源码+详细注释(高分项目)
- 基于Python和PyTorch框架完成的一个手写数字识别实验源码(带MINIST手写数字数据集)+详细注释(高分项目)
- 基于Matlab在MNIST数据集上利用CNN完成手写体数字识别任务,并实现单层CNN反向传播算法+源代码+文档说明(高分项目)
- NVIDIA驱动、CUDA和Pytorch及其依赖
- 基于SVM多特征融合的微表情识别python源码+项目说明+详细注释(高分课程设计)
- html动态爱心代码一(附源码)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功