New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 15240 for NEMO/branches/UKMO – NEMO

Changeset 15240 for NEMO/branches/UKMO


Ignore:
Timestamp:
2021-09-09T17:22:33+02:00 (3 years ago)
Author:
dford
Message:

Add option to use time mean background.

Location:
NEMO/branches/UKMO/NEMO_4.0.4_generic_obs
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/cfgs/SHARED/namelist_ref

    r15180 r15240  
    12801280   rn_avgphiscl           = 0.             !    N/S diameter of observation footprint (metres/degrees) 
    12811281   ln_night               = .false.        !    Logical switch for calculating night-time average for obs 
     1282   ln_time_mean_bkg       = .false.        !    Logical switch for applying time mean of background (e.g. to remove tidal signal) 
     1283   rn_time_mean_period    = 24.8333        !    Meaning period in hours if ln_time_mean_bkg (default is AMM tidal period) 
    12821284   ln_obsbias             = .false.        !    Logical switch for bias correction 
    12831285   cn_obsbiasfiles        = ''             !    Bias input file names 
     
    12921294!!! NOT YET IMPLEMENTED: 
    12931295!!!   OUTPUT CLIMATOLOGY 
    1294 !!!   TIME MEAN BACKGROUND 
    12951296/ 
    12961297!----------------------------------------------------------------------- 
  • NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/diaobs.F90

    r15228 r15240  
    249249               ! Read in surface obs types 
    250250               ! 
    251                CALL obs_rea_surf( sobsgroups(jgroup)%ssurfdata, & 
    252                   &               sobsgroups(jgroup)%nobsfiles, & 
    253                   &               sobsgroups(jgroup)%cobsfiles, & 
    254                   &               sobsgroups(jgroup)%nobstypes, & 
    255                   &               sobsgroups(jgroup)%naddvars,  & 
    256                   &               sobsgroups(jgroup)%nextvars,  & 
    257                   &               nitend-nit000+2,              & 
    258                   &               rn_dobsini,                   & 
    259                   &               rn_dobsend,                   & 
    260                   &               sobsgroups(jgroup)%lignmis,   & 
    261                   &               .FALSE.,                      & 
    262                   &               sobsgroups(jgroup)%lnight,    & 
     251               CALL obs_rea_surf( sobsgroups(jgroup)%ssurfdata,         & 
     252                  &               sobsgroups(jgroup)%nobsfiles,         & 
     253                  &               sobsgroups(jgroup)%cobsfiles,         & 
     254                  &               sobsgroups(jgroup)%nobstypes,         & 
     255                  &               sobsgroups(jgroup)%naddvars,          & 
     256                  &               sobsgroups(jgroup)%nextvars,          & 
     257                  &               nitend-nit000+2,                      & 
     258                  &               rn_dobsini,                           & 
     259                  &               rn_dobsend,                           & 
     260                  &               sobsgroups(jgroup)%rtime_mean_period, & 
     261                  &               sobsgroups(jgroup)%ltime_mean_bkg,    & 
     262                  &               sobsgroups(jgroup)%lignmis,           & 
     263                  &               .FALSE.,                              & 
     264                  &               sobsgroups(jgroup)%lnight,            & 
    263265                  &               sobsgroups(jgroup)%cobstypes ) 
    264266               ! 
     
    373375      !! * Local declarations 
    374376      INTEGER :: idaystp           ! Number of timesteps per day 
     377      INTEGER :: imeanstp          ! Number of timesteps for time averaging 
    375378      INTEGER :: jtype             ! Data loop variable 
    376379      INTEGER :: jvar              ! Variable number 
     
    504507                     ENDIF 
    505508                  ELSE 
     509                     IF ( sobsgroups(jgroup)%ltime_mean_bkg ) THEN 
     510                        ! Number of time-steps in meaning period 
     511                        imeanstp = NINT( ( sobsgroups(jgroup)%rtime_mean_period * 60.0 * 60.0 ) / rdt ) 
     512                     ENDIF 
    506513                     CALL obs_surf_opt( sobsgroups(jgroup)%ssurfdataqc,       & 
    507514                        &               kstp, jpi, jpj,                       & 
     
    514521                        &               sobsgroups(jgroup)%ravgphiscl,        & 
    515522                        &               sobsgroups(jgroup)%lfp_indegs,        & 
     523                        &               sobsgroups(jgroup)%ltime_mean_bkg,    & 
     524                        &               imeanstp,                             & 
    516525                        &               kssh=sobsgroups(jgroup)%nadd_ssh,     & 
    517526                        &               kmdt=sobsgroups(jgroup)%next_mdt,     & 
  • NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_group_def.F90

    r15228 r15240  
    8282      LOGICAL  :: lall_at_all        !: Logical switch for computing all model variables at all obs points 
    8383      LOGICAL  :: lnight             !: Logical switch for calculating night-time average 
     84      LOGICAL  :: ltime_mean_bkg     !: Logical switch for applying time mean of background (e.g. to remove tidal signal) 
    8485      LOGICAL  :: lfp_indegs         !: Logical: T=> averaging footprint is in degrees, F=> in metres 
    8586      ! 
     
    8889      REAL(wp) :: rmdtcorr           !: MDT correction 
    8990      REAL(wp) :: rmdtcutoff         !: MDT cutoff for computed correction 
     91      REAL(wp) :: rtime_mean_period  !: Meaning period if ltime_mean_bkg 
    9092      ! 
    9193      REAL(wp), POINTER, DIMENSION(:,:,:)   :: rglam  !: Longitudes 
     
    193195      LOGICAL                                    :: ln_all_at_all 
    194196      LOGICAL                                    :: ln_night 
     197      LOGICAL                                    :: ln_time_mean_bkg 
    195198      LOGICAL                                    :: ln_fp_indegs 
    196199      REAL(wp)                                   :: rn_avglamscl 
     
    198201      REAL(wp)                                   :: rn_mdtcorr 
    199202      REAL(wp)                                   :: rn_mdtcutoff 
     203      REAL(wp)                                   :: rn_time_mean_period 
    200204      !! 
    201205      NAMELIST/namobs_dta/cn_groupname, ln_prof, ln_surf, ln_enabled,           & 
     
    204208         &                ln_fp_indegs, rn_avglamscl, rn_avgphiscl, ln_obsbias, & 
    205209         &                cn_obsbiasfiles, cn_type_to_biascorrect,              & 
    206          &                cn_obsbiasfile_varname, ln_night, ln_altbias,         & 
    207          &                cn_altbiasfile, nn_msshc, rn_mdtcorr, rn_mdtcutoff,   & 
    208          &                ln_all_at_all 
     210         &                cn_obsbiasfile_varname, ln_night, ln_time_mean_bkg,   & 
     211         &                rn_time_mean_period, ln_altbias, cn_altbiasfile,      & 
     212         &                nn_msshc, rn_mdtcorr, rn_mdtcutoff, ln_all_at_all 
    209213      !!---------------------------------------------------------------------- 
    210214 
     
    350354         sdobsgroup%lall_at_all        = ln_all_at_all 
    351355         sdobsgroup%lnight             = ln_night 
     356         sdobsgroup%ltime_mean_bkg     = ln_time_mean_bkg 
    352357         sdobsgroup%lfp_indegs         = ln_fp_indegs 
    353358         sdobsgroup%ravglamscl         = rn_avglamscl 
     
    355360         sdobsgroup%rmdtcorr           = rn_mdtcorr 
    356361         sdobsgroup%rmdtcutoff         = rn_mdtcutoff 
     362         sdobsgroup%rtime_mean_period  = rn_time_mean_period 
    357363      ENDIF 
    358364 
     
    411417            WRITE(numout,*) '             N/S diameter of obs footprint                      rn_avgphiscl = ', sdobsgroup%ravgphiscl 
    412418            WRITE(numout,*) '             Logical switch for night-time average                  ln_night = ', sdobsgroup%lnight 
     419            WRITE(numout,*) '             Logical switch for time-mean background        ln_time_mean_bkg = ', sdobsgroup%ltime_mean_bkg 
     420            WRITE(numout,*) '             Meaning period (hours) for time-mean bkg    rn_time_mean_period = ', sdobsgroup%rtime_mean_period 
    413421            WRITE(numout,*) '             Logical switch for bias correction                   ln_obsbias = ', sdobsgroup%lobsbias 
    414422            IF ( sdobsgroup%lobsbias ) THEN 
  • NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_oper.F90

    r15228 r15240  
    455455      &                     kit000, kdaystp, kvar, psurf, psurfmask, & 
    456456      &                     k2dint, ldnightav, plamscl, pphiscl,     & 
    457       &                     lindegrees, kssh, kmdt, kfbd, ksnow ) 
     457      &                     lindegrees, ldtime_mean, kmeanstp,       & 
     458      &                     kssh, kmdt, kfbd, ksnow ) 
    458459 
    459460      !!----------------------------------------------------------------------- 
     
    512513      LOGICAL, INTENT(IN) :: & 
    513514         & lindegrees                  ! T=> plamscl and pphiscl are specified in degrees, F=> in metres 
     515      LOGICAL, INTENT(IN) :: & 
     516         & ldtime_mean                 ! Observations/background represent a time mean 
     517      INTEGER, INTENT(IN) :: kmeanstp  ! Number of time steps for meaning if ldtime_mean 
    514518      INTEGER, OPTIONAL, INTENT(IN) :: & 
    515519         & kssh                        ! Index of additional variable representing SSH 
     
    531535      INTEGER :: imodi, imodj 
    532536      INTEGER :: idayend 
     537      INTEGER :: imeanend 
    533538      INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: & 
    534539         & igrdi,   & 
     
    543548      REAL(wp), DIMENSION(1) :: zext, zobsmask 
    544549      REAL(wp) :: zdaystp 
     550      REAL(wp) :: zmeanstp 
    545551      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: & 
    546552         & zweig,  & 
     
    571577      CALL obs_max_fpsize( k2dint, plamscl, pphiscl, lindegrees, psurfmask, imaxifp, imaxjfp ) 
    572578 
     579      IF ( ldtime_mean .AND. ldnightav ) THEN 
     580         CALL ctl_stop( 'obs_surf_opt: Can have ldtime_mean or ldnightav but not both' ) 
     581      ENDIF 
     582 
     583      IF ( ldtime_mean ) THEN 
     584         ! Initialize time mean for first timestep 
     585         imeanend = MOD( kt - kit000 + 1, kmeanstp ) 
     586         IF (lwp) WRITE(numout,*) 'Obs time mean ', kt, kit000, kmeanstp, imeanend 
     587 
     588         ! Added kt == 0 test to catch restart case 
     589         IF ( ( imeanend == 1 ) .OR. ( kt == 0 ) ) THEN 
     590            IF (lwp) WRITE(numout,*) 'Reset surfdataqc%vdmean on time-step: ',kt 
     591            DO jj = 1, jpj 
     592               DO ji = 1, jpi 
     593                  surfdataqc%vdmean(ji,jj,kvar) = 0.0 
     594               END DO 
     595            END DO 
     596         ENDIF 
     597 
     598         ! On each time-step, increment the field for computing time mean 
     599         IF (lwp) WRITE(numout,*)'Accumulating surfdataqc%vdmean on time-step: ',kt 
     600         DO jj = 1, jpj 
     601            DO ji = 1, jpi 
     602               surfdataqc%vdmean(ji,jj,kvar) = surfdataqc%vdmean(ji,jj,kvar) & 
     603                  &                            + psurf(ji,jj) 
     604            END DO 
     605         END DO 
     606 
     607         ! Compute the time mean at the end of time period 
     608         IF ( imeanend == 0 ) THEN 
     609            zmeanstp = 1.0 / REAL( kmeanstp ) 
     610            IF (lwp) WRITE(numout,*)'Calculating surfdataqc%vdmean time mean on time-step: ',kt,' with weight: ',zmeanstp 
     611            DO jj = 1, jpj 
     612               DO ji = 1, jpi 
     613                  surfdataqc%vdmean(ji,jj,kvar) = surfdataqc%vdmean(ji,jj,kvar) & 
     614                     &                            * zmeanstp 
     615               END DO 
     616            END DO 
     617         ENDIF 
     618      ENDIF 
    573619 
    574620      IF ( ldnightav ) THEN 
     
    685731      CALL obs_int_comm_2d( imaxifp, imaxjfp, isurf, kpi, kpj, & 
    686732         &                  igrdi, igrdj, psurfmask, zmask ) 
    687       CALL obs_int_comm_2d( imaxifp, imaxjfp, isurf, kpi, kpj, & 
    688          &                  igrdi, igrdj, psurf, zsurf ) 
     733 
     734      ! At the end of the averaging period get interpolated means 
     735      IF ( ldtime_mean ) THEN 
     736         IF ( imeanend == 0 ) THEN 
     737            ALLOCATE( zsurfm(imaxifp,imaxjfp,isurf) ) 
     738            IF (lwp) WRITE(numout,*)' Interpolating the time mean values on time step: ',kt 
     739            CALL obs_int_comm_2d( imaxifp, imaxjfp, isurf, kpi, kpj, & 
     740               &                  igrdi, igrdj, surfdataqc%vdmean(:,:,kvar), zsurfm ) 
     741         ENDIF 
     742      ELSE 
     743         CALL obs_int_comm_2d( imaxifp, imaxjfp, isurf, kpi, kpj, & 
     744            &                  igrdi, igrdj, psurf, zsurf ) 
     745      ENDIF 
     746 
     747! IF ( k2dint > 4 ) THEN   AROUND THIS? - SEEMS TO BE IN V3.6 
    689748      CALL obs_int_comm_2d( imaxifp+1, imaxjfp+1, isurf, kpi, kpj, & 
    690749         &                  igrdip1, igrdjp1, glamf, zglamf ) 
     
    730789         zphi = surfdataqc%rphi(jobs) 
    731790 
    732          IF ( ldnightav .AND. idayend == 0 ) THEN 
    733             ! Night-time averaged data 
     791         IF ( ( ldnightav .AND. idayend == 0 ) .OR. (ldtime_mean .AND. imeanend == 0) ) THEN 
     792            ! Night-time or N=kmeanstp timestep averaged data 
    734793            zsurftmp(:,:,iobs) = zsurfm(:,:,iobs) 
    735794         ELSE 
     
    737796         ENDIF 
    738797 
    739          IF ( k2dint <= 4 ) THEN 
    740  
    741             ! Get weights to interpolate the model value to the observation point 
    742             CALL obs_int_h2d_init( 1, 1, k2dint, zlam, zphi,         & 
    743                &                   zglam(:,:,iobs), zgphi(:,:,iobs), & 
    744                &                   zmask(:,:,iobs), zweig, zobsmask ) 
    745  
    746             ! Interpolate the model value to the observation point  
    747             CALL obs_int_h2d( 1, 1, zweig, zsurftmp(:,:,iobs), zext ) 
    748  
    749          ELSE 
    750  
    751             ! Get weights to average the model field to the observation footprint 
    752             CALL obs_avg_h2d_init( 1, 1, imaxifp, imaxjfp, k2dint, zlam,  zphi, & 
    753                &                   zglam(:,:,iobs), zgphi(:,:,iobs), & 
    754                &                   zglamf(:,:,iobs), zgphif(:,:,iobs), & 
    755                &                   zmask(:,:,iobs), plamscl, pphiscl, & 
    756                &                   lindegrees, zweig, zobsmask ) 
    757  
    758             ! Average the model field to the observation footprint 
    759             CALL obs_avg_h2d( 1, 1, imaxifp, imaxjfp, & 
    760                &              zweig, zsurftmp(:,:,iobs),  zext ) 
    761  
    762          ENDIF 
    763  
    764          IF ( TRIM(surfdataqc%cvars(kvar)) == cobsname_sla .AND. PRESENT(kssh) .AND. PRESENT(kmdt) ) THEN 
    765             ! ... Remove the MDT from the SSH at the observation point to get the SLA 
    766             surfdataqc%radd(jobs,kssh,kvar) = zext(1) 
    767             surfdataqc%rmod(jobs,kvar) = surfdataqc%radd(jobs,kssh,kvar) - surfdataqc%rext(jobs,kmdt) 
     798         IF ( ( .NOT. ldtime_mean ) .OR. ( ldtime_mean .AND. imeanend == 0) ) THEN 
     799 
     800            IF ( k2dint <= 4 ) THEN 
     801 
     802               ! Get weights to interpolate the model value to the observation point 
     803               CALL obs_int_h2d_init( 1, 1, k2dint, zlam, zphi,         & 
     804                  &                   zglam(:,:,iobs), zgphi(:,:,iobs), & 
     805                  &                   zmask(:,:,iobs), zweig, zobsmask ) 
     806 
     807               ! Interpolate the model value to the observation point  
     808               CALL obs_int_h2d( 1, 1, zweig, zsurftmp(:,:,iobs), zext ) 
     809 
     810            ELSE 
     811 
     812               ! Get weights to average the model field to the observation footprint 
     813               CALL obs_avg_h2d_init( 1, 1, imaxifp, imaxjfp, k2dint, zlam,  zphi, & 
     814                  &                   zglam(:,:,iobs), zgphi(:,:,iobs), & 
     815                  &                   zglamf(:,:,iobs), zgphif(:,:,iobs), & 
     816                  &                   zmask(:,:,iobs), plamscl, pphiscl, & 
     817                  &                   lindegrees, zweig, zobsmask ) 
     818 
     819               ! Average the model field to the observation footprint 
     820               CALL obs_avg_h2d( 1, 1, imaxifp, imaxjfp, & 
     821                  &              zweig, zsurftmp(:,:,iobs),  zext ) 
     822 
     823            ENDIF 
     824 
     825            IF ( TRIM(surfdataqc%cvars(kvar)) == cobsname_sla .AND. PRESENT(kssh) .AND. PRESENT(kmdt) ) THEN 
     826               ! ... Remove the MDT from the SSH at the observation point to get the SLA 
     827               surfdataqc%radd(jobs,kssh,kvar) = zext(1) 
     828               surfdataqc%rmod(jobs,kvar) = surfdataqc%radd(jobs,kssh,kvar) - surfdataqc%rext(jobs,kmdt) 
    768829#if defined key_si3 || defined key_cice 
    769          ELSE IF ( TRIM(surfdataqc%cvars(kvar)) == cobsname_fbd .AND. PRESENT(kfbd) .AND. PRESENT(ksnow) ) THEN 
    770             ! Convert radar freeboard to true freeboard 
    771             ! (add 1/4 snow depth; 1/4 based on ratio of speed of light in vacuum 
    772             !  compared to snow (3.0e8 vs 2.4e8 m/s)) 
    773             surfdataqc%radd(jobs,kfbd,kvar) = surfdataqc%robs(jobs,kvar) 
    774             surfdataqc%robs(jobs,kvar) = surfdataqc%radd(jobs,kfbd,kvar) + 0.25*surfdataqc%rext(jobs,ksnow) 
    775             ! If the corrected freeboard observation is outside -0.3 to 3.0 m (CPOM) then set the QC flag to bad 
    776             IF ((surfdataqc%robs(jobs,kvar) < -0.3) .OR. (surfdataqc%robs(jobs,kvar) > 3.0)) THEN 
     830            ELSE IF ( TRIM(surfdataqc%cvars(kvar)) == cobsname_fbd .AND. PRESENT(kfbd) .AND. PRESENT(ksnow) ) THEN 
     831               ! Convert radar freeboard to true freeboard 
     832               ! (add 1/4 snow depth; 1/4 based on ratio of speed of light in vacuum 
     833               !  compared to snow (3.0e8 vs 2.4e8 m/s)) 
     834               surfdataqc%radd(jobs,kfbd,kvar) = surfdataqc%robs(jobs,kvar) 
     835               surfdataqc%robs(jobs,kvar) = surfdataqc%radd(jobs,kfbd,kvar) + 0.25*surfdataqc%rext(jobs,ksnow) 
     836               ! If the corrected freeboard observation is outside -0.3 to 3.0 m (CPOM) then set the QC flag to bad 
     837               IF ((surfdataqc%robs(jobs,kvar) < -0.3) .OR. (surfdataqc%robs(jobs,kvar) > 3.0)) THEN 
     838                  surfdataqc%nqc(jobs) = 4 
     839               ENDIF            
     840               ! Convert corrected freeboard to ice thickness following Tilling et al. (2016) 
     841               surfdataqc%robs(jobs,kvar) = (surfdataqc%robs(jobs,kvar)*rhow + surfdataqc%rext(jobs,ksnow)*rhos)/ & 
     842                  &                         (rhow - rhoi) 
     843#endif 
     844            ELSE 
     845               surfdataqc%rmod(jobs,kvar) = zext(1) 
     846            ENDIF 
     847 
     848            IF ( zext(1) == obfillflt ) THEN 
     849               ! If the observation value is a fill value, set QC flag to bad 
    777850               surfdataqc%nqc(jobs) = 4 
    778             ENDIF            
    779             ! Convert corrected freeboard to ice thickness following Tilling et al. (2016) 
    780             surfdataqc%robs(jobs,kvar) = (surfdataqc%robs(jobs,kvar)*rhow + surfdataqc%rext(jobs,ksnow)*rhos)/ & 
    781                &                         (rhow - rhoi) 
    782 #endif 
    783          ELSE 
    784             surfdataqc%rmod(jobs,kvar) = zext(1) 
    785          ENDIF 
    786  
    787          IF ( zext(1) == obfillflt ) THEN 
    788             ! If the observation value is a fill value, set QC flag to bad 
    789             surfdataqc%nqc(jobs) = 4 
     851            ENDIF 
     852 
    790853         ENDIF 
    791854 
     
    808871         & ) 
    809872 
    810       ! At the end of the day also deallocate night-time mean array 
    811       IF ( idayend == 0 .AND. ldnightav ) THEN 
     873      ! At the end of the day also deallocate time mean array 
     874      IF ( ( idayend == 0 .AND. ldnightav ) .OR. ( imeanend == 0 .AND. ldtime_mean ) ) THEN 
    812875         DEALLOCATE( & 
    813876            & zsurfm  & 
  • NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_read_surf.F90

    r15228 r15240  
    4343   SUBROUTINE obs_rea_surf( surfdata, knumfiles, cdfilenames, & 
    4444      &                     kvars, kadd, kextr, kstp, ddobsini, ddobsend, & 
     45      &                     ptime_mean_period, ld_time_mean_bkg, & 
    4546      &                     ldignmis, ldmod, ldnightav, cdvars ) 
    4647      !!--------------------------------------------------------------------- 
     
    6465      !! * Arguments 
    6566      TYPE(obs_surf), INTENT(INOUT) :: & 
    66          & surfdata                     ! Surface data to be read 
    67       INTEGER, INTENT(IN) :: knumfiles  ! Number of corio format files to read 
     67         & surfdata                             ! Surface data to be read 
     68      INTEGER,  INTENT(IN) :: knumfiles         ! Number of corio format files to read 
    6869      CHARACTER(LEN=128), INTENT(IN) :: & 
    69          & cdfilenames(knumfiles)       ! File names to read in 
    70       INTEGER, INTENT(IN) :: kvars      ! Number of variables in surfdata 
    71       INTEGER, INTENT(IN) :: kadd       ! Number of additional fields 
    72                                         !   in addition to those in the input file(s) 
    73       INTEGER, INTENT(IN) :: kextr      ! Number of extra fields 
    74                                         !   in addition to those in the input file(s) 
    75       INTEGER, INTENT(IN) :: kstp       ! Ocean time-step index 
    76       LOGICAL, INTENT(IN) :: ldignmis   ! Ignore missing files 
    77       LOGICAL, INTENT(IN) :: ldmod      ! Initialize model from input data 
    78       LOGICAL, INTENT(IN) :: ldnightav  ! Observations represent a night-time average 
    79       REAL(dp), INTENT(IN) :: ddobsini   ! Obs. ini time in YYYYMMDD.HHMMSS 
    80       REAL(dp), INTENT(IN) :: ddobsend   ! Obs. end time in YYYYMMDD.HHMMSS 
    81       CHARACTER(len=8), DIMENSION(kvars), INTENT(IN) :: cdvars 
     70         & cdfilenames(knumfiles)               ! File names to read in 
     71      INTEGER,  INTENT(IN) :: kvars             ! Number of variables in surfdata 
     72      INTEGER,  INTENT(IN) :: kadd              ! Number of additional fields 
     73                                                !   in addition to those in the input file(s) 
     74      INTEGER,  INTENT(IN) :: kextr             ! Number of extra fields 
     75                                                !   in addition to those in the input file(s) 
     76      INTEGER,  INTENT(IN) :: kstp              ! Ocean time-step index 
     77      REAL(dp), INTENT(IN) :: ddobsini          ! Obs. ini time in YYYYMMDD.HHMMSS 
     78      REAL(dp), INTENT(IN) :: ddobsend          ! Obs. end time in YYYYMMDD.HHMMSS 
     79      REAL(wp), INTENT(IN) :: ptime_mean_period ! Averaging period in hours 
     80      LOGICAL,  INTENT(IN) :: ld_time_mean_bkg  ! Will reset times to end of averaging period 
     81      LOGICAL,  INTENT(IN) :: ldignmis          ! Ignore missing files 
     82      LOGICAL,  INTENT(IN) :: ldmod             ! Initialize model from input data 
     83      LOGICAL,  INTENT(IN) :: ldnightav         ! Observations represent a night-time average 
     84      CHARACTER(len=8), DIMENSION(kvars), INTENT(IN) :: cdvars  ! Expected variable names 
    8285 
    8386      !! * Local declarations 
     
    376379               inpfiles(jj)%iobsj(:,:) = -1 
    377380            ENDIF 
     381 
     382            ! If observations are representing a time mean then set the time 
     383            ! of the obs to the end of that meaning period relative to the start of the run 
     384            IF ( ld_time_mean_bkg ) THEN 
     385               DO ji = 1, inpfiles(jj)%nobs 
     386                  ! Only do this for obs within time window 
     387                  IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. & 
     388                     & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN 
     389                     inpfiles(jj)%ptim(ji) = djulini(jj) + (ptime_mean_period/24.0) 
     390                  ENDIF 
     391               END DO 
     392            ENDIF 
     393 
    378394            inowin = 0 
    379395            DO ji = 1, inpfiles(jj)%nobs 
Note: See TracChangeset for help on using the changeset viewer.