TXT to ROPP converter

This page descibes the logic of the txt2ropp routine, written by Hans Gleisner (DMI), in

 /data/nwp1/idculv/ROPP/ropp_src/branches/dev/Share/hw_grib2ropp/hgl_script/txt2ropp.


Interface:


!----------------------------------------------------------------------------------------!
!                                                                                        !
! NAME                                                                                   !
!   asc2ropp                                                                             !
!                                                                                        !
! DESCRIPTION                                                                            !
!   Read data from one or several OCC/ASCII files and store in a ROPP/netCDF file.       !
!                                                                                        !
! DEPENDENCIES                                                                           !
!   module rom_num                                                                       !
!   module rom_io                                                                        !
!   module ropp_io                                                                       !
!                                                                                        !
! SYNOPSIS                                                                               !
!   asc2ropp  ascfile [-o roppfile]                      &                               !
!                     [-obsdir obsdir]                   &                               !
!                     [-bgrfile bgrfile]                 &                               !
!                     [-outfile outfile]                 &                               !
!                     [-datdir datadir]                  &                               !
!                     [-obs | -bgr]                      &                               !
!                     [-sil] [-h]                                                        !
!                                                                                        !
! ARGUMENTS                                                                              !
!   <ascfile>           Name of input files (without prefix or suffix when converting    !
!                         OCC/ASCII files to ROPP/netCDF files).                         !
!   -o <roppfile>       Name of output files (without prefix & suffix when converting    !
!                         OCC/ASCII files to ROPP/netCDF files).                         !
!   -obsdir <obsdir>    Directory where the input observed data files are located.       !
!   -bgrfile <bgrfile>  Input ASCII file.                                                !
!   -outfile <outfile>  Output netCDF file.                                              !
!   -datdir <datadir>   Root directory to the O, B, and GSM-96 data directories.         !
!   -obs                Convert observed profile data from the OCC software.             !
!   -bgr                Convert ECMWF profile data.                                      !
!   -sil                Execute silently.                                                !
!   -h                  Help.                                                            !
!                                                                                        !
! NOTES                                                                                  !
!   Already existing output files will be overwritten.                                   !
!                                                                                        !
! AUTHOR                                                                                 !
!   Hans Gleisner (hgl@dmi.dk)                                                           !
!                                                                                        !
! VERSION                                                                                !
!   01-Mar-2012                                                                          !
!                                                                                        !
! CODE DESCRIPTION:                                                                      !
!   Language: Fortran 90                                                                 !
!                                                                                        !
!----------------------------------------------------------------------------------------!

The output outfile from grib2txt is the input bgrfile to txt2ropp.


Steps:

1) Specifying -bgrfile sets inputBGR=.true.

2) Call readfile_BGR.  This reads time, location, {Z0, P0, LSmask, NmodLevs, P(i), T(i), q(i)} from the ascii input, which is in a known format.  For ROPP, we may prefer to use namelists.  

readfile_BGR also reads level coeffs Ak and Bk from files. Since these are known from the GRIB file, we should probably write them out from grib2txt and read them in with txt2ropp.

It also defines the ROprof structure BGRprof, whose Lev2b substructure it then populates with the injested values, thus:

BGRprof%occ_id = 'nnnn'

BGRprof%Lev2b%press          = Pmod
BGRprof%Lev2b%temp           = Tmod
BGRprof%Lev2b%shum           = Qmod
BGRprof%Lev2b%meteo_qual     = 100.0d0
BGRprof%Lev2c%geop_sfc       = Z0mod
BGRprof%Lev2c%press_sfc      = P0mod
BGRprof%Lev2c%press_sfc_qual = 100.0d0
BGRprof%Lev2d%level_type     = "ECMWF"
BGRprof%Lev2d%level_coeff_a  = ak
BGRprof%Lev2d%level_coeff_b  = bk

BGRprof%GEOref%lat = lat
BGRprof%GEOref%lon = lon

BGRprof%bg%source   = "ECMWF"
BGRprof%bg%year     = year
BGRprof%bg%month    = month
BGRprof%bg%day      = day
BGRprof%bg%hour     = hour
BGRprof%bg%minute   = minute
BGRprof%bg%fcperiod = fcast

BGRprof%PCD = 0
BGRprof%PCD = ibset(BGRprof%PCD, PCD_offline)
BGRprof%PCD = ibset(BGRprof%PCD, PCD_occultation)

3) There's a check that we have  60, 91, or 126 levels in the file. (We must have, or it wouldn't have been able to find the Aks and Bks.)  We don't need this for ROPP, because we'll hold the Aks and Bks in the ascii file.

4) Call writefile_BGR_ropp(outfile, BGRdata, 0).  This is basically a call to ropp_io_write(BGRdata, BGRfile, ranchk=.false., ierr=ierr).



Example:

cd /data/nwp1/idculv/ROPP/ropp_src/branches/dev/Share/ic_grib2ropp/hgl_script/txt2ropp

./compile_asc2ropp.bash

./asc2ropp.x \
   -bgr \
   -bgrfile '/data/nwp1/idculv/ROPP/ropp_src/branches/dev/Share/ic_grib2ropp/hgl_script/grib2txt/example1.out' \
   -datdir  '/net/data/nwp1/idculv/ROPP/ropp_src/branches/dev/Share/ic_grib2ropp/hgl_script/ancillary' \
   -outfile 'example1.nc'

produces:

/net/data/nwp1/idculv/ROPP/ropp_src/branches/dev/Share/ic_grib2ropp/hgl_script/txt2ropp
idculv@eld037:> ncks -H -ddim_lev2b,0,4 -vpress,temp,shum example1.nc
dim_unlim[0] dim_lev2b[0] press[0]=1005.936
dim_unlim[0] dim_lev2b[1] press[1]=1003.05
dim_unlim[0] dim_lev2b[2] press[2]=999.052
dim_unlim[0] dim_lev2b[3] press[3]=993.804
dim_unlim[0] dim_lev2b[4] press[4]=987.317

dim_unlim[0] dim_lev2b[0] shum[0]=8.83387
dim_unlim[0] dim_lev2b[1] shum[1]=8.92123
dim_unlim[0] dim_lev2b[2] shum[2]=8.99149
dim_unlim[0] dim_lev2b[3] shum[3]=9.07474
dim_unlim[0] dim_lev2b[4] shum[4]=9.11437

dim_unlim[0] dim_lev2b[0] temp[0]=286.18
dim_unlim[0] dim_lev2b[1] temp[1]=286.13
dim_unlim[0] dim_lev2b[2] temp[2]=286
dim_unlim[0] dim_lev2b[3] temp[3]=285.83
dim_unlim[0] dim_lev2b[4] temp[4]=285.79


idculv@eld037:> ncks -H -ddim_lev2d,0,4 -vlevel_coeff_a,level_coeff_b example1.nc
dim_unlim[0] dim_lev2d[0] level_coeff_a[0]=0
dim_unlim[0] dim_lev2d[1] level_coeff_a[1]=3.16e-05
dim_unlim[0] dim_lev2d[2] level_coeff_a[2]=0.0657563
dim_unlim[0] dim_lev2d[3] level_coeff_a[3]=0.542083
dim_unlim[0] dim_lev2d[4] level_coeff_a[4]=1.62043

dim_unlim[0] dim_lev2d[0] level_coeff_b[0]=1
dim_unlim[0] dim_lev2d[1] level_coeff_b[1]=0.99763
dim_unlim[0] dim_lev2d[2] level_coeff_b[2]=0.994204
dim_unlim[0] dim_lev2d[3] level_coeff_b[3]=0.989153
dim_unlim[0] dim_lev2d[4] level_coeff_b[4]=0.982238

idculv@eld037:> ncks -H -vgeop_sfc,press_sfc example1.nc
dim_unlim[0] geop_sfc[0]=-1.43

dim_unlim[0] press_sfc[0]=1007.13

Which all looks OK.


Aspects relevant to ROPP implementation:

1) Need to be able to read from general ascii file input, not just those produced by grib2txt.  Maybe namelists?  For same reason, need to read Ak and Bk.  Perhaps we could default all these, and allow the user to overwrite them all.
2) Don't need the GRIB API as an external library, like netCDF or BUFR, for this.
3) No need to worry about the orog etc: can assume the user can produce geopotential on model levels.
4) Any need to cope with more than one ascii file at a time?  Might be simpler not to bother, and to advise users to use ncrcat or ncecat to combine into a multifile.  (Need to check this works.)
5) Some overlaps with gfz2ropp.
6) I suggest we start with this, and then we'll know better what output we should produce with grib2txt.
7) Natural place to put it: ropp_io/tools/text2ropp.



Last updated 24th September 2012 by ian.culverwell@metoffice.gov.uk