Skip to content
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
11 changes: 7 additions & 4 deletions sorc/emcsfc_snow2mdl.fd/driver.f
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
!> @file
!!
!! @brief Create a snow cover and snow depth analysis on a nam
!! @brief Create a snow cover and snow depth analysis.
!! @author gayno @date 2005-dec-16

!> Create a snow cover and snow depth analysis on a nam
!! or global gfs gaussian grid using nesdis/ims snow cover, autosnow snow
!! cover and/or afwa depth data.
!! @author gayno @date 2005-dec-16
!!
!!
!! Program History Log
!! - 2005-dec-16 gayno initial version
!! - 2007-nov-30 gayno added processing of nam b-grids.
Expand Down Expand Up @@ -138,6 +139,8 @@
!! defined threshold, the depth is set to 0,
!! regardless of the afwa depth value.
!!
!! @return 0 for success, error code otherwise.
!! @author gayno @date 2005-dec-16
program driver

use snowdat, only : readnesdis, &
Expand Down
4 changes: 1 addition & 3 deletions sorc/emcsfc_snow2mdl.fd/grib_utils.f
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,9 @@ subroutine init_grib2(century, year, month, day, hour, kgds, &

end subroutine init_grib2

!> Nullify the grib2 gribfield pointers.
!> Nullify the grib2 gribfield pointers.
!!
!! @param[in] gfld a gribfield data structure
!! @param[out] gfld a gribfield data structure
!!
!! @author George Gayno org: w/np2 @date 2014-Sep-28
subroutine grib2_null(gfld)
Expand All @@ -631,7 +630,6 @@ end subroutine grib2_null
!> Deallocate the grib2 gribfield pointers.
!!
!! @param[in] gfld a gribfield data structure
!! @param[in] gfld a gribfield data structure
!!
!! @author George Gayno org: w/np2 @date 2014-Sep-28
subroutine grib2_free(gfld)
Expand Down
70 changes: 32 additions & 38 deletions sorc/emcsfc_snow2mdl.fd/model_grid.f
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
!> @file
!! @brief Read in data defining the model grid.
!!
!! @author George Gayno org: w/np2 @date 2005-Dec-16

!> 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.
Expand All @@ -9,26 +12,8 @@
!! 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)
!!
!! @author George Gayno org: w/np2 @date 2005-Dec-16
module model_grid
Expand All @@ -38,24 +23,33 @@ module model_grid
model_lat_file, &
gfs_lpl_file

integer :: grid_id_mdl
integer :: imdl
integer :: jmdl
integer :: ijmdl ! only land points
integer, allocatable :: ipts_mdl(:), jpts_mdl(:)

integer :: kgds_mdl(200)
integer, allocatable :: lonsperlat_mdl (:)
integer :: grid_id_mdl !< grib id of model grid, 4-gaussian, 203-egrid
integer :: imdl !< i-dimension of model grid
integer :: jmdl !< j-dimension of model grid
integer :: ijmdl !< total number of model land points
integer, allocatable :: ipts_mdl(:) !< i index of point on full grid
integer, allocatable :: jpts_mdl(:) !< j index of point on full grid

integer :: kgds_mdl(200) !< holds grib gds info of model grid
integer, allocatable :: lonsperlat_mdl (:) !< Number of longitudes (i-points)
!! for each latitude (row). Used
!! for global thinned (reduced) grids.

logical :: thinned

real, allocatable :: lats_mdl (:)
real :: lat11, latlast
real :: lon11, lonlast
real, allocatable :: lons_mdl (:)
real, allocatable :: lsmask_mdl (:,:)
real, allocatable :: lsmask_mdl_sav (:,:)
real :: resol_mdl ! in km
logical :: thinned !< When true, global grids will run thinned
!! (number of i points decrease toward pole)

real, allocatable :: lats_mdl(:) !< Latitudes of model grid points
real :: lat11 !< Corner point latitude (1,1) of model grid.
real :: latlast !< Corner point latitude (imdl,jmdl) of model grid.
real :: lon11 !< Corner point longitude (1,1) of model grid.
real :: lonlast !< Corner point longitude (imdl,jmdl) of model grid.
real, allocatable :: lons_mdl(:) !< longitudes of model grid points
real, allocatable :: 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
real, allocatable :: lsmask_mdl_sav(:,:) !< saved copy of land mask of model grid (0 - non land, 1-land)
!! only used for global thinned grids.
real :: resol_mdl !< approximate model resolution in km.

contains
!> Read mdl grid.
Expand Down Expand Up @@ -572,14 +566,14 @@ subroutine read_mdl_grid_info
end subroutine read_mdl_grid_info


!> Clean up allocatable arrays.
!> Clean up allocatable arrays.
!!
!! This deallocate this module's allocatable array.
!!
!! program history log:
!! 2005-dec-16 gayno - initial version
!!
!! @author George Gayno org: w/np2 @Date 2005-Dec-16
!! @author George Gayno org: w/np2 @date Dec 16, 2005
subroutine model_grid_cleanup

implicit none
Expand Down
117 changes: 49 additions & 68 deletions sorc/emcsfc_snow2mdl.fd/program_setup.f
Original file line number Diff line number Diff line change
@@ -1,87 +1,67 @@
!> @file
!! @brief This module reads in data from the program's configuration
!! @brief This module reads in data from the program's configuration.
!! namelist.
!! @author George Gayno org: w/np2 @date 2005-DEC-16

!> 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.
!!
!! @author George Gayno org: w/np2 @date 2005-DEC-16
module program_setup

implicit none

private

character*200, public :: afwa_snow_global_file
character*150, public :: afwa_snow_nh_file
character*150, public :: afwa_snow_sh_file
character*150, public :: afwa_lsmask_nh_file
character*150, public :: afwa_lsmask_sh_file
character*150, public :: autosnow_file
character*150, public :: climo_qc_file
character*150, public :: gfs_lpl_file
character*150, public :: model_lat_file
character*150, public :: model_lon_file
character*150, public :: model_lsmask_file
character*150, public :: model_snow_file
character*150, public :: nesdis_lsmask_file
character*150, public :: nesdis_snow_file

integer, public :: grib_century
integer, public :: grib_day
integer, public :: grib_hour
integer, public :: grib_month
integer, public :: grib_year

logical, public :: output_grib2

real, public :: lat_threshold
real, public :: min_snow_depth
real, public :: snow_cvr_threshold

public :: read_config_nml
character*200, public :: afwa_snow_global_file !< global afwa snow file.
character*150, public :: afwa_snow_nh_file !< path/name afwa n hemis snow depth
character*150, public :: afwa_snow_sh_file !< path/name afwa s hemis snow depth
character*150, public :: afwa_lsmask_nh_file !< path/name afwa n hemis land/sea mask
character*150, public :: afwa_lsmask_sh_file !< path/name afwa s hemis land/sea mask
character*150, public :: autosnow_file !< path/name s hemis autosnow file
character*150, public :: climo_qc_file !< Climatological snow cover
!! file. Used to quality control snow data.
character*150, public :: gfs_lpl_file !< GFS gaussian thinned (reduced) grid
!! definition file. Contains the number of
!! longitudes (i-points) for each latitude (row).
character*150, public :: model_lat_file !< path/name lats on the model grid
character*150, public :: model_lon_file !< path/name lons on the model grid
character*150, public :: model_lsmask_file !< path/name nesdis/ims land mask
character*150, public :: model_snow_file !< path/name nesdis/ims snow cover
character*150, public :: nesdis_lsmask_file !< nesdis/ims land mask file
character*150, public :: nesdis_snow_file !< nesdis/ims snow file

integer, public :: grib_century !< date of the final merged snow product that will be placed in grib header.

integer, public :: grib_day !< date of the final merged snow product that will be placed in grib header.
integer, public :: grib_hour !< date of the final merged snow product that will be placed in grib header.
integer, public :: grib_month !< date of the final merged snow product that will be placed in grib header.
integer, public :: grib_year !< date of the final merged snow product that will be placed in grib header.

logical, public :: output_grib2 !< when true, output model snow analysis is grib 2. when false, grib 1.

real, public :: 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.
real, public :: min_snow_depth !< minimum snow depth in meters at model points with coverage exceeding threshold.
real, public :: 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.

public :: read_config_nml !< Read configuration namelist.

contains

!> read namelist controls
!! @author George Gayno org: w/np2 @date 2005-Dec-16
!> Read namelist control.
!!
!! @note this subroutine reads the program's configuration namelist
!! that contains the the paths/filenames for input and output, and
!! other program control flags.
!! @note This subroutine reads the program's configuration namelist
!! that contains the the paths/filenames for input and output, and
!! other program control flags.
!!
!! program history log:
!! 2005-dec-16 gayno - initial version
Expand All @@ -93,9 +73,10 @@ module program_setup
!! - program configuration namelist, fort.41
!!
!! condition codes: all fatal
!! 77 - bad open on configuration namelist
!! 78 - bad read on configuration namelist
!! - 77 - bad open on configuration namelist
!! - 78 - bad read on configuration namelist
!!
!! @author George Gayno org: w/np2 @date 2005-Dec-16
subroutine read_config_nml

implicit none
Expand Down
Loading