From 5041b16736b10024d9bbc1df52652fdaac9d2cf5 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Fri, 24 May 2024 04:50:33 -0600 Subject: [PATCH 1/4] some 8-byte changes --- src/g2index.F90 | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/src/g2index.F90 b/src/g2index.F90 index 77f17823..086b899c 100644 --- a/src/g2index.F90 +++ b/src/g2index.F90 @@ -1268,7 +1268,7 @@ subroutine ix2gb2(lugb, lskip8, idxver, lgrib8, cbuf, numfld, mlen, iret) character cver, cdisc character(len = 4) :: ctemp integer (kind = 8) :: loclus8, locgds8, locbms8 - integer locgds, loclus, locbms + integer loclus, locbms integer :: indbmp, numsec, newsize, g2_mova2i, mbuf, lindex integer :: lskip integer :: ilndrs, ilnpds, istat @@ -1351,7 +1351,6 @@ end subroutine g2_sbytec1 ! Initialize values and allocate buffer (at the user-provided cbuf ! pointer) where the index data will be written. When subroutine is ! complete, cbuf will hold either version 1 or 2 index data. - loclus = 0 loclus8 = 0 iret = 0 mlen = 0 @@ -1425,7 +1424,6 @@ end subroutine g2_sbytec1 if (numsec .eq. 2) then ! Save the location of the local use section in the message. loclus8 = ibskip8 - lskip8 - loclus = int(ibskip8 - lskip8, kind(4)) elseif (numsec .eq. 3) then ! For the GDS section, read the whole section into the cgds ! buffer. @@ -1437,7 +1435,6 @@ end subroutine g2_sbytec1 return endif ! Remember the GDS location in the message. - locgds = int(ibskip8 - lskip8, kind(4)) locgds8 = ibskip8 - lskip8 elseif (numsec .eq. 4) then ! Having found the PDS, we write the beginning of the index @@ -1456,13 +1453,10 @@ end subroutine g2_sbytec1 inc = 0 lskip = int(lskip8, kind(4)) call g2_sbytec1(cindex, lskip, mypos, INT4_BITS) ! bytes to skip - !print '(i3, a7, i4)', mypos/8, ' lskip ', lskip, mypos mypos = mypos + INT4_BITS - call g2_sbytec1(cindex, loclus, mypos, INT4_BITS) ! location of local use - !print '(i3, a8, i4)', mypos/8, ' loclus ', loclus + call g2_sbytec1(cindex, int(loclus8, kind(4)), mypos, INT4_BITS) ! location of local use mypos = mypos + INT4_BITS - call g2_sbytec1(cindex, locgds, mypos, INT4_BITS) ! location of gds - !print '(i3, a8, i4)', mypos/8, ' locgds ', locgds + call g2_sbytec1(cindex, int(locgds8, kind(4)), mypos, INT4_BITS) ! location of gds mypos = mypos + INT4_BITS call g2_sbytec1(cindex, int(ibskip8 - lskip8, kind(4)), mypos, INT4_BITS) ! location of pds #ifdef LOGGING @@ -1470,21 +1464,16 @@ end subroutine g2_sbytec1 ' loc ', int(ibskip8 - lskip8, kind(4)) call g2_log(4) #endif - !print '(i3, a8, i4)', mypos/8, ' locpds ', int(ibskip8 - lskip8, kind(4)) mypos = mypos + INT4_BITS * 4 ! skip ahead in cbuf else inc = 28 call g2_sbytec81(cindex, lskip8, mypos, INT8_BITS) ! bytes to skip - !print '(i3, a7, i4)', mypos/8, ' lskip ', lskip mypos = mypos + INT8_BITS call g2_sbytec81(cindex, loclus8, mypos, INT8_BITS) ! location of local use - !print '(i3, a8, i4)', mypos/8, ' loclus ', loclus mypos = mypos + INT8_BITS call g2_sbytec81(cindex, locgds8, mypos, INT8_BITS) ! location of gds - !print '(i3, a8, i4)', mypos/8, ' locgds ', locgds mypos = mypos + INT8_BITS call g2_sbytec81(cindex, ibskip8 - lskip8, mypos, INT8_BITS) ! location of pds - !print '(i3, a8, i4)', mypos/8, ' locpds ', int(ibskip8 - lskip8, kind(4)) mypos = mypos + INT8_BITS * 4 ! skip ahead in cbuf endif @@ -1495,34 +1484,21 @@ end subroutine g2_sbytec1 ! These ints are the same size in index version 1 and 2. The ! mypos variable contains the proper offset, which is call g2_sbytec81(cindex, lgrib8, mypos, INT8_BITS) ! length of grib2 - !print '(i3, a8, i4)', mypos/8, ' lgrib8 ', lgrib8 mypos = mypos + INT8_BITS cindex((mypos / 8) + 1) = cver - !print '(i3, a6, z1)', mypos/8, ' cver ', cver mypos = mypos + INT1_BITS cindex((mypos / 8) + 1) = cdisc - !print '(i3, a7, z2)', mypos/8, ' cdisc ', cdisc mypos = mypos + INT1_BITS call g2_sbytec1(cindex, numfld + 1, mypos, INT2_BITS) ! field num - !print '(i3, a8, i4)', mypos/8, ' numfld ', numfld + 1 mypos = mypos + INT2_BITS ! Copy the section 1 values into the cindex buffer. cindex(IXIDS + 1 + inc:IXIDS + lensec1 + inc) = cids(1:lensec1) lindex = IXIDS + lensec1 + inc - ! print *, 'section 1:', IXIDS + inc, IXIDS + lensec1 + inc - ! do i=1, lensec1 - ! print *, i, ichar(cids(i)) - ! end do ! Copy the GDS values into the cindex buffer. cindex(lindex + 1:lindex + lengds8) = cgds(1:lengds8) - !print *, 'gds:', lindex, lindex + lengds8 lindex = lindex + int(lengds8, kind(lindex)) - ! print *, 'gds:', lindex, lengds8 - ! do i=1, lengds8 - ! print *, i, ichar(cgds(i)) - ! end do ! Now read the PDS values from the file directly into cindex. ilnpds = lensec @@ -1532,7 +1508,6 @@ end subroutine g2_sbytec1 iret = 2 return endif - !print *, 'pds:', lindex, lindex + ilnpds lindex = lindex + ilnpds mypos = mypos + ilnpds #ifdef LOGGING @@ -1552,7 +1527,6 @@ end subroutine g2_sbytec1 else call g2_sbytec81(cindex, ibskip8 - lskip8, IXDRS2 * INT1_BITS, INT8_BITS) ! location of drs endif - !print '(i3, a8, i5)', mypos/8, ' locdrs ', int(ibskip8 - lskip8, kind(4)) ! Read the DRS section directly into the cindex buffer. ilndrs = lensec @@ -1562,7 +1536,6 @@ end subroutine g2_sbytec1 iret = 2 return endif - !print *, 'drs:', lindex, lindex + ilndrs lindex = lindex + ilndrs elseif (numsec .eq. 6) then ! Write the location of the BMS section in the message into @@ -1601,16 +1574,11 @@ end subroutine g2_sbytec1 ! Copy 6 bytes of the BMS from data buffer to the cindex buffer. cindex(lindex + 1:lindex + MXBMS) = cbread(1:MXBMS) - ! print *, 'bms:', lindex, lindex + MXBMS - ! do i=1, MXBMS - ! print *, i, ichar(cindex(lindex + i)) - ! end do lindex = lindex + MXBMS ! The size of the index record is now known, so write it to ! the cindex buffer. call g2_sbytec1(cindex, lindex, 0, INT4_BITS) ! num bytes in index record - !print '(i3, a8, i5)', 0, ' lindex ', lindex elseif (numsec .eq. 7) then ! found data section #ifdef LOGGING From af23d056f33a80b873eab66961f4ba33ac56d831 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Fri, 24 May 2024 05:04:06 -0600 Subject: [PATCH 2/4] some 8-byte changes --- src/g2index.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g2index.F90 b/src/g2index.F90 index 086b899c..af124fef 100644 --- a/src/g2index.F90 +++ b/src/g2index.F90 @@ -1268,7 +1268,7 @@ subroutine ix2gb2(lugb, lskip8, idxver, lgrib8, cbuf, numfld, mlen, iret) character cver, cdisc character(len = 4) :: ctemp integer (kind = 8) :: loclus8, locgds8, locbms8 - integer loclus, locbms + integer locbms integer :: indbmp, numsec, newsize, g2_mova2i, mbuf, lindex integer :: lskip integer :: ilndrs, ilnpds, istat From e9d58dfa71da6f932f3b82d555a90f2c4a1aa7f3 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Fri, 24 May 2024 05:10:48 -0600 Subject: [PATCH 3/4] some 8-byte changes --- src/g2getgb2.F90 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/g2getgb2.F90 b/src/g2getgb2.F90 index 004ff41b..bb9d190d 100644 --- a/src/g2getgb2.F90 +++ b/src/g2getgb2.F90 @@ -868,7 +868,7 @@ subroutine getgb2r2(lugb, idxver, cindex, gfld, iret) character(len=1):: csize(4) character(len=1), allocatable :: ctemp(:) real, pointer, dimension(:) :: newfld - integer :: n, j, iskip, iofst, ilen, ierr, idum + integer :: n, j, iofst, ilen, ierr, idum integer (kind = 8) :: lskip8, lread8, ilen8, iskip8 ! Bytes to skip in (version 1 and 2) index record to get to bms. integer :: IXBMS1, IXBMS2 @@ -944,11 +944,10 @@ end subroutine g2_gbytec81 skip68 = skip6 else call g2_gbytec81(cindex, skip68, IXBMS2 * INT1_BITS, INT8_BITS) - skip6 = int(skip68, kind(4)) endif #ifdef LOGGING - write(g2_log_msg, *) ' getgb2r2: skip6', skip6 + write(g2_log_msg, *) ' getgb2r2: skip68', skip68 call g2_log(1) #endif @@ -967,8 +966,7 @@ end subroutine g2_gbytec81 ! Read and unpack bit_map, if present. if (gfld%ibmap .eq. 0 .or. gfld%ibmap .eq. 254) then - iskip = lskip + skip6 - iskip8 = lskip8 + skip6 + iskip8 = lskip8 + skip68 ! Get length of bitmap section. call bareadl(lugb, iskip8, 4_8, lread8, csize) @@ -996,7 +994,6 @@ end subroutine g2_gbytec81 endif ! Read and unpack data field. - iskip = lskip + skip7 iskip8 = lskip8 + skip7 ! Get length of data section. @@ -1216,7 +1213,6 @@ end subroutine g2_gbytec81 inc = 28 call g2_gbytec81(cindex, iskip8, mypos, INT8_BITS) ! bytes to skip in file mypos = mypos + INT8_BITS - iskip = int(iskip8, kind(4)) call g2_gbytec81(cindex, iskp2_8, mypos, INT8_BITS) ! bytes to skip for section 2 mypos = mypos + INT8_BITS From 06169f0de023739c9909dac9fa735fbca5e92fe8 Mon Sep 17 00:00:00 2001 From: Edward Hartnett Date: Fri, 24 May 2024 05:12:12 -0600 Subject: [PATCH 4/4] some 8-byte changes --- src/g2getgb2.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g2getgb2.F90 b/src/g2getgb2.F90 index bb9d190d..08de8907 100644 --- a/src/g2getgb2.F90 +++ b/src/g2getgb2.F90 @@ -1282,23 +1282,23 @@ end subroutine g2_gbytec81 ! Read the location of section 7 from the index. if (idxver .eq. 1) then call g2_gbytec1(cindex, iskp7, IXDS1 * INT1_BITS, INT4_BITS) ! bytes to skip for section 7 + iskp78 = iskp7 else call g2_gbytec81(cindex, iskp78, IXDS2 * INT1_BITS, INT8_BITS) ! bytes to skip for section 7 - iskp7 = int(iskp78, kind(4)) endif #ifdef LOGGING - write(g2_log_msg, *) 'getgb2rp2: iskp7', iskp7, 'IXDS2', IXDS2 + write(g2_log_msg, *) 'getgb2rp2: iskp78', iskp78, 'IXDS2', IXDS2 call g2_log(2) #endif ! Read in the length of section 7 from the data file. - call bareadl(lugb, iskip8 + iskp7, 4_8, lread8, ctemp) + call bareadl(lugb, iskip8 + iskp78, 4_8, lread8, ctemp) call g2_gbytec1(ctemp, len7, 0, INT4_BITS) ! length of section 7 ! Now read in section 7. allocate(csec7(len7)) len7_8 = len7 - call bareadl(lugb, iskip8 + iskp7, len7_8, lread8, csec7) + call bareadl(lugb, iskip8 + iskp78, len7_8, lread8, csec7) #ifdef LOGGING write(g2_log_msg, *) 'getgb2rp2: len0 ', len0, 'len1', len1, 'len2', len2 , 'len3', len3