12.07.2015 Views

CAD in Civil Engineering - Baustatik-Info-Server

CAD in Civil Engineering - Baustatik-Info-Server

CAD in Civil Engineering - Baustatik-Info-Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Page 24 Computer Languages for Eng<strong>in</strong>eer<strong>in</strong>g - SS 132.5.5 Declaration of Variables and Constants <strong>in</strong> FORTRAN 90The declaration of variables <strong>in</strong> FORTRAN 90 is slightly different from the FORTRAN 77 format and isgiven by the follow<strong>in</strong>g statement.Data Type :: List of VariablesIn the follow<strong>in</strong>g example the three <strong>in</strong>teger variables month, day and year are declared. In the secondl<strong>in</strong>e the real variable seconds is declared. The character variables which should store some str<strong>in</strong>gsshould be declared with a properly length. The first declaration shows the declaration with an explicitlength parameter, the second declaration uses only the value of the length.List<strong>in</strong>g 2.8: Declaration <strong>in</strong> 90++1 INTEGER :: day, month, year2 REAL :: seconds3 CHARACTER(len = 10) :: prename4 CHARACTER(20) :: famnameIn the follow<strong>in</strong>g example you can see how to <strong>in</strong>itialize the just declared variables. This is like declarationand <strong>in</strong>itialization <strong>in</strong> the language C simply with<strong>in</strong> one step. So the obsolete statement DATA is no longerneeded and can be canceled from modern FOTRAN 90 sources (see also section 2.5.4).List<strong>in</strong>g 2.9: Declaration and Initialization <strong>in</strong> 90++1 INTEGER :: day = 16, month = 10 , year = 20102 REAL :: seconds = 10.53 CHARACTER(len = 10) :: prename = ’Ernst’4 CHARACTER(20) :: famname = ’Baeck’The follow<strong>in</strong>g example shows, how to declare parameters (constants). You see the code is very simularcompared with the previous code. Only the attribut PARAMETER was added. With<strong>in</strong> the first code thecontent of the variables can be changed by an assignment. With<strong>in</strong> the second code, we have declaredparameters and the content of this parameters can not be changed, because a parameter is fixed. So yousee, that the FORTRAN 77 statement PARAMETER, now obsolete, is also no longer necessary and canbe deleted from modern FORTRAN 90 code (see also section 2.5.4).List<strong>in</strong>g 2.10: Declaration and Parameters <strong>in</strong> 90++1 INTEGER, PARAMETER :: day = 16, month = 10 , year = 20102 REAL, PARAMETER :: seconds = 10.53 CHARACTER(len = 10), PARAMETER :: prename = ’Ernst’4 CHARACTER(20), PARAMETER :: famname = ’Baeck’2.6 OperatorsFortran offers a set of operators, which are offered from the most computer languages. Fortran usesthe same precedence as we know form the mathematics. The power operation has the strongest b<strong>in</strong>d<strong>in</strong>gfollowed by the po<strong>in</strong>t operators (products and divisions) followed by the l<strong>in</strong>e operators (plus and m<strong>in</strong>us).Unary operators will always be applied first. To change the standard precedence of the operators we uselike <strong>in</strong> mathematics parenthesis to dictate the way a formula should be evaluated.E. Baeck

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!