












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













Often in Meteorology and Climate Science we need to:
data.
Three types of arrays are used extensively in MCS:
Example:
latitude in a1-D array (180 values!)
Example:
With the 4 th^ dimension being time?
We do this via the
DIMENSION
statement.
Example:
REAL, DIMENSION(180) :: CORIOLIS
Says:
Another example:
Says:
Appearance inside code ???
Given:
REAL, DIMENSION (100) :: TIME
We might have:
OPEN (18, FILE=‘TIMES.DAT’, STATUS=‘OLD’) DO K = 1, 100 READ (18, 80) TIME(K)! Reads in 100 values of TIME ENDDO! Assigns each to an array location 80 FORMAT (1X, F10.4) PRINT*, TIME(1), TIME(100)! Print start and end times
Another example:
SUM = 0. AVG = 0. DO J = 1, 100 SUM = SUM + TIME(J)! Adds together values from the ENDDO! Array TIME inside the DO loop AVG = SUM / (100.) PRINT*, SUM, AVG
Suppose we wish to add two arrays, each with temperatures measurements recorded every minute: TEMP_AUG01 and TEMP_AUG02.
Fortran
REAL, DIMENSION(1440) :: TEMP_AUG01, TEMP_AUG REAL, DIMENSION(1440) :: SUM SUM = TEMP_AUG01 + TEMP_AUG
This statement is legal as long as each array is of dimension (1440)
Fortran77 version…
REAL TEMP_AUG01 (1440), TEMP_AUG02(1440) REAL SUM(1440)
DO 10 JJ=1, SUM(JJ) = TEMP_AUG01(JJ) + TEMP_AUG02(JJ) 10 CONTINUE
II) For an array with unchanging values (such as Coriolis values), we can set values as follows:
Example: latitudes every 30 degrees from pole-to-pole
INTEGER, DIMENSION(7) :: LAT
LAT = (/ -90, -60, -30, 0, 30, 60, 90 /) ← note format using ‘/’ or: LAT(1) = - DO JJ = 2, 7 LAT(JJ) = LAT(JJ-1) + 30 END DO
III) We can access a subset of an array as follows:
REAL, DIMENSION(100) :: ARRTST
REAL, DIMENSION(11) :: BSUB
BSUB = ARRTST(50:60:1)
BSUB = ARRTST(50:60) is enough to do this!