
Fortran Programming Guide for Atmospheric Science Students
Explore the fundamentals of Fortran programming tailored for first-year students in the Atmospheric Science Department. Learn about variable naming, data types, arithmetic operations, mathematical functions, trigonometric functions, input/output codes, and more. Enhance your knowledge with examples and exercises.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Computer Programs Computer Programs 1 1st stYear Year Atmospheric Science Dept. Atmospheric Science Dept. Fortran f95 code Fortran f95 code Lec Lec. Omar L. Khalid . Omar L. Khalid
Fortran Interface Components Title bar Menu bar : file view build variables naming Conditions Variable name must begin with a letter Variable name can t include a space, the program use the underscore (F95 , F_95). Variable name should not overtake 30 characters .
Data types Integer : ( -1 , 0 , 1 ) Real : (1.4 , -1.4 , 1.4e2 . 1.4e-2) Complex : (real numbers ) and (imaginary part ) == Z = X + Yi, for example : Complex ( 2.0 , -1.0 ) === 2.0 1.0i Logical : (. true . and . false .) Characters : ( signalquotes , doublequotes ) Note (c , j , k , l , m , n ) are integers and the rest are real ( ! ) this symbol is use to add a note on the program steps ( & ) this symbol is use to continue the line , for example : Cos ( alpha ) = b*b c*c - & 2*b*c*cos(gama)
Arithmetic operation in Fortran Example Result Symbol 23 Raise to power ** 2 x 3 Multiply * 2 / 3 Divide / 2 + 3 Addition + 2 - 3 Subtraction -
Priorities of Math Operations in Fortran Arches powers (from right to left) Multiplication and division Addition and subtraction Homework ( 4 + 82) / 2 (22)3 3x(1+2) 3x2+1 Input and Output Codes Input : read* Output : print*, write (*,*) Homework (x+y)/(x+2) xyz xy2 (x3 + y3) sin x cos y
Mathematical functions Exponential Functions Exponential Functions Example F. in F95 Operation ex Exp(x) Exponential function log(x) log(x) Natural logarithmic function Sqrt(x) Square rote function x IxI Abs(x) Absolute function
Trigonometric Functions Fortran forms Fortran forms sin(x) cos(x) tan(x) atan(x) sinh(x) cosh(x) Type of argument Type of argument Type of result Type of result real real real real real real real real real real real real
Routing & Remainder functions floor : Round toward negative infinity ( - ) : floor ( -3.4) = -4 , floor ( 3.4 ) = 3 int : Converts any number to an integer : int(0.3)=0 , int(-0.3)=0 , int(3.9)=3 nint : Round to nearest integer : nint(5.9)=6 , nint(-5.9)=-6 real : Convert number to real : real(-1.5)=-1.5000 , real(8)=8.000 mod : Modulus after division : mod(a,b) = a-int(a/b)*b :: mod(4,2)=0 , mod(9,4)=1 modulo : Remainder after division : modulo(a,b)== a- floor(a/b)*b :: modulo(8,10)=8 , modulo(-1,20)=-1 homework : Mod(6,10) , int(4.3) , floor(5.4) , nint(6.9) , modulo(8,10) , real(2.4) , nint(-3.4) floor(5.5) , nint(9.6) , modulo(8,10) , real(9/9) , nint(-3.5) Mod(5,8) , int(6.8) ,
Next week Next week Flowchart Pseudocode