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

fix thanks to coding rules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.