Most recent version at:
http://engineering.dartmouth.edu/~d30574x/consulting/consultingIndex.html
CONTENTS:
1. SUPPORT f2matlab AND CONSULTING
0. DISCLAIMER
1. OBJECTIVE
2. MOTIVATION
3. BUG REPORTS and WISH LIST
4. F2MATLAB CAPABILITIES
5. F2MATLAB LIMITATIONS
6. HOW TO USE F2MATLAB
7. EXAMPLES
8. REVISION HISTORY
1.SUPPORT f2matlab.
I now also do conversion/translation/validation/optimization consulting.
Please refer to my webpage:
http://engineering.dartmouth.edu/~d30574x/consulting/consultingIndex.html
Even though f2matlab is free (under GPL) for the using, I would like
to ask that those who find it useful, wish to support the project,
and are able to make a contribution to please do so commesurate with
use (especially corporations). *** Important  Please donate using
your PayPal account and not a credit card so as to avoid fees at
PayPal. Thank you! PayPal email ID: barrowes@alum.mit.edu
0. DISCLAIMER: Matlab is a trademark of the Mathworks company and is
owned by them. The author makes no guarantee express or implied of
any kind as to the applicability, usefulness, efficacy,
bugfreeness, or the accuracy of the ensuing results from using
f2matlab.
The author bears no responsibility for any unwanted effect
resulting from the use of this program. The author is not
affiliated with the Mathworks. The source code is given in full in
the hopes that it will prove useful. Devlopment is done through
sourceforge at f2matlab.sourceforge.net.
1. OBJECTIVE: f2matlab.m is a small translator which aims to
convert Fortran90 files to Matlab mfiles.
2. MOTIVATION:
1) Matlab is becoming ubiquitous in the engineering and scientific
communities for its ease of use coupled with its powerful
libraries. Yet the fact remains that a large number of stable and
dependable programs exist in the fortran77/90 corpus.
2) Many times, often amidst the porting of fortran programs to
Matlab, an automated converter of fortran90 code to Matlab code would
be useful.
3) Having written matlab2fmex.m, a matlab to fortran90 mex file
converter, the writing of f2matlab, which performs the reverse
conversion, was substantially simplified.
3. BUG REPORTS and WISH LIST:
For all bug reports, a wish list for f2matlab, and suggestions,
see http://engineering.dartmouth.edu/~d30574x/consulting/consultingIndex.html
or email barrowes@alum.mit.edu
4. F2MATLAB CAPABILITIES: f2matlab is aimed at converting
Fortran90 code to Matlab mfiles. Accordingly, only basic data types
and constructions are recommended. f2matlab can handle:
all numeric types (handled by Matlab interpreter)
most string functions
comparisons, branches, loops, etc.
basic read/write/print statements (if it's not too fancy...)
modules
5. F2MATLAB LIMITATIONS: f2matlab can not handle some features of
fortran90 yet. These include:
can't handle complex read and write statements
derivedtyped variables
equivalence
...
6. HOW TO USE F2MATLAB: f2matlab expects a single fortran90 fortran file to
convert. If you have fortran77 code, use some free converter
(e.g. to_f90 by Alan Miller) before running f2matlab. Then simply
call f2matlab by using the full filename:
f2matlab('filename.f90');
The output will be filename.m in the same directory.
A few flags are available that effect conversion:
% want_kb=0; 1 ==> if keyboard mode is desired after some conversion steps
% want_ze=0; 1 ==> direct f2matlab to zero all array variables.
% want_fi=0; 1 ==> direct f2matlab to try to put fix()'s around declared integers.
Multiple subroutines and functions can and should be in the same fortran90 file.
Ben Barrowes (2020). benbarrowes/f2matlab (https://github.com/benbarrowes/f2matlab), GitHub. Retrieved .
4.1.0.0  Updated description. 

4.1.0.0  Now on github. 

1.6.0.0  Added link to most recent version off site. 

1.3.0.0  Several bug fixes and enhancements. Include files, types, etc. 

1.2.0.0  bug fixes, features added, more robust 

1.1.0.0  Some documentation updates and bug fixes. 

1.0.0.0  Many bug fixes and major upgrade of capabilities. 

updated description 

Bugfixes, added functionality. 

Speed improvement. Bug fixes. Module capability better. 

Changed description 

Fixed some bugs.


Some improvements and fixes. 

Some bug fixes. Some enhancements. 

Bug fixes. 

03/09/05  put fix() around declared integers


Many bugs is last dist. 

More bug fixes. Support for strings as cells. I/O enhancements. 

01/20/05  some bug fixes


bug fixes, more robust 

Some bug fixes. 

Enhancements, bug fixes.


Enhancements, bug fixes.


Enhancements, bug fixes. 

Enhancements, bug fixes. 

Added module support. 
Inspired: Generalised Exponential Integral, GaussHermite
Create scripts with code, output, and formatted text in a single executable document.
Maryam, f2matlab cannot find your file. Make sure you are in the correct directory with your file in it, and f2matlab is on your path.
Hi Ben, thanks for your code.
When I am using the code, I get this error.
f2matlab('femprb.f90');

 f2matlab  Ben Barrowes, Barrowes Consulting 

Error using fscanf
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in f2matlab (line 212)
fid=fopen(filename); filestr=fscanf(fid,'%c'); fclose(fid);
Would you please tell me what the problem is. I tried this with the simple code of mine and also your sample codes.
Andrea, please email me your code and I can take a look. barrowes@alum.mit.edu
Hi Ben, your code give me this error:
Expected one output from a curly brace or dot indexing expression, but there were 0 results.
Error in f2matlab (line 2558)
for i=1:length(funstrwords{fundecline}(funargs))
Error in fortranmatlab (line 1)
f2matlab('fortran.f90');
how can I resolve it? thank u
Martijn, there maybe something wrong with your file. Email me your code and I can take a look.
Dear Ben,
No matter what file I select I always get the error: Index exceeds array bounds (Line 3877): if ~any(strcmp(funstrwords{i}{j},noChangeWords). Is this a known issue? Looking forward to your reply.
Sema, f2matlab seems to be having trouble finding faverage.f90. Make sure you are in the directory with faverage.f90 when you invoke f2matlab. You can PM me if you still have issues.
Hi, thank you very much for this code to convert f90 files to matlab. Unfortunately I got message "Unable to resolve the name faverage.f90. All the files are in the same directory. What could be the reason?. If you help me I would be grateful
Niti, Odd that it would complete but generate no warnings or output. Please make sure your code is up to f90 standards. Then PM me the code if it still doesn't work for you. bb
Hi Ben, thank you for this code to convert fortran file to matlab.
I tried running my file using f2matlab('test.f90') and it starts running but completes without generating a .m file.
It works with the example files provided with the folder, however I'm not getting any output for my .f90 file.
Stuart, It looks like there is an implied do loop that is giving f2matlab difficulty in your code. Please make sure your code is up to f90 standards after following the README file. If that doesn't fix the problem, PM me your code, and I can take a look. bb
All of the examples run just fine but when I try to run it on a piece of code of my own I get the following errors. Any advice you can provide would be appreciated.
Index exceeds matrix dimensions.
Error in convertRW_impLoops (line 19)
if strcmp(groupsIn{ii}(1),'''')
Error in convertRW (line 12)
temp7=convertRW_impLoops(temp6);
Error in convertWrite (line 208)
convertRW
Error in wordconverter_f (line 233)
convertWrite
Error in f2matlab (line 3909)
[funstr,fortranfunwords,tempflag,temp2,temp4,needThings]=wordconverter_f(i,j,funstr,funstrnumbers,funstrnumbers_b,funstrnumbers_e,funstrwords,funstrwords_b,funstrwords_e,fs_good,funwords,fortranfunwords,formats,localVar,modLocalVar,MLapp,varp,want_row,var_words,this_fun_name,TFops,allTypeDefs,funwordsML,statementFunction,fun_name,dumvar,want_gl,fundecline,funargs,needThings,usedMods);
Error in f2matlab (line 1706)
[temp2,temp3,temp4,temp5]=f2matlab(filename,fun_name{i},i,segmentStarts,fun_name);
Your source code is very very very very difficult to modify!!!!!!!!
matlab is so easy to use. However, you initialise the variables with a lot of if and check modules. That's funny.
Parth, f95 has a few more features than f90, but they are mostly the same.
It looks like f2matlab couldn't find you file. Go through the README with the examples first.
Hey, thanks for the converter ben, when i try to run f2matlab it says
((Error using fscanf
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in f2matlab (line 212)
fid=fopen(filename);
filestr=fscanf(fid,'%c'); fclose(fid);))
and another thing is how do i convert f95 to f90 ?? both are same ?
Klearchos, make sure the directory you unzipped f2matlab in is on the matlab path.
Email me at barrowes@alum.mit.edu for more help than I can give here.
Thanks,
bb
Hello Ben
I keep trying to use f2matlab as you note in part 6. I have a *.f90 file (written with Crimson Editor) and when I use the command >>f2matlab('*.f90'); no output '*.m' file is returned. No errors occur and your function works though. I have everything in the same folder/path. I also tried to use it on your example '*.f90' files, but I still don't get an output file.
Hello Ben
I really would love to try your f2matlab. I have a very important f.90 code I would like to convert to Matlab. I have tried your f2matlab function which always seems to work for your examples but never mind. Can you please update your function to help fix a problem such as this
Error:
Index exceeds matrix dimensions.
Error in f2matlab (line 1621)
[dummy,temp2,usedMods]=intersect({modUsedMods{temp,2}{:}},{modLocalVar{temp3,1}});
Thanks
Hi Ben Barrowes,
First thing to say thanks for your convert f2matlab.
My problem is the following:
I have several script in fortran90. These include some subroutines within each script. I apply your code to convert and it apparently works well. However, when I try running some of these codes starting to have problem. As each script in fortran90 contain several subroutines, How matlab takes it into account?
There is part of my fortran90 code as:
use readandwrite !this module contains subroutines for reading, formatting and writing data
use FindError
Implicit None
character :: peaklistname*100 !name of the file with all the observed modes in it.
character :: outputname*100 !name of the output file
character :: bestname*125 !name of the output file with the best correlations
character :: gridname*125 !name of the output file with the complete grid search results
character :: tab = ACHAR(9) !tab
integer, parameter :: TS = 3 !the highest allowed term in the expansion
integer, parameter :: MAX_STEPS = 100000 !The maximum possible steps in one direction for the nongrid search........
.............. 60 format (a).....
that I don't understand the conversion to matlab:
format_60=['%c'];
readandwrite;
finderror;
%name of the file with all the observed modes in it.
if isempty(peaklistname), peaklistname=repmat(' ',1,100); end;
%name of the output file
if isempty(outputname), outputname=repmat(' ',1,100); end;
%name of the output file with the best correlations
if isempty(bestname), bestname=repmat(' ',1,125); end;
%name of the output file with the complete grid search results
if isempty(gridname), gridname=repmat(' ',1,125); end;
%tab
if isempty(tab), tab = char(9); end;
%the highest allowed term in the expansion
if isempty(ts), ts = 3; end;
%The maximum possible steps in one direction for the nongrid search
if isempty(max_steps), max_steps = 100000; end;
.......
On the other hand, when I try running it is broken and give the message:
...Cannot find an exact (casesensitive) match for 'strassign'......
Thank you very much....
I tried to convert some Fortran subroutines to MATLAB, I am getting the following error:
??? Undefined function or variable 'assignSwitches'.
Error in ==> f2matlab at 104
assignSwitches
Thank you for any suggestion.
Ara,
The first error looks like it cannot find the file you specified.
The error regarding modUsedMods probably indicates f2matlab could not find a module your fortran program "use"d.
Not sure about the "index exceeds..." error.
Please send me a private email with your code and I can take a look.
bb
Tried 3 different files and getting errors as follows:
1.
Error using fscanf
Invalid file identifier. Use fopen to generate a valid file
identifier.
Error in f2matlab (line 212)
fid=fopen(filename); filestr=fscanf(fid,'%c'); fclose(fid);
2 & 3.
Index exceeds matrix dimensions.
Error in f2matlab (line 1621)
[dummy,temp2,usedMods]=intersect({modUsedMods{temp,2}{:}},{modLocalVar{temp3,1}});
Kathryn,
Try tof90 by Alan Miller for a f77 to f90 converter. But I am not sure why you should have this recursion error. Please email me your code at barrowes@alum.mit.edu so I can take a look.
bb
I am getting a recursion error.
Error message: Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit.Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
Could this be a result of using fortran77 code?
Do you have a suggestion of a free converter for f77 to f90?
Maria, Please follow the README. You need to put the directory containing f2matlab on your matlab path.
I have tried to convert a fortran 95 program.
The error found is:
Undefined function or variable 'f2matlab'
Chirag, I am not sure why you would have to change the recursion limit. Please send me your code so I can take a look. bb
I figure out how to change recursion limit but I can increase this limit to 1000, and it gives error. so in fortran code which thing I should change?
can anyone help me out how to change recursion limit during converting fortran to matlab ?
Michel Hajj (or anyone having trouble with f2matlab), please email me with your fortran file, so I can take a look:
barrowes@alum.mit.edu
Index exceeds matrix dimensions.
Error in f2matlab (line 4539)
if (strcmp(temp5,'character')  ~isempty(temp6{16})) && length(temp6{5})>0
any help, please?
When when I try run f2matlab to convert fortran in matlab. The screen show me a error below:
??? Undefined function or variable 'getfunwordsonly'.
Error in ==> f2matlab at 103 funwords=getfunwordsonly;)
Anyone can help me? Please
Good one
can anybody please explain step by step the process of conversion, because the readme file doesn't exist.
implicit none
REAL U1,U2,r,dt,dx,nu,tf,t,c,X,a,b,d,c2,d2,k,cl,lambda,alpha
integer n,i,j,scheme
ALLOCATABLE U1(:),U2(:),X(:),a(:),b(:),c(:),d(:),c2(:),d2(:)
CHARACTER*80 DON
CHARACTER*80 param
WRITE(*,*) 'Fichier de donnees ? '
READ(*,'(A)') param
OPEN(4,FILE=param)
READ(4,*) n
READ(4,*) dt
READ(4,*) tf
READ(4,*) nu
READ(4,*) scheme
READ(4,*) cl
READ(4,*) lambda
READ(4,*) alpha
CLOSE(4)
IF(scheme.EQ.1) THEN
WRITE(*,*) 'Explicit scheme'
ELSE
WRITE(*,*) 'Implicit scheme'
ENDIF
IF(cl.EQ.0) THEN
WRITE(*,*) 'cl rigide '
ELSE
WRITE(*,*) 'cl libre'
ENDIF
WRITE(*,*) 'n =',n
WRITE(*,*) 'dt =',dt
WRITE(*,*) 'tf =',tf
WRITE(*,*) 'nu =',nu
WRITE(*,*) 'lambda =',lambda
WRITE(*,*) 'alpha =',alpha
dx=1./float(n)
r=nu*dt/(dx*dx)
k=dt/(2*dx)
ALLOCATE (U1(n+1),U2(n+1),X(n+1),a(n+1),b(n+1),c(n+1),
& d(n+1),c2(n+1),d2(n+1))
DO i=1,n+1
X(i)=(i1)*dx
a(i)=0
b(i)=0
c(i)=0
d(i)=0
END DO
c initialisation
DO i=1,n+1
U1(i)=SIN(2*3.1415927*(i1)/n)
END DO
t=0
DO WHILE (t.LT.tf)
t=t+dt
c conditions limites
U1(1)=0
U1(n+1)=0
U2(1)=0
U2(n+1)=0
c boucle explicite
IF(scheme.EQ.1) THEN
DO i=2,n
U2(i)=r*U1(i+1)+(12*r)*U1(i)+r*U1(i1)
& k*U1(i)*(U1(i+1)U1(i1))
END DO
DO i=1,n
U1(i)=U2(i)
END DO
c boucle implicite
ELSE
DO j=2,n+1
a(j)=0.25*dt*U1(j1)/dx0.5*r
END DO
DO j=1,n+1
b(j)=1+r
END DO
DO j=1,n
c(j)=0.25*dt*U1(j+1)/dx0.5*r
END DO
d(1)=(1r)*U1(1)+0.5*r*U1(2)
d(n+1)=0.5*r*U1(n)+(1r)*U1(n+1)
DO j=2,n
d(j)=0.5*r*U1(j1)+(1r)*U1(j)+0.5*r*U1(j+1)
& +dt*(lambda*U1(j)+alpha*U1(j)*U1(j)*U1(j))
END DO
c algorithme de Thomas
c2(1)=c(1)/b(1)
d2(1)=d(1)/b(1)
DO i=2,n+1
c2(i)=c(i)/(b(i)a(i)*c2(i1))
d2(i)=(d(i)a(i)*d2(i1))/(b(i)a(i)*c2(i1))
END DO
U1(n+1)=d2(n+1)
DO i=1,n
U1(n+1i)=d2(n+1i)U1(ni+2)*c2(n+1i)
END DO
ENDIF
END DO
WRITE(*,*) 'Fichier de resultat ? '
READ(*,'(A)') DON
OPEN(5,FILE=DON)
DO i=1,n+1
WRITE(5,*) X(i),U1(i)
END DO
CLOSE (5)
END
can any one to convert this code into .m file matlab
thanks
1 DIMENSION A {17,17},B{17,17}
2 DO 6 I=2,17
3 DO 5 J=1,17
4 A{I,J}=0.
5 CONTINUE
6 CONTINUE
7 DO 9 J=2,16
8 A{I,J}=100.
9 CONTINUE
10 A{L,L}=50.
11 A{1,17}=50
12 DO 16 I=2,16
13 DO 15 J=2,16
14 A{I,J}={A{I,J6}+A{IL+J}+A{I,J+L}+A{I+L,J}}/4.
15 CONTINUE
16 CONTINUE
17 DO 23 I=2,16
18 DO 22 J=2,16
19 C={A{I,JL}+A{IL,J}+A{I,J+L}+A{I,L.J}}/4
20 B{I,J}=A{I,J}C
21 IF{{ABS{B{I,J}}.00001}.GT.O.} GO TO 12
22 CONTINUE
23 CONTINUE
24 WRITE{6,25}{{A{I,J},J=1,17},I=1,17}
25 FORMAT {1H0,17F7.2}
26 STOP
27 END
Hi
I have a problem installing this program on Matlab R2011b
Can you provide an explantion of using those files?
Ran the code and immediately received the following error:
??? Index exceeds matrix dimensions.
Error in ==> f2matlab at 1055
funstr={funstr{segmentStarts(whichsub):segmentStarts(whichsub+1)1}}';
Don't know enough about the code to solve this problem.
I´m trying to convert as well a frotran code to matlab code. I always get the errormessage

??? Too many outputs requested. Most likely cause is missing [] around
left hand side that has a comma separated list expansion.
Error in ==> findendSub_f at 80
sublist{slLen+1,7}=sublist{temp6,1};
Error in ==> f2matlab at 899
[sublist,funstr,funstrnumbers,funstrnumbers_b,funstrnumbers_e,funstrwords,funstrwords_b,funstrwords_e,fs_good]=findendSub_f([],sublist,s,funstr,funstrnumbers,funstrnumbers_b,funstrnumbers_e,funstrwo
Error in ==> test at 2
f2matlab('MarqStepEX_P.for');

and i have no idea want it means. thx for any help
I am using this f2matlab file but when I call the function to convert my fortran90 code to .m file, it says "bad cell reference"
I am giving my fortran code below:
C
C RANKINE SOURCE WAVES TRANSFERRED TO FORM KELVIN ANGLE
C (UNIT STRENGTH, UNIT VOLUME)
DIMENSION FSPANL(20,40), FSP2(30,50),
+ A(40,20),B(40,20),H(40,20),
+ AK(40,20),BK(40,20),HK(40,20)
DATA IR,DEPTH/20,20.0/
C
C
C
DO 100 I=1,20
DO 100 J=1,40
100 FSPANL(I,J)=0.0
C
C
C
DELTAR=20.0/FLOAT(IR)
DO 200 I1=1,IR
R=DELTAR*FLOAT(I1)
RK=DELTAR*FLOAT(I1)+0.5
THETA=2.0*3.141592/FLOAT(I1*4)
ITHETA=I1*4
DO 300 I2=1,ITHETA
ANGLE=THETA*FLOAT(I21)
A(I2,I1)=R*COS(ANGLE)
AK(I2,I1)=RK*COS(ANGLE)
B(I2,I1)=R*SIN(ANGLE)
BK(I2,I1)=RK*SIN(ANGLE)
300 CONTINUE
C
DO 350 I2=1,ITHETA
R3D=SQRT((A(I2,I1)A(1,I1))**2+(B(I2,I1)B(1,I1))**2+DEPTH**2)
R3DK=SQRT((AK(I2,I1)AK(1,I1))**2
+ +(BK(I2,I1)BK(1,I1))**2+DEPTH**2)
H(I2,I1)=R3D**2/(2.0*9.81*(R3D**3))
HK(I2,I1)=R3DK**2/(2.0*9.81*(R3DK**3))
350 CONTINUE
C
DO 360 I2=1,ITHETA
A(I2,I1)=A(I2,I1)+3.0*R
AK(I2,I1)=AK(I2,I1)+3.0*R
B(I2,I1)=B(I2,I1)+10.0
BK(I2,I1)=BK(I2,I1)+10.0
360 CONTINUE
C
C
C
DO 1000 I2=1,ITHETA
C
I=1
J=1
ICOUNT=1
COL=1.0
IF (A(I2,I1).GT.40.0) GO TO 910
400 IF (A(I2,I1).GT.COL) GO TO 500
J=ICOUNT
GO TO 600
500 COL=COL+1.0
ICOUNT=ICOUNT+1
GO TO 400
600 CONTINUE
C
ICOUNT=1
ROW=1.0
IF (B(I2,I1).GT.20.0) GO TO 910
IF (B(I2,I1).LT.0.0) GO TO 910
700 IF (B(I2,I1).GT.ROW) GO TO 800
I=ICOUNT
GO TO 900
800 ROW=ROW+1.0
ICOUNT=ICOUNT+1
GO TO 700
C
910 H(I2,I1)=0.0
900 FSPANL(I,J)=FSPANL(I,J)+H(I2,I1)
C
I=1
J=1
ICOUNT=1
COL=1.0
IF (AK(I2,I1).GT.40.0) GO TO 915
405 IF (AK(I2,I1).GT.COL) GO TO 505
J=ICOUNT
GO TO 605
505 COL=COL+1.0
ICOUNT=ICOUNT+1
GO TO 405
605 CONTINUE
C
ICOUNT=1
ROW=1.0
IF (BK(I2,I1).GT.20.0) GO TO 915
IF (BK(I2,I1).LT.0.0) GO TO 915
705 IF (BK(I2,I1).GT.ROW) GO TO 805
I=ICOUNT
GO TO 905
805 ROW=ROW+1.0
ICOUNT=ICOUNT+1
GO TO 705
C
915 HK(I2,I1)=0.0
905 FSPANL(I,J)=FSPANL(I,J)+HK(I2,I1)
C
1000 CONTINUE
200 CONTINUE
C
C
C
DO 3000 I=1,30
DO 3000 J=1,50
3000 FSP2(I,J)=0.0
C
DO 4000 I=1,20
DO 4000 J=1,40
IP5=I+5
JP10=J+10
4000 FSP2(IP5,JP10)=FSPANL(I,J)
C
C
C
DO 1100 I=1,30
DO 1100 J=1,50
X=0.5+1.0*(J1)
Y=0.5+1.0*(I1)
Z=FSP2(I,J)
WRITE(15,5000) X,Y,Z
5000 FORMAT(1X,3F10.6)
1100 CONTINUE
C
C
STOP
END
if anybody can help me to convert this into .m file, I will appreciate his or her effort.
Thanks
Mishu
Hi,
How do I install f2matlab on Vista? I cannot get the "INSTALL" file to execute, there is no 'Run' command when I rightclick on it.
Thanks,
it would be great if I could fix the error points with a guide..
how to use it, can be given one example of step by step process of using f2matlab
I know nothing about Fortran, and had to convert some code into Matlab. The conversions that f2matlab made helped me immensely to give me a starting point. Many thanks!
Very useful package indeed. Thank you.
It's great to know this great tool is still imporved.
Hello
I have tried to convert the where statement applied to a 2D array to matlab and it seems f2matlab does not translate well.
Best Regards
Eduardo
program ed_example
integer B(10, 2)
B(1:10, 1) = 0
B(1:10, 2) = 1
where (B(:,:)>0)
B(:,:) = B(:,:) + 9
endwhere
end program
Translating:
f2matlab('ed_example.f')
ans =
b([1:10], 1) = 0;
b([1:10], 2) = 1;
fmask=(b(:,:)>0);
b(fmask,:) = b(fmask,:) + 9;
endwhere;
Running:
>> b(fmask,:) = b(fmask,:) + 9
??? Index exceeds matrix dimensions.
I tried to run the code but I keep getting the error:
??? Input argument "filename" is undefined.
Error in ==> f2matlab at 101
if exist(filename,'file')==2
I think this is because Matlab does not like when functions are defined in the script. I should define the function outside of the script in a separate .m file, but when I try to do so, I just get more errors. It's hard for to to see what I need to cut from the original program to define the function separately. Anybody with comments on this please email me.
very good
good work
The actual utility is really useful... When it works.
However, (I think due to the ambiguity between row and column vectors in Fortran) I found a lot of problems in translation, where it just ground to a halt.
In a sense that's to be expected; but there is almost no error handling to cope with that kind of situation If I could just find out which line of the source code was causing the trouble, I'd be able to comment that section out in the F90 file and manually translate those particular lines. As the f2matlab code is largely uncommented it's havoc to try and trace which lines of code cause the translation problem.
Don't get me wrong; this can be extremely useful code  and clearly a lot of effort has gone into it's development. However, it needs to be a bit more transparent to help us get over the patches where the ambiguity of Fortran lets the translation down.
Though it's not perfect (because of the ambiguity of the GOTO, READ, and WRITE functions in FORTRAN, they don't convert correctly), this converted about 1000 lines of code for me that I was then able to debug and convert to MATLAB format in about 8 hours. Not bad, considering the code was written by someone else!
This is a very useful function