Changeset 48


Ignore:
Timestamp:
03/16/14 20:38:39 (10 years ago)
Author:
pinsard
Message:

fix thanks to coding rules

Location:
trunk
Files:
45 edited

Legend:

Unmodified
Added
Removed
  • trunk/FIG_bar_transp_write.pro

    r2 r48  
    1 PRO FIG_bar_transp_write,iyear,ian  
     1PRO FIG_bar_transp_write,iyear,ian 
    22@init2 
    33@initorca2_bab 
     
    1515;e_year0='10' 
    1616key_portrait = 0 
    17 ; stockage des fichiers brut  
     17; stockage des fichiers brut 
    1818  ioDATA='/usr/work/sur/fvi/OPA/ORCA2/'+e_exp 
    19   file_U=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_U.nc'  
     19  file_U=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_U.nc' 
    2020  print, file_U 
    21   file_V=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_V.nc'  
     21  file_V=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_V.nc' 
    2222  print, file_V 
    2323 
     
    2727     t_bt  = 'bar_transp' 
    2828ioORLN2 = '/usr/work/sur/fvi/OPA/ORCA2' 
    29 ;facteur d'echelle vertical  for partial steps 
     29;facteur d'echelle vertical for partial steps 
    3030e3v3d=read_ncdf('e3v_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
    3131e3u3d=read_ncdf('e3u_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
     
    3434 
    3535; vertical integration: 
    36 e3t3d=make_array(jpi,jpj,jpk)    
     36e3t3d=make_array(jpi,jpj,jpk) 
    3737        for k=0, jpk-1 do begin              &$ 
    38           for j=0,jpj-1 do begin              &$       
     38          for j=0,jpj-1 do begin              &$ 
    3939            for i=0,jpi-1 do begin             &$ 
    4040              e3t3d(i,j,k) = e3t(k)    &$ 
     
    4444jpt = 73 
    4545 
    46 ;vud = make_array(jpi,jpj,jpt)    
     46;vud = make_array(jpi,jpj,jpt) 
    4747;vvd = make_array(jpi, jpj, jpt) 
    4848 
    49 ; ouverture des fichiers dans lesquels on va écrire  
     49; ouverture des fichiers dans lesquels on va écrire 
    5050id3=NCDF_OPEN('/usr/work/sur/fvi/geomag/U_5d_'+iyear+'_grid_T.nc',/write) 
    5151id4=NCDF_OPEN('/usr/work/sur/fvi/geomag/V_5d_'+iyear+'_grid_T.nc',/write) 
    5252 
    53 FOR jt = 0, jpt-1 DO BEGIN &$    
     53FOR jt = 0, jpt-1 DO BEGIN &$ 
    5454 
    5555; ouverture des fichiers et stockage en memoire partial steps 
    56   vu=read_ncdf('vozocrtx',jt,jt, /timestep, iodir=ioDATA,/nostruct,/TOUT,filename=file_U)  &$    
    57   vv=read_ncdf('vomecrty',jt,jt, /timestep,iodir=ioDATA,/nostruct,/TOUT,filename=file_V)  &$    
     56  vu=read_ncdf('vozocrtx',jt,jt, /timestep, iodir=ioDATA,/nostruct,/TOUT,filename=file_U)  &$ 
     57  vv=read_ncdf('vomecrty',jt,jt, /timestep,iodir=ioDATA,/nostruct,/TOUT,filename=file_V)  &$ 
    5858 
    59    
     59 
    6060 
    6161; Somme sur la verticale partial steps 
    62                 vum=total( vu*e3u3d*umask(),3 )  &$    
    63                 vvm=total( vv*e3v3d*vmask(),3 )  &$    
     62                vum=total( vu*e3u3d*umask(),3 )  &$ 
     63                vvm=total( vv*e3v3d*vmask(),3 )  &$ 
    6464 
    6565; Shit sur la grille T partial steps 
    66              vut= (vum+shift(vum,1,0) )*0.5   &$    
     66             vut= (vum+shift(vum,1,0) )*0.5   &$ 
    6767             vvt= (vvm+shift(vvm,0,1) )*0.5   &$ 
    68 ; Bande de recouvrement  
     68; Bande de recouvrement 
    6969             vut(0, *) = vut(jpi-2, *) 
    7070             vvt(*, 0) = 0. 
    71 ; stockage dans le fichier de sortie  
     71; stockage dans le fichier de sortie 
    7272NCDF_VARPUT, id3,'sossheig',vut, offset = [0, 0, jt] 
    7373NCDF_VARPUT, id4,'sossheig',vvt, offset = [0, 0, jt] 
     
    7575print,  jt 
    7676 
    77 ENDFOR   
     77ENDFOR 
    7878; on ferme le NetCDF 
    7979NCDF_CLOSE,id3 
     
    107107;    tidout = NCDF_DIMDEF(idout, 'time_counter', /unlimited) 
    108108 
    109     
     109 
    110110; Attributs globaux 
    111111;    id0  = NCDF_VARDEF(idout, 'nav_lon'     , [xidout, yidout                ], /FLOAT) 
     
    141141;    NCDF_ATTPUT, idout, id5, 'title', 'vomecrty' 
    142142;    NCDF_ATTPUT, idout, id5, 'long_name', 'meridian current summmed on vertical' 
    143   
     143 
    144144;    NCDF_CONTROL, idout, /ENDEF 
    145145 
     
    148148; Creation de la latitude 
    149149;    NCDF_VARPUT, idout, id1, gphit 
    150 ; Creation de la profondeur  
     150; Creation de la profondeur 
    151151;    prof=1. 
    152 ;    NCDF_VARPUT, idout, id2, prof  
     152;    NCDF_VARPUT, idout, id2, prof 
    153153; Creation du calendrier 
    154154;   temps = findgen(jpt)*5.*86400. +julday(1, 1, 1) 
     
    158158;    NCDF_VARPUT, idout, id3, temps 
    159159 
    160     
     160 
    161161; Ecriture des donnees 
    162162 
  • trunk/INTERP2/check_inside.pro

    r2 r48  
    9393 
    9494result= where( ( (AB_Vect_BP LE 0.) AND (BC_Vect_CP LE 0.) AND (CD_Vect_DP LE 0.) AND (DA_Vect_AP LE 0.) ) OR      $ 
    95                ( (AB_Vect_BP GE 0.) AND (BC_Vect_CP GE 0.) AND (CD_Vect_DP GE 0.) AND (DA_Vect_AP GE 0.) )  )                         
     95               ( (AB_Vect_BP GE 0.) AND (BC_Vect_CP GE 0.) AND (CD_Vect_DP GE 0.) AND (DA_Vect_AP GE 0.) )  ) 
    9696 
    9797 
  • trunk/INTERP2/init_path2.pro

    r2 r48  
    3838 
    3939; 
    40 ; 2. Input information  
     40; 2. Input information 
    4141; ==================== 
    4242; 
     
    4444;  ------------------- 
    4545; 
    46   
     46 
    4747 
    4848   datafile = 'ForcageMOED_5d_1993_grid_T.nc' 
     
    6161 
    6262; 
    63 ; 3. Output information   
     63; 3. Output information 
    6464; ===================== 
    6565; 
     
    8282; 
    8383;;;;   outputfile = 'DivBustar_5d_1998_reg.nc' 
    84   
     84 
    8585 
    8686; 
     
    9090 
    9191   errorfile='error_wT' 
    92     
     92 
    9393;*************** END OF USER'S PART ******************* 
    9494;********DO NOT MODIFY ANYTHING BELLOW THIS LINE******* 
  • trunk/INTERP2/initorca.pro

    r2 r48  
    1 ; 
    21; 
    32@common 
  • trunk/INTERP2/initorca_grand.pro

    r2 r48  
    1 ; 
    2 ; 
    31@common 
    42@init_path2 
  • trunk/INTERP2/initorca_reg.pro

    r2 r48  
    1 ; 
    2 ; 
    31@common 
    42@init_path2 
  • trunk/INTERP2/interp2.pro

    r2 r48  
    1313; 
    1414; INPUTS : 
    15 ;         A full ORCA grid file + a 1D or 2D field on this grid  
     15;         A full ORCA grid file + a 1D or 2D field on this grid 
    1616; OUTPUTS : 
    1717;        - A grid file for the geographical equivalent to the given 
    18 ;         ORCA grid    
     18;         ORCA grid 
    1919;        - The interpolated field on this new grid + the weights and 
    2020;          pointers required to creat it. 
     
    7575 
    7676end 
    77  
    78  
  • trunk/INTERP2/make_geogrid.pro

    r2 r48  
    5353; Output values are set to input values 
    5454 
    55   glamt_reg=glamt 
    56   glamu_reg=glamu 
    57   glamv_reg=glamv 
    58   glamf_reg=glamf 
    59  
    60   gphit_reg=gphit 
    61   gphiu_reg=gphiu 
    62   gphiv_reg=gphiv 
    63   gphif_reg=gphif 
    64  
    65   e1t_reg=e1t 
    66   e1u_reg=e1u 
    67   e1v_reg=e1v 
    68   e1f_reg=e1f 
    69  
    70   e2t_reg=e2t 
    71   e2u_reg=e2u 
    72   e2v_reg=e2v 
    73   e2f_reg=e2f 
    74    
    75   tmask_reg=tmask 
    76   umask_reg=tmask 
    77   vmask_reg=tmask 
    78   fmask_reg=tmask 
     55glamt_reg=glamt 
     56glamu_reg=glamu 
     57glamv_reg=glamv 
     58glamf_reg=glamf 
     59 
     60gphit_reg=gphit 
     61gphiu_reg=gphiu 
     62gphiv_reg=gphiv 
     63gphif_reg=gphif 
     64 
     65e1t_reg=e1t 
     66e1u_reg=e1u 
     67e1v_reg=e1v 
     68e1f_reg=e1f 
     69 
     70e2t_reg=e2t 
     71e2u_reg=e2u 
     72e2v_reg=e2v 
     73e2f_reg=e2f 
     74 
     75tmask_reg=tmask 
     76umask_reg=tmask 
     77vmask_reg=tmask 
     78fmask_reg=tmask 
    7979 
    8080 
     
    9696; Let's get the reference longitude 
    9797 
    98 equador=where(abs(gphit) EQ  min(abs(gphit)) ) 
     98equador=where(abs(gphit) EQ min(abs(gphit)) ) 
    9999 
    100100ref_longitude=glamt(equador) 
     
    171171 
    172172;************************************************ 
    173 ;  2nd STEP : Define the mask of the outpût grid 
     173;  2nd STEP : Define the mask of the outpût grid 
    174174;************************************************ 
    175175 
     
    188188; to avoid any problem 
    189189 
    190 sph_coord(2,jpj*jpi-1-jpi/2:jpj*jpi-1)=10.  
     190sph_coord(2,jpj*jpi-1-jpi/2:jpj*jpi-1)=10. 
    191191 
    192192sph_coord(0,*)=reform(glamt,jpi*jpj) 
     
    196196 
    197197xx_grid=rec_grid(0,*) 
    198 yy_grid=rec_grid(1,*)    
     198yy_grid=rec_grid(1,*) 
    199199zz_grid=rec_grid(2,*) 
    200    
     200 
    201201 
    202202not_found=1 
    203203for jj=0, jpj-1 do begin 
    204204 
    205    lat_max_ORCA=max( gphit(*,jj)     ) 
    206    lat_max_reg =max( gphit_reg(*,jj) ) 
    207  
    208  
    209    if ((lat_max_ORCA NE lat_max_reg) AND (not_found EQ 1)) then begin 
     205lat_max_ORCA=max( gphit(*,jj)     ) 
     206lat_max_reg =max( gphit_reg(*,jj) ) 
     207 
     208 
     209if ((lat_max_ORCA NE lat_max_reg) AND (not_found EQ 1)) then begin 
    210210   jpj_start=jj-2 
    211211   not_found=0 
    212    endif 
     212endif 
    213213 
    214214end 
     
    220220for jj=jpj/2,jpj-1 do begin 
    221221    for ji=0,jpi-1 do begin 
    222     
     222 
    223223 
    224224; Coordinates of our point 
     
    226226    xx=glamt_reg(ji,jj) 
    227227    yy=gphit_reg(ji,jj) 
    228     
     228 
    229229    sph_coord=replicate(1.,3) 
    230230    sph_coord(0)=xx 
    231231    sph_coord(1)=yy 
    232232 
    233 ; Convert them into cartesian  
    234      
     233; Convert them into cartesian 
     234 
    235235    rec_coord=cv_coord(/DEGREES,FROM_SPHERE=sph_coord,/TO_RECT) 
    236236 
     
    242242                +(yy_grid-yy_bis)*(yy_grid-yy_bis)  $ 
    243243                +(zz_grid-zz_bis)*(zz_grid-zz_bis)) 
    244      
     244 
    245245 
    246246    sort_mod=where(modules EQ min(modules)) 
    247247 
    248     answj=sort_mod(0)/jpi    
     248    answj=sort_mod(0)/jpi 
    249249 
    250250    answi=sort_mod(0)-answj*jpi 
     
    252252 
    253253    mask_reg(ji,jj,*)=tmask(answi,answj,*) 
    254      
    255   
     254 
     255 
    256256    endfor 
    257257endfor 
     
    265265; Create Global Mask file for T point 
    266266 
    267     tmask_reg_glo=replicate(0.,jpiglo,jpjglo,jpk) 
    268  
    269     tmask_reg_glo(1:jpiglo-2,0:jpjglo-2, *)=mask_reg 
     267tmask_reg_glo=replicate(0.,jpiglo,jpjglo,jpk) 
     268 
     269tmask_reg_glo(1:jpiglo-2,0:jpjglo-2, *)=mask_reg 
    270270 
    271271 
     
    274274; North 
    275275 
    276     tmask_reg_glo(*,jpjglo-1,*)=tmask_reg_glo(*,jpjglo-2,*) 
     276tmask_reg_glo(*,jpjglo-1,*)=tmask_reg_glo(*,jpjglo-2,*) 
    277277;E/W 
    278278 
    279     tmask_reg_glo(0,*,*)=tmask_reg_glo(jpiglo-2,*,*) 
    280     tmask_reg_glo(jpiglo-1,*,*)=tmask_reg_glo(1,*,*) 
     279tmask_reg_glo(0,*,*)=tmask_reg_glo(jpiglo-2,*,*) 
     280tmask_reg_glo(jpiglo-1,*,*)=tmask_reg_glo(1,*,*) 
    281281 
    282282; Global T mask in created 
     
    285285 
    286286 
    287    umask_reg=tmask_reg_glo(1:jpiglo-2,0:jpjglo-2,*)*tmask_reg_glo(2:jpiglo-1,0:jpjglo-2,*) 
    288  
    289    vmask_reg=tmask_reg_glo(1:jpiglo-2,0:jpjglo-2,*)*tmask_reg_glo(1:jpiglo-2,1:jpjglo-1,*) 
    290  
    291    fmask_reg=tmask_reg_glo(1:jpiglo-2,0:jpjglo-2,*)*tmask_reg_glo(2:jpiglo-1,0:jpjglo-2,*) $ 
    292             *tmask_reg_glo(1:jpiglo-2,1:jpjglo-1,*)*tmask_reg_glo(2:jpiglo-1,1:jpjglo-1,*) 
     287umask_reg=tmask_reg_glo(1:jpiglo-2,0:jpjglo-2,*)*tmask_reg_glo(2:jpiglo-1,0:jpjglo-2,*) 
     288 
     289vmask_reg=tmask_reg_glo(1:jpiglo-2,0:jpjglo-2,*)*tmask_reg_glo(1:jpiglo-2,1:jpjglo-1,*) 
     290 
     291fmask_reg=tmask_reg_glo(1:jpiglo-2,0:jpjglo-2,*)*tmask_reg_glo(2:jpiglo-1,0:jpjglo-2,*) $ 
     292*tmask_reg_glo(1:jpiglo-2,1:jpjglo-1,*)*tmask_reg_glo(2:jpiglo-1,1:jpjglo-1,*) 
    293293 
    294294; Create Global Mask file for U,V & F points 
    295295 
    296     umask_reg_glo=replicate(0.,jpiglo,jpjglo,jpk) 
    297     umask_reg_glo(1:jpiglo-2,0:jpjglo-2, *)=umask_reg 
    298  
    299     vmask_reg_glo=replicate(0.,jpiglo,jpjglo,jpk) 
    300     vmask_reg_glo(1:jpiglo-2,0:jpjglo-2, *)=vmask_reg 
    301  
    302     fmask_reg_glo=replicate(0.,jpiglo,jpjglo,jpk) 
    303     fmask_reg_glo(1:jpiglo-2,0:jpjglo-2, *)=fmask_reg 
     296umask_reg_glo=replicate(0.,jpiglo,jpjglo,jpk) 
     297umask_reg_glo(1:jpiglo-2,0:jpjglo-2, *)=umask_reg 
     298 
     299vmask_reg_glo=replicate(0.,jpiglo,jpjglo,jpk) 
     300vmask_reg_glo(1:jpiglo-2,0:jpjglo-2, *)=vmask_reg 
     301 
     302fmask_reg_glo=replicate(0.,jpiglo,jpjglo,jpk) 
     303fmask_reg_glo(1:jpiglo-2,0:jpjglo-2, *)=fmask_reg 
    304304 
    305305; Data Duplication 
     
    307307; North 
    308308 
    309     umask_reg_glo(*,jpjglo-1,*)=umask_reg_glo(*,jpjglo-2,*) 
    310     vmask_reg_glo(*,jpjglo-1,*)=vmask_reg_glo(*,jpjglo-2,*) 
    311     fmask_reg_glo(*,jpjglo-1,*)=fmask_reg_glo(*,jpjglo-2,*) 
     309umask_reg_glo(*,jpjglo-1,*)=umask_reg_glo(*,jpjglo-2,*) 
     310vmask_reg_glo(*,jpjglo-1,*)=vmask_reg_glo(*,jpjglo-2,*) 
     311fmask_reg_glo(*,jpjglo-1,*)=fmask_reg_glo(*,jpjglo-2,*) 
    312312 
    313313;E/W 
    314314 
    315     umask_reg_glo(0,*,*)=umask_reg_glo(jpiglo-2,*,*) 
    316     umask_reg_glo(jpiglo-1,*,*)=umask_reg_glo(1,*,*) 
    317  
    318     vmask_reg_glo(0,*,*)=vmask_reg_glo(jpiglo-2,*,*) 
    319     vmask_reg_glo(jpiglo-1,*,*)=vmask_reg_glo(1,*,*) 
    320  
    321     fmask_reg_glo(0,*,*)=fmask_reg_glo(jpiglo-2,*,*) 
    322     fmask_reg_glo(jpiglo-1,*,*)=fmask_reg_glo(1,*,*) 
     315umask_reg_glo(0,*,*)=umask_reg_glo(jpiglo-2,*,*) 
     316umask_reg_glo(jpiglo-1,*,*)=umask_reg_glo(1,*,*) 
     317 
     318vmask_reg_glo(0,*,*)=vmask_reg_glo(jpiglo-2,*,*) 
     319vmask_reg_glo(jpiglo-1,*,*)=vmask_reg_glo(1,*,*) 
     320 
     321fmask_reg_glo(0,*,*)=fmask_reg_glo(jpiglo-2,*,*) 
     322fmask_reg_glo(jpiglo-1,*,*)=fmask_reg_glo(1,*,*) 
    323323 
    324324; ***** NAV_LON & NAV_LAT ********** 
     
    327327; Create Global longitude and latitude 
    328328 
    329     glamt_reg_glo=replicate(0.,jpiglo,jpjglo) 
    330  
    331     glamt_reg_glo(1:jpiglo-2,0:jpjglo-2)=glamt_reg 
    332  
    333     gphit_reg_glo=replicate(0.,jpiglo,jpjglo) 
    334  
    335     gphit_reg_glo(1:jpiglo-2,0:jpjglo-2)=gphit_reg 
    336  
    337     nav_lon_reg_glo=replicate(0.,jpiglo,jpjglo) 
    338  
    339     nav_lat_reg_glo=replicate(0.,jpiglo,jpjglo) 
    340  
    341     nav_lon_reg_glo=glamt_reg_glo 
    342  
    343     nav_lat_reg_glo=gphit_reg_glo 
     329glamt_reg_glo=replicate(0.,jpiglo,jpjglo) 
     330 
     331glamt_reg_glo(1:jpiglo-2,0:jpjglo-2)=glamt_reg 
     332 
     333gphit_reg_glo=replicate(0.,jpiglo,jpjglo) 
     334 
     335gphit_reg_glo(1:jpiglo-2,0:jpjglo-2)=gphit_reg 
     336 
     337nav_lon_reg_glo=replicate(0.,jpiglo,jpjglo) 
     338 
     339nav_lat_reg_glo=replicate(0.,jpiglo,jpjglo) 
     340 
     341nav_lon_reg_glo=glamt_reg_glo 
     342 
     343nav_lat_reg_glo=gphit_reg_glo 
    344344 
    345345; Data Duplication 
     
    347347; E/W Transition 
    348348 
    349     nav_lon_reg_glo(0,*)=nav_lon_reg_glo(jpiglo-2,*) 
    350     nav_lon_reg_glo(jpiglo-1,*)=nav_lon_reg_glo(1,*) 
    351  
    352     nav_lat_reg_glo(0,*)=nav_lat_reg_glo(jpiglo-2,*) 
    353     nav_lat_reg_glo(jpiglo-1,*)=nav_lat_reg_glo(1,*) 
    354  
    355 ; North 
    356  
    357     nav_lon_reg_glo(*,jpjglo-1)= nav_lon_reg_glo(*,jpjglo-2) 
    358     nav_lat_reg_glo(*,jpjglo-1)= nav_lat_reg_glo(*,jpjglo-2) 
     349nav_lon_reg_glo(0,*)=nav_lon_reg_glo(jpiglo-2,*) 
     350nav_lon_reg_glo(jpiglo-1,*)=nav_lon_reg_glo(1,*) 
     351 
     352nav_lat_reg_glo(0,*)=nav_lat_reg_glo(jpiglo-2,*) 
     353nav_lat_reg_glo(jpiglo-1,*)=nav_lat_reg_glo(1,*) 
     354 
     355; North 
     356 
     357nav_lon_reg_glo(*,jpjglo-1)= nav_lon_reg_glo(*,jpjglo-2) 
     358nav_lat_reg_glo(*,jpjglo-1)= nav_lat_reg_glo(*,jpjglo-2) 
    359359 
    360360; ***** GLAMT ***** 
    361 ; We don't do it to save memory :  same as nav_lon  
     361; We don't do it to save memory :  same as nav_lon 
    362362 
    363363; ***** GLAMU ***** 
    364364 
    365     glamu_reg_glo=replicate(0.,jpiglo,jpjglo) 
    366     glamu_reg_glo(1:jpiglo-2,0:jpjglo-2)=glamu_reg 
    367  
    368 ; North 
    369  
    370     glamu_reg_glo(*,jpjglo-1)=glamu_reg_glo(*,jpjglo-2) 
    371      
    372 ; E/W 
    373   
    374     glamu_reg_glo(0,*)=glamu_reg_glo(jpiglo-2,*) 
    375     glamu_reg_glo(jpiglo-1,*)=glamu_reg_glo(1,*) 
    376      
     365glamu_reg_glo=replicate(0.,jpiglo,jpjglo) 
     366glamu_reg_glo(1:jpiglo-2,0:jpjglo-2)=glamu_reg 
     367 
     368; North 
     369 
     370glamu_reg_glo(*,jpjglo-1)=glamu_reg_glo(*,jpjglo-2) 
     371 
     372; E/W 
     373 
     374glamu_reg_glo(0,*)=glamu_reg_glo(jpiglo-2,*) 
     375glamu_reg_glo(jpiglo-1,*)=glamu_reg_glo(1,*) 
     376 
    377377; ***** GLAMV ***** 
    378378 
    379     glamv_reg_glo=replicate(0.,jpiglo,jpjglo) 
    380     glamv_reg_glo(1:jpiglo-2,0:jpjglo-2)=glamv_reg 
    381  
    382 ; North 
    383  
    384     glamv_reg_glo(*,jpjglo-1)=glamv_reg_glo(*,jpjglo-2) 
    385      
    386 ; E/W 
    387   
    388     glamv_reg_glo(0,*)=glamv_reg_glo(jpiglo-2,*) 
    389     glamv_reg_glo(jpiglo-1,*)=glamv_reg_glo(1,*) 
     379glamv_reg_glo=replicate(0.,jpiglo,jpjglo) 
     380glamv_reg_glo(1:jpiglo-2,0:jpjglo-2)=glamv_reg 
     381 
     382; North 
     383 
     384glamv_reg_glo(*,jpjglo-1)=glamv_reg_glo(*,jpjglo-2) 
     385 
     386; E/W 
     387 
     388glamv_reg_glo(0,*)=glamv_reg_glo(jpiglo-2,*) 
     389glamv_reg_glo(jpiglo-1,*)=glamv_reg_glo(1,*) 
    390390 
    391391 
    392392; ***** GLAMF ***** 
    393393 
    394     glamf_reg_glo=replicate(0.,jpiglo,jpjglo) 
    395     glamf_reg_glo(1:jpiglo-2,0:jpjglo-2)=glamf_reg 
    396  
    397 ; North 
    398  
    399     glamf_reg_glo(*,jpjglo-1)=glamf_reg_glo(*,jpjglo-2) 
    400      
    401 ; E/W 
    402   
    403     glamf_reg_glo(0,*)=glamf_reg_glo(jpiglo-2,*) 
    404     glamf_reg_glo(jpiglo-1,*)=glamf_reg_glo(1,*) 
     394glamf_reg_glo=replicate(0.,jpiglo,jpjglo) 
     395glamf_reg_glo(1:jpiglo-2,0:jpjglo-2)=glamf_reg 
     396 
     397; North 
     398 
     399glamf_reg_glo(*,jpjglo-1)=glamf_reg_glo(*,jpjglo-2) 
     400 
     401; E/W 
     402 
     403glamf_reg_glo(0,*)=glamf_reg_glo(jpiglo-2,*) 
     404glamf_reg_glo(jpiglo-1,*)=glamf_reg_glo(1,*) 
    405405 
    406406 
    407407; ***** GPHIT ***** 
    408 ; We don't do it to save memory :  same as nav_lat  
     408; We don't do it to save memory :  same as nav_lat 
    409409 
    410410; ***** GPHIU ***** 
    411411 
    412     gphiu_reg_glo=replicate(0.,jpiglo,jpjglo) 
    413     gphiu_reg_glo(1:jpiglo-2,0:jpjglo-2)=gphiu_reg 
    414  
    415 ; North 
    416  
    417     gphiu_reg_glo(*,jpjglo-1)=gphiu_reg_glo(*,jpjglo-2) 
    418      
    419 ; E/W 
    420   
    421     gphiu_reg_glo(0,*)=gphiu_reg_glo(jpiglo-2,*) 
    422     gphiu_reg_glo(jpiglo-1,*)=gphiu_reg_glo(1,*) 
    423      
     412gphiu_reg_glo=replicate(0.,jpiglo,jpjglo) 
     413gphiu_reg_glo(1:jpiglo-2,0:jpjglo-2)=gphiu_reg 
     414 
     415; North 
     416 
     417gphiu_reg_glo(*,jpjglo-1)=gphiu_reg_glo(*,jpjglo-2) 
     418 
     419; E/W 
     420 
     421gphiu_reg_glo(0,*)=gphiu_reg_glo(jpiglo-2,*) 
     422gphiu_reg_glo(jpiglo-1,*)=gphiu_reg_glo(1,*) 
     423 
    424424; ***** GPHIV ***** 
    425425 
    426     gphiv_reg_glo=replicate(0.,jpiglo,jpjglo) 
    427     gphiv_reg_glo(1:jpiglo-2,0:jpjglo-2)=gphiv_reg 
    428  
    429 ; North 
    430  
    431     gphiv_reg_glo(*,jpjglo-1)=gphiv_reg_glo(*,jpjglo-2) 
    432      
    433 ; E/W 
    434   
    435     gphiv_reg_glo(0,*)=gphiv_reg_glo(jpiglo-2,*) 
    436     gphiv_reg_glo(jpiglo-1,*)=gphiv_reg_glo(1,*) 
     426gphiv_reg_glo=replicate(0.,jpiglo,jpjglo) 
     427gphiv_reg_glo(1:jpiglo-2,0:jpjglo-2)=gphiv_reg 
     428 
     429; North 
     430 
     431gphiv_reg_glo(*,jpjglo-1)=gphiv_reg_glo(*,jpjglo-2) 
     432 
     433; E/W 
     434 
     435gphiv_reg_glo(0,*)=gphiv_reg_glo(jpiglo-2,*) 
     436gphiv_reg_glo(jpiglo-1,*)=gphiv_reg_glo(1,*) 
    437437 
    438438 
    439439; ***** GPHIF ***** 
    440440 
    441     gphif_reg_glo=replicate(0.,jpiglo,jpjglo) 
    442     gphif_reg_glo(1:jpiglo-2,0:jpjglo-2)=gphif_reg 
    443  
    444 ; North 
    445  
    446     gphif_reg_glo(*,jpjglo-1)=gphif_reg_glo(*,jpjglo-2) 
    447      
    448 ; E/W 
    449   
    450     gphif_reg_glo(0,*)=gphif_reg_glo(jpiglo-2,*) 
    451     gphif_reg_glo(jpiglo-1,*)=gphif_reg_glo(1,*) 
     441gphif_reg_glo=replicate(0.,jpiglo,jpjglo) 
     442gphif_reg_glo(1:jpiglo-2,0:jpjglo-2)=gphif_reg 
     443 
     444; North 
     445 
     446gphif_reg_glo(*,jpjglo-1)=gphif_reg_glo(*,jpjglo-2) 
     447 
     448; E/W 
     449 
     450gphif_reg_glo(0,*)=gphif_reg_glo(jpiglo-2,*) 
     451gphif_reg_glo(jpiglo-1,*)=gphif_reg_glo(1,*) 
    452452 
    453453; ***** FF ******* 
    454454 
    455     omega = 2.0 * !PI / 86164.0 
    456      
    457     ff_reg_glo = 2.*omega*sin(gphif_reg_glo*!PI/180.)  
    458      
     455omega = 2.0 * !PI / 86164.0 
     456 
     457ff_reg_glo = 2.*omega*sin(gphif_reg_glo*!PI/180.) 
     458 
    459459 
    460460; *********** E1T*************** 
    461      
    462     e1t_reg_glo=replicate(0.,jpiglo,jpjglo) 
    463     e1t_reg_glo(1:jpiglo-2,0:jpjglo-2)=e1t_reg 
    464  
    465 ; North 
    466  
    467     e1t_reg_glo(*,jpjglo-1)=e1t_reg_glo(*,jpjglo-2) 
    468      
    469 ; E/W 
    470   
    471     e1t_reg_glo(0,*)=e1t_reg_glo(jpiglo-2,*) 
    472     e1t_reg_glo(jpiglo-1,*)=e1t_reg_glo(1,*) 
     461 
     462e1t_reg_glo=replicate(0.,jpiglo,jpjglo) 
     463e1t_reg_glo(1:jpiglo-2,0:jpjglo-2)=e1t_reg 
     464 
     465; North 
     466 
     467e1t_reg_glo(*,jpjglo-1)=e1t_reg_glo(*,jpjglo-2) 
     468 
     469; E/W 
     470 
     471e1t_reg_glo(0,*)=e1t_reg_glo(jpiglo-2,*) 
     472e1t_reg_glo(jpiglo-1,*)=e1t_reg_glo(1,*) 
    473473 
    474474 
    475475 
    476476; *********** E2T*************** 
    477      
    478     e2t_reg_glo=replicate(0.,jpiglo,jpjglo) 
    479     e2t_reg_glo(1:jpiglo-2,0:jpjglo-2)=e2t_reg 
    480  
    481 ; North 
    482  
    483     e2t_reg_glo(*,jpjglo-1)=e2t_reg_glo(*,jpjglo-2) 
    484      
    485 ; E/W 
    486   
    487     e2t_reg_glo(0,*)=e2t_reg_glo(jpiglo-2,*) 
    488     e2t_reg_glo(jpiglo-1,*)=e2t_reg_glo(1,*) 
     477 
     478e2t_reg_glo=replicate(0.,jpiglo,jpjglo) 
     479e2t_reg_glo(1:jpiglo-2,0:jpjglo-2)=e2t_reg 
     480 
     481; North 
     482 
     483e2t_reg_glo(*,jpjglo-1)=e2t_reg_glo(*,jpjglo-2) 
     484 
     485; E/W 
     486 
     487e2t_reg_glo(0,*)=e2t_reg_glo(jpiglo-2,*) 
     488e2t_reg_glo(jpiglo-1,*)=e2t_reg_glo(1,*) 
    489489 
    490490; *********** E1U*************** 
    491      
    492     e1u_reg_glo=replicate(0.,jpiglo,jpjglo) 
    493     e1u_reg_glo(1:jpiglo-2,0:jpjglo-2)=e1u_reg 
    494  
    495 ; North 
    496  
    497     e1u_reg_glo(*,jpjglo-1)=e1u_reg_glo(*,jpjglo-2) 
    498      
    499 ; E/W 
    500   
    501     e1u_reg_glo(0,*)=e1u_reg_glo(jpiglo-2,*) 
    502     e1u_reg_glo(jpiglo-1,*)=e1u_reg_glo(1,*) 
     491 
     492e1u_reg_glo=replicate(0.,jpiglo,jpjglo) 
     493e1u_reg_glo(1:jpiglo-2,0:jpjglo-2)=e1u_reg 
     494 
     495; North 
     496 
     497e1u_reg_glo(*,jpjglo-1)=e1u_reg_glo(*,jpjglo-2) 
     498 
     499; E/W 
     500 
     501e1u_reg_glo(0,*)=e1u_reg_glo(jpiglo-2,*) 
     502e1u_reg_glo(jpiglo-1,*)=e1u_reg_glo(1,*) 
    503503 
    504504 
    505505; *********** E2U*************** 
    506      
    507     e2u_reg_glo=replicate(0.,jpiglo,jpjglo) 
    508     e2u_reg_glo(1:jpiglo-2,0:jpjglo-2)=e2u_reg 
    509  
    510 ; North 
    511  
    512     e2u_reg_glo(*,jpjglo-1)=e2u_reg_glo(*,jpjglo-2) 
    513      
    514 ; E/W 
    515   
    516     e2u_reg_glo(0,*)=e2u_reg_glo(jpiglo-2,*) 
    517     e2u_reg_glo(jpiglo-1,*)=e2u_reg_glo(1,*) 
     506 
     507e2u_reg_glo=replicate(0.,jpiglo,jpjglo) 
     508e2u_reg_glo(1:jpiglo-2,0:jpjglo-2)=e2u_reg 
     509 
     510; North 
     511 
     512e2u_reg_glo(*,jpjglo-1)=e2u_reg_glo(*,jpjglo-2) 
     513 
     514; E/W 
     515 
     516e2u_reg_glo(0,*)=e2u_reg_glo(jpiglo-2,*) 
     517e2u_reg_glo(jpiglo-1,*)=e2u_reg_glo(1,*) 
    518518 
    519519; *********** E1V*************** 
    520      
    521     e1v_reg_glo=replicate(0.,jpiglo,jpjglo) 
    522     e1v_reg_glo(1:jpiglo-2,0:jpjglo-2)=e1v_reg 
    523  
    524 ; North 
    525  
    526     e1v_reg_glo(*,jpjglo-1)=e1v_reg_glo(*,jpjglo-2) 
    527      
    528 ; E/W 
    529   
    530     e1v_reg_glo(0,*)=e1v_reg_glo(jpiglo-2,*) 
    531     e1v_reg_glo(jpiglo-1,*)=e1v_reg_glo(1,*) 
     520 
     521e1v_reg_glo=replicate(0.,jpiglo,jpjglo) 
     522e1v_reg_glo(1:jpiglo-2,0:jpjglo-2)=e1v_reg 
     523 
     524; North 
     525 
     526e1v_reg_glo(*,jpjglo-1)=e1v_reg_glo(*,jpjglo-2) 
     527 
     528; E/W 
     529 
     530e1v_reg_glo(0,*)=e1v_reg_glo(jpiglo-2,*) 
     531e1v_reg_glo(jpiglo-1,*)=e1v_reg_glo(1,*) 
    532532 
    533533; *********** E2V*************** 
    534      
    535     e2v_reg_glo=replicate(0.,jpiglo,jpjglo) 
    536     e2v_reg_glo(1:jpiglo-2,0:jpjglo-2)=e2v_reg 
    537  
    538 ; North 
    539  
    540     e2v_reg_glo(*,jpjglo-1)=e2v_reg_glo(*,jpjglo-2) 
    541      
    542 ; E/W 
    543   
    544     e2v_reg_glo(0,*)=e2v_reg_glo(jpiglo-2,*) 
    545     e2v_reg_glo(jpiglo-1,*)=e2v_reg_glo(1,*) 
     534 
     535e2v_reg_glo=replicate(0.,jpiglo,jpjglo) 
     536e2v_reg_glo(1:jpiglo-2,0:jpjglo-2)=e2v_reg 
     537 
     538; North 
     539 
     540e2v_reg_glo(*,jpjglo-1)=e2v_reg_glo(*,jpjglo-2) 
     541 
     542; E/W 
     543 
     544e2v_reg_glo(0,*)=e2v_reg_glo(jpiglo-2,*) 
     545e2v_reg_glo(jpiglo-1,*)=e2v_reg_glo(1,*) 
    546546 
    547547; *********** E1F ************** 
    548548 
    549     e1f_reg_glo=replicate(0.,jpiglo,jpjglo) 
    550     e1f_reg_glo(1:jpiglo-2,0:jpjglo-2)=e1f_reg 
    551  
    552 ; North 
    553  
    554     e1f_reg_glo(*,jpjglo-1)=e1f_reg_glo(*,jpjglo-2) 
    555      
    556 ; E/W 
    557   
    558     e1f_reg_glo(0,*)=e1f_reg_glo(jpiglo-2,*) 
    559     e1f_reg_glo(jpiglo-1,*)=e1f_reg_glo(1,*) 
     549e1f_reg_glo=replicate(0.,jpiglo,jpjglo) 
     550e1f_reg_glo(1:jpiglo-2,0:jpjglo-2)=e1f_reg 
     551 
     552; North 
     553 
     554e1f_reg_glo(*,jpjglo-1)=e1f_reg_glo(*,jpjglo-2) 
     555 
     556; E/W 
     557 
     558e1f_reg_glo(0,*)=e1f_reg_glo(jpiglo-2,*) 
     559e1f_reg_glo(jpiglo-1,*)=e1f_reg_glo(1,*) 
    560560 
    561561; *********** E2F*************** 
    562      
    563     e2f_reg_glo=replicate(0.,jpiglo,jpjglo) 
    564     e2f_reg_glo(1:jpiglo-2,0:jpjglo-2)=e2f_reg 
    565  
    566 ; North 
    567  
    568     e2f_reg_glo(*,jpjglo-1)=e2f_reg_glo(*,jpjglo-2) 
    569      
    570 ; E/W 
    571   
    572     e2f_reg_glo(0,*)=e2f_reg_glo(jpiglo-2,*) 
    573     e2f_reg_glo(jpiglo-1,*)=e2f_reg_glo(1,*) 
     562 
     563e2f_reg_glo=replicate(0.,jpiglo,jpjglo) 
     564e2f_reg_glo(1:jpiglo-2,0:jpjglo-2)=e2f_reg 
     565 
     566; North 
     567 
     568e2f_reg_glo(*,jpjglo-1)=e2f_reg_glo(*,jpjglo-2) 
     569 
     570; E/W 
     571 
     572e2f_reg_glo(0,*)=e2f_reg_glo(jpiglo-2,*) 
     573e2f_reg_glo(jpiglo-1,*)=e2f_reg_glo(1,*) 
    574574 
    575575 
     
    577577;****************END OF ATTRIBUTES**************** 
    578578 
    579   
     579 
    580580;************************************************* 
    581581; 4th STEP : CREATES NCDF MESHMASK FILE 
     
    585585 
    586586 
    587    vargrid = 'T' 
     587vargrid = 'T' 
    588588 
    589589; Name 
    590    idout = NCDF_CREATE(outputgrid,/clobber) 
    591    print, 'Creation du fichier Netcdf' 
    592    NCDF_CONTROL, idout, /nofill 
     590idout = NCDF_CREATE(outputgrid,/clobber) 
     591print, 'Creation du fichier Netcdf' 
     592NCDF_CONTROL, idout, /nofill 
    593593; Dimension 
    594594 
    595    xidout = NCDF_DIMDEF(idout, 'x', jpiglo) 
    596    yidout = NCDF_DIMDEF(idout, 'y', jpjglo) 
    597    didout = NCDF_DIMDEF(idout, 'z', jpk) 
    598    x_a    = NCDF_DIMDEF(idout, 'x_a',1) 
    599    y_a    = NCDF_DIMDEF(idout, 'y_a',1) 
    600    z_a    = NCDF_DIMDEF(idout, 'z_a',1) 
    601    tidout = NCDF_DIMDEF(idout, 'time_counter', /unlimited) 
     595xidout = NCDF_DIMDEF(idout, 'x', jpiglo) 
     596yidout = NCDF_DIMDEF(idout, 'y', jpjglo) 
     597didout = NCDF_DIMDEF(idout, 'z', jpk) 
     598x_a    = NCDF_DIMDEF(idout, 'x_a',1) 
     599y_a    = NCDF_DIMDEF(idout, 'y_a',1) 
     600z_a    = NCDF_DIMDEF(idout, 'z_a',1) 
     601tidout = NCDF_DIMDEF(idout, 'time_counter', /unlimited) 
    602602 
    603603; Attributes 
    604       
    605    id0  = NCDF_VARDEF(idout, 'nav_lon'     , [xidout, yidout                ],/FLOAT ) 
    606    id1  = NCDF_VARDEF(idout, 'nav_lat'     , [xidout, yidout                ],/FLOAT ) 
    607    id2  = NCDF_VARDEF(idout, 'nav_lev'     , [                didout        ],/FLOAT ) 
    608    id3  = NCDF_VARDEF(idout, 'time'        , [                        tidout],/FLOAT ) 
    609    id4  = NCDF_VARDEF(idout, 'time_steps'  , [                        tidout],/LONG  ) 
    610    id5  = NCDF_VARDEF(idout, 'glamt'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    611    id6  = NCDF_VARDEF(idout, 'glamu'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    612    id7  = NCDF_VARDEF(idout, 'glamv'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    613    id8  = NCDF_VARDEF(idout, 'glamf'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    614    id9  = NCDF_VARDEF(idout, 'gphit'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    615    id10 = NCDF_VARDEF(idout, 'gphiu'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    616    id11 = NCDF_VARDEF(idout, 'gphiv'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    617    id12 = NCDF_VARDEF(idout, 'gphif'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    618    id13 = NCDF_VARDEF(idout, 'e1t'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    619    id14 = NCDF_VARDEF(idout, 'e1u'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    620    id15 = NCDF_VARDEF(idout, 'e1v'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    621    id16 = NCDF_VARDEF(idout, 'e1f'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    622    id17 = NCDF_VARDEF(idout, 'e2t'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    623    id18 = NCDF_VARDEF(idout, 'e2u'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    624    id19 = NCDF_VARDEF(idout, 'e2v'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    625    id20 = NCDF_VARDEF(idout, 'e2f'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    626    id21 = NCDF_VARDEF(idout, 'tmask'       , [xidout, yidout, didout, tidout],/DOUBLE) 
    627    id22 = NCDF_VARDEF(idout, 'umask'       , [xidout, yidout, didout, tidout],/DOUBLE) 
    628    id23 = NCDF_VARDEF(idout, 'vmask'       , [xidout, yidout, didout, tidout],/DOUBLE) 
    629    id24 = NCDF_VARDEF(idout, 'fmask'       , [xidout, yidout, didout, tidout],/DOUBLE) 
    630    id25 = NCDF_VARDEF(idout, 'ff'          , [xidout, yidout, z_a   , tidout],/DOUBLE) 
    631    id26 = NCDF_VARDEF(idout, 'gdept'       , [x_a   , y_a   , didout, tidout],/DOUBLE) 
    632    id27 = NCDF_VARDEF(idout, 'gdepw'       , [x_a   , y_a   , didout, tidout],/DOUBLE) 
    633    id28 = NCDF_VARDEF(idout, 'e3t'         , [x_a   , y_a   , didout, tidout],/DOUBLE) 
    634    id29 = NCDF_VARDEF(idout, 'e3w'         , [x_a   , y_a   , didout, tidout],/DOUBLE) 
     604 
     605id0  = NCDF_VARDEF(idout, 'nav_lon'     , [xidout, yidout                ],/FLOAT ) 
     606id1  = NCDF_VARDEF(idout, 'nav_lat'     , [xidout, yidout                ],/FLOAT ) 
     607id2  = NCDF_VARDEF(idout, 'nav_lev'     , [                didout        ],/FLOAT ) 
     608id3  = NCDF_VARDEF(idout, 'time'        , [                        tidout],/FLOAT ) 
     609id4  = NCDF_VARDEF(idout, 'time_steps'  , [                        tidout],/LONG  ) 
     610id5  = NCDF_VARDEF(idout, 'glamt'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     611id6  = NCDF_VARDEF(idout, 'glamu'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     612id7  = NCDF_VARDEF(idout, 'glamv'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     613id8  = NCDF_VARDEF(idout, 'glamf'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     614id9  = NCDF_VARDEF(idout, 'gphit'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     615id10 = NCDF_VARDEF(idout, 'gphiu'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     616id11 = NCDF_VARDEF(idout, 'gphiv'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     617id12 = NCDF_VARDEF(idout, 'gphif'       , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     618id13 = NCDF_VARDEF(idout, 'e1t'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     619id14 = NCDF_VARDEF(idout, 'e1u'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     620id15 = NCDF_VARDEF(idout, 'e1v'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     621id16 = NCDF_VARDEF(idout, 'e1f'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     622id17 = NCDF_VARDEF(idout, 'e2t'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     623id18 = NCDF_VARDEF(idout, 'e2u'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     624id19 = NCDF_VARDEF(idout, 'e2v'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     625id20 = NCDF_VARDEF(idout, 'e2f'         , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     626id21 = NCDF_VARDEF(idout, 'tmask'       , [xidout, yidout, didout, tidout],/DOUBLE) 
     627id22 = NCDF_VARDEF(idout, 'umask'       , [xidout, yidout, didout, tidout],/DOUBLE) 
     628id23 = NCDF_VARDEF(idout, 'vmask'       , [xidout, yidout, didout, tidout],/DOUBLE) 
     629id24 = NCDF_VARDEF(idout, 'fmask'       , [xidout, yidout, didout, tidout],/DOUBLE) 
     630id25 = NCDF_VARDEF(idout, 'ff'          , [xidout, yidout, z_a   , tidout],/DOUBLE) 
     631id26 = NCDF_VARDEF(idout, 'gdept'       , [x_a   , y_a   , didout, tidout],/DOUBLE) 
     632id27 = NCDF_VARDEF(idout, 'gdepw'       , [x_a   , y_a   , didout, tidout],/DOUBLE) 
     633id28 = NCDF_VARDEF(idout, 'e3t'         , [x_a   , y_a   , didout, tidout],/DOUBLE) 
     634id29 = NCDF_VARDEF(idout, 'e3w'         , [x_a   , y_a   , didout, tidout],/DOUBLE) 
    635635 
    636636; Variable 0 
    637    NCDF_ATTPUT, idout, id0, 'units', 'degrees_east' 
    638    NCDF_ATTPUT, idout, id0, 'long_name', 'Longitude' 
    639    NCDF_ATTPUT, idout, id0, 'nav_model', 'Default grid' 
     637NCDF_ATTPUT, idout, id0, 'units', 'degrees_east' 
     638NCDF_ATTPUT, idout, id0, 'long_name', 'Longitude' 
     639NCDF_ATTPUT, idout, id0, 'nav_model', 'Default grid' 
    640640; Variable 1 
    641    NCDF_ATTPUT, idout, id1, 'units', 'degrees_north' 
    642    NCDF_ATTPUT, idout, id1, 'long_name', 'Latitude' 
    643    NCDF_ATTPUT, idout, id1, 'nav_model', 'Default grid' 
     641NCDF_ATTPUT, idout, id1, 'units', 'degrees_north' 
     642NCDF_ATTPUT, idout, id1, 'long_name', 'Latitude' 
     643NCDF_ATTPUT, idout, id1, 'nav_model', 'Default grid' 
    644644; Variable 2 
    645    NCDF_ATTPUT, idout, id2, 'units','meters' 
    646    NCDF_ATTPUT, idout, id2, 'long_name','Depth' 
    647    NCDF_ATTPUT, idout, id2, 'nav_model','Default grid' 
     645NCDF_ATTPUT, idout, id2, 'units','meters' 
     646NCDF_ATTPUT, idout, id2, 'long_name','Depth' 
     647NCDF_ATTPUT, idout, id2, 'nav_model','Default grid' 
    648648; Variable 3 
    649    NCDF_ATTPUT, idout, id3, 'units', 'seconds since 0001-01-15 12:00:00 ' 
    650    NCDF_ATTPUT, idout, id3, 'calendar','noleap' 
    651    NCDF_ATTPUT, idout, id3, 'title', 'Time' 
    652    NCDF_ATTPUT, idout, id3, 'long_name', 'Time axis' 
    653    NCDF_ATTPUT, idout, id3, 'time_origin','0000-DEC-15 00:00:00' 
    654  
    655    
    656    NCDF_CONTROL, idout, /ENDEF 
     649NCDF_ATTPUT, idout, id3, 'units', 'seconds since 0001-01-15 12:00:00 ' 
     650NCDF_ATTPUT, idout, id3, 'calendar','noleap' 
     651NCDF_ATTPUT, idout, id3, 'title', 'Time' 
     652NCDF_ATTPUT, idout, id3, 'long_name', 'Time axis' 
     653NCDF_ATTPUT, idout, id3, 'time_origin','0000-DEC-15 00:00:00' 
     654 
     655 
     656NCDF_CONTROL, idout, /ENDEF 
    657657 
    658658 
     
    661661 
    662662 
    663    NCDF_VARPUT, idout, id0 , nav_lon_reg_glo 
    664    NCDF_VARPUT, idout, id1 , nav_lat_reg_glo 
    665    NCDF_VARPUT, idout, id2 , gdept 
    666    NCDF_VARPUT, idout, id3 , 1. 
    667    NCDF_VARPUT, idout, id4 , 1. 
    668    NCDF_VARPUT, idout, id5 , nav_lon_reg_glo 
    669  
    670    NCDF_VARPUT, idout, id6 , glamu_reg_glo 
    671    NCDF_VARPUT, idout, id7 , glamv_reg_glo 
    672    NCDF_VARPUT, idout, id8 , glamf_reg_glo 
    673    NCDF_VARPUT, idout, id9 , nav_lat_reg_glo 
    674    NCDF_VARPUT, idout, id10, gphiu_reg_glo 
    675    NCDF_VARPUT, idout, id11, gphiv_reg_glo 
    676    NCDF_VARPUT, idout, id12, gphif_reg_glo 
    677    NCDF_VARPUT, idout, id13, e1t_reg_glo 
    678    NCDF_VARPUT, idout, id14, e1u_reg_glo 
    679    NCDF_VARPUT, idout, id15, e1v_reg_glo 
    680    NCDF_VARPUT, idout, id16, e1f_reg_glo 
    681    NCDF_VARPUT, idout, id17, e2t_reg_glo 
    682    NCDF_VARPUT, idout, id18, e2u_reg_glo 
    683    NCDF_VARPUT, idout, id19, e2v_reg_glo 
    684    NCDF_VARPUT, idout, id20, e2f_reg_glo 
    685    NCDF_VARPUT, idout, id21, tmask_reg_glo 
    686    NCDF_VARPUT, idout, id22, umask_reg_glo 
    687    NCDF_VARPUT, idout, id23, vmask_reg_glo 
    688    NCDF_VARPUT, idout, id24, fmask_reg_glo 
    689    NCDF_VARPUT, idout, id25, ff_reg_glo 
    690  
    691    dummy=replicate(0.,1,1,jpk,1) 
    692    dummy(0,0,*,0)=gdept 
    693  
    694    NCDF_VARPUT, idout, id26, dummy 
    695  
    696     dummy=replicate(0.,1,1,jpk,1) 
    697     dummy(0,0,*,0)=gdepw 
    698  
    699    NCDF_VARPUT, idout, id27, dummy 
    700  
    701     dummy=replicate(0.,1,1,jpk,1) 
    702     dummy(0,0,*,0)=e3t 
    703  
    704    NCDF_VARPUT, idout, id28, dummy 
    705  
    706     dummy=replicate(0.,1,1,jpk,1) 
    707     dummy(0,0,*,0)=e3w 
    708  
    709    NCDF_VARPUT, idout, id29, dummy 
    710  
    711    NCDF_CLOSE, idout 
    712  
    713     
     663NCDF_VARPUT, idout, id0 , nav_lon_reg_glo 
     664NCDF_VARPUT, idout, id1 , nav_lat_reg_glo 
     665NCDF_VARPUT, idout, id2 , gdept 
     666NCDF_VARPUT, idout, id3 , 1. 
     667NCDF_VARPUT, idout, id4 , 1. 
     668NCDF_VARPUT, idout, id5 , nav_lon_reg_glo 
     669 
     670NCDF_VARPUT, idout, id6 , glamu_reg_glo 
     671NCDF_VARPUT, idout, id7 , glamv_reg_glo 
     672NCDF_VARPUT, idout, id8 , glamf_reg_glo 
     673NCDF_VARPUT, idout, id9 , nav_lat_reg_glo 
     674NCDF_VARPUT, idout, id10, gphiu_reg_glo 
     675NCDF_VARPUT, idout, id11, gphiv_reg_glo 
     676NCDF_VARPUT, idout, id12, gphif_reg_glo 
     677NCDF_VARPUT, idout, id13, e1t_reg_glo 
     678NCDF_VARPUT, idout, id14, e1u_reg_glo 
     679NCDF_VARPUT, idout, id15, e1v_reg_glo 
     680NCDF_VARPUT, idout, id16, e1f_reg_glo 
     681NCDF_VARPUT, idout, id17, e2t_reg_glo 
     682NCDF_VARPUT, idout, id18, e2u_reg_glo 
     683NCDF_VARPUT, idout, id19, e2v_reg_glo 
     684NCDF_VARPUT, idout, id20, e2f_reg_glo 
     685NCDF_VARPUT, idout, id21, tmask_reg_glo 
     686NCDF_VARPUT, idout, id22, umask_reg_glo 
     687NCDF_VARPUT, idout, id23, vmask_reg_glo 
     688NCDF_VARPUT, idout, id24, fmask_reg_glo 
     689NCDF_VARPUT, idout, id25, ff_reg_glo 
     690 
     691dummy=replicate(0.,1,1,jpk,1) 
     692dummy(0,0,*,0)=gdept 
     693 
     694NCDF_VARPUT, idout, id26, dummy 
     695 
     696 dummy=replicate(0.,1,1,jpk,1) 
     697 dummy(0,0,*,0)=gdepw 
     698 
     699NCDF_VARPUT, idout, id27, dummy 
     700 
     701 dummy=replicate(0.,1,1,jpk,1) 
     702 dummy(0,0,*,0)=e3t 
     703 
     704NCDF_VARPUT, idout, id28, dummy 
     705 
     706 dummy=replicate(0.,1,1,jpk,1) 
     707 dummy(0,0,*,0)=e3w 
     708 
     709NCDF_VARPUT, idout, id29, dummy 
     710 
     711NCDF_CLOSE, idout 
     712 
     713 
    714714 
    715715end 
  • trunk/INTERP2/make_weight.pro

    r2 r48  
    66; 
    77; PURPOSE: Creates for a given ORCA grid, and its ORCA_GEO equivalent 
    8 ;          grid  the required  
     8;          grid the required 
    99; 
    1010; CATEGORY : Subroutine 
     
    3636 
    3737 
    38 @initorca 
    39 @naminterp2 
    40 @init_path2 
    41  
    42  
    43 ;***************************************** 
    44 ; Error file opening 
    45 ;***************************************** 
    46  
    47 openu, lun_err,errorfile,/get_lun 
    48  
    49 ;************************ 
    50 ; Compute Geogrid 
    51 ;************************ 
    52 ; Let's get our reference latitude 
    53  
    54 northernmost=where(gphit EQ max(gphit)) 
    55  
    56 jnorth=northernmost/jpi 
    57  
    58 inorth=min(northernmost-jnorth*jpi) 
    59  
    60 ref_latitude=gphit(inorth,*) 
    61  
    62 ; Let's get the reference longitude 
    63  
    64 equador=where(abs(gphit) EQ  min(abs(gphit)) ) 
    65  
    66 ref_longitude=glamt(equador) 
    67  
    68 ; Now we have the new grid 
    69  
    70  
    71 glamt_reg=ref_longitude#replicate(1,n_elements(ref_latitude)) 
    72  
    73  
    74 gphit_reg=replicate(1,n_elements(ref_longitude))#ref_latitude 
    75  
    76 ; Get the output mask 
    77  
    78 mask_reg=read_ncdf('tmask',FILENAME=outputgrid,/NOSTRUCT,/cont_nofill) 
    79  
    80 ; Get the latitude and longitude with extra boundary lines 
    81  
    82 get_fullmesh, glamt_full,gphit_full 
    83  
    84 sph_coord_full=replicate(9999.,3,jpiglo*jpjglo) 
    85  
    86 sph_coord_full(0,*)=reform(glamt_full,jpiglo*jpjglo) 
    87 sph_coord_full(1,*)=reform(gphit_full,jpiglo*jpjglo) 
    88 sph_coord_full(2,*)=replicate(1.,jpiglo*jpjglo) 
    89  
    90 rec_grid_full=cv_coord(/DEGREES,FROM_SPHERE=sph_coord_full,/TO_RECT) 
    91  
    92 xx_grid_full=rec_grid_full(0,*) 
    93 yy_grid_full=rec_grid_full(1,*)    
    94 zz_grid_full=rec_grid_full(2,*) 
    95  
    96  
    97 sph_coord=replicate(9999.,3,jpi*jpj) 
    98  
    99 radius=replicate(1.,jpi,jpj) 
    100 radius(0:jpi/2,jpj-1)=1000. 
    101  
    102 sph_coord(0,*)=reform(glamt,jpi*jpj) 
    103 sph_coord(1,*)=reform(gphit,jpi*jpj) 
    104 sph_coord(2,*)=reform(radius,jpi*jpj) 
    105  
    106 rec_grid=cv_coord(/DEGREES,FROM_SPHERE=sph_coord,/TO_RECT) 
    107  
    108 xx_grid=rec_grid(0,*) 
    109 yy_grid=rec_grid(1,*)    
    110 zz_grid=rec_grid(2,*) 
    111  
    112  
    113  
    114 ; Init array to stock pointers 
    115  
    116   pointer_Tx=replicate(999,jpi,jpj,4) 
    117   pointer_Ty=replicate(999,jpi,jpj,4) 
     38    @initorca 
     39    @naminterp2 
     40    @init_path2 
     41 
     42 
     43    ;***************************************** 
     44    ; Error file opening 
     45    ;***************************************** 
     46 
     47    openu, lun_err,errorfile,/get_lun 
     48 
     49    ;************************ 
     50    ; Compute Geogrid 
     51    ;************************ 
     52    ; Let's get our reference latitude 
     53 
     54    northernmost=where(gphit EQ max(gphit)) 
     55 
     56    jnorth=northernmost/jpi 
     57 
     58    inorth=min(northernmost-jnorth*jpi) 
     59 
     60    ref_latitude=gphit(inorth,*) 
     61 
     62    ; Let's get the reference longitude 
     63 
     64    equador=where(abs(gphit) EQ  min(abs(gphit)) ) 
     65 
     66    ref_longitude=glamt(equador) 
     67 
     68    ; Now we have the new grid 
     69 
     70 
     71    glamt_reg=ref_longitude#replicate(1,n_elements(ref_latitude)) 
     72 
     73 
     74    gphit_reg=replicate(1,n_elements(ref_longitude))#ref_latitude 
     75 
     76    ; Get the output mask 
     77 
     78    mask_reg=read_ncdf('tmask',FILENAME=outputgrid,/NOSTRUCT,/cont_nofill) 
     79 
     80    ; Get the latitude and longitude with extra boundary lines 
     81 
     82    get_fullmesh, glamt_full,gphit_full 
     83 
     84    sph_coord_full=replicate(9999.,3,jpiglo*jpjglo) 
     85 
     86    sph_coord_full(0,*)=reform(glamt_full,jpiglo*jpjglo) 
     87    sph_coord_full(1,*)=reform(gphit_full,jpiglo*jpjglo) 
     88    sph_coord_full(2,*)=replicate(1.,jpiglo*jpjglo) 
     89 
     90    rec_grid_full=cv_coord(/DEGREES,FROM_SPHERE=sph_coord_full,/TO_RECT) 
     91 
     92    xx_grid_full=rec_grid_full(0,*) 
     93    yy_grid_full=rec_grid_full(1,*) 
     94    zz_grid_full=rec_grid_full(2,*) 
     95 
     96 
     97    sph_coord=replicate(9999.,3,jpi*jpj) 
     98 
     99    radius=replicate(1.,jpi,jpj) 
     100    radius(0:jpi/2,jpj-1)=1000. 
     101 
     102    sph_coord(0,*)=reform(glamt,jpi*jpj) 
     103    sph_coord(1,*)=reform(gphit,jpi*jpj) 
     104    sph_coord(2,*)=reform(radius,jpi*jpj) 
     105 
     106    rec_grid=cv_coord(/DEGREES,FROM_SPHERE=sph_coord,/TO_RECT) 
     107 
     108    xx_grid=rec_grid(0,*) 
     109    yy_grid=rec_grid(1,*) 
     110    zz_grid=rec_grid(2,*) 
     111 
     112 
     113 
     114    ; Init array to stock pointers 
     115 
     116    pointer_Tx=replicate(999,jpi,jpj,4) 
     117    pointer_Ty=replicate(999,jpi,jpj,4) 
    118118; Init weight matric 
    119119 
    120   weight_T=double(replicate(0.,jpi,jpj,4)) 
     120    weight_T=double(replicate(0.,jpi,jpj,4)) 
    121121 
    122122; Get the latitude to start from 
    123123 
    124 not_found=1 
    125 for jj=0, jpj-1 do begin 
    126  
    127    lat_max_ORCA=max( gphit(*,jj)     ) 
    128    lat_max_reg =max( gphit_reg(*,jj) ) 
    129  
    130  
    131    if ((lat_max_ORCA NE lat_max_reg) AND (not_found EQ 1)) then begin 
    132    jpj_start=jj-2 
    133    not_found=0 
    134    endif 
    135  
    136 end 
     124    not_found=1 
     125    for jj=0, jpj-1 do begin 
     126 
     127       lat_max_ORCA=max( gphit(*,jj)     ) 
     128       lat_max_reg =max( gphit_reg(*,jj) ) 
     129 
     130 
     131       if ((lat_max_ORCA NE lat_max_reg) AND (not_found EQ 1)) then begin 
     132           jpj_start=jj-2 
     133           not_found=0 
     134       endif 
     135 
     136    end 
    137137 
    138138 
    139139    for jj=0,jpj-1 do begin 
    140    
    141     for ji=0,jpi-1 do begin  
    142  
    143  
    144     if mask_reg(ji,jj) NE 0 then begin 
    145  
    146 ; Coordinates of our point 
    147  
    148     xx=glamt_reg(ji,jj) 
    149     yy=gphit_reg(ji,jj) 
    150     
     140 
     141        for ji=0,jpi-1 do begin 
     142 
     143 
     144            if mask_reg(ji,jj) NE 0 then begin 
     145 
     146                ; Coordinates of our point 
     147 
     148                xx=glamt_reg(ji,jj) 
     149                yy=gphit_reg(ji,jj) 
     150 
    151151    sph_coord=replicate(1.,3) 
    152152    sph_coord(0)=xx 
    153153    sph_coord(1)=yy 
    154154 
    155 ; Convert them into cartesian  
    156      
     155; Convert them into cartesian 
     156 
    157157    rec_coord=cv_coord(/DEGREES,FROM_SPHERE=sph_coord,/TO_RECT) 
    158158 
     
    162162 
    163163 
    164      
     164 
    165165 
    166166;**************************************************************** 
    167 ; Finds in which grid cell point stand    
     167; Finds in which grid cell point stand 
    168168;**************************************************************** 
    169      
     169 
    170170    xx_bis=reform(xx_bis,jpi,jpj) 
    171171    yy_bis=reform(yy_bis,jpi,jpj) 
     
    176176    zz_grid_full=reform(zz_grid_full,jpiglo,jpjglo) 
    177177 
    178      
     178 
    179179    check_inside,xx_bis ,yy_bis ,zz_bis,$ 
    180180                 xx_grid_full(1:jpiglo-2,0:jpjglo-2),yy_grid_full(1:jpiglo-2,0:jpjglo-2),zz_grid_full(1:jpiglo-2,0:jpjglo-2),$ 
     
    183183                 xx_grid_full(1:jpiglo-2,1:jpjglo-1),yy_grid_full(1:jpiglo-2,1:jpjglo-1),zz_grid_full(1:jpiglo-2,1:jpjglo-1), answer 
    184184 
    185      
    186       
     185 
     186 
    187187    if answer(0) EQ -1 then begin 
    188188 
     
    191191 
    192192    endif 
    193      
    194      
     193 
     194 
    195195    answer_j=answer/jpi 
    196196    answer_i=answer-answer_j*jpi 
    197     
    198      
     197 
     198 
    199199    answer_j=answer_j(where(answer_i EQ min(answer_i))) 
    200200    answer_i=answer_i(where(answer_i EQ min(answer_i))) 
    201      
     201 
    202202    answer_j=answer_j(0) 
    203     answer_i=answer_i(0)     
    204  
    205     pointer_Tx(ji,jj,0)=answer_i  
     203    answer_i=answer_i(0) 
     204 
     205    pointer_Tx(ji,jj,0)=answer_i 
    206206    pointer_Ty(ji,jj,0)=answer_j 
    207207    point_x1=answer_i 
    208208    point_y1=answer_j 
    209   
     209 
    210210    pointer_Tx(ji,jj,1)=answer_i+1 
    211211    pointer_Ty(ji,jj,1)=answer_j 
     
    223223    point_y4=answer_j+1 
    224224 
    225     
     225 
    226226 
    227227; Now we know which 4 points are located nearby our output T point. 
     
    231231    glamt_ref=replicate(0.,4) 
    232232    gphit_ref=replicate(0.,4) 
    233    
    234    
    235     
    236     glamt_ref(0)=glamt_full(point_x1+1,point_y1)               
     233 
     234 
     235 
     236    glamt_ref(0)=glamt_full(point_x1+1,point_y1) 
    237237    gphit_ref(0)=gphit_full(point_x1+1,point_y1) 
    238238 
    239     glamt_ref(1)=glamt_full(point_x2+1,point_y2)               
     239    glamt_ref(1)=glamt_full(point_x2+1,point_y2) 
    240240    gphit_ref(1)=gphit_full(point_x2+1,point_y2) 
    241      
    242     glamt_ref(2)=glamt_full(point_x3+1,point_y3)               
     241 
     242    glamt_ref(2)=glamt_full(point_x3+1,point_y3) 
    243243    gphit_ref(2)=gphit_full(point_x3+1,point_y3) 
    244244 
    245      
    246     glamt_ref(3)=glamt_full(point_x4+1,point_y4)               
     245 
     246    glamt_ref(3)=glamt_full(point_x4+1,point_y4) 
    247247    gphit_ref(3)=gphit_full(point_x4+1,point_y4) 
    248    
    249      
     248 
     249 
    250250 
    251251; Let's make things simple for coordinates 
    252    
     252 
    253253   sph_coord_ref=replicate(0.,3,5) 
    254254 
     
    262262 
    263263   rec_coord_ref=cv_coord(/DEGREES,FROM_SPHERE=sph_coord_ref,/TO_RECT) 
    264    
     264 
    265265   xx=rec_coord_ref(0,0) 
    266266   yy=rec_coord_ref(1,0) 
     
    270270   y1=rec_coord_ref(1,1) 
    271271   z1=rec_coord_ref(2,1) 
    272   
     272 
    273273   x2=rec_coord_ref(0,2) 
    274274   y2=rec_coord_ref(1,2) 
     
    286286   yG=total(rec_coord_ref(1,1:4))/4. 
    287287   zG=total(rec_coord_ref(2,1:4))/4. 
    288     
     288 
    289289   rec_coord_ref(0,*)=rec_coord_ref(0,*)-xG 
    290290   rec_coord_ref(1,*)=rec_coord_ref(1,*)-yG 
     
    292292 
    293293   XT=rec_coord_ref(*,1:4) 
    294   
     294 
    295295   XM=MATRIX_MULTIPLY(XT,XT,/BTRANSPOSE) 
    296296   EVAL=HQR(ELMHES(XM),/DOUBLE) 
     
    299299   EVAL=FLOAT(EVAL) 
    300300   EVEC=FLOAT(EVEC) 
    301    ORDER=SORT(EVAL)   
    302     
     301   ORDER=SORT(EVAL) 
     302 
    303303 
    304304   xx=total(rec_coord_ref(*,0)*EVEC(*,ORDER(1))) 
     
    316316   x4=total(rec_coord_ref(*,4)*EVEC(*,ORDER(1))) 
    317317   y4=total(rec_coord_ref(*,4)*EVEC(*,ORDER(2))) 
    318     
     318 
    319319 
    320320;************************************************** 
     
    358358 
    359359b_coeff= -(x2-x1)*yj0-(xx-x1)*(yj0-yj1)+(yy-y1)*(xj0-xj1)+(y2-y1)*xj0 
    360     
     360 
    361361c_coeff= (xx-x1)*yj0-(yy-y1)*xj0 
    362362 
     
    432432 
    433433b_coeff= -(x4-x1)*yi0-(xx-x1)*(yi0-yi1)+(yy-y1)*(xi0-xi1)+(y4-y1)*xi0 
    434     
     434 
    435435c_coeff= (xx-x1)*yi0-(yy-y1)*xi0 
    436436 
     
    441441jP=999. 
    442442 
    443 if abs(a_coeff) GT 1.E-5  then begin 
     443if abs(a_coeff) GT 1.E-5 then begin 
    444444 
    445445sol1=(-b_coeff+sqrt(delta))/(2.*a_coeff) 
     
    461461 
    462462endelse 
    463     
    464     
     463 
     464 
    465465   weight_T(ji,jj,0) = (1.-iP)*(1.-jP) 
    466466 
     
    471471   weight_T(ji,jj,3) = (1.-iP)*jP 
    472472 
    473     
     473 
    474474   if min(weight_T(ji,jj,*)) LT 0 OR max(weight_T(ji,jj,*)) GT 1 then begin 
    475475 
     
    477477      printf, lun_err,'IP=',iP,' JP=',jP 
    478478 
    479       
     479 
    480480      printf, lun_err,'XP=',xx,' YP=',yy 
    481481      printf, lun_err,'XA=',x1,' YA=',y1 
     
    483483      printf, lun_err,'XC=',x3,' YC=',y3 
    484484      printf, lun_err,'XD=',x4,' YD=',y4 
    485        
    486    endif 
    487    
    488  
    489    endif 
    490  
    491    
    492   end 
     485 
     486               endif 
     487 
     488 
     489           endif 
     490 
     491 
     492    end 
    493493 
    494494end 
    495495 
    496 close, lun_err 
    497 free_lun,lun_err 
    498  
    499 ; Convert to full format 
    500  
    501  
    502   weight_full=replicate(0.,jpiglo,jpjglo,4) 
    503   pointer_i_full=replicate(0,jpiglo,jpjglo,4) 
    504   pointer_j_full=replicate(0,jpiglo,jpjglo,4) 
    505  
    506   weight_full(1:jpiglo-2,0:jpjglo-2,*)=weight_T 
    507   pointer_i_full(1:jpiglo-2,0:jpjglo-2,*)=pointer_Tx 
    508   pointer_j_full(1:jpiglo-2,0:jpjglo-2,*)=pointer_Ty 
    509  
    510  
    511  
    512  
    513 ; Let's save Weight functions and the pointer arrays 
    514  
    515  
    516 ; Creates Netcdf File to save this 
    517  
    518  
    519    vargrid = 'T' 
    520  
    521 ; Name 
     496    close, lun_err 
     497    free_lun,lun_err 
     498 
     499    ; Convert to full format 
     500 
     501 
     502    weight_full=replicate(0.,jpiglo,jpjglo,4) 
     503    pointer_i_full=replicate(0,jpiglo,jpjglo,4) 
     504    pointer_j_full=replicate(0,jpiglo,jpjglo,4) 
     505 
     506    weight_full(1:jpiglo-2,0:jpjglo-2,*)=weight_T 
     507    pointer_i_full(1:jpiglo-2,0:jpjglo-2,*)=pointer_Tx 
     508    pointer_j_full(1:jpiglo-2,0:jpjglo-2,*)=pointer_Ty 
     509 
     510 
     511 
     512 
     513    ; Let's save Weight functions and the pointer arrays 
     514 
     515 
     516    ; Creates Netcdf File to save this 
     517 
     518 
     519    vargrid = 'T' 
     520 
     521    ; Name 
    522522   idout = NCDF_CREATE(weightfile,/clobber) 
    523    
     523 
    524524   NCDF_CONTROL, idout, /nofill 
    525 ; Dimension 
     525    ; Dimension 
    526526   xidout = NCDF_DIMDEF(idout, 'x', jpiglo) 
    527527   yidout = NCDF_DIMDEF(idout, 'y', jpjglo) 
     
    531531 
    532532 
    533 ; Attributes    
     533; Attributes 
    534534   id_0  = NCDF_VARDEF(idout, 'nav_lon'     , [xidout, yidout                ], /FLOAT) 
    535535   id_1  = NCDF_VARDEF(idout, 'nav_lat'     , [xidout, yidout                ], /FLOAT) 
    536536   id_2  = NCDF_VARDEF(idout, 'deptht'      , [                didout        ], /FLOAT) 
    537537   id_3  = NCDF_VARDEF(idout, 'time_counter', [                        tidout], /FLOAT) 
    538    
     538 
    539539   id0   = NCDF_VARDEF(idout, 'weight_1'      , [xidout, yidout,didout,tidout ], /FLOAT) 
    540540   id1   = NCDF_VARDEF(idout, 'weight_2'      , [xidout, yidout,didout,tidout  ], /FLOAT) 
     
    573573   NCDF_ATTPUT, idout, id0, 'units','no unit' 
    574574   NCDF_ATTPUT, idout, id0, 'long_name','W1' 
    575   
     575 
    576576; Variable 1 
    577577   NCDF_ATTPUT, idout, id1, 'units','no unit' 
     
    588588   NCDF_ATTPUT, idout, id4, 'units','no unit' 
    589589   NCDF_ATTPUT, idout, id4, 'long_name','i1' 
    590   
     590 
    591591; Variable 1 
    592592   NCDF_ATTPUT, idout, id5, 'units','no unit' 
     
    604604   NCDF_ATTPUT, idout, id8, 'units','no unit' 
    605605   NCDF_ATTPUT, idout, id8, 'long_name','j1' 
    606   
     606 
    607607; Variable 1 
    608608   NCDF_ATTPUT, idout, id9, 'units','no unit' 
     
    636636   NCDF_VARPUT, idout, id_3, temps(0) 
    637637 
    638   
     638 
    639639   NCDF_VARPUT, idout, id0,weight_full(*,*,0) 
    640640   NCDF_VARPUT, idout, id1,weight_full(*,*,1) 
     
    649649   NCDF_VARPUT, idout, id10,pointer_j_full(*,*,2) 
    650650   NCDF_VARPUT, idout, id11,pointer_j_full(*,*,3) 
    651    
     651 
    652652 
    653653 
  • trunk/INTERP2/naminterp2.pro

    r2 r48  
    2121; 
    2222; MODIFICATION HISTORY: 08/2002 Robinson Hordoir 
    23 ;                       03/2003 Robinson Hordoir & Christian Ethe  
     23;                       03/2003 Robinson Hordoir & Christian Ethe 
    2424; 
    2525;------------------------------------------------------------ 
     
    2727;------------------------------------------------------------ 
    2828;--------------------------------------------------- 
    29 ; INTERP2 : NAMELIST                     
     29; INTERP2 : NAMELIST 
    3030;--------------------------------------------------- 
    3131 
     
    3636 
    3737; From which ORCA grid 
    38 ; Please give geographical accuracy of your input grid  
     38; Please give geographical accuracy of your input grid 
    3939; (ex. for ORCA2, grid_def=2.) 
    4040 
     
    7171;**************************************** 
    7272 
    73 ; Number of levels  
     73; Number of levels 
    7474 
    7575nlevel=1 
     
    9595do_rempl = 0 
    9696 
    97 ; If extrapolation is required, how many interations shall be done ? 
     97; If extrapolation is required, how many iterations shall be done ? 
    9898 
    9999niterations = 10 
  • trunk/INTERP2/newinterp.pro

    r2 r48  
    1212; 
    1313; INPUTS : 
    14 ;         ORCA_GEO grid file + ORCA_GEO weight file + Input field  
     14;         ORCA_GEO grid file + ORCA_GEO weight file + Input field 
    1515;         on ORCA grid 
    1616; OUTPUTS : 
     
    108108 
    109109   for jj=0,jpj-1 do begin 
    110     
    111     
     110 
     111 
    112112   if mask_reg(ji,jj,0) NE 0 then begin 
    113113 
     
    117117                + weight(ji,jj,2)*input_field(pointer_i(ji,jj,2)+1,pointer_j(ji,jj,2),*,*) $ 
    118118                + weight(ji,jj,3)*input_field(pointer_i(ji,jj,3)+1,pointer_j(ji,jj,3),*,*) 
    119     
     119 
    120120   endif 
    121121 
     
    131131; Data of the input grid is duplicated for the northern boundary condition 
    132132 
    133 zdata_inv(0:jpi/2 -1 ,*,*,*) = zdata_north(jpi/2:jpi-1,*,*,*)  
    134 zdata_inv(jpi/2:jpi-1 ,*,*,*) = zdata_north(0:jpi/2-1,*,*,*)  
     133zdata_inv(0:jpi/2 -1 ,*,*,*) = zdata_north(jpi/2:jpi-1,*,*,*) 
     134zdata_inv(jpi/2:jpi-1 ,*,*,*) = zdata_north(0:jpi/2-1,*,*,*) 
    135135zdata_inv = reverse(zdata_inv,2) 
    136136zdata_north(*,jpj:jpj+jplus-1,*,*) = zdata_inv(*,jpj:jpj+jplus-1,*,*) 
     
    178178 
    179179; Attributes 
    180       
     180 
    181181   id0  = NCDF_VARDEF(idout, 'nav_lon'     , [xidout, yidout                ],/FLOAT ) 
    182182   id1  = NCDF_VARDEF(idout, 'nav_lat'     , [xidout, yidout                ],/FLOAT ) 
     
    207207 
    208208 
    209    
     209 
    210210   NCDF_CONTROL, idout, /ENDEF 
    211211 
     
    222222   NCDF_CLOSE, idout 
    223223 
    224    
    225     
     224 
     225 
    226226 
    227227end 
    228  
    229  
    230  
    231  
    232  
    233  
    234  
    235  
  • trunk/angle.pro

    r2 r48  
    1616;;      common 
    1717;;            /comcoh/ glamf,   : longitudes and latitudes at F-points 
    18 ;;                     gphif    
     18;;                     gphif 
    1919;; 
    2020;;   Output : 
    2121;;   ------- 
    2222;;      common 
    23 ;;            /comcoh/ gsinu,gcosu : sinus and cosinus of the angle  
    24 ;;                     gsinv,gcosv   between north-south direction  
    25 ;;                                   and the j-direction of the mesh 
     23;;            /comcoh/ gsinu,gcosu : sinus and cosinus of the angle 
     24;;                     gsinv,gcosv   between north-south direction 
     25;;                                   and the j-direction of the mesh 
    2626;; 
    2727;;   Modifications: 
     
    3737;;;--------------------------------------------------------------------- 
    3838; 
    39 ; 
    4039; I. Compute the cosinus and sinus 
    4140; ================================ 
    42 ;      
     41; 
    4342;     ... north pole direction & modulous (at u-point) 
    4443      zxnpu = 0. - fsxspp( glamu, gphiu ) 
    4544      zynpu = 0. - fsyspp( glamu, gphiu ) 
    4645      znnpu = zxnpu*zxnpu + zynpu*zynpu 
    47 ;      
     46; 
    4847;     ... north pole direction & modulous (at v-point) 
    4948      zxnpv = 0. - fsxspp( glamv, gphiv ) 
    5049      zynpv = 0. - fsyspp( glamv, gphiv ) 
    5150      znnpv = zxnpv*zxnpv + zynpv*zynpv 
    52 ;      
     51; 
    5352;     ... j-direction: f-point segment direction (u-point) 
    5453      zxffu=  fsxspp( glamf, gphif ) - fsxspp( shift(glamf, 0, 1), shift(gphif, 0, 1) ) 
     
    5655      zmnpfu= sqrt ( znnpu * ( zxffu*zxffu + zyffu*zyffu )  ) 
    5756 
    58       
    59 ;      
     57 
     58; 
    6059;     ... i-direction: f-point segment direction (v-point) 
    6160      zxffv=  fsxspp( glamf, gphif ) - fsxspp( shift(glamf, 1, 0), shift(gphif, 1, 0) ) 
    6261      zyffv=  fsyspp( glamf, gphif ) - fsyspp( shift(glamf, 1, 0), shift(gphif, 1, 0) ) 
    6362      zmnpfv= sqrt ( znnpv * ( zxffv*zxffv + zyffv*zyffv )  ) 
    64       
    65 ;      
     63 
     64; 
    6665;     ... cosinus and sinus using scalar and vectorial products 
    6766      gsinu = ( zxnpu*zyffu - zynpu*zxffu ) / zmnpfu 
     
    6968 
    7069 
    71 ;      
     70; 
    7271;     ... cosinus and sinus using scalar and vectorial products 
    7372;     (caution, rotation of 90 degres) 
     
    7574      gcosv =-( zxnpv*zyffv - zynpv*zxffv ) / zmnpfv 
    7675 
    77       
    78 ;      
    79 ;      
     76 
     77; 
     78; 
    8079;     II. Geographic mesh 
    8180;     =================== 
    82 ;      
    83 ;      
     81; 
     82; 
    8483      ind = where(abs(glamf-shift(glamf, 0, 1)) LT 1.e-8) 
    8584      gsinu(ind) = 0.d 
    8685      gcosu(ind) = 1.d 
    87 ;      
     86; 
    8887      ind = where(abs(gphif-shift(gphif, 1, 0)) LT 1.e-8) 
    8988      gsinv(ind) = 0.d 
     
    9190; 
    9291return 
    93 END  
     92END 
  • trunk/common_interp.pro

    r41 r48  
    11;+ 
    22; 
    3 ; @history  
     3; @history 
    44; 11/99 A. Jouzeau 
    55; 10/2001 R. Hordoir, Added variables for 
     
    88; 03/2003 R. Hordoir, Added variables for 
    99; irregular input grid 
    10 ;                        
     10; 
    1111;- 
    1212;----------------------------------------------------------------------- 
  • trunk/condmag_from_orca.pro

    r41 r48  
    2727; to specify on which grid we do the interpolation T, U, V 
    2828; must belong to T, U or V 
    29 ; ++ je ne sais pas comment ce paramètre doit intervenir 
     29; ++ je ne sais pas comment ce paramÚtre doit intervenir 
    3030; 
    3131; @keyword DRAKKAR_EXP 
     
    3333; only used when orcares = ORCA025 
    3434; must be G42 ++ G70 
    35 ; ++ je ne sais pas comment ce paramètre doit intervenir a priori 
    36 ; la partie mesh est la même pour toutes les expériences mais attention 
    37 ; pas forcément le mask. 
     35; ++ je ne sais pas comment ce paramÚtre doit intervenir a priori 
     36; la partie mesh est la même pour toutes les expériences mais attention 
     37; pas forcément le mask. 
    3838; 
    3939; @keyword PERF 
     
    8888PRO condmag_from_orca, orcares, method, gridtype, DRAKKAR_EXP = drakkar_exp, PERF = perf 
    8989; 
    90   compile_opt idl2, strictarrsubs 
    91 ; 
    92 IF keyword_set(perf) EQ 1 THEN BEGIN 
    93     msg = 'iii : start profiler' 
     90    compile_opt idl2, strictarrsubs 
     91    ; 
     92    IF keyword_set(perf) EQ 1 THEN BEGIN 
     93        msg = 'iii : start profiler' 
     94        ras = report(msg) 
     95        ;PROFILER, /SYSTEM & PROFILER 
     96        PROFILER, /SYSTEM & PROFILER 
     97        ; ++ ne tracera que les modules compilés au moment de l'appel à cette commande 
     98        ; donc ++ regarder si on a bien tout et si on doit ajouter des PROFILER,toto dans 
     99        ; tous les modules 
     100    ENDIF 
     101        ; 
     102        ;---- 
     103        ; check input parameters 
     104        ;---- 
     105        ; 
     106        ; check orcares definition 
     107        ; 
     108        CASE orcares OF 
     109           'ORCA2': BEGIN 
     110                     msg = 'iii : valid orcares parameter = ' + orcares 
     111                     ras = report(msg) 
     112                     filename_oce = 'meshmask_bab.nc' 
     113                     IF keyword_set(DRAKKAR_EXP) THEN BEGIN 
     114                        msg = 'www : unused DRAKKAR_EXP keyword = ' + drakkar_exp 
     115                        ras = report(msg) 
     116                     END 
     117                  END 
     118         'ORCA025': BEGIN 
     119                     msg = 'iii : valid orcares parameter = ' + orcares 
     120                     ras = report(msg) 
     121                     IF keyword_set(DRAKKAR_EXP) THEN BEGIN 
     122                        msg = 'iii : DRAKKAR_EXP keyword set' 
     123                        ras = report(msg) 
     124                        msg = 'iii : DRAKKAR_EXP = ' + drakkar_exp 
     125                        ras = report(msg) 
     126                        CASE drakkar_exp OF 
     127                           'G42' : BEGIN 
     128                                      msg = 'iii : valid DRAKKAR_EXP keyword = ' + drakkar_exp 
     129                                      ras = report(msg) 
     130                                   END 
     131                           'G70' : BEGIN 
     132                                      msg = 'iii : valid DRAKKAR_EXP keyword = ' + drakkar_exp 
     133                                      ras = report(msg) 
     134                                   END 
     135                           ELSE : BEGIN 
     136                                      msg = 'eee : invalid DRAKKAR_EXP keyword = ' + drakkar_exp 
     137                                      ras = report(msg) 
     138                                      RETURN 
     139                                  END 
     140                        ENDCASE 
     141                        filename_oce = orcares + '-' + drakkar_exp + '_mesh_hgr.nc' 
     142                     ENDIF ELSE BEGIN 
     143                        msg = 'eee : unset DRAKKAR_EXP keyword' 
     144                        ras = report(msg) 
     145                        msg = 'eee : orcares must be G42 or G70' 
     146                        ras = report(msg) 
     147                        RETURN 
     148                     ENDELSE 
     149                  END 
     150          ELSE : BEGIN 
     151                     msg = 'eee : invalid orcares parameter = ' + orcares 
     152                     ras = report(msg) 
     153                     msg = 'eee : orcares must be ORCA2 or ORCA025' 
     154                     ras = report(msg) 
     155                     RETURN 
     156                  END 
     157      ENDCASE 
     158        ; 
     159        ; check method definition 
     160      CASE method OF 
     161         'bilinear': BEGIN 
     162                        msg = 'iii : valid method parameter = ' + method 
     163                        ras = report(msg) 
     164                     END 
     165         ELSE      : BEGIN 
     166                        msg = 'eee : invalid method parameter = ' + method 
     167                        ras = report(msg) 
     168                        msg = 'eee : method must be bilinear' 
     169                        ras = report(msg) 
     170                        RETURN 
     171                     END 
     172      ENDCASE 
     173        ; 
     174        ; check gridtype definition 
     175      gridtype = strupcase(gridtype) 
     176      CASE gridtype OF 
     177         'T' : BEGIN 
     178                  msg = 'iii : valid gridtype parameter = ' + gridtype 
     179                  ras = report(msg) 
     180               END 
     181         'U' : BEGIN 
     182                  msg = 'iii : valid gridtype parameter = ' + gridtype 
     183                  ras = report(msg) 
     184               END 
     185         'V' : BEGIN 
     186                  msg = 'iii : valid gridtype parameter = ' + gridtype 
     187                  ras = report(msg) 
     188               END 
     189         ELSE : BEGIN 
     190                  msg = 'eee : invalid gridtype parameter = ' + gridtype 
     191                  ras = report(msg) 
     192                  msg = 'eee : gridtype must be T, U or V' 
     193                  ras = report(msg) 
     194                  RETURN 
     195         END 
     196    ENDCASE 
     197        ; 
     198        ; check for input files 
     199        ; 
     200        ; test if ${GEOMAG_ID} defined 
     201        geomag_id_env=GETENV('GEOMAG_ID') 
     202        CASE geomag_id_env OF 
     203         ''  :  BEGIN 
     204                  msg = 'eee : ${GEOMAG_ID} is not defined' 
     205                  ras = report(msg) 
     206                  RETURN 
     207                END 
     208         ELSE: BEGIN 
     209                 msg = 'iii : ${GEOMAG_ID} is ' + geomag_id_env 
     210                 ras = report(msg) 
     211               END 
     212        ENDCASE 
     213        ; 
     214        iodirin = isadirectory(geomag_id_env) 
     215        ; 
     216        ; existence and protection of ${GEOMAG_ID} 
     217        IF (FILE_TEST(iodirin, /DIRECTORY,/EXECUTABLE , /READ) EQ 0) THEN BEGIN 
     218           msg = 'eee : the directory' + iodirin  + ' is not accessible.' 
     219           ras = report(msg) 
     220           RETURN 
     221        ENDIF 
     222        ; 
     223        ; build input filenames 
     224        filename_cond_sed = 'cond_sed' + '_' + orcares +'.nc' 
     225        fullfilename_cond_sed = iodirin + filename_cond_sed 
     226        ; 
     227        ; check if this file exists 
     228        fullfilename_cond_sed = isafile(iodirin + filename_cond_sed, NEW=0,/MUST_EXIST) 
     229        IF fullfilename_cond_sed[0] EQ '' THEN BEGIN 
     230           msg = 'eee : the file ' + fullfilename_cond_sed + ' was not found.' 
     231           ras = report(msg) 
     232           RETURN 
     233        ENDIF 
     234        ; 
     235        ; protection 
     236        IF (FILE_TEST(fullfilename_cond_sed[0], /READ) EQ 0) THEN BEGIN 
     237           msg = 'eee : the file ' + fullfilename_cond_sed[0] + ' is not readable.' 
     238           ras = report(msg) 
     239           RETURN 
     240        ENDIF 
     241        ; 
     242        filename_Br = 'Br' + '_' + orcares +'.nc' 
     243        fullfilename_Br = iodirin + filename_Br 
     244        ; 
     245        ; check if this file exists 
     246        fullfilename_Br = isafile(iodirin + filename_Br, NEW=0,/MUST_EXIST) 
     247        IF fullfilename_Br[0] EQ '' THEN BEGIN 
     248           msg = 'eee : the file ' + fullfilename_Br + ' was not found.' 
     249           ras = report(msg) 
     250           RETURN 
     251        ENDIF 
     252        ; 
     253        ; protection 
     254        IF (FILE_TEST(fullfilename_Br[0], /READ) EQ 0) THEN BEGIN 
     255           msg = 'eee : the file ' + fullfilename_Br[0] + ' is not readable.' 
     256           ras = report(msg) 
     257           RETURN 
     258        ENDIF 
     259        ; 
     260        ; mesh mask 
     261        ; check if this file exists 
     262        fullfilename_oce = isafile(iodirin + filename_oce, NEW=0, /MUST_EXIST, $ 
     263                           RECURSIVE=0) 
     264        IF fullfilename_oce[0] EQ '' THEN BEGIN 
     265           msg = 'eee : the file ' + fullfilename_oce + ' was not found.' 
     266           ras = report(msg) 
     267           RETURN 
     268        ENDIF 
     269        ; 
     270        ; protection 
     271        IF (FILE_TEST(fullfilename_oce[0], /READ) EQ 0) THEN BEGIN 
     272           msg = 'eee : the file ' + fullfilename_oce[0] + ' is not readable.' 
     273           ras = report(msg) 
     274           RETURN 
     275        ENDIF 
     276        ; 
     277        filename_condmag = 'condmag.nc' 
     278        fullfilename_condmag = iodirin + filename_condmag 
     279        ; 
     280        ; check if this file exists 
     281        fullfilename_condmag = isafile(iodirin + filename_condmag, NEW=0,/MUST_EXIST) 
     282        IF fullfilename_condmag[0] EQ '' THEN BEGIN 
     283           msg = 'eee : the file ' + fullfilename_condmag + ' was not found.' 
     284           ras = report(msg) 
     285           RETURN 
     286        ENDIF 
     287        ; 
     288        ; protection 
     289        IF (FILE_TEST(fullfilename_condmag[0], /READ) EQ 0) THEN BEGIN 
     290           msg = 'eee : the file ' + fullfilename_condmag[0] + ' is not readable.' 
     291           ras = report(msg) 
     292           RETURN 
     293        ENDIF 
     294        ; 
     295        ; test if ${GEOMAG_OD} defined 
     296        geomag_od_env=GETENV('GEOMAG_OD') 
     297        CASE geomag_od_env OF 
     298           '' : BEGIN 
     299                   msg = 'eee : ${GEOMAG_OD} is not defined' 
     300                   ras = report(msg) 
     301                   RETURN 
     302                END 
     303           ELSE: BEGIN 
     304                   msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env 
     305                   ras = report(msg) 
     306                 END 
     307        ENDCASE 
     308        ; 
     309        ; check if output data will be possible 
     310        iodirout = isadirectory(geomag_od_env) 
     311        ; 
     312        ; existence and protection 
     313        IF (FILE_TEST(iodirout, /DIRECTORY,/WRITE) EQ 0) THEN BEGIN 
     314           msg = 'eee : the directory' + iodirout  + ' was not found.' 
     315           ras = report(msg) 
     316           RETURN 
     317        ENDIF 
     318        ; 
     319        ; build output filename 
     320        filename = 'condmag_from_' +  orcares +'.nc' 
     321        fullfilename = iodirout + filename 
     322        ; 
     323        ; in order to avoid unexpected overwritten 
     324        IF (FILE_TEST(fullfilename) EQ 1) THEN BEGIN 
     325           msg = 'eee : the file ' + fullfilename  + ' already exists.' 
     326           ras = report(msg) 
     327           RETURN 
     328        ENDIF 
     329        ; 
     330        ;---- 
     331        ; Oceanic grid parameters ie input grid + mask 
     332        ;---- 
     333        ; 
     334        initocemesh, orcares, DRAKKAR_EXP = drakkar_exp 
     335        ; 
     336        ;---- 
     337        ; read data to interpolate on regular grid 
     338        ;---- 
     339        ; 
     340    a=read_ncdf('cond_sed', 0, /timestep, $ 
     341    file = fullfilename_cond_sed[0], /nostruct) 
     342    msg = 'iii : ' + fullfilename_cond_sed[0] + ' opened for read' 
    94343    ras = report(msg) 
    95     ;PROFILER, /SYSTEM & PROFILER 
    96     PROFILER, /SYSTEM & PROFILER 
    97 ; ++ ne tracera que les modules compilés au moment de l'appel à cette commande 
    98 ; donc ++ regarder si on a bien tout et si on doit ajouter des  PROFILER,toto dans 
    99 ; tous les modules 
    100 ENDIF 
    101 ; 
    102 ;---- 
    103 ; check input parameters 
    104 ;---- 
    105 ; 
    106 ; check orcares definition 
    107 ; 
    108   CASE orcares OF 
    109      'ORCA2': BEGIN 
    110                  msg = 'iii : valid orcares parameter = ' + orcares 
    111                  ras = report(msg) 
    112                  filename_oce = 'meshmask_bab.nc' 
    113                  IF keyword_set(DRAKKAR_EXP) THEN BEGIN 
    114                     msg = 'www : unused DRAKKAR_EXP keyword = ' + drakkar_exp 
    115                     ras = report(msg) 
    116                  END 
    117               END 
    118      'ORCA025': BEGIN 
    119                  msg = 'iii : valid orcares parameter = ' + orcares 
    120                  ras = report(msg) 
    121                  IF keyword_set(DRAKKAR_EXP) THEN BEGIN 
    122                     msg = 'iii : DRAKKAR_EXP keyword set' 
    123                     ras = report(msg) 
    124                     msg = 'iii : DRAKKAR_EXP = ' + drakkar_exp 
    125                     ras = report(msg) 
    126                     CASE drakkar_exp OF 
    127                        'G42' : BEGIN 
    128                                   msg = 'iii : valid DRAKKAR_EXP keyword = ' + drakkar_exp 
    129                                   ras = report(msg) 
    130                                END 
    131                        'G70' : BEGIN 
    132                                   msg = 'iii : valid DRAKKAR_EXP keyword = ' + drakkar_exp 
    133                                   ras = report(msg) 
    134                                END 
    135                        ELSE : BEGIN 
    136                                   msg = 'eee : invalid DRAKKAR_EXP keyword = ' + drakkar_exp 
    137                                   ras = report(msg) 
    138                                   RETURN 
    139                               END 
    140                     ENDCASE 
    141                     filename_oce = orcares + '-' + drakkar_exp + '_mesh_hgr.nc' 
    142                  ENDIF ELSE BEGIN 
    143                     msg = 'eee : unset DRAKKAR_EXP keyword' 
    144                     ras = report(msg) 
    145                     msg = 'eee : orcares must be G42 or G70' 
    146                     ras = report(msg) 
    147                     RETURN 
    148                  ENDELSE 
    149               END 
    150       ELSE  : BEGIN 
    151                  msg = 'eee : invalid orcares parameter = ' + orcares 
    152                  ras = report(msg) 
    153                  msg = 'eee : orcares must be ORCA2 or ORCA025' 
    154                  ras = report(msg) 
    155                  RETURN 
    156               END 
    157   ENDCASE 
    158 ; 
    159 ; check method definition 
    160   CASE method OF 
    161      'bilinear': BEGIN 
    162                     msg = 'iii : valid method parameter = ' + method 
    163                     ras = report(msg) 
    164                  END 
    165      ELSE      : BEGIN 
    166                     msg = 'eee : invalid method parameter = ' + method 
    167                     ras = report(msg) 
    168                     msg = 'eee : method must be bilinear' 
    169                     ras = report(msg) 
    170                     RETURN 
    171                  END 
    172   ENDCASE 
    173 ; 
    174 ; check gridtype definition 
    175   gridtype = strupcase(gridtype) 
    176   CASE gridtype OF 
    177      'T' : BEGIN 
    178               msg = 'iii : valid gridtype parameter = ' + gridtype 
    179               ras = report(msg) 
    180            END 
    181      'U' : BEGIN 
    182               msg = 'iii : valid gridtype parameter = ' + gridtype 
    183               ras = report(msg) 
    184            END 
    185      'V' : BEGIN 
    186               msg = 'iii : valid gridtype parameter = ' + gridtype 
    187               ras = report(msg) 
    188            END 
    189      ELSE: BEGIN 
    190               msg = 'eee : invalid gridtype parameter = ' + gridtype 
    191               ras = report(msg) 
    192               msg = 'eee : gridtype must be T, U or V' 
    193               ras = report(msg) 
    194               RETURN 
    195            END 
    196   ENDCASE 
    197 ; 
    198 ; check for input files 
    199 ; 
    200 ; test if ${GEOMAG_ID} defined 
    201   geomag_id_env=GETENV('GEOMAG_ID') 
    202   CASE geomag_id_env OF 
    203      ''  :  BEGIN 
    204               msg = 'eee : ${GEOMAG_ID} is not defined' 
    205               ras = report(msg) 
    206               RETURN 
    207             END 
    208      ELSE: BEGIN 
    209              msg = 'iii : ${GEOMAG_ID} is ' + geomag_id_env 
    210              ras = report(msg) 
    211            END 
    212   ENDCASE 
    213 ; 
    214   iodirin = isadirectory(geomag_id_env) 
    215 ; 
    216 ; existence and protection of ${GEOMAG_ID} 
    217   IF (FILE_TEST(iodirin, /DIRECTORY,/EXECUTABLE , /READ) EQ 0) THEN BEGIN 
    218      msg = 'eee : the directory' + iodirin  + ' is not accessible.' 
    219      ras = report(msg) 
    220      RETURN 
    221   ENDIF 
    222 ; 
    223 ; build input filenames 
    224   filename_cond_sed = 'cond_sed' + '_' + orcares +'.nc' 
    225   fullfilename_cond_sed = iodirin + filename_cond_sed 
    226 ; 
    227 ; check if this file exists 
    228   fullfilename_cond_sed = isafile(iodirin + filename_cond_sed, NEW=0,/MUST_EXIST) 
    229   IF fullfilename_cond_sed[0] EQ '' THEN BEGIN 
    230      msg = 'eee : the file ' + fullfilename_cond_sed + ' was not found.' 
    231      ras = report(msg) 
    232      RETURN 
    233   ENDIF 
    234 ; 
    235 ; protection 
    236   IF (FILE_TEST(fullfilename_cond_sed[0], /READ) EQ 0) THEN BEGIN 
    237      msg = 'eee : the file ' + fullfilename_cond_sed[0] + ' is not readable.' 
    238      ras = report(msg) 
    239      RETURN 
    240   ENDIF 
    241 ; 
    242   filename_Br = 'Br' + '_' + orcares +'.nc' 
    243   fullfilename_Br = iodirin + filename_Br 
    244 ; 
    245 ; check if this file exists 
    246   fullfilename_Br = isafile(iodirin + filename_Br, NEW=0,/MUST_EXIST) 
    247   IF fullfilename_Br[0] EQ '' THEN BEGIN 
    248      msg = 'eee : the file ' + fullfilename_Br + ' was not found.' 
    249      ras = report(msg) 
    250      RETURN 
    251   ENDIF 
    252 ; 
    253 ; protection 
    254   IF (FILE_TEST(fullfilename_Br[0], /READ) EQ 0) THEN BEGIN 
    255      msg = 'eee : the file ' + fullfilename_Br[0] + ' is not readable.' 
    256      ras = report(msg) 
    257      RETURN 
    258   ENDIF 
    259 ; 
    260 ; mesh mask 
    261 ; check if this file exists 
    262   fullfilename_oce = isafile(iodirin + filename_oce, NEW=0, /MUST_EXIST, $ 
    263                      RECURSIVE=0) 
    264   IF fullfilename_oce[0] EQ '' THEN BEGIN 
    265      msg = 'eee : the file ' + fullfilename_oce + ' was not found.' 
    266      ras = report(msg) 
    267      RETURN 
    268   ENDIF 
    269 ; 
    270 ; protection 
    271   IF (FILE_TEST(fullfilename_oce[0], /READ) EQ 0) THEN BEGIN 
    272      msg = 'eee : the file ' + fullfilename_oce[0] + ' is not readable.' 
    273      ras = report(msg) 
    274      RETURN 
    275   ENDIF 
    276 ; 
    277   filename_condmag = 'condmag.nc' 
    278   fullfilename_condmag = iodirin + filename_condmag 
    279 ; 
    280 ; check if this file exists 
    281   fullfilename_condmag = isafile(iodirin + filename_condmag, NEW=0,/MUST_EXIST) 
    282   IF fullfilename_condmag[0] EQ '' THEN BEGIN 
    283      msg = 'eee : the file ' + fullfilename_condmag + ' was not found.' 
    284      ras = report(msg) 
    285      RETURN 
    286   ENDIF 
    287 ; 
    288 ; protection 
    289   IF (FILE_TEST(fullfilename_condmag[0], /READ) EQ 0) THEN BEGIN 
    290      msg = 'eee : the file ' + fullfilename_condmag[0] + ' is not readable.' 
    291      ras = report(msg) 
    292      RETURN 
    293   ENDIF 
    294 ; 
    295 ; test if ${GEOMAG_OD} defined 
    296   geomag_od_env=GETENV('GEOMAG_OD') 
    297   CASE geomag_od_env OF 
    298      '' : BEGIN 
    299              msg = 'eee : ${GEOMAG_OD} is not defined' 
    300              ras = report(msg) 
    301              RETURN 
    302           END 
    303      ELSE: BEGIN 
    304              msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env 
    305              ras = report(msg) 
    306            END 
    307   ENDCASE 
    308 ; 
    309 ; check if output data will be possible 
    310   iodirout = isadirectory(geomag_od_env) 
    311 ; 
    312 ; existence and protection 
    313   IF (FILE_TEST(iodirout, /DIRECTORY,/WRITE) EQ 0) THEN BEGIN 
    314      msg = 'eee : the directory' + iodirout  + ' was not found.' 
    315      ras = report(msg) 
    316      RETURN 
    317   ENDIF 
    318 ; 
    319 ; build output filename 
    320   filename = 'condmag_from_' +  orcares +'.nc' 
    321   fullfilename = iodirout + filename 
    322 ; 
    323 ; in order to avoid unexpected overwritten 
    324   IF (FILE_TEST(fullfilename) EQ 1) THEN BEGIN 
    325      msg = 'eee : the file ' + fullfilename  + ' already exists.' 
    326      ras = report(msg) 
    327      RETURN 
    328   ENDIF 
    329 ; 
    330 ;---- 
    331 ; Oceanic grid parameters ie input grid + mask 
    332 ;---- 
    333 ; 
    334 initocemesh, orcares, DRAKKAR_EXP = drakkar_exp 
    335 ; 
    336 ;---- 
    337 ; read data to interpolate on regular grid 
    338 ;---- 
    339 ; 
    340 a=read_ncdf('cond_sed', 0, /timestep, $ 
    341 file = fullfilename_cond_sed[0], /nostruct) 
    342 msg = 'iii : ' + fullfilename_cond_sed[0] + ' opened for read' 
    343 ras = report(msg) 
    344 ; mask and limite cond_sed on values below 5000 ++ 
    345 cond_sedin = extrapsmooth(a, tmask[*, *, 0]*(a le 5000), /x_periodic) 
    346 ; 
    347 b = read_ncdf('Br', 0, /timestep, $ 
    348 file = fullfilename_Br[0], /nostruct) 
    349 msg = 'iii : ' + fullfilename_Br[0] + ' opened for read' 
    350 ras = report(msg) 
    351 ; mask and limit Br on values below/above ++ 
    352 Brin = extrapsmooth(b, tmask[*, *, 0]*(b), /x_periodic) 
    353 ; 
    354 glamin = glamt 
    355 gphiin = gphit 
    356 maskin = tmask[*, *, 0] 
    357 ; 
    358 ;--- 
    359 ; conductivity and magnetic field grid parameters ie output grid 
    360 ;---- 
     344        ; mask and limite cond_sed on values below 5000 ++ 
     345    cond_sedin = extrapsmooth(a, tmask[*, *, 0]*(a le 5000), /x_periodic) 
     346        ; 
     347    b = read_ncdf('Br', 0, /timestep, $ 
     348    file = fullfilename_Br[0], /nostruct) 
     349    msg = 'iii : ' + fullfilename_Br[0] + ' opened for read' 
     350    ras = report(msg) 
     351        ; mask and limit Br on values below/above ++ 
     352    Brin = extrapsmooth(b, tmask[*, *, 0]*(b), /x_periodic) 
     353        ; 
     354    glamin = glamt 
     355    gphiin = gphit 
     356    maskin = tmask[*, *, 0] 
     357        ; 
     358        ;--- 
     359        ; conductivity and magnetic field grid parameters ie output grid 
     360        ;---- 
    361361 
    362 initncdf, fullfilename_condmag[0], xaxisname = 'lo', yaxisname = 'la' 
    363 msg = 'iii : ' + fullfilename_condmag[0] + ' opened for read' 
    364 ras = report(msg) 
    365 ; 
    366 glamout = glamt 
    367 gphiout = gphit 
    368 ; 
     362    initncdf, fullfilename_condmag[0], xaxisname = 'lo', yaxisname = 'la' 
     363    msg = 'iii : ' + fullfilename_condmag[0] + ' opened for read' 
     364    ras = report(msg) 
     365        ; 
     366    glamout = glamt 
     367    gphiout = gphit 
     368        ; 
    369369 
    370 dimidxout = jpi 
    371 dimidyout = jpj 
    372 ; 
    373 ;--------------- 
    374 ; Interpolate 
    375 ;--------------- 
    376 ;++ cond_sedout = fromirr('bilinear', cond_sedin, glamin, gphiin, maskin,  glamout, gphiout, -1,  WEIG = weights, ADDR = addresses) 
     370    dimidxout = jpi 
     371    dimidyout = jpj 
     372    ; 
     373    ;--------------- 
     374    ; Interpolate 
     375    ;--------------- 
     376    ;++ cond_sedout = fromirr('bilinear', cond_sedin, glamin, gphiin, maskin,  glamout, gphiout, -1,  WEIG = weights, ADDR = addresses) 
    377377cond_sedout=dindgen(dimidxout,dimidyout) 
    378 ;Brout=fromirr('bilinear', Brin, weights, addresses) ; ++ pb doc % Variable is undefined: LONOUT 
    379 ;++Brout = fromirr('bilinear', Brin, glamin, gphiin, maskin,  glamout, gphiout, -1,  WEIG = weights, ADDR = addresses) 
    380 ; 
     378    ;Brout=fromirr('bilinear', Brin, weights, addresses) ; ++ pb doc % Variable is undefined: LONOUT 
     379    ;++Brout = fromirr('bilinear', Brin, glamin, gphiin, maskin,  glamout, gphiout, -1,  WEIG = weights, ADDR = addresses) 
     380    ; 
    381381Brout=dindgen(dimidxout,dimidyout) 
    382382 
    383 ; 
    384 ;--------------- 
    385 ; Produce outputs 
    386 ;--------------- 
    387 ; 
    388   netcdf_id = NCDF_CREATE(fullfilename, /clobber) 
    389   NCDF_CONTROL, netcdf_id, /NOFILL 
    390 ; 
    391 ; dimension 
    392   dimidxout = NCDF_DIMDEF(netcdf_id, 'la' ,  jpi) 
    393   dimidyout = NCDF_DIMDEF(netcdf_id, 'lo' ,  jpj) 
    394 ; 
    395 ; global attributes 
    396   NCDF_ATTPUT, netcdf_id, 'Conventions', 'GDT 1.2', /GLOBAL ; ++ conformite 
    397 ;++  NCDF_ATTPUT, netcdf_id, 'file_name'  , filename, /GLOBAL 
    398 ;++  NCDF_ATTPUT, netcdf_id, 'Title'      , title, /GLOBAL 
    399 ; 
    400 ; declaration of variables 
    401   varid = lonarr(4) 
    402 ; 
    403   varid[0] = NCDF_VARDEF(netcdf_id, 'la'  , [dimidxout], /FLOAT) 
    404   varid[1] = NCDF_VARDEF(netcdf_id, 'lo'  , [dimidyout], /FLOAT) 
    405   varid[2] = NCDF_VARDEF(netcdf_id, 'cond_sed'  , [dimidxout, dimidyout], /FLOAT) 
    406   NCDF_ATTPUT, netcdf_id, varid[2], 'units'    , 'siemens' 
    407   varid[3] = NCDF_VARDEF(netcdf_id, 'Br'  , [dimidxout, dimidyout], /FLOAT) 
    408   NCDF_ATTPUT, netcdf_id, varid[3], 'units'    , 'siemens' 
    409 ; 
    410   NCDF_CONTROL, netcdf_id, /ENDEF 
    411 ; 
    412   NCDF_VARPUT, netcdf_id, varid[0], dindgen(dimidxout,dimidyout) 
    413   NCDF_VARPUT, netcdf_id, varid[1], dindgen(dimidyout,dimidyout) 
    414 ; 
    415 ; write the data 
    416 ; 
    417   NCDF_VARPUT, netcdf_id, varid[2], cond_sedout 
    418 ;++  NCDF_VARPUT, netcdf_id, 'Br', Brout 
    419 ;--------------------------- 
    420 ; close the netcdf files 
    421   NCDF_CLOSE, netcdf_id 
    422 ; 
    423   msg = 'iii : ' + fullfilename + ' created' 
    424   ras = report(msg) 
    425 ; 
    426 IF keyword_set(perf) EQ 1 THEN BEGIN 
    427   msg = 'iii : report profiler results' 
    428   ras = report(msg) 
    429 ; ++ tri par ordre alpha , par ordre de pourcentage croissant ou décroissant 
    430 ; +++ d'utilisation 
    431   profiler,/REPORT 
    432 ;  shut down all profiling (according to 
    433 ; http://www.dfanning.com/code_tips/whyslow.html) 
    434   profiler, /CLEAR, /SYSTEM 
    435   profiler, /CLEAR, /RESET 
     383    ; 
     384    ;--------------- 
     385    ; Produce outputs 
     386    ;--------------- 
     387    ; 
     388    netcdf_id = NCDF_CREATE(fullfilename, /clobber) 
     389    NCDF_CONTROL, netcdf_id, /NOFILL 
     390    ; 
     391    ; dimension 
     392    dimidxout = NCDF_DIMDEF(netcdf_id, 'la' ,  jpi) 
     393    dimidyout = NCDF_DIMDEF(netcdf_id, 'lo' ,  jpj) 
     394    ; 
     395    ; global attributes 
     396    NCDF_ATTPUT, netcdf_id, 'Conventions', 'GDT 1.2', /GLOBAL ; ++ conformite 
     397    ;++  NCDF_ATTPUT, netcdf_id, 'file_name'  , filename, /GLOBAL 
     398    ;++  NCDF_ATTPUT, netcdf_id, 'Title'      , title, /GLOBAL 
     399    ; 
     400    ; declaration of variables 
     401    varid = lonarr(4) 
     402    ; 
     403    varid[0] = NCDF_VARDEF(netcdf_id, 'la'  , [dimidxout], /FLOAT) 
     404    varid[1] = NCDF_VARDEF(netcdf_id, 'lo'  , [dimidyout], /FLOAT) 
     405    varid[2] = NCDF_VARDEF(netcdf_id, 'cond_sed'  , [dimidxout, dimidyout], /FLOAT) 
     406    NCDF_ATTPUT, netcdf_id, varid[2], 'units'    , 'siemens' 
     407    varid[3] = NCDF_VARDEF(netcdf_id, 'Br'  , [dimidxout, dimidyout], /FLOAT) 
     408    NCDF_ATTPUT, netcdf_id, varid[3], 'units'    , 'siemens' 
     409    ; 
     410    NCDF_CONTROL, netcdf_id, /ENDEF 
     411    ; 
     412    NCDF_VARPUT, netcdf_id, varid[0], dindgen(dimidxout,dimidyout) 
     413    NCDF_VARPUT, netcdf_id, varid[1], dindgen(dimidyout,dimidyout) 
     414    ; 
     415    ; write the data 
     416    ; 
     417    NCDF_VARPUT, netcdf_id, varid[2], cond_sedout 
     418    ;++  NCDF_VARPUT, netcdf_id, 'Br', Brout 
     419    ;--------------------------- 
     420    ; close the netcdf files 
     421    NCDF_CLOSE, netcdf_id 
     422    ; 
     423    msg = 'iii : ' + fullfilename + ' created' 
     424    ras = report(msg) 
     425    ; 
     426    IF keyword_set(perf) EQ 1 THEN BEGIN 
     427        msg = 'iii : report profiler results' 
     428        ras = report(msg) 
     429        ; ++ tri par ordre alpha , par ordre de pourcentage croissant ou décroissant 
     430        ; +++ d'utilisation 
     431        profiler,/REPORT 
     432        ;  shut down all profiling (according to 
     433        ; http://www.dfanning.com/code_tips/whyslow.html) 
     434        profiler, /CLEAR, /SYSTEM 
     435        profiler, /CLEAR, /RESET 
    436436ENDIF 
    437 ; 
     437    ; 
    438438END 
  • trunk/condmag_on_orca.pro

    r41 r48  
    9292;- 
    9393PRO condmag_on_orca, orcares, method, gridtype, DRAKKAR_EXP = drakkar_exp 
    94 ; 
    95   compile_opt idl2, strictarrsubs 
    96 ; 
    97 ;---- 
    98 ; check input parameters 
    99 ;---- 
    100 ; 
    101 ; check orcares definition 
    102 ; 
    103   CASE orcares OF 
    104      'ORCA2': BEGIN 
     94    ; 
     95    compile_opt idl2, strictarrsubs 
     96    ; 
     97    ;---- 
     98    ; check input parameters 
     99    ;---- 
     100    ; 
     101    ; check orcares definition 
     102    ; 
     103    CASE orcares OF 
     104       'ORCA2': BEGIN 
    105105                 msg = 'iii : valid orcares parameter = ' + orcares 
    106106                 ras = report(msg) 
     
    111111                 END 
    112112              END 
    113      'ORCA025': BEGIN 
    114                  msg = 'iii : valid orcares parameter = ' + orcares 
     113       'ORCA025': BEGIN 
     114                   msg = 'iii : valid orcares parameter = ' + orcares 
    115115                 ras = report(msg) 
    116116                 IF keyword_set(DRAKKAR_EXP) THEN BEGIN 
     
    136136                    filename_oce = orcares + '-' + drakkar_exp + '_mesh_hgr.nc' 
    137137                 ENDIF ELSE BEGIN 
    138                     msg = 'eee : unset DRAKKAR_EXP keyword'  
     138                    msg = 'eee : unset DRAKKAR_EXP keyword' 
    139139                    ras = report(msg) 
    140140                    msg = 'eee : orcares must be G42 or G70' 
     
    143143                 ENDELSE 
    144144              END 
    145       ELSE : BEGIN 
     145        ELSE : BEGIN 
    146146                 msg = 'eee : invalid orcares parameter = ' + orcares 
    147147                 ras = report(msg) 
     
    149149                 ras = report(msg) 
    150150                 RETURN 
    151               END 
    152   ENDCASE 
    153 ; 
    154 ; check method definition 
    155   CASE method OF 
    156      'bilinear': BEGIN 
     151        END 
     152    ENDCASE 
     153    ; 
     154    ; check method definition 
     155    CASE method OF 
     156       'bilinear': BEGIN 
    157157                    msg = 'iii : valid method parameter = ' + method 
    158158                    ras = report(msg) 
     
    162162                    ras = report(msg) 
    163163                 END 
    164      ELSE      : BEGIN 
     164       ELSE      : BEGIN 
    165165                    msg = 'eee : invalid method parameter = ' + method 
    166166                    ras = report(msg) 
     
    169169                    RETURN 
    170170                 END 
    171   ENDCASE 
    172 ; 
    173 ; check gridtype definition 
    174   gridtype = strupcase(gridtype) 
    175   CASE gridtype OF 
    176      'T' : BEGIN 
     171    ENDCASE 
     172    ; 
     173    ; check gridtype definition 
     174    gridtype = strupcase(gridtype) 
     175    CASE gridtype OF 
     176       'T' : BEGIN 
    177177              msg = 'iii : valid gridtype parameter = ' + gridtype 
    178178              ras = report(msg) 
     
    186186              ras = report(msg) 
    187187           END 
    188      ELSE: BEGIN 
     188     ELSE : BEGIN 
    189189              msg = 'eee : invalid gridtype parameter = ' + gridtype 
    190190              ras = report(msg) 
     
    193193              RETURN 
    194194           END 
    195   ENDCASE 
    196 ; 
    197 ; check for input files 
    198 ; 
    199 ; test if ${GEOMAG_ID} defined 
    200   geomag_id_env=GETENV('GEOMAG_ID') 
    201   CASE geomag_id_env OF 
    202      ''  :  BEGIN 
     195    ENDCASE 
     196    ; 
     197    ; check for input files 
     198    ; 
     199    ; test if ${GEOMAG_ID} defined 
     200    geomag_id_env=GETENV('GEOMAG_ID') 
     201    CASE geomag_id_env OF 
     202       ''  :  BEGIN 
    203203              msg = 'eee : ${GEOMAG_ID} is not defined' 
    204204              ras = report(msg) 
     
    209209             ras = report(msg) 
    210210           END 
    211   ENDCASE 
    212 ; 
    213   iodirin = isadirectory(geomag_id_env) 
    214 ; 
    215 ; existence and protection of ${GEOMAG_ID} 
    216   IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN 
    217      msg = 'eee : the directory' + iodirin  + ' is not accessible.' 
    218      ras = report(msg) 
    219      RETURN 
    220   ENDIF 
    221 ; 
    222 ; conductivity and magnetic field 
    223   filename_condmag = 'condmag.nc' 
    224 ; 
    225 ; check if this file exists 
    226   fullfilename_condmag = isafile(iodirin + filename_condmag, NEW=0, /MUST_EXIST) 
    227   IF fullfilename_condmag[0] EQ '' THEN BEGIN 
    228      msg = 'eee : the file ' + fullfilename_condmag + ' was not found.' 
    229      ras = report(msg) 
    230      RETURN 
    231   ENDIF 
    232 ; 
    233 ; protection 
    234   IF (FILE_TEST(fullfilename_condmag[0], /READ) EQ 0) THEN BEGIN 
    235      msg = 'eee : the file ' + fullfilename_condmag[0] + ' is not readable.' 
    236      ras = report(msg) 
    237      RETURN 
    238   ENDIF 
    239 ; 
    240 ; mesh mask 
    241 ; check if this file exists 
    242   fullfilename_oce = isafile(iodirin + filename_oce, NEW=0, /MUST_EXIST, $ 
    243                      RECURSIVE=0) 
    244   IF fullfilename_oce[0] EQ '' THEN BEGIN 
    245      msg = 'eee : the file ' + fullfilename_oce + ' was not found.' 
    246      ras = report(msg) 
    247      RETURN 
    248   ENDIF 
    249 ; 
    250 ; protection 
    251   IF (FILE_TEST(fullfilename_oce[0], /READ) EQ 0) THEN BEGIN 
    252      msg = 'eee : the file ' + fullfilename_oce[0] + ' is not readable.' 
    253      ras = report(msg) 
    254      RETURN 
    255   ENDIF 
    256 ; 
    257 ; test if ${GEOMAG_OD} defined 
    258   geomag_od_env=GETENV('GEOMAG_OD') 
    259   CASE geomag_od_env OF 
    260      '' : BEGIN 
    261              msg = 'eee : ${GEOMAG_OD} is not defined' 
    262              ras = report(msg) 
     211    ENDCASE 
     212    ; 
     213    iodirin = isadirectory(geomag_id_env) 
     214    ; 
     215    ; existence and protection of ${GEOMAG_ID} 
     216    IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN 
     217       msg = 'eee : the directory' + iodirin  + ' is not accessible.' 
     218       ras = report(msg) 
     219       RETURN 
     220    ENDIF 
     221    ; 
     222    ; conductivity and magnetic field 
     223    filename_condmag = 'condmag.nc' 
     224    ; 
     225    ; check if this file exists 
     226    fullfilename_condmag = isafile(iodirin + filename_condmag, NEW=0, /MUST_EXIST) 
     227    IF fullfilename_condmag[0] EQ '' THEN BEGIN 
     228       msg = 'eee : the file ' + fullfilename_condmag + ' was not found.' 
     229       ras = report(msg) 
     230       RETURN 
     231    ENDIF 
     232    ; 
     233    ; protection 
     234    IF (FILE_TEST(fullfilename_condmag[0], /READ) EQ 0) THEN BEGIN 
     235       msg = 'eee : the file ' + fullfilename_condmag[0] + ' is not readable.' 
     236       ras = report(msg) 
     237       RETURN 
     238    ENDIF 
     239    ; 
     240    ; mesh mask 
     241    ; check if this file exists 
     242    fullfilename_oce = isafile(iodirin + filename_oce, NEW=0, /MUST_EXIST, $ 
     243    RECURSIVE=0) 
     244    IF fullfilename_oce[0] EQ '' THEN BEGIN 
     245       msg = 'eee : the file ' + fullfilename_oce + ' was not found.' 
     246       ras = report(msg) 
     247       RETURN 
     248    ENDIF 
     249    ; 
     250    ; protection 
     251    IF (FILE_TEST(fullfilename_oce[0], /READ) EQ 0) THEN BEGIN 
     252       msg = 'eee : the file ' + fullfilename_oce[0] + ' is not readable.' 
     253       ras = report(msg) 
     254       RETURN 
     255    ENDIF 
     256    ; 
     257    ; test if ${GEOMAG_OD} defined 
     258    geomag_od_env=GETENV('GEOMAG_OD') 
     259    CASE geomag_od_env OF 
     260       '' : BEGIN 
     261               msg = 'eee : ${GEOMAG_OD} is not defined' 
     262               ras = report(msg) 
    263263             RETURN 
    264264          END 
    265      ELSE: BEGIN 
    266              msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env 
     265       ELSE: BEGIN 
     266               msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env 
    267267             ras = report(msg) 
    268268           END 
    269   ENDCASE 
    270 ; 
    271 ; check if output data will be possible 
    272   iodirout = isadirectory(geomag_od_env) 
    273 ; 
    274 ; existence and protection 
    275   IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN 
    276      msg = 'eee : the directory' + iodirout  + ' was not found.' 
    277      ras = report(msg) 
    278      RETURN 
    279   ENDIF 
    280 ; 
    281 ; d'après ncdump -h /usr/work/sur/fvi/OPA/geomag/condmag.nc 
    282   condmaglonname = 'lo' 
    283   condmaglatname = 'la' 
    284 ; 
    285 ;---- 
    286 ; conductivity and magnetic field grid parameters 
    287 ;---- 
    288 ; 
    289   get_gridparams, fullfilename_condmag[0], $ 
    290      condmaglonname, condmaglatname, $ 
    291      condmaglon, condmaglat, jpia, jpja, 1, /DOUBLE 
    292 ; 
    293 ;---- 
    294 ; Oceanic grid parameters 
    295 ;---- 
    296 ; 
    297   olonname = 'glam' + STRLOWCASE(gridtype) 
    298   olatname = 'gphi' + STRLOWCASE(gridtype) 
    299   get_gridparams, fullfilename_oce[0], $ 
    300      olonname, olatname, $ 
    301      olon, olat, jpio, jpjo, 2, /DOUBLE 
    302   msg = 'iii : ' + fullfilename_oce[0] + ' opened for read' 
    303   ras = report(msg) 
    304 ; 
    305 ;--------------- 
    306 ; Compute weight and address 
    307 ;--------------- 
    308 ; 
    309   CASE method OF 
    310      'bilinear': compute_fromreg_bilinear_weigaddr, $ 
     269    ENDCASE 
     270    ; 
     271    ; check if output data will be possible 
     272    iodirout = isadirectory(geomag_od_env) 
     273    ; 
     274    ; existence and protection 
     275    IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN 
     276       msg = 'eee : the directory' + iodirout  + ' was not found.' 
     277       ras = report(msg) 
     278       RETURN 
     279    ENDIF 
     280    ; 
     281    ; d'aprÚs ncdump -h /usr/work/sur/fvi/OPA/geomag/condmag.nc 
     282    condmaglonname = 'lo' 
     283    condmaglatname = 'la' 
     284    ; 
     285    ;---- 
     286    ; conductivity and magnetic field grid parameters 
     287    ;---- 
     288    ; 
     289    get_gridparams, fullfilename_condmag[0], $ 
     290    condmaglonname, condmaglatname, $ 
     291    condmaglon, condmaglat, jpia, jpja, 1, /DOUBLE 
     292    ; 
     293    ;---- 
     294    ; Oceanic grid parameters 
     295    ;---- 
     296    ; 
     297    olonname = 'glam' + STRLOWCASE(gridtype) 
     298    olatname = 'gphi' + STRLOWCASE(gridtype) 
     299    get_gridparams, fullfilename_oce[0], $ 
     300    olonname, olatname, $ 
     301    olon, olat, jpio, jpjo, 2, /DOUBLE 
     302    msg = 'iii : ' + fullfilename_oce[0] + ' opened for read' 
     303    ras = report(msg) 
     304    ; 
     305    ;--------------- 
     306    ; Compute weight and address 
     307    ;--------------- 
     308    ; 
     309    CASE method OF 
     310       'bilinear': compute_fromreg_bilinear_weigaddr, $ 
     311                      condmaglon, condmaglat, olon, olat, weig, addr 
     312       'imoms3'  : compute_fromreg_imoms3_weigaddr, $ 
    311313                    condmaglon, condmaglat, olon, olat, weig, addr 
    312      'imoms3'  : compute_fromreg_imoms3_weigaddr, $ 
    313                     condmaglon, condmaglat, olon, olat, weig, addr 
    314   ENDCASE 
    315 ; 
    316 ; reading condmag file 
    317   netcdf_id_condmag = NCDF_OPEN(fullfilename_condmag[0], /NOWRITE) 
    318   msg = 'iii : ' + fullfilename_condmag[0] + ' opened for read' 
    319   ras = report(msg) 
    320 ; 
    321   varname_cond_sed = 'cond_sed' 
    322   varname_br = 'Br' 
    323 ; 
    324   varinq_cond_sed = NCDF_VARINQ(netcdf_id_condmag, varname_cond_sed) 
    325   NCDF_VARGET, netcdf_id_condmag, varname_cond_sed, varin_cond_sed 
    326 ; 
    327   varinq_br = NCDF_VARINQ(netcdf_id_condmag, varname_br) 
    328   NCDF_VARGET, netcdf_id_condmag, varname_br, varin_br 
    329 ; 
    330   NCDF_CLOSE, netcdf_id_condmag 
    331 ; 
    332 ;--------------------------- 
    333 ; do the interpolation 
    334       varin_cond_sed = TOTAL(weig*varin_cond_sed[addr], 1) 
    335       varin_cond_sed = REFORM(varin_cond_sed, jpio, jpjo, /OVER) 
    336       varin_br = TOTAL(weig*varin_br[addr], 1) 
    337       varin_br = REFORM(varin_br, jpio, jpjo, /OVER) 
    338 ; 
    339       varout_cond_sed = TEMPORARY(varin_cond_sed) 
    340       varout_br = TEMPORARY(varin_br) 
    341 ; 
    342 ; put back the masked value 
    343 ;++      IF bad[0] NE -1 THEN varout_cond_sed[TEMPORARY(bad)] = 32767 
    344 ;++      IF bad[0] NE -1 THEN varout_br[TEMPORARY(bad)] = 32767 
    345 ; 
    346 ; 
    347 ; produce outputs 
    348   condmag_output, orcares, $ 
    349      varinq_cond_sed, 'Conductance', 'Conductance', 'siemens', $ 
    350      jpio, jpjo, olon, olat, $ 
    351      varout_cond_sed 
    352   condmag_output, orcares, $ 
    353      varinq_br, 'Magnetic field', 'magnetic field', 'tesla', $ 
    354      jpio, jpjo, olon, olat, $ 
    355      varout_br 
    356 ; 
     314    ENDCASE 
     315    ; 
     316    ; reading condmag file 
     317    netcdf_id_condmag = NCDF_OPEN(fullfilename_condmag[0], /NOWRITE) 
     318    msg = 'iii : ' + fullfilename_condmag[0] + ' opened for read' 
     319    ras = report(msg) 
     320    ; 
     321    varname_cond_sed = 'cond_sed' 
     322    varname_br = 'Br' 
     323    ; 
     324    varinq_cond_sed = NCDF_VARINQ(netcdf_id_condmag, varname_cond_sed) 
     325    NCDF_VARGET, netcdf_id_condmag, varname_cond_sed, varin_cond_sed 
     326    ; 
     327    varinq_br = NCDF_VARINQ(netcdf_id_condmag, varname_br) 
     328    NCDF_VARGET, netcdf_id_condmag, varname_br, varin_br 
     329    ; 
     330    NCDF_CLOSE, netcdf_id_condmag 
     331    ; 
     332    ;--------------------------- 
     333    ; do the interpolation 
     334    varin_cond_sed = TOTAL(weig*varin_cond_sed[addr], 1) 
     335    varin_cond_sed = REFORM(varin_cond_sed, jpio, jpjo, /OVER) 
     336    varin_br = TOTAL(weig*varin_br[addr], 1) 
     337    varin_br = REFORM(varin_br, jpio, jpjo, /OVER) 
     338    ; 
     339    varout_cond_sed = TEMPORARY(varin_cond_sed) 
     340    varout_br = TEMPORARY(varin_br) 
     341    ; 
     342    ; put back the masked value 
     343    ;++      IF bad[0] NE -1 THEN varout_cond_sed[TEMPORARY(bad)] = 32767 
     344    ;++      IF bad[0] NE -1 THEN varout_br[TEMPORARY(bad)] = 32767 
     345    ; 
     346    ; 
     347    ; produce outputs 
     348    condmag_output, orcares, $ 
     349    varinq_cond_sed, 'Conductance', 'Conductance', 'siemens', $ 
     350    jpio, jpjo, olon, olat, $ 
     351    varout_cond_sed 
     352    condmag_output, orcares, $ 
     353    varinq_br, 'Magnetic field', 'magnetic field', 'tesla', $ 
     354    jpio, jpjo, olon, olat, $ 
     355    varout_br 
     356    ; 
    357357END 
  • trunk/condmag_output.pro

    r36 r48  
    7979;- 
    8080PRO condmag_output, orcares, variable, title, long_name, units, jpio, jpjo, olon, olat, values 
    81 ; 
    82   compile_opt idl2, strictarrsubs 
    83 ; 
    84 ;---- 
    85 ; check input parameters 
    86 ;---- 
    87 ; 
    88 ; check orcares definition 
    89 ; 
    90   CASE orcares OF 
    91      'ORCA2': BEGIN 
     81    ; 
     82    compile_opt idl2, strictarrsubs 
     83    ; 
     84    ;---- 
     85    ; check input parameters 
     86    ;---- 
     87    ; 
     88    ; check orcares definition 
     89    ; 
     90    CASE orcares OF 
     91        'ORCA2': BEGIN 
    9292                 msg = 'iii : valid orcares parameter = ' +  orcares 
    9393                 ras = report(msg) 
    94               END 
    95      'ORCA025': BEGIN 
     94         END 
     95        'ORCA025': BEGIN 
    9696                 msg = 'iii : valid orcares parameter = ' +  orcares 
    9797                 ras = report(msg) 
    98               END 
    99       ELSE : BEGIN 
     98         END 
     99         ELSE : BEGIN 
    100100                 msg = 'eee : invalid orcares parameter = ' + orcares 
    101101                 ras = report(msg) 
     
    103103                 ras = report(msg) 
    104104                 RETURN 
    105               END 
    106   ENDCASE 
    107 ; 
    108 ; check variable definition 
    109 ; ++ dimension etc. 
    110   CASE variable.NAME OF 
    111      'cond_sed': BEGIN 
    112                     msg = 'iii : valid variable.NAME parameter = ' + variable.NAME 
    113                     ras = report(msg) 
    114                     CASE title OF 
    115                        'Conductance': BEGIN 
    116                                      msg = 'iii : valid title parameter = ' + title 
    117                                      ras = report(msg) 
    118                                   END 
    119                         ELSE      : BEGIN 
    120                                       msg = 'eee : invalid title parameter = ' + title 
    121                                       ras = report(msg) 
    122                                       msg = 'eee : title must be Conductance' 
    123                                       ras = report(msg) 
    124                                       RETURN 
    125                                    END 
    126                         ENDCASE 
    127                     CASE long_name OF 
    128                        'Conductance': BEGIN 
    129                                      msg = 'iii : valid long_name parameter = ' + long_name 
    130                                      ras = report(msg) 
    131                                   END 
    132                         ELSE      : BEGIN 
    133                                       msg = 'eee : invalid long_name parameter = ' + long_name 
    134                                       ras = report(msg) 
    135                                       msg = 'eee : long_name must be Conductance' 
    136                                       ras = report(msg) 
    137                                       RETURN 
    138                                    END 
    139                         ENDCASE 
    140                     CASE units OF 
    141                        'siemens': BEGIN 
     105         END 
     106    ENDCASE 
     107    ; 
     108    ; check variable definition 
     109    ; ++ dimension etc. 
     110    CASE variable.NAME OF 
     111        'cond_sed': BEGIN 
     112             msg = 'iii : valid variable.NAME parameter = ' + variable.NAME 
     113             ras = report(msg) 
     114             CASE title OF 
     115                 'Conductance': BEGIN 
     116                      msg = 'iii : valid title parameter = ' + title 
     117                      ras = report(msg) 
     118                 END 
     119                 ELSE      : BEGIN 
     120                     msg = 'eee : invalid title parameter = ' + title 
     121                     ras = report(msg) 
     122                     msg = 'eee : title must be Conductance' 
     123                     ras = report(msg) 
     124                     RETURN 
     125                 END 
     126             ENDCASE 
     127             CASE long_name OF 
     128                 'Conductance': BEGIN 
     129                     msg = 'iii : valid long_name parameter = ' + long_name 
     130                     ras = report(msg) 
     131                 END 
     132                 ELSE      : BEGIN 
     133                     msg = 'eee : invalid long_name parameter = ' + long_name 
     134                     ras = report(msg) 
     135                     msg = 'eee : long_name must be Conductance' 
     136                     ras = report(msg) 
     137                     RETURN 
     138                 END 
     139             ENDCASE 
     140             CASE units OF 
     141                 'siemens': BEGIN 
    142142                                     msg = 'iii : valid units parameter = ' + units 
    143143                                     ras = report(msg) 
    144                                   END 
    145                         ELSE      : BEGIN 
     144                 END 
     145                 ELSE      : BEGIN 
    146146                                      msg = 'eee : invalid units parameter = ' + units 
    147147                                      ras = report(msg) 
     
    149149                                      ras = report(msg) 
    150150                                      RETURN 
    151                                    END 
    152                         ENDCASE 
    153                  END 
    154      'Br'  : BEGIN 
    155                     msg = 'iii : valid variable.NAME parameter = ' + variable.NAME 
     151                 END 
     152             ENDCASE 
     153         END 
     154         'Br'  : BEGIN 
     155             msg = 'iii : valid variable.NAME parameter = ' + variable.NAME 
     156             ras = report(msg) 
     157             CASE title OF 
     158                 'Magnetic field': BEGIN 
     159                     msg = 'iii : valid title parameter = ' + title 
     160                     ras = report(msg) 
     161                 END 
     162                 ELSE      : BEGIN 
     163                    msg = 'eee : invalid title parameter = ' + title 
    156164                    ras = report(msg) 
    157                     CASE title OF 
    158                        'Magnetic field': BEGIN 
    159                                      msg = 'iii : valid title parameter = ' + title 
    160                                      ras = report(msg) 
    161                                   END 
    162                         ELSE      : BEGIN 
    163                                       msg = 'eee : invalid title parameter = ' + title 
    164                                       ras = report(msg) 
    165                                       msg = 'eee : title must be Magnetic field' 
    166                                       ras = report(msg) 
    167                                       RETURN 
    168                                    END 
    169                         ENDCASE 
    170                     CASE long_name OF 
    171                        'magnetic field': BEGIN 
    172                                      msg = 'iii : valid long_name parameter = ' + long_name 
    173                                      ras = report(msg) 
    174                                   END 
    175                         ELSE      : BEGIN 
    176                                       msg = 'eee : invalid long_name parameter = ' + long_name 
    177                                       ras = report(msg) 
    178                                       msg = 'eee : long_name must be magnetic field' 
    179                                       ras = report(msg) 
    180                                       RETURN 
    181                                    END 
    182                         ENDCASE 
    183                     CASE units OF 
    184                        'tesla': BEGIN 
    185                                      msg = 'iii : valid units parameter = ' + units 
    186                                      ras = report(msg) 
    187                                   END 
    188                         ELSE      : BEGIN 
    189                                       msg = 'eee : invalid units parameter = ' + units 
    190                                       ras = report(msg) 
    191                                       msg = 'eee : units must be tesla' 
    192                                       ras = report(msg) 
    193                                       RETURN 
    194                                    END 
    195                         ENDCASE 
    196                  END 
    197      ELSE      : BEGIN 
    198                     msg = 'eee : invalid variable.NAME parameter = ' + variable.NAME 
    199                     ras = report(msg) 
    200                     msg = 'eee : variable.NAME must be cond_sed or Br' 
     165                    msg = 'eee : title must be Magnetic field' 
    201166                    ras = report(msg) 
    202167                    RETURN 
    203168                 END 
    204   ENDCASE 
    205 ; 
    206 ; check jpio 
    207   IF (jpio LT 1) THEN BEGIN 
    208      msg = ' eee : invalid jpio parameter = ' + STRING(jpio) 
    209      ras = report(msg) 
    210      msg = ' eee : jpio must be greater or equal to 1' 
    211      ras = report(msg) 
    212      RETURN 
    213   ENDIF ELSE BEGIN 
    214      msg = 'iii : valid jpio parameter = ' + STRING(jpio) 
    215      ras = report(msg) 
    216   ENDELSE 
    217 ; 
    218 ; check jpjo 
    219   IF (jpjo LT 1) THEN BEGIN 
    220      msg = ' eee : invalid jpjo parameter = ' + STRING(jpjo) 
    221      ras = report(msg) 
    222      msg = ' eee : jpjo must be greater or equal to 1' 
    223      ras = report(msg) 
    224      RETURN 
    225   ENDIF ELSE BEGIN 
    226      msg = 'iii : valid jpjo parameter = ' + STRING(jpjo) 
    227      ras = report(msg) 
    228   ENDELSE 
    229 ; 
    230 ; check olon ++ what to check 
    231 ; when decided reproduce with olat ++ 
    232   IF (N_ELEMENTS(olon) NE jpio*jpjo) THEN BEGIN 
    233      msg = ' eee : invalid nb of elements of olon parameter = ' + STRING(N_ELEMENTS(olon)) 
    234      ras = report(msg) 
    235      msg = ' eee : nb of elements of olon must be equal to jpio*jpjo = ' + STRING(jpio*jpjo) 
    236      ras = report(msg) 
    237      RETURN 
    238   ENDIF ELSE BEGIN 
    239      msg = 'iii : valid nb of elements olon parameter' 
    240      ras = report(msg) 
    241   ENDELSE 
    242 ; 
    243 ; check values ++ 
    244 ; test if ${GEOMAG_OD} defined 
    245   geomag_od_env=GETENV('GEOMAG_OD') 
    246   CASE geomag_od_env OF 
    247      '' : BEGIN 
    248              msg = 'eee : ${GEOMAG_OD} is not defined' 
    249              ras = report(msg) 
    250              RETURN 
    251           END 
    252      ELSE: BEGIN 
     169             ENDCASE 
     170             CASE long_name OF 
     171                 'magnetic field': BEGIN 
     172                     msg = 'iii : valid long_name parameter = ' + long_name 
     173                     ras = report(msg) 
     174                 END 
     175             ELSE      : BEGIN 
     176                 msg = 'eee : invalid long_name parameter = ' + long_name 
     177                 ras = report(msg) 
     178                 msg = 'eee : long_name must be magnetic field' 
     179                 ras = report(msg) 
     180                 RETURN 
     181             END 
     182         ENDCASE 
     183         CASE units OF 
     184             'tesla': BEGIN 
     185                 msg = 'iii : valid units parameter = ' + units 
     186                 ras = report(msg) 
     187             END 
     188             ELSE      : BEGIN 
     189                 msg = 'eee : invalid units parameter = ' + units 
     190                 ras = report(msg) 
     191                 msg = 'eee : units must be tesla' 
     192                 ras = report(msg) 
     193                 RETURN 
     194             END 
     195         ENDCASE 
     196     END 
     197     ELSE      : BEGIN 
     198         msg = 'eee : invalid variable.NAME parameter = ' + variable.NAME 
     199         ras = report(msg) 
     200         msg = 'eee : variable.NAME must be cond_sed or Br' 
     201         ras = report(msg) 
     202         RETURN 
     203     END 
     204ENDCASE 
     205    ; 
     206    ; check jpio 
     207    IF (jpio LT 1) THEN BEGIN 
     208       msg = ' eee : invalid jpio parameter = ' + STRING(jpio) 
     209       ras = report(msg) 
     210       msg = ' eee : jpio must be greater or equal to 1' 
     211       ras = report(msg) 
     212       RETURN 
     213    ENDIF ELSE BEGIN 
     214       msg = 'iii : valid jpio parameter = ' + STRING(jpio) 
     215       ras = report(msg) 
     216    ENDELSE 
     217    ; 
     218    ; check jpjo 
     219    IF (jpjo LT 1) THEN BEGIN 
     220       msg = ' eee : invalid jpjo parameter = ' + STRING(jpjo) 
     221       ras = report(msg) 
     222       msg = ' eee : jpjo must be greater or equal to 1' 
     223       ras = report(msg) 
     224       RETURN 
     225    ENDIF ELSE BEGIN 
     226       msg = 'iii : valid jpjo parameter = ' + STRING(jpjo) 
     227       ras = report(msg) 
     228    ENDELSE 
     229    ; 
     230    ; check olon ++ what to check 
     231    ; when decided reproduce with olat ++ 
     232    IF (N_ELEMENTS(olon) NE jpio*jpjo) THEN BEGIN 
     233       msg = ' eee : invalid nb of elements of olon parameter = ' + STRING(N_ELEMENTS(olon)) 
     234       ras = report(msg) 
     235       msg = ' eee : nb of elements of olon must be equal to jpio*jpjo = ' + STRING(jpio*jpjo) 
     236       ras = report(msg) 
     237       RETURN 
     238    ENDIF ELSE BEGIN 
     239       msg = 'iii : valid nb of elements olon parameter' 
     240       ras = report(msg) 
     241    ENDELSE 
     242    ; 
     243    ; check values ++ 
     244    ; test if ${GEOMAG_OD} defined 
     245    geomag_od_env=GETENV('GEOMAG_OD') 
     246    CASE geomag_od_env OF 
     247        '' : BEGIN 
     248               msg = 'eee : ${GEOMAG_OD} is not defined' 
     249               ras = report(msg) 
     250               RETURN 
     251        END 
     252        ELSE : BEGIN 
    253253             msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env 
    254254             ras = report(msg) 
    255            END 
    256   ENDCASE 
    257 ; 
    258 ; check if output data will be possible 
    259   iodirout = isadirectory(geomag_od_env) 
    260 ; 
    261 ; existence and protection 
    262   IF (FILE_TEST(iodirout, /DIRECTORY,/WRITE) EQ 0) THEN BEGIN 
    263      msg = 'eee : the directory' + iodirout  + ' was not found.' 
    264      ras = report(msg) 
    265      RETURN 
    266   ENDIF 
    267 ; 
    268 ; build output filenames 
    269   filename = variable.NAME + '_' + orcares +'.nc' 
    270   fullfilename = iodirout + filename 
    271 ; 
    272 ; in order to avoid unexpected overwritten 
    273   IF (FILE_TEST(fullfilename) EQ 1) THEN BEGIN 
    274      msg = 'eee : the file ' + fullfilename  + ' already exists.' 
    275      ras = report(msg) 
    276      RETURN 
    277   ENDIF 
    278 ; 
    279 ; d'après ncdump -h /usr/work/sur/fvi/OPA/geomag/condmag.nc 
    280 ; ces lignes n'ont rien a faire la ++ ces information devrait etre en parameter 
    281   condmaglonname = 'lo' 
    282   condmaglatname = 'la' 
    283   varname = variable.NAME 
    284 ; 
    285 ;--------------------------- 
    286 ; Creation of the NetCdf output file 
    287 ;--------------------------- 
    288 ; 
    289   netcdf_id = NCDF_CREATE(fullfilename, /clobber) 
    290   NCDF_CONTROL, netcdf_id, /NOFILL 
    291 ; 
    292 ; dimension 
    293   dimidx = NCDF_DIMDEF(netcdf_id, 'x' ,  jpio) 
    294   dimidy = NCDF_DIMDEF(netcdf_id, 'y' ,  jpjo) 
    295   dimidt = NCDF_DIMDEF(netcdf_id, 'lo', /UNLIMITED) 
    296 ; 
    297 ; global attributes 
    298   NCDF_ATTPUT, netcdf_id, 'Conventions', 'GDT 1.2', /GLOBAL ; ++ conformite 
    299   NCDF_ATTPUT, netcdf_id, 'file_name'  , filename, /GLOBAL 
    300   NCDF_ATTPUT, netcdf_id, 'Title'      , title, /GLOBAL 
    301 ; 
    302 ; declaration of variables 
    303 ; 4 common variables for the two files to produce 
    304   varid = lonarr(4) 
    305 ; 
    306   varid[0] = NCDF_VARDEF(netcdf_id, 'nav_lon'  , [dimidx, dimidy], /FLOAT) 
    307   NCDF_ATTPUT, netcdf_id, varid[0], 'units'    , 'degrees_east' 
    308   NCDF_ATTPUT, netcdf_id, varid[0], 'valid_min', min(olon, max = omax), /FLOAT 
    309   NCDF_ATTPUT, netcdf_id, varid[0], 'valid_max', omax, /FLOAT 
    310   NCDF_ATTPUT, netcdf_id, varid[0], 'long_name', 'Longitude at t-point' 
    311 ; 
    312   varid[1] = NCDF_VARDEF(netcdf_id, 'nav_lat'  , [dimidx, dimidy], /FLOAT) 
    313   NCDF_ATTPUT, netcdf_id, varid[1], 'units'    , 'degrees_north' 
    314   NCDF_ATTPUT, netcdf_id, varid[1], 'valid_min', min(olat, max = omax), /FLOAT 
    315   NCDF_ATTPUT, netcdf_id, varid[1], 'valid_max', omax, /FLOAT 
    316   NCDF_ATTPUT, netcdf_id, varid[1], 'long_name', 'Latitude at t-point' 
    317 ; 
    318   varid[2] = NCDF_VARDEF(netcdf_id, 'time'     , [dimidt], /FLOAT) 
    319 ; 
    320   varid[3] =  NCDF_VARDEF(netcdf_id, varname, [dimidx, dimidy, dimidt], /FLOAT) 
    321   NCDF_ATTPUT, netcdf_id, varid[3], 'long_name', long_name 
    322   NCDF_ATTPUT, netcdf_id, varid[3], 'units', units 
    323 ; pour min  et max, il faut avoir lu la variable ... cf. plus bas ++ 
    324 ; donc pour l'instant on les met à valeur manquante 
    325   NCDF_ATTPUT, netcdf_id, varid[3], 'valid_min', !VALUES.F_NAN, /FLOAT 
    326   NCDF_ATTPUT, netcdf_id, varid[3], 'valid_max', !VALUES.F_NAN, /FLOAT 
    327 ; 
    328 ;--------------------------- 
    329 ; end of header definition, writing of the NetCdf files 
    330 ;--------------------------- 
    331 ; 
    332   NCDF_CONTROL, netcdf_id, /ENDEF 
    333 ; 
    334   NCDF_VARPUT, netcdf_id, 'nav_lon', olon 
    335   NCDF_VARPUT, netcdf_id, 'nav_lat', olat 
    336   NCDF_VARPUT, netcdf_id, varid[2], FLOAT(0.5) ; ++ c'est quoi cette valeur 
    337 ; 
    338 ; compute min max 
    339       minarr = min(values, max = maxarr) 
    340 ; 
    341 ; put back the masked value 
    342 ;++      IF bad[0] NE -1 THEN values[TEMPORARY(bad)] = 32767 
    343 ; 
    344 ; write the data 
    345       NCDF_VARPUT, netcdf_id, varname, values, COUNT = [jpio, jpjo, 1], OFFSET = [0, 0, 0] 
    346 ; 
    347 ; update min max attributes 
    348   NCDF_CONTROL, netcdf_id, /REDEF 
    349   NCDF_ATTPUT, netcdf_id, varid[3], 'valid_min', minarr, /FLOAT 
    350   NCDF_ATTPUT, netcdf_id, varid[3], 'valid_max', maxarr, /FLOAT 
    351   NCDF_CONTROL, netcdf_id, /ENDEF 
    352 ; 
    353 ; close the netcdf files 
    354   NCDF_CLOSE, netcdf_id 
    355 ; 
    356   msg = 'iii : ' + fullfilename + ' created' 
    357   ras = report(msg) 
    358 ; 
     255        END 
     256    ENDCASE 
     257    ; 
     258    ; check if output data will be possible 
     259    iodirout = isadirectory(geomag_od_env) 
     260    ; 
     261    ; existence and protection 
     262    IF (FILE_TEST(iodirout, /DIRECTORY,/WRITE) EQ 0) THEN BEGIN 
     263       msg = 'eee : the directory' + iodirout  + ' was not found.' 
     264       ras = report(msg) 
     265       RETURN 
     266    ENDIF 
     267    ; 
     268    ; build output filenames 
     269    filename = variable.NAME + '_' + orcares +'.nc' 
     270    fullfilename = iodirout + filename 
     271    ; 
     272    ; in order to avoid unexpected overwritten 
     273    IF (FILE_TEST(fullfilename) EQ 1) THEN BEGIN 
     274       msg = 'eee : the file ' + fullfilename  + ' already exists.' 
     275       ras = report(msg) 
     276       RETURN 
     277    ENDIF 
     278    ; 
     279    ; d'aprÚs ncdump -h /usr/work/sur/fvi/OPA/geomag/condmag.nc 
     280    ; ces lignes n'ont rien a faire la ++ ces information devrait etre en parameter 
     281    condmaglonname = 'lo' 
     282    condmaglatname = 'la' 
     283    varname = variable.NAME 
     284    ; 
     285    ;--------------------------- 
     286    ; Creation of the NetCdf output file 
     287    ;--------------------------- 
     288    ; 
     289    netcdf_id = NCDF_CREATE(fullfilename, /clobber) 
     290    NCDF_CONTROL, netcdf_id, /NOFILL 
     291    ; 
     292    ; dimension 
     293    dimidx = NCDF_DIMDEF(netcdf_id, 'x' ,  jpio) 
     294    dimidy = NCDF_DIMDEF(netcdf_id, 'y' ,  jpjo) 
     295    dimidt = NCDF_DIMDEF(netcdf_id, 'lo', /UNLIMITED) 
     296    ; 
     297    ; global attributes 
     298    NCDF_ATTPUT, netcdf_id, 'Conventions', 'GDT 1.2', /GLOBAL ; ++ conformite 
     299    NCDF_ATTPUT, netcdf_id, 'file_name'  , filename, /GLOBAL 
     300    NCDF_ATTPUT, netcdf_id, 'Title'      , title, /GLOBAL 
     301    ; 
     302    ; declaration of variables 
     303    ; 4 common variables for the two files to produce 
     304    varid = lonarr(4) 
     305    ; 
     306    varid[0] = NCDF_VARDEF(netcdf_id, 'nav_lon'  , [dimidx, dimidy], /FLOAT) 
     307    NCDF_ATTPUT, netcdf_id, varid[0], 'units'    , 'degrees_east' 
     308    NCDF_ATTPUT, netcdf_id, varid[0], 'valid_min', min(olon, max = omax), /FLOAT 
     309    NCDF_ATTPUT, netcdf_id, varid[0], 'valid_max', omax, /FLOAT 
     310    NCDF_ATTPUT, netcdf_id, varid[0], 'long_name', 'Longitude at t-point' 
     311    ; 
     312    varid[1] = NCDF_VARDEF(netcdf_id, 'nav_lat'  , [dimidx, dimidy], /FLOAT) 
     313    NCDF_ATTPUT, netcdf_id, varid[1], 'units'    , 'degrees_north' 
     314    NCDF_ATTPUT, netcdf_id, varid[1], 'valid_min', min(olat, max = omax), /FLOAT 
     315    NCDF_ATTPUT, netcdf_id, varid[1], 'valid_max', omax, /FLOAT 
     316    NCDF_ATTPUT, netcdf_id, varid[1], 'long_name', 'Latitude at t-point' 
     317    ; 
     318    varid[2] = NCDF_VARDEF(netcdf_id, 'time'     , [dimidt], /FLOAT) 
     319    ; 
     320    varid[3] =  NCDF_VARDEF(netcdf_id, varname, [dimidx, dimidy, dimidt], /FLOAT) 
     321    NCDF_ATTPUT, netcdf_id, varid[3], 'long_name', long_name 
     322    NCDF_ATTPUT, netcdf_id, varid[3], 'units', units 
     323    ; pour min et max, il faut avoir lu la variable ... cf. plus bas ++ 
     324    ; donc pour l'instant on les met à valeur manquante 
     325    NCDF_ATTPUT, netcdf_id, varid[3], 'valid_min', !VALUES.F_NAN, /FLOAT 
     326    NCDF_ATTPUT, netcdf_id, varid[3], 'valid_max', !VALUES.F_NAN, /FLOAT 
     327    ; 
     328    ;--------------------------- 
     329    ; end of header definition, writing of the NetCdf files 
     330    ;--------------------------- 
     331    ; 
     332    NCDF_CONTROL, netcdf_id, /ENDEF 
     333    ; 
     334    NCDF_VARPUT, netcdf_id, 'nav_lon', olon 
     335    NCDF_VARPUT, netcdf_id, 'nav_lat', olat 
     336    NCDF_VARPUT, netcdf_id, varid[2], FLOAT(0.5) ; ++ c'est quoi cette valeur 
     337    ; 
     338    ; compute min max 
     339    minarr = min(values, max = maxarr) 
     340    ; 
     341    ; put back the masked value 
     342    ;++      IF bad[0] NE -1 THEN values[TEMPORARY(bad)] = 32767 
     343    ; 
     344    ; write the data 
     345    NCDF_VARPUT, netcdf_id, varname, values, COUNT = [jpio, jpjo, 1], OFFSET = [0, 0, 0] 
     346    ; 
     347    ; update min max attributes 
     348    NCDF_CONTROL, netcdf_id, /REDEF 
     349    NCDF_ATTPUT, netcdf_id, varid[3], 'valid_min', minarr, /FLOAT 
     350    NCDF_ATTPUT, netcdf_id, varid[3], 'valid_max', maxarr, /FLOAT 
     351    NCDF_CONTROL, netcdf_id, /ENDEF 
     352    ; 
     353    ; close the netcdf files 
     354    NCDF_CLOSE, netcdf_id 
     355    ; 
     356    msg = 'iii : ' + fullfilename + ' created' 
     357    ras = report(msg) 
    359358END 
  • trunk/correc_angle.pro

    r41 r48  
    1212;                    zresul_vv, zresul_vu, zresul_u, zresul_v 
    1313; 
    14 ; INPUTS:  
    15 ;          zresul_uu : x-component of interpolated field at  
    16 ;                      u-point    
    17 ;          zresul_uv : x-component of interpolated field at  
    18 ;                      v-point    
    19 ;          zresul_vv : y-component of interpolated field at  
    20 ;                      v-point    
    21 ;          zresul_vu : y-component of interpolated field at  
    22 ;                      u-point    
     14; INPUTS: 
     15;          zresul_uu : x-component of interpolated field at 
     16;                      u-point 
     17;          zresul_uv : x-component of interpolated field at 
     18;                      v-point 
     19;          zresul_vv : y-component of interpolated field at 
     20;                      v-point 
     21;          zresul_vu : y-component of interpolated field at 
     22;                      u-point 
    2323; 
    2424; KEYWORD PARAMETERS: None 
    2525; 
    26 ; OUTPUTS:  
    27 ;          zresul_u : corrected x-component of interpolated  
     26; OUTPUTS: 
     27;          zresul_u : corrected x-component of interpolated 
    2828;                     field at u-point 
    29 ;          zresul_v : corrected y-component of interpolated  
     29;          zresul_v : corrected y-component of interpolated 
    3030;                     field at v-point 
    3131; 
    3232; COMMON BLOCKS: 
    33 ;       common_interp.pro 
     33;    common_interp.pro 
    3434; 
    35 ; SIDE EFFECTS:  
     35; SIDE EFFECTS: 
    3636; 
    3737; RESTRICTIONS: 
     
    5555angle, lon_u, lat_u, lon_v, lat_v, lon_f, lat_f, gsinu, gsinv, gcosu, gcosv 
    5656; 
    57 ; 2. Correct the two components of the field  
     57; 2. Correct the two components of the field 
    5858; ========================================== 
    5959; 
     
    6868; 
    6969return 
    70 END  
     70END 
  • trunk/detectbarotropicmode.sh

    r47 r48  
    1616# ======== 
    1717# 
    18 # .. code-blcok:: bash 
     18# .. code-block:: bash 
    1919# 
    2020#    detectbarotropicmode.sh -l list -r resolution -exp experience -g grid \ 
     
    3131# in the box [-50,30] [295,335]: 
    3232# 
    33 # .. code-block :: bash 
     33# .. code-block:: bash 
    3434# 
    3535#    detectbarotropicmode.sh -l ${GEOMAG_OD}/list_G42 -r ORCA025 -exp G42 -g gridT \ 
     
    6060command=detectbarotropicmode.sh 
    6161# 
    62 usage=" Usage : ${command} -l list -r orcares -exp drakkar_exp -g grid -latmin latmin -latmax latmax -longmin longmin -longmax longmax" 
    63 # 
    64 set +u 
    65 while [ ! -z "${1}" ] 
     62usage="Usage : ${command} -l list -r orcares -exp drakkar_exp -g grid -latmin latmin -latmax latmax -longmin longmin -longmax longmax" 
     63# 
     64set -u 
     65while [ ${#} -gt 0 ] 
    6666do 
    67    case ${1} in 
    68       -l) 
    69          list=${2} 
    70          shift 
    71       ;; 
    72       -r) 
    73          orcares=${2} 
    74          shift 
    75       ;; 
    76       -exp) 
    77          drakkar_exp=${2} 
    78          shift 
    79       ;; 
    80       -g) 
    81          grid=${2} 
    82          shift 
    83       ;; 
    84       -latmin) 
    85          latmin=${2} 
    86          shift 
    87       ;; 
    88       -latmax) 
    89          latmax=${2} 
    90          shift 
    91       ;; 
    92       -longmin) 
    93          longmin=${2} 
    94          shift 
    95       ;; 
    96       -longmax) 
    97          longmax=${2} 
    98          shift 
    99       ;; 
    100       *) 
    101          # other choice 
    102          echo "eee : unknown option ${1}" 
    103          echo "${usage}" 
    104       ;; 
    105    esac 
    106    # next flag 
    107    shift 
     67    case ${1} in 
     68        -l) 
     69            list=${2} 
     70            shift 
     71        ;; 
     72        -r) 
     73            orcares=${2} 
     74            shift 
     75        ;; 
     76        -exp) 
     77            drakkar_exp=${2} 
     78            shift 
     79        ;; 
     80        -g) 
     81            grid=${2} 
     82            shift 
     83        ;; 
     84        -latmin) 
     85            latmin=${2} 
     86            shift 
     87        ;; 
     88        -latmax) 
     89            latmax=${2} 
     90            shift 
     91        ;; 
     92        -longmin) 
     93            longmin=${2} 
     94            shift 
     95        ;; 
     96        -longmax) 
     97            longmax=${2} 
     98            shift 
     99        ;; 
     100        *) 
     101            # other choice 
     102            echo "eee : unknown option ${1}" 
     103            echo "${usage}" 
     104        ;; 
     105    esac 
     106    # next flag 
     107    shift 
    108108done 
    109 # 
    110 set -u 
    111109# 
    112110# check GEOMAG environement 
    113111if [ ! -d ${GEOMAG_LOG} ] 
    114112then 
    115    echo " eee : \${GEOMAG_LOG} not found" 
    116    exit 1 
     113    echo " eee : \${GEOMAG_LOG} not found" 
     114    exit 1 
    117115fi 
    118116# ++ blindage en tout genre 
    119117# 
    120118case ${grid} in 
    121    gridT) 
    122       echo "iii : grid=${orcares}" 
    123    ;; 
    124    *) 
    125       echo "eee : pb \${grid} = ${grid}" 
    126       exit 1 
    127    ;; 
     119    gridT) 
     120        echo "iii : grid=${orcares}" 
     121    ;; 
     122    *) 
     123        echo "eee : pb \${grid} = ${grid}" 
     124        exit 1 
     125    ;; 
    128126esac 
    129127# 
    130128case ${orcares} in 
    131    ORCA025) 
    132       echo "iii : orcares=${orcares}" 
    133    ;; 
    134    *) 
    135       echo "eee : pb \${orcares} = ${orcares}" 
    136       exit 1 
    137    ;; 
     129    ORCA025) 
     130        echo "iii : orcares=${orcares}" 
     131    ;; 
     132    *) 
     133        echo "eee : pb \${orcares} = ${orcares}" 
     134        exit 1 
     135    ;; 
    138136esac 
    139137# 
    140138case ${drakkar_exp} in 
    141    G42) 
    142       echo "iii : drakkar_exp=${drakkar_exp}" 
    143    ;; 
    144    *) 
    145       echo "eee : pb \${drakkar_exp} = ${drakkar_exp}" 
    146       exit 1 
    147    ;; 
     139    G42) 
     140        echo "iii : drakkar_exp=${drakkar_exp}" 
     141    ;; 
     142    *) 
     143        echo "eee : pb \${drakkar_exp} = ${drakkar_exp}" 
     144        exit 1 
     145    ;; 
    148146esac 
    149147# 
    150148# ++ conversion of latitude and longitude in x and y indexes 
    151149case ${orcares} in 
    152    ORCA025) 
    153       xmin=529 
    154       xmax=689 
    155       ymin=266 
    156       ymax=372 
    157       echo "iii : forcage xmin xmax ymin ymax : ${xmin} ${xmax} ${ymin} ${ymax}" 
    158    ;; 
    159    *) 
    160       echo "eee : pb conversion lat,long to x,y" 
    161       exit 1 
    162    ;; 
     150    ORCA025) 
     151        xmin=529 
     152        xmax=689 
     153        ymin=266 
     154        ymax=372 
     155        echo "iii : forcage xmin xmax ymin ymax : ${xmin} ${xmax} ${ymin} ${ymax}" 
     156    ;; 
     157    *) 
     158        echo "eee : pb conversion lat,long to x,y" 
     159        exit 1 
     160    ;; 
    163161esac 
    164162# 
     
    167165for file in `cat ${list}` 
    168166do 
    169    echo "iii : extraction from ${file}" # ++ voir seulement si debug demandé 
    170    filessh=${GEOMAG_OD}/`basename ${file} .nc`_ssh.nc 
    171    rm -f ${filessh} 2> /dev/null 
    172    ncks --dimension x,${xmin},${xmax} --dimension y,${ymin},${ymax}  -v sossheig,nav_lon,nav_lat \ 
    173       ${file} ${filessh} 
    174    status_ncks=${?} 
    175    if [ ${status_ncks} -ne 0 ] 
    176    then 
    177       echo "eee : pb with ncks ${file}" 
    178       exit 1 
    179    else 
    180       list_ssh="${list_ssh} ${filessh}" 
    181    fi 
     167    echo "iii : extraction from ${file}" # ++ voir seulement si debug demandé 
     168    filessh=${GEOMAG_OD}/`basename ${file} .nc`_ssh.nc 
     169    rm -f ${filessh} 2> /dev/null 
     170    ncks --dimension x,${xmin},${xmax} --dimension y,${ymin},${ymax}  -v sossheig,nav_lon,nav_lat \ 
     171    ${file} ${filessh} 
     172    status_ncks=${?} 
     173    if [ ${status_ncks} -ne 0 ] 
     174    then 
     175        echo "eee : pb with ncks ${file}" 
     176        exit 1 
     177    else 
     178        list_ssh="${list_ssh} ${filessh}" 
     179    fi 
    182180done 
    183181line=`head -n 1 ${list}` 
     
    195193if [ ${status_ncrcat} -ne 0 ] 
    196194then 
    197    echo "eee : pb with ncrcat" 
    198    exit 1 
     195    echo "eee : pb with ncrcat" 
     196    exit 1 
    199197else 
    200    echo "iii : result in ${filetot}" 
     198    echo "iii : result in ${filetot}" 
    201199fi 
    202200# 
  • trunk/divfred.pro

    r41 r48  
    2525; - Requires SAXO tools 
    2626; - les matrices u et v peuvent de 2 a 4 dimensions. 
    27 ; attention pour distinguer les différentes configurations de u et v 
     27; attention pour distinguer les différentes configurations de u et v 
    2828; (xy, xyz, xyt, xyzt), on regarde la variable du common 
    2929;        -time qui contient le calendrier en jour julien d''IDL auquel 
    3030;        se rapportent u et v ansi que la variable 
    31 ;        -jpt qui est le nombre de pas de temps à considérer dans time. 
    32 ; les tableaux u et v sont découpés sur le même domaine 
    33 ; géographique. A cause du décalage des grilles T, U, V et F il est 
    34 ; possible que ces 2 tableaux n''aient pas la même taille et se 
    35 ; reportent à des indices différents. Si tel est le cas les tableaux 
    36 ; sont redécoupés sur les indices qu'ils ont en commun et le dommaine 
    37 ; est redéfini pour qu'il colle à ces indices communs. 
    38 ; pour éviter ces redécoupes utiliser le mot clé /memeindice dans 
     31;        -jpt qui est le nombre de pas de temps à considérer dans time. 
     32; les tableaux u et v sont découpés sur le même domaine 
     33; géographique. A cause du décalage des grilles T, U, V et F il est 
     34; possible que ces 2 tableaux n''aient pas la même taille et se 
     35; reportent à des indices différents. Si tel est le cas les tableaux 
     36; sont redécoupés sur les indices qu'ils ont en commun et le dommaine 
     37; est redéfini pour qu'il colle à ces indices communs. 
     38; pour éviter ces redécoupes utiliser le mot clé /memeindice dans 
    3939; <pro>domdef</pro> 
    4040; 
    41 ; les points sur le bord du dessin sont mis à !values.f_nan 
     41; les points sur le bord du dessin sont mis à !values.f_nan 
    4242; 
    4343; @todo 
    44 ; ++ pas fini de comprendre, tester (compatibilité saxo), adapter, commenter 
     44; ++ pas fini de comprendre, tester (compatibilité saxo), adapter, commenter 
    4545; nettoyer 
    4646; ++ a comparer et merger avec SAXO_DIR/ToBeReviewed/CALCULS/div.pro 
     
    111111               v = v[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1, *] 
    112112            END 
    113             ELSE:BEGIN 
     113            ELSE :BEGIN 
    114114               zdiv = -1 
    115115               GOTO, sortie 
     
    142142; mise a !values.f_nan de la bordure 
    143143;------------------------------------------------------------ 
    144          if  NOT keyword_set(key_periodic) OR nx NE jpi then begin 
     144         if NOT keyword_set(key_periodic) OR nx NE jpi then begin 
    145145            zdiv(0, *, *) = !values.f_nan 
    146146            zdiv(nx-1, *, *) = !values.f_nan 
     
    161161         varunits = '1e6*s-1' 
    162162         domdef, (glamt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, grille = ['t'] 
    163          if keyword_set(direc) then  zdiv = moyenne(zdiv,direc,/nan, boite = boite) 
     163         if keyword_set(direc) then zdiv = moyenne(zdiv,direc,/nan, boite = boite) 
    164164      END 
    165165;---------------------------------------------------------------------------- 
     
    189189               v = v[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1, *] 
    190190            END 
    191             ELSE:return,  -1 
     191            ELSE : return,  -1 
    192192         endcase 
    193193;------------------------------------------------------------ 
     
    216216; mise a !values.f_nan de la bordure 
    217217;------------------------------------------------------------ 
    218          if  NOT keyword_set(key_periodic) OR nx NE jpi then begin 
     218         if NOT keyword_set(key_periodic) OR nx NE jpi then begin 
    219219            zdiv(0, *, *) = !values.f_nan 
    220220            zdiv(nx-1, *, *) = !values.f_nan 
     
    232232         varunits = '1e6*s-1' 
    233233         domdef, (glamt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, grille = ['t'] 
    234          if keyword_set(direc) then  zdiv = grossemoyenne(zdiv,direc,/nan, boite = boite) 
     234         if keyword_set(direc) then zdiv = grossemoyenne(zdiv,direc,/nan, boite = boite) 
    235235      END 
    236236;---------------------------------------------------------------------------- 
     
    247247;---------------------------------------------------------------------------- 
    248248;---------------------------------------------------------------------------- 
    249       ELSE:BEGIN                ;xy 
     249      ELSE : BEGIN                ;xy 
    250250         indice3d = lindgen(jpi, jpj, jpk) 
    251251         indice3d = indice3d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1, firstzt] 
     
    273273               v = v[indice2d] 
    274274            END 
    275             ELSE:return,  -1 
     275            ELSE : return,  -1 
    276276         endcase 
    277277;------------------------------------------------------------ 
     
    289289; mise a !values.f_nan de la bordure 
    290290;------------------------------------------------------------ 
    291          if  NOT keyword_set(key_periodic) OR nx NE jpi then begin 
     291         if NOT keyword_set(key_periodic) OR nx NE jpi then begin 
    292292            zdiv(0, *) = !values.f_nan 
    293293            zdiv(nx-1, *) = !values.f_nan 
     
    308308         varunits = '1e6*s-1' 
    309309         domdef, (glamt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, grille = ['t'] 
    310          if keyword_set(direc) then  zdiv = moyenne(zdiv,direc,/nan, boite = boite) 
     310         if keyword_set(direc) then zdiv = moyenne(zdiv,direc,/nan, boite = boite) 
    311311 
    312312      END 
  • trunk/draw.pro

    r2 r48  
    2525IF n_elements(ind) GT 1 THEN field(ind) = 0. 
    2626; 
    27 IF size(glam, /n_dimensions) EQ 1 THEN triangles = triangule() ELSE triangulate, glamt, gphit, triangles  
     27IF size(glam, /n_dimensions) EQ 1 THEN triangles = triangule() ELSE triangulate, glamt, gphit, triangles 
    2828; 
    29 IF keyword_set(land) THEN BEGIN  
     29IF keyword_set(land) THEN BEGIN 
    3030   if dessin EQ 1 then plt, field, zmin, zmax, nite = 0, /carte, petit = [nbcol, nbdessin, dessin], /remplit, div = 4, /cont_nofill, retain = 2, /nocontour, /land $ 
    3131   ELSE plt, field, zmin, zmax, nite = 0, /carte, petit = [nbcol, nbdessin, dessin], $ 
    3232    /noerase, /remplit, div = 4, /cont_nofill, /nocontour, /land 
    33 ENDIF ELSE BEGIN  
     33ENDIF ELSE BEGIN 
    3434if dessin EQ 1 then plt, field, zmin, zmax, nite = 0, /carte, petit = [nbcol, nbdessin, dessin], /remplit, div = 4, /cont_nofill, retain = 2, /nocontour, /port $ 
    3535ELSE plt, field, zmin, zmax, nite = 0, /carte, petit = [nbcol, nbdessin, dessin], $ 
    3636 /noerase, /remplit, div = 4, /cont_nofill, /nocontour, /port 
    37 ENDELSE  
     37ENDELSE 
    3838return 
    3939end 
  • trunk/extrap.pro

    r41 r48  
    22; NAME: extrap.pro (based on remplit.pro) 
    33; 
    4 ; PURPOSE: Extrapolates ocean data values on land points  
     4; PURPOSE: Extrapolates ocean data values on land points 
    55; 
    66; CATEGORY: Subroutine 
     
    88; CALLING SEQUENCE: extrap, zdata, zmask, it, val 
    99; 
    10 ; INPUTS:  
     10; INPUTS: 
    1111;          zdata : field to extrapolate 
    1212;          zmask : field's mask 
    1313;          it    : iteration 
    14 ;          val   : field value on masked points   
     14;          val   : field value on masked points 
    1515; 
    1616; KEYWORD PARAMETERS: None 
    1717; 
    18 ; OUTPUTS:  
    19 ;          zdata : extrapolated field  
     18; OUTPUTS: 
     19;          zdata : extrapolated field 
    2020;          zmask : mask after extrapolation 
    2121; 
    2222; COMMON BLOCKS: 
    23 ;       common_interp.pro  
     23;          common_interp.pro 
    2424; 
    2525; 
     
    3838; IF keyword_set(key_performance) THEN print, systime(1)-temp 
    3939; 
    40 ; 2. Extrapolating when needed  
     40; 2. Extrapolating when needed 
    4141; ============================ 
    4242; 
     
    7171; IF keyword_set(key_performance) THEN print, systime(1)-temp 
    7272; IF keyword_set(key_performance) THEN temp = systime(1) 
    73 ; IF n_elements(ocean2) NE jpiatm*(jpjatm+4) THEN BEGIN  
     73; IF n_elements(ocean2) NE jpiatm*(jpjatm+4) THEN BEGIN 
    7474; land = where(zmask EQ 0.) 
    7575; zremplit(land) = val 
    76 ; ENDIF  
     76; ENDIF 
    7777; IF keyword_set(key_performance) THEN print, systime(1)-temp 
    7878; 
     
    9595   terre = where(mmmask EQ 0) 
    9696   if terre[0] EQ -1 then GOTO, fini 
    97 ; les points du bord du cadre doivent maintenan etre dans la terre 
     97; les points du bord du cadre doivent maintenant etre dans la terre 
    9898   mmmask[0, *] = 0 
    9999   mmmask[jpiatm+1, *] = 0 
     
    119119    +1./sqrt(2)*(z[(jpiatm+2)+1+cote]+z[(jpiatm+2)-1+cote]+z[-(jpiatm+2)+1+cote]+z[-(jpiatm+2)-1+cote]) 
    120120   poids = voisins[cote] 
    121        
     121 
    122122   z[cote] = zcote/poids 
    123123;--------------------------------------------------------------- 
  • trunk/forcage.pro

    r2 r48  
    1 PRO forcagequimarche,iyear,ian  
     1PRO forcagequimarche,iyear,ian 
    22@init2 
    33@initorca2_bab 
    44 
    5  
    6  
    7  
    85@common 
    9  
    10  
    116 
    127;ian='01' 
     
    1611rep_fred='/usr/work/sur/fvi/OPA/geomag/' 
    1712key_portrait = 0 
    18 ; stockage des fichiers brut  
     13; stockage des fichiers brut 
    1914  ioDATA='/usr/work/sur/fvi/OPA/ORCA2/' 
    20   file_U=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_U.nc'  
     15  file_U=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_U.nc' 
    2116  print, file_U 
    22   file_V=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_V.nc'  
     17  file_V=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_V.nc' 
    2318  print, file_V 
    24   file_T=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_T.nc'  
     19  file_T=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_T.nc' 
    2520  print, file_T 
    2621  file_Sed= rep_fred+'cond_sed_ORCA2.nc' 
     
    3328     t_bt  = 'bar_transp' 
    3429ioORLN2 = '/usr/work/sur/fvi/OPA/ORCA2' 
    35 ;facteur d'echelle vertical  for partial steps 
     30;facteur d'echelle vertical for partial steps 
    3631e3v3d=read_ncdf('e3v_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
    3732e3u3d=read_ncdf('e3u_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
     
    4439 
    4540; vertical integration: 
    46 e3t3d=make_array(jpi,jpj,jpk)    
     41e3t3d=make_array(jpi,jpj,jpk) 
    4742        for k=0, jpk-1 do begin              &$ 
    48           for j=0,jpj-1 do begin              &$       
     43          for j=0,jpj-1 do begin              &$ 
    4944            for i=0,jpi-1 do begin             &$ 
    5045              e3t3d(i,j,k) = e3t(k)    &$ 
     
    5449jpt = 73 
    5550 
    56 ;vud = make_array(jpi,jpj,jpt)    
     51;vud = make_array(jpi,jpj,jpt) 
    5752;vvd = make_array(jpi, jpj, jpt) 
    5853divBustar = make_array(jpi, jpj, jpt) 
    5954diver2=fltarr(jpi,jpj,1,73) 
    6055 
    61 ; ouverture des fichiers dans lesquels on va écrire  
     56; ouverture des fichiers dans lesquels on va écrire 
    6257;id3=NCDF_OPEN('/usr/work/sur/fvi/OPA/geomag/U_5d_'+iyear+'_grid_T.nc',/write) 
    6358;id4=NCDF_OPEN('/usr/work/sur/fvi/OPA/geomag/V_5d_'+iyear+'_grid_T.nc',/write) 
     
    6661;id4=NCDF_OPEN('/usr/work/sur/fvi/OPA/ORCA2/DivBustar_5d_'+iyear+'_grid_T.nc',/write) 
    6762 
    68 FOR jt = 0, jpt-1 DO BEGIN &$    
     63FOR jt = 0, jpt-1 DO BEGIN &$ 
    6964 
    7065; ouverture des fichiers et stockage en memoire partial steps 
    71   vu=read_ncdf('vozocrtx',jt,jt, /timestep, iodir=ioDATA,/nostruct,/TOUT,filename=file_U)  &$    
    72 ;stop 
    73   vv=read_ncdf('vomecrty',jt,jt, /timestep,iodir=ioDATA,/nostruct,/TOUT,filename=file_V)  &$    
     66  vu=read_ncdf('vozocrtx',jt,jt, /timestep, iodir=ioDATA,/nostruct,/TOUT,filename=file_U)  &$ 
     67;stop 
     68  vv=read_ncdf('vomecrty',jt,jt, /timestep,iodir=ioDATA,/nostruct,/TOUT,filename=file_V)  &$ 
    7469;stop 
    7570; lecture salinite & temperature 
     
    107102 
    108103  conduct_v=(conduct+shift(conduct,0,1,0))/2. 
    109    
     104 
    110105  u_cond_u=total( vu*conduct_u*e3u3d*umask(),3) 
    111106 
     
    126121;for jj=0,147 do begin &$ 
    127122;  for ji=0,179 do begin &$ 
    128 ;   if( Diver(ji,jj) GT 1e10 ) then begin &$  
    129 ;       Diver(ji,jj) = 0. &$ 
     123;   if( Diver(ji,jj) GT 1e10 ) then begin &$ 
     124;      Diver(ji,jj) = 0. &$ 
    130125;   endif &$ 
    131126;  endfor &$ 
    132 ;endfor  
     127;endfor 
    133128 
    134129;stop 
     
    137132;stop 
    138133; Somme sur la verticale partial steps 
    139 ;                vum=total( vu*e3u3d*umask(),3 )  &$    
    140 ;                vvm=total( vv*e3v3d*vmask(),3 )  &$    
     134;                vum=total( vu*e3u3d*umask(),3 )  &$ 
     135;                vvm=total( vv*e3v3d*vmask(),3 )  &$ 
    141136 
    142137; Shift sur la grille T partial steps 
    143 ;             vut= (vum+shift(vum,1,0) )*0.5   &$    
     138;             vut= (vum+shift(vum,1,0) )*0.5   &$ 
    144139;             vvt= (vvm+shift(vvm,0,1) )*0.5   &$ 
    145 ; Bande de recouvrement  
     140; Bande de recouvrement 
    146141;             vut(0, *) = vut(jpi-2, *) 
    147142;             vvt(*, 0) = 0. 
    148 ; stockage dans le fichier de sortie  
     143; stockage dans le fichier de sortie 
    149144;NCDF_VARPUT, id3,'sossheig',vut, offset = [0, 0, jt] 
    150145;NCDF_VARPUT, id4,'sossheig',Diver, offset = [0, 0, jt] 
     
    153148 
    154149 
    155 ENDFOR   
     150ENDFOR 
    156151; on ferme le NetCDF 
    157152;NCDF_CLOSE,id3 
     
    218213; Creation de la latitude 
    219214   NCDF_VARPUT, idout, id1, gphit 
    220 ; Creation de la profondeur  
    221    NCDF_VARPUT, idout, id2, gdept  
     215; Creation de la profondeur 
     216   NCDF_VARPUT, idout, id2, gdept 
    222217; Creation du calendrier 
    223218 
    224219   NCDF_VARPUT, idout, id3, temps 
    225220 
    226     
     221 
    227222; Ecriture des donnees 
    228223 
    229 ; ecriture des glam_8  
     224; ecriture des glam_8 
    230225   NCDF_VARPUT, idout, id4 , diver2 
    231226 
  • trunk/forcageforMOED.pro

    r2 r48  
    11PRO forcageforMOED 
    2 @init2 
    3 @initorca2_bab 
    4  
    5 @common 
    6  
    7 ian='01' 
    8 iyear='1993' 
    9  
    10 e_exp='ESS' 
    11 rep_fred='/usr/work/sur/fvi/OPA/geomag/' 
    12 key_portrait = 0 
    13 ; stockage des fichiers brut  
    14   ioDATA='/usr/work/sur/fvi/OPA/ORCA2/' 
    15   file_U=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_U.nc'  
    16   print, file_U 
    17   file_V=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_V.nc'  
    18   print, file_V 
    19   file_T=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_T.nc'  
    20   print, file_T 
    21   file_Sed= rep_fred+'cond_sed_ORCA2.nc' 
    22   file_Br= rep_fred+'Br_ORCA2.nc' 
    23  
    24  
    25 ; title 
    26      t_exp= e_exp 
    27          
    28      t_bt  = 'bar_transp' 
    29 ioORLN2 = '/usr/work/sur/fvi/OPA/ORCA2' 
    30 ;facteur d'echelle vertical  for partial steps 
    31 e3v3d=read_ncdf('e3v_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
    32 e3u3d=read_ncdf('e3u_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
    33 SIGMAsed=read_ncdf('cond_sed',0,/timestep,/nostruct,/tout,filename=file_Sed,/cont_nofill) 
    34 BR=read_ncdf('Br',0,/timestep,/nostruct,/tout,filename=file_Br,/cont_nofill) 
    35  
    36  
    37  
    38  
    39  
    40 ; vertical integration: 
    41 e3t3d=make_array(jpi,jpj,jpk)    
    42         for k=0, jpk-1 do begin              &$ 
    43           for j=0,jpj-1 do begin              &$       
     2    @init2 
     3    @initorca2_bab 
     4 
     5    @common 
     6 
     7    ian='01' 
     8    iyear='1993' 
     9 
     10    e_exp='ESS' 
     11    rep_fred='/usr/work/sur/fvi/OPA/geomag/' 
     12    key_portrait = 0 
     13    ; stockage des fichiers brut 
     14    ioDATA='/usr/work/sur/fvi/OPA/ORCA2/' 
     15    file_U=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_U.nc' 
     16    print, file_U 
     17    file_V=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_V.nc' 
     18    print, file_V 
     19    file_T=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_T.nc' 
     20    print, file_T 
     21    file_Sed= rep_fred+'cond_sed_ORCA2.nc' 
     22    file_Br= rep_fred+'Br_ORCA2.nc' 
     23 
     24 
     25    ; title 
     26    t_exp= e_exp 
     27 
     28    t_bt  = 'bar_transp' 
     29    ioORLN2 = '/usr/work/sur/fvi/OPA/ORCA2' 
     30    ;facteur d'echelle vertical for partial steps 
     31    e3v3d=read_ncdf('e3v_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
     32    e3u3d=read_ncdf('e3u_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
     33    SIGMAsed=read_ncdf('cond_sed',0,/timestep,/nostruct,/tout,filename=file_Sed,/cont_nofill) 
     34    BR=read_ncdf('Br',0,/timestep,/nostruct,/tout,filename=file_Br,/cont_nofill) 
     35 
     36    ; vertical integration: 
     37    e3t3d=make_array(jpi,jpj,jpk) 
     38    for k=0, jpk-1 do begin              &$ 
     39        for j=0,jpj-1 do begin              &$ 
    4440            for i=0,jpi-1 do begin             &$ 
    45               e3t3d(i,j,k) = e3t(k)    &$ 
     41                e3t3d(i,j,k) = e3t(k)    &$ 
    4642            endfor                     &$ 
    47           endfor                      &$ 
    48         endfor 
    49 jpt = 73 
    50  
    51 ;vud = make_array(jpi,jpj,jpt)    
    52 ;vvd = make_array(jpi, jpj, jpt) 
    53 divBustar = make_array(jpi, jpj, jpt) 
    54 diver3=replicate(0.,182,149,1,73) 
    55 sigma3=replicate(0.,182,149,1,73) 
    56 Jpu=replicate(0.,182,149,1,73) 
    57 Jpv=replicate(0.,182,149,1,73) 
    58  
    59  
    60 FOR jt = 0, jpt-1 DO BEGIN &$    
    61  
    62 ; ouverture des fichiers et stockage en memoire partial steps 
    63   vu=read_ncdf('vozocrtx',jt,jt, /timestep, iodir=ioDATA,/nostruct,/TOUT,filename=file_U)  &$    
    64 ;stop 
    65   vv=read_ncdf('vomecrty',jt,jt, /timestep,iodir=ioDATA,/nostruct,/TOUT,filename=file_V)  &$    
    66 ;stop 
    67 ; lecture salinite & temperature 
    68   temp= read_ncdf('votemper',jt,jt,/timestep,iodir=ioDATA,/nostruct,/tout,filename=file_T) 
    69 ;stop 
    70   salin=read_ncdf('vosaline',jt,jt,/timestep,iodir=ioDATA,/nostruct,/tout,filename=file_T) 
    71 ;stop 
    72   conduct=0.02047780622061 + 0.00273147624197*temp + 0.00035133182334*temp*temp + 0.09139808809909*salin + 0.00241425798890*salin*temp -0.00023998958774*salin*salin 
    73   mask_t=where(conduct GT 1.e+19) 
    74   conduct(mask_t)=0. 
    75 ; Somme conduct au point T 
    76  
    77  
    78 ; Calcul SIGMA 
    79  
    80   SIGMAoc=total(conduct*e3t3d*tmask,3) 
    81   SIGMA=SIGMAsed+SIGMAoc 
    82  
    83  
    84  
    85   SIGMA_u=(SIGMA+shift(SIGMA,-1,0))/2. 
    86  
    87   SIGMA_v=(SIGMA+shift(SIGMA,0,1))/2. 
    88  
    89 ; Calcul B en points u et v 
    90  
    91   BR_u=(BR+shift(BR,-1,0))/2. 
    92  
    93   BR_v=(BR+shift(BR,0,1))/2. 
    94  
    95  
    96 ; Calcul integrale conduct 
    97  
    98   conduct_u=(conduct+shift(conduct,-1,0,0))/2. 
    99  
    100   conduct_v=(conduct+shift(conduct,0,1,0))/2. 
    101    
    102   u_cond_u=total( vu*conduct_u*e3u3d*umask(),3) 
    103  
    104   v_cond_v=total( vv*conduct_v*e3v3d*vmask(),3) 
    105  
    106  
    107 ;calcul de Jp= u_star x Fz k 
    108   Jpv_star= -1*BR_u*u_cond_u 
    109  
    110   Jpu_star= BR_v*v_cond_v 
    111  
    112 ; Divergence du champ 
    113  
    114   Diver=divfred(Jpu_star,Jpv_star) 
    115  
    116 Diver=Diver*1e-6 
    117 ;stop 
    118 lecontinent=where(Diver GT 1.E08) 
    119 Diver(lecontinent)=0. 
    120  
    121  
    122  
    123 ;stop 
    124 ;bande de recouvrement:: 
    125  
    126 diver3(1:180,0:147,*,jt)=Diver(*,*) 
    127 diver3(0,*,*,*)=diver3(180,*,*,*) 
    128 diver3(181,*,*,*)=diver3(1,*,*,*) 
    129  
    130 sigma3(1:180,0:147,*,jt)=SIGMA(*,*) 
    131 sigma3(0,*,*,*)=sigma3(180,*,*,*) 
    132 sigma3(181,*,*,*)=sigma3(1,*,*,*) 
    133  
    134 Jpu(1:180,0:147,*,jt)=Jpu_star(*,*) 
    135 Jpu(0,*,*,*)=Jpu(180,*,*,*) 
    136 Jpu(181,*,*,*)=Jpu(1,*,*,*) 
    137  
    138 Jpv(1:180,0:147,*,jt)=Jpv_star(*,*) 
    139 Jpv(0,*,*,*)=Jpv(180,*,*,*) 
    140 Jpv(181,*,*,*)=Jpv(1,*,*,*) 
    141  
    142  
    143  
    144  
    145 print,  jt 
    146  
    147  
    148 ENDFOR  
    149   
    150  
    151  
    152  
    153 temps=fltarr(73) 
    154 temps(0)=0. 
    155 for jt=0,71 do begin &$ 
    156 temps(jt+1)=temps(jt) +5*86400. &$ 
    157 endfor 
    158 print,temps 
    159  
    160    vargrid = 'T' 
    161    iodir = '/usr/work/sur/fvi/OPA/ORCA2/' 
    162 ; Nom 
    163    idout = NCDF_CREATE(iodir+'ForcageMOED_5d_'+iyear+'_grid_T.nc',/clobber) 
    164    print, 'Creation du fichier Netcdf' 
    165    NCDF_CONTROL, idout, /nofill 
    166 ; Dimension 
    167    xidout = NCDF_DIMDEF(idout, 'x',jpiglo) 
    168    yidout = NCDF_DIMDEF(idout, 'y',jpjglo) 
    169    didout = NCDF_DIMDEF(idout, 'deptht',1) 
    170    tidout = NCDF_DIMDEF(idout, 'time_counter', /unlimited) 
    171  
    172    didout1 = NCDF_DIMDEF(idout, 'deptht1',jpk) 
     43        endfor                      &$ 
     44    endfor 
     45    jpt = 73 
     46 
     47    ;vud = make_array(jpi,jpj,jpt) 
     48    ;vvd = make_array(jpi, jpj, jpt) 
     49    divBustar = make_array(jpi, jpj, jpt) 
     50    diver3=replicate(0.,182,149,1,73) 
     51    sigma3=replicate(0.,182,149,1,73) 
     52    Jpu=replicate(0.,182,149,1,73) 
     53    Jpv=replicate(0.,182,149,1,73) 
     54 
     55 
     56    FOR jt = 0, jpt-1 DO BEGIN &$ 
     57 
     58        ; ouverture des fichiers et stockage en memoire partial steps 
     59          vu=read_ncdf('vozocrtx',jt,jt, /timestep, iodir=ioDATA,/nostruct,/TOUT,filename=file_U)  &$ 
     60        ;stop 
     61          vv=read_ncdf('vomecrty',jt,jt, /timestep,iodir=ioDATA,/nostruct,/TOUT,filename=file_V)  &$ 
     62        ;stop 
     63        ; lecture salinite & temperature 
     64          temp= read_ncdf('votemper',jt,jt,/timestep,iodir=ioDATA,/nostruct,/tout,filename=file_T) 
     65        ;stop 
     66          salin=read_ncdf('vosaline',jt,jt,/timestep,iodir=ioDATA,/nostruct,/tout,filename=file_T) 
     67        ;stop 
     68          conduct=0.02047780622061 + 0.00273147624197*temp + 0.00035133182334*temp*temp + 0.09139808809909*salin + 0.00241425798890*salin*temp -0.00023998958774*salin*salin 
     69          mask_t=where(conduct GT 1.e+19) 
     70          conduct(mask_t)=0. 
     71        ; Somme conduct au point T 
     72 
     73 
     74        ; Calcul SIGMA 
     75 
     76          SIGMAoc=total(conduct*e3t3d*tmask,3) 
     77          SIGMA=SIGMAsed+SIGMAoc 
     78 
     79          SIGMA_u=(SIGMA+shift(SIGMA,-1,0))/2. 
     80 
     81          SIGMA_v=(SIGMA+shift(SIGMA,0,1))/2. 
     82 
     83        ; Calcul B en points u et v 
     84 
     85          BR_u=(BR+shift(BR,-1,0))/2. 
     86 
     87          BR_v=(BR+shift(BR,0,1))/2. 
     88 
     89 
     90        ; Calcul integrale conduct 
     91 
     92          conduct_u=(conduct+shift(conduct,-1,0,0))/2. 
     93 
     94          conduct_v=(conduct+shift(conduct,0,1,0))/2. 
     95 
     96          u_cond_u=total( vu*conduct_u*e3u3d*umask(),3) 
     97 
     98          v_cond_v=total( vv*conduct_v*e3v3d*vmask(),3) 
     99 
     100 
     101        ;calcul de Jp= u_star x Fz k 
     102        Jpv_star= -1*BR_u*u_cond_u 
     103 
     104        Jpu_star= BR_v*v_cond_v 
     105 
     106        ; Divergence du champ 
     107 
     108        Diver=divfred(Jpu_star,Jpv_star) 
     109 
     110        Diver=Diver*1e-6 
     111        ;stop 
     112        lecontinent=where(Diver GT 1.E08) 
     113        Diver(lecontinent)=0. 
     114 
     115 
     116 
     117        ;stop 
     118        ;bande de recouvrement: 
     119 
     120        diver3(1:180,0:147,*,jt)=Diver(*,*) 
     121        diver3(0,*,*,*)=diver3(180,*,*,*) 
     122        diver3(181,*,*,*)=diver3(1,*,*,*) 
     123 
     124        sigma3(1:180,0:147,*,jt)=SIGMA(*,*) 
     125        sigma3(0,*,*,*)=sigma3(180,*,*,*) 
     126        sigma3(181,*,*,*)=sigma3(1,*,*,*) 
     127 
     128        Jpu(1:180,0:147,*,jt)=Jpu_star(*,*) 
     129        Jpu(0,*,*,*)=Jpu(180,*,*,*) 
     130        Jpu(181,*,*,*)=Jpu(1,*,*,*) 
     131 
     132        Jpv(1:180,0:147,*,jt)=Jpv_star(*,*) 
     133        Jpv(0,*,*,*)=Jpv(180,*,*,*) 
     134        Jpv(181,*,*,*)=Jpv(1,*,*,*) 
     135 
     136        print,  jt 
     137 
     138    ENDFOR 
     139 
     140    temps=fltarr(73) 
     141    temps(0)=0. 
     142    for jt=0,71 do begin &$ 
     143        temps(jt+1)=temps(jt) +5*86400. &$ 
     144    endfor 
     145    print,temps 
     146 
     147    vargrid = 'T' 
     148    iodir = '/usr/work/sur/fvi/OPA/ORCA2/' 
     149    ; Nom 
     150    idout = NCDF_CREATE(iodir+'ForcageMOED_5d_'+iyear+'_grid_T.nc',/clobber) 
     151    print, 'Creation du fichier Netcdf' 
     152    NCDF_CONTROL, idout, /nofill 
     153    ; Dimension 
     154    xidout = NCDF_DIMDEF(idout, 'x',jpiglo) 
     155    yidout = NCDF_DIMDEF(idout, 'y',jpjglo) 
     156    didout = NCDF_DIMDEF(idout, 'deptht',1) 
     157    tidout = NCDF_DIMDEF(idout, 'time_counter', /unlimited) 
     158 
     159    didout1 = NCDF_DIMDEF(idout, 'deptht1',jpk) 
    173160 
    174161 
    175162; Attributs globaux 
    176    id0  = NCDF_VARDEF(idout, 'nav_lon'     , [xidout, yidout                ], /FLOAT) 
    177    id1  = NCDF_VARDEF(idout, 'nav_lat'     , [xidout, yidout                ], /FLOAT) 
    178    id2  = NCDF_VARDEF(idout, 'deptht'      , [                didout1        ], /FLOAT) 
    179    id3  = NCDF_VARDEF(idout, 'time_counter', [                        tidout], /FLOAT) 
    180    id4  = NCDF_VARDEF(idout, 'DivJp'  , [xidout, yidout, didout, tidout], /DOUBLE) 
    181    id5  = NCDF_VARDEF(idout, 'Sigma'  , [xidout, yidout, didout, tidout], /DOUBLE) 
    182    id6  = NCDF_VARDEF(idout, 'Jpu'  , [xidout, yidout, didout, tidout], /DOUBLE) 
    183    id7  = NCDF_VARDEF(idout, 'Jpv'  , [xidout, yidout, didout, tidout], /DOUBLE) 
     163    id0  = NCDF_VARDEF(idout, 'nav_lon'     , [xidout, yidout                ], /FLOAT) 
     164    id1  = NCDF_VARDEF(idout, 'nav_lat'     , [xidout, yidout                ], /FLOAT) 
     165    id2  = NCDF_VARDEF(idout, 'deptht'      , [                didout1        ], /FLOAT) 
     166    id3  = NCDF_VARDEF(idout, 'time_counter', [                        tidout], /FLOAT) 
     167    id4  = NCDF_VARDEF(idout, 'DivJp'  , [xidout, yidout, didout, tidout], /DOUBLE) 
     168    id5  = NCDF_VARDEF(idout, 'Sigma'  , [xidout, yidout, didout, tidout], /DOUBLE) 
     169    id6  = NCDF_VARDEF(idout, 'Jpu'  , [xidout, yidout, didout, tidout], /DOUBLE) 
     170    id7  = NCDF_VARDEF(idout, 'Jpv'  , [xidout, yidout, didout, tidout], /DOUBLE) 
    184171 
    185172; Variable 0 
    186    NCDF_ATTPUT, idout, id0, 'units', 'degrees_east' 
    187    NCDF_ATTPUT, idout, id0, 'long_name', 'Longitude' 
    188    NCDF_ATTPUT, idout, id0, 'nav_model', 'Default grid' 
     173    NCDF_ATTPUT, idout, id0, 'units', 'degrees_east' 
     174    NCDF_ATTPUT, idout, id0, 'long_name', 'Longitude' 
     175    NCDF_ATTPUT, idout, id0, 'nav_model', 'Default grid' 
    189176; Variable 1 
    190    NCDF_ATTPUT, idout, id1, 'units', 'degrees_north' 
    191    NCDF_ATTPUT, idout, id1, 'long_name', 'Latitude' 
    192    NCDF_ATTPUT, idout, id1, 'nav_model', 'Default grid' 
     177    NCDF_ATTPUT, idout, id1, 'units', 'degrees_north' 
     178    NCDF_ATTPUT, idout, id1, 'long_name', 'Latitude' 
     179    NCDF_ATTPUT, idout, id1, 'nav_model', 'Default grid' 
    193180; Variable 2 
    194    NCDF_ATTPUT, idout, id2, 'units','meters' 
    195    NCDF_ATTPUT, idout, id2, 'long_name','Depth' 
    196    NCDF_ATTPUT, idout, id2, 'nav_model','Default grid' 
     181    NCDF_ATTPUT, idout, id2, 'units','meters' 
     182    NCDF_ATTPUT, idout, id2, 'long_name','Depth' 
     183    NCDF_ATTPUT, idout, id2, 'nav_model','Default grid' 
    197184; Variable3 
    198    NCDF_ATTPUT, idout, id3, 'units', 'seconds since 0001-01-01 00:00:00 ' 
    199    NCDF_ATTPUT, idout, id3, 'calendar','noleap' 
    200    NCDF_ATTPUT, idout, id3, 'title', 'Time' 
    201    NCDF_ATTPUT, idout, id3, 'long_name', 'Time axis' 
    202    NCDF_ATTPUT, idout, id3, 'time_origin','0001-JAN-01 00:00:00' 
     185    NCDF_ATTPUT, idout, id3, 'units', 'seconds since 0001-01-01 00:00:00 ' 
     186    NCDF_ATTPUT, idout, id3, 'calendar','noleap' 
     187    NCDF_ATTPUT, idout, id3, 'title', 'Time' 
     188    NCDF_ATTPUT, idout, id3, 'long_name', 'Time axis' 
     189    NCDF_ATTPUT, idout, id3, 'time_origin','0001-JAN-01 00:00:00' 
    203190; Variables 
    204    NCDF_ATTPUT, idout, id4, 'long_name', 'Divergence Jp' 
     191    NCDF_ATTPUT, idout, id4, 'long_name', 'Divergence Jp' 
    205192; Variables 
    206    NCDF_ATTPUT, idout, id5, 'long_name', 'Total Conductance' 
    207    NCDF_ATTPUT, idout, id6, 'long_name', 'Jpu=u_star x B (x comp)' 
    208    NCDF_ATTPUT, idout, id7, 'long_name', 'Jpv=u_star x B (y comp)' 
    209  
    210  
    211    NCDF_CONTROL, idout, /ENDEF 
     193    NCDF_ATTPUT, idout, id5, 'long_name', 'Total Conductance' 
     194    NCDF_ATTPUT, idout, id6, 'long_name', 'Jpu=u_star x B (x comp)' 
     195    NCDF_ATTPUT, idout, id7, 'long_name', 'Jpv=u_star x B (y comp)' 
     196 
     197 
     198    NCDF_CONTROL, idout, /ENDEF 
    212199 
    213200; Creation de la longitude 
    214    NCDF_VARPUT, idout, id0, glamt 
     201    NCDF_VARPUT, idout, id0, glamt 
    215202; Creation de la latitude 
    216    NCDF_VARPUT, idout, id1, gphit 
    217 ; Creation de la profondeur  
    218    NCDF_VARPUT, idout, id2, gdept  
     203    NCDF_VARPUT, idout, id1, gphit 
     204; Creation de la profondeur 
     205    NCDF_VARPUT, idout, id2, gdept 
    219206; Creation du calendrier 
    220207 
    221    NCDF_VARPUT, idout, id3, temps 
    222  
    223     
    224 ; Ecriture des donnees 
    225  
    226 ; ecriture des glam_8  
    227    NCDF_VARPUT, idout, id4 , diver3 
    228    NCDF_VARPUT, idout, id5 , sigma3 
    229    NCDF_VARPUT, idout, id6 , Jpu 
    230    NCDF_VARPUT, idout, id7 , Jpv 
    231  
    232  
    233  
    234    NCDF_CLOSE, idout 
    235  
     208    NCDF_VARPUT, idout, id3, temps 
     209 
     210 
     211    ; Ecriture des donnees 
     212 
     213    ; ecriture des glam_8 
     214    NCDF_VARPUT, idout, id4 , diver3 
     215    NCDF_VARPUT, idout, id5 , sigma3 
     216    NCDF_VARPUT, idout, id6 , Jpu 
     217    NCDF_VARPUT, idout, id7 , Jpv 
     218 
     219    NCDF_CLOSE, idout 
    236220 
    237221END 
  • trunk/forcagequimarche.pro

    r36 r48  
    22; 
    33; @file_comments 
    4 ; calcul d'une matrice 3D de conductivité sigma=f(T,S) en fonction de T et S 
     4; calcul d'une matrice 3D de conductivité sigma=f(T,S) en fonction de T et S 
    55; de ORCA, sur la grille T 
    66; 
     
    6767; 
    6868PRO forcagequimarche, orcares, iyear, ian, DRAKKAR_EXP = drakkar_exp 
    69 ; 
    70 ;---- 
    71 ; check input parameters 
    72 ;---- 
    73 ; 
    74 ; check orcares definition 
    75 ; 
    76   CASE orcares OF 
    77      'ORCA2': BEGIN 
    78                  msg = 'iii : valid orcares parameter = ' + orcares 
    79                  ras = report(msg) 
    80                  filename_oce = 'meshmask_bab.nc' 
    81                  IF keyword_set(DRAKKAR_EXP) THEN BEGIN 
    82                     msg = 'www : unused DRAKKAR_EXP keyword = ' + drakkar_exp 
    83                     ras = report(msg) 
    84                  END 
     69    ; 
     70    ;---- 
     71    ; check input parameters 
     72    ;---- 
     73    ; 
     74    ; check orcares definition 
     75    ; 
     76    CASE orcares OF 
     77       'ORCA2': BEGIN 
     78                   msg = 'iii : valid orcares parameter = ' + orcares 
     79                   ras = report(msg) 
     80                   filename_oce = 'meshmask_bab.nc' 
     81                   IF keyword_set(DRAKKAR_EXP) THEN BEGIN 
     82                      msg = 'www : unused DRAKKAR_EXP keyword = ' + drakkar_exp 
     83                      ras = report(msg) 
     84                   END 
     85        END 
     86        ELSE : BEGIN 
     87                   msg = 'eee : invalid orcares parameter = ' + orcares 
     88                   ras = report(msg) 
     89                   msg = 'eee : orcares must be ORCA2 or ORCA025++' 
     90                   ras = report(msg) 
     91                   RETURN 
     92        END 
     93    ENDCASE 
     94   
     95    ; ++ check iyear 
     96    ; ++ check ian 
     97     
     98    ;++@init2 
     99    ; init grid 
     100    initocemeshmask, orcares, DRAKKAR_EXP = drakkar_exp 
     101   
     102    @common 
     103    ; 
     104    ; check for input files 
     105    ; 
     106    ; test if ${GEOMAG_ID} defined 
     107    geomag_id_env=GETENV('GEOMAG_ID') 
     108    CASE geomag_id_env OF 
     109       ''  :  BEGIN 
     110                msg = 'eee : ${GEOMAG_ID} is not defined' 
     111                ras = report(msg) 
     112                RETURN 
    85113              END 
    86       ELSE  : BEGIN 
    87                  msg = 'eee : invalid orcares parameter = ' + orcares 
    88                  ras = report(msg) 
    89                  msg = 'eee : orcares must be ORCA2 or ORCA025++' 
    90                  ras = report(msg) 
    91                  RETURN 
    92               END 
     114       ELSE : BEGIN 
     115               msg = 'iii : ${GEOMAG_ID} is ' + geomag_id_env 
     116               ras = report(msg) 
     117       END 
     118    ENDCASE 
     119    ; 
     120    iodirin = isadirectory(geomag_id_env) 
     121    ; 
     122  ; existence and protection of ${GEOMAG_ID} 
     123    IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN 
     124       msg = 'eee : the directory' + iodirin  + ' is not accessible.' 
     125       ras = report(msg) 
     126       RETURN 
     127    ENDIF 
     128  ; 
     129  ; test if ${GEOMAG_OD} defined 
     130    geomag_od_env=GETENV('GEOMAG_OD') 
     131    CASE geomag_od_env OF 
     132       '' : BEGIN 
     133               msg = 'eee : ${GEOMAG_OD} is not defined' 
     134               ras = report(msg) 
     135               RETURN 
     136            END 
     137       ELSE : BEGIN 
     138               msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env 
     139               ras = report(msg) 
     140             END 
    93141  ENDCASE 
    94  
    95 ; ++ check iyear 
    96 ; ++ check ian 
    97  
    98 ;++@init2 
    99 ; init grid 
    100 initocemeshmask, orcares, DRAKKAR_EXP = drakkar_exp 
    101  
    102 @common 
    103 ; 
    104 ; check for input files 
    105 ; 
    106 ; test if ${GEOMAG_ID} defined 
    107   geomag_id_env=GETENV('GEOMAG_ID') 
    108   CASE geomag_id_env OF 
    109      ''  :  BEGIN 
    110               msg = 'eee : ${GEOMAG_ID} is not defined' 
    111               ras = report(msg) 
    112               RETURN 
    113             END 
    114      ELSE: BEGIN 
    115              msg = 'iii : ${GEOMAG_ID} is ' + geomag_id_env 
    116              ras = report(msg) 
    117            END 
    118   ENDCASE 
    119 ; 
    120   iodirin = isadirectory(geomag_id_env) 
    121 ; 
    122 ; existence and protection of ${GEOMAG_ID} 
    123   IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN 
    124      msg = 'eee : the directory' + iodirin  + ' is not accessible.' 
    125      ras = report(msg) 
    126      RETURN 
    127   ENDIF 
    128 ; 
    129 ; test if ${GEOMAG_OD} defined 
    130   geomag_od_env=GETENV('GEOMAG_OD') 
    131   CASE geomag_od_env OF 
    132      '' : BEGIN 
    133              msg = 'eee : ${GEOMAG_OD} is not defined' 
    134              ras = report(msg) 
    135              RETURN 
    136           END 
    137      ELSE: BEGIN 
    138              msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env 
    139              ras = report(msg) 
    140            END 
    141   ENDCASE 
    142 ; 
    143 ; check if output data will be possible 
    144   iodirout = isadirectory(geomag_od_env) 
    145 ; 
    146 ; existence and protection 
    147   IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN 
    148      msg = 'eee : the directory' + iodirout  + ' was not found.' 
    149      ras = report(msg) 
    150      RETURN 
    151   ENDIF 
    152 ; 
    153 e_exp='ESS' 
    154 key_portrait = 0 
    155 ; stockage des fichiers brut 
    156   ioDATA=geomag_id_env 
    157  
    158   CASE orcares OF 
    159      'ORCA2': BEGIN 
    160   file_U=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_U.nc' 
    161   file_V=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_V.nc' 
    162   file_T=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_T.nc' 
    163 jpt = 73 ;time counter des fichiers ci-dessus 
    164      END 
    165   ENDCASE 
    166   file_Sed= geomag_id_env+'cond_sed_'+orcares+'.nc' 
    167   file_Br= geomag_id_env+'Br_'+orcares + '.nc' 
    168 ; 
    169 ; title 
    170      t_exp= e_exp 
    171      t_bt  = 'bar_transp' 
    172 ioORLN2 = geomag_id_env 
    173 ; 
    174 ;facteur d'echelle vertical for partial steps 
    175 e3v3d=read_ncdf('e3v_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
    176 e3u3d=read_ncdf('e3u_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
    177 SIGMAsed=read_ncdf('cond_sed',0,/timestep,/nostruct,/tout,filename=file_Sed,/cont_nofill) 
    178 ;BR=read_ncdf('Br',0,/timestep,/nostruct,/tout,filename=file_Br) 
    179 BR=read_ncdf('Br',0,/timestep,/nostruct,/tout,filename=file_Br,/cont_nofill) 
    180 ; 
    181 ; vertical integration: 
    182 e3t3d=make_array(jpi,jpj,jpk) 
    183         for k=0, jpk-1 do begin              &$ 
    184           for j=0,jpj-1 do begin              &$ 
    185             for i=0,jpi-1 do begin             &$ 
    186               e3t3d(i,j,k) = e3t(k)    &$ 
    187             endfor                     &$ 
    188           endfor                      &$ 
    189         endfor 
    190 ; 
    191 ;vud = make_array(jpi,jpj,jpt) 
    192 ;vvd = make_array(jpi, jpj, jpt) 
    193 divBustar = make_array(jpi, jpj, jpt) 
    194 diver3=replicate(0.,182,149,1,jpt) 
    195 sigma3=replicate(0.,182,149,1,jpt) 
    196 ; 
    197 FOR jt = 0, jpt-1 DO BEGIN &$ 
    198 ; 
    199 ; ouverture des fichiers et stockage en memoire partial steps 
    200   vu=read_ncdf('vozocrtx',jt,jt, /timestep, iodir=ioDATA,/nostruct,/TOUT,filename=file_U)  &$ 
     142  ; 
     143  ; check if output data will be possible 
     144    iodirout = isadirectory(geomag_od_env) 
     145  ; 
     146  ; existence and protection 
     147    IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN 
     148       msg = 'eee : the directory' + iodirout  + ' was not found.' 
     149       ras = report(msg) 
     150       RETURN 
     151    ENDIF 
     152  ; 
     153  e_exp='ESS' 
     154  key_portrait = 0 
     155  ; stockage des fichiers brut 
     156    ioDATA=geomag_id_env 
     157   
     158    CASE orcares OF 
     159       'ORCA2': BEGIN 
     160    file_U=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_U.nc' 
     161    file_V=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_V.nc' 
     162    file_T=e_exp+'_5d_'+ian+'0101_'+ian+'1231_grid_T.nc' 
     163  jpt = 73 ;time counter des fichiers ci-dessus 
     164       END 
     165    ENDCASE 
     166    file_Sed= geomag_id_env+'cond_sed_'+orcares+'.nc' 
     167    file_Br= geomag_id_env+'Br_'+orcares + '.nc' 
     168  ; 
     169  ; title 
     170       t_exp= e_exp 
     171       t_bt  = 'bar_transp' 
     172  ioORLN2 = geomag_id_env 
     173  ; 
     174  ;facteur d'echelle vertical for partial steps 
     175  e3v3d=read_ncdf('e3v_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
     176  e3u3d=read_ncdf('e3u_ps',0,/timestep,iodir=ioORLN2,/nostruct,/tout,filename='meshmask_bab.nc') 
     177  SIGMAsed=read_ncdf('cond_sed',0,/timestep,/nostruct,/tout,filename=file_Sed,/cont_nofill) 
     178  ;BR=read_ncdf('Br',0,/timestep,/nostruct,/tout,filename=file_Br) 
     179  BR=read_ncdf('Br',0,/timestep,/nostruct,/tout,filename=file_Br,/cont_nofill) 
     180  ; 
     181  ; vertical integration: 
     182  e3t3d=make_array(jpi,jpj,jpk) 
     183          for k=0, jpk-1 do begin              &$ 
     184            for j=0,jpj-1 do begin              &$ 
     185              for i=0,jpi-1 do begin             &$ 
     186                e3t3d(i,j,k) = e3t(k)    &$ 
     187              endfor                     &$ 
     188            endfor                      &$ 
     189          endfor 
     190  ; 
     191  ;vud = make_array(jpi,jpj,jpt) 
     192  ;vvd = make_array(jpi, jpj, jpt) 
     193  divBustar = make_array(jpi, jpj, jpt) 
     194  diver3=replicate(0.,182,149,1,jpt) 
     195  sigma3=replicate(0.,182,149,1,jpt) 
     196  ; 
     197  FOR jt = 0, jpt-1 DO BEGIN &$ 
     198  ; 
     199  ; ouverture des fichiers et stockage en memoire partial steps 
     200    vu=read_ncdf('vozocrtx',jt,jt, /timestep, iodir=ioDATA,/nostruct,/TOUT,filename=file_U)  &$ 
     201  ;stop 
     202    vv=read_ncdf('vomecrty',jt,jt, /timestep,iodir=ioDATA,/nostruct,/TOUT,filename=file_V)  &$ 
     203  ;stop 
     204  ; lecture salinite & temperature 
     205    temp= read_ncdf('votemper',jt,jt,/timestep,iodir=ioDATA,/nostruct,/tout,filename=file_T) 
     206  ;stop 
     207    salin=read_ncdf('vosaline',jt,jt,/timestep,iodir=ioDATA,/nostruct,/tout,filename=file_T) 
     208  ;stop 
     209    conduct=0.02047780622061 + 0.00273147624197*temp + 0.00035133182334*temp*temp + 0.09139808809909*salin + 0.00241425798890*salin*temp -0.00023998958774*salin*salin 
     210    mask_t=where(conduct GT 1.e+19) 
     211    conduct(mask_t)=0. 
     212  ; Somme conduct au point T 
     213  ; 
     214  ; Calcul SIGMA 
     215  ; 
     216    SIGMAoc=total(conduct*e3t3d*tmask,3) 
     217    SIGMA=SIGMAsed+SIGMAoc 
     218  ; 
     219    SIGMA_u=(SIGMA+shift(SIGMA,-1,0))/2. 
     220    SIGMA_v=(SIGMA+shift(SIGMA,0,1))/2. 
     221  ; 
     222  ; Calcul B en points u et v 
     223  ; 
     224    BR_u=(BR+shift(BR,-1,0))/2. 
     225    BR_v=(BR+shift(BR,0,1))/2. 
     226  ; 
     227  ; Calcul integrale conduct 
     228  ; 
     229    conduct_u=(conduct+shift(conduct,-1,0,0))/2. 
     230    conduct_v=(conduct+shift(conduct,0,1,0))/2. 
     231  ; 
     232    u_cond_u=total( vu*conduct_u*e3u3d*umask(),3) 
     233    v_cond_v=total( vv*conduct_v*e3v3d*vmask(),3) 
     234  ; 
     235    Bu_star= BR_u*u_cond_u/SIGMA_u 
     236    Bv_star= BR_v*v_cond_v/SIGMA_v 
     237   
     238  ; Transport horizontal 
     239    T_u=total( vu*e3u3d*umask(),3) 
     240    T_v=total( vv*e3v3d*vmask(),3) 
     241   
     242  ; 
     243  ; Divergence du champ 
     244    Diver=divfred(Bu_star,Bv_star) 
     245   
     246  Diver=Diver*1e-6 
     247  ;stop 
     248  lecontinent=where(Diver GT 1.E08) 
     249  Diver(lecontinent)=0. 
     250 
    201251;stop 
    202   vv=read_ncdf('vomecrty',jt,jt, /timestep,iodir=ioDATA,/nostruct,/TOUT,filename=file_V)  &$ 
    203 ;stop 
    204 ; lecture salinite & temperature 
    205   temp= read_ncdf('votemper',jt,jt,/timestep,iodir=ioDATA,/nostruct,/tout,filename=file_T) 
    206 ;stop 
    207   salin=read_ncdf('vosaline',jt,jt,/timestep,iodir=ioDATA,/nostruct,/tout,filename=file_T) 
    208 ;stop 
    209   conduct=0.02047780622061 + 0.00273147624197*temp + 0.00035133182334*temp*temp + 0.09139808809909*salin + 0.00241425798890*salin*temp -0.00023998958774*salin*salin 
    210   mask_t=where(conduct GT 1.e+19) 
    211   conduct(mask_t)=0. 
    212 ; Somme conduct au point T 
    213 ; 
    214 ; Calcul SIGMA 
    215 ; 
    216   SIGMAoc=total(conduct*e3t3d*tmask,3) 
    217   SIGMA=SIGMAsed+SIGMAoc 
    218 ; 
    219   SIGMA_u=(SIGMA+shift(SIGMA,-1,0))/2. 
    220   SIGMA_v=(SIGMA+shift(SIGMA,0,1))/2. 
    221 ; 
    222 ; Calcul B en points u et v 
    223 ; 
    224   BR_u=(BR+shift(BR,-1,0))/2. 
    225   BR_v=(BR+shift(BR,0,1))/2. 
    226 ; 
    227 ; Calcul integrale conduct 
    228 ; 
    229   conduct_u=(conduct+shift(conduct,-1,0,0))/2. 
    230   conduct_v=(conduct+shift(conduct,0,1,0))/2. 
    231 ; 
    232   u_cond_u=total( vu*conduct_u*e3u3d*umask(),3) 
    233   v_cond_v=total( vv*conduct_v*e3v3d*vmask(),3) 
    234 ; 
    235   Bu_star= BR_u*u_cond_u/SIGMA_u 
    236   Bv_star= BR_v*v_cond_v/SIGMA_v 
    237  
    238 ; Transport horizontal 
    239   T_u=total( vu*e3u3d*umask(),3) 
    240   T_v=total( vv*e3v3d*vmask(),3) 
    241  
    242 ; 
    243 ; Divergence du champ 
    244   Diver=divfred(Bu_star,Bv_star) 
    245  
    246 Diver=Diver*1e-6 
    247 ;stop 
    248 lecontinent=where(Diver GT 1.E08) 
    249 Diver(lecontinent)=0. 
    250  
    251 ;stop 
    252 ;bande de recouvrement:: 
     252;bande de recouvrement: 
    253253 
    254254diver3(1:180,0:147,*,jt)=Diver(*,*) 
     
    342342 
    343343   NCDF_CLOSE, idout 
    344 ; ++ l'équivalent avec forcage_output 
     344; ++ l'équivalent avec forcage_output 
    345345forcage_output, orcares, variable, 'Divergence', long_name, jpiglo, jpjglo, gphit, glamt,diver3 
    346346 
  • trunk/fsxspp.pro

    r2 r48  
    1010; 
    1111return, z 
    12 END  
     12END 
  • trunk/fsyspp.pro

    r2 r48  
    1010; 
    1111return, z 
    12 END  
     12END 
  • trunk/geomag_profile.sh

    r47 r48  
    3030# =========== 
    3131# 
    32 # .. option:: -d  <directory> 
    33 # .. option:: -i  <indir> 
    34 # .. option:: -o  <outdir> 
    35 # .. option:: -t  <tempdir> 
     32# .. option:: -d <directory> 
     33# .. option:: -i <indir> 
     34# .. option:: -o <outdir> 
     35# .. option:: -t <tempdir> 
    3636# 
    3737# define GEOMAG environment 
     
    7373# ++ besoin de posix 
    7474# 
    75 # ++ pas de MANPATH defini par défaut sur zeus 
     75# ++ pas de MANPATH defini par défaut sur zeus 
    7676# 
    7777# EVOLUTIONS 
     
    116116usage=" Usage : ${command} -d directory -i indir -o outdir -t tempdir" 
    117117# 
    118 set +u 
    119 while [ ! -z "${1}" ] 
    120 do 
    121    case ${1} in 
    122       -d) 
    123          # directory for application choosen by user (see svn checkout command used) 
    124          directory=${2} 
    125          shift 
    126       ;; 
    127       -i) 
    128          # directory for inputs choosen by user 
    129          indir=${2} 
    130          shift 
    131       ;; 
    132       -o) 
    133          # directory for outputs choosen by user 
    134          outdir=${2} 
    135          shift 
    136       ;; 
    137       -t) 
    138          # directory for temporary outputs choosen by user 
    139          tempdir=${2} 
    140          shift 
    141       ;; 
    142       *) 
    143          # other choice 
    144          echo "eee : unknown option ${1}" 
    145          echo "${usage}" 
    146          # nb : no exit because this file should be launched by login process 
    147       ;; 
    148    esac 
    149    # next flag 
    150    shift 
    151 done 
    152 unset usage 
    153 # 
    154118set -u 
    155 # 
    156 # check for ${directory} 
    157 if [ ! -d ${directory} ] 
     119pb=0 
     120# 
     121minargcount=8 
     122maxargcount=8 
     123narg=${#} 
     124# 
     125if [ ${narg} -lt ${minargcount} ] 
    158126then 
    159    echo " eee : ${directory} not found" 
    160    # nb : no exit because this file should be launched by login process 
     127    echo "eee : not enought arguments (${narg} vs ${minargcount})" 
     128    echo "${usage}" 
     129    # nb : no exit because this file should be launched by login process 
     130    pb=1 
    161131fi 
    162 # 
    163 # check for permission on directory 
    164 if [ ! -x ${directory} ] 
     132unset minargcount 
     133# 
     134if [ ${narg} -gt ${maxargcount} ] 
    165135then 
    166    echo " eee : ${directory} not reachable" 
    167    # nb : no exit because this file should be launched by login process 
     136    echo "eee : too many arguments (${narg} vs ${maxargcount})" 
     137    echo "${usage}" 
     138    # nb : no exit because this file should be launched by login process 
     139    pb=1 
    168140fi 
    169 # 
    170 set -u 
    171 system=$(uname) 
    172 case "${system}" in 
    173    IRIX64) 
    174       echo " www : no specific posix checking" 
    175    ;; 
    176    *) 
    177       set -o posix 
    178    ;; 
    179 esac 
    180 unset system 
    181 # 
    182 GEOMAG=${directory} 
    183 export GEOMAG 
    184 unset directory 
    185 # 
    186 # add GEOMAG tools to PATH 
    187 # if not already done 
    188 suppath=$(echo ${GEOMAG} | tr -s "/") 
    189 echo ${PATH} | grep -q "${suppath}:" 
    190 test_path=${?} 
    191 if [ ${test_path} -ne 0 ] 
     141unset maxargcount 
     142unset narg 
     143# 
     144if [ ${pb} -eq 0 ] 
    192145then 
    193    PATH=${suppath}:${PATH} 
    194    export PATH 
    195 else 
    196    # option bavarde oui/non pas encore implantée ++ 
    197    echo "${command} : iii : ${suppath}/ already in \${PATH}" 
     146    # 
     147    while [ ${#} -gt 0 ] 
     148    do 
     149       case ${1} in 
     150          -d) 
     151             # directory for application choosen by user  
     152             # (see svn checkout command used) 
     153             directory=${2} 
     154             shift 
     155          ;; 
     156          -i) 
     157             # directory for inputs choosen by user 
     158             indir=${2} 
     159             shift 
     160          ;; 
     161          -o) 
     162             # directory for outputs choosen by user 
     163             outdir=${2} 
     164             shift 
     165          ;; 
     166          -t) 
     167             # directory for temporary outputs choosen by user 
     168             tempdir=${2} 
     169             shift 
     170          ;; 
     171          *) 
     172             # other choice 
     173             echo "eee : unknown option ${1}" 
     174             echo "${usage}" 
     175             # nb : no exit because this file should be launched by login process 
     176          ;; 
     177       esac 
     178       # next flag 
     179       shift 
     180    done 
     181    unset usage 
    198182fi 
    199 unset test_path 
    200 unset suppath 
    201 # 
    202 # add GEOMAG manuals to MANPATH 
    203 # if not already done 
    204 suppath=$(echo ${GEOMAG}/doc/manuals/man/ | tr -s "/") 
    205 echo ${MANPATH} | grep -q "${suppath}:" 
    206 test_manpath=${?} 
    207 if [ ${test_manpath} -ne 0 ] 
     183if [ ${pb} -eq 0 ] 
    208184then 
    209    MANPATH=${suppath}:${MANPATH} 
    210    export MANPATH 
    211 else 
    212    # option bavarde oui/non pas encore implantée ++ 
    213    echo "${command} : iii : ${suppath} already in \${MANPATH}" 
     185    # 
     186    # check for ${directory} 
     187    if [ ! -d ${directory} ] 
     188    then 
     189       echo " eee : ${directory} not found" 
     190       # nb : no exit because this file should be launched by login process 
     191    fi 
     192    # 
     193    # check for permission on directory 
     194    if [ ! -x ${directory} ] 
     195    then 
     196       echo " eee : ${directory} not reachable" 
     197       # nb : no exit because this file should be launched by login process 
     198    fi 
     199    # 
     200    system=$(uname) 
     201    case "${system}" in 
     202       IRIX64) 
     203          echo " www : no specific posix checking" 
     204       ;; 
     205       *) 
     206          set -o posix 
     207       ;; 
     208    esac 
     209    unset system 
     210    # 
     211    GEOMAG=${directory} 
     212    export GEOMAG 
     213    unset directory 
     214    # 
     215    # add GEOMAG tools to PATH 
     216    # if not already done 
     217    suppath=$(echo ${GEOMAG} | tr -s "/") 
     218    echo ${PATH} | grep -q "${suppath}:" 
     219    test_path=${?} 
     220    if [ ${test_path} -ne 0 ] 
     221    then 
     222       PATH=${suppath}:${PATH} 
     223       export PATH 
     224    else 
     225       # option bavarde oui/non pas encore implantée ++ 
     226       echo "${command} : iii : ${suppath}/ already in \${PATH}" 
     227    fi 
     228    unset test_path 
     229    unset suppath 
     230    # 
     231    # add GEOMAG manuals to MANPATH 
     232    # if not already done 
     233    suppath=$(echo ${GEOMAG}/doc/manuals/man/ | tr -s "/") 
     234    echo ${MANPATH} | grep -q "${suppath}:" 
     235    test_manpath=${?} 
     236    if [ ${test_manpath} -ne 0 ] 
     237    then 
     238       MANPATH=${suppath}:${MANPATH} 
     239       export MANPATH 
     240    else 
     241       # option bavarde oui/non pas encore implantée ++ 
     242       echo "${command} : iii : ${suppath} already in \${MANPATH}" 
     243    fi 
     244    unset test_manpath 
     245    unset suppath 
     246    # 
     247    GEOMAG_LOG=${tempdir} 
     248    export GEOMAG_LOG 
     249    unset tempdir 
     250    if [ ! -d ${GEOMAG_LOG} ] 
     251    then 
     252       mkdir -p ${GEOMAG_LOG} 
     253       status=${?} 
     254       if [ ${status} -ne 0 ] 
     255       then 
     256          echo "${command} : eee : can not create \${GEOMAG_LOG}" 
     257          # nb : no exit because this file should be launched by login process 
     258       else 
     259          echo "${command} : iii : creation of \${GEOMAG_LOG}" 
     260       fi 
     261       unset status 
     262    fi 
     263    # check for permission on GEOMAG_LOG 
     264    if [ ! -x ${GEOMAG_LOG} ] 
     265    then 
     266       echo " eee : ${GEOMAG_LOG} not reachable" 
     267       # nb : no exit because this file should be launched by login process 
     268    fi 
     269    # 
     270    # check for permission on GEOMAG_LOG 
     271    if [ ! -w ${GEOMAG_LOG} ] 
     272    then 
     273       echo " eee : ${GEOMAG_LOG} not writable" 
     274       # nb : no exit because this file shouldreachable be launched  
     275       # by login process 
     276    fi 
     277    # 
     278    EDITOR=vi 
     279    export EDITOR 
     280    # 
     281    # io directories 
     282    GEOMAG_ID=${indir} 
     283    export GEOMAG_ID 
     284    unset indir 
     285    if [ ! -d ${GEOMAG_ID} ] 
     286    then 
     287       mkdir -p ${GEOMAG_ID} 
     288       echo "${command} : iii : creation of \${GEOMAG_ID}" 
     289    fi 
     290    # check for permission on GEOMAG_ID 
     291    if [ ! -x ${GEOMAG_ID} ] 
     292    then 
     293       echo " eee : ${GEOMAG_ID} not reachable" 
     294       # nb : no exit because this file should be launched by login process 
     295    fi 
     296    # 
     297    GEOMAG_OD=${outdir} 
     298    export GEOMAG_OD 
     299    unset outdir 
     300    if [ ! -d ${GEOMAG_OD} ] 
     301    then 
     302       mkdir -p ${GEOMAG_OD} 
     303       echo "${command} : iii : creation of \${GEOMAG_OD}" 
     304    fi 
     305    # check for permission on GEOMAG_OD 
     306    if [ ! -x ${GEOMAG_OD} ] 
     307    then 
     308       echo " eee : ${GEOMAG_OD} not reachable" 
     309       # nb : no exit because this file should be launched by login process 
     310    fi 
     311    if [ ! -w ${GEOMAG_OD} ] 
     312    then 
     313       echo " eee : ${GEOMAG_OD} not writable" 
     314       # nb : no exit because this file should be launched by login process 
     315    fi 
     316    # 
    214317fi 
    215 unset test_manpath 
    216 unset suppath 
    217 # 
    218 GEOMAG_LOG=${tempdir} 
    219 export GEOMAG_LOG 
    220 unset tempdir 
    221 if [ ! -d ${GEOMAG_LOG} ] 
    222 then 
    223    mkdir -p ${GEOMAG_LOG} 
    224    status=${?} 
    225    if [ ${status} -ne 0 ] 
    226    then 
    227       echo "${command} : eee : can not create \${GEOMAG_LOG}" 
    228       # nb : no exit because this file should be launched by login process 
    229    else 
    230       echo "${command} : iii : creation of \${GEOMAG_LOG}" 
    231    fi 
    232    unset status 
    233 fi 
    234 # check for permission on GEOMAG_LOG 
    235 if [ ! -x ${GEOMAG_LOG} ] 
    236 then 
    237    echo " eee : ${GEOMAG_LOG} not reachable" 
    238    # nb : no exit because this file should be launched by login process 
    239 fi 
    240 # 
    241 # check for permission on GEOMAG_LOG 
    242 if [ ! -w ${GEOMAG_LOG} ] 
    243 then 
    244    echo " eee : ${GEOMAG_LOG} not writable" 
    245    # nb : no exit because this file shouldreachable be launched by login process 
    246 fi 
    247 # 
    248 EDITOR=vi 
    249 export EDITOR 
    250 # 
    251 # io directories 
    252 GEOMAG_ID=${indir} 
    253 export GEOMAG_ID 
    254 unset indir 
    255 if [ ! -d ${GEOMAG_ID} ] 
    256 then 
    257    mkdir -p ${GEOMAG_ID} 
    258    echo "${command} : iii : creation of \${GEOMAG_ID}" 
    259 fi 
    260 # check for permission on GEOMAG_ID 
    261 if [ ! -x ${GEOMAG_ID} ] 
    262 then 
    263    echo " eee : ${GEOMAG_ID} not reachable" 
    264    # nb : no exit because this file should be launched by login process 
    265 fi 
    266 # 
    267 GEOMAG_OD=${outdir} 
    268 export GEOMAG_OD 
    269 unset outdir 
    270 if [ ! -d ${GEOMAG_OD} ] 
    271 then 
    272    mkdir -p ${GEOMAG_OD} 
    273    echo "${command} : iii : creation of \${GEOMAG_OD}" 
    274 fi 
    275 # check for permission on GEOMAG_OD 
    276 if [ ! -x ${GEOMAG_OD} ] 
    277 then 
    278    echo " eee : ${GEOMAG_OD} not reachable" 
    279    # nb : no exit because this file should be launched by login process 
    280 fi 
    281 if [ ! -w ${GEOMAG_OD} ] 
    282 then 
    283    echo " eee : ${GEOMAG_OD} not writable" 
    284    # nb : no exit because this file should be launched by login process 
    285 fi 
    286 # 
     318unset pb 
    287319# end 
    288320unset command 
  • trunk/getmodelout.sh

    r47 r48  
    2727# ======== 
    2828# 
    29 # To get DRAKKAR G42 experiment output on grid T points beteween year 9 and 10: 
     29# To get DRAKKAR G42 experiment output on grid T points between year 9 and 10: 
    3030# 
    3131# .. code-block:: bash 
     
    5151usage=" Usage : ${command} -r orcares -exp drakkar_exp -g grid -o list" 
    5252# 
    53 set +u 
    54 while [ ! -z "${1}" ] 
     53set -u 
     54while [ ${#} -gt 0 ] 
    5555do 
    5656   case ${1} in 
     
    8989done 
    9090unset usage 
    91 # 
    92 set -u 
    9391# 
    9492# check GEOMAG environement 
  • trunk/grad.pro

    r41 r48  
    1111   res = litchamp(field) 
    1212   taille=size(res) 
    13    grille, mask, glam, gphi, gdep, nx, ny,nz,premierx,premiery,premierz,dernierx, derniery, dernierz      
     13   grille, mask, glam, gphi, gdep, nx, ny,nz,premierx,premiery,premierz,dernierx, derniery, dernierz 
    1414   if n_elements(valmask) EQ 0 then valmask = 1e20 
    1515   case strupcase(vargrid) of 
    1616      'T':BEGIN 
    1717         case direc of 
    18             'x':BEGIN  
     18            'x':BEGIN 
    1919               divi = e1u[premierx:dernierx, premiery:derniery] 
    2020               newmask = (umask())[premierx:dernierx, premiery:derniery, premierz:dernierz] 
     
    3535               vargrid = 'W' 
    3636            END 
    37             ELSE:return, report('Bad definition of direction argument') 
     37            ELSE : return, report('Bad definition of direction argument') 
    3838         ENDCASE 
    3939      END 
     
    4747               vargrid = 'T' 
    4848            END 
    49             ELSE:return, report('Bad definition of direction argument') 
     49            ELSE : return, report('Bad definition of direction argument') 
    5050         endcase 
    5151      END 
     
    7171               vargrid = 'W' 
    7272            END 
    73             ELSE:return, report('Bad definition of direction argument') 
     73            ELSE : return, report('Bad definition of direction argument') 
    7474         endcase 
    7575      END 
     
    9595               vargrid = 'W' 
    9696            END 
    97             ELSE:return, report('Bad definition of direction argument') 
     97            ELSE : return, report('Bad definition of direction argument') 
    9898         endcase 
    9999      END 
     
    103103;             'y':divi = (shift(e2u, 0, -1))[premierx:dernierx, premiery:derniery] 
    104104;             'z':divi = e3w[premierz:dernierz] 
    105 ;             ELSE:return, report('Bad definition of direction argument') 
     105;             ELSE : return, report('Bad definition of direction argument') 
    106106;          endcase 
    107107;       END 
    108       ELSE:return, report('Bad definition of vargrid') 
     108      ELSE : return, report('Bad definition of vargrid') 
    109109   ENDCASE 
    110110   res = fitintobox(res) 
     
    117117         if earth[0] NE -1 then res[earth] = !values.f_nan 
    118118         case direc of 
    119             'x':BEGIN  
     119            'x':BEGIN 
    120120               res = (shift(res, -1, 0)-res)/divi 
    121121               if key_periodique EQ 0 OR nx NE jpi THEN res[nx-1, *] = !values.f_nan 
    122122               if vargrid EQ 'T' OR vargrid EQ 'V' then res = shift(res, 1, 0) 
    123123            END 
    124             'y':BEGIN  
     124            'y':BEGIN 
    125125               res = (shift(res, 0, -1)-res)/divi 
    126126               res[*, ny-1] = !values.f_nan 
    127                if vargrid EQ 'T' OR vargrid EQ 'U' then res =   shift(res, 0, 1)            
    128             END 
    129             ELSE:return,  report('Bad definition of direction argument for the type of array') 
     127               if vargrid EQ 'T' OR vargrid EQ 'U' then res =   shift(res, 0, 1) 
     128            END 
     129            ELSE : return,  report('Bad definition of direction argument for the type of array') 
    130130         ENDCASE 
    131131         earth = where(newmask[*, *, premierz] EQ 0) 
     
    143143         divi = divi[*]#replicate(1, jpt) 
    144144         case direc of 
    145             'x':BEGIN  
     145            'x':BEGIN 
    146146               res = (shift(res, -1, 0, 0)-res)/divi 
    147147               if key_periodique EQ 0 OR nx NE jpi THEN res[nx-1, *, *] = !values.f_nan 
    148148               if vargrid EQ 'T' OR vargrid EQ 'V'  then res = shift(res, 1, 0, 0) 
    149149            END 
    150             'y':BEGIN  
     150            'y':BEGIN 
    151151               res = (shift(res, 0, -1, 0)-res)/divi 
    152152               res[*, ny-1, *] = !values.f_nan 
    153                if vargrid EQ 'T' OR vargrid EQ 'U'  then res = shift(res, 0, 1, 0)         
    154             END 
    155             ELSE:return,  report('Bad definition of direction argument for the type of array') 
     153               if vargrid EQ 'T' OR vargrid EQ 'U'  then res = shift(res, 0, 1, 0) 
     154            END 
     155            ELSE : return,  report('Bad definition of direction argument for the type of array') 
    156156         ENDCASE 
    157157         earth = where(newmask[*, *, premierz] EQ 0) 
    158          if earth[0] NE -1 then BEGIN  
     158         if earth[0] NE -1 then BEGIN 
    159159            earth = earth#replicate(1, jpt)+replicate(1, n_elements(earth))#(nx*ny*lindgen(jpt)) 
    160160            res[earth] = valmask 
     
    168168         if earth[0] NE -1 then res[earth] = !values.f_nan 
    169169         case direc OF 
    170             'x':BEGIN  
     170            'x':BEGIN 
    171171               divi = divi[*]#replicate(1, nz) 
    172172               res = (shift(res, -1, 0, 0)-res)/divi 
     
    174174               if vargrid EQ 'T' OR vargrid EQ 'V' then res = shift(res, 1, 0, 0) 
    175175            END 
    176             'y':BEGIN  
     176            'y':BEGIN 
    177177               divi = divi[*]#replicate(1, nz) 
    178178               res = (shift(res, 0, -1, 0)-res)/divi 
    179179               res[*, ny-1, *] = !values.f_nan 
    180                if vargrid EQ 'T' OR vargrid EQ 'U'  then res = shift(res, 0, 1, 0)         
     180               if vargrid EQ 'T' OR vargrid EQ 'U'  then res = shift(res, 0, 1, 0) 
    181181            END 
    182182            'z':BEGIN 
    183183               divi = reform(replicate(1, nx*ny)#divi, nx, ny, nz) 
    184184               if nx EQ 1 OR ny EQ 1 then res = reform(res, nx, ny, nz) 
    185                if vargrid EQ 'W' THEN BEGIN  
     185               if vargrid EQ 'W' THEN BEGIN 
    186186                  res = (shift(res, 0, 0, 1)-res)/divi 
    187187                  res[*, *, 0] = !values.f_nan 
     
    206206               divi = reform(divi[*]#replicate(1, jpt), nx, ny, nz, jpt, /over) 
    207207               if nx EQ 1 OR ny EQ 1 then res = reform(res, nx, ny, nz, jpt) 
    208                if vargrid EQ 'W' THEN BEGIN  
     208               if vargrid EQ 'W' THEN BEGIN 
    209209                  res = (shift(res, 0, 0, 1, 0)-res)/divi 
    210210                  res[*, *, 0, *] = !values.f_nan 
     
    227227   return, res 
    228228end 
    229  
    230  
    231  
    232  
    233  
    234  
  • trunk/init2.pro

    r2 r48  
    3737homedir = '/usr/work/sur/fvi/OPA/geomag/' 
    3838iodir = '/usr/work/sur/fvi/OPA/ORCA2/' 
    39 animdir =iodir  
     39animdir =iodir 
    4040psdir = '/usr/work/sur/fvi/IDL/IDL_PS/' 
    4141imagedir = iodir 
  • trunk/init_interp.pro

    r2 r48  
    11;------------------------------------------------------------ 
    22; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 
    3 ;                       26/5/98 
     3;                       26/5/98 
    44;------------------------------------------------------------ 
    55 
  • trunk/init_path.pro

    r2 r48  
    99output_dir = '/usr/work/sur/fvi/OPA/geomag/' 
    1010; 
    11 ; 2. Input information  
     11; 2. Input information 
    1212; ==================== 
    1313; 
     
    1515;  ------------------- 
    1616; 
    17 IF keyword_set(nscal) THEN BEGIN  
    18 data_u_file = 'OMIP_east_west_stress.nc' 
    19 data_v_file = 'OMIP_north_south_stress.nc' 
    20 ENDIF ELSE BEGIN  
    21    datafile = 'condmag.nc' 
    22 ENDELSE  
     17IF keyword_set(nscal) THEN BEGIN 
     18    data_u_file = 'OMIP_east_west_stress.nc' 
     19    data_v_file = 'OMIP_north_south_stress.nc' 
     20ENDIF ELSE BEGIN 
     21    datafile = 'condmag.nc' 
     22ENDELSE 
    2323; 
    2424;  2.2. Data mask file name 
     
    3232gridfile = 'meshmask_bab.nc' 
    3333; 
    34 ; 3. Output information   
     34; 3. Output information 
    3535; ===================== 
    3636; 
     
    3838;  --------------------- 
    3939; 
    40 IF keyword_set(nscal) THEN BEGIN  
    41   outputfile_x = 'OMIP_east_west_stress_ORCA_R2_grid_U.nc' 
    42   outputfile_y = 'OMIP_north_south_stress_ORCA_R2_grid_V.nc' 
    43 ENDIF ELSE BEGIN  
    44  outputfile = 'cond_sed_ORCA2.nc' 
    45    outputfile = 'Br_ORCA2.nc' 
    46 ENDELSE  
     40IF keyword_set(nscal) THEN BEGIN 
     41    outputfile_x = 'OMIP_east_west_stress_ORCA_R2_grid_U.nc' 
     42    outputfile_y = 'OMIP_north_south_stress_ORCA_R2_grid_V.nc' 
     43ENDIF ELSE BEGIN 
     44    ; outputfile = 'cond_sed_ORCA2.nc' 
     45    outputfile = 'Br_ORCA2.nc' 
     46ENDELSE 
    4747; 
    4848printf, 40, '' 
    49 IF keyword_set(nscal) THEN BEGIN  
    50 printf, 40, 'Data input file (x-component) : ', string(input_dir, '/', data_u_file) 
    51 printf, 40, 'Data input file (y-component) : ', string(input_dir, '/', data_v_file) 
    52 ENDIF ELSE BEGIN  
    53 printf, 40, 'Data input file  : ', string(input_dir, '/', datafile) 
    54 ENDELSE  
     49IF keyword_set(nscal) THEN BEGIN 
     50    printf, 40, 'Data input file (x-component) : ', string(input_dir, '/', data_u_file) 
     51    printf, 40, 'Data input file (y-component) : ', string(input_dir, '/', data_v_file) 
     52ENDIF ELSE BEGIN 
     53    printf, 40, 'Data input file  : ', string(input_dir, '/', datafile) 
     54ENDELSE 
    5555IF keyword_set(key_mask) THEN printf, 40, 'Mask input file  : ', string(input_dir, '/', maskfile) 
    56 IF keyword_set(nscal) THEN BEGIN  
    57 printf, 40, 'Output file (x-component) : ', string(output_dir, '/', outputfile_x) 
    58 printf, 40, 'Output file (y-component) : ', string(output_dir, '/', outputfile_y) 
    59 ENDIF ELSE BEGIN  
    60 printf, 40, 'Output file      : ', string(output_dir, '/', outputfile) 
    61 ENDELSE  
     56IF keyword_set(nscal) THEN BEGIN 
     57    printf, 40, 'Output file (x-component) : ', string(output_dir, '/', outputfile_x) 
     58    printf, 40, 'Output file (y-component) : ', string(output_dir, '/', outputfile_y) 
     59ENDIF ELSE BEGIN 
     60    printf, 40, 'Output file      : ', string(output_dir, '/', outputfile) 
     61ENDELSE 
    6262printf, 40, 'Target grid file : ', string(input_dir, '/', gridfile) 
    63  
  • trunk/initocemeshmask.pro

    r41 r48  
    8282   'ORCA2': BEGIN 
    8383               msg = 'iii : valid orcares parameter = ' + orcares 
    84                ras = report(msg) 
     84               ras = report(msg) 
    8585               filename_oce = 'meshmask_bab.nc' 
    8686               IF keyword_set(DRAKKAR_EXP) THEN BEGIN 
     
    121121                 ENDELSE 
    122122              END 
    123     ELSE  : BEGIN 
     123    ELSE : BEGIN 
    124124               msg = 'eee : invalid orcares parameter = ' + orcares 
    125                ras = report(msg) 
     125               ras = report(msg) 
    126126               msg = 'eee : orcares must be ORCA2 or ORCA025' 
    127                ras = report(msg) 
     127               ras = report(msg) 
    128128               RETURN 
    129             END 
     129    END 
    130130  ENDCASE 
    131131; 
     
    140140              RETURN 
    141141            END 
    142      ELSE: BEGIN 
     142     ELSE : BEGIN 
    143143             msg = 'iii : ${GEOMAG_ID} is ' + geomag_id_env 
    144144             ras = report(msg) 
    145            END 
     145     END 
    146146  ENDCASE 
    147147iodirin = isadirectory(geomag_id_env) 
     
    197197; 
    198198              END 
    199       ELSE  : BEGIN 
     199      ELSE : BEGIN 
    200200                 msg = 'eee : invalid orcares parameter = ' + orcares 
    201201                 ras = report(msg) 
     
    203203                 ras = report(msg) 
    204204                 RETURN 
    205               END 
     205      END 
    206206  ENDCASE 
    207207jpt = 1 
  • trunk/initorca.pro

    r2 r48  
    11;------------------------------------------------------------ 
    22; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 
    3 ;                       26/5/98 
     3;                       26/5/98 
    44; pris le 25 janvier 99 par Maurice Imbard 
    55;------------------------------------------------------------ 
  • trunk/interp.pro

    r41 r48  
    22; NAME: interp.pro 
    33; 
    4 ; PURPOSE: Performs a bilinear or bicubic interpolation on  
     4; PURPOSE: Performs a bilinear or bicubic interpolation on 
    55;          data from a regular origin grid to any grid 
    66 
     
    99; CALLING SEQUENCE: interp, znumdta, zdata_name, mask, t, glam, gphi, zresul 
    1010; 
    11 ; INPUTS:  
     11; INPUTS: 
    1212; 
    1313;          znumdta    : ID of input data file 
    1414;          zdata_name : input data name 
    1515;          mask       : data mask 
    16 ;          t          : timestep  
     16;          t          : timestep 
    1717;          glam       : longitude of target grid 
    18 ;          gphi       : latitude  "     "    "    
     18;          gphi       : latitude  "     "    " 
    1919; 
    2020; KEYWORD PARAMETERS: None 
    2121; 
    22 ; OUTPUTS:  
     22; OUTPUTS: 
    2323;          zresul : interpolated field 
    2424; 
    2525; COMMON BLOCKS: 
    26 ;       common_interp.pro 
    27 ; 
    28 ; SIDE EFFECTS:  
     26;        common_interp.pro 
     27; 
     28; SIDE EFFECTS: 
    2929; 
    3030; RESTRICTIONS: 
     
    4242;                       grid on meridian axis 
    4343; 
    44 ; 
    4544;- 
    4645;------------------------------------------------------------ 
     
    5554;------------------------------------------------- 
    5655; 
    57 ; 
    5856; 0. Extracting data at timestep t 
    5957; ================================ 
     
    6260zzresul2 = fltarr(jpioce, jpjoce, jpkoce) 
    6361 
    64 FOR jk = 0, jpkatm-1 DO BEGIN  
    65  
    66   
     62FOR jk = 0, jpkatm-1 DO BEGIN 
     63 
     64 
    6765   IF keyword_set(ndim) THEN $ 
    6866     ncdf_varget, znumdta, zdata_name, zdata, count = [jpiatm, jpjatm, 1, 1], offset = [0, 0, jk, t] ELSE BEGIN 
     
    7068       ncdf_varget, znumdta, zdata_name, zdata, count = [jpiatm, jpjatm, 1], offset = [0, 0, t] ELSE $ 
    7169       ncdf_varget, znumdta, zdata_name, zdata, count = [jpiatm, jpjatm,1, 1], offset = [0, 0, 0, t] 
    72    ENDELSE  
    73     
     70   ENDELSE 
     71 
    7472   zmask = fltarr(jpiatm, jpjatm) 
    7573   zmask = mask(*, *, jk) 
    7674   printf, 40, '' 
    7775   printf, 40, 'Data reading OK' 
    78    IF keyword_set(key_vari) THEN BEGIN  
     76   IF keyword_set(key_vari) THEN BEGIN 
    7977      varid = ncdf_varid(znumdta, zdata_name) 
    8078      ncdf_attget, znumdta, varid, "scale_factor", scale_factor 
    8179      ncdf_attget, znumdta, varid, "add_offset", add_offset 
    82        
     80 
    8381      printf, 40, '' 
    8482      printf, 40, 'Scale factor and add_offset reading OK' 
    85    ENDIF  
    86 ; Scale Factor + Add_offset     
     83   ENDIF 
     84; Scale Factor + Add_offset 
    8785; Modif Fred 
    88 ;   zdata=ncdf_lec('/usr/work/sur/fvi/OPA/geomag/condmag.nc',var='cond_sed') 
     86; zdata=ncdf_lec('/usr/work/sur/fvi/OPA/geomag/condmag.nc',var='cond_sed') 
    8987   zdata=ncdf_lec('/usr/work/sur/fvi/OPA/geomag/condmag.nc',var='Br') 
    9088 
     
    9997 
    10098;   zdata = double(zdata) 
    101    IF keyword_set(nreverse) THEN BEGIN  
     99   IF keyword_set(nreverse) THEN BEGIN 
    102100      zdata = reverse(zdata, 2) 
    103101      printf, 40, 'Re-arranging data in latitudes : North-South --> South-North' 
     
    109107; ============================================= 
    110108; 
    111      
    112      
    113  
    114     IF  keyword_set(nscal) AND keyword_set(north_pole) THEN BEGIN 
    115  
    116        IF  zdata_name EQ data_u_name then BEGIN 
    117            
     109 
     110 
     111 
     112    IF keyword_set(nscal) AND keyword_set(north_pole) THEN BEGIN 
     113 
     114       IF zdata_name EQ data_u_name then BEGIN 
     115 
    118116 
    119117          zdata_u=zdata 
     
    126124       ENDIF 
    127125 
    128        IF  zdata_name EQ data_v_name then BEGIN 
    129            
     126       IF zdata_name EQ data_v_name then BEGIN 
     127 
    130128 
    131129          zdata_v=zdata 
     
    139137 
    140138          ; Check is made here 
    141           
     139 
    142140          global_vect=replicate(0.,jpiatm,jpjatm,2) 
    143            
     141 
    144142          global_vect(*,*,0)=zdata_u 
    145           global_vect(*,*,1)=zdata_v        
    146            
     143          global_vect(*,*,1)=zdata_v 
     144 
    147145          northwind, global_vect,zdata_name,t 
    148           
     146 
    149147          zdata_u=global_vect(*,*,0) 
    150148          zdata_v=global_vect(*,*,1) 
     
    155153 
    156154 
    157        IF  zdata_name EQ data_u_name then BEGIN 
    158            
     155       IF zdata_name EQ data_u_name then BEGIN 
     156 
    159157         zdata=zdata_u 
    160158 
    161159       ENDIF 
    162160 
    163        IF  zdata_name EQ data_v_name then BEGIN 
    164             
     161       IF zdata_name EQ data_v_name then BEGIN 
     162 
    165163         zdata=zdata_v 
    166164 
     
    168166 
    169167    ENDIF 
    170            
    171 ; 
    172 ; 
    173 ; 1. Applying mask on data and plotting  
     168 
     169; 
     170; 1. Applying mask on data and plotting 
    174171; ===================================== 
    175172; 
    176173   val = 1.e20 
    177    IF keyword_set(nmiss) THEN BEGIN  
    178        
     174   IF keyword_set(nmiss) THEN BEGIN 
     175 
    179176       ind = where(abs(zdata) GE abs(missing_val)) 
    180177       IF ind[0] NE -1 then zmask(ind) = 0. 
    181       
    182    ENDIF  
     178 
     179   ENDIF 
    183180 
    184181   ind = where(zmask EQ 0.) 
    185     
    186    IF ind[0] NE -1 then  zdata(ind) = val 
     182 
     183   IF ind[0] NE -1 then zdata(ind) = val 
    187184 
    188185   ind = where(zmask NE 0.) 
    189    IF ind[0] NE -1 THEN min = min(zdata(ind)) ELSE BEGIN  
     186   IF ind[0] NE -1 THEN min = min(zdata(ind)) ELSE BEGIN 
    190187      min = missing_val 
    191    ENDELSE  
    192    IF ind[0] NE -1 THEN max = max(zdata(ind)) ELSE BEGIN  
     188   ENDELSE 
     189   IF ind[0] NE -1 THEN max = max(zdata(ind)) ELSE BEGIN 
    193190      max = missing_val 
    194191      zdata(*, *) = missing_val 
    195    ENDELSE  
     192   ENDELSE 
    196193   IF t MOD ndraw EQ 0 AND keyword_set(keydraw) AND jk MOD nlevel EQ 0 THEN BEGIN 
    197194      IF keyword_set(key_ps) THEN openps, string(zdata_name, '_controle_iteration_', strtrim(t+1, 2), '.ps') 
    198195      draw, zdata, lonatm, latatm, jpiatm, jpjatm, 1, 1, 3, $ 
    199196       TITLE = zdata_name+', iteration = '+strtrim(t+1,1), min, max 
    200    ENDIF  
     197   ENDIF 
    201198; 
    202199; 2. Extrapolating coastal values on land points 
     
    207204   tempsun2 = systime(1)        ; pour key_performance 
    208205; 
    209 ; ... adding a border to overcome shifting problems  
     206; ... adding a border to overcome shifting problems 
    210207; 
    211208   zero = fltarr(jpiatm+2, jpjatm+2) 
     
    218215 
    219216; 
    220 ; ... filling  
    221 ; 
    222  
    223    if max(zmask) GT 0  then begin 
    224  
    225      WHILE n LE nfil AND eps LE 1.e-5 DO BEGIN  
     217; ... filling 
     218; 
     219 
     220   if max(zmask) GT 0 then begin 
     221 
     222     WHILE n LE nfil AND eps LE 1.e-5 DO BEGIN 
    226223 
    227224        extrap, zdata, zmask, n, val 
     
    237234   zmask = zmask[1:jpiatm, 1:jpjatm] 
    238235; 
    239    if keyword_set(key_performance) THEN print, 'temps extrap', systime(1)-tempsun2  
     236   if keyword_set(key_performance) THEN print, 'temps extrap', systime(1)-tempsun2 
    240237;  .. drawing 
    241    IF t MOD ndraw EQ 0 AND keyword_set(keydraw) AND jk MOD nlevel EQ 0 THEN BEGIN  
     238   IF t MOD ndraw EQ 0 AND keyword_set(keydraw) AND jk MOD nlevel EQ 0 THEN BEGIN 
    242239      draw, zdata, lonatm, latatm, jpiatm, jpjatm, 1, 2, 3, $ 
    243240       TITLE = 'extrapolated '+zdata_name+', iteration = '+strtrim(t+1,1), min, max 
    244    ENDIF  
    245     
     241   ENDIF 
     242 
    246243   ind = where(zmask NE 0. AND zdata GE val) 
    247    IF n_elements(ind) GT 1 THEN BEGIN  
     244   IF n_elements(ind) GT 1 THEN BEGIN 
    248245      print, 'We stop because of insufficient extrapolation on missing values' 
    249246      print, n_elements(ind), ' points non extrapolated' 
    250247      print, 'Increase nfill in naminterp.pro' 
    251248      stop 
    252    ENDIF   
     249   ENDIF 
    253250 
    254251 
    255252; 3. Treatment of Boundary Conditions 
    256253; ======================================================== 
    257 ; Treatment of boundary conditions require extra stripes     
     254; Treatment of boundary conditions require extra stripes 
    258255; Size of extra stripe is calculated after a given extension 
    259256; along x and y axis on the OUTPUT grid. iplus and jplus will be 
     
    266263 
    267264; Initialisation of array for the northern boundary condition 
    268     
     265 
    269266   zdata_north=replicate(0.,jpiatm,jpjatm+jplus) 
    270267   zdata_north(*,0:jpjatm-1)=zdata 
    271     
     268 
    272269; Data of the input grid is duplicated for the northern boundary condition 
    273270 
    274    zdata_inv=shift(zdata_north(*,jpjatm-1-jplus+1:jpjatm-1),jpiatm/2,0)    
    275     
     271   zdata_inv=shift(zdata_north(*,jpjatm-1-jplus+1:jpjatm-1),jpiatm/2,0) 
     272 
    276273   zdata_inv=reverse(zdata_inv,2) 
    277274 
     
    281278 
    282279   zdata=zdata_north 
    283     
     280 
    284281; East/West Boundary Condition, zdata_extend will be the array that 
    285282; contains both northern boundary condition and E/W boundary 
     
    288285 
    289286   zdata_extend=replicate(0.,jpiatm+2*iplus,jpjatm+jplus) 
    290     
     287 
    291288   zdata_extend(iplus:jpiatm-1+iplus,*)=zdata 
    292     
     289 
    293290   zdata_extend(0:iplus-1,*)=zdata(jpiatm-1-iplus+1:jpiatm-1,*) 
    294291 
    295292   zdata_extend(jpiatm+iplus:jpiatm+2*iplus-1,*)=zdata(0:iplus-1,*) 
    296     
     293 
    297294; 
    298295; 3.1 Interpolating data on output grid and plotting result 
     
    304301; grid 
    305302 
    306    print, 'Time Step=',t  
     303   print, 'Time Step=',t 
    307304   print, 'Input Level=',jk 
    308305 
     
    311308    gphi2 = replicate(0.,jpioce,jpjoce) 
    312309 
    313    
     310 
    314311 
    315312    for ji = 0, jpioce - 1 do begin 
    316        for  jj = 0, jpjoce - 1 do begin 
    317             
    318  
    319  
    320            diff = - gphi(ji,jj)  $           
    321                   + phi_field   
    322          
    323            diff = where( diff GE 0. )  
    324           
    325              
    326            j_above=min( diff )  
    327                           
     313       for jj = 0, jpjoce - 1 do begin 
     314 
     315           diff = - gphi(ji,jj)  $ 
     316                  + phi_field 
     317 
     318           diff = where( diff GE 0. ) 
     319 
     320 
     321           j_above=min( diff ) 
     322 
    328323           if diff(0) eq -1 then begin 
    329324             ;   print, 'Output grid goes above input grid latitude top value !!!' 
     
    334329               gphi2(ji,jj) = j_fine 
    335330           endif else begin 
    336            
    337              j_bellow = j_above -1  
     331 
     332             j_bellow = j_above -1 
    338333 
    339334              if j_bellow GE 0 then begin 
     
    345340               endif 
    346341 
    347                gphi2(ji,jj) = j_fine  
     342               gphi2(ji,jj) = j_fine 
    348343               if j_fine GT j_above then stop 
    349        
     344 
    350345              endif else begin 
    351346 
     
    353348 
    354349               gphi2(ji,jj) = j_fine 
    355                  
     350 
    356351              endelse 
    357                 
    358          
    359            endelse  
    360             
     352 
     353 
     354           endelse 
     355 
    361356    endfor 
    362357   endfor 
    363358 
    364     
    365    IF keyword_set(ninterp) THEN BEGIN  
     359 
     360   IF keyword_set(ninterp) THEN BEGIN 
    366361 
    367362      zresul = interpolate(zdata_extend, glam2, gphi2, cubic = -.5) 
    368363 
    369    ENDIF ELSE BEGIN  
    370    
     364   ENDIF ELSE BEGIN 
     365 
    371366      zresul = bilinear(zdata_extend , glam2, gphi2) 
    372        
     367 
    373368   ENDELSE 
    374               
    375    IF t MOD ndraw EQ 0 AND keyword_set(keydraw) AND jk MOD nlevel EQ 0 THEN BEGIN  
     369 
     370   IF t MOD ndraw EQ 0 AND keyword_set(keydraw) AND jk MOD nlevel EQ 0 THEN BEGIN 
    376371      draw, zresul, glam, gphi, jpioce, jpjoce, 1, 3, 3, $ 
    377372       TITLE = 'interpolated '+zdata_name+', iteration = '+strtrim(t+1,1), min, max 
    378       IF keyword_set(key_ps) THEN BEGIN  
     373      IF keyword_set(key_ps) THEN BEGIN 
    379374         closeps 
    380       ENDIF ELSE BEGIN  
     375      ENDIF ELSE BEGIN 
    381376         print, 'Press return to continue' 
    382377         zxc = strarr(1) 
    383378         read, zxc 
    384       ENDELSE  
    385    ENDIF  
     379      ENDELSE 
     380   ENDIF 
    386381   zzresul(*, *, jk) = temporary(zresul) 
    387 ENDFOR  
     382ENDFOR 
    388383zresul = zzresul 
    389384 
    390385; 
    391 ; 4. Interpolating data on the vertical axis if the outdept not equal datadept  
     386; 4. Interpolating data on the vertical axis if the outdept not equal datadept 
    392387; =========================================================================== 
    393388 
    394389 
    395 IF keyword_set(ndim) THEN BEGIN  
     390IF keyword_set(ndim) THEN BEGIN 
    396391 
    397392    nlev_flag = WHERE ( datadept(0:jpkatm-1) ne outdept(0:jpkoce-1) ) 
    398393    IF nlev_flag(0) NE -1 THEN BEGIN 
    399         FOR jk = 0, jpkoce-1 DO BEGIN  
    400              
     394        FOR jk = 0, jpkoce-1 DO BEGIN 
     395 
    401396            jn = where(abs(datadept) GE abs(outdept(jk)) $ 
    402397                       AND abs(shift(datadept, 1)) LT abs(outdept(jk))) 
    403      
    404      
    405             IF min(jn) GE 0 THEN BEGIN  
     398 
     399 
     400            IF min(jn) GE 0 THEN BEGIN 
    406401 
    407402                ikt=jn-1 
     
    409404 
    410405                IF jn NE 0 then begin 
    411                  
     406 
    412407                  zt1=abs(outdept(jk))-abs(datadept(ikt)) 
    413408                  zt2=abs(datadept(ikb))-abs(outdept(jk)) 
     
    418413 
    419414                ENDIF ELSE BEGIN 
    420                    
     415 
    421416                  zzresul2(*, *, jk) = zzresul(*, *, ikb) 
    422                    
    423                 ENDELSE   
    424  
    425             ENDIF ELSE BEGIN  
     417 
     418                ENDELSE 
     419 
     420            ENDIF ELSE BEGIN 
    426421 
    427422                zzresul2(*, *, jk) = temporary(zzresul2(*, *, jk-1)) 
    428423 
    429             ENDELSE   
    430         ENDFOR    
     424            ENDELSE 
     425        ENDFOR 
    431426        zresul = zzresul2 
    432427    ENDIF ELSE BEGIN 
     
    435430        print, ' ' 
    436431    ENDELSE 
    437 ENDIF  
    438  
    439  
    440    if keyword_set(key_performance) THEN print, 'temps interp', systime(1)-tempsun  
     432ENDIF 
     433 
     434 
     435   if keyword_set(key_performance) THEN print, 'temps interp', systime(1)-tempsun 
    441436 
    442437return 
    443 END   
     438END 
  • trunk/interpolation.pro

    r41 r48  
    99; CALLING SEQUENCE: interpolation 
    1010; 
    11 ; INPUTS: Complete the INIT_PATH and NAMINTERP files      
     11; INPUTS: Complete the INIT_PATH and NAMINTERP files 
    1212; 
    1313; KEYWORD PARAMETERS: None 
     
    1616; 
    1717; COMMON BLOCKS: 
    18 ;       common_interp.pro 
    19 ; 
    20 ; SIDE EFFECTS:  
     18;          common_interp.pro 
     19; 
     20; SIDE EFFECTS: 
    2121; 
    2222; RESTRICTIONS: 
     
    7070 
    7171; 
    72 ;---------------------------------------------------  
     72;--------------------------------------------------- 
    7373; READING INPUT MASK & OUTPUT COORDINATES          * 
    7474;--------------------------------------------------- 
     
    8787   lonatm(i) = west_lon + i*dx 
    8888ENDFOR 
    89 FOR j = 0, jpjatm-1 DO BEGIN  
     89FOR j = 0, jpjatm-1 DO BEGIN 
    9090   latatm(j) = phi_input(j) 
    91 ENDFOR  
     91ENDFOR 
    9292; 
    9393;--------------------------------------------------- 
     
    9999printf, 40, '===========================' 
    100100; 
    101 IF keyword_set(negmask) THEN BEGIN  
     101IF keyword_set(negmask) THEN BEGIN 
    102102   mask = abs(temporary(mask)) 
    103103   printf, 40, 'Taking the abs of mask (-1 --> +1)' 
    104 ENDIF  
    105 IF keyword_set(nreverse) THEN BEGIN  
     104ENDIF 
     105IF keyword_set(nreverse) THEN BEGIN 
    106106   mask = reverse(mask, 2) 
    107107   printf, 40, 'Re-arranging mask in latitudes : North-South --> South-North' 
    108 ENDIF  
     108ENDIF 
    109109ind = where(mask NE 0 AND mask NE 1) 
    110 IF n_elements(ind) NE 1 THEN BEGIN  
     110IF n_elements(ind) NE 1 THEN BEGIN 
    111111   printf, 40, '' 
    112112   printf, 40, '************************************************************' 
     
    115115   printf, 40, '' 
    116116   printf, 40, 'program stops' 
    117    stop  
    118 ENDIF  
    119 IF keyword_set(invmask) THEN BEGIN  
     117   stop 
     118ENDIF 
     119IF keyword_set(invmask) THEN BEGIN 
    120120   mask = inv_mask(mask) 
    121121   printf, 40, 'Giving value = 1 to mask on ocean points ' 
     
    141141; ============================================== 
    142142; 
    143 IF keyword_set(nscal) THEN BEGIN  
     143IF keyword_set(nscal) THEN BEGIN 
    144144   printf, 40, '' 
    145145   printf, 40, ' V-1- Writing attributes of interpolated field to files' 
     
    149149   printf, 40, '' 
    150150   printf, 40, 'Writing attributes of x-component of interpolated field' 
    151    ncdf_varget, nummsh, mask_u_name, umask, count = [jpioce, jpjoce, jpkoce, 1]  
     151   ncdf_varget, nummsh, mask_u_name, umask, count = [jpioce, jpjoce, jpkoce, 1] 
    152152   netcdf_output, mask_u_name, umask, data_u_name, lon_u, lat_u, outputfile_x, $ 
    153153    title_x, long_x_name, POINT = "u", $ 
     
    156156   printf, 40, '' 
    157157   printf, 40, 'Writing attributes of y-component of interpolated field' 
    158    ncdf_varget, nummsh, mask_v_name, vmask, count = [jpioce, jpjoce, jpkoce, 1]  
     158   ncdf_varget, nummsh, mask_v_name, vmask, count = [jpioce, jpjoce, jpkoce, 1] 
    159159   netcdf_output, mask_v_name, vmask, data_v_name, lon_v, lat_v, outputfile_y, $ 
    160160    title_y, long_y_name, POINT = "v", $ 
    161     numout_v, varid_v, numdta_v  
    162 ENDIF ELSE BEGIN  
     161    numout_v, varid_v, numdta_v 
     162ENDIF ELSE BEGIN 
    163163   printf, 40, '' 
    164164   printf, 40, ' V-1- Writing attributes of interpolated field to file' 
    165165   printf, 40, ' -----------------------------------------------------' 
    166166; 
    167    ncdf_varget, nummsh, mask_t_name, tmask, count = [jpioce, jpjoce, jpkoce, 1]  
     167   ncdf_varget, nummsh, mask_t_name, tmask, count = [jpioce, jpjoce, jpkoce, 1] 
    168168   netcdf_output, mask_t_name, tmask, data_name, lon_t, lat_t, outputfile, $ 
    169169    title, long_name, POINT = "t", $ 
    170170    numout, varid, numdta 
    171 ENDELSE  
    172  
    173  
    174 ; 
    175 ; 1. Interpolation  
     171ENDELSE 
     172 
     173 
     174; 
     175; 1. Interpolation 
    176176; ================ 
    177177; 
     
    184184;  BEGINNING OF TIME LOOP 
    185185; 
    186 IF keyword_set(nscal) THEN BEGIN  
     186IF keyword_set(nscal) THEN BEGIN 
    187187   mi_u = 1.e20 
    188188   ma_u = -1.e20 
    189189   mi_v = 1.e20 
    190190   ma_v = -1.e20 
    191 ENDIF ELSE BEGIN  
     191ENDIF ELSE BEGIN 
    192192   mi = 1.e20 
    193193   ma = -1.e20 
     
    195195 
    196196 
    197 FOR t = nit000-1, nitend-1 DO BEGIN  
     197FOR t = nit000-1, nitend-1 DO BEGIN 
    198198   tempsun4 = systime(1)        ; pour key_performance 
    199199   printf, 40, '' 
     
    204204      IF keyword_set(nscal) THEN BEGIN 
    205205         printf, 40, 'A vectorial field has been chosen for interpolation' 
    206          IF keyword_set(north_pole) THEN BEGIN  
     206         IF keyword_set(north_pole) THEN BEGIN 
    207207         printf, 40, 'Vectorial Fied will be Tested for Coherence nearby North Pole' 
    208208         ENDIF 
     
    218218         printf, 40, 'interpolating ', data_name, ' at t-point' 
    219219         interp, numdta, data_name, 1,mask, t, lon_t, lat_t, phi_input, zresul 
    220       ENDELSE  
     220      ENDELSE 
    221221   ENDELSE 
    222222 
     
    224224 
    225225; 
    226 ; 2. Angles correction for 2D fields                   
     226; 2. Angles correction for 2D fields 
    227227; ================================== 
    228 ;  
    229    IF keyword_set(nscal) THEN BEGIN  
     228; 
     229   IF keyword_set(nscal) THEN BEGIN 
    230230      printf, 40, '' 
    231231      printf, 40, ' angles correction' 
     
    233233      tempsun2 = systime(1)      ; pour key_performance 
    234234      correc_angle, zresul_uu, zresul_uv, zresul_vv, zresul_vu, zresul_u, zresul_v 
    235       if keyword_set(key_performance) THEN print, 'temps angles', systime(1)-tempsun2  
     235      if keyword_set(key_performance) THEN print, 'temps angles', systime(1)-tempsun2 
    236236      IF t MOD ndraw EQ 0 AND keyword_set(keydraw) THEN BEGIN 
    237237         ncdf_varget, numdta_u, data_u_name, zdata_u, $ 
     
    245245         zu = zdata_u 
    246246         zv = zdata_v 
    247          IF keyword_set(nmiss) THEN BEGIN  
     247         IF keyword_set(nmiss) THEN BEGIN 
    248248            ind = where(abs(zu) GE missing_val) 
    249249            zu(ind) = 0. 
    250250            ind = where(abs(zv) GE missing_val) 
    251251            zv(ind) = 0. 
    252          ENDIF  
     252         ENDIF 
    253253         ind = where(mask NE 0.) 
    254254         minu = min(zu(ind)) 
     
    266266         draw, zresul_v, lon_f, lat_f, jpioce, jpjoce, 2, 4, 2, $ 
    267267          TITLE = data_v_name+' interpolated, iteration = '+strtrim(t+1,1), minv, maxv, /land 
    268          IF keyword_set(key_ps) THEN BEGIN  
     268         IF keyword_set(key_ps) THEN BEGIN 
    269269            closeps 
    270          ENDIF ELSE BEGIN  
     270         ENDIF ELSE BEGIN 
    271271            print, 'Press return to continue' 
    272272            zxc = strarr(1) 
    273273            read, zxc 
    274          ENDELSE  
     274         ENDELSE 
    275275      ENDIF 
    276    ENDIF  
    277    
    278 ; 
    279 ; 3. NetCDF output to file of interpolated field  
     276   ENDIF 
     277 
     278; 
     279; 3. NetCDF output to file of interpolated field 
    280280; ============================================== 
    281281; 
    282282    tempsun3 = systime(1) ; pour key_performance 
    283   IF keyword_set(nscal) THEN BEGIN  
     283  IF keyword_set(nscal) THEN BEGIN 
    284284      printf, 40, '' 
    285285      printf, 40, 'Storing components of interpolated field' 
    286        
     286 
    287287 
    288288      ncdf_varput, numout_u, varid_u, zresul_u, offset = [0, 0, 0, t-nit000+1] 
    289289      ind = where(abs(zresul_u) LT 1.e10) 
    290       IF ind[0] NE -1 THEN BEGIN  
     290      IF ind[0] NE -1 THEN BEGIN 
    291291         IF min(zresul_u) LT mi_u THEN mi_u = min(zresul_u[ind]) 
    292292         IF max(zresul_u) GT ma_u THEN ma_u = max(zresul_u[ind]) 
    293       ENDIF ELSE BEGIN  
     293      ENDIF ELSE BEGIN 
    294294         mi_u = missing_val 
    295295         ma_u = missing_val 
    296296      ENDELSE 
    297         
     297 
    298298      ncdf_varput, numout_v, varid_v, zresul_v, offset = [0, 0, 0, t-nit000+1] 
    299299      ind = where(abs(zresul_v) LT 1.e10) 
    300       IF ind[0] NE -1 THEN BEGIN  
     300      IF ind[0] NE -1 THEN BEGIN 
    301301         IF min(zresul_v) LT mi_v THEN mi_v = min(zresul_v[ind]) 
    302302         IF max(zresul_v) GT ma_v THEN ma_v = max(zresul_v[ind]) 
    303       ENDIF ELSE BEGIN  
     303      ENDIF ELSE BEGIN 
    304304         mi_v = missing_val 
    305305         ma_v = missing_val 
    306       ENDELSE  
    307    ENDIF ELSE BEGIN  
     306      ENDELSE 
     307   ENDIF ELSE BEGIN 
    308308      printf, 40, '' 
    309309      printf, 40, 'Storing field' 
    310        
     310 
    311311      ncdf_varput, numout, varid, zresul, offset = [0, 0, 0, t-nit000+1] 
    312312      ind = where(abs(zresul) LT 1.e10) 
    313313      IF min(zresul) LT mi THEN mi = min(zresul[ind]) 
    314314      IF max(zresul) GT ma THEN ma = max(zresul[ind]) 
    315    ENDELSE  
    316       if keyword_set(key_performance) THEN print, 'temps ecriture variable', systime(1)-tempsun3  
    317       if keyword_set(key_performance) THEN printf, 40, 'temps ecriture variable', systime(1)-tempsun3  
    318       if keyword_set(key_performance) THEN print, 'temps boucle', systime(1)-tempsun4  
    319       if keyword_set(key_performance) THEN printf, 40, 'temps boucle', systime(1)-tempsun4  
     315   ENDELSE 
     316      if keyword_set(key_performance) THEN print, 'temps ecriture variable', systime(1)-tempsun3 
     317      if keyword_set(key_performance) THEN printf, 40, 'temps ecriture variable', systime(1)-tempsun3 
     318      if keyword_set(key_performance) THEN print, 'temps boucle', systime(1)-tempsun4 
     319      if keyword_set(key_performance) THEN printf, 40, 'temps boucle', systime(1)-tempsun4 
    320320ENDFOR 
    321321; 
     
    330330; storing min and max in attributes 
    331331; 
    332 IF keyword_set(nscal) THEN BEGIN  
     332IF keyword_set(nscal) THEN BEGIN 
    333333   ncdf_control, numout_u, /redef 
    334334   ncdf_control, numout_v, /redef 
     
    337337   ncdf_attput, numout_v, varid_v, "valid_min", mi_v 
    338338   ncdf_attput, numout_v, varid_v, "valid_max", ma_v 
    339 ENDIF ELSE BEGIN  
     339ENDIF ELSE BEGIN 
    340340   ncdf_control, numout, /redef 
    341341   ncdf_attput, numout, varid, "valid_min", mi 
    342342   ncdf_attput, numout, varid, "valid_max", ma 
    343 ENDELSE  
     343ENDELSE 
    344344IF keyword_set(key_mask) THEN ncdf_close, nummsk 
    345 IF keyword_set(nscal) THEN BEGIN  
     345IF keyword_set(nscal) THEN BEGIN 
    346346   ncdf_close, numdta_u 
    347347   ncdf_close, numdta_v 
    348348   ncdf_close, numout_u 
    349349   ncdf_close, numout_v 
    350 ENDIF ELSE BEGIN  
     350ENDIF ELSE BEGIN 
    351351   ncdf_close, numout 
    352352   ncdf_close, numdta 
    353 ENDELSE  
     353ENDELSE 
    354354ncdf_close, nummsh 
    355355; 
     
    360360; 
    361361close, 40 
    362    if keyword_set(key_performance) THEN print, 'temps total', systime(1)-tempsun  
    363    if keyword_set(key_performance) THEN printf,40, 'temps total', systime(1)-tempsun  
     362   if keyword_set(key_performance) THEN print, 'temps total', systime(1)-tempsun 
     363   if keyword_set(key_performance) THEN printf,40, 'temps total', systime(1)-tempsun 
    364364; 
    365365return 
    366 END  
     366END 
  • trunk/inv_mask.pro

    r41 r48  
    88; CALLING SEQUENCE: inv_mask, mask 
    99; 
    10 ; INPUTS:  
    11 ;          mask : mask field composed of 0 and 1 values   
     10; INPUTS: 
     11;          mask : mask field composed of 0 and 1 values 
    1212; 
    1313; KEYWORD PARAMETERS: None 
    1414; 
    15 ; OUTPUTS:  
    16 ;          mask : mask field composed of 0 and 1 values  
    17 ;                 inverted  
     15; OUTPUTS: 
     16;          mask : mask field composed of 0 and 1 values 
     17;                 inverted 
    1818; 
    1919; COMMON BLOCKS: None 
    2020; 
    21 ; SIDE EFFECTS:  
     21; SIDE EFFECTS: 
    2222; 
    2323; RESTRICTIONS: 
     
    4343printf, 40, 'Inversion done' 
    4444return, z 
    45 END  
     45END 
  • trunk/naminterp.pro

    r2 r48  
    1313ndim = 0 
    1414;   Case ndim = 0 
    15 ;   -if the field and mask are really 2D (x,y(,t)) then  
     15;   -if the field and mask are really 2D (x,y(,t)) then 
    1616;      key_2d = 1 
    1717;   -else if they are (x,y,z_a(,t)) where z_a=1 then 
     
    3535;  1.4. Mask on points 
    3636;  ------------------- 
    37 ;   key_mask = 1 if some points are masked  
     37;   key_mask = 1 if some points are masked 
    3838;            = 0 if no masked points 
    3939; 
     
    4848;  ------------------------- 
    4949; 
    50 keydraw = 0 ; =0 if no drawing =1 else  
     50keydraw = 0 ; =0 if no drawing =1 else 
    5151key_ps = 0  ; =0 if no Postscript file wanted =1 if PS wanted (implies keydraw=1) 
    5252ndraw = 1 
    5353nlevel = 33 ; every nlevel levels 
    5454; 
    55 ;  
    56 ; 2. Information about the data file  
     55; 2. Information about the data file 
    5756; ================================== 
    5857; 
     
    6059;  ----------------- 
    6160; ... data 
    62 IF keyword_set(nscal) THEN BEGIN  
     61IF keyword_set(nscal) THEN BEGIN 
    6362   data_u_name = 'stress_x' 
    6463   data_v_name = 'stress_y' 
     
    7372IF keyword_set(key_mask) THEN mask_name = 'tmask' 
    7473; Input Latitude Axis 
    75 IF keyword_set(nscal) THEN BEGIN  
     74IF keyword_set(nscal) THEN BEGIN 
    7675   y_axis_u = 'nav_lat' 
    7776   y_axis_v = 'nav_lat' 
    78 ENDIF ELSE BEGIN  
     77ENDIF ELSE BEGIN 
    7978   y_axis   = 'la' 
    8079ENDELSE 
    8180 
    8281; ... input grid depth (3D field only) 
    83 IF keyword_set(ndim) THEN BEGIN  
     82IF keyword_set(ndim) THEN BEGIN 
    8483   datadept_name = 'deptht' 
    8584;  ... location (ndep =1 if depth in data file, =0 if in mask file) 
    8685   ndep = 1 
    8786ENDIF 
    88 ; ... time  
     87; ... time 
    8988time_name = 'lo' 
    9089; ... output grid mask(s) 
    91 IF keyword_set(nscal) THEN BEGIN  
     90IF keyword_set(nscal) THEN BEGIN 
    9291   mask_u_name = 'umask' 
    9392   mask_v_name = 'vmask' 
    94 ENDIF ELSE BEGIN  
     93ENDIF ELSE BEGIN 
    9594   mask_t_name = 'tmask' 
    9695ENDELSE 
    97 ; ... output grid depth  
     96; ... output grid depth 
    9897IF keyword_set(ndim) THEN outdept_name = 'gdept' 
    99 ; ... output grid coordinates  
    100 IF keyword_set(nscal) THEN BEGIN  
     98; ... output grid coordinates 
     99IF keyword_set(nscal) THEN BEGIN 
    101100   lon_u_name = 'glamu' 
    102101   lat_u_name = 'gphiu' 
     
    105104   lon_f_name = 'glamf' 
    106105   lat_f_name = 'gphif' 
    107 ENDIF ELSE BEGIN  
     106ENDIF ELSE BEGIN 
    108107   lon_name = 'nav_lon' 
    109108   lat_name = 'nav_lat' 
    110 ENDELSE  
     109ENDELSE 
    111110; ... missing value 
    112 ;      
     111; 
    113112;     nmiss = 0 --> no missing value 
    114113;     nmiss = 1 --> missing value of value missing_val 
     
    141140nit000 = 1                    ; first time step 
    142141nitend = 1                   ; last time step 
    143 nstep = nitend-nit000+1       ; number of steps  
     142nstep = nitend-nit000+1       ; number of steps 
    144143; 
    145144;  2.4. Pretreatment of input variables 
    146145;  ------------------------------------ 
    147146;   data = data*scale_factor + add_offset 
    148 ;   when handling multiple files with scale_factor and  
     147;   when handling multiple files with scale_factor and 
    149148;   add_offset defined, put key_vari=1 in case they change 
    150149;   from one file to another 
     
    165164; 
    166165;   mask = 1 on OCEAN points  -->  invmask = 0 
    167 ;   mask = 1 on LAND  points  -->  invmask = 1  
     166;   mask = 1 on LAND  points  -->  invmask = 1 
    168167; 
    169168invmask = 0 
     
    174173; 
    175174extend = 0 
    176 ; 
    177175; 
    178176; 3. Information about the output grid 
     
    191189pres_y=2.     ; Precision of the output grid along y axis 
    192190ext_x=40      ; Number of extension point on the output grid to treat for E/W boundary conditions 
    193 ext_y=40      ; Number of extension point on the output grid to treat for North fold boundary conditions;    
     191ext_y=40      ; Number of extension point on the output grid to treat for North fold boundary conditions; 
    194192;   modlam --> 0 if all longitudes are lower than 360 degrees 
    195193;          --> 1 if some longitudes are greater than 360 degrees 
    196 ;      
     194; 
    197195modlam = 0 
    198196; 
    199 ; 
    200 ; 4. Title(s) of output file(s)  
     197; 4. Title(s) of output file(s) 
    201198; ============================= 
    202199; 
    203 IF keyword_set(nscal) THEN BEGIN  
     200IF keyword_set(nscal) THEN BEGIN 
    204201   long_x_name = 'Zonal wind stress' 
    205202   title_x = "Daily interpolated OMIP stress x wind on ORCA2 grid" 
    206203   long_y_name = 'Meridional wind stress' 
    207204   title_y = "Daily interpolated OMIP stress y wind on ORCA2 grid" 
    208 ENDIF ELSE BEGIN  
     205ENDIF ELSE BEGIN 
    209206   long_name = 'Salinity' 
    210207   title = "Monthly Levitus Sea Salinity corrected" 
    211 ENDELSE  
     208ENDELSE 
    212209; 
    213210key_performance = 0 
     
    217214IF keyword_set(ndim)  THEN printf, 40, ' --> 3D' ELSE printf, 40, ' --> 2D' 
    218215; 
    219 IF keyword_set(nscal) THEN  BEGIN  
    220    printf, 40, 'Interpolation of the vector array : '  
    221    printf, 40, ' --> ', '[', data_u_name, ',', data_v_name, ']'  
    222 ENDIF ELSE BEGIN  
    223    printf, 40, 'Interpolation of the scalar array : '  
     216IF keyword_set(nscal) THEN BEGIN 
     217   printf, 40, 'Interpolation of the vector array : ' 
     218   printf, 40, ' --> ', '[', data_u_name, ',', data_v_name, ']' 
     219ENDIF ELSE BEGIN 
     220   printf, 40, 'Interpolation of the scalar array : ' 
    224221   printf, 40, ' --> ', data_name 
    225 ENDELSE  
     222ENDELSE 
    226223; 
    227224printf, 40, 'Type of the interpolation :' 
  • trunk/netcdf_input.pro

    r41 r48  
    22; NAME: netcdf_input.pro 
    33; 
    4 ; PURPOSE: Reads coordinates, data and mask  
     4; PURPOSE: Reads coordinates, data and mask 
    55; 
    66; CATEGORY: Subroutine 
     
    88; CALLING SEQUENCE: netcdf_input, mask 
    99; 
    10 ; INPUTS:  
     10; INPUTS: 
    1111; 
    1212;          maskfile  : name of mask file 
    1313;          gridfile  : name of grid file 
    14 ;          mask_name : mask name  
     14;          mask_name : mask name 
    1515;  SCALAR FIELD : 
    1616;          datafile  : name of input data file 
     
    2929; KEYWORD PARAMETERS: None 
    3030; 
    31 ; OUTPUTS:  
     31; OUTPUTS: 
    3232;          mask     : mask of the origin grid 
    3333;          nummsk   : ID of input mask file 
    3434;          nummsh   : ID of output coordinates and mask file 
    35 ;  SCALAR FIELD :  
     35;  SCALAR FIELD : 
    3636;          lon_t  : longitudes of target grid at t-point 
    37 ;          lat_t  : latitudes of target grid at t-point  
     37;          lat_t  : latitudes of target grid at t-point 
    3838;          numdta : ID of input data file 
    3939;  VECTOR FIELD : 
    4040;          lon_u    : longitudes of target grid at u-point 
    41 ;          lat_u    : latitudes of target grid at u-point  
     41;          lat_u    : latitudes of target grid at u-point 
    4242;          lon_v    : longitudes of target grid at v-point 
    43 ;          lat_v    : latitudes of target grid at v-point  
     43;          lat_v    : latitudes of target grid at v-point 
    4444;          lon_f    : longitudes of target grid at f-point 
    45 ;          lat_f    : latitudes of target grid at f-point  
     45;          lat_f    : latitudes of target grid at f-point 
    4646;          numdta_u : ID of input data x-component file 
    4747;          numdta_v : ID of input data y-component file 
    4848; 
    4949; COMMON BLOCKS: 
    50 ;       common_interp.pro 
     50;          common_interp.pro 
    5151; 
    52 ; SIDE EFFECTS:  
     52; SIDE EFFECTS: 
    5353; 
    5454; RESTRICTIONS: 
     
    7474IF keyword_set(key_mask) THEN nummsk = ncdf_open(input_dir+ '/'+ maskfile) 
    7575IF keyword_set(key_mask) THEN printf, 40, maskfile, ' opening OK' 
    76 IF keyword_set(nscal) THEN BEGIN  
     76IF keyword_set(nscal) THEN BEGIN 
    7777   numdta_u = ncdf_open(string(input_dir, '/', data_u_file)) 
    7878   printf, 40, data_u_file, ' opening OK' 
    7979   numdta_v = ncdf_open(string(input_dir, '/', data_v_file)) 
    8080   IF data_u_file NE data_v_file THEN printf, 40, data_v_file, ' opening OK' 
    81 ENDIF ELSE BEGIN  
     81ENDIF ELSE BEGIN 
    8282   numdta = ncdf_open(input_dir+ '/'+ datafile) 
    8383   printf, 40, datafile, ' opening OK' 
    84 ENDELSE  
     84ENDELSE 
    8585nummsh = ncdf_open(input_dir+ '/'+ gridfile) 
    8686printf, 40, gridfile, ' opening OK' 
     
    8989; ===================================== 
    9090; 
    91 IF keyword_set(nscal) THEN BEGIN  
     91IF keyword_set(nscal) THEN BEGIN 
    9292   ncdf_varget, nummsh, lon_u_name, lon_u 
    9393   ncdf_varget, nummsh, lat_u_name, lat_u 
     
    9696   ncdf_varget, nummsh, lon_v_name, lon_v 
    9797   ncdf_varget, nummsh, lat_v_name, lat_v 
    98    IF keyword_set(modlam) THEN BEGIN  
     98   IF keyword_set(modlam) THEN BEGIN 
    9999      ii=where(lon_f gt 360) 
    100100      lon_f(ii)=lon_f(ii)-360 
     
    103103      ii=where(lon_v gt 360) 
    104104      lon_v(ii)=lon_v(ii)-360 
    105    ENDIF  
    106 ENDIF ELSE BEGIN  
     105   ENDIF 
     106ENDIF ELSE BEGIN 
    107107   ncdf_varget, nummsh, lon_name, lon_t 
    108108   ncdf_varget, nummsh, lat_name, lat_t 
    109    IF keyword_set(modlam) THEN BEGIN  
     109   IF keyword_set(modlam) THEN BEGIN 
    110110      ii=where(lon_t gt 360) 
    111111      lon_t(ii)=lon_t(ii)-360 
    112    ENDIF  
    113 ENDELSE  
     112   ENDIF 
     113ENDELSE 
    114114printf, 40, '' 
    115115printf, 40, 'Coordinates of output grid reading OK' 
     
    122122 
    123123IF keyword_set(nscal) THEN BEGIN 
    124     
     124 
    125125       ncdf_varget, numdta_u,y_axis_u,phi_input_u, count = [jpiatm, jpjatm] 
    126126       ncdf_varget, numdta_v,y_axis_v,phi_input_v, count = [jpiatm, jpjatm] 
    127         
     127 
    128128       phi_input_u=phi_input_u(0,*) 
    129129       phi_input_v=phi_input_v(0,*) 
    130         
     130 
    131131ENDIF ELSE BEGIN 
    132132 
    133       
    134        ncdf_varget, numdta  ,y_axis  ,phi_input  , count = [ jpjatm]  
    135 ;   modif  FRED      
     133 
     134       ncdf_varget, numdta  ,y_axis  ,phi_input  , count = [ jpjatm] 
     135;   modif FRED 
    136136       phi_input=reverse(phi_input) 
    137 ;   fin modif FRED  
     137;   fin modif FRED 
    138138;stop 
    139139;       phi_input=phi_input(0,*) 
     
    143143; Data Mask 
    144144 
    145 IF keyword_set(key_mask) THEN BEGIN  
     145IF keyword_set(key_mask) THEN BEGIN 
    146146   IF keyword_set(ndim) THEN $ 
    147     ncdf_varget, nummsk, mask_name, mask, count = [jpiatm, jpjatm, jpkatm, 1] ELSE BEGIN   
     147    ncdf_varget, nummsk, mask_name, mask, count = [jpiatm, jpjatm, jpkatm, 1] ELSE BEGIN 
    148148 
    149149    IF keyword_set(key_2d) THEN $ 
    150150       ncdf_varget, nummsk, mask_name, mask, count = [jpiatm, jpjatm] ELSE $ 
    151151       ncdf_varget, nummsk, mask_name, mask, count = [jpiatm, jpjatm, 1, 1] 
    152     ENDELSE  
    153     
     152    ENDELSE 
     153 
    154154   printf, 40, '' 
    155155   printf, 40, 'Data mask reading OK' 
     
    157157   IF keyword_set(ndim) THEN mask = replicate(1., jpiatm, jpjatm, jpkatm) ELSE $ 
    158158    mask = replicate(1., jpiatm, jpjatm) 
    159 ENDELSE  
     159ENDELSE 
    160160; 
    161161; 3. Reading depths of input and output grids (3D field) 
    162162; ====================================================== 
    163163; 
    164 IF keyword_set(ndim) THEN BEGIN  
     164IF keyword_set(ndim) THEN BEGIN 
    165165   IF keyword_set(ndep) THEN $ 
    166166    ncdf_varget, numdta, datadept_name, datadept ELSE $ 
     
    169169   datadept = float(datadept) 
    170170   outdept = float(outdept) 
    171 ENDIF  
     171ENDIF 
    172172; 
    173173return 
    174 END   
     174END 
  • trunk/netcdf_output.pro

    r41 r48  
    99;                                 zoutputfile, ztitle, POINT = point, znumout, zvarid 
    1010; 
    11 ; INPUTS:  
     11; INPUTS: 
    1212;          zout_mask_name : name of interpolated field mask 
    13 ;               zout_mask : mask of interpolated field 
     13;               zout_mask : mask of interpolated field 
    1414;              zdata_name : name of data 
    1515;               zlon,zlat : coordinates of output grid 
     
    2020; KEYWORD PARAMETERS: None 
    2121; 
    22 ; OUTPUTS:  
     22; OUTPUTS: 
    2323;          NetCDF file containing the attributes of interpolated field 
    2424;          znumout : ID of output file 
     
    2626; 
    2727; COMMON BLOCKS: 
    28 ;       common_interp.pro 
     28;        common_interp.pro 
    2929; 
    30 ; SIDE EFFECTS:  
     30; SIDE EFFECTS: 
    3131; 
    3232; RESTRICTIONS: 
     
    6666;  -------------- 
    6767; 
    68 IF size(zlon, /n_dimensions) EQ 1 THEN BEGIN  
     68IF size(zlon, /n_dimensions) EQ 1 THEN BEGIN 
    6969   varlon = ncdf_vardef(znumout, 'nav_lon', [xid], /float) 
    7070   varlat = ncdf_vardef(znumout, 'nav_lat', [yid], /float) 
    71 ENDIF ELSE BEGIN  
     71ENDIF ELSE BEGIN 
    7272   varlon = ncdf_vardef(znumout, 'nav_lon', [xid, yid], /float) 
    7373   varlat = ncdf_vardef(znumout, 'nav_lat', [xid, yid], /float) 
    74 ENDELSE  
    75 IF keyword_set(ndim) THEN BEGIN  
     74ENDELSE 
     75IF keyword_set(ndim) THEN BEGIN 
    7676   varlev1 = ncdf_varid(nummsh, 'nav_lev') 
    7777   vart1 = ncdf_varid(znumdta, time_name) 
    78    varlev = ncdf_vardef(znumout, 'nav_lev', [zid], /float)  
     78   varlev = ncdf_vardef(znumout, 'nav_lev', [zid], /float) 
    7979   vart = ncdf_vardef(znumout, 'time', [tid], /float) 
    8080;   varmsk = ncdf_vardef(znumout, zout_mask_name, [xid, yid, zid], /float) 
    8181   zvarid = ncdf_vardef(znumout, zdata_name, [xid, yid, zid, tid], /float) 
    82 ENDIF ELSE BEGIN  
     82ENDIF ELSE BEGIN 
    8383   vart1 = ncdf_varid(znumdta, time_name) 
    8484   vart = ncdf_vardef(znumout, 'time', [tid], /float) 
    8585;   varmsk = ncdf_vardef(znumout, zout_mask_name, [xid, yid], /float) 
    8686   zvarid = ncdf_vardef(znumout, zdata_name, [xid, yid, tid], /float) 
    87 ENDELSE  
     87ENDELSE 
    8888; 
    8989;  2.3. Attributes 
     
    9898ncdf_attput, znumout, varlat, "valid_max", max(zlat) 
    9999ncdf_attput, znumout, varlat, "long_name", string("Latitude at ", point, "-point") 
    100 IF keyword_set(ndim) THEN BEGIN  
     100IF keyword_set(ndim) THEN BEGIN 
    101101   rien = ncdf_attcopy(nummsh, varlev1, "units", znumout, varlev) 
    102102   rien = ncdf_attcopy(nummsh, varlev1, "valid_min", znumout, varlev) 
     
    106106zatt = ncdf_varinq(znumdta, vart1) 
    107107znbatt = zatt.natts 
    108 FOR i = 0, znbatt-1 DO BEGIN  
     108FOR i = 0, znbatt-1 DO BEGIN 
    109109   namatt = ncdf_attname(znumdta, vart1, i) 
    110110   rien = ncdf_attcopy(znumdta, vart1, namatt,znumout, vart) 
    111 ENDFOR  
    112 ncdf_attput, znumout, zvarid, "units", units  
    113 ncdf_attput, znumout, zvarid, "long_name", zlong_name  
     111ENDFOR 
     112ncdf_attput, znumout, zvarid, "units", units 
     113ncdf_attput, znumout, zvarid, "long_name", zlong_name 
    114114; 
    115115; ... Global attributes 
     
    119119ncdf_attput, znumout,"Title", ztitle, /global 
    120120; 
    121 ; 3. Writing data  
     121; 3. Writing data 
    122122; =============== 
    123123; 
     
    131131ncdf_varput, znumout, varlon, zlon 
    132132ncdf_varput, znumout, varlat, zlat 
    133 IF keyword_set(ndim) THEN BEGIN  
     133IF keyword_set(ndim) THEN BEGIN 
    134134   ncdf_varget, nummsh, 'nav_lev', z, count = [jpkoce] 
    135135   ncdf_varput, znumout, varlev, z 
    136 ENDIF  
     136ENDIF 
    137137; 
    138138;  3.2. Time and mask 
     
    144144ncdf_varput, znumout, vart, zt 
    145145;ncdf_varput, znumout, varmsk, zout_mask 
    146    if keyword_set(key_performance) THEN print, 'temps netcdf_output', systime(1)-tempsun  
     146   if keyword_set(key_performance) THEN print, 'temps netcdf_output', systime(1)-tempsun 
    147147; 
    148148return 
    149 END  
     149END 
  • trunk/northwind.pro

    r41 r48  
    33; 
    44; PURPOSE: Check on in the intput field the level of coherence of winds nearby north pole, 
    5 ;          and corrects it. Thi stask is performed before interpolation  
     5;          and corrects it. Thi stask is performed before interpolation 
    66; 
    77; CATEGORY: Subroutine 
     
    99; CALLING SEQUENCE: northwind 
    1010; 
    11 ; INPUTS:  
    12 ; 
     11; INPUTS: 
    1312; 
    1413; KEYWORD PARAMETERS: None 
    1514; 
    16 ; OUTPUTS:  
     15; OUTPUTS: 
    1716;          zresul : the same wind field with its upward stripe 
    1817;          corrected in order to get coherence of winds on north polte 
    1918; 
    2019; COMMON BLOCKS: 
    21 ;          common_interp.pro 
    22 ; 
     20;           common_interp.pro 
    2321; 
    2422PRO northwind, datglo,zdata_name,t 
     
    2624@common_interp 
    2725 
    28 ; Treatment of north pole stripe  
     26; Treatment of north pole stripe 
    2927 
    30      
     28 
    3129; Get from global array, the last stripe and the last but one stripe 
    32   
     30 
    3331;    Initialising data arrays 
    3432 
    3533     datglo_rect  = replicate(0.,2,jpiatm) 
    36      datglo_rectb = replicate(0.,2,jpiatm)  
     34     datglo_rectb = replicate(0.,2,jpiatm) 
    3735 
    3836; Put data of the last two stripes into arrays 
    3937 
    40       
     38 
    4139     datglo_rect(0,*) = datglo(*,jpjatm-1,0) 
    4240     datglo_rect(1,*) = datglo(*,jpjatm-1,1) 
     
    4543     datglo_rectb(1,*)= datglo(*,jpjatm-2,1) 
    4644 
    47       
     45 
    4846 
    4947; Converts data of these two lines into polar coordinates 
     
    5957     datglo_polarb=CV_COORD(FROM_RECT=datglo_rect,/TO_POLAR) 
    6058     datglo_polarb(0,*)=datglo_polar(0,*)+2*!PI*indgen(jpiatm)/jpiatm 
    61      
     59 
    6260 
    6361; Coherence of the last line needs to be corrected 
     
    6967     mean_argb=replicate((total(datglo_polarb(0,*))/jpiatm+2*!PI*west_lon/360.+!PI*(jpiatm-1.)/float(jpiatm)) ,jpiatm) 
    7068 
    71       
     69 
    7270 
    7371     ; Checks whether module is about the same on the North Pole line : 
    74      
     72 
    7573     test_mod=abs(mean_mod-datglo_polar(1,*)) 
    7674 
    7775     IF ( max(test_mod)/mean_mod(0) ) GT 0.01 THEN BEGIN 
    78      
    79           print, 'MODULE IS NOT COHERENT AND WILL BE CORRECTED TO A MEAN VALUE OF :', mean_mod(0)  
    80            
     76 
     77          print, 'MODULE IS NOT COHERENT AND WILL BE CORRECTED TO A MEAN VALUE OF :', mean_mod(0) 
     78 
    8179          datglo_polar(1,*)=mean_mod 
    82           
     80 
    8381     ENDIF 
    84      
     82 
    8583 
    8684     ; Checks whether argument is coherent on the North Pole line : 
     
    8886     test_arg=abs(mean_arg-datglo_polar(0,*)) 
    8987 
    90      IF ( max(test_arg)/mean_arg(0)) GT 0.01 THEN BEGIN  
     88     IF ( max(test_arg)/mean_arg(0)) GT 0.01 THEN BEGIN 
    9189 
    9290          print, 'ARGUMENT IS NOT COHERENT AND WILL BE CORRECTED TO A MEAN VALUE :', mean_argb(0) 
    93    
     91 
    9492          datglo_polar(0,*)=mean_argb-!PI/2-(2*!PI*indgen(jpiatm)/float(jpiatm)+replicate(2.*!PI*west_lon/360.,jpiatm)) 
    95             
    96       
     93 
     94 
    9795 
    9896     ; Cross Corellation Method for wind coherence on North Pole 
    9997 
    10098     all_phases=indgen(jpiatm) 
    101       
     99 
    102100     Ux=mean_mod*cos(all_phases*2.*!PI/jpiatm) 
    103      Uy=mean_mod*sin(all_phases*2.*!PI/jpiatm)  
     101     Uy=mean_mod*sin(all_phases*2.*!PI/jpiatm) 
    104102 
    105103     phyx=C_CORRELATE(Ux,datglo(*,jpjatm-2,0),all_phases) 
     
    110108     deph_x=where(phyx EQ max(phyx)) 
    111109     deph_y=where(phyy EQ max(phyy)) 
    112       
     110 
    113111     deph_x=deph_x(0) 
    114112     deph_y=deph_y(0) 
    115113 
    116       
     114 
    117115 
    118116 
     
    122120     datglo(*,jpjatm-1,0)=Ux 
    123121     datglo(*,jpjatm-1,1)=Uy 
    124   
     122 
    125123 
    126124     ENDIF 
    127125 
    128   
    129      
     126 
     127 
    130128 
    131129end 
  • trunk/preproc_mask.pro

    r41 r48  
    33; NAME: preproc_mask.pro 
    44; 
    5 ; PURPOSE: Extends land-sea mask by one point over ocean  
     5; PURPOSE: Extends land-sea mask by one point over ocean 
    66; 
    77; CATEGORY: Function 
     
    99; CALLING SEQUENCE: preproc_mask, mask 
    1010; 
    11 ; INPUTS:  
    12 ;          mask : mask field composed of 0 and 1 values  
    13 ;                 with 0 over land points         
     11; INPUTS: 
     12;          mask : mask field composed of 0 and 1 values 
     13;                 with 0 over land points 
    1414; 
    1515; KEYWORD PARAMETERS: None 
    1616; 
    17 ; OUTPUTS:  
    18 ;          mask : mask field extended  
    19 ;                   
     17; OUTPUTS: 
     18;          mask : mask field extended 
    2019; 
    21 ; COMMON BLOCKS:  
     20; 
     21; COMMON BLOCKS: 
    2222;          common_interp 
    2323; 
    24 ; SIDE EFFECTS:  
     24; SIDE EFFECTS: 
    2525; 
    2626; RESTRICTIONS: 
     
    5050; 
    5151return, z 
    52 END  
     52END 
  • trunk/rseries_ncdf.pro

    r41 r48  
    6565; "years since 1979-01-01 00:00:00" 
    6666; 4) The calendar must be the Gregorian calendar 
    67 ; 5) The name of the file must begining by 
     67; 5) The name of the file must beginning by 
    6868; exp_freq_datefirst_datelast_* 
    6969; 6) The maximum gap between 2 consecutive files must be one day. 
     
    118118  if n_elements(freqin) EQ 0 then freq = '5d' ELSE freq = freqin 
    119119;------------------------------------------------ 
    120 ; determinaition of the filename beginning with exp_freq_* 
     120; determination of the filename beginning with exp_freq_* 
    121121;------------------------------------------------ 
    122122  IF keyword_set(gridtype) EQ 0 THEN gridtype = '' 
     
    141141; date1 
    142142  CASE strmid(freqin, 0, 1, /rever) OF 
    143     'm':div = 100 
    144     'y':div = 10000 
    145     ELSE:div = 1 
     143    'm' : div = 100 
     144    'y' : div = 10000 
     145    ELSE : div = 1 
    146146  ENDCASE 
    147147  goodfile = where(datefirst le date1/div and datelast GE date1/div) 
     
    243243    'm':datelast = 100*datelast + daysinmonth(datelast MOD 100, datelast / 100) 
    244244    'y':div = 10000*datelast+360+(5+leapyr(datelast+century))*(key_caltype EQ 'greg') 
    245     ELSE:div = 1 
     245    ELSE : div = 1 
    246246  ENDCASE 
    247247  if date2 GT datelast THEN BEGIN 
    248248; if we need to read more than one file, 
    249249; first we read the first file 
    250 ;++    print,var,date1+century*1000000L, datelast[0]+century*1000000L  
    251 ;++READ, B, PROMPT='Enter Name: '   
     250;++    print,var,date1+century*1000000L, datelast[0]+century*1000000L 
     251;++READ, B, PROMPT='Enter Name: ' 
    252252    res1 = read_ncdf(var, date1+century*1000000L, datelast[0]+century*1000000L $ 
    253253                     , filename = filename, /nostruct, _extra = ex) 
     
    269269        res = temporary(res1) 
    270270      END 
    271       ELSE:BEGIN 
     271      ELSE : BEGIN 
    272272 ; we glue the result of the first read and the result of the new call 
    273273; to rseries_ncdf 
  • trunk/step1_diff.pro

    r41 r48  
    114114ENDELSE 
    115115; 
    116 ; 
    117116; write output 
    118117; in order to avoid unexpected overwritten 
     
    122121   RETURN 
    123122ENDIF 
    124 ; 
    125123; 
    126124;--------------------------- 
  • trunk/step2_diff.sh

    r47 r48  
    1616# ======== 
    1717# 
    18 # .. code-blcok:: bash 
     18# .. code-block:: bash 
    1919# 
    2020#    step2_diff.sh -y year 
     
    2525# For test on year 1994: 
    2626# 
    27 # .. code-blcok:: bash 
     27# .. code-block:: bash 
    2828# 
    2929#    ./step2_diff.sh -y 1994 
     
    5959usage=" Usage : ${command} -y year" 
    6060# 
    61 set +u 
    62 while [ ! -z "${1}" ] 
     61while [ ${#} -gt 0 ] 
    6362do 
    6463   case ${1} in 
Note: See TracChangeset for help on using the changeset viewer.