source: trunk/src/compute_erai_daily_region_2d.sh @ 67

Last change on this file since 67 was 67, checked in by pinsard, 13 years ago

fix for doc

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