Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ### Job Name
- #PBS -N JAN
- ### Project code
- #PBS -A UCLR0002
- #PBS -l walltime=01:00:00
- #PBS -q economy
- ### Merge output and error files
- #PBS -j oe
- ### Select 6 nodes with 72 CPUs each for a total of 72 MPI processes
- #PBS -l select=1:ncpus=1:mpiprocs=1
- #
- #_______________________________________________________________________#
- # #
- # Original Programmer : Taufiq Hassan #
- # Creation Date : Mar. 15, 2019 #
- # Last Update : Apr. 9, 2019 (by Taufiq) #
- #=======================================================================#
- # This batch script will prepare the AM4 output for ingesting it into
- # the AM4 nudging simulations. It vertically interpolaates and uses CDO
- # utility to add in the air temperature variable into the NCEP T60
- # Reanalysis datasets.
- #------------------------------------------------------------------------
- source /etc/profile.d/modules.sh
- module load cdo
- module load nco
- #
- anom=0.25
- days=(0.0 31.0 28.0 31.0 30.0 31.0 30.0 31.0 31.0 30.0 31.0 30.0 31.0)
- Ldays=(0.0 31.0 29.0 31.0 30.0 31.0 30.0 31.0 31.0 30.0 31.0 30.0 31.0)
- mon=(jan feb mar apr may jun jul aug sep oct nov dec)
- INPUT=/glade/scratch/thassan/gfdl_input/NUDGING_data
- for count in 1 2 3 4 5 6 7 8 9
- do
- export file$count=NCEP.T62.h060$count.nc
- export ifile$count=${mon[$(($count-1))]}
- done
- for count in 10 11 12
- do
- export file$count=NCEP.T62.h06$count.nc
- export ifile$count=${mon[$(($count-1))]}
- tmpfile=$INPUT/tmp.nc
- rfile=/glade/scratch/thassan/AM4_run2K/19990101.atmos_4xdaily.nc
- ofile=int_tmp.nc
- ofile2=int_tmp2.nc
- ofile3=int_tmp3.nc
- targetlevels=2.70000005,10.1000004,18.2999992,28.7999992,41.7999992,58.0,78.1999969,102.800003,132.600006,168.199997,210.100006,258.200012,312.5,372.0,435.700012,501.700012,568.099976,632.900024,694.299988,750.799988,801.400024,845.799988,883.799988,915.900024,942.5,964.400024,982.099976,995.0
- #
- cd $INPUT
- #
- number3=0.0
- number2=0.0
- for count in 1 2 3 4 5 6 7 8 9 10 11 12
- do
- inp=ifile$count
- number1=$(echo "$number3"+366.25+3*365|bc)
- number3=$(echo "$number2"+"${days[$(($count-0))]}"|bc)
- number2=$(echo "$number1"-366.25-3*365+"${days[$(($count-0))]}"|bc)
- echo $number1 $number2 $(echo 366+3*365+"$number3"|bc)
- if [ $count == 1 ]
- then
- ncks -O -d time,$number1,$(echo 366+3*365.0+"${days[$(($count-0))]}"|bc) $rfile ${!inp}.nc
- else
- ncks -O -d time,$number1,$(echo 366+3*365+"$number3"|bc) $rfile ${!inp}.nc # Splitting file into monthly files
- fi
- done
- #
- #
- for count in 1 2 3 4 5 6 7 8 9 10 11 12
- do
- inp=ifile$count
- tmp=file$count
- cp ${!tmp} $tmpfile # Copy target format
- cdo intlevel,$targetlevels ${!inp}.nc $ofile # vertical interpolation
- ncap2 -s 'where(land_mask==0)temp=-999.0' $ofile $ofile3
- #cp $ofile $ofile3
- ncrename -v temp,T $ofile3 # Change variable name from temp to T
- ncks -A -v T $ofile3 $tmpfile # put T into the target format file
- ncks -C -x -v time $tmpfile $ofile2 # remove the new time variable from target
- ncks -A -v time ${!tmp} $ofile2 # Add the orginal time variable from target file
- mv $ofile2 NCEP.T62.h0$(($count+48)).nc
- rm -rf $tmpfile $ofile $ofile2 $ofile3 ${!inp}.nc
- done
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement