[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ next ]


Fortran 90 Lessons for Computational Chemistry
Chapter 1 - Introduction


1.1 Objectives

The main aims of this session consist of:

  1. giving a short introduction on programming and programming languages.

  1. emphasize the importance of a clear understanding of the problem under study and the use of flow diagrams for achieving structured and clear source code.

  1. a brief presentation of the main features of the Fortran programming language.

  1. installation of the GNU Fortran compiler, gfortran.

  1. Studying two simple codes.

  1. Presenting possible sources of information for the interested student.


1.2 Main items.

By default we will use the emacs text editor. The first examples are the simple programs excode_1_1.f90, Section 1.3.1 y excode_1_2.f90, Section 1.3.2.

Using the examples the student should be aware of the main sections included in a program::

  1. Head of the code with the statement PROGRAM program_name.

  1. Variable definition.

  1. Main program body, including I/O operations.

  1. End of the program: END PROGRAM program_name.

Things to take into account:


1.3 Example Codes.


1.3.1 excode_1_1.f90

     PROGRAM ex_1_1
       !
       ! This program reads and displays a string.
       !
       IMPLICIT NONE
       CHARACTER(LEN=50) :: Name
       !
       PRINT *,' Write your name. Do not forget quoting it:'
       PRINT *,' (max 50 characters)'
       READ(*,*), Name
       PRINT *, Name
       !
     END PROGRAM ex_1_1

1.3.2 excode_1_2.f90

     PROGRAM ex_1_2
       !
       ! This program reads three numbers and compute their sum and mean value 
       !
       IMPLICIT NONE
       REAL :: N1, N2, N3, Average = 0.0, Total = 0.0
       INTEGER :: N = 3
       PRINT *,' Input three numbers (return, coma, or space separated).'
       PRINT *,' '
       READ *,N1,N2,N3
       Total =  N1 + N2 + N3
       Average = Total/N
       PRINT *,'Sum: ',Total
       PRINT *,'Mean value: ',Average
     END PROGRAM ex_1_2

[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ next ]


Fortran 90 Lessons for Computational Chemistry

0.0

Curro Pérez-Bernal mailto:francisco.perez@dfaie.uhu.es