Compute Maximum 10 m Winds in WRF Code

Also see example in WRF Software talk
 

  • Make sure you are in the WRFV3 directory.
     
  • Edit the subroutine dyn_em/solve_em.F:

    Near the top

    Look for the following code:

    #ifdef DM_PARALLEL
       USE module_dm, ONLY : &
             local_communicator, mytask, ntasks, ntasks_x, ntasks_y &
            ,local_communicator_periodic, wrf_dm_maxval
       USE module_comm_dm, ONLY : &
            halo_em_a_sub,halo_em_b_sub,halo_em_c2_sub,halo_em_chem_e_3_sub &
            ,halo_em_chem_e_5_sub,halo_em_chem_e_7_sub,halo_em_chem_old_e_5_sub &
            ,halo_em_chem_old_e_7_sub,halo_em_c_sub,halo_em_d2_3_sub &
            ,halo_em_d2_5_sub,halo_em_d3_3_sub,halo_em_d3_5_sub,halo_em_d_sub &
            ,halo_em_e_3_sub,halo_em_e_5_sub,halo_em_hydro_uv_sub &
            ,halo_em_moist_e_3_sub,halo_em_moist_e_5_sub,halo_em_moist_e_7_sub &
            ,halo_em_moist_old_e_5_sub,halo_em_moist_old_e_7_sub &
            ,halo_em_scalar_e_3_sub,halo_em_scalar_e_5_sub,halo_em_scalar_e_7_sub &
            ,halo_em_scalar_old_e_5_sub,halo_em_scalar_old_e_7_sub,halo_em_tke_3_sub &
            ,halo_em_tke_5_sub,halo_em_tke_7_sub,halo_em_tke_advect_3_sub &
            ,halo_em_tke_advect_5_sub,halo_em_tke_old_e_5_sub &
            ,halo_em_tke_old_e_7_sub,halo_em_tracer_e_3_sub,halo_em_tracer_e_5_sub &
            ,halo_em_tracer_e_7_sub,halo_em_tracer_old_e_5_sub &
            ,halo_em_tracer_old_e_7_sub,period_bdy_em_a_sub &
            ,period_bdy_em_b3_sub,period_bdy_em_b_sub,period_bdy_em_chem2_sub &
            ,period_bdy_em_chem_old_sub,period_bdy_em_chem_sub,period_bdy_em_d3_sub &
            ,period_bdy_em_d_sub,period_bdy_em_e_sub,period_bdy_em_moist2_sub &
            ,period_bdy_em_moist_old_sub,period_bdy_em_moist_sub &
            ,period_bdy_em_scalar2_sub,period_bdy_em_scalar_old_sub &
            ,period_bdy_em_scalar_sub,period_bdy_em_tke_old_sub &
            ,period_bdy_em_tracer2_sub,period_bdy_em_tracer_old_sub &
            ,period_bdy_em_tracer_sub,period_em_da_sub,period_em_hydro_uv_sub &
            ,halo_em_f_sub,halo_em_init_4_sub
    #endif

    Add the highlighted bits below:

    #ifdef DM_PARALLEL
       USE module_dm, ONLY : &
             local_communicator, mytask, ntasks, ntasks_x, ntasks_y &
            ,local_communicator_periodic, wrf_dm_maxval, wrf_dm_sum_real, wrf_dm_max_real, wrf_dm_maxval_real
       USE module_comm_dm, ONLY : &
            halo_em_a_sub,halo_em_b_sub,halo_em_c2_sub,halo_em_chem_e_3_sub &
            ,halo_em_chem_e_5_sub,halo_em_chem_e_7_sub,halo_em_chem_old_e_5_sub &
            ,halo_em_chem_old_e_7_sub,halo_em_c_sub,halo_em_d2_3_sub &
            ,halo_em_d2_5_sub,halo_em_d3_3_sub,halo_em_d3_5_sub,halo_em_d_sub &
            ,halo_em_e_3_sub,halo_em_e_5_sub,halo_em_hydro_uv_sub &
            ,halo_em_moist_e_3_sub,halo_em_moist_e_5_sub,halo_em_moist_e_7_sub &
            ,halo_em_moist_old_e_5_sub,halo_em_moist_old_e_7_sub &
            ,halo_em_scalar_e_3_sub,halo_em_scalar_e_5_sub,halo_em_scalar_e_7_sub &
            ,halo_em_scalar_old_e_5_sub,halo_em_scalar_old_e_7_sub,halo_em_tke_3_sub &
            ,halo_em_tke_5_sub,halo_em_tke_7_sub,halo_em_tke_advect_3_sub &
            ,halo_em_tke_advect_5_sub,halo_em_tke_old_e_5_sub &
            ,halo_em_tke_old_e_7_sub,halo_em_tracer_e_3_sub,halo_em_tracer_e_5_sub &
            ,halo_em_tracer_e_7_sub,halo_em_tracer_old_e_5_sub &
            ,halo_em_tracer_old_e_7_sub,period_bdy_em_a_sub &
            ,period_bdy_em_b3_sub,period_bdy_em_b_sub,period_bdy_em_chem2_sub &
            ,period_bdy_em_chem_old_sub,period_bdy_em_chem_sub,period_bdy_em_d3_sub &
            ,period_bdy_em_d_sub,period_bdy_em_e_sub,period_bdy_em_moist2_sub &
            ,period_bdy_em_moist_old_sub,period_bdy_em_moist_sub &
            ,period_bdy_em_scalar2_sub,period_bdy_em_scalar_old_sub &
            ,period_bdy_em_scalar_sub,period_bdy_em_tke_old_sub &
            ,period_bdy_em_tracer2_sub,period_bdy_em_tracer_old_sub &
            ,period_bdy_em_tracer_sub,period_em_da_sub,period_em_hydro_uv_sub &
            ,halo_em_f_sub,halo_em_init_4_sub
    #endif

    Near the top add these extra declarations


    Look for the following code (it will be around line 120):

    ! Changes in tendency at this timestep real ,DIMENSION(grid%sm31:grid%em31,grid%sm32:grid%em32,grid%sm33:grid%em33) :: h_tendency, & z_tendency

    Just above these lines, add the following code:

    REAL :: sum_ws, max_ws, glat, glon, wind_vel
    LOGICAL, EXTERNAL :: wrf_dm_on_monitor
    CHARACTER*256 :: outstring


     

    Near the bottom add the following code


    Look for the following code:

    ! Finish timers if compiled with -DBENCH. #include RETURN END SUBROUTINE solve_em

    Just above these lines, add the following code:

    ! Compute local maximum and sum of 10m wind-speed
    sum_ws = 0.
    max_ws = 0.
    DO j = jps, jpe
      DO i = ips, ipe
        wind_vel = sqrt( grid%u10(i,j)*grid%u10(i,j) + grid%v10(i,j)*grid%v10(i,j))
        IF ( wind_vel .GT. max_ws ) THEN
          max_ws = wind_vel
          idex = i
          jdex = j
        ENDIF
        sum_ws = sum_ws + wind_vel
     ENDDO
    ENDDO
     
    ! Compute global sum
    sum_ws = wrf_dm_sum_real ( sum_ws )
     
    ! Compute global maximum and associated i,j point
    CALL wrf_dm_maxval_real ( max_ws, idex, jdex )
     
    ! Determine if i,j point of maximum is on this process
    ! and if so, set the lat and lon of that point, otherwise
    ! set to an absolute minimum
    IF ( ips .LE. idex .AND. idex .LE. ipe .AND. &
          jps .LE. jdex .AND. jdex .LE. jpe ) THEN
      glat = grid%xlat(idex,jdex)
      glon = grid%xlong(idex,jdex)
    ELSE
      glat = -99999.
      glon = -99999.
    ENDIF
     
    ! Compute global maximum to find glat and glon
    glat = wrf_dm_max_real ( glat )
    glon = wrf_dm_max_real ( glon )
     
    ! Print out the result on the monitor process
    IF ( wrf_dm_on_monitor() ) THEN
      WRITE(outstring,*)'Avg. ',sum_ws/((ide-ids*1)*(jde-jds+1))
      CALL wrf_message ( TRIM(outstring) )
      WRITE(outstring,*)'Max. ',max_ws,' Lat. ',glat,' Lon. ',glon
      CALL wrf_message ( TRIM(outstring) )
    ENDIF

  • Type only 'compile em_real >& log.compile'. (Do not type './clean' first)
    This will only recompile the few routines needed.
     
     
  • Run the model as before

    Look in the log files, you will see extra print-outs that look like this:

    Avg. 5.881783
    Max. 14.73283    Lat. 29.00684    Lon. 126.9531

     


  • Organization Suggestion:

    Recall the suggestion (from the "basic" case) to create a directory to put your files in. Do this again for this case:
    mkdir diagnostic_variable
    and then copy the necessary files into that directory to preserve them for potential later use.


If this was successful, you can continue to run another case of your choice, or generate graphics for your case.