Changeset 4320 for TOOLS


Ignore:
Timestamp:
03/15/19 17:39:05 (5 years ago)
Author:
omamce
Message:

O.M.: MOSAIX. Correct netcdf header

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/CreateWeightsMask.bash

    r4317 r4320  
    4141# CplModel=ORCA2.3xICO40 
    4242# CplModel=eORCA1.2xICO40 
     43# CplModel=eORCA1.2xICO450 
    4344# CplModel=eORCA1.2xLMD256256 
    44 # CplModel=eORCA1.2xICO450 
     45# CplModel=eORCA025.1xLMD144142 
    4546# CplModel=eORCA025.1xLMD256256 
    4647# 
     
    6465echo ${Titre}"Defines model"${Norm} 
    6566# ================================= 
    66 #CplModel=ORCA2.3xLMD9695 
     67CplModel=ORCA2.3xLMD9695 
    6768#CplModel=ORCA2.3xICO30 
    6869#CplModel=ORCA2.3xICO40 
    69 CplModel=eORCA1.2xLMD144142 
     70#CplModel=eORCA1.2xLMD144142 
    7071#CplModel=eORCA1.2xLMD256256 
    7172#CplModel=eORCA1.2xICO40 
     
    7374#CplModel=eORCA025.1xLMD256256 
    7475 
    75 Version="v3" ; Comment="Preliminary attempt - Do not trust !" 
     76Version="v0" ; Comment="Fully tested in IPSLCM6 eORCA1.2 x LMD 144x142" 
    7677 
    7778# If available, get model name from job name 
     
    120121## Classic cases for IPSLCM6 
    121122AtmOceFluxes="   Direction=a2o,Order=1st,Quantity=false,Renormalize=false,atmGrid=t,oceGrid=t,useArea=true,maskSrc=true,maskDst=true,Name=HeatWaterFluxes" # Heat and water fluxes 
    122 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 
    123 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 
    124 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 
    125 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 
    126 AtmOceQuantity=" Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=t,oceGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=Quantity"   # e.g. runoff 
     123OceAtmTemp="     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 
     124OceAtmTemp2nd="  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 
     125AtmOceStressU="  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 
     126AtmOceStressV="  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 
     127AtmOceQuantity=" Direction=a2o,Order=1st,Quantity=true,Renormalize=false,atmGrid=t,oceGrid=t,useArea=false,maskSrc=true,maskDst=true,Name=Quantity"        # e.g. runoff 
    127128# For new parameterization 
    128129AtmOceTemp="     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 
     
    148149#CommandList=( ${AtmOceFluxes} Runoff Calving Grids ) 
    149150#CommandList=( ${AtmOceFluxes} ${OceAtmTemp} ) 
     151#CommandList=( ${AtmOceFluxes} ) 
    150152#CommandList=( Runoff ) 
    151153#CommandList=( Runoff Calving Grids ) 
     
    232234if [[ $(hostname) = lsce*     ]] ; then arch=spip  ; center=spip ; fi 
    233235 
    234 PROGRAM=$(basename ${0}) 
    235  
    236236case ${arch} in 
    237237    ( irene ) 
     
    241241    TMPDIR=${CCCWORKDIR}/TMP 
    242242    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 
    243     PROGRAM=${BRIDGE_MSUB_REQNAME} 
    244243    MpiRun="time ccc_mprun" 
    245244    PyRun="time ccc_mprun -n 1" # Needed to force python to run on one process only 
     
    319318setValues ${DefaultValues} 
    320319 
     320OutFileName=${srcGrid}${src}_to_${dstGrid}${dst}_${FullName} 
     321 
    321322cp iodef_oce_to_atm.xml   iodef.xml 
    322323 
     
    331332python3 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 
    332333python3 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 
    333 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} 
     334python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                               -k name  -v dia_${OutFileName} 
    334335python3 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}" 
    335336python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="source_grid"]' -t ${srcDomainType} 
     
    338339python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_src"]'                    -k type  -v ${srcDomainType} 
    339340python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                    -k type  -v ${dstDomainType} 
    340 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 
     341python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain' -k weight_filename -v rmp_${OutFileName}.nc 
    341342python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order -v 1 
    342343python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="normalization"]' -t false 
     
    347348python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k use_area    -v false 
    348349 
    349 cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${FullName}.xml 
     350cp iodef.xml iodef_${OutFileName}.xml 
    350351ln -fs ${OCE}_coordinates_mask.nc  oce_grid.nc 
    351352ln -fs ${ATM}_grid.nc              atm_grid.nc 
    352353 
    353354${MpiRun} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 
     355 
     356ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  rmp_${OutFileName}.nc 
     357ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  dia_${OutFileName}.nc 
     358 
     359ncatted --history --attribute normalization,global,o,c,"false"  rmp_${OutFileName}.nc 
     360ncatted --history --attribute normalization,global,o,c,"false"  dia_${OutFileName}.nc 
     361 
     362ncatted --history --attribute Quantity,global,o,c,"false"  rmp_${OutFileName}.nc 
     363ncatted --history --attribute Quantity,global,o,c,"false"  dia_${OutFileName}.nc 
     364 
     365ncatted --history --attribute UseArea,global,o,c,"false"  rmp_${OutFileName}.nc 
     366ncatted --history --attribute UseArea,global,o,c,"false"  dia_${OutFileName}.nc 
    354367 
    355368## 
     
    419432fi 
    420433 
    421 ncks --history --alphabetize  --append --variable aire atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc 
     434ncks --history --alphabetize --append --variable aire atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc 
    422435ncatted  --history --attribute units,aire,m,c,"m^2" ${ATM}_grid_maskFrom_${OCE}.nc 
    423436 
    424437[[ ${atm} = *ico* ]] && ncks --alphabetize --history --append --variable bounds_lon,bounds_lat atm_grid.nc ${ATM}_grid_maskFrom_${OCE}.nc 
     438 
    425439 
    426440 
     
    481495        ;; 
    482496    esac 
     497 
     498    OutFileName=${srcGrid}${src}_to_${dstGrid}${dst}_${FullName} 
    483499     
    484500    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_read"]/domain_definition/domain[@id="domain_dst"]'                     -k type  -v ${dstDomainType} 
     
    488504    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]'                      -k type  -v ${dstDomainType} 
    489505     
    490     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 
     506    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_${OutFileName}.nc 
    491507    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k order       -v ${numOrder} 
    492508    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/domain_definition/domain[@id="domain_dst"]/interpolate_domain'   -k quantity    -v ${Quantity} 
     
    494510    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} 
    495511     
    496     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} 
     512    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]'                                 -k name -v dia_${OutFileName} 
    497513    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}" 
    498514    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="dest_grid"]'     -t ${dstDomainType} 
     
    503519    python3 update_xml.py -i iodef.xml -n 'context[@id="interpol_run"]/file_definition/file[@id="dia"]/variable[@name="use_area"]'      -t ${useArea} 
    504520     
    505     cp iodef.xml iodef_${srcGrid}${src}_to_${dstGrid}${dst}_${FullName}.xml 
     521    cp iodef.xml iodef_${OutFileName}.xml 
    506522    ${MpiRun} ./interpol.exe --mask_src=${maskSrc} --mask_dst=${maskDst} --use_area=${useArea} 
     523 
     524    case ${numOrder} in 
     525        ( 1 ) 
     526        ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  rmp_${OutFileName}.nc 
     527        ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  dia_${OutFileName}.nc 
     528        ;; 
     529        ( 2 ) 
     530        ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 2nd order"  rmp_${OutFileName}.nc 
     531        ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 2nd order"  dia_${OutFileName}.nc 
     532        ;; 
     533    esac 
     534 
     535    ncatted --history --attribute normalization,global,o,c,"${Renormalize}"  rmp_${OutFileName}.nc 
     536    ncatted --history --attribute normalization,global,o,c,"${Renormalize}"  dia_${OutFileName}.nc 
     537 
     538    ncatted --history --attribute Quantity,global,o,c,"${Quantity}"  rmp_${OutFileName}.nc 
     539    ncatted --history --attribute Quantity,global,o,c,"${Quantity}"  dia_${OutFileName}.nc 
     540 
     541    ncatted --history --attribute UseArea,global,o,c,"${useArea}"  rmp_${OutFileName}.nc 
     542    ncatted --history --attribute UseArea,global,o,c,"${useArea}"  dia_${OutFileName}.nc 
     543     
    507544done 
    508545 
     
    529566            --attribute description,global,o,c,"Fields needed by OASIS-MCT"       \ 
    530567            --attribute title,global,o,c,"${InFile}.nc"                           \ 
    531             --attribute Program,global,o,c,"Generated by ${PROGRAM}"              \ 
     568            --attribute Program,global,o,c,"Generated by CreateWeightsMask"       \ 
    532569            --attribute timeStamp,global,o,c,"$(date)"                            \ 
    533570            --attribute HOSTNAME,global,o,c,"$(hostname)"                         \ 
     
    545582            ${InFile} 
    546583done 
     584 
     585# Duplicate with no global attribute to avoid erasing attributes in other files 
     586cp ${ATM}_grid_maskFrom_${OCE}.nc ${ATM}_grid_maskFrom_${OCE}_noglobal.nc 
     587ncatted --history --attribute ,global,d,c, ${ATM}_grid_maskFrom_${OCE}_noglobal.nc 
     588 
    547589## 
    548590echo ${Titre}"Update and complete weight files to fit OASIS requested format"${Norm} 
     
    561603    ncrename --history --variable  dst_idx,dst_address  ${rmpFile} 
    562604    ncrename --history --variable  weight,remap_matrix  ${rmpFile} 
    563     case ${rmpFile} in 
    564         ( *1storder* ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 1st order"  ${rmpFile} ;; 
    565         ( *2ndorder* ) ncatted --history --attribute map_method,global,o,c,"Conservative Remapping - 2nd order"  ${rmpFile} ;; 
    566     esac 
    567     case ${rmpFile} in 
    568         ( *_Normalized*   ) ncatted --history --attribute map_method,global,o,c,"Normalization: true"  ${rmpFile} ;; 
    569         ( *_UnNormalized* ) ncatted --history --attribute map_method,global,o,c,"Normalization: false" ${rmpFile} ;; 
    570     esac 
    571     case ${rmpFile} in 
    572         ( *Integrated*   ) ncatted --history --attribute map_method,global,o,c,"Quantity: true"  ${rmpFile} ;; 
    573         ( *Surfacic*     ) ncatted --history --attribute map_method,global,o,c,"Quantity: false" ${rmpFile} ;; 
    574     esac 
     605 
     606   
    575607    ncatted --history --attribute conventions,global,o,c,"SCRIP"   ${rmpFile} 
    576608    ncatted --history --attribute normalization,global,o,c,"none"  ${rmpFile} 
     
    674706        cp add_varatm.nco add_varatm_$(basename ${rmpFile} .nc)_o_to_a.nco 
    675707        if [[ ${o_to_a} = true ]] ; then 
    676             ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_o_to_a.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     708            ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_o_to_a.nco ${ATM}_grid_maskFrom_${OCE}_noglobal.nc ${rmpFile} 
    677709            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 
    678710            mv rmp_tmp.nc ${rmpFile} 
     
    682714        cp add_varatm.nco add_varatm_$(basename ${rmpFile} .nc)_a_to_o.nco 
    683715        if [[ ${a_to_o} = true ]] ; then 
    684             ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_a_to_o.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     716            ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_a_to_o.nco ${ATM}_grid_maskFrom_${OCE}_noglobal.nc ${rmpFile} 
     717            exit 
    685718            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 
    686719            mv rmp_tmp.nc ${rmpFile} 
     
    718751        cp add_varatm.nco add_varatm_$(basename ${rmpFile} .nc)_o_to_a.nco 
    719752        if [[ ${o_to_a} = true ]] ; then 
    720             ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_o_to_a.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     753            ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_o_to_a.nco ${ATM}_grid_maskFrom_${OCE}_noglobal.nc ${rmpFile} 
    721754            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 
    722755            mv rmp_tmp.nc ${rmpFile} 
     
    726759        cp add_varatm.nco add_varatm_$(basename ${rmpFile} .nc)_a_to_o.nco 
    727760        if [[ ${a_to_o} = true ]] ; then 
    728             ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_a_to_o.nco ${ATM}_grid_maskFrom_${OCE}.nc ${rmpFile} 
     761            ncap2 --history --append --script-file add_varatm_$(basename ${rmpFile} .nc)_a_to_o.nco ${ATM}_grid_maskFrom_${OCE}_noglobal.nc ${rmpFile} 
    729762            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 
    730763            mv rmp_tmp.nc ${rmpFile} 
     
    733766done 
    734767ls -al ${OCE}_coordinates_mask.nc 
    735  
    736768## 
    737769## ============================================================================ 
     
    882914 
    883915for 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 
    884     ncatted --attribute uuid,global,o,c,"${UUID}" ${file} 
     916    ncatted --history --attribute uuid,global,o,c,"${UUID}" ${file} 
    885917    echo "$(shasum ${file})" >> README.txt 
    886918done 
Note: See TracChangeset for help on using the changeset viewer.