|
17 | 17 | end if
|
18 | 18 | end ; procedure debug_print
|
19 | 19 |
|
| 20 | +undef("check_date_format") |
| 21 | +function check_date_format(date_in,date_type,routine_name,debug) |
| 22 | +begin |
| 23 | + if (date_in.lt.1.e4) then ; input just YYYY, need to add MMDDHH |
| 24 | + if (date_type.eq."start") then |
| 25 | + date_suffix = 101*100 |
| 26 | + else if (date_type.eq."end") then |
| 27 | + date_suffix = 1231*10 |
| 28 | + else |
| 29 | + print("ERROR: "+routine_name+" No date_type given to function check_date_format") |
| 30 | + end if |
| 31 | + end if |
| 32 | + |
| 33 | + debug_print("Incoming "+date_type+" date YYYY format: "+date_in,routine_name,debug) |
| 34 | + date_out = date_in*1000000+ date_suffix |
| 35 | + debug_print("Corrected "+date_type+" date to:"+date_out,routine_name,debug) |
| 36 | + |
| 37 | + else |
| 38 | + if (date_in .lt. 100000000) ; YYYYMMDD |
| 39 | + debug_print("Incoming "+date_type+" date YYYYMMDD format: "+date_in,routine_name,debug) |
| 40 | + date_out = date_in*100 ;; HH = 00 |
| 41 | + debug_print("Corrected "+date_type+" date to:"+date_out,routine_name,debug) |
| 42 | + else |
| 43 | + debug_print("Found start date format YYYYMMDDHH: "+yr,routine_name,debug) |
| 44 | + date_out = date_in |
| 45 | + end if ; YYYYMMDD |
| 46 | + end if ; YYYY |
| 47 | + |
| 48 | + return date_out |
| 49 | +end ; function check_date_format |
20 | 50 |
|
21 | 51 | begin
|
22 | 52 | ; read daily output files from CAM2 and process the data
|
@@ -63,12 +93,10 @@ nd = dimsizes(time_all)
|
63 | 93 | i2 = nd(0) - 1
|
64 | 94 | debug_print("Time range in file: "+time_all(0)+" -"+time_all(i2),routine_name,debug)
|
65 | 95 |
|
66 |
| - ; in hours to match cd_calendar/ut_calendar output YYYYMMDDHH |
67 |
| - ; uses 18 hrs for endtime since 6-hourly is the most high res we expect |
68 |
| - ; should still work for daily, just finds YYYY123100 |
69 |
| - start_time = yr1*1000000+101*100 |
70 |
| - end_time = yr2*1000000+1231*100+18 |
71 |
| - debug_print("Time range requested: "+start_time+" "+end_time,routine_name,debug) |
| 96 | +; Check if date came in as YYYYMMDD or YYYY (historic) |
| 97 | +start_time = check_date_format(yr1,"start",routine_name,debug) |
| 98 | +end_time = check_date_format(yr2,"end",routine_name,debug) |
| 99 | + |
72 | 100 | tol = 24 ; 24 hours tolerance allows for different time resolutions
|
73 | 101 | do i=0,dimsizes(time_all)-1
|
74 | 102 | ; debug_print("examining times "+i+" "+time_all(i),routine_name,debug)
|
@@ -108,8 +136,7 @@ if ( isMonotonic(date) .ne. 1 ) then
|
108 | 136 | exit ; exit on error
|
109 | 137 | end if
|
110 | 138 |
|
111 |
| -; DRB: used to do pr, rlut separately. Folding them into the loop instead. |
112 |
| -; **here first just use read_model_file for pr here, then put into var loop below |
| 139 | +; First just use read_model_file for pr here, then put into var loop below |
113 | 140 | ; precipitation rate (pr)
|
114 | 141 | print("daily_netcdf.ncl reading "+file_pr+" for making precip file!")
|
115 | 142 |
|
|
0 commit comments