Changeset 4172
- Timestamp:
- 12/05/18 11:17:10 (5 years ago)
- Location:
- TOOLS/MOSAIX
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/MOSAIX/CalvingWeights.py
r4159 r4172 42 42 parser.add_argument ('--repartition_file', help='Data files with iceberg melting' , type=str, default='./runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc' ) 43 43 parser.add_argument ('--repartition_var' , help='Variable name for iceshelf' , type=str, default=None) 44 parser.add_argument ('--output' , help='output rmp file name', default='rmp_tlmd_to_torc_calving_64bit.nc' ) 45 parser.add_argument ('--fmt' , help='NetCDF file format, using nco syntax', default='64bits', choices=['classic', 'netcdf3', '64bit', '64bit_data', '64bit_data', 'netcdf4', 'netcdf4_classsic'] ) 44 46 45 47 # Parse command line … … 63 65 64 66 nb_zone = len(limit_lat) 67 68 if myargs.fmt == 'classic' : FmtNetcdf = 'CLASSIC' 69 if myargs.fmt == 'netcdf3' : FmtNetcdf = 'CLASSIC' 70 if myargs.fmt == '64bit' : FmtNetcdf = 'NETCDF3_64BIT_OFFSET' 71 if myargs.fmt == '64bit_data' : FmtNetcdf = 'NETCDF3_64BIT_DATA' 72 if myargs.fmt == '64bit_offset' : FmtNetcdf = 'NETCDF3_64BIT_OFFSET' 73 if myargs.fmt == 'netcdf4' : FmtNetcdf = 'NETCDF4' 74 if myargs.fmt == 'netcdf4_classic' : FmtNetcdf = 'NETCDF4_CLASSIC' 65 75 ### ========================================================================================== 66 76 … … 258 268 print (' ') 259 269 270 271 260 272 ## End of loop 261 273 print (' ') … … 265 277 print ( 'Total num_links : {:10d}'.format(num_links) ) 266 278 279 # Diag : interpolate uniform field 280 src_field = np.zeros(shape=(src_grid_size)) 281 for n_bas in np.arange ( nb_zone ) : 282 index_src = ((src_grid_size - 1)*n_bas) // (nb_zone-1) + 1 283 src_field[index_src-1] = n_bas 284 285 dst_field = np.zeros(shape=(dst_grid_size,)) 286 for link in np.arange (num_links) : 287 dst_field [dst_address [link]-1] += remap_matrix[link] * src_field[src_address[link]-1] 288 267 289 ### ===== Writing the weights file, for OASIS MCT ========================================== 268 290 269 291 # Output file 270 calving = 'rmp_t' + src_Name + '_to_' + 't' + dst_Name + '_calving_' + myargs.type + '.nc'271 f_calving = netCDF4.Dataset ( calving, 'w', format= 'NETCDF3_64BIT')272 292 calving = myargs.output 293 f_calving = netCDF4.Dataset ( calving, 'w', format=FmtNetcdf ) 294 273 295 print ('Output file: ' + calving ) 274 296 … … 285 307 f_calving.title = calving 286 308 f_calving.Program = "Generated by " + sys.argv[0] + " with flags " + str(sys.argv[1:]) 309 f_calving.repartitionType = myargs.type 310 if myargs.type in ['iceberg', 'iceshelf' ] : 311 f_calving.repartitionFile = myargs.repartition_file 312 f_calving.repartitionVar = repartitionVar 313 f_calving.gridsFile = grids 314 f_calving.areasFile = areas 315 f_calving.masksFile = masks 287 316 f_calving.timeStamp = time.asctime() 288 317 f_calving.uuid = f_areas.uuid … … 293 322 f_calving.release = platform.release() 294 323 f_calving.hardware = platform.machine() 295 f_calving.Comment = "Preliminary attempt - Do not trust !"296 324 f_calving.conventions = "SCRIP" 297 325 if src_name == 'lmd' : f_calving.source_grid = "curvilinear" … … 381 409 v_dst_repartition[:] = key_repartition.reshape( (nb_zone,dst_grid_size) ) 382 410 383 # Addit oonnal fields for debugging411 # Additionnal fields for debugging 384 412 # ================================ 385 413 v_dst_grid_imaskutil = f_calving.createVariable ( 'dst_grid_imaskutil' , 'f8', ('dst_grid_size',) ) … … 407 435 v_dst_imaskutil_addressed[:] = dst_mskutil.ravel()[dst_address-1].ravel() 408 436 437 v_src_field = f_calving.createVariable ( 'src_field', 'f8', ('src_grid_size',) ) 438 v_dst_field = f_calving.createVariable ( 'dst_field', 'f8', ('dst_grid_size',) ) 439 v_src_field[:] = src_field 440 v_dst_field[:] = dst_field 441 409 442 f_calving.close () 410 443 -
TOOLS/MOSAIX/CreateOasisGrids.bash
r3913 r4172 25 25 # $HeadURL$ 26 26 27 ## 28 ## Default configuration (may be overrided by command line parameters) 27 set +vx 28 29 echo ${Titre}"Starting CreateOasisGrids.bash"${Norm} 30 31 ## 32 echo ${Titre}"Default configuration (may be overrided by command line parameters)"${Norm} 29 33 ## =========================================================================== 30 34 OCE=ORCA2.3 … … 32 36 ATM=ICO30 33 37 #ATM=ICO40 34 # 35 # 36 # 38 #ATM=ICO450 39 #ATM=LMD144142 40 #ATM=LMD9695 37 41 38 42 ## =========================================================================== … … 42 46 ## =========================================================================== 43 47 44 # Defines computer 48 echo ${Titre}"Defines computer"${Norm} 45 49 # ================ 46 50 if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi … … 72 76 73 77 ## 74 ## Command line parameters 78 echo ${Titre}"Command line parameters"${Norm} 75 79 ## =========================================================================== 76 80 set -e … … 97 101 98 102 ## 99 ## Short names (grid names in Oasis) 103 echo ${Titre}"Short names (grid names in Oasis)"${Norm} 100 104 ## =========================================================================== 101 105 case ${OCE} in … … 111 115 112 116 ## 113 ## Get input files 117 echo ${Titre}"Get input files"${Norm} 114 118 ## =========================================================================== 115 119 [[ -f ${OCE}_coordinates_mask.nc ]] || cp ${R_IN}/OCE/NEMO/${OCE}/${OCE}_coordinates_mask.nc . … … 117 121 118 122 # 119 # Format for OASIS-MCT files : should be NetCDF3 classic or NetCDF3 64 bits 123 echo ${Titre}"Format for OASIS-MCT files : should be NetCDF3 classic or NetCDF3 64 bits"${Norm} 120 124 # --------------------------------------------------------------------------- 121 125 FL_FMT3=64bit 122 126 123 127 # 124 # Cleaning 128 echo ${Titre}"Cleaning"${Norm} 125 129 # ---------------------------------------------------------------------------- 126 130 rm -f grids_${CplModel}.nc masks_${CplModel}.nc areas_${CplModel}.nc … … 128 132 129 133 # 130 # Creates NetCDF3 version of input files 134 echo ${Titre}"Creates NetCDF3 version of input files"${Norm} 131 135 # ---------------------------------------------------------------------------- 132 136 ncks --overwrite --fl_fmt=${FL_FMT} --history ${OCE}_coordinates_mask.nc ${OCE}_coordinates_mask_${FL_FMT3}.nc … … 135 139 136 140 # 137 # Creates ocean fields 141 echo ${Titre}"Creates ocean fields"${Norm} 138 142 # ---------------------------------------------------------------------------- 139 143 for OCEGRID in T U V ; do … … 162 166 163 167 # 164 # We need to have different names for dimensions and variables 168 echo ${Titre}"We need to have different names for dimensions and variables"${Norm} 165 169 # ---------------------------------------------------------------------------- 166 170 ncrename --history --variable lon,alon grids_${CplModel}.nc … … 212 216 213 217 # 214 # DYNAMICO grids : 215 # - Set correct order of dimensions 216 # - Add a dimension 218 echo ${Titre}"DYNAMICO grids : 1) Set correct order of dimensions, 2) Add a dimension"${Norm} 217 219 # ---------------------------------------------------------------------------- 218 220 if [[ ${atm} = dynamico* || ${atm} = ico* ]] ; then … … 243 245 244 246 # 245 # Some changes specific to LMDZ lon/lat grid 247 echo ${Titre}"Some changes specific to LMDZ lon/lat grid"${Norm} 246 248 # ---------------------------------------------------------------------------- 247 249 if [[ ${atm} = lmd* ]] ; then 248 # Spreads lon and lat to get 2D fields250 echo ${Titre}"Spreads lon and lat to get 2D fields"${Norm} 249 251 # ----------------------------------------------------------------------- 250 252 mv grids_${CplModel}.nc grids_${CplModel}_tmp.nc … … 261 263 --attribute overlap,alat,o,i,0 grids_${CplModel}.nc 262 264 263 # Generates cell corners265 echo ${Titre}"Generates cell corners"${Norm} 264 266 # ----------------------------------------------------------------------- 265 267 cat <<EOF > add_bounds.nco … … 290 292 291 293 # 292 # Generates grid "o${atm}", "o" meaning "one": same as t${atm} grid, with surfaces set to 1 294 echo ${Titre}"Generates grid o${atm}, 'o' meaning 'one'"${Norm} 295 # same as t${atm} grid, with surfaces set to 1 293 296 # and mask to 0 (ocean everywhere, to compute integral over the whole grid)) 294 297 # This grid is used when field are quantities instead of fluxes (i.e river flow) … … 306 309 307 310 # 308 # Final renaming 311 echo ${Titre}"Final renaming"${Norm} 309 312 # ---------------------------------------------------------------------------- 310 313 for OCEGRID in T U V … … 348 351 349 352 ## 350 ## Change all NetCDF files to NetCDF 3 format 353 echo ${Titre}"Change all NetCDF files to NetCDF 3 format"${Norm} 351 354 ## =========================================================================== 352 355 for InFile in areas_${CplModel}.nc grids_${CplModel}.nc masks_${CplModel}.nc ; do … … 359 362 360 363 ## 361 ## Add some useful information in NetCDF headers 364 echo ${Titre}"Add some useful information in NetCDF headers"${Norm} 362 365 ## =========================================================================== 363 366 UUID=$(uuid) … … 390 393 --attribute release,global,o,c,"$(uname -r)" \ 391 394 --attribute hardware,global,o,c,"$(uname -i)" \ 392 --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \393 395 --attribute SVN_Author,global,o,c,"$Author$" \ 394 396 --attribute SVN_Date,global,o,c,"$Date$" \ … … 399 401 done 400 402 401 ##402 ## Cleaning403 ## ===========================================================================404 #rm *_tmp.nc ${OCE}_coordinates_mask_${FL_FMT3}.nc ${ATM}_grid_maskFrom_${OCE}_${FL_FMT3}.nc *.nco405 403 406 404 exit 407 405 # 408 # Name of the dimensions ?406 echo ${Titre}"Name of the dimensions ?"${Norm} 409 407 # ---------------------------------------------------------------------------- 410 408 for OCEGRID in T U V ; do … … 416 414 417 415 ## =========================================================================== 418 ## 419 ## That's all folk's !!! 420 ## 421 ## =========================================================================== 416 echo ${Titre}"exit from CreateOasisGrids "${Norm} 417 418 ## =========================================================================== 419 ## 420 echo ${Titre}" That's all folk's !!! "${Norm} 421 ## 422 ## =========================================================================== -
TOOLS/MOSAIX/CreateWeightsMask.bash
r4159 r4172 38 38 # $HeadURL$ 39 39 # 40 set +vx 40 41 export Bold=$(tput bold) 41 42 export Unde=$(tput smul) ; export OffUnde=$(tput rmul) … … 45 46 for i in $(seq 0 7 ) ; do eval "export ${couleurs[$i]}=$(tput setf $i)" ; done 46 47 export Norm=$(tput sgr0 ) 48 export Titre=${Bold}${Blue} 47 49 48 50 ## … … 52 54 53 55 # 54 # Defines models 56 echo ${Titre}"Defines models"${Norm} 55 57 # ============== 56 #OCE=ORCA2.358 OCE=ORCA2.3 57 59 #OCE=eORCA1.2 58 OCE=eORCA02560 #OCE=eORCA025 59 61 60 62 #ATM=ICO30 … … 63 65 ATM=LMD9695 64 66 #ATM=LMD144142 67 #ATM=LMD256256 68 69 # Runoff parameter (LMDZ grids only) 70 atmCoastWidth=2 ; oceCoastWidth=2 ; searchRadius=1000.0 71 72 if [[ ${OCE} = ORCA2.3 && ${ATM} = LMD9695 ]] ; then atmCoastWidth=2 ; oceCoastWidth=1 ; searchRadius=1000.0 ; fi 73 if [[ ${OCE} = ORCA2.3 && ${ATM} = LMD144142 ]] ; then atmCoastWidth=2 ; oceCoastWidth=1 ; searchRadius=1000.0 ; fi 74 if [[ ${OCE} = eORCA1.2 && ${ATM} = LMD9695 ]] ; then atmCoastWidth=2 ; oceCoastWidth=3 ; searchRadius=1000.0 ; fi 75 if [[ ${OCE} = eORCA1.2 && ${ATM} = LMD144142 ]] ; then atmCoastWidth=2 ; oceCoastWidth=3 ; searchRadius=1000.0 ; fi 65 76 66 77 # Default values, used to create ocean fraction on atmospheric grid 67 78 DefaultValues=( Direction=o2a,oceGrid=t,atmGrid=t,Order=1st,Quantity=false,Renormalize=false,useArea=false,maskSrc=true,maskDst=false ) 68 79 69 # List of weights to build 70 CommandList=( \ 71 Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true \ 72 Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true \ 73 Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true \ 74 Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=v,useArea=true,maskSrc=true,maskDst=true \ 75 Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=c,oceGrid=t,useArea=true,maskSrc=true,maskDst=true \ 76 ) 77 78 # Each item in CommandList describes the property of interpolation weights to generate. 80 ## List of weights to build 81 ## ==================================================================================================================================== 82 # 83 # Each item in CommandList describes the properties of interpolation weights to generate. 79 84 # White spaces separate analysis. No spaces in any analysis. 85 # 86 # Specific commands : 'Runoff', 'Calving' 80 87 # 81 88 # Keywords : … … 85 92 # or intensive value (temperature, salinity, sea-ice fraction, ...) 86 93 # Renormalize : used when source grid is masked, to use values on non masked points only 87 # oceGrid : t, u or v point for OPAgrid94 # oceGrid : t, u or v point for NEMO C grid 88 95 # atmGrid : up to know, only t grid used in the atmosphere 89 96 # useArea : if true area from the model metrics is used. If false, areas are computed by XIOS from grid corners … … 91 98 # maskDst : true to use the destination grid mask, false to use all grid points 92 99 # 100 # Classic cases 101 AtmOceFluxes=" Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true" # Heat and water fluxes 102 OceAtmTemp=" Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true" # Temperature, sea-ice fraction, albedo 103 AtmOceStressU="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true" # Wind stress to NEMO U point 104 AtmOceStressV="Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=v,useArea=true,maskSrc=true,maskDst=true" # Wind stress to NEMO V point 105 # Other cases 106 OceAtmFluxes=" Direction=o2a,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true" # e.g. CO2 fluxes 107 AtmOceTemp=" Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true" # e.g. T and S correction from DWL parametrization 108 AtmOceCoastal="Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=c,oceGrid=t,useArea=true,maskSrc=true,maskDst=true" # Runoff atm to oce, limited to oce coastal points 109 110 CommandList=( ${AtmOceFluxes} Runoff Calving ) 111 112 #CommandList=( Runoff Calving ) #\ 113 # Direction=o2a,Order=1st,Quantity=false,Renormalize=true,oceGrid=t,atmGrid=t,useArea=false,maskSrc=true,maskDst=true \ 114 # Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true \ 115 # Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=u,useArea=true,maskSrc=true,maskDst=true \ 116 # Direction=a2o,Order=2nd,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=v,useArea=true,maskSrc=true,maskDst=true \ 117 # Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=c,oceGrid=t,useArea=true,maskSrc=true,maskDst=true \ 118 # Calving \ 119 # Runoff \ 120 # ) 121 122 123 124 Comment="Preliminary attempt - Do not trust !" 125 #Version 93 126 94 127 ## =========================================================================== … … 169 202 SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 170 203 PROGRAM=${BRIDGE_MSUB_REQNAME} 171 MPIRUN=ccc_mprun 204 MpiRun="time ccc_mprun" 205 PyRun="ccc_mprun -n 1" 172 206 source ${SUBMIT_DIR}/arch.env 173 207 module load nco 174 module load cdo175 208 #source $(ccc_home -u igcmg)/MachineEnvironment/irene/env_irene 176 module load python /2.7.8209 module load python3 177 210 module load datadir/igcmg 178 211 module list … … 182 215 TMPDIR=${HOME}/Scratch/TMP 183 216 SUBMIT_DIR=$(pwd) 184 MPIRUN=/opt/local/bin/mpirun -n 4 217 MpiRun="/opt/local/bin/mpirun -n 4" 218 PyRun="time" 185 219 ;; 186 220 ( * ) exit -1 ;; … … 209 243 case ${OCE} in # Periodicity type of ORCA grid 210 244 ( ORCA2.3* ) OcePerio=4 ;; 211 ( ORCA1* | eORCA1*) OcePerio=6 ;;245 ( ORCA1* | eORCA1* ) OcePerio=6 ;; 212 246 ( ORCA025* | eORCA025 ) OcePerio=6 ;; 213 247 esac 214 248 # 215 # Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits 249 echo ${Titre}"Format for OASIS files : should be NetCDF3 classic or NetCDF3 64 bits"${Norm} 216 250 # --------------------------------------------------------------------------- 217 251 FMT_OASIS=64bit … … 229 263 ncks --overwrite --fl_fmt=${FMT_OASIS} --history ${ATM}_grid.nc ${ATM}_grid_${FMT_OASIS}.nc 230 264 # 231 # Creates OCEAN C grid : redundant points removed to compute proper integrals # A passer dans CreateWeights 265 echo ${Titre}"Creates OCEAN C grid : redundant points removed to compute proper integrals # A passer dans CreateWeights"${Norm} 232 266 # -------------------------------------------------------------------------------------------------------- 233 267 cat <<EOF >add_c_grid.nco … … 258 292 259 293 ## 260 ## NEMO T point towards ATM - 1st order 294 echo ${Titre}"NEMO T point towards ATM - 1st order"${Norm} 261 295 ## =========================================================================== 262 296 echo "Command parameters : ${Command}" … … 267 301 cp iodef_oce_to_atm.xml iodef.xml 268 302 269 python 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_T270 python 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_T271 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType}272 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType}273 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1274 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity -v false275 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false276 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k use_area -v false277 python 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_T278 python 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_T279 python 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}_${Suffix}280 python 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}"281 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType}282 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]' -t ${dstDomainType}283 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t 1284 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType}285 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType}286 python 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}_${Suffix}.nc287 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1288 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false289 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]' -t false290 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]' -t false291 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false292 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity -v false293 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k use_area -v false303 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 304 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 305 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType} 306 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType} 307 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 308 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity -v false 309 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false 310 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 311 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 312 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 313 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}_${Suffix} 314 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}" 315 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType} 316 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]' -t ${dstDomainType} 317 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t 1 318 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType} 319 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType} 320 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}_${Suffix}.nc 321 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v 1 322 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false 323 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]' -t false 324 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]' -t false 325 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v false 326 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity -v false 327 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 294 328 295 329 cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.xml … … 297 331 ln -fs ${ATM}_grid.nc atm_grid.nc 298 332 299 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 300 ## 301 ## Correct spurious values (extremes) 333 ${MpiRun} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 334 335 ## 336 echo ${Titre}"Correct spurious values (extremes)"${Norm} 302 337 ## =========================================================================== 303 338 cat <<EOF > correction_masque.nco … … 313 348 314 349 ## 315 ## Creates ocean fractions on ATM grid 350 echo ${Titre}"Creates ocean fractions on ATM grid"${Norm} 316 351 ## =========================================================================== 317 352 cp dia_t${oce}_to_t${atm}_${Suffix}.nc dia_t${oce}_to_t${atm}_${Suffix}_mask.nc … … 330 365 rm dia_t${oce}_to_t${atm}_${Suffix}_mask.nc 331 366 332 # Change dimension names, and some attributes accordingly 367 echo "Change dimension names, and some attributes accordingly" 333 368 if [[ $(ncdump -h ${ATM}_grid_maskFrom_${OCE}.nc | grep domain_dst | wc -l) -gt 0 ]] ; then 334 369 case ${atm} in … … 357 392 358 393 ## 359 ## Creates mask of coastal OCE points 360 ## =========================================================================== 361 ccc_mprun -n 1 python -u ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal 362 ## 363 ## Creates mask of coastal ATM points 394 echo ${Titre}"Creates mask of coastal OCE points"${Norm} 395 ## =========================================================================== 396 ${PyRun} python3 -u ComputeNemoCoast.py -n ${OcePerio} -i ${OCE}_coordinates_mask.nc # Creates OceCoastal 397 398 ## 399 echo ${Titre}"Creates mask of coastal ATM points"${Norm} 364 400 ## =========================================================================== 365 401 cat <<EOF > coastal.nco … … 374 410 375 411 ## 376 ## Other weights files 412 echo ${Titre}"Other weights files"${Norm} 377 413 ## =========================================================================== 378 414 # Loop on commands … … 382 418 read_Command ${DefaultValues} 383 419 read_Command ${Command} 420 421 if [[ ${Command} = "Runoff" ]] ; then okRunoff=yes ; continue ; fi 422 if [[ ${Command} = "Calving" ]] ; then okCalving=yes ; continue ; fi 423 384 424 setValues 385 425 … … 391 431 cp iodef_oce_to_atm.xml iodef.xml 392 432 393 python 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}394 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_dst"]/field[@id="mask_dst"]' -k name -v OceMask433 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} 434 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 OceMask 395 435 396 python 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}397 python 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}398 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="mask_dest"]' -k name -v OceMask399 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_dst"]/field[@id="area_dest"]' -k name -v aire436 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} 437 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} 438 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 OceMask 439 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 400 440 ;; 401 441 ( a2o ) 402 442 cp iodef_atm_to_oce.xml iodef.xml 403 443 404 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/file_definition/file[@id="file_src"]/field[@id="mask_src"]' -k name -v OceMask405 python 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}444 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 OceMask 445 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} 406 446 407 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="mask_source"]' -k name -v OceMask408 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="file_src"]/field[@id="area_source"]' -k name -v aire409 python 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}410 python 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}447 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 OceMask 448 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 449 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} 450 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} 411 451 ;; 412 452 esac 413 453 414 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType}415 python update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType}416 417 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType}418 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType}419 420 python 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}_${Suffix}.nc421 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v ${numOrder}422 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity -v ${Quantity}423 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v ${Renormalize}424 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k use_area -v ${useArea}425 426 python 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}_${Suffix}427 python 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}"428 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]' -t ${dstDomainType}429 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType}430 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${Renormalize}431 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t ${numOrder}432 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]' -t ${Quantity}433 python update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]' -t ${useArea}454 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType} 455 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType} 456 457 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]' -k type -v ${srcDomainType} 458 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]' -k type -v ${dstDomainType} 459 460 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}_${Suffix}.nc 461 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k order -v ${numOrder} 462 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k quantity -v ${Quantity} 463 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k renormalize -v ${Renormalize} 464 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} 465 466 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}_${Suffix} 467 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}" 468 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]' -t ${dstDomainType} 469 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType} 470 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t ${Renormalize} 471 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="order"]' -t ${numOrder} 472 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="quantity"]' -t ${Quantity} 473 python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]' -t ${useArea} 434 474 435 475 cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${Suffix}.xml 436 time /usr/bin/time ${MPIRUN} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea}476 ${MpiRun} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 437 477 done 438 478 439 479 ## 440 ## Copy all NetCDF files to NetCDF 3 format (needed for OASIS) 480 echo ${Titre}"Copy all NetCDF files to NetCDF 3 format (needed for OASIS)"${Norm} 441 481 ## =========================================================================== 442 482 for InFile in *.nc ; do … … 446 486 447 487 ## 448 ## Add time axis and coordinates information 488 echo ${Titre}"Add time axis and coordinates information"${Norm} 449 489 ## (needed if files need to be read by XIOS) 450 490 ## =========================================================================== … … 491 531 492 532 ## 493 ## Add some metadata in file headers 533 echo ${Titre}"Add some metadata in file headers"${Norm} 494 534 ## =========================================================================== 495 535 496 536 UUID=$(uuid) 497 537 NCO="$(ncks --version |& tail -1|sed 's/ncks //')" 498 PYTHON_VER=$( python -c "import sys ; print (sys.version.split(' ')[0])" )538 PYTHON_VER=$( python3 -c "import sys ; print (sys.version.split(' ')[0])" ) 499 539 for InFile in $(ls *${oce}_to_*${atm}_*.nc *${atm}_to_*${oce}_*.nc ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_${FMT_OASIS}.nc 2>/dev/null) ; do 500 540 ncatted --history \ … … 520 560 --attribute LOGNAME,global,o,c,"$(whoami)" \ 521 561 --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \ 522 --attribute Python,global,o,c,"Python version ${PYTHON_VER}" \562 --attribute Python,global,o,c,"Python3 version ${PYTHON_VER}" \ 523 563 --attribute OS,global,o,c,"$(uname -o)" \ 524 564 --attribute release,global,o,c,"$(uname -r)" \ 525 565 --attribute directory,global,o,c,"$(pwd)" \ 526 566 --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" \ 527 --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \528 567 --attribute SVN_Author,global,o,c,'$Author$' \ 529 568 --attribute SVN_Date,global,o,c,'$Date$' \ … … 533 572 done 534 573 ## 535 ## Update and complete weight files to fit OASIS requested format 574 echo ${Titre}"Update and complete weight files to fit OASIS requested format"${Norm} 536 575 ## =========================================================================== 537 576 cat <<EOF > add_dim.nco … … 582 621 583 622 ## 584 ## Add missing variables in rmp files 623 echo ${Titre}"Add missing variables in rmp files"${Norm} 585 624 ## =========================================================================== 586 625 for $(ls rmpFile in rmp_?${atm}_to_[tuv]${oce}_*.nc rmp_[tuv]${oce}_to_t${atm}_*.nc* 2>/dev/null) ; do … … 721 760 722 761 ## 723 ## Creates and save auxiliary files for OASIS : grids.nc, areas.nc and masks.nc 762 echo ${Titre}"Creates and save auxiliary files for OASIS : grids.nc, areas.nc and masks.nc"${Norm} 724 763 ## ============================================================================ 725 764 bash ${SUBMIT_DIR}/CreateOasisGrids.bash --oce ${OCE} --atm ${ATM} 765 766 767 768 ## 769 echo ${Titre}"Runoff weights"${Norm} 770 ## =========================================================================== 771 if [[ "X${okRunoff}" = "Xyes" && "${atm}" = "lmd" ]] ; then 772 ${PyRun} python3 -u cotes_etal.py --oce=${OCE} --atm=${ATM} \ 773 --atmCoastWidth=${atmCoastWidth} --oceCoastWidth=${oceCoastWidth} --searchRadius=${searchRadius} \ 774 --grids=grids_${OCE}x${ATM}.nc --areas=areas_${OCE}x${ATM}.nc --masks=masks_${OCE}x${ATM}.nc \ 775 --o2a=${ATM}_grid_maskFrom_${OCE}.nc --output=rmp_t${atm}_to_t${oce}_runoff_${FMT_OASIS}.nc \ 776 --fmt=${FMT_OASIS} 777 fi 778 779 ## 780 echo ${Titre}"Calving weights"${Norm} 781 ## =========================================================================== 782 if [[ "X${okCalving}" = "Xyes" ]] ; then 783 case ${OCE} in 784 ( eORCA025 ) 785 cp ${R_IN}/OCE/NEMO/ORCA025_LIM3_PISCES/v3.6_stable/eORCA_R025_runoff_v1.1.nc . 786 ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_full_${FMT_OASIS}.nc --fmt=${FMT_OASIS} \ 787 --oce=${OCE} --atm=${ATM} --type=full --dir=. 788 ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_nosouth_${FMT_OASIS}.nc --fmt=${FMT_OASIS} \ 789 --oce=${OCE} --atm=${ATM} --type=nosouth --dir=. --repartition_file=eORCA_R025_runoff_v1.1.nc 790 ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceberg_${FMT_OASIS}.nc --fmt=${FMT_OASIS} \ 791 --oce=${OCE} --atm=${ATM} --type=iceberg --dir=. --repartition_file=eORCA_R025_runoff_v1.1.nc --repartition_var=sornficbisf 792 ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceshelf_${FMT_OASIS}.nc --fmt=${FMT_OASIS} \ 793 --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=. --repartition_file=eORCA_R025_runoff_v1.1.nc --repartition_var=sofwfisf 794 ;; 795 796 ( eORCA1.2 ) 797 cp ${R_IN}/OCE/NEMO/ORCA1_LIM3_PISCES/v3.6_stable/runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc . 798 ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_nosouth_${FMT_OASIS}.nc --fmt=${FMT_OASIS}\ 799 --oce=${OCE} --atm=${ATM} --type=nosouth --dir=. 800 ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceberg_${FMT_OASIS}.nc --fmt=${FMT_OASIS}\ 801 --oce=${OCE} --atm=${ATM} --type=iceberg --dir=. --repartition_file=runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc --repartition_var=Icb_flux 802 ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_iceshelf_${FMT_OASIS}.nc --fmt=${FMT_OASIS}\ 803 --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=. --repartition_file=runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc --repartition_var=sornfisf 804 ;; 805 806 ( * ) 807 ${PyRun} python3 -u CalvingWeights.py --output=rmp_t${atm}_to_t${oce}_calving_full_${FMT_OASIS}.nc --fmt=${FMT_OASIS} \ 808 --oce=${OCE} --atm=${ATM} --type=full --dir=. 809 ;; 810 811 esac 812 fi 813 814 ## 815 echo ${Titre}"Save results"${Norm} 816 ## =========================================================================== 817 818 cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR} 819 for File in dia_*.nc rmp_*.nc 820 do 821 ncatted --history --attribute history_of_appended_files,global,d,c,"" ${File} 822 [[ "X${Comment}" != "X" ]] && ncatted --history --attribute Comment,global,o,c,"${Comment}" ${File} 823 [[ "X${Version}" != "X" ]] && ncatted --history --attribute Version,global,o,c,"${Version}" ${File} 824 825 NewFile=$(echo ${File} | sed -e "s/${atm}/${ATM}/" -e "s/${oce}/${OCE}/" ) 826 cp ${File} ${SUBMIT_DIR}/${NewFile} 827 done 726 828 727 829 cp areas_${OCE}x${ATM}.nc ${SUBMIT_DIR} … … 729 831 cp masks_${OCE}x${ATM}.nc ${SUBMIT_DIR} 730 832 731 ## 732 ## Calving weights 733 ## =========================================================================== 734 case ${OCE} in 735 ( eORCA025 ) 736 ccc_mprun -n 1 python -u CalvingWeights.py --oce=${OCE} --atm=${ATM} --type=full --dir=. 737 ;; 738 739 ( eORCA1.2 ) 740 cp ${R_IN}/OCE/NEMO/ORCA1_LIM3_PISCES/v3.6_stable/runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc . 741 ccc_mprun -n 1 python CalvingWeights.py --oce=${OCE} --atm=${ATM} --type=nosouth --dir=. 742 ccc_mprun -n 1 python CalvingWeights.py --oce=${OCE} --atm=${ATM} --type=iceberg --dir=. --repartition_file=runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc --repartition_var=Icb_flux 743 ccc_mprun -n 1 python CalvingWeights.py --oce=${OCE} --atm=${ATM} --type=iceshelf --dir=. --repartition_file=runoff-icb_DaiTrenberth_Depoorter_eORCA1_JD.nc --repartition_var=sornfisf 744 ;; 745 746 ( * ) 747 ccc_mprun -n 1 python CalvingWeights.py --oce=${OCE} --atm=${ATM} --type=full --dir=. 748 ;; 749 esac 750 751 ## 752 ## Save results 753 ## =========================================================================== 754 cp ${ATM}_grid_maskFrom_${OCE}.nc ${SUBMIT_DIR} 755 for File in dia_*.nc rmp_*.nc 756 do 757 ncatted --history --attribute history_of_appended_files,global,d,c,"" ${File} 758 NewFile=$(echo ${File} | sed -e "s/${atm}/${ATM}/" -e "s/${oce}/${OCE}/" ) 759 cp ${File} ${SUBMIT_DIR}/${NewFile} 760 done 761 762 ## 763 ## Creates a README.txt file 833 834 ## 835 echo ${Titre}"Creates a README.txt file"${Norm} 764 836 ## =========================================================================== 765 837 [[ -f README.txt ]] && rm README.txt … … 802 874 echo '$HeadURL$ ' >> README.txt 803 875 804 # Compute checksums and add thmer to README 876 echo ${Titre}"Compute checksums and add them to README"${Norm} 805 877 # ----------------------------------------- 806 878 cat << EOF >> README.txt … … 824 896 ## =========================================================================== 825 897 ## 826 ## That's all folk's !!! 827 ## 828 ## =========================================================================== 829 898 echo ${Titre}" That's all folk's !!! "${Norm} 899 ## 900 ## =========================================================================== 901 -
TOOLS/MOSAIX/cotes_etal.py
r4151 r4172 25 25 ## 26 26 27 ## Modules 27 28 import netCDF4 28 29 import numpy as np … … 32 33 33 34 ## Userful constants 34 zero = np.dtype('float64').type(0.0)35 zone = np.dtype('float64').type(1.0)35 zero = np.dtype('float64').type(0.0) 36 zone = np.dtype('float64').type(1.0) 36 37 epsfrac = np.dtype('float64').type(1.0E-10) 37 pi = np.pi38 rad = pi/np.dtype('float64').type(180.0)39 ra = np.dtype('float64').type(6400000.0) # Earth radius38 pi = np.pi 39 rad = pi/np.dtype('float64').type(180.0) 40 ra = np.dtype('float64').type(6371229.0) # Earth radius 40 41 41 42 ## Functions … … 47 48 return geodist 48 49 49 50 51 52 50 ### ===== Reading command line parameters ================================================== 53 51 # Creating a parser … … 57 55 58 56 # Adding arguments 59 parser.add_argument ('--oce' , help='oce model name', type=str, default='eORCA1.2', choices=['ORCA2.3', 'eORCA1.2', 'eORCA025'] ) 60 parser.add_argument ('--atm' , help='atm model name (LMD*)', type=str, default='LMD9695' ) 61 parser.add_argument ('--atmCoastWidth', help='width of the coastal band in atmosphere (in grid points)', default=1 ) 62 parser.add_argument ('--oceCoastWidth', help='width of the coastal band in ocean (in grid points)' , default=2 ) 63 parser.add_argument ('--grids', help='grids file name', default='grids.nc' ) 64 parser.add_argument ('--areas', help='masks file name', default='areas.nc' ) 65 parser.add_argument ('--masks', help='areas file name', default='masks.nc' ) 66 parser.add_argument ('--o2a' , help='o2a file name', default='o2a.nc' ) 67 parser.add_argument ('--output', help='output rmp file name', default='rmp_tlmd_to_torc_runoff.nc' ) 57 parser.add_argument ('--oce' , help='oce model name', type=str, default='eORCA1.2', choices=['ORCA2.3', 'eORCA1.2', 'eORCA025'] ) 58 parser.add_argument ('--atm' , help='atm model name (LMD*)', type=str, default='LMD9695' ) 59 parser.add_argument ('--atmCoastWidth', help='width of the coastal band in atmosphere (in grid points)', type=int, default=1 ) 60 parser.add_argument ('--oceCoastWidth', help='width of the coastal band in ocean (in grid points)' , type=int, default=2 ) 61 parser.add_argument ('--searchRadius' , help='max distance to connect a land point to an ocean point (in km)', type=float, default=600000.0) 62 parser.add_argument ('--grids' , help='grids file name', default='grids.nc' ) 63 parser.add_argument ('--areas' , help='masks file name', default='areas.nc' ) 64 parser.add_argument ('--masks' , help='areas file name', default='masks.nc' ) 65 parser.add_argument ('--o2a' , help='o2a file name' , default='o2a.nc' ) 66 parser.add_argument ('--output', help='output rmp file name', default='rmp_tlmd_to_torc_runoff_64bit.nc' ) 67 parser.add_argument ('--fmt' , help='NetCDF file format, using nco syntax', default='64bit', choices=['classic', 'netcdf3', '64bit', '64bit_data', '64bit_data', 'netcdf4', 'netcdf4_classsic'] ) 68 68 69 69 # Parse command line … … 83 83 # Width of the coastal band (ocean points) in the ocean 84 84 oceCoastWidth = myargs.oceCoastWidth 85 85 searchRadius = myargs.searchRadius * 1000.0 # From km to meters 86 # Netcdf format 87 if myargs.fmt == 'classic' : FmtNetcdf = 'CLASSIC' 88 if myargs.fmt == 'netcdf3' : FmtNetcdf = 'CLASSIC' 89 if myargs.fmt == '64bit' : FmtNetcdf = 'NETCDF3_64BIT_OFFSET' 90 if myargs.fmt == '64bit_data' : FmtNetcdf = 'NETCDF3_64BIT_DATA' 91 if myargs.fmt == '64bit_offset' : FmtNetcdf = 'NETCDF3_64BIT_OFFSET' 92 if myargs.fmt == 'netcdf4' : FmtNetcdf = 'NETCDF4' 93 if myargs.fmt == 'netcdf4_classic' : FmtNetcdf = 'NETCDF4_CLASSIC' 86 94 87 95 ### Read coordinates of all models … … 93 101 maskFile = netCDF4.Dataset ( masks ) 94 102 95 o2aFrac = diaFile [' field01_dst'][:].filled()103 o2aFrac = diaFile ['OceFrac'][:].squeeze() 96 104 o2aFrac = np.where ( np.abs(o2aFrac) < 1E10, o2aFrac, 0.0) 97 105 98 atm_grid_center_lat = gridFile['tlmd.lat'][:] .filled()99 atm_grid_center_lon = gridFile['tlmd.lon'][:] .filled()100 atm_grid_corner_lat = gridFile['tlmd.cla'][:] .filled()101 atm_grid_corner_lon = gridFile['tlmd.clo'][:] .filled()102 103 atm_grid_area = areaFile['tlmd.srf'][:] .filled()104 atm_grid_imask = 1-maskFile['tlmd.msk'][:].squeeze() .filled()106 atm_grid_center_lat = gridFile['tlmd.lat'][:] 107 atm_grid_center_lon = gridFile['tlmd.lon'][:] 108 atm_grid_corner_lat = gridFile['tlmd.cla'][:] 109 atm_grid_corner_lon = gridFile['tlmd.clo'][:] 110 111 atm_grid_area = areaFile['tlmd.srf'][:] 112 atm_grid_imask = 1-maskFile['tlmd.msk'][:].squeeze() 105 113 atm_grid_dims = atm_grid_area.shape 106 114 (atm_nvertex, atm_jpj, atm_jpi) = atm_grid_corner_lat.shape … … 110 118 atm_grid_size = atm_jpj*atm_jpi 111 119 112 oce_grid_center_lat = gridFile['torc.lat'][:] .filled()113 oce_grid_center_lon = gridFile['torc.lon'][:] .filled()114 oce_grid_corner_lat = gridFile['torc.cla'][:] .filled()115 oce_grid_corner_lon = gridFile['torc.clo'][:] .filled()116 oce_grid_area = areaFile['torc.srf'][:] .filled()117 oce_grid_imask = 1-maskFile['torc.msk'][:] .filled()120 oce_grid_center_lat = gridFile['torc.lat'][:] 121 oce_grid_center_lon = gridFile['torc.lon'][:] 122 oce_grid_corner_lat = gridFile['torc.cla'][:] 123 oce_grid_corner_lon = gridFile['torc.clo'][:] 124 oce_grid_area = areaFile['torc.srf'][:] 125 oce_grid_imask = 1-maskFile['torc.msk'][:] 118 126 oce_grid_dims = oce_grid_area.shape 119 127 (oce_nvertex, oce_jpj, oce_jpi) = oce_grid_corner_lat.shape ; jpon=oce_jpj*oce_jpj … … 151 159 oceCoast_address = oce_address [oceCoast] 152 160 153 154 161 print ("Determination d'une bande cotiere atmosphere " ) 155 162 atmLand = np.where (o2aFrac[:] < epsfrac , True, False) … … 183 190 for ja in np.arange(len(atmCoast_grid_pmask)) : 184 191 z_dist = geodist ( atmCoast_grid_center_lon[ja], atmCoast_grid_center_lat[ja], oceCoast_grid_center_lon, oceCoast_grid_center_lat) 185 z_mask = np.where ( z_dist*ra < 600000.0, True, False)192 z_mask = np.where ( z_dist*ra < searchRadius, True, False) 186 193 num_links = z_mask.sum() 187 194 if num_links == 0 : continue 188 195 z_area = oceCoast_grid_area[z_mask].sum() 189 196 poids = 1.0 / z_area 190 print ( num_links, z_mask.sum(), z_area )197 #print ( num_links, z_mask.sum(), z_area ) 191 198 # 192 199 matrix_local = np.ones ((num_links),dtype=np.float64) * poids … … 199 206 atm_address = np.append ( atm_address , atm_address_local ) 200 207 oce_address = np.append ( oce_address , oce_address_local ) 201 202 208 203 209 print ('End of loop') … … 207 213 ### Output file 208 214 runoff = myargs.output 209 f_runoff = netCDF4.Dataset ( runoff, 'w', format='NETCDF3_64BIT' ) 210 215 f_runoff = netCDF4.Dataset ( runoff, 'w', format=FmtNetcdf ) 211 216 print ('Output file: ' + runoff ) 212 217 … … 222 227 f_runoff.title = runoff 223 228 f_runoff.Program = "Generated by " + sys.argv[0] + " with flags " + str(sys.argv[1:]) 229 f_runoff.atmCoastWidth = str(atmCoastWidth) + " grid points" 230 f_runoff.oceCoastWidth = str(oceCoastWidth) + " grid points" 231 f_runoff.searchRadius = str(searchRadius/1000.) + " km" 232 f_runoff.gridsFile = grids 233 f_runoff.areasFile = areas 234 f_runoff.masksFile = masks 235 f_runoff.o2aFile = o2a 224 236 f_runoff.timeStamp = time.asctime() 225 237 f_runoff.uuid = areaFile.uuid … … 230 242 f_runoff.release = platform.release() 231 243 f_runoff.hardware = platform.machine() 232 f_runoff.Comment = "Preliminary attempt - Do not trust !"233 244 f_runoff.conventions = "SCRIP" 234 245 f_runoff.source_grid = "curvilinear" … … 241 252 f_runoff.SVN_HeadURL = "$HeadURL$" 242 253 243 num_links = f_runoff.createDimension ('num_links' , num_links )244 num_wgts = f_runoff.createDimension ('num_wgts' , 1 )245 246 atm_grid_size = f_runoff.createDimension ('src_grid_size' , atm_grid_size )247 atm_grid_corners = f_runoff.createDimension ('src_grid_corners', atm_grid_corner_lon.shape[0] )248 atm_grid_rank = f_runoff.createDimension ('src_grid_rank' , 2 )249 250 oce_grid_size = f_runoff.createDimension ('dst_grid_size' , oce_grid_size )251 oce_grid_corners = f_runoff.createDimension ('dst_grid_corners', oce_grid_corner_lon.shape[0] )252 oce_grid_rank = f_runoff.createDimension ('dst_grid_rank' , 2 )254 d_num_links = f_runoff.createDimension ('num_links' , num_links ) 255 d_num_wgts = f_runoff.createDimension ('num_wgts' , 1 ) 256 257 d_atm_grid_size = f_runoff.createDimension ('src_grid_size' , atm_grid_size ) 258 d_atm_grid_corners = f_runoff.createDimension ('src_grid_corners', atm_grid_corner_lon.shape[0] ) 259 d_atm_grid_rank = f_runoff.createDimension ('src_grid_rank' , 2 ) 260 261 d_oce_grid_size = f_runoff.createDimension ('dst_grid_size' , oce_grid_size ) 262 d_oce_grid_corners = f_runoff.createDimension ('dst_grid_corners', oce_grid_corner_lon.shape[0] ) 263 d_oce_grid_rank = f_runoff.createDimension ('dst_grid_rank' , 2 ) 253 264 254 265 v_remap_matrix = f_runoff.createVariable ( 'remap_matrix', 'f8', ('num_links', 'num_wgts') ) … … 280 291 v_atm_grid_center_lon[:] = atm_grid_center_lon[:].ravel() 281 292 v_atm_grid_center_lat[:] = atm_grid_center_lat[:].ravel() 282 v_atm_grid_corner_lon[:] = atm_grid_corner_lon.reshape( (atm_jpi*atm_jpj, atm_grid_corners.__len__()) )283 v_atm_grid_corner_lat[:] = atm_grid_corner_lat.reshape( (atm_jpi*atm_jpj, atm_grid_corners.__len__()) )293 v_atm_grid_corner_lon[:] = atm_grid_corner_lon.reshape( (atm_jpi*atm_jpj, d_atm_grid_corners.__len__()) ) 294 v_atm_grid_corner_lat[:] = atm_grid_corner_lat.reshape( (atm_jpi*atm_jpj, d_atm_grid_corners.__len__()) ) 284 295 v_atm_grid_area [:] = atm_grid_area[:].ravel() 285 296 v_atm_grid_imask [:] = atm_grid_imask[:].ravel() … … 307 318 v_oce_grid_center_lon[:] = oce_grid_center_lon[:].ravel() 308 319 v_oce_grid_center_lat[:] = oce_grid_center_lat[:].ravel() 309 v_oce_grid_corner_lon[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, oce_grid_corners.__len__()) )310 v_oce_grid_corner_lat[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, oce_grid_corners.__len__()) )320 v_oce_grid_corner_lon[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, d_oce_grid_corners.__len__()) ) 321 v_oce_grid_corner_lat[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, d_oce_grid_corners.__len__()) ) 311 322 v_oce_grid_area [:] = oce_grid_area[:].ravel() 312 323 v_oce_grid_imask [:] = oce_grid_imask[:].ravel() 313 324 v_oce_grid_pmask [:] = oce_grid_pmask[:].ravel() 314 325 315 ## For diag, not used by OASIS316 326 v_atm_lon_addressed = f_runoff.createVariable ( 'src_lon_addressed' , 'f8', ('num_links',) ) 317 327 v_atm_lat_addressed = f_runoff.createVariable ( 'src_lat_addressed' , 'f8', ('num_links',) ) … … 368 378 v_oceCoast[:] = oceCoast.ravel() 369 379 370 f_runoff.close () 380 f_runoff.sync () 381 382 ## 383 f_runoff.close() 384 385 print ('The end') 386 387 ## ====================================================================================== -
TOOLS/MOSAIX/rangement.bash
r4153 r4172 17 17 # ============================================================ 18 18 19 for ATM in LMD144142 LMD9695 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico45019 for ATM in LMD144142 LMD9695 LMD256256 ICO30 ICO40 ICO450 dynamico30 dynamico40 dynamico450 20 20 do 21 for OCE in ORCA2.3 eORCA1.2 ORCA02521 for OCE in ORCA2.3 eORCA1.2 eORCA025 ORCA025 22 22 do 23 23 Liste=$(ls README_${OCE}x${ATM}.txt *${ATM}*_*${OCE}*.nc *${OCE}*_*${ATM}*.nc *${ATM}x${OCE}*.nc *${OCE}x${ATM}*.nc 2> /dev/null )
Note: See TracChangeset
for help on using the changeset viewer.