Index: /trunk/src/compute_erai_daily_region_2d.sh
===================================================================
--- /trunk/src/compute_erai_daily_region_2d.sh	(revision 32)
+++ /trunk/src/compute_erai_daily_region_2d.sh	(revision 33)
@@ -16,8 +16,19 @@
 # ::
 #
-#  $ compute_erai_daily_region_2d.sh
+#  $ compute_erai_daily_region_2d.sh [--debug] [--diff_cmd arg]
 #
 # DESCRIPTION
 # ===========
+#
+# .. option:: --diff_cmd <arg>
+#
+#    by default :samp:`ncflint` command is used to compute difference between NetCDF files
+#
+#    if :samp:`cdo` is specified here, this command will be used instead.
+#
+# .. option:: --debug
+#
+#    if this option is set, :samp:`ncdump -v time` will be added to log file
+#
 #
 # Put in ${TROPFLUX_ID} ERA-Intermin reference files
@@ -31,11 +42,11 @@
 #           rankdir="LR",
 #           ]
-#           filein_str [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/FC_SF/yyyy/mm/str.yyyymmdd*"];
-#           filein_msl [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/msl.yyyymm.ashei.GLOBAL_075.nc"];
-#           filein_sstk [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/sstk.yyyymm.ashei.GLOBAL_075.nc"];
-#           filein_t2 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/t2.yyyymm.ashei.GLOBAL_075.nc"];
-#           filein_d2 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/d2.yyyymm.ashei.GLOBAL_075.nc"];
-#           filein_u10 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/u10.yyyymm.ashei.GLOBAL_075.nc"];
-#           filein_v10 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/mm/v10.yyyymm.ashei.GLOBAL_075.nc"];
+#           filein_str [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/FC_SF/yyyy/mm/str.yyyymmdd.fshei.GLOBAL_075.nc"];
+#           filein_msl [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/msl.yyyymm.ashei.GLOBAL_075.nc"];
+#           filein_sstk [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/sstk.yyyymm.ashei.GLOBAL_075.nc"];
+#           filein_t2 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/t2.yyyymm.ashei.GLOBAL_075.nc"];
+#           filein_d2 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/d2.yyyymm.ashei.GLOBAL_075.nc"];
+#           filein_u10 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/u10.yyyymm.ashei.GLOBAL_075.nc"];
+#           filein_v10 [shape=ellipse,fontname=Courier,label="/bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_SF/yyyy/v10.yyyymm.ashei.GLOBAL_075.nc"];
 #
 #           fileout_str [shape=ellipse,fontname=Courier,label="${TROPFLUX_ID}/erai_TROP_1d_yyyy0101_yyyy1231_str_gridOrig.nc"];
@@ -101,16 +112,19 @@
 # ====
 #
+# add cdo reference
+#
+# minimize use of generic characters (*) to avoid ambiguity
+#
 # parametrisation of year min and year max
 #
-# explication on ncflint arguments
-#
 # split get and process files
 #
 # coding rules
 #
-# correction of min and max of latitude field (still -90,+90 !)
+# correction of min and max values of latitude attributes (still -90,+90 !) in output files
 #
 # are cmonthmin and cmonthmax the real info to put in output file name ? may be not because if input files do not exist
 #
+# same idea for day min and max - some time hard coded with 01 or 31 (avoid yyyy0231 !!)
 #
 # solve this kind of warning::
@@ -118,7 +132,38 @@
 #  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
 #
+#  
+#  this seems to be solved by using cdo instead of ncflint. to be confirmed !
+#
+#
+# no files *19890101* in /bdd/ERAI/NETCDF/GLOBAL_075/4xdaily/FC_SF/1989/01/ :
+# is it normal ?
+#
+# check units of str ::
+#
+#     str:long_name = "Surface thermal radiation" ;
+#     str:units = "W/m^2 s" 
+# 
+# still true after ncflint/cdo arithmetic ?
+#
+# Modify global attributes : Still CF ? no more "five time values per day " in Forecast attributes
+#
+# enrich info in log file
 #
 # EVOLUTIONS
 # ==========
+#
+# $URL$
+#
+# - pinsard 2011-02-02T16:11:07Z loholt1.ipsl.polytechnique.fr (Linux)
+#
+#   * add parameter --debug
+#   * add parameter --diff_cmd to choose between ncflint and cdo
+#   * usage of :samp:`cdo sub` and :samp: cdo divc,86400.` if parameter --diff_cmd is set to cdo
+#     thanks to https://code.zmaw.de/embedded/cdo/1.4.7/cdo.html#x1-2280002.7.4
+#   * add natural language explanation on ncflit usage provided by Matthieu
+#
+# - fplod 20110127T142038Z
+#
+#   * correction of path of input files in header
 #
 # - fplod 20110126T132641Z
@@ -174,12 +219,73 @@
 log_date=$(date -u +"%Y%m%dT%H%M%SZ")
 #
-usage=" Usage : ${command}"
+usage=" Usage : ${command} --debug --diff_cmd [ncflint|cdo]"
 #
 hostname=$(hostname)
 # default
-# N.A. because no parameters
+diff_cmd=ncflint
+debug=0
+#
+minargcount=0
+if [ ${#} -lt ${minargcount} ]
+then
+   echo "${command} : eee : not enought arguments"
+   echo "${usage}"
+   exit 1
+fi
+#
+set +u
+while [ ! -z "${1}" ]
+do
+   case ${1} in
+      --debug)
+         debug=1
+      ;;
+      --diff_cmd)
+         diff_cmd=${2}
+         shift
+      ;;
+      *)
+        # anything else
+        echo "${command} : eee : unknown option ${1}"
+        echo "${command} : eee : ${usage}"
+        exit 1
+      ;;
+   esac
+   # next flag
+   shift
+done
 #
 set -u
-#
+# test if diff_cmd valid
+case ${diff_cmd} in
+   ncflint)
+      # test if ncflint available
+      tool=ncflint
+      type ${tool} 1> /dev/null 2>&1
+      status=${?}
+      if [ ${status} -ne 0 ]
+      then
+         echo "${command} : eee : ${tool} not found"
+         exit 1
+      fi
+      unset status
+   ;;
+   cdo)
+      # test if cdo available
+      tool=cdo
+      type ${tool} 1> /dev/null 2>&1
+      status=${?}
+      if [ ${status} -ne 0 ]
+      then
+         echo "${command} : eee : ${tool} not found"
+         exit 1
+      fi
+      unset status
+   ;;
+   *)
+      echo "${command} : eee : diff_cmd ${diff_cmd} argument invalid"
+      exit 1
+esac
+
 # check for ${TROPFLUX_LOG} definition
 if [ "${TROPFLUX_LOG}" = "" ]
@@ -219,5 +325,10 @@
 echo "runtime=${log_date}" 1>> ${log}
 unset log_date
+#
 echo "" 1>> ${log}
+echo "[Parameters]" 1>> ${log}
+echo "diff_cmd=${diff_cmd}" 1>> ${log}
+echo "" 1>> ${log}
+#
 #
 minlat=-36.
@@ -262,7 +373,15 @@
          do
             cday=$(printf "%2.2d" ${day})
-            if [ -f ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}* ]
+            if [ -f ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}.fshei.GLOBAL_075.nc ]
             then
-               ncpdq -U ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}* ${dirtemp}/${var}.${yyyy}${cmonth}${cday}.temp.GLOBAL_075.nc
+               if [ ${debug} -eq 1 ]
+               then
+                  ncdump -v time ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}.fshei.GLOBAL_075.nc >> ${log} 2>&1
+               fi
+               ncpdq -U ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}.fshei.GLOBAL_075.nc ${dirtemp}/${var}.${yyyy}${cmonth}${cday}.temp.GLOBAL_075.nc
+               if [ ${debug} -eq 1 ]
+               then
+                  ncdump -v time ${dirtemp}/${var}.${yyyy}${cmonth}${cday}.temp.GLOBAL_075.nc >> ${log} 2>&1
+               fi
             else
                echo "${command} : iii : no files ${dirin}/FC_SF/${yyyy}/${cmonth}/${var}.${yyyy}${cmonth}${cday}*" >> ${log}
@@ -273,10 +392,49 @@
          if [ "${exist_temp_files}" != "" ]
          then
-            ncrcat -O ${dirtemp}/${var}.${yyyy}${cmonth}*temp* ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc
-            rm ${dirtemp}/${var}.${yyyy}${cmonth}*temp* 2> /dev/null
+            # concatenation of daily files
+            ncrcat -O ${dirtemp}/${var}.${yyyy}${cmonth}??.temp.GLOBAL_075.nc ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc
+            if [ ${debug} -eq 1 ]
+            then
+               ncdump -v time ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc >> ${log} 2>&1
+            fi
+            rm ${dirtemp}/${var}.${yyyy}${cmonth}??.temp.GLOBAL_075.nc 2> /dev/null
             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
+            if [ ${debug} -eq 1 ]
+            then
+               ncdump -v time ${dirtemp}/temp_time0.nc >> ${log} 2>&1
+            fi
             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
-            ncflint -w 1.1574074,-1.1574074 ${dirtemp}/temp_time0.nc ${dirtemp}/temp_time4.nc ${dirtemp}/temp_time.nc
-            ncflint -w 0.00001,0.0 ${dirtemp}/temp_time.nc ${dirtemp}/temp_time.nc ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc
+            if [ ${debug} -eq 1 ]
+            then
+               ncdump -v time ${dirtemp}/temp_time4.nc >> ${log} 2>&1
+            fi
+            case "${diff_cmd}" in
+               ncflint)
+                  # 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
+                  ncflint -w 1.1574074,-1.1574074 ${dirtemp}/temp_time0.nc ${dirtemp}/temp_time4.nc ${dirtemp}/temp_time.nc
+                  if [ ${debug} -eq 1 ]
+                  then
+                      ncdump -v time ${dirtemp}/temp_time.nc >> ${log} 2>&1
+                  fi
+                  # La deuxieme permet uniquement de passer en seconde. 1.1574074*.00001=1/86400. (jour a seconde)
+                  ncflint -w 0.00001,0.0 ${dirtemp}/temp_time.nc ${dirtemp}/temp_time.nc ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc
+                  if [ ${debug} -eq 1 ]
+                  then
+                     ncdump -v time ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc >> ${log} 2>&1
+                  fi
+               ;;
+               cdo)
+                  cdo sub ${dirtemp}/temp_time0.nc ${dirtemp}/temp_time4.nc ${dirtemp}/temp_time.nc >> ${log} 2>&1
+                  if [ ${debug} -eq 1 ]
+                  then
+                     ncdump -v time ${dirtemp}/temp_time.nc >> ${log} 2>&1
+                  fi
+                  cdo divc,86400. ${dirtemp}/temp_time.nc ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc >> ${log} 2>&1
+                  if [ ${debug} -eq 1 ]
+                  then
+                     ncdump -v time ${dirtemp}/temp_int_${var}_${yyyy}${cmonth}.nc >> ${log} 2>&1
+                  fi
+               ;;
+            esac
             rm ${dirtemp}/temp_time* 2> /dev/null
             rm ${dirtemp}/${var}.${yyyy}${cmonth}.fshei.GLOBAL_075.nc 2> /dev/null
@@ -287,5 +445,10 @@
          month=$(( ${month} + 1 ))
       done
-      ncrcat -O ${dirtemp}/temp_int_${var}_${yyyy}* ${TROPFLUX_ID}/erai_${reg}_1d_${yyyy}${cmonthmin}01_${yyyy}${cmonthmax}31_${var}_gridOrig.nc
+      # concatenation of monthly files
+      if [ ${debug} -eq 1 ]
+      then
+         ncdump -v time ${dirtemp}/temp_int_${var}_${yyyy}??.nc 1>> ${log} 2>&1
+      fi
+      ncrcat -O ${dirtemp}/temp_int_${var}_${yyyy}??.nc ${TROPFLUX_ID}/erai_${reg}_1d_${yyyy}${cmonthmin}01_${yyyy}${cmonthmax}31_${var}_gridOrig.nc 1>> ${log} 2>&1
       rm ${dirtemp}/temp_int_${var}_${yyyy}* 2> /dev/null
       yyyy=$(( ${yyyy} + 1 ))
@@ -307,5 +470,5 @@
       do
          cmonth=$(printf "%2.2d" ${month})
-         if [ -f ${dirin}/AN_SF/${yyyy}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ] 
+         if [ -f ${dirin}/AN_SF/${yyyy}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ]
          then
             ncpdq -U ${dirin}/AN_SF/${yyyy}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc ${dirtemp}/${var}.${yyyy}${cmonth}.ashei.GLOBAL_075.nc
@@ -322,10 +485,19 @@
           fi
       done
-      ncrcat -O ${dirtemp}/temp_int_${yyyy}* ${TROPFLUX_ID}/erai_${reg}_1d_${yyyy}${cmonthmin}01_${yyyy}${cmonthmax}31_${var}_gridOrig.nc
+      # concatenation of monthly files
+      if [ ${debug} -eq 1 ]
+      then
+         ncdump -v time ${dirtemp}/temp_int_${yyyy}??.nc >> ${log} 2>&1
+      fi
+      ncrcat -O ${dirtemp}/temp_int_${yyyy}??.nc ${TROPFLUX_ID}/erai_${reg}_1d_${yyyy}${cmonthmin}01_${yyyy}${cmonthmax}31_${var}_gridOrig.nc >> ${log} 2>&1
       rm ${dirtemp}/temp_int_${yyyy}* 2> /dev/null
       yyyy=$(( ${yyyy} + 1 ))
    done
 done
-#
+# debug to check if clean is done
+if [ ${debug} -eq 1 ]
+then
+   ls ${dirtemp}/  >> ${log} 2>&1
+fi
 # end
 exit 0
Index: /trunk/src/get_oaflux.sh
===================================================================
--- /trunk/src/get_oaflux.sh	(revision 32)
+++ /trunk/src/get_oaflux.sh	(revision 33)
@@ -77,4 +77,6 @@
 #
 # :ref:`tropflux_profile.sh`
+#
+# :ref:`oaflux_mask_30N30S.pro`
 #
 # EVOLUTIONS
Index: /trunk/src/interp_erai_t2m_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_t2m_1989_2009.pro	(revision 32)
+++ /trunk/src/interp_erai_t2m_1989_2009.pro	(revision 33)
@@ -318,12 +318,54 @@
 
 
-ncfields = 't2m[longitude,latitude,time]=t2mout:t2m_attr; ' $
-                      + 'longitude[]=lon:lon_attr; ' $
-                      + 'latitude[]=lat:lat_attr; ' $
-		      + 'time[*time]=timein:time_attr ' $
-                      + ' @ globattr'
-
+help, t2mout
+help, timein
+;ncfields = 't2m[longitude,latitude,*time]=t2mout:t2m_attr; ' $
+;                      + 'longitude[]=lon:lon_attr; ' $
+;                      + 'latitude[]=lat:lat_attr; ' $
+;		      + 'time[]=timein:time_attr ' $
+;                      + ' @globattr'
+
+; ok ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr'
+; ok ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timein:time_attr'
+; ok ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[*]=timein:time_attr'
+; ok ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[*]=timein:time_attr@globattr'
+; pas ok ncfields = 't2m[longitude,latitude,*time]=t2mout:t2m_attr;longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[*]=timein:time_attr@globattr'
+; pas ok  ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[*]=timein:time_attr;t2m[longitude,latitude,*time]=t2mout:t2m_attr@globattr'
+
+; the simpliest one
+nlat=73
+nlon=96
+latitudetp=findgen(nlat)
+longitudetp=findgen(nlon)
+timetp=findgen(2)
+pressure3d=findgen(nlon,nlat,2)
+patts = {units:'pascal',missing_value:1e10}
+globatts={source:'my program',version:2}
+NCFIELDS = 'pressure3d[longitudetp,latitudetp,*timetp]=pressure3d:patts;longitudetp[];latitudetp[];timetp[]@globatts'
+ncfile='my4.nc'
 @ncdf_quickwrite
 
+timepb=findgen(2)
+t2m=findgen(350,60,2)
+help, lat
+help, lon
+help, t2m 
+help, time
+help, timein
+help, timepb
+ncfile='!' + fullfilename_out
+; pas ok ncfields = 'longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timein:time_attr;t2m[longitude,latitude,*time]'
+; pas ok ncfields = 't2m[longitude,latitude,*time];longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timein:time_attr'
+; ok avec timepb=findgen(2) ncfields = 't2m[longitude,latitude,*time];longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timepb:time_attr'
+; ok
+;timepb=findgen(2)
+;timepb[0]=280512.
+;timepb[1]=280536.
+;ncfields = 't2m[longitude,latitude,*time];longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timepb:time_attr'
+
+timepb=findgen(7670)
+ncfields = 't2m[longitude,latitude,*time];longitude[]=lon:lon_attr;latitude[]=lat:lat_attr;time[]=timepb:time_attr'
+@ncdf_quickwrite
+
 
 end
Index: /trunk/src/test/read.jnl
===================================================================
--- /trunk/src/test/read.jnl	(revision 32)
+++ /trunk/src/test/read.jnl	(revision 33)
@@ -30,8 +30,7 @@
 ! ========
 !
-! matlab/octave similar program
-!
-! :ref:`read.m`
+! matlab/octave similar program : :ref:`read.m`
 ! 
+! IDL+SAXO similar program : :ref:`read.pro`
 !
 ! TODO
