Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to convert GO TO (Fortran) to Matlab

Subject: how to convert GO TO (Fortran) to Matlab

From: edward kabanyas

Date: 15 Aug, 2011 20:25:31

Message: 1 of 7

Hi all,

Again, I need your share if you have experience in converting Fortran to Matlab. I have Fortran code working with NCL graphic library. However, I am not successful to run this fortran code in my windows PC (under cygwin). It works perfectly in LINUX, but I want to work only in one PC (windows). Therefore, I plan to convert this fortran to Matlab code, but I got problem to convert GO TO in Fortran to Matlab.

 For example:

DO 250 IX=1,NX-1

      X1=XMIN+(IX-1)*DX
      X4=X1+DX
      X2=X1
      X3=X4

C IF(X1.LT.PX1.OR.X4.GT.PX2)GO TO 250

      R1=DAT(IX,IY+1)
      R4=DAT(IX+1,IY+1)
      R2=DAT(IX,IY)
      R3=DAT(IX+1,IY)

      NC=1
      IF(R1.EQ.BAD.OR.R2.EQ.BAD.OR.R3.EQ.BAD.OR.R4.EQ.BAD)
     + GO TO 250

Do you have idea how to convert GO TO in this code to Matlab ?

Thanks for help.

Edward

Subject: how to convert GO TO (Fortran) to Matlab

From: someone

Date: 15 Aug, 2011 20:53:29

Message: 2 of 7

"edward kabanyas" <djuky_hmi@yahoo.com> wrote in message <j2bvbr$l2k$1@newscl01ah.mathworks.com>...
> Hi all,
>
> Again, I need your share if you have experience in converting Fortran to Matlab. I have Fortran code working with NCL graphic library. However, I am not successful to run this fortran code in my windows PC (under cygwin). It works perfectly in LINUX, but I want to work only in one PC (windows). Therefore, I plan to convert this fortran to Matlab code, but I got problem to convert GO TO in Fortran to Matlab.
>
> For example:
>
> DO 250 IX=1,NX-1
>
> X1=XMIN+(IX-1)*DX
> X4=X1+DX
> X2=X1
> X3=X4
>
> C IF(X1.LT.PX1.OR.X4.GT.PX2)GO TO 250
>
> R1=DAT(IX,IY+1)
> R4=DAT(IX+1,IY+1)
> R2=DAT(IX,IY)
> R3=DAT(IX+1,IY)
>
> NC=1
> IF(R1.EQ.BAD.OR.R2.EQ.BAD.OR.R3.EQ.BAD.OR.R4.EQ.BAD)
> + GO TO 250
>
> Do you have idea how to convert GO TO in this code to Matlab ?
>
> Thanks for help.
>
> Edward

In general, there is no replacement for the GOTO statement.

But, in your above case, since 250 is the end of a DO loop,
you can replace "GOTO 250" with a "continue" statement.

Subject: how to convert GO TO (Fortran) to Matlab

From: TideMan

Date: 15 Aug, 2011 21:35:50

Message: 3 of 7

On Aug 16, 8:25 am, "edward kabanyas" <djuky_...@yahoo.com> wrote:
> Hi all,
>
> Again, I need your share if you have experience in converting Fortran to Matlab. I have Fortran code working with NCL graphic library. However, I am not successful to run this fortran code in my windows PC (under cygwin). It works perfectly in LINUX, but I want to work only in one PC (windows). Therefore, I plan to convert this fortran to Matlab code, but I got problem to convert GO TO in Fortran to Matlab.
>
>  For example:
>
> DO 250 IX=1,NX-1
>
>       X1=XMIN+(IX-1)*DX
>       X4=X1+DX
>       X2=X1
>       X3=X4
>
> C      IF(X1.LT.PX1.OR.X4.GT.PX2)GO TO 250
>
>       R1=DAT(IX,IY+1)
>       R4=DAT(IX+1,IY+1)
>       R2=DAT(IX,IY)
>       R3=DAT(IX+1,IY)
>
>       NC=1
>       IF(R1.EQ.BAD.OR.R2.EQ.BAD.OR.R3.EQ.BAD.OR.R4.EQ.BAD)
>      +  GO TO 250
>
> Do you have idea how to convert GO TO in this code to Matlab ?
>
> Thanks for help.
>
> Edward

If it works perfectly in Linux, why not simply recompile it in
Windows?
I use gfortran, and code that works on one works on the other.
Indeed, the make files are the same as well.
Your code is Fortran 77 or earlier, so there should be no problem.
You don't even need cygwin.

Subject: how to convert GO TO (Fortran) to Matlab

From: edward kabanyas

Date: 15 Aug, 2011 21:59:27

Message: 4 of 7

Hi Tide Man;

Thanks for your reply. My Fortran is Fortran 77. The problem is related to the NCL graphic library. Because if I remove this library from my fortran code, it works perfectly but without visualization of the result. If I compile in LINUX and run the. exe/.out file in windows, it does not work. Therefore, I need to convert to Matlab so that the calculation and visualization can be done in Matlab without NCL graphic library..

Edward

TideMan <mulgor@gmail.com> wrote in message <260a0c28-af86-4d32-9b0a-ee836205e000@t9g2000vbs.googlegroups.com>...
> On Aug 16, 8:25 am, "edward kabanyas" <djuky_...@yahoo.com> wrote:
> > Hi all,
> >
> > Again, I need your share if you have experience in converting Fortran to Matlab. I have Fortran code working with NCL graphic library. However, I am not successful to run this fortran code in my windows PC (under cygwin). It works perfectly in LINUX, but I want to work only in one PC (windows). Therefore, I plan to convert this fortran to Matlab code, but I got problem to convert GO TO in Fortran to Matlab.
> >
> >  For example:
> >
> > DO 250 IX=1,NX-1
> >
> >       X1=XMIN+(IX-1)*DX
> >       X4=X1+DX
> >       X2=X1
> >       X3=X4
> >
> > C      IF(X1.LT.PX1.OR.X4.GT.PX2)GO TO 250
> >
> >       R1=DAT(IX,IY+1)
> >       R4=DAT(IX+1,IY+1)
> >       R2=DAT(IX,IY)
> >       R3=DAT(IX+1,IY)
> >
> >       NC=1
> >       IF(R1.EQ.BAD.OR.R2.EQ.BAD.OR.R3.EQ.BAD.OR.R4.EQ.BAD)
> >      +  GO TO 250
> >
> > Do you have idea how to convert GO TO in this code to Matlab ?
> >
> > Thanks for help.
> >
> > Edward
>
> If it works perfectly in Linux, why not simply recompile it in
> Windows?
> I use gfortran, and code that works on one works on the other.
> Indeed, the make files are the same as well.
> Your code is Fortran 77 or earlier, so there should be no problem.
> You don't even need cygwin.

Subject: how to convert GO TO (Fortran) to Matlab

From: dpb

Date: 15 Aug, 2011 23:29:50

Message: 5 of 7

On 8/15/2011 4:59 PM, edward kabanyas wrote:
...
...[top posting repaired--don't do that; hard conversation follow makes]...

>
> TideMan <mulgor@gmail.com> wrote in message
> <260a0c28-af86-4d32-9b0a-ee836205e000@t9g2000vbs.googlegroups.com>...
...
>> If it works perfectly in Linux, why not simply recompile it in
>> Windows?
>> I use gfortran, and code that works on one works on the other.
>> Indeed, the make files are the same as well.
>> Your code is Fortran 77 or earlier, so there should be no problem.
>> You don't even need cygwin.

 > Thanks for your reply. My Fortran is Fortran 77. The problem is related
 > to the NCL graphic library. Because if I remove this library from my
 > fortran code, it works perfectly but without visualization of the
 > result. If I compile in LINUX and run the. exe/.out file in windows, it
 > does not work. Therefore, I need to convert to Matlab so that the
 > calculation and visualization can be done in Matlab without NCL graphic
 > library..
...

Of course an .exe compiled under Linux won't run under Windows; compile
the same source under Windows; gfortran supports both.

Or, of course, it's not as pretty a solution but you could run the data
generation on the Linux machine and simply transport the data to the
Windows Matlab box...

--

Subject: how to convert GO TO (Fortran) to Matlab

From: benbarrowes

Date: 16 Aug, 2011 02:10:41

Message: 6 of 7

On Aug 15, 4:25 pm, "edward kabanyas" <djuky_...@yahoo.com> wrote:
> Hi all,
>
> Again, I need your share if you have experience in converting Fortran to Matlab. I have Fortran code working with NCL graphic library. However, I am not successful to run this fortran code in my windows PC (under cygwin). It works perfectly in LINUX, but I want to work only in one PC (windows). Therefore, I plan to convert this fortran to Matlab code, but I got problem to convert GO TO in Fortran to Matlab.
>
>  For example:
>
> DO 250 IX=1,NX-1
>
>       X1=XMIN+(IX-1)*DX
>       X4=X1+DX
>       X2=X1
>       X3=X4
>
> C      IF(X1.LT.PX1.OR.X4.GT.PX2)GO TO 250
>
>       R1=DAT(IX,IY+1)
>       R4=DAT(IX+1,IY+1)
>       R2=DAT(IX,IY)
>       R3=DAT(IX+1,IY)
>
>       NC=1
>       IF(R1.EQ.BAD.OR.R2.EQ.BAD.OR.R3.EQ.BAD.OR.R4.EQ.BAD)
>      +  GO TO 250
>
> Do you have idea how to convert GO TO in this code to Matlab ?
>
> Thanks for help.
>
> Edward

You can get rid of about 60-80% of fortran goto's with automatic
restructuring programs. There is a good free one for linux or windows,
spag from polyhedron:
http://www.polyhedron.com/pflinux0html

I wrote a program that I use in my fortran/matlab conversion
consulting (in concert with my f2matlab) to remove all the remaining
goto's from fortran code. I will release that at some point via the
file exchange or similar (still testing). But in the meantime, if spag
doesn't remove enough goto's, PM me and I'll see what I can do.

Good luck,
bb

Subject: how to convert GO TO (Fortran) to Matlab

From: Sebastian Rooks

Date: 18 Aug, 2011 02:41:30

Message: 7 of 7

On Mon, 15 Aug 2011 21:59:27 +0000 (UTC), "edward kabanyas"
<djuky_hmi@yahoo.com> wrote:

>Hi Tide Man;
>
>Thanks for your reply. My Fortran is Fortran 77.
>The problem is related to the NCL graphic library. Because if I remove this library from my fortran code,
>it works perfectly but without visualization of the result. If I compile in LINUX and run the. exe/.out file
>in windows, it does not work.

If you compile it in linux and run the exe/out file in windows?!

This is certanly a typo, but you need to compile it in windows to run
it under windows (exceptions exist, but lets leave them for now).


>Therefore, I need to convert to Matlab so that the calculation and
>visualization can be done in Matlab without NCL graphic library..

Or you can get a different graphics library ...

what kind of plotting were you doing?

Sebastian

>
>Edward
>

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us