Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converted tocgrib2super to user getgb2p2() #338

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/tocgrib2super/tocgrib2super.F90
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,25 @@ PROGRAM tocgrib2super
character(len=1),pointer,dimension(:) :: gribm

logical :: extract=.false.
integer idxver
integer (kind = 8) :: itot8

interface
SUBROUTINE GETGB2P(LUGB,LUGI,J,JDISC,JIDS,JPDTN,JPDT,JGDTN,JGDT, &
EXTRACT,K,GRIBM,LENG,IRET)
INTEGER,INTENT(IN) :: LUGB,LUGI,J,JDISC,JPDTN,JGDTN
INTEGER,DIMENSION(:) :: JIDS(*),JPDT(*),JGDT(*)
LOGICAL,INTENT(IN) :: EXTRACT
INTEGER,INTENT(OUT) :: K,IRET
CHARACTER(LEN=1),POINTER,DIMENSION(:) :: GRIBM
END SUBROUTINE GETGB2P
subroutine getgb2p2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
extract, idxver, k, gribm, leng8, iret)
integer, intent(in) :: lugb, lugi, j, jdisc
integer, dimension(:) :: jids(*)
integer, intent(in) :: jpdtn
integer, dimension(:) :: jpdt(*)
integer, intent(in) :: jgdtn
integer, dimension(:) :: jgdt(*)
logical, intent(in) :: extract
integer, intent(inout) :: idxver
integer, intent(out) :: k
character(len = 1), pointer, dimension(:) :: gribm
integer (kind = 8), intent(out) :: leng8
integer, intent(out) :: iret
end subroutine getgb2p2
end interface

NAMELIST /GRIBIDS/DSCPL,IDS,GDTN,GDT,PDTN,PDT,DESC,WMOHEAD,EXTRACT
Expand Down Expand Up @@ -223,8 +232,9 @@ END SUBROUTINE GETGB2P
!
! Read and return packed GRIB field
!
CALL GETGB2P(lugb,lugi,jrew,DSCPL,IDS,PDTN,PDT, &
GDTN,GDT,extract,KREW,gribm,itot,iret)
CALL GETGB2P2(lugb,lugi,jrew,DSCPL,IDS,PDTN,PDT, &
GDTN,GDT,extract,idxver,KREW,gribm,itot8,iret)
itot = int(itot8, kind(4))
IF (IRET.NE.0) THEN
IF (IRET.EQ.96)WRITE(6,'(A)')' GETGB2P: ERROR READING INDEX' &
//' FILE'
Expand Down
7 changes: 5 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ if(FTP_TEST_FILES)
# gu_copy_test_data(ref_rrfs.t12z.prslevfaa.f010.na3km.grib2.degrib2)
gu_copy_test_data(ref_GFSPRS.GrbF06.degrib2)
gu_copy_test_data(ref_rrfs.t18z.prslev.f000.grib2.degrib2)
gu_copy_test_data(ref_grib2.awips.rrfs.010)
# gu_copy_test_data(ref_grib2.awips.rrfs.010)
endif()
endif()

Expand All @@ -111,6 +111,8 @@ gu_test(run_copygb2_tests2)
gu_test(run_degrib2_tests)
gu_test(run_grbindex_tests)
gu_test(run_grb2index_tests)
gu_test(run_tocgrib2_tests)
gu_test(run_tocgrib2super_tests)

if(G2C_COMPARE)
find_program(G2C_COMPARE g2c_compare)
Expand Down Expand Up @@ -175,6 +177,7 @@ if(FTP_TEST_FILES)
endif()
if(FTP_EXTRA_TEST_FILES)
gu_test(run_degrib2_extra_file_tests)
gu_test(run_tocgrib2_tests)
gu_test(run_tocgrib2_extra_file_tests)
gu_test(run_tocgrib2super_extra_file_tests)
endif()
endif()
22 changes: 22 additions & 0 deletions tests/run_tocgrib2_extra_files_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
# This is a test script for the NCEPLIBS-grib_util project. This tests
# the tocgrib2 utility.
#
# Ed Hartnett, 4/20/24

set -e
echo ""
echo "*** Running tocgrib2 extra file tests"

echo "*** Running tocgrib2 with input/output defined, but one missing field. It will fail."
export FORT11="data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
export FORT51=out.grib2
../src/tocgrib2/tocgrib2 < data/tocgrib2_bad.nml && exit 1

echo "*** Running tocgrib2 with input/output defined. It will succeed."
export FORT11="data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
export FORT51=out.grib2
../src/tocgrib2/tocgrib2 < data/tocgrib2.nml

echo "*** SUCCESS!"
exit 0
24 changes: 12 additions & 12 deletions tests/run_tocgrib2_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ set -e
echo ""
echo "*** Running tocgrib2 tests"

# echo "*** Running tocgrib2 without input/output defined. Should return STOP 10"
# unset FORT11
# unset FORT51
# ../src/tocgrib2/tocgrib2 && exit 1
echo "*** Running tocgrib2 without input/output defined. Should return STOP 10"
unset FORT11
unset FORT51
../src/tocgrib2/tocgrib2 && exit 1

echo "*** Running tocgrib2 with input/output defined, but one missing field. It will fail."
export FORT11="data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
export FORT51=out.grib2
../src/tocgrib2/tocgrib2 < data/tocgrib2_bad.nml && exit 1
#echo "*** Running tocgrib2 with input/output defined, but one missing field. It will fail."
# export FORT11="data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
# export FORT51=out.grib2
# ../src/tocgrib2/tocgrib2 < data/tocgrib2_bad.nml && exit 1

echo "*** Running tocgrib2 with input/output defined. It will succeed."
export FORT11="data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
export FORT51=out.grib2
../src/tocgrib2/tocgrib2 < data/tocgrib2.nml
# echo "*** Running tocgrib2 with input/output defined. It will succeed."
# export FORT11="data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
# export FORT51=out.grib2
# ../src/tocgrib2/tocgrib2 < data/tocgrib2.nml

echo "*** SUCCESS!"
exit 0
22 changes: 22 additions & 0 deletions tests/run_tocgrib2super_extra_files_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
# This is a test script for the NCEPLIBS-grib_util project. This tests
# the tocgrib2super utility with extra files downloaded from FTP.
#
# Ed Hartnett, 5/28/24

set -e
echo ""
echo "*** Running tocgrib2super extra tests"

echo "*** Running tocgrib2super with input/output defined, but one missing field. It will fail."
export FORT11="data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
export FORT51=out.grib2
../src/tocgrib2super/tocgrib2super < data/tocgrib2_bad.nml && exit 1

echo "*** Running tocgrib2 with input/output defined. It will succeed."
export FORT11="data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
export FORT51=out.grib2
../src/tocgrib2super/tocgrib2super < data/tocgrib2.nml

echo "*** SUCCESS!"
exit 0
27 changes: 27 additions & 0 deletions tests/run_tocgrib2super_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
# This is a test script for the NCEPLIBS-grib_util project. This tests
# the tocgrib2super utility.
#
# Ed Hartnett, 5/28/24

set -e
echo ""
echo "*** Running tocgrib2super tests"

echo "*** Running tocgrib2 without input/output defined. Should return STOP 10"
unset FORT11
unset FORT51
../src/tocgrib2super/tocgrib2super && exit 1

# echo "*** Running tocgrib2super with input/output defined, but one missing field. It will fail."
# export FORT11="data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
# export FORT51=out.grib2
# ../src/tocgrib2super/tocgrib2super < data/tocgrib2_bad.nml && exit 1

# echo "*** Running tocgrib2 with input/output defined. It will succeed."
# export FORT11="data/rrfs.t12z.prslevfaa.f010.na3km.grib2"
# export FORT51=out.grib2
# ../src/tocgrib2super/tocgrib2super < data/tocgrib2.nml

echo "*** SUCCESS!"
exit 0
Loading