From: madhura ranade <madhuraran_at_nyahnyahspammersnyahnyah>

Date: Tue Apr 02 2013 - 01:49:55 MDT

Date: Tue Apr 02 2013 - 01:49:55 MDT

Hello all,

Is there any way that I can write a subroutine in NCL? I know we can call

fortran subroutines, but what if I want to write one in NCL?

Any help would be appreciated.

Thanks,

Madhura

On 2 April 2013 13:12, sangeeta maharjan <sangeetamaharjan@gmail.com> wrote:

*> Dear ncl-talk,
*

*>
*

*> Again I had a problem.I used fortran subroutine to generate time
*

*> series data(24 hours) of temperature, uv component, humidity, pressure
*

*> of place with lat = 27.7 , lon = 85.3 from wrf output file and store
*

*> all of them into txt file. Actually I want to compare these simulation
*

*> data with my station data. My programs didn't work well. Can you
*

*> please have a look on it.
*

*>
*

*> time_series_Dhm.f90
*

*> SUBROUTINE COMPARE_DHM(day,hr,temp,hum,u,v,p,x,y)
*

*> IMPLICIT NONE
*

*> INTEGER,DIMENSION(97),INTENT(IN)::day
*

*> INTEGER,DIMENSION(97),INTENT(IN)::hr
*

*> REAL,DIMENSION(51,51,27,97),INTENT(IN)::temp
*

*> REAL,DIMENSION(51,51,27,97),INTENT(IN)::hum
*

*> REAL,DIMENSION(51,51,27,97),INTENT(IN)::u
*

*> REAL,DIMENSION(51,51,27,97),INTENT(IN)::v
*

*> REAL,DIMENSION(51,51,27,97),INTENT(IN)::p
*

*> INTEGER,INTENT(IN)::x,y
*

*> INTEGER::D
*

*>
*

*> OPEN(UNIT=12,FILE="COMPARE.TXT",STATUS="NEW",FORM="FORMATTED")
*

*>
*

*> DO D=1,24
*

*>
*

*> WRITE(12,100)hr(D),temp(x,y,1,D),hum(x,y,1,D),u(x,y,1,D),v(x,y,1,D),p(x,y,1,D)
*

*> END DO
*

*>
*

*> 100 FORMAT(I4,3X,F12.4,3X,F12.4,3X,F12.4,3X,F12.4,3X,F12.4)
*

*> CLOSE(12)
*

*>
*

*> END SUBROUTINE COMPARE_DHM
*

*>
*

*>
*

*> time_series_Dhm.stub
*

*> NCLFORTSTART
*

*> COMPARE_DHM(day,hr,temp,hum,u,v,p,x,y)
*

*> INTEGER day(97)
*

*> INTEGER hr(97)
*

*> REAL temp(51,51,27,97)
*

*> REAL hum(51,51,27,97)
*

*> REAL u(51,51,27,97)
*

*> REAL v(51,51,27,97)
*

*> REAL p(51,51,27,97)
*

*> INTEGER x,y
*

*> C NCLEND
*

*>
*

*> time_series_Dhm.ncl
*

*> external TIME_SERIES_DHM "./time_series_Dhm.so"
*

*> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
*

*> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
*

*>
*

*> begin
*

*>
*

*> a =
*

*> addfile("/root/Desktop/TWAS/KTM_OUT/wrfout_d03_2012-04-26_00:00:00.nc
*

*> ","r")
*

*>
*

*> ; Find the ij location for the point of interest
*

*> lat = 27.7
*

*> lon = 85.3
*

*> llres = True
*

*> llres@ReturnInt = True ; Return integer values
*

*> locij = wrf_user_ll_to_ij(a, lon, lat, llres)
*

*> locij = locij - 1 ; array pointers in NCL space
*

*> locX = locij(0)
*

*> locY = locij(1)
*

*>
*

*> ;get time information and strip out the day and hour
*

*> times_in_file = a->Times
*

*> dims = dimsizes(times_in_file)
*

*> Day = new(dims(0),integer)
*

*> Hr = new(dims(0),integer)
*

*> do i=0,dims(0)-1
*

*> Day(i)=stringtointeger(chartostring(times_in_file(i,8:9)));extract
*

*> day from Times
*

*> Hr(i) =
*

*> stringtointeger(chartostring(times_in_file(i,11:12)));extract hour
*

*> from Times
*

*> end do
*

*>
*

*> Tempc=wrf_user_getvar(a,"tc",-1);celsius
*

*> Rhumidity=wrf_user_getvar(a,"rh",-1);%
*

*> UV=wrf_user_getvar(a,"uvmet",-1);m/s horizontal
*

*> P=wrf_user_getvar(a,"pres",-1);Pa pressure
*

*>
*

*> U=UV(0,:,:,:,:);extracting U component
*

*> V=UV(1,:,:,:,:)extracting V component
*

*>
*

*> printVarSummary(Day)
*

*> printVarSummary(Hr)
*

*> printVarSummary(Tempc)
*

*> printVarSummary(Rhumidity)
*

*> printVarSummary(UV)
*

*> printVarSummary(U)
*

*> printVarSummary(V)
*

*> printVarSummary(P)
*

*> print(locX)
*

*> print(locY)
*

*>
*

*>
*

*> TIME_SERIES_DHM::COMPARE_DHM(Day,Hr,Tempc,Rhumidity,U,V,P,locX,locY)
*

*> end
*

*>
*

*> Any help would be appreciated.
*

*>
*

*> Sangeeta Maharjan.
*

*> _______________________________________________
*

*> ncl-talk mailing list
*

*> List instructions, subscriber options, unsubscribe:
*

*> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
*

*>
*

-- * Give me freshening breeze, A white and swelling sail, A ship that cuts the dashing waves, And weathers every gale. *

_______________________________________________

ncl-talk mailing list

List instructions, subscriber options, unsubscribe:

http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Tue Apr 2 01:50:10 2013

*
This archive was generated by hypermail 2.1.8
: Tue Apr 02 2013 - 21:23:48 MDT
*