module io_metadata
  use io
  implicit none

  ! type :: variable_metadata
  !   character(len=32) :: name                       ! variable name
  !   character(len=32), dimension(4) :: dim_names    ! dimension names
  !   character(len=32) :: char_name(10) = ''    ! character metadata names
  !   character(len=32) :: char_value(10) = ''   ! character metadata values
  !   character(len=32) :: int_name(10) = ''     ! integer metadata names
  !   integer :: int_value(10) = 0               ! integer metadata values
  !   character(len=32) :: real_name(10) = ''    ! real metadata names
  !   real :: real_value(10) = 0.0               ! real metadata values
  ! end type variable_metadata

  ! variable metadata collection

  type(variable_metadata), public :: meta_temperature = variable_metadata( &
    name = 'T2M', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'], &
    char_name = [character(len=32) :: &
      'long_name', &
      'units', &
      '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: &
      'Air Temperature', &
      'C', &
      '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: &
      'missing_value', &
      'scale_factor', &
      '', '', '', '', '', '', '', ''], &
    real_value = [&
      -9999.9, &
      1.0, &
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

  type(variable_metadata), public :: meta_pressure = variable_metadata( &
    name = 'SLP', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Time', ''], &
    char_name = [character(len=32) :: &
      'long_name', &
      'units', &
      '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: &
      'Air Pressure at Sea Level', &
      'Pa', &
      '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: &
      'missing_value', &
      'scale_factor', &
      '', '', '', '', '', '', '', ''], &
    real_value = [&
      -9999.9, &
      1.0, &
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

  type(variable_metadata), public :: meta_humidity = variable_metadata( &
    name = 'HUM_2M', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Time', ''], &
    char_name = [character(len=32) :: &
      'long_name', &
      'units', &
      '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: &
      'Relative Humidity', &
      '%', &
      '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: &
      'missing_value', &
      'scale_factor', &
      '', '', '', '', '', '', '', ''], &
    real_value = [&
      -9999.9, &
      1.0, &
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

  type(variable_metadata), public :: meta_richnum = variable_metadata( &
    name = 'RICHNUM', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'])

  type(variable_metadata), public :: meta_anzt = variable_metadata( &
    name = 'ANZT', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'])

  type(variable_metadata), public :: meta_anzu = variable_metadata( &
    name = 'ANZU', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'])

  type(variable_metadata), public :: meta_theta_vermix = variable_metadata( &
    name = 'Theta', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'])

  type(variable_metadata), public :: meta_den_vermix = variable_metadata( &
    name = 'Density', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'])

  type(variable_metadata), public :: meta_uu_vermix = variable_metadata( &
    name = 'U', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'])

  type(variable_metadata), public :: meta_vv_vermix = variable_metadata( &
    name = 'V', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'])

  type(variable_metadata), public :: meta_N2_vermix = variable_metadata( &
    name = 'N2', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'])

  type(variable_metadata), public :: meta_S2_vermix = variable_metadata( &
    name = 'S2', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'])

  type(variable_metadata), public :: meta_mld_vermix = variable_metadata( &
    name = 'mld', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Time', ''])

  type(variable_metadata), public :: meta_test1d = variable_metadata( &
    name = 'TEST1D', &
    dim_names = [character(len=32) :: 'X', '', '', ''], &
    char_name = [character(len=32) :: &
      'long_name', &
      'units', &
      '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: &
      'Test 1D variable', &
      '-', &
      '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: &
      'missing_value', &
      'scale_factor', &
      '', '', '', '', '', '', '', ''], &
    real_value = [&
      -9999.9, &
      1.0, &
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

  type(variable_metadata), public :: meta_test2d = variable_metadata( &
    name = 'TEST2D', &
    dim_names = [character(len=32) :: 'X', 'Y', '', ''], &
    char_name = [character(len=32) :: &
      'long_name', &
      'units', &
      '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: &
      'Test 2D variable', &
      '-', &
      '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: &
      'missing_value', &
      'scale_factor', &
      '', '', '', '', '', '', '', ''], &
    real_value = [&
      -9999.9, &
      1.0, &
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

  type(variable_metadata), public :: meta_test3d = variable_metadata( &
    name = 'TEST3D', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', ''], &
    char_name = [character(len=32) :: &
      'long_name', &
      'units', &
      '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: &
      'Test 1D variable', &
      '-', &
      '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: &
      'missing_value', &
      'scale_factor', &
      '', '', '', '', '', '', '', ''], &
    real_value = [&
      -9999.9, &
      1.0, &
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
  
  type(variable_metadata), public :: meta_test4d = variable_metadata( &
    name = 'TEST4D', &
    dim_names = [character(len=32) :: 'X', 'Y', 'Z', 'Time'], &
    char_name = [character(len=32) :: &
      'long_name', &
      'units', &
      '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: &
      'Test 2D variable', &
      '-', &
      '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: &
      'missing_value', &
      'scale_factor', &
      '', '', '', '', '', '', '', ''], &
    real_value = [&
      -9999.9, &
      1.0, &
      0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

  type(variable_metadata), public :: meta_ri_grad_2d = variable_metadata( &
    name = 'Ri_grad', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''])

  type(variable_metadata), public :: meta_kh_2d = variable_metadata( &
    name = 'kh', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    real_name = [character(len=32) :: &
    'missing_value', &
    'scale_factor', &
    '', '', '', '', '', '', '', ''], &
  real_value = [&
    -9999.9, &
    -3.0, &
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

  type(variable_metadata), public :: meta_km_2d = variable_metadata( &
    name = 'km', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    real_name = [character(len=32) :: &
    'missing_value', &
    'scale_factor', &
    '', '', '', '', '', '', '', ''], &
  real_value = [&
    -9999.9, &
    -3.0, &
    0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

    ! Metadata for Theta
    type(variable_metadata), public :: meta_theta = variable_metadata( &
    name = 'Theta', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Temperature', 'Kelvin', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', 'scale_factor', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    type(variable_metadata), public :: meta_theta_C = variable_metadata( &
    name = 'Theta_C', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Temperature', 'degrees Celsius', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', 'scale_factor', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for Salin
    type(variable_metadata), public :: meta_salin = variable_metadata( &
    name = 'Salin', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Salinity', 'PSU', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', 'scale_factor', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for U
    type(variable_metadata), public :: meta_u = variable_metadata( &
    name = 'U', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Zonal Velocity', 'm s-1', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', 'scale_factor', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for V
    type(variable_metadata), public :: meta_v = variable_metadata( &
    name = 'V', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Meridional Velocity', 'm s-1', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', 'scale_factor', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for Rho
    type(variable_metadata), public :: meta_rho = variable_metadata( &
    name = 'Rho', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Density', 'kg m-3', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', 'scale_factor', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for N2
    type(variable_metadata), public :: meta_n2 = variable_metadata( &
    name = 'N2', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Brunt-Vaisala Frequency Squared', 's-2', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', 'scale_factor', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for S2
    type(variable_metadata), public :: meta_s2 = variable_metadata( &
    name = 'S2', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Shear Squared', 's-2', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', 'scale_factor', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

        ! Metadata for Ri_grad
    type(variable_metadata), public :: meta_ri_grad = variable_metadata( &
    name = 'Ri_grad', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Gradient Richardson Number', 'Ri', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', '', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for Kh
    type(variable_metadata), public :: meta_kh = variable_metadata( &
    name = 'Kh', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Vertical Diffusivity', 'm2 s-1', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', 'scale_factor', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, -3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for Km
    type(variable_metadata), public :: meta_km = variable_metadata( &
    name = 'Km', &
    dim_names = [character(len=32) :: 'Z', 'Time', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Vertical Viscosity', 'm2 s-1', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', 'scale_factor', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, -3.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for mld
    type(variable_metadata), public :: meta_mld = variable_metadata( &
    name = 'mld', &
    dim_names = [character(len=32) :: 'Time', '', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Mixed Layer Depth', 'm', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', '', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])
     
    ! Metadata for lab_mld
    type(variable_metadata), public :: meta_lab_mld = variable_metadata( &
    name = 'lab_mld', &
    dim_names = [character(len=32) :: 'Time', '', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Mixed Layer Depth', 'm', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', '', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for eld
    type(variable_metadata), public :: meta_eld = variable_metadata( &
    name = 'eld', &
    dim_names = [character(len=32) :: 'Time', '', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Entrainment Layer Depth', 'm', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', '', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])
     
    ! Metadata for lab_eld
    type(variable_metadata), public :: meta_lab_eld = variable_metadata( &
    name = 'lab_eld', &
    dim_names = [character(len=32) :: 'Time', '', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Entrainment Layer Depth', 'm', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', '', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for tau_u
    type(variable_metadata), public :: meta_tau_u = variable_metadata( &
    name = 'tau_u', &
    dim_names = [character(len=32) :: 'Time', '', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Zonal Wind Stress', 'N m-2', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', '', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    ! Metadata for tau_v
    type(variable_metadata), public :: meta_tau_v = variable_metadata( &
    name = 'tau_v', &
    dim_names = [character(len=32) :: 'Time', '', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Meridional Wind Stress', 'N m-2', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', '', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

     ! Metadata for theta_surf
    type(variable_metadata), public :: meta_theta_surf = variable_metadata( &
    name = 'Theta_surf', &
    dim_names = [character(len=32) :: 'Time', '', '', ''], &
    char_name = [character(len=32) :: 'long_name', 'units', '', '', '', '', '', '', '', ''], &
    char_value = [character(len=32) :: 'Temperature surface', 'K', '', '', '', '', '', '', '', ''], &
    real_name = [character(len=32) :: 'missing_value', '', '', '', '', '', '', '', '', ''], &
    real_value = [ -9999.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ])

    type(variable_metadata), public :: meta_init_theta = variable_metadata( &
    name = 'Init Theta', &
    dim_names = [character(len=32) :: 'Z_init', '', '', ''])

    type(variable_metadata), public :: meta_init_salin = variable_metadata( &
    name = 'Init Salinity', &
    dim_names = [character(len=32) :: 'Z_init', '', '', ''])

    type(variable_metadata), public :: meta_init_u = variable_metadata( &
    name = 'Init U', &
    dim_names = [character(len=32) :: 'Z_init', '', '', ''])

    type(variable_metadata), public :: meta_init_v = variable_metadata( &
    name = 'Init V', &
    dim_names = [character(len=32) :: 'Z_init', '', '', ''])

end module io_metadata