25.12.2012 Views

WRF ARW User's Guide - MMM - UCAR

WRF ARW User's Guide - MMM - UCAR

WRF ARW User's Guide - MMM - UCAR

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

POST-PROCESSING<br />

Add the markers NCLFORTSTART and NCLEND to the subroutine as indicated<br />

below.<br />

Note, that<br />

local variables are outside these block markers.<br />

FORTRAN 77 routine called myTK.f, with NCL markers added<br />

C NCLFORTSTART<br />

subroutine compute_tk (tk, pressure, theta, nx, ny, nz)<br />

implicit none<br />

C Variables<br />

integer nx, ny,<br />

nz<br />

real tk( nx,ny,nz) , pressure(nx,ny,nz), theta(nx,ny,nz)<br />

C NCLEND<br />

C Local Variables<br />

integer i, j, k<br />

real pi<br />

DO k=1,nz<br />

DO j=1,ny<br />

DO i=1,nx<br />

pi=(pressure(i,j,k)<br />

/ 1000.)**(287./1004.)<br />

tk( i,j,k) = pi*theta(i,j,k)<br />

ENDDO<br />

ENDDO<br />

ENDDO<br />

return<br />

end<br />

Now compile this code using the NCL script WRAPIT.<br />

NOTE: If WRAPIT<br />

cannot be found, make sure the environment variable<br />

NCARG_ROOT<br />

has been set correctly.<br />

If the subroutine compiles successfully, a new library will be<br />

created, called myTK.so.<br />

This<br />

library can be linked to an NCL<br />

script to calculate TK. See how this is done in the<br />

example below:<br />

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/<strong>WRF</strong>User<strong>ARW</strong>.ncl” external myTK "./myTK.so"<br />

begin<br />

WRAPIT myTK.f<br />

t = wrf_user_getvar (a,”T”,5)<br />

theta = t + 300<br />

p = wrf_user_getvar (a,”pressure”,5)<br />

<strong>WRF</strong>-<strong>ARW</strong> V3: User’s <strong>Guide</strong> 9-17

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!