[3620] | 1 | #!/bin/bash |
---|
[3719] | 2 | #MSUB -r WeightsMask # Job name |
---|
| 3 | #MSUB -o Out_WeightsMask # Standard output |
---|
| 4 | #MSUB -e Out_WeightsMask # Error output |
---|
[3620] | 5 | #MSUB -eo |
---|
[4159] | 6 | #MSUB -n 16 # Number of processors |
---|
[4186] | 7 | #MSUB -T 7200 # Time limit (seconds) |
---|
[3966] | 8 | #MSUB -q skylake |
---|
| 9 | #MSUB -p gen2212 |
---|
| 10 | #MSUB -m work |
---|
[3620] | 11 | |
---|
| 12 | ### =========================================================================== |
---|
| 13 | ### |
---|
[3719] | 14 | ### Creates interpolation weights between ORCA and atmosphere grids. |
---|
[3620] | 15 | ### Interpolates ORCA mask to atmosphere grid. |
---|
| 16 | ### Weight files are at OASIS-MCT format. |
---|
| 17 | ### |
---|
| 18 | ### Atmosphere grid may be lon/lat LMDZ or DYNAMICO icosahedron |
---|
[3627] | 19 | ### |
---|
| 20 | ### Documentation : https://forge.ipsl.jussieu.fr/igcmg/wiki/IPSLCM6/MOSAIX |
---|
[3620] | 21 | ### =========================================================================== |
---|
| 22 | ## |
---|
| 23 | ## Warning, to install, configure, run, use any of Olivier Marti's |
---|
| 24 | ## software or to read the associated documentation you'll need at least |
---|
| 25 | ## one (1) brain in a reasonably working order. Lack of this implement |
---|
| 26 | ## will void any warranties (either express or implied). |
---|
| 27 | ## O. Marti assumes no responsability for errors, omissions, |
---|
| 28 | ## data loss, or any other consequences caused directly or indirectly by |
---|
| 29 | ## the usage of his software by incorrectly or partially configured |
---|
| 30 | ## personal. |
---|
| 31 | ## |
---|
[3623] | 32 | ## SVN information |
---|
[3665] | 33 | # $Author$ |
---|
| 34 | # $Date$ |
---|
| 35 | # $Revision$ |
---|
| 36 | # $Id$ |
---|
[3632] | 37 | # $HeadURL$ |
---|
[4090] | 38 | # |
---|
[4298] | 39 | # export CplModel=eORCA1.2xLMD144142 ; qsub -r ${CplModel} -o Out_${CplModel} -e Out_${CplModel} CreateWeightsMask.bash |
---|
| 40 | # export CplModel=ORCA2.3xLMD9695 |
---|
| 41 | # export CplModel=ORCA2.3xICO30 |
---|
| 42 | # export CplModel=ORCA2.3xICO40 |
---|
| 43 | # export CplModel=eORCA1.2xICO40 |
---|
| 44 | # export CplModel=eORCA1.2xLMD256256 |
---|
| 45 | # export CplModel=eORCA1.2xICO450 |
---|
| 46 | # export CplModel=eORCA025.1xLMD256256 |
---|
[4195] | 47 | # |
---|
| 48 | |
---|
[4172] | 49 | set +vx |
---|
[3901] | 50 | export Bold=$(tput bold) |
---|
| 51 | export Unde=$(tput smul) ; export OffUnde=$(tput rmul) |
---|
| 52 | export Stou=$(tput smso) ; export OffStou=$(tput rmso) |
---|
| 53 | export Reve=$(tput rev ) |
---|
| 54 | couleurs=( "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" ) |
---|
[4259] | 55 | for i in $(seq 0 7) ; do eval "export ${couleurs[$i]}=$(tput setf ${i})" ; done |
---|
[4186] | 56 | export Norm=$(tput sgr0) |
---|
[4172] | 57 | export Titre=${Bold}${Blue} |
---|
[3620] | 58 | |
---|
| 59 | ## |
---|
| 60 | ## Configuration |
---|
| 61 | ## =========================================================================== |
---|
[4159] | 62 | set -e |
---|
[3620] | 63 | |
---|
| 64 | # |
---|
[4172] | 65 | echo ${Titre}"Defines models"${Norm} |
---|
[4199] | 66 | # ================================== |
---|
[4298] | 67 | OCE=ORCA2.3 |
---|
| 68 | #OCE=eORCA1.2 |
---|
| 69 | #OCE=eORCA025.1 |
---|
[3620] | 70 | |
---|
[4298] | 71 | ATM=ICO30 |
---|
[4195] | 72 | #ATM=ICO40 |
---|
[3620] | 73 | #ATM=ICO450 |
---|
[4186] | 74 | #ATM=LMD9695 |
---|
[4298] | 75 | #ATM=LMD144142 |
---|
[4172] | 76 | #ATM=LMD256256 |
---|
[3620] | 77 | |
---|
[4199] | 78 | |
---|
| 79 | Comment="Preliminary attempt - Do not trust !" |
---|
[4298] | 80 | Version="v2" |
---|
[4199] | 81 | |
---|
[4195] | 82 | CplModel=${OCE}x${ATM} |
---|
[4298] | 83 | # If available, get model names from job name |
---|
[4195] | 84 | if [[ X${SLURM_JOB_NAME} = X*ORC* || X${SLURM_JOB_NAME} = X*LMD* || X${SLURM_JOB_NAME} = X*ICO* ]] ; then |
---|
| 85 | CplModel=${SLURM_JOB_NAME} ; OCE=${CplModel//x*} ; ATM=${CplModel##*x} |
---|
| 86 | fi |
---|
| 87 | |
---|
[4186] | 88 | echo ${Titre}"ATM model : ${ATM}"${Norm} |
---|
| 89 | echo ${Titre}"OCE model : ${OCE}"${Norm} |
---|
[4195] | 90 | echo ${Titre}"Cpl model : ${CplModel}"${Norm} |
---|
[4172] | 91 | |
---|
[4186] | 92 | # Runoff parameter. atmCoastWidth and oceCoastWidth in grid points, searchRadius in km |
---|
| 93 | atmCoastWidth=2 ; oceCoastWidth=2 ; searchRadius=600.0 |
---|
[4298] | 94 | runOff_atmQuantity=Quantity ; runOff_oceQuantity=Surfacic |
---|
[4172] | 95 | |
---|
[4298] | 96 | [[ ${ATM} = ICO* ]] && atmCoastWidth=0 # Parameter relevant for LMD rectilinear grid only |
---|
| 97 | [[ ${ATM} = LMD* ]] && atmCoastWidth=2 |
---|
| 98 | [[ ${OCE} = ORCA2.3 ]] && oceCoastWidth=1 |
---|
| 99 | [[ ${OCE} = eORCA1.2 ]] && oceCoastWidth=3 |
---|
| 100 | [[ ${OCE} = eORCA025* ]] && oceCoastWidth=1 |
---|
[4186] | 101 | |
---|
| 102 | |
---|
[4153] | 103 | # Default values, used to create ocean fraction on atmospheric grid |
---|
[4186] | 104 | DefaultValues=( Direction=o2a,oceGrid=t,atmGrid=t,Order=1st,Quantity=false,Renormalize=false,useArea=false,maskSrc=true,maskDst=false,Name=OceFrac ) |
---|
[3620] | 105 | |
---|
[4172] | 106 | ## List of weights to build |
---|
| 107 | ## ==================================================================================================================================== |
---|
| 108 | # |
---|
| 109 | # Each item in CommandList describes the properties of interpolation weights to generate. |
---|
[4159] | 110 | # White spaces separate analysis. No spaces in any analysis. |
---|
| 111 | # |
---|
[4172] | 112 | # Specific commands : 'Runoff', 'Calving' |
---|
| 113 | # |
---|
[4159] | 114 | # Keywords : |
---|
[4298] | 115 | # Direction : o2a for ocean to atmosphere, a2o for atmosphere to ocean. |
---|
| 116 | # Order : 1st or 2nd. |
---|
[4159] | 117 | # Quantity : true if integrated quantity over a grid box, false for flux (quantity / m^2) |
---|
[4298] | 118 | # or intensive value (temperature, salinity, sea-ice fraction, ...). |
---|
| 119 | # Renormalize : used when source grid is masked, to use values on non masked points only. |
---|
| 120 | # oceGrid : t, u or v point for NEMO C grid. |
---|
| 121 | # atmGrid : up to know, only t grid used in the atmosphere. |
---|
| 122 | # useArea : if true area from the model metrics is used. If false, areas are computed by XIOS from grid corners. |
---|
| 123 | # maskSrc : true to use the source grid mask, false to used all grid points. |
---|
| 124 | # maskDst : true to use the destination grid mask, false to use all grid points. |
---|
[4159] | 125 | # |
---|
[4259] | 126 | ## Classic cases for IPSLCM6 |
---|
| 127 | AtmOceFluxes=" Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=HeatWaterFluxes" # Heat and water fluxes |
---|
| 128 | OceAtmTemp=" Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=TempIceAlb" # Temperature, sea-ice fraction, albedo |
---|
| 129 | OceAtmTemp2nd=" Direction=o2a,Order=2nd,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=TempIceAlb" # Temperature, sea-ice fraction, albedo |
---|
| 130 | AtmOceStressU=" Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true,Name=WindStress" # Wind stress to NEMO U point |
---|
| 131 | AtmOceStressV=" Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=v,useArea=true,maskSrc=true,maskDst=true,Name=WindStress" # Wind stress to NEMO V point |
---|
| 132 | AtmOceQuantity=" Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=t,oceGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=Quantity" # e.g. runoff |
---|
[4298] | 133 | # For new parameterization |
---|
| 134 | AtmOceTemp=" Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=OceTemp" # e.g. T and S correction from DWL parametrization |
---|
[4259] | 135 | OceAtmFluxes=" Direction=o2a,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=OceAtmFluxes" # e.g. CO2 fluxes |
---|
[4298] | 136 | # Test to do with 2nd order |
---|
| 137 | AtmOceFluxes2nd="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=HeatWaterFluxes" # Heat and water fluxes |
---|
[4259] | 138 | OceAtmFluxes2nd="Direction=o2a,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=OceAtmFluxes" # e.g. CO2 fluxes |
---|
| 139 | AtmOceTemps2nd=" Direction=o2a,Order=2nd,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=OceTemp" # e.g. T and S correction from DWL parametrization |
---|
[4159] | 140 | |
---|
[4259] | 141 | ## Creates the list |
---|
| 142 | |
---|
[4186] | 143 | # Standard list for IPSLCM6 |
---|
| 144 | #CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} Runoff Calving Grids ) |
---|
[4172] | 145 | |
---|
[4259] | 146 | # More comprehensive list for IPSLCM6 with new features |
---|
[4298] | 147 | CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} ${AtmOceTemp} Runoff Calving Grids ) |
---|
[4172] | 148 | |
---|
[4259] | 149 | # With 2nd order |
---|
[4298] | 150 | #CommandList=( ${AtmOceFluxes} ${AtmOceFluxes2nd} ${OceAtmTemp} ${OceAtmTemp2nd} ${AtmOceStressU} ${AtmOceStressV} ${OceAtmFluxes} ${OceAtmFluxes2nd} ${AtmOceTemp} ${AtmOceTemp2nd} Runoff Calving Grids ) |
---|
[4259] | 151 | |
---|
[4186] | 152 | # Debugs |
---|
| 153 | #CommandList=( ${AtmOceFluxes} ${OceAtmTemp} Runoff Calving Grids ) |
---|
[4199] | 154 | #CommandList=( ${AtmOceFluxes} Runoff Calving Grids ) |
---|
[4259] | 155 | #CommandList=( ${AtmOceFluxes} ) |
---|
| 156 | #CommandList=( Runoff ) |
---|
| 157 | #CommandList=( Runoff Calving Grids ) |
---|
[4186] | 158 | #CommandList=( Calving ) |
---|
| 159 | #CommandList=( Grids ) |
---|
[4172] | 160 | |
---|
[3620] | 161 | ## =========================================================================== |
---|
| 162 | ## |
---|
| 163 | ## You should not change anything below this line .... |
---|
| 164 | ## |
---|
| 165 | ## =========================================================================== |
---|
[4199] | 166 | Tag="MOSAIX" |
---|
[3620] | 167 | SUBMIT_DIR=$(pwd) |
---|
[4259] | 168 | FMT_XIOS=netcdf4 |
---|
[4159] | 169 | |
---|
| 170 | # Functions to handle command parameters |
---|
| 171 | # ====================================== |
---|
[4153] | 172 | function read_Command { |
---|
| 173 | # Decipher the command line to set bash variables |
---|
| 174 | local l_Debug="no" l_Element |
---|
| 175 | while [[ ${1} = -* ]] ; do |
---|
| 176 | case ${1} in |
---|
| 177 | ( -- ) shift ; break ;; |
---|
| 178 | ( -d | --debug ) l_Debug="true" ; shift ;; |
---|
| 179 | esac |
---|
| 180 | done |
---|
| 181 | local l_Command=${1} |
---|
[4159] | 182 | for l_Element in $(echo ${l_Command} | tr "," "\n" ) ; do |
---|
[4153] | 183 | [[ "X${l_Debug}" = "Xtrue" ]] && echo ${l_Element} |
---|
| 184 | eval export ${l_Element} |
---|
| 185 | done |
---|
| 186 | } |
---|
[3620] | 187 | |
---|
[4153] | 188 | function setValues { |
---|
| 189 | # |
---|
[4186] | 190 | read_Command "Direction=None,Order=None,Quantity=None,Renormalize=None,atmGrid=None,oceGrid=None,useArea=None,maskSrc=None,maskDst=None" |
---|
| 191 | read_Command ${1} |
---|
| 192 | # |
---|
[4159] | 193 | oceGrid=${oceGrid,,} ; atmGrid=${atmGrid,,} |
---|
| 194 | OCEGRID=${oceGrid^^} ; ATMGRID=${atmGrid^^} |
---|
[4153] | 195 | |
---|
| 196 | case ${Order} in |
---|
| 197 | ( 1st ) numOrder=1 ;; |
---|
| 198 | ( 2nd ) numOrder=2 ;; |
---|
| 199 | esac |
---|
| 200 | case ${Renormalize} in |
---|
| 201 | ( true ) NormName=Normalized ;; |
---|
| 202 | ( false ) NormName=UnNormalized ;; |
---|
| 203 | esac |
---|
| 204 | case ${Quantity} in |
---|
| 205 | ( true ) QuantName=Integrated ;; |
---|
| 206 | ( false ) QuantName=Surfacic ;; |
---|
| 207 | esac |
---|
| 208 | case ${useArea} in |
---|
| 209 | ( true ) AreaName=Area ;; |
---|
| 210 | ( false ) AreaName=NoArea ;; |
---|
| 211 | esac |
---|
| 212 | |
---|
[4186] | 213 | if [[ "${Name}" != "None" ]] ; then |
---|
[4259] | 214 | FullName=${Name}_${Order}Order |
---|
[4186] | 215 | else |
---|
[4199] | 216 | FullName=${Order}Order_${NormName}_${QuantName}_${AreaName} |
---|
[4186] | 217 | fi |
---|
| 218 | |
---|
[4153] | 219 | case ${Direction} in |
---|
| 220 | ( o2a ) |
---|
[4159] | 221 | src=${oce} ; SRC=${OCE} ; srcGrid=${oceGrid} ; srcDomainType=${oceDomainType} ; SRCGRID=${OCEGRID} ; srcArea=area_grid_${OCEGRID} |
---|
| 222 | dst=${atm} ; DST=${ATM} ; dstGrid=${atmGrid} ; dstDomainType=${atmDomainType} ; DSTGRID=${ATMGRID} ; dstArea=aire |
---|
[4153] | 223 | ;; |
---|
| 224 | ( a2o ) |
---|
[4159] | 225 | src=${atm} ; SRC=${ATM} ; srcGrid=${atmGrid} ; srcDomainType=${atmDomainType} ; SRCGRID=${ATMGRID} ; srcArea=aire |
---|
| 226 | dst=${oce} ; DST=${OCE} ; dstGrid=${oceGrid} ; dstDomainType=${oceDomainType} ; DSTGRID=${OCEGRID} ; dstArea=area_grid_${OCEGRID} |
---|
[4153] | 227 | ;; |
---|
| 228 | esac |
---|
[4186] | 229 | echo ${Green}"${SRC} ${SRCGRID} toward ${DST} ${DSTGRID} - ${Order} Order - Normalize: ${Renormalize} - Quantity: ${QuantName} - Area: ${AreaName} "${Norm} |
---|
[4199] | 230 | echo ${Green}"FullName : ${FullName}"${Norm} |
---|
[4153] | 231 | } |
---|
[4186] | 232 | |
---|
[3620] | 233 | # |
---|
| 234 | # Defines computer |
---|
| 235 | # ================ |
---|
[3901] | 236 | if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi |
---|
[4153] | 237 | if [[ $(hostname) = lsce* ]] ; then arch=spip ; center=spip ; fi |
---|
[3734] | 238 | |
---|
[3620] | 239 | PROGRAM=$(basename ${0}) |
---|
| 240 | |
---|
| 241 | case ${arch} in |
---|
[4153] | 242 | ( irene ) |
---|
[3620] | 243 | set +vx |
---|
[4259] | 244 | set +e |
---|
[3966] | 245 | R_IN=$(ccc_home -u igcmg --cccwork)/IGCM |
---|
| 246 | TMPDIR=${CCCWORKDIR}/TMP |
---|
| 247 | SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} |
---|
| 248 | PROGRAM=${BRIDGE_MSUB_REQNAME} |
---|
[4172] | 249 | MpiRun="time ccc_mprun" |
---|
[4195] | 250 | PyRun="time ccc_mprun -n 1" # Needed to force python to run on one process only |
---|
[4259] | 251 | #module purge |
---|
| 252 | source $(ccc_home -u igcmg)/MachineEnvironment/irene/env_irene |
---|
[4153] | 253 | source ${SUBMIT_DIR}/arch.env |
---|
[4259] | 254 | #module load nco |
---|
[4172] | 255 | module load python3 |
---|
[4153] | 256 | module load datadir/igcmg |
---|
[3966] | 257 | module list |
---|
[4259] | 258 | set -e |
---|
[3966] | 259 | ;; |
---|
[3734] | 260 | ( spip ) |
---|
| 261 | R_IN=${HOME}/Scratch/IGCM |
---|
| 262 | TMPDIR=${HOME}/Scratch/TMP |
---|
| 263 | SUBMIT_DIR=$(pwd) |
---|
[4172] | 264 | MpiRun="/opt/local/bin/mpirun -n 4" |
---|
| 265 | PyRun="time" |
---|
[3734] | 266 | ;; |
---|
[3901] | 267 | ( * ) exit -1 ;; |
---|
[3620] | 268 | esac |
---|
| 269 | |
---|
| 270 | set -x ; set -e |
---|
| 271 | |
---|
[4195] | 272 | mkdir -p ${TMPDIR}/${CplModel} || exit 1 |
---|
| 273 | cd ${TMPDIR}/${CplModel} || exit 1 |
---|
[4146] | 274 | rm -fr * |
---|
[3620] | 275 | |
---|
| 276 | # |
---|
| 277 | # Suffixes |
---|
| 278 | # --------------------------------------------------------------------------- |
---|
| 279 | |
---|
| 280 | case ${OCE} in |
---|
[4153] | 281 | ( *ORC* ) oce=orc ; oceDomainType=curvilinear ;; |
---|
[3620] | 282 | esac |
---|
[4159] | 283 | |
---|
[3620] | 284 | case ${ATM} in |
---|
[4153] | 285 | ( *dynamico* ) atm=ico ; atmDomainType=unstructured ;; |
---|
| 286 | ( *ICO* ) atm=ico ; atmDomainType=unstructured ;; |
---|
| 287 | ( *lmd* | *LMD* ) atm=lmd ; atmDomainType=rectilinear ;; |
---|
[3620] | 288 | esac |
---|
| 289 | |
---|
[4159] | 290 | case ${OCE} in # Periodicity type of ORCA grid |
---|
[4298] | 291 | ( ORCA2* ) OcePerio=4 ;; |
---|
[4172] | 292 | ( ORCA1* | eORCA1* ) OcePerio=6 ;; |
---|
[4298] | 293 | ( ORCA025* | eORCA025* ) OcePerio=6 ;; |
---|
[3723] | 294 | esac |
---|
[3620] | 295 | # |
---|
| 296 | |
---|
[4195] | 297 | cp ${SUBMIT_DIR}/bin/interpol.exe . |
---|
| 298 | cp ${SUBMIT_DIR}/*.py . |
---|
[4153] | 299 | cp ${SUBMIT_DIR}/iodef_atm_to_oce.xml . |
---|
| 300 | cp ${SUBMIT_DIR}/iodef_oce_to_atm.xml . |
---|
[3620] | 301 | |
---|
| 302 | cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc . |
---|
[3639] | 303 | cp ${R_IN}/ATM/GRID/${ATM}_grid.nc . |
---|
[3620] | 304 | |
---|
[3901] | 305 | # |
---|
[4186] | 306 | # echo ${Titre}"Creates OCEAN C grid : redundant points removed to compute proper integrals # A passer dans CreateWeights"${Norm} |
---|
| 307 | # # -------------------------------------------------------------------------------------------------------- |
---|
| 308 | # cat <<EOF >add_c_grid.nco |
---|
| 309 | # defdim("x_grid_C", \$x_grid_T.size) ; |
---|
| 310 | # defdim("y_grid_C", \$y_grid_T.size) ; |
---|
| 311 | # defdim("nvertex_grid_C", 4) ; |
---|
| 312 | # nav_lon_grid_C[y_grid_C,x_grid_C] = nav_lon_grid_T(:,:) ; |
---|
| 313 | # nav_lat_grid_C[y_grid_C,x_grid_C] = nav_lat_grid_T(:,:) ; |
---|
| 314 | # bounds_lon_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lon_grid_T(:,:,:) ; |
---|
| 315 | # bounds_lat_grid_C[y_grid_C,x_grid_C,nvertex_grid_C] = bounds_lat_grid_T(:,:,:) ; |
---|
| 316 | # mask_C[y_grid_C,x_grid_C] = maskutil_T(:,:) ; |
---|
| 317 | # area_grid_C[y_grid_C,x_grid_C] = area_grid_T(:,:) ; |
---|
| 318 | # EOF |
---|
[3620] | 319 | |
---|
[4186] | 320 | # ncap2 --overwrite --history --script-file add_c_grid.nco ${OCE}_coordinates_mask.nc tmp_${OCE}_coordinates_mask.nc |
---|
| 321 | # ncatted --history --attribute bounds,nav_lon_grid_C,m,c,"bounds_lon_grid_C" tmp_${OCE}_coordinates_mask.nc |
---|
| 322 | # ncatted --history --attribute bounds,nav_lat_grid_C,m,c,"bounds_lat_grid_C" tmp_${OCE}_coordinates_mask.nc |
---|
| 323 | # ncks --history --overwrite --variable nav_lon_grid_C,nav_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc |
---|
| 324 | # ncks --history --append --variable bounds_lon_grid_C,bounds_lat_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc |
---|
| 325 | # ncks --history --append --variable area_grid_C tmp_${OCE}_coordinates_mask.nc C_${OCE}_coordinates_mask.nc |
---|
[3912] | 326 | |
---|
[4186] | 327 | # ncks --history --append C_${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask.nc |
---|
| 328 | # rm C_${OCE}_coordinates_mask.nc |
---|
[3901] | 329 | |
---|
[4186] | 330 | # ls -al |
---|
[3901] | 331 | |
---|
| 332 | ## |
---|
[4172] | 333 | echo ${Titre}"NEMO T point towards ATM - 1st order"${Norm} |
---|
[3901] | 334 | ## =========================================================================== |
---|
[4153] | 335 | echo "Command parameters : ${Command}" |
---|
[4186] | 336 | setValues ${DefaultValues} |
---|
[3620] | 337 | |
---|
[4153] | 338 | cp iodef_oce_to_atm.xml iodef.xml |
---|
| 339 | |
---|
[4172] | 340 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v maskutil_T |
---|
| 341 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="area_src"]' -k name -v area_grid_T |
---|
| 342 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType} |
---|
| 343 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType} |
---|
| 344 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 |
---|
| 345 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity -v false |
---|
| 346 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false |
---|
| 347 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k use_area -v false |
---|
| 348 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name -v maskutil_T |
---|
| 349 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name -v area_grid_T |
---|
[4199] | 350 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]' -k name -v dia_${srcGrid}${src}_to_${dstGrid}${dst}_${FullName} |
---|
[4172] | 351 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]' -t "${SRC} mask interpolated to ${DST}" |
---|
| 352 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType} |
---|
| 353 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]' -t ${dstDomainType} |
---|
| 354 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t 1 |
---|
| 355 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType} |
---|
| 356 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType} |
---|
[4199] | 357 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_${srcGrid}${src}_to_${dstGrid}${dst}_${FullName}.nc |
---|
[4172] | 358 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 |
---|
| 359 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false |
---|
| 360 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]' -t false |
---|
| 361 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]' -t false |
---|
| 362 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false |
---|
| 363 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity -v false |
---|
| 364 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k use_area -v false |
---|
[3620] | 365 | |
---|
[4199] | 366 | cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${FullName}.xml |
---|
[3901] | 367 | ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
| 368 | ln -fs ${ATM}_grid.nc atm_grid.nc |
---|
[3620] | 369 | |
---|
[4172] | 370 | ${MpiRun} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} |
---|
| 371 | |
---|
[3620] | 372 | ## |
---|
[4172] | 373 | echo ${Titre}"Correct spurious values (extremes)"${Norm} |
---|
[3620] | 374 | ## =========================================================================== |
---|
| 375 | cat <<EOF > correction_masque.nco |
---|
| 376 | where (OceFrac < 0.00001 ) OceFrac=OceFrac.get_miss() ; |
---|
| 377 | where (OceFrac > 0.99999 ) OceFrac=1.0 ; |
---|
| 378 | OceFrac.delete_miss() ; |
---|
| 379 | // Fill masked values to land values |
---|
| 380 | where (OceFrac > 1.0 ) OceFrac=0.0 ; |
---|
| 381 | where (OceFrac < 0.0 ) OceFrac=0.0 ; |
---|
[4298] | 382 | OceMask = OceFrac ; |
---|
[3620] | 383 | EOF |
---|
[4199] | 384 | ncap2 --history --overwrite --script-file correction_masque.nco dia_t${oce}_to_t${atm}_${FullName}.nc tmp_dia_t${oce}_to_t${atm}_${FullName}.nc ; mv tmp_dia_t${oce}_to_t${atm}_${FullName}.nc dia_t${oce}_to_t${atm}_${FullName}.nc |
---|
| 385 | ncatted --history -a missing_value,OceFrac,d,,"" -a _FillValue,OceFrac,d,,"" dia_t${oce}_to_t${atm}_${FullName}.nc |
---|
[4298] | 386 | ncatted --history -a missing_value,OceMask,d,,"" -a _FillValue,OceMask,d,,"" dia_t${oce}_to_t${atm}_${FullName}.nc |
---|
| 387 | |
---|
[3620] | 388 | ## |
---|
[4298] | 389 | echo ${Titre}"Creates mask on ATM grid"${Norm} |
---|
[3620] | 390 | ## =========================================================================== |
---|
[4199] | 391 | cp dia_t${oce}_to_t${atm}_${FullName}.nc dia_t${oce}_to_t${atm}_${FullName}_mask.nc |
---|
[4298] | 392 | ncks --alphabetize --history --overwrite --variable OceFrac dia_t${oce}_to_t${atm}_${FullName}_mask.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[3620] | 393 | |
---|
| 394 | cat <<EOF > creation_masque.nco |
---|
[4298] | 395 | Oce2AtmMask = OceMask ; |
---|
| 396 | where (OceMask > 0.0 ) Oce2AtmMask=1 ; |
---|
| 397 | where (OceMask <= 0.0 ) Oce2AtmMask=0 ; |
---|
[3620] | 398 | EOF |
---|
[4081] | 399 | |
---|
[4298] | 400 | ncap2 --history --overwrite --script-file creation_masque.nco dia_t${oce}_to_t${atm}_${FullName}.nc tmp_dia_${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 401 | ncks --overwrite --history --variable OceMask,OceFrac,Oce2AtmMask tmp_dia_${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[3620] | 402 | |
---|
[4172] | 403 | echo "Change dimension names, and some attributes accordingly" |
---|
[4298] | 404 | ## =========================================================== |
---|
[4081] | 405 | if [[ $(ncdump -h ${ATM}_grid_maskFrom_${OCE}.nc | grep domain_dst | wc -l) -gt 0 ]] ; then |
---|
| 406 | case ${atm} in |
---|
| 407 | ( *ico* ) |
---|
[4088] | 408 | ncrename --history --dimension cell_domain_dst,cell ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 409 | ncrename --history --dimension nvertex_domain_dst,nvertex ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 410 | ncrename --history --variable lat_domain_dst,lat ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 411 | ncrename --history --variable lon_domain_dst,lon ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 412 | ncrename --history --variable bounds_lat_domain_dst,bounds_lat ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 413 | ncrename --history --variable bounds_lon_domain_dst,bounds_lon ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 414 | ncatted --history --attribute bounds,lat,m,c,"bounds_lat" ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 415 | ncatted --history --attribute bounds,lon,m,c,"bounds_lon" ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[4081] | 416 | ;; |
---|
| 417 | ( *lmd* ) |
---|
[4088] | 418 | ncrename --history --dimension lon_domain_dst,lon ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 419 | ncrename --history --dimension lat_domain_dst,lat ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[4081] | 420 | ;; |
---|
| 421 | esac |
---|
| 422 | ncatted --history --attribute coordinates,OceFrac,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 423 | ncatted --history --attribute coordinates,OceMask,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[4298] | 424 | ncatted --history --attribute coordinates,Oce2AtmMask,m,c,"lat lon" ${ATM}_grid_maskFrom_${OCE}.nc |
---|
[4088] | 425 | |
---|
[4081] | 426 | fi |
---|
| 427 | |
---|
| 428 | ncks --history --alphabetize --append --variable aire atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 429 | [[ ${atm} = *ico* ]] && ncks --alphabetize --history --append --variable bounds_lon,bounds_lat atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 430 | |
---|
[3620] | 431 | ## |
---|
[4298] | 432 | |
---|
| 433 | #cp ${ATM}_grid.nc ${ATM}_gridFromOce.nc |
---|
| 434 | |
---|
| 435 | |
---|
| 436 | ## |
---|
[4199] | 437 | #echo ${Titre}"Creates mask of coastal OCE points"${Norm} |
---|
[3901] | 438 | ## =========================================================================== |
---|
[4199] | 439 | #${PyRun} python3 -u ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal |
---|
[4172] | 440 | |
---|
[3901] | 441 | ## |
---|
[4199] | 442 | #echo ${Titre}"Creates mask of coastal ATM points"${Norm} |
---|
[3901] | 443 | ## =========================================================================== |
---|
[4199] | 444 | #cat <<EOF > coastal.nco |
---|
| 445 | #AtmCoastal = OceFrac * 0.0 ; |
---|
| 446 | #where (OceFrac > 0.0 && OceFrac < 1.0 ) AtmCoastal = 1.0 ; |
---|
| 447 | #EOF |
---|
| 448 | #ncap2 --history --overwrite --script-file coastal.nco ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_coastal_maskFrom_${OCE}.nc |
---|
| 449 | #ncks --history --append --variable AtmCoastal ${ATM}_coastal_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}.nc |
---|
| 450 | #rm ${ATM}_coastal_maskFrom_${OCE}.nc |
---|
[4081] | 451 | |
---|
[3901] | 452 | ## |
---|
[4172] | 453 | echo ${Titre}"Other weights files"${Norm} |
---|
[3718] | 454 | ## =========================================================================== |
---|
[4153] | 455 | # Loop on commands |
---|
| 456 | for Command in ${CommandList[@]} |
---|
| 457 | do |
---|
| 458 | echo "Command parameters : ${Command}" |
---|
[4186] | 459 | setValues ${Command} |
---|
[4172] | 460 | if [[ ${Command} = "Runoff" ]] ; then okRunoff=yes ; continue ; fi |
---|
| 461 | if [[ ${Command} = "Calving" ]] ; then okCalving=yes ; continue ; fi |
---|
[4186] | 462 | if [[ ${Command} = "Grids" ]] ; then okGrids=yes ; continue ; fi |
---|
[4172] | 463 | |
---|
[4153] | 464 | ln -fs ${OCE}_coordinates_mask.nc oce_grid.nc |
---|
[4298] | 465 | #ln -fs ${ATM}_grid.nc atm_grid.nc |
---|
| 466 | ln -fs ${ATM}_grid_maskFrom_${OCE}.nc atm_grid.nc |
---|
[4153] | 467 | |
---|
| 468 | case ${Direction} in |
---|
| 469 | ( o2a ) |
---|
| 470 | cp iodef_oce_to_atm.xml iodef.xml |
---|
[4082] | 471 | |
---|
[4172] | 472 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v mask_${DSTGRID} |
---|
[4298] | 473 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]' -k name -v Oce2AtmMask |
---|
[4082] | 474 | |
---|
[4172] | 475 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name -v maskutil_${SRCGRID} |
---|
| 476 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name -v area_grid_${SRCGRID} |
---|
[4298] | 477 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="mask_dest"]' -k name -v Oce2AtmMask |
---|
[4172] | 478 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="area_dest"]' -k name -v aire |
---|
[4153] | 479 | ;; |
---|
| 480 | ( a2o ) |
---|
| 481 | cp iodef_atm_to_oce.xml iodef.xml |
---|
[4082] | 482 | |
---|
[4298] | 483 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v Oce2AtmMask |
---|
[4172] | 484 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]' -k name -v mask_${DSTGRID} |
---|
[4082] | 485 | |
---|
[4298] | 486 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name -v Oce2AtmMask |
---|
[4172] | 487 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name -v aire |
---|
| 488 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="mask_dest"]' -k name -v mask_${DSTGRID} |
---|
| 489 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="area_dest"]' -k name -v area_grid_${DSTGRID} |
---|
[4153] | 490 | ;; |
---|
| 491 | esac |
---|
| 492 | |
---|
[4172] | 493 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType} |
---|
| 494 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType} |
---|
[4153] | 495 | |
---|
[4172] | 496 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType} |
---|
| 497 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType} |
---|
[4153] | 498 | |
---|
[4199] | 499 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_${srcGrid}${src}_to_${dstGrid}${dst}_${FullName}.nc |
---|
[4172] | 500 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v ${numOrder} |
---|
| 501 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity -v ${Quantity} |
---|
| 502 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v ${Renormalize} |
---|
| 503 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k use_area -v ${useArea} |
---|
[4153] | 504 | |
---|
[4199] | 505 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]' -k name -v dia_${srcGrid}${src}_to_${dstGrid}${dst}_${FullName} |
---|
[4172] | 506 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="title"]' -t "${SRC} mask interpolated to ${DST}" |
---|
| 507 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]' -t ${dstDomainType} |
---|
| 508 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType} |
---|
| 509 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${Renormalize} |
---|
| 510 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t ${numOrder} |
---|
| 511 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]' -t ${Quantity} |
---|
| 512 | python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]' -t ${useArea} |
---|
[4153] | 513 | |
---|
[4199] | 514 | cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${FullName}.xml |
---|
[4172] | 515 | ${MpiRun} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} |
---|
[3719] | 516 | done |
---|
[4153] | 517 | |
---|
[3620] | 518 | ## |
---|
[4172] | 519 | echo ${Titre}"Add some metadata in file headers"${Norm} |
---|
[3620] | 520 | ## =========================================================================== |
---|
| 521 | |
---|
| 522 | NCO="$(ncks --version |& tail -1|sed 's/ncks //')" |
---|
[4172] | 523 | PYTHON_VER=$( python3 -c "import sys ; print (sys.version.split(' ')[0])" ) |
---|
[4199] | 524 | for InFile in $(ls *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc 2> /dev/null) ; do |
---|
[3639] | 525 | ncatted --history \ |
---|
[3620] | 526 | --attribute LongName,global,d,, \ |
---|
| 527 | --attribute nco_openmp_thread_number,global,d,, \ |
---|
| 528 | --attribute Conventions,global,o,c,"CF-1.6" \ |
---|
| 529 | --attribute source,global,o,c,"IPSL Earth system model" \ |
---|
| 530 | --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center" \ |
---|
| 531 | --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr" \ |
---|
| 532 | --attribute Ocean,global,o,c,"${OCE} https://www.nemo-ocean.eu" \ |
---|
| 533 | --attribute Atmosphere,global,o,c,"${ATM} http://lmdz.lmd.jussieu.fr" \ |
---|
| 534 | --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}') " \ |
---|
| 535 | --attribute originalFiles,global,o,c,"${OCE}_coordinates_mask.nc ${ATM}_grid_mask.nc" \ |
---|
[4195] | 536 | --attribute associatedFiles,global,o,c,"grids_${CplModel}.nc areas_${CplModel}.nc masks_${CplModel}.nc" \ |
---|
[3620] | 537 | --attribute directory,global,o,c,"$(pwd)" \ |
---|
| 538 | --attribute description,global,o,c,"Fields needed by OASIS-MCT" \ |
---|
| 539 | --attribute title,global,o,c,"${InFile}.nc" \ |
---|
| 540 | --attribute Program,global,o,c,"Generated by ${PROGRAM}" \ |
---|
| 541 | --attribute timeStamp,global,o,c,"$(date)" \ |
---|
| 542 | --attribute HOSTNAME,global,o,c,"$(hostname)" \ |
---|
| 543 | --attribute LOGNAME,global,o,c,"$(whoami)" \ |
---|
| 544 | --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \ |
---|
[4172] | 545 | --attribute Python,global,o,c,"Python3 version ${PYTHON_VER}" \ |
---|
[3620] | 546 | --attribute OS,global,o,c,"$(uname -o)" \ |
---|
| 547 | --attribute release,global,o,c,"$(uname -r)" \ |
---|
| 548 | --attribute directory,global,o,c,"$(pwd)" \ |
---|
[3624] | 549 | --attribute description,global,o,c,"Generated with XIOS http://forge.ipsl.jussieu.fr/ioserver and MOSAIX https://forge.ipsl.jussieu.fr/igcmg/browser/TOOLS/MOSAIX" \ |
---|
[4090] | 550 | --attribute SVN_Author,global,o,c,'$Author$' \ |
---|
| 551 | --attribute SVN_Date,global,o,c,'$Date$' \ |
---|
| 552 | --attribute SVN_Revision,global,o,c,'$Revision$' \ |
---|
| 553 | --attribute SVN_Id,global,o,c,'$Id$' \ |
---|
[3620] | 554 | ${InFile} |
---|
| 555 | done |
---|
| 556 | ## |
---|
[4172] | 557 | echo ${Titre}"Update and complete weight files to fit OASIS requested format"${Norm} |
---|
[3620] | 558 | ## =========================================================================== |
---|
| 559 | cat <<EOF > add_dim.nco |
---|
| 560 | defdim("num_wgts",1) ; |
---|
| 561 | weight[n_weight, num_wgts] = weight ; |
---|
| 562 | EOF |
---|
| 563 | |
---|
[3719] | 564 | for rmpFile in rmp_*.nc ; do |
---|
[4199] | 565 | mv ${rmpFile} tmp_${rmpFile} |
---|
| 566 | ncap2 --history --script-file add_dim.nco tmp_${rmpFile} ${rmpFile} ; rm tmp_${rmpFile} |
---|
[3620] | 567 | |
---|
[3719] | 568 | ncrename --history --dimension n_weight,num_links ${rmpFile} |
---|
| 569 | ncrename --history --variable src_idx,src_address ${rmpFile} |
---|
| 570 | ncrename --history --variable dst_idx,dst_address ${rmpFile} |
---|
| 571 | ncrename --history --variable weight,remap_matrix ${rmpFile} |
---|
| 572 | case ${rmpFile} in |
---|
[4082] | 573 | ( *1storder* ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order" ${rmpFile} ;; |
---|
| 574 | ( *2ndorder* ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 2nd order" ${rmpFile} ;; |
---|
[3620] | 575 | esac |
---|
[3719] | 576 | case ${rmpFile} in |
---|
[4082] | 577 | ( *_Normalized* ) ncatted --history --attribute map_method,global,o,c,"Normalization: true" ${rmpFile} ;; |
---|
| 578 | ( *_UnNormalized* ) ncatted --history --attribute map_method,global,o,c,"Normalization: false" ${rmpFile} ;; |
---|
[3719] | 579 | esac |
---|
[4082] | 580 | case ${rmpFile} in |
---|
| 581 | ( *Integrated* ) ncatted --history --attribute map_method,global,o,c,"Quantity: true" ${rmpFile} ;; |
---|
| 582 | ( *Surfacic* ) ncatted --history --attribute map_method,global,o,c,"Quantity: false" ${rmpFile} ;; |
---|
| 583 | esac |
---|
[3719] | 584 | ncatted --history --attribute conventions,global,o,c,"SCRIP" ${rmpFile} |
---|
| 585 | ncatted --history --attribute normalization,global,o,c,"none" ${rmpFile} |
---|
[3620] | 586 | |
---|
[3719] | 587 | case ${rmpFile} in |
---|
[3620] | 588 | ( rmp_*${oce}_to_t${atm}_* ) |
---|
[3639] | 589 | ncatted --history \ |
---|
[3620] | 590 | --attribute title,global,o,c,"Weights ${OCE} to ${ATM}" \ |
---|
[4153] | 591 | --attribute source_grid,global,o,c,"${oceDomainType}" \ |
---|
| 592 | --attribute dest_grid,global,o,c,"${atmDomainType}" \ |
---|
[3719] | 593 | ${rmpFile} |
---|
[3620] | 594 | ;; |
---|
| 595 | ( rmp_*${atm}_to_*${oce}_* ) |
---|
[3639] | 596 | ncatted --history \ |
---|
[3620] | 597 | --attribute title,global,o,c,"Weights ${ATM} to ${OCE}" \ |
---|
[4153] | 598 | --attribute source_grid,global,o,c,"${atmDomainType}" \ |
---|
| 599 | --attribute dest_grid,global,o,c,"${oceDomainType}" \ |
---|
[3719] | 600 | ${rmpFile} |
---|
[3620] | 601 | ;; |
---|
| 602 | esac |
---|
| 603 | done |
---|
| 604 | |
---|
[4186] | 605 | ls |
---|
[3620] | 606 | ## |
---|
[4172] | 607 | echo ${Titre}"Add missing variables in rmp files"${Norm} |
---|
[3639] | 608 | ## =========================================================================== |
---|
[4259] | 609 | for rmpFile in $(ls rmp_?${atm}_to_[tuv]${oce}_*.nc rmp_[tuv]${oce}_to_t${atm}_*.nc 2> /dev/null ) ; do |
---|
[3901] | 610 | echo ${rmpFile} |
---|
[3719] | 611 | a_to_o=false ; o_to_a=false |
---|
| 612 | case ${rmpFile} in |
---|
| 613 | ( rmp_?${oce}_to_?${atm}_*.nc ) o_to_a=true ;; |
---|
| 614 | ( rmp_?${atm}_to_?${oce}_*.nc ) a_to_o=true ;; |
---|
| 615 | esac |
---|
| 616 | |
---|
[3901] | 617 | for Grid in t u v o c ; do # Identify grids |
---|
| 618 | [[ ${rmpFile} = rmp_${Grid}${oce}_to_?${atm}_*.nc ]] && ogrid=${Grid} |
---|
| 619 | [[ ${rmpFile} = rmp_?${oce}_to_${Grid}${atm}_*.nc ]] && agrid=${Grid} |
---|
| 620 | [[ ${rmpFile} = rmp_${Grid}${atm}_to_?${oce}_*.nc ]] && agrid=${Grid} |
---|
| 621 | [[ ${rmpFile} = rmp_?${atm}_to_${Grid}${oce}_*.nc ]] && ogrid=${Grid} |
---|
[3719] | 622 | done |
---|
| 623 | OGRID=${ogrid^} |
---|
| 624 | AGRID=${agrid^} |
---|
[3639] | 625 | |
---|
[3719] | 626 | cat <<EOF >add_varoce.nco |
---|
[3639] | 627 | defdim ("src_grid_size" , \$x_grid_${OGRID}.size*\$y_grid_${OGRID}.size) ; |
---|
| 628 | defdim ("src_grid_corners", 4) ; |
---|
| 629 | defdim ("src_grid_rank" , 2) ; |
---|
| 630 | // |
---|
| 631 | src_grid_dims[src_grid_rank] = { \$y_grid_${OGRID}.size, \$x_grid_${OGRID}.size } ; |
---|
| 632 | // |
---|
| 633 | src_grid_center_lat [src_grid_size] = 0.0d ; |
---|
| 634 | src_grid_center_lon [src_grid_size] = 0.0d ; |
---|
| 635 | src_grid_center_lat (:) = nav_lat_grid_${OGRID}(:,:) ; |
---|
| 636 | src_grid_center_lon (:) = nav_lon_grid_${OGRID}(:,:) ; |
---|
| 637 | // |
---|
| 638 | src_grid_corner_lat [src_grid_size, src_grid_corners] = 0.0d ; |
---|
| 639 | src_grid_corner_lon [src_grid_size, src_grid_corners] = 0.0d ; |
---|
| 640 | src_grid_corner_lat(:,:) = bounds_lat_grid_${OGRID}(:,:,:) ; |
---|
| 641 | src_grid_corner_lon(:,:) = bounds_lon_grid_${OGRID}(:,:,:) ; |
---|
| 642 | // |
---|
| 643 | src_grid_imask [src_grid_size] = 0 ; |
---|
| 644 | src_grid_area [src_grid_size] = 0.0d ; |
---|
| 645 | src_grid_frac [src_grid_size] = 1.0d ; |
---|
| 646 | src_grid_imask (:) = 1 - mask_${OGRID}(:,:) ; |
---|
| 647 | src_grid_imask.int() ; |
---|
| 648 | src_grid_area (:) = area_grid_${OGRID}(:,:) ; |
---|
| 649 | EOF |
---|
| 650 | |
---|
[4146] | 651 | cp add_varoce.nco add_varoce_$(basename ${rmpFile} .nc)_o_to_a.nco |
---|
[4199] | 652 | [[ ${o_to_a} = true ]] && ncap2 --history --append --script-file add_varoce_$(basename ${rmpFile} .nc)_o_to_a.nco ${OCE}_coordinates_mask.nc ${rmpFile} |
---|
[3719] | 653 | sed --in-place "s/src_/dst_/g" add_varoce.nco |
---|
[4146] | 654 | cp add_varoce.nco add_varoce_$(basename ${rmpFile} .nc)_a_to_o.nco |
---|
[4199] | 655 | [[ ${a_to_o} = true ]] && ncap2 --history --append --script-file add_varoce_$(basename ${rmpFile} .nc)_a_to_o.nco ${OCE}_coordinates_mask.nc ${rmpFile} |
---|
[3719] | 656 | |
---|
| 657 | if [[ ${atm} = ico ]] ; then |
---|
| 658 | cat <<EOF >add_varatm.nco |
---|
[3639] | 659 | defdim ("dst_grid_size" , \$cell.size) ; |
---|
| 660 | defdim ("dst_grid_corners", 6) ; |
---|
| 661 | defdim ("dst_grid_rank" , 2) ; |
---|
| 662 | // |
---|
| 663 | dst_grid_dims[dst_grid_rank] = { \$cell.size, 1 } ; |
---|
| 664 | // |
---|
| 665 | dst_grid_center_lat [dst_grid_size] = 0.0d ; |
---|
| 666 | dst_grid_center_lon [dst_grid_size] = 0.0d ; |
---|
| 667 | dst_grid_center_lat (:) = lat(:) ; |
---|
| 668 | dst_grid_center_lon (:) = lon(:) ; |
---|
| 669 | // |
---|
| 670 | dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ; |
---|
| 671 | dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ; |
---|
| 672 | dst_grid_corner_lat(:,:) = bounds_lat(:,:) ; |
---|
| 673 | dst_grid_corner_lon(:,:) = bounds_lon(:,:) ; |
---|
| 674 | // |
---|
| 675 | dst_grid_imask [dst_grid_size] = 0 ; |
---|
| 676 | dst_grid_area [dst_grid_size] = 0.0d ; |
---|
| 677 | dst_grid_frac [dst_grid_size] = 1.0d ; |
---|
[4298] | 678 | dst_grid_imask (:) = 1 - Oce2AtmMask(:) ; |
---|
[3639] | 679 | dst_grid_imask.int() ; |
---|
| 680 | dst_grid_area (:) = aire(:) ; |
---|
[4259] | 681 | dst_grid_frac (:) = OceFrac(:) ; |
---|
[3639] | 682 | EOF |
---|
[4146] | 683 | cp add_varatm.nco add_varatm_$(basename ${rmpFile} .nc)_o_to_a.nco |
---|
[3719] | 684 | if [[ ${o_to_a} = true ]] ; then |
---|
[4199] | 685 | ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_o_to_a.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} |
---|
[3719] | 686 | ncks --alphabetize --history --overwrite --variable 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 ${rmpFile} rmp_tmp.nc |
---|
| 687 | mv rmp_tmp.nc ${rmpFile} |
---|
| 688 | fi |
---|
[3718] | 689 | |
---|
[3719] | 690 | sed --in-place "s/dst_/src_/g" add_varatm.nco |
---|
[4146] | 691 | cp add_varatm.nco add_varatm_$(basename ${rmpFile} .nc)_a_to_o.nco |
---|
[3719] | 692 | if [[ ${a_to_o} = true ]] ; then |
---|
[4199] | 693 | ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_a_to_o.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} |
---|
[3719] | 694 | ncks --alphabetize --history --overwrite --variable 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 ${rmpFile} rmp_tmp.nc |
---|
| 695 | mv rmp_tmp.nc ${rmpFile} |
---|
| 696 | fi |
---|
| 697 | fi |
---|
[3966] | 698 | |
---|
[3719] | 699 | if [[ ${atm} = lmd ]] ; then |
---|
| 700 | cat <<EOF >add_varatm.nco |
---|
[3639] | 701 | defdim ("dst_grid_size" , \$lon.size*\$lat.size) ; |
---|
| 702 | defdim ("dst_grid_corners", 4) ; |
---|
| 703 | defdim ("dst_grid_rank" , 2) ; |
---|
| 704 | // |
---|
| 705 | dst_grid_dims[dst_grid_rank] = { \$lat.size, \$lon.size } ; |
---|
| 706 | // |
---|
| 707 | dst_grid_center_lat [dst_grid_size] = 0.0d ; |
---|
| 708 | dst_grid_center_lon [dst_grid_size] = 0.0d ; |
---|
| 709 | lat0lon[lat,lon] = lat(:)+0*lon(:) ; |
---|
| 710 | lon0lat[lat,lon] = lon(:)+0*lat(:) ; |
---|
| 711 | dst_grid_center_lat (:) = lat0lon(:,:) ; |
---|
| 712 | dst_grid_center_lon (:) = lon0lat(:,:) ; |
---|
| 713 | // |
---|
| 714 | //dst_grid_corner_lat [dst_grid_size, dst_grid_corners] = 0.0d ; // Not available for LMDZ lon/lat grid |
---|
| 715 | //dst_grid_corner_lon [dst_grid_size, dst_grid_corners] = 0.0d ; |
---|
| 716 | //dst_grid_corner_lat(:,:) = bounds_lat(:,:) ; |
---|
| 717 | //dst_grid_corner_lon(:,:) = bounds_lon(:,:) ; |
---|
| 718 | // |
---|
| 719 | dst_grid_imask [dst_grid_size] = 0 ; |
---|
| 720 | dst_grid_area [dst_grid_size] = 0.0d ; |
---|
| 721 | dst_grid_frac [dst_grid_size] = 1.0d ; |
---|
[4298] | 722 | dst_grid_imask (:) = 1 - Oce2AtmMask(:,:) ; |
---|
[3639] | 723 | dst_grid_imask.int() ; |
---|
| 724 | dst_grid_area (:) = aire(:,:) ; |
---|
[4259] | 725 | dst_grid_frac (:) = OceFrac(:,:) ; |
---|
[3639] | 726 | EOF |
---|
[4146] | 727 | cp add_varatm.nco add_varatm_$(basename ${rmpFile} .nc)_o_to_a.nco |
---|
[3719] | 728 | if [[ ${o_to_a} = true ]] ; then |
---|
[4199] | 729 | ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_o_to_a.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} |
---|
[3719] | 730 | ncks --alphabetize --history --overwrite --variable 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 ${rmpFile} rmp_tmp.nc |
---|
| 731 | mv rmp_tmp.nc ${rmpFile} |
---|
| 732 | fi |
---|
| 733 | |
---|
| 734 | sed --in-place "s/dst/src/g" add_varatm.nco |
---|
[4146] | 735 | cp add_varatm.nco add_varatm_$(basename ${rmpFile} .nc)_a_to_o.nco |
---|
[3719] | 736 | if [[ ${a_to_o} = true ]] ; then |
---|
[4199] | 737 | ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_a_to_o.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} |
---|
[3719] | 738 | ncks --alphabetize --history --overwrite --variable 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 ${rmpFile} rmp_tmp.nc |
---|
| 739 | mv rmp_tmp.nc ${rmpFile} |
---|
| 740 | fi |
---|
| 741 | fi |
---|
[3639] | 742 | done |
---|
[3901] | 743 | ls -al ${OCE}_coordinates_mask.nc |
---|
[4097] | 744 | |
---|
[3639] | 745 | ## |
---|
[4186] | 746 | ## ============================================================================ |
---|
[4172] | 747 | echo ${Titre}"Creates and save auxiliary files for OASIS : grids.nc, areas.nc and masks.nc"${Norm} |
---|
[4186] | 748 | cp ${SUBMIT_DIR}/CreateOasisGrids.bash . |
---|
| 749 | bash CreateOasisGrids.bash --oce ${OCE} --atm ${ATM} |
---|
[4097] | 750 | |
---|
| 751 | |
---|
| 752 | ## |
---|
[4172] | 753 | echo ${Titre}"Runoff weights"${Norm} |
---|
[4097] | 754 | ## =========================================================================== |
---|
[4186] | 755 | if [[ "X${okRunoff}" = "Xyes" ]] ; then |
---|
[4195] | 756 | ${PyRun} python3 -u RunoffWeights.py --oce=${OCE} --atm=${ATM} \ |
---|
[4172] | 757 | --atmCoastWidth=${atmCoastWidth} --oceCoastWidth=${oceCoastWidth} --searchRadius=${searchRadius} \ |
---|
[4195] | 758 | --grids=grids_${CplModel}.nc --areas=areas_${CplModel}.nc --masks=masks_${CplModel}.nc \ |
---|
[4199] | 759 | --o2a=${ATM}_grid_maskFrom_${OCE}.nc --output=rmp_t${atm}_to_t${oce}_runoff_${runOff_atmQuantity}_to_${runOff_oceQuantity}.nc \ |
---|
| 760 | --fmt=${FMT_XIOS} \ |
---|
[4186] | 761 | --atmQuantity=${runOff_atmQuantity} --oceQuantity=${runOff_oceQuantity} |
---|
[4172] | 762 | fi |
---|
[4097] | 763 | |
---|
| 764 | ## |
---|
[4172] | 765 | echo ${Titre}"Calving weights"${Norm} |
---|
[3620] | 766 | ## =========================================================================== |
---|
[4172] | 767 | if [[ "X${okCalving}" = "Xyes" ]] ; then |
---|
| 768 | case ${OCE} in |
---|
[4298] | 769 | ( eORCA025* ) |
---|
[4186] | 770 | cp /ccc/work/cont003/gencmip6/deshayej/eORCA_R025_runoff_v1.2.nc . |
---|
[4199] | 771 | ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_nosouth.nc --fmt=${FMT_XIOS} \ |
---|
[4186] | 772 | --oce=${OCE} --atm=${ATM} --type=nosouth --dir=. |
---|
[4199] | 773 | ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceberg.nc --fmt=${FMT_XIOS} \ |
---|
[4186] | 774 | --oce=${OCE} --atm=${ATM} --type=iceberg --dir=. --repartition_file=eORCA_R025_runoff_v1.2.nc --repartition_var=Icb_flux |
---|
[4199] | 775 | ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceshelf.nc --fmt=${FMT_XIOS} \ |
---|
[4186] | 776 | --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=. --repartition_file=eORCA_R025_runoff_v1.2.nc --repartition_var=sornfisf |
---|
[4172] | 777 | ;; |
---|
| 778 | |
---|
| 779 | ( eORCA1.2 ) |
---|
| 780 | cp ${R_IN}/OCE/NEMO/ORCA1_LIM3_PISCES/v3.6_stable/runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc . |
---|
[4199] | 781 | ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_nosouth.nc --fmt=${FMT_XIOS}\ |
---|
[4172] | 782 | --oce=${OCE} --atm=${ATM} --type=nosouth --dir=. |
---|
[4199] | 783 | ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceberg.nc --fmt=${FMT_XIOS}\ |
---|
[4172] | 784 | --oce=${OCE} --atm=${ATM} --type=iceberg --dir=. --repartition_file=runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc --repartition_var=Icb_flux |
---|
[4199] | 785 | ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceshelf.nc --fmt=${FMT_XIOS}\ |
---|
[4172] | 786 | --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=. --repartition_file=runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc --repartition_var=sornfisf |
---|
| 787 | ;; |
---|
| 788 | |
---|
| 789 | ( * ) |
---|
[4199] | 790 | ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_full.nc --fmt=${FMT_XIOS} \ |
---|
[4172] | 791 | --oce=${OCE} --atm=${ATM} --type=full --dir=. |
---|
| 792 | ;; |
---|
| 793 | |
---|
| 794 | esac |
---|
| 795 | fi |
---|
| 796 | |
---|
| 797 | ## |
---|
[4199] | 798 | echo ${Titre}"Simplifies headers, add version and comment"${Norm} |
---|
[4172] | 799 | ## =========================================================================== |
---|
[4199] | 800 | for File in $(ls dia_*.nc rmp_*.nc ${ATM}_grid_maskFrom_${OCE}*.nc areas_${OCE}x${ATM}*.nc grids_${OCE}x${ATM}*.nc masks_${OCE}x${ATM}*.nc 2> /dev/null ) ; do |
---|
[4037] | 801 | ncatted --history --attribute history_of_appended_files,global,d,c,"" ${File} |
---|
[4199] | 802 | ncatted --history --attribute history,global,d,c,"" ${File} |
---|
[4172] | 803 | [[ "X${Comment}" != "X" ]] && ncatted --history --attribute Comment,global,o,c,"${Comment}" ${File} |
---|
| 804 | [[ "X${Version}" != "X" ]] && ncatted --history --attribute Version,global,o,c,"${Version}" ${File} |
---|
[4199] | 805 | [[ "X${Tag}" != "X" ]] && ncatted --history --attribute Version,global,o,c,"${Tag}" ${File} |
---|
| 806 | done |
---|
| 807 | |
---|
| 808 | ## |
---|
| 809 | echo ${Titre}"Rename rmp and dia files"${Norm} |
---|
| 810 | ## =========================================================================== |
---|
[4259] | 811 | for File in $(ls *${oce}*${atm}* *${atm}*${oce}* 2> /dev/null ); do |
---|
[3719] | 812 | NewFile=$(echo ${File} | sed -e "s/${atm}/${ATM}/" -e "s/${oce}/${OCE}/" ) |
---|
[4259] | 813 | mv ${File} ${NewFile} |
---|
[3620] | 814 | done |
---|
| 815 | |
---|
[4199] | 816 | ## |
---|
| 817 | echo ${Titre}"Add Tag"${Norm} |
---|
| 818 | ## =========================================================================== |
---|
| 819 | if [[ "X${Tag}" != "X" ]] ; then |
---|
| 820 | for File in $(ls dia_*.nc rmp_*.nc ${ATM}_grid_maskFrom_${OCE}*.nc areas_${OCE}x${ATM}*.nc grids_${OCE}x${ATM}*.nc masks_${OCE}x${ATM}*.nc 2> /dev/null ) ; do |
---|
| 821 | mv ${File} $(basename ${File} .nc)_${Tag}.nc |
---|
| 822 | done |
---|
[4186] | 823 | fi |
---|
[4199] | 824 | ## |
---|
| 825 | echo ${Titre}"Add Version"${Norm} |
---|
| 826 | ## =========================================================================== |
---|
| 827 | if [[ "X${Version}" != "X" ]] ; then |
---|
| 828 | for File in $(ls dia_*.nc rmp_*.nc ${ATM}_grid_maskFrom_${OCE}*.nc areas_${OCE}x${ATM}*.nc grids_${OCE}x${ATM}*.nc masks_${OCE}x${ATM}*.nc 2> /dev/null ) ; do |
---|
| 829 | mv ${File} $(basename ${File} .nc)_${Version}.nc |
---|
| 830 | done |
---|
| 831 | fi |
---|
| 832 | |
---|
| 833 | ## =========================================================================== |
---|
| 834 | echo ${Titre}"Save results"${Norm} |
---|
| 835 | ## =========================================================================== |
---|
| 836 | for File in $(ls dia_*.nc rmp_*.nc ${ATM}_grid_maskFrom_${OCE}*.nc areas_${OCE}x${ATM}*.nc grids_${OCE}x${ATM}*.nc masks_${OCE}x${ATM}*.nc 2> /dev/null ) ; do |
---|
| 837 | cp ${File} ${SUBMIT_DIR} |
---|
| 838 | done |
---|
[4172] | 839 | |
---|
[4199] | 840 | |
---|
[3620] | 841 | ## |
---|
[4172] | 842 | echo ${Titre}"Creates a README.txt file"${Norm} |
---|
[4090] | 843 | ## =========================================================================== |
---|
| 844 | [[ -f README.txt ]] && rm README.txt |
---|
[4298] | 845 | UUID=$(uuid) |
---|
[3620] | 846 | |
---|
[4090] | 847 | cat <<EOF > README.txt |
---|
| 848 | Files produced by CreateWeightsMask.bash and CreateOasisGrids.bash |
---|
| 849 | |
---|
| 850 | rmp_* are weights files |
---|
| 851 | dia_* are diagnostic files not needed for the coupler |
---|
[4195] | 852 | grids_${CplModel}.nc areas_${CplModel}.nc masks_${CplModel}.nc are auxiliary file needed by OASIS-MCT |
---|
[4090] | 853 | All files have the same uuid in the global attributes |
---|
| 854 | |
---|
| 855 | Description : Weigths and auxiliary files for coupling ${OCE} and ${ATM} needed by OASIS-MCT |
---|
| 856 | Conventions : CF-1.6 |
---|
| 857 | source : IPSL Earth system model |
---|
| 858 | group : ICMC IPSL Climate Modelling Center |
---|
| 859 | Institution : IPSL https://www.ipsl.fr |
---|
| 860 | Ocean : ${OCE} https://www.nemo-ocean.eu |
---|
| 861 | Atmosphere : ${ATM} http://lmdz.lmd.jussieu.fr |
---|
| 862 | production : $(finger ${LOGNAME} | head -1 | awk '{print $4, $5}') |
---|
| 863 | originalFiles : ${OCE}_coordinates_mask.nc ${ATM}_grid_mask.nc |
---|
[4195] | 864 | associatedFiles : grids_${CplModel}.nc areas_${CplModel}.nc masks_${CplModel}.nc |
---|
[4090] | 865 | directory : $(pwd) |
---|
| 866 | timeStamp : $(date) |
---|
| 867 | uuid : ${UUID} |
---|
| 868 | HOSTNAME : $(hostname) |
---|
| 869 | LOGNAME : $(whoami) |
---|
| 870 | NCO : NCO netCDF Operator ${NCO} http://nco.sourceforge.net |
---|
| 871 | Python version : ${PYTHON_VER} |
---|
| 872 | OS : $(uname -o) |
---|
| 873 | release : $(uname -r) |
---|
| 874 | hardware : $(uname -i) |
---|
[4091] | 875 | EOF |
---|
[4090] | 876 | |
---|
[4091] | 877 | echo 'SVN Information : ' >> README.txt |
---|
| 878 | echo '$Author$ ' >> README.txt |
---|
| 879 | echo '$Date$ ' >> README.txt |
---|
| 880 | echo '$Revision$ ' >> README.txt |
---|
| 881 | echo '$Id$ ' >> README.txt |
---|
| 882 | echo '$HeadURL$ ' >> README.txt |
---|
[4090] | 883 | |
---|
[4172] | 884 | echo ${Titre}"Compute checksums and add them to README"${Norm} |
---|
[4199] | 885 | # ------------------------------------------------------------ |
---|
[4091] | 886 | cat << EOF >> README.txt |
---|
[4090] | 887 | |
---|
[4159] | 888 | Files produced, with checksum produced by Unix command shasum (version $(shasum --version)) with default algorithm |
---|
[4090] | 889 | |
---|
| 890 | EOF |
---|
| 891 | |
---|
[4199] | 892 | for file in $(ls dia_*.nc rmp_*.nc ${ATM}_grid_maskFrom_${OCE}*.nc areas_${OCE}x${ATM}*.nc grids_${OCE}x${ATM}*.nc masks_${OCE}x${ATM}*.nc 2> /dev/null ) ; do |
---|
[4298] | 893 | ncatted --attribute uuid,global,o,c,"${UUID}" ${file} |
---|
[4090] | 894 | echo "$(shasum ${file})" >> README.txt |
---|
| 895 | done |
---|
| 896 | |
---|
| 897 | cat <<EOF >> README.txt |
---|
| 898 | |
---|
| 899 | ================= That's all folk's ! ======================== |
---|
| 900 | EOF |
---|
| 901 | |
---|
[4259] | 902 | if [[ "X${Version}" != "X" ]] ; then |
---|
| 903 | cp README.txt ${SUBMIT_DIR}/README_${CplModel}_MOSAIX_${Version}.txt |
---|
| 904 | else |
---|
| 905 | cp README.txt ${SUBMIT_DIR}/README_${CplModel}_MOSAIX.txt |
---|
| 906 | fi |
---|
[3620] | 907 | ## =========================================================================== |
---|
| 908 | ## |
---|
[4172] | 909 | echo ${Titre}" That's all folk's !!! "${Norm} |
---|
[3620] | 910 | ## |
---|
| 911 | ## =========================================================================== |
---|
| 912 | |
---|