Changeset 17 for trunk/src


Ignore:
Timestamp:
12/17/10 11:00:48 (13 years ago)
Author:
pinsard
Message:

oaflux_mask_30N30S.pro no more hard coded directories

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/oaflux_mask_30N30S.pro

    r15 r17  
    77; ====================== 
    88; 
     9; Produce a NetCDF file with  OAFLUX mask over global tropical oceans  
     10; 
    911;     .. graphviz:: 
    1012; 
     
    1315;           rankdir="LR", 
    1416;           ] 
    15 ;           file_oaflux [shape=ellipse,fontname=Courier,label="/Volumes/vialardj/OAFLUX/lh_oaflux_2004.nc"]; 
    16 ;           mask [shape=ellipse,fontname=Courier,label="/Users/jv/data/OAFLUX/mask_oaflux_30N30S.nc"]; 
     17;           file_oaflux [shape=ellipse,fontname=Courier,label="${TROPFLUX_ID}/lh_oaflux_2004.nc"]; 
     18;           mask [shape=ellipse,fontname=Courier,label="${TROPFLUX_OD}/mask_oaflux_30N30S.nc"]; 
    1719; 
    1820;           oaflux_mask_30N30S [shape=box, 
     
    3133; :ref:`guide data OAFLUX <data_in_oaflux>` 
    3234; 
     35; :ref:`tropflux_profile.sh` 
     36; 
     37; :func:`report` 
     38; :func:`initncdf` 
     39; :func:`ncdf_lec` 
     40; :ref:`ncdf_quickwrite` 
     41; :func:`isadirectory` 
     42; 
    3343; EXAMPLES 
    3444; ======== 
     
    4151; ==== 
    4252; 
    43 ; hard coded directory - usage of ${TROPFLUX_ID} 
     53; SAXO new (keep compatibility false) 
    4454; 
    4555; coding rules 
    4656; 
     57; pro -> function 
     58; 
     59; NetCDF CF (may be area_type)  
     60;  
     61; global attributes corrections : 
     62;  - written now : OAFLUX mask over the Indian Ocean: 40E-120E, 30S-30N 
     63;  - while data latitude=[-29.5,+29.5] longitude=[30.5,379.5] 
     64; 
     65; KNOWN ISSUES 
     66; ============ 
     67; 
     68; test of existence of fullfilename_in not very efficient because 
     69; MUST_EXIST keyword of :func:`isafile` not yet implemented 
     70; 
    4771; EVOLUTIONS 
    4872; ========== 
     73; 
     74; - fplod 20101217T081915Z aedon.locean-ipsl.upmc.fr (Darwin) 
     75; 
     76;   * remove hard coded directory - usage of ${TROPFLUX_ID} and ${TROPFLUX_OD} 
     77;   * add IO test 
    4978; 
    5079; - fplod 20101216T141137Z aedon.locean-ipsl.upmc.fr (Darwin) 
     
    5988; 
    6089PRO oaflux_mask_30N30S 
    61  
     90; 
    6291@common 
    63  
    6492; 
    65 ;; Read oaflux grid and mask 
     93; check for input file 
    6694; 
    67 dir='/Volumes/vialardj/OAFLUX/' 
    68 dir='/Users/jv/data/OAFLUX/' 
    69  
    70 yy=2004 & cy=string(yy,format='(i4.4)') 
    71 fi=dir+'lh_oaflux_'+cy+'.nc' 
    72 initncdf, fi 
    73 lh=ncdf_lec(fi,var='lhtfl',count=[jpi,jpj,1]) & lh=float(lh) 
     95; test if ${TROPFLUX_ID} defined 
     96tropflux_id_env=GETENV('TROPFLUX_ID') 
     97CASE tropflux_id_env OF 
     98    ''  :  BEGIN 
     99     msg = 'eee : ${TROPFLUX_ID} is not defined' 
     100     ras = report(msg) 
     101     STOP 
     102           END 
     103 ELSE: BEGIN 
     104     msg = 'iii : ${TROPFLUX_ID} is ' + tropflux_id_env 
     105     ras = report(msg) 
     106       END 
     107ENDCASE 
     108; 
     109iodirin = isadirectory(tropflux_id_env) 
     110; 
     111; existence and protection of ${TROPFLUX_ID} 
     112IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN 
     113   msg = 'eee : the directory' + iodirin  + ' is not accessible.' 
     114   ras = report(msg) 
     115   STOP 
     116ENDIF 
     117; 
     118; build input filename 
     119yyyy=2004 
     120cy=string(yyyy,format='(i4.4)') 
     121filename_in='lh_oaflux_'+cy+'.nc' 
     122; 
     123; check if this file exists 
     124fullfilename_in = isafile(iodirin + filename_in, NEW=0, /MUST_EXIST) 
     125IF fullfilename_in[0] EQ '' THEN BEGIN 
     126   msg = 'eee : the file ' + fullfilename_in + ' was not found.' 
     127   ras = report(msg) 
     128   STOP 
     129ENDIF 
     130; 
     131; test if ${TROPFLUX_OD} defined 
     132tropflux_od_env=GETENV('TROPFLUX_OD') 
     133CASE tropflux_od_env OF 
     134  '' : BEGIN 
     135   msg = 'eee : ${TROPFLUX_OD} is not defined' 
     136   ras = report(msg) 
     137   STOP 
     138       END 
     139ELSE: BEGIN 
     140   msg = 'iii : ${TROPFLUX_OD} is ' + tropflux_od_env 
     141   ras = report(msg) 
     142        END 
     143ENDCASE 
     144; 
     145; check if output data will be possible 
     146iodirout = isadirectory(tropflux_od_env) 
     147; 
     148; existence and protection 
     149IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN 
     150   msg = 'eee : the directory' + iodirout  + ' was not found.' 
     151   ras = report(msg) 
     152   STOP 
     153ENDIF 
     154; 
     155fullfilename_out=iodirout+'mask_oaflux_30N30S.nc' 
     156; in order to avoid unexpected overwritten 
     157IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN 
     158   msg = 'eee : the file ' + fullfilename_out  + ' already exists.' 
     159   ras = report(msg) 
     160   STOP 
     161ENDIF 
     162; 
     163; Read oaflux grid and mask 
     164initncdf, fullfilename_in 
     165lh=ncdf_lec(fullfilename_in,var='lhtfl',count=[jpi,jpj,1]) & lh=float(lh) 
    74166valmask=1.e20 
    75167ind=where(lh ge 32000,compl=nind) & lh(ind)=valmask & lh(nind)=-0.1*lh(nind) 
     
    88180 
    89181 
    90 ncfile='!'+dir+'mask_oaflux_30N30S.nc' 
     182ncfile='!'+fullfilename_out 
    91183lon_attr={units:'degrees_east',long_name:'Longitude'} 
    92184lat_attr={units:'degrees_north',long_name:'Latitude'} 
Note: See TracChangeset for help on using the changeset viewer.