[3620] | 1 | #!/bin/bash |
---|
| 2 | ### =========================================================================== |
---|
| 3 | ### |
---|
| 4 | ### Creates grids.nc, masks.nc and areas.nc for OASIS-MCT |
---|
| 5 | ### |
---|
| 6 | ### =========================================================================== |
---|
| 7 | ## |
---|
| 8 | ## Warning, to install, configure, run, use any of Olivier Marti's |
---|
| 9 | ## software or to read the associated documentation you'll need at least |
---|
| 10 | ## one (1) brain in a reasonably working order. Lack of this implement |
---|
| 11 | ## will void any warranties (either express or implied). |
---|
| 12 | ## O. Marti assumes no responsability for errors, omissions, |
---|
| 13 | ## data loss, or any other consequences caused directly or indirectly by |
---|
| 14 | ## the usage of his software by incorrectly or partially configured |
---|
| 15 | ## personal. |
---|
| 16 | ## |
---|
[3627] | 17 | ### |
---|
| 18 | ### Documentation : https://forge.ipsl.jussieu.fr/igcmg/wiki/IPSLCM6/MOSAIX |
---|
| 19 | ### |
---|
[3623] | 20 | ## SVN information |
---|
[3665] | 21 | # $Author$ |
---|
| 22 | # $Date$ |
---|
| 23 | # $Revision$ |
---|
| 24 | # $Id$ |
---|
[3633] | 25 | # $HeadURL$ |
---|
[3620] | 26 | |
---|
[4172] | 27 | set +vx |
---|
| 28 | |
---|
| 29 | echo ${Titre}"Starting CreateOasisGrids.bash"${Norm} |
---|
| 30 | |
---|
[3620] | 31 | ## |
---|
[4172] | 32 | echo ${Titre}"Default configuration (may be overrided by command line parameters)"${Norm} |
---|
[3620] | 33 | ## =========================================================================== |
---|
| 34 | OCE=ORCA2.3 |
---|
| 35 | # OCE=eORCA1.2 |
---|
| 36 | ATM=ICO30 |
---|
| 37 | #ATM=ICO40 |
---|
[4172] | 38 | #ATM=ICO450 |
---|
| 39 | #ATM=LMD144142 |
---|
| 40 | #ATM=LMD9695 |
---|
[3620] | 41 | |
---|
| 42 | ## =========================================================================== |
---|
| 43 | ## |
---|
| 44 | ## You should not change anything below this line .... |
---|
| 45 | ## |
---|
| 46 | ## =========================================================================== |
---|
| 47 | |
---|
[4172] | 48 | echo ${Titre}"Defines computer"${Norm} |
---|
[3620] | 49 | # ================ |
---|
[3901] | 50 | if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi |
---|
| 51 | if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi |
---|
| 52 | if [[ $(hostname) = lsce3005* ]] ; then arch=spip ; center=spip ; fi |
---|
| 53 | |
---|
[3620] | 54 | PROGRAM=$(basename ${0}) |
---|
| 55 | |
---|
| 56 | case ${arch} in |
---|
| 57 | ( curie | irene ) |
---|
| 58 | set +vx |
---|
| 59 | module unload cdo nco ferret |
---|
| 60 | module unload netcdf hdf5 |
---|
| 61 | module load python # /2.7.12 |
---|
| 62 | module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS |
---|
| 63 | module load nco |
---|
| 64 | R_IN=$(ccc_home -u igcmg --cccwork)/IGCM |
---|
| 65 | TMPDIR=${SCRATCHDIR}/TMP |
---|
| 66 | SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} |
---|
| 67 | ;; |
---|
[3901] | 68 | ( spip ) |
---|
| 69 | R_IN=${HOME}/Scratch/IGCM |
---|
| 70 | TMPDIR=${HOME}/Scratch/TMP |
---|
| 71 | SUBMIT_DIR=$(pwd) |
---|
| 72 | MPIRUN=/opt/local/bin/mpirun-openmpi-gcc49 -n 2 |
---|
| 73 | ;; |
---|
| 74 | ( * ) exit -1 ;; |
---|
[3620] | 75 | esac |
---|
[3901] | 76 | |
---|
[3620] | 77 | ## |
---|
[4172] | 78 | echo ${Titre}"Command line parameters"${Norm} |
---|
[3620] | 79 | ## =========================================================================== |
---|
[3686] | 80 | set -e |
---|
[3620] | 81 | set -o verbose |
---|
| 82 | set -o xtrace |
---|
| 83 | |
---|
| 84 | while [[ ${1} = -* ]] ; do |
---|
| 85 | case ${1} in |
---|
| 86 | ( -- ) shift ; break ;; |
---|
| 87 | ( -o=* | --oce=* ) OCE=${1##*=} ; echo OCE:${OCE} ;; |
---|
| 88 | ( -o | --oce ) shift ; OCE=${1} ; echo OCE:${OCE} ;; |
---|
| 89 | ( -a=* | --atm=* ) ATM=${1##*=} ; echo ATM:${ATM} ;; |
---|
| 90 | ( -a | --atm ) shift ; ATM=${1} ; echo ATM:${ATM} ;; |
---|
| 91 | ( -v | --verbose ) set -o verbose ;; |
---|
| 92 | ( -x | --xtrace ) set -o xtrace ;; |
---|
| 93 | ( -e ) set -e ;; |
---|
| 94 | ( -V | --noverbose ) set +o verbose ;; |
---|
| 95 | ( -X | --noxtrace ) set +o xtrace ;; |
---|
| 96 | ( -E ) set +e ;; |
---|
| 97 | ( -* ) echo ${Bold}"Unknown option : ${1}"${Norm} ; return 1 ;; |
---|
| 98 | esac |
---|
| 99 | shift |
---|
| 100 | done |
---|
| 101 | |
---|
| 102 | ## |
---|
[4172] | 103 | echo ${Titre}"Short names (grid names in Oasis)"${Norm} |
---|
[3620] | 104 | ## =========================================================================== |
---|
| 105 | case ${OCE} in |
---|
| 106 | ( *ORC*) oce=orc ;; |
---|
| 107 | esac |
---|
| 108 | case ${ATM} in |
---|
| 109 | ( *ICO* ) atm=ico ;; |
---|
| 110 | ( *dynamico* ) atm=ico ;; |
---|
| 111 | ( *lmd* | *LMD* ) atm=lmd ;; |
---|
| 112 | esac |
---|
| 113 | |
---|
| 114 | CplModel=${OCE}x${ATM} |
---|
| 115 | |
---|
| 116 | ## |
---|
[4172] | 117 | echo ${Titre}"Get input files"${Norm} |
---|
[3620] | 118 | ## =========================================================================== |
---|
| 119 | [[ -f ${OCE}_coordinates_mask.nc ]] || cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc . |
---|
[3686] | 120 | [[ -f ${ATM}_grid.nc ]] || cp ${R_IN}/ATM/GRID/${ATM}_grid.nc . |
---|
[3620] | 121 | |
---|
| 122 | # |
---|
[4172] | 123 | echo ${Titre}"Format for OASIS-MCT files : should be NetCDF3 classic or NetCDF3 64 bits"${Norm} |
---|
[3620] | 124 | # --------------------------------------------------------------------------- |
---|
[3901] | 125 | FL_FMT3=64bit |
---|
[3620] | 126 | |
---|
| 127 | # |
---|
[4172] | 128 | echo ${Titre}"Cleaning"${Norm} |
---|
[3620] | 129 | # ---------------------------------------------------------------------------- |
---|
| 130 | rm -f grids_${CplModel}.nc masks_${CplModel}.nc areas_${CplModel}.nc |
---|
| 131 | rm -f *_tmp.nc |
---|
| 132 | |
---|
| 133 | # |
---|
[4172] | 134 | echo ${Titre}"Creates NetCDF3 version of input files"${Norm} |
---|
[3620] | 135 | # ---------------------------------------------------------------------------- |
---|
[3901] | 136 | ncks --overwrite --fl_fmt=${FL_FMT} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FL_FMT3}.nc |
---|
| 137 | ncks --overwrite --fl_fmt=${FL_FMT} --history ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc |
---|
| 138 | |
---|
| 139 | |
---|
[3620] | 140 | # |
---|
[4172] | 141 | echo ${Titre}"Creates ocean fields"${Norm} |
---|
[3620] | 142 | # ---------------------------------------------------------------------------- |
---|
[3913] | 143 | for OCEGRID in T U V ; do |
---|
[3901] | 144 | 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 |
---|
| 145 | ncks --fl_fmt=${FL_FMT3} -C --history --append --variable area_grid_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc areas_${CplModel}.nc |
---|
[3620] | 146 | # Inverts mask values and switch to integer |
---|
[3901] | 147 | ncks --fl_fmt=${FL_FMT33} --history -C --variable mask_${OCEGRID} ${OCE}_coordinates_mask_${FL_FMT3}.nc mask_${OCEGRID}_tmp.nc |
---|
[3620] | 148 | ncatted --history \ |
---|
| 149 | --attribute coordinates,mask_${OCEGRID},d,, \ |
---|
| 150 | --attribute online_operation,mask_${OCEGRID},d,, \ |
---|
| 151 | --attribute cell_measures,mask_${OCEGRID},d,, \ |
---|
| 152 | mask_${OCEGRID}_tmp.nc |
---|
| 153 | |
---|
[3901] | 154 | ncap2 --fl_fmt=${FL_FMT3} --history --append --script "mask_${OCEGRID}=int(1-mask_${OCEGRID});" mask_${OCEGRID}_tmp.nc masks_${CplModel}.nc |
---|
| 155 | rm mask_${OCEGRID}_tmp.nc |
---|
[3620] | 156 | ncatted --history \ |
---|
| 157 | --attribute long_name,mask_${OCEGRID},o,c,"Land-sea mask" \ |
---|
| 158 | --attribute units,mask_${OCEGRID},o,c,"Land:1, Ocean:0" masks_${CplModel}.nc |
---|
| 159 | # Change order of dimensions |
---|
| 160 | mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc |
---|
| 161 | ncpdq --permute nvertex_grid_${OCEGRID},y_grid_${OCEGRID},x_grid_${OCEGRID} grids_${CplModel}_tmp.nc grids_${CplModel}.nc |
---|
[3901] | 162 | rm grids_${CplModel}_tmp.nc |
---|
[3620] | 163 | done |
---|
| 164 | |
---|
[3901] | 165 | ncks --history --append --variable lon,lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc grids_${CplModel}.nc |
---|
| 166 | |
---|
[3620] | 167 | # |
---|
[4172] | 168 | echo ${Titre}"We need to have different names for dimensions and variables"${Norm} |
---|
[3620] | 169 | # ---------------------------------------------------------------------------- |
---|
[3686] | 170 | ncrename --history --variable lon,alon grids_${CplModel}.nc |
---|
| 171 | ncrename --history --variable lat,alat grids_${CplModel}.nc |
---|
[3620] | 172 | |
---|
| 173 | if [[ ${ATM} = dynamico* || ${ATM} = ICO* ]] ; then |
---|
[3901] | 174 | ncks --fl_fmt=${FL_FMT3} --history --append --variable bounds_lon,bounds_lat ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc grids_${CplModel}.nc |
---|
[3620] | 175 | fi |
---|
| 176 | |
---|
[3901] | 177 | ncks --fl_fmt=${FL_FMT3} --history -C --append --variable aire ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc areas_${CplModel}.nc |
---|
[3620] | 178 | ncatted --history --attribute coordinates,aire,d,, \ |
---|
| 179 | --attribute _FillValue,aire,d,, \ |
---|
| 180 | --attribute missing_value,aire,d,, \ |
---|
| 181 | --attribute online_operation,aire,d,, \ |
---|
| 182 | --attribute units,aire,o,c,"m2" \ |
---|
| 183 | --attribute standard_name,aire,o,c,"cell_area" \ |
---|
| 184 | areas_${CplModel}.nc |
---|
| 185 | |
---|
[3901] | 186 | ncks --fl_fmt=${FL_FMT3} --history -C --variable OceMask ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc OceMask_tmp.nc |
---|
[3620] | 187 | ncatted --history \ |
---|
| 188 | --attribute coordinates,OceMask,d,, \ |
---|
| 189 | --attribute online_operation,OceMask,d,, \ |
---|
| 190 | --attribute _FillValue,OceMask,d,, \ |
---|
| 191 | --attribute missing_value,OceMask,d,, \ |
---|
| 192 | OceMask_tmp.nc |
---|
[3901] | 193 | ncap2 --fl_fmt=${FL_FMT3} --history --append --script "OceMask=int(1-OceMask)" OceMask_tmp.nc masks_${CplModel}.nc # For OASIS, ocean=0, land=1 |
---|
| 194 | rm OceMask_tmp.nc |
---|
[3620] | 195 | ncatted --history \ |
---|
| 196 | --attribute long_name,OceMask,o,c,"Land-sea mask" \ |
---|
| 197 | --attribute units,OceMask,o,c,"Land:1, Ocean:0" masks_${CplModel}.nc |
---|
| 198 | |
---|
| 199 | ncatted --history --attribute history,global,d,, grids_${CplModel}.nc |
---|
| 200 | ncatted --history --attribute history,global,d,, masks_${CplModel}.nc |
---|
| 201 | ncatted --history --attribute history,global,d,, areas_${CplModel}.nc |
---|
| 202 | |
---|
| 203 | if [[ ${atm} = *dynamico* || ${atm} = ico* ]] ; then |
---|
[3686] | 204 | ncrename --history --dimension cell,ycell grids_${CplModel}.nc |
---|
| 205 | ncrename --history --dimension cell,ycell areas_${CplModel}.nc |
---|
| 206 | ncrename --history --dimension cell,ycell masks_${CplModel}.nc |
---|
[3620] | 207 | fi |
---|
| 208 | # if [[ ${atm} = *lmd* ]] ; then |
---|
[3686] | 209 | # ncrename --dimension lon,tlmdlon grids_${CplModel}.nc |
---|
| 210 | # ncrename --dimension lat,tlmdlat grids_${CplModel}.nc |
---|
| 211 | # ncrename --dimension lon,tlmdlon masks_${CplModel}.nc |
---|
| 212 | # ncrename --dimension lat,tlmdlat masks_${CplModel}.nc |
---|
| 213 | # ncrename --dimension lon,tlmdlon areas_${CplModel}.nc |
---|
| 214 | # ncrename --dimension lat,tlmdlat areas_${CplModel}.nc |
---|
[3620] | 215 | # fi |
---|
| 216 | |
---|
| 217 | # |
---|
[4172] | 218 | echo ${Titre}"DYNAMICO grids : 1) Set correct order of dimensions, 2) Add a dimension"${Norm} |
---|
[3620] | 219 | # ---------------------------------------------------------------------------- |
---|
| 220 | if [[ ${atm} = dynamico* || ${atm} = ico* ]] ; then |
---|
| 221 | mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc |
---|
| 222 | ncpdq --permute nvertex,ycell,xcell grids_${CplModel}_tmp.nc grids_${CplModel}.nc |
---|
| 223 | |
---|
| 224 | mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc |
---|
| 225 | cat <<EOF >add_dim.nco |
---|
| 226 | // |
---|
| 227 | defdim("xcell",1) ; |
---|
| 228 | alat [ycell,xcell] = alat ; |
---|
| 229 | alon [ycell,xcell] = alon ; |
---|
| 230 | bounds_lat [nvertex,ycell,xcell] = bounds_lat ; |
---|
| 231 | bounds_lon [nvertex,ycell,xcell] = bounds_lon ; |
---|
| 232 | // |
---|
| 233 | EOF |
---|
| 234 | |
---|
[3901] | 235 | ncap2 --fl_fmt=${FL_FMT3} --history --append --script-file add_dim.nco grids_${CplModel}_tmp.nc grids_${CplModel}.nc |
---|
[3620] | 236 | |
---|
| 237 | mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc |
---|
[3901] | 238 | ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; OceMask[time_counter,ycell,xcell]=OceMask(:,:)' masks_${CplModel}_tmp.nc masks_${CplModel}.nc |
---|
[3620] | 239 | |
---|
| 240 | mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc |
---|
[3901] | 241 | ncap2 --fl_fmt=${FL_FMT3} --history --append --script 'defdim("xcell",1) ; aire[ycell,xcell]=aire(:) ; ' areas_${CplModel}_tmp.nc areas_${CplModel}.nc |
---|
| 242 | |
---|
| 243 | rm -f grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc masks_${CplModel}_tmp.nc |
---|
[3620] | 244 | fi |
---|
| 245 | |
---|
| 246 | # |
---|
[4172] | 247 | echo ${Titre}"Some changes specific to LMDZ lon/lat grid"${Norm} |
---|
[3620] | 248 | # ---------------------------------------------------------------------------- |
---|
| 249 | if [[ ${atm} = lmd* ]] ; then |
---|
[4172] | 250 | echo ${Titre}"Spreads lon and lat to get 2D fields"${Norm} |
---|
[3620] | 251 | # ----------------------------------------------------------------------- |
---|
| 252 | mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc |
---|
[3901] | 253 | ncap2 --fl_fmt=${FL_FMT3} --history --append --script "alon[lat,lon]=alon; alat[lat,lon]=alat" grids_${CplModel}_tmp.nc grids_${CplModel}.nc |
---|
| 254 | rm -f grids_${CplModel}_tmp.nc |
---|
[3620] | 255 | ncatted --history \ |
---|
| 256 | --attribute long_name,alon,o,c,"Longitude" \ |
---|
| 257 | --attribute long_name,alat,o,c,"Latitude" \ |
---|
| 258 | --attribute units,alon,o,c,"degrees_east" \ |
---|
| 259 | --attribute units,alat,o,c,"degrees_north" \ |
---|
| 260 | --attribute grid_type,alon,o,c,"P" \ |
---|
| 261 | --attribute grid_type,alat,o,c,"P" \ |
---|
| 262 | --attribute overlap,alon,o,i,0 \ |
---|
| 263 | --attribute overlap,alat,o,i,0 grids_${CplModel}.nc |
---|
| 264 | |
---|
[4172] | 265 | echo ${Titre}"Generates cell corners"${Norm} |
---|
[3620] | 266 | # ----------------------------------------------------------------------- |
---|
| 267 | cat <<EOF > add_bounds.nco |
---|
| 268 | defdim ("nvertex_lmd", 4) ; |
---|
| 269 | *delta_x = alon(0,1) - alon(0,0) ; |
---|
| 270 | *delta_y = alat(1,0) - alat(0,0) ; |
---|
| 271 | // |
---|
| 272 | bounds_lon[nvertex_lmd,lat,lon] = 0.0 ; |
---|
| 273 | bounds_lat[nvertex_lmd,lat,lon] = 0.0 ; |
---|
| 274 | // |
---|
| 275 | bounds_lon (0,:,:) = alon + delta_x*0.5 ; |
---|
| 276 | bounds_lat (0,:,:) = alat + delta_y*0.5 ; |
---|
| 277 | bounds_lon (1,:,:) = alon + delta_x*0.5 ; |
---|
| 278 | bounds_lat (1,:,:) = alat - delta_y*0.5 ; |
---|
| 279 | bounds_lon (2,:,:) = alon - delta_x*0.5 ; |
---|
| 280 | bounds_lat (2,:,:) = alat - delta_y*0.5 ; |
---|
| 281 | bounds_lon (3,:,:) = alon - delta_x*0.5 ; |
---|
| 282 | bounds_lat (3,:,:) = alat + delta_y*0.5 ; |
---|
| 283 | // |
---|
| 284 | where (bounds_lat > 90.0 ) bounds_lat = 90.0 ;; |
---|
| 285 | where (bounds_lat < -90.0 ) bounds_lat = -90.0 ;; |
---|
| 286 | // |
---|
| 287 | EOF |
---|
| 288 | mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc |
---|
[3901] | 289 | ncap2 --fl_fmt=${FL_FMT3} --history --script-file add_bounds.nco -O grids_${CplModel}_tmp.nc grids_${CplModel}.nc |
---|
| 290 | rm grids_${CplModel}_tmp.nc |
---|
[3620] | 291 | fi |
---|
| 292 | |
---|
| 293 | # |
---|
[4172] | 294 | echo ${Titre}"Generates grid o${atm}, 'o' meaning 'one'"${Norm} |
---|
| 295 | # same as t${atm} grid, with surfaces set to 1 |
---|
[3686] | 296 | # and mask to 0 (ocean everywhere, to compute integral over the whole grid)) |
---|
[3620] | 297 | # This grid is used when field are quantities instead of fluxes (i.e river flow) |
---|
| 298 | # ---------------------------------------------------------------------------- |
---|
| 299 | mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc |
---|
[3901] | 300 | 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 |
---|
[3620] | 301 | |
---|
| 302 | mv areas_${CplModel}.nc areas_${CplModel}_tmp.nc |
---|
[3901] | 303 | ncap2 --fl_fmt=${FL_FMT3} --history --script "o${atm}_aire=aire*0.0d+1.0d; " areas_${CplModel}_tmp.nc areas_${CplModel}.nc |
---|
[3620] | 304 | |
---|
| 305 | mv masks_${CplModel}.nc masks_${CplModel}_tmp.nc |
---|
[3901] | 306 | ncap2 --fl_fmt=${FL_FMT3} --history --script "o${atm}_mask=int(OceMask)*0+0; " masks_${CplModel}_tmp.nc masks_${CplModel}.nc |
---|
[3620] | 307 | |
---|
[3901] | 308 | rm grids_${CplModel}_tmp.nc areas_${CplModel}_tmp.nc masks_${CplModel}_tmp.nc |
---|
| 309 | |
---|
[3620] | 310 | # |
---|
[4172] | 311 | echo ${Titre}"Final renaming"${Norm} |
---|
[3620] | 312 | # ---------------------------------------------------------------------------- |
---|
[3913] | 313 | for OCEGRID in T U V |
---|
[3620] | 314 | do |
---|
| 315 | ocegrid=${OCEGRID~} # To lowercase |
---|
[3686] | 316 | ncrename --history --variable nav_lon_grid_${OCEGRID},${ocegrid}${oce}.lon grids_${CplModel}.nc |
---|
| 317 | ncrename --history --variable nav_lat_grid_${OCEGRID},${ocegrid}${oce}.lat grids_${CplModel}.nc |
---|
| 318 | ncrename --history --variable bounds_lon_grid_${OCEGRID},${ocegrid}${oce}.clo grids_${CplModel}.nc |
---|
| 319 | ncrename --history --variable bounds_lat_grid_${OCEGRID},${ocegrid}${oce}.cla grids_${CplModel}.nc |
---|
| 320 | ncrename --history --variable mask_${OCEGRID},${ocegrid}${oce}.msk masks_${CplModel}.nc |
---|
| 321 | ncrename --history --variable area_grid_${OCEGRID},${ocegrid}${oce}.srf areas_${CplModel}.nc |
---|
[3620] | 322 | |
---|
| 323 | ncatted --history \ |
---|
| 324 | --attribute bounds,${ocegrid}${oce}.lon,m,c,"${ocegrid}${oce}.clo" \ |
---|
| 325 | --attribute bounds,${ocegrid}${oce}.lat,m,c,"${ocegrid}${oce}.cla" \ |
---|
| 326 | --attribute units,${ocegrid}${oce}.clo,o,c,"degrees_east" \ |
---|
| 327 | --attribute units,${ocegrid}${oce}.clo,o,c,"degrees_north" grids_${CplModel}.nc |
---|
| 328 | done |
---|
| 329 | |
---|
[3686] | 330 | ncrename --history --variable alon,t${atm}.lon grids_${CplModel}.nc |
---|
| 331 | ncrename --history --variable alat,t${atm}.lat grids_${CplModel}.nc |
---|
| 332 | ncrename --history --variable o${atm}_lon,o${atm}.lon grids_${CplModel}.nc |
---|
| 333 | ncrename --history --variable o${atm}_lat,o${atm}.lat grids_${CplModel}.nc |
---|
| 334 | ncrename --history --variable OceMask,t${atm}.msk masks_${CplModel}.nc |
---|
| 335 | ncrename --history --variable o${atm}_mask,o${atm}.msk masks_${CplModel}.nc |
---|
| 336 | ncrename --history --variable aire,t${atm}.srf areas_${CplModel}.nc |
---|
| 337 | ncrename --history --variable o${atm}_aire,o${atm}.srf areas_${CplModel}.nc |
---|
[3620] | 338 | |
---|
[3686] | 339 | ncrename --history --variable bounds_lon,t${atm}.clo grids_${CplModel}.nc |
---|
| 340 | ncrename --history --variable bounds_lat,t${atm}.cla grids_${CplModel}.nc |
---|
| 341 | ncrename --history --variable bounds_o${atm}_lon,o${atm}.clo grids_${CplModel}.nc |
---|
| 342 | ncrename --history --variable bounds_o${atm}_lat,o${atm}.cla grids_${CplModel}.nc |
---|
[3620] | 343 | |
---|
| 344 | for atmgrid in t o ; do |
---|
| 345 | ncatted --history \ |
---|
| 346 | --attribute bounds,${atmgrid}${atm}.lon,c,c,"${atmgrid}${atm}.clo" \ |
---|
| 347 | --attribute bounds,${atmgrid}${atm}.lat,c,c,"${atmgrid}${atm}.cla" \ |
---|
[3686] | 348 | --attribute units,${atmgrid}${atm}.clo,o,c,"degrees_east" \ |
---|
[3620] | 349 | --attribute units,${atmgrid}${atm}.cla,o,c,"degrees_north" grids_${CplModel}.nc |
---|
| 350 | done |
---|
| 351 | |
---|
| 352 | ## |
---|
[4172] | 353 | echo ${Titre}"Change all NetCDF files to NetCDF 3 format"${Norm} |
---|
[3620] | 354 | ## =========================================================================== |
---|
| 355 | for InFile in areas_${CplModel}.nc grids_${CplModel}.nc masks_${CplModel}.nc ; do |
---|
| 356 | if [[ $(ncdump -k ${InFile}) = *netCDF-4* ]] ; then |
---|
| 357 | mv ${InFile} tmp_${InFile} |
---|
[3901] | 358 | ncks --fl_fmt=${FL_FMT3} --history tmp_${InFile} ${InFile} |
---|
| 359 | rm tmp_${InFile} |
---|
[3620] | 360 | fi |
---|
| 361 | done |
---|
| 362 | |
---|
| 363 | ## |
---|
[4172] | 364 | echo ${Titre}"Add some useful information in NetCDF headers"${Norm} |
---|
[3620] | 365 | ## =========================================================================== |
---|
| 366 | UUID=$(uuid) |
---|
| 367 | NCO=$(ncks --version |& tail -1|sed 's/ncks //') |
---|
| 368 | for type in areas masks grids ; do |
---|
| 369 | ncatted --history \ |
---|
| 370 | --attribute nco_openmp_thread_number,global,d,, \ |
---|
| 371 | --attribute uuid,global,d,, \ |
---|
| 372 | --attribute LongName,global,d,, \ |
---|
| 373 | --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \ |
---|
| 374 | --attribute Conventions,global,o,c,"CF-1.6" \ |
---|
| 375 | --attribute source,global,o,c,"IPSL Earth system model" \ |
---|
| 376 | --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center" \ |
---|
| 377 | --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}') " \ |
---|
| 378 | --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr" \ |
---|
| 379 | --attribute Ocean,global,o,c,"${OCE} https://www.nemo-ocean.eu" \ |
---|
| 380 | --attribute Atmosphere,global,o,c,"${ATM} http://lmdz.lmd.jussieu.fr" \ |
---|
| 381 | --attribute HOSTNAME,global,o,c,"$(hostname)" \ |
---|
| 382 | --attribute LOGNAME,global,o,c,"$(whoami)" \ |
---|
| 383 | --attribute Program,global,o,c,"Generated by ${0}" \ |
---|
[3718] | 384 | --attribute name,global,o,c,"${type}_${CplModel}.nc" \ |
---|
[3620] | 385 | --attribute directory,global,o,c,"$(pwd)" \ |
---|
| 386 | --attribute description,global,o,c,"Fields needed by OASIS-MCT" \ |
---|
[3718] | 387 | --attribute title,global,o,c,"${type}_${CplModel}.nc" \ |
---|
[3620] | 388 | --attribute timeStamp,global,o,c,"$(date)" \ |
---|
| 389 | --attribute associatedFiles,global,o,c,"grids_${CplModel}.nc areas_${CplModel}.nc masks_${CplModel}.nc" \ |
---|
| 390 | --attribute originalFiles,global,o,c,"${OCE}_coordinates_mask.nc ${ATM}_grid_mask.nc"\ |
---|
| 391 | --attribute uuid,global,o,c,"${UUID}" \ |
---|
| 392 | --attribute OS,global,o,c,"$(uname -o)" \ |
---|
| 393 | --attribute release,global,o,c,"$(uname -r)" \ |
---|
| 394 | --attribute hardware,global,o,c,"$(uname -i)" \ |
---|
[3718] | 395 | --attribute SVN_Author,global,o,c,"$Author$" \ |
---|
| 396 | --attribute SVN_Date,global,o,c,"$Date$" \ |
---|
[3665] | 397 | --attribute SVN_Revision,global,o,c,"$Revision$" \ |
---|
[3718] | 398 | --attribute SVN_Id,global,o,c,"$Id$" \ |
---|
| 399 | --attribute SVN_HeardURL,global,o,c,"$HeadURL $" \ |
---|
[3620] | 400 | ${type}_${CplModel}.nc |
---|
| 401 | done |
---|
| 402 | |
---|
| 403 | |
---|
| 404 | exit |
---|
| 405 | # |
---|
[4172] | 406 | echo ${Titre}"Name of the dimensions ?"${Norm} |
---|
[3620] | 407 | # ---------------------------------------------------------------------------- |
---|
[3913] | 408 | for OCEGRID in T U V ; do |
---|
[3620] | 409 | ocegrid=${OCEGRID~} # Downcase name of grids |
---|
[3686] | 410 | ncrename --history --dimension x_grid_${OCEGRID},x${ocegrid}${oce} grids_${CplModel}.nc |
---|
| 411 | ncrename --history --dimension y_grid_${OCEGRID},y${ocegrid}${oce} grids_${CplModel}.nc |
---|
| 412 | ncrename --history --dimension nvertex_grid_${OCEGRID},crn${ocegrid}${oce} grids_${CplModel}.nc |
---|
[3620] | 413 | done |
---|
| 414 | |
---|
| 415 | ## =========================================================================== |
---|
[4172] | 416 | echo ${Titre}"exit from CreateOasisGrids "${Norm} |
---|
| 417 | |
---|
| 418 | ## =========================================================================== |
---|
[3620] | 419 | ## |
---|
[4172] | 420 | echo ${Titre}" That's all folk's !!! "${Norm} |
---|
[3620] | 421 | ## |
---|
| 422 | ## =========================================================================== |
---|