Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Do While Sample Code

JohnNichols
Valued Contributor III
8,643 Views

 

    input = ' '
    DO WHILE ((input .NE. 'n') .AND. (input .NE. 'y'))
        WRITE (*, 110)
110     Format('Enter y or n: ',\)
        READ (*, '(A)') input
    END DO

 

Dear Barbara:

The Intel sample do while code has the read input on the next line, it looks old fashioned and kludgy.  

Is kludgy a word, it passes spell check so it must be, the computer never lies.  

I made it so it teaches the lesson of leaving the cursor with the question, we can teach multiple things in one lesson?

--------------------------------------------------------------------------------------------------------

Student ::   I want to take a day off class - can I get an excused absence for XYZ?

Me:  Not usually excused.

Student :: Please sir?

Me:  Bring me a note from your mother to say it is necessary and she agrees? 

A letter arrives from law firm, Dear Professor Nichols, I have not had the pleasure of writing my son a note since the fifth grade, yes he needs to be there and thank you for brightening my day.... 

etc  etc  etc  

I did not say to the student, there are 260 in the class and I do not take roll, some things like general intelligence you cannot teach. 

Some times we even see that here. 

 

0 Kudos
7 Replies
Barbara_P_Intel
Employee
8,575 Views

Thanks, John. I'll make the suggestion.

This might be even a little cleaner:

 

    input = ' '
     DO WHILE ((input .NE. 'n') .AND. (input .NE. 'y'))
        WRITE (*, '(A,\)') 'Enter y or n: '
        READ (*, '(A)') input
    END DO

 

 

0 Kudos
JohnNichols
Valued Contributor III
8,562 Views

I tried something like that first - but it kept throwing an error, I am not a fan of inline format.  

Just getting old...........................................................

0 Kudos
andrew_4619
Honored Contributor III
8,545 Views

I think if you ask 3 fortraners you will get 3 different opinions.  I hate format statements, and for that matter numbered lines, I never use them or have a need.  The inline format is best IMO because you can see it in-place without hunting and it doesn't disrupt the indentation scheme when scan reading down the code. If the format is used more than once then I often use a parameter) as below at least you know where the definition is going to be rather than a randomly placed format and it can have a name which beats some number any day.

character(*), parameter :: ftmblob='(f0.3,1x,f12.4)'
write(*,fmtblob) bloba,blobb

 

Another pet hate is .EQ. ,  .NE. , .LT., and .GT.  I find ==, /=, < and > both shorter to type  and less stone age looking.....

 

0 Kudos
JohnNichols
Valued Contributor III
8,526 Views

 

        if(IA .eq. 1) then
            write (sdd,335)NCYC
335         format(11x,'                  Execute the :: Stiffness Subroutine Cycle Number :: ', I5)
        END IF

 

Old fashioned, but as you said three opinions, all of them almost correct.  

Who was that talked about syntactic sugar, I forget his name and am too lazy to use google,  but it caused some heat. 

I am amazed at the patience of these folk, and thankful.  One message board was closed because the owner did not like my posts. My friend said quietly, leave it be. She is also a patient kind human. 

As a written language LISP is much cleaner and neater to understand.  

Language, 

You see you is actually plural and thee is the correct singular, but we all use you because the POSH people did in the 15th century and we want to keep up with Queen Elizabeth and her ilk, the first Elizabeth, I mean.  She who had a propensity for head lopping, as a real queen should do.  

I am also told by true grammarians I should not use ilk in that fashion, but it is a great word. 

I agree on the ==, but old habits at typing speed die hard.  

I knew I could get Bruce Willis into this message.  

 

  • Grog: pure Id, a caveman's caveman; a primitive, semi-evolved wild man with enough strength to knock the sun out of the sky using a golfball. His vocabulary was very limited until a January 1977 strip in which, to Peter's shock, he actually spoke full sentences.

And last but not least - my favourite human being, grog.  

One more 

 

One of the comic's early out-of-context jokes, from June 22, 1967, was this one:

Peter: "I used to think the Sun revolved around the Earth." B.C.: "What does it revolve around?" Peter: "The United States!"

0 Kudos
andrew_4619
Honored Contributor III
8,516 Views

Well not to be fully out randomed, I today noted an ancient error message in my code that should never happen "'Point database error, +++out of cheese+++'" though that is probably wrong is should say "Out of Cheese Error. Redo From Start"

 

 

 

0 Kudos
JohnNichols
Valued Contributor III
8,474 Views
include 'mkl_vsl.f90'
include "errcheck.inc"

!     ******************************************************************
!
PROGRAM ULARC
!
!     ******************************************************************
!
!     SAMPLE ELASTO-PLASTIC ANALYSIS OF PLANE FRAMES
!
!     PROGRAMMED BY A. SUDHAKAR, G. H. POWELL, G. ORR, R. WHEATON
!		    UNIVERSITY OF CALIFORNIA, BERKELEY, CALIFORNIA
!		    1972
!
!     ******************************************************************
!

use Base
use Scotia
Implicit None
character*60 ZFILE1,ZFILE2

Irrespective of the age of the content, Fortran will allow one to do spectacular things in numerical analysis.  I can feel confident in assuming that the rocket going to the metal meteor has Fortran coding to speed it on its way.  

Where else can you take a 1972 program written by a graduate student to do Monte Carlo analysis of structural reliability problems on bridges built in 1948. 

So the random humour, overlies a serious purpose, but even the Pros from Dover get to play golf from time to time.  

Or as Heinlein once said " Anyone who cannot cope with mathematics  etc.. etc.." and either you have read Time Enough for Love or you have not, you have to be in one of those camps.  

Or as I tell my daughter when she struggles with math, we all hit the math wall sooner or later, whether it is 1+ 1 = 2 or Fermat's Last Theorem, I know it is solved, but he cannot be considered to be normal on any scale.   

When I hit a wall I know there is this site, Kaplan and Lewis, Conte and de Boore and the World Wide Web. 

Jim:

How would you write a math routine to determine the rate of corrosion of steel bar buried in concrete subject to cracking and road salt applied 2000 times over 20 years, if you know the permeability of the stone in the aggregate and the average rainfall. 

John

In Fortran. 

0 Kudos
jimdempseyatthecove
Honored Contributor III
8,455 Views

>>How would you write a math routine to determine the rate of corrosion of steel bar buried in concrete subject to cracking and road salt applied 2000 times over 20 years, if you know the permeability of the stone in the aggregate and the average rainfall. 

 

John, not my area of expertise.

Your problem statement has too few of "givens" to make any reasonable guess. I presume "permeability" refers to clean water, as opposed to salt water at (???) concentration. You would also be missing a factor of rate of corrosion of steel (re)bar buried in concrete. Uncertain of the effect of calcium carbonate has on steel. You would also need to know how long, the surface was wet verses dry, and possibly the temperature as this may affect both the permeability and corrosion rate. Traffic patterns may also apply, and freeze/thaw cycles, as over 20 years, fractures are likely to occur.

 

A few years ago, I did some optimization work for SANRAL (South African National Roads Agency), that simulated roadway degradation. This didn't include salt (no winters to speak of ), but there were many factors (up to 20-some layers, composition of each layer, thicknesses, traffic of mixed weights, axles, footprint, temperatures through the day, ...) to name a few.

 

Jim Dempsey

0 Kudos
Reply