INSTRUCTIONS / NAMELIST / FILES / REFERENCES / BUGS / PLANS /

PROGRAM prepbufr

Contact: Hui Liu
Revision: $Revision: 3033 $
Source: $URL: http://subversion.ucar.edu/DAReS/DART/trunk/ncep_obs/prep_bufr/prep_bufr.html $
Change Date: $Date: 2007-07-27 10:46:07 -0600 (Fri, 27 Jul 2007) $
Change history: try "svn log" or "svn diff"

OVERVIEW

Translating NCEP BUFR files into DART obs_seq.out files (input file to filter) is a 2 stage process. The first stage uses NCEP software to translate the BUFR file into an "intermediate" text file. This is described in this document. The second step is to translate the intermediate files into obs_seq.out files, which is done by create_real_obs, as described in create_real_obs .




INSTRUCTIONS

The prep_bufr package is free-standing and has not been completely assimilated into the DART architecture. It also requires adaptation of the sources codes and scripts to the computing environment where it will be run. It is not so robust that it can be controlled just with input parameters. It may not have the same levels of error detection and warning that the rest of DART has, so the user should very careful about checking the end product for correctness.

Overview of what needs to be built and run

More detailed instructions follow, but this section describes a quick overview of what programs you will be building and running.

Building

Running the install.sh script will build the library and main executable. You will probably have to edit this script to set which fortran compiler is available on your system.

If you have raw unblocked BUFR files you will need to convert them to blocked format (what prepbufr expects as input). You will need to uncomment the blk/ublk section in the script and build that converter program.

If you are running on an Intel (little-endian) based machine, uncomment the grabbufr section in the script to build that converter program.

One-shot execution

If you are converting a single obs file, or are walking through the process by hand for the first time, you can follow the more detailed build instructions below, and then run the prep_bufr.x program by hand. This involves the following steps:

Production mode

If you have multiple days (or months) of observations that you are intending to convert, there is a script in the work subdirectory which is set up to run the converter on a sequence of raw data files, and concatinate the output files together into one output file per day. Edit the work/prepbufr.csh script and set the necessary values in the 'USER SET PARAMETERS' section near the top. This script can either be run from the command line, or it can be submitted to a batch queue for a long series of conversion runs.

Installation of the NCEP BUFR decoding program

This package is currently (as of the Jamaica release) organized into files under the DART/ncep_obs/prep_bufr directory:
src           Source code of the NCEP PREPBUFR decoder
lib           NCEP BUFR library source
install.sh    A script to install the NCEP PREPBUFR decoder and the NCEP BUFR library.
exe           Executables of the decoder and converter.
data          Where the NCEP BUFR files (prepqm****) could be loaded into
              from the NCAR Mass Store (the script assumes this is the default location).
work          Where we run the script to do the decoding.
convert_bufr  Source code (grabbufr) to convert the binary big-endian BUFR files to 
              little-endian files, and a script to compile the program.
blk_ublk      Source code (cwordsh) to convert between blocked and unblocked format.
docs          Some background information about NCEP BUFR observations.

The decoding program: src/prepbufr.f

The program prepbufr.f is used to decode the NCEP reanalysis BUFR data into intermediate text files. This program was originally developed by NCEP. It has been modified to output surface pressure, dry temperature, specific humidity, and wind components (U/V) of conventional radiosonde, aircraft reports, and satellite cloud motion derived wind. There are additional observation types on the BUFR files, but using them they would require significant modifications of prepbufr and require detailed knowledge of the NCEP BUFR files. The NCEP quality control indexes for these observations based on NCEP forecasts are also output and used in DART observation sequence files. The NCEP PREPBUFR decoding program is written in Fortran 77 and has been successfully compiled on Linux computers using pgi90, SGI® computers with f77, IBM® SP® systems with xlf, and Intel® based Mac® with gfortran.

If your operating system uses modules you may need to remove the default compiler and add the one desired for this package. For example

To compile the BUFR libraries and the decoding program, set the CPLAT variable in the install.sh script to match the compilers available on your system. CPLAT = linux is the default. Execute the install.sh script to complete the compilations for the main decoding program and the NCEP BUFR library.

The executables (i.e., prepbufr.x, prepbufr_03Z.x) are placed in the ../exe directory.

Platforms tested: The code has been tested on NCAR systems:

The byte-swapping program convert_bufr/grabbufr.f

For platforms with little-endian binary file format (e.g. Intel, AMD®, and non-MIPS SGI processors) the program grabbufr.f is used to convert the big-endian format NCEP BUFR data into little-endian format. The grabbufr.f code is written in Fortran 90, and has been compiled can be compiled with the pgf90 compiler on a Linux system, with gfortran on an Intel based Mac, and the ifort compiler on other Linux machines. Instructions for building it can be found in convert_bufr/README, but basically go to the convert_bufr subdirectory, edit covert_bufr.csh to set your compiler, and run it to compile the converter code (grabbufr).

This program reads the whole BUFR file into memory, and needs to know the size of the file (in bytes). Unfortunately, the system call STAT() returns this size as one number in an array, and the index into that array differs depending on the system and sometimes the bit size (32 vs 64) of the compiler. To test that the program is using the right offset into this array, you can compile and run the stat_test.f program. It takes a single filename argument and prints out information about that file. One of the numbers will be the file size in bytes. Compare this to the size you see with the 'ls -l' command for that same file. If the numbers do not agree, find the right index and edit the grabbufr.f source file. Look for the INDEXVAL line near the first section of executable code.

If grabbufr.f does not compile because the getarg() or iargc() subroutines are not found or not available, then either use the arg_test.f program to debug how to get command line arguments into a fortran program on your system, or simply go into the grabbufr.f source and comment out the section which tries to parse command line arguments and comment in the hardcoded input and output filenames. Now to run this program you must either rename the data files to these predetermined filenames, or you can use links to temporarily give the files the names needed.

The blocking program blk_ublk/cwordsh

The prepbufr.x program expects to read a blocked input file, which is generally what is available for download. However, if you have an unblocked file that you need to convert, there is a conversion program. Change directories into the blk_ublk subdirectory and edit the cwordsh.make file and edit it to match your system. Execute it and it will build a cwordsh.x executable, which can be run with the shell-script wrapper program cwordsh.

The shell scripts in this directory actually create both a .c and .f file (which did not exist before), then compile them, then remove them. If you have problems with the compile, comment out the remove at the end of the make script so you can see the files it is actually trying to compile.

Note that if you can get the blocked file formats to begin with, this program is not needed.

Getting the NCEP Reanalysis BUFR format data from NCAR MSS.

The NCEP BUFR files (prepqmYYMMDDHH) can be found within the NCEP reanalysis dataset, ds090.0, on NCAR Mass Store System (MSS).

To find the files:

The prepqm file will be grouped with others in a weekly (monthly after 2003) tar file. Each tar file has a unique file number like "A#####". For example, for January of 2003, the 4 MSS TAR files are: A21899, A21900, A21901, A21902. Before 2004 these are unblocked files. The decoding program requires blocked version of the files. The corresponding blocked files are A21899.blk, A21900.blk, A21901.blk, and A21902.blk. These names don't appear in the web page, but are found on the mass store. Each is about 400 Mb. After 2003 the files without ".blk" are blocked and can be used. They are about 1.7 Gb.

Change directories into the prep_bufr/data subdirectory. From a machine with access to the MSS use

or where ##### is the data set number, to read the NCEP BUFR data tar files.

Then

will yield individual 6-hourly NCEP BUFR data files for the observations in the +/- 3-hours time window of 00Z, 06Z, 12Z, and 18Z of each day. Note that DART obs_seq files are organized such that a 24 hour file with 4 observation times would contain observations from 3:01Z to 3:00Z of the next day, centered on 6Z, 12Z, 18Z and "24Z". In addition, there are some observations at 3:00Z on the BUFR file labelled with 06Z. Then, in order to make a full day intermediate file incorporating all the required obs from the "next" day, you'll need the BUFR files through 6Z of the day after the last day of interest. For example, to generate the observation sequence for Jan 1, 2003, the decoded NCEP BUFR text files for Jan 1 and 2, 2003 are needed, and hence the BUFR files are needed.

Running the NCEP BUFR decoding program

In prep_bufr/work/prepbufr.csh set the appropriate values of the year, month, first day, and last day of the period you desire, and the variable "convert" to control conversion from big- to little-endian. Confirm that the raw BUFR files are in ../data, or that prepbufr.csh has been changed to find them. Execute prepbufr.csh in the work directory. It has code for running in the LSF batch environment, but not PBS.

Currently, the script generates daily decoded BUFR text data which contains the observations within the time window of 3:01Z of the day to 3:00Z of next day. These daily output text files are named as temp_obs.yyyymmdd. These text BUFR data files can then be read by DART/ncep_obs/work/ create_real_obs . to generate the DART daily observation sequence files.




OTHER MODULES USED




INCLUDE file

The prepbufr package doesn't use any namelists, but prepbufr.prm contains some parameters, while other parameters are set in work/prepbufr.csh



FILES




REFERENCES

DART/ncep_obs/prep_bufr/docs/* (NCEP text files describing the BUFR files)


KNOWN BUGS




FUTURE PLANS

Further development to get observations directly from original
(undecoded) NCEP BUFR files.