NOAA-EMC / NCEPLIBS-g2

Utilities for coding/decoding GRIB2 messages.
Other
6 stars 15 forks source link

How do we test tocgrib2super? #735

Open edwardhartnett opened 4 months ago

edwardhartnett commented 4 months ago

How in the world do we run togrib2super?

I am trying this and it's not working:

export FORT11="../tests/data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
export FORT51=out.grib2
../utils/tocgrib2super < data/tocgrib2.nml

and this does not work. Fails opening a file.

When I look at the code I see:

 !        Read GRIB2 data and index file names from the FORTnn
  !        environment variables, and open the files.
  !
  envvar='FORT  '
  write(envvar(5:6),fmt='(I2)') lugb
  call getenv(envvar,fileb)
  write(envvar(5:6),fmt='(I2)') luga
  call getenv(envvar,filea)
  write(envvar(5:6),fmt='(I2)') lugi
  call getenv(envvar,filei)
  !
  !     Get the file size of the grib file
  !
  !     call baopenr(luga,filea,iret1)
  open(unit=luga,file='filesize',form='formatted',status='old', &
       iostat=iret1)
  if (iret1  .ne. 0) then
     write(6,fmt='(" Error opening GRIB file: ",A200)') filea
     write(6,fmt='(" baopenr error = ",I5)') iret1
     stop 10
  endif

How is the file size supposed to be passed in?

Do we know where this is being used? If so, can I look at how they do it?

@Hang-Lei-NOAA and @GeorgeVandenberghe-NOAA do you know where tocgrib2super is used?

GeorgeVandenberghe-NOAA commented 4 months ago

I will try to snag this. Meanwhile if you have access to source, put in prints to find out what the %^( is going on here. "Filesize" is a very odd variable name for a NAME btw but I know this ain't your code.

To speed this up if you have source and a testcase, where are they.

edwardhartnett commented 4 months ago

Code here: https://github.com/NOAA-EMC/NCEPLIBS-g2/blob/develop/utils/tocgrib2super.F90

Test (commented out currently) here: https://github.com/NOAA-EMC/NCEPLIBS-g2/blob/develop/test_utils/run_tocgrib2super_tests.sh

GeorgeVandenberghe-NOAA commented 3 months ago

Okay, filesize is the NAME of a file read as unit 12 that has the exact size of the file in unit 11. THis method of obtaining file size was common at the turn of the century and predates the more modern method of using stat() to return the size in the inode. (And be careful.. the internal stat structure also unix, linux and filesystem implementation dependent but it's still the preferred method and seems to have stabilized with both Lustre and GPFS returning the same data structure). Anyway if fortran unit 11 is, 40999888 bytes long, then fortran unit 12 should be a single 8 character text string containing this integer value. In setting up this test I am stuck getting a proper namelist for unit 5 input.