Langley DAAC Version Number: LD_008_004_003_00_00_0_19990526 ERBE S-10 Readme The readpgm.f program reads either ERBE S-9, S-10, or S-10N data from a file/tape for a particular month, year, and satellite. This program prompts the user for information regarding the type of file to be read, the total number of regions to be processed, whether these regions are in consecutive order, and if not, will prompt the user to input the other regions which need to be processed. After reaching the desired region on the file, it prompts the user once again regarding the type of record the user wants as output, the number of regions to be read, whether these regions are consecutive, and the first region to be read. This program uses C routines to open and read the data from the file. These routines, copen and cread, are found in a file called io.c. Other C routines which are used are gbytes and gbyte which are found in a file called gbytes.c. The gbyte and gbytes routines are used to unpack the data from the NOS 60-bit format to the UNIX format. Information pertaining to the io.c and to the gbytes.c routines can be found at the end of this document. If users have questions while using the sample read software, please contact the Langley DAAC Science, Users and Data Services office at: EOSDIS Langley DAAC Science, Users and Data Services Office NASA Langley Research Center Mail Code 157D 2 South Wright Street Hampton, Virginia 23681-2199 U.S.A. E-mail: support-asdc@earthdata.nasa.gov Phone: (757) 864-8656 FAX: (757) 864-8807 The user needs to modify two namelist files in order to be able to read other months of data. The namelist files are contained in files called fort.9 and fort.10. A sample namelist is shown here. Sample Namelist ----------------- &GENRAL isatcd = 2, month = 03, iyear = 91, ires = 50, inst = 1, irtyp = 3, iprnt = 1, vsnin = 'ea1111x', fov = 2, &END The parameters of fort.9 are: Variable Definition Allowed values Definition of values isatcd satellite code 1-7 1--NOAA-9 2--ERBS 3--NOAA-10 4--NOAA-9/NOAA-10 5--ERBS/NOAA-9 6--ERBS/NOAA-10 7--ERBS/NOAA-9/NOAA-10 month month of year 1-12 months of the year iyear last 2 digits of year 84-90 ires resolution 25,50,100 25-- to represent 2.5, scanner 50-- to represent 5.0, numerical filter 100-- to represent 10.0, shape factor inst flag indicating 0,1 (inoperative in this field-of-view version of read program) irtyp flag to indicate 1,2,3 1=first record desired if both types of 2=second record desired records desired 3=both records desired iprnt flag to indicate 0,1 0=no writing desired if writing data to 1=writing desired file is desired vsnin tape/file name any 7 char. name fov field of view 0,1,2 0-- narrow-field-of-view (scanner) 1--medium-field-of-view 2--wide-field-of-view **NOTE** Because this read software is able to read ERBE S-9, ERBE S-10, and ERBE S-10N data products, not all of the allowed values for the parameters listed above will output any information. The reason is that not all data granules for these products contain data for all of these options. If you have any questions please contact the Langley DAAC Science, Users and Data Services Office. Sample Namelist ------------------ $TP10 S9VSN = 'EA4022x', NFILES = 1, IFIRST =433, ILAST(1) =2160, ILAST(2) = 0, ILAST(3) = 0, ILAST(4) = 0, ILAST(5) = 0, ILAST(6) = 0, ILAST(7) = 0$ The parameters of fort.10 are: Variable Definition Allowed values Definition of values s9vsn tape/file name 7 char. name nfiles number of files on tape 1-7 ifirst first region on file 1-10368 ilast(1) last region of file one 1-10368 ilast(2) last region of file two 0-10368 0=no file two . . . ilast(7) last region of file seven 0-10368 0=no file seven The output files are named fort.2 and fort.95. The fort.2 file is the actual output which contains the namelist, the scale factors used in scaling the data, and all the requested regions and their requested record types. Fort.95 contains the information which was input by the user. The following files are needed in order for this program to work: readpgm.f This is the main software program in FORTRAN. setloc.f Subroutine that initializes the arrays. Written in FORTRAN. gbytes.c Routine to unpack the data. Written in C. io.c Routine to open and read files. Written in C. fort.9 Namelist file. fort.10 Namelist file. s10tape_regions The number of files, the regions in each file, and the regions missing from the data for several months for the S-10 and S-10N products. In order to use these codes, the following steps need to be taken: 1) cc -c io.c 2) cc -c gbytes.c 3) f77 readpgm.f setloc.f io.o gbytes.o 4) a.out (this prompts the user to enter information so that the program can start processing.) Once again, the output can be found in fort.2. THIS SECTION GIVES A DESCRIPTION OF THE SUBROUTINES INCLUDED IN THE FILE CALLED "io.c." **NOTE: The "i" in the first column stands for input which means that the user needs to pass the information into the subroutine. The "o" in the first column stands for output which means the subroutine will return information to the called program. **NOTE: I have also included what "type" is expected for each parameter. ******************************************************************************* * * * COPEN * * * ******************************************************************************* This routine opens the i/o file. call copen(name,length,unit) i name filename (character*#) name must be in single quotes if passing the name i length number of characters in the filename (integer) o unit unit number returned from system routine (integer) ******************************************************************************* * * * CCREAT * * * ******************************************************************************* This routine allows the user to create an output file. call ccreat(name,length,unit) i name filename (character*#) i length number of letters in the filename (integer) o unit unit number returned from system routine (integer) ******************************************************************************* * * * CCLOS * * * ******************************************************************************* This routine closes the i/o file. call cclos(unit,ioerr) i unit unit number used when file was opened (integer) o ioerr zero returned if no problems occurred while trying to close the file (integer) ******************************************************************************* * * * CREWND * * * ******************************************************************************* This routine rewinds the i/o file back to the beginning. call crewnd(unit,ioerr) i unit unit number used when file was opened (integer) o ioerr zero returned if no problems occurred while trying to close the file (integer) ******************************************************************************* * * * CWRIT * * * ******************************************************************************* This routine allows the user to write data in a specific number of bytes to a file. call cwrit(unit,nbuf,buf,ioerr) i unit unit number used when file was opened (integer) i nbuf = number of integers read * size of integer in bytes (8 bits equals 1 byte) (integer) i buf the array that has all of the bytes stored in packed form where 4 bytes equals one word (32 bits) (integer) o ioerr no problems have arisen if ioerr equals nbuf (integer) ******************************************************************************* * * * CREAD * * * ******************************************************************************* This routine allows the user to read a specific number of bytes from a file into a CHARACTER array. call cread(unit,nbuf,buf,ioerr) i unit unit number used when file was opened (integer) i nbuf = number of integers read * size of integer in bytes (8 bits equals 1 byte) (integer) o buf the array that has all of the bytes were stored in packed form where 4 bytes equals one word (32 bits) (character) o ioerr no problems have arisen if ioerr equals nbuf (integer) ******************************************************************************* * * * PCWRIT * * * ******************************************************************************* This routine allows the user to write just portions of the packed array to a file. call pcwrit(unit,nbuf,buf,spos,ioerr) i unit unit number used when file was opened (integer) i nbuf = number of integers read * size of integer in bytes(8 bits equals 1 byte) (integer) i spos allows user to skip a number of bytes and continue to write bytes to a file (integer) o ioerr no problems have arisen if ioerr equals nbuf (integer) ******************************************************************************* * * * CREADI * * * ******************************************************************************* This routine allows the user to read a specific number of bytes from a file into an INTEGER array. call creadi(unit,nbuf,buf,ioerr) i unit unit number used when file was opened (integer) i nbuf = number of integers read * size of integer in bytes (8 bits equals 1 byte) (integer) o buf the array that has all of the bytes were stored in packed form where 4 bytes equals one word (32 bits) (character) o ioerr no problems have arisen if ioerr equals nbuf (integer) THIS SECTION GIVES A DESCRIPTION OF THE SUBROUTINES INCLUDED IN THE FILE CALLED "gbytes.c." ******************************************************************************* * * * GBYTES * * * ******************************************************************************* This routine allows the user to unpack any amount of bits and perform this operation a number of times. call gbytes (packed,unpacked,noff,nbits,nskip,iter) i packed array which contains the packed binary read. (integer) o unpacked array which contains the unpacked data in byte form. (integer) i noff The initial number of bits to skip, left to right, in packed order to locate the first byte to unpack. (integer) i nbits The number of bits in each byte to be unpacked. Maximum is machine word size. (integer) i nskip The number of bits to skip between each byte in packed in order to locate the next byte to be unpacked. (integer) i iter The number of bytes to be unpacked. ******************************************************************************* * * * SBYTES * * * ******************************************************************************* This routine allows the user to pack any amount of bits and perform this operation a number of times. call sbytes (packed,unpacked,noff,nbits,nskip,iter) o packed array which contains the packed binary read. (integer) i unpacked array which contains the unpacked data in byte form. (integer) i noff The initial number of bits to skip, left to right, in unpacked order to locate the first byte to pack. (integer) i nbits The number of bits in each byte to be packed. Maximum is machine word size. (integer) i nskip The number of bits to skip between each byte in the unpacked in order to locate the next byte to be packed. (integer) i iter The number of bytes to be packed. ******************************************************************************* * * * GBYTE * * * ******************************************************************************* The singular version of the gbytes routine which accesses only one byte in each call. call gbyte (packed,unpacked,noff,nbits) i packed array which contains the packed binary read. (integer) o unpacked array which contains the unpacked data in byte form. (integer) i noff The initial number of bits to skip, left to right, in packed order to locate the first byte to unpack. (integer) i nbits The number of bits in each byte to be unpacked. Maximum is machine word size. (integer) ******************************************************************************* * * * SBYTE * * * ******************************************************************************* The singular version of the sbytes routine which accesses only one byte in each call. call sbyte (packed,unpacked,noff,nbits) o packed array which contains the packed binary read. (integer) i unpacked array which contains the unpacked data in byte form. (integer) i noff The initial number of bits to skip, left to right, in unpacked order to locate the first byte to pack. (integer) i nbits The number of bits in each byte to be packed. Maximum is machine word size. (integer)