[ncl-talk] daylight_fao56 function error

Beáta Szabó-Takács szabo.b at czechglobe.cz
Wed Oct 4 04:28:14 MDT 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171004/458b3241/attachment.html>


More information about the ncl-talk mailing list