/wrfv2_fire/dyn_nmm/module_initialize_real.F
FORTRAN Legacy | 5238 lines | 3350 code | 960 blank | 928 comment | 103 complexity | 132c80bdb132b364e3d5f3f4a821dd15 MD5 | raw file
Possible License(s): AGPL-1.0
Large files files are truncated, but you can click here to view the full file
- !REAL:MODEL_LAYER:INITIALIZATION
- ! This MODULE holds the routines which are used to perform various initializations
- ! for individual domains utilizing the NMM dynamical core.
- !-----------------------------------------------------------------------
- MODULE module_initialize_real
- USE module_bc
- USE module_configure
- USE module_domain
- USE module_io_domain
- USE module_model_constants
- ! USE module_si_io_nmm
- USE module_state_description
- USE module_timing
- USE module_soil_pre
- #ifdef DM_PARALLEL
- USE module_dm, ONLY : LOCAL_COMMUNICATOR &
- ,MYTASK,NTASKS,NTASKS_X &
- ,NTASKS_Y
- USE module_comm_dm
- USE module_ext_internal
- #endif
- INTEGER :: internal_time_loop
- INTEGER:: MPI_COMM_COMP,MYPE
- INTEGER:: loopinc, iloopinc
- CONTAINS
- !-------------------------------------------------------------------
- SUBROUTINE init_domain ( grid )
- IMPLICIT NONE
- ! Input space and data. No gridded meteorological data has been stored, though.
- ! TYPE (domain), POINTER :: grid
- TYPE (domain) :: grid
- ! Local data.
- INTEGER :: idum1, idum2
- CALL set_scalar_indices_from_config ( head_grid%id , idum1, idum2 )
- CALL init_domain_nmm (grid &
- !
- #include <actual_new_args.inc>
- !
- )
- END SUBROUTINE init_domain
- !-------------------------------------------------------------------
- !---------------------------------------------------------------------
- SUBROUTINE init_domain_nmm ( grid &
- !
- # include <dummy_new_args.inc>
- !
- )
- USE module_optional_input
- IMPLICIT NONE
- ! Input space and data. No gridded meteorological data has been stored, though.
- ! TYPE (domain), POINTER :: grid
- TYPE (domain) :: grid
- # include <dummy_new_decl.inc>
- TYPE (grid_config_rec_type) :: config_flags
- ! Local domain indices and counters.
- INTEGER :: num_veg_cat , num_soil_top_cat , num_soil_bot_cat
- INTEGER :: &
- ids, ide, jds, jde, kds, kde, &
- ims, ime, jms, jme, kms, kme, &
- its, ite, jts, jte, kts, kte, &
- ips, ipe, jps, jpe, kps, kpe, &
- i, j, k, NNXP, NNYP
- ! Local data
- CHARACTER(LEN=19):: start_date
- #ifdef DM_PARALLEL
- LOGICAL,EXTERNAL :: WRF_DM_ON_MONITOR
- logical :: test
- ! INTEGER :: DOMDESC
- REAL,ALLOCATABLE :: SICE_G(:,:), SM_G(:,:)
- INTEGER, ALLOCATABLE:: IHE_G(:),IHW_G(:)
- INTEGER, ALLOCATABLE:: ITEMP(:,:)
- INTEGER :: my_e,my_n,my_s,my_w,my_ne,my_nw,my_se,my_sw,myi,myj,npe
- INTEGER :: istat,inpes,jnpes
- #else
- integer, allocatable:: ihw(:),ihe(:)
- #endif
- CHARACTER (LEN=255) :: message
- INTEGER :: error
- REAL :: p_surf, p_level
- REAL :: cof1, cof2
- REAL :: qvf , qvf1 , qvf2 , pd_surf
- REAL :: p00 , t00 , a
- REAL :: hold_znw, rmin,rmax
- REAL :: p_top_requested , ptsgm
- INTEGER :: num_metgrid_levels, ICOUNT
- REAL , DIMENSION(max_eta) :: eta_levels
- LOGICAL :: stretch_grid, dry_sounding, debug, log_flag_sst, hyb_coor
- REAL, ALLOCATABLE,DIMENSION(:,:):: ADUM2D,SNOWC,HT,TG_ALT, &
- PDVP,PSFC_OUTV
- REAL, ALLOCATABLE,DIMENSION(:,:,:):: P3D_OUT,P3DV_OUT,P3DV_IN, &
- QTMP,QTMP2
- INTEGER, ALLOCATABLE, DIMENSION(:):: KHL2,KVL2,KHH2,KVH2, &
- KHLA,KHHA,KVLA,KVHA
- ! INTEGER, ALLOCATABLE, DIMENSION(:,:):: grid%lu_index
- REAL, ALLOCATABLE, DIMENSION(:):: DXJ,WPDARJ,CPGFUJ,CURVJ, &
- FCPJ,FDIVJ,EMJ,EMTJ,FADJ, &
- HDACJ,DDMPUJ,DDMPVJ
- REAL, ALLOCATABLE,DIMENSION(:),SAVE:: SG1,SG2,DSG1,DSG2, &
- SGML1,SGML2
- !-- Carsel and Parrish [1988]
- REAL , DIMENSION(100) :: lqmi
- integer iicount
- REAL:: TPH0D,TLM0D
- REAL:: TPH0,WB,SB,TDLM,TDPH
- REAL:: WBI,SBI,EBI,ANBI,STPH0,CTPH0
- REAL:: TSPH,DTAD,DTCF
- REAL:: ACDT,CDDAMP,DXP,FP
- REAL:: WBD,SBD
- REAL:: RSNOW,SNOFAC
- REAL, PARAMETER:: SALP=2.60
- REAL, PARAMETER:: SNUP=0.040
- REAL:: SMCSUM,STCSUM,SEAICESUM,FISX
- REAL:: cur_smc, aposs_smc
- REAL:: COAC, CODAMP
- INTEGER,PARAMETER:: DOUBLE=SELECTED_REAL_KIND(15,300)
- REAL(KIND=DOUBLE):: TERM1,APH,TLM,TPH,DLM,DPH,STPH,CTPH
- INTEGER:: KHH,KVH,JAM,JA, IHL, IHH, L
- INTEGER:: II,JJ,ISRCH,ISUM,ITER,Ilook,Jlook
- REAL, PARAMETER:: DTR=0.01745329
- REAL, PARAMETER:: W_NMM=0.08
- #if defined(HWRF)
- REAL, PARAMETER:: DDFC=1.0
- #else
- REAL, PARAMETER:: DDFC=8.0
- #endif
- REAL, PARAMETER:: TWOM=.00014584
- REAL, PARAMETER:: CP=1004.6
- REAL, PARAMETER:: DFC=1.0
- REAL, PARAMETER:: ROI=916.6
- REAL, PARAMETER:: R=287.04
- REAL, PARAMETER:: CI=2060.0
- REAL, PARAMETER:: ROS=1500.
- REAL, PARAMETER:: CS=1339.2
- REAL, PARAMETER:: DS=0.050
- REAL, PARAMETER:: AKS=.0000005
- REAL, PARAMETER:: DZG=2.85
- REAL, PARAMETER:: DI=.1000
- REAL, PARAMETER:: AKI=0.000001075
- REAL, PARAMETER:: DZI=2.0
- REAL, PARAMETER:: THL=210.
- REAL, PARAMETER:: PLQ=70000.
- REAL, PARAMETER:: ERAD=6371200.
- REAL, PARAMETER:: TG0=258.16
- REAL, PARAMETER:: TGA=30.0
- integer :: numzero,numexamined
- #ifdef HWRF
- !============================================================================
- ! gopal's doing for ocean coupling
- !============================================================================
- REAL, DIMENSION(:,:), ALLOCATABLE :: NHLAT,NHLON,NVLAT,NVLON,HRES_SM
- REAL :: NDLMD,NDPHD,NWBD,NSBD
- INTEGER :: NIDE,NJDE,ILOC,JLOC
- INTEGER fid, ierr, nprocs
- CHARACTER*255 f65name, SysString
- !============================================================================
- ! end gopal's doing for ocean coupling
- !============================================================================
- #endif
- if (ALLOCATED(ADUM2D)) DEALLOCATE(ADUM2D)
- if (ALLOCATED(TG_ALT)) DEALLOCATE(TG_ALT)
- !#define COPY_IN
- !#include <scalar_derefs.inc>
- #ifdef DM_PARALLEL
- # include <data_calls.inc>
- #endif
- SELECT CASE ( model_data_order )
- CASE ( DATA_ORDER_ZXY )
- kds = grid%sd31 ; kde = grid%ed31 ;
- ids = grid%sd32 ; ide = grid%ed32 ;
- jds = grid%sd33 ; jde = grid%ed33 ;
- kms = grid%sm31 ; kme = grid%em31 ;
- ims = grid%sm32 ; ime = grid%em32 ;
- jms = grid%sm33 ; jme = grid%em33 ;
- kts = grid%sp31 ; kte = grid%ep31 ; ! tile is entire patch
- its = grid%sp32 ; ite = grid%ep32 ; ! tile is entire patch
- jts = grid%sp33 ; jte = grid%ep33 ; ! tile is entire patch
- CASE ( DATA_ORDER_XYZ )
- ids = grid%sd31 ; ide = grid%ed31 ;
- jds = grid%sd32 ; jde = grid%ed32 ;
- kds = grid%sd33 ; kde = grid%ed33 ;
- ims = grid%sm31 ; ime = grid%em31 ;
- jms = grid%sm32 ; jme = grid%em32 ;
- kms = grid%sm33 ; kme = grid%em33 ;
- its = grid%sp31 ; ite = grid%ep31 ; ! tile is entire patch
- jts = grid%sp32 ; jte = grid%ep32 ; ! tile is entire patch
- kts = grid%sp33 ; kte = grid%ep33 ; ! tile is entire patch
- CASE ( DATA_ORDER_XZY )
- ids = grid%sd31 ; ide = grid%ed31 ;
- kds = grid%sd32 ; kde = grid%ed32 ;
- jds = grid%sd33 ; jde = grid%ed33 ;
- ims = grid%sm31 ; ime = grid%em31 ;
- kms = grid%sm32 ; kme = grid%em32 ;
- jms = grid%sm33 ; jme = grid%em33 ;
- its = grid%sp31 ; ite = grid%ep31 ; ! tile is entire patch
- kts = grid%sp32 ; kte = grid%ep32 ; ! tile is entire patch
- jts = grid%sp33 ; jte = grid%ep33 ; ! tile is entire patch
- END SELECT
- #ifdef DM_PARALLEL
- CALL WRF_GET_MYPROC(MYPE)
- CALL WRF_GET_DM_COMMUNICATOR(MPI_COMM_COMP)
- call wrf_get_nprocx(inpes)
- call wrf_get_nprocy(jnpes)
- !
- allocate(itemp(inpes,jnpes),stat=istat)
- npe=0
- !
- do j=1,jnpes
- do i=1,inpes
- itemp(i,j)=npe
- if(npe==mype)then
- myi=i
- myj=j
- endif
- npe=npe+1
- enddo
- enddo
- !
- my_n=-1
- if(myj+1<=jnpes)my_n=itemp(myi,myj+1)
- !
- my_e=-1
- if(myi+1<=inpes)my_e=itemp(myi+1,myj)
- !
- my_s=-1
- if(myj-1>=1)my_s=itemp(myi,myj-1)
- !
- my_w=-1
- if(myi-1>=1)my_w=itemp(myi-1,myj)
- !
- my_ne=-1
- if((myi+1<=inpes).and.(myj+1<=jnpes)) &
- my_ne=itemp(myi+1,myj+1)
- !
- my_se=-1
- if((myi+1<=inpes).and.(myj-1>=1)) &
- my_se=itemp(myi+1,myj-1)
- !
- my_sw=-1
- if((myi-1>=1).and.(myj-1>=1)) &
- my_sw=itemp(myi-1,myj-1)
- !
- my_nw=-1
- if((myi-1>=1).and.(myj+1<=jnpes)) &
- my_nw=itemp(myi-1,myj+1)
- !
- ! my_neb(1)=my_n
- ! my_neb(2)=my_e
- ! my_neb(3)=my_s
- ! my_neb(4)=my_w
- ! my_neb(5)=my_ne
- ! my_neb(6)=my_se
- ! my_neb(7)=my_sw
- ! my_neb(8)=my_nw
- !
- deallocate(itemp)
- #endif
- NNXP=min(ITE,IDE-1)
- NNYP=min(JTE,JDE-1)
- write(message,*) 'IDE, JDE: ', IDE,JDE
- write(message,*) 'NNXP, NNYP: ', NNXP,NNYP
- CALL wrf_message(message)
- JAM=6+2*(JDE-JDS-10)
- if (internal_time_loop .eq. 1) then
- ALLOCATE(ADUM2D(grid%sm31:grid%em31,jms:jme))
- ALLOCATE(KHL2(JTS:NNYP),KVL2(JTS:NNYP),KHH2(JTS:NNYP),KVH2(JTS:NNYP))
- ALLOCATE(DXJ(JTS:NNYP),WPDARJ(JTS:NNYP),CPGFUJ(JTS:NNYP),CURVJ(JTS:NNYP))
- ALLOCATE(FCPJ(JTS:NNYP),FDIVJ(JTS:NNYP),&
- FADJ(JTS:NNYP))
- ALLOCATE(HDACJ(JTS:NNYP),DDMPUJ(JTS:NNYP),DDMPVJ(JTS:NNYP))
- ALLOCATE(KHLA(JAM),KHHA(JAM))
- ALLOCATE(KVLA(JAM),KVHA(JAM))
- endif
- CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags )
- IF ( CONFIG_FLAGS%FRACTIONAL_SEAICE == 1 ) THEN
- CALL WRF_ERROR_FATAL("NMM cannot use FRACTIONAL_SEAICE = 1")
- ENDIF
- if ( config_flags%bl_pbl_physics == BOULACSCHEME ) then
- call wrf_error_fatal("Cannot use BOULAC PBL with NMM")
- endif
- write(message,*) 'cen_lat: ', config_flags%cen_lat
- CALL wrf_debug(100,message)
- write(message,*) 'cen_lon: ', config_flags%cen_lon
- CALL wrf_debug(100,message)
- write(message,*) 'dx: ', config_flags%dx
- CALL wrf_debug(100,message)
- write(message,*) 'dy: ', config_flags%dy
- CALL wrf_debug(100,message)
- write(message,*) 'config_flags%start_year: ', config_flags%start_year
- CALL wrf_debug(100,message)
- write(message,*) 'config_flags%start_month: ', config_flags%start_month
- CALL wrf_debug(100,message)
- write(message,*) 'config_flags%start_day: ', config_flags%start_day
- CALL wrf_debug(100,message)
- write(message,*) 'config_flags%start_hour: ', config_flags%start_hour
- CALL wrf_debug(100,message)
- write(start_date,435) config_flags%start_year, config_flags%start_month, &
- config_flags%start_day, config_flags%start_hour
- 435 format(I4,'-',I2.2,'-',I2.2,'_',I2.2,':00:00')
- grid%dlmd=config_flags%dx
- grid%dphd=config_flags%dy
- tph0d=config_flags%cen_lat
- tlm0d=config_flags%cen_lon
- !==========================================================================
- !!
- ! Check to see if the boundary conditions are set
- ! properly in the namelist file.
- ! This checks for sufficiency and redundancy.
- CALL boundary_condition_check( config_flags, bdyzone, error, grid%id )
- ! Some sort of "this is the first time" initialization. Who knows.
- grid%itimestep=0
- ! Pull in the info in the namelist to compare it to the input data.
- grid%real_data_init_type = model_config_rec%real_data_init_type
- write(message,*) 'what is flag_metgrid: ', flag_metgrid
- CALL wrf_message(message)
- IF ( flag_metgrid .EQ. 1 ) THEN ! <----- START OF VERTICAL INTERPOLATION PART ---->
- num_metgrid_levels = grid%num_metgrid_levels
- IF (grid%ght_gc(its,jts,num_metgrid_levels/2) .lt. grid%ght_gc(its,jts,num_metgrid_levels/2+1)) THEN
- write(message,*) 'normal ground up file order'
- hyb_coor=.false.
- CALL wrf_message(message)
- ELSE
- hyb_coor=.true.
- write(message,*) 'reverse the order of coordinate'
- CALL wrf_message(message)
- CALL reverse_vert_coord(grid%ght_gc, 2, num_metgrid_levels &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE )
- #if defined(HWRF)
- if(.not. grid%use_prep_hybrid) then
- #endif
- CALL reverse_vert_coord(grid%p_gc, 2, num_metgrid_levels &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE )
- CALL reverse_vert_coord(grid%t_gc, 2, num_metgrid_levels &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE )
- CALL reverse_vert_coord(grid%u_gc, 2, num_metgrid_levels &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE )
- CALL reverse_vert_coord(grid%v_gc, 2, num_metgrid_levels &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE )
- CALL reverse_vert_coord(grid%rh_gc, 2, num_metgrid_levels &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE )
- #if defined(HWRF)
- endif
- #endif
- endif
- IF (hyb_coor) THEN
- ! limit extreme deviations from source model topography
- ! due to potential for nasty extrapolation/interpolation issues
- !
- write(message,*) 'min, max of grid%ht_gc before adjust: ', minval(grid%ht_gc), maxval(grid%ht_gc)
- CALL wrf_debug(100,message)
- ICOUNT=0
- DO J=JTS,min(JTE,JDE-1)
- DO I=ITS,min(ITE,IDE-1)
- IF ((grid%ht_gc(I,J) - grid%ght_gc(I,J,2)) .LT. -150.) THEN
- grid%ht_gc(I,J)=grid%ght_gc(I,J,2)-150.
- IF (ICOUNT .LT. 20) THEN
- write(message,*) 'increasing NMM topo toward RUC ', I,J
- CALL wrf_debug(100,message)
- ICOUNT=ICOUNT+1
- ENDIF
- ELSEIF ((grid%ht_gc(I,J) - grid%ght_gc(I,J,2)) .GT. 150.) THEN
- grid%ht_gc(I,J)=grid%ght_gc(I,J,2)+150.
- IF (ICOUNT .LT. 20) THEN
- write(message,*) 'decreasing NMM topo toward RUC ', I,J
- CALL wrf_debug(100,message)
- ICOUNT=ICOUNT+1
- ENDIF
- ENDIF
- END DO
- END DO
- write(message,*) 'min, max of ht_gc after correct: ', minval(grid%ht_gc), maxval(grid%ht_gc)
- CALL wrf_debug(100,message)
- ENDIF
- CALL boundary_smooth(grid%ht_gc,grid%landmask, grid, 12 , 12 &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE )
- DO j = jts, MIN(jte,jde-1)
- DO i = its, MIN(ite,ide-1)
- if (grid%landmask(I,J) .gt. 0.5) grid%sm(I,J)=0.
- if (grid%landmask(I,J) .le. 0.5) grid%sm(I,J)=1.
- if (grid%tsk_gc(I,J) .gt. 0.) then
- grid%nmm_tsk(I,J)=grid%tsk_gc(I,J)
- else
- #if defined(HWRF)
- if(grid%use_prep_hybrid) then
- if(grid%t(I,J,1)<100) then
- write(*,*) 'NO VALID SURFACE TEMPERATURE: I,J,TSK_GC(I,J),T(I,J,1) = ', &
- I,J,grid%TSK_GC(I,J),grid%T(I,J,1)
- else
- grid%nmm_tsk(I,J)=grid%t(I,J,1) ! stopgap measure
- end if
- else
- #endif
- grid%nmm_tsk(I,J)=grid%t_gc(I,J,1) ! stopgap measure
- #if defined(HWRF)
- endif
- #endif
- endif
- !
- grid%glat(I,J)=grid%hlat_gc(I,J)*DEGRAD
- grid%glon(I,J)=grid%hlon_gc(I,J)*DEGRAD
- grid%weasd(I,J)=grid%snow(I,J)
- grid%xice(I,J)=grid%xice_gc(I,J)
- ENDDO
- ENDDO
- ! First item is to define the target vertical coordinate
- num_metgrid_levels = grid%num_metgrid_levels
- eta_levels(1:kde) = model_config_rec%eta_levels(1:kde)
- ptsgm = model_config_rec%ptsgm
- p_top_requested = grid%p_top_requested
- grid%pt=p_top_requested
- if (internal_time_loop .eq. 1) then
- if (eta_levels(1) .ne. 1.0) then
- #if defined(HWRF)
- if(grid%use_prep_hybrid) then
- call wrf_error_fatal('PREP_HYBRID ERROR: eta_levels is not specified, but use_prep_hybrid=.true.')
- end if
- #endif
- write(message,*) '********************************************************************* '
- CALL wrf_message(message)
- write(message,*) '** eta_levels appears not to be specified in the namelist'
- CALL wrf_message(message)
- write(message,*) '** We will call compute_nmm_levels to define layer thicknesses.'
- CALL wrf_message(message)
- write(message,*) '** These levels should be reasonable for running the model, '
- CALL wrf_message(message)
- write(message,*) '** but may not be ideal for the simulation being made. Consider '
- CALL wrf_message(message)
- write(message,*) '** defining your own levels by specifying eta_levels in the model '
- CALL wrf_message(message)
- write(message,*) '** namelist. '
- CALL wrf_message(message)
- write(message,*) '********************************************************************** '
- CALL wrf_message(message)
- CALL compute_nmm_levels(KDE,p_top_requested,eta_levels)
- DO L=1,KDE
- write(message,*) 'L, eta_levels(L) returned :: ', L,eta_levels(L)
- CALL wrf_message(message)
- ENDDO
- endif
- write(message,*) 'KDE-1: ', KDE-1
- CALL wrf_debug(1,message)
- allocate(SG1(1:KDE-1))
- allocate(SG2(1:KDE-1))
- allocate(DSG1(1:KDE-1))
- allocate(DSG2(1:KDE-1))
- allocate(SGML1(1:KDE))
- allocate(SGML2(1:KDE))
- CALL define_nmm_vertical_coord (kde-1, ptsgm, grid%pt,grid%pdtop, eta_levels, &
- grid%eta1,grid%deta1,grid%aeta1, &
- grid%eta2,grid%deta2,grid%aeta2, grid%dfl, grid%dfrlg )
- DO L=KDS,KDE-1
- grid%deta(L)=eta_levels(L)-eta_levels(L+1)
- ENDDO
- endif
- write(message,*) 'num_metgrid_levels: ', num_metgrid_levels
- CALL wrf_message(message)
- DO j = jts, MIN(jte,jde-1)
- DO i = its, MIN(ite,ide-1)
- grid%fis(I,J)=grid%ht_gc(I,J)*g
- !
- ! IF ( grid%p_gc(I,J,1) .ne. 200100. .AND. (grid%ht_gc(I,J) .eq. grid%ght_gc(I,J,1)) .AND. grid%ht_gc(I,J) .ne. 0) THEN
- IF ( grid%p_gc(I,J,1) .ne. 200100. .AND. (abs(grid%ht_gc(I,J)-grid%ght_gc(I,J,1)) .lt. 0.01) .AND. grid%ht_gc(I,J) .ne. 0) THEN
- IF (mod(I,10) .eq. 0 .and. mod(J,10) .eq. 0) THEN
- write(message,*) 'grid%ht_gc and grid%toposoil to swap, flag_soilhgt ::: ', &
- I,J, grid%ht_gc(I,J),grid%toposoil(I,J),flag_soilhgt
- CALL wrf_debug(10,message)
- ENDIF
- IF ( ( flag_soilhgt.EQ. 1 ) ) THEN
- grid%ght_gc(I,J,1)=grid%toposoil(I,J)
- ENDIF
- ENDIF
- ENDDO
- ENDDO
- numzero=0
- numexamined=0
- DO j = jts, MIN(jte,jde-1)
- DO i = its, MIN(ite,ide-1)
- numexamined=numexamined+1
- if(grid%fis(i,j)<1e-5 .and. grid%fis(i,j)>-1e5 ) then
- numzero=numzero+1
- end if
- enddo
- enddo
- write(message,*) 'TOTAL NEAR-ZERO FIS POINTS: ',numzero,' OF ',numexamined
- call wrf_debug(10,message)
- #if defined(HWRF)
- interp_notph: if(.not. grid%use_prep_hybrid) then
- #endif
- if (.NOT. allocated(PDVP)) allocate(PDVP(IMS:IME,JMS:JME))
- if (.NOT. allocated(P3D_OUT)) allocate(P3D_OUT(IMS:IME,JMS:JME,KDS:KDE-1))
- if (.NOT. allocated(PSFC_OUTV)) allocate(PSFC_OUTV(IMS:IME,JMS:JME))
- if (.NOT. allocated(P3DV_OUT)) allocate(P3DV_OUT(IMS:IME,JMS:JME,KDS:KDE-1))
- if (.NOT. allocated(P3DV_IN)) allocate(P3DV_IN(IMS:IME,JMS:JME,num_metgrid_levels))
- CALL compute_nmm_surfacep (grid%ht_gc, grid%ght_gc, grid%p_gc , grid%t_gc &
- &, grid%psfc_out, num_metgrid_levels &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE ) ! H points
- if (internal_time_loop .eq. 1) then
- write(message,*) 'psfc points (final combined)'
- loopinc=max( (JTE-JTS)/20,1)
- iloopinc=max( (ITE-ITS)/10,1)
- CALL wrf_message(message)
- DO J=min(JTE,JDE-1),JTS,-loopinc
- write(message,633) (grid%psfc_out(I,J)/100.,I=its,min(ite,IDE-1),iloopinc)
- CALL wrf_message(message)
- ENDDO
-
- endif
- 633 format(35(f5.0,1x))
- CALL compute_3d_pressure (grid%psfc_out,grid%aeta1,grid%aeta2 &
- &, grid%pdtop,grid%pt,grid%pd,p3d_out &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE )
- #ifdef DM_PARALLEL
- ips=its ; ipe=ite ; jps=jts ; jpe=jte ; kps=kts ; kpe=kte
- # include "HALO_NMM_MG2.inc"
- #endif
- #ifdef DM_PARALLEL
- # include "HALO_NMM_MG3.inc"
- #endif
- do K=1,num_metgrid_levels
- do J=JTS,min(JTE,JDE-1)
- do I=ITS,min(ITE,IDE-1)
- IF (K .eq. KTS) THEN
- IF (J .eq. JDS .and. I .lt. IDE-1) THEN ! S boundary
- PDVP(I,J)=0.5*(grid%pd(I,J)+grid%pd(I+1,J))
- PSFC_OUTV(I,J)=0.5*(grid%psfc_out(I,J)+grid%psfc_out(I+1,J))
- ELSEIF (J .eq. JDE-1 .and. I .lt. IDE-1) THEN ! N boundary
- PDVP(I,J)=0.5*(grid%pd(I,J)+grid%pd(I+1,J))
- PSFC_OUTV(I,J)=0.5*(grid%psfc_out(I,J)+grid%psfc_out(I+1,J))
- ELSEIF (I .eq. IDS .and. mod(J,2) .eq. 0) THEN ! W boundary
- PDVP(I,J)=0.5*(grid%pd(I,J-1)+grid%pd(I,J+1))
- PSFC_OUTV(I,J)=0.5*(grid%psfc_out(I,J-1)+grid%psfc_out(I,J+1))
- ELSEIF (I .eq. IDE-1 .and. mod(J,2) .eq. 0) THEN ! E boundary
- PDVP(I,J)=0.5*(grid%pd(I,J-1)+grid%pd(I,J+1))
- PSFC_OUTV(I,J)=0.5*(grid%psfc_out(I,J-1)+grid%psfc_out(I,J+1))
- ELSEIF (I .eq. IDE-1 .and. mod(J,2) .eq. 1) THEN ! phantom E boundary
- PDVP(I,J)=grid%pd(I,J)
- PSFC_OUTV(I,J)=grid%psfc_out(I,J)
- ELSEIF (mod(J,2) .eq. 0) THEN ! interior even row
- PDVP(I,J)=0.25*(grid%pd(I,J)+grid%pd(I-1,J)+grid%pd(I,J+1)+grid%pd(I,J-1))
- PSFC_OUTV(I,J)=0.25*(grid%psfc_out(I,J)+grid%psfc_out(I-1,J)+ &
- grid%psfc_out(I,J+1)+grid%psfc_out(I,J-1))
- ELSE ! interior odd row
- PDVP(I,J)=0.25*(grid%pd(I,J)+grid%pd(I+1,J)+grid%pd(I,J+1)+grid%pd(I,J-1))
- PSFC_OUTV(I,J)=0.25*(grid%psfc_out(I,J)+grid%psfc_out(I+1,J)+ &
- grid%psfc_out(I,J+1)+grid%psfc_out(I,J-1))
- ENDIF
- ENDIF
- IF (J .eq. JDS .and. I .lt. IDE-1) THEN ! S boundary
- P3DV_IN(I,J,K)=0.5*(grid%p_gc(I,J,K)+grid%p_gc(I+1,J,K))
- ELSEIF (J .eq. JDE-1 .and. I .lt. IDE-1) THEN ! N boundary
- P3DV_IN(I,J,K)=0.5*(grid%p_gc(I,J,K)+grid%p_gc(I+1,J,K))
- ELSEIF (I .eq. IDS .and. mod(J,2) .eq. 0) THEN ! W boundary
- P3DV_IN(I,J,K)=0.5*(grid%p_gc(I,J-1,K)+grid%p_gc(I,J+1,K))
- ELSEIF (I .eq. IDE-1 .and. mod(J,2) .eq. 0) THEN ! E boundary
- P3DV_IN(I,J,K)=0.5*(grid%p_gc(I,J-1,K)+grid%p_gc(I,J+1,K))
- ELSEIF (I .eq. IDE-1 .and. mod(J,2) .eq. 1) THEN ! phantom E boundary
- P3DV_IN(I,J,K)=grid%p_gc(I,J,K)
- ELSEIF (mod(J,2) .eq. 0) THEN ! interior even row
- P3DV_IN(I,J,K)=0.25*(grid%p_gc(I,J,K)+grid%p_gc(I-1,J,K) + &
- grid%p_gc(I,J+1,K)+grid%p_gc(I,J-1,K))
- ELSE ! interior odd row
- P3DV_IN(I,J,K)=0.25*(grid%p_gc(I,J,K)+grid%p_gc(I+1,J,K) + &
- grid%p_gc(I,J+1,K)+grid%p_gc(I,J-1,K))
- ENDIF
- enddo
- enddo
- enddo
- CALL compute_3d_pressure (psfc_outv,grid%aeta1,grid%aeta2 &
- &, grid%pdtop,grid%pt,pdvp,p3dv_out &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE )
- CALL interp_press2press_lin(grid%p_gc, p3d_out &
- &, grid%t_gc, grid%t,num_metgrid_levels &
- &, .TRUE.,.TRUE.,.TRUE. & ! extrap, ignore_lowest, t_field
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE, internal_time_loop )
- CALL interp_press2press_lin(p3dv_in, p3dv_out &
- &, grid%u_gc, grid%u,num_metgrid_levels &
- &, .FALSE.,.TRUE.,.FALSE. &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE, internal_time_loop )
- CALL interp_press2press_lin(p3dv_in, p3dv_out &
- &, grid%v_gc, grid%v,num_metgrid_levels &
- &, .FALSE.,.TRUE.,.FALSE. &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE, internal_time_loop )
- IF (hyb_coor) THEN
- CALL wind_adjust(p3dv_in,p3dv_out,grid%u_gc,grid%v_gc,grid%u,grid%v &
- &, num_metgrid_levels,5000. &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE )
- ENDIF
- ALLOCATE(qtmp(IMS:IME,JMS:JME,num_metgrid_levels))
- ALLOCATE(qtmp2(IMS:IME,JMS:JME,num_metgrid_levels))
- CALL rh_to_mxrat (grid%rh_gc, grid%t_gc, grid%p_gc, qtmp , .TRUE. , &
- ids , ide , jds , jde , 1 , num_metgrid_levels , &
- ims , ime , jms , jme , 1 , num_metgrid_levels , &
- its , ite , jts , jte , 1 , num_metgrid_levels )
- do K=1,num_metgrid_levels
- do J=JTS,min(JTE,JDE-1)
- do I=ITS,min(ITE,IDE-1)
- QTMP2(I,J,K)=QTMP(I,J,K)/(1.0+QTMP(I,J,K))
- end do
- end do
- end do
- CALL interp_press2press_log(grid%p_gc, p3d_out &
- &, QTMP2, grid%q,num_metgrid_levels &
- &, .FALSE.,.TRUE. &
- &, IDS,IDE,JDS,JDE,KDS,KDE &
- &, IMS,IME,JMS,JME,KMS,KME &
- &, ITS,ITE,JTS,JTE,KTS,KTE, internal_time_loop )
- IF (ALLOCATED(QTMP)) DEALLOCATE(QTMP)
- IF (ALLOCATED(QTMP)) DEALLOCATE(QTMP2)
- #if defined(HWRF)
- else ! we are using prep_hybrid
- ! Compute surface pressure:
- grid%psfc_out=grid%pdtop+grid%pd
- end if interp_notph
- #endif
- ! Get the monthly values interpolated to the current date
- ! for the traditional monthly
- ! fields of green-ness fraction and background grid%albedo.
- if (internal_time_loop .eq. 1 .or. config_flags%sst_update .eq. 1) then
- CALL monthly_interp_to_date ( grid%greenfrac_gc , current_date , grid%vegfra , &
- ids , ide , jds , jde , kds , kde , &
- ims , ime , jms , jme , kms , kme , &
- its , ite , jts , jte , kts , kte )
- CALL monthly_interp_to_date ( grid%albedo12m_gc , current_date , grid%albbck , &
- ids , ide , jds , jde , kds , kde , &
- ims , ime , jms , jme , kms , kme , &
- its , ite , jts , jte , kts , kte )
- ! Get the min/max of each i,j for the monthly green-ness fraction.
- CALL monthly_min_max ( grid%greenfrac_gc , grid%shdmin , grid%shdmax , &
- ids , ide , jds , jde , kds , kde , &
- ims , ime , jms , jme , kms , kme , &
- its , ite , jts , jte , kts , kte )
- ! The model expects the green-ness values in percent, not fraction.
- DO j = jts, MIN(jte,jde-1)
- DO i = its, MIN(ite,ide-1)
- !! grid%vegfra(i,j) = grid%vegfra(i,j) * 100.
- grid%shdmax(i,j) = grid%shdmax(i,j) * 100.
- grid%shdmin(i,j) = grid%shdmin(i,j) * 100.
- grid%vegfrc(I,J)=grid%vegfra(I,J)
- END DO
- END DO
- ! The model expects the albedo fields as
- ! a fraction, not a percent. Set the water values to 8%.
- DO j = jts, MIN(jte,jde-1)
- DO i = its, MIN(ite,ide-1)
- if (grid%albbck(i,j) .lt. 5.) then
- write(message,*) 'reset albedo to 8%... I,J,albbck:: ', I,J,grid%albbck(I,J)
- CALL wrf_debug(10,message)
- grid%albbck(I,J)=8.
- endif
- grid%albbck(i,j) = grid%albbck(i,j) / 100.
- grid%snoalb(i,j) = grid%snoalb(i,j) / 100.
- IF ( grid%landmask(i,j) .LT. 0.5 ) THEN
- grid%albbck(i,j) = 0.08
- grid%snoalb(i,j) = 0.08
- END IF
- grid%albase(i,j)=grid%albbck(i,j)
- grid%mxsnal(i,j)=grid%snoalb(i,j)
- END DO
- END DO
- endif
- #if defined(HWRF)
- if(.not.grid%use_prep_hybrid) then
- #endif
- ! new deallocs
- DEALLOCATE(p3d_out,p3dv_out,p3dv_in)
- #if defined(HWRF)
- end if
- #endif
- END IF ! <----- END OF VERTICAL INTERPOLATION PART ---->
- !! compute SST at each time if updating SST
- if (config_flags%sst_update == 1) then
- DO j = jts, MIN(jde-1,jte)
- DO i = its, MIN(ide-1,ite)
- if (grid%SM(I,J) .lt. 0.5) then
- grid%SST(I,J)=0.
- endif
- if (grid%SM(I,J) .gt. 0.5) then
- grid%SST(I,J)=grid%NMM_TSK(I,J)
- grid%NMM_TSK(I,J)=0.
- endif
- IF ( (grid%NMM_TSK(I,J)+grid%SST(I,J)) .lt. 200. .or. &
- (grid%NMM_TSK(I,J)+grid%SST(I,J)) .gt. 350. ) THEN
- write(message,*) 'TSK, SST trouble at : ', I,J
- CALL wrf_message(message)
- write(message,*) 'SM, NMM_TSK,SST ', grid%SM(I,J),grid%NMM_TSK(I,J),grid%SST(I,J)
- CALL wrf_message(message)
- ENDIF
- ENDDO
- ENDDO
- endif ! sst_update test
- if (internal_time_loop .eq. 1) then
- !!! weasd has "snow water equivalent" in mm
- DO j = jts, MIN(jte,jde-1)
- DO i = its, MIN(ite,ide-1)
- IF(grid%sm(I,J).GT.0.9) THEN
- IF (grid%xice(I,J) .gt. 0) then
- grid%si(I,J)=1.0
- ENDIF
- ! SEA
- grid%epsr(I,J)=.97
- grid%embck(I,J)=.97
- grid%gffc(I,J)=0.
- grid%albedo(I,J)=.06
- grid%albase(I,J)=.06
- IF(grid%si (I,J).GT.0. ) THEN
- ! SEA-ICE
- grid%sm(I,J)=0.
- grid%si(I,J)=0.
- grid%sice(I,J)=1.
- grid%gffc(I,J)=0. ! just leave zero as irrelevant
- grid%albedo(I,J)=.60
- grid%albase(I,J)=.60
- ENDIF
- ELSE
- grid%si(I,J)=5.0*grid%weasd(I,J)/1000.
- ! LAND
- grid%epsr(I,J)=1.0
- grid%embck(I,J)=1.0
- grid%gffc(I,J)=0.0 ! just leave zero as irrelevant
- grid%sice(I,J)=0.
- grid%sno(I,J)=grid%si(I,J)*.20
- ENDIF
- ENDDO
- ENDDO
- ! DETERMINE grid%albedo OVER LAND
- DO j = jts, MIN(jte,jde-1)
- DO i = its, MIN(ite,ide-1)
- IF(grid%sm(I,J).LT.0.9.AND.grid%sice(I,J).LT.0.9) THEN
- ! SNOWFREE albedo
- IF ( (grid%sno(I,J) .EQ. 0.0) .OR. &
- (grid%albase(I,J) .GE. grid%mxsnal(I,J) ) ) THEN
- grid%albedo(I,J) = grid%albase(I,J)
- ELSE
- ! MODIFY albedo IF SNOWCOVER:
- ! BELOW SNOWDEPTH THRESHOLD...
- IF (grid%sno(I,J) .LT. SNUP) THEN
- RSNOW = grid%sno(I,J)/SNUP
- SNOFAC = 1. - ( EXP(-SALP*RSNOW) - RSNOW*EXP(-SALP))
- ! ABOVE SNOWDEPTH THRESHOLD...
- ELSE
- SNOFAC = 1.0
- ENDIF
- ! CALCULATE grid%albedo ACCOUNTING FOR SNOWDEPTH AND VGFRCK
- grid%albedo(I,J) = grid%albase(I,J) &
- + (1.0-grid%vegfra(I,J))*SNOFAC*(grid%mxsnal(I,J)-grid%albase(I,J))
- ENDIF
- END IF
- grid%si(I,J)=5.0*grid%weasd(I,J)
- grid%sno(I,J)=grid%weasd(I,J)
- !! convert vegfra
- grid%vegfra(I,J)=grid%vegfra(I,J)*100.
- !
- ENDDO
- ENDDO
- #ifdef DM_PARALLEL
- ALLOCATE(SM_G(IDS:IDE,JDS:JDE),SICE_G(IDS:IDE,JDS:JDE))
- CALL WRF_PATCH_TO_GLOBAL_REAL( grid%sice(IMS,JMS) &
- &, SICE_G,grid%DOMDESC &
- &, 'z','xy' &
- &, IDS,IDE-1,JDS,JDE-1,1,1 &
- &, IMS,IME,JMS,JME,1,1 &
- &, ITS,ITE,JTS,JTE,1,1 )
- CALL WRF_PATCH_TO_GLOBAL_REAL( grid%sm(IMS,JMS) &
- &, SM_G,grid%DOMDESC &
- &, 'z','xy' &
- &, IDS,IDE-1,JDS,JDE-1,1,1 &
- &, IMS,IME,JMS,JME,1,1 &
- &, ITS,ITE,JTS,JTE,1,1 )
- IF (WRF_DM_ON_MONITOR()) THEN
- 637 format(40(f3.0,1x))
- allocate(IHE_G(JDS:JDE-1),IHW_G(JDS:JDE-1))
- DO j = JDS, JDE-1
- IHE_G(J)=MOD(J+1,2)
- IHW_G(J)=IHE_G(J)-1
- ENDDO
- DO ITER=1,10
- DO j = jds+1, (jde-1)-1
- DO i = ids+1, (ide-1)-1
- ! any sea ice around point in question?
- IF (SM_G(I,J) .ge. 0.9) THEN
- SEAICESUM=SICE_G(I+IHE_G(J),J+1)+SICE_G(I+IHW_G(J),J+1)+ &
- SICE_G(I+IHE_G(J),J-1)+SICE_G(I+IHW_G(J),J-1)
- IF (SEAICESUM .ge. 1. .and. SEAICESUM .lt. 3.) THEN
- IF ((SICE_G(I+IHE_G(J),J+1).lt.0.1 .and. SM_G(I+IHE_G(J),J+1).lt.0.1) .OR. &
- (SICE_G(I+IHW_G(J),J+1).lt.0.1 .and. SM_G(I+IHW_G(J),J+1).lt.0.1) .OR. &
- (SICE_G(I+IHE_G(J),J-1).lt.0.1 .and. SM_G(I+IHE_G(J),J-1).lt.0.1) .OR. &
- (SICE_G(I+IHW_G(J),J-1).lt.0.1 .and. SM_G(I+IHW_G(J),J-1).lt.0.1)) THEN
- ! HAVE SEA ICE AND A SURROUNDING LAND POINT - CONVERT TO SEA ICE
- write(message,*) 'making seaice (1): ', I,J
- CALL wrf_debug(100,message)
- SICE_G(I,J)=1.0
- SM_G(I,J)=0.
- ENDIF
- ELSEIF (SEAICESUM .ge. 3) THEN
- ! WATER POINT SURROUNDED BY ICE - CONVERT TO SEA ICE
- write(message,*) 'making seaice (2): ', I,J
- CALL wrf_debug(100,message)
- SICE_G(I,J)=1.0
- SM_G(I,J)=0.
- ENDIF
- ENDIF
- ENDDO
- ENDDO
- ENDDO
- ENDIF
- CALL WRF_GLOBAL_TO_PATCH_REAL( SICE_G, grid%sice &
- &, grid%DOMDESC &
- &, 'z','xy' &
- &, IDS,IDE-1,JDS,JDE-1,1,1 &
- &, IMS,IME,JMS,JME,1,1 &
- &, ITS,ITE,JTS,JTE,1,1 )
- CALL WRF_GLOBAL_TO_PATCH_REAL( SM_G,grid%sm &
- &, grid%DOMDESC &
- &, 'z','xy' &
- &, IDS,IDE-1,JDS,JDE-1,1,1 &
- &, IMS,IME,JMS,JME,1,1 &
- &, ITS,ITE,JTS,JTE,1,1 )
- IF (WRF_DM_ON_MONITOR()) THEN
- #if defined(HWRF)
- ! SM_G is still needed for the high-res grid
- #else
- DEALLOCATE(SM_G)
- #endif
- deallocate(SICE_G)
- DEALLOCATE(IHE_G,IHW_G)
- ENDIF
- ! write(message,*) 'revised sea ice on patch'
- ! CALL wrf_debug(100,message)
- ! DO J=JTE,JTS,-(((JTE-JTS)/25)+1)
- ! write(message,637) (grid%sice(I,J),I=ITS,ITE,ITE/20)
- ! CALL wrf_debug(100,message)
- ! END DO
- #else
- ! serial sea ice reprocessing
- allocate(IHE(JDS:JDE-1),IHW(JDS:JDE-1))
- DO j = jts, MIN(jte,jde-1)
- IHE(J)=MOD(J+1,2)
- IHW(J)=IHE(J)-1
- ENDDO
- DO ITER=1,10
- DO j = jts+1, MIN(jte,jde-1)-1
- DO i = its+1, MIN(ite,ide-1)-1
- ! any sea ice around point in question?
- IF (grid%sm(I,J) .gt. 0.9) THEN
- SEAICESUM=grid%sice(I+IHE(J),J+1)+grid%sice(I+IHW(J),J+1)+ &
- grid%sice(I+IHE(J),J-1)+grid%sice(I+IHW(J),J-1)
- IF (SEAICESUM .ge. 1. .and. SEAICESUM .lt. 3.) THEN
- IF ((grid%sice(I+IHE(J),J+1).lt.0.1 .and. grid%sm(I+IHE(J),J+1).lt.0.1) .OR. &
- (grid%sice(I+IHW(J),J+1).lt.0.1 .and. grid%sm(I+IHW(J),J+1).lt.0.1) .OR. &
- (grid%sice(I+IHE(J),J-1).lt.0.1 .and. grid%sm(I+IHE(J),J-1).lt.0.1) .OR. &
- (grid%sice(I+IHW(J),J-1).lt.0.1 .and. grid%sm(I+IHW(J),J-1).lt.0.1)) THEN
- ! HAVE SEA ICE AND A SURROUNDING LAND POINT - CONVERT TO SEA ICE
- grid%sice(I,J)=1.0
- grid%sm(I,J)=0.
- ENDIF
- ELSEIF (SEAICESUM .ge. 3) THEN
- ! WATER POINT SURROUNDED BY ICE - CONVERT TO SEA ICE
- grid%sice(I,J)=1.0
- grid%sm(I,J)=0.
- ENDIF
- ENDIF
- ENDDO
- ENDDO
- ENDDO
- DEALLOCATE(IHE,IHW)
- #endif
- ! this block meant to guarantee land/sea agreement between sm and landmask
- DO j = jts, MIN(jte,jde-1)
- DO i = its, MIN(ite,ide-1)
- IF (grid%sm(I,J) .gt. 0.5) THEN
- grid%landmask(I,J)=0.0
- ELSEIF (grid%sm(I,J) .lt. 0.5 .and. grid%sice(I,J) .gt. 0.9) then
- grid%landmask(I,J)=0.0
- ELSEIF (grid%sm(I,J) .lt. 0.5 .and. grid%sice(I,J) .lt. 0.1) then
- grid%landmask(I,J)=1.0
- ELSE
- write(message,*) 'missed point in grid%landmask definition ' , I,J
- CALL wrf_message(message)
- grid%landmask(I,J)=0.0
- ENDIF
- !
- IF (grid%sice(I,J) .gt. 0.5 .and. grid%nmm_tsk(I,J) .lt. 0.1 .and. grid%sst(I,J) .gt. 0.) THEN
- write(message,*) 'set grid%nmm_tsk to: ', grid%sst(I,J)
- CALL wrf_message(message)
- grid%nmm_tsk(I,J)=grid%sst(I,J)
- grid%sst(I,J)=0.
- endif
- ENDDO
- ENDDO
- ! For sf_surface_physics = 1, we want to use close to a 10 cm value
- ! for the bottom level of the soil temps.
- IF ( ( model_config_rec%sf_surface_physics(grid%id) .EQ. 1 ) .AND. &
- ( flag_st000010 .EQ. 1 ) ) THEN
- DO j = jts , MIN(jde-1,jte)
- DO i = its , MIN(ide-1,ite)
- grid%soiltb(i,j) = grid%st000010(i,j)
- END DO
- END DO
- END IF
- ! Adjust the various soil temperature values depending on the difference in
- ! in elevation between the current model's elevation and the incoming data's
- ! orography.
- IF ( ( flag_toposoil .EQ. 1 ) ) THEN
- ALLOCATE(HT(ims:ime,jms:jme))
- DO J=jms,jme
- DO I=ims,ime
- HT(I,J)=grid%fis(I,J)/9.81
- END DO
- END DO
- ! if (maxval(grid%toposoil) .gt. 100.) then
- !
- ! Being avoided. Something to revisit eventually.
- !
- !1219 might be simply a matter of including toposoil
- !
- ! CODE NOT TESTED AT NCEP USING THIS FUNCTIONALITY,
- ! SO TO BE SAFE WILL AVOID FOR RETRO RUNS.
- !
- ! CALL adjust_soil_temp_new ( grid%soiltb , 2 , &
- ! grid%nmm_tsk , ht , grid%toposoil , grid%landmask, flag_toposoil , &
- ! grid%st000010 , st010040 , st040100 , st100200 , st010200 , &
- ! flag_st000010 , flag_st010040 , flag_st040100 , &
- ! flag_st100200 , flag_st010200 , &
- ! soilt000 , soilt005 , soilt020 , soilt040 , &
- ! soilt160 , soilt300 , &
- ! flag_soilt000 , flag_soilt005 , flag_soilt020 , &
- ! flag_soilt040 , flag_soilt160 , flag_soilt300 , &
- ! ids , ide , jds , jde , kds , kde , &
- ! ims , ime , jms , jme , kms , kme , &
- ! its , ite , jts , jte , kts , kte )
- ! endif
- END IF
- ! Process the LSM data.
- ! surface_input_source=1 => use data from static file
- ! (fractional category as input)
- ! surface_input_source=2 => use data from grib file
- ! (dominant category as input)
- IF ( config_flags%surface_input_source .EQ. 1 ) THEN
- grid%vegcat (its,jts) = 0
- grid%soilcat(its,jts) = 0
- END IF
- ! Generate the vegetation and soil category information
- ! from the fractional input
- ! data, or use the existing dominant category fields if they exist.
- IF ((grid%soilcat(its,jts) .LT. 0.5) .AND. (grid%vegcat(its,jts) .LT. 0.5)) THEN
- num_veg_cat = SIZE ( grid%landusef_gc , DIM=3 )
- num_soil_top_cat = SIZE ( grid%soilctop_gc , DIM=3 )
- num_soil_bot_cat = SIZE ( grid%soilcbot_gc , DIM=3 )
- do J=JMS,JME
- do K=1,num_veg_cat
- do I=IMS,IME
- grid%landusef(I,K,J)=grid%landusef_gc(I,J,K)
- enddo
- enddo
- enddo
- do J=JMS,JME
- do K=1,num_soil_top_cat
- do I=IMS,IME
- grid%soilctop(I,K,J)=grid%soilctop_gc(I,J,K)
- enddo
- enddo
- enddo
- do J=JMS,JME
- do K=1,num_soil_bot_cat
- do I=IMS,IME
- grid%soilcbot(I,K,J)=grid%soilcbot_gc(I,J,K)
- enddo
- enddo
- enddo
- ! grid%sm (1=water, 0=land)
- ! grid%landmask(0=water, 1=land)
- write(message,*) 'landmask into process_percent_cat_new'
- CALL wrf_debug(1,message)
- do J=JTE,JTS,-(((JTE-JTS)/20)+1)
- write(message,641) (grid%landmask(I,J),I=ITS,min(ITE,IDE-1),((ITE-ITS)/15)+1)
- CALL wrf_debug(1,message)
- enddo
- 641 format(25(f3.0,1x))
- CALL process_percent_cat_new ( grid%landmask , &
- grid%landusef , grid%soilctop , grid%soilcbot , &
- grid%isltyp , grid%ivgtyp , &
- num_veg_cat , num_soil_top_cat , num_soil_bot_cat , &
- ids , ide , jds , jde , kds , kde , &
- ims , ime , jms , jme , kms , kme , &
- its , ite , jts , jte , kts , kte , &
- model_config_rec%iswater(grid%id) )
- DO j = jts , MIN(jde-1,jte)
- DO i = its , MIN(ide-1,ite)
- grid%vegcat(i,j) = grid%ivgtyp(i,j)
- grid%soilcat(i,j) = grid%isltyp(i,j)
- END DO
- END DO
- ELSE
- ! Do we have dominant soil and veg data from the input already?
- IF ( grid%soilcat(its,jts) .GT. 0.5 ) THEN
- DO j = jts, MIN(jde-1,jte)
- DO i = its, MIN(ide-1,ite)
- grid%isltyp(i,j) = NINT( grid%soilcat(i,j) )
- END DO
- END DO
- END IF
- IF ( grid%vegcat(its,jts) .GT. 0.5 ) THEN
- DO j = jts, MIN(jde-1,jte)
- DO i = its, MIN(ide-1,ite)
- grid%ivgtyp(i,j) = NINT( grid%vegcat(i,j) )
- END DO
- END DO
- END IF
- ENDIF
- DO j = jts, MIN(jde-1,jte)
- DO i = its, MIN(ide-1,ite)
- IF (grid%sice(I,J) .lt. 0.1) THEN
- IF (grid%landmask(I,J) .gt. 0.5 .and. grid%sm(I,J) .gt. 0.5) THEN
- write(message,*) 'land mask and grid%sm both > 0.5: ', &
- I,J,grid%landmask(I,J),grid%sm(I,J)
- CALL wrf_message(message)
- grid%sm(I,J)=0.
- ELSEIF (grid%landmask(I,J) .lt. 0.5 .and. grid%sm(I,J) .lt. 0.5) THEN
- write(message,*) 'land mask and grid%sm both < 0.5: ', &
- I,J, grid%landmask(I,J),grid%sm(I,J)
- CALL wrf_message(message)
- grid%sm(I,J)=1.
- ENDIF
- ELSE
- IF (grid%landmask(I,J) .gt. 0.5 .and. grid%sm(I,J)+grid%sice(I,J) .gt. 0.9) then
- write(message,*) 'landmask says LAND, sm/sice say SEAICE: ', I,J
- ENDIF
- ENDIF
- ENDDO
- ENDDO
- DO j = jts, MIN(jde-1,jte)
- DO i = its, MIN(ide-1,ite)
- if (grid%sice(I,J) .gt. 0.9) then
- grid%isltyp(I,J)=16
- grid%ivgtyp(I,J)=24
- endif
- ENDDO
- ENDDO
- DO j = jts, MIN(jde-1,jte)
- DO i = its, MIN(ide-1,ite)
- if (grid%sm(I,J) .lt. 0.5) then
- grid%sst(I,J)=0.
- endif
- if (grid%sm(I,J) .gt. 0.5) then
- if (grid%sst(I,J) .lt. 0.1) then
- grid%sst(I,J)=grid%nmm_tsk(I,J)
- endif
- grid%nmm_tsk(I,J)=0.
- endif
- IF ( (grid%nmm_tsk(I,J)+grid%sst(I,J)) .lt. 200. .or. &
- (grid%nmm_tsk(I,J)+grid%sst(I,J)) .gt. 350. ) THEN
- write(message,*) 'TSK, sst trouble at : ', I,J
- CALL wrf_message(message)
- write(message,*) 'sm, nmm_tsk,sst ', grid%sm(I,J),grid%nmm_tsk(I,J),grid%sst(I,J)
- CALL wrf_message(message)
- ENDIF
- ENDDO
- ENDDO
- write(message,*) 'grid%sm'
- CALL wrf_message(message)
- DO J=min(jde-1,jte),jts,-((jte-jts)/15+1)
- write(message,635) (grid%sm(i,J),I=its,ite,((ite-its)/10)+1)
- CALL wrf_message(message)
- END DO
- write(message,*) 'sst/nmm_tsk'
- CALL wrf_debug(10,message)
- DO J=min(jde-1,jte),jts,-((jte-jts)/15+1)
- write(message,635) (grid%sst(I,J)+grid%nmm_tsk(I,J),I=ITS,min(ide-1,ite),((ite-its)/10)+1)
- CALL wrf_debug(10,message)
- END DO
- 635 format(20(f5.1,1x))
- DO j = jts, MIN(jde-1,jte)
- DO i = its, MIN(ide-1,ite)
- IF ( ( grid%landmask(i,j) .LT. 0.5 ) .AND. ( flag_sst .EQ. 1 ) ) THEN
- grid%soiltb(i,j) = grid%sst(i,j)
- ELSE IF ( grid%landmask(i,j) .GT. 0.5 ) THEN
- grid%soiltb(i,j) = grid%nmm_tsk(i,j)
- END IF
- END DO
- END DO
- ! END IF
- ! Land use categories, dominant soil and vegetation types (if available).
- ! allocate(grid%lu_index(ims:ime,jms:jme))
- DO j = jts, MIN(jde-1,jte)
- DO i = its, MIN(ide-1,ite)
- grid%lu_index(i,j) = grid%ivgtyp(i,j)
- END DO
- END DO
- if (flag_sst .eq. 1) log_flag_sst=.true.
- if (flag_sst .eq. 0) log_flag_sst=.false.
- write(message,*) 'st_input dimensions: ', size(st_input,dim=1), &
- size(st_input,dim=2),size(st_input,dim=3)
- CALL wrf_debug(100,message)
- ! write(message,*) 'maxval st_input(1): ', maxval(st_input(:,1,:))
- ! CALL wrf_message(message)
- ! write(message,*) 'maxval st_input(2): ', maxval(st_input(:,2,:))
- ! CALL wrf_message(message)
- ! write(message,*) 'maxval st_input(3): ', maxval(st_input(:,3,:))
- ! CALL wrf_message(message)
- ! write(message,*) 'maxval st_input(4): ', maxval(st_input(:,4,:))
- ! CALL wrf_message(message)
- ! =============================================================
- IF (.NOT. ALLOCATED(TG_ALT))ALLOCATE(TG_ALT(grid%sm31:grid%em31,jms:jme))
- TPH0=TPH0D*DTR
- WBD=-(((ide-1)-1)*grid%dlmd)
- WB= WBD*DTR
- SBD=-(((jde-1)/2)*grid%dphd)
- SB= SBD*DTR
- DLM=grid%dlmd*DTR
- DPH=grid%dp…
Large files files are truncated, but you can click here to view the full file