# rda-bufr-decode-ADPsfc This project contains Fortran source code to read BUFR data files containing NCEP ADP surface observations, which are archived and available for download in the [NCAR Research Data Archive (RDA) dataset ds461.0](https://rda.ucar.edu/datasets/ds461.0/). The ds461.0 archive contains NCEP ADP global surface data observations, including ADPSFC and SFCSHP observations, for the time period 1999 - present. ## Usage After compiling the source code, the executable can be run with the command ``` ./bufrsurface.x <BUFR input file> <output file> <configuration file> ``` For example: ``` ./bufrsurface.x ../bufrobs/gdas.adpsfc.t00z.20210701.bufr ../textobs/gdas.adpsfc.t00z.20210701.txt ../configs/bufrsurface.config ``` ## Directory structure The directories provided in this project are as follows: ``` bufrobs/ Can be used to store BUFR input data files for the decoder. configs/ Contains a descriptive template and example configuration files to be used as input to the decoder. docs/ Contains files showing some basic parameter mnemonics and a link to recent NCEP BUFR tables. exe/ Directory containing the decoder executables. install/ Contains a shell script for compiling and installing BUFR decoders. src/ Contains two FORTRAN BUFR decoder source code files: 1) a flexible, user configurable program and 2) a simple program for dumping BUFR output. textobs/ Can be used to store text files generated by the decoders. ``` ## Detailed instructions The following lists the steps necessary to build the software and decode the BUFR data. Steps include preparing the decoder software, preparing the configuration files, and finally running the decoder software. 1. Preparing the decoder software: To compile the BUFR libraries and extraction code, go to the `/install` directory and run the `install.sh` script to complete the compilations. You will need to edit `LIB` in `install.sh` to point to the correct location of the BUFRLIB library on your computer or system prior to running the script. Note: `install.sh` uses `gfortran` to compile and link the source code. This is tested and works for Linux platforms, but may require adjustments for other operating systems. After compiling, the executables will be placed in the `/exe` directory. These can be copied to an arbitrary directory, e.g. `~/bin`, for your convenience. Executables built by `install.sh`: ``` exe/bufrsurface.x: used to make a selective dump from ADPSFC and/or SFCSHP BUFR files - gdas.adpsfc.tHHz.YYYYMMDD.bufr - gdas.sfcshp.tHHz.YYYYMMDD.bufr exe/dumpbufr.x: used to dump all contents of a BUFR file. ``` 2. Preparing the input files: BUFR files can be placed in the `bufrobs/` directory for convenience File names in the NCAR RDA dataset ds461.0 are of the following form: gdas.adpsfc.tHHz.YYYYMMDD.bufr (ADPSFC: land based surface observations) gdas.sfcshp.tHHz.YYYYMMDD.bufr (SFCSHP: marine based surface observations) 3. Preparing the configuration file: Go to the `configs/` directory and create your configuration file following the instructional template and examples on how to build a configuration file. 4. Running the decoder software: To decode the BUFR data according to the instructions in your configuration file, run the `exe/bufrsurface.x` executable with the input BUFR file, output file, and configuration file provided as command line arguments. For example: ``` ./bufrsurface.x ../bufrobs/gdas.adpsfc.t00z.20210701.bufr ../textobs/gdas.adpsfc.t00z.20210701.txt ../configs/bufrsurface.config ``` To generically dump output from an individual file, run the `exe/dumpbufr.x` executable. From here you will be prompted to enter the name of the input BUFR file (including path) from which you would like all output to be printed. ## Additional information The NCEP BUFRLIB software library is required to compile and run these programs, and it is recommended to compile and install BUFRLIB with the same compiler you use to compile the source code in this project. The BUFRLIB software and installation instructions are provided on the [NCEP BUFRLIB support page](https://emc.ncep.noaa.gov/emc/pages/infrastructure/bufrlib.php).