16. Listing of the FORTRAN Data Retrieval Programs

This section lists the five FORTRAN data retrieval programs provided by CDIAC with this data base. Each program is designed to read and write the contents of one of the five flat ASCII data files.

The first program (WCGRID.FOR, File 2) is designed to read and print the file WCGRID.ASC (File 5).


c*********************************************************
c* fortran program to read and write wcgrid.asc (file 5) *
c*********************************************************
integer nlin
integer id, elnum, gl, gm, slyr, ernum, trnum
real elavg, elmax, elmin, slr, slg, slc, sls
real eravg, ermax, ermin, travg, trmax, trlvl
real whavg, whmax, whsd
c*********************************************************
c* initialize a counter and open files for input/output *
c*********************************************************
nlin=0
open(unit=5,file='wcgrid.asc',readonly,status='old')
open(unit=6,file='wcgrid.out',status='new')
c*********************************************************
c* read/write the grid cell id and the 22 data variables *
c*********************************************************
10 read(5,100,end=999) id, elavg, elmax, elmin, elnum,
1 gl, gm, slr, slg, slc, sls, slyr
read(5,110) eravg, ermax, ermin, ernum, travg,
1 trmax, trlvl, trnum, whavg, whmax, whsd
if (nlin.gt.32) nlin=0
if (nlin.eq.0) write (6,120)
if (nlin.eq.0) write (6,130)
nlin=nlin+1
write(6,105) id, elavg, elmax, elmin, elnum,
1 gl, gm, slr, slg, slc, sls, slyr
write(6,115) eravg, ermax, ermin, ernum, travg,
1 trmax, trlvl, trnum, whavg, whmax, whsd
20 continue
go to 10
100 format (i5,3f8.2,3i4,4f8.2,i4)
105 format (1x,i5,3f8.2,3i4,4f8.2,i4)
110 format (3f8.2,i4,3f8.2,i4,3f8.2)
115 format (1x,3f8.2,i4,3f8.2,i4,3f8.2)
120 format (4x,'id',1x,'elavg',3x,'elmax',3x,'elmin',1x,
1 'elnum',2x,'gl',2x,'gm',1x,'slr',5x,'slg',5x,'slc',
1 5x,'sls',4x,'slyr')
130 format (2x,'eravg',3x,'ermax',3x,'ermin',1x,'ernum',
1 1x,'travg',3x,'trmax',3x,'trlvl',1x,'trnum',1x,
1 'whavg',3x,'whmax',3x,'whsd')
c***********************************************************
c***** close files and exit ******
c***********************************************************
999 close(unit=5)
close(unit=6)
stop
end

The second FORTRAN program (WCRISK.FOR, File 6) is designed to read and print the file WCRISK.ASC (File 9).

c*********************************************************
c* fortran program to read and write wcrisk.asc (file 9) *
c*********************************************************
integer nlin
integer id, elr, glr, gmr, lsr, err, trr, whr
c*********************************************************
c* initialize a counter and open files for input/output *
c*********************************************************
nlin=0
open(unit=5,file='wcrisk.asc',readonly,status='old')
open(unit=6,file='wcrisk.out',status='new')
c*********************************************************
c* read/write the grid cell id and the 7 risk variables *
c*********************************************************
10 read(5,100,end=999) id, elr, glr, gmr, lsr,
1 err, trr, whr
if (nlin.gt.63) nlin=0
if (nlin.eq.0) write (6,110)
nlin=nlin+1
write(6,105) id, elr, glr, gmr, lsr,
1 err, trr, whr
20 continue
go to 10
100 format (i5,7i4)
105 format (1x,i5,7i4)
110 format (4x,'id',1x,'elr',1x,'glr',1x,'gmr',1x,
1 'lsr',1x,'err',1x,'trr',1x,'whr')
c***********************************************************
c***** close files and exit ******
c***********************************************************
999 close(unit=5)
close(unit=6)
stop
end

The third FORTRAN program (WCLINE.FOR, File 10) is designed to read and print the file WCLINE.ASC (File 13).

c**********************************************************
c* fortran program to read and write wcline.asc (file 13) *
c**********************************************************
integer nlin
integer id, elnum, gl, gm, slyr, ernum, trnum
integer elr, glr, gmr, lsr, err, trr, whr
real elavg, elmax, elmin, slr, slg, slc, sls
real eravg, ermax, ermin, travg, trmax, trlvl
real whavg, whmax, whsd
c*********************************************************
c* initialize a counter and open files for input/output *
c*********************************************************
nlin=0
open(unit=5,file='wcline.asc',readonly,status='old')
open(unit=6,file='wcline.out',status='new')
c************************************************************
c* read/write the line segment id and the 29 data variables *
c* including the 22 original and 7 risk data variables *
c************************************************************
10 read(5,100,end=999) id, elavg, elmax, elmin, elnum,
1 elr, gl, glr, gm, gmr, slr, slg, slc
read(5,110) sls, slyr, lsr, eravg, ermax, ermin,
1 elnum, err, travg, trmax, trlvl, trnum, trr
read(5,120) whavg, whmax, whsd, whr
if (nlin.gt.32) nlin=0
if (nlin.eq.0) write (6,130)
if (nlin.eq.0) write (6,140)
if (nlin.eq.0) write (6,150)
nlin=nlin+1
write(6,105) id, elavg, elmax, elmin, elnum,
1 elr, gl, glr, gm, gmr, slr, slg, slc
write(6,115) sls, slyr, lsr, eravg, ermax, ermin,
1 ernum, err, travg, trmax, trlvl, trnum, trr
write(6,125) whavg, whmax, whsd, whr
20 continue
go to 10
100 format (i4,3f8.2,6i4,3f8.2)
105 format (i4,3f8.2,6i4,3f8.2)
110 format (f8.2,2i4,3f8.2,2i4,3f8.2,2i4)
115 format (f8.2,2i4,3f8.2,2i4,3f8.2,2i4)
120 format (3f8.2,i4)
125 format (3f8.2,i4)
130 format (2x,'id',2x,'elavg',2x,'elmax',2x,'elmin',
1 1x,'elnum',2x,'elr',2x,'gl',2x,'glr',1x,'gm',
1 2x,'gmr',4x'slr',5x,'slg',5x,'slc')
140 format (3x,'sls',2x,'slyr',1x,'slr',3x,'eravg',2x,'ermax',
1 2x,'ermin,1x,'ernum',1x,'err',3x,'travg',
1 2x,'trmax',2x,'trlvl',1x,'trnum',1x,'trr')
150 format ('whavg',3x,'whmax',3x,'whsd',5x,'whr')
c***********************************************************
c***** close files and exit ******
c***********************************************************
999 close(unit=5)
close(unit=6)
stop
end

The fourth FORTRAN program (WCPOINT.FOR, file 14) is designed to read and print the file WCPOINT.ASC (File 17).

c***********************************************************
c* fortran program to read and write wcpoint.asc (file 17) *
c***********************************************************
integer nlin
integer id, slyr, trid
real sllong, sllat, slr, slg, slc, sls
real trlong, trlat, travg, trmax, trlvl
character slname*40, trname*45
c***********************************************************
c* initialize a counter and open files for input/output *
c***********************************************************
nlin=0
open(unit=5,file='wcpoint.asc',readonly,status='old')
open(unit=6,file='wcpoint.out',status='new')
c***********************************************************
c* read/write the point id and the 15 station variables *
c***********************************************************
10 read (5,100,end=999) id, sllong, sllat, slr, slg,
1 slc, sls, slyr
read(5,110) slname, trlong, trlat, travg,
1 trmax, trlvl,
read(5,120) trid, trname
if (nlin.gt.32) nlin=0
if (nlin.eq.0) write (6,130)
if (nlin.eq.0) write (6,140)
if (nline.eq.0) write (6,150)
nlin=nlin+1
write(6,105) id, sllong, sllat, slr, slg,
1 slc, sls, slyr
write(6,115) slname, trlong, trlat, travg,
1 trmax, trlvl,
write(5,125) trid, trname
20 continue
go to 10
100 format (i5,6f8.2,i4)
105 format (i5,6f8.2,i4)
110 format (a40,5f8.2)
115 format (a40,5f8.2)
120 format (i4,a50)
125 format (i4,a50)
130 format (4x,'id',2x,'sllong',3x,'sllat',5x,'slr',
1 5x,'slg',5x,'slc',5x,'sls',1x,'slyr',1x,'slname')
140 format (3x,'trlong',3x,'trlat',3x,'travg',3x,'trmax',
1 3x,'trlvl',1x,'trid',1x,'trname')
150 format ('trid',1x,'trname')
c***********************************************************
c***** close files and exit ******
c***********************************************************
999 close(unit=5)
close(unit=6)
stop
end

The last FORTRAN program (WCOAST.FOR, File 18) is designed to read and print the file WCOAST.ASC (File 21).

c**********************************************************
c* fortran program to read and write wcoast.asc (file 21) *
c**********************************************************
character id*6, name*7
character comma
integer i, num, nlin
real long, lat
c*********************************************************
c* open files for input/output *
c*********************************************************
open(unit=5,file='wcoast.asc',readonly,status='old')
open(unit=6,file='wcoast.out',status='new')
c*********************************************************
c* read/write the line segment id and x,y coordinates *
c*********************************************************
10 nlin=0
read(5,100,end=999) id,comma,num
if (comma.eq.'-') num=num*-1
if (comma.eq.',') then
name=id//','
else
name=id//' '
end if
write(6,130)
write(6,110) name, num
c********************************************************
c* read and print x,y coordinates for the line *
c********************************************************
do 20 i = 1, num*-1
if (nlin.gt.77) nlin=0
if (nlin.eq.0) write (6,140)
nlin=nlin+1
read (5,120) long,comma,lat
write (6,125) long,comma,lat
20 continue
go to 10
100 format (a6,a1,i6)
110 format (a7,i6)
120 format (f9.4,a1,f8.4)
130 format (1x,'name , number')
140 format (1x,'longitude,latitude')
c***********************************************************
c***** close files and exit ******
c***********************************************************
999 close(unit=5)
close(unit=6)
stop
end