Ignore:
Timestamp:
04/07/23 15:40:03 (15 months ago)
Author:
omamce
Message:

O.M.

CPLRESTART

Remove most nco commands : all is handled by the python script
Adapt to be more tolerant when inout variables are missing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/CPLRESTART/CreateRestartAtm4Oasis.bash

    r6327 r6366  
    2727 
    2828# Usage exemples : 
    29 # CreateRestartAtm4Oasis.bash --oce ORCA2.3 /ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/ATM/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_histmth.nc 
    30 # CreateRestartAtm4Oasis.bash --oce eORCA1.2 /ccc/store/cont003/gencmip6/p86maf/IGCM_OUT/IPSLCM6/PROD/piControl/CM61-LR-pi-03/ATM/Output/MO/CM61-LR-pi-03_23400101_23491231_1M_histmth.nc 
    31 # CreateRestartAtm4Oasis.bash --oce ORCA2.3 /ccc/work/cont003/gencmip6/bedidil/SAVE8_ORCA2/STORE1/dynamico_grid.nc 
    32 # CreateRestartAtm4Oasis.bash --oce ORCA2.3 /ccc/work/cont003/gencmip6/bedidil/SAVE9_ORCA2_DYN30_1MO/STORE1/histmth.nc 
     29# CreateRestartAtm4Oasis.bash --oce ORCA2.3    /ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/ATM/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_histmth.nc 
     30# CreateRestartAtm4Oasis.bash --oce eORCA1.2   /ccc/store/cont003/gencmip6/p86maf/IGCM_OUT/IPSLCM6/PROD/piControl/CM61-LR-pi-03/ATM/Output/MO/CM61-LR-pi-03_23400101_23491231_1M_histmth.nc 
     31# CreateRestartAtm4Oasis.bash --oce ORCA2.3    /ccc/work/cont003/gencmip6/bedidil/SAVE8_ORCA2/STORE1/dynamico_grid.nc 
     32# CreateRestartAtm4Oasis.bash --oce ORCA2.3    /ccc/work/cont003/gencmip6/bedidil/SAVE9_ORCA2_DYN30_1MO/STORE1/histmth.nc 
     33# CreateRestartAtm4Oasis.bash --oce eORCA1.4.2 /ccc/scratch/cont003/gencmip6/p86caub/RUN_DIR/9114048_89294/ICOLOR-SROUT.11.NBP80.HISTMTH.89294/histday.nc 
    3334 
    3435## =========================================================================== 
     
    5657    set +e 
    5758    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM 
    58     TMPDIR=${CCCWORKDIR}/TMP 
    59     SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 
     59    TMPDIR=${CCCSCRATCHDIR}/TMP/CPLRESTART 
     60    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR:-$(pwd)}} 
    6061    MpiRun="time ccc_mprun" 
    6162    PyRun="time ccc_mprun -n 1" # Needed to force python to run on one process only 
     
    6364    module load hdf5 
    6465    module load netcdf-c 
    65     module load nco/4.9.1 
    66     module load cdo/1.9.5 
    67     module load python3/3.7.2 
     66    module load nco # /4.9.1 
     67    module load cdo # /1.9.5 
     68    module load python3 # /3.7.2 
    6869    module load datadir/igcmg 
    6970    module list 
     
    8485set -o xtrace 
    8586set -e 
     87 
     88mkdir -p ${TMPDIR}  
     89 
     90cd ${TMPDIR} 
    8691 
    8792while [[ ${1} = -* ]] ; do 
     
    108113#AtmFile=${1:-/ccc/store/cont003/dsm/p25sepul/IGCM_OUT/IPSLCM5A2/PROD/piControl/CM5A2.1.pi.00/ATM/Output/MO/CM5A2.1.pi.00_40100101_40191231_1M_histmth.nc} 
    109114#AtmFile=${1:-/ccc/work/cont003/gencmip6/bedidil/SAVE8_ORCA2/STORE1/dynamico_grid.nc} 
    110 AtmFile=${1:-/ccc/work/cont003/gencmip6/bedidil/SAVE9_ORCA2_DYN30_1MO/STORE1/histmth.nc} 
     115AtmFile=${1:-/ccc/scratch/cont003/gencmip6/p86caub/RUN_DIR/9114048_89294/ICOLOR-SROUT.11.NBP80.HISTMTH.89294/histday.nc} 
    111116 
    112117# 
     
    115120FL_FMT=64bit 
    116121 
    117 ## 
    118 ## Extract variables 
    119 ## =========================================================================== 
    120 ncks --overwrite --fl_fmt=${FL_FMT} --history --dimension time_counter,0,0 --variable lon,lat,sols,soll,fract_oce,fract_sic,precip,snow,evap_sic,evap_oce,wind10m,taux_oce,tauy_oce,taux_sic,tauy_sic ${AtmFile} flxat_fields.nc 
    121 ncwa --overwrite --fl_fmt=${FL_FMT} --history --average time_counter flxat_fields.nc flxat_fields_notime.nc # remove time dimension  
    122 ncatted --history --attribute history,global,d,c,""  flxat_fields_notime.nc          # cleaning of history attributes 
    123122 
    124 ## 
    125 ## Determines if the file is unstructured (Dynamico) or lon/lat (LMDZ) 
    126 ## Set atmosphere name 
    127 ## =========================================================================== 
    128 Count=$(ncdump -h flxat_fields_notime.nc | grep nvertex | wc -l) 
     123Count=$(ncdump -h  ${AtmFile} | grep nvertex | wc -l) 
    129124if [[ ${Count} -gt 0 ]] ; then 
    130     IsUnstructured=yes 
    131     dim_cell=$(ncdump -h flxat_fields_notime.nc |& grep "cell *=" | awk '{print $3}' ) # Get nominal DYNAMICO resolution (nbp parameter) 
     125    IsUnstructured=True 
     126    dim_cell=$(ncdump -h  ${AtmFile} |& grep "cell *=" | awk '{print $3}' ) # Get nominal DYNAMICO resolution (nbp parameter) 
    132127    ico_nbp=$( echo "sqrt(($dim_cell-2)/10)" | bc -l | sed 's/\..*//' ) 
    133128    ATM=ICO${ico_nbp} 
    134     ncrename --history --dimension cell,y flxat_fields_notime.nc 
    135 cat <<EOF > add_dim.nco 
    136 defdim("x",1) ; 
    137 lon      [y,x] = lon       ; 
    138 lat      [y,x] = lat       ; 
    139 sols     [y,x] = sols      ; 
    140 soll     [y,x] = soll      ; 
    141 fract_oce[y,x] = fract_oce ; 
    142 fract_sic[y,x] = fract_sic ; 
    143 precip   [y,x] = precip    ; 
    144 snow     [y,x] = snow      ; 
    145 evap_sic [y,x] = evap_sic  ; 
    146 evap_oce [y,x] = evap_oce  ; 
    147 wind10m  [y,x] = wind10m   ; 
    148 taux_oce [y,x] = taux_oce  ; 
    149 tauy_oce [y,x] = tauy_oce  ; 
    150 taux_sic [y,x] = taux_sic  ; 
    151 tauy_sic [y,x] = tauy_sic  ; 
    152 EOF 
    153     ncap2 --history --overwrite --fl_fmt=${FL_FMT} --script-file add_dim.nco flxat_fields_notime.nc tmp_flxat_fields_notime.nc 
    154     mv tmp_flxat_fields_notime.nc flxat_fields_notime.nc 
     129     
    155130else 
    156131    # lat/lon 
    157     IsUnstructured=no 
    158     dim_lat=$(ncdump -h flxat_fields_notime.nc | grep "lat *=" | awk '{print $3}' ) 
    159     dim_lon=$(ncdump -h flxat_fields_notime.nc | grep "lon *=" | awk '{print $3}' ) 
    160     ncrename --history --dimension lon,x flxat_fields_notime.nc 
    161     ncrename --history --dimension lat,y flxat_fields_notime.nc 
    162 cat <<EOF > add_dim.nco 
    163 lon[y,x] = lon ; 
    164 lat[y,x] = lat ; 
    165 EOF 
    166     ncap2 --history --overwrite --fl_fmt=${FL_FMT} --script-file add_dim.nco flxat_fields_notime.nc tmp_flxat_fields_notime.nc 
    167     mv tmp_flxat_fields_notime.nc flxat_fields_notime.nc 
     132    IsUnstructured=False 
     133    dim_lat=$(ncdump -h ${AtmFile} | grep "lat *=" | awk '{print $3}' ) 
     134    dim_lon=$(ncdump -h ${AtmFile} | grep "lon *=" | awk '{print $3}' ) 
     135    #ncrename --history --dimension lon,x flxat_fields_notime.nc 
     136    #ncrename --history --dimension lat,y flxat_fields_notime.nc 
    168137    (( dim_lat = dim_lat - 1 )) 
    169138    ATM=LMD${dim_lon}${dim_lat} 
    170139    (( n_lat = dim_lat - 1 )) 
    171  
    172  
    173140fi 
    174141 
    175142echo "Version atmosphere : " ${ATM} 
    176  
    177143 
    178144## 
     
    180146## =========================================================================== 
    181147 
    182 python3 create_flxat.py --IsUnstructured=${IsUnstructured} --input flxat_fields_notime.nc --output tmp_flxat.nc 
     148python3 ${SUBMIT_DIR}/create_flxat.py --IsUnstructured=${IsUnstructured} --input ${AtmFile} --output flxat.nc 
    183149 
    184 #this is not needed anymore since bounds are included in flxat.py if they exist 
    185 #[[ ${IsUnstructured} = yes ]] && ncks --fl_fmt=${FL_FMT} --history --append --variable bounds_lon,bounds_lat tmp_flxat.nc 
    186 ncks --fl_fmt=${FL_FMT} --append --history --variable COTAUXXU,COTAUYYU,COTAUZZU,COTAUXXV,COTAUYYV,COTAUZZV,COTOTRAI,COTOTSNO,COTOTEVA,COICEVAP,COQSRMIX,COQNSMIX,COSHFICE,CONSFICE,CODFLXDT,COCALVIN,COLIQRUN,COWINDSP,COTAUMOD tmp_flxat.nc flxat.nc 
     150#ncks --fl_fmt=${FL_FMT} --append --history --variable COTAUXXU,COTAUYYU,COTAUZZU,COTAUXXV,COTAUYYV,COTAUZZV,COTOTRAI,COTOTSNO,COTOTEVA,COICEVAP,COQSRMIX,COQNSMIX,COSHFICE,CONSFICE,CODFLXDT,COCALVIN,COLIQRUN,COWINDSP,COTAUMOD tmp_flxat.nc flxat.nc 
    187151 
    188152## 
     
    191155 
    192156UUID=$(uuid) 
    193 NCO="$(ncks --version |& tail -1|sed 's/ncks //')" 
     157NCO="$(ncks --version |& tail -1 | sed 's/ncks //')" 
    194158ncatted --history \ 
    195159        --attribute nco_openmp_thread_number,global,d,,                       \ 
    196         --attribute source,global,o,c,"IPSL Earth system model"               \ 
    197         --attribute group,global,o,c,"ICMC IPSL Climate Modelling Center"     \ 
    198         --attribute Institution,global,o,c,"IPSL https://www.ipsl.fr"         \ 
    199         --attribute Model,global,o,c,"${ATM} http://lmdz.lmd.jussieu.fr"      \ 
    200         --attribute Ocean,global,o,c,"${OCE} https://www.nemo-ocean.eu"       \ 
    201160        --attribute production,global,o,c,"$(finger ${LOGNAME} | head -1 | awk '{print $4, $5}')" \ 
    202         --attribute originalFiles,global,o,c,"${AtmFile}"                     \ 
    203         --attribute directory,global,o,c,"$(pwd)"                             \ 
    204         --attribute description,global,o,c,"Fields needed by OASIS-MCT"       \ 
    205         --attribute timeStamp,global,o,c,"$(date)"                            \ 
    206         --attribute Program,global,o,c,"Generated by ${0}"                    \ 
     161        --attribute Program,global,o,c,"Generated by ${0}"      \ 
     162        --attribute originalFiles,global,o,c,"${AtmFile}"       \ 
    207163        --attribute uuid,global,o,c,"${UUID}"                                 \ 
    208         --attribute HOSTNAME,global,o,c,"$(hostname)"                         \ 
    209         --attribute LOGNAME,global,o,c,"$(whoami)"                            \ 
    210164        --attribute NCO,global,o,c,"NCO netCDF Operator ${NCO} http://nco.sourceforge.net" \ 
    211         --attribute OS,global,o,c,"$(uname -o)"                               \ 
    212         --attribute release,global,o,c,"$(uname -r)"                          \ 
    213         --attribute hardware,global,o,c,"$(uname -i)"                         \ 
    214         --attribute directory,global,o,c,"$(pwd)"                             \ 
    215165        --attribute Comment,global,o,c,"${Comment}"                           \ 
    216         --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \ 
    217         --attribute SVN_Author,global,o,c,"$Author$"                 \ 
    218         --attribute SVN_Date,global,o,c,"$Date$" \ 
    219         --attribute SVN_Revision,global,o,c,"$Revision$"               \ 
    220         --attribute SVN_Id,global,o,c,"$Id$" \ 
    221166        flxat.nc 
    222  
    223167 
    224168## 
     
    229173ncks --history --variable COCALVIN flxat_${ATM}_maskFrom_${OCE}.nc icshf_${ATM}_maskFrom_${OCE}.nc 
    230174 
    231 ## 
    232 ## Cleaning 
    233 ## =========================================================================== 
    234 rm -f flxat_fields.nc flxat_fields_notime.nc tmp_flxat.nc 
    235  
    236175## =========================================================================== 
    237176## 
Note: See TracChangeset for help on using the changeset viewer.