Skip to content

Commit

Permalink
feature/mod_cleanup
Browse files Browse the repository at this point in the history
Merge branch 'develop' into feature/mod_cleanup

Issue ufs-community#235.
  • Loading branch information
GeorgeGayno-NOAA committed Dec 15, 2020
2 parents b5115c5 + ed92c78 commit dac5abc
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 192 deletions.
55 changes: 22 additions & 33 deletions sorc/emcsfc_snow2mdl.fd/grib_utils.f
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
!> @file
!! @brief Determine whether file is grib or not.
!
!> Determine whether file is grib or not.
!! @author gayno org: w/np2 @date 2007-nov-28
!!
!! program history log:
!! - 2007-nov-28 gayno - initial version
!! - 2011-apr-26 gayno - replace my simple-minded logic
!! with call to w3lib routin skgb.
!! - 2014-feb-07 gayno - determine whether file is
!! grib1 or grib2.
!!
!! @param[in] file_name - file to be checked
!! @param[out] isgrib - '1' or '2' if grib1/2 file '0' if not grib
!!
!! input files:
!! - file to be checked, fort.11
!!
!! condition codes: all fatal
!! - bad file open, fort.11
!!
subroutine grib_check(file_name, isgrib)
!$$$ subprogram documentation block
!
! subprogram: grib_check
! prgmmr: gayno org: w/np2 date: 2007-nov-28
!
! abstract: determine whether file is grib or not.
!
! program history log:
! 2007-nov-28 gayno - initial version
! 2011-apr-26 gayno - replace my simple-minded logic
! with call to w3lib routin skgb.
! 2014-feb-07 gayno - determine whether file is
! grib1 or grib2.
!
! usage: call grib_check(file_name, isgrib)
!
! input argument list: file_name - file to be checked
!
! output argument list: isgrib - '1' or '2' if grib1/2 file
! '0' if not grib
!
! files:
! input:
! - file to be checked, fort.11
!
! output: none
!
! condition codes: all fatal
! - bad file open, fort.11
!
! remarks: none.
!
!$$$

implicit none

Expand Down
73 changes: 34 additions & 39 deletions sorc/emcsfc_snow2mdl.fd/model_grid.f
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
!> @file
!! @brief Read in data defining the model grid.
!!
!! @author gayno org: w/np2 @date 2005-dec-16
!!
!! program history log:
!! - 2005-dec-16 gayno - initial version
!! - 2007-nov-30 gayno - improved method for thinning gfs grids.
!! added nam b-grids.
!! - 2014-sep-29 gayno - add option to read model lat, lon and
!! landmask data in grib2.
!!
!! variable definitions:
!! - grid_id_mdl - grib id of model grid, 4-gaussian, 203-egrid
!! - i/jpts_mdl - i/j index of point on full grid
!! - imdl - i-dimension of model grid
!! - jmdl - j-dimension of model grid
!! - ijmdl - total number of model land points
!! - kgds_mdl - holds grib gds info of model grid
!! - lats_mdl - latitudes of model grid points
!! - lons_mdl - longitudes of model grid points
!! - lonsperlat - for global grids, the number of i points
!! in each row (decrease toward pole)
!! - lsmask_mdl - land mask of model grid (0 - non land, 1-land)
!! for global grids run thinned, will contain
!! a modified version of the original mask
!! that has land at all points encompassed by a
!! thinned point
!! - lsmask_mdl_sav - saved copy of land mask of model grid (0 - non land, 1-land)
!! only used for global thinned grids.
!! - resol_mdl - approximate model resolution in km.
!! - thinned - when true, global grids will run thinned
!! (# i points decrease toward pole)
!!
module model_grid
!$$$ module documentation block
!
! module: model_grid
! prgmmr: gayno org: w/np2 date: 2005-dec-16
!
! abstract: read in data defining the model grid.
!
! program history log:
! 2005-dec-16 gayno - initial version
! 2007-nov-30 gayno - improved method for thinning gfs grids.
! added nam b-grids.
! 2014-sep-29 gayno - add option to read model lat, lon and
! landmask data in grib2.
!
! usage: use model_grid
!
! remarks: some variable definitions
! grid_id_mdl - grib id of model grid, 4-gaussian, 203-egrid
! i/jpts_mdl - i/j index of point on full grid
! imdl - i-dimension of model grid
! jmdl - j-dimension of model grid
! ijmdl - total number of model land points
! kgds_mdl - holds grib gds info of model grid
! lats_mdl - latitudes of model grid points
! lons_mdl - longitudes of model grid points
! lonsperlat - for global grids, the number of i points
! in each row (decrease toward pole)
! lsmask_mdl - land mask of model grid (0 - non land, 1-land)
! for global grids run thinned, will contain
! a modified version of the original mask
! that has land at all points encompassed by a
! thinned point
! lsmask_mdl_sav - saved copy of land mask of model grid (0 - non land, 1-land)
! only used for global thinned grids.
! resol_mdl - approximate model resolution in km.
! thinned - when true, global grids will run thinned
! (# i points decrease toward pole)
!
!$$$

use program_setup, only : model_lsmask_file, &
model_lon_file, &
Expand Down
87 changes: 41 additions & 46 deletions sorc/emcsfc_snow2mdl.fd/program_setup.f
Original file line number Diff line number Diff line change
@@ -1,50 +1,45 @@
!> @file
!! @brief This module reads in data from the program's configuration
!! namelist.
!!
!! @author gayno org: w/np2 @date 2005-DEC-16
!!
!! program history log:
!! - 2005-DEC-16 gayno - initial version
!! - 2008-Feb-01 gayno - added autosnow data
!! - 2014-Sep-30 gayno - added 'output_grib2' flag
!!
!! variable definitions:
!! - afwa_snow_nh_file - path/name afwa n hemis snow depth
!! - afwa_snow_sh_file - path/name afwa s hemis snow depth
!! - afwa_lsmask_nh_file - path/name afwa n hemis land/sea mask
!! - afwa_lsmask_sh_file - path/name afwa s hemis land/sea mask
!! - autosnow_file - path/name s hemis autosnow file
!! - grib_century/day/hour/month/year -
!! date of the final merged
!! snow product that will be placed
!! in grib header.
!! - model_lat_file - path/name lats on the model grid
!! - model_lon_file - path/name lons on the model grid
!! - nesdis_lsmask_file - path/name nesdis/ims land mask
!! - nesdis_snow_file - path/name nesdis/ims snow cover
!! - lat_threshold - equatorward of this latitude, model
!! points with undefined cover or depth
!! (because the interpolation routines
!! could not find valid snow data)
!! are set to a default value of zero.
!! poleward, undefined points are set
!! according to logic in module snow2mdl
!! - min_snow_depth - minimum snow depth in meters at model
!! points with coverage exceeding threshold.
!! - output_grib2 - when true, output model snow analysis
!! is grib 2. when false, grib 1.
!! - snow_cvr_threshold - if percent coverage according to nesdis/ims
!! or autosnow exceeds this value, then
!! non-zero snow depth is assigned. below
!! this threshold, depth is set to zero.
!!
module program_setup
!$$$ module documentation block
! . . . .
! module: program_setup
! prgmmr: gayno org: w/np2 date: 2005-DEC-16
!
! abstract: this module reads in data from the program's
! configuration namelist.
!
! program history log:
! 2005-DEC-16 gayno - initial version
! 2008-Feb-01 gayno - added autosnow data
! 2014-Sep-30 gayno - added 'output_grib2' flag
!
! usage: use program_setup
!
! remarks: some variable definitions
! afwa_snow_nh_file - path/name afwa n hemis snow depth
! afwa_snow_sh_file - path/name afwa s hemis snow depth
! afwa_lsmask_nh_file - path/name afwa n hemis land/sea mask
! afwa_lsmask_sh_file - path/name afwa s hemis land/sea mask
! autosnow_file - path/name s hemis autosnow file
! grib_century/day/hour/month/year -
! date of the final merged
! snow product that will be placed
! in grib header.
! model_lat_file - path/name lats on the model grid
! model_lon_file - path/name lons on the model grid
! nesdis_lsmask_file - path/name nesdis/ims land mask
! nesdis_snow_file - path/name nesdis/ims snow cover
! lat_threshold - equatorward of this latitude, model
! points with undefined cover or depth
! (because the interpolation routines
! could not find valid snow data)
! are set to a default value of zero.
! poleward, undefined points are set
! according to logic in module snow2mdl
! min_snow_depth - minimum snow depth in meters at model
! points with coverage exceeding threshold.
! output_grib2 - when true, output model snow analysis
! is grib 2. when false, grib 1.
! snow_cvr_threshold - if percent coverage according to nesdis/ims
! or autosnow exceeds this value, then
! non-zero snow depth is assigned. below
! this threshold, depth is set to zero.
!
!$$$
implicit none
Expand Down
43 changes: 17 additions & 26 deletions sorc/emcsfc_snow2mdl.fd/snow2mdl.f
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
!> @file
!! @brief Interpolate snow data to model grid and grib the result.
!!
!! @author gayno org: w/np2 @date 2005-dec-16
!!
!! program history log:
!! - 2005-DEC-16 gayno - initial version
!! - 2007-SEP-20 gayno - tested for b-grids. added improved
!! thinning for gfs grid.
!! - 2008-feb-04 gayno - added autosnow data
!! - 2014-sep-26 gayno - added option to output analysed
!! snow in grib2.
!!
!! variable definitions:
!! - snow_cvr_mdl - snow cover on model grid in percent
!! - snow_dep_mdl - snow depth on model grid in meters
!!
module snow2mdl
!$$$ module documentation block
!
! module: snow2mdl
! prgmmr: gayno org: w/np2 date: 2005-dec-16
!
! abstract: interpolate snow data to model grid and grib the result
!
! program history log:
! 2005-DEC-16 gayno - initial version
! 2007-SEP-20 gayno - tested for b-grids. added improved
! thinning for gfs grid.
! 2008-feb-04 gayno - added autosnow data
! 2014-sep-26 gayno - added option to output analysed
! snow in grib2.
!
! usage: use snow2mdl
!
! remarks: some variable definitions
! snow_cvr_mdl - snow cover on model grid in percent
! snow_dep_mdl - snow depth on model grid in meters
!
! attributes:
! language: fortran 90
! machine: ibm wcoss
!
!$$$

use program_setup, only : lat_threshold, &
model_snow_file, &
Expand Down
91 changes: 43 additions & 48 deletions sorc/emcsfc_snow2mdl.fd/snowdat.f
Original file line number Diff line number Diff line change
@@ -1,52 +1,47 @@
!> @file
!! @brief Read and qc afwa, nesdis/ims and autosnow snow data.
!!
!! @author gayno org: w/np2 @date 2005-dec-16
!!
!! program history log:
!! - 2005-dec-16 gayno - initial version
!! - 2007-aug-10 gayno - allow program to run with no nesdis/ims data
!! add 16th mesh afwa grib data
!! - 2008-feb-04 gayno - add autosnow cover data for sh.
!! - 2009-jun-03 gayno - add qc check for nesdis/ims and afwa data.
!! - 2014-feb-07 gayno - read nesdis/ims data in grib1 or grib 2
!! format.
!! - 2014-sep-30 gayno - convert weekly nh snow climatology - used to
!! qc input data - to grib 2.
!!
!! variable definitions:
!! - afwa_res - resolution of afwa data in km
!! - autosnow_res - resolution of autosnow in km
!! - bad_afwa_Xh - is afwa data corrupt?
!! - bad_nesdis - is nesdis ims data corrupt?
!! - bitmap_afwa_Xh - bitmap of afwa grid (false-non land, true-land)
!! - bitmap_nesdis - bitmap of nesdis grid (false-non land, true-land)
!! - iafwa - i-dimension of afwa grid
!! - jafwa - j-dimension of afwa grid
!! - iautosnow - i-dimension of autosnow grid
!! - jautosnow - j-dimension of autosnow grid
!! - inesdis - i-dimension of nesdis grid
!! - jnesdis - j-dimension of nesdis grid
!! - kgds_afwa_Xh - afwa grid description section (grib section 2)
!! - kgds_autosnow - autosnow grid description section (grib section 2)
!! - kgds_nesdis - nesdis/ims grid description section (grib section 2)
!! - mesh_nesdis - nesdis/ims data is 96th mesh (or bediant)
!! - nesdis_res - resolution of nesdis/ims data in km
!! - sea_ice_nesdis - nesdis/ims sea ice flag (0-open water, 1-ice)
!! - snow_cvr_autosnow - autosnow snow cover flag (0-no, 100-yes)
!! - snow_cvr_nesdis - nesdis/ims snow cover flag (0-no, 100-yes)
!! - snow_dep_afwa_Xh - afwa snow depth data (inches*10 on input,
!! meters on output)
!! - use_xh_afwa - true if afwa data to be used
!! - use_autosnow - true if autosnow data to be used
!! - use_nesdis - true if nesdis/ims data to be used
!!
module snowdat
!$$$ module documentation block
!
! module: snowdat
! prgmmr: gayno org: w/np2 date: 2005-dec-16
!
! abstract: read and qc afwa, nesdis/ims and autosnow snow data.
!
! program history log:
! 2005-dec-16 gayno - initial version
! 2007-aug-10 gayno - allow program to run with no nesdis/ims data
! add 16th mesh afwa grib data
! 2008-feb-04 gayno - add autosnow cover data for sh.
! 2009-jun-03 gayno - add qc check for nesdis/ims and afwa data.
! 2014-feb-07 gayno - read nesdis/ims data in grib1 or grib 2
! format.
! 2014-sep-30 gayno - convert weekly nh snow climatology - used to
! qc input data - to grib 2.
!
! usage: use snowdat
!
! remarks: some variable definitions
! afwa_res - resolution of afwa data in km
! autosnow_res - resolution of autosnow in km
! bad_afwa_Xh - is afwa data corrupt?
! bad_nesdis - is nesdis ims data corrupt?
! bitmap_afwa_Xh - bitmap of afwa grid (false-non land, true-land)
! bitmap_nesdis - bitmap of nesdis grid (false-non land, true-land)
! iafwa - i-dimension of afwa grid
! jafwa - j-dimension of afwa grid
! iautosnow - i-dimension of autosnow grid
! jautosnow - j-dimension of autosnow grid
! inesdis - i-dimension of nesdis grid
! jnesdis - j-dimension of nesdis grid
! kgds_afwa_Xh - afwa grid description section (grib section 2)
! kgds_autosnow - autosnow grid description section (grib section 2)
! kgds_nesdis - nesdis/ims grid description section (grib section 2)
! mesh_nesdis - nesdis/ims data is 96th mesh (or bediant)
! nesdis_res - resolution of nesdis/ims data in km
! sea_ice_nesdis - nesdis/ims sea ice flag (0-open water, 1-ice)
! snow_cvr_autosnow - autosnow snow cover flag (0-no, 100-yes)
! snow_cvr_nesdis - nesdis/ims snow cover flag (0-no, 100-yes)
! snow_dep_afwa_Xh - afwa snow depth data (inches*10 on input,
! meters on output)
! use_xh_afwa - true if afwa data to be used
! use_autosnow - true if autosnow data to be used
! use_nesdis - true if nesdis/ims data to be used
!
!$$$

use program_setup, only : autosnow_file, &
nesdis_snow_file, &
Expand Down

0 comments on commit dac5abc

Please sign in to comment.