Ignore:
Timestamp:
08/08/22 10:39:24 (2 years ago)
Author:
omamce
Message:

O.M. : CPLRESTART
Switch complexe nco script to python

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/CPLRESTART/CreateRestartAtm4Oasis.bash

    r6226 r6228  
    2828# Usage exemples : 
    2929# 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 
    3031# CreateRestartAtm4Oasis.bash --oce ORCA2.3 /ccc/work/cont003/gencmip6/bedidil/SAVE8_ORCA2/STORE1/dynamico_grid.nc 
    3132# CreateRestartAtm4Oasis.bash --oce ORCA2.3 /ccc/work/cont003/gencmip6/bedidil/SAVE9_ORCA2_DYN30_1MO/STORE1/histmth.nc 
     
    4950if [[ $(hostname) = curie* ]] ; then arch=curie ; center=tgcc ; fi 
    5051if [[ $(hostname) = irene* ]] ; then arch=irene ; center=tgcc ; fi 
     52if [[ $(hostname) = lsce*  ]] ; then arch=spip  ; center=spip ; fi 
    5153 
    5254case ${arch} in 
    53     ( curie | irene ) 
    54     set +vx 
    55     module unload cdo nco ferret 
    56     module unload netcdf hdf5 
    57     module load python # /2.7.12 
    58     module load netcdf/4.3.3.1_hdf5_parallel # Version for XIOS 
     55    ( irene ) 
     56    set +e 
     57    R_IN=$(ccc_home -u igcmg --cccwork)/IGCM 
     58    TMPDIR=${CCCWORKDIR}/TMP 
     59    SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 
     60    MpiRun="time ccc_mprun" 
     61    PyRun="time ccc_mprun -n 1" # Needed to force python to run on one process only 
     62    module purge 
     63    module load hdf5 
     64    module load netcdf-c 
    5965    module load nco 
    60     R_IN=$(ccc_home -u igcmg --cccwork)/IGCM 
    61     TMPDIR=${SCRATCHDIR}/TMP 
    62     SUBMIT_DIR=${BRIDGE_MSUB_PWD:-${SUBMIT_DIR}} 
     66    module load cdo 
     67    module load python3 
     68    module load datadir/igcmg 
     69    module list 
     70    set -e 
     71    ;; 
     72    ( spip ) 
     73    R_IN=${HOME}/Scratch/IGCM 
     74    TMPDIR=${HOME}/Scratch/TMP 
     75    SUBMIT_DIR=$(pwd) 
     76    MpiRun="/opt/local/bin/mpirun -n 1" 
     77    PyRun="time" 
    6378    ;; 
    6479    ( * ) 
     
    87102    shift 
    88103done 
     104 
     105 
     106set -e 
    89107 
    90108#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} 
     
    135153    ncap2 --history --overwrite --fl_fmt=${FL_FMT} --script-file add_dim.nco flxat_fields_notime.nc tmp_flxat_fields_notime.nc 
    136154    mv tmp_flxat_fields_notime.nc flxat_fields_notime.nc 
    137  
    138 cat<<EOF > lonlat2xyz.nco 
    139 // Value at North Pole for DYNAMICO grid  
    140 where ( lat(:,:) >= 90.0d ) COTAUXXU = double(-tau_y) ; 
    141 where ( lat(:,:) >= 90.0d ) COTAUYYU = double( tau_x) ; 
    142 // Value at South Pole for DYNAMICO grid ? 
    143 EOF 
    144155else 
    145156    # lat/lon 
     
    158169    ATM=LMD${dim_lon}${dim_lat} 
    159170    (( n_lat = dim_lat - 1 )) 
    160 cat<<EOF > lonlat2xyz.nco 
    161 // Value at North Pole for LMDZ lon/lat grid 
    162 COTAUXXU(0,:) = double( -tau_x (0, 0) ) ; 
    163 COTAUYYU(0,:) = double( -tau_y (0, 0) ) ; 
    164 COTAUZZU(0,:) =  0.0d ;  
    165 // Value at south Pole for LMDZ lon/lat grid ? 
    166 COTAUXXU(${n_lat},:) = double( -tau_x (${n_lat}, 0) ) ; 
    167 COTAUYYU(${n_lat},:) = double( -tau_y (${n_lat}, 0) ) ; 
    168 COTAUZZU(${n_lat},:) =  0.0d ;  
    169 EOF 
     171 
    170172 
    171173fi 
     
    178180## =========================================================================== 
    179181 
    180 cat <<EOF > create_flxat.nco 
    181 // 
    182 *fract_oce_plus_sic  = double(fract_oce + fract_sic) ; // ocean fraction 
    183 *fract_oce_norm[y,x] = 0.0d ; *fract_sic_norm[y,x] = 0.0d ;  
    184 where (fract_oce_plus_sic >  0.0d ) fract_oce_norm = double(fract_oce)/fract_oce_plus_sic ; // free ocean vs. total ocean fraction 
    185 where (fract_oce_plus_sic >  0.0d ) fract_sic_norm = double(fract_sic)/fract_oce_plus_sic ; // sea ice vs. total ocean fraction 
    186 // 
    187 COTOTRAI[y,x] = double(precip-snow)    ;  //  Liquid precip 
    188 COTOTSNO[y,x] = double(snow)           ;  //  Solid precipitation 
    189 COTOTEVA[y,x] = double(evap_oce*fract_oce_norm + evap_sic*fract_sic_norm) ; 
    190 COICEVAP[y,x] = double(evap_sic)       ; // Evaporation on sea ice 
    191 COQSRMIX[y,x] = double(sols)           ; // Heat flux short wave 
    192 COQNSMIX[y,x] = double(soll)           ; // Heat flux minus short wave 
    193 COSHFICE[y,x] = double(sols)           ; // Heat flux short wave over sea ice 
    194 CONSFICE[y,x] = double(soll)           ; // Heat flux minus short wave over sea ice 
    195 CODFLXDT[y,x] = -20.0d       ; // W/m2 - dQ/dt 
    196 COCALVIN[y,x] =   0.0d       ; // Calving of icebergs, solid 
    197 COLIQRUN[y,x] =   0.0d       ; // River run-off , liquid 
    198 COWINDSP[y,x] = double( wind10m )      ; // Wind speed at 10m high 
    199 COTAUMOD[y,x] =   0.0d                 ; // Wind stress modulus 
    200 // Wind stress 
    201 *tau_x[y,x] = double(taux_oce*fract_oce_norm + taux_sic*fract_sic_norm) ;  
    202 *tau_y[y,x] = double(tauy_oce*fract_oce_norm + tauy_sic*fract_sic_norm) ; 
    203 COTAUMOD[y,x] = sqrt ( double(tau_x*tau_x + tau_y*tau_y) )  ;  
    204 // Wind stress, from east/north components to geocentric 
    205 *rpi = acos (-1.0d) ;  *rad = rpi / 180.0d  ;  
    206 COTAUXXU[y,x] = double( -tau_x * sin(rad * lon) - tau_y * sin(rad * lat) * cos(rad * lon) );  
    207 COTAUYYU[y,x] = double(  tau_x * cos(rad * lon) - tau_y * sin(rad * lat) * sin(rad * lon) ); 
    208 COTAUZZU[y,x] = double(  tau_y * cos(rad * lat) ) ; 
    209 // Value at North Pole 
    210 #include "lonlat2xyz.nco" 
    211 // 
    212 COTAUXXV[y,x] = COTAUXXU ; 
    213 COTAUYYV[y,x] = COTAUYYU ; 
    214 COTAUZZV[y,x] = COTAUZZU ; 
    215 // 
    216 EOF 
    217 ncap2 --overwrite --fl_fmt=${FL_FMT} --history --script-file create_flxat.nco flxat_fields_notime.nc tmp_flxat.nc 
    218  
    219 ncks --fl_fmt=${FL_FMT} --overwrite --history --variable lon,lat tmp_flxat.nc flxat.nc 
    220 [[ ${IsUnstructured} = yes ]] && ncks --fl_fmt=${FL_FMT} --history --append --variable bounds_lon,bounds_lat tmp_flxat.nc flxat.nc 
     182python3 create_flxat.py --IsUnstructured=${IsUnstructured} --input flxat_fields_notime.nc --output tmp_flxat.nc 
     183 
     184[[ ${IsUnstructured} = yes ]] && ncks --fl_fmt=${FL_FMT} --history --append --variable bounds_lon,bounds_lat flxat.nc  tmp_flxat.nc  
    221185ncks --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 
    222186 
     
    251215        --attribute Comment,global,o,c,"Preliminary attempt - Do not trust !" \ 
    252216        --attribute SVN_Author,global,o,c,"$Author$"                 \ 
    253         --attribute SVN_Date,global,o,c,"$Date$"                            \ 
     217        --attribute SVN_Date,global,o,c,"$Date$" \ 
    254218        --attribute SVN_Revision,global,o,c,"$Revision$"               \ 
    255         --attribute SVN_Id,global,o,c,"$Id$"                                \ 
     219        --attribute SVN_Id,global,o,c,"$Id$" \ 
    256220        flxat.nc 
    257221 
Note: See TracChangeset for help on using the changeset viewer.