diff --git a/sorc/global_cycle.fd/CMakeLists.txt b/sorc/global_cycle.fd/CMakeLists.txt index 1b8e13973..41df2c28d 100644 --- a/sorc/global_cycle.fd/CMakeLists.txt +++ b/sorc/global_cycle.fd/CMakeLists.txt @@ -1,3 +1,7 @@ +# This is the CMake file for the global_cycle utility in the UFS_UTILS +# project. +# +# George Gayno set(fortran_src cycle.f90 machine.f90 diff --git a/sorc/global_cycle.fd/cycle.f90 b/sorc/global_cycle.fd/cycle.f90 index 6ea44b4ae..1aab2ce28 100644 --- a/sorc/global_cycle.fd/cycle.f90 +++ b/sorc/global_cycle.fd/cycle.f90 @@ -1,6 +1,8 @@ !> @file -!! -!! Stand alone surface/NSST cycle driver for the cubed-sphere grid. +!! @brief Update surface and NSST fields +!! @author Mark Iredell NCEP/EMC + +!> Stand alone surface/NSST cycle driver for the cubed-sphere grid. !! Each cubed-sphere tile runs independently on its own mpi task. !! The surface update component runs with threads. The NSST !! update component in not threaded. @@ -31,59 +33,59 @@ !! NOTE: running (3) then (4) is equivalent to running (2). !! !! INPUT FILES: -!! ----------- -!! -fngrid.$NNN The cubed-sphere grid file (contains +!! - fngrid.$NNN The cubed-sphere grid file (contains !! grid point latitude and longitdue). -!! -fnorog.$NNN The cubed-sphere orography file (contains +!! - fnorog.$NNN The cubed-sphere orography file (contains !! land mask and orography). -!! -fnbgsi.$NNN The cubed-sphere input sfc/nsst restart +!! - fnbgsi.$NNN The cubed-sphere input sfc/nsst restart !! file. -!! -$GSI_FILE Gaussian GSI file which contains NSST +!! - $GSI_FILE Gaussian GSI file which contains NSST !! TREF increments !! !! OUTPUT FILES: -!! ------------ -!! -fnbgso.$NNN The updated sfc/nsst restart file. +!! - fnbgso.$NNN The updated sfc/nsst restart file. !! !! NOTE: $NNN corresponds to (mpi rank + 1) - +!! !! NAMELIST VARIABLE DEFINITIONS: !! -!! -IDIM,JDIM i/j dimension of a cubed-sphere tile. -!! -LUGB Unit number used in the sfccycle subprogram +!! - IDIM,JDIM i/j dimension of a cubed-sphere tile. +!! - LUGB Unit number used in the sfccycle subprogram !! to read input datasets. -!! -LSOIL Number of soil layers. -!! -IY,IM,ID,IH Year, month, day, and hour of initial state. -!! -FH Forecast hour -!! -DELTSFC Cycling frequency in hours. -!! -IALB Use modis albedo when '1'. Use brigleb when '0'. -!! -USE_UFO Adjust sst and soil substrate temperature for +!! - LSOIL Number of soil layers. +!! - IY,IM,ID,IH Year, month, day, and hour of initial state. +!! - FH Forecast hour +!! - DELTSFC Cycling frequency in hours. +!! - IALB Use modis albedo when '1'. Use brigleb when '0'. +!! - USE_UFO Adjust sst and soil substrate temperature for !! differences between the filtered and unfiltered !! terrain. -!! -DONST Process NSST records. -!! -ADJT_NST_ONLY When true, only do the NSST update (don't call -!! sfcsub component). -!! -ISOT Use statsgo soil type when '1'. Use zobler when '0'. -!! -IVEGSRC Use igbp veg type when '1'. Use sib when '2'. -!! -ZSEA1/2_MM When running with NSST model, this is the lower/ +!! - DONST Process NSST records. +!! - ADJT_NST_ONLY When true, only do the NSST update (don't call +!! sfcsub component). +!! - ISOT Use statsgo soil type when '1'. Use zobler when '0'. +!! - IVEGSRC Use igbp veg type when '1'. Use sib when '2'. +!! - ZSEA1/2_MM When running with NSST model, this is the lower/ !! upper bound of depth of sea temperature. In !! whole mm. -!! -MAX_TASKS Normally, program should be run with a number of mpi +!! - MAX_TASKS Normally, program should be run with a number of mpi !! tasks equal to the number of cubed-sphere tiles !! being processed. However, the current parallel !! scripts may over-specify the number of tasks. !! Set this variable to not process any ranks > !! (max_tasks-1). -!! -GSI_FILE path/name of the gaussian GSI file which contains NSST +!! - GSI_FILE Path/name of the gaussian GSI file which contains NSST !! TREF increments. !! -!! -2005-02-03: Iredell for global_analysis -!! -2014-11-30: xuli add nst_anl -!! -2015-05-26: Hang Lei Added NEMSIO read/write function in the code -!! -2017-08-08: Gayno Modify to work on cubed-sphere grid. -!! Added processing of NSST and TREF update. -!! Added mpi directives. -!! +!! Program Updates: +!! - 2005-02-03: Iredell For global_analysis +!! - 2014-11-30: Xu Li Add nst_anl +!! - 2015-05-26: Hang Lei Added NEMSIO read/write function in the code +!! - 2017-08-08: Gayno Modify to work on cubed-sphere grid. +!! Added processing of NSST and TREF update. +!! Added mpi directives. +!! @author Mark Iredell NOAA/EMC +!! @return 0 for success, error code otherwise. PROGRAM SFC_DRV use mpi @@ -171,8 +173,114 @@ PROGRAM SFC_DRV STOP END PROGRAM SFC_DRV -! - SUBROUTINE SFCDRV(LUGB,IDIM,JDIM,LENSFC,LSOIL,DELTSFC, & + + !> Driver routine for updating the surface fields. + !! + !! This program runs in two different modes: + !! + !! 1. Analysis mode (FH=0.) + !! + !! This program merges climatology, analysis and forecast guess to create + !! new surface fields. If analysis file is given, the program + !! uses it if date of the analysis matches with IY,IM,ID,IH (see Note + !! below). + !! + !! 2. Forecast mode (FH.GT.0.) + !! + !! This program interpolates climatology to the date corresponding to the + !! forecast hour. If surface analysis file is given, for the corresponding + !! dates, the program will use it. This is forcing-by-observation experiment. + !! + !! If the date of the analysis does not match given IY,IM,ID,IH, (and FH), + !! the program searches an old analysis by going back 6 hours, then 12 hours, + !! then one day upto NREPMX days (parameter statement in the SUBROTINE FIXRD. + !! Now defined as 15). This allows the user to provide non-daily analysis to + !! be used. If matching field is not found, the forecast guess will be used. + !! + !! Variable naming convention for this program: + !! + !! - OROG .. Orography + !! - ALB .. Snow-free albedo + !! - SNO .. Liquid-equivalent snow depth + !! - ZOR .. Surface roughness length + !! - VET .. Vegetation type + !! - TSF .. Surface skin temperature. Sea surface temp. over ocean. + !! - TG3 .. Deep soil temperature (at 500cm) + !! - STC .. Soil temperature (LSOIL layrs) + !! - SMC .. Total soil moisture (LSOIL layrs) + !! - AIS .. Sea ice mask (0 or 1) + !! - CNP .. Canopy water content + !! - CV .. Convective cloud cover + !! - CVB .. Convective cloud base + !! - CVT .. Convective cloud top + !! - SLI .. LAND/SEA/SEA-ICE mask. (1/0/2 respectively) + !! - VEG .. Vegetation cover + !! - SOT .. Soil type + !! - SIH .. Sea ice thickness + !! - SIC .. Sea ice concentration + !! - SWD .. Actual snow depth + !! - SLC .. Liquid soil moisture (LSOIL layers) + !! - VMN .. Vegetation cover minimum + !! - VMX .. Vegetation cover maximum + !! - SLP .. Slope type + !! - ABS .. Maximum snow albedo + !! - T2M .. 2m Temperature + !! - Q2M .. 2m Specific Humidity + !! - TICE .. Ice Temperature + !! - OROG_UF .. Orography unfiltered + !! + !! Most fields have a blending coefficient. This controls + !! the blending of the forecast (first guess) and interpolated + !! climatology or analyzed fields. When it is equal to 1.0, the + !! pure forecast is used. When the coefficient is equal to 0, + !! the pure climatology or analysis is used. The default values + !! are set as follows: + !! + !! Variables | Land | Sea + !! ----------|--------|------------------------------------- + !! Surface temperature | Forecast | Analysis + !! Albedo | Analysis | Analysis + !! Sea-ice | Analysis | Analysis + !! Snow | Analysis | Forecast (over sea ice) + !! Roughness | Analysis | Forecast + !! Plant resistance | Analysis | Analysis + !! Soil moisture | Weighted average | Analysis + !! Soil temperature | Forecast | Analysis + !! Canopy waver content | Forecast | Forecast + !! Convective cloud cover | Forecast | Forecast + !! Convective cloud bottm | Forecast | Forecast + !! Convective cloud top | Forecast | Forecast + !! Vegetation greenness | Analysis | Analysis + !! Vegetation type | Analysis | Analysis + !! Soil type | Analysis | Analysis + !! + !! @param[in] LUGB Fortran unit number uses in sfccycle subprogram to + !! read input datasets. + !! @param[in] IDIM 'i' dimension of the cubed-sphere tile + !! @param[in] JDIM 'j' dimension of the cubed-sphere tile + !! @param[in] LENSFC Total numberof points for the cubed-sphere tile + !! @param[in] LSOIL Number of soil layers + !! @param[in] DELTSFC Cycling frequency in hours + !! @param[in] IY Year of initial state + !! @param[in] IM Month of initial state + !! @param[in] ID Day of initial state + !! @param[in] IH Hour of initial state + !! @param[in] FH Forecast hour + !! @param[in] IALB Use modis albedo when '1'. Use brigleb when '0'. + !! @param[in] USE_UFO When true, adjust SST and soil temperature for + !! differences between the filtered and unfiltered terrain. + !! @param[in] DO_NSST When true, process NSST records. + !! @param[in] ADJT_NST_ONLY When true, only do the NSST update (don't + !! call sfcsub component. + !! @param[in] ZSEA1 When running NSST model, this is the lower bound + !! of depth of sea temperature. In whole mm. + !! @param[in] ZSEA2 When running NSST model, this is the upper bound + !! of depth of sea temperature. In whole mm. + !! @param[in] ISOT Use STATSGO soil type when '1'. Use Zobler when '0'. + !! @param[in] IVEGSRC Use IGBP vegetation type when '1'. Use SIB when '2'. + !! @param[in] MYRANK MPI rank number + !! @author Mark Iredell, George Gayno + SUBROUTINE SFCDRV(LUGB, IDIM,JDIM,LENSFC,LSOIL,DELTSFC, & IY,IM,ID,IH,FH,IALB, & USE_UFO,DO_NSST,ADJT_NST_ONLY, & ZSEA1,ZSEA2,ISOT,IVEGSRC,MYRANK) @@ -221,12 +329,15 @@ SUBROUTINE SFCDRV(LUGB,IDIM,JDIM,LENSFC,LSOIL,DELTSFC, & REAL :: FMM(LENSFC), FHH(LENSFC) REAL :: RLA(LENSFC), RLO(LENSFC) REAL(KIND=4) :: ZSOIL(LSOIL) - REAL :: SIG1T(LENSFC) + REAL :: SIG1T(LENSFC) !< The sigma level 1 temperature for a + !! dead start. Set to zero for non-dead + !! start. REAL, ALLOCATABLE :: SLIFCS_FG(:) TYPE(NSST_DATA) :: NSST real, dimension(idim,jdim) :: tf_clm,tf_trd,sal_clm real, dimension(lensfc) :: tf_clm_tile,tf_trd_tile,sal_clm_tile + !-------------------------------------------------------------------------------- ! GSI_FILE is the path/name of the gaussian GSI file which contains NSST ! increments. @@ -236,100 +347,6 @@ SUBROUTINE SFCDRV(LUGB,IDIM,JDIM,LENSFC,LSOIL,DELTSFC, & NAMELIST/NAMSFCD/ GSI_FILE -!-------------------------------------------------------------------------------- -! -! This program runs in two different modes: -! -! 1. Analysis mode (FH=0.) -! -! This program merges climatology, analysis and forecast guess to create -! new surface fields. If analysis file is given, the program -! uses it if date of the analysis matches with IY,IM,ID,IH (see Note -! below). -! -! 2. Forecast mode (FH.GT.0.) -! -! This program interpolates climatology to the date corresponding to the -! forecast hour. If surface analysis file is given, for the corresponding -! dates, the program will use it. This is forcing-by-observation experiment. -! -! NOTE: -! -! If the date of the analysis does not match given IY,IM,ID,IH, (and FH), -! the program searches an old analysis by going back 6 hours, then 12 hours, -! then one day upto NREPMX days (parameter statement in the SUBROTINE FIXRD. -! Now defined as 15). This allows the user to provide non-daily analysis to -! be used. If matching field is not found, the forecast guess will be used. -! -! LUGB is the unit number used in sfccycle subprogram -! IDIM,JDIM is thegrid dimension in x and y direction, respectively of a tile -! of the cubed-sphere grid. -! LSOIL is the number of soil layers -! IY,IM,ID,IH is the Year, month, day, and hour of initial state. -! FH is the forecast hour -! SIG1T is the sigma level 1 temperature for dead start. -! SIG1T is the sigma level 1 temperature for dead start. -! If not dead start, no need for dimension but set to zero. -! -! Variable naming conventions: -! -! OROG .. Orography -! ALB .. Snow-free albedo -! SNO .. Liquid-equivalent snow depth -! ZOR .. Surface roughness length -! VET .. Vegetation type -! TSF .. Surface skin temperature. Sea surface temp. over ocean. -! TG3 .. Deep soil temperature (at 500cm) -! STC .. Soil temperature (LSOIL layrs) -! SMC .. Total soil moisture (LSOIL layrs) -! AIS .. Sea ice mask (0 or 1) -! CNP .. Canopy water content -! CV .. Convective cloud cover -! CVB .. Convective cloud base -! CVT .. Convective cloud top -! SLI .. LAND/SEA/SEA-ICE mask. (1/0/2 respectively) -! VEG .. Vegetation cover -! SOT .. Soil type -! SIH .. Sea ice thickness -! SIC .. Sea ice concentration -! SWD .. Actual snow depth -! SLC .. Liquid soil moisture (LSOIL layers) -! VMN .. Vegetation cover minimum -! VMX .. Vegetation cover maximum -! SLP .. Slope type -! ABS .. Maximum snow albedo -! T2M .. 2m Temperature -! Q2M .. 2m Specific Humidity -! TICE .. Ice Temperature -! OROG_UF .. Orography unfiltered -! -! COEEFICIENTS OF BLENDING FORECAST AND INTERPOLATED CLIM -! (OR ANALYZED) FIELDS OVER SEA OR LAND(L) (NOT FOR CLOUDS) -! 1.0 = USE OF FORECAST -! 0.0 = REPLACE WITH INTERPOLATED ANALYSIS -! -! These values are set for analysis mode. -! -! Variables Land Sea -! --------------------------------------------------------- -! Surface temperature Forecast Analysis -! Albedo Analysis Analysis -! Sea-ice Analysis Analysis -! Snow Analysis Forecast (over sea ice) -! Roughness Analysis Forecast -! Plant resistance Analysis Analysis -! Soil wetness (layer) Weighted average Analysis -! Soil temperature Forecast Analysis -! Canopy waver content Forecast Forecast -! Convective cloud cover Forecast Forecast -! Convective cloud bottm Forecast Forecast -! Convective cloud top Forecast Forecast -! Vegetation cover Analysis Analysis -! vegetation type Analysis Analysis -! soil type Analysis Analysis -! -!-------------------------------------------------------------------------------- - SIG1T = 0.0 ! Not a dead start! INPUT_NML_FILE = "NULL" @@ -524,17 +541,42 @@ SUBROUTINE SFCDRV(LUGB,IDIM,JDIM,LENSFC,LSOIL,DELTSFC, & END SUBROUTINE SFCDRV + !> Read in gsi file with the updated reference temperature increments (on the gaussian + !! grid), interpolate increments to the cubed-sphere tile, and + !! perform required nsst adjustments and qc. + !! + !! @param[inout] RLA Latitude on the cubed-sphere tile + !! @param[inout] RLO Longitude on the cubed-sphere tile + !! @param[in] SLMSK_TILE Land-sea mask on the cubed-sphere tile + !! @param[in] SLMSK_FG_TILE First guess land-sea mask on the cubed-sphere tile + !! @param[inout] SKINT_TILE Skin temperature on the cubed-sphere tile + !! @param[inout] SICET_TILE Ice temperature on the cubed-sphere tile + !! @param[inout] sice_tile Ice concentration on the cubed-sphere tile + !! @param[inout] SOILT_TILE Soil temperature on the cubed-sphere tile + !! @param[in] NSST Data structure holding nsst fields + !! @param[in] LENSFC Number of points on a tile + !! @param[in] LSOIL Number of soil layers + !! @param[in] IDIM 'I' dimension of a tile + !! @param[in] JDIM 'J' dimension of a tile + !! @param[in] ZSEA1 When running nsst model, this is the lower bound of + !! depth of sea temperature. In whole mm. + !! @param[in] ZSEA2 When running nsst model, this is the upper bound of + !! depth of sea temperature. In whole mm. + !! @param[in] MON Month + !! @param[in] DAY Day + !! @param[in] DELTSFC Cycling frequency in hours + !! @param[in] tf_clm_tile Climatological reference temperature on the + !! cubed-sphere tile. + !! @param[in] tf_trd_tile Climatolocial reference temperature trend on the + !! cubed-sphere tile. + !! @param[in] sal_clm_tile Climatological salinity on the cubed-sphere tile. + !! + !! @author Xu Li, George Gayno SUBROUTINE ADJUST_NSST(RLA,RLO,SLMSK_TILE,SLMSK_FG_TILE,SKINT_TILE,& SICET_TILE,sice_tile,SOILT_TILE,NSST,LENSFC,LSOIL, & IDIM,JDIM,ZSEA1,ZSEA2,MON,DAY,DELTSFC, & tf_clm_tile,tf_trd_tile,sal_clm_tile) -!-------------------------------------------------------------------------------- -! READ IN GSI FILE WITH THE UPDATED TREF INCREMENTS (ON THE GAUSSIAN -! GRID), INTERPOLATE INCREMENTS TO THE CUBED-SPHERE TILE, AND PERFORM -! REQUIRED NSST ADJUSTMENTS AND QC. -!-------------------------------------------------------------------------------- - USE GDSWZD_MOD USE READ_WRITE_DATA, ONLY : IDIM_GAUS, JDIM_GAUS, & SLMSK_GAUS, DTREF_GAUS, & @@ -928,15 +970,17 @@ SUBROUTINE ADJUST_NSST(RLA,RLO,SLMSK_TILE,SLMSK_FG_TILE,SKINT_TILE,& END SUBROUTINE ADJUST_NSST + !> If the tile point is an isolated water point that has no + !! corresponding gsi water point, then tref is updated using the rtg + !! sst climo trend. This monthly trend is sorted by latitude band. + !! + !! @param[in] LATITUDE Latitude of tile point + !! @param[in] MON Month + !! @param[in] DAY Day + !! @param[in] DELTSFC Cycling frequency in hours + !! @param[out] DTREF Monthly trend of reference temperature + !! @author Xu Li, George Gayno SUBROUTINE CLIMO_TREND(LATITUDE, MON, DAY, DELTSFC, DTREF) - -!---------------------------------------------------------------- -! IF THE TILE POINT IS AN ISOLATED WATER POINT THAT HAS NO -! CORRESPONDING GSI WATER POINT, THEN TREF IS UPDATED USING -! THE RTG SST CLIMO TREND. THIS MONTHLY TREND IS SORTED BY -! LATITUDE BAND. -!---------------------------------------------------------------- - IMPLICIT NONE INTEGER, INTENT(IN) :: MON, DAY @@ -1078,34 +1122,18 @@ SUBROUTINE CLIMO_TREND(LATITUDE, MON, DAY, DELTSFC, DTREF) END SUBROUTINE CLIMO_TREND + !> Compute the vertical mean of the NSST t-profile. + !! + !! @param[in] xt Heat content in the diurnal thermocline layer. + !! @param[in] xz Thickness of the diurnal thermocline layer. + !! @param[in] dt_cool Skin-layer cooling amount. + !! @param[in] zc Thickness of skin-layer. + !! @param[in] z1 Lower bound of depth of sea temperature. + !! @param[in] z2 Upper bound of depth of sea temperature. + !! @param[out] dtzm Mean of the NSST t-profile from z1 to z2. + !! + !! @author Xu Li @date 2015 SUBROUTINE DTZM_POINT(XT,XZ,DT_COOL,ZC,Z1,Z2,DTZM) -! ===================================================================== ! -! ! -! description: get dtzm = mean of dT(z) (z1 - z2) with NSST dT(z) ! -! dT(z) = (1-z/xz)*dt_warm - (1-z/zc)*dt_cool ! -! ! -! usage: ! -! ! -! call dtzm_point ! -! ! -! inputs: ! -! (xt,xz,dt_cool,zc,z1,z2, ! -! outputs: ! -! dtzm) ! -! ! -! program history log: ! -! ! -! 2015 -- xu li createad original code ! -! inputs: ! -! xt - real, heat content in dtl 1 ! -! xz - real, dtl thickness 1 ! -! dt_cool - real, sub-layer cooling amount 1 ! -! zc - sub-layer cooling thickness 1 ! -! z1 - lower bound of depth of sea temperature 1 ! -! z2 - upper bound of depth of sea temperature 1 ! -! outputs: ! -! dtzm - mean of dT(z) (z1 to z2) 1 ! -! implicit none real, intent(in) :: xt,xz,dt_cool,zc,z1,z2 @@ -1158,14 +1186,34 @@ SUBROUTINE DTZM_POINT(XT,XZ,DT_COOL,ZC,Z1,Z2,DTZM) END SUBROUTINE DTZM_POINT + !> Generate the weights and index of the grids used in the bilinear + !! interpolation. + !! + !! This routine was taken from the forecast model - + !! ./atmos_cubed_sphere/tools/fv_treat_da_inc.f90. + !! + !! @param[in] is Start index in x-direction of the source array. + !! @param[in] ie End index in x-direction of the source array. + !! @param[in] js Start index in y-direction of the source array. + !! @param[in] je End index in y-direction of the source array. + !! @param[in] im x-dimension of the source array. + !! @param[in] jm y-dimension of the source array. + !! @param[in] lon 1-d array of longitudes (in radians). + !! @param[in] lat 1-d array of latitudes (in radians). + !! @param[in] agrid 2-d array for lon [agrid(:,:,1)] & lat + !! [agrid(:,:,2)] (in radians). + !! @param[out] s2c Bi-linear interpolation weights of the four nearby + !! grids of the source array. + !! @param[out] id1 Index 1 in x-direction of the nearby grids of + !! the source array. + !! @param[out] id2 Index 2 in x-direction of the nearby grids of + !! the source array. + !! @param[out] jdc Index in y-direction of the nearby grid of the + !! source array. + !! @author Xu Li SUBROUTINE REMAP_COEF( is, ie, js, je,& im, jm, lon, lat, id1, id2, jdc, s2c, agrid ) -!---------------------------------------------------------------------- -! THIS ROUTINE WAS TAKEN FROM THE FORECAST MODEL - -! ./ATMOS_CUBED_SPHERE/TOOLS/FV_TREAT_DA_INC.F90. -!---------------------------------------------------------------------- - implicit none integer, intent(in):: is, ie, js, je integer, intent(in):: im, jm @@ -1243,17 +1291,27 @@ SUBROUTINE REMAP_COEF( is, ie, js, je,& END SUBROUTINE REMAP_COEF + !> Set the background reference temperature (tf) for points where + !! the ice has just melted. + !! + !! @param[in] tf_ij Foundation temperature background on FV3 native grids. + !! @param[in] mask_ij Mask of the tile (FV3 native grids). + !! @param[in] itile Location index in the 'i' direction. + !! @param[in] jtile Location index in the 'j' direction. + !! @param[in] tice Water temperature (calulated with a salinity formula). + !! @param[in] tclm SST climatology valid at the analysis time. + !! @param [out] tf_thaw Foundation temperature of thawed points. + !! @param[inout] nx 'i' dimension of tf_ij + !! @param[inout] ny 'j' dimension of tf_ij + !! @param[inout] nset_thaw_s Number of foundation temperature points filled + !! via a search. + !! @param[inout] nset_thaw_i Number of ice points filled with a calculated + !! tice. + !! @param[inout] nset_thaw_c Number of points filled with a weighted + !! average of tice and tclm. + !! @author Xu Li subroutine tf_thaw_set(tf_ij,mask_ij,itile,jtile,tice,tclm,tf_thaw,nx,ny, & nset_thaw_s,nset_thaw_i,nset_thaw_c) -! -! set a vakue to tf background for the thaw (just melted water) situation -! -!Input/output: -! tf : Foundation temperature background on FV3 native grids -! mask_ij : mask of the tile (FV3 native grids) -! itile,jtile : location index of the tile -! tice : water temperature (calulated with a salinity formula) -! tclm : SST climatology valid at the analysis time real, dimension(nx*ny), intent(in) :: tf_ij integer, dimension(nx*ny), intent(in) :: mask_ij @@ -1336,13 +1394,14 @@ subroutine tf_thaw_set(tf_ij,mask_ij,itile,jtile,tice,tclm,tf_thaw,nx,ny, & end subroutine tf_thaw_set + !> If the first guess was sea ice, but the analysis is open water, + !! reset all nsst variables. + !! + !! @param[inout] nsst Data structure that holds the nsst fields + !! @param[in] ij Index of point to be updated + !! @param[in] tf_thaw Reference temperature for former ice points + !! @author Xu Li subroutine nsst_water_reset(nsst,ij,tf_thaw) - -!------------------------------------------------------------------- -! if the first guess was sea ice, but the analysis is open water, -! reset all nsst variables. -!------------------------------------------------------------------- - use read_write_data, only : nsst_data implicit none @@ -1373,20 +1432,30 @@ subroutine nsst_water_reset(nsst,ij,tf_thaw) end subroutine nsst_water_reset + !> Get the sst climatology at the valid time and on the target + !! grid. + !! + !! @param[in] xlats_ij latitude of target grid + !! @param[in] xlons_ij longitude of target grid + !! @param[in] ny 'j' dimension of target grid + !! @param[in] nx 'i' dimension of target grid + !! @param[in] iy Year + !! @param[in] im Month + !! @param[in] id Day + !! @param[in] ih Hour + !! @param[out] tf_clm sst climatology at the valid time and on the target grid + !! @param[out] tf_trd 6-hourly sst climatology tendency at the valid time + !! and on the target grid. + !! @author Xu Li subroutine get_tf_clm(xlats_ij,xlons_ij,ny,nx,iy,im,id,ih,tf_clm,tf_trd) -! -! abstract: get sst climatology at the valid time (atime) and target resolution (nx,ny) -! -! input & output -! use read_write_data, only : get_tf_clm_dim implicit none - real, dimension(nx*ny), intent(in) :: xlats_ij ! latitudes of target grids (nx*ny) - real, dimension(nx*ny), intent(in) :: xlons_ij ! latitudes of target grids (nx*ny) - real, dimension(nx,ny), intent(out) :: tf_clm ! sst climatology valid at atime (nx,ny) - real, dimension(nx,ny), intent(out) :: tf_trd ! 6-hourly sst climatology tendency valid at atime (nx,ny) + real, dimension(nx*ny), intent(in) :: xlats_ij + real, dimension(nx*ny), intent(in) :: xlons_ij + real, dimension(nx,ny), intent(out) :: tf_clm + real, dimension(nx,ny), intent(out) :: tf_trd integer, intent(in) :: iy,im,id,ih,nx,ny ! local declare real, allocatable, dimension(:,:) :: tf_clm0 ! sst climatology at the valid time (nxc,nyc) @@ -1433,11 +1502,21 @@ subroutine get_tf_clm(xlats_ij,xlons_ij,ny,nx,iy,im,id,ih,tf_clm,tf_trd) end subroutine get_tf_clm +!> Get the reference temperature/sst climatology and its trend at analysis time. +!! The data is time interpolated between two bounding months. +!! +!! @param[out] tf_clm_ta Climatological tf/sst at analysis time +!! @param[out] tf_clm_trend Climatological tf/sst trend at analysis time +!! @param[out] xlats Latitudes on the climatological data grid +!! @param[out] xlons Longitudes on the climatological data grid +!! @param[in] nlat 'j' dimension on the climatological grid +!! @param[in] nlon 'i' dimension on the climatological grid +!! @param[in] mon1 First bounding month +!! @param[in] mon2 Second bounding month +!! @param[in] wei1 Weighting of first bounding month +!! @param[in] wei2 Weighting of second bounding month +!! @author Xu Li @date March 2019 subroutine get_tf_clm_ta(tf_clm_ta,tf_clm_trend,xlats,xlons,nlat,nlon,mon1,mon2,wei1,wei2) -!$$$ -! abstract: get tf/sst climatology & the trend at analysis time -! created by xu li, march, 2019 - use read_write_data, only : read_tf_clim_grb implicit none @@ -1473,18 +1552,25 @@ subroutine get_tf_clm_ta(tf_clm_ta,tf_clm_trend,xlats,xlons,nlat,nlon,mon1,mon2, write(*,'(a,2f9.3)') 'tf_clm_trend, min, max : ',minval(tf_clm_trend),maxval(tf_clm_trend) end subroutine get_tf_clm_ta + !> Get salinity climatology at the valid time on the target grid. + !! + !! @param[in] xlats_ij Latitudes of target grid + !! @param[in] xlons_ij Longitudes of target grid + !! @param[in] ny 'j' dimension of target grid + !! @param[in] nx 'i' dimension of target grid + !! @param[in] iy Year + !! @param[in] im Month + !! @param[in] id Day + !! @param[in] ih Hour + !! @param[out] sal_clm Salinity climatology on the target grid at the valid time + !! @author Xu Li subroutine get_sal_clm(xlats_ij,xlons_ij,ny,nx,iy,im,id,ih,sal_clm) -! -! abstract: get salinity climatology at the valid time (atime) and target resolution (nx,ny) -! -! input & output -! use read_write_data, only : get_dim_nc implicit none - real, dimension(nx*ny), intent(in) :: xlats_ij ! latitudes of target grids (nx*ny) - real, dimension(nx*ny), intent(in) :: xlons_ij ! latitudes of target grids (nx*ny) - real, dimension(nx,ny), intent(out) :: sal_clm ! salinity climatology valid at atime (nx,ny) + real, dimension(nx*ny), intent(in) :: xlats_ij ! + real, dimension(nx*ny), intent(in) :: xlons_ij ! + real, dimension(nx,ny), intent(out) :: sal_clm ! integer, intent(in) :: iy,im,id,ih,nx,ny ! local declare real, allocatable, dimension(:,:) :: sal_clm0 ! salinity climatology at the valid time @@ -1526,10 +1612,19 @@ subroutine get_sal_clm(xlats_ij,xlons_ij,ny,nx,iy,im,id,ih,sal_clm) end subroutine get_sal_clm +!> Get climatological salinity at the analysis time. +!! +!! @param[in] nlat 'j' dimension of climatological data +!! @param[in] nlon 'i' dimension of climatological data +!! @param[in] mon1 First bounding month +!! @param[in] mon2 Second bounding month +!! @param[in] wei1 Weight of first bounding month +!! @param[in] wei2 Weight of second bounding month +!! @param[out] sal_clm_ta Climatological salinity at the analysis time +!! @param[out] xlats Latitudes on the climatological grid +!! @param[out] xlons Longitudes on the climatological grid +!! @author Xu Li @date March 2019 subroutine get_sal_clm_ta(sal_clm_ta,xlats,xlons,nlat,nlon,mon1,mon2,wei1,wei2) -!$$$ -! abstract: get sal climatology at analysis time -! created by xu li, march, 2019 use read_write_data, only : read_salclm_gfs_nc implicit none @@ -1560,28 +1655,22 @@ subroutine get_sal_clm_ta(sal_clm_ta,xlats,xlons,nlat,nlon,mon1,mon2,wei1,wei2) write(*,'(a,2f9.3)') 'sal_clm_ta, min, max : ',minval(sal_clm_ta),maxval(sal_clm_ta) end subroutine get_sal_clm_ta + !> Interpolate lon/lat grid data to the fv3 native grid (tf_lalo => tf_tile). Does not + !! account for a mask. + !! + !! @param[in] tf_lalo (idim_lalo,idim_lalo) field on the lat/lon regular grid. + !! @param[in] dlats_lalo (jdim_lalo) latitudes along y direction of lat/lon regular grid points. + !! @param[in] dlons_lalo (idim_lalo) longitudes along x direction of lat/lon regular grid points. + !! @param[in] jdim_lalo number of y dimension of tf_lalo. + !! @param[in] idim_lalo number of x dimension of tf_lalo. + !! @param[in] xlats_tile (jdim_tile*idim_tile) latitudes of all tile grid points. + !! @param[in] xlons_tile (jdim_tile*idim_tile) longitudes of all tile grid points. + !! @param[in] jdim_tile number of y dimension of tf_tile. + !! @param[in] idim_tile number of x dimension of tf_tile. + !! @param[out] tf_tile (jdim_tile*idim_tile) field on the cubed sphere grid. + !! @author Xu Li subroutine intp_tile(tf_lalo,dlats_lalo,dlons_lalo,jdim_lalo,idim_lalo, & tf_tile,xlats_tile,xlons_tile,jdim_tile,idim_tile) -!-------------------------------------------------------------------------------- -! abstract: interpolate lon/lat grid to fv3 native grid (tf_lalo => tf_tile) for -! not dependent on mask -!-------------------------------------------------------------------------------- - -! input -! -! tf_lalo : (idim_lalo,idim_lalo) tf at lat/lon regular grid -! dlats_lalo : (jdim_lalo) latitudes along y direction of lat/lon regular grid points -! dlons_lalo : (idim_lalo) longitudes along x direction of lat/lon regular grid points -! jdim_lalo : number of y dimension of tf_lalo -! idim_lalo : number of x dimension of tf_lalo -! xlats_tile : (jdim_tile*idim_tile) latitudes of all tile grid points -! xlons_tile : (jdim_tile*idim_tile) longitudes of all tile grid points -! jdim_tile : number of y dimension of tf_tile -! idim_tile : number of x dimension of tf_tile -! -! output -! -! tf_tile : (jdim_tile*idim_tile) tf at cubed sphere grid implicit none @@ -1656,11 +1745,19 @@ subroutine intp_tile(tf_lalo,dlats_lalo,dlons_lalo,jdim_lalo,idim_lalo, & end subroutine intp_tile +!> For a given date, determine the bounding months and the linear +!! time interpolation weights. +!! +!! @param[in] iy The year +!! @param[in] im The month +!! @param[in] id The day +!! @param[in] ih The hour +!! @param[out] mon1 First bounding month +!! @param[out] mon2 Second bounding month +!! @param[out] wei1 Weighting of first bounding month +!! @param[out] wei2 Weighting of second bounding month +!! @author Xu Li @date March 2019 subroutine get_tim_wei(iy,im,id,ih,mon1,mon2,wei1,wei2) -!$$$ -! abstract: get two months and weights for monthly climatology -! created by xu li, march, 2019 - implicit none ! input @@ -1718,10 +1815,16 @@ subroutine get_tim_wei(iy,im,id,ih,mon1,mon2,wei1,wei2) end subroutine get_tim_wei + !> Compute the freezing point of water as a function of salinity. + !! + !! Constants taken from Gill, 1982. + !! + !! @date 21 September 1994. + !! @author Robert Grumbine + !! + !! @param [in] salinity The salinity. + !! @return tfreez The freezing point of water. real function tfreez(salinity) -!Constants taken from Gill, 1982. -!Author: Robert Grumbine -!LAST MODIFIED: 21 September 1994. implicit none diff --git a/sorc/global_cycle.fd/machine.f90 b/sorc/global_cycle.fd/machine.f90 index 7f106643f..138e75323 100755 --- a/sorc/global_cycle.fd/machine.f90 +++ b/sorc/global_cycle.fd/machine.f90 @@ -1,16 +1,24 @@ !> @file +!! @brief Holds machine dependent constants for global_cycle. +!! @author Mark Iredell NOAA/EMC + +!> Holds machine dependent constants for global_cycle. +!! @author Mark Iredell NOAA/EMC MODULE MACHINE IMPLICIT NONE SAVE ! Machine dependant constants - integer, parameter :: kind_io4 = 4, kind_io8 = 8 , kind_ior = 8, & - kind_evod = 8, kind_dbl_prec = 8, & - kind_rad = selected_real_kind(13,60), & ! the '60' maps to 64-bit real - kind_phys = selected_real_kind(13,60), & ! the '60' maps to 64-bit real - kind_REAL = 8, & ! used in cmp_comm - kind_INTEGER = 4 ! -,,- + integer, parameter :: kind_io4 = 4 + integer, parameter :: kind_io8 = 8 + integer, parameter :: kind_ior = 8 + integer, parameter :: kind_evod = 8 + integer, parameter :: kind_dbl_prec = 8 + integer, parameter :: kind_rad = selected_real_kind(13,60) !< the '60' maps to 64-bit real + integer, parameter :: kind_phys = selected_real_kind(13,60) !< the '60' maps to 64-bit real + integer, parameter :: kind_REAL = 8 !< used in cmp_comm + integer, parameter :: kind_INTEGER = 4 !< -,,- ! - real(kind=kind_evod), parameter :: mprec = 1.e-12 ! machine precision to restrict dep + real(kind=kind_evod), parameter :: mprec = 1.e-12 !< machine precision to restrict dep END MODULE MACHINE diff --git a/sorc/global_cycle.fd/num_parthds.f90 b/sorc/global_cycle.fd/num_parthds.f90 index 35392ceed..5c877a7c9 100755 --- a/sorc/global_cycle.fd/num_parthds.f90 +++ b/sorc/global_cycle.fd/num_parthds.f90 @@ -1,4 +1,11 @@ !> @file +!! @brief Return number of threads. +!! @author Mark Iredell NCEP/EMC + +!> Return the number of omp threads. +!! +!! @return num_parthds The number of threads. +!! @author Mark Iredell NCEP/EMC integer function num_parthds() use omp_lib !$OMP PARALLEL diff --git a/sorc/global_cycle.fd/read_write_data.f90 b/sorc/global_cycle.fd/read_write_data.f90 index 16bc04a0c..dd1e5cce1 100644 --- a/sorc/global_cycle.fd/read_write_data.f90 +++ b/sorc/global_cycle.fd/read_write_data.f90 @@ -1,5 +1,11 @@ !> @file - MODULE READ_WRITE_DATA +!! @brief Contains utility routines that read and write data. +!! +!! @author Xu Li, Hang Lei, George Gayno NOAA/EMC + +!> This module contains routines that read and write data. +!! @author Xu Li, Hang Lei, George Gayno NOAA/EMC +MODULE READ_WRITE_DATA USE NETCDF @@ -29,11 +35,15 @@ MODULE READ_WRITE_DATA REAL, ALLOCATABLE :: ZM(:) END TYPE NSST_DATA - INTEGER, PUBLIC :: IDIM_GAUS, JDIM_GAUS - - INTEGER, ALLOCATABLE, PUBLIC :: SLMSK_GAUS(:,:) + INTEGER, PUBLIC :: IDIM_GAUS !< 'i' dimension of GSI gaussian + !! grid. + INTEGER, PUBLIC :: JDIM_GAUS !< 'j' dimension of GSI gaussian + !! grid. + INTEGER, ALLOCATABLE, PUBLIC :: SLMSK_GAUS(:,:) !< GSI land mask on the + !! gaussian grid. - REAL, ALLOCATABLE, PUBLIC :: DTREF_GAUS(:,:) + REAL, ALLOCATABLE, PUBLIC :: DTREF_GAUS(:,:) !< GSI foundation temperature + !! increment on the gaussian grid. PUBLIC :: READ_DATA PUBLIC :: READ_GSI_DATA @@ -44,6 +54,57 @@ MODULE READ_WRITE_DATA CONTAINS + !> Write out all surface records - and nsst records if selected - + !! on a single cubed-sphere tile to a model restart file (in netcdf). + !! + !! @note The model restart files contain an additional snow field - + !! snow cover (snocvr). That field is required for bit identical + !! reproducability. If that record does not exist, the model will + !! compute it as an initialization step. Because this program does not + !! contain the snow cover algorithm, it will let the model compute it. + !! + !! @param[in] slifcs Land-sea mask. + !! @param[in] tsffcs Skin temperature. + !! @param[in] snofcs Liquid-equivalent snow depth. + !! @param[in] tg3fcs Soil substrate temperature. + !! @param[in] zorfcs Roughness length. + !! @param[in] albfcs Snow-free albedo. + !! @param[in] alffcs Fractional coverage for strong/weak zenith angle + !! dependent albedo. + !! @param[in] vegfcs Vegetation greenness. + !! @param[in] cnpfcs Plant canopy moisture content. + !! @param[in] f10m log((z0+10)/z0). See model routine sfc_diff.f for + !! details. + !! @param[in] t2m Two-meter air temperature. + !! @param[in] q2m Two-meter specific humidity. + !! @param[in] vetfcs Vegetation type. + !! @param[in] sotfcs Soil type. + !! @param[in] ustar Friction velocity. + !! @param[in] fmm log((z0+z1)/z0). See model routine sfc_diff.f for + !! details. + !! @param[in] fhh log(ztmax+z1)/ztmax). See model routine sfc_diff.f for + !! details. + !! @param[in] sicfcs Sea ice concentraton. + !! @param[in] sihfcs Sea ice depth. + !! @param[in] sitfcs Sea ice temperature. + !! @param[in] tprcp Precipitation. + !! @param[in] srflag Snow/rain flag. + !! @param[in] swdfcs Physical snow depth. + !! @param[in] vmnfcs Minimum vegetation greenness. + !! @param[in] vmxfcs Maximum vegetation greenness. + !! @param[in] slpfcs Slope type. + !! @param[in] absfcs Maximum snow albedo. + !! @param[in] slcfcs Liquid portion of volumetric soil moisture. + !! @param[in] smcfcs Total volumetric soil moisture. + !! @param[in] stcfcs Soil temperature. + !! @param[in] idim 'i' dimension of a tile. + !! @param[in] jdim 'j' dimension of a tile. + !! @param[in] lensfc Total number of points on a tile. + !! @param[in] lsoil Number of soil layers. + !! @param[in] do_nsst When true, nsst fields were processed. + !! @param[in] nsst Data structure containing nsst fields. + !! + !! @author George Gayno NOAA/EMC subroutine write_data(slifcs,tsffcs,snofcs,tg3fcs,zorfcs, & albfcs,alffcs,vegfcs,cnpfcs,f10m, & t2m,q2m,vetfcs,sotfcs,ustar,fmm,fhh, & @@ -52,17 +113,6 @@ subroutine write_data(slifcs,tsffcs,snofcs,tg3fcs,zorfcs, & absfcs,slcfcs,smcfcs,stcfcs,& idim,jdim,lensfc,lsoil,do_nsst,nsst) -!------------------------------------------------------------------ -! Write out all surface records - and nsst records if selected - -! to a netcdf file. -! -! Note: the model restart files contain an additional snow field - -! snow cover (snocvr). That field is required for bit identical -! reproducability. If that record does not exist, the model -! will compute it as an initialization step. Because this -! program does not contain the snow cover algorithm, it will -! let the model compute it. -!------------------------------------------------------------------ use mpi @@ -845,15 +895,22 @@ subroutine write_data(slifcs,tsffcs,snofcs,tg3fcs,zorfcs, & end subroutine write_data + !> Read latitude and longitude for the cubed-sphere tile from the + !! 'grid' file. Read the filtered and unfiltered orography from + !! the 'orography' file. + !! + !! @param[in] IDIM 'i' dimension of cubed-sphere tile. + !! @param[in] JDIM 'j' dimension of cubed-sphere tile. + !! @param[in] IJDIM Total number of points on the cubed-sphere tile. + !! @param[out] RLA Latitude on the cubed-sphere tile. + !! @param[out] RLO Longitude on the cubed-sphere tile. + !! @param[out] OROG Filtered orography. + !! @param[out] OROG_UF Unfiltered orography. + !! @param[out] TILE_NUM Cubed-sphere tile number + !! @author George Gayno NOAA/EMC SUBROUTINE READ_LAT_LON_OROG(RLA,RLO,OROG,OROG_UF,& TILE_NUM,IDIM,JDIM,IJDIM) -!-------------------------------------------------------------- -! READ LATITUDE, LONGITUDE, FILTERED OROGRAPHY, AND -! UNFILTERED OROGRAPHY FOR THE CUBED-SPHERE TILE FROM -! THE "GRID" FILE. -!-------------------------------------------------------------- - USE MPI IMPLICIT NONE @@ -979,13 +1036,14 @@ SUBROUTINE READ_LAT_LON_OROG(RLA,RLO,OROG,OROG_UF,& END SUBROUTINE READ_LAT_LON_OROG + !> If a NetCDF call returns an error, print out a user-supplied + !! message and the NetCDF library message. Then stop processing. + !! + !! @param[in] ERR NetCDF error code. + !! @param[in] STRING User-defined error message. + !! @author George Gayno NOAA/EMC SUBROUTINE NETCDF_ERR( ERR, STRING ) -!-------------------------------------------------------------- -! IF AT NETCDF CALL RETURNS AN ERROR, PRINT OUT A MESSAGE -! AND STOP PROCESSING. -!-------------------------------------------------------------- - USE MPI IMPLICIT NONE @@ -1005,16 +1063,17 @@ SUBROUTINE NETCDF_ERR( ERR, STRING ) RETURN END SUBROUTINE NETCDF_ERR + !> Read file from the GSI containing the foundation temperature + !! increments and mask. + !! + !! The data is in NetCDF and on a gaussian grid. The grid contains two + !! extra rows for each pole. The interpolation from gaussian to + !! native grid assumes no pole points, so these are removed. + !! + !! @param[in] GSI_FILE Path/name of the GSI file to be read. + !! @author George Gayno NOAA/EMC SUBROUTINE READ_GSI_DATA(GSI_FILE) -!----------------------------------------------------------------- -! READ FILE FROM THE GSI CONTAINING THE FOUNDATION TEMPERATURE -! INCREMENTS AND MASK. DATA IS IN NETCDF AND ON A GAUSSIAN GRID. -! THE GRID CONTAINS TWO EXTRA ROWS FOR EACH POLE. THE -! INTERPOLATION FROM GAUSSIAN TO NATIVE GRID ASSUMES NO POLE -! POINTS, SO THESE ARE REMOVED. -!----------------------------------------------------------------- - IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: GSI_FILE @@ -1073,6 +1132,51 @@ SUBROUTINE READ_GSI_DATA(GSI_FILE) END SUBROUTINE READ_GSI_DATA + !> Read the first guess surface records and nsst records (if + !! selected) for a single cubed-sphere tile. + !! + !! @param[in] LSOIL Number of soil layers. + !! @param[in] LENSFC Total number of points on a tile. + !! @param[in] DO_NSST When true, nsst fields are read. + !! @param[out] TSFFCS Skin Temperature. + !! @param[out] SMCFCS Total volumetric soil moisture. + !! @param[out] SNOFCS Liquid-equivalent snow depth. + !! @param[out] STCFCS Soil temperature. + !! @param[out] TG3FCS Soil substrate temperature. + !! @param[out] ZORFCS Roughness length. + !! @param[out] CVFCS Cloud cover. + !! @param[out] CVBFCS Cloud base. + !! @param[out] CVTFCS Cloud top. + !! @param[out] ALBFCS Snow-free albedo. + !! @param[out] SLIFCS Land-sea mask including ice flag. + !! @param[out] VEGFCS Vegetation greenness. + !! @param[out] CNPFCS Plant canopy moisture content. + !! @param[out] F10M log((z0+10)/z0). See model routine sfc_diff.f for details. + !! @param[out] VETFCS Vegetation type. + !! @param[out] SOTFCS Soil type. + !! @param[out] ALFFCS Fractional coverage for strong/weak zenith angle + !! dependent albedo. + !! @param[out] USTAR Friction velocity. + !! @param[out] FMM log((z0+z1)/z0). See model routine sfc_diff.f for details. + !! @param[out] FHH log((ztmax+z1)/ztmax). See model routine sfc_diff.f for + !! details. + !! @param[out] SIHFCS Sea ice depth. + !! @param[out] SICFCS Sea ice concentration. + !! @param[out] SITFCS Sea ice temperature. + !! @param[out] TPRCP Precipitation. + !! @param[out] SRFLAG Snow/rain flag. + !! @param[out] SWDFCS Physical snow depth. + !! @param[out] VMNFCS Minimum vegetation greenness. + !! @param[out] VMXFCS Maximum vegetation greenness. + !! @param[out] SLCFCS Liquid portion of volumetric soil moisture. + !! @param[out] SLPFCS Slope type. + !! @param[out] ABSFCS Maximum snow albedo. + !! @param[out] T2M Two-meter air temperature. + !! @param[out] Q2M Two-meter specific humidity. + !! @param[out] SLMASK Land-sea mask without ice flag. + !! @param[out] ZSOIL Soil layer thickness. + !! @param[out] NSST Data structure containing nsst fields. + !! @author George Gayno NOAA/EMC SUBROUTINE READ_DATA(TSFFCS,SMCFCS,SNOFCS,STCFCS, & TG3FCS,ZORFCS, & CVFCS,CVBFCS,CVTFCS,ALBFCS, & @@ -1084,12 +1188,6 @@ SUBROUTINE READ_DATA(TSFFCS,SMCFCS,SNOFCS,STCFCS, & VMNFCS,VMXFCS,SLCFCS, & SLPFCS,ABSFCS,T2M,Q2M,SLMASK, & ZSOIL,LSOIL,LENSFC,DO_NSST,NSST) - -!----------------------------------------------------------------- -! READ THE FIRST GUESS SURFACE RECORDS AND NSST RECORDS (IF -! SELECTED) FOR A SINGLE CUBED-SPHERE TILE. -!----------------------------------------------------------------- - USE MPI IMPLICIT NONE @@ -1503,45 +1601,24 @@ SUBROUTINE READ_DATA(TSFFCS,SMCFCS,SNOFCS,STCFCS, & END SUBROUTINE READ_DATA + !> Read a GRIB1 sst climatological analysis file. + !! + !! Read the sst analysis and save it as an expanded and + !! transposed array. + !! + !! @note The data is stored from north to south, but this + !! routine flips the poles. + !! + !! @param[in] file_sst File name of the sst file. + !! @param[in] mlat_sst 'j' dimension of the sst data. + !! @param[in] mlon_sst 'i' dimension of the sst data. + !! @param[in] mon The month of the year. + !! @param[out] sst The sst analysis data. + !! @param[out] rlats_sst The latitudes of the sst data points. + !! @param[out] rlons_sst The longitudes of the sst data points. + !! @author Xu Li NOAA/EMC @date 2019-03-13 subroutine read_tf_clim_grb(file_sst,sst,rlats_sst,rlons_sst,mlat_sst,mlon_sst,mon) -! . . . . -! abstrac: read_tf_clim_grb : read grib1 sst analysis -! prgmmr: xu li org: np23 date: 2019-03-13 -! -! abstract: read sst analysis (grib format) and save it as expanded and transposed array -! -! subroutine rdgrbsst must be compiled with the ncep w3 library -! and the bacio library. -! -! -! program history log: -! -! input argument list: -! file_sst - file name of grib sst file -! mon - month number -! mlat_sst,mlon_sst -! output: -! rlats_sst -! rlons_sst -! sst -! -! argument list defined by this reading: -! sst - sst field -! note: (1) the data is stored from north to south originally in grib format, -! but is stored from south to north with this reading routine -! nlat_sst - latitudinal dimension of sst -! nlon_sst - longitudinal dimension of sst -! xsst0 - latitude of origin -! ysst0 - longitude of origin -! dres - lat/lon increment -! -! call subs: getgbh, getgb -! -! attributes: -! language: f90 -! -!$$$ use mpi implicit none @@ -1560,14 +1637,17 @@ subroutine read_tf_clim_grb(file_sst,sst,rlats_sst,rlons_sst,mlat_sst,mlon_sst,m ! declare local variables and arrays logical(1), allocatable, dimension(:) :: lb - integer :: nlat_sst,nlon_sst + integer :: nlat_sst !< Latitudinal dimension of the sst data. + integer :: nlon_sst !< Longitudinal dimension of the sst data. integer :: iret,ni,nj integer :: mscan,kb1,ierr integer :: jincdir,i,iincdir,kb2,kb3,kf,kg,k,j,jf integer, dimension(22):: jgds,kgds integer, dimension(25):: jpds,kpds - real :: xsst0,ysst0,dres + real :: xsst0 !< Latitude of the origin. + real :: ysst0 !< Longitude of the origin. + real :: dres !< Latitude/longitude increment. real, allocatable, dimension(:) :: f !************+****************************************************************************** @@ -1672,26 +1752,14 @@ subroutine read_tf_clim_grb(file_sst,sst,rlats_sst,rlons_sst,mlat_sst,mlon_sst,m end subroutine read_tf_clim_grb +!> Get the i/j dimensions of RTG SST climatology file. +!! The file is GRIB1. +!! +!! @param[in] file_sst File name of the sst file. +!! @param[in] mlat_sst The 'j' dimension of the data. +!! @param[in] mlon_sst The 'i' dimension of the data. +!! @author Xu Li NOAA/EMC @date 2019-03-13 subroutine get_tf_clm_dim(file_sst,mlat_sst,mlon_sst) -! . . . . -! abstract: get_tf_clm_dim : get dimension of rtg sst climatology -! prgmmr: xu li org: np23 date: 2019-03-13 -! -! -! program history log: -! -! input argument list: -! file_sst - file name of grib sst file -! output -! mlat_sst,mlon_sst -! -! call subs: getgbh -! -! attributes: -! language: f90 -! machine: ibm rs/6000 sp -! -!$$$ use mpi implicit none @@ -1739,8 +1807,18 @@ subroutine get_tf_clm_dim(file_sst,mlat_sst,mlon_sst) endif end subroutine get_tf_clm_dim +!> Read the woa05 salinity monthly climatology file. +!! The file is NetCDF. +!! +!! @param[in] filename The name of the climatology file. +!! @param[in] nlat The 'j' dimension of the data in the file. +!! @param[in] nlon The 'i' dimension of the data in the file. +!! @param[in] itime The monthly record to read. +!! @param[out] xlats The latitude of the data points. +!! @param[out] xlons The longitude of the data points. +!! @param[out] sal The salinity. +!! @author Xu Li NOAA/EMC subroutine read_salclm_gfs_nc(filename,sal,xlats,xlons,nlat,nlon,itime) -! abstract: read woa05 salinity monthly climatology (netcdf) use netcdf implicit none @@ -1810,8 +1888,13 @@ subroutine read_salclm_gfs_nc(filename,sal,xlats,xlons,nlat,nlon,itime) end subroutine read_salclm_gfs_nc +!> Get the i/j dimensions of the data from a NetCDF file. +!! +!! @param[in] filename Name of the file to be read. +!! @param[out] nlat 'j' dimension of the data in the file. +!! @param[out] nlon 'i' dimension of the data in the file. +!! @author Xu Li NOAA/EMC subroutine get_dim_nc(filename,nlat,nlon) -! abstract: get dimensions of sal array use netcdf implicit none @@ -1843,6 +1926,11 @@ subroutine get_dim_nc(filename,nlat,nlon) end subroutine get_dim_nc +!> Check the NetCDF status code. If there is an error, +!! print the library error message and stop processing. +!! +!! @param[in] status NetCDF status code. +!! @author Xu Li NOAA/EMC subroutine nc_check(status) use mpi diff --git a/sorc/global_cycle.fd/sfcsub.F b/sorc/global_cycle.fd/sfcsub.F index 6919366c6..c5b190350 100644 --- a/sorc/global_cycle.fd/sfcsub.F +++ b/sorc/global_cycle.fd/sfcsub.F @@ -1,7 +1,8 @@ !> @file !! @brief This is a limited point version of surface program. -!! -!! This program runs in two different modes: +!! @author M. Iredell, xuli, Hang Lei, George Gayno + +!> This program runs in two different modes: !! !! 1. analysis mode (fh=0.) !! this program merges climatology, analysis and forecast guess to create @@ -41,6 +42,7 @@ !! grid. if not dead start, no need for dimension but set to zero !! as in the example below. !! +!! @author M. Iredell, xuli, Hang Lei, George Gayno module sfccyc_module implicit none save @@ -71,6 +73,69 @@ module sfccyc_module integer :: soil_type_landice ! end module sfccyc_module + +!> Surface cycling driver routine. Update 'first guess' surface +!! fields with either analysis or climatological data. +!! +!! @param[in] lugb Fortran unit number used to read data files. +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @param[in] sig1t Sigma level 1 temperature for dead start. +!! @param[in] deltsfc Cycling frequency in hours. +!! @param[in] iy Year of initial state. +!! @param[in] im Month of initial state. +!! @param[in] id Day of initial state. +!! @param[in] ih Hour of initial state. +!! @param[in] fh Forecast hour. +!! @param[in] rla Latitude of model points. +!! @param[in] rlo Longitude of model points. +!! @param[in] slmask Model land-sea mask without ice flag. +!! @param[in] orog Filtered orography on model grid. +!! @param[in] orog_uf Unfiltered orography on model grid. +!! @param[in] use_ufo When true, adjust sst and soil substrate +!! temperature for differences between filtered and unfiltered terrain. +!! @param[in] nst_anl Set to true when using nst model. +!! @param[inout] sihfcs Sea ice thickness on model grid. +!! @param[inout] sicfcs Sea ice concentration on model grid. +!! @param[inout] sitfcs Sea ice skin temperature on model grid. +!! @param[inout] swdfcs Physical snow depth on model grid. +!! @param[inout] slcfcs Liquid portion of volumentric soil moisture on +!! model grid. +!! @param[inout] vmnfcs Minimum greenness fraction of model grid. +!! @param[inout] vmxfcs Maximum greenness fraction of model grid. +!! @param[inout] slpfcs Slope type on model grid. +!! @param[inout] absfcs Maximum snow albedo on model grid. +!! @param[inout] tsffcs Skin temperature/SST on model grid. +!! @param[inout] snofcs Liquid equivalent snow depth on model grid. +!! @param[inout] zorfcs Roughness length on model grid. +!! @param[inout] albfcs Snow-free albedo on model grid. +!! @param[inout] tg3fcs Soil substrate temperature on model grid. +!! @param[inout] cnpfcs Canopy moisture content on model grid. +!! @param[inout] smcfcs Total volumetric soil moisture on model grid. +!! @param[inout] stcfcs Soil/ice depth temperature on model grid. +!! @param[inout] slifcs Model land-sea mask including ice flag. +!! @param[inout] aisfcs Model ice mask. +!! @param[inout] vegfcs Vegetation greenness on model grid. +!! @param[inout] vetfcs Vegetation type on model grid. +!! @param[inout] sotfcs Soil type on model grid. +!! @param[inout] alffcs Fraction for strongly and weakly +!! zenith angle dependent albedo on model grid. +!! @param[inout] cvfcs Convective cloud cover on model grid. +!! @param[inout] cvbfcs Convective cloud base on model grid. +!! @param[inout] cvtfcs Convective cloud top on model grid. +!! @param[in] me MPI task number. +!! @param[in] nlunit Program namelist unit number. +!! @param[in] sz_nml Dimension of input_nml_file. +!! @param[in] input_nml_file Name of program namelist file. +!! @param[in] ialb Use modis albedo when '1'. Use brigleb when '0'. +!! @param[in] isot When '1', use statsgo soil type. When '0' use +!! zobler soil type. +!! @param[in] ivegsrc When '1', use igbp vegetation type. When '2' +!! use sib vegetation type. +!! @param[in] tile_num_ch Model tile number to process. +!! @param[in] i_index The 'i' indices of the model grid to process. +!! @param[in] j_index The 'j' indices of the model grid to process. +!! @author Shrinivas Moorthi subroutine sfccycle(lugb,len,lsoil,sig1t,deltsfc &, iy,im,id,ih,fh &, rla, rlo, slmask,orog,orog_uf,use_ufo,nst_anl @@ -2514,6 +2579,14 @@ subroutine sfccycle(lugb,len,lsoil,sig1t,deltsfc ! if(lprnt) print *,' tsffcsf=',tsffcs(iprnt) return end subroutine sfccycle + +!> Counts the number of model points that are snow covered land, +!! snow-free land, open water, sea ice, and snow covered sea ice. +!! +!! @param[in] slimsk The land-sea-ice mask. +!! @param[in] sno Snow +!! @param[in] ijmax Number of model points to process. +!! @author Shrinivas Moorthi NOAA/EMC subroutine count(slimsk,sno,ijmax) use machine , only : kind_io8,kind_io4 implicit none @@ -2566,6 +2639,17 @@ subroutine count(slimsk,sno,ijmax) ! if(lprnt) print *,' tsffcsf=',tsffcs(iprnt) return end + +!> Determine the maximum and minimum values of a surface field +!! at snow-free and snow covered land, open water, and +!! snow-free and snow covered sea ice. +!! +!! @param[in] lfld The name of the surface field to monitory. +!! @param[in] fld The surface field to monitor. +!! @param[in] slimsk Land-sea-ice mask. +!! @param[in] sno Snow. +!! @param[in] ijmax Number of model points to process. +!! @author Shrinivas Moorthi NOAA/EMC subroutine monitr(lfld,fld,slimsk,sno,ijmax) use machine , only : kind_io8,kind_io4 implicit none @@ -2630,6 +2714,14 @@ subroutine monitr(lfld,fld,slimsk,sno,ijmax) ! return end + +!> Compute day of the year based on month and day. +!! +!! @param[in] iyr Year. +!! @param[in] imo Month. +!! @param[in] idy Day. +!! @param[out] ldy Day of the year. +!! @author Mark Iredell NOAA/EMC subroutine dayoyr(iyr,imo,idy,ldy) implicit none integer ldy,i,idy,iyr,imo @@ -2645,6 +2737,22 @@ subroutine dayoyr(iyr,imo,idy,ldy) enddo return end + +!> Read a high-resolution land mask. It will be used +!! as a surrogate for GRIB input data without a bitmap. +!! This is NOT the model land mask. This mask file is GRIB1. +!! +!! @param[in] lugb Fortran unit number of the mask file. +!! @param[out] imsk 'i' dimension of the mask. +!! @param[out] jmsk 'j' dimension of the mask. +!! @param[in] fnmskh Name of the mask file. +!! @param[in] kpds5 GRIB1 parameter number for mask. +!! @param[out] slmskh The high-resolution mask. +!! @param[out] gausm When true, mask is on a gaussian grid. +!! @param[out] blnmsk Corner point longitude of the mask grid. +!! @param[out] bltmsk Corner point latitude of the mask grid. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi NOAA/EMC subroutine hmskrd(lugb,imsk,jmsk,fnmskh, & kpds5,slmskh,gausm,blnmsk,bltmsk,me) use machine , only : kind_io8,kind_io4 @@ -2678,6 +2786,21 @@ subroutine hmskrd(lugb,imsk,jmsk,fnmskh, ! return end + +!> Read a GRIB1 file. Return the requested data record +!! and some grid specifications. +!! +!! @param[in] lugb Fortran unit number of the grib file. +!! @param[inout] idim "i" dimension of the data. +!! @param[inout] jdim "j" dimension of the data. +!! @param[in] fngrib Name of the grib file. +!! @param[in] kpds5 The grib1 parameter number for the requested field. +!! @param[out] gdata The requested data. +!! @param[out] gaus When true, grid is gaussian. +!! @param[out] blno Corner point longitude of grid. +!! @param[out] blto Corner point latitude of grid. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi NOAA/EMC subroutine fixrdg(lugb,idim,jdim,fngrib, & kpds5,gdata,gaus,blno,blto,me) use machine , only : kind_io8,kind_io4 @@ -2793,6 +2916,21 @@ subroutine fixrdg(lugb,idim,jdim,fngrib, deallocate(lbms) return end + +!> For a given GRIB1 grid description section array, determine +!! some grid specifications. +!! +!! @param[in] kgds GRIB1 grid description section array. +!! @param[out] dlat Grid resolution in the 'j' direction. +!! @param[out] dlon Grid resolution in the 'i' direction. +!! @param[out] rslat Latitude of the southern row of data. +!! @param[out] rnlat Latitude of the northern row of data. +!! @param[out] wlon Longitude of the western column of data. +!! @param[out] elon Longitude of the eastern column of data. +!! @param[out] ijordr When false, adjacent points in the 'i' direction +!! are consecutive. Otherwise, 'j' points are consecutive. +!! @param[in] me MPI rank number. +!! @author Shrinivas Moorthi NOAA/EMC subroutine getarea(kgds,dlat,dlon,rslat,rnlat,wlon,elon,ijordr &, me) use machine , only : kind_io8,kind_io4 @@ -2943,6 +3081,19 @@ subroutine getarea(kgds,dlat,dlon,rslat,rnlat,wlon,elon,ijordr ! return end + +!> Take an array of data on a lat/lon based grid and rearrange +!! it so the corner point is in the 'lower left' and adjacent +!! points in the 'i' direction are consecutive. +!! +!! @param[inout] data The data to be adjusted. +!! @param[in] imax 'i' dimension of data. +!! @param[in] jmax 'j' dimension of data. +!! @param[in] dlon Delta longitude of the data. +!! @param[in] dlat Delta latitude of the data. +!! @param[in] ijordr When false, adjacent points in the 'i' direction +!! are consecutive. Otherwise, 'j' points are consecutive. +!! @author Shrinivas Moorthi subroutine subst(data,imax,jmax,dlon,dlat,ijordr) use machine , only : kind_io8,kind_io4 implicit none @@ -3003,6 +3154,26 @@ subroutine subst(data,imax,jmax,dlon,dlat,ijordr) endif return end + +!> Interpolate data from a lat/lon grid to the model grid. +!! +!! @param[in] regin Input data. +!! @param[in] imxin 'i' dimension of input data. +!! @param[in] jmxin 'j' dimension of input data. +!! @param[in] rinlon +!! @param[in] rinlat +!! @param[in] rlon +!! @param[in] rlat +!! @param[in] inttyp +!! @param[out] gauout The interpolated data on the model grid. +!! @param[in] len Number of model points to process. +!! @param[in] lmask +!! @param[in] rslmsk +!! @param[in] slmask Model land-sea-ice mask. +!! @param[in] outlat Latitudes on the model grid. +!! @param[in] outlon Longitudes on the model grid. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorth subroutine la2ga(regin,imxin,jmxin,rinlon,rinlat,rlon,rlat,inttyp, & gauout,len,lmask,rslmsk,slmask &, outlat, outlon,me) @@ -3540,6 +3711,13 @@ subroutine la2ga(regin,imxin,jmxin,rinlon,rinlat,rlon,rlat,inttyp, ! return end subroutine la2ga + +!> Compute the maxmimum and minimum of a field. +!! +!! @param[in] f The field to check. +!! @param[in] imax The horizontal dimension of the field. +!! @param[in] kmax Number of vertical levels of the field. +!! @author Shrinivas Moorthi subroutine maxmin(f,imax,kmax) use machine , only : kind_io8,kind_io4 implicit none @@ -3572,6 +3750,74 @@ subroutine maxmin(f,imax,kmax) ! return end + +!> Fill in analysis arrays with climatology before reading analysis +!! data. +!! +!! @param[out] tsfanl Skin temperature/SST analysis on model grid. +!! @param[out] tsfan2 Skin temperature/SST analysis on model grid +!! at time minus deltsfc. +!! @param[out] wetanl Soil wetness analysis on model grid. +!! @param[out] snoanl Liquid equivalent snow depth analysis on model grid. +!! @param[out] zoranl Roughness length analysis on model grid. +!! @param[out] albanl Snow-free albedo analysis on model grid. +!! @param[out] aisanl Sea ice mask analysis on model grid. +!! @param[out] tg3anl Soil substrate temperature analysis on model grid. +!! @param[out] cvanl Convective cloud cover analysis on model grid. +!! @param[out] cvbanl Convective cloud base analysis on model grid. +!! @param[out] cvtanl Convective cloud top analysis on model grid. +!! @param[out] cnpanl Canopy water content analysis on model grid. +!! @param[out] smcanl Soil moisture analysis on model grid. +!! @param[out] stcanl Soil temperature analysis on model grid. +!! @param[out] slianl Land-sea-ice mask analysis on model grid. +!! @param[out] scvanl Snow cover analysis on model grid. +!! @param[out] veganl Vegetation greenness analysis on model grid. +!! @param[out] vetanl Vegetation type analysis on model grid. +!! @param[out] sotanl Soil type analysis on model grid. +!! @param[out] alfanl Fraction for strongly and weakly zenith +!! angle dependent albedo analysis on model grid. +!! @param[out] sihanl Sea ice depth analysis on model grid. +!! @param[out] sicanl Sea ice concentration analysis on model grid. +!! @param[out] vmnanl Minimum vegetation greenness analysis on model +!! grid. +!! @param[out] vmxanl Maximum vegetation greenness analysis on model +!! grid. +!! @param[out] slpanl Slope type analysis on model grid. +!! @param[out] absanl Maximum snow albedo analysis on model grid. +!! @param[in] tsfclm Climatological skin temperature/SST on model grid. +!! @param[in] tsfcl2 Climatological skin temperature/SST on model grid +!! at time minus deltsfc. +!! @param[in] wetclm Climatological soil wetness on model grid. +!! @param[in] snoclm Climatological liquid equivalent snow depth on model grid. +!! @param[in] zorclm Climatological roughness length on model grid. +!! @param[in] albclm Climatological snow-free albedo on model grid. +!! @param[in] aisclm Climatological sea ice mask on model grid. +!! @param[in] tg3clm Climatological soil substrate temperature on model +!! grid. +!! @param[in] cvclm Climatological convective cloud cover on model grid. +!! @param[in] cvbclm Climatological convective cloud base on model grid. +!! @param[in] cvtclm Climatological convective cloud top on model grid. +!! @param[in] cnpclm Climatological canopy water content on model grid. +!! @param[in] smcclm Climatological soil moisture on model grid. +!! @param[in] stcclm Climatologcial soil temperature on model grid. +!! @param[in] sliclm Climatological model land-sea-ice mask. +!! @param[in] scvclm Climatological snow cover on model grid. +!! @param[in] vegclm Climatological vegetation greenness on model grid. +!! @param[in] vetclm Climatological vegetation type on model grid. +!! @param[in] sotclm Climatological soil type on model grid. +!! @param[in] alfclm Climatological fraction for strongly and weakly +!! zenith angle dependent albedo on model grid. +!! @param[in] sihclm Climatological sea ice depth on the model grid. +!! @param[in] sicclm Climatological sea ice concentration on the model grid. +!! @param[in] vmnclm Climatological minimum vegetation greenness on +!! model grid. +!! @param[in] vmxclm Climatological maximum vegetation greenness on +!! model grid. +!! @param[in] slpclm Climatological slope type on model grid. +!! @param[in] absclm Climatological maximum snow albedo on model grid. +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @author Shrinivas Moorthi subroutine filanl(tsfanl,tsfan2,wetanl,snoanl,zoranl,albanl, & aisanl, & tg3anl,cvanl ,cvbanl,cvtanl, @@ -3669,6 +3915,133 @@ subroutine filanl(tsfanl,tsfan2,wetanl,snoanl,zoranl,albanl, ! return end + +!> Read analysis fields. +!! +!! @param[in] lugb Fortran unit number for analysis files. +!! @param[in] iy Cycle year. +!! @param[in] im Cycle month. +!! @param[in] id Cycle day. +!! @param[in] ih Cycle hour. +!! @param[in] fh Forecast hour. +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @param[in] slmask Model land-sea mask. +!! @param[in] fntsfa SST analysis file. +!! @param[in] fnweta Soil wetness analysis file. +!! @param[in] fnsnoa Snow analysis file +!! @param[in] fnzora Roughness length analysis file. +!! @param[in] fnalba Snow-free albedo analysis file. +!! @param[in] fnaisa Sea ice mask analysis file. +!! @param[in] fntg3a Soil substrate analysis file. +!! @param[in] fnscva Snow cover analysis file. +!! @param[in] fnsmca Soil moisture analysis file. +!! @param[in] fnstca Soil temperature analysis file. +!! @param[in] fnacna Sea ice concentration analysis file. +!! @param[in] fnvega Vegetation greenness analysis file. +!! @param[in] fnveta Vegetation type analysis file. +!! @param[in] fnsota Soil type analysis file. +!! @param[in] fnvmna Minimum vegetation greenness analysis file. +!! @param[in] fnvmxa Maximum vegetation greenness analysis file. +!! @param[in] fnslpa Slope type analysis file. +!! @param[in] fnabsa Maximum snow albedo analysis file. +!! @param[out] tsfanl Skin temperature/SST analysis on model grid. +!! @param[out] wetanl Soil wetness analysis on model grid. +!! @param[out] snoanl Snow analysis on model grid. +!! @param[out] zoranl Roughness length analysis on model grid. +!! @param[out] albanl Snow-free albedo analysis on model grid. +!! @param[out] aisanl Sea ice mask analysis on model grid. +!! @param[out] tg3anl Soil substrate analysis on model grid. +!! @param[out] cvanl Convective cloud cover analysis on model grid. +!! @param[out] cvbanl Convective cloud base analysis on model grid. +!! @param[out] cvtanl Convective cloud top analysis on model grid. +!! @param[out] smcanl Soil moisture analysis on model grid. +!! @param[out] stcanl Soil temperature analysis on model grid. +!! @param[out] slianl Not used. +!! @param[out] scvanl Snow cover analysis on model grid. +!! @param[out] acnanl Sea ice concentration analysis on model grid. +!! @param[out] veganl Vegetation greenness analysis on model grid. +!! @param[out] vetanl Vegetation type analysis on model grid. +!! @param[out] sotanl Soil type analysis on model grid. +!! @param[out] alfanl Analysis of fraction for strongly and +!! weakly zenith angle dependent albedo on model grid. +!! @param[out] tsfan0 SST analysis at forecast hour 0 on model grid. +!! @param[out] vmnanl Minimum vegetation greenness analysis on model +!! grid. +!! @param[out] vmxanl Maximum vegetation greenness analysis on model +!! grid. +!! @param[out] slpanl Slope type analysis on model grid. +!! @param[out] absanl Maximum snow albedo analysis on model grid. +!! @param[in] kpdtsf Grib parameter number of skin temperature/SST. +!! @param[in] kpdwet Grib parameter number of soil wetness. +!! @param[in] kpdsno Grib parameter number of liquid equivalent snow +!! depth. +!! @param[in] kpdsnd Grib parameter number of physical snow depth. +!! @param[in] kpdzor Grib parameter number of roughness length. +!! @param[in] kpdalb Grib parameter number of snow-free albedo. +!! @param[in] kpdais Grib parameter number of sea ice mask. +!! @param[in] kpdtg3 Grib parameter number of soil substrate +!! temperature. +!! @param[in] kpdscv Grib parameter number of snow cover. +!! @param[in] kpdacn Grib parameter number of sea ice concentration. +!! @param[in] kpdsmc Grib parameter number of soil moisture. +!! @param[in] kpdstc Grib parameter number of soil temperature. +!! @param[in] kpdveg Grib parameter number of vegetation greenness. +!! @param[in] kprvet Grib parameter number of vegetation type. +!! @param[in] kpdsot Grib parameter number of soil type. +!! @param[in] kpdalf Grib parameter number for fraction for strongly +!! and weakly zenith angle dependent albedo. +!! @param[in] kpdvmn Grib parameter number of minimum vegetation +!! greenness. +!! @param[in] kpdvmx Grib parameter number of maximum vegetation +!! greenness. +!! @param[in] kpdslp Grib parameter number of slope type. +!! @param[in] kpdabs Grib parameter number of maximum snow albedo. +!! @param[out] irttsf Return code from read of skin temperature/SST +!! analysis file. +!! @param[out] irtwet Return code from read of soil wetness analysis +!! file. +!! @param[out] irtsno Return code from read of snow analysis file. +!! @param[out] irtzor Return code from read of roughness length file. +!! @param[out] irtalb Return code from read of snow-free albedo analysis file. +!! @param[out] irtais Return code from read of ice mask analysis file. +!! @param[out] irttg3 Return code from read of soil substrate +!! temperature analysis file. +!! @param[out] irtscv Return code from read of snow cover analysis file. +!! @param[out] irtacn Return code from read of sea ice concentration +!! analysis file. +!! @param[out] irtsmc Return code from read of soil moisture analysis +!! file. +!! @param[out] irtstc Return code from read of soil temperature analysis +!! file. +!! @param[out] irtveg Return code from read of vegetation greenness +!! analysis file. +!! @param[out] irtvet Return code from read of vegetation type analysis +!! file. +!! @param[out] irtsot Return code from read of soil type analysis file. +!! @param[out] irtalf Return code from read of file containing fraction +!! for strongly and weakly zenith angle dependent albedo. +!! @param[out] irtvmn Return code from read of minimum vegetation +!! greenness analysis file. +!! @param[out] irtvmx Return code from read of maximum vegetation +!! greenness analysis file. +!! @param[out] irtslp Return code from read of slope type analysis file. +!! @param[out] irtabs Return code from read of maximum snow albedo +!! analysis file. +!! @param[in] imsk 'i' dimension of the high-res mask used for +!! analysis data without a bitmap. +!! @param[in] jmsk 'j' dimension of the high-res mask used for +!! analysis data without a bitmap. +!! @param[in] slmskh The high-resolution mask used for +!! analysis data without a bitmap. +!! @param[in] outlat Model latitudes +!! @param[in] outlon Model longitudes +!! @param[in] gaus When true, the high-res mask is on a gaussian grid. +!! @param[in] blno Corner point longitude of the high-res mask. +!! @param[in] blto Corner point latitude of the high-res mask. +!! @param[in] me MPI task number. +!! @param[in] lanom When true, do sst anomaly interpolation. +!! @author Shrinivas Moorthi subroutine analy(lugb,iy,im,id,ih,fh,len,lsoil, & slmask,fntsfa,fnweta,fnsnoa,fnzora,fnalba,fnaisa, & fntg3a,fnscva,fnsmca,fnstca,fnacna,fnvega, @@ -4333,6 +4706,63 @@ subroutine analy(lugb,iy,im,id,ih,fh,len,lsoil, ! return end + +!> Fill in model grid guess arrays with analysis values if this is a dead start. +!! All fields are on the model grid. +!! +!! @param[out] tsffcs First guess skin temperature/SST analysis. +!! @param[out] wetfcs First guess soil wetness. +!! @param[out] snofcs First guess liquid equivalent snow depth. +!! @param[out] zorfcs First guess roughness length. +!! @param[out] albfcs First guess snow-free albedo. +!! @param[out] tg3fcs First guess soil substrate temperature. +!! @param[out] cvfcs First guess cloud cover. +!! @param[out] cvbfcs First guess convective cloud bottom. +!! @param[out] cvtfcs First guess convective cloud top. +!! @param[out] cnpfcs First guess canopy water content. +!! @param[out] smcfcs First guess soil moisture. +!! @param[out] stcfcs First guess soil temperature. +!! @param[out] slifcs First guess land-sea-ice mask. +!! @param[out] aisfcs First guess sea ice mask. +!! @param[out] vegfcs First guess vegetation greenness. +!! @param[out] vetfcs First guess vegetation type. +!! @param[out] sotfcs First guess soil type. +!! @param[out] alffcs First guess of fraction for strongly and +!! weakly zenith angle dependent albedo. +!! @param[out] sihfcs First guess sea ice depth. +!! @param[out] sicfcs First guess sea ice concentration. +!! @param[out] vmnfcs First guess minimum greenness fraction. +!! @param[out] vmxfcs First guess maximum greenness fraction. +!! @param[out] slpfcs First guess slope type. +!! @param[out] absfcs First guess maximum snow albedo analysis. +!! @param[in] tsfanl Skin temperature/SST analysis. +!! @param[in] wetanl Soil wetness analysis. +!! @param[in] snoanl Liquid equivalent snow depth analysis. +!! @param[in] zoranl Roughness length analysis. +!! @param[in] albanl Snow-free albedo analysis. +!! @param[in] tg3anl Soil substrate temperature analysis. +!! @param[in] cvanl Convective cloud cover analysis. +!! @param[in] cvbanl Convective cloud base analysis. +!! @param[in] cvtanl Convective cloud top analysis. +!! @param[in] cnpanl Canopy water content analysis. +!! @param[in] smcanl Soil moisture analysis. +!! @param[in] stcanl Soil temperature analysis. +!! @param[in] slianl Land-sea-ice mask analysis. +!! @param[in] aisanl Sea ice mask analysis. +!! @param[in] veganl Vegetation greenness analysis. +!! @param[in] vetanl Vegetation type analysis. +!! @param[in] sotanl Soil type analysis. +!! @param[in] alfanl Analysis of fraction for strongly and weakly +!! zenith angle dependent albedo. +!! @param[in] sihanl Sea ice depth analysis. +!! @param[in] sicanl Sea ice concentration analysis. +!! @param[in] vmnanl Minimum greenness fraction analysis. +!! @param[in] vmxanl Maximum greenness fraction analysis. +!! @param[in] slpanl Slope type analysis. +!! @param[in] absanl Maximum snow albedo analysis. +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @author Shrinivas Moorthi subroutine filfcs(tsffcs,wetfcs,snofcs,zorfcs,albfcs, & tg3fcs,cvfcs ,cvbfcs,cvtfcs, & cnpfcs,smcfcs,stcfcs,slifcs,aisfcs, @@ -4425,34 +4855,15 @@ subroutine filfcs(tsffcs,wetfcs,snofcs,zorfcs,albfcs, ! return end - subroutine bktges(smcfcs,slianl,stcfcs,len,lsoil) -! - use machine , only : kind_io8,kind_io4 - implicit none - integer i,j,len,lsoil,k - real (kind=kind_io8) smcfcs(len,lsoil), stcfcs(len,lsoil), - & slianl(len) -! -! note that smfcs comes in with the original unit (cm?) (not grib file) -! - do i = 1, len - smcfcs(i,1) = (smcfcs(i,1)/150.) * .37 + .1 - enddo - do k = 2, lsoil - do i = 1, len - smcfcs(i,k) = smcfcs(i,1) - enddo - enddo - if(lsoil.gt.2) then - do k = 3, lsoil - do i = 1, len - stcfcs(i,k) = stcfcs(i,2) - enddo - enddo - endif -! - return - end + +!> Round a field up to one or down to zero. +!! +!! @param[inout] aisfld The field to adjust. +!! @param[in] len Number of model points to process. +!! @param[in] op Operation on field. +!! @param[in] crit Critical value above/below the +!! field is rounded. +!! @author Shrinivas Moorthi subroutine rof01(aisfld,len,op,crit) use machine , only : kind_io8,kind_io4 implicit none @@ -4499,6 +4910,17 @@ subroutine rof01(aisfld,len,op,crit) ! return end + +!> Adjust skin temperature or SST for terrain. +!! +!! @param[inout] tsfc Skin temperature/SST +!! @param[in] orog Orography height. +!! @param[in] slmask Model land-sea mask. +!! @param[in] umask When '0' adjust SST, when '1' adjust skin +!! temperature. +!! @param[in] len Number of model points to process. +!! @param[in] rlapse Standard atmospheric lapse rate. +!! @author Shrinivas Moorthi subroutine tsfcor(tsfc,orog,slmask,umask,len,rlapse) ! use machine , only : kind_io8,kind_io4 @@ -4514,6 +4936,21 @@ subroutine tsfcor(tsfc,orog,slmask,umask,len,rlapse) enddo return end + +!> Estimate snow depth at glacial, land and sea ice points. +!! +!! @param[in] scvanl Snow cover. +!! @param[in] slianl Land-sea-ice mask. +!! @param[in] tsfanl Skin temperature. +!! @param[in] snoclm Climatological snow depth. +!! @param[in] glacir Permanent glacial point when '1'. +!! @param[in] snwmax Maximum snow depth. +!! @param[in] snwmin Minimum snow depth. +!! @param[in] landice When true, point is permanent land ice. +!! @param[in] len Number of model points to process. +!! @param[out] snoanl Snow depth. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi subroutine snodpth(scvanl,slianl,tsfanl,snoclm, & glacir,snwmax,snwmin,landice,len,snoanl, me) use machine , only : kind_io8,kind_io4 @@ -4568,6 +5005,166 @@ subroutine snodpth(scvanl,slianl,tsfanl,snoclm, enddo return end subroutine snodpth + +!> Blend the model forecast (or first guess) fields with the +!! analysis/climatology. The forecast/first guess variables +!! are named with "fcs". The analysis/climatology variables +!! are named with "anl". On output, the blended fields are +!! stored in the "anl" variables. +!! +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @param[in] iy Cycle year. +!! @param[in] im Cycle month. +!! @param[in] id Cycle day. +!! @param[in] ih Cycle hour. +!! @param[in] fh Forecast hour. +!! @param[in] deltsfc Cycling frequency in hours. +!! @param[in] sihfcs First guess sea ice depth. +!! @param[in] sicfcs First guess sea ice concentration. +!! @param[in] vmnfcs First guess minimum vegetation greenness. +!! @param[in] vmxfcs First guess maximum vegetation greenness. +!! @param[in] slpfcs First guess slope type. +!! @param[in] absfcs First guess maximum snow albedo. +!! @param[in] tsffcs First guess skin temperature/SST. +!! @param[in] wetfcs First guess soil wetness. +!! @param[in] snofcs First guess liquid equivalent snow depth. +!! @param[in] zorfcs First guess roughness length. +!! @param[in] albfcs First guess snow free albedo. +!! @param[in] aisfcs First guess ice. +!! @param[in] cvfcs First guess convective cloud cover. +!! @param[in] cvbfcs First guess convective cloud bottom. +!! @param[in] cvtfcs First guess convective cloud top. +!! @param[in] cnpfcs First guess canopy water content. +!! @param[in] smcfcs First guess soil moisture. +!! @param[in] stcfcs First guess soil/ice temperature. +!! @param[in] slifcs First guess land-sea-ice mask. +!! @param[in] vegfcs First guess vegetation greenness. +!! @param[in] vetfcs First guess vegetation type. +!! @param[in] sotfcs First guess soil type. +!! @param[in] alffcs First guess strong/weak zenith angle +!! dependent albedo. +!! @param[inout] sihanl Blended sea ice depth. +!! @param[inout] sicanl Blended sea ice concentration. +!! @param[inout] vmnanl Blended minimum vegetation greenness. +!! @param[inout] vmxanl Blended maximum vegetation greenness. +!! @param[inout] slpanl Blended slope type. +!! @param[inout] absanl Blended maximum snow albedo. +!! @param[inout] tsfanl Blended skin temperature/SST. +!! @param[inout] tsfan2 Not used. +!! @param[inout] wetanl Blended soil wetness. +!! @param[inout] snoanl Blended liquid equivalent snow depth. +!! @param[inout] zoranl Blended roughness length. +!! @param[inout] albanl Blended snow-free albedo. +!! @param[inout] aisanl Blended ice. +!! @param[inout] cvanl Blended convective cloud cover. +!! @param[inout] cvbanl Blended convective cloud base. +!! @param[inout] cvtanl Blended convective cloud top. +!! @param[inout] cnpanl Blended canopy moisture content. +!! @param[inout] smcanl Blended soil moisture. +!! @param[inout] stcanl Blended soil/ice temperature. +!! @param[inout] slianl Blended land-sea-ice mask. +!! @param[inout] veganl Blended vegetation greenness. +!! @param[inout] vetanl Blended vegetation type. +!! @param[inout] sotanl Blended soil type. +!! @param[inout] alfanl Blended strong/weak zenith angle +!! dependent albedo. +!! @param[in] ctsfl Merging coefficient for skin temperature. +!! @param[in] calbl Merging coefficient for snow-free albedo at land +!! points. +!! @param[in] caisl Merging coefficient for sea ice at land points. +!! @param[in] csnol Merging coefficient for snow at land points. +!! @param[in] csmcl Merging coefficient for soil moisture at land +!! points. +!! @param[in] czorl Merging coefficient for roughness length at land +!! points. +!! @param[in] cstcl Merging coefficient for soil temperature at land +!! points. +!! @param[in] cvegl Merging coefficient for vegetation greenness at land +!! points. +!! @param[in] ctsfs Merging coefficient for SST. +!! @param[in] calbs Merging coefficient for snow-free albedo at water +!! points. +!! @param[in] caiss Merging coefficient for sea ice at water points. +!! @param[in] csnos Merging coefficient for snow at water points. +!! @param[in] csmcs Merging coefficient for soil moisture at water +!! points. +!! @param[in] czors Merging coefficient for roughness length at water +!! points. +!! @param[in] cstcs Merging coefficient for sea ice temperature at water +!! points. +!! @param[in] cvegs Merging coefficient for vegetation greenness at +!! water points. +!! @param[in] ccv Merging coefficient for convective cloud cover. +!! @param[in] ccvb Merging coefficient for covective cloud bottom. +!! @param[in] ccvt Merging coefficient for covective cloud top. +!! @param[in] ccnp Merging coefficient for canopy moisture. +!! @param[in] cvetl Merging coefficient for vegetation type at land +!! points. +!! @param[in] cvets Merging coefficient for vegetation type at water +!! points. +!! @param[in] csotl Merging coefficient for soil type at land points. +!! @param[in] csots Merging coefficient for soil type at water points. +!! @param[in] calfl Merging coefficient for strong/weak zenith +!! angle dependent albedo at land points. +!! @param[in] calfs Merging coefficient for strong/weak zenith +!! angle dependent albedo at water points. +!! @param[in] csihl Merging coefficient for sea ice depth at land +!! points. +!! @param[in] csihs Merging coefficient for sea ice depth at water +!! points. +!! @param[in] csicl Merging coefficient for sea ice concentration at +!! land points. +!! @param[in] csics Merging coefficient for sea ice concentration at +!! water points. +!! @param[in] cvmnl Merging coefficient for minimum vegetation greenness +!! at land points. +!! @param[in] cvmns Merging coefficient for minimum vegetation greenness +!! at water points. +!! @param[in] cvmxl Merging coefficient for maximum vegetation greenness +!! at land points. +!! @param[in] cvmxs Merging coefficient for maximum vegetation greenness +!! at water points. +!! @param[in] cslpl Merging coefficient for slope type at land points. +!! @param[in] cslps Merging coefficient for slope type at water points. +!! @param[in] cabsl Merging coefficient for maximum snow albedo at land +!! points. +!! @param[in] cabss Merging coefficient for maximum snow albedo at +!! water points. +!! @param[in] irttsf Return code from read of skin temperature/SST +!! analysis file. +!! @param[in] irtwet Return code from read of soil wetness analysis +!! file. +!! @param[in] irtsno Return code from read of snow analysis file. +!! @param[in] irtzor Return code from read of roughness length file. +!! @param[in] irtalb Return code from read of snow-free albedo analysis file. +!! @param[in] irtais Return code from read of ice mask analysis file. +!! @param[in] irttg3 Return code from read of soil substrate +!! temperature analysis file. +!! @param[in] irtscv Return code from read of snow cover analysis file. +!! @param[in] irtacn Return code from read of sea ice concentration +!! analysis file. +!! @param[in] irtsmc Return code from read of soil moisture analysis +!! file. +!! @param[in] irtstc Return code from read of soil temperature analysis +!! file. +!! @param[in] irtveg Return code from read of vegetation greenness +!! analysis file. +!! @param[in] irtvmn Return code from read of minimum vegetation +!! greenness analysis file. +!! @param[in] irtvmx Return code from read of maximum vegetation +!! greenness analysis file. +!! @param[in] irtslp Return code from read of slope type analysis file. +!! @param[in] irtabs Return code from read of maximum snow albedo +!! analysis file. +!! @param[in] irtvet Return code from read of vegetation type analysis +!! file. +!! @param[in] irtsot Return code from read of soil type analysis file. +!! @param[in] irtalf Return code from read of file containing fraction +!! for strongly and weakly zenith angle dependent albedo. +!! @param[in] landice Permanent land ice flag. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi subroutine merge(len,lsoil,iy,im,id,ih,fh,deltsfc, & sihfcs,sicfcs, & vmnfcs,vmxfcs,slpfcs,absfcs, @@ -5019,6 +5616,39 @@ subroutine merge(len,lsoil,iy,im,id,ih,fh,deltsfc, !$omp end parallel do return end subroutine merge + +!> Adjust surface fields when ice melts or forms. +!! +!! @param[in] slianl Land-sea-ice mask. +!! @param[in] slifcs First guess land-sea-ice mask. +!! @param[out] tsfanl Skin temperature/SST. +!! @param[in] tsffcs First guess skin temperature/SST. +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @param[in] sihnew Sea ice depth for new ice. +!! @param[in] sicnew Sea ice concentration for new ice. +!! @param[out] sihanl Sea ice depth. +!! @param[out] sicanl Sea ice concentration. +!! @param[out] albanl Snow-free albedo. +!! @param[out] snoanl Liquid equivalent snow depth. +!! @param[out] zoranl Roughness length. +!! @param[out] smcanl Soil moisture +!! @param[out] stcanl Soil temperature +!! @param[in] albsea Albedo at open water. +!! @param[in] snosea Snow at open water. +!! @param[in] zorsea Roughness length at open water. +!! @param[in] smcsea Soil moisture at open water. +!! @param[in] smcice Soil moisture at ice. +!! @param[in] tsfmin SST at open water. +!! @param[in] tsfice Skin temperature at ice. +!! @param[in] albice Ice albedo. +!! @param[in] zorice Roughness length of ice. +!! @param[in] tgice Freezing point of salt water. +!! @param[in] rla Model latitudes. +!! @param[in] rlo Model longitudes. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi +!! @author Xingen Wu subroutine newice(slianl,slifcs,tsfanl,tsffcs,len,lsoil, !cwu [+1l] add sihnew,sicnew,sihanl,sicanl & sihnew,sicnew,sihanl,sicanl, @@ -5115,6 +5745,18 @@ subroutine newice(slianl,slifcs,tsfanl,tsffcs,len,lsoil, ! return end + +!> Quality control snow at the model points. +!! +!! @param[out] snoanl Model snow to be qc'd. +!! @param[in] slmask Land-sea-ice mask. +!! @param[in] aisanl Ice mask. +!! @param[in] glacir Permanent glacial point when '1'. +!! @param[in] len Number of model points to process. +!! @param[in] snoval Minimum snow depth at glacial points. +!! @param[in] landice Is the point permanent land ice? +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi subroutine qcsnow(snoanl,slmask,aisanl,glacir,len,snoval, & landice,me) use machine , only : kind_io8,kind_io4 @@ -5161,6 +5803,21 @@ subroutine qcsnow(snoanl,slmask,aisanl,glacir,len,snoval, endif return end subroutine qcsnow + +!> Check the sea ice cover mask against the land-sea mask. +!! +!! @param[out] ais Sea ice cover mask. +!! @param[in] glacir Glacial flag +!! @param[in] amxice Maximum ice extent. +!! @param[in] aicice Ice indicator. +!! @param[in] aicsea Open water indicator. +!! @param[in] sllnd Land indicator. +!! @param[in] slmask Land-sea-ice mask. +!! @param[in] rla Model latitudes +!! @param[in] rlo Model longitudes +!! @param[in] len Number of model points to process. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi subroutine qcsice(ais,glacir,amxice,aicice,aicsea,sllnd,slmask, & rla,rlo,len,me) use machine , only : kind_io8,kind_io4 @@ -5260,6 +5917,15 @@ subroutine qcsice(ais,glacir,amxice,aicice,aicsea,sllnd,slmask, ! enddo return end + +!> Set land-sea-ice mask at sea ice. +!! +!! @param[in] slmask The model mask on input. +!! @param[in] aisfld The ice mask on the model grid. +!! @param[in] len Number of model points to process. +!! @param[in] aicice Ice concentration theshold for an ice point. +!! @param[out] slifld The model mask with sea ice added. +!! @author Shrinivas Moorthi subroutine setlsi(slmask,aisfld,len,aicice,slifld) ! use machine , only : kind_io8,kind_io4 @@ -5278,6 +5944,13 @@ subroutine setlsi(slmask,aisfld,len,aicice,slifld) enddo return end + +!> Multiply a field by a scaling factor. +!! +!! @param[inout] fld The field to scale. +!! @param[in] len Number of model points to process. +!! @param[in] scl Scaling factor. +!! @author Shrinivas Moorthi subroutine scale(fld,len,scl) ! use machine , only : kind_io8,kind_io4 @@ -5289,6 +5962,38 @@ subroutine scale(fld,len,scl) enddo return end + +!> Range check a field. The check is a function of whether the +!! point is land, water or ice. +!! +!! @param[in] ttl Name of field. +!! @param[inout] fld The field array to be ranged checked. +!! @param[in] slimsk The land-sea-ice mask. +!! @param[in] sno Snow. +!! @param[in] iceflg When true, check ice points. +!! @param[in] fldlmx Maximum allowable value at snow-free land. +!! @param[in] fldlmn Minimum allowable value at snow-free land. +!! @param[in] fldomx Maximum allowable value at open water. +!! @param[in] fldomn Minimum allowable value at open water. +!! @param[in] fldimx Maximum allowable value at snow-free ice. +!! @param[in] fldimn Minimum allowable value at snow-free ice. +!! @param[in] fldjmx Maximum allowable value at snow covered ice. +!! @param[in] fldjmn Minimum allowable value at snow covered ice. +!! @param[in] fldsmx Maximum allowable value at snow covered land. +!! @param[in] fldsmn Minimum allowable value at snow covered land. +!! @param[in] epsfld Difference from the max/min allowable +!! value at which the field is updated. +!! @param[in] rla Latitude of the points to process. +!! @param[in] rlo Longitude of the points to process. +!! @param[in] len Number of points to process. +!! @param[in] mode When '1', update the field. When not '1', run +!! routine in diagnostic mode. +!! @param[in] percrit Critical percentage of 'bad' points required +!! for abort. +!! @param[in] lgchek When true, abort when a critical percentage of points +!! are outside acceptable range. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi NOAA/EMC subroutine qcmxmn(ttl,fld,slimsk,sno,iceflg, & fldlmx,fldlmn,fldomx,fldomn,fldimx,fldimn, & fldjmx,fldjmn,fldsmx,fldsmn,epsfld, @@ -5706,6 +6411,13 @@ subroutine qcmxmn(ttl,fld,slimsk,sno,iceflg, ! return end + +!> Set a field to zero if it is less than a threshold. +!! +!! @param[inout] fld Field to set. +!! @param[in] eps Threshold. +!! @param[in] len Number of model points to process. +!! @author Shrinivas Moorthi subroutine setzro(fld,eps,len) ! use machine , only : kind_io8,kind_io4 @@ -5717,6 +6429,13 @@ subroutine setzro(fld,eps,len) enddo return end + +!> Set snow cover flag based on snow depth. +!! +!! @param[in] snofld Snow depth. +!! @param[out] scvfld Snow cover. +!! @param[in] len Number of model points to process. +!! @author Shrinivas Moorthi subroutine getscv(snofld,scvfld,len) ! use machine , only : kind_io8,kind_io4 @@ -5730,6 +6449,17 @@ subroutine getscv(snofld,scvfld,len) enddo return end + +!> Set soil temperature and sea ice column temperature. +!! +!! @param[in] tsffld Skin temperature/SST. +!! @param[in] tg3fld Soil substrate temperature. +!! @param[in] slifld Land-sea-ice mask. +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @param[out] stcfld Soil/sea ice column temperature. +!! @param[in] tsfimx Freezing point of sea water. +!! @author Shrinivas Moorthi subroutine getstc(tsffld,tg3fld,slifld,len,lsoil,stcfld,tsfimx) ! use machine , only : kind_io8,kind_io4 @@ -5763,6 +6493,15 @@ subroutine getstc(tsffld,tg3fld,slifld,len,lsoil,stcfld,tsfimx) endif return end + +!> Set soil moisture from soil wetness. +!! +!! @param[in] wetfld Soil wetness +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @param[out] smcfld Soil moisture. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi subroutine getsmc(wetfld,len,lsoil,smcfld,me) ! use machine , only : kind_io8,kind_io4 @@ -5781,6 +6520,19 @@ subroutine getsmc(wetfld,len,lsoil,smcfld,me) enddo return end + +!> Set soil temperature and sea ice column temperature for +!! a dead start. +!! +!! @param[in] sig1t Sigma level 1 temperature for dead start. +!! @param[in] slianl Land-sea-ice mask. +!! @param[in] tg3anl Soil substrate temperature. +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @param[out] tsfanl Skin temperature. +!! @param[out] stcanl Soil/sea ice column temperature. +!! @param[in] tsfimx Freezing point of sea water. +!! @author Shrinivas Moorthi subroutine usesgt(sig1t,slianl,tg3anl,len,lsoil,tsfanl,stcanl, & tsfimx) ! @@ -5804,6 +6556,16 @@ subroutine usesgt(sig1t,slianl,tg3anl,len,lsoil,tsfanl,stcanl, ! return end + +!> Check skin temperature at points with snow. If it is +!! above a threshold, reset it to that value. +!! +!! @param[in] snoanl Snow. +!! @param[inout] tsfanl Skin temperature at the model points. +!! @param[in] tsfsmx Maximum allowable skin temperature at snow points. +!! @param[in] len Number of model points to process. +!! @param[in] me MPI rank +!! @author Shrinivas Moorthi NOAA/EMC subroutine snosfc(snoanl,tsfanl,tsfsmx,len,me) use machine , only : kind_io8,kind_io4 implicit none @@ -5828,6 +6590,14 @@ subroutine snosfc(snoanl,tsfanl,tsfsmx,len,me) endif return end + +!> Set the albedo at open water points. +!! +!! @param[inout] albclm Albedo. +!! @param[in] slmask The land-sea-ice mask. +!! @param[in] albomx The albedo at open water. +!! @param[in] len Number of model points to process. +!! @author Shrinivas Moorthi NOAA/EMC subroutine albocn(albclm,slmask,albomx,len) use machine , only : kind_io8,kind_io4 implicit none @@ -5844,6 +6614,14 @@ subroutine albocn(albclm,slmask,albomx,len) enddo return end + +!> Quality control maximum ice extent. +!! +!! @param[in] glacir Glacial flag +!! @param[out] amxice Maximum ice extent. +!! @param[in] len Number of model points to process. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi subroutine qcmxice(glacir,amxice,len,me) use machine , only : kind_io8,kind_io4 implicit none @@ -5864,6 +6642,15 @@ subroutine qcmxice(glacir,amxice,len,me) endif return end + +!> Check consistency between the forecast and analysis +!! land-sea-ice mask. +!! +!! @param[in] slianl Analysis mask. +!! @param[inout] slifcs Forecast mask. +!! @param[in] len Number of model points to process. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi subroutine qcsli(slianl,slifcs,len,me) use machine , only : kind_io8,kind_io4 implicit none @@ -5902,6 +6689,7 @@ subroutine qcsli(slianl,slifcs,len,me) endif return end + ! subroutine nntprt(data,imax,fact) ! real (kind=kind_io8) data(imax) ! ilast=0 @@ -5927,6 +6715,30 @@ subroutine qcsli(slianl,slifcs,len,me) !1111 format(80i1) ! return ! end + +!> Quality control analysis fields using the first guess. +!! +!! @param[in] tsffcs First guess skin temperature/SST. +!! @param[in] snofcs First guess snow. +!! @param[in] qctsfs Surface temperature above which no snow +!! allowed. +!! @param[in] qcsnos Snow depth above which snow must exits. +!! @param[in] qctsfi SST above which sea ice is not allowed. +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @param[out] snoanl Snow analysis. +!! @param[in] aisanl Ice mask. +!! @param[in] slianl Land-sea-ice mask. +!! @param[out] tsfanl Skin temperature/SST analysis. +!! @param[in] albanl Snow-free albedo analysis. +!! @param[in] zoranl Roughness length analysis. +!! @param[in] smcanl Soil moisture analysis. +!! @param[in] smcclm Soil moisture climatology. +!! @param[in] tsfsmx Not used. +!! @param[in] albomx Snow-free albedo at open water. +!! @param[in] zoromx Roughness length at open water. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi subroutine qcbyfc(tsffcs,snofcs,qctsfs,qcsnos,qctsfi, & len,lsoil,snoanl,aisanl,slianl,tsfanl,albanl, & zoranl,smcanl, @@ -6023,6 +6835,32 @@ subroutine qcbyfc(tsffcs,snofcs,qctsfs,qcsnos,qctsfi, ! return end + +!> Set the mask for the input data. (Not the model mask). +!! The mask is determined from the input data bitmap or by +!! interpolating a high-resolution mask to the input +!! data grid. Note: not all data has a mask. +!! +!! @param[in] kpds5 Grib parameter number. +!! @param[in] slmask High-resolution mask. +!! @param[in] igaul "i" dimension of the high-res mask. +!! @param[in] jgaul "j" dimension of the high-res mask. +!! @param[in] wlon Longitude of 'west' boundary of input data. +!! @param[in] rnlat Latitude of north row of input data. +!! @param[in] data The input data. +!! @param[in] imax "i" dimension of input grid. +!! @param[in] jmax "j" dimension of input grid. +!! @param[out] rlnout Latitudes on input data grid. +!! @param[out] rltout Longitudes on input data grid. +!! @param[out] lmask True, when input data has a mask. +!! @param[out] rslmsk The mask of the input data grid. +!! @param[in] gaus Is high-resolution mask on a gaussian grid. +!! @param[in] blno Corner point longitude of the high-res mask. +!! @param[in] blto Corner point longitude of the high-res mask. +!! @param[in] kgds1 Grib indicator for grid type. +!! @param[in] kpds4 Grib indicator for bitmap. +!! @param[in] lbms Bitmap of input data. +!! @author Shrinivas Moorthi subroutine setrmsk(kpds5,slmask,igaul,jgaul,wlon,rnlat, & data,imax,jmax,rlnout,rltout,lmask,rslmsk &, gaus,blno, blto, kgds1, kpds4, lbms) @@ -6504,6 +7342,23 @@ subroutine setrmsk(kpds5,slmask,igaul,jgaul,wlon,rnlat, ! return end + +!> ??? +!! +!! @param[in] gauin +!! @param[in] imxin +!! @param[in] jmxin +!! @param[in] regout +!! @param[in] imxout +!! @param[in] jmxout +!! @param[in] wlon +!! @param[in] rnlat +!! @param[in] rlnout +!! @param[in] rltout +!! @param[in] gaus +!! @param[in] blno +!! @param[in] blto +!! @author M. Iredell, xuli, Hang Lei, George Gayno subroutine ga2la(gauin,imxin,jmxin,regout,imxout,jmxout, & wlon,rnlat,rlnout,rltout,gaus,blno, blto) use machine , only : kind_io8,kind_io4 @@ -6750,6 +7605,15 @@ subroutine ga2la(gauin,imxin,jmxin,regout,imxout,jmxout, ! return end + +!> Set vegetation, soil and slope type at undefined model points. +!! +!! @param[inout] vegtype Vegetation type +!! @param[inout] soiltype Soil type +!! @param[inout] slptype Slope type +!! @param[in] slmask Land-sea-ice mask. +!! @param[in] len Number of model points to process. +!! @author Shrinivas Moorthi subroutine landtyp(vegtype,soiltype,slptype,slmask,len) use machine , only : kind_io8,kind_io4 implicit none @@ -6768,6 +7632,12 @@ subroutine landtyp(vegtype,soiltype,slptype,slmask,len) enddo return end subroutine landtyp + +!> Calculate gaussian latitudes. +!! +!! @param[out] gaul Gaussian latitudes +!! @param[in] k Number of latitudes +!! @author Shrinivas Moorthi subroutine gaulat(gaul,k) ! use machine , only : kind_io8,kind_io4 @@ -6791,7 +7661,15 @@ subroutine gaulat(gaul,k) 6000 format(//5x,'error in gauaw'//) stop end -!----------------------------------------------------------------------- + +!> Add initial SST anomaly to date interpolated climatology +!! +!! @param[in] tsfan0 Skin temperature/SST analysis at initial time. +!! @param[in] tsfclm Skin temperature/SST climatology. +!! @param[in] tsfcl0 Skin temperature/SST climatology at initial time. +!! @param[out] tsfanl Updated skin temperature/SST. +!! @param[in] len Number of model points to process. +!! @author Shrinivas Moorthi subroutine anomint(tsfan0,tsfclm,tsfcl0,tsfanl,len) ! use machine , only : kind_io8,kind_io4 @@ -6809,6 +7687,118 @@ subroutine anomint(tsfan0,tsfclm,tsfcl0,tsfanl,len) enddo return end + +!> Driver routine that reads in climatological data for a given time, +!! and, if necessary, interpolates it to the model grid. +!! +!! @param[in] lugb Fortran unit number of GRIB1 climatological data. +!! @param[in] iy Cycle year. +!! @param[in] im Cycle month. +!! @param[in] id Cycle day. +!! @param[in] ih Cycle hour. +!! @param[in] fh Forecast hour. +!! @param[in] len Number of model points to process. +!! @param[in] lsoil Number of soil layers. +!! @param[in] slmask Model land-sea-ice mask. +!! @param[in] fntsfc Climatological SST file. +!! @param[in] fnwetc Climatological soil wetness file. +!! @param[in] fnsnoc Climatological snow depth file. +!! @param[in] fnzorc Climatological roughness length file. Or 'igbp' +!! to use igbp vegetation type lookup table. Or 'sib' to use sib +!! vegeation type lookup table. +!! @param[in] fnalbc Climatological snow-free albedo file. +!! @param[in] fnaisc Climatological sea ice mask file. +!! @param[in] fntg3c Climatological soil substrate temperature file. +!! @param[in] fnscvc Climatological snow cover file. +!! @param[in] fnsmcc Climatological soil moisture file. +!! @param[in] fnstcc Climatological soil temperature file. +!! @param[in] fnacnc Climatological sea ice concentration file. +!! @param[in] fnvegc Climatological vegetation greenness file. +!! @param[in] fnvetc Climatological vegetation type file. +!! @param[in] fnsotc Climatological soil type file. +!! @param[in] fnvmnc Climatological minimum vegetation greenness file. +!! @param[in] fnvmxc Climatological maximum vegetation greenness file. +!! @param[in] fnslpc Climatological slope type file. +!! @param[in] fnabsc Climatological maximum snow albedo file. +!! @param[out] tsfclm Climatological skin temperature/SST on model grid. +!! @param[out] tsfcl2 Climatological skin temperature/SST on model grid +!! at time minus deltsfc. +!! @param[out] wetclm Climatological soil wetness on model grid. +!! @param[out] snoclm Climatological liquid equivalent snow depth on model grid. +!! @param[out] zorclm Climatological roughness length on model grid. +!! @param[out] albclm Climatological snow-free albedo on model grid. +!! @param[out] aisclm Climatological sea ice mask on model grid. +!! @param[out] tg3clm Climatological soil substrate temperature on model +!! grid. +!! @param[out] cvclm Climatological convective cloud cover on model grid. +!! @param[out] cvbclm Climatological convective cloud base on model grid. +!! @param[out] cvtclm Climatological convective cloud top on model grid. +!! @param[out] cnpclm Climatological canopy water content on model grid. +!! @param[out] smcclm Climatological soil moisture on model grid. +!! @param[out] stcclm Climatologcial soil temperature on model grid. +!! @param[out] sliclm Climatological model land-sea-ice mask. +!! @param[out] scvclm Climatological snow cover on model grid. +!! @param[out] acnclm Climatological sea ice concentration on model grid. +!! @param[out] vegclm Climatological vegetation greenness on model grid. +!! @param[out] vetclm Climatological vegetation type on model grid. +!! @param[out] sotclm Climatological soil type on model grid. +!! @param[out] alfclm Climatological fraction for strongly and weakly +!! zenith angle dependent albedo on model grid. +!! @param[out] vmnclm Climatological minimum vegetation greenness on +!! model grid. +!! @param[out] vmxclm Climatological maximum vegetation greenness on +!! model grid. +!! @param[out] slpclm Climatological slope type on model grid. +!! @param[out] absclm Climatological maximum snow albedo on model grid. +!! @param[in] kpdtsf Grib parameter number of skin temperature/SST. +!! @param[in] kpdwet Grib parameter number of soil wetness. +!! @param[in] kpdsno Grib parameter number of liquid equivalent snow +!! depth. +!! @param[in] kpdzor Grib parameter number of roughness length. +!! @param[in] kpdalb Grib parameter number of snow-free albedo. +!! @param[in] kpdais Grib parameter number of sea ice mask. +!! @param[in] kpdtg3 Grib parameter number of soil substrate +!! temperature. +!! @param[in] kpdscv Grib parameter number of snow cover. +!! @param[in] kpdacn Grib parameter number of sea ice concentration. +!! @param[in] kpdsmc Grib parameter number of soil moisture. +!! @param[in] kpdstc Grib parameter number of soil temperature. +!! @param[in] kpdveg Grib parameter number of vegetation greenness. +!! @param[in] kpdvet Grib parameter number of vegetation type. +!! @param[in] kpdsot Grib parameter number of soil type. +!! @param[in] kpdalf Grib parameter number for fraction for strongly +!! and weakly zenith angle dependent albedo. +!! @param[in] tsfcl0 Climatological SST at forecast +!! hour 0. +!! @param[in] kpdvmn Grib parameter number of minimum vegetation +!! greenness. +!! @param[in] kpdvmx Grib parameter number of maximum vegetation +!! greenness. +!! @param[in] kpdslp Grib parameter number of slope type. +!! @param[in] kpdabs Grib parameter number of maximum snow albedo. +!! @param[in] deltsfc Cycling frequency in hours. +!! @param[in] lanom When true, do sst anomaly interpolation. +!! @param[in] imsk 'i' dimension of the high-res mask used for +!! climatological data without a bitmap. +!! @param[in] jmsk 'j' dimension of the high-res mask used for +!! climatological data without a bitmap. +!! @param[in] slmskh The high-resolution mask used for +!! climatological data without a bitmap. +!! @param[in] outlat Model latitudes +!! @param[in] outlon Model longitudes +!! @param[in] gaus When true, the high-res mask is on a gaussian grid. +!! @param[in] blno Corner point longitude of the high-res mask. +!! @param[in] blto Corner point latitude of the high-res mask. +!! @param[in] me MPI task number. +!! @param[in] lprnt Turn of diagnostic print. +!! @param[in] iprnt Index of diagnotic print point. +!! @param[in] fnalbc2 File containing climatological fraction for +!! strongly and weakly zenith angle dependent albedo. +!! @param[in] ialb Use modis albedo when '1'. Use brigleb when '0'. +!! @param[in] tile_num_ch Model tile number to process. +!! @param[in] i_index The 'i' indices of the model grid to process. +!! @param[in] j_index The 'j' indices of the model grid to process. +!! @author Shrinivas Moorthi NOAA/EMC subroutine clima(lugb,iy,im,id,ih,fh,len,lsoil, & slmask,fntsfc,fnwetc,fnsnoc,fnzorc,fnalbc,fnaisc, & fntg3c,fnscvc,fnsmcc,fnstcc,fnacnc,fnvegc, @@ -7979,6 +8969,22 @@ subroutine clima(lugb,iy,im,id,ih,fh,len,lsoil, ! return end subroutine clima + +!> Reads in climatological data on the model grid tile for +!! a given month. Unlike fixrdc, this routine assumes +!! the input data is already interpolated to the model tile. +!! The climatological data must be NetCDF. +!! +!! @param[in] filename_raw The name of the climatological file. +!! @param[in] tile_num_ch The tile number to be processed. +!! @param[in] i_index The 'i' indices of the model grid to process. +!! @param[in] j_index The 'j' indices of the model grid to process. +!! @param[in] kpds Parameter code for the data. +!! @param[out] var The climatological data on the model grid. +!! @param[in] mon Which month of data to read. +!! @param[in] npts Number of model points to process. +!! @param[in] me MPI task number. +!! @author George Gayno NOAA/EMC subroutine fixrdc_tile(filename_raw, tile_num_ch, & i_index, j_index, kpds, & var, mon, npts, me) @@ -8116,6 +9122,11 @@ subroutine fixrdc_tile(filename_raw, tile_num_ch, return end subroutine fixrdc_tile + +!> Print the error message for a given netCDF return code. +!! +!! @param[in] error +!! @author Xu Li NOAA/EMC subroutine netcdf_err(error) use netcdf @@ -8129,6 +9140,32 @@ subroutine netcdf_err(error) call abort end subroutine netcdf_err + +!> Read in grib1 climatology data for a specific month and +!! and horizontally interpolate to the model grid. +!! +!! @param[in] lugb Fortran unit number of the grib1 climatology data file. +!! @param[in] fngrib The name of the grib1 climatology data file. +!! @param[in] kpds5 The grib1 parameter number of the requested data. +!! @param[in] kpds7 The grib1 level indicator of the requested data. +!! @param[in] mon The requested month. +!! @param[in] slmask Model land-sea-ice mask. +!! @param[out] gdata The climatology data interpolated to the model grid. +!! @param[in] len The number of model points to process. +!! @param[in] iret Return code. '0' is success. +!! @param[in] imsk 'i' dimension of the high-res mask used for input +!! data without a bitmap. +!! @param[in] jmsk 'j' dimension of the high-res mask used for input +!! data without a bitmap. +!! @param[in] slmskh The high-resolution mask used for input +!! data witouth a bitmap. +!! @param[in] gaus When true, the high-res mask is on a gaussian grid. +!! @param[in] blno Corner point longitude of the high-res mask. +!! @param[in] blto Corner point latitude of the high-res mask. +!! @param[in] outlat Model latitudes. +!! @param[in] outlon Model longitudes. +!! @param[in] me MPI task number +!! @author Shrinivas Moorthi NOAA/EMC subroutine fixrdc(lugb,fngrib,kpds5,kpds7,mon,slmask, & gdata,len,iret &, imsk, jmsk, slmskh, gaus,blno, blto @@ -8140,11 +9177,6 @@ subroutine fixrdc(lugb,fngrib,kpds5,kpds7,mon,slmask, & jmsk,len,lugb,kpds5,mon,lskip,lgrib,ndata,lugi,me,kmami &, jj,w3kindreal,w3kindint real (kind=kind_io8) wlon,elon,rnlat,dlat,dlon,rslat,blno,blto -! -! read in grib climatology files and interpolate to the input -! grid. grib files should allow all the necessary parameters -! to be extracted from the description records. -! ! character*500 fngrib ! character*80 fngrib, asgnstr @@ -8305,6 +9337,36 @@ subroutine fixrdc(lugb,fngrib,kpds5,kpds7,mon,slmask, deallocate(lbms) return end subroutine fixrdc + +!> Read in grib1 analysis data for the requested date and +!! horizontally interpolate to the model grid. If data not found +!! for the requested date, a backwards search is performed. +!! +!! @param[in] lugb Fortran unit number of the grib1 analysis data file. +!! @param[in] fngrib The name of the grib1 analysis data file. +!! @param[in] kpds5 The grib1 parameter number of the requested data. +!! @param[in] slmask Model land-sea-ice mask. +!! @param[in] iy Year. +!! @param[in] im Month. +!! @param[in] id Day. +!! @param[in] ih Hour. +!! @param[in] fh Forecast hour. +!! @param[out] gdata The analysis data interpolated to the model grid. +!! @param[in] len The number of model points to process. +!! @param[in] iret Return code. '0' is success. +!! @param[in] imsk 'i' dimension of the high-res mask used for input analysis +!! data without a bitmap. +!! @param[in] jmsk 'j' dimension of the high-res mask used for input analysis +!! data without a bitmap. +!! @param[in] slmskh The high-resolution mask used for input analysis +!! data witouth a bitmap. +!! @param[in] gaus When true, the high-res mask is on a gaussian grid. +!! @param[in] blno Corner point longitude of the high-res mask. +!! @param[in] blto Corner point latitude of the high-res mask. +!! @param[in] outlat Model latitudes. +!! @param[in] outlon Model longitudes. +!! @param[in] me MPI task number +!! @author Shrinivas Moorthi NOAA/EMC subroutine fixrda(lugb,fngrib,kpds5,slmask, & iy,im,id,ih,fh,gdata,len,iret &, imsk, jmsk, slmskh, gaus,blno, blto @@ -8319,10 +9381,6 @@ subroutine fixrda(lugb,fngrib,kpds5,slmask, real (kind=kind_io8) rnlat,rslat,wlon,elon,dlon,dlat,fh,blno, & rjday,blto ! -! read in grib climatology/analysis files and interpolate to the input -! dates and the grid. grib files should allow all the necessary parameters -! to be extracted from the description records. -! ! nrepmx: max number of days for going back date search ! nvalid: analysis later than (current date - nvalid) is regarded as ! valid for current analysis @@ -8624,6 +9682,15 @@ subroutine fixrda(lugb,fngrib,kpds5,slmask, deallocate(data8) return end subroutine fixrda + +!> Ensure deep snow pack at permanent glacial points. +!! +!! @param[in] glacir Glacial flag +!! @param[in] snwmax Deep snow pack depth +!! @param[inout] snoanl Model snow +!! @param[in] len Number of model points to process. +!! @param[in] me MPI task number. +!! @author Shrinivas Moorthi NOAA/EMC subroutine snodpth2(glacir,snwmax,snoanl, len, me) use machine , only : kind_io8,kind_io4 implicit none