mk_fluko_sra 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/bin/ksh
  2. #
  3. # script to compute a fluxcorrection (you may call it oceanic heat transport)
  4. # for the mixed layer and the sea ice module of the Planet Simulator
  5. #
  6. # ocean and sea ice output from a uncoupled simulation (nice=nocean=0)
  7. # can be used.
  8. #
  9. # service format and ascii files are generated, the latter can serve as the
  10. # fluxcorrection input files in the coupled run.
  11. #
  12. # to use the script, you may change the shell variable at the beginning of
  13. # this script according to your setup...
  14. #
  15. # at the end you may display the .srv files with GRADS using the srv2gra
  16. # tool
  17. #
  18. set -ex
  19. #
  20. DATA=`pwd` # dir. where the PlaSim data are
  21. ICEFILE=ice_ctl. # preface for ice output
  22. OCEANFILE=oce_ctl. # preface for ocean output
  23. FLUKOICE=${DATA}/N032_surf_0709_fl.sra # flux correction for ice
  24. FLUKOOCE=${DATA}/N032_surf_0903_fl.sra # flux correction for ocean
  25. FIRSTYEAR=31 # first year to be used
  26. LASTYEAR=40 # last year to be used
  27. NICE=1 # compute ice flux correction
  28. NOCE=1 # compute ocean flux correction
  29. #
  30. # your calls for some utilities
  31. #
  32. F90=f90 # FORTRAN
  33. #
  34. TMPDIR=${DATA}/tmpdir/FLUKO$$ # temporary dir. (will be deleted)
  35. #
  36. ########################
  37. mkdir -p $TMPDIR
  38. cd $TMPDIR
  39. #
  40. #########################
  41. #
  42. cat > form.f90 << EOF
  43. program form
  44. !
  45. integer ih(8)
  46. real,allocatable :: f(:,:)
  47. !
  48. read(10) ih
  49. n=ih(5)*ih(6)
  50. allocate(f(n,12))
  51. jm=1
  52. 1000 continue
  53. read(10) f(:,jm)
  54. read(10,end=1001) ih
  55. jm=jm+1
  56. goto 1000
  57. 1001 continue
  58. write(20,'(8I10)') ih(1:2),0,0,ih(5:8)
  59. write(20,'(4E16.6)') f(:,12)
  60. do jm=1,12
  61. write(20,'(8I10)') ih(1:2),jm*100,0,ih(5:8)
  62. write(20,'(4E16.6)') f(:,jm)
  63. enddo
  64. write(20,'(8I10)') ih(1:2),1300,0,ih(5:8)
  65. write(20,'(4E16.6)') f(:,1)
  66. !
  67. stop
  68. end
  69. EOF
  70. gfortran -o form.x form.f90
  71. #
  72. YY=${FIRSTYEAR}
  73. while [ ${YY} -le ${LASTYEAR} ]
  74. do
  75. if [ ${YY} -lt 100 ]
  76. then
  77. YY=0${YY}
  78. fi
  79. if [ ${YY} -lt 10 ]
  80. then
  81. YY=0${YY}
  82. fi
  83. #
  84. ##
  85. #
  86. if [ ${NICE} -eq 1 ]
  87. then
  88. INFILE=${DATA}/${ICEFILE}${YY}
  89. cdo selcode,709 ${INFILE} ICEYEAR709
  90. cat ICEYEAR709 >> ICEFLUKO
  91. fi
  92. ###
  93. if [ ${NOCE} -eq 1 ]
  94. then
  95. INFILE=${DATA}/${OCEANFILE}${YY}
  96. cdo selcode,903 ${INFILE} OCEANYEAR903
  97. cat OCEANYEAR903 >> OCEANFLUKO
  98. fi
  99. ####
  100. YY=`expr ${YY} + 1`
  101. done
  102. ####
  103. if [ ${NICE} -eq 1 ]
  104. then
  105. cdo ymonmean ICEFLUKO fort.10
  106. ./form.x
  107. mv fort.20 ${FLUKOICE}
  108. fi
  109. ####
  110. if [ ${NOCE} -eq 1 ]
  111. then
  112. cdo ymonmean OCEANFLUKO fort.10
  113. ./form.x
  114. mv fort.20 ${FLUKOOCE}
  115. fi
  116. ####
  117. cd ${DATA}
  118. rm -r $TMPDIR
  119. exit