Changeset 3097 for TOOLS


Ignore:
Timestamp:
01/25/17 16:51:45 (8 years ago)
Author:
jgipsl
Message:

Added case to create yearly files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/INTERP_NUDGE/interp_from_era.ksh

    r2172 r3097  
    1313 
    1414# gridfile : file grilles_gcm.nc containing longitudes and latitudes of the destination grid 
    15 gridfile=/ccc/store/cont003/dsm/p86ghatt/IGCM_OUT/LMDZ/ELC-128x118x39/ATM/Output/Grid/ELC-128x118x39_grilles_gcm.nc 
     15gridfile=/ccc/store/cont003/dsm/p86ghatt/IGCM_OUT/LMDZ/ELI-144x142x79/ATM/Output/Grid/ELI-144x142x79_1979_grilles_gcm.nc 
    1616 
    1717# indir : path for directory containing the files to interpolate 
    1818#indir=/u/rech/psl/rpsl376/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_PL 
    19 indir=/ccc/store/cont003/subipsl/subipsl/dmf_import/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_PL 
     19indir=/ccc/work/cont003/subipsl/subipsl/ERAI/NETCDF/GLOBAL_075/4xdaily/AN_PL/ 
    2020# insuffix : suffix in input files 
    2121insuffix=.aphei.GLOBAL_075.nc 
     
    2626# Variables for output : 
    2727# outdir : directory to store output files 
    28 outdir=$WORKDIR/NUDGEFILES/ERAI-128x118x39 
     28outdir=$WORKDIR/NUDGEFILES/ERAI-144x142x79 
    2929# outsuffix : suffix to output files 
    3030outsuffix=_erai.nc 
     
    3232# Time variables : 
    3333# first_year : first year to interpolate 
    34 first_year=2000 
     34first_year=1979 
    3535# last_year : last year to interpolate 
    36 last_year=2000 
     36last_year=2016 
    3737 
     38# Frequency of output files : yearly or monthly 
     39# OutFreq='monthly' or OutFrequ='yearly' 
     40OutFreq='yearly' 
     41  
    3842# rundir : temporary run directory 
    3943rundir=`pwd`/rundir 
     
    99103 
    100104 
     105    # Do different treatement if monthly or yearly output files are wanted 
     106    if [[ $OutFreq = 'monthly' ]] ; then 
    101107    # 2 - Loop over all files and add a time step :  
    102108    #     take the first time step from next coming month and add last in current month 
     
    139145    done 
    140146 
     147    elif [[ $OutFreq = 'yearly' ]] ; then 
     148        # 3a. Concate the monthly files into yearly files 
     149        mkdir -p  ${outdir}/allyears 
     150         
     151        year=$first_year 
     152        while [[ ${year} -le ${last_year} ]] ; do 
     153        echo Now merge year=$year for variable $var 
     154            cdo mergetime ${outdir}/${year}/${var}_${year}* ${outdir}/allyears/${var}_${year}${outsuffix} 
     155            year=`expr $year + 1` 
     156        done 
    141157 
     158        # 3b.Add a last timestep in the end of the yearly files from next coming year 
     159            year=$first_year 
     160            while [[ ${year} -le ${last_year} ]] ; do 
     161              # Find next month and year 
     162              nextyear=`expr $year + 1` 
     163                 
     164              file=${outdir}/allyears/${var}_${year}${outsuffix} 
     165              nextfile=${outdir}/allyears/${var}_${nextyear}${outsuffix} 
     166              if [ -f ${nextfile} ] ; then 
     167                 echo First time step from file ${nextfile} will be added last in file ${file} 
     168                 cp -f $file file.nc 
     169                 cp -f $nextfile next.nc 
     170                 ncks -O -d TIME,0,0 next.nc tmp.nc 
     171                 ncrcat -O file.nc tmp.nc tmptot.nc 
     172                 mv tmptot.nc $file 
     173              else 
     174                 echo Next file ${nextfile} does not exist. Nothing will be done for ${file} 
     175              fi 
     176 
     177              # Update month and year 
     178              year=$nextyear 
     179          done 
     180    fi 
    142181     
    143182# End of loop variable list 
Note: See TracChangeset for help on using the changeset viewer.