Index: /trunk/src/compute_erai_daily_region_2d.sh
===================================================================
--- /trunk/src/compute_erai_daily_region_2d.sh	(revision 25)
+++ /trunk/src/compute_erai_daily_region_2d.sh	(revision 26)
@@ -109,4 +109,10 @@
 # :func:`ncea <nco:ncea>`
 # :func:`ncflint <nco:ncflint>`
+#
+# :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`
 #
 # TODO
Index: /trunk/src/interp_erai_t2m_1989_2009.pro
===================================================================
--- /trunk/src/interp_erai_t2m_1989_2009.pro	(revision 25)
+++ /trunk/src/interp_erai_t2m_1989_2009.pro	(revision 26)
@@ -3,8 +3,17 @@
 ; .. _interp_erai_t2m_1989_2009.pro:
 ;
-; =============================
-; interp_erai_t2m_1989_2009.pro
-; =============================
-;
+; ==================================================================================
+; interp_erai_t2m_1989_2009.pro - Interpolation of t2 from ERA-I grid to OAFLUX grid
+; ==================================================================================
+;
+; Interpolation of t2 from ERA-I grid to OAFLUX grid
+;
+; :file:`${TROPFLUX_ID}/20c3m_erai_t2_TROP_1989_2009.nc` containing t2 from ERA-I have been produced
+; by :ref:`compute_erai_daily_region_2d.sh`.
+;
+; :file:`${TROPFLUX_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid have been produced by :ref:`oaflux_mask_30N30S.pro`.
+;
+; Interpolated t2 is written in
+; :file:`${TROPFLUX_OD}/erai_t2m_19890101_20091231_oafluxgrid.nc` if this file not already exists.
 ;
 ;     .. graphviz::
@@ -17,5 +26,5 @@
 ;           mask [shape=ellipse,fontname=Courier,label="${TROPFLUX_ID}/mask_oaflux_30N30S.nc"];
 ;
-;           ncfile [shape=ellipse,fontname=Courier,label="/Volumes/PRAVEEN/TropFlux/input_uncor/erai_t2m_19890101_20091231_oafluxgrid.nc"];
+;           ncfile [shape=ellipse,fontname=Courier,label="${TROPFLUX_OD}/erai_t2m_19890101_20091231_oafluxgrid.nc"];
 ;
 ;           interp_erai_t2m_1989_2009 [shape=box,
@@ -37,4 +46,8 @@
 ; :ref:`tropflux_profile.sh`
 ;
+; :ref:`compute_erai_daily_region_2d.sh`
+;
+; :ref:`oaflux_mask_30N30S.pro`
+;
 ; :func:`report <saxo:report>`
 ; :func:`isadirectory <saxo:isadirectory>`
@@ -42,4 +55,5 @@
 ; :func:`initncdf <saxo:initncdf>`
 ; :func:`read_ncdf <saxo:read_ncdf>`
+; :func:`ncdf_lec <saxo:ncdf_lec>`
 ; :func:`domdef <saxo:domdef>`
 ; :func:`call_interp2d <saxo:call_interp2d>`
@@ -60,17 +74,20 @@
 ; make it work !!
 ;
-; now (20101222) : 
-;  - /usr/work/incas/fplod/tropflux_d/20c3m_erai_t2_TROP_1989_2009.nc as no time axis variable
-;  - Value of Julian date is out of allowed range
-;  - % Array used to subscript array contains out of range subscript: DATAIN
+; strange view (lat and lon shift with ncview) : check grid init
+;
+; remove useless netcdf_read
+;
+; check time values
 ;
 ; why use :func:`call_interp2d <saxo:call_interp2d>` : this is an hidden function of SAXO
 ; see :func:`file_interp <saxo:file_interp>`
 ;
-; hard coded directory - usage of ${TROPFLUX_ID}
-;
 ; use as input a file produced by compute_erai_daily_region_2d.sh
 ;
 ; coding rules
+;
+; hard coded time in module name and in code
+;
+; why two "initncdf, fullfilename_msk"
 ;
 ; KNOWN ISSUES
@@ -82,4 +99,29 @@
 ; EVOLUTIONS
 ; ==========
+;
+; - fplod 20101223T130406Z aedon.locean-ipsl.upmc.fr (Darwin)
+;
+;    * replace /Volumes/PRAVEEN/TropFlux/input_uncor/ by ${TROPFLUX_OD}
+;    * complete documentation
+;    * get time dimension in data file
+;    * replace read_ncdf by ncdf_lec
+;
+;      usage of timestep keyword in read_ncdf was not efficient because of  memory problem :
+;      can not read the whole time range (ok with 7580, not ok with 7591 while need is 7670
+;      ::
+;
+;        % Unable to allocate memory: to make array.
+;        Cannot allocate memory
+;
+;
+;      When timestep keyword is not used we can see these messages::
+;
+;         /usr/work/incas/fplod/tropflux_d/20c3m_erai_t2_TROP_1989_2009.nc as no time axis variable
+;         given by Praveen
+;
+;         Value of Julian date is out of allowed range
+;
+;         % Array used to subscript array contains out of range subscript: DATAIN
+;
 ;
 ; - fplod 20101222T163216Z aedon.locean-ipsl.upmc.fr (Darwin)
@@ -154,20 +196,71 @@
 ENDIF
 ;
+; test if ${TROPFLUX_OD} defined
+tropflux_od_env=GETENV('TROPFLUX_OD')
+CASE tropflux_od_env OF
+  '' : BEGIN
+         msg = 'eee : ${TROPFLUX_OD} is not defined'
+         ras = report(msg)
+       STOP
+       END
+  ELSE: BEGIN
+          msg = 'iii : ${TROPFLUX_OD} is ' + tropflux_od_env
+          ras = report(msg)
+        END
+ ENDCASE
+;
+; check if output data will be possible
+iodirout = isadirectory(tropflux_od_env)
+;
+; existence and protection
+IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN
+    msg = 'eee : the directory' + iodirout  + ' was not found.'
+    ras = report(msg)
+    STOP
+ENDIF
+;
+; build output filename
+filename_out = 'erai_t2m_19890101_20091231_oafluxgrid.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
+;
+; define grid parameters with t2 file
 initncdf, fullfilename_t2
 domdef
 latin=reform(gphit(0,*)) & lonin=reform(glamt(*,0))
-print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0)
-print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0)
-t2min=read_ncdf("t2",19880101,20100930,file=fullfilename_t2,/nostr)
-
-timein=time & jptin=jpt
+print, 'lat grid from data',min(latin),max(latin),latin(1)-latin(0)
+print, 'lon grid from data',min(lonin),max(lonin),lonin(1)-lonin(0)
+;
+; get the number of time step in t2 file
+time_in_step=ncdf_lec(fullfilename_t2,var='time')
+ntt=n_elements(time_in_step)
+print, 'time steps from data ', ntt
+print, 'The first 10 time values (variable time_in_step) = ', time_in_step[0:9]
+;
+; read t2 data
+;++ pb memory t2min=read_ncdf("t2",0,ntt-1,/timestep,file=fullfilename_t2,/nostr)
+; the following line is here just to prepare replacement of read_ncdf by ncdf_lec
+t2min_read_ncdf=read_ncdf("t2",0,10,/timestep,file=fullfilename_t2,/nostr)
+help, t2min_read_ncdf
+;++print, 'The first 10 time values (variable time) = ', time[0:9]
+;++print, 'time steps after read_ncdf (variable jpt) ', jpt
+t2min=ncdf_lec(fullfilename_t2,var='t2')
+help, t2min
+;
+timein=time & jptin=ntt
 tab=t2min(*,*,0)
 mskin=glamt*0.+1.
 
+; define grid parameters with mask file
 initncdf, fullfilename_msk
 domdef
 latout=reform(gphit(0,*)) & lonout=reform(glamt(*,0))
-print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0)
-print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0)
+print, 'lat grid from mask ',min(latout),max(latout),latout(1)-latout(0)
+print, 'lon grid from mask ',min(lonout),max(lonout),lonout(1)-lonout(0)
 mskout=read_ncdf("msk", file=fullfilename_msk,/nostr)
 
@@ -176,5 +269,4 @@
 t2mout=fltarr(jpi,jpj,jptin)
 for jt=0,jptin-1 do begin
-  print, 'Interpolation jt=',jt,' / ',jptin-1
   tab=reform(t2min(*,*,jt))
   t2mout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin,lonout,latout,method='bilinear')
@@ -182,13 +274,12 @@
 endfor
 
-timein=timein & jptin=jpt
-
 initncdf, fullfilename_msk
 help, t2mout
 tt=timein
-time=julday(1,1,1989)+lindgen(7670)+0.5 & jpt=n_elements(time)
-;cda0=string(jul2date(time(0)),format='(i8.8)')
+time=julday(1,1,1989)+lindgen(ntt)+0.5 & jpt=n_elements(time)
+help, time
+;cda0=string(jul2date(time[0]),format='(i8.8)')
 ;cda1=string(jul2date(time(jpt-1)),format='(i8.8)')
-;cda0=string('19890101') & cda1=string('20091231')
+cda0=string('19890101') & cda1=string('20091231')
 
 timein=time-julday(1,1,1950,00,00)
@@ -196,5 +287,6 @@
 lat=latout
 lon=lonout
-ncfile='!/Volumes/PRAVEEN/TropFlux/input_uncor/erai_t2m_19890101_20091231_oafluxgrid.nc'
+ncfile='!' + fullfilename_out
+print, 'ncfile ', ncfile
 lon_attr={units:'degrees_east',long_name:'Longitude'}
 lat_attr={units:'degrees_north',long_name:'Latitude'}
