source: trunk/src/compute_erai_daily_region_2d.sh

Last change on this file was 204, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo

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