- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I
This is the second of the Harrison programs that I put into IFORT.
it runs quite nicely, but there is a slight weirdness, there is a do loop - 160 - which uses I as the index at the start of the program - the second half of the program includes a loop generation with a straight goto 160 back to the 160 continue. The compiler warns that it is jumping into a block, but the code works fine and gives the correct -as far as I can tell answers. The second part of the program uses a rather interesting method to set I from 1 to 4 for the input file - rename as a.inp and prints out the results
Write(*,1010)I 1010 FORMAT(//11H MEMBER NO.,I3/) Write(*,*)' L/SET AX.TENSION MAB-Z-AX1S MBA-Z-AXIS MAB-Y-AXIS MBA-Y-AXIS TORQUE'
So as a simple first step to get rid of the goto warning I put a 161 continue after the 160 loop. Compiled but it only went through the output loop once and only put out member 1 not 2 and 3 as shown in the capture image. Going back to the loop 160 jump works. I put in some simple print statements - but they do not appear to print in the logical order I would expect. Here A and Here ISW should print each time through the loop, but they do not.
I am missing something simple - I tried several variations on loops and just lost the output all together. So I am stumped and I would prefer not to rewrite more extensively as the program is short and sweet. I will fix the arthimetic if's but not till I solve this little problem
John
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nested loops with shared CONTINUE - ugh. First, add a 161 CONTINUE, 162 CONTINUE and 163 CONTINUE after 160 and change the DO loops at lines 150, 256 and 266 to reference 163, 162 and 161 respectively.
When you have a shared CONTINUE, the CONTINUE is considered part of the innermost DO, which is why you get the warning.
Now what to do about the GOTO 160 at line 395? It looks to me as if there is an "escape" from the outer loop at line 240, and this GOTO is from an ancient "extended range of DO" feature that wants to jump back in. I am guessing that you want to change this to GOTO 163 and it should do what you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve:
Thanks - I will try it.
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
160 CONTINUE !do while(rt .eq. 0) CAll PrintGK(GK,nl,nk) 2011 format (12(1x,E12.5)) write(*,*)'hereA' write(*,*)'Here ISW ',ISW IF(ISW)164,1040,1040
Steve:
If it steps back the 160 loop (I fixed the nested loops but 160 is the last now) - it should print hereA next - it does not till I = NM , which is the end of the original loop after it has been to 160 continue theoretically 3 times
I tried a nice little do while and it went nowhere
Weird really
JOhn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Extended do loop - found it in the Intel Manual
So Steve:
It is quite difficult to unroll this code without a major rewrite - I was not aware of the extended do feature, but unless I am wrong the do loop 160 does it's three passes ISW is set to -1 so it stays inside the loop and sets up the necessary inversion matrices, control than passes to the next code and it works out the results matrix, then they set I to 1 and do the member output - there are three members, it uses the go to 160 cast to send the program back to the do loop with the index reset, but ISW is now set to 1 so it is a controlled go to at 240 to jump outside the loop again after it recalculates a needed matrix and loops 3 times till I is outside the do loop limit.
To fix it I need to encapsulate the needed code into a subroutine and then call it separately inside the 160 loop and then in the final convoluted loop.
Interesting logic - what warped soul invented this syntax?
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your posts have been spread over several threads, but I do not recall seeing a post with the original source code BEAMS.f copied from the book. If you do not have a working copy of the original code, it will be difficult to assess whether all the code modifications that you have done have not resulted in changes to the logic or other errors.
The extended DO was one way of simulating a subroutine call within a loop, as in the GOSUB statement of Basic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Beams code and input file is in the first post in this thread.
Yes I now understand the logic - it is a simple way to generate "subroutine like code" without the subroutine - in the old days of punch cards entirely understandable. My problem was I was not aware of the feature and incorrectly assumed that coming back to the 160 continue then leads to the next statement - but it leads back to the start of the loop - once I had that worked out it made weird sense.
This code is to be matched with the FEAST subroutine and so I am trying to join the codes. I do not actually need this later code, but it was puzzling - it worked but I did not know why.
The EP was quite chuffed that I showed her how to solve her problem with '73 code and FEAST - Eigenvalue solver in a few minutes, they were spending days on it.
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I saw the source in #1 and concluded that it was your modified source since I don't expect Fortran-9x source code to come from a 1970's book or for old Fortran to contain double colons in declarations. Does the book show results for some example input?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is the original sample file and the copy of the results.
The beams program is close to original - I declared the variables, added some print statements and some minor error coding so I could make sure what I had was as shown in the original book.
It gives the correct answers.
The code with the extended do loop is as exact as I could make it.
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I change any part of the 160 loop system as Steve suggests I break the code
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Copy (cut) from the statement 900 ID=0 through to the GO TO 160
Paste immediately following:
IF(ISW)105,105,900
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Excellent
Then I can place a do loop around the 54 goto loop which is really a do me twice call as all other structural programs do
Thanks to all
John
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page