source: trunk/src/compute_erai_daily_region_2d.sh @ 169

Last change on this file since 169 was 167, checked in by pinsard, 12 years ago

interp_erai_lwr is now a function

File size: 18.9 KB
Line 
1#! /bin/sh
2#
3#+
4#
5# .. program:: compute_erai_daily_region_2d.sh
6#
7# .. _compute_erai_daily_region_2d.sh:
8#
9# ===============================
10# compute_erai_daily_region_2d.sh
11# ===============================
12#
13# SYNOPSIS
14# ========
15#
16# ::
17#
18#  $ compute_erai_daily_region_2d.sh [--debug] [--diff_cmd arg] -b yyyymmdd -e yyyymmdd
19#
20# DESCRIPTION
21# ===========
22#
23# .. option:: --diff_cmd <arg>
24#
25#    By default :samp:`ncflint` command is used to compute difference
26#    between NetCDF files
27#
28#    If :samp:`cdo` is specified here, this command will be used instead.
29#
30# .. option:: --debug
31#
32#    If this option is set, :samp:`ncdump -v time` will be added to log file
33#
34# .. option:: -b beginning date <yyyymmdd>
35# .. option:: -e end date <yyyymmdd>
36#
37# Put in ${PROJECT_ID} ERA-Intermin uninterpolated reference files.
38#
39# Log file is written on :file:`${PROJECT_LOG}/compute_erai_daily_region_2d.log.{YYYYMMDDTHHMMSSZ}`
40#
41#     .. graphviz::
42#
43#        digraph compute_erai_daily_region_2d {
44#
45#           filein_str [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/FC_SF/yyyy/mm/str.yyyymmdd.fshei.GLOBAL_075.nc"];
46#           filein_msl [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/msl.yyyymm.ashei.GLOBAL_075.nc"];
47#           filein_sstk [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/sstk.yyyymm.ashei.GLOBAL_075.nc"];
48#           filein_t2 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/t2.yyyymm.ashei.GLOBAL_075.nc"];
49#           filein_d2 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/d2.yyyymm.ashei.GLOBAL_075.nc"];
50#           filein_u10 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/u10.yyyymm.ashei.GLOBAL_075.nc"];
51#           filein_v10 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/v10.yyyymm.ashei.GLOBAL_075.nc"];
52#
53#           fileout_str [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/erai_TROP_1d_yyyy0101_yyyy1231_str_gridOrig.nc"];
54#           fileout_msl [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/erai_TROP_1d_yyyy0101_yyyy1231_msl_gridOrig.nc"];
55#           fileout_sstk [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/erai_TROP_1d_yyyy0101_yyyy1231_sstk_gridOrig.nc"];
56#           fileout_t2 [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/erai_TROP_1d_yyyy0101_yyyy1231_t2_gridOrig.nc"];
57#           fileout_d2 [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/erai_TROP_1d_yyyy0101_yyyy1231_d2_gridOrig.nc"];
58#           fileout_u10 [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/erai_TROP_1d_yyyy0101_yyyy1231_u10_gridOrig.nc"];
59#           fileout_v10 [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/erai_TROP_1d_yyyy0101_yyyy1231_v10_gridOrig.nc"];
60#
61#           compute_erai_daily_region_2d [shape=box,
62#           fontname=Courier,
63#           color=blue,
64#           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/compute_erai_daily_region_2d.sh",
65#           label="${PROJECT}/src/compute_erai_daily_region_2d.sh"];
66#
67#           {filein_str filein_msl filein_sstk filein_t2 filein_d2 filein_u10 filein_v10} -> {compute_erai_daily_region_2d} -> {fileout_str fileout_msl fileout_sstk fileout_t2 fileout_d2 fileout_u10 fileout_v10}
68#
69#       }
70#
71# .. caution::
72#
73#    Output files if exist are overwritten.
74#
75# EXAMPLES
76# ========
77#
78# On climserv only if you don't have any ERA-I reference data,
79# you just have to run this tool ::
80#
81#  $ compute_erai_daily_region_2d.sh -b 19890102 -e 20091231
82#
83# And look at log file with ::
84#
85#  $ tlogd.sh compute_erai_daily_region_2d
86#
87# and of course on files in ${PROJECT_ID}.
88#
89# SEE ALSO
90# ========
91#
92# :ref:`data_in_erai`
93#
94# http://climserv.ipsl.polytechnique.fr/fr/les-donnees/era-interim-4.html
95# for variables names
96#
97# :ref:`project_profile.sh`
98#
99# :func:`ncpdq <nco:ncpdq>`
100# :func:`ncks <nco:ncks>`
101# :func:`ncrcat <nco:ncrcat>`
102# :func:`ncea <nco:ncea>`
103# :func:`ncflint <nco:ncflint>`
104#
105# :func:`sub <cdo:sub>`
106# :func:`divc <cdo:divc>`
107#
108# :func:`interp_erai_dewt`
109# :func:`interp_erai_lwr`
110# :ref:`interp_erai_sst_1989_2009.pro`
111# :func:`interp_erai_t2m`
112# :ref:`interp_erai_ws_1989_2009.pro`
113#
114# TODO
115# ====
116#
117# catalog
118#
119# improve log
120#
121# handle dd parameter : now from 1 to end of month
122#
123# adjust yyyymmddb_min and yyyymmddb_max
124#
125# trouble with cdo reference (extra %23name in generated url using sphinx1.0.7)
126#
127# minimize use of generic characters (*) to avoid ambiguity
128#
129# split get and process files
130#
131# coding rules
132#
133# correction of min and max values of latitude attributes (still -90,+90 !) in output files
134#
135# are cmonthmin and cmonthmax the real info to put in output file name ? may be not because if input files do not exist
136#
137# same idea for day min and max - some time hard coded with 01 or 31 (avoid yyyy0231 !!)
138#
139# solve this kind of warning::
140#
141#  ncrcat: WARNING Intra-file non-monotonicity. Record coordinate "time" does not monotonically decrease between (input file /homedata/pinsard/log//compute_erai_daily_region_2d.20110126T154235Z.temp//temp_int_str_199012.nc record indices: 29, 30) (output file /homedata/pinsard/tropflux_d//erai_TROP_1d_19900101_19901231_str_gridOrig.nc record indices 363, 364) record coordinate values -0.000278, -0.000278
142#
143#  this seems to be solved by using cdo instead of ncflint. to be confirmed !
144#
145# no files *19890101* in /bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/FC_SF/1989/01/ :
146# is it normal ?
147#
148# check units of str ::
149#
150#     str:long_name = "Surface thermal radiation" ;
151#     str:units = "W/m^2 s"
152#
153# still true after ncflint/cdo arithmetic ?
154#
155# Modify global attributes : Still CF ? no more "five time values per day " in Forecast attributes
156#
157# enrich info in log file
158#
159# EVOLUTIONS
160# ==========
161#
162# $Id$
163#
164# $URL$
165#
166# - fplod 20110429T114649Z aedon.locean-ipsl.upmc.fr (Darwin)
167#
168#   * add -b and -e parameters
169#
170# - fplod 20110203T101720Z aedon.locean-ipsl.upmc.fr (Darwin)
171#
172#   * add cdo reference
173#
174# - pinsard 2011-02-02T16:11:07Z loholt1.ipsl.polytechnique.fr (Linux)
175#
176#   * add parameter --debug
177#   * add parameter --diff_cmd to choose between ncflint and cdo
178#   * usage of :samp:`cdo sub` and :samp: cdo divc,86400.` if parameter --diff_cmd is set to cdo
179#     thanks to https://code.zmaw.de/embedded/cdo/1.4.7/cdo.html#x1-2280002.7.4
180#   * add natural language explanation on ncflit usage provided by Matthieu
181#
182# - fplod 20110127T142038Z
183#
184#   * correction of path of input files in header
185#
186# - fplod 20110126T132641Z
187#
188#   * avoid ncrcat interactive question
189#   * remove unused variables
190#   * change GLOG to TROP (36N,36S)
191#   * yearmax 2009
192#   * add a test of existence of monthly file (symetric to test on daily files)
193#
194# - fplod 20101223T084153Z aedon.locean-ipsl.upmc.fr (Darwin)
195#
196#   * add reference to nco commands
197#
198# - fplod 20101220T150356Z aedon.locean-ipsl.upmc.fr#
199#
200#   * indentation
201#   * replace date by yyyy (date is a shell command)
202#   * replace for yyyy by while yyyy
203#   * replace for month by while month
204#   * replace for day by while day
205#   * work only on existing dates
206#
207# - fplod 20101220T142107Z aedon.locean-ipsl.upmc.fr (Darwin)
208#
209#   * add Long name variables
210#   * replace /bdd/IPCC/Reanalysis/ERAI/${reg}/ by ${TROPFLUX_ID}
211#   * add examples
212#   * add log management
213#   * dirtemp not hard coded values
214#   * check dirin permission
215#
216# - fplod 20101216T110626Z aedon.locean-ipsl.upmc.fr (Darwin)
217#
218#   * add minimal header
219#   * add graph in header
220#
221#-
222system=$(uname)
223case "${system}" in
224   AIX|IRIX64)
225      echo "www : no specific posix checking"
226      date_cmd=date
227   ;;
228   Darwin)
229      set -o posix
230      date_cmd=gdate
231   ;;
232   Linux)
233      set -o posix
234      date_cmd=date
235   ;;
236   *)
237     set -o posix
238   ;;
239esac
240unset system
241#
242LANG=POSIX
243#
244set -u
245#
246command=$(basename ${0})
247log_date=$(date -u +"%Y%m%dT%H%M%SZ")
248#
249usage=" Usage : ${command} [--debug] [--diff_cmd [ncflint|cdo]] -b yyyymmdd -e yyyymmdd"
250#
251hostname=$(hostname)
252#
253yyyymmddb_min=19890101
254yyyymmdde_max=20091231
255#
256# default
257diff_cmd=ncflint
258debug=0
259yyyymmddb=19890101
260yyyymmdde=20091231
261minlat=-36.
262maxlat=36.
263minlon=0.
264maxlon=360.
265reg=TROP
266#
267minargcount=4
268if [ ${#} -lt ${minargcount} ]
269then
270   echo "${command} : eee : not enought arguments"
271   echo "${usage}"
272   exit 1
273fi
274#
275while [ ${#} -gt 0 ]
276do
277   case ${1} in
278      --debug)
279         debug=1
280      ;;
281      --diff_cmd)
282         diff_cmd=${2}
283         shift
284      ;;
285      -b)
286         # first date to get
287         yyyymmddb=${2}
288         shift
289      ;;
290      -e)
291         # last date to get
292         yyyymmdde=${2}
293         shift
294      ;;
295      *)
296        # anything else
297        echo "${command} : eee : unknown option ${1}"
298        echo "${command} : eee : ${usage}"
299        exit 1
300      ;;
301   esac
302   # next flag
303   shift
304done
305#
306# check parameters
307#
308${date_cmd} -d "${yyyymmddb}" > /dev/null
309status_date=${?}
310if [ ${status_date} -ne 0 ]
311then
312     echo "${command} : eee : yyyymmddb ${yyyymmddb} argument invalid"
313     exit 1
314fi
315unset status_date
316#
317if [[ "${yyyymmddb}" < "${yyyymmddb_min}" ]]
318then
319     echo "${command} : eee : yyyymmddb ${yyyymmddb} must be equal or greater than ${yyyymmddb_min}"
320     exit 1
321fi
322#
323${date_cmd} -d "${yyyymmdde}" > /dev/null
324status_date=${?}
325if [ ${status_date} -ne 0 ]
326then
327     echo "${command} : eee : yyyymmdde ${yyyymmdde} argument invalid"
328     exit 1
329fi
330unset status_date
331#
332if [[ "${yyyymmdde}" > "${yyyymmdde_max}" ]]
333then
334     echo "${command} : eee : yyyymmdde ${yyyymmdde} must be lower or equal to ${yyyymmdde_max}"
335     exit 1
336fi
337#
338#
339if [[ "${yyyymmdde}" < "${yyyymmddb}" ]]
340then
341     echo "${command} : eee : yyyymmdde ${yyyymmdde} must be equal or greater than yyyymmddb ${yyyymmddb}"
342     exit 1
343fi
344#
345# test if diff_cmd valid
346case ${diff_cmd} in
347   ncflint)
348      # test if ncflint available
349      tool=ncflint
350      type ${tool} 1> /dev/null 2>&1
351      status=${?}
352      if [ ${status} -ne 0 ]
353      then
354         echo "${command} : eee : ${tool} not found"
355         exit 1
356      fi
357      unset status
358   ;;
359   cdo)
360      # test if cdo available
361      tool=cdo
362      type ${tool} 1> /dev/null 2>&1
363      status=${?}
364      if [ ${status} -ne 0 ]
365      then
366         echo "${command} : eee : ${tool} not found"
367         exit 1
368      fi
369      unset status
370   ;;
371   *)
372      echo "${command} : eee : diff_cmd ${diff_cmd} argument invalid"
373      exit 1
374esac
375
376# check for ${PROJECT_LOG} definition
377if [ "${PROJECT_LOG}" = "" ]
378then
379   echo "${command} : eee : \${PROJECT_LOG} not defined"
380   exit 1
381fi
382#
383# check for ${PROJECT_LOG} existence
384if [ ! -d ${PROJECT_LOG} ]
385then
386   echo "${command} : eee : ${PROJECT_LOG} not found"
387   exit 1
388fi
389#
390# check for permission access on PROJECT_LOG
391if [ ! -x ${PROJECT_LOG} ]
392then
393   echo "${command} : eee : ${PROJECT_LOG} not reachable"
394   exit 1
395fi
396#
397# check for write permission on PROJECT_LOG
398if [ ! -w ${PROJECT_LOG} ]
399then
400   echo "${command} : eee : ${PROJECT_LOG} not writable"
401   exit 1
402fi
403#
404dirtemp=${PROJECT_LOG}/$(basename ${0} .sh).${log_date}.temp/
405mkdir -p ${dirtemp}
406#
407log=${PROJECT_LOG}/$(basename ${0} .sh).log.${log_date}
408echo "[Context]" 1>> ${log}
409echo "command=$(basename ${0})" 1>>${log}
410echo "hostname=${hostname}" 1>> ${log}
411echo "runtime=${log_date}" 1>> ${log}
412unset log_date
413#
414echo "" 1>> ${log}
415echo "[Parameters]" 1>> ${log}
416echo "yyyymmddb=${yyyymmddb}" 1>> ${log}
417echo "yyyymmdde=${yyyymmdde}" 1>> ${log}
418echo "minlat=${minlat}" 1>> ${log}
419echo "maxlat=${maxlat}" 1>> ${log}
420echo "minlon=${minlon}" 1>> ${log}
421echo "maxlon=${maxlon}" 1>> ${log}
422echo "diff_cmd=${diff_cmd}" 1>> ${log}
423echo "" 1>> ${log}
424#
425yearmin=$(${date_cmd} -d "${yyyymmddb}" +%Y)
426yearmax=$(${date_cmd} -d "${yyyymmdde}" +%Y)
427monthmin=$(${date_cmd} -d "${yyyymmddb}" +%m)
428monthmax=$(${date_cmd} -d "${yyyymmdde}" +%m)
429cmonthmin=$(printf "%2.2d" ${monthmin})
430cmonthmax=$(printf "%2.2d" ${monthmax})
431dirin=/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/
432# check for dirin existence
433if [ ! -d ${dirin} ]
434then
435   echo "${command} : eee : ${dirin} not found"
436   exit 1
437fi
438#
439# check for permission access on dirin
440if [ ! -x ${dirin} ]
441then
442   echo "${command} : eee : ${dirin} not reachable"
443   exit 1
444fi
445#
446# str = Surface thermal radiation
447for var in str ; do
448   yyyy=${yearmin}
449   while [ ${yyyy} -le ${yearmax} ]
450   do
451      month=${monthmin}
452      while [ ${month} -le ${monthmax} ]
453      do
454         cmonth=$(printf "%2.2d" ${month})
455         daymin=1
456         daymax=$(cal ${month} ${yyyy} | grep . | fmt -1 | tail -1)
457         day=${daymin}
458         while [ ${day} -le ${daymax} ]
459         do
460            echo "iii : ${yyyy}${cmonth}${day}"
461            cday=$(printf "%2.2d" ${day})
462            if [ -f ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}.fshei.GLOBAL_075.nc ]
463            then
464               if [ ${debug} -eq 1 ]
465               then
466                  ncdump -v time ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}.fshei.GLOBAL_075.nc >> ${log} 2>&1
467               fi
468               ncpdq -U ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}.fshei.GLOBAL_075.nc ${dirtemp}/${var}.${yyyy}${cmonth}${cday}.temp.GLOBAL_075.nc
469               if [ ${debug} -eq 1 ]
470               then
471                  ncdump -v time ${dirtemp}/${var}.${yyyy}${cmonth}${cday}.temp.GLOBAL_075.nc >> ${log} 2>&1
472               fi
473            else
474               echo "${command} : iii : no files ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}*" >> ${log}
475            fi
476            day=$(( ${day} + 1 ))
477         done
478         exist_temp_files=$(find ${dirtemp} -name "${var}.${yyyy}${cmonth}*temp*")
479         if [ "${exist_temp_files}" != "" ]
480         then
481            # concatenation of daily files
482            ncrcat -O ${dirtemp}/${var}.${yyyy}${cmonth}??.temp.GLOBAL_075.nc ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc
483            if [ ${debug} -eq 1 ]
484            then
485               ncdump -v time ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc >> ${log} 2>&1
486            fi
487            rm ${dirtemp}/${var}.${yyyy}${cmonth}??.temp.GLOBAL_075.nc 2> /dev/null
488            ncks -d lat,${minlat},${maxlat} -d lon,${minlon},${maxlon} -d time,0,,5 ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc ${dirtemp}/temp_time0.nc
489            if [ ${debug} -eq 1 ]
490            then
491               ncdump -v time ${dirtemp}/temp_time0.nc >> ${log} 2>&1
492            fi
493            ncks -d lat,${minlat},${maxlat} -d lon,${minlon},${maxlon} -d time,4,,5 ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc ${dirtemp}/temp_time4.nc
494            if [ ${debug} -eq 1 ]
495            then
496               ncdump -v time ${dirtemp}/temp_time4.nc >> ${log} 2>&1
497            fi
498            case "${diff_cmd}" in
499               ncflint)
500                  # différence entre les forcast a 36 et a 12h (pour avoir des flux par jour) et la constante suivant le -w permet de se ramener a des unites connues
501                  ncflint -w 1.1574074,-1.1574074 ${dirtemp}/temp_time0.nc ${dirtemp}/temp_time4.nc ${dirtemp}/temp_time.nc
502                  if [ ${debug} -eq 1 ]
503                  then
504                      ncdump -v time ${dirtemp}/temp_time.nc >> ${log} 2>&1
505                  fi
506                  # La deuxieme permet uniquement de passer en seconde. 1.1574074*.00001=1/86400. (jour a seconde)
507                  ncflint -w 0.00001,0.0 ${dirtemp}/temp_time.nc ${dirtemp}/temp_time.nc ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc
508                  if [ ${debug} -eq 1 ]
509                  then
510                     ncdump -v time ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc >> ${log} 2>&1
511                  fi
512               ;;
513               cdo)
514                  cdo sub ${dirtemp}/temp_time0.nc ${dirtemp}/temp_time4.nc ${dirtemp}/temp_time.nc >> ${log} 2>&1
515                  if [ ${debug} -eq 1 ]
516                  then
517                     ncdump -v time ${dirtemp}/temp_time.nc >> ${log} 2>&1
518                  fi
519                  cdo divc,86400. ${dirtemp}/temp_time.nc ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc >> ${log} 2>&1
520                  if [ ${debug} -eq 1 ]
521                  then
522                     ncdump -v time ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc >> ${log} 2>&1
523                  fi
524               ;;
525            esac
526            rm ${dirtemp}/temp_time* 2> /dev/null
527            rm ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc 2> /dev/null
528         else
529            echo "${command} : iii : no files ${dirtemp}/${var}.${yyyy}${cmonth}*temp*" >> ${log}
530         fi
531         unset exist_temp_files
532         month=$(( ${month} + 1 ))
533      done
534      # concatenation of monthly files
535      if [ ${debug} -eq 1 ]
536      then
537         ncdump -v time ${dirtemp}/temp_int_${var}_${yyyy}??.nc 1>> ${log} 2>&1
538      fi
539      ncrcat -O ${dirtemp}/temp_int_${var}_${yyyy}??.nc ${PROJECT_ID}/erai_${reg}_1d_${yyyy}${cmonthmin}01_${yyyy}${cmonthmax}31_${var}_gridOrig.nc 1>> ${log} 2>&1
540      rm ${dirtemp}/temp_int_${var}_${yyyy}* 2> /dev/null
541      yyyy=$(( ${yyyy} + 1 ))
542   done
543done
544#
545# msl = Mean sea level pressure
546# sstk = Sea surface temperature
547# t2 = Temperature at 2 meters
548# d2 = Dew point at 2 meters
549# u10 = 10m U wind component
550# v10 = 10m V wind component
551for var in msl sstk t2 d2 u10 v10 ; do
552   yyyy=${yearmin}
553   while [ ${yyyy} -le ${yearmax} ]
554   do
555      month=${monthmin}
556      while [ ${month} -le ${monthmax} ]
557      do
558         cmonth=$(printf "%2.2d" ${month})
559         if [ -f ${dirin}/AN_SF/${yyyy}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ]
560         then
561            ncpdq -U ${dirin}/AN_SF/${yyyy}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ${dirtemp}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc
562            ncks -d lat,${minlat},${maxlat} -d lon,${minlon},${maxlon} -d time,0,,4 ${dirtemp}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ${dirtemp}/temp_time1.nc
563            ncks -d lat,${minlat},${maxlat} -d lon,${minlon},${maxlon} -d time,1,,4 ${dirtemp}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ${dirtemp}/temp_time2.nc
564            ncks -d lat,${minlat},${maxlat} -d lon,${minlon},${maxlon} -d time,2,,4 ${dirtemp}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ${dirtemp}/temp_time3.nc
565            ncks -d lat,${minlat},${maxlat} -d lon,${minlon},${maxlon} -d time,3,,4 ${dirtemp}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ${dirtemp}/temp_time4.nc
566            ncea ${dirtemp}/temp_time* ${dirtemp}/temp_int_${yyyy}${cmonth}.nc
567            rm ${dirtemp}/temp_time* 2> /dev/null
568            rm ${dirtemp}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc 2> /dev/null
569            month=$(( ${month} + 1 ))
570          else
571             echo "${command} : iii : no file ${dirin}/AN_SF/${yyyy}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc " >> ${log}
572          fi
573      done
574      # concatenation of monthly files
575      if [ ${debug} -eq 1 ]
576      then
577         ncdump -v time ${dirtemp}/temp_int_${yyyy}??.nc >> ${log} 2>&1
578      fi
579      ncrcat -O ${dirtemp}/temp_int_${yyyy}??.nc ${PROJECT_ID}/erai_${reg}_1d_${yyyy}${cmonthmin}01_${yyyy}${cmonthmax}31_${var}_gridOrig.nc >> ${log} 2>&1
580      rm ${dirtemp}/temp_int_${yyyy}* 2> /dev/null
581      yyyy=$(( ${yyyy} + 1 ))
582   done
583done
584# debug to check if clean is done
585if [ ${debug} -eq 1 ]
586then
587   ls ${dirtemp}/  >> ${log} 2>&1
588fi
589# end
590exit 0
Note: See TracBrowser for help on using the repository browser.