my_variables.F90 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. MODULE my_variables
  2. IMPLICIT NONE
  3. ! 0. Variable declaration
  4. ! -----------------------
  5. !
  6. ! 0.1 Type of real (that made me struggle so bad ARGH)
  7. INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(12,307)
  8. INTEGER, PARAMETER :: wp = dp
  9. REAL(wp) :: rzero = 0._wp
  10. REAL(wp) :: rone = 1._wp
  11. ! 0.1 File names
  12. CHARACTER(LEN=99) :: cfile_analysis_ice, cfile_forecast_ice, cfile_analysis_oce, cfile_forecast_oce
  13. CHARACTER(LEN=99) :: cfileout_ice = "ice_out.nc"
  14. CHARACTER(LEN=99) :: cfileout_oce = "oce_out.nc"
  15. CHARACTER(LEN=99) :: cinteger, cinteger2 ! To convert integers to strings
  16. ! 0.2 Model variable names (e.g. a_i_htc, v_i_htc, ...)
  17. CHARACTER(LEN=99) :: cvarroot, cvarname
  18. ! 0.3 File Opening & Reading
  19. LOGICAL :: l_ex ! whether a file exists or not
  20. INTEGER :: incid_ice_an_in, incid_mask, incid_mesh, incid_oce_an_in,&
  21. &incid_ice_an_out, incid_oce_an_out, incid_oce_fc_in, incid_ice_fc_in
  22. INTEGER :: ierr, ivarid, idimid(5) ! Error log, variable id
  23. ! & variable dimension
  24. !INTEGER :: varID ! The id given by the
  25. ! Netcdf
  26. !
  27. ! 0.4 Geometrical data (mask, mesh, domain dimensions)
  28. INTEGER :: jpi, jpj ! Horizontal grid dimensions
  29. INTEGER :: jpk ! Vertical
  30. INTEGER :: jpl, nlay_i ! Number of ice categories and layers
  31. INTEGER :: nlay_s ! Number of snow layers
  32. REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: ze1t, ze2t ! Grid edge length
  33. REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zcellarea ! The product ze1t*ze2t
  34. INTEGER, ALLOCATABLE, DIMENSION(:,:) :: ilandmask ! Horizontal land-sea mask
  35. CHARACTER(LEN=99), PARAMETER :: cmaskfile = "mask.nc"
  36. CHARACTER(LEN=99), PARAMETER :: cmaskvar = "tmask"
  37. CHARACTER(LEN=99), PARAMETER :: cmeshfile = "mesh_hgr.nc"
  38. CHARACTER(LEN=99), PARAMETER :: ce1tvar = "e1t"
  39. CHARACTER(LEN=99), PARAMETER :: ce2tvar = "e2t"
  40. ! 0.5 Ice variables of interest
  41. REAL(wp) :: ztime_counter ! iteration
  42. REAL(wp), DIMENSION(:), ALLOCATABLE :: hi_max
  43. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: a_i, v_i, ht_i, v_s,&
  44. & oa_i, smv_i, t_su,&
  45. & v_i_fc, v_s_fc
  46. ! -Ice concentration (jpi,jpj,jpl)
  47. ! -Ice volume per surface unit
  48. ! (jpi,jpj,jpl)
  49. ! -In situ thickness (jpi,jpj,jpl)
  50. ! -Snow volume per surface unit
  51. ! -Ice age
  52. ! -Ice salinity
  53. ! -Surface temperature
  54. REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: at_i, snwice_mass, snwice_mass_b
  55. ! Total (sum over categories) of conc.
  56. ! Snow ice loads
  57. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) :: e_i, e_s
  58. ! ice enthalpy (jpi,jpi,nlay_i,jpl)
  59. ! snow ~
  60. CHARACTER(LEN=99) :: csss_m = "sss_m" ! Sea surf. salinity name in restart
  61. CHARACTER(LEN=99) :: csn = "sn" ! Sea salinity name in restart
  62. CHARACTER(LEN=99) :: csst_m = "sst_m" ! Sea surf. temperature name in restart
  63. CHARACTER(LEN=99) :: ctn = "tn" ! Sea temperature name in restart
  64. CHARACTER(LEN=99) :: cun = "un" ! Sea velocity
  65. CHARACTER(LEN=99) :: cub = "ub" ! Sea velocity
  66. CHARACTER(LEN=99) :: cvn = "vn" ! Sea velocity
  67. CHARACTER(LEN=99) :: cvb = "vb" ! Sea velocity
  68. CHARACTER(LEN=99) :: cssu_m = "ssu_m" ! Sea surf. velocity
  69. CHARACTER(LEN=99) :: cssv_m = "ssv_m" ! Sea surf. velocity
  70. REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: sss_m_an ! Sea surface salinity (jpi,jpj) of the analysis
  71. REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: sss_m_fc ! Sea surface salinity (jpi, jpj) of the forecast
  72. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: sn_an ! Sea salinity (jpi,jpj,jpk) of the analysis
  73. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: sn_fc ! Sea salinity (jpi,jpj,jpk) of the forecast
  74. REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: sst_m_an ! Sea surface temperature (jpi,jpj) of the analysis
  75. REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: sst_m_fc ! Sea surface temperature (jpi, jpj) of the forecast
  76. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: tn_an ! Sea temperature (jpi,jpj,jpk) of the analysis
  77. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: tn_fc ! Sea temperature (jpi,jpj,jpk) of the forecast
  78. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: ub_an, ub_fc, un_an, un_fc ! Ocean velocity
  79. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: vb_an, vb_fc, vn_an, vn_fc ! Ocean velocity
  80. REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: ssu_m_an, ssu_m_fc ! Sea surface velocity
  81. REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: ssv_m_an, ssv_m_fc ! Sea surface velocity
  82. REAL(wp) :: zalpha ! To discretize the thickness distribution
  83. REAL(wp) :: rn_himean ! Expected mean thickness (to construct the ITD bounds)
  84. REAL(wp) :: zhmax ! Max ITD bound (usually 3 x rn_himean)
  85. REAL(wp) :: znum ! temporary variable
  86. REAL(wp) :: zden ! temporary variable
  87. REAL(wp) :: zs ! temporary variable
  88. REAL(wp) :: r1_S0 ! ratio involved in the calculation of freezing point
  89. REAL(wp) :: zh ! Ratio between min thickness in
  90. ! category 1 and actual thickness in 1st
  91. ! category.
  92. REAL(wp) :: zda_i, zdv_i, zda_ex
  93. ! Possible excess of ice concentration
  94. ! 0.6 Variables for shift between categories
  95. INTEGER :: zshiftflag ! flag if at least one
  96. ! point in the domain
  97. ! has too thick/thin ice
  98. ! in the running category
  99. INTEGER, ALLOCATABLE, DIMENSION(:,:,:) :: idonor ! ice donor index. see below
  100. ! for detailed explanation
  101. INTEGER, ALLOCATABLE, DIMENSION(:,:,:) :: internal_melt ! Switch for internal melt
  102. ! of layers
  103. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: zdaice, zdvice
  104. ! Area and volume of ice
  105. ! transferred to other categories
  106. REAL(wp) :: ze_s ! local snow variable
  107. REAL(wp) :: zsaldiff, ztempdiff ! difference in
  108. ! salinity and temperature btw analysis and forecast
  109. REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zheat_res, zdmsnif
  110. ! Snow heat and mass release after melting
  111. LOGICAL :: l_adjust ! To tackle numerical
  112. ! problems with ice conc> 1 by epsilon
  113. ! 0.6 Switches
  114. REAL(wp) :: zindb, zindsn, zindic, zindg
  115. INTEGER :: num_sal = 2 !( see namelist )
  116. ! 0.6 Constants
  117. REAL(wp), PARAMETER :: epsi10 = 1.e-10_wp, epsi06 = 1.e-6_wp, epsi04 = 1.e-4_wp, &
  118. & epsi20= 1.e-20_wp, zbigvalue = 1.0e+20
  119. REAL(wp), PARAMETER :: zamax = 0.999 ! Maximum concentration -- see A. Barthélemy's modifs in the code
  120. REAL(wp), PARAMETER :: rtt = 273.16 ! 3ple point water
  121. REAL(wp), PARAMETER :: tmut = 0.054 ! Variation of sea ice melting point with temperature
  122. REAL(wp), PARAMETER :: zrho0 = 1020.0 ! Volumic mass water reference
  123. REAL(wp), PARAMETER :: zrhoic = 917.0 ! Volumic mass sea ice
  124. REAL(wp), PARAMETER :: zcpic = 2067.0 ! Specific heat for ice
  125. REAL(wp), PARAMETER :: zrhosn = 330.0 ! Volumic mass snow density
  126. REAL(wp), PARAMETER :: zlfus = 0.334e+6 ! Latent heat fusion fresh ice
  127. REAL(wp), PARAMETER :: zrcp = 4.0e+3 ! Specific heat for sea water
  128. REAL(wp), PARAMETER :: zhiclim = 0.10 ! hiclim in the namelist, i.e. minimal
  129. !ice thickness in the 1st category
  130. REAL(wp), PARAMETER :: rdt_ice = 21600.0 ! Ice time step.
  131. INTEGER , PARAMETER :: nn_fsbc = 6 ! Frequency of ice model call (1
  132. ! time unit = 1 ocean time step)
  133. ! 0.7 Debug
  134. LOGICAL :: ldebug = .TRUE. ! to display messages
  135. INTEGER :: jiindx = 106 , jjindx = 118 ! Grid index for debugging
  136. END MODULE my_variables