MODULE getin_mod

PRIVATE

  INTERFACE getin
    MODULE PROCEDURE getin_c , getin_c1d, getin_l, getin_i, getin_r
  END INTERFACE getin
 
PUBLIC getin, getin_c, getin_r
  
CONTAINS

  SUBROUTINE getin_c(name,value)
  USE ioipsl, ONLY : getin_=>getin
  USE transfert_omp_mod
  USE omp_para
  USE mpipara
  IMPLICIT NONE
    CHARACTER(LEN=*), INTENT(IN) :: name
    CHARACTER(LEN=*), INTENT(INOUT) :: value

!$OMP MASTER    
    CALL getin_(name,value)
    IF(is_mpi_root) PRINT *,'GETIN ',TRIM(name),' = ', TRIM(value)
!$OMP END MASTER
    IF (omp_in_parallel()) CALL bcast_omp(value)
  END SUBROUTINE getin_c

SUBROUTINE getin_c1d(name,value)
  USE ioipsl, ONLY : getin_=>getin
  USE transfert_omp_mod
  USE omp_para
  USE mpipara
  IMPLICIT NONE
    CHARACTER(LEN=*), INTENT(IN) :: name
    CHARACTER(LEN=*), INTENT(INOUT) :: value(:)
    INTEGER :: i
!$OMP MASTER    
    CALL getin_(name,value)
    IF(is_mpi_root) THEN
      DO i=1,size(value)
        PRINT *,'GETIN ',TRIM(name),' = ', TRIM(value(i))
      ENDDO
    ENDIF  
!$OMP END MASTER
    IF (omp_in_parallel()) THEN
      DO i=1,size(value)
        CALL bcast_omp(value(i))
      ENDDO
    ENDIF
  END SUBROUTINE getin_c1d


  SUBROUTINE getin_l(name,value)
  USE ioipsl, ONLY : getin_=>getin
  USE transfert_omp_mod
  USE omp_para
  USE mpipara
  IMPLICIT NONE
    CHARACTER(LEN=*) :: name
    LOGICAL          :: value

!$OMP MASTER    
    CALL getin_(name,value)
    IF(is_mpi_root) PRINT *,'GETIN ',TRIM(name),' = ', value
!$OMP END MASTER
    IF (omp_in_parallel()) CALL bcast_omp(value)
  END SUBROUTINE getin_l

  SUBROUTINE getin_i(name,value)
  USE ioipsl, ONLY : getin_=>getin
  USE transfert_omp_mod
  USE omp_para
  USE mpipara
  IMPLICIT NONE
    CHARACTER(LEN=*) :: name
    INTEGER          :: value

!$OMP MASTER    
    CALL getin_(name,value)
    IF(is_mpi_root) PRINT *,'GETIN ',TRIM(name), ' = ', value
!$OMP END MASTER
    IF (omp_in_parallel()) CALL bcast_omp(value)
  END SUBROUTINE getin_i
  
  
  SUBROUTINE getin_r(name,value)
  USE ioipsl, ONLY : getin_=>getin
  USE omp_para
  USE mpipara
  USE transfert_omp_mod
  IMPLICIT NONE
    CHARACTER(LEN=*), INTENT(IN) :: name
    REAL, INTENT(INOUT)          :: value

!$OMP MASTER    
    CALL getin_(name,value)
    IF(is_mpi_root) PRINT *,'GETIN ',TRIM(name), ' = ', value
!$OMP END MASTER
    IF (omp_in_parallel()) CALL bcast_omp(value)
  END SUBROUTINE getin_r
 
END MODULE getin_mod
