diff --git a/sorc/chgres_cube.fd/chgres.F90 b/sorc/chgres_cube.fd/chgres.F90 index c3472867d..5024cde6e 100644 --- a/sorc/chgres_cube.fd/chgres.F90 +++ b/sorc/chgres_cube.fd/chgres.F90 @@ -1,19 +1,22 @@ !> @file !! @brief Initialize an FV3 model run. !! +!! @author George Gayno NOAA/EMC + +!> Initialize an FV3 model run. +!! !! Initialize an FV3 run using history or restart data from another !! FV3 run, the spectral GFS, and a few other models. Converts !! atmospheric, surface and nst data. !! !! This file reads a configuration namelist. !! -!! Usage: -!! Link the configuration namelist to ./fort.41. Then run the -!! program with a multiple of six mpi tasks (an ESMF library -!! requirement for fv3 cubed sphere grids). -!! +!! Link the configuration namelist to ./fort.41. Then run the program +!! with a multiple of six mpi tasks (an ESMF library requirement for +!! fv3 cubed sphere grids). !! !! @author George Gayno NOAA/EMC +!! @return 0 for success, error code otherwise. program chgres use mpi diff --git a/sorc/chgres_cube.fd/input_data.F90 b/sorc/chgres_cube.fd/input_data.F90 index 66c05c0f5..8d8e8c4b2 100644 --- a/sorc/chgres_cube.fd/input_data.F90 +++ b/sorc/chgres_cube.fd/input_data.F90 @@ -104,24 +104,25 @@ module input_data ! Fields associated with the nst model. - type(esmf_field), public :: c_d_input_grid - type(esmf_field), public :: c_0_input_grid - type(esmf_field), public :: d_conv_input_grid - type(esmf_field), public :: dt_cool_input_grid - type(esmf_field), public :: ifd_input_grid - type(esmf_field), public :: qrain_input_grid - type(esmf_field), public :: tref_input_grid !< reference temperature - type(esmf_field), public :: w_d_input_grid - type(esmf_field), public :: w_0_input_grid - type(esmf_field), public :: xs_input_grid - type(esmf_field), public :: xt_input_grid - type(esmf_field), public :: xu_input_grid - type(esmf_field), public :: xv_input_grid - type(esmf_field), public :: xz_input_grid - type(esmf_field), public :: xtts_input_grid - type(esmf_field), public :: xzts_input_grid - type(esmf_field), public :: z_c_input_grid - type(esmf_field), public :: zm_input_grid + type(esmf_field), public :: c_d_input_grid !< Coefficient 2 to calculate d(tz)/d(ts) + type(esmf_field), public :: c_0_input_grid !< Coefficient 1 to calculate d(tz)/d(ts) + type(esmf_field), public :: d_conv_input_grid !< Thickness of free convection layer + type(esmf_field), public :: dt_cool_input_grid !< Sub-layer cooling amount + type(esmf_field), public :: ifd_input_grid !< Model mode index. 0-diurnal model not + !< started; 1-diurnal model started. + type(esmf_field), public :: qrain_input_grid !< Sensible heat flux due to rainfall + type(esmf_field), public :: tref_input_grid !< Reference temperature + type(esmf_field), public :: w_d_input_grid !< Coefficient 4 to calculate d(tz)/d(ts) + type(esmf_field), public :: w_0_input_grid !< Coefficient 3 to calculate d(tz)/d(ts) + type(esmf_field), public :: xs_input_grid !< Salinity content in diurnal thermocline layer + type(esmf_field), public :: xt_input_grid !< Heat content in diurnal thermocline layer + type(esmf_field), public :: xu_input_grid !< u-current content in diurnal thermocline layer + type(esmf_field), public :: xv_input_grid !< v-current content in diurnal thermocline layer + type(esmf_field), public :: xz_input_grid !< Diurnal thermocline layer thickness + type(esmf_field), public :: xtts_input_grid !< d(xt)/d(ts) + type(esmf_field), public :: xzts_input_grid !< d(xz)/d(ts) + type(esmf_field), public :: z_c_input_grid !< Sub-layer cooling thickness + type(esmf_field), public :: zm_input_grid !< Oceanic mixed layer depth public :: read_input_atm_data public :: cleanup_input_atm_data diff --git a/sorc/chgres_cube.fd/program_setup.f90 b/sorc/chgres_cube.fd/program_setup.f90 index 919661f7c..ef260e516 100644 --- a/sorc/chgres_cube.fd/program_setup.f90 +++ b/sorc/chgres_cube.fd/program_setup.f90 @@ -1,41 +1,41 @@ !> @file !! @brief Set up program execution !! -!! @author George Gayno NCEP/EMC -!! !! Set up program execution !! -!! Public variables: -!! -!! - atm_core_files_input_grid - File names of input atmospheric restart -!! core files. Only used for 'restart' -!! input type. -!! - atm_tracer_files_input_grid - File names of input atmospheric restart -!! tracer files. Only used for 'restart' -!! input type. -!! - atm_weight_file - File containing pre-computed weights -!! to horizontally interpolate -!! atmospheric fields. -!! - bb_target - Soil 'b' parameter, target grid -!! - convert_atm - Convert atmospheric data when true. -!! - convert_nst - Convert nst data when true. -!! - convert_sfc - Convert sfc data when true. -!! - cres_target_grid - Target grid resolution, i.e., C768. -!! - cycle_mon/day/hour - Cycle month/day/hour -!! - data_dir_input_grid - Directory containing input atm or sfc -!! files. -!! - drysmc_input/target - Air dry soil moisture content input/ -!! target grids. -!! - fix_dir_target_grid - Directory containing target grid -!! pre-computed fixed data (ex: soil type) -!! - halo_blend - Number of row/cols of blending halo, -!! where model tendencies and lateral -!! boundary tendencies are applied. -!! Regional target grids only. -!! - halo_bndy - Number of row/cols of lateral halo, -!! where pure lateral bndy conditions are -!! applied (regional target grids). -!! - input_type - Input data type: +!! @author George Gayno NCEP/EMC + module program_setup + + implicit none + + private + + character(len=500), public :: varmap_file = "NULL" !< REQUIRED. Full path of the relevant varmap file. + character(len=500), public :: atm_files_input_grid(6) = "NULL" !< File names of input + !< atmospheric data. Not used + !< for "grib2" or "restart" + !< input types. + character(len=500), public :: atm_core_files_input_grid(7) = "NULL" !< File names of input atmospheric restart core files. Only used for 'restart' input type. + character(len=500), public :: atm_tracer_files_input_grid(6) = "NULL" !< File names of input atmospheric restart tracer files. Only used for 'restart' input type. + character(len=500), public :: data_dir_input_grid = "NULL" !< Directory containing input atm or sfc files. + character(len=500), public :: fix_dir_target_grid = "NULL" !< Directory containing target grid pre-computed fixed data (ex: soil type). + character(len=500), public :: mosaic_file_input_grid = "NULL" !< Input grid mosaic file. Only used for "restart" or "history" input type. + character(len=500), public :: mosaic_file_target_grid = "NULL" !< Target grid mosaic file. + character(len=500), public :: nst_files_input_grid = "NULL" !< File name of input nst data. Only used for input_type "gfs_gaussian_nemsio". + character(len=500), public :: grib2_file_input_grid = "NULL" !< REQUIRED. File name of grib2 input data. Assumes atmospheric and surface data are in a single file. + character(len=500), public :: geogrid_file_input_grid = "NULL" !< Name of "geogrid" file, which contains static + !! surface fields on the input grid. GRIB2 option + !! only. + character(len=500), public :: orog_dir_input_grid = "NULL" !< Directory containing the input grid orography files. Only used for "restart" or "history" input types. + character(len=500), public :: orog_files_input_grid(6) = "NULL" !< Input grid orography files. Only used for "restart" or "history" input types. + character(len=500), public :: orog_dir_target_grid = "NULL" !< Directory containing the target grid orography files. + character(len=500), public :: orog_files_target_grid(6) = "NULL" !< Target grid orography files. + character(len=500), public :: sfc_files_input_grid(6) = "NULL" !< File names containing input surface data. Not used for 'grib2' input type. + character(len=500), public :: vcoord_file_target_grid = "NULL" !< Vertical coordinate definition file. + character(len=500), public :: thomp_mp_climo_file= "NULL" !< Path/name to the Thompson MP climatology file. + character(len=6), public :: cres_target_grid = "NULL" !< Target grid resolution, i.e., C768. + character(len=500), public :: atm_weight_file="NULL" !< File containing pre-computed weights to horizontally interpolate atmospheric fields. + character(len=25), public :: input_type="restart" !< Input data type: !! - "restart" for fv3 tiled warm restart !! files (netcdf). !! - "history" for fv3 tiled history files @@ -49,182 +49,90 @@ !! gaussian nemsio files !! - "gfs_sigio" for spectral gfs !! gfs sigio/sfcio files. -!! - max_tracers - Maximum number of atmospheric tracers -!! processed -!! - maxsmc_input/target - Maximum soil moisture content input/ -!! target grids -!! - mosaic_file_input_grid - Input grid mosaic file. Only used for -!! "restart" or "history" input type. -!! - mosaic_file_target_grid - Target grid mosaic file -!! - nst_files_input_grid - File name of input nst data. Only -!! used for input_type "gfs_gaussian_nemsio". -!! - num_tracers - Number of atmospheric tracers to -!! be processed. -!! - orog_dir_input_grid - Directory containing the input grid -!! orography files. Only used for "restart" -!! or "history" input types. -!! - orog_files_input_grid - Input grid orography files. Only used for -!! "restart" or "history" input types. -!! - orog_dir_target_grid - Directory containing the target grid -!! orography files. -!! - orog_files_target_grid - Target grid orography files. -!! - refsmc_input/target - Reference soil moisture content input/ -!! target grids (onset of soil moisture -!! stress). -!! - regional - For regional target grids. When '1' -!! remove boundary halo region from -!! atmospheric/surface data and -!! output atmospheric boundary file. -!! When '2' output boundary file only. -!! Default is '0' (global grids). -!! - satpsi_target - Saturated soil potential, target grid -!! - sfc_files_input_grid - File names containing input surface data. -!! Not used for 'grib2' input type. -!! - thomp_mp_climo_file - Path/name to the Thompson MP climatology -!! file. -!! - tracers - Name of each atmos tracer to be processed. -!! These names will be used to identify -!! the tracer records in the output files. -!! Follows the convention in the field table. -!! FOR GRIB2 FILES: Not used. Tracers instead taken -!! from the varmap file. -!! - tracers_input - Name of each atmos tracer record in -!! the input file. May be different from -!! value in 'tracers'. -!! FOR GRIB2 FILES: Not used. Tracers instead taken -!! from the varmap file. -!! - use_thomp_mp_climo - When true, read and process Thompson -!! MP climatological tracers. False, -!! when 'thomp_mp_climo_file' is NULL. -!! - vcoord_file_target_grid - Vertical coordinate definition file -!! - wltsmc_input/target - Plant wilting point soil moisture content -!! input/target grids -!! - nsoill_out - Number of soil levels desired in the output data. -!! chgres_cube can interpolate from 9 input to 4 output -!! levels. DEFAULT: 4 -!! -!! Variables that are relevant only for "grib2" input type: -!! -!! - grib2_file_input_grid - REQUIRED. File name of grib2 input data. -!! Assumes atmospheric and surface data are in a single -!! file. -!! -!! - varmap_file - REQUIRED. Full path of the relevant varmap file. -!! -!! - external_model - The model that the input data is derived from. Current -!! supported options are: "GFS", "HRRR", "NAM", "RAP". -!! Default: "GFS" -!! -!! - vgtyp_from_climo - If false, interpolate vegetation type from the input -!! data to the target grid instead of using data from -!! static data. Use with caution as vegetation categories -!! can vary. Default: True -!! -!! - sotyp_from_climo - If false, interpolate soil type from the input -!! data to the target grid instead of using data from -!! static data. Use with caution as the code assumes -!! input soil type use STATSGO soil categories. -!! Default: True -!! -!! - vgfrc_from_climo - If false, interpolate vegetation fraction from the input -!! data to the target grid instead of using data from -!! static data. Use with caution as vegetation categories -!! can vary. -!! Default: True -!! -!! - minmax_vgfrc_from_climo - If false, interpolate min/max vegetation fraction from -!! the input data to the target grid instead of using data -!! from static data. Use with caution as vegetation -!! categories can vary. -!! Default: True -!! -!! - lai_from_climo - If false, interpolate leaf area index from the input -!! data to the target grid instead of using data from -!! static data. -!! Default: True -!! -!! - tg3_from_soil - If false, use lowest level soil temperature for the -!! base soil temperature instead of using data from -!! static data. -!! Default: False -!! - module program_setup - - implicit none - - private - - character(len=500), public :: varmap_file = "NULL" - character(len=500), public :: atm_files_input_grid(6) = "NULL" !< File names of input - !< atmospheric data. Not used - !< for "grib2" or "restart" - !< input types. - character(len=500), public :: atm_core_files_input_grid(7) = "NULL" - character(len=500), public :: atm_tracer_files_input_grid(6) = "NULL" - character(len=500), public :: data_dir_input_grid = "NULL" - character(len=500), public :: fix_dir_target_grid = "NULL" - character(len=500), public :: mosaic_file_input_grid = "NULL" - character(len=500), public :: mosaic_file_target_grid = "NULL" - character(len=500), public :: nst_files_input_grid = "NULL" - character(len=500), public :: grib2_file_input_grid = "NULL" - character(len=500), public :: geogrid_file_input_grid = "NULL" - character(len=500), public :: orog_dir_input_grid = "NULL" - character(len=500), public :: orog_files_input_grid(6) = "NULL" - character(len=500), public :: orog_dir_target_grid = "NULL" - character(len=500), public :: orog_files_target_grid(6) = "NULL" - character(len=500), public :: sfc_files_input_grid(6) = "NULL" - character(len=500), public :: vcoord_file_target_grid = "NULL" - character(len=500), public :: thomp_mp_climo_file= "NULL" - character(len=6), public :: cres_target_grid = "NULL" - character(len=500), public :: atm_weight_file="NULL" - character(len=25), public :: input_type="restart" - character(len=20), public :: external_model="GFS" !Default assume gfs data - - + character(len=20), public :: external_model="GFS" !< The model that the input data is derived from. Current supported options are: "GFS", "HRRR", "NAM", "RAP". Default: "GFS" - character(len=500), public :: fix_dir_input_grid = "NULL" + character(len=500), public :: fix_dir_input_grid = "NULL" !< Directory containing files of latitude and + !! and longitude for certain GRIB2 input data. - integer, parameter, public :: max_tracers=100 - integer, public :: num_tracers, num_tracers_input + integer, parameter, public :: max_tracers=100 !< Maximum number of atmospheric tracers processed. + integer, public :: num_tracers !< Number of atmospheric tracers to be processed. + integer, public :: num_tracers_input !< Number of atmospheric tracers in input file. - logical, allocatable, public :: read_from_input(:) + logical, allocatable, public :: read_from_input(:) !< When false, variable was not read from GRIB2 + !! input file. - character(len=20), public :: tracers(max_tracers)="NULL" - character(len=20), public :: tracers_input(max_tracers)="NULL" - character(len=20), allocatable, public :: missing_var_methods(:) - character(len=20), allocatable, public :: chgres_var_names(:) - character(len=20), allocatable, public :: field_var_names(:) + character(len=20), public :: tracers(max_tracers)="NULL" !< Name of each atmos tracer to be processed. + !! These names will be used to identify + !! the tracer records in the output files. + !! Follows the convention in the field table. + !! FOR GRIB2 FILES: Not used. Tracers instead taken + !! from the varmap file. + character(len=20), public :: tracers_input(max_tracers)="NULL" !< Name of each atmos tracer record in + !! the input file. May be different from + !! value in 'tracers'. + !! FOR GRIB2 FILES: Not used. Tracers instead taken + !! from the varmap file. + character(len=20), allocatable, public :: missing_var_methods(:) !< Method to replace missing GRIB2 input + !! records. + character(len=20), allocatable, public :: chgres_var_names(:) !< Varmap table variable name as recognized + !! by this program. + character(len=20), allocatable, public :: field_var_names(:) !< The GRIB2 variable name in the varmap table. - integer, public :: cycle_mon = -999 - integer, public :: cycle_day = -999 - integer, public :: cycle_hour = -999 - integer, public :: regional = 0 - integer, public :: halo_bndy = 0 - integer, public :: halo_blend = 0 - integer, public :: nsoill_out = 4 - - logical, public :: convert_atm = .false. - logical, public :: convert_nst = .false. - logical, public :: convert_sfc = .false. + integer, public :: cycle_mon = -999 !< Cycle month. + integer, public :: cycle_day = -999 !< Cycle day. + integer, public :: cycle_hour = -999 !< Cycle hour. + integer, public :: regional = 0 !< For regional target grids. When '1' remove boundary halo region from atmospheric/surface data and + !! output atmospheric boundary file. When '2' output boundary file only. Default is '0' (global grids). + integer, public :: halo_bndy = 0 !< Number of row/cols of lateral halo, where pure lateral bndy conditions are applied (regional target grids). + integer, public :: halo_blend = 0 !< Number of row/cols of blending halo, where model tendencies and lateral boundary tendencies are applied. Regional target grids only. + integer, public :: nsoill_out = 4 !< Number of soil levels desired in the output data. chgres_cube can interpolate from 9 input to 4 output levels. DEFAULT: 4. + + logical, public :: convert_atm = .false. !< Convert atmospheric data when true. + logical, public :: convert_nst = .false. !< Convert nst data when true. + logical, public :: convert_sfc = .false. !< Convert sfc data when true. ! Options for replacing vegetation/soil type, veg fraction, and lai with data from the grib2 file ! Default is to use climatology instead - logical, public :: vgtyp_from_climo = .true. - logical, public :: sotyp_from_climo = .true. - logical, public :: vgfrc_from_climo = .true. - logical, public :: minmax_vgfrc_from_climo = .true. - logical, public :: lai_from_climo = .true. - logical, public :: tg3_from_soil = .false. - logical, public :: use_thomp_mp_climo=.false. - - real, allocatable, public :: drysmc_input(:), drysmc_target(:) - real, allocatable, public :: maxsmc_input(:), maxsmc_target(:) - real, allocatable, public :: refsmc_input(:), refsmc_target(:) - real, allocatable, public :: wltsmc_input(:), wltsmc_target(:) - real, allocatable, public :: bb_target(:), satpsi_target(:) - real, allocatable, public :: missing_var_values(:) + logical, public :: vgtyp_from_climo = .true. !< If false, interpolate vegetation type from the input + !! data to the target grid instead of using data from + !! static data. Use with caution as vegetation categories + !! can vary. Default: True. + logical, public :: sotyp_from_climo = .true. !< If false, interpolate soil type from the input + !! data to the target grid instead of using data from + !! static data. Use with caution as the code assumes + !! input soil type use STATSGO soil categories. + !! Default: True. + logical, public :: vgfrc_from_climo = .true. !< If false, interpolate vegetation fraction from the input + !! data to the target grid instead of using data from + !! static data. Use with caution as vegetation categories + !! can vary. Default: True. + + logical, public :: minmax_vgfrc_from_climo = .true. !< If false, interpolate min/max vegetation fraction from + !! the input data to the target grid instead of using data + !! from static data. Use with caution as vegetation + !! categories can vary. Default: True. + logical, public :: lai_from_climo = .true. !< If false, interpolate leaf area index from the input + !! data to the target grid instead of using data from + !! static data. Default: True. + logical, public :: tg3_from_soil = .false. !< If false, use lowest level soil temperature for the + !! base soil temperature instead of using data from + !! static data. Default: False. + logical, public :: use_thomp_mp_climo=.false. !< When true, read and process Thompson MP climatological tracers. False, when 'thomp_mp_climo_file' is NULL. + + real, allocatable, public :: drysmc_input(:) !< Air dry soil moisture content input grid. + real, allocatable, public :: drysmc_target(:) !< Air dry soil moisture content target grid. + real, allocatable, public :: maxsmc_input(:) !< Maximum soil moisture content input grid. + real, allocatable, public :: maxsmc_target(:) !< Maximum soil moisture content target grid. + real, allocatable, public :: refsmc_input(:) !< Reference soil moisture content input grid (onset of soil moisture stress). + real, allocatable, public :: refsmc_target(:) !< Reference soil moisture content target grid (onset of soil moisture stress). + real, allocatable, public :: wltsmc_input(:) !< Plant wilting point soil moisture content input grid. + real, allocatable, public :: wltsmc_target(:) !< Plant wilting point soil moisture content target grid. + real, allocatable, public :: bb_target(:) !< Soil 'b' parameter, target grid + real, allocatable, public :: satpsi_target(:) !< Saturated soil potential, target grid + real, allocatable, public :: missing_var_values(:) !< If input GRIB2 record is missing, the variable + !! is set to this value. public :: read_setup_namelist diff --git a/sorc/chgres_cube.fd/search_util.f90 b/sorc/chgres_cube.fd/search_util.f90 index 816a20a47..15d6750ce 100644 --- a/sorc/chgres_cube.fd/search_util.f90 +++ b/sorc/chgres_cube.fd/search_util.f90 @@ -1,12 +1,11 @@ !> @file !! @brief Replace undefined surface values. !! -!! @author George Gayno NCEP/EMC -!! !! Replace undefined values with a valid value. This can !! happen for an isolated lake or island that is unresolved by !! the input grid. !! +!! @author George Gayno NCEP/EMC module search_util private @@ -15,18 +14,29 @@ module search_util contains -!! Replace undefined surface values. +!> Replace undefined surface values. +!! !! Replace undefined values on the model grid with a valid value at !! a nearby neighbor. Undefined values are typically associated !! with isolated islands where there is no source data. +!! !! Routine searches a neighborhood with a radius of 100 grid points. !! If no valid value is found, a default value is used. +!! !! This routine works for one tile of a cubed sphere grid. It !! does not consider valid values at adjacent faces. That is a !! future upgrade. -!! @param terrain_land - 2D field of terrain height points. -!! @param soilt_climo - 2D field of soil type points. - +!! +!! @param [inout] field On input/output, surface data with undefined/no undefined values. +!! @param [in] mask land-mask of surface data. +!! @param [in] idim 'i' dimension of tile +!! @param [in] jdim 'j' dimension of tile +!! @param [in] tile tile number +!! @param [in] field_num surface field number +!! @param [in] latitude latitude of the surface data +!! @param [in] terrain_land terrain height +!! @param [in] soilt_climo climatological soil type +!! @author George Gayno NCEP/EMC subroutine search (field, mask, idim, jdim, tile, field_num, latitude, terrain_land, soilt_climo) use mpi @@ -199,10 +209,11 @@ subroutine search (field, mask, idim, jdim, tile, field_num, latitude, terrain_l end subroutine search -!> set sst values based on latitude +!> Set sst values based on latitude. +!! +!! @param latitude latitude input +!! @param sst sst guess value to be set !! @author George Gayno NCEP/EMC -!! @param latitude - latitude input -!! @param sst - sst guess value to be set subroutine sst_guess(latitude, sst) use esmf diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index a4d055b71..19ff3feb2 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -1,17 +1,17 @@ !> @file !! @brief Process surface and nst fields. !! -!! @author gayno NCEP/EMC -!! -!! Process surface and nst fields. Interpolates fields from -!! the input to target grids. Adjusts soil temperature according -!! to differences in input and target grid terrain. Rescales -!! soil moisture for soil type differences between input and target -!! grid. Computes frozen portion of total soil moisture. +!! Process surface and nst fields. Interpolates fields from the input +!! to target grids. Adjusts soil temperature according to differences +!! in input and target grid terrain. Rescales soil moisture for soil +!! type differences between input and target grid. Computes frozen +!! portion of total soil moisture. !! -!! Public variables are defined below. "target" indicates field +!! Public variables are defined below. "target" indicates field !! associated with the target grid. "input" indicates field associated !! with the input grid. +!! +!! @author gayno NCEP/EMC module surface use esmf @@ -25,87 +25,109 @@ module surface ! surface fields (not including nst) type(esmf_field), public :: canopy_mc_target_grid - ! canopy moisture content + !< canopy moisture content type(esmf_field), public :: f10m_target_grid - ! log((z0+10)*1/z0) - ! See sfc_diff.f for details + !< log((z0+10)*1/z0) + !< See sfc_diff.f for details type(esmf_field), public :: ffmm_target_grid - ! log((z0+z1)*1/z0) - ! See sfc_diff.f for details + !< log((z0+z1)*1/z0) + !< See sfc_diff.f for details type(esmf_field), public :: q2m_target_grid - ! 2-m specific humidity + !< 2-m specific humidity type(esmf_field), public :: seaice_depth_target_grid - ! sea ice depth + !< sea ice depth type(esmf_field), public :: seaice_fract_target_grid - ! sea ice fraction + !< sea ice fraction type(esmf_field), public :: seaice_skin_temp_target_grid - ! sea ice skin temperature + !< sea ice skin temperature type(esmf_field), public :: skin_temp_target_grid - ! skin temperature/sst + !< skin temperature/sst type(esmf_field), public :: srflag_target_grid - ! snow/rain flag + !< snow/rain flag type(esmf_field), public :: snow_liq_equiv_target_grid - ! liquid equiv snow depth + !< liquid equiv snow depth type(esmf_field), public :: snow_depth_target_grid - ! physical snow depth + !< physical snow depth type(esmf_field), public :: soil_temp_target_grid - ! 3-d soil temperature + !< 3-d soil temperature type(esmf_field), public :: soilm_liq_target_grid - ! 3-d liquid soil moisture + !< 3-d liquid soil moisture type(esmf_field), public :: soilm_tot_target_grid - ! 3-d total soil moisture + !< 3-d total soil moisture type(esmf_field), public :: t2m_target_grid - ! 2-m temperatrure + !< 2-m temperatrure type(esmf_field), public :: tprcp_target_grid - ! precip + !< precip type(esmf_field), public :: ustar_target_grid - ! friction velocity + !< friction velocity type(esmf_field), public :: z0_target_grid - ! roughness length + !< roughness length type(esmf_field), public :: lai_target_grid - ! leaf area index + !< leaf area index ! nst fields type(esmf_field), public :: c_d_target_grid + !< Coefficient 2 to calculate d(tz)/d(ts) type(esmf_field), public :: c_0_target_grid + !< Coefficient 1 to calculate d(tz)/d(ts) type(esmf_field), public :: d_conv_target_grid + !< Thickness of free convection layer type(esmf_field), public :: dt_cool_target_grid + !< Sub-layer cooling amount type(esmf_field), public :: ifd_target_grid + !< Model mode index. 0-diurnal model not + !< started; 1-diurnal model started. type(esmf_field), public :: qrain_target_grid + !< Sensible heat flux due to rainfall type(esmf_field), public :: tref_target_grid - ! reference temperature + !< reference temperature type(esmf_field), public :: w_d_target_grid + !< Coefficient 4 to calculate d(tz)/d(ts) type(esmf_field), public :: w_0_target_grid + !< Coefficient 3 to calculate d(tz)/d(ts) type(esmf_field), public :: xs_target_grid + !< Salinity content in diurnal + !< thermocline layer type(esmf_field), public :: xt_target_grid + !< Heat content in diurnal thermocline + !< layer type(esmf_field), public :: xu_target_grid + !< u-current content in diurnal + !< thermocline layer type(esmf_field), public :: xv_target_grid + !< v-current content in diurnal + !< thermocline layer type(esmf_field), public :: xz_target_grid + !< Diurnal thermocline layer thickness type(esmf_field), public :: xtts_target_grid + !< d(xt)/d(ts) type(esmf_field), public :: xzts_target_grid + !< d(xz)/d(ts) type(esmf_field), public :: z_c_target_grid + !< Sub-layer cooling thickness type(esmf_field), public :: zm_target_grid + !< Oceanic mixed layer depth type(esmf_field) :: soil_type_from_input_grid - ! soil type interpolated from - ! input grid + !< soil type interpolated from + !< input grid type(esmf_field) :: terrain_from_input_grid - ! terrain height interpolated - ! from input grid + !< terrain height interpolated + !< from input grid type(esmf_field) :: terrain_from_input_grid_land - ! terrain height interpolated - ! from input grid at all land points + !< terrain height interpolated + !< from input grid at all land points real, parameter, private :: blim = 5.5 - ! soil 'b' parameter limit + !< soil 'b' parameter limit real, parameter, private :: frz_h2o = 273.15 - ! melting pt water + !< melting pt water real, parameter, private :: frz_ice = 271.21 - ! melting pt sea ice + !< melting pt sea ice real, parameter, private :: grav = 9.81 - ! gravity + !< gravity real, parameter, private :: hlice = 3.335E5 - ! latent heat of fusion + !< latent heat of fusion public :: surface_driver @@ -268,10 +290,9 @@ subroutine surface_driver(localpet) end subroutine surface_driver -!--------------------------------------------------------------------------------------------- -! Horizontally interpolate surface fields using esmf routines. -!--------------------------------------------------------------------------------------------- - +!> Horizontally interpolate surface fields using esmf routines. +!! +!! @author George Gayno NOAA/EMC subroutine interp(localpet) use mpi @@ -2482,10 +2503,9 @@ subroutine interp(localpet) end subroutine interp -!--------------------------------------------------------------------------------------------- -! Compute liquid portion of the total soil moisture. -!--------------------------------------------------------------------------------------------- - +!> Compute liquid portion of the total soil moisture. +!! +!! @author George Gayno NOAA/EMC subroutine calc_liq_soil_moisture use esmf @@ -2749,14 +2769,16 @@ end subroutine calc_liq_soil_moisture ! !end subroutine check_smois_water - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!> Check soil mositure +!! !! When using vegetation type from the input data instead of the orography file, there !! are frequently points with ~0 soil moisture at land points. For these points, set !! values in all relevant target grid surface arrays to fill values (done in !! check_smois_land) then run the search routine again to fill with appropriate values !! from nearby points (done in replace_land_sfcparams). -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! +!! @author Larissa Reames +!! @author Jeff Beck subroutine check_smois_land use model_grid, only : landmask_target_grid @@ -2930,14 +2952,17 @@ subroutine check_smois_land !call search(soilm_target_ptr(clb(1):cub(1),clb(2):cub(2), end subroutine check_smois_land - -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!> Replace bad surface points. +!! !! When using vegetation type from the input data instead of the orography file, there !! are frequently points with ~0 soil moisture at land points. For these points, set !! values in all relevant target grid surface arrays to fill values (done in !! check_smois_land) then run the search routine again to fill with appropriate values !! from nearby points (done in replace_land_sfcparams). -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! +!! @param[in] localpet ESMF local persistent execution thread +!! @author Larissa Reames +!! @author Jeff Beck subroutine replace_land_sfcparams(localpet) use search_util @@ -3117,51 +3142,31 @@ subroutine replace_land_sfcparams(localpet) end subroutine replace_land_sfcparams - +!> Calculate supercooled soil moisture +!! +!! Calculate amount of supercooled liquid soil water content if +!! temperature is below 273.15K. Requires Newton-type iteration to +!! solve the nonlinear implicit equation given in eqn 17 of Koren et. al +!! (1999, JGR, VOL 104(D16), 19569-19585). +!! +!! New version (June 2001): Much faster and more accurate Newton +!! iteration achieved by first taking log of eqn cited above -- less than +!! 4 (typically 1 or 2) iterations achieves convergence. Also, explicit +!! 1-step solution option for special case of parameter ck=0, which +!! reduces the original implicit equation to a simpler explicit form, +!! known as the "Flerchinger eqn". Improved handling of solution in the +!! limit of freezing point temperature. +!! +!! @param[in] tkelv Temperature (Kelvin) +!! @param[in] smc Total soil moisture content (volumetric) +!! @param[in] sh2O Liquid soil moisture content (volumetric) +!! @param[in] smcmax Saturation soil moisture content +!! @param[in] bexp Soil type "b" parameter +!! @param[in] psis Saturated soil matric potential +!! @return frh2O Supercooled liquid water content +!! +!! @author George Gayno NOAA/EMC @date 2005-05-20 FUNCTION FRH2O (TKELV,SMC,SH2O,SMCMAX,BEXP,PSIS) -!$$$ function documentation block -! -! function: frh2o -! prgmmr: gayno org: w/np2 date: 2005-05-20 -! -! abstract: calculate supercooled soil moisture -! -! program history log: -! 2005-05-20 gayno - initial version -! -! usage: x = frh2o (tkelv,smc,sh2o,smcmax,bexp,psis) -! -! input argument list: -! tkelv - temperature (Kelvin) -! smc - total soil moisture content (volumetric) -! sh2O - liquid soil moisture content (volumetric) -! smcmax - saturation soil moisture content -! b - soil type "b" parameter -! psis - saturated soil matric potential -! -! output argument list: -! frh2O - supercooled liquid water content -! -! remarks: stolen from noah lsm code -! -! CALCULATE AMOUNT OF SUPERCOOLED LIQUID SOIL WATER CONTENT IF -! TEMPERATURE IS BELOW 273.15K (T0). REQUIRES NEWTON-TYPE ITERATION TO -! SOLVE THE NONLINEAR IMPLICIT EQUATION GIVEN IN EQN 17 OF KOREN ET AL -! (1999, JGR, VOL 104(D16), 19569-19585). -! -! NEW VERSION (JUNE 2001): MUCH FASTER AND MORE ACCURATE NEWTON -! ITERATION ACHIEVED BY FIRST TAKING LOG OF EQN CITED ABOVE -- LESS THAN -! 4 (TYPICALLY 1 OR 2) ITERATIONS ACHIEVES CONVERGENCE. ALSO, EXPLICIT -! 1-STEP SOLUTION OPTION FOR SPECIAL CASE OF PARAMETER CK=0, WHICH -! REDUCES THE ORIGINAL IMPLICIT EQUATION TO A SIMPLER EXPLICIT FORM, -! KNOWN AS THE "FLERCHINGER EQN". IMPROVED HANDLING OF SOLUTION IN THE -! LIMIT OF FREEZING POINT TEMPERATURE [AT0. -! -! attributes: -! language: fortran 90 -! machine: IBM SP -! -!$$$ use esmf @@ -3294,10 +3299,10 @@ FUNCTION FRH2O (TKELV,SMC,SH2O,SMCMAX,BEXP,PSIS) END function frh2o -!--------------------------------------------------------------------------------------------- -! Adjust soil moisture for changes in soil type between the input and target grids. -!--------------------------------------------------------------------------------------------- - +!> Adjust soil moisture for changes in soil type between the input and target grids. +!! Works for Noah land model only. +!! +!! @author George Gayno NOAA/EMC subroutine rescale_soil_moisture use esmf @@ -3462,11 +3467,10 @@ subroutine rescale_soil_moisture end subroutine rescale_soil_moisture -!--------------------------------------------------------------------------------------------- -! Adjust soil temperature for changes in terrain height between the input and -! target grids. -!--------------------------------------------------------------------------------------------- - +!> Adjust soil temperature for changes in terrain height between the input and +!! target grids. +!! +!! @author George Gayno NOAA/EMC subroutine adjust_soilt_for_terrain use model_grid, only : landmask_target_grid, & @@ -3537,11 +3541,12 @@ subroutine adjust_soilt_for_terrain end subroutine adjust_soilt_for_terrain -!--------------------------------------------------------------------------------------------- -! Adjust soil levels of the input grid if there's a mismatch between input and -! target grids. Presently can only convert from 9 to 4 levels. -!--------------------------------------------------------------------------------------------- - +!> Adjust soil levels of the input grid if there is a mismatch between input and +!! target grids. Presently can only convert from 9 to 4 levels. +!! +!! @param[in] localpet ESMF local persistent execution thread +!! @author Larissa Reames +!! @author Jeff Beck subroutine adjust_soil_levels(localpet) use model_grid, only : lsoil_target, i_input, j_input, input_grid use input_data, only : lsoil_input, soil_temp_input_grid, & @@ -3653,10 +3658,9 @@ subroutine adjust_soil_levels(localpet) end subroutine adjust_soil_levels -!--------------------------------------------------------------------------------------------- -! Set roughness at land and sea ice. -!--------------------------------------------------------------------------------------------- - +!> Set roughness length at land and sea ice. +!! +!! @author George Gayno NOAA/EMC subroutine roughness use model_grid, only : landmask_target_grid @@ -3708,10 +3712,9 @@ subroutine roughness end subroutine roughness -!--------------------------------------------------------------------------------------------- -! QC data before output. -!--------------------------------------------------------------------------------------------- - +!> Perform some quality control checks before output. +!! +!! @author George Gayno NOAA/EMC subroutine qc_check use model_grid, only : landmask_target_grid @@ -4043,11 +4046,10 @@ subroutine qc_check end subroutine qc_check -!--------------------------------------------------------------------------------------------- -! nst is not active at land or sea ice points. Set nst fields to flag values at these -! points. -!--------------------------------------------------------------------------------------------- - +!> nst is not active at land or sea ice points. Set nst fields to flag values at these +!! points. +!! +!! @author George Gayno NOAA/EMC subroutine nst_land_fill use model_grid, only : landmask_target_grid @@ -4254,6 +4256,9 @@ subroutine nst_land_fill end subroutine nst_land_fill +!> Create ESMF fields for the target grid surface variables +!! +!! @author George Gayno NOAA/EMC subroutine create_surface_esmf_fields use model_grid, only : target_grid, lsoil_target @@ -4588,6 +4593,9 @@ subroutine create_surface_esmf_fields end subroutine create_surface_esmf_fields +!> Create ESMF fields for the target grid nst variables +!! +!! @author George Gayno subroutine create_nst_esmf_fields use model_grid, only : target_grid @@ -4724,6 +4732,14 @@ subroutine create_nst_esmf_fields end subroutine create_nst_esmf_fields +!> Convert 1d index to 2d indices. +!! +!! @param[in] ij the 1d index +!! @param[in] itile i-dimension of the tile +!! @param[in] jtile j-dimension of the tile +!! @param[out] i the "i" index +!! @param[out] j the "j" index +!! @author George Gayno NOAA/EMC subroutine ij_to_i_j(ij, itile, jtile, i, j) implicit none