Changeset 3686 for TOOLS/MOSAIX/CreateOasisGrids.bash
- Timestamp:
- 03/23/18 10:55:23 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/MOSAIX/CreateOasisGrids.bash
r3665 r3686 67 67 ## Command line parameters 68 68 ## =========================================================================== 69 set -e 69 70 set -o verbose 70 71 set -o xtrace … … 106 107 ## =========================================================================== 107 108 [[ -f ${OCE}_coordinates_mask.nc ]] || cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc . 108 [[ -f ${ATM}_grid.nc ]] || cp ${R_IN}/ATM/ ${ATM}/${ATM}_grid.nc .109 [[ -f ${ATM}_grid.nc ]] || cp ${R_IN}/ATM/GRID/${ATM}_grid.nc . 109 110 110 111 # … … 129 130 130 131 for OCEGRID in T U V ; do 131 ncks --fl_fmt=${FL_FMT} -C --history --append - vnav_lon_grid_${OCEGRID},nav_lat_grid_${OCEGRID},bounds_lon_grid_${OCEGRID},bounds_lat_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc grids_${CplModel}.nc132 ncks --fl_fmt=${FL_FMT} -C --history --append - varea_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc areas_${CplModel}.nc132 ncks --fl_fmt=${FL_FMT} -C --history --append --variable nav_lon_grid_${OCEGRID},nav_lat_grid_${OCEGRID},bounds_lon_grid_${OCEGRID},bounds_lat_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc grids_${CplModel}.nc 133 ncks --fl_fmt=${FL_FMT} -C --history --append --variable area_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc areas_${CplModel}.nc 133 134 # Inverts mask values and switch to integer 134 ncks --fl_fmt=${FL_FMT} --history -C - vmask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc mask_${OCEGRID}_tmp.nc135 ncks --fl_fmt=${FL_FMT} --history -C --variable mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc mask_${OCEGRID}_tmp.nc 135 136 ncatted --history \ 136 137 --attribute coordinates,mask_${OCEGRID},d,, \ … … 139 140 mask_${OCEGRID}_tmp.nc 140 141 141 ncap2 --fl_fmt=${FL_FMT} --history --append - s"mask_${OCEGRID}=int(1-mask_${OCEGRID});" mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc142 ncap2 --fl_fmt=${FL_FMT} --history --append --script "mask_${OCEGRID}=int(1-mask_${OCEGRID});" mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc 142 143 ncatted --history \ 143 144 --attribute long_name,mask_${OCEGRID},o,c,"Land-sea mask" \ … … 148 149 done 149 150 150 ncks --history --append - vlon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc151 ncks --history --append --variable lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc 151 152 152 153 # 153 154 # We need to have different names for dimensions and variables 154 155 # ---------------------------------------------------------------------------- 155 ncrename --history - vlon,alon grids_${CplModel}.nc156 ncrename --history - vlat,alat grids_${CplModel}.nc156 ncrename --history --variable lon,alon grids_${CplModel}.nc 157 ncrename --history --variable lat,alat grids_${CplModel}.nc 157 158 158 159 if [[ ${ATM} = dynamico* || ${ATM} = ICO* ]] ; then 159 ncks --fl_fmt=${FL_FMT} --history --append - vbounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc160 ncks --fl_fmt=${FL_FMT} --history --append --variable bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc 160 161 fi 161 162 162 ncks --fl_fmt=${FL_FMT} --history -C --append - vaire ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc areas_${CplModel}.nc163 ncks --fl_fmt=${FL_FMT} --history -C --append --variable aire ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc areas_${CplModel}.nc 163 164 ncatted --history --attribute coordinates,aire,d,, \ 164 165 --attribute _FillValue,aire,d,, \ … … 169 170 areas_${CplModel}.nc 170 171 171 ncks --fl_fmt=${FL_FMT} --history -C - vOceMask ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc OceMask_tmp.nc172 ncks --fl_fmt=${FL_FMT} --history -C --variable OceMask ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc OceMask_tmp.nc 172 173 ncatted --history \ 173 174 --attribute coordinates,OceMask,d,, \ … … 176 177 --attribute missing_value,OceMask,d,, \ 177 178 OceMask_tmp.nc 178 ncap2 --fl_fmt=${FL_FMT} --history --append - s"OceMask=int(1-OceMask)" OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1179 ncap2 --fl_fmt=${FL_FMT} --history --append --script "OceMask=int(1-OceMask)" OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 179 180 ncatted --history \ 180 181 --attribute long_name,OceMask,o,c,"Land-sea mask" \ … … 186 187 187 188 if [[ ${atm} = *dynamico* || ${atm} = ico* ]] ; then 188 ncrename --history - dcell,ycell grids_${CplModel}.nc189 ncrename --history - dcell,ycell areas_${CplModel}.nc190 ncrename --history - dcell,ycell masks_${CplModel}.nc189 ncrename --history --dimension cell,ycell grids_${CplModel}.nc 190 ncrename --history --dimension cell,ycell areas_${CplModel}.nc 191 ncrename --history --dimension cell,ycell masks_${CplModel}.nc 191 192 fi 192 193 # if [[ ${atm} = *lmd* ]] ; then 193 # ncrename - dlon,tlmdlon grids_${CplModel}.nc194 # ncrename - dlat,tlmdlat grids_${CplModel}.nc195 # ncrename - dlon,tlmdlon masks_${CplModel}.nc196 # ncrename - dlat,tlmdlat masks_${CplModel}.nc197 # ncrename - dlon,tlmdlon areas_${CplModel}.nc198 # ncrename - dlat,tlmdlat areas_${CplModel}.nc194 # ncrename --dimension lon,tlmdlon grids_${CplModel}.nc 195 # ncrename --dimension lat,tlmdlat grids_${CplModel}.nc 196 # ncrename --dimension lon,tlmdlon masks_${CplModel}.nc 197 # ncrename --dimension lat,tlmdlat masks_${CplModel}.nc 198 # ncrename --dimension lon,tlmdlon areas_${CplModel}.nc 199 # ncrename --dimension lat,tlmdlat areas_${CplModel}.nc 199 200 # fi 200 201 … … 219 220 EOF 220 221 221 ncap2 --fl_fmt=${FL_FMT} --history --append - Sadd_dim.nco grids_${CplModel}_tmp.nc grids_${CplModel}.nc222 ncap2 --fl_fmt=${FL_FMT} --history --append --script-file add_dim.nco grids_${CplModel}_tmp.nc grids_${CplModel}.nc 222 223 223 224 mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 224 ncap2 --fl_fmt=${FL_FMT} --history --append - s'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)' masks_${CplModel}_tmp.nc masks_${CplModel}.nc225 ncap2 --fl_fmt=${FL_FMT} --history --append --script 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)' masks_${CplModel}_tmp.nc masks_${CplModel}.nc 225 226 226 227 mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 227 ncap2 --fl_fmt=${FL_FMT} --history --append - s'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; ' areas_${CplModel}_tmp.nc areas_${CplModel}.nc228 ncap2 --fl_fmt=${FL_FMT} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; ' areas_${CplModel}_tmp.nc areas_${CplModel}.nc 228 229 fi 229 230 … … 235 236 # ----------------------------------------------------------------------- 236 237 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 237 ncap2 --fl_fmt=${FL_FMT} --history --append - s"alon[lat,lon]=alon; alat[lat,lon]=alat" grids_${CplModel}_tmp.nc grids_${CplModel}.nc238 ncap2 --fl_fmt=${FL_FMT} --history --append --script "alon[lat,lon]=alon; alat[lat,lon]=alat" grids_${CplModel}_tmp.nc grids_${CplModel}.nc 238 239 ncatted --history \ 239 240 --attribute long_name,alon,o,c,"Longitude" \ … … 270 271 EOF 271 272 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 272 ncap2 --fl_fmt=${FL_FMT} --history - Sadd_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc273 ncap2 --fl_fmt=${FL_FMT} --history --script-file add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc 273 274 fi 274 275 275 276 # 276 # Generates grid "aone" : same as t-ocean grid, with surfaces set to 1 277 # Generates grid "o${atm}e" : same as t${atm} grid, with surfaces set to 1 278 # and mask to 0 (ocean everywhere, to compute integral over the whole grid)) 277 279 # This grid is used when field are quantities instead of fluxes (i.e river flow) 278 280 # ---------------------------------------------------------------------------- 279 281 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 280 ncap2 --fl_fmt=${FL_FMT} --history - s "aone_lon=alon; aone_lat=alat; bounds_aone_lon=bounds_lon; bounds_aone_lat=bounds_lat; " grids_${CplModel}_tmp.nc grids_${CplModel}.nc282 ncap2 --fl_fmt=${FL_FMT} --history --script "o${atm}_lon=alon; o${atm}_lat=alat; bounds_o${atm}_lon=bounds_lon; bounds_o${atm}_lat=bounds_lat; " grids_${CplModel}_tmp.nc grids_${CplModel}.nc 281 283 282 284 mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 283 ncap2 --fl_fmt=${FL_FMT} --history - s "aone_aire=aire*0+1; "areas_${CplModel}_tmp.nc areas_${CplModel}.nc285 ncap2 --fl_fmt=${FL_FMT} --history --script "o${atm}_aire=aire*0.0d+1.0d; " areas_${CplModel}_tmp.nc areas_${CplModel}.nc 284 286 285 287 mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 286 ncap2 --fl_fmt=${FL_FMT} --history - s "aone_mask=int(OceMask); " masks_${CplModel}_tmp.nc masks_${CplModel}.nc288 ncap2 --fl_fmt=${FL_FMT} --history --script "o${atm}_mask=int(OceMask)*0+0; " masks_${CplModel}_tmp.nc masks_${CplModel}.nc 287 289 288 290 # … … 292 294 do 293 295 ocegrid=${OCEGRID~} # To lowercase 294 ncrename --history - vnav_lon_grid_${OCEGRID},${ocegrid}${oce}.lon grids_${CplModel}.nc295 ncrename --history - vnav_lat_grid_${OCEGRID},${ocegrid}${oce}.lat grids_${CplModel}.nc296 ncrename --history - vbounds_lon_grid_${OCEGRID},${ocegrid}${oce}.clo grids_${CplModel}.nc297 ncrename --history - vbounds_lat_grid_${OCEGRID},${ocegrid}${oce}.cla grids_${CplModel}.nc298 ncrename --history - vmask_${OCEGRID},${ocegrid}${oce}.msk masks_${CplModel}.nc299 ncrename --history - varea_grid_${OCEGRID},${ocegrid}${oce}.srf areas_${CplModel}.nc296 ncrename --history --variable nav_lon_grid_${OCEGRID},${ocegrid}${oce}.lon grids_${CplModel}.nc 297 ncrename --history --variable nav_lat_grid_${OCEGRID},${ocegrid}${oce}.lat grids_${CplModel}.nc 298 ncrename --history --variable bounds_lon_grid_${OCEGRID},${ocegrid}${oce}.clo grids_${CplModel}.nc 299 ncrename --history --variable bounds_lat_grid_${OCEGRID},${ocegrid}${oce}.cla grids_${CplModel}.nc 300 ncrename --history --variable mask_${OCEGRID},${ocegrid}${oce}.msk masks_${CplModel}.nc 301 ncrename --history --variable area_grid_${OCEGRID},${ocegrid}${oce}.srf areas_${CplModel}.nc 300 302 301 303 ncatted --history \ … … 306 308 done 307 309 308 ncrename --history - v alon,t${atm}.longrids_${CplModel}.nc309 ncrename --history - v alat,t${atm}.latgrids_${CplModel}.nc310 ncrename --history - v aone_lon,o${atm}.longrids_${CplModel}.nc311 ncrename --history - v aone_lat,o${atm}.latgrids_${CplModel}.nc312 ncrename --history - v OceMask,t${atm}.mskmasks_${CplModel}.nc313 ncrename --history - v aone_mask,o${atm}.mskmasks_${CplModel}.nc314 ncrename --history - v aire,t${atm}.srfareas_${CplModel}.nc315 ncrename --history - v aone_aire,o${atm}.srfareas_${CplModel}.nc316 317 ncrename --history - v bounds_lon,t${atm}.clogrids_${CplModel}.nc318 ncrename --history - v bounds_lat,t${atm}.clagrids_${CplModel}.nc319 ncrename --history - v bounds_aone_lon,o${atm}.clogrids_${CplModel}.nc320 ncrename --history - v bounds_aone_lat,o${atm}.clagrids_${CplModel}.nc310 ncrename --history --variable alon,t${atm}.lon grids_${CplModel}.nc 311 ncrename --history --variable alat,t${atm}.lat grids_${CplModel}.nc 312 ncrename --history --variable o${atm}_lon,o${atm}.lon grids_${CplModel}.nc 313 ncrename --history --variable o${atm}_lat,o${atm}.lat grids_${CplModel}.nc 314 ncrename --history --variable OceMask,t${atm}.msk masks_${CplModel}.nc 315 ncrename --history --variable o${atm}_mask,o${atm}.msk masks_${CplModel}.nc 316 ncrename --history --variable aire,t${atm}.srf areas_${CplModel}.nc 317 ncrename --history --variable o${atm}_aire,o${atm}.srf areas_${CplModel}.nc 318 319 ncrename --history --variable bounds_lon,t${atm}.clo grids_${CplModel}.nc 320 ncrename --history --variable bounds_lat,t${atm}.cla grids_${CplModel}.nc 321 ncrename --history --variable bounds_o${atm}_lon,o${atm}.clo grids_${CplModel}.nc 322 ncrename --history --variable bounds_o${atm}_lat,o${atm}.cla grids_${CplModel}.nc 321 323 322 324 for atmgrid in t o ; do … … 324 326 --attribute bounds,${atmgrid}${atm}.lon,c,c,"${atmgrid}${atm}.clo" \ 325 327 --attribute bounds,${atmgrid}${atm}.lat,c,c,"${atmgrid}${atm}.cla" \ 326 --attribute units,${atmgrid}${atm}.clo,o,c,"degrees_east" \328 --attribute units,${atmgrid}${atm}.clo,o,c,"degrees_east" \ 327 329 --attribute units,${atmgrid}${atm}.cla,o,c,"degrees_north" grids_${CplModel}.nc 328 330 done … … 389 391 for OCEGRID in T U V ; do 390 392 ocegrid=${OCEGRID~} # Downcase name of grids 391 ncrename --history - dx_grid_${OCEGRID},x${ocegrid}${oce} grids_${CplModel}.nc392 ncrename --history - dy_grid_${OCEGRID},y${ocegrid}${oce} grids_${CplModel}.nc393 ncrename --history - dnvertex_grid_${OCEGRID},crn${ocegrid}${oce} grids_${CplModel}.nc393 ncrename --history --dimension x_grid_${OCEGRID},x${ocegrid}${oce} grids_${CplModel}.nc 394 ncrename --history --dimension y_grid_${OCEGRID},y${ocegrid}${oce} grids_${CplModel}.nc 395 ncrename --history --dimension nvertex_grid_${OCEGRID},crn${ocegrid}${oce} grids_${CplModel}.nc 394 396 done 395 397
Note: See TracChangeset
for help on using the changeset viewer.