; --------------------------------------------------------------------------- ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Program Name: topo_adj.ncl ; ; ; ; National Water Model (NWM) WRF-hydro forcing engine is developed by ; ; National Center for Atmospheric Research (NCAR), under the sponsorship ; ; of National Water Center (NWC). ; ; ; ; Team Members: ; ; NCAR Staff: Linlin Pan, Wei Yu, and David Gochis ; ; NWC/OWP Staff: Brian Cosgrove, Zhengtao Cui, Cham Pham, and James Taft ; ; ; ; This is a ncl program to perform height adjustment. ; ; ; ; Input: topo file, to be adjusted file ; ; ; ; Output: topo adjusted file ; ; ; ; For non-fatal errors output is witten to $DATA/logs ; ; ; ; Author(s)/Contact(s): Linlin Pan, lpan@ucar.edu ; ; Origination June, 2015 ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;---------------------------------------------------------------------- ;------------------------ ;external TOPO_ADJF90 "$HOME/HYDRO/REGRID/DOWN/topo_adjf90.so" external NWM_FORCING_TOPO_ADJ "$LIBnwm/nwm_forcing_topo_adj.so" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl" ;==============================================================================; ; 0. Define function ;==============================================================================; ;------------------------------------------------------------- ; 0.0 Load useful ncl scripts ;------------------------------------------------------------- load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" ; load "/opt/ncl_ncarg-5.1.1-pgi/lib/ncarg/nclscripts/csm/contributed.ncl" ; load "$CSH_ARCHIVE/ncl/WRFUserARW.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl" function sub_string_double(s:string,i:integer,j:integer) begin s_char = stringtochar(s) sub_str = s_char(i:j) return (stringtodouble(chartostring(sub_str))) end function sub_string_float(s:string,i:integer,j:integer) begin s_char = stringtochar(s) sub_str = s_char(i:j) return (stringtofloat(chartostring(sub_str))) end begin ; ; Calculate three values of a quadratic equation ; ; input files inputGeo = getenv("inputGeo") outFile = getenv("outFile") f1 = addfile(inputGeo,"r") ; out files fout = addfile(outFile,"w") hgt = f1->HGT_M(0,:,:) xlat = f1->XLAT_M(0,:,:) xlong = f1->XLONG_M(0,:,:) swdown_in=fout->SWDOWN(:,:) dx = f1@DX dy = f1@DY nsizes=dimsizes(hgt) print(nsizes) printVarSummary(hgt) nx=nsizes(1) ny=nsizes(0) cosa = f1->COSALPHA(0,:,:) sina = f1->SINALPHA(0,:,:) swdown_out=swdown_in*0. ss=outFile yyyy=floattointeger(sub_string_float(ss,0,3)) mon=floattointeger(sub_string_float(ss,4,5)) dd=floattointeger(sub_string_float(ss,6,7)) hh=floattointeger(sub_string_float(ss,8,9)) xtime = hh*60. yyyy@calendar = "julian" julian = day_of_year(yyyy,mon,dd) print(julian) print(xtime) NWM_FORCING_TOPO_ADJ:: topo_adj(hgt,xlat,xlong,dx,dy,nx,ny,cosa, sina, xtime, julian,swdown_in, swdown_out) swdown_out = where(ismissing(swdown_in),swdown_in,swdown_out) swdown_out = where(swdown_out.lt.0,0,swdown_out) fout->SWDOWN=swdown_out exit ; EX01::cquad(-1., 2., 3., nump, x, qval) ; Call the NCL version of ; your Fortran subroutine. end status_exit(1)