Ignore:
Timestamp:
12/13/06 15:58:23 (17 years ago)
Author:
pinsard
Message:

externalisation of outputs in condmag_on_orca.pro

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/condmag_on_orca.pro

    r10 r14  
    2121; to specify on which grid we do the interpolation T, U, V 
    2222; must belong to T, U or V 
     23; 
     24; @keyword DRAKKAR_EXP {type=string} 
     25; code for Drakkar experiment 
     26; only used when orcares = ORC025 
     27; must be G42 ++ G70 
    2328; 
    2429; @restrictions 
     
    4045; for ORCA2 filename is meshmask_bab.nc 
    4146; ++ au pif entre mesh_hgr, mesh_zgr et mask 
    42 ; for ORCA0252 filename is ORCA025-G42_mesh_hgr.nc  
     47; for ORCA0252 filename is ORCA025-G42_mesh_hgr.nc 
    4348; 
    4449; @post 
     
    5257; 
    5358; @history 
     59; reee522 2006-12-13T13:50:32Z rhodes (IRIX64) 
     60; add optional keyword drakkar_exp 
     61; reee522 2006-12-13T12:09:05Z rhodes (IRIX64) 
     62; externalisation of netcdf writing 
    5463; reee522 2006-11-23T13:34:31Z rhodes (IRIX64) 
    5564; add ORCA025 (beginning) 
     
    6372; ++ not very beautifuly implemented 
    6473; fplod 2006-11-22T10:38:51Z aedon.locean-ipsl.upmc.fr (Darwin) 
    65 ; always use msg = 'iii : ...' or msg = 'eee : ...'  
     74; always use msg = 'iii : ...' or msg = 'eee : ...' 
    6675; information on open io 
    6776; fplod 2006-11-20T10:32:02Z aedon.locean-ipsl.upmc.fr (Darwin) 
     
    8291; 
    8392;- 
    84 PRO condmag_on_orca, orcares, method, gridtype 
     93PRO condmag_on_orca, orcares, method, gridtype, DRAKKAR_EXP = drakkar_exp 
    8594; 
    8695  compile_opt idl2, strictarrsubs 
     
    94103  CASE orcares OF 
    95104     'ORCA2': BEGIN 
    96                  msg = 'iii : valid orcares parameter = ' +  orcares 
     105                 msg = 'iii : valid orcares parameter = ' + orcares 
    97106                 PRINT, msg 
    98107                 filename_oce = 'meshmask_bab.nc' 
     108                 IF keyword_set(DRAKKAR_EXP) THEN BEGIN 
     109                    msg = 'www : unused DRAKKAR_EXP keyword = ' + drakkar_exp 
     110                    PRINT, msg 
     111                 END 
    99112              END 
    100113     'ORCA025': BEGIN 
    101                  msg = 'iii : valid orcares parameter = ' +  orcares 
     114                 msg = 'iii : valid orcares parameter = ' + orcares 
    102115                 PRINT, msg 
    103                  filename_oce = orcares + '-G42_mesh_hgr.nc'  
     116                 IF keyword_set(DRAKKAR_EXP) THEN BEGIN 
     117                    msg = 'iii : DRAKKAR_EXP keyword set' 
     118                    PRINT, msg 
     119                    msg = 'iii : DRAKKAR_EXP = ' + drakkar_exp 
     120                    PRINT, msg 
     121                    CASE drakkar_exp OF 
     122                       'G42' : BEGIN 
     123                                  msg = 'iii : valid DRAKKAR_EXP keyword = ' + drakkar_exp 
     124                                  PRINT, msg 
     125                               END 
     126                       'G70' : BEGIN 
     127                                  msg = 'iii : valid DRAKKAR_EXP keyword = ' + drakkar_exp 
     128                                  PRINT, msg 
     129                               END 
     130                       ELSE : BEGIN 
     131                                  msg = 'eee : invalid DRAKKAR_EXP keyword = ' + drakkar_exp 
     132                                  PRINT, msg 
     133                                  RETURN 
     134                              END 
     135                    ENDCASE 
     136                    filename_oce = orcares + '-' + drakkar_exp + '_mesh_hgr.nc' 
     137                 END 
    104138              END 
    105139      ELSE  : BEGIN 
     
    123157                 END 
    124158     ELSE      : BEGIN 
    125                     msg = 'eee : invalid method parameter = ' + method  
     159                    msg = 'eee : invalid method parameter = ' + method 
    126160                    PRINT, msg 
    127161                    msg = 'eee : method must be bilinear or imoms3' 
     
    147181           END 
    148182     ELSE: BEGIN 
    149               msg = 'eee : invalid gridtype parameter = ' + gridtype  
     183              msg = 'eee : invalid gridtype parameter = ' + gridtype 
    150184              PRINT, msg 
    151185              msg = 'eee : gridtype must be T, U or V' 
     
    168202             msg = 'iii : ${GEOMAG_ID} is ' + geomag_id_env 
    169203             PRINT, msg 
    170            END  
     204           END 
    171205  ENDCASE 
    172206; 
     
    200234; mesh mask 
    201235; check if this file exists 
    202   fullfilename_oce = isafile(iodirin + filename_oce, NEW=0,/MUST_EXIST, RECURSIVE=0) 
     236  fullfilename_oce = isafile(iodirin + filename_oce, NEW=0, /MUST_EXIST, $ 
     237                     RECURSIVE=0) 
    203238  IF fullfilename_oce[0] EQ '' THEN BEGIN 
    204239     msg = 'eee : the file ' + fullfilename_oce + ' was not found.' 
     
    225260             msg = 'iii : ${GEOMAG_OD} is ' + geomag_od_env 
    226261             PRINT, msg 
    227            END  
     262           END 
    228263  ENDCASE 
    229264; 
     
    238273  ENDIF 
    239274; 
    240 ; build output filenames 
    241   filename_cond_sed = 'cond_sed' + '_' + orcares +'.nc' 
    242   fullfilename_cond_sed = iodirout + filename_cond_sed 
    243 ; 
    244 ; in order to avoid unexpected overwritten 
    245   IF (FILE_TEST(fullfilename_cond_sed) EQ 1) THEN BEGIN 
    246      msg = 'eee : the file ' + fullfilename_cond_sed  + ' already exists.' 
    247      PRINT, msg 
    248      RETURN 
    249   ENDIF 
    250 ; 
    251   filename_br = 'Br' + '_' + orcares +'.nc' 
    252   fullfilename_br = iodirout + filename_br 
    253 ; 
    254 ; in order to avoid unexpected overwritten 
    255   IF (FILE_TEST(fullfilename_br) EQ 1) THEN BEGIN 
    256      msg = 'eee : the file ' + fullfilename_br  + ' already exists.' 
    257      PRINT, msg 
    258      RETURN 
    259   ENDIF 
    260 ; 
    261275; d'après ncdump -h /usr/work/sur/fvi/OPA/geomag/condmag.nc 
    262276  condmaglonname = 'lo' 
    263277  condmaglatname = 'la' 
    264   varname_cond_sed = 'cond_sed' 
    265   varname_br = 'Br' 
    266278; 
    267279;---- 
     
    300312  msg = 'iii : ' + fullfilename_condmag[0] + ' opened for read' 
    301313  PRINT, msg 
    302    
     314; 
     315  varname_cond_sed = 'cond_sed' 
     316  varname_br = 'Br' 
     317; 
    303318  varinq_cond_sed = NCDF_VARINQ(netcdf_id_condmag, varname_cond_sed) 
     319  NCDF_VARGET, netcdf_id_condmag, varname_cond_sed, varin_cond_sed 
     320; 
    304321  varinq_br = NCDF_VARINQ(netcdf_id_condmag, varname_br) 
     322  NCDF_VARGET, netcdf_id_condmag, varname_br, varin_br 
     323; 
     324  NCDF_CLOSE, netcdf_id_condmag 
    305325; 
    306326;--------------------------- 
    307 ; Creation of the NetCdf file for cond_sed and Br 
    308 ;--------------------------- 
    309 ; 
    310   netcdf_id_cond_sed = NCDF_CREATE(fullfilename_cond_sed, /clobber) 
    311   NCDF_CONTROL, netcdf_id_cond_sed, /NOFILL 
    312   netcdf_id_br = NCDF_CREATE(fullfilename_br, /clobber) 
    313   NCDF_CONTROL, netcdf_id_br, /NOFILL 
    314 ; 
    315 ; dimension 
    316   dimidx = NCDF_DIMDEF(netcdf_id_cond_sed, 'x' ,  jpio) 
    317   dimidy = NCDF_DIMDEF(netcdf_id_cond_sed, 'y' ,  jpjo) 
    318   dimidt = NCDF_DIMDEF(netcdf_id_cond_sed, 'lo', /UNLIMITED) 
    319   dimidx = NCDF_DIMDEF(netcdf_id_br, 'x' ,  jpio) 
    320   dimidy = NCDF_DIMDEF(netcdf_id_br, 'y' ,  jpjo) 
    321   dimidt = NCDF_DIMDEF(netcdf_id_br, 'lo', /UNLIMITED) 
    322 ; 
    323 ; global attributes 
    324   NCDF_ATTPUT, netcdf_id_cond_sed, 'Conventions', 'GDT 1.2', /GLOBAL ; ++ conformité 
    325   NCDF_ATTPUT, netcdf_id_cond_sed, 'file_name'  , filename_cond_sed, /GLOBAL 
    326   NCDF_ATTPUT, netcdf_id_cond_sed, 'Title'      , 'Conductance', /GLOBAL 
    327   NCDF_ATTPUT, netcdf_id_br, 'Conventions', 'GDT 1.2', /GLOBAL ; ++ conformité 
    328   NCDF_ATTPUT, netcdf_id_br, 'file_name'  , filename_Br, /GLOBAL 
    329   NCDF_ATTPUT, netcdf_id_br, 'Title'      , 'Magnetic field', /GLOBAL 
    330 ; 
    331 ; declaration of variables 
    332 ; 4 common variables for the two files to produce 
    333   varid = lonarr(3) 
    334 ; 
    335   varid[0] = NCDF_VARDEF(netcdf_id_cond_sed, 'nav_lon'  , [dimidx, dimidy], /FLOAT) 
    336   NCDF_ATTPUT, netcdf_id_cond_sed, varid[0], 'units'    , 'degrees_east' 
    337   NCDF_ATTPUT, netcdf_id_cond_sed, varid[0], 'valid_min', min(olon, max = omax),/FLOAT 
    338   NCDF_ATTPUT, netcdf_id_cond_sed, varid[0], 'valid_max', omax,/FLOAT 
    339   NCDF_ATTPUT, netcdf_id_cond_sed, varid[0], 'long_name', 'Longitude at t-point' 
    340   varid[0] = NCDF_VARDEF(netcdf_id_br, 'nav_lon'  , [dimidx, dimidy], /FLOAT) 
    341   NCDF_ATTPUT, netcdf_id_br, varid[0], 'units'    , 'degrees_east' 
    342   NCDF_ATTPUT, netcdf_id_br, varid[0], 'valid_min', min(olon, max = omax),/FLOAT 
    343   NCDF_ATTPUT, netcdf_id_br, varid[0], 'valid_max', omax,/FLOAT 
    344   NCDF_ATTPUT, netcdf_id_br, varid[0], 'long_name', 'Longitude at t-point' 
    345 ; 
    346   varid[1] = NCDF_VARDEF(netcdf_id_cond_sed, 'nav_lat'  , [dimidx, dimidy], /FLOAT) 
    347   NCDF_ATTPUT, netcdf_id_cond_sed, varid[1], 'units'    , 'degrees_north' 
    348   NCDF_ATTPUT, netcdf_id_cond_sed, varid[1], 'valid_min', min(olat, max = omax),/FLOAT 
    349   NCDF_ATTPUT, netcdf_id_cond_sed, varid[1], 'valid_max', omax,/FLOAT 
    350   NCDF_ATTPUT, netcdf_id_cond_sed, varid[1], 'long_name', 'Latitude at t-point' 
    351   varid[1] = NCDF_VARDEF(netcdf_id_br, 'nav_lat'  , [dimidx, dimidy], /FLOAT) 
    352   NCDF_ATTPUT, netcdf_id_br, varid[1], 'units'    , 'degrees_north' 
    353   NCDF_ATTPUT, netcdf_id_br, varid[1], 'valid_min', min(olat, max = omax),/FLOAT 
    354   NCDF_ATTPUT, netcdf_id_br, varid[1], 'valid_max', omax,/FLOAT 
    355   NCDF_ATTPUT, netcdf_id_br, varid[1], 'long_name', 'Latitude at t-point' 
    356 ; 
    357   varid[2] = NCDF_VARDEF(netcdf_id_cond_sed, 'time'     , [dimidt], /FLOAT) 
    358   varid[2] = NCDF_VARDEF(netcdf_id_br, 'time'     , [dimidt], /FLOAT) 
    359 ; 
    360 ; each of the two files to produce contains a specific variable 
    361 ; 
    362   varid_cond_sed = lonarr(1) 
    363   varid_cond_sed[0] = NCDF_VARDEF(netcdf_id_cond_sed, varname_cond_sed, [dimidx, dimidy, dimidt], /FLOAT) 
    364 ; 
    365 ; variable 3 
    366   NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'long_name', 'Conductance' ; ++ non cf  
    367   NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'units', 'siemens' ; ++ récupérer l'unite de cond_sed dans condmag.nc 
    368 ; pour min  et max, il faut avoir lu la variable ... cf. plus bas ++ 
    369 ; donc pour l'instant on les met à valeur manquante 
    370   NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'valid_min', !VALUES.F_NAN ,/FLOAT 
    371   NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'valid_max', !VALUES.F_NAN ,/FLOAT 
    372 ; 
    373   varid_br = lonarr(1) 
    374   varid_br[0] = NCDF_VARDEF(netcdf_id_br, varname_br, [dimidx, dimidy, dimidt], /FLOAT) 
    375 ; 
    376 ; variable 3 
    377   NCDF_ATTPUT, netcdf_id_br, varid_br[0], 'long_name', 'magnetic field' ; ++ non cf  
    378   NCDF_ATTPUT, netcdf_id_br, varid_br[0], 'units', 'tesla' ; ++ récupérer l'unité de Br dans condmag.nc 
    379 ; pour min  et max, il faut avoir lu la variable ... cf. plus bas ++ 
    380 ; donc pour l'instant on les met à valeur manquante 
    381   NCDF_ATTPUT, netcdf_id_br, varid_br[0], 'valid_min', !VALUES.F_NAN ,/FLOAT 
    382   NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'valid_max', !VALUES.F_NAN ,/FLOAT 
    383 ; 
    384 ;--------------------------- 
    385 ; end of header definition, writing of the NetCdf files 
    386 ;--------------------------- 
    387   NCDF_CONTROL, netcdf_id_cond_sed, /ENDEF 
    388   NCDF_CONTROL, netcdf_id_br, /ENDEF 
    389   NCDF_CLOSE, netcdf_id_condmag ; ++ si le close n'est pas ici ça merde mais je ne sais pas pourquoi 
    390 ; 
    391 ; grid 
    392   NCDF_VARPUT, netcdf_id_cond_sed, 'nav_lon', olon 
    393   NCDF_VARPUT, netcdf_id_cond_sed, 'nav_lat', olat 
    394   NCDF_VARPUT, netcdf_id_cond_sed, varid[2], FLOAT(0.5) ; ++ c'est quoi cette valeur 
    395   NCDF_VARPUT, netcdf_id_br, 'nav_lon', olon 
    396   NCDF_VARPUT, netcdf_id_br, 'nav_lat', olat 
    397   NCDF_VARPUT, netcdf_id_br, varid[2], FLOAT(0.5) ; ++ c'est quoi cette valeur 
    398  
    399 ;--------------------------- 
    400 ; réouverture du fichier ... mais pourquoi on le relit !!++ 
    401   netcdf_id_condmag = NCDF_OPEN(fullfilename_condmag[0],/NOWRITE) 
    402   msg = 'iii : ' + fullfilename_condmag[0] + ' reopened for read' 
    403   PRINT, msg 
    404 ; 
    405   NCDF_VARGET, netcdf_id_condmag, varname_cond_sed, varin_cond_sed ; , COUNT = [jpia, jpja, 1], OFFSET = [0, 0, 0] 
    406   NCDF_VARGET, netcdf_id_condmag, varname_br, varin_br ; , COUNT = [jpia, jpja, 1], OFFSET = [0, 0, 0] 
    407 ; 
    408327; do the interpolation 
    409328      varin_cond_sed = TOTAL(weig*varin_cond_sed[addr], 1) 
     
    412331      varin_br = REFORM(varin_br, jpio, jpjo, /OVER) 
    413332; 
    414       NCDF_CLOSE, netcdf_id_condmag 
    415333      varout_cond_sed = TEMPORARY(varin_cond_sed) 
    416334      varout_br = TEMPORARY(varin_br) 
    417 ; compute min max 
    418       minarr_cond_sed = min(varout_cond_sed, max = maxarr_cond_sed) 
    419       minarr_br = min(varout_br, max = maxarr_br) 
    420335; 
    421336; put back the masked value 
     
    423338;++      IF bad[0] NE -1 THEN varout_br[TEMPORARY(bad)] = 32767 
    424339; 
    425 ; write the data 
    426       NCDF_VARPUT, netcdf_id_cond_sed, varname_cond_sed, varout_cond_sed, COUNT = [jpio, jpjo, 1], OFFSET = [0, 0, 0] 
    427       NCDF_VARPUT, netcdf_id_br, varname_br, varout_br, COUNT = [jpio, jpjo, 1], OFFSET = [0, 0, 0] 
    428 ; 
    429 ; update min max attributes 
    430   NCDF_CONTROL, netcdf_id_cond_sed, /REDEF 
    431   NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'valid_min', minarr_cond_sed,/FLOAT 
    432   NCDF_ATTPUT, netcdf_id_cond_sed, varid_cond_sed[0], 'valid_max', maxarr_cond_sed,/FLOAT 
    433   NCDF_CONTROL, netcdf_id_cond_sed, /ENDEF 
    434   NCDF_CONTROL, netcdf_id_br, /REDEF 
    435   NCDF_ATTPUT, netcdf_id_br, varid_br[0], 'valid_min', minarr_br,/FLOAT 
    436   NCDF_ATTPUT, netcdf_id_br, varid_br[0], 'valid_max', maxarr_br,/FLOAT 
    437   NCDF_CONTROL, netcdf_id_br, /ENDEF 
    438 ; 
    439 ;--------------------------- 
    440 ; close the netcdf files 
    441   NCDF_CLOSE, netcdf_id_cond_sed 
    442   NCDF_CLOSE, netcdf_id_br 
    443 ; 
    444   msg = 'iii : ' + fullfilename_cond_sed + ' created' 
    445   PRINT, msg 
    446   msg = 'iii : ' + fullfilename_br + ' created' 
    447   PRINT, msg 
     340; 
     341; produce outputs 
     342  condmag_output, orcares, $ 
     343     varinq_cond_sed, 'Conductance', 'Conductance', 'siemens', $ 
     344     jpio, jpjo, olon, olat, $ 
     345     varout_cond_sed 
     346  condmag_output, orcares, $ 
     347     varinq_br, 'Magnetic field', 'magnetic field', 'tesla', $ 
     348     jpio, jpjo, olon, olat, $ 
     349     varout_br 
    448350; 
    449351END 
Note: See TracChangeset for help on using the changeset viewer.