Changeset 3901 for TOOLS/MOSAIX/CreateOasisGrids.bash
- Timestamp:
- 06/07/18 15:59:11 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/MOSAIX/CreateOasisGrids.bash
r3718 r3901 44 44 # Defines computer 45 45 # ================ 46 if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi 47 if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi 46 if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi 47 if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi 48 if [[ $(hostname) = lsce3005* ]] ; then arch=spip ; center=spip ; fi 49 48 50 PROGRAM=$(basename ${0}) 49 51 … … 60 62 SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 61 63 ;; 62 ( * ) 63 exit -1 64 ;; 64 ( spip ) 65 R_IN=${HOME}/Scratch/IGCM 66 TMPDIR=${HOME}/Scratch/TMP 67 SUBMIT_DIR=$(pwd) 68 MPIRUN=/opt/local/bin/mpirun-openmpi-gcc49 -n 2 69 ;; 70 ( * ) exit -1 ;; 65 71 esac 72 66 73 ## 67 74 ## Command line parameters … … 112 119 # Format for OASIS-MCT files : should be NetCDF3 classic or NetCDF3 64 bits 113 120 # --------------------------------------------------------------------------- 114 FL_FMT =64bit121 FL_FMT3=64bit 115 122 116 123 # … … 123 130 # Creates NetCDF3 version of input files 124 131 # ---------------------------------------------------------------------------- 125 ncks --overwrite --fl_fmt=${FL_FMT} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FL_FMT}.nc 126 ncks --overwrite --fl_fmt=${FL_FMT} --history ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc 132 ncks --overwrite --fl_fmt=${FL_FMT} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FL_FMT3}.nc 133 ncks --overwrite --fl_fmt=${FL_FMT} --history ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc 134 135 127 136 # 128 137 # Creates ocean fields 129 138 # ---------------------------------------------------------------------------- 130 131 for OCEGRID in T U V ; do 132 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 139 for OCEGRID in T U V C ; do 140 ncks --fl_fmt=${FL_FMT3} -C --history --append --variable nav_lon_grid_${OCEGRID},nav_lat_grid_${OCEGRID},bounds_lon_grid_${OCEGRID},bounds_lat_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc grids_${CplModel}.nc 141 ncks --fl_fmt=${FL_FMT3} -C --history --append --variable area_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc areas_${CplModel}.nc 134 142 # Inverts mask values and switch to integer 135 ncks --fl_fmt=${FL_FMT } --history -C --variable mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT}.nc mask_${OCEGRID}_tmp.nc143 ncks --fl_fmt=${FL_FMT33} --history -C --variable mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc mask_${OCEGRID}_tmp.nc 136 144 ncatted --history \ 137 145 --attribute coordinates,mask_${OCEGRID},d,, \ … … 140 148 mask_${OCEGRID}_tmp.nc 141 149 142 ncap2 --fl_fmt=${FL_FMT} --history --append --script "mask_${OCEGRID}=int(1-mask_${OCEGRID});" mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc 150 ncap2 --fl_fmt=${FL_FMT3} --history --append --script "mask_${OCEGRID}=int(1-mask_${OCEGRID});" mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc 151 rm mask_${OCEGRID}_tmp.nc 143 152 ncatted --history \ 144 153 --attribute long_name,mask_${OCEGRID},o,c,"Land-sea mask" \ … … 147 156 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 148 157 ncpdq --permute nvertex_grid_${OCEGRID},y_grid_${OCEGRID},x_grid_${OCEGRID} grids_${CplModel}_tmp.nc grids_${CplModel}.nc 149 done 150 151 ncks --history --append --variable lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc 152 158 rm grids_${CplModel}_tmp.nc 159 done 160 161 ncks --history --append --variable lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc grids_${CplModel}.nc 162 153 163 # 154 164 # We need to have different names for dimensions and variables … … 158 168 159 169 if [[ ${ATM} = dynamico* || ${ATM} = ICO* ]] ; then 160 ncks --fl_fmt=${FL_FMT } --history --append --variable bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc grids_${CplModel}.nc170 ncks --fl_fmt=${FL_FMT3} --history --append --variable bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc grids_${CplModel}.nc 161 171 fi 162 172 163 ncks --fl_fmt=${FL_FMT } --history -C --append --variable aire ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc areas_${CplModel}.nc173 ncks --fl_fmt=${FL_FMT3} --history -C --append --variable aire ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc areas_${CplModel}.nc 164 174 ncatted --history --attribute coordinates,aire,d,, \ 165 175 --attribute _FillValue,aire,d,, \ … … 170 180 areas_${CplModel}.nc 171 181 172 ncks --fl_fmt=${FL_FMT } --history -C --variable OceMask ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc OceMask_tmp.nc182 ncks --fl_fmt=${FL_FMT3} --history -C --variable OceMask ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc OceMask_tmp.nc 173 183 ncatted --history \ 174 184 --attribute coordinates,OceMask,d,, \ … … 177 187 --attribute missing_value,OceMask,d,, \ 178 188 OceMask_tmp.nc 179 ncap2 --fl_fmt=${FL_FMT} --history --append --script "OceMask=int(1-OceMask)" OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 189 ncap2 --fl_fmt=${FL_FMT3} --history --append --script "OceMask=int(1-OceMask)" OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 190 rm OceMask_tmp.nc 180 191 ncatted --history \ 181 192 --attribute long_name,OceMask,o,c,"Land-sea mask" \ … … 220 231 EOF 221 232 222 ncap2 --fl_fmt=${FL_FMT } --history --append --script-file add_dim.nco grids_${CplModel}_tmp.nc grids_${CplModel}.nc233 ncap2 --fl_fmt=${FL_FMT3} --history --append --script-file add_dim.nco grids_${CplModel}_tmp.nc grids_${CplModel}.nc 223 234 224 235 mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 225 ncap2 --fl_fmt=${FL_FMT } --history --append --script 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)' masks_${CplModel}_tmp.nc masks_${CplModel}.nc236 ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)' masks_${CplModel}_tmp.nc masks_${CplModel}.nc 226 237 227 238 mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 228 ncap2 --fl_fmt=${FL_FMT} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; ' areas_${CplModel}_tmp.nc areas_${CplModel}.nc 239 ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; ' areas_${CplModel}_tmp.nc areas_${CplModel}.nc 240 241 rm -f grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc masks_${CplModel}_tmp.nc 229 242 fi 230 243 … … 236 249 # ----------------------------------------------------------------------- 237 250 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 238 ncap2 --fl_fmt=${FL_FMT} --history --append --script "alon[lat,lon]=alon; alat[lat,lon]=alat" grids_${CplModel}_tmp.nc grids_${CplModel}.nc 251 ncap2 --fl_fmt=${FL_FMT3} --history --append --script "alon[lat,lon]=alon; alat[lat,lon]=alat" grids_${CplModel}_tmp.nc grids_${CplModel}.nc 252 rm -f grids_${CplModel}_tmp.nc 239 253 ncatted --history \ 240 254 --attribute long_name,alon,o,c,"Longitude" \ … … 271 285 EOF 272 286 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 273 ncap2 --fl_fmt=${FL_FMT} --history --script-file add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc 287 ncap2 --fl_fmt=${FL_FMT3} --history --script-file add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc 288 rm grids_${CplModel}_tmp.nc 274 289 fi 275 290 276 291 # 277 # Generates grid "o${atm} e": same as t${atm} grid, with surfaces set to 1292 # Generates grid "o${atm}", "o" meaning "one": same as t${atm} grid, with surfaces set to 1 278 293 # and mask to 0 (ocean everywhere, to compute integral over the whole grid)) 279 294 # This grid is used when field are quantities instead of fluxes (i.e river flow) 280 295 # ---------------------------------------------------------------------------- 281 296 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc 282 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}.nc297 ncap2 --fl_fmt=${FL_FMT3} --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 283 298 284 299 mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc 285 ncap2 --fl_fmt=${FL_FMT } --history --script "o${atm}_aire=aire*0.0d+1.0d; " areas_${CplModel}_tmp.nc areas_${CplModel}.nc300 ncap2 --fl_fmt=${FL_FMT3} --history --script "o${atm}_aire=aire*0.0d+1.0d; " areas_${CplModel}_tmp.nc areas_${CplModel}.nc 286 301 287 302 mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc 288 ncap2 --fl_fmt=${FL_FMT} --history --script "o${atm}_mask=int(OceMask)*0+0; " masks_${CplModel}_tmp.nc masks_${CplModel}.nc 303 ncap2 --fl_fmt=${FL_FMT3} --history --script "o${atm}_mask=int(OceMask)*0+0; " masks_${CplModel}_tmp.nc masks_${CplModel}.nc 304 305 rm grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc masks_${CplModel}_tmp.nc 289 306 290 307 # 291 308 # Final renaming 292 309 # ---------------------------------------------------------------------------- 293 for OCEGRID in T U V 310 for OCEGRID in T U V C 294 311 do 295 312 ocegrid=${OCEGRID~} # To lowercase … … 336 353 if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then 337 354 mv ${InFile} tmp_${InFile} 338 ncks --fl_fmt=${FL_FMT} --history tmp_${InFile} ${InFile} 355 ncks --fl_fmt=${FL_FMT3} --history tmp_${InFile} ${InFile} 356 rm tmp_${InFile} 339 357 fi 340 358 done … … 384 402 ## Cleaning 385 403 ## =========================================================================== 386 #rm *_tmp.nc ${OCE}_coordinates_mask_${FL_FMT }.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT}.nc *.nco404 #rm *_tmp.nc ${OCE}_coordinates_mask_${FL_FMT3}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc *.nco 387 405 388 406 exit … … 390 408 # Name of the dimensions ? 391 409 # ---------------------------------------------------------------------------- 392 for OCEGRID in T U V ; do410 for OCEGRID in T U V C ; do 393 411 ocegrid=${OCEGRID~} # Downcase name of grids 394 412 ncrename --history --dimension x_grid_${OCEGRID},x${ocegrid}${oce} grids_${CplModel}.nc
Note: See TracChangeset
for help on using the changeset viewer.