diff --git a/reg_tests/chgres_cube/c96.gefs.grib2.sh b/reg_tests/chgres_cube/c96.gefs.grib2.sh new file mode 100755 index 000000000..3b2823252 --- /dev/null +++ b/reg_tests/chgres_cube/c96.gefs.grib2.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +#----------------------------------------------------------------------------- +# Invoke chgres to create C96 coldstart files using GEFS GRIB2 data +# as input. The coldstart files are then compared to baseline files +# using the 'nccmp' utility. This script is run by the machine specific +# driver script. +#----------------------------------------------------------------------------- + +set -x + +export DATA=$OUTDIR/c96_gefs_grib2 +rm -fr $DATA + +export CRES=96 +export FIXfv3=${HOMEreg}/fix/C96 +export COMIN=${HOMEreg}/input_data/gefs.grib2 + +export GRIB2_FILE_INPUT=gec00.t06z.pgrb2abf00 +export VCOORD_FILE=${HOMEufs}/fix/fix_am/global_hyblev.l65.txt +export VARMAP_FILE=${HOMEufs}/parm/varmap_tables/GFSphys_var_map.txt +export INPUT_TYPE='grib2' +export CONVERT_NST=".false." +export TRACERS_TARGET='"sphum","liq_wat","o3mr"' +export TRACERS_INPUT='"spfh","clwmr","o3mr"' + +export CDATE=2020082506 + +export OMP_NUM_THREADS_CH=${OMP_NUM_THREADS:-1} + +NCCMP=${NCCMP:-$(which nccmp)} + +#----------------------------------------------------------------------------- +# Invoke chgres program. +#----------------------------------------------------------------------------- + +echo "Starting at: " `date` + +${HOMEufs}/ush/chgres_cube.sh + +iret=$? +if [ $iret -ne 0 ]; then + set +x + echo "<<< C96 GEFS GRIB2 TEST FAILED. <<<" + exit $iret +fi + +echo "Ending at: " `date` + +#----------------------------------------------------------------------------- +# Compare output from chgres to baseline set of data. +#----------------------------------------------------------------------------- + +cd $DATA + +test_failed=0 +for files in *.nc +do + if [ -f $files ]; then + echo CHECK $files + $NCCMP -dmfqS $files $HOMEreg/baseline_data/c96_gefs_grib2/$files + iret=$? + if [ $iret -ne 0 ]; then + test_failed=1 + fi + fi +done + +set +x +if [ $test_failed -ne 0 ]; then + echo "<<< C96 GEFS GRIB2 TEST FAILED. >>>" + if [ "$UPDATE_BASELINE" = "TRUE" ]; then + $HOMEufs/reg_tests/update_baseline.sh $HOMEreg "c96_gefs_grib2" $commit_num + fi +else + echo "<<< C96 GEFS GRIB2 TEST PASSED. >>>" +fi + +exit 0 diff --git a/reg_tests/chgres_cube/driver.hera.sh b/reg_tests/chgres_cube/driver.hera.sh index d95cbadf9..d7a42a80a 100755 --- a/reg_tests/chgres_cube/driver.hera.sh +++ b/reg_tests/chgres_cube/driver.hera.sh @@ -209,13 +209,22 @@ export OMP_NUM_THREADS=1 # should match cpus-per-task TEST16=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.pbgrib2.conus \ -o $LOG_FILE -e $LOG_FILE ./25km.conus.gfs.pbgrib2.sh) +#----------------------------------------------------------------------------- +# Initialize global C96 using GEFS GRIB2 files. +#----------------------------------------------------------------------------- + +LOG_FILE=consistency.log17 +export OMP_NUM_THREADS=1 # should match cpus-per-task +TEST17=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ + -o $LOG_FILE -e $LOG_FILE ./c96.gefs.grib2.sh) + #----------------------------------------------------------------------------- # Create summary log. #----------------------------------------------------------------------------- LOG_FILE=consistency.log sbatch --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J chgres_summary -o $LOG_FILE -e $LOG_FILE \ --open-mode=append -q $QUEUE -d\ - afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16 << EOF + afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16:$TEST17 << EOF #!/bin/bash grep -a '<<<' $LOG_FILE* > $SUM_FILE EOF diff --git a/reg_tests/chgres_cube/driver.jet.sh b/reg_tests/chgres_cube/driver.jet.sh index 4b7a29786..813f13cfe 100755 --- a/reg_tests/chgres_cube/driver.jet.sh +++ b/reg_tests/chgres_cube/driver.jet.sh @@ -210,6 +210,15 @@ export OMP_NUM_THREADS=1 # should match cpus-per-task TEST16=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=1 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.pbgrib2.conus \ --exclusive -o $LOG_FILE -e $LOG_FILE ./25km.conus.gfs.pbgrib2.sh) +#----------------------------------------------------------------------------- +# Initialize C96 using GEFS GRIB2 data. +#----------------------------------------------------------------------------- + +LOG_FILE=consistency.log17 +export OMP_NUM_THREADS=1 +TEST17=$(sbatch --parsable --partition=xjet --nodes=1 --ntasks-per-node=6 -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ + --exclusive -o $LOG_FILE -e $LOG_FILE ./c96.gefs.grib2.sh) + #----------------------------------------------------------------------------- # Create summary log. #----------------------------------------------------------------------------- @@ -217,7 +226,7 @@ TEST16=$(sbatch --parsable --partition=xjet --ntasks-per-node=6 --nodes=1 -t 0:0 LOG_FILE=consistency.log sbatch --partition=xjet --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J chgres_summary -o $LOG_FILE -e $LOG_FILE \ --open-mode=append -q $QUEUE -d\ - afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16 << EOF + afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16:$TEST17 << EOF #!/bin/bash grep -a '<<<' $LOG_FILE* > $SUM_FILE EOF diff --git a/reg_tests/chgres_cube/driver.orion.sh b/reg_tests/chgres_cube/driver.orion.sh index bfa1c543c..66de8b85b 100755 --- a/reg_tests/chgres_cube/driver.orion.sh +++ b/reg_tests/chgres_cube/driver.orion.sh @@ -213,13 +213,22 @@ export OMP_NUM_THREADS=1 # should match cpus-per-task TEST16=$(sbatch --parsable --ntasks-per-node=12 --nodes=1 --mem=75G -t 0:10:00 -A $PROJECT_CODE -q $QUEUE -J 25km.conus.gfs.pbgrib2 \ --open-mode=append -o $LOG_FILE16 -e $LOG_FILE16 ./25km.conus.gfs.pbgrib2.sh) +#----------------------------------------------------------------------------- +# Initialize C96 using GEFS GRIB2 file. +#----------------------------------------------------------------------------- + +LOG_FILE17=${LOG_FILE}17 +export OMP_NUM_THREADS=1 # needs to match cpus-per-task +TEST17=$(sbatch --parsable --ntasks-per-node=6 --nodes=1 --mem=75G -t 0:05:00 -A $PROJECT_CODE -q $QUEUE -J c96.gefs.grib2 \ + --open-mode=append -o $LOG_FILE17 -e $LOG_FILE17 ./c96.gefs.grib2.sh) + #----------------------------------------------------------------------------- # Create summary log. #----------------------------------------------------------------------------- sbatch --nodes=1 -t 0:01:00 -A $PROJECT_CODE -J chgres_summary -o $LOG_FILE -e $LOG_FILE \ --open-mode=append -q $QUEUE \ - -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16 << EOF + -d afterok:$TEST1:$TEST2:$TEST3:$TEST4:$TEST5:$TEST6:$TEST7:$TEST8:$TEST9:$TEST10:$TEST11:$TEST12:$TEST13:$TEST14:$TEST15:$TEST16:$TEST17 << EOF #!/bin/bash grep -a '<<<' ${LOG_FILE}* > $SUM_FILE EOF diff --git a/sorc/chgres_cube.fd/input_data.F90 b/sorc/chgres_cube.fd/input_data.F90 index ed7f60cd0..193d295de 100644 --- a/sorc/chgres_cube.fd/input_data.F90 +++ b/sorc/chgres_cube.fd/input_data.F90 @@ -2476,14 +2476,14 @@ subroutine read_input_atm_grib2_file(localpet) integer :: i, j, k, n integer :: ii,jj integer :: rc, clb(3), cub(3) - integer :: vlev, iret,varnum, o3n + integer :: vlev, iret,varnum, o3n, pdt_num integer :: intrp_ier, done_print integer :: trac_names_oct10(ntrac_max) integer :: tracers_input_oct10(num_tracers_input) integer :: trac_names_oct11(ntrac_max) integer :: tracers_input_oct11(num_tracers_input) integer :: lugb, lugi, jdisc, jpdt(200), jgdt(200), iscale - integer :: jids(200), jpdtn, jgdtn, octet23, octet29 + integer :: jids(200), jpdtn, jgdtn, octet_23, octet_29 integer :: count_spfh, count_rh, count_icmr, count_scliwc integer :: count_cice, count_rwmr, count_scllwc, count @@ -2545,28 +2545,61 @@ subroutine read_input_atm_grib2_file(localpet) jids = -9999 ! Array of values in identification section, set to wildcard jgdt = -9999 ! Array of values in grid definition template, set to wildcard jgdtn = -1 ! Search for any grid definition number. - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = -1 ! Search for any product definition template number. + unpack =.false. + call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, & + unpack, k, gfld, iret) + +!---------------------------------------------------------------------- +! Read first record and check if this is NCEP GEFS data. +! This will determine what product definition template number to +! search for (Section 4/Octets 8-9). +! +! Section 1/Octets 6-7 is '7' (NCEP) +! Section 1/Octets 8-9 is '2' (NCEP Ensemble products). +!---------------------------------------------------------------------- + + if (iret == 0) then + if (gfld%idsect(1) == 7 .and. gfld%idsect(2) == 2) then + print*,'- THIS IS NCEP GEFS DATA.' + pdt_num = 1 ! Search for product definition template number 1. + ! Individual ensember forecast. + else + pdt_num = 0 ! Search for product definition template number 0. + ! Analysis or forecast. + endif + else + call error_handler("READING GRIB2 FILE", iret) + endif + +!---------------------------------------------------------------------- ! First, check for the vertical coordinate. If temperture at the 10 hybrid ! level is found, hybrid coordinates are assumed. Otherwise, data is on ! isobaric levels. +!---------------------------------------------------------------------- - jpdt(1) = 0 ! Sect4/oct 10 - param category - temperature field - jpdt(2) = 0 ! Sect4/oct 11 - param number - temperature - jpdt(10) = 105 ! Sect4/oct 23 - type of level - hybrid - jpdt(12) = 10 ! oct 23 - type of level - value of hybrid level + j = 0 + jpdtn = pdt_num ! Search for the specific product definition template number. + jpdt(1) = 0 ! Sect4/oct 10 - Parameter category - temperature field + jpdt(2) = 0 ! Sect4/oct 11 - Parameter number - temperature + jpdt(10) = 105 ! Sect4/oct 23 - Type of level - hybrid + jpdt(12) = 10 ! Sect4/octs 25/28 - Value of hybrid level unpack=.false. call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, & unpack, k, gfld, iret) - if (iret == 0) then ! data is on hybrid levels - octet23 = 105 - octet29 = 255 + if (iret == 0) then + print*,'- DATA IS ON HYBRID LEVELS.' + octet_23 = 105 ! Section 4/Oct 23 - type of first fixed surface. + octet_29 = 255 ! Section 4/Oct 29 - type of second fixed surface (N/A). isnative=.true. - else ! data is on isobaric levels - octet23 = 100 - octet29 = 255 + else + print*,'- DATA IS ON ISOBARIC LEVELS.' + octet_23 = 100 ! Section 4/Oct 23 - type of first fixed surface. + octet_29 = 255 ! Section 4/Oct 29 - type of second fixed surface (N/A). + isnative=.false. endif ! Now count the number of vertical levels by searching for u-wind. @@ -2576,6 +2609,7 @@ subroutine read_input_atm_grib2_file(localpet) lev_input = 0 iret = 0 j = 0 + jpdtn = -1 jpdt = -9999 do @@ -2585,11 +2619,10 @@ subroutine read_input_atm_grib2_file(localpet) if (iret /= 0) exit if (gfld%discipline == 0) then ! Discipline - meteorological products - if (gfld%ipdtnum == 0) then ! Product definition template number - - ! analysis or forecast at single level. + if (gfld%ipdtnum == pdt_num) then ! Product definition template number. if (gfld%ipdtmpl(1) == 2 .and. gfld%ipdtmpl(2) == 2) then ! u-wind ! Sect4/octs 10 and 11. - if (gfld%ipdtmpl(10) == octet23 .and. gfld%ipdtmpl(13) == octet29) then + if (gfld%ipdtmpl(10) == octet_23 .and. gfld%ipdtmpl(13) == octet_29) then ! Sect4 octs 23 and 29. ! Hybrid or isobaric. lev_input = lev_input + 1 @@ -2603,11 +2636,12 @@ subroutine read_input_atm_grib2_file(localpet) j = k enddo - endif + endif ! read file on task 0. call mpi_barrier(MPI_COMM_WORLD, iret) call MPI_BCAST(isnative,1,MPI_LOGICAL,0,MPI_COMM_WORLD,iret) call MPI_BCAST(lev_input,1,MPI_INTEGER,0,MPI_COMM_WORLD,iret) + call MPI_BCAST(pdt_num,1,MPI_INTEGER,0,MPI_COMM_WORLD,iret) call MPI_BCAST(rlevs_hold, max_levs, MPI_INTEGER,0,MPI_COMM_WORLD,iret) allocate(slevs(lev_input)) @@ -2645,14 +2679,11 @@ subroutine read_input_atm_grib2_file(localpet) if (localpet == 0) then + jpdtn = pdt_num ! Product definition template number. jpdt = -9999 - jpdt(1) = 1 ! Sect4/oct 10 - param category - moisture - jpdt(2) = 0 ! Sect4/oct 11 - param number - specific humidity - if (isnative) then - jpdt(10) = 105 ! Sect4/oct 23 - type of level - hybrid - else - jpdt(10) = 100 ! Sect4/oct 23 - type of level - isobaric - endif + jpdt(1) = 1 ! Sect4/oct 10 - Parameter category - moisture + jpdt(2) = 0 ! Sect4/oct 11 - Parameter number - specific humidity + jpdt(10) = octet_23 ! Sect4/oct 23 - type of level. unpack=.false. count_spfh=0 @@ -2667,11 +2698,10 @@ subroutine read_input_atm_grib2_file(localpet) if (iret == 0) then count_spfh = count_spfh + 1 endif - enddo - jpdt(1) = 1 ! Sec4/oct 10 - param category - moisture - jpdt(2) = 1 ! Sec4/oct 11 - param number - rel humidity + jpdt(1) = 1 ! Sec4/oct 10 - Parameter category - moisture + jpdt(2) = 1 ! Sec4/oct 11 - Parameter number - rel humidity count_rh=0 do vlev = 1, lev_input @@ -2711,12 +2741,9 @@ subroutine read_input_atm_grib2_file(localpet) if (localpet == 0) then + jpdtn = pdt_num ! Product definition template number. jpdt = -9999 - if (isnative) then - jpdt(10) = 105 ! Sect4/oct 23 - type of level - hybrid - else - jpdt(10) = 100 ! Sect4/oct 23 - type of level - isobaric - endif + jpdt(10) = octet_23 ! Sect4/oct 23 - type of level. unpack=.false. count_icmr=0 @@ -2728,8 +2755,8 @@ subroutine read_input_atm_grib2_file(localpet) do vlev = 1, lev_input j = 0 - jpdt(1) = 1 ! Sect4/oct 10 - param category - moisture - jpdt(2) = 23 ! Sect4/oct 11 - param number - ice water mixing ratio + jpdt(1) = 1 ! Sect4/oct 10 - Parameter category - moisture + jpdt(2) = 23 ! Sect4/oct 11 - Parameter number - ice water mixing ratio jpdt(12) = nint(rlevs(vlev)) call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, & @@ -2740,8 +2767,8 @@ subroutine read_input_atm_grib2_file(localpet) endif j = 0 - jpdt(1) = 1 ! Sect4/oct 10 - param category - moisture - jpdt(2) = 84 ! Sect4/oct 11 - param number - cloud ice water content. + jpdt(1) = 1 ! Sect4/oct 10 - Parameter category - moisture + jpdt(2) = 84 ! Sect4/oct 11 - Parameter number - cloud ice water content. call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, & unpack, k, gfld, iret) @@ -2750,8 +2777,8 @@ subroutine read_input_atm_grib2_file(localpet) endif j = 0 - jpdt(1) = 6 ! Sect4/oct 10 - param category - clouds - jpdt(2) = 0 ! Sect4/oct 11 - param number - cloud ice + jpdt(1) = 6 ! Sect4/oct 10 - Parameter category - clouds + jpdt(2) = 0 ! Sect4/oct 11 - Parameter number - cloud ice call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, & unpack, k, gfld, iret) @@ -2760,8 +2787,8 @@ subroutine read_input_atm_grib2_file(localpet) endif j = 0 - jpdt(1) = 1 ! Sect4/oct 10 - param category - moisture - jpdt(2) = 24 ! Sect4/oct 11 - param number - rain mixing ratio + jpdt(1) = 1 ! Sect4/oct 10 - Parameter category - moisture + jpdt(2) = 24 ! Sect4/oct 11 - Parameter number - rain mixing ratio call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, & unpack, k, gfld, iret) @@ -2770,9 +2797,9 @@ subroutine read_input_atm_grib2_file(localpet) endif j = 0 - jpdt(1) = 1 ! Sect4/oct 10 - param category - moisture - jpdt(2) = 83 ! Sect4/oct 11 - param number - specific cloud liquid - ! water content. + jpdt(1) = 1 ! Sect4/oct 10 - Parameter category - moisture + jpdt(2) = 83 ! Sect4/oct 11 - Parameter number - specific cloud liquid + ! water content. call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, & unpack, k, gfld, iret) @@ -2787,13 +2814,13 @@ subroutine read_input_atm_grib2_file(localpet) if (count_cice == 0) then print*,'- FILE DOES NOT CONTAIN CICE.' else - trac_names_oct10(4) = 6 ! Sect4/oct 10 - param category - clouds - trac_names_oct11(4) = 0 ! Sect4/oct 11 - param number - cloud ice + trac_names_oct10(4) = 6 ! Sect4/oct 10 - Parameter category - clouds + trac_names_oct11(4) = 0 ! Sect4/oct 11 - Parameter number - cloud ice print*,"- FILE CONTAINS CICE." endif else - trac_names_oct10(4) = 1 ! Sect4/oct 10 - param category - moisture - trac_names_oct11(4) = 84 ! Sect4/oct 11 - param number - cloud ice water content. + trac_names_oct10(4) = 1 ! Sect4/oct 10 - Parameter category - moisture + trac_names_oct11(4) = 84 ! Sect4/oct 11 - Parameter number - cloud ice water content. print*,"- FILE CONTAINS SCLIWC." endif else @@ -2804,8 +2831,8 @@ subroutine read_input_atm_grib2_file(localpet) if (count_scllwc == 0) then print*,"- FILE DOES NOT CONTAIN SCLLWC." else - trac_names_oct10(4) = 1 ! Sect4/oct 10 - param category - moisture - trac_names_oct11(4) = 83 ! Sect4/oct 11 - param number - specific cloud liquid + trac_names_oct10(4) = 1 ! Sect4/oct 10 - Parameter category - moisture + trac_names_oct11(4) = 83 ! Sect4/oct 11 - Parameter number - specific cloud liquid ! water content. print*,"- FILE CONTAINS SCLLWC." endif @@ -2869,15 +2896,10 @@ subroutine read_input_atm_grib2_file(localpet) jids = -9999 ! array of values in identification section, set to wildcard jgdt = -9999 ! array of values in grid definition template, set to wildcard jgdtn = -1 ! search for any grid definition number. - jpdtn = 0 ! search for product def template number 0 - anl or fcst. - jpdt(1) = 0 ! Sect 4/oct 10 - param category - temperature - jpdt(2) = 0 ! Sect 4/oct 11 - param number - temperature - - if (isnative) then - jpdt(10) = 105 ! Sect 4/oct 23 - type of level - hybrid - else - jpdt(10) = 100 ! Sect 4/oct 23 - type of level - isobaric - endif + jpdtn = pdt_num ! Search for specific product definition template number. + jpdt(1) = 0 ! Sect 4/oct 10 - parameter category - temperature + jpdt(2) = 0 ! Sect 4/oct 11 - parameter number - temperature + jpdt(10) = octet_23 ! Sect4/oct 23 - type of level. unpack=.true. @@ -2928,13 +2950,9 @@ subroutine read_input_atm_grib2_file(localpet) jids = -9999 ! array of values in identification section, set to wildcard jgdt = -9999 ! array of values in grid definition template, set to wildcard jgdtn = -1 ! search for any grid definition number. - jpdtn = 0 ! search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. + jpdt(10) = octet_23 ! Sect4/oct 23 - type of level. unpack = .false. - if (isnative) then - jpdt(10) = 105 ! Sect4/oct 23 - type of level - hybrid - else - jpdt(10) = 100 ! Sect4/oct 23 - type of level - isobaric - endif count = 0 @@ -3068,7 +3086,7 @@ subroutine read_input_atm_grib2_file(localpet) deallocate(dummy3d_col_in, dummy3d_col_out) - call read_winds(u_tmp_3d,v_tmp_3d,localpet,isnative,rlevs,lugb) + call read_winds(u_tmp_3d,v_tmp_3d,localpet,octet_23,rlevs,lugb,pdt_num) if (localpet == 0) print*,"- CALL FieldScatter FOR INPUT U-WIND." call ESMF_FieldScatter(u_input_grid, u_tmp_3d, rootpet=0, rc=rc) @@ -3089,7 +3107,7 @@ subroutine read_input_atm_grib2_file(localpet) jids = -9999 ! array of values in identification section, set to wildcard jgdt = -9999 ! array of values in grid definition template, set to wildcard jgdtn = -1 ! search for any grid definition number. - jpdtn = 0 ! search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt(1) = 3 ! Sect4/oct 10 - param category - mass jpdt(2) = 0 ! Sect4/oct 11 - param number - pressure jpdt(10) = 1 ! Sect4/oct 23 - type of level - ground surface @@ -3123,15 +3141,10 @@ subroutine read_input_atm_grib2_file(localpet) jids = -9999 ! array of values in identification section, set to wildcard jgdt = -9999 ! array of values in grid definition template, set to wildcard jgdtn = -1 ! search for any grid definition number. - jpdtn = 0 ! search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt(1) = 2 ! Sect4/oct 10 - param category - momentum jpdt(2) = 9 ! Sect4/oct 11 - param number - dzdt - - if (isnative) then - jpdt(10) = 105 ! Sect4/oct 23 - type of level - hybrid - else - jpdt(10) = 100 ! Sect4/oct 23 - type of level - isobaric - endif + jpdt(10) = octet_23 ! Sect4/oct 23 - type of level unpack=.true. @@ -3184,7 +3197,7 @@ subroutine read_input_atm_grib2_file(localpet) jids = -9999 ! array of values in identification section, set to wildcard jgdt = -9999 ! array of values in grid definition template, set to wildcard jgdtn = -1 ! search for any grid definition number. - jpdtn = 0 ! search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt(1) = 3 ! Sect4/oct 10 - param category - mass jpdt(2) = 5 ! Sect4/oct 11 - param number - geopotential height jpdt(10) = 1 ! Sect4/oct 23 - type of level - ground surface @@ -3304,10 +3317,10 @@ subroutine read_input_atm_grib2_file(localpet) jids = -9999 ! array of values in identification section, set to wildcard jgdt = -9999 ! array of values in grid definition template, set to wildcard jgdtn = -1 ! search for any grid definition number. - jpdtn = 0 ! search for product def template number 0 - anl or fcst. - jpdt(1) = 3 ! Sect4/oct 10 - param category - mass - jpdt(2) = 0 ! Sect4/oct 11 - param number - pressure - jpdt(10) = 105 ! Sect4/oct 23 - type of level - hybrid + jpdtn = pdt_num ! Search for the product definition template number. + jpdt(1) = 3 ! Sect4/oct 10 - parameter category - mass + jpdt(2) = 0 ! Sect4/oct 11 - parameter number - pressure + jpdt(10) = octet_23 ! Sect4/oct 23 - type of level. unpack=.true. do vlev = 1, lev_input @@ -5017,7 +5030,7 @@ subroutine read_input_sfc_grib2_file(localpet) integer :: rc, varnum, iret, i, j,k integer :: ncid2d, varid, varsize integer :: lugb, lugi - integer :: jdisc, jgdtn, jpdtn + integer :: jdisc, jgdtn, jpdtn, pdt_num integer :: jids(200), jgdt(200), jpdt(200) logical :: rap_latlon, unpack @@ -5058,7 +5071,23 @@ subroutine read_input_sfc_grib2_file(localpet) jpdt = -9999 ! array of values in product definition template, set to wildcard unpack = .false. ! unpack data + call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, & + unpack, k, gfld, rc) + + if (rc == 0) then + if (gfld%idsect(1) == 7 .and. gfld%idsect(2) == 2) then + print*,'- THIS IS NCEP GEFS DATA.' + pdt_num = 1 + else + pdt_num = 0 + endif + else + if (rc /= 0) call error_handler("ERROR READING GRIB2 FILE.", rc) + endif + + j = 0 lsoil_input = 0 + do call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, & @@ -5067,7 +5096,7 @@ subroutine read_input_sfc_grib2_file(localpet) if (rc /= 0) exit if (gfld%discipline == 2) then ! discipline - land products - if (gfld%ipdtnum == 0) then ! prod template number - analysis or forecast at single level. + if (gfld%ipdtnum == pdt_num) then ! prod template number - analysis or forecast at single level. if (gfld%ipdtmpl(1) == 0 .and. gfld%ipdtmpl(2) == 2) then ! soil temp ! Sect4/octs 10 and 11 if (gfld%ipdtmpl(10) == 106 .and. gfld%ipdtmpl(13) == 106) then ! Sect4/octs 23/29. @@ -5155,7 +5184,7 @@ subroutine read_input_sfc_grib2_file(localpet) j = 0 jdisc = 0 ! Search for discipline 0 - meteorological products jpdt = -9999 ! array of values in product definition template, set to wildcard. - jpdtn = 0 ! search for product definition template number 0 - anl or fcst. + jpdtn = pdt_num ! search for product definition template number 0 - anl or fcst. jpdt(1) = 3 ! Sec4/oct 10 - param cat - mass field jpdt(2) = 5 ! Sec4/oct 11 - param number - geopotential height jpdt(10) = 1 ! Sec4/oct 23 - type of level - ground surface @@ -5180,7 +5209,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 10 ! Search for discipline - ocean products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for product def template number 0 - anl or fcst. jpdt = -9999 ! Array of values in Sec 4 product definition template; ! Initialize to wildcard. jpdt(1) = 2 ! Sec4/oct 10 - parameter category - ice @@ -5216,7 +5245,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 2 ! Search for discipline - land products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product definition template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for product definition template number 0 - anl or fcst. jpdt = -9999 ! Initialize array of values in product definition template - Sec 4. jpdt(1) = 0 ! Sec4/oct 10 - parameter category - veg/biomass jpdt(2) = 218 ! Sec4/oct 11 - parameter number - land nearest neighbor @@ -5232,7 +5261,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 2 ! Search for discipline - land products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for product def template number 0 - anl or fcst. jpdt = -9999 ! Initialize array of values in product definition template - Sec 4. jpdt(1) = 0 ! Sec4/oct 10 - parameter category - veg/biomass jpdt(2) = 0 ! Sec4/oct 11 - parameter number - land cover (fraction) @@ -5273,7 +5302,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 0 ! Search for discipline - meteorological products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product definition template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for product definition template number 0 - anl or fcst. jpdt = -9999 ! Initialize array of values in product definition template - Sec4 jpdt(1) = 0 ! Sec4/oct 10 - parameter category - temperature jpdt(2) = 0 ! Sec4/oct 11 - parameter number - temperature @@ -5306,7 +5335,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 0 ! Search for discipline - meteorological products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product definition template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template - Sec4 jpdt(1) = 1 ! Sec4/oct 10 - parameter category - moisture jpdt(2) = 13 ! Sec4/oct 11 - parameter number - liquid equiv snow depth @@ -5340,7 +5369,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 0 ! Search for discipline - meteorological products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product definition template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template - Sec4 jpdt(1) = 1 ! Sec4/oct 10 - parameter category - moisture jpdt(2) = 11 ! Sec4/oct 11 - parameter number - snow depth @@ -5377,7 +5406,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 0 ! Search for discipline - meteorological products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template - Sec4 jpdt(1) = 0 ! Sec4/oct 10 - parameter category - temperature jpdt(2) = 0 ! Sec4/oct 11 - parameter number - temperature @@ -5406,7 +5435,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 0 ! Search for discipline - meteorological products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product definition template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template - Sec4 jpdt(1) = 1 ! Sec4/oct 10 - parameter category - moisture jpdt(2) = 0 ! Sec4/oct 11 - parameter number - specific humidity @@ -5435,7 +5464,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 0 ! Search for discipline - meteorological products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product definition template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template - Sec4 jpdt(1) = 0 ! Sec4/oct 10 - parameter category - temperature jpdt(2) = 0 ! Sec4/oct 11 - parameter number - temperature @@ -5487,7 +5516,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 2 ! Search for discipline - land products j = 0 ! Search at beginning of file - jpdtn = 0 ! Search for product definition template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template - Sec4 jpdt(1) = 3 ! Sec4/oct 10 - parameter category - soil products jpdt(2) = 0 ! Sec4/oct 11 - parameter number - soil type @@ -5620,7 +5649,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 2 ! Search for discipline - land products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product definition template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template Sec4. jpdt(1) = 0 ! Sec4/oct 10 - parameter category - veg/biomass jpdt(2) = 4 ! Sec4/oct 11 - parameter number - vegetation @@ -5658,7 +5687,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 2 ! Search for discipline - land products j = 1105 ! grib2 file does not distinguish between the various veg ! fractions. Need to search using record number. - jpdtn = 0 ! Search for product definition template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template Sec4. jpdt(1) = 0 ! Sec4/oct 10 - parameter category - veg/biomass jpdt(2) = 4 ! Sec4/oct 11 - parameter number - vegetation @@ -5698,7 +5727,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 2 ! Search for discipline - land products j = 1106 ! Have to search by record number. - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template Sec4. jpdt(1) = 0 ! Sec4/oct 10 - parameter category - veg/biomass jpdt(2) = 4 ! Sec4/oct 11 - parameter number - vegetation @@ -5741,7 +5770,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 0 ! Search for discipline - meteorological products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template Sec4. jpdt(1) = 7 ! Sec4/oct 10 - parameter category - thermo stability indices jpdt(2) = 198 ! Sec4/oct 11 - parameter number - leaf area index @@ -5776,7 +5805,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 10 ! Search for discipline - ocean products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template Sec4. jpdt(1) = 2 ! Sec4/oct 10 - parameter category - ice jpdt(2) = 1 ! Sec4/oct 11 - parameter number - thickness @@ -5872,7 +5901,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 0 ! Search for discipline - meteorological products j = 0 ! Search at beginning of file. - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template Sec4. jpdt(1) = 2 ! Sec4/oct 10 - parameter category - momentum jpdt(2) = 30 ! Sec4/oct 11 - parameter number - friction velocity @@ -5944,7 +5973,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 2 ! Search for discipline - land products j = 0 ! Search from beginning of file - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template Sec4. jpdt(1) = 0 ! Sec4/oct 10 - parameter category - veg/biomass jpdt(2) = 13 ! Sec4/oct 11 - parameter number - canopy water @@ -5991,7 +6020,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 2 ! Search for discipline - land products j = 0 ! Search from beginning of file. - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template Sec4. jpdt(1) = 0 ! Sec4/oct 10 - parameter category - veg/biomass jpdt(2) = 1 ! Sec4/oct 11 - parameter number - surface roughness @@ -6026,7 +6055,7 @@ subroutine read_input_sfc_grib2_file(localpet) print*,"- READ LIQUID SOIL MOISTURE." vname = "soill" vname_file = ":SOILL:" - call read_grib_soil(vname,vname_file,lugb, dummy3d) !!! NEED TO HANDLE + call read_grib_soil(vname,vname_file,lugb, pdt_num,dummy3d) !!! NEED TO HANDLE !!! SOIL LEVELS endif @@ -6039,7 +6068,7 @@ subroutine read_input_sfc_grib2_file(localpet) print*,"- READ TOTAL SOIL MOISTURE." vname = "soilw" vname_file = "var2_2_1_" ! the var number instead - call read_grib_soil(vname,vname_file,lugb,dummy3d) + call read_grib_soil(vname,vname_file,lugb, pdt_num,dummy3d) endif print*,"- CALL FieldScatter FOR INPUT TOTAL SOIL MOISTURE." @@ -6064,7 +6093,7 @@ subroutine read_input_sfc_grib2_file(localpet) jdisc = 2 ! Search for discipline - land products j = 0 ! Search from beginning of file. - jpdtn = 0 ! Search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. jpdt = -9999 ! Initialize array of values in product definition template Sec4. jpdt(1) = 0 ! Sec4/oct 10 - parameter category - veg/biomass jpdt(2) = 198 ! Sec4/oct 11 - parameter number - vegetation type @@ -6141,7 +6170,7 @@ subroutine read_input_sfc_grib2_file(localpet) print*,"- READ SOIL TEMPERATURE." vname = "soilt" vname_file = ":TSOIL:" - call read_grib_soil(vname,vname_file,lugb,dummy3d) + call read_grib_soil(vname,vname_file,lugb,pdt_num,dummy3d) call check_soilt(dummy3d,slmsk_save,tsk_save) deallocate(tsk_save) endif @@ -6768,12 +6797,12 @@ END SUBROUTINE READ_FV3_GRID_DATA_NETCDF !! @param [inout] u u-component wind !! @param [inout] v v-component wind !! @param[in] localpet ESMF local persistent execution thread -!! @param[in] isnative When true, data on hybrid levels. Otherwise -!! data is on isobaric levels. +!! @param[in] octet_23 Section 4/Octet 23 - Type of first fixed surface. !! @param[in] rlevs Array of atmospheric level values !! @param[in] lugb Logical unit number of GRIB2 file. +!! @param[in] pdt_num Product definition template number. !! @author Larissa Reames - subroutine read_winds(u,v,localpet,isnative,rlevs,lugb) + subroutine read_winds(u,v,localpet,octet_23,rlevs,lugb,pdt_num) use grib_mod use program_setup, only : get_var_cond @@ -6781,8 +6810,7 @@ subroutine read_winds(u,v,localpet,isnative,rlevs,lugb) implicit none integer, intent(in) :: localpet, lugb - - logical, intent(in) :: isnative + integer, intent(in) :: pdt_num, octet_23 real(esmf_kind_r8), intent(inout), allocatable :: u(:,:,:),v(:,:,:) real(esmf_kind_r8), intent(in), dimension(lev_input) :: rlevs @@ -6842,7 +6870,7 @@ subroutine read_winds(u,v,localpet,isnative,rlevs,lugb) jids = -9999 ! array of values in identification section, set to wildcard jgdt = -9999 ! array of values in grid definition template, set to wildcard jgdtn = -1 ! search for any grid definition number. - jpdtn = 0 ! search for product def template number 0 - anl or fcst. + jpdtn = pdt_num ! Search for the product definition template number. unpack=.false. call getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, & @@ -6869,11 +6897,7 @@ subroutine read_winds(u,v,localpet,isnative,rlevs,lugb) endif - if (isnative) then - jpdt(10) = 105 ! Sec4/oct 23 - type of level - hybrid - else - jpdt(10) = 100 ! Sec4/oct 23 - type of level - isobaric - endif + jpdt(10) = octet_23 ! Sec4/oct 23 - type of level. unpack=.true. @@ -7181,9 +7205,10 @@ end subroutine handle_grib_error !! @param [in] vname variable name in varmap table !! @param [in] vname_file variable name in grib2 file !! @param [in] lugb logical unit number for surface grib2 file +!! @param [in] pdt_num product definition template number. !! @param [inout] dummy3d array of soil data !! @author George Gayno NCEP/EMC - subroutine read_grib_soil(vname, vname_file, lugb, dummy3d) + subroutine read_grib_soil(vname, vname_file, lugb, pdt_num, dummy3d) use grib_mod @@ -7191,7 +7216,7 @@ subroutine read_grib_soil(vname, vname_file, lugb, dummy3d) character(len=20), intent(in) :: vname,vname_file - integer, intent(in) :: lugb + integer, intent(in) :: lugb, pdt_num real(esmf_kind_r8), intent(inout) :: dummy3d(:,:,:) @@ -7234,16 +7259,16 @@ subroutine read_grib_soil(vname, vname_file, lugb, dummy3d) jids = -9999 ! array of values in identification section, set to wildcard jgdt = -9999 ! array of values in grid definition template 3.m jgdtn = -1 ! search for any grid definition number. - jpdtn = 0 ! search for product def template number 0 - anl or fcst. - jpdt(1) = 0 ! oct 10 - param cat - veg/biomass - if (trim(vname) == 'soilt') jpdt(2) = 2 ! oct 11 - param number - soil temp - if (trim(vname) == 'soilw') jpdt(2) = 192 ! oct 11 - param number - total soilm + jpdtn = pdt_num ! Search for the product definition template number. + jpdt(1) = 0 ! Section 4/Octet 10 - parameter category - veg/biomass + if (trim(vname) == 'soilt') jpdt(2) = 2 ! Section 4/Octet 11 - parameter number - soil temp + if (trim(vname) == 'soilw') jpdt(2) = 192 ! Section 4/Octet 11 - parameter number - total soilm if (trim(vname) == 'soill') then - jpdt(1) = 3 ! oct 10 - soil products - jpdt(2) = 192 ! oct 11 - param number - liquid soilm + jpdt(1) = 3 ! Section 4/Octet 10 - soil products + jpdt(2) = 192 ! Section 4/Octet 11 - parameter number - liquid soilm endif - jpdt(10) = 106 ! oct 23 - depth below ground - jpdt(13) = 106 ! oct 29 - depth below ground + jpdt(10) = 106 ! Section 4/Octet 23 - depth below ground + jpdt(13) = 106 ! Section 4/Octet 29 - depth below ground unpack=.true. do i = 1,lsoil_input