Re: ezread & rdhst

CCM Processor (ccmproc2@neit.cgd.ucar.edu)
Sun, 20 Aug 1995 12:50:40 -0600 (MDT)


From: ccmproc2@neit.cgd.ucar.edu (CCM Processor)
Message-Id: <199508201850.MAA11167@sol.cgd.ucar.EDU>
Subject: Re: ezread & rdhst
To: lhartten@al.noaa.gov (Leslie Hartten)
Date: Sun, 20 Aug 1995 12:50:40 -0600 (MDT)
In-Reply-To: <9508182308.AA28216@papeeha.al.noaa.gov> from "Leslie Hartten" at Aug 18, 95 05:08:47 pm

Leslie Hartten asks....
> rdhst is more general, so I'll take my examples from it. There are the
>following statements early on:
>
> COMMON /HEADER/ IH(37),IFS(3,100), ! Integer header
> 1 CH(89),CFS(2,100), ! Character header
> 2 RH(2000) ! Real header
>C
> CHARACTER*8 CH, CFS
>
>Then later, use is made of CFS(1,I), IFS(1,NUM), IFS(2,NUM), & IFS(3,NUM).
>However, there are never any assignments to CFS or IFS, nor is there an
>EQUIVALENCE statement! From later portions of the code coupled with the
>header output, I've found that the following works for CFS:
>
> DO 30 I=1,IH(16)
> INDEX=IH(37)+2*(I-1)+0
> CFS(1,I) = CH(INDEX)
> 30 CONTINUE
>
>However, I do not see how to assign values to IFS. Anyone out there worked
>through this already?

The read statements in the code which you are asking about is:

C Read the integer, character and real headers (these are never packed).

read(11,iostat=io,end=96,err=97) ih(1),(ih(k),k=2,ih( 1))
read(11,iostat=io,end=96,err=97) (ch(k),k=1,ih(31))
read(11,iostat=io,end=96,err=97) (rh(k),k=1,ih(32))

One can write an equivalent integer header read statement to explicitly
show the IFS assignment:

read(11,iostat=io,end=96,err=97) (ih(k),k=1,37),
$ ((ifs(j,k),j=1,3),k=1,(ih(1)-37)/3)

The key to how the first integer read statement works is the concept
that data held in a common block are always concurrent in memory.

Therefore the common block HEADER looks like a big vector:

IH(1),IH(2),....IH(37),ifs(1,1),ifs(2,1),ifs(3,1),ifs(1,2),ifs(2,2),
ifs(3,2),ifs(1,3).....ifs(2,100),ifs(3,100),CH(1),CH(2),CH(3),...,CH(88),
CH(89),cfs(1,1),cfs(2,1),cfs(2,1),cfs(2,2),cfs(1,3)....cfs(1,100),
cfs(2,100),RH(1),RH(2)....RH(2000)

The first word in the integer header is the length of the integer header.
For the standard 414 control runs, this value is 217, which is much larger
than the dimension of IH(37).

When the integer header is read, ih(1) (the total length of the integer
header) is read first, then the rest of the integer header is read based
on the value of ih(1). During the read, the first 37 of the 217 words
being read go into IH(1)...IH(37). The rest of the data being read
(217-37=180 words) spill over into IFS. Notice that there are 60 fields
on the CCM2 414 control run tapes, which corresponds to those 180 words,
divided by 3 words per field. The same concept holds true for the
character and real headers. This is safe practice on machines where the
integer, character and real word lengths are all the same, like the
Crays.

The philosophy of those sample codes is to show quick ways to access
history tape data, in as few lines of code as possible and without the
use of automatic arrays. So, I overdimensioned those header arrays
which are dependent on the number of fields, constructed the
read/unpacking statements in the shortest form possible and put all the
header information in one common block for easy access to other
subroutines.

-- 
                                     Lawrence Buja
                                     ccmproc2@ncar.ucar.edu