!+ Subroutine to read a SAMSON file.
!
! Method:
!	The input file is opened and the standard reading routine
!	is called. The returned array is indexed from 0 to N_LAYER,
!	but when fields in layers are read it will normally be necessary
!	to offset the topmost field by one, cloud fractions being the
!	exception.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!	Version		Date			Comment
!	1.0		12-04-95		First Version under RCS
!						(J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77  with extensions listed in documentation.
!
!- ---------------------------------------------------------------------
      SUBROUTINE READ_SAMSON_FIELD(IERR, L_WARN, L_OFFSET
     &   , FILE_NAME, FILE_TITLE
     &   , N_PROFILE, N_LAYER, P, PSTAR, FIELD
     &   )
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER.
      INCLUDE 'incl/dimensions_field.ucf'
      INCLUDE 'incl/samson_parm.ecf'
      INCLUDE 'incl/def_samson_io.icf'
      INCLUDE 'incl/error.pcf'
!
!     DUMMY ARGUMENTS.
      INTEGER	!, INTENT(OUT)
     &     IERR
!             ERROR FLAG
     &   , N_PROFILE
!             NUMBER OF PROFILES
     &   , N_LAYER
!             NUMBER OF LAYERS
      CHARACTER	!, INTENT(OUT)
     &     FILE_NAME*(*)
!             NAME OF FILE
     &   , FILE_TITLE*(*)
!             TITLE OF FILE
      LOGICAL	!, INTENT(IN)
     &     L_WARN
!             LOGICAL TO PRINT WARNING
     &   , L_OFFSET
!             LOGICAL TO OFFSET FIELD
      REAL*8	!, INTENT(OUT)
     &     P(0: NPD_LAYER)
!             PRESSURES IN LAYERS
     &   , PSTAR
!             SURFACE PRESSURE
     &   , FIELD(NPD_PROFILE, 0: NPD_LAYER)
!             FIELD READ IN
!
!     LOCAL VARIABLES.
      INTEGER
     &     inthead(P_headlen)
!             SAMSON FILE HEADER
     &   , I
!             LOOP VARIABLE
     &   , L
!             LOOP VARIABLE
      REAL*8
     &     samson_field(-1: NPD_PROFILE, NPD_LAYER+1)
!             SAMSON FIELD
!
!     SUBROUTINES CALLED:
      EXTERNAL
     &     OPEN_SAMSON_IN, SAMSON_IN
!
!
!
      CALL OPEN_SAMSON_IN(IERR, IU_SAMSON_IN, FILE_NAME, L_WARN)
      IF (IERR.EQ.I_MISSING_DATA) THEN
!        TIDY UP AND RETURN.
         CLOSE(IU_SAMSON_OUT)
         RETURN
      ENDIF
      CALL SAMSON_IN(IU_SAMSON_IN, file_title, inthead, samson_field)
      CLOSE(IU_SAMSON_IN)
!
!     PREPARE SAMSON HEADERS AND THE FIELD.
      N_PROFILE=inthead(1)
      IF (L_OFFSET) THEN
         N_LAYER=inthead(2)
         DO I=1, N_LAYER
            P(I)=samson_field(0, I)+PSTAR*samson_field(-1, I)
            DO L=1, N_PROFILE
               FIELD(L, I)=samson_field(L, I)
            ENDDO
         ENDDO
      ELSE
         N_LAYER=inthead(2)-1
         DO I=0, N_LAYER
            P(I)=samson_field(0, I+1)+PSTAR*samson_field(-1, I+1)
            DO L=1, N_PROFILE
               FIELD(L, I)=samson_field(L, I+1)
            ENDDO
         ENDDO
      ENDIF
!
!
      RETURN
      END
