[Dart-dev] [5949] DART/branches/development/observations/NCEP/prep_bufr/convert_bufr: minor change prompted by a error report from ting-chi wu

nancy at ucar.edu nancy at ucar.edu
Fri Jan 18 15:24:12 MST 2013


Revision: 5949
Author:   nancy
Date:     2013-01-18 15:24:11 -0700 (Fri, 18 Jan 2013)
Log Message:
-----------
minor change prompted by a error report from ting-chi wu
at the U of miami.  on current intel compilers the one-line
stat() and test fails, but assigning the stat return explicitly
to an integer variable first and then testing for 0 succeeds
and gives the right info in the stat buffer.  i've tested
this on ifort, pgi, pathscale and gnu on yellowstone; ifort
and gnu on mac.  on ibm power platforms, xlf needs index 11
instead of 8, but for that machine this program isn't used
so i'm leaving the default at 8.

Modified Paths:
--------------
    DART/branches/development/observations/NCEP/prep_bufr/convert_bufr/grabbufr.f
    DART/branches/development/observations/NCEP/prep_bufr/convert_bufr/stat_test.f

-------------- next part --------------
Modified: DART/branches/development/observations/NCEP/prep_bufr/convert_bufr/grabbufr.f
===================================================================
--- DART/branches/development/observations/NCEP/prep_bufr/convert_bufr/grabbufr.f	2013-01-18 22:06:05 UTC (rev 5948)
+++ DART/branches/development/observations/NCEP/prep_bufr/convert_bufr/grabbufr.f	2013-01-18 22:24:11 UTC (rev 5949)
@@ -48,7 +48,7 @@
       CHARACTER(len=80) :: infile,outfile
       character(len=4) :: bufr='BUFR',ctemp,csec0
       INTEGER(4)       narg,iargc,JSTAT(100)
-      integer findbufr, i, INDEXVAL
+      integer findbufr, i, INDEXVAL, rc
       character*1 byte(8)
  
       data i1/11/,i2/51/,newed/2/
@@ -85,7 +85,13 @@
 C
 C  Use STAT function to get size of input BUFR file
 C
-      IF (STAT(infile,JSTAT).NE.0) THEN
+c  the original code was:
+c      IF (STAT(infile,JSTAT).NE.0) THEN
+c  but this failed on the linux systems, at least with intel
+c  as the compiler. but changing it so the return code was assigned to 
+c  an integer variable before being tested seemed to fix the problem.
+      rc = STAT(infile,JSTAT)
+      IF (rc.NE.0) THEN
          PRINT *,'ERROR IN FUNCTION STAT GETTING FILE STATS'
          CALL EXIT(99)
       ELSE
@@ -97,9 +103,9 @@
 c        The following line may need to be changed for different machines
 c        and compilers (and sometimes even between 32 and 64 bit versions of
 c        the same compiler).
-         INDEXVAL = 8       ! for gfortran on Macs, 32 bit ifort on linux
-c        INDEXVAL = 12      ! for pgf90 32 bytes, (ifort 64 bit?)
-c        INDEXVAL = 13      ! for pgf90 64 bytes
+         INDEXVAL = 8       ! seems to be right for most current compilers
+c        INDEXVAL = 12      ! for old versions of pgf90 32 bytes
+c        INDEXVAL = 13      ! for old versions of pgf90 64 bytes
 
          KBYTES = JSTAT(INDEXVAL)
          PRINT *,'NUMBER OF BYTES IN INPUT FILE = ',KBYTES

Modified: DART/branches/development/observations/NCEP/prep_bufr/convert_bufr/stat_test.f
===================================================================
--- DART/branches/development/observations/NCEP/prep_bufr/convert_bufr/stat_test.f	2013-01-18 22:06:05 UTC (rev 5948)
+++ DART/branches/development/observations/NCEP/prep_bufr/convert_bufr/stat_test.f	2013-01-18 22:24:11 UTC (rev 5949)
@@ -46,7 +46,7 @@
 C$$$
       CHARACTER(len=80) :: infile
       INTEGER(4)        :: narg,iargc,JSTAT(100)
-      integer           :: i, KBYTES
+      integer           :: i, KBYTES, rc
 
 C
 c liu 03/16/2005
@@ -74,7 +74,13 @@
 C
 C  Use STAT function to get size of input BUFR file
 C
-      IF (STAT(infile,JSTAT).NE.0) THEN
+c  this used to be a oneliner, but the function test failed
+c  on recent intel compilers.  splitting the call and test into
+c  two separate lines with an explicit integer variable seems
+c  to have fixed it.  also, for all the recent compilers i have
+c  tested the right offset seems to be 8
+      rc = STAT(infile,JSTAT)
+      IF (rc.NE.0) THEN
          PRINT *,'ERROR IN FUNCTION STAT GETTING FILE INFO'
          CALL EXIT(99)
       ELSE


More information about the Dart-dev mailing list