Changeset 3639


Ignore:
Timestamp:
03/15/18 10:59:22 (6 years ago)
Author:
omamce
Message:

O.M. : add full description in rmp files.
Note: bounds are still missing for LMD lon/lat grid.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CreateWeightsMask.bash

    r3632 r3639  
    4545# Defines models 
    4646# ============== 
    47 OCE=ORCA2.3 
    48 #OCE=eORCA1.2 
     47#OCE=ORCA2.3 
     48OCE=eORCA1.2 
    4949#OCE=ORCA025 
    5050 
     
    126126## =========================================================================== 
    127127cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc  . 
    128 cp ${R_IN}/ATM/${ATM}/${ATM}_grid.nc . 
     128cp ${R_IN}/ATM/GRID/${ATM}_grid.nc . 
    129129 
    130130ln -s ${OCE}_coordinates_mask.nc  oce_grid.nc 
     
    163163where (OceFrac <  0.0 )  OceFrac=0.0 ;  
    164164EOF 
    165 ncap2 -h --overwrite --script-file correction_masque.nco dia_t${oce}_to_t${atm}_1storder.nc tmp_dia_t${oce}_to_t${atm}_1storder.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder.nc dia_t${oce}_to_t${atm}_1storder.nc 
    166 ncatted -h -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder.nc 
     165ncap2 --history --overwrite --script-file correction_masque.nco dia_t${oce}_to_t${atm}_1storder.nc tmp_dia_t${oce}_to_t${atm}_1storder.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder.nc dia_t${oce}_to_t${atm}_1storder.nc 
     166ncatted --history -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_1storder.nc 
    167167 
    168168## 
     
    170170## =========================================================================== 
    171171cp dia_t${oce}_to_t${atm}_1storder.nc  dia_t${oce}_to_t${atm}_1storder_mask.nc 
    172 ncks -h --overwrite -v OceFrac dia_t${oce}_to_t${atm}_1storder_mask.nc  ${ATM}_grid_maskFrom_${OCE}.nc 
    173 ncks -h --append    -v aire    atm_grid.nc                              ${ATM}_grid_maskFrom_${OCE}.nc 
    174 [[ ${atm} = *ico* ]] && ncks -h --append -v bounds_lon,bounds_lat atm_grid.nc                              ${ATM}_grid_maskFrom_${OCE}.nc 
     172ncks --alphabetize --history --overwrite -v OceFrac dia_t${oce}_to_t${atm}_1storder_mask.nc  ${ATM}_grid_maskFrom_${OCE}.nc 
     173ncks --alphabetize --history --append    -v aire    atm_grid.nc                              ${ATM}_grid_maskFrom_${OCE}.nc 
     174[[ ${atm} = *ico* ]] && ncks --alphabetize --history --append -v bounds_lon,bounds_lat atm_grid.nc                              ${ATM}_grid_maskFrom_${OCE}.nc 
    175175 
    176176cat <<EOF > creation_masque.nco 
     
    178178where (OceFrac <= 0.0 )  OceFrac=0 ; 
    179179EOF 
    180 ncap2 -h --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_1storder_mask.nc tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc dia_t${oce}_to_t${atm}_1storder_mask.nc 
    181 ncrename -h -v OceFrac,OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc 
    182  
    183 ncks -h --append  -v OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc   ${ATM}_grid_maskFrom_${OCE}.nc 
     180ncap2 --history --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_1storder_mask.nc tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc ; mv tmp_dia_t${oce}_to_t${atm}_1storder_mask.nc dia_t${oce}_to_t${atm}_1storder_mask.nc 
     181ncrename --history -v OceFrac,OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc 
     182 
     183ncks --alphabetize --history --append  -v OceMask dia_t${oce}_to_t${atm}_1storder_mask.nc   ${ATM}_grid_maskFrom_${OCE}.nc 
    184184 
    185185 
     
    263263    if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then 
    264264        mv ${InFile} tmp_${InFile} 
    265         ncks --fl_fmt=${FL_FMT} -h  tmp_${InFile}  ${InFile} 
     265        ncks --alphabetize --fl_fmt=${FL_FMT} --history  tmp_${InFile}  ${InFile} 
    266266    fi 
    267267done 
     
    277277OceMask [time_counter,cell] = OceMask (:) ; 
    278278EOF 
    279     ncap2 -O -h -S add_time.nco   ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    280     ncks -O --mk_rec time_counter ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    281     ncatted -h \ 
     279    ncap2 -O --history --script-file add_time.nco   ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
     280    ncks --alphabetize -O --mk_rec time_counter ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
     281    ncatted --history \ 
    282282            -a coordinates,OceFrac,c,c,"time_counter cell" \ 
    283283            -a coordinates,OceMask,c,c,"time_counter cell" \ 
     
    290290OceMask [time_counter,lat,lon] = OceMask (:,:) ; 
    291291EOF 
    292     ncap2 -O -h -S add_time.nco   ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    293     ncks -O --mk_rec time_counter ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    294     ncatted -h \ 
     292    ncap2 -O --history --script-file add_time.nco   ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
     293    ncks --alphabetize -O --mk_rec time_counter ${ATM}_grid_maskFrom_${OCE}.nc tmp_${ATM}_grid_maskFrom_${OCE}.nc ; mv tmp_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc 
     294    ncatted --history \ 
    295295            -a coordinates,OceFrac,c,c,"time_counter lat lon" \ 
    296296            -a coordinates,OceMask,c,c,"time_counter lat lon" \ 
     
    306306PYTHON_VER=$( python -i -c "import sys ; print (sys.version.split(' ')[0])" ) 
    307307for InFile in *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ; do 
    308     ncatted -h \ 
     308    ncatted --history \ 
    309309            --attribute uuid,global,d,,                                           \ 
    310310            --attribute LongName,global,d,,                                       \ 
     
    354354for file in rmp_*${oce}_to_*${atm}_*.nc rmp_*${atm}_to_*${oce}_*.nc ; do 
    355355    mv ${file} xios_${file} 
    356     ncap2 --fl_fmt=${FL_FMT} -h --script-file add_dim.nco xios_${file} ${file} 
     356    ncap2 --fl_fmt=${FL_FMT} --history --script-file add_dim.nco xios_${file} ${file} 
    357357     
    358     ncrename -h --dimension n_weight,num_links   ${file} 
    359     ncrename -h --variable  src_idx,src_address  ${file} 
    360     ncrename -h --variable  dst_idx,dst_address  ${file} 
    361     ncrename -h --variable  weight,remap_matrix  ${file} 
     358    ncrename --history --dimension n_weight,num_links   ${file} 
     359    ncrename --history --variable  src_idx,src_address  ${file} 
     360    ncrename --history --variable  dst_idx,dst_address  ${file} 
     361    ncrename --history --variable  weight,remap_matrix  ${file} 
    362362    case ${file} in 
    363         ( *1storder.nc ) ncatted -h --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  ${file} ;; 
    364         ( *2ndorder.nc ) ncatted -h --attribute map_method,global,o,c,"Conservative Remapping - 2nd order"  ${file} ;; 
     363        ( *1storder.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  ${file} ;; 
     364        ( *2ndorder.nc ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 2nd order"  ${file} ;; 
    365365    esac 
    366     ncatted -h --attribute conventions,global,o,c,"SCRIP"   ${file} 
    367     ncatted -h --attribute normalization,global,o,c,"none"  ${file} 
     366    ncatted --history --attribute conventions,global,o,c,"SCRIP"   ${file} 
     367    ncatted --history --attribute normalization,global,o,c,"none"  ${file} 
    368368     
    369369    case ${file} in 
    370370        ( rmp_*${oce}_to_t${atm}_* ) 
    371         ncatted -h \ 
     371        ncatted --history \ 
    372372                --attribute title,global,o,c,"Weights ${OCE} to ${ATM}" \ 
    373373                --attribute source_grid,global,o,c,"${oce_domain_type}" \ 
     
    376376        ;; 
    377377        ( rmp_*${atm}_to_*${oce}_* ) 
    378         ncatted -h \ 
     378        ncatted --history \ 
    379379                --attribute title,global,o,c,"Weights ${ATM} to ${OCE}" \ 
    380380                --attribute source_grid,global,o,c,"${atm_domain_type}" \ 
     
    383383        ;; 
    384384    esac 
     385done 
     386 
     387## 
     388## Add missing variables in rmp files 
     389## =========================================================================== 
     390for OGRID in ${ListOCEGRID} ; do 
     391    for order in ${Listorder} ; do 
     392        ogrid=${OGRID~} 
     393        agrid=t 
     394         
     395        file_o_to_a=rmp_${ogrid}${oce}_to_${agrid}${atm}_${order}order.nc 
     396        file_a_to_o=rmp_${agrid}${atm}_to_${ogrid}${oce}_${order}order.nc 
     397         
     398        cat <<EOF >add_varoce.nco 
     399defdim ("src_grid_size"   , \$x_grid_${OGRID}.size*\$y_grid_${OGRID}.size) ; 
     400defdim ("src_grid_corners", 4) ; 
     401defdim ("src_grid_rank"   , 2) ; 
     402// 
     403src_grid_dims[src_grid_rank] = { \$y_grid_${OGRID}.size, \$x_grid_${OGRID}.size } ; 
     404// 
     405src_grid_center_lat [src_grid_size] =  0.0d ; 
     406src_grid_center_lon [src_grid_size] =  0.0d ; 
     407src_grid_center_lat (:) = nav_lat_grid_${OGRID}(:,:)   ; 
     408src_grid_center_lon (:) = nav_lon_grid_${OGRID}(:,:)   ; 
     409// 
     410src_grid_corner_lat [src_grid_size, src_grid_corners] = 0.0d ; 
     411src_grid_corner_lon [src_grid_size, src_grid_corners] = 0.0d ; 
     412src_grid_corner_lat(:,:) = bounds_lat_grid_${OGRID}(:,:,:) ; 
     413src_grid_corner_lon(:,:) = bounds_lon_grid_${OGRID}(:,:,:) ; 
     414// 
     415src_grid_imask [src_grid_size] =    0 ; 
     416src_grid_area  [src_grid_size] = 0.0d ; 
     417src_grid_frac  [src_grid_size] = 1.0d ; 
     418src_grid_imask (:) = 1 - mask_${OGRID}(:,:) ; 
     419src_grid_imask.int() ; 
     420src_grid_area  (:) = area_grid_${OGRID}(:,:) ; 
     421EOF 
     422 
     423        ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${file_o_to_a} 
     424        sed --in-place "s/src_/dst_/g" add_varoce.nco 
     425        ncap2 --history --append --script-file add_varoce.nco oce_grid.nc ${file_a_to_o} 
     426 
     427        if [[ ${atm} = ico ]] ; then 
     428            cat <<EOF >add_varatm.nco 
     429defdim ("dst_grid_size"   , \$cell.size) ; 
     430defdim ("dst_grid_corners", 6) ; 
     431defdim ("dst_grid_rank"   , 2) ; 
     432// 
     433dst_grid_dims[dst_grid_rank] = { \$cell.size, 1 } ; 
     434// 
     435dst_grid_center_lat [dst_grid_size] =  0.0d ; 
     436dst_grid_center_lon [dst_grid_size] =  0.0d ; 
     437dst_grid_center_lat (:) = lat(:)   ; 
     438dst_grid_center_lon (:) = lon(:)   ; 
     439// 
     440dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ; 
     441dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ; 
     442dst_grid_corner_lat(:,:) = bounds_lat(:,:) ; 
     443dst_grid_corner_lon(:,:) = bounds_lon(:,:) ; 
     444// 
     445dst_grid_imask [dst_grid_size] =    0 ; 
     446dst_grid_area  [dst_grid_size] = 0.0d ; 
     447dst_grid_frac  [dst_grid_size] = 1.0d ; 
     448dst_grid_imask (:) = 1 - OceMask(0,:) ; 
     449dst_grid_imask.int() ; 
     450dst_grid_area  (:) = aire(:) ; 
     451EOF 
     452            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_o_to_a} 
     453            sed --in-place "s/dst_/src_/g" add_varatm.nco 
     454            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_a_to_o} 
     455             
     456            ncks --alphabetize --history --overwrite  -v src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${file_o_to_a} rmp_tmp.nc 
     457            mv rmp_tmp.nc ${file_o_to_a} 
     458            ncks --alphabetize --history --overwrite  -v src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${file_a_to_o} rmp_tmp.nc 
     459            mv rmp_tmp.nc ${file_a_to_o} 
     460 
     461        fi 
     462        if [[ ${atm} = lmd ]] ; then 
     463            cat <<EOF >add_varatm.nco 
     464defdim ("dst_grid_size"   , \$lon.size*\$lat.size) ; 
     465defdim ("dst_grid_corners", 4) ; 
     466defdim ("dst_grid_rank"   , 2) ; 
     467// 
     468dst_grid_dims[dst_grid_rank] = { \$lat.size, \$lon.size } ; 
     469// 
     470dst_grid_center_lat [dst_grid_size] =  0.0d ; 
     471dst_grid_center_lon [dst_grid_size] =  0.0d ; 
     472lat0lon[lat,lon] = lat(:)+0*lon(:) ;  
     473lon0lat[lat,lon] = lon(:)+0*lat(:) ; 
     474dst_grid_center_lat (:) = lat0lon(:,:)   ; 
     475dst_grid_center_lon (:) = lon0lat(:,:)   ; 
     476// 
     477//dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ; // Not available for LMDZ lon/lat grid 
     478//dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ; 
     479//dst_grid_corner_lat(:,:) = bounds_lat(:,:) ; 
     480//dst_grid_corner_lon(:,:) = bounds_lon(:,:) ; 
     481// 
     482dst_grid_imask [dst_grid_size] =    0 ; 
     483dst_grid_area  [dst_grid_size] = 0.0d ; 
     484dst_grid_frac  [dst_grid_size] = 1.0d ; 
     485dst_grid_imask (:) = 1 - OceMask(0,:,:) ; 
     486dst_grid_imask.int() ; 
     487dst_grid_area  (:) = aire(:,:) ; 
     488dst_grid_frac (:)  = OceFrac(0,:,:) ; 
     489EOF 
     490            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_o_to_a} 
     491            sed --in-place "s/dst/src/g" add_varatm.nco 
     492            ncap2 --history --append --script-file add_varatm.nco ${ATM}_grid_maskFrom_${OCE}.nc ${file_a_to_o} 
     493 
     494            ncks --alphabetize --history --overwrite  -v src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_corner_lon,src_grid_corner_lat,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_area,dst_grid_imask ${file_o_to_a} rmp_tmp.nc 
     495            mv rmp_tmp.nc ${file_o_to_a} 
     496            ncks --alphabetize --history --overwrite  -v src_address,dst_address,remap_matrix,src_grid_dims,src_grid_center_lat,src_grid_center_lon,src_grid_area,src_grid_imask,dst_grid_dims,dst_grid_center_lat,dst_grid_center_lon,dst_grid_corner_lon,dst_grid_corner_lat,dst_grid_area,dst_grid_imask ${file_a_to_o} rmp_tmp.nc 
     497            mv rmp_tmp.nc ${file_a_to_o} 
     498 
     499        fi 
     500    done 
    385501done 
    386502 
Note: See TracChangeset for help on using the changeset viewer.