[gradsusr] converting GRIB to .dat for FORTRAN

Frost, Mr. Michael Michael.Frost at nrlmry.navy.mil
Wed May 8 12:55:57 EDT 2019


Hello,

 

I think that 'wgrib' will do the trick for you.

 

==

Portable Grib decoder for NCEP/NCAR Reanalysis etc.

   it slices, dices    v1.7.3.1 (8-5-99) Wesley Ebisuzaki

   usage: wgrib [grib file] [options]

 

Inventory/diagnostic-output selections

   -s/-v                   short/verbose inventory

   -V                      diagnostic output (not inventory)

   (none)                  regular inventory

Options

   -PDS/-PDS10             print PDS in hex/decimal

   -GDS/-GDS10             print GDS in hex/decimal

   -verf                   print forecast verification time

   -ncep_opn/-ncep_rean    default T62 NCEP grib table

   -4yr                    print year using 4 digits

Decoding GRIB selection

   -d [record number|all]  decode record number

   -p [byte position]      decode record at byte position

   -i                      decode controlled by stdin (inventory list)

   (none)                  no decoding

Options

   -text/-ieee/-grib/-bin  convert to text/ieee/grib/bin (default)

   -nh/-h                  output will have no headers/headers (default)

   -H                      output will include PDS and GDS (-bin/-ieee only)

   -append                 append to output file

   -o [file]               output file name, 'dump' is default

==

 

 

 

Mike

 

From: gradsusr [mailto:gradsusr-bounces at gradsusr.org] On Behalf Of Stephan
Steyn
Sent: Tuesday, May 7, 2019 7:58 AM
To: gradsusr at gradsusr.org
Subject: [gradsusr] converting GRIB to .dat for FORTRAN

 

Dear GrADS users

 

As described on
https://ds.data.jma.go.jp/tcc/tcc/library/MRCS_SV12/sstdata/readme_grib_e.ht
m I am attempting to use a GrADS script to convert  a GRIB file (in the form
of ERA5 gridded surface data) to a .dat file that I can read with FORTRAN
(4-byte real floating point format). I already have fortran programs that
can ingest this format. 

 

I managed to use "grib2ctl.pl" to create the .ctl file (copied below) and
"gribmap" to create a .grib.idx file and successfully display the data in
GrADS.

Upon executing "run convert.gs" (copied below) within GrADS I don't receive
any error messages, only to find that the .dat file was never created. I
also tried to make subsets of the data with the same non-result.

 

I am using GrADS Version 2.0.2 run on 64-bit Fedora in a Oracle Virtualbox
on Lenovo Thinkpad (Core i7).

 

I am pretty much stuck now... Please help!

 

Stephan

 

*** convert.gs ***

*---------------------------------------------------------------------

function main()

* Please edit the following line to match your computer environment:

mydir='/home/stephan/ERA5'

'open ERA5_sfcvar12_197901.ctl'

'set lon 0.00 359.75'

'set lat -90.00 90.00'

'set time jan1979'

'set gxout fwrite'

'set fwrite 'mydir'/ERA5_sfcvar12_197901.dat'

'quit'

*----------------------------------------------------------------------

 

Below the content of "ERA_sfcvar12_197901.ctl": -----------------------

dset ^ERA5_sfcvar12_197901.grib

index ^ERA5_sfcvar12_197901.grib.idx

undef 9.999E+20

title ERA5_sfcvar12_197901.grib

*  produced by grib2ctl v0.9.15

* command line options: ERA5_sfcvar12_197901.grib

dtype grib 255

options yrev

ydef 721 linear -90.000000 0.25

xdef 1440 linear 0.000000 0.250000

tdef 31 linear 12Z01jan1979 1dy

zdef 1 linear 1 1

vars 4

no10Usfc  0 165,1,0  ** surface 10 metre U wind component [m s**-1]

no10Vsfc  0 166,1,0  ** surface 10 metre V wind component [m s**-1]

no2Dsfc  0 168,1,0  ** surface 2 metre dewpoint temperature [K]

no2Tsfc  0 167,1,0  ** surface 2 metre temperature [K]

ENDVARS

 

  _____  

University of the Free State: This message and its contents are subject to a
disclaimer. 
Please refer to http://www.ufs.ac.za/disclaimer for full details.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20190508/06c5e120/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5407 bytes
Desc: not available
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20190508/06c5e120/attachment-0001.p7s>


More information about the gradsusr mailing list