Index: /trunk/src/TropFlux_19890101_20091231.pro
===================================================================
--- /trunk/src/TropFlux_19890101_20091231.pro	(revision 87)
+++ /trunk/src/TropFlux_19890101_20091231.pro	(revision 88)
@@ -63,13 +63,13 @@
 ;
 ; net heat flux components are written
-; in :file:`${PROJECT_OD}/TropFlux_19890101_20091231.nc`
+; in :file:`${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc`
 ; if this file not already exists.
 ;
+; This output file :file:`${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc`
+; will be used by :ref:`TropFlux_NRT_ncdf.pro`.
+;
 ;     .. graphviz::
 ;
 ;        digraph tropflux_19890101_20091231 {
-;           graph [
-;           rankdir="LR",
-;           ]
 ;
 ;           mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"];
@@ -82,5 +82,5 @@
 ;           file_q2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc"];
 ;
-;           file_out[shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_19890101_20091231.nc"];
+;           file_out[shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc"];
 ;
 ;           tropflux_19890101_20091231 [shape=box,
@@ -109,4 +109,6 @@
 ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
 ;
+; :func:`qsee`
+; :func:`calc_claud_vlat` 
 ; :func:`cor30a`
 ;
@@ -122,6 +124,28 @@
 ; ====
 ;
-; no ${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc yet because of pb in
-; TropFlux_swr_BLND_19890101_20091231.pro
+; missing lwnet_clark::
+;
+;    % Variable is undefined: LWNET_CLARK.
+;    % Execution halted at: TROPFLUX_19890101_20091231  434 /.autofs/home/fplod/incas/tropflux/tropflux_ws/src/TropFlux_19890101_20091231.pr
+;      o
+;    %                      $MAIN$          
+;    % Program caused arithmetic error: Floating overflow
+;    % Program caused arithmetic error: Floating illegal operand
+;
+; check if K or °C in input 
+;
+; get rid of::
+;
+;   % date 1: 19880101 is not found in the time axis.
+;
+; why ::
+;
+;   da1=19880101
+;
+; 1st date 19890101 no ? 
+;
+; why da1-1 (with da1=19880101) when reading gustiness file ::
+;
+;   wg=read_ncdf('wg',da1-1,da2,file=fullfilename_wg,/nostr)
 ;
 ; avoid mix lower/uppercase in pro name to avoid compile
@@ -141,4 +165,9 @@
 ;
 ; $URL$
+;
+; - fplod 20110819T144332Z aedon.locean-ipsl.upmc.fr (Darwin)
+;
+;   * add _coarev3 to filename output
+;   * check if filename output exists
 ;
 ; - fplod 20110809T110911Z aedon.locean-ipsl.upmc.fr (Darwin)
@@ -330,4 +359,14 @@
 IF fullfilename_wg[0] EQ '' THEN BEGIN
    msg = 'eee : the file ' + fullfilename_wg + ' was not found.'
+   ras = report(msg)
+   STOP
+ENDIF
+;
+; build output filename
+filename_out = 'TropFlux_19890101_20091231_coarev3.nc'
+fullfilename_out = iodirout + filename_out
+; in order to avoid unexpected overwritten
+IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
+   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
    ras = report(msg)
    STOP
@@ -426,5 +465,5 @@
 xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*))
 
-ncfile='!${PROJECT_OD}/TropFlux_19890101_20091231.nc'
+ncfile='!' + fullfilename_out
 lon_attr={units:'degrees_east',long_name:'Longitude'}
 lat_attr={units:'degrees_north',long_name:'Latitude'}
Index: /trunk/src/TropFlux_NRT_ncdf.pro
===================================================================
--- /trunk/src/TropFlux_NRT_ncdf.pro	(revision 87)
+++ /trunk/src/TropFlux_NRT_ncdf.pro	(revision 88)
@@ -7,14 +7,34 @@
 ; =====================
 ;
+; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc`
+; containing
+; ws corrected on OAFLUX grid
+; has been produced by
+; :ref:`TropFlux_swr_BLND_19890101_20091231.pro`.
+;
+; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc`
+; containing
+; lwr corrected on OAFLUX grid
+; has been produced by
+; :ref:`lwr_correction_ncdf.pro`.
+;
+; :file:`${PROJECT_OD}/TropFlux_19890101_20091231_coare3.nc`
+; containing
+; ++
+; has been produced by
+; :ref:`TropFlux_19890101_20091231.pro`.
+;
+; ++ are written
+; in :file:`${PROJECT_OD}/TropFlux_19890101_20091231.nc`
+; if this file not already exists.
+;
 ;     .. graphviz::
 ;
 ;        digraph tropflux_nrt_ncdf {
-;           graph [
-;           rankdir="LR",
-;           ]
-;           file1 [shape=ellipse,fontname=Courier,label="/Users/pkb/data/TropFlux/TropFlux_swr_19890101_20091231_BLND.nc"];
-;           file2 [shape=ellipse,fontname=Courier,label="/Users/pkb/data/TropFlux/TropFlux_lwr_19890101_20091231_v50.nc"];
-;           file3 [shape=ellipse,fontname=Courier,label="/Users/pkb/data/TropFlux/TropFlux_19890101_20091231_v51.nc"];
-;           ncfile [shape=ellipse,fontname=Courier,label="/Users/pkb/data/TropFlux/TropFlux_19890101_20091231.nc"];
+;
+;           file_swr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc"];
+;           file_lwr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_19890101_200912310.nc"];
+;           file_coare [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc"];
+;           file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_19890101_20091231.nc"];
 ;
 ;           tropflux_nrt_ncdf [shape=box,
@@ -24,6 +44,7 @@
 ;           label="${PROJECT}/src/TropFlux_NRT_ncdf.pro" ];
 ;
-;           {file1 file2 file3} -> {tropflux_nrt_ncdf} -> {ncfile}
-;          }
+;           {file_swr file_lwr file_coare} -> {tropflux_nrt_ncdf} -> {file_out}
+;
+;        }
 ;
 ; SEE ALSO
@@ -46,5 +67,5 @@
 ; ====
 ;
-; hard coded directory - usage of ${PROJECT_ID}
+; no yet tested because pb in TropFlux_19890101_20091231.pro
 ;
 ; coding rules
@@ -62,4 +83,6 @@
 ;
 ;   * remove v50 from pro name and in the graph
+;   * add coarev3 to the file coming from TropFlux_19890101_20091231.pro
+;   * use $PROJECT_OD
 ;
 ; - fplod 20101214T112526Z aedon.locean-ipsl.upmc.fr (Darwin)
@@ -77,21 +100,102 @@
 ;-
 pro TropFlux_NRT_ncdf
-@common
-
-dir="/Users/pkb/data/TropFlux/"
-file=dir+"TropFlux_swr_19890101_20091231_BLND.nc"
-initncdf, file
+;
+@cm_4cal
+@cm_4data
+@cm_4mesh
+@cm_4data
+@cm_project
+;
+;
+; test if ${PROJECT_OD} defined
+CASE project_od_env OF
+  '' : BEGIN
+         msg = 'eee : ${PROJECT_OD} is not defined'
+         ras = report(msg)
+       STOP
+       END
+  ELSE: BEGIN
+          msg = 'iii : ${PROJECT_OD} is ' + project_od_env
+          ras = report(msg)
+        END
+ ENDCASE
+;
+; check if output data will be possible
+iodirout = isadirectory(project_od_env)
+;
+; existence and protection for reading
+IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN
+   msg = 'eee : the directory' + iodirout  + ' is not accessible.'
+   ras = report(msg)
+   STOP
+ENDIF
+;
+; existence and protection for writing
+IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
+    msg = 'eee : the directory' + iodirout  + ' was not found.'
+    ras = report(msg)
+    STOP
+ENDIF
+;
+; build SWR blnd data filename
+filename_swr_blnd="TropFlux_swr_19890101_20091231_BLND.nc"
+;
+; check if this file exists
+msg='iii : looking for ' + filename_swr_blnd
+ras = report(msg)
+fullfilename_swr_blnd = isafile(iodirout + filename_swr_blnd, NEW=0, /MUST_EXIST)
+IF fullfilename_swr_blnd[0] EQ '' THEN BEGIN
+   msg = 'eee : the file ' + fullfilename_swr_blnd + ' was not found.'
+   ras = report(msg)
+   STOP
+ENDIF
+;
+; build LWR data filename
+filename_lwr="TropFlux_lwr_19890101_20091231.nc"
+;
+; check if this file exists
+msg='iii : looking for ' + filename_lwr
+ras = report(msg)
+fullfilename_lwr = isafile(iodirout + filename_lwr, NEW=0, /MUST_EXIST)
+IF fullfilename_lwr[0] EQ '' THEN BEGIN
+   msg = 'eee : the file ' + fullfilename_lwr + ' was not found.'
+   ras = report(msg)
+   STOP
+ENDIF
+;
+;  build COARE data filename
+filename_coare="TropFlux_19890101_20091231_coarev3.nc"
+;
+; check if this file exists
+msg='iii : looking for ' + filename_lwr
+ras = report(msg)
+fullfilename_coare = isafile(iodirout + filename_coare, NEW=0, /MUST_EXIST)
+IF fullfilename_coare[0] EQ '' THEN BEGIN
+   msg = 'eee : the file ' + fullfilename_coare + ' was not found.'
+   ras = report(msg)
+   STOP
+ENDIF
+;
+filename_out='TropFlux_19890101_20091231.nc'
+fullfilename_out = iodirout + filename_out
+; in order to avoid unexpected overwritten
+IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN
+   msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
+   ras = report(msg)
+   STOP
+ENDIF
+;
 st=19800101 & en=20101231
 
-swr=read_ncdf("swr", st, en, file=file,/nostr)
-
-file=dir+"TropFlux_lwr_19890101_20091231_v50.nc"
-initncdf, file
-lwr=read_ncdf("lwr", st, en, file=file,/nostr)
-
-file=dir+"TropFlux_19890101_20091231_v51.nc"
-initncdf, file
-lhf=read_ncdf("lhf", st, en, file=file,/nostr)
-shf=read_ncdf("shf", st, en, file=file,/nostr)
+initncdf, fullfilename_swr_blnd
+
+swr=read_ncdf("swr", st, en, file=fullfilename_swr_blnd,/nostr)
+
+initncdf, fullfilename_lwr
+lwr=read_ncdf("lwr", st, en, file=fullfilename_lwr,/nostr)
+
+initncdf, fullfilename_coare
+lhf=read_ncdf("lhf", st, en, file=fullfilename_coare,/nostr)
+shf=read_ncdf("shf", st, en, file=fullfilename_coare,/nostr)
 
 help, swr, lwr, lhf, shf
Index: /trunk/src/TropFlux_swr_BLND_19890101_20091231.pro
===================================================================
--- /trunk/src/TropFlux_swr_BLND_19890101_20091231.pro	(revision 87)
+++ /trunk/src/TropFlux_swr_BLND_19890101_20091231.pro	(revision 88)
@@ -28,5 +28,5 @@
 ; if this file not already exists.
 ;
-; This file will be used by :ref:`TropFlux_NRT_cfd.pro`.
+; This file will be used by :ref:`TropFlux_NRT_ncdf.pro`.
 ;
 ;     .. graphviz::
@@ -63,5 +63,5 @@
 ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
 ;
-; :ref:`Tropflux_NRT_cdf.pro`
+; :ref:`Tropflux_NRT_ncdf.pro`
 ;
 ; EXAMPLES
@@ -76,11 +76,5 @@
 ; ====
 ;
-; resolve crash on cratos idl7::
-;
-;   % Attempt to subscript SWR_DT with JT is out of range.
-;
-; line::
-;
-;    for jt=0,jpt-1 do swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt)
+; submit read_ncdf with 19890101 pb to saxo-dev
 ;
 ; avoid mix lower/uppercase in pro name to avoid compile
@@ -90,9 +84,10 @@
 ; complete description
 ;
-; why different date1 and date2 when readind dt and nrt
-;
-; why two read_ncdf for nrt
-;
-; according to pk 20110811 we can include this process in TropFlux_swr_NRT_19890101_20091231.pro
+; why 20080100, 20100112 as  date1 and date2 when readind nrt
+;
+; why two read_ncdf for nrt 
+;
+; according to pk 20110811 we can include this process in 
+; TropFlux_swr_NRT_19890101_20091231.pro ... later
 ;
 ; KNOWN ISSUES
@@ -109,4 +104,50 @@
 ; $URL$
 ;
+; - fplod 20110819T120412Z aedon.locean-ipsl.upmc.fr (Darwin)
+;
+;   * change 19890101 to 19890100 to read 6939 timesteps in DT file
+;     even if uggly and understanted SAXO strange behaviour
+;
+;     this resolve crash on cratos idl7::
+;
+;       % Attempt to subscript SWR_DT with JT is out of range.
+;
+;     line::
+;
+;        for jt=0,jpt-1 do swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt)
+;
+;     problably because  6938+731=7669 and not 7670 when
+;     :samp:`dt=read_ncdf("swr", 19890101, 20071231, file=fullfilename_dt,/nostr)`
+;     was used ::
+;
+;        DT              FLOAT     = Array[350, 60, 6938]
+;        NRT             FLOAT     = Array[350, 60, 731]
+;        SWR_DT          FLOAT     = Array[350, 60, 7669]
+;        SWR_NRT         FLOAT     = Array[350, 60, 7670]
+;
+;     nb jours 19890101-20071231::
+;
+;        IDL>  print, julday(12,31,2007) - julday(01, 01, 1989) +1
+;        6939
+;
+;     et ncdump -h $PROJECT_OD/TropFlux_swr_19890101_20071231_DT.nc time = UNLIMITED ; // (6939 currently)
+;
+;     nb jours 19890101-20091231::
+;
+;        IDL>  print, julday(12,31,2009) - julday(01, 01, 1989) +1
+;        7670
+;
+;     strange behaviour of read_ncdf ... see::
+;
+;        IDL> fullfilename_dt='TropFlux_swr_19890101_20071231_DT.nc'
+;        IDL> dt=read_ncdf("swr", 19890100, 20071231, file=fullfilename_dt,/nostr)
+;        IDL> print, 'first time step (should crash with invalid date)', jul2date(time[0])   
+;        first time step (should be 19890101)       19890101.
+;        IDL> dt=read_ncdf("swr", 19890101, 20071231, file=fullfilename_dt,/nostr)
+;        IDL> print, 'first time step (should be 19890101)', jul2date(time[0])   
+;        first time step (should be 19890101)       19890102.
+;
+;   * correction for reading gustiness file
+; 
 ; - fplod 20110809T115747Z aedon.locean-ipsl.upmc.fr (Darwin)
 ;
@@ -135,5 +176,4 @@
 @cm_4data
 @cm_project
-;
 ;
 ; test if ${PROJECT_OD} defined
@@ -217,6 +257,9 @@
 ;
 initncdf, fullfilename_dt
-dt=read_ncdf("swr", 19890101, 20071231, file=fullfilename_dt,/nostr)
+dt=read_ncdf("swr", 19890100, 20071231, file=fullfilename_dt,/nostr)
+print, 'www : should crash with invalide date 19890100'
 help, dt
+print, 'first time step (should be 19890101)', jul2date(time[0])
+print, 'last time step (should be 20071231)', jul2date(time[jpt-1])
 
 initncdf, fullfilename_nrt
@@ -227,5 +270,5 @@
 
 swr_dt=[[[dt]],[[nrt]]]
-help, swr_dt, swr_nrt
+help, nrt, swr_dt, swr_nrt
 
 swr_merged=swr_dt*0.
@@ -235,7 +278,9 @@
 a=interpol([1.,0.],[julday(10,01,2007),julday(12,31,2007)],time)
 a=((a > 0.) < 1.)
-for jt=0,jpt-1 do swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt)
-
-initncdf, file_wg
+for jt=0,jpt-1 do begin
+    swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt)
+endfor
+
+initncdf, fullfilename_wg
 time=timegen(7670, units='days', start=julday(1,1,1989,0)) & jpt=n_elements(time)
 lat=reform(gphit(0,0:jpj-1))
Index: /trunk/src/add_19890101.sh
===================================================================
--- /trunk/src/add_19890101.sh	(revision 88)
+++ /trunk/src/add_19890101.sh	(revision 88)
@@ -0,0 +1,389 @@
+#! /bin/sh
+#
+#+
+#
+# .. program:: add_19890101.sh
+#
+# .. _add_19890101.sh:
+#
+# ==================
+# add_19890101.sh 
+# ==================
+#
+# SYNOPSIS
+# ========
+#
+# ::
+#
+#  $ add_19890101.sh [--debug]
+#
+# DESCRIPTION
+# ===========
+#
+# .. option:: --debug
+#
+#    If this option is set, :samp:`ncdump -v tt` will be added to log file
+#
+# Artificialy add 19890101 to lwr interpolated on OAFLUX grid dataset.
+#
+# :file:`${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc`
+# containing 
+# ++
+# has been produced by
+# :ref:`interp_erai_lwr_1989_2009.pro`.
+# repeat the first time step in 
+#
+# File :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc`
+# will be written
+# if this file not already exists.
+#
+# This output file 
+# :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc`
+# must be processed after by 
+# :ref:`lwr_correction_ncdf.pro`.
+# 
+# Log file is written on :file:`${PROJECT_LOG}/add_19890101.sh.log.{YYYYMMDDTHHMMSSZ}`
+#
+#     .. graphviz::
+#
+#        digraph add_19890101 {
+#
+#           filein [shape=ellipse,fontname=Courier,label="$PROJECT_OD/erai_lwr_19890102_20091231_oafluxgrid.nc"];
+#           fileout [shape=ellipse,fontname=Courier,label="$PROJECT_OD/erai_lwr_19890101_20091231_oafluxgrid.nc"];
+#
+#           add_19890101 [shape=box,
+#           fontname=Courier,
+#           color=blue,
+#           URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/add_19890101.sh",
+#           label="${PROJECT}/src/add_19890101.sh"];
+#
+#           {filein} -> {add_19890101} -> {fileout}
+#
+#       }
+#
+# EXAMPLES
+# ========
+#
+# To produce $PROJECT_OD/erai_lwr_19890101_20091231_oafluxgrid.nc 
+# from $PROJECT_OD/erai_lwr_19890102_20091231_oafluxgrid.nc ::
+#
+#  $ add_19890101.sh --debug
+#
+# And look at log file with ::
+#
+#  $ tlogd.sh add_19890101
+#
+# and of course on files in ${PROJECT_OD}.
+#
+# TIPS
+# ====
+#
+# To see the 3 first time values in input and files::
+#
+#  $ ncks -s "%16.10f\n" -v tt -d time,0,2 ${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc 
+#    14246.0000000005
+#    14247.0000000005
+#    14248.0000000005
+#
+#  $ ncks -s "%16.10f\n" -v tt -d time,0,2 ${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc 
+#    14245.0000000005
+#    14246.0000000005
+#    14247.0000000005
+#
+# while :
+#
+#   $ idl
+#   IDl> print, julday(01, 01, 1989,12)-julday(01, 01, 1950,0)
+#   14245.500
+#   IDL> print, julday(01, 01, 1989,12)-julday(01, 01, 1950,0) +1
+#   14246.500
+#
+# SEE ALSO
+# ========
+#
+# :ref:`project_profile.sh`
+#
+# :func:`ncks <nco:ncks>`
+# :func:`ncrcat <nco:ncrcat>`
+# :func:`ncatted <nco:ncatted>`
+# :func:`ncap2 <nco:ncap2>`
+#
+# :ref:`lwr_correction_ncdf.pro`
+#
+# TODO
+# ====
+#
+# coding rules
+#
+# won't it be more conveniant to add this articifial time step in 
+# the IDL creation tool interp_erai_lwr_1989_2009.pro.
+# It will allow to avoid a shell interruption in the IDL processing chain.
+#
+# improve global attributes with ... creation_date and so on
+#
+# check if the first time step is really 19890102 in the input file
+#
+# change tt to ttt to complete time correction
+#
+# remove hard coded end time
+#
+# get rid of this long mesage on cratos::
+#
+#    ncrcat: WARNING Variable lwr has attribute "missing_value" but not "_FillValue". To 
+#    comply with netCDF conventions, NCO ignores values that equal the _FillValue attribu
+#    te when performing arithmetic. Confusingly, values equal to the missing_value should
+#     also be neglected. However, it is tedious and (possibly) computationally expensive 
+#    to check each value against multiple missing values during arithmetic on large varia
+#    bles. So NCO thinks that processing variables with a "missing_value" attribute and n
+#    o "_FillValue" attribute may produce undesired arithmetic results (i.e., where value
+#    s that were intended to be neglected were not, in fact, neglected). We suggest you r
+#    ename all "missing_value" attributes to "_FillValue" or include both "missing_value"
+#     and "_FillValue" attributes (with the _same values_) for all variables that have ei
+#    ther attribute. Because it is long, this message is only printed once per operator e
+#    ven though multiple variables may have the same attribute configuration. More inform
+#    ation on missing values is given at:
+#    http://nco.sf.net/nco.html#mss_val
+#    Examples of renaming attributes are at:
+#    http://nco.sf.net/nco.html#xmp_ncrename
+#
+# ... on a déjà une idee de la solution : convention CF et meilleure gestion des
+# valeurs manquantes dans les softs IDL !!!
+#
+#
+# EVOLUTIONS
+# ==========
+#
+# $Id$
+#
+# $URL$
+#
+# - fplod 20110819T091143Z aedon.locean-ipsl.upmc.fr (Darwin)
+#
+#   * creation from pk email 20110811 "lwr first timestep"
+#   * include time correction and timerange modificaton
+#
+#-
+system=$(uname)
+case "${system}" in
+   AIX|IRIX64)
+      echo "www : no specific posix checking"
+      date_cmd=date
+   ;;
+   Darwin)
+      set -o posix
+      date_cmd=gdate
+   ;;
+   Linux)
+      set -o posix
+      date_cmd=date
+   ;;
+   *)
+     set -o posix
+   ;;
+esac
+unset system
+#
+LANG=POSIX
+#
+command=$(basename ${0})
+log_date=$(date -u +"%Y%m%dT%H%M%SZ")
+#
+usage=" Usage : ${command} [--debug]"
+#
+hostname=$(hostname)
+#
+# default
+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
+      ;;
+      *)
+        # anything else
+        echo "${command} : eee : unknown option ${1}"
+        echo "${command} : eee : ${usage}"
+        exit 1
+      ;;
+   esac
+   # next flag
+   shift
+done
+#
+set -u
+#
+# check parameters
+# N.A.
+#
+tool=ncrcat
+type ${tool} 1> /dev/null 2>&1
+status=${?}
+if [ ${status} -ne 0 ]
+then
+   echo "${command} : eee : tool ${tool} not found"
+   exit 1
+fi
+unset status
+unset tool
+#
+tool=ncks
+type ${tool} 1> /dev/null 2>&1
+status=${?}
+if [ ${status} -ne 0 ]
+then
+   echo "${command} : eee : tool ${tool} not found"
+   exit 1
+fi
+unset status
+unset tool
+#
+tool=ncatted
+type ${tool} 1> /dev/null 2>&1
+status=${?}
+if [ ${status} -ne 0 ]
+then
+   echo "${command} : eee : tool ${tool} not found"
+   exit 1
+fi
+unset status
+unset tool
+#
+# check for ${PROJECT_LOG} definition
+if [ "${PROJECT_LOG}" = "" ]
+then
+   echo "${command} : eee : \${PROJECT_LOG} not defined"
+   exit 1
+fi
+#
+# check for ${PROJECT_LOG} existence
+if [ ! -d ${PROJECT_LOG} ]
+then
+   echo "${command} : eee : ${PROJECT_LOG} not found"
+   exit 1
+fi
+#
+# check for permission access on PROJECT_LOG
+if [ ! -x ${PROJECT_LOG} ]
+then
+   echo "${command} : eee : ${PROJECT_LOG} not reachable"
+   exit 1
+fi
+#
+# check for write permission on PROJECT_LOG
+if [ ! -w ${PROJECT_LOG} ]
+then
+   echo "${command} : eee : ${PROJECT_LOG} not writable"
+   exit 1
+fi
+#
+log=${PROJECT_LOG}/$(basename ${0} .sh).log.${log_date}
+echo "[Context]" 1>> ${log}
+echo "command=$(basename ${0})" 1>>${log}
+echo "hostname=${hostname}" 1>> ${log}
+echo "runtime=${log_date}" 1>> ${log}
+unset log_date
+#
+echo "" 1>> ${log}
+echo "[Parameters]" 1>> ${log}
+echo "N.A." 1>> ${log}
+echo "" 1>> ${log}
+#
+filein=${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc
+if [ ! -f ${filein} ]
+then
+    echo " eee : ${filein} not found" 1>> ${log}
+    exit 1 
+fi
+fileout=${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc
+if [ -f ${fileout} ]
+then
+      echo "eee : ${fileout} already exists" 1>>${log}
+      exit 1
+fi
+#
+rm -f ${PROJECT_OD}/erai_lwr_step19890101.nc 2> /dev/null
+rm -f ${PROJECT_OD}/erai_lwr_step19890102.nc 2> /dev/null
+#
+# extraction of the first time step 19890102
+ncks -h -d time,0,0 ${filein} ${PROJECT_OD}/erai_lwr_step19890102.nc >> ${log} 2>&1
+status=${?}
+if [ ${status} -ne 0 ]
+then
+    echo "eee : pb with ncks" >> ${log} 2>&1
+    ncdump -h ${filein} >> ${log} 2>&1
+    exit 1
+fi
+unset status
+#
+# ++ check if tt[0] is really 19890102
+#
+# substract 1 to tt to simulate 19890101
+ncap2 -h -s "tt=tt-1" \
+    ${PROJECT_OD}/erai_lwr_step19890102.nc \
+    ${PROJECT_OD}/erai_lwr_step19890101.nc
+status=${?}
+if [ ${status} -ne 0 ] 
+then
+    echo "eee : pb with ncap2" >> ${log} 2>&1
+    ncdump -h ${PROJECT_OD}/erai_lwr_step19890102.nc >> ${log} 2>&1
+    exit 1
+fi  
+unset status
+ls -l ${PROJECT_OD}/erai_lwr_step19890102.nc >> ${log} 2>&1
+ls -l ${PROJECT_OD}/erai_lwr_step19890101.nc >> ${log} 2>&1
+#
+# ++ check if tt[0] is really 19890101
+# 
+rm ${fileout}_bad_timerange 2> /dev/null
+ncrcat -h \
+       ${PROJECT_OD}/erai_lwr_step19890101.nc \
+       ${filein} \
+       ${fileout}_bad_timerange >> ${log} 2>&1
+status=${?}
+if [ ${status} -ne 0 ] 
+then
+    echo "eee : pb with ncrcat" >> ${log} 2>&1
+    ncdump -h ${PROJECT_OD}/erai_lwr_step19890101.nc >> ${log} 2>&1
+    ncdump -h ${filein} >> ${log} 2>&1
+    exit 1
+fi  
+unset status
+#
+ncatted -h -a timerange,global,o,c,"19890101 - 20091231" \
+       ${fileout}_bad_timerange \
+       ${fileout} >> ${log} 2>&1
+status=${?}
+if [ ${status} -ne 0 ]
+then
+    echo "eee : pb with ncatted" >> ${log} 2>&1
+    ncdump -h ${fileout}_bad_timerange >> ${log} 2>&1
+    exit 1
+fi 
+unset status
+#
+if [ ${debug} -eq 1 ]
+then
+    ncdump -v tt ${fileout} >> ${log} 2>&1
+fi
+#
+# cleanning
+#++rm -f ${PROJECT_OD}/erai_lwr_step19890101.nc 2> /dev/null
+#++rm -f ${PROJECT_OD}/erai_lwr_step19890102.nc 2> /dev/null
+#++rm -f ${PROJECT_OD}/${fileout}_bad_timerange 2> /dev/null
+#
+unset fileout
+unset filein
+#++ set
+# end
+exit 0
Index: /trunk/src/calc_cloud_vlat.pro
===================================================================
--- /trunk/src/calc_cloud_vlat.pro	(revision 87)
+++ /trunk/src/calc_cloud_vlat.pro	(revision 88)
@@ -1,3 +1,4 @@
-
+;+
+;-
  function calc_cloud_vlat, jday,SWR,XLAT
 
Index: /trunk/src/compute_erai_daily_region_2d.sh
===================================================================
--- /trunk/src/compute_erai_daily_region_2d.sh	(revision 87)
+++ /trunk/src/compute_erai_daily_region_2d.sh	(revision 88)
@@ -7,7 +7,7 @@
 # .. _compute_erai_daily_region_2d.sh:
 #
-# ==========================================================================
-# compute_erai_daily_region_2d.sh - get ERA-I uninterpolated reference files
-# ==========================================================================
+# ===============================
+# compute_erai_daily_region_2d.sh 
+# ===============================
 #
 # SYNOPSIS
@@ -23,5 +23,6 @@
 # .. option:: --diff_cmd <arg>
 #
-#    By default :samp:`ncflint` command is used to compute difference between NetCDF files
+#    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.
@@ -34,5 +35,5 @@
 # .. option:: -e end date <yyyymmdd>
 #
-# Put in ${PROJECT_ID} ERA-Intermin reference files.
+# Put in ${PROJECT_ID} ERA-Intermin uninterpolated reference files.
 #
 # Log file is written on :file:`${PROJECT_LOG}/compute_erai_daily_region_2d.log.{YYYYMMDDTHHMMSSZ}`
@@ -41,7 +42,5 @@
 #
 #        digraph compute_erai_daily_region_2d {
-#           graph [
-#           rankdir="LR",
-#           ]
+#
 #           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"];
@@ -91,5 +90,5 @@
 # ========
 #
-# :ref:`guide data ERA-I <data_in_erai>`
+# :ref:`data_in_erai`
 #
 # http://climserv.ipsl.polytechnique.fr/fr/les-donnees/era-interim-4.html
@@ -160,4 +159,6 @@
 # EVOLUTIONS
 # ==========
+#
+# $Id$
 #
 # $URL$
Index: /trunk/src/cronin_gustiness_ncdf.pro
===================================================================
--- /trunk/src/cronin_gustiness_ncdf.pro	(revision 87)
+++ /trunk/src/cronin_gustiness_ncdf.pro	(revision 88)
@@ -61,5 +61,6 @@
 ; coding rules
 ;
-; why writing more than 1 timestep ?
+; why da1=19880101 & da2=20101231 ? should be 19890101 and 20091231 or better
+; deduce from reading sst
 ;
 ; KNOWN ISSUES
@@ -135,5 +136,4 @@
 ;
 da1=19880101 & da2=20101231
-date1=19890101 & date2=20081231
 ;
 ; build data filename
Index: /trunk/src/interp_erai_dewt_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_dewt_1989_2009.pro	(revision 87)
+++ /trunk/src/interp_erai_dewt_1989_2009.pro	(revision 88)
@@ -102,5 +102,5 @@
 ; $Id$
 ;
-; $URL$
+; $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/tropflux/svn/trunk/src/interp_erai_dewt_1989_2009.pro $
 ;
 ; - fplod 20110808T094156Z cratos (Linux)
Index: /trunk/src/interp_erai_lwr_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_lwr_1989_2009.pro	(revision 87)
+++ /trunk/src/interp_erai_lwr_1989_2009.pro	(revision 88)
@@ -12,13 +12,21 @@
 ; Interpolation of str from ERA-I grid to OAFLUX grid
 ;
-; :file:`${PROJECT_ID}/20c3m_erai_str_TROP_1989_2009.nc` containing str from ERA-I have been produced
+; :file:`${PROJECT_ID}/20c3m_erai_str_TROP_1989_2009.nc` 
+; containing str from ERA-I 
+; have been produced
 ; by :ref:`compute_erai_daily_region_2d.sh`.
 ;
-; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid have been produced by :ref:`oaflux_mask_30N30S.pro`.
+; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` 
+; containing OAFLUX mask
+; have been produced by 
+; :ref:`oaflux_mask_30N30S.pro`.
 ;
 ; Interpolated str is written in
-; :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` if this file not already exists.
-;
-; This output file :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` must be processed after by :ref:`lwr_correction_ncdf.pro`.
+; :file:`${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc` 
+; if this file not already exists.
+;
+; This output file 
+; :file:`${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc` 
+; must be processed after by :ref:`add_198900101.sh`.
 ;
 ;     .. graphviz::
@@ -57,5 +65,5 @@
 ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
 ;
-; :ref:`lwr_correction_ncdf.pro`
+; :ref:`add_198900101.sh`
 ;
 ; EXAMPLES
@@ -94,4 +102,6 @@
 ; use real output of :ref:`compute_erai_daily_region_2d.sh`.
 ;
+; remove hard coded time
+;
 ; 19890101 is not provided in ERA-Intermim file str : a possible workaround is to copy 19890102
 ; dataset to 19890101 using nco after this processing. see :ref:`compute_erai_daily_region_2d.sh`
@@ -110,5 +120,10 @@
 ; $Id$
 ;
-; $URL$
+; $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/tropflux/svn/trunk/src/interp_erai_lwr_1989_2009.pro $
+;
+; - fplod 20110819T084310Z aedon.locean-ipsl.upmc.fr (Darwin)
+;
+;   * replace next step :ref:`lwr_correction_ncdf.pro` by :ref:`add_19890101.sh`
+;   * fix output file name to erai_lwr_19890102_20091231_oafluxgrid.nc
 ;
 ; - pinsard 2011-08-08T16:03:48Z loholt1.ipsl.polytechnique.fr (Linux)
@@ -227,5 +242,5 @@
 ;
 ; build output filename
-filename_out = 'erai_lwr_19890101_20091231_oafluxgrid.nc'
+filename_out = 'erai_lwr_19890102_20091231_oafluxgrid.nc'
 fullfilename_out = iodirout + filename_out
 ; in order to avoid unexpected overwritten
@@ -267,6 +282,4 @@
       , lonout,latout,method='bilinear' $
       , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout)
-  help, OUTMASK_IND
-  help, SET_OUTMSKVAL
   lwrout(*,*,jt)=lwrout(*,*,jt)*mskout+(1.-mskout)*1.e20
 
Index: /trunk/src/interp_erai_sst_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_sst_1989_2009.pro	(revision 87)
+++ /trunk/src/interp_erai_sst_1989_2009.pro	(revision 88)
@@ -99,5 +99,5 @@
 ; $Id$
 ;
-; $URL$
+; $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/tropflux/svn/trunk/src/interp_erai_sst_1989_2009.pro $
 ;
 ; - fplod 20110808T094156Z cratos (Linux)
Index: /trunk/src/interp_erai_t2m_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_t2m_1989_2009.pro	(revision 87)
+++ /trunk/src/interp_erai_t2m_1989_2009.pro	(revision 88)
@@ -121,5 +121,5 @@
 ; $Id$
 ;
-; $URL$
+; $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/tropflux/svn/trunk/src/interp_erai_t2m_1989_2009.pro $
 ;
 ; - pinsard 2011-08-08T16:11:48Z loholt1.ipsl.polytechnique.fr (Linux)
Index: /trunk/src/interp_erai_ws_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_ws_1989_2009.pro	(revision 87)
+++ /trunk/src/interp_erai_ws_1989_2009.pro	(revision 88)
@@ -106,5 +106,5 @@
 ; $Id$
 ;
-; $URL$
+; $URL: svn+ssh://pinsard@forge.ipsl.jussieu.fr/ipsl/forge/projets/tropflux/svn/trunk/src/interp_erai_ws_1989_2009.pro $
 ;
 ; - fplod 20110808T094156Z cratos (Linux)
Index: /trunk/src/lwr_correction_ncdf.pro
===================================================================
--- /trunk/src/lwr_correction_ncdf.pro	(revision 87)
+++ /trunk/src/lwr_correction_ncdf.pro	(revision 88)
@@ -9,8 +9,12 @@
 ; Correction of lwr on OAFLUX grid
 ;
-; :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` have been
-; produced by :ref:`interp_erai_lwr_1989_2009.pro`.
-;
-; Corrected lwr on OAFLUX grid is written in
+; :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` 
+; containing
+; ++
+; have been produced by 
+; :ref:`add_19890101.sh`.
+;
+; Corrected lwr on OAFLUX grid 
+; is written in
 ; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc`
 ; if this file not already exists.
@@ -21,7 +25,4 @@
 ;
 ;        digraph lwr_correction_ncdf {
-;           graph [
-;           rankdir="LR",
-;           ]
 ;
 ;           file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc"];
@@ -45,5 +46,5 @@
 ; :ref:`mooring_corrections`
 ;
-; :ref:`interp_erai_lwr_1989_2009.pro`
+; :ref:`add_19890101.sh`
 ;
 ; :func:`initncdf <saxo:initncdf>`
@@ -68,20 +69,7 @@
 ; lwr long name 'Air Temperature at 2m" : ???
 ;
-; 19890101 is not provided in ERA-Intermim file str : a possible workaround is
-; to copy 19890102
-; dataset to 19890101 using nco before processing.
-;
-; here is the sequence used by pk wher erai_lwr_19890102_20091231_oafluxgrid.nc is the regridded (interpolated output)
-; 
-;   $ ncks -d time,0,0 erai_lwr_19890102_20091231_oafluxgrid.nc erai_lwr_step0.nc
-;
-; This will combine the two files ::
-;
-;   $ ncrcat erai_lwr_step0.nc erai_lwr_19890102_20091231_oafluxgrid.nc erai_lwr_19890101_20091231_oafluxgrid.nc.
-;
-; must be put in a shell script or find IDL equivalent
-;
-; here I (fp) replace hard coded date 19890102 by 19890101. must check
-; consistency with this module and interp_erai_lwr_1989_2009.pro.
+; remove hard doded time
+;
+; add_19890101.sh sould not be the previous step in a near future
 ;
 ; KNOWN ISSUES
@@ -97,4 +85,10 @@
 ;
 ; $URL$
+;
+; - fplod 20110819T105050Z aedon.locean-ipsl.upmc.fr (Darwin)
+;
+;   * replace previous step :ref:`interp_erai_lwr_1989_2009.pro`
+;     by :ref:`add_19890101.sh`
+;   * change 19890102 to 19890101
 ;
 ; - fplod 20110808T120234Z cratos (Linux)
@@ -215,5 +209,5 @@
 lat=reform(gphit(0,0:jpj-1))
 lon=reform(glamt(0:jpi-1,0))
-time=timegen(7669, units='days', start=julday(1,2,1989)) & jpt=n_elements(time)
+time=timegen(7670, units='days', start=julday(1,1,1989)) & jpt=n_elements(time)
 
 cda0=string(jul2date(time(0)),format='(i8.8)')
Index: /trunk/src/paper01/fig7/air_validation_scatter_2000_2009_basin.pro
===================================================================
--- /trunk/src/paper01/fig7/air_validation_scatter_2000_2009_basin.pro	(revision 87)
+++ /trunk/src/paper01/fig7/air_validation_scatter_2000_2009_basin.pro	(revision 88)
@@ -12,5 +12,5 @@
 ;
 ;    digraph air_validation_scatter_2000_2009_basin {
-,
+;
 ;       air_erai [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/air_2000_2009_erai_*.txt"];
 ;       air_tropflux [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/air_2000_2009_trop_*.txt"];
Index: /trunk/src/qsee.pro
===================================================================
--- /trunk/src/qsee.pro	(revision 87)
+++ /trunk/src/qsee.pro	(revision 88)
@@ -1,3 +1,4 @@
-;--------------------------------------------------------
+;+
+;-
 function qsee, sst,Ps
 ;
@@ -5,5 +6,4 @@
 ; sst: SST (degC)
 ; Ps : surface pressure (mb)
-;--------------------------------------------------------
 x=sst
 p=Ps
@@ -14,3 +14,2 @@
 
 end
-;--------------------------------------------------------
