[ncl-talk] daylight_fao56 function error

Adam Phillips asphilli at ucar.edu
Thu Oct 5 10:04:25 MDT 2017


Hi Beata,
I think you have found a bug in crop.ncl. I would suggest copying crop.ncl
to your local directory, modifying line 779 from this:
daylightmax(:,nl) = con*ws        ; eq 34
to this:
daylightmax(:,nl,ml) = con*ws        ; eq 34

and then loading your version of crop.ncl at the top of your script. If
that does not work let ncl-talk know. I will file a JIRA ticket for this.
Adam


On Wed, Oct 4, 2017 at 4:28 AM, Beáta Szabó-Takács <szabo.b at czechglobe.cz>
wrote:

> Dear NCL Users,
>
> I have a matter with daylight_fao56 function. I have a lat(nlat,mlon) and
> doy(ntime) variables what I used in daylight_fao56 function but I got an
> error message:
>
> fatal:Number of subscripts (2) and number of dimensions (3) do not match
> for variable (daylightmax)
>
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 779 in
> file $NCARG_ROOT/lib/ncarg/nclscripts/csm/crop.ncl
>
>
>
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 48 in
> file ex_regrid_ETo_turc.ncl
>
>
>
> My script:
>
>
>
> 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/contrib/calendar_decode2.ncl"
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/crop.ncl"
>
>
>
> begin
>
> ;-- open file
>
> a = addfile("CNRM-CM5-CLM4.8.171971.nc","r")             ;read the nc file
>
> b = addfile("sund_CNRM-CM5-CLM1971.nc","r")
>
>
>
>   tas = a->tas                                   ; read daily tasmax
> values
>
>   sund = b->sund                                   ; read daily sund
> values
>
>
>
>   time = a->time                                       ; read time values
>
>   time_bnds = a->time_bnds
>
>   lat = a->lat
>
>   lon = a->lon
>
>   lon_bnds = a->lon_bnds
>
>   lat_bnds = a->lat_bnds
>
>   rlon = a->rlon
>
>   rlat = a->rlat
>
>   rotated = a->rotated_latitude_longitude
>
>
>
>   print(lat)
>
>   tmean = tas + 273.15                                              ;
> convert K to Celsius degree
>
>   nsun  = sund/3600                                                    ;
> convert second to hour
>
>   time2 = calendar_decode2(time,-5)                    ; convert the time
> codes (days since 1949,12,1) to yyyy,mm,dd in integer
>
>
>
>   doy = day_of_year(time2(:,0),time2(:,1),time2(:,2))
>                           ; calculate day of year
>
>   print (doy)
>
>
>
>   ra_0 = radext_fao56(doy, lat, 0)             ; Compute extraterrestrial
> radiation for daily periods
>
>   ra_0 = where(ismissing(ra_0), 0, ra_0)   ; convert the missing value due
> to limited validity at high latitudes to 0
>
>   print(ra_0)
>
>
>
>   sunhrx = daylight_fao56(doy, lat)        ; max daylight/sun; hr per day
>
>   print(sunhrx)
>
>
>
>   rs_0   = radsol_fao56(ra_0, sunhrx, nsun, (/0,0/), False)          ;
> 'radsol' (total solar radiation)
>
>   evturc_0  = refevt_turc( tmean, rs_0, (/0,0,0/) )                  ;
> Turc ETo formulation in mm/day
>
>
>
>     out1 = addfile("CNRM-CM5_CLM_evturc_01.nc","c")
> ; write ETo to netCDF file
>
>     out1->evturc = evturc_0
>
>     out1->evturc!0 = "time"
>
>     out1->evturc!1 = "rlat"
>
>     out1->evturc!2 = "rlon"
>
>     out1->lat = lat
>
>     out1->lat_bnds = lat_bnds
>
>     out1->lon = lon
>
>     out1->lon_bnds = lon_bnds
>
>     out1->rlon = rlon
>
>     out1->rlat = rlat
>
>     out1->rotated_pole = rotated
>
>     out1->time = time
>
>     out1->time_bnds = time_bnds
>
> end
>
>
>
> According to my best knowledge radext_fao56 and daylight_fao56 functions
> use same variables (jday and lat). The radext function works correctly but
> daylight function does not. Could someone write me what I did wrong and how
> I can fix this error? Thank you very much for your help in advance!
>
> Beata
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171005/a34b69f2/attachment.html>


More information about the ncl-talk mailing list