1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
PROGRAM BUFR_SPLIT_TABLES
C
C**** *BUFR_SPLIT_TABLES*
C
C
C PURPOSE.
C --------
C
C Splits bufr source text bufr tables into
C standard wmo table and local table
C
C
C** INTERFACE.
C ----------
C
C NONE.
C
C METHOD.
C -------
C
C NONE.
C
C
C EXTERNALS.
C ----------
C
C CALL BUFREX
C
C REFERENCE.
C ----------
C
C NONE.
C
C AUTHOR.
C -------
C
C M. DRAGOSAVAC *ECMWF* 15/07/97.
C
C
C MODIFICATIONS.
C --------------
C
C NONE.
C
C
IMPLICIT LOGICAL(L,O,G), CHARACTER*8(C,H,Y)
C
CHARACTER*256 CF1,CF2,CF3,carg(4)
character*120 record
c
C
C ------------------------------------------------------------------
C* 1. INITIALIZE CONSTANTS AND VARIABLES.
C -----------------------------------
100 CONTINUE
C
C Input file name
C
C Get input and output file name.
C
narg=IARGC()
c
IF(narg.NE.2) THEN
print*,'Usage -- bufr_split_tables -i infile '
stop
END IF
c
do 101 j=1,narg
call getarg(j,carg(j))
101 continue
c
if(carg(1).ne.'-i'.and.carg(1).ne.'-I'.or.
1 carg(2).eq.' ') then
print*,'Usage -- bufr_split_tables -i inpfile '
stop
end if
c
cf1=carg(2)
ii=index(cf1,' ')
if(ii.gt.1) ii=ii-1
cf2='L'//cf1(2:ii)
cf3=cf1(1:II-6)//'00.TXT'
C
C* 1.2 OPEN FILE CONTAINING BUFR DATA.
C -------------------------------
120 CONTINUE
C
iunit1=23
iunit2=24
iunit3=25
open(iunit1,file=cf1(1:ii),status='old',
1 recl=120,form='formatted')
open(iunit2,file=cf2(1:ii),status='unknown',
1 recl=120,form='formatted')
open(iunit3,file=cf3(1:ii),status='unknown',
1 recl=120,form='formatted')
C
C -----------------------------------------------------------------
C* 3. READ BUFR TABLE
C ------------------
300 CONTINUE
C
read(iunit1,'(a)',end=400) record
read(record(5:7),'(i3)') ix
c
if(cf1(1:1).eq.'B') then
if(ix.ge.193) then
write(iunit2,'(a)') record
else
write(iunit3,'(a)') record
end if
elseif(cf1(1:1).eq.'D') then
if(ix.ge.193) then
read(record(8:10),'(i3)') iloop
write(iunit2,'(a)') record
do i=1,iloop-1
read(iunit1,'(a)',end=400) record
write(iunit2,'(a)') record
end do
else
read(record(8:10),'(i3)') iloop
write(iunit3,'(a)') record
do i=1,iloop-1
read(iunit1,'(a)',end=400) record
write(iunit3,'(a)') record
end do
end if
else
print*,'The table has not been split'
go to 400
end if
C
go to 300
C
C -----------------------------------------------------------------
C* 4. Close files
C --------------------
400 CONTINUE
C
close(iunit1)
close(iunit2)
close(iunit3)
C -----------------------------------------------------------------
C
C
C
END
|