diff --git a/sorc/chgres_cube.fd/atmosphere.F90 b/sorc/chgres_cube.fd/atmosphere.F90 index 53ae2d077..7f5b4cbcf 100644 --- a/sorc/chgres_cube.fd/atmosphere.F90 +++ b/sorc/chgres_cube.fd/atmosphere.F90 @@ -1,30 +1,22 @@ +!> @file +!! @brief Process atmospheric fields +!! +!! @author gayno NCEP/EMC +!! +!! Process atmospheric fields: Horizontally interpolate input +!! fields to the target grid. Adjust surface pressure according to +!! terrain difference between input and target grids. Vertically +!! interpolate to target grid vertical levels. Processing based on +!! the spectral GFS version of CHGRES. +!! +!! Variables defined below. Here "b4adj" indicates fields on the target +!! grid before vertical adjustment. "target" indicates data on target +!! grid. "input" indicates data on input grid. "_s" indicates fields +!! on the 'south' edge of the grid box. "_w" indicate fields on the +!! 'west' edge of the grid box. Otherwise, fields are at the center +!! of the grid box. module atmosphere -!-------------------------------------------------------------------------- -! Module atmosphere -! -! Abstract: Process atmospheric fields: Horizontally interpolate input -! fields to the target grid. Adjust surface pressure according to -! terrain difference between input and target grids. Vertically -! interpolate to target grid vertical levels. Processing based on -! the spectral GFS version of CHGRES. -! -! Public Subroutines: -! ------------------- -! atmosphere driver Driver routine for processing atmospheric -! fields -! -! Public variables: -! ----------------- -! Variables defined below. Here "b4adj" indicates fields on the target -! grid before vertical adjustment. "target" indicates data on target -! grid. "input" indicates data on input grid. "_s" indicates fields -! on the 'south' edge of the grid box. "_w" indicate fields on the -! 'west' edge of the grid box. Otherwise, fields are at the center -! of the grid box. -! -!-------------------------------------------------------------------------- - use esmf use input_data, only : lev_input, & @@ -138,10 +130,9 @@ module atmosphere contains -!----------------------------------------------------------------------------------- -! Driver routine for atmospheric fields. -!----------------------------------------------------------------------------------- - +!> @brief +!! Driver routine for atmospheric fields. +!! subroutine atmosphere_driver(localpet) use mpi diff --git a/sorc/chgres_cube.fd/chgres.F90 b/sorc/chgres_cube.fd/chgres.F90 index 20d6b94cc..3aace4ba8 100644 --- a/sorc/chgres_cube.fd/chgres.F90 +++ b/sorc/chgres_cube.fd/chgres.F90 @@ -1,14 +1,14 @@ +!> @file +!! @brief Initialize an FV3 model run. +!! +!! Program CHGRES_CUBE +!! +!! 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. +!! program chgres -!------------------------------------------------------------------------- -! Program CHGRES -! -! Abstract: Initialize an FV3 run using history or restart data from -! another FV3 run, or the NEMS version of the spectral GFS. -! Converts atmospheric, surface and nst data. -! -!------------------------------------------------------------------------- - use mpi use esmf diff --git a/sorc/chgres_cube.fd/grib2_util.F90 b/sorc/chgres_cube.fd/grib2_util.F90 index 195d5c71d..ebdb1dfc5 100644 --- a/sorc/chgres_cube.fd/grib2_util.F90 +++ b/sorc/chgres_cube.fd/grib2_util.F90 @@ -1,12 +1,8 @@ +!> @file +!! @brief Utilities for use when reading grib2 data. +!! module grib2_util -!-------------------------------------------------------------------------- -! Module: grib2_util -! -! Abstract: Utilities for use when reading grib2 data. -! -!-------------------------------------------------------------------------- - use esmf use model_grid, only : i_input, j_input diff --git a/sorc/chgres_cube.fd/input_data.F90 b/sorc/chgres_cube.fd/input_data.F90 index 66691a845..78005194c 100644 --- a/sorc/chgres_cube.fd/input_data.F90 +++ b/sorc/chgres_cube.fd/input_data.F90 @@ -1,28 +1,17 @@ +!> @file +!! @brief Read input data +!! @author gayno NCEP/EMC +!! +!! Read atmospheric, surface and nst data on the input grid. +!! Supported formats include fv3 tiled 'restart' files, fv3 tiled +!! 'history' files, fv3 gaussian history files, spectral gfs +!! gaussian nemsio files, and spectral gfs sigio/sfcio files. +!! +!! Public variables are defined below: "input" indicates field +!! associated with the input grid. +!! module input_data -!-------------------------------------------------------------------------- -! Module input_data -! -! Abstract: Read atmospheric, surface and nst data on the input grid. -! Supported formats include fv3 tiled 'restart' files, fv3 tiled -! 'history' files, fv3 gaussian history files, spectral gfs -! gaussian nemsio files, and spectral gfs sigio/sfcio files. -! -! Public Subroutines: -! ----------------- -! read_input_atm_data Driver routine to read atmospheric data -! cleanup_input_atm_data Free up memory associated with atm data -! read_input_sfc_data Driver routine to read surface data -! cleanup_input_sfc_data Free up memory associated with sfc data -! read_input_nst_data Driver routine to read nst data -! cleanup_input_nst_data Free up memory associated with nst data -! -! Public variables: -! ----------------- -! Defined below. "input" indicates field associated with the input grid. -! -!-------------------------------------------------------------------------- - use esmf use netcdf use nemsio_module @@ -52,7 +41,7 @@ module input_data num_tiles_input_grid, & latitude_input_grid, & longitude_input_grid, & - inv_file!, the_file_hrrr + inv_file implicit none @@ -143,10 +132,9 @@ module input_data contains -!--------------------------------------------------------------------------- -! Read input grid atmospheric data driver -!--------------------------------------------------------------------------- - +!> @brief +!! Read input grid atmospheric data driver +!! subroutine read_input_atm_data(localpet) implicit none @@ -213,10 +201,9 @@ subroutine read_input_atm_data(localpet) end subroutine read_input_atm_data -!--------------------------------------------------------------------------- -! Read input grid nst data driver -!--------------------------------------------------------------------------- - +!> @brief +!! Driver to read input grid nst data. +!! subroutine read_input_nst_data(localpet) implicit none @@ -375,10 +362,9 @@ subroutine read_input_nst_data(localpet) end subroutine read_input_nst_data -!--------------------------------------------------------------------------- -! Read input grid surface data driver. -!--------------------------------------------------------------------------- - +!> @brief +!! Driver to read input grid surface data. +!! subroutine read_input_sfc_data(localpet) implicit none @@ -6428,6 +6414,9 @@ subroutine read_grib_soil(the_file,inv_file,vname,vname_file,dummy3d,rc) end subroutine read_grib_soil +!> @brief +!! Free up memory associated with atm data +!! subroutine cleanup_input_atm_data implicit none @@ -6450,6 +6439,9 @@ subroutine cleanup_input_atm_data end subroutine cleanup_input_atm_data +!> @brief +!! Free up memory associated with nst data +!! subroutine cleanup_input_nst_data implicit none @@ -6480,6 +6472,9 @@ subroutine cleanup_input_nst_data end subroutine cleanup_input_nst_data +!> @brief +!! Free up memory associated with sfc data +!! subroutine cleanup_input_sfc_data implicit none diff --git a/sorc/chgres_cube.fd/model_grid.F90 b/sorc/chgres_cube.fd/model_grid.F90 index 6258ce44d..0e4221e03 100644 --- a/sorc/chgres_cube.fd/model_grid.F90 +++ b/sorc/chgres_cube.fd/model_grid.F90 @@ -1,60 +1,12 @@ +!> @file +!! @brief Specify input and target model grids +!! +!! @author gayno NCEP/EMC +!! +!! Specify input and target model grids via ESMF grid objects. +!! module model_grid -!-------------------------------------------------------------------------- -! Module model_grid -! -! Abstract: Specify input and target model grids -! -! Public Subroutines: -! ------------------- -! define_target_grid Setup the esmf grid object for the -! target grid. -! define_input_grid Setup the esmf grid object for the -! input grid. -! cleanup_input_target_grid_data Deallocate all esmf grid objects. -! -! Public variables: -! ----------------- -! i/j_input i/j dimension of each cube of the -! input grid. -! ip1/jp1_input i/j dimension plus 1 of input grid. -! i/j_target i/j dimension of each cube or of -! a nest, target grid. -! ip1/jp1_target i/j dimension plus 1 of input grid. -! input_grid input grid esmf grid object -! landmask_target_grid land mask target grid - '1' land; -! '0' non-land -! latitude_input_grid latitude of grid center, input grid -! latitude_target_grid latitude of grid center, target grid -! latitude_s_input_grid latitude of 'south' edge of grid -! box, input grid -! latitude_s_target_grid latitude of 'south' edge of grid -! box, target grid -! latitude_w_input_grid latitude of 'west' edge of grid -! box, input grid -! latitude_w_target_grid latitude of 'west' edge of grid -! box, target grid -! longitude_input_grid longitude of grid center, input grid -! longitude_target_grid longitude of grid center, target grid -! longitude_s_input_grid longitude of 'south' edge of grid -! box, input grid -! longitude_s_target_grid longitude of 'south' edge of grid -! box, target grid -! longitude_w_input_grid longitude of 'west' edge of grid -! box, input grid -! longitude_w_target_grid longitude of 'west' edge of grid -! box, target grid -! lsoil_target Number of soil layers, target grid. -! num_tiles_input_grid Number of tiles, input grid -! num_tiles_target_grid Number of tiles, target grid -! seamask_target_grid sea mask target grid - '1' non-land; -! '0' land -! target_grid target grid esmf grid object. -! terrain_target_grid terrain height target grid -! tiles_target_grid Tile names of target grid. -! -!-------------------------------------------------------------------------- - use esmf use ESMF_LogPublicMod @@ -63,39 +15,86 @@ module model_grid private character(len=5), allocatable, public :: tiles_target_grid(:) + !< Tile names of target grid. character(len=10), public :: inv_file = "chgres.inv" + !< wgrib2 inventory file character(len=50), public :: input_grid_type = "latlon" - !character(len=100), public :: the_file_hrrr = "./HRRR_adj_rad.grib2" + !< map projection of input grid ! Made lsoil_target non-parameter to allow for RAP land surface initiation integer, public :: lsoil_target = 4 ! # soil layers - - integer, public :: i_input, j_input - integer, public :: ip1_input, jp1_input - integer, public :: i_target, j_target - integer, public :: ip1_target, jp1_target + !< Number of soil layers, target grid. + integer, public :: i_input + !< i-dimension of input grid + !! (or of each global tile) + integer, public :: j_input + !< j-dimension of input grid + !! (or of each global tile) + integer, public :: ip1_input + !< i_input plus 1 + integer, public :: jp1_input + !< j_input plus 1 + integer, public :: i_target + !< i dimension of each global tile, + !! or of a nest, target grid. + integer, public :: j_target + !< j dimension of each global tile, + !! or of a nest, target grid. + integer, public :: ip1_target + !< ip1_target plus 1 + integer, public :: jp1_target + !< jp1_target plus 1 integer, public :: num_tiles_input_grid + !< Number of tiles, input grid integer, public :: num_tiles_target_grid + !< Number of tiles, target grid type(esmf_grid), public :: input_grid + !< input grid esmf grid object type(esmf_grid), public :: target_grid + !< target grid esmf grid object. type(esmf_field), public :: latitude_input_grid + !< latitude of grid center, input grid type(esmf_field), public :: longitude_input_grid + !< longitude of grid center, input grid type(esmf_field), public :: latitude_s_input_grid + !< latitude of 'south' edge of grid + !! box, input grid type(esmf_field), public :: longitude_s_input_grid + !< longitude of 'south' edge of grid + !! box, input grid type(esmf_field), public :: latitude_w_input_grid + !< latitude of 'west' edge of grid + !! box, input grid type(esmf_field), public :: longitude_w_input_grid + !< longitude of 'west' edge of grid + !! box, input grid type(esmf_field), public :: landmask_target_grid + !< land mask target grid - '1' land; + !! '0' non-land type(esmf_field), public :: latitude_target_grid + !< latitude of grid center, target grid type(esmf_field), public :: latitude_s_target_grid + !< latitude of 'south' edge of grid + !! box, target grid type(esmf_field), public :: latitude_w_target_grid + !< latitude of 'west' edge of grid + !! box, target grid type(esmf_field), public :: longitude_target_grid + !< longitude of grid center, target grid type(esmf_field), public :: longitude_s_target_grid + !< longitude of 'south' edge of grid + !! box, target grid type(esmf_field), public :: longitude_w_target_grid + !< longitude of 'west' edge of grid + !! box, target grid type(esmf_field), public :: seamask_target_grid + !< sea mask target grid - '1' non-land; + !! '0' land type(esmf_field), public :: terrain_target_grid + !< terrain height target grid public :: define_target_grid public :: define_input_grid @@ -103,15 +102,14 @@ module model_grid contains -!-------------------------------------------------------------------------- -! Set up the esmf grid object for the input grid. If the input -! source is tiled fv3 restart or history data, the grid is created -! by reading the mosaic and grid files. If the input source is -! fv3 global gaussian nemsio, spectral gfs global gaussian nemsio, or -! spectral gfs global gaussian sigio/sfcio, the grid is setup by -! computing lat/lons using the sp library. -!-------------------------------------------------------------------------- - +!> @brief Setup the esmf grid object for the input grid. +!! +!! If the input source is tiled fv3 restart or history data, the grid is +!! created by reading the mosaic and grid files. If the input source is +!! fv3 global gaussian nemsio, spectral gfs global gaussian nemsio, or +!! spectral gfs global gaussian sigio/sfcio, the grid is setup by +!! computing lat/lons using the sp library. +!! subroutine define_input_grid(localpet, npets) use program_setup, only : input_type, external_model @@ -1081,6 +1079,9 @@ subroutine define_input_grid_grib2(localpet, npets) end subroutine define_input_grid_grib2 +!> @brief +!! Setup the esmf grid object for the target grid. +!! subroutine define_target_grid(localpet, npets) use netcdf @@ -1643,6 +1644,8 @@ subroutine get_model_mask_terrain(orog_file, idim, jdim, mask, terrain) end subroutine get_model_mask_terrain +!> @brief Deallocate all esmf grid objects. +!! subroutine cleanup_input_target_grid_data implicit none diff --git a/sorc/chgres_cube.fd/program_setup.f90 b/sorc/chgres_cube.fd/program_setup.f90 index 2b2d6ba65..7bf070e93 100644 --- a/sorc/chgres_cube.fd/program_setup.f90 +++ b/sorc/chgres_cube.fd/program_setup.f90 @@ -1,166 +1,158 @@ +!> @file +!! @brief Set up program execution +!! +!! @author gayno NCEP/EMC +!! +!! Set up program execution +!! +!! Public variables: +!! +!! - atm_files_input_grid - File names of input atmospheric data. +!! Not used for "grib2" or "restart" +!! input types. +!! - 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: +!! - "restart" for fv3 tiled warm restart +!! files (netcdf). +!! - "history" for fv3 tiled history files +!! (netcdf). +!! - "gaussian_nemsio" for fv3 gaussian +!! nemsio files; +!! - "gaussian_netcdf" for fv3 gaussian +!! netcdf files. +!! - "grib2" for grib2 files. +!! - "gfs_gaussian_nemsio" for spectral gfs +!! 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 - 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 -!-------------------------------------------------------------------------- -! Module program_setup -! -! Abstract: Set up program execution -! -! Public Subroutines: -! ------------------- -! read_setup_namelist Reads configuration namelist -! calc_soil_params_driver Computes soil parameters -! -! Public variables: -! ----------------- -! atm_files_input_grid File names of input atmospheric data. -! Not used for "grib2" or "restart" -! input types. -! 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: -! (1) "restart" for fv3 tiled warm restart -! files (netcdf). -! (2) "history" for fv3 tiled history files -! (netcdf). -! (3) "gaussian_nemsio" for fv3 gaussian -! nemsio files; -! (4) "gaussian_netcdf" for fv3 gaussian -! netcdf files. -! (5) "grib2" for grib2 files. -! (6) "gfs_gaussian_nemsio" for spectral gfs -! gaussian nemsio files -! (7) "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 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 -! -!-------------------------------------------------------------------------- - implicit none private @@ -242,6 +234,10 @@ module program_setup contains +!> @brief Reads configuration namelist. +!! +!! @author gayno NCEP/EMC +!! subroutine read_setup_namelist implicit none @@ -295,7 +291,6 @@ subroutine read_setup_namelist close (41) call to_lower(input_type) -! call to_upper(phys_suite) orog_dir_target_grid = trim(orog_dir_target_grid) // '/' orog_dir_input_grid = trim(orog_dir_input_grid) // '/' @@ -517,6 +512,10 @@ subroutine get_var_cond(var_name,this_miss_var_method,this_miss_var_value, & end subroutine get_var_cond +!> @brief Compute soil parameters. +!! +!! @author gayno NCEP/EMC +!! subroutine calc_soil_params_driver(localpet) implicit none diff --git a/sorc/chgres_cube.fd/search_util.f90 b/sorc/chgres_cube.fd/search_util.f90 index e5bec9c53..6239b8c9c 100644 --- a/sorc/chgres_cube.fd/search_util.f90 +++ b/sorc/chgres_cube.fd/search_util.f90 @@ -1,39 +1,34 @@ +!> @file +!! @brief Replace undefined surface values. +!! +!! @author 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. +!! module search_util -!-------------------------------------------------------------------------- -! Module search -! -! Abstract: Replace undefined values with a valid value. This can -! happen for an isolated lake or island that is unresolved by -! the input grid. -! -! Public Subroutines: -! ------------------- -! search Performs the search and replace. -! -!-------------------------------------------------------------------------- - private public :: search contains +!> @brief 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. +!! +!! @note 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. subroutine search (field, mask, idim, jdim, tile, field_num, latitude, terrain_land, soilt_climo) -!----------------------------------------------------------------------- -! 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. -! -! Note: 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. -!----------------------------------------------------------------------- - use mpi use esmf diff --git a/sorc/chgres_cube.fd/static_data.F90 b/sorc/chgres_cube.fd/static_data.F90 index 3bd297475..5386e8dc7 100644 --- a/sorc/chgres_cube.fd/static_data.F90 +++ b/sorc/chgres_cube.fd/static_data.F90 @@ -1,40 +1,33 @@ +!> @file +!! @brief Process static surface data +!! +!! @author gayno NCEP/EMC +!! +!! Read pre-computed static/climatological data on the fv3 +!! target grid. Time interpolate if necessary (for example a +!! monthly climo field). +!! +!! Public variables: +!! +!! - alnsf_target_grid - near ir black sky albedo +!! - alnwf_target_grid - near ir white sky albedo +!! - alvsf_target_grid - visible black sky albedo +!! - alvwf_target_grid - visible white sky albedo +!! - facsf_target_grid - fractional coverage for strong +!! zenith angle dependent albedo +!! - facwf_target_grid - fractional coverage for weak +!! zenith angle dependent albedo +!! - max_veg_greenness_target_grid - maximum annual greenness fraction +!! - min_veg_greenness_target_grid - minimum annual greenness fraction +!! - mxsno_albedo_target_grid - maximum snow albedo +!! - slope_type_target_grid - slope type +!! - soil_type_target_grid - soil type +!! - substrate_temp_target_grid - soil subtrate temperature +!! - veg_greenness_target_grid - vegetation greenness fraction +!! - veg_type_target_grid - vegetation type +!! module static_data -!-------------------------------------------------------------------------- -! Module static data -! -! Abstract: Read pre-computed static/climatological data on the fv3 -! target grid. Time interpolate if necessary (for example a -! monthly climo fields). -! -! Public Subroutines: -! ------------------- -! get_static_fields Driver routine to read/time interpolate -! static/climo fields on the fv3 target -! grid. -! cleanup_static_fields Free up memory for fields in this module. -! -! Public variables: -! ----------------- -! alnsf_target_grid near ir black sky albedo -! alnwf_target_grid near ir white sky albedo -! alvsf_target_grid visible black sky albedo -! alvwf_target_grid visible white sky albedo -! facsf_target_grid fractional coverage for strong -! zenith angle dependent albedo -! facwf_target_grid fractional coverage for weak -! zenith angle dependent albedo -! max_veg_greenness_target_grid maximum annual greenness fraction -! min_veg_greenness_target_grid minimum annual greenness fraction -! mxsno_albedo_target_grid maximum snow albedo -! slope_type_target_grid slope type -! soil_type_target_grid soil type -! substrate_temp_target_grid soil subtrate temperature -! veg_greenness_target_grid vegetation greenness fraction -! veg_type_targe_grid vegetation type -! -!-------------------------------------------------------------------------- - use esmf implicit none @@ -61,10 +54,11 @@ module static_data contains -!------------------------------------------------------------------------------ -! Read static fields on the target grid. -!------------------------------------------------------------------------------ - +!> @brief Driver routine to read/time interpolate static/climo fields +!! on the fv3 target grid. +!! +!! @author gayno NCEP/EMC +!! subroutine get_static_fields(localpet) use model_grid, only : target_grid, & @@ -362,10 +356,10 @@ subroutine get_static_fields(localpet) end subroutine get_static_fields -!------------------------------------------------------------------------------ -! Read data file. -!------------------------------------------------------------------------------ - +!> @brief Read static climatological data file +!! +!! @author gayno NCEP/EMC +!! subroutine read_static_file(field, i_target, j_target, tile, & data_one_tile, max_data_one_tile, & min_data_one_tile) @@ -500,6 +494,10 @@ subroutine read_static_file(field, i_target, j_target, tile, & end subroutine read_static_file +!> @brief Free up memory for fields in this module. +!! +!! @author gayno NCEP/EMC +!! subroutine cleanup_static_fields implicit none diff --git a/sorc/chgres_cube.fd/surface.F90 b/sorc/chgres_cube.fd/surface.F90 index 7701534aa..a4d055b71 100644 --- a/sorc/chgres_cube.fd/surface.F90 +++ b/sorc/chgres_cube.fd/surface.F90 @@ -1,25 +1,19 @@ +!> @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. +!! +!! Public variables are defined below. "target" indicates field +!! associated with the target grid. "input" indicates field associated +!! with the input grid. module surface -!-------------------------------------------------------------------------- -! Module surface -! -! Abstract: 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 Subroutines: -! ----------------- -! surface_driver Driver routine to process surface/nst data -! -! Public variables: -! ----------------- -! Defined below. "target" indicates field associated with the target grid. -! "input" indicates field associated with the input grid. -! -!-------------------------------------------------------------------------- - use esmf implicit none @@ -117,6 +111,10 @@ module surface contains +!> @brief Driver routine to process surface/nst data +!! +!! @author gayno NCEP/EMC +!! subroutine surface_driver(localpet) use input_data, only : cleanup_input_sfc_data, & diff --git a/sorc/chgres_cube.fd/thompson_mp_climo_data.F90 b/sorc/chgres_cube.fd/thompson_mp_climo_data.F90 index 82104324a..accd83382 100644 --- a/sorc/chgres_cube.fd/thompson_mp_climo_data.F90 +++ b/sorc/chgres_cube.fd/thompson_mp_climo_data.F90 @@ -1,10 +1,11 @@ +!> @file +!! @brief Process Thompson climatological MP data +!! +!! Module to read the Thompson climatological MP data file +!! and set up the associated esmf field and grid objects. +!! module thompson_mp_climo_data -!----------------------------------------------------------------------------------- -! Module to read the Thompson climatological MP data file and set up the -! associated esmf field and grid objects. -!----------------------------------------------------------------------------------- - use esmf use netcdf use program_setup, only : cycle_mon, cycle_day, cycle_hour, & @@ -15,25 +16,33 @@ module thompson_mp_climo_data private integer :: i_thomp_mp_climo + !< i-dimension of Thompson climo data integer :: j_thomp_mp_climo + !< j-dimension of Thompson climo data integer, public :: lev_thomp_mp_climo + !< number of vert lvls of Thompson climo data type(esmf_grid) :: thomp_mp_climo_grid + !< esmf grid object for Thompson data grid type(esmf_field), public :: qnifa_climo_input_grid + !< number concentration of ice friendly + !! nuclei. type(esmf_field), public :: qnwfa_climo_input_grid + !< number concentration of water friendly + !! nuclei. type(esmf_field), public :: thomp_pres_climo_input_grid + !< 3-d pressure of the Thompson climo + !! data points public :: read_thomp_mp_climo_data public :: cleanup_thomp_mp_climo_input_data contains -!----------------------------------------------------------------------------------- -! Read Thompson climatological MP data file and time interpolate data to current -! cycle time. -!----------------------------------------------------------------------------------- - +!> @brief Read Thompson climatological MP data file and time interpolate data to +!! to current cycle time. +!! subroutine read_thomp_mp_climo_data implicit none @@ -309,10 +318,9 @@ subroutine read_thomp_mp_climo_data end subroutine read_thomp_mp_climo_data -!----------------------------------------------------------------------------------- -! Cleanup routine -!----------------------------------------------------------------------------------- - +!> @brief +!! Free up memory associated with this module. +!! subroutine cleanup_thomp_mp_climo_input_data implicit none diff --git a/sorc/chgres_cube.fd/utils.f90 b/sorc/chgres_cube.fd/utils.f90 index 337083fd3..7ddb06288 100644 --- a/sorc/chgres_cube.fd/utils.f90 +++ b/sorc/chgres_cube.fd/utils.f90 @@ -1,3 +1,12 @@ +!> @file +!! @brief Contains utility routines +!! + + +!> @brief General error handler. +!! +!! @param[in] string error message +!! @param[in] rc error status code subroutine error_handler(string, rc) use mpi @@ -16,6 +25,10 @@ subroutine error_handler(string, rc) end subroutine error_handler +!> @brief Error handler for netcdf +!! +!! @param[in] err error status code +!! @param[in] string error message subroutine netcdf_err( err, string ) use mpi @@ -37,9 +50,13 @@ subroutine netcdf_err( err, string ) return end subroutine netcdf_err +!> @brief Convert from lower to uppercase. +!! @author Clive Page +!! +!! Adapted from http://www.star.le.ac.uk/~cgp/fortran.html (25 May 2012) +!! +!! @param[in,out] strIn string to convert subroutine to_upper(strIn) -! Adapted from http://www.star.le.ac.uk/~cgp/fortran.html (25 May 2012) -! Original author: Clive Page implicit none @@ -58,9 +75,13 @@ subroutine to_upper(strIn) strIn(:) = strOut(:) end subroutine to_upper +!> @brief Convert from upper to lowercase +!! @author Clive Page +!! +!! Adapted from http://www.star.le.ac.uk/~cgp/fortran.html (25 May 2012) +!! +!! @param[in,out] strIn string to convert subroutine to_lower(strIn) -! Adapted from http://www.star.le.ac.uk/~cgp/fortran.html (25 May 2012) -! Original author: Clive Page implicit none diff --git a/sorc/chgres_cube.fd/write_data.F90 b/sorc/chgres_cube.fd/write_data.F90 index a05c824d8..c4014bbae 100644 --- a/sorc/chgres_cube.fd/write_data.F90 +++ b/sorc/chgres_cube.fd/write_data.F90 @@ -1,22 +1,16 @@ -!-------------------------------------------------------------------------- -! Module: write_data -! -! Abstract: Write out target grid data into appropriate files for -! the forecast model. -! -! Main Subroutines: -! ------------------- -! write_fv3_atm_header_netcdf Writes atmospheric header file, -! netcdf format. -! write_fv3_atm_bndy_data_netcdf Writes atmospheric fields along the -! lateral boundary. For regional grids. -! netcdf format. -! write_fv3_atm_data_netcdf Writes atmospheric data into a -! 'coldstart' file (netcdf) -! write_fv3_sfc_data_netcdf Writes surface and nst data into a -! 'coldstart' file (netcdf) -!-------------------------------------------------------------------------- - +!> @file +!! @brief Write model coldstart files. +!! +!! @author gayno NCEP/EMC +!! +!! Write out target grid data into appropriate files for +!! the forecast model. +!! + +!> @brief Writes atmospheric header file in netcdf format +!! +!! @author gayno NCEP/EMC +!! subroutine write_fv3_atm_header_netcdf(localpet) use esmf @@ -85,6 +79,12 @@ subroutine write_fv3_atm_header_netcdf(localpet) end subroutine write_fv3_atm_header_netcdf +!> @brief +!! Writes atmospheric fields along the lateral boundary. +!! For regional grids only. Output in netcdf format. +!! +!! @author gayno NCEP/EMC +!! subroutine write_fv3_atm_bndy_data_netcdf(localpet) !--------------------------------------------------------------------------- @@ -1183,14 +1183,14 @@ subroutine write_fv3_atm_bndy_data_netcdf(localpet) end subroutine write_fv3_atm_bndy_data_netcdf -!--------------------------------------------------------------------------- -! Write atmospheric coldstart files. -! -! Routine write tiled files in parallel. Tile 1 is written by -! localpet 0; tile 2 by localpet 1, etc. The number of pets -! must be equal to or greater than the number of tiled files. -!--------------------------------------------------------------------------- - +!> @brief Write atmospheric coldstart files (netcdf format). +!! +!! @author gayno NCEP/EMC +!! +!! Routine writes tiled files in parallel. Tile 1 is written by +!! localpet 0; tile 2 by localpet 1, etc. The number of pets +!! must be equal to or greater than the number of tiled files. +!! subroutine write_fv3_atm_data_netcdf(localpet) use esmf @@ -1800,9 +1800,10 @@ subroutine write_fv3_atm_data_netcdf(localpet) end subroutine write_fv3_atm_data_netcdf -!------------------------------------------------------------------------------- -!------------------------------------------------------------------------------- - +!> @brief Writes surface and nst data into a 'coldstart' file (netcdf). +!! +!! @author gayno NCEP/EMC +!! subroutine write_fv3_sfc_data_netcdf(localpet) use esmf