MODULE metric
   USE metric_var_mod
   INTEGER, PARAMETER :: metric_icosa_global = 1
   INTEGER, PARAMETER :: metric_icosa_area = 2
   INTEGER, SAVE :: metric_type

CONTAINS

   SUBROUTINE init_metric
      USE metric_icosa_global_mod, ONLY: compute_metric_icosa_global => compute_metric
      USE metric_icosa_area_old_mod, ONLY: compute_metric_icosa_area_old => compute_metric
      USE metric_icosa_area_mod, ONLY: compute_metric_icosa_area => compute_metric
      USE mpipara, ONLY: is_mpi_root
      USE getin_mod
      IMPLICIT NONE
      CHARACTER(LEN=255) :: metric_type_str
      CHARACTER(LEN=255) :: area_metric

      metric_type_str = 'icosa_global'
      CALL getin('metric_type', metric_type_str)
      SELECT CASE (TRIM(metric_type_str))
      CASE ('icosa_global')
         metric_type = metric_icosa_global
         CALL compute_metric_icosa_global
      CASE ('icosa_area')
         metric_type = metric_icosa_area
         area_metric="hexagon"
         CALL getin("area_metric", area_metric)
         IF (TRIM(area_metric)=='hexagon_old') THEN
           CALL compute_metric_icosa_area_old
         ELSE
           CALL compute_metric_icosa_area
         ENDIF
       CASE DEFAULT
         IF (is_mpi_root) PRINT *, "Bad selector for variable <metric_type> : ", &
            TRIM(metric_type_str), ", options are <icosa_global>, <icosa_area>"
         STOP
      END SELECT
   END SUBROUTINE init_metric

END MODULE metric
