Index: /trunk/src/TropFlux_19890101_20091231.pro
===================================================================
--- /trunk/src/TropFlux_19890101_20091231.pro	(revision 152)
+++ /trunk/src/TropFlux_19890101_20091231.pro	(revision 153)
@@ -18,5 +18,5 @@
 ; OAFLUX grid
 ; has been produced by
-; :ref:`oaflux_mask_30N30S.pro`.
+; :func:`oaflux_mask_30n30s`.
 ;
 ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc`
Index: /trunk/src/interp_erai_dewt_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_dewt_1989_2009.pro	(revision 152)
+++ /trunk/src/interp_erai_dewt_1989_2009.pro	(revision 153)
@@ -21,5 +21,5 @@
 ; containing OAFLUX grid
 ; has been produced by
-; :ref:`oaflux_mask_30N30S.pro`.
+; :func:`oaflux_mask_30n30s.pro`.
 ;
 ; Interpolated d2
Index: /trunk/src/interp_erai_lwr_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_lwr_1989_2009.pro	(revision 152)
+++ /trunk/src/interp_erai_lwr_1989_2009.pro	(revision 153)
@@ -20,5 +20,5 @@
 ; containing OAFLUX mask
 ; has been produced by
-; :ref:`oaflux_mask_30N30S.pro`.
+; :func:`oaflux_mask_30n30s`.
 ;
 ; Interpolated str
@@ -147,5 +147,4 @@
 ;   * fix typo
 ;     .. note::
-;
 ;        IDL do not warn when asking size of an undefined array::
 ;
Index: /trunk/src/interp_erai_msl_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_msl_1989_2009.pro	(revision 152)
+++ /trunk/src/interp_erai_msl_1989_2009.pro	(revision 153)
@@ -22,5 +22,5 @@
 ; OAFLUX grid
 ; has been produced by
-; :ref:`oaflux_mask_30N30S.pro`.
+; :func:`oaflux_mask_30n30s`.
 ;
 ; Interpolated msl
Index: /trunk/src/interp_erai_sst_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_sst_1989_2009.pro	(revision 152)
+++ /trunk/src/interp_erai_sst_1989_2009.pro	(revision 153)
@@ -21,5 +21,5 @@
 ; OAFLUX grid
 ; has been produced by
-; :ref:`oaflux_mask_30N30S.pro`.
+; :func:`oaflux_mask_30n30s`.
 ;
 ; Interpolated sst
Index: /trunk/src/interp_erai_t2m_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_t2m_1989_2009.pro	(revision 152)
+++ /trunk/src/interp_erai_t2m_1989_2009.pro	(revision 153)
@@ -21,5 +21,5 @@
 ; containing OAFLUX grid
 ; has been produced by
-; :ref:`oaflux_mask_30N30S.pro`.
+; :func:`oaflux_mask_30n30s`.
 ;
 ; Interpolated t2
@@ -66,5 +66,5 @@
 ; :ref:`compute_erai_daily_region_2d.sh`
 ;
-; :ref:`oaflux_mask_30N30S.pro`
+; :func:`oaflux_mask_30n30s`
 ;
 ; :func:`report <saxo:report>`
Index: /trunk/src/interp_erai_ws_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_ws_1989_2009.pro	(revision 152)
+++ /trunk/src/interp_erai_ws_1989_2009.pro	(revision 153)
@@ -27,5 +27,5 @@
 ; containing OAFLUX grid
 ; has been produced by
-; :ref:`oaflux_mask_30N30S.pro`.
+; :func:`oaflux_mask_30n30s.pro`.
 ;
 ; Interpolated u10 and v10 are written in
Index: /trunk/src/interp_olr_30n30s_1989_2009.pro
===================================================================
--- /trunk/src/interp_olr_30n30s_1989_2009.pro	(revision 152)
+++ /trunk/src/interp_olr_30n30s_1989_2009.pro	(revision 153)
@@ -18,5 +18,5 @@
 ; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid
 ; have been produced by
-; :ref:`oaflux_mask_30N30S.pro`.
+; :func:`oaflux_mask_30n30s`.
 ;
 ; Interpolated OLR is written in
Index: /trunk/src/oaflux_mask_30n30s.pro
===================================================================
--- /trunk/src/oaflux_mask_30n30s.pro	(revision 152)
+++ /trunk/src/oaflux_mask_30n30s.pro	(revision 153)
@@ -1,9 +1,12 @@
 ;+
 ;
-; .. _oaflux_mask_30n30s.pro:
-;
 ; ======================
-; oaflux_mask_30n30s.pro 
+; oaflux_mask_30n30s.pro
 ; ======================
+;
+; .. function:: oaflux_mask_30n30s()
+;
+; DESCRIPTION
+; ===========
 ;
 ; Produce a NetCDF file with OAFLUX mask over global tropical oceans (30N-30S)
@@ -33,4 +36,7 @@
 ;      }
 ;
+; :returns: 0 if ok,  -1 if error
+; :rtype: integer
+;
 ; SEE ALSO
 ; ========
@@ -40,23 +46,26 @@
 ; :ref:`guide data OAFLUX <data_in_oaflux>`
 ;
-; :ref:`project_profile.sh`
-; :ref:`project_init.pro`
+; Environement :
+; :ref:`project_profile.sh`, 
+; :ref:`project_init.pro`,
 ; :ref:`cm_project.pro`
 ;
-; :ref:`get_oaflux.sh`
-;
-; :func:`report <saxo:report>`
-; :func:`initncdf <saxo:initncdf>`
-; :func:`ncdf_lec <saxo:ncdf_lec>`
-; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`
-; :func:`isadirectory <saxo:isadirectory>`
+; Previous step : :ref:`get_oaflux.sh`
+;
+; Use :
+; :func:`report <saxo:report>`,
+; :func:`initncdf <saxo:initncdf>`,
+; :func:`ncdf_lec <saxo:ncdf_lec>`,
+; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>`,
+; :func:`isadirectory <saxo:isadirectory>`,
 ; :func:`isafile <saxo:isafile>`
 ;
-; :ref:`TropFlux_19890101_20091231.pro`
-; :ref:`interp_erai_dewt_1989_2009.pro`
-; :ref:`interp_erai_lwr_1989_2009.pro`
-; :ref:`interp_erai_sst_1989_2009.pro`
-; :ref:`interp_erai_t2m_1989_2009.pro`
-; :ref:`interp_erai_ws_1989_2009.pro`
+; Following program use :func:`oaflux_mask_30n30s` output:
+; :ref:`TropFlux_19890101_20091231.pro`,
+; :ref:`interp_erai_dewt_1989_2009.pro`,
+; :ref:`interp_erai_lwr_1989_2009.pro`,
+; :ref:`interp_erai_sst_1989_2009.pro`,
+; :ref:`interp_erai_t2m_1989_2009.pro`,
+; :ref:`interp_erai_ws_1989_2009.pro`,
 ; :ref:`interp_olr_30n30s_1989_2009.pro`
 ;
@@ -66,5 +75,5 @@
 ; ::
 ;
-;  IDL> oaflux_mask_30n30s
+;  IDL> result = oaflux_mask_30n30s()
 ;
 ; TODO
@@ -74,6 +83,4 @@
 ;
 ; coding rules
-;
-; pro -> function
 ;
 ; NetCDF CF (may be area_type)
@@ -83,4 +90,6 @@
 ;  - while data latitude=[-29.5,+29.5] longitude=[30.5,379.5]
 ;
+; 30n30s in name vs future global output ... parameters lat and long max
+;
 ; KNOWN ISSUES
 ; ============
@@ -91,6 +100,12 @@
 ; EVOLUTIONS
 ; ==========
-; 
+;
 ; $Id$
+;
+; $URL$
+;
+; - fplod 20120305
+;
+;   * pro -> function
 ;
 ; - fplod 20110411T140133Z aedon.locean-ipsl.upmc.fr (Darwin)
@@ -98,5 +113,5 @@
 ;   * usage of tropflux_init and cm_project
 ;   * replace 30N30S by 30n30s
-; 
+;
 ; - fplod 20101217T081915Z aedon.locean-ipsl.upmc.fr (Darwin)
 ;
@@ -114,5 +129,5 @@
 ;-
 ;
-PRO oaflux_mask_30n30s
+FUNCTION oaflux_mask_30n30s
 ;
 @cm_4cal
@@ -122,4 +137,18 @@
 @cm_project
 
+; Return to caller if errors
+on_error, 2
+;
+result = -1
+;
+usage = 'result=oaflux_mask_30n30s()'
+nparam = N_PARAMS()
+IF (nparam NE 0) THEN BEGIN
+   ras = report(['Incorrect number of arguments.' $
+         + '!C' $
+	 + 'Usage : ' + usage])
+   return, -1
+ENDIF
+;
 ; check for input file
 ; build input filename
@@ -133,5 +162,5 @@
    msg = 'eee : the file ' + fullfilename_in + ' was not found.'
    ras = report(msg)
-   STOP
+   return, -1
 ENDIF
 ;
@@ -141,14 +170,14 @@
    msg = 'eee : the file ' + fullfilename_out  + ' already exists.'
    ras = report(msg)
-   STOP
+   return, -1
 ENDIF
 ;
 ; Read oaflux grid and mask
 initncdf, fullfilename_in
-lh=ncdf_lec(fullfilename_in,var='lhtfl',count=[jpi,jpj,1]) 
+lh=ncdf_lec(fullfilename_in,var='lhtfl',count=[jpi,jpj,1])
 lh=float(lh)
 valmask=1.e20
-ind=where(lh ge 32000,compl=nind) 
-lh(ind)=valmask 
+ind=where(lh ge 32000,compl=nind)
+lh(ind)=valmask
 lh(nind)=-0.1*lh(nind)
 mask_out=(lh ne valmask)
@@ -178,3 +207,6 @@
 @ncdf_quickwrite
 
+result = 0
+
+return, result
 END
Index: /trunk/src/tropflux.sh
===================================================================
--- /trunk/src/tropflux.sh	(revision 152)
+++ /trunk/src/tropflux.sh	(revision 153)
@@ -1,3 +1,3 @@
-#! /bin/sh -x
+#! /bin/sh
 #+
 #
@@ -43,4 +43,6 @@
 #        digraph tropflux {
 #
+#           file_oaflux [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/lh_oaflux_2004.nc"];
+
 #           log [shape=ellipse,fontname=Courier,label="${PROJECT_LOG}/tropflux.log{YYYYMMDDTHHMMSSZ}"];
 #
@@ -51,5 +53,5 @@
 #           label="${PROJECT}/src/tropflux.sh"];
 #
-#           {++ mask} -> {tropflux} -> {log ++}
+#           {file_oaflux} -> {tropflux} -> {log fileout}
 #
 #         }
@@ -83,5 +85,5 @@
 #
 # Use :
-# :ref:`inter_erai_t2m_1989_2009.pro`, etc.
+# :func:`oaflux_mask_30n30s`, :ref:`inter_erai_t2m_1989_2009.pro`, etc.
 #
 # Next step : +validation ++ comparison
@@ -108,4 +110,5 @@
 #
 #   * creation (draft)
+#   * handling error of oaflux_mask_30n30s (now a function)
 #
 #-
@@ -265,5 +268,10 @@
 cat >> ${PROJECT}/src/tropflux_${$}.pro << EOF
 .compile file_interp
-;oaflux_mask_30n30s
+result = oaflux_mask_30n30s()
+if (result NE 0) THEN BEGIN
+   msg = 'eee : pb after oaflux_mask_30n30s'
+   err = report(msg)
+   exit
+ENDIF
 ;interp_erai_dewt_1989_2009
 ;interp_erai_lwr_1989_2009
@@ -273,5 +281,7 @@
 ;interp_erai_ws_1989_2009
 ;interp_olr_30n30s_1989_2009
-;d2m_to_q2m_erai
+d2m_to_q2m_erai 
+;++Program caused arithmetic error: Floating overflow
+;++ Program caused arithmetic error: Floating illegal operand
 .compile TropFlux_swr_DT_19890101_20071231
 tropflux_swr_dt_19890101_20071231
@@ -290,8 +300,6 @@
 .compile TropFlux_NRT_ncdf
 tropflux_nrt_ncdf
+exit
 EOF
-#
-more ${PROJECT}/src/tropflux_${$}.pro
-read a
 #
 # run IDL or equivalent
