Advertisement
Guest User

Untitled

a guest
Apr 9th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.24 KB | None | 0 0
  1. #!/bin/bash
  2. ### Job Name
  3. #PBS -N JAN
  4. ### Project code
  5. #PBS -A UCLR0002
  6. #PBS -l walltime=01:00:00
  7. #PBS -q economy
  8. ### Merge output and error files
  9. #PBS -j oe
  10. ### Select 6 nodes with 72 CPUs each for a total of 72 MPI processes
  11. #PBS -l select=1:ncpus=1:mpiprocs=1
  12. #
  13.  
  14. #_______________________________________________________________________#
  15. #                                                                       #
  16. # Original Programmer : Taufiq Hassan                                   #
  17. # Creation Date : Mar. 15, 2019                                         #
  18. # Last Update : Apr. 9, 2019 (by Taufiq)                                #
  19. #=======================================================================#
  20. # This batch script will prepare the AM4 output for ingesting it into
  21. # the AM4 nudging simulations. It vertically interpolaates and uses CDO
  22. # utility to add in the air temperature variable into the NCEP T60
  23. # Reanalysis datasets.
  24. #------------------------------------------------------------------------
  25.  
  26. source /etc/profile.d/modules.sh
  27. module load cdo
  28. module load nco
  29. #
  30. anom=0.25
  31. 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)
  32. 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)
  33. mon=(jan feb mar apr may jun jul aug sep oct nov dec)
  34. INPUT=/glade/scratch/thassan/gfdl_input/NUDGING_data
  35. for count in 1 2 3 4 5 6 7 8 9
  36. do
  37. export file$count=NCEP.T62.h060$count.nc
  38. export ifile$count=${mon[$(($count-1))]}
  39. done
  40. for count in 10 11 12
  41. do
  42. export file$count=NCEP.T62.h06$count.nc
  43. export ifile$count=${mon[$(($count-1))]}
  44. tmpfile=$INPUT/tmp.nc
  45. rfile=/glade/scratch/thassan/AM4_run2K/19990101.atmos_4xdaily.nc
  46. ofile=int_tmp.nc
  47. ofile2=int_tmp2.nc
  48. ofile3=int_tmp3.nc
  49. 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
  50. #
  51. cd $INPUT
  52. #
  53. number3=0.0
  54. number2=0.0
  55. for count in 1 2 3 4 5 6 7 8 9 10 11 12
  56. do
  57. inp=ifile$count
  58. number1=$(echo "$number3"+366.25+3*365|bc)
  59. number3=$(echo "$number2"+"${days[$(($count-0))]}"|bc)
  60. number2=$(echo "$number1"-366.25-3*365+"${days[$(($count-0))]}"|bc)
  61. echo $number1 $number2 $(echo 366+3*365+"$number3"|bc)
  62. if [ $count == 1 ]
  63. then
  64.         ncks -O -d time,$number1,$(echo 366+3*365.0+"${days[$(($count-0))]}"|bc) $rfile ${!inp}.nc
  65. else
  66.         ncks -O -d time,$number1,$(echo 366+3*365+"$number3"|bc) $rfile ${!inp}.nc # Splitting file into monthly files
  67. fi
  68. done
  69. #
  70. #
  71. for count in 1 2 3 4 5 6 7 8 9 10 11 12
  72. do
  73. inp=ifile$count
  74. tmp=file$count
  75. cp ${!tmp} $tmpfile # Copy target format
  76. cdo intlevel,$targetlevels ${!inp}.nc $ofile # vertical interpolation
  77. ncap2 -s 'where(land_mask==0)temp=-999.0' $ofile $ofile3
  78. #cp $ofile $ofile3
  79. ncrename -v temp,T $ofile3 # Change variable name from temp to T
  80. ncks -A -v T $ofile3 $tmpfile # put T into the target format file
  81. ncks -C -x -v time $tmpfile $ofile2 # remove the new time variable from target
  82. ncks -A -v time ${!tmp} $ofile2 # Add the orginal time variable from target file
  83. mv $ofile2 NCEP.T62.h0$(($count+48)).nc
  84. rm -rf $tmpfile $ofile $ofile2 $ofile3 ${!inp}.nc
  85. done
  86. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement