Skip to content
Snippets Groups Projects
diaobs.F90 52.8 KiB
Newer Older
Guillaume Samson's avatar
Guillaume Samson committed
      !!          
      !! ** Purpose : Get final date in double precision YYYYMMDD.HHMMSS format
      !!
      !! ** Method  : 
      !!
      !! ** Action  : 
      !!
      !! History :
      !!        !  06-03  (K. Mogensen)  Original code
      !!        !  06-05  (K. Mogensen)  Reformatted
      !!        !  06-10  (A. Weaver) Cleaning
      !!        !  10-05  (D. Lea) Update to month length calculation for NEMO vn3.2
      !!        !  2014-09  (D. Lea) Change to call generic routine calc_date
      !!----------------------------------------------------------------------

      IMPLICIT NONE

      !! * Arguments
      REAL(wp), INTENT(OUT) :: ddobsfin ! Final date in YYYYMMDD.HHMMSS
Guillaume Samson's avatar
Guillaume Samson committed

      CALL calc_date( nitend, ddobsfin )

   END SUBROUTINE fin_date
   
   SUBROUTINE obs_settypefiles( ntypes, jpmaxnfiles, ifiles, cobstypes, cfiles )

      INTEGER, INTENT(IN) :: ntypes      ! Total number of obs types
      INTEGER, INTENT(IN) :: jpmaxnfiles ! Maximum number of files allowed for each type
      INTEGER, DIMENSION(ntypes), INTENT(OUT) :: &
         &                   ifiles      ! Out number of files for each type
      CHARACTER(len=lca), DIMENSION(ntypes), INTENT(IN) :: &
         &                   cobstypes   ! List of obs types
      CHARACTER(len=128), DIMENSION(ntypes, jpmaxnfiles), INTENT(IN) :: &
         &                   cfiles      ! List of files for all types

      !Local variables
      INTEGER :: jfile
      INTEGER :: jtype

      DO jtype = 1, ntypes

         ifiles(jtype) = 0
         DO jfile = 1, jpmaxnfiles
            IF ( trim(cfiles(jtype,jfile)) /= '' ) &
                      ifiles(jtype) = ifiles(jtype) + 1
         END DO

         IF ( ifiles(jtype) == 0 ) THEN
              CALL ctl_stop( 'Logical for observation type '//TRIM(cobstypes(jtype))//   &
                 &           ' set to true but no files available to read' )
         ENDIF

         IF(lwp) THEN    
            WRITE(numout,*) '             '//cobstypes(jtype)//' input observation file names:'
            DO jfile = 1, ifiles(jtype)
               WRITE(numout,*) '                '//TRIM(cfiles(jtype,jfile))
            END DO
         ENDIF

      END DO

   END SUBROUTINE obs_settypefiles

   SUBROUTINE obs_setinterpopts( ntypes, jtype, ctypein,             &
              &                  n2dint_default, n2dint_type,        &
              &                  ravglamscl_type, ravgphiscl_type,   &
              &                  lfp_indegs_type, lavnight_type,     &
              &                  n2dint, ravglamscl, ravgphiscl,     &
              &                  lfpindegs, lavnight )

      INTEGER, INTENT(IN)  :: ntypes             ! Total number of obs types
      INTEGER, INTENT(IN)  :: jtype              ! Index of the current type of obs
      INTEGER, INTENT(IN)  :: n2dint_default     ! Default option for interpolation type
      INTEGER, INTENT(IN)  :: n2dint_type        ! Option for interpolation type
      REAL(wp), INTENT(IN) :: &
         &                    ravglamscl_type, & !E/W diameter of obs footprint for this type
         &                    ravgphiscl_type    !N/S diameter of obs footprint for this type
      LOGICAL, INTENT(IN)  :: lfp_indegs_type    !T=> footprint in degrees, F=> in metres
      LOGICAL, INTENT(IN)  :: lavnight_type      !T=> obs represent night time average
      CHARACTER(len=lca), INTENT(IN) :: ctypein 
Guillaume Samson's avatar
Guillaume Samson committed

      INTEGER, DIMENSION(ntypes), INTENT(INOUT) :: &
         &                    n2dint 
      REAL(wp), DIMENSION(ntypes), INTENT(INOUT) :: &
         &                    ravglamscl, ravgphiscl
      LOGICAL, DIMENSION(ntypes), INTENT(INOUT) :: &
         &                    lfpindegs, lavnight

      lavnight(jtype) = lavnight_type

      IF ( (n2dint_type >= 0) .AND. (n2dint_type <= 6) ) THEN
         n2dint(jtype) = n2dint_type
      ELSE IF ( n2dint_type == -1 ) THEN
         n2dint(jtype) = n2dint_default
      ELSE
         CALL ctl_stop(' Choice of '//TRIM(ctypein)//' horizontal (2D) interpolation method', &
           &                    ' is not available')
      ENDIF

      ! For averaging observation footprints set options for size of footprint 
      IF ( (n2dint(jtype) > 4) .AND. (n2dint(jtype) <= 6) ) THEN
         IF ( ravglamscl_type > 0._wp ) THEN
            ravglamscl(jtype) = ravglamscl_type
         ELSE
            CALL ctl_stop( 'Incorrect value set for averaging footprint '// &
                           'scale (ravglamscl) for observation type '//TRIM(ctypein) )      
         ENDIF

         IF ( ravgphiscl_type > 0._wp ) THEN
            ravgphiscl(jtype) = ravgphiscl_type
         ELSE
            CALL ctl_stop( 'Incorrect value set for averaging footprint '// &
                           'scale (ravgphiscl) for observation type '//TRIM(ctypein) )      
         ENDIF

         lfpindegs(jtype) = lfp_indegs_type 

      ENDIF

      ! Write out info 
      IF(lwp) THEN
         IF ( n2dint(jtype) <= 4 ) THEN
            WRITE(numout,*) '             '//TRIM(ctypein)// &
               &            ' model counterparts will be interpolated horizontally'
         ELSE IF ( n2dint(jtype) <= 6 ) THEN
            WRITE(numout,*) '             '//TRIM(ctypein)// &
               &            ' model counterparts will be averaged horizontally'
            WRITE(numout,*) '             '//'    with E/W scale: ',ravglamscl(jtype)
            WRITE(numout,*) '             '//'    with N/S scale: ',ravgphiscl(jtype)
            IF ( lfpindegs(jtype) ) THEN
                WRITE(numout,*) '             '//'    (in degrees)'
            ELSE
                WRITE(numout,*) '             '//'    (in metres)'
            ENDIF
         ENDIF
      ENDIF

   END SUBROUTINE obs_setinterpopts

END MODULE diaobs