script_interp_vert_ocean_outputs.bash 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. set -evx
  3. #
  4. # This script interpolates vertically ocean monthly mean temperature and
  5. # salinity, extrapolates them horizontally, fills up empty seas with
  6. # climatologies, and extrapolate vertically. These monthly mean temperature and
  7. # salinity are to be used as reference files for ocean nudging.
  8. #
  9. # History : Virginie Guemas - Initial version 2012
  10. # Virginie Guemas - ORAS4 + vertical extrapolation +
  11. # commenting and clarifying - July 2014
  12. #
  13. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  14. monthly_in=$1 # Monthly mean netcdf file from the reanalysis to be interpolated
  15. # GLORYS2v1, GLOSEA5 or ORAS4
  16. varin=$2 # Input variable : 'votemper' or 'vosaline' - if this script
  17. # is extended to be used for other variables, a few lines need
  18. # to be changed below in the case varin loop.
  19. meshmaskin='/cfu/autosubmit/con_files/mesh_mask_nemo.nemovar_O1L42.nc'
  20. # Meshmask of the input reanalysis. Example:
  21. #'/cfu/autosubmit/con_files/mesh_mask_nemo.glorys2v1_O25L75.nc'
  22. confout='ORCA1L46' # output configuration
  23. vertgridout='/cfu/autosubmit/con_files/mesh_mask_nemo.Ec3.0_O1L46.nc'
  24. # Meshmask of the output grid, i.e. model and grid to be used in
  25. # the nudged simulation
  26. Ptoextrap='/cfu/pub/scripts/prep_restarts/auxfiles/masks/Tofill_ecearth.v3.0.ORCA1L46.extrap.oras4.outputs.nc'
  27. # Locations of the points where to extrapolate horizontally the outputs after
  28. # interpolation, = 1 in the netcdf file, 0 everywhere else. Locations
  29. # available for the tmask grid. If you don't know what is tmask,
  30. # read the NEMO documentation about the grid.
  31. # To obtain the Ptoextrap netcdf file, it is necessary to run once this script
  32. # without extrapolation and filling of the empty seas and compare the output
  33. # with the meshmask of the output grid. To do so, set 0 everywhere in
  34. # Ptoextrap and use build_Tofill.bash afterwards.
  35. Ptofillclim='/cfu/pub/scripts/prep_restarts/auxfiles/masks/Tofill_ecearth.v3.0.ORCA1L46.clim.nc'
  36. # Locations of the empty seas that need to be filled up with a climatology
  37. # after interpolation = 1 in the netcdf file, 0 everywhere else. Locations
  38. # available for the tmask grid. If you don't know what is tmask,
  39. # read the NEMO documentation about the grid.
  40. # To obtain the Ptofillclim netcdf file, it is necessary to run once this
  41. # script without extrapolation and filling of the empty seas and compare the
  42. # output with the meshmask of the output grid. To do so, set 0 everywhere in
  43. # Ptofillclim and use build_Tofill.bash afterwards.
  44. mon=$4 # Month of the restart on 2 digits MM
  45. monthly_out=$3 # Output netcdf file name
  46. cfutools='/home/vguemas/CFU_tools_new'
  47. # Location of the cfutools repository
  48. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. source ${cfutools}/prep_restarts/library/library.bash
  50. cdo vertsum -selvar,tmask $meshmaskin mask2din.nc
  51. mask='tmask' ; varlon='glamt' ; varlat='gphit' ; fill='tmask'
  52. # The vertical interpolation is performed below
  53. python ${cfutools}/interpolation/interp_vert.py $monthly_in $varin $meshmaskin e3t_0 mask2din.nc $mask $vertgridout e3t_0 gdept_0 int_${monthly_in}
  54. # The function extrap extrapolates horizontally and fill in the empty seas with a climatology
  55. extrap int_${monthly_in} ${varin} ${meshmaskin} ${varlon} ${varlat} ${Ptoextrap} ${Ptofillclim} ${fill} int2_${monthly_in} 3d $cfutools $confout $mon
  56. # The vertical extrapolation to empty levels is performed below
  57. python ${cfutools}/interpolation/vertextrap.py int2_${monthly_in} ${varin} $vertgridout nav_lev int3_${monthly_in}
  58. # Apply the mask
  59. applymask $vertgridout $mask int3_${monthly_in} $varin $monthly_out
  60. # Add vertical levels
  61. ncrename -v z,nav_lev $monthly_out
  62. ncks -A -v gdepw_0 $vertgridout $monthly_out
  63. # Clean
  64. rm -f int_${monthly_in} int2_${monthly_in} int3_${monthly_in} mask2din.nc