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 5682 for branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS – NEMO

Ignore:
Timestamp:
2015-08-12T17:46:45+02:00 (9 years ago)
Author:
mattmartin
Message:

OBS simplification changes committed to branch after running SETTE tests to make sure we get the same results as the trunk for ORCA2_LIM_OBS.

Location:
branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/diaobs.F90

    r5659 r5682  
    66   !!====================================================================== 
    77 
    8    !!---------------------------------------------------------------------- 
    9    !!   'key_diaobs' : Switch on the observation diagnostic computation 
    108   !!---------------------------------------------------------------------- 
    119   !!   dia_obs_init : Reading and prepare observations 
     
    1513   !!   fin_date     : Compute the final date YYYYMMDD.HHMMSS 
    1614   !!---------------------------------------------------------------------- 
    17    !! * Modules used    
     15   !! * Modules used 
    1816   USE wrk_nemo                 ! Memory Allocation 
    1917   USE par_kind                 ! Precision variables 
     
    2119   USE par_oce 
    2220   USE dom_oce                  ! Ocean space and time domain variables 
    23    USE obs_fbm, ONLY: ln_cl4    ! Class 4 diagnostic switch 
    24    USE obs_read_prof            ! Reading and allocation of observations (Coriolis) 
    25    USE obs_read_surf            ! Reading and allocation of SLA observations   
     21   USE obs_read_prof            ! Reading and allocation of profile obs 
     22   USE obs_read_surf            ! Reading and allocation of surface obs 
    2623   USE obs_readmdt              ! Reading and allocation of MDT for SLA. 
    2724   USE obs_prep                 ! Preparation of obs. (grid search etc). 
     
    4542      &   dia_obs_dealloc  ! Deallocate dia_obs data 
    4643 
    47    !! * Shared Module variables 
    48    LOGICAL, PUBLIC, PARAMETER :: & 
    49 #if defined key_diaobs 
    50       & lk_diaobs = .TRUE.   !: Logical switch for observation diangostics 
    51 #else 
    52       & lk_diaobs = .FALSE.  !: Logical switch for observation diangostics 
    53 #endif 
    54  
    5544   !! * Module variables 
    56    LOGICAL, PUBLIC :: ln_t3d         !: Logical switch for temperature profiles 
    57    LOGICAL, PUBLIC :: ln_s3d         !: Logical switch for salinity profiles 
    58    LOGICAL, PUBLIC :: ln_sla         !: Logical switch for sea level anomalies  
    59    LOGICAL, PUBLIC :: ln_sst         !: Logical switch for sea surface temperature 
    60    LOGICAL, PUBLIC :: ln_seaice      !: Logical switch for sea ice concentration 
    61    LOGICAL, PUBLIC :: ln_vel3d       !: Logical switch for velocity component (u,v) observations 
    62    LOGICAL, PUBLIC :: ln_ssh         !: Logical switch for sea surface height 
    63    LOGICAL, PUBLIC :: ln_sss         !: Logical switch for sea surface salinity 
    64    LOGICAL, PUBLIC :: ln_sstnight    !: Logical switch for night mean SST observations 
    65    LOGICAL, PUBLIC :: ln_nea         !: Remove observations near land 
    66    LOGICAL, PUBLIC :: ln_altbias     !: Logical switch for altimeter bias   
    67    LOGICAL, PUBLIC :: ln_ignmis      !: Logical switch for ignoring missing files 
    68    LOGICAL, PUBLIC :: ln_s_at_t      !: Logical switch to compute model S at T observations 
    69  
    70    REAL(KIND=dp), PUBLIC :: dobsini   !: Observation window start date YYYYMMDD.HHMMSS 
    71    REAL(KIND=dp), PUBLIC :: dobsend   !: Observation window end date YYYYMMDD.HHMMSS 
    72    
    73    INTEGER, PUBLIC :: numobtypes   !: Number of observation types to read in. 
    74    INTEGER, PUBLIC :: n1dint       !: Vertical interpolation method 
    75    INTEGER, PUBLIC :: n2dint       !: Horizontal interpolation method  
    76    INTEGER, DIMENSION(:), ALLOCATABLE :: nvarsprof !Number of profile variables 
    77    INTEGER, DIMENSION(:), ALLOCATABLE :: nextrprof !Number of profile extra variables 
    78    INTEGER, DIMENSION(:), ALLOCATABLE :: nvarssurf !Number of surface variables 
    79    INTEGER, DIMENSION(:), ALLOCATABLE :: nextrsurf !Number of surface extra variables 
     45   LOGICAL, PUBLIC :: ln_diaobs   !: Logical switch for the obs operator 
     46   LOGICAL :: ln_sstnight         !: Logical switch for night mean SST obs 
     47 
     48   INTEGER :: nn_1dint       !: Vertical interpolation method 
     49   INTEGER :: nn_2dint       !: Horizontal interpolation method 
    8050   INTEGER, DIMENSION(imaxavtypes) :: & 
    81       & dailyavtypes !: Data types which are daily average 
    82  
    83    TYPE(obs_surf), PUBLIC, POINTER, DIMENSION(:) :: surfdata   ! Initial surface data 
    84    TYPE(obs_surf), PUBLIC, POINTER, DIMENSION(:) :: surfdataqc ! Surface data after quality control 
    85    TYPE(obs_prof), PUBLIC, POINTER, DIMENSION(:) :: profdata   ! Initial profile data 
    86    TYPE(obs_prof), PUBLIC, POINTER, DIMENSION(:) :: profdataqc ! Profile data after quality control 
    87  
    88    CHARACTER(len=6),   PUBLIC, DIMENSION(:),   ALLOCATABLE :: obstypesprof 
    89    CHARACTER(len=6),   PUBLIC, DIMENSION(:),   ALLOCATABLE :: obstypessurf 
    90  
    91  
    92        
    93    INTEGER, PARAMETER :: MaxNumFiles = 1000 
    94     
    95    LOGICAL, DIMENSION(MaxNumFiles) :: & 
    96       & ln_profb_ena, & !: Is the feedback files from ENACT data ? 
    97    !                    !: If so use dailyavtypes 
    98       & ln_profb_enatim !: Change tim for 820 enact data set. 
    99     
    100    LOGICAL, DIMENSION(MaxNumFiles) :: & 
    101       & ln_velfb_av   !: Is the velocity feedback files daily average? 
    102    LOGICAL, DIMENSION(:), ALLOCATABLE :: & 
    103       & ld_enact     !: Profile data is ENACT so use dailyavtypes 
    104    LOGICAL, DIMENSION(:), ALLOCATABLE :: & 
    105       & ld_velav     !: Velocity data is daily averaged 
    106    LOGICAL, DIMENSION(:), ALLOCATABLE :: & 
    107       & ld_sstnight  !: SST observation corresponds to night mean 
     51      & nn_profdavtypes      !: Profile data types representing a daily average 
     52   INTEGER :: nproftypes     !: Number of profile obs types 
     53   INTEGER :: nsurftypes     !: Number of surface obs types 
     54   INTEGER, DIMENSION(:), ALLOCATABLE :: & 
     55      & nvarsprof, &         !: Number of profile variables 
     56      & nvarssurf            !: Number of surface variables 
     57   INTEGER, DIMENSION(:), ALLOCATABLE :: & 
     58      & nextrprof, &         !: Number of profile extra variables 
     59      & nextrsurf            !: Number of surface extra variables 
     60 
     61   TYPE(obs_surf), PUBLIC, POINTER, DIMENSION(:) :: & 
     62      & surfdata, &          !: Initial surface data 
     63      & surfdataqc           !: Surface data after quality control 
     64   TYPE(obs_prof), PUBLIC, POINTER, DIMENSION(:) :: & 
     65      & profdata, &          !: Initial profile data 
     66      & profdataqc           !: Profile data after quality control 
     67 
     68   CHARACTER(len=6), PUBLIC, DIMENSION(:), ALLOCATABLE :: & 
     69      & cobstypesprof, &     !: Profile obs types 
     70      & cobstypessurf        !: Surface obs types 
    10871 
    10972   !!---------------------------------------------------------------------- 
     
    13699 
    137100      !! * Local declarations 
    138       CHARACTER(len=128) :: profbfiles(MaxNumFiles) 
    139       CHARACTER(len=128) :: sstfbfiles(MaxNumFiles) 
    140       CHARACTER(len=128) :: slafbfiles(MaxNumFiles) 
    141       CHARACTER(len=128) :: seaicefbfiles(MaxNumFiles) 
    142       CHARACTER(len=128) :: velfbfiles(MaxNumFiles) 
    143       CHARACTER(LEN=128) :: bias_file 
    144       CHARACTER(LEN=20)  :: datestr=" ", timestr=" " 
    145  
    146       NAMELIST/namobs/ln_t3d, ln_s3d, ln_sla, ln_sss, ln_ssh,         & 
    147          &            ln_sst, ln_seaice, ln_vel3d,                    & 
     101      INTEGER, PARAMETER :: & 
     102         & jpmaxnfiles = 1000    ! Maximum number of files for each obs type 
     103      INTEGER, DIMENSION(:), ALLOCATABLE :: & 
     104         & ifilesprof, &         ! Number of profile files 
     105         & ifilessurf            ! Number of surface files 
     106      INTEGER :: ios             ! Local integer output status for namelist read 
     107      INTEGER :: jtype           ! Counter for obs types 
     108      INTEGER :: jvar            ! Counter for variables 
     109      INTEGER :: jfile           ! Counter for files 
     110 
     111      CHARACTER(len=128), DIMENSION(jpmaxnfiles) :: & 
     112         & cn_profbfiles, &      ! T/S profile input filenames 
     113         & cn_sstfbfiles, &      ! Sea surface temperature input filenames 
     114         & cn_slafbfiles, &      ! Sea level anomaly input filenames 
     115         & cn_sicfbfiles, &      ! Seaice concentration input filenames 
     116         & cn_velfbfiles         ! Velocity profile input filenames 
     117      CHARACTER(LEN=128) :: & 
     118         & cn_altbiasfile        ! Altimeter bias input filename 
     119      CHARACTER(len=128), DIMENSION(:,:), ALLOCATABLE :: & 
     120         & clproffiles, &        ! Profile filenames 
     121         & clsurffiles           ! Surface filenames 
     122 
     123      LOGICAL :: ln_t3d          ! Logical switch for temperature profiles 
     124      LOGICAL :: ln_s3d          ! Logical switch for salinity profiles 
     125      LOGICAL :: ln_sla          ! Logical switch for sea level anomalies  
     126      LOGICAL :: ln_sst          ! Logical switch for sea surface temperature 
     127      LOGICAL :: ln_sic          ! Logical switch for sea ice concentration 
     128      LOGICAL :: ln_vel3d        ! Logical switch for velocity (u,v) obs 
     129      LOGICAL :: ln_nea          ! Logical switch to remove obs near land 
     130      LOGICAL :: ln_altbias      ! Logical switch for altimeter bias 
     131      LOGICAL :: ln_ignmis       ! Logical switch for ignoring missing files 
     132      LOGICAL :: ln_s_at_t       ! Logical switch to compute model S at T obs 
     133      LOGICAL :: llvar1          ! Logical for profile variable 1 
     134      LOGICAL :: llvar2          ! Logical for profile variable 1 
     135      LOGICAL :: llnightav       ! Logical for calculating night-time averages 
     136 
     137      REAL(dp) :: rn_dobsini     ! Obs window start date YYYYMMDD.HHMMSS 
     138      REAL(dp) :: rn_dobsend     ! Obs window end date   YYYYMMDD.HHMMSS 
     139      REAL(wp), DIMENSION(jpi,jpj) :: & 
     140         & zglam1, &             ! Model longitudes for profile variable 1 
     141         & zglam2                ! Model longitudes for profile variable 2 
     142      REAL(wp), DIMENSION(jpi,jpj) :: & 
     143         & zgphi1, &             ! Model latitudes for profile variable 1 
     144         & zgphi2                ! Model latitudes for profile variable 2 
     145      REAL(wp), DIMENSION(jpi,jpj,jpk) :: & 
     146         & zmask1, &             ! Model land/sea mask associated with variable 1 
     147         & zmask2                ! Model land/sea mask associated with variable 2 
     148 
     149      NAMELIST/namobs/ln_diaobs, ln_t3d, ln_s3d, ln_sla,              & 
     150         &            ln_sst, ln_sic, ln_vel3d,                       & 
    148151         &            ln_altbias, ln_nea, ln_grid_global,             & 
    149          &            ln_grid_search_lookup, ln_cl4,                  & 
     152         &            ln_grid_search_lookup,                          & 
    150153         &            ln_ignmis, ln_s_at_t, ln_sstnight,              & 
    151          &            ln_profb_ena, ln_profb_enatim,                  & 
    152          &            profbfiles, slafbfiles, sssfbfiles,             & 
    153          &            sshfbfiles, sstfbfiles, seaicefbfiles,          & 
    154          &            velfbfiles, bias_file, grid_search_file,        & 
    155          &            dobsini, dobsend, n1dint, n2dint,               & 
    156          &            nmsshc, mdtcorr, mdtcutoff,                     & 
    157          &            grid_search_res, dailyavtypes 
    158  
    159       INTEGER :: jtype 
    160       INTEGER :: ios                 ! Local integer output status for namelist read 
    161       INTEGER, DIMENSION(:), ALLOCATABLE :: jnumfilesprof 
    162       INTEGER, DIMENSION(:), ALLOCATABLE :: jnumfilessurf 
    163       CHARACTER(len=128), DIMENSION(:,:), ALLOCATABLE :: obsfilesprof 
    164       CHARACTER(len=128), DIMENSION(:,:), ALLOCATABLE :: obsfilessurf 
    165       LOGICAL :: lmask(MaxNumFiles) 
     154         &            cn_profbfiles, cn_slafbfiles,                   & 
     155         &            cn_sstfbfiles, cn_sicfbfiles,                   & 
     156         &            cn_velfbfiles, cn_altbiasfile,                  & 
     157         &            cn_gridsearchfile, rn_gridsearchres,            & 
     158         &            rn_dobsini, rn_dobsend, nn_1dint, nn_2dint,     & 
     159         &            nn_msshc, rn_mdtcorr, rn_mdtcutoff,             & 
     160         &            nn_profdavtypes 
     161 
    166162      !----------------------------------------------------------------------- 
    167163      ! Read namelist parameters 
    168164      !----------------------------------------------------------------------- 
    169165 
    170       profbfiles(:) = '' 
    171       slafbfiles(:) = '' 
    172       sstfbfiles(:) = '' 
    173       seaicefbfiles(:) = '' 
    174       velfbfiles(:) = '' 
    175       dailyavtypes(:) = -1 
    176       dailyavtypes(1) = 820 
    177       ln_profb_ena(:) = .FALSE. 
    178       ln_profb_enatim(:) = .TRUE. 
    179       ln_velfb_av(:) = .FALSE. 
    180       ln_ignmis = .FALSE. 
    181  
    182       CALL ini_date( dobsini ) 
    183       CALL fin_date( dobsend ) 
    184  
    185       ! Read Namelist namobs : control observation diagnostics 
    186       REWIND( numnam_ref )              ! Namelist namobs in reference namelist : Diagnostic: control observation 
     166      ! Some namelist arrays need initialising 
     167      cn_profbfiles(:) = '' 
     168      cn_slafbfiles(:) = '' 
     169      cn_sstfbfiles(:) = '' 
     170      cn_sicfbfiles(:) = '' 
     171      cn_velfbfiles(:) = '' 
     172      nn_profdavtypes(:) = -1 
     173 
     174      CALL ini_date( rn_dobsini ) 
     175      CALL fin_date( rn_dobsend ) 
     176 
     177      ! Read namelist namobs : control observation diagnostics 
     178      REWIND( numnam_ref )   ! Namelist namobs in reference namelist 
    187179      READ  ( numnam_ref, namobs, IOSTAT = ios, ERR = 901) 
    188180901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namobs in reference namelist', lwp ) 
    189181 
    190       REWIND( numnam_cfg )              ! Namelist namobs in configuration namelist : Diagnostic: control observation 
     182      REWIND( numnam_cfg )   ! Namelist namobs in configuration namelist 
    191183      READ  ( numnam_cfg, namobs, IOSTAT = ios, ERR = 902 ) 
    192184902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namobs in configuration namelist', lwp ) 
    193185      IF(lwm) WRITE ( numond, namobs ) 
    194186 
    195       !Set up list of observation types to be used 
    196       numproftypes = COUNT( (/ln_t3d .OR. ln_s3d, ln_vel3d /) ) 
    197       numsurftypes = COUNT( (/ln_sla, ln_sss, ln_sst, ln_seaice /) ) 
    198       IF ( numproftypes > 0 ) THEN 
    199        
    200          ALLOCATE( obstypesprof(numproftypes) ) 
    201          ALLOCATE( jnumfilesprof(numproftypes) ) 
    202          ALLOCATE( obsfilesprof(numproftypes, MaxNumFiles) ) 
    203        
    204          DO jtype = 1, numproftypes 
    205             IF (ln_t3d .OR. ln_s3d) THEN 
    206                obsfilesprof(:,jtype) = profbfiles(:) 
    207                obstypesprof(jtype) = 'prof' 
    208             ENDIF 
    209             IF (ln_vel3d) THEN 
    210                obsfilesprof(:,jtype) = velfbfiles(:) 
    211                obstypesprof(jtype) = 'vel' 
    212             ENDIF 
    213           
    214             lmask(:) = .FALSE. 
    215             WHERE (obsfilesprof(jtype,:) /= '') lmask(:) = .TRUE. 
    216             jnumfilesprof(jtype) = COUNT(lmask) 
    217          END DO 
    218           
    219       ENDIF 
    220        
    221       IF ( numsurftypes > 0 ) THEN 
    222        
    223          ALLOCATE( obstypessurf(numsurftypes) ) 
    224          ALLOCATE( jnumfilessurf(numproftypes) ) 
    225          ALLOCATE( obsfilessurf(numsurftypes, MaxNumFiles) ) 
    226           
    227          DO jtype = 1, numsurftypes 
    228             IF (ln_sla) THEN 
    229                obsfilessurf(:,jtype) = slafbfiles(:) 
    230                obstypessurf(jtype) = 'sla' 
    231             ENDIF 
    232             IF (ln_sss) THEN 
    233                obsfilessurf(:,jtype) = sssfbfiles(:) 
    234                obstypessurf(jtype) = 'sss' 
    235             ENDIF 
    236             IF (ln_sst) THEN 
    237                obsfilessurf(:,jtype) = sstfbfiles(:) 
    238                obstypessurf(jtype) = 'sst' 
    239             ENDIF 
     187      IF ( .NOT. ln_diaobs ) THEN 
     188         IF(lwp) WRITE(numout,cform_war) 
     189         IF(lwp) WRITE(numout,*)' ln_diaobs is set to false so not calling dia_obs' 
     190         RETURN 
     191      ENDIF 
     192 
     193      !----------------------------------------------------------------------- 
     194      ! Set up list of observation types to be used 
     195      ! and the files associated with each type 
     196      !----------------------------------------------------------------------- 
     197 
     198      nproftypes = COUNT( (/ln_t3d .OR. ln_s3d, ln_vel3d /) ) 
     199      nsurftypes = COUNT( (/ln_sla, ln_sst, ln_sic /) ) 
     200 
     201      IF ( nproftypes == 0 .AND. nsurftypes == 0 ) THEN 
     202         IF(lwp) WRITE(numout,cform_war) 
     203         IF(lwp) WRITE(numout,*) ' ln_diaobs is set to true, but all obs operator logical flags', & 
     204            &                    ' ln_t3d, ln_s3d, ln_sla, ln_sst, ln_sic, ln_vel3d', & 
     205            &                    ' are set to .FALSE. so turning off calls to dia_obs' 
     206         nwarn = nwarn + 1 
     207         ln_diaobs = .FALSE. 
     208         RETURN 
     209      ENDIF 
     210 
     211      IF ( nproftypes > 0 ) THEN 
     212 
     213         ALLOCATE( cobstypesprof(nproftypes) ) 
     214         ALLOCATE( ifilesprof(nproftypes) ) 
     215         ALLOCATE( clproffiles(nproftypes,jpmaxnfiles) ) 
     216 
     217         jtype = 0 
     218         IF (ln_t3d .OR. ln_s3d) THEN 
     219            jtype = jtype + 1 
     220            clproffiles(jtype,:) = cn_profbfiles(:) 
     221            cobstypesprof(jtype) = 'prof  ' 
     222            ifilesprof(jtype) = 0 
     223            DO jfile = 1, jpmaxnfiles 
     224               IF ( trim(clproffiles(jtype,jfile)) /= '' ) & 
     225                  ifilesprof(jtype) = ifilesprof(jtype) + 1 
     226            END DO 
     227         ENDIF 
     228         IF (ln_vel3d) THEN 
     229            jtype = jtype + 1 
     230            clproffiles(jtype,:) = cn_velfbfiles(:) 
     231            cobstypesprof(jtype) = 'vel   ' 
     232            ifilesprof(jtype) = 0 
     233            DO jfile = 1, jpmaxnfiles 
     234               IF ( trim(clproffiles(jtype,jfile)) /= '' ) & 
     235                  ifilesprof(jtype) = ifilesprof(jtype) + 1 
     236            END DO 
     237         ENDIF 
     238 
     239      ENDIF 
     240 
     241      IF ( nsurftypes > 0 ) THEN 
     242 
     243         ALLOCATE( cobstypessurf(nsurftypes) ) 
     244         ALLOCATE( ifilessurf(nsurftypes) ) 
     245         ALLOCATE( clsurffiles(nsurftypes, jpmaxnfiles) ) 
     246 
     247         jtype = 0 
     248         IF (ln_sla) THEN 
     249            jtype = jtype + 1 
     250            clsurffiles(jtype,:) = cn_slafbfiles(:) 
     251            cobstypessurf(jtype) = 'sla   ' 
     252            ifilessurf(jtype) = 0 
     253            DO jfile = 1, jpmaxnfiles 
     254               IF ( trim(clsurffiles(jtype,jfile)) /= '' ) & 
     255                  ifilessurf(jtype) = ifilessurf(jtype) + 1 
     256            END DO 
     257         ENDIF 
     258         IF (ln_sst) THEN 
     259            jtype = jtype + 1 
     260            clsurffiles(jtype,:) = cn_sstfbfiles(:) 
     261            cobstypessurf(jtype) = 'sst   ' 
     262            ifilessurf(jtype) = 0 
     263            DO jfile = 1, jpmaxnfiles 
     264               IF ( trim(clsurffiles(jtype,jfile)) /= '' ) & 
     265                  ifilessurf(jtype) = ifilessurf(jtype) + 1 
     266            END DO 
     267         ENDIF 
    240268#if defined key_lim2 || defined key_lim3 
    241             IF (ln_seaice) THEN 
    242                obsfilessurf(:,jtype) = seaicefbfiles(:) 
    243                obstypessurf(jtype) = 'seaice' 
    244             ENDIF 
     269         IF (ln_sic) THEN 
     270            jtype = jtype + 1 
     271            clsurffiles(jtype,:) = cn_sicfbfiles(:) 
     272            cobstypessurf(jtype) = 'sic   ' 
     273            ifilessurf(jtype) = 0 
     274            DO jfile = 1, jpmaxnfiles 
     275               IF ( trim(clsurffiles(jtype,jfile)) /= '' ) & 
     276                  ifilessurf(jtype) = ifilessurf(jtype) + 1 
     277            END DO 
     278         ENDIF 
    245279#endif 
    246280 
    247             lmask(:) = .FALSE. 
    248             WHERE (obsfilessurf(jtype,:) /= '') lmask(:) = .TRUE. 
    249             jnumfilessurf(jtype) = COUNT(lmask) 
    250           
    251          END DO 
    252           
    253281      ENDIF 
    254282 
     
    259287         WRITE(numout,*) '~~~~~~~~~~~~' 
    260288         WRITE(numout,*) '          Namelist namobs : set observation diagnostic parameters'  
    261          WRITE(numout,*) '             Logical switch for T profile observations          ln_t3d = ', ln_t3d 
    262          WRITE(numout,*) '             Logical switch for S profile observations          ln_s3d = ', ln_s3d 
    263          WRITE(numout,*) '             Logical switch for SLA observations                ln_sla = ', ln_sla 
    264          WRITE(numout,*) '             Logical switch for SSH observations                ln_ssh = ', ln_ssh 
    265          WRITE(numout,*) '             Logical switch for SST observations                ln_sst = ', ln_sst 
    266          WRITE(numout,*) '             Logical switch for night-time SST obs         ln_sstnight = ', ln_sstnight 
    267          WRITE(numout,*) '             Logical switch for SSS observations                ln_sss = ', ln_sss 
    268          WRITE(numout,*) '             Logical switch for Sea Ice observations         ln_seaice = ', ln_seaice 
    269          WRITE(numout,*) '             Logical switch for velocity observations         ln_vel3d = ', ln_vel3d 
    270          WRITE(numout,*) '             Global distribution of observations        ln_grid_global = ',ln_grid_global 
    271          WRITE(numout,*) & 
    272    '             Logical switch for obs grid search w/lookup table  ln_grid_search_lookup = ',ln_grid_search_lookup 
     289         WRITE(numout,*) '             Logical switch for T profile observations                ln_t3d = ', ln_t3d 
     290         WRITE(numout,*) '             Logical switch for S profile observations                ln_s3d = ', ln_s3d 
     291         WRITE(numout,*) '             Logical switch for SLA observations                      ln_sla = ', ln_sla 
     292         WRITE(numout,*) '             Logical switch for SST observations                      ln_sst = ', ln_sst 
     293         WRITE(numout,*) '             Logical switch for Sea Ice observations                  ln_sic = ', ln_sic 
     294         WRITE(numout,*) '             Logical switch for velocity observations               ln_vel3d = ', ln_vel3d 
     295         WRITE(numout,*) '             Global distribution of observations              ln_grid_global = ',ln_grid_global 
     296         WRITE(numout,*) '             Logical switch for obs grid search lookup ln_grid_search_lookup = ',ln_grid_search_lookup 
    273297         IF (ln_grid_search_lookup) & 
    274             WRITE(numout,*) '             Grid search lookup file header       grid_search_file = ', grid_search_file 
    275          WRITE(numout,*) '             Initial date in window YYYYMMDD.HHMMSS        dobsini = ', dobsin 
    276          WRITE(numout,*) '             Final date in window YYYYMMDD.HHMMSS          dobsend = ', dobsend 
    277          WRITE(numout,*) '             Type of vertical interpolation method          n1dint = ', n1dint 
    278          WRITE(numout,*) '             Type of horizontal interpolation method        n2dint = ', n2dint 
    279          WRITE(numout,*) '             Rejection of observations near land swithch    ln_nea = ', ln_nea 
    280          WRITE(numout,*) '             MSSH correction scheme                         nmsshc = ', nmsshc 
    281          WRITE(numout,*) '             MDT  correction                               mdtcorr = ', mdtcorr 
    282          WRITE(numout,*) '             MDT cutoff for computed correction          mdtcutoff = ', mdtcutoff 
    283          WRITE(numout,*) '             Logical switch for alt bias                ln_altbias = ', ln_altbias 
    284          WRITE(numout,*) '             Logical switch for ignoring missing files   ln_ignmis = ', ln_ignmis 
    285          WRITE(numout,*) '             Daily average types                                   = ', dailyavtypes 
    286  
    287          IF ( numproftypes > 0 ) THEN 
    288             DO jtype = 1, numproftypes 
    289                DO ji = 1, jnumfilesprof(jtype) 
    290                   WRITE(numout,'(1X,2A)') '             '//obstypesprof(jtype)//' input observation file names  = ', & 
    291                      TRIM(obsfilesprof(jtype,ji)) 
    292                   IF ( TRIM(obstypesprof(jtype)) == 'prof' ) & 
    293                      WRITE(numout,'(1X,2A)') '       Enact feedback input time setting switch    ln_profb_enatim = ', ln_profb_enatim(ji) 
     298            WRITE(numout,*) '             Grid search lookup file header                cn_gridsearchfile = ', cn_gridsearchfile 
     299         WRITE(numout,*) '             Initial date in window YYYYMMDD.HHMMSS               rn_dobsini = ', rn_dobsini 
     300         WRITE(numout,*) '             Final date in window YYYYMMDD.HHMMSS                 rn_dobsend = ', rn_dobsend 
     301         WRITE(numout,*) '             Type of vertical interpolation method                  nn_1dint = ', nn_1dint 
     302         WRITE(numout,*) '             Type of horizontal interpolation method                nn_2dint = ', nn_2dint 
     303         WRITE(numout,*) '             Rejection of observations near land switch               ln_nea = ', ln_nea 
     304         WRITE(numout,*) '             MSSH correction scheme                                 nn_msshc = ', nn_msshc 
     305         WRITE(numout,*) '             MDT  correction                                      rn_mdtcorr = ', rn_mdtcorr 
     306         WRITE(numout,*) '             MDT cutoff for computed correction                 rn_mdtcutoff = ', rn_mdtcutoff 
     307         WRITE(numout,*) '             Logical switch for alt bias                          ln_altbias = ', ln_altbias 
     308         WRITE(numout,*) '             Logical switch for ignoring missing files             ln_ignmis = ', ln_ignmis 
     309         WRITE(numout,*) '             Daily average types                             nn_profdavtypes = ', nn_profdavtypes 
     310         WRITE(numout,*) '             Logical switch for night-time SST obs               ln_sstnight = ', ln_sstnight 
     311         WRITE(numout,*) '          Number of profile obs types: ',nproftypes 
     312 
     313         IF ( nproftypes > 0 ) THEN 
     314            DO jtype = 1, nproftypes 
     315               DO jfile = 1, ifilesprof(jtype) 
     316                  WRITE(numout,'(1X,2A)') '             '//cobstypesprof(jtype)//' input observation file names  = ', & 
     317                     TRIM(clproffiles(jtype,jfile)) 
    294318               END DO 
    295319            END DO 
    296320         ENDIF 
    297           
    298          IF ( numsurftypes > 0 ) THEN 
    299             DO jtype = 1, numsurftypes 
    300                DO ji = 1, jnumfilessurf(jtype) 
    301                   WRITE(numout,'(1X,2A)') '             '//obstypessurf(jtype)//' input observation file names  = ', & 
    302                      TRIM(obsfilessurf(jtype,ji)) 
     321 
     322         WRITE(numout,*)'          Number of surface obs types: ',nsurftypes 
     323         IF ( nsurftypes > 0 ) THEN 
     324            DO jtype = 1, nsurftypes 
     325               DO jfile = 1, ifilessurf(jtype) 
     326                  WRITE(numout,'(1X,2A)') '             '//cobstypessurf(jtype)//' input observation file names  = ', & 
     327                     TRIM(clsurffiles(jtype,jfile)) 
    303328               END DO 
    304329            END DO 
    305330         ENDIF 
    306  
    307       ENDIF 
    308        
     331         WRITE(numout,*) '~~~~~~~~~~~~' 
     332 
     333      ENDIF 
     334 
     335      !----------------------------------------------------------------------- 
     336      ! Obs operator parameter checking and initialisations 
     337      !----------------------------------------------------------------------- 
     338 
    309339      IF ( ln_vel3d .AND. ( .NOT. ln_grid_global ) ) THEN 
    310340         CALL ctl_stop( 'Velocity data only works with ln_grid_global=.true.' ) 
     
    312342      ENDIF 
    313343 
    314       CALL obs_typ_init 
    315        
    316       CALL mppmap_init 
    317        
    318       ! Parameter control 
    319 #if defined key_diaobs 
    320       IF ( numobtypes == 0 ) THEN 
    321          IF(lwp) WRITE(numout,cform_war) 
    322          IF(lwp) WRITE(numout,*) ' key_diaobs is activated but logical flags', & 
    323             &                    ' ln_t3d, ln_s3d, ln_sla, ln_ssh, ln_sst, ln_sss, ln_seaice, ln_vel3d are all set to .FALSE.' 
    324          nwarn = nwarn + 1 
    325       ENDIF 
    326 #endif 
    327  
    328       CALL obs_grid_setup( ) 
    329       IF ( ( n1dint < 0 ).OR.( n1dint > 1 ) ) THEN 
     344      IF ( ( nn_1dint < 0 ) .OR. ( nn_1dint > 1 ) ) THEN 
    330345         CALL ctl_stop(' Choice of vertical (1D) interpolation method', & 
    331346            &                    ' is not available') 
    332347      ENDIF 
    333       IF ( ( n2dint < 0 ).OR.( n2dint > 4 ) ) THEN 
     348 
     349      IF ( ( nn_2dint < 0 ) .OR. ( nn_2dint > 4 ) ) THEN 
    334350         CALL ctl_stop(' Choice of horizontal (2D) interpolation method', & 
    335351            &                    ' is not available') 
    336352      ENDIF 
    337353 
     354      CALL obs_typ_init 
     355 
     356      CALL mppmap_init 
     357 
     358      CALL obs_grid_setup( ) 
     359 
    338360      !----------------------------------------------------------------------- 
    339361      ! Depending on switches read the various observation types 
    340362      !----------------------------------------------------------------------- 
    341        
    342       IF ( numproftypes > 0 ) THEN 
    343        
    344          ALLOCATE(profdata(numproftypes)) 
    345          ALLOCATE(profdataqc(numproftypes)) 
    346          ALLOCATE(nvarsprof(numproftypes)) 
    347          ALLOCATE(nextrprof(numproftypes)) 
    348              
    349          DO jtype = 1, numproftypes 
    350        
     363 
     364      IF ( nproftypes > 0 ) THEN 
     365 
     366         ALLOCATE(profdata(nproftypes)) 
     367         ALLOCATE(profdataqc(nproftypes)) 
     368         ALLOCATE(nvarsprof(nproftypes)) 
     369         ALLOCATE(nextrprof(nproftypes)) 
     370 
     371         DO jtype = 1, nproftypes 
     372 
    351373            nvarsprof(jtype) = 2 
    352             IF ( TRIM(obstypesprof(jtype)) == 'prof' ) nextrprof(jtype) = 1 
    353             IF ( TRIM(obstypesprof(jtype)) == 'vel' )  nextrprof(jtype) = 2 
    354  
    355             !Read in profile or velocity obs types 
    356             CALL obs_rea_prof( profdata(jtype),          & 
    357                &               jnumfilesprof(jtype),       & 
    358                &               obsfilesprof(jtype,1:jnumfilesprof(jtype)), & 
    359                &               nvarsprof(jtype), nextrprof(jtype), nitend-nit000+2,             & 
    360                &               dobsini, dobsend, ln_t3d, ln_s3d, & 
    361                &               ln_ignmis, ln_s_at_t, .TRUE., .FALSE., & 
    362                &               kdailyavtypes = dailyavtypes ) 
    363              
    364             DO jvar = 1, nvars 
     374            IF ( TRIM(cobstypesprof(jtype)) == 'prof' ) THEN 
     375               nextrprof(jtype) = 1 
     376               llvar1 = ln_t3d 
     377               llvar2 = ln_s3d 
     378               zglam1 = glamt 
     379               zgphi1 = gphit 
     380               zmask1 = tmask 
     381               zglam2 = glamt 
     382               zgphi2 = gphit 
     383               zmask2 = tmask 
     384            ENDIF 
     385            IF ( TRIM(cobstypesprof(jtype)) == 'vel' )  THEN 
     386               nextrprof(jtype) = 2 
     387               llvar1 = ln_vel3d 
     388               llvar2 = ln_vel3d 
     389               zglam1 = glamu 
     390               zgphi1 = gphiu 
     391               zmask1 = umask 
     392               zglam2 = glamv 
     393               zgphi2 = gphiv 
     394               zmask2 = vmask 
     395            ENDIF 
     396 
     397            !Read in profile or profile obs types 
     398            CALL obs_rea_prof( profdata(jtype), ifilesprof(jtype),       & 
     399               &               clproffiles(jtype,1:ifilesprof(jtype)), & 
     400               &               nvarsprof(jtype), nextrprof(jtype), nitend-nit000+2, & 
     401               &               rn_dobsini, rn_dobsend, llvar1, llvar2, & 
     402               &               ln_ignmis, ln_s_at_t, .FALSE., & 
     403               &               kdailyavtypes = nn_profdavtypes ) 
     404 
     405            DO jvar = 1, nvarsprof(jtype) 
    365406               CALL obs_prof_staend( profdata(jtype), jvar ) 
    366407            END DO 
    367           
    368             CALL obs_pre_prof( profdata(jtype), profdataqc(jtype),   & 
    369                &              ln_t3d, ln_s3d, ln_nea, & 
    370                &              kdailyavtypes = dailyavtypes ) 
     408 
     409            CALL obs_pre_prof( profdata(jtype), profdataqc(jtype), & 
     410               &               llvar1, llvar2, & 
     411               &               zmask1, zglam1, zgphi1, zmask2, zglam2, zgphi2,  & 
     412               &               ln_nea, kdailyavtypes = nn_profdavtypes ) 
    371413 
    372414         END DO 
    373415 
    374          DEALLOCATE( jnumfilesprof, obsfilesprof ) 
    375  
    376       ENDIF 
    377  
    378       IF ( numsurftypes > 0 ) THEN 
    379        
    380          ALLOCATE(surfdata(numsurftypes)) 
    381          ALLOCATE(surfdatatqc(numsurftypes)) 
    382          ALLOCATE(nvarssurf(numsurftypes)) 
    383          ALLOCATE(nextrsurf(numsurftypes)) 
    384           
    385          DO jtype = 1, numsurftypes 
    386        
     416         DEALLOCATE( ifilesprof, clproffiles ) 
     417 
     418      ENDIF 
     419 
     420      IF ( nsurftypes > 0 ) THEN 
     421 
     422         ALLOCATE(surfdata(nsurftypes)) 
     423         ALLOCATE(surfdataqc(nsurftypes)) 
     424         ALLOCATE(nvarssurf(nsurftypes)) 
     425         ALLOCATE(nextrsurf(nsurftypes)) 
     426 
     427         DO jtype = 1, nsurftypes 
     428 
    387429            nvarssurf(jtype) = 1 
    388430            nextrsurf(jtype) = 0 
    389             IF ( TRIM(obstypessurf(jtype)) == 'sla' ) nextrsurf(jtype) = 2 
     431            llnightav = .FALSE. 
     432            IF ( TRIM(cobstypessurf(jtype)) == 'sla' ) nextrsurf(jtype) = 2 
     433            IF ( TRIM(cobstypessurf(jtype)) == 'sst' ) llnightav = ln_sstnight 
    390434 
    391435            !Read in surface obs types 
    392             CALL obs_rea_surf( surfdata(jtype), jnumfilessurf(jtype), & 
    393                &               obsfilessurf(jtype,1:jnumfilessurf(jtype)), & 
     436            CALL obs_rea_surf( surfdata(jtype), ifilessurf(jtype), & 
     437               &               clsurffiles(jtype,1:ifilessurf(jtype)), & 
    394438               &               nvarssurf(jtype), nextrsurf(jtype), nitend-nit000+2, & 
    395                &               dobsini, dobsend, ln_ignmis, .FALSE. ) 
     439               &               rn_dobsini, rn_dobsend, ln_ignmis, .FALSE., llnightav ) 
    396440 
    397441            CALL obs_pre_surf( surfdata(jtype), surfdataqc(jtype), ln_nea ) 
    398           
    399             IF ( TRIM(obstypessurf(jtype)) == 'sla' ) THEN 
    400                CALL obs_rea_mdt( surfdataqc(jtype), n2dint ) 
    401                IF ( ln_altbias ) CALL obs_rea_altbias ( surfdataqc(jtype), n2dint, bias_file ) 
     442 
     443            IF ( TRIM(cobstypessurf(jtype)) == 'sla' ) THEN 
     444               CALL obs_rea_mdt( surfdataqc(jtype), nn_2dint ) 
     445               IF ( ln_altbias ) CALL obs_rea_altbias ( surfdataqc(jtype), nn_2dint, cn_altbiasfile ) 
    402446            ENDIF 
    403447 
    404             DEALLOCATE( jnumfilessurf, obsfilessurf ) 
    405  
    406448         END DO 
     449 
     450         DEALLOCATE( ifilessurf, clsurffiles ) 
     451 
     452      ENDIF 
    407453 
    408454   END SUBROUTINE dia_obs_init 
     
    415461      !! 
    416462      !! ** Method  : Call the observation operators on each time step to 
    417       !!              compute the model equivalent of the following date: 
    418       !!               - T profiles 
    419       !!               - S profiles 
    420       !!               - Sea surface height (referenced to a mean) 
    421       !!               - Sea surface temperature 
    422       !!               - Sea surface salinity 
    423       !!               - Velocity component (U,V) profiles 
    424       !! 
    425       !! ** Action  :  
     463      !!              compute the model equivalent of the following data: 
     464      !!               - Profile data, currently T/S or U/V 
     465      !!               - Surface data, currently SST, SLA or sea-ice concentration. 
     466      !! 
     467      !! ** Action  : 
    426468      !! 
    427469      !! History : 
     
    432474      !!        !  07-04  (G. Smith) Generalized surface operators 
    433475      !!        !  08-10  (M. Valdivieso) obs operator for velocity profiles 
     476      !!        !  15-08  (M. Martin) Combined surface/profile routines. 
    434477      !!---------------------------------------------------------------------- 
    435478      !! * Modules used 
    436       USE dom_oce, ONLY : &             ! Ocean space and time domain variables 
    437          & rdt,           &                        
    438          & gdept_1d,       &              
    439          & tmask, umask, vmask                             
    440       USE phycst, ONLY : &              ! Physical constants 
    441          & rday                          
    442       USE oce, ONLY : &                 ! Ocean dynamics and tracers variables 
    443          & tsn,  &              
    444          & un, vn,  & 
     479      USE phycst, ONLY : &         ! Physical constants 
     480         & rday 
     481      USE oce, ONLY : &            ! Ocean dynamics and tracers variables 
     482         & tsn,       & 
     483         & un,        & 
     484         & vn,        & 
    445485         & sshn 
    446486#if defined  key_lim3 
    447       USE ice, ONLY : &                     ! LIM Ice model variables 
     487      USE ice, ONLY : &            ! LIM3 Ice model variables 
    448488         & frld 
    449489#endif 
    450490#if defined key_lim2 
    451       USE ice_2, ONLY : &                     ! LIM Ice model variables 
     491      USE ice_2, ONLY : &          ! LIM2 Ice model variables 
    452492         & frld 
    453493#endif 
     
    455495 
    456496      !! * Arguments 
    457       INTEGER, INTENT(IN) :: kstp                         ! Current timestep 
     497      INTEGER, INTENT(IN) :: kstp  ! Current timestep 
    458498      !! * Local declarations 
    459       INTEGER :: idaystp                ! Number of timesteps per day 
    460       INTEGER :: jtype                  ! data loop variable 
    461       INTEGER :: jvar                   ! Variable number     
     499      INTEGER :: idaystp           ! Number of timesteps per day 
     500      INTEGER :: jtype             ! Data loop variable 
     501      INTEGER :: jvar              ! Variable number 
     502      REAL(wp), DIMENSION(jpi,jpj,jpk) :: & 
     503         & zprofvar1, &            ! Model values for 1st variable in a prof ob 
     504         & zprofvar2               ! Model values for 2nd variable in a prof ob 
     505      REAL(wp), DIMENSION(jpi,jpj,jpk) :: & 
     506         & zprofmask1, &           ! Mask associated with zprofvar1 
     507         & zprofmask2              ! Mask associated with zprofvar2 
     508      REAL(wp), DIMENSION(jpi,jpj)     :: & 
     509         & zsurfvar                ! Model values equivalent to surface ob. 
     510      REAL(wp), DIMENSION(jpi,jpj) :: & 
     511         & zglam1,    &            ! Model longitudes for prof variable 1 
     512         & zglam2,    &            ! Model longitudes for prof variable 2 
     513         & zgphi1,    &            ! Model latitudes for prof variable 1 
     514         & zgphi2                  ! Model latitudes for prof variable 2 
    462515#if ! defined key_lim2 && ! defined key_lim3 
    463       REAL(wp), POINTER, DIMENSION(:,:) :: frld    
     516      REAL(wp), POINTER, DIMENSION(:,:) :: frld 
    464517#endif 
    465       CHARACTER(LEN=20) :: datestr=" ",timestr=" " 
    466   
     518      LOGICAL :: llnightav        ! Logical for calculating night-time average 
     519 
    467520#if ! defined key_lim2 && ! defined key_lim3 
    468521      CALL wrk_alloc(jpi,jpj,frld)  
     
    473526         WRITE(numout,*) 'dia_obs : Call the observation operators', kstp 
    474527         WRITE(numout,*) '~~~~~~~' 
     528         CALL FLUSH(numout) 
    475529      ENDIF 
    476530 
     
    484538#endif 
    485539      !----------------------------------------------------------------------- 
    486       ! Depending on switches call various observation operators 
    487       !----------------------------------------------------------------------- 
    488  
    489       IF ( numproftypes > 0 ) THEN 
    490          DO jtype = 1, numproftypes 
    491        
    492             SELECT CASE ( TRIM(obstypesprof(jtype)) ) 
     540      ! Call the profile and surface observation operators 
     541      !----------------------------------------------------------------------- 
     542 
     543      IF ( nproftypes > 0 ) THEN 
     544 
     545         DO jtype = 1, nproftypes 
     546 
     547            SELECT CASE ( TRIM(cobstypesprof(jtype)) ) 
    493548            CASE('prof') 
    494                profvar1(:,:,:) = tsn(:,:,:,jp_tem) 
    495                profvar2(:,:,:) = tsn(:,:,:,jp_sal) 
    496                profmask1(:,:,:) = tmask(:,:,:) 
    497                profmask2(:,:,:) = tmask(:,:,:) 
     549               zprofvar1(:,:,:) = tsn(:,:,:,jp_tem) 
     550               zprofvar2(:,:,:) = tsn(:,:,:,jp_sal) 
     551               zprofmask1(:,:,:) = tmask(:,:,:) 
     552               zprofmask2(:,:,:) = tmask(:,:,:) 
     553               zglam1(:,:) = glamt(:,:) 
     554               zglam2(:,:) = glamt(:,:) 
     555               zgphi1(:,:) = gphit(:,:) 
     556               zgphi2(:,:) = gphit(:,:) 
    498557            CASE('vel') 
    499                profvar1(:,:,:) = un(:,:,:) 
    500                profvar2(:,:,:) = vn(:,:,:) 
    501                profmask1(:,:,:) = umask(:,:,:) 
    502                profmask2(:,:,:) = vmask(:,:,:) 
     558               zprofvar1(:,:,:) = un(:,:,:) 
     559               zprofvar2(:,:,:) = vn(:,:,:) 
     560               zprofmask1(:,:,:) = umask(:,:,:) 
     561               zprofmask2(:,:,:) = vmask(:,:,:) 
     562               zglam1(:,:) = glamu(:,:) 
     563               zglam2(:,:) = glamv(:,:) 
     564               zgphi1(:,:) = gphiu(:,:) 
     565               zgphi2(:,:) = gphiv(:,:) 
    503566            END SELECT 
    504              
    505             CALL obs_prof_opt( profdataqc(jtype),                       & 
    506                &               kstp, jpi, jpj, jpk, nit000, idaystp,   & 
    507                &               profvar1, profvar2,   & 
    508                &               gdept_1d, profmask1, profmask2, n1dint, n2dint,        & 
    509                &               kdailyavtypes = dailyavtypes ) 
    510              
     567 
     568            CALL obs_prof_opt( profdataqc(jtype), kstp, jpi, jpj, jpk,  & 
     569               &               nit000, idaystp,                         & 
     570               &               zprofvar1, zprofvar2,                    & 
     571               &               gdept_1d, zprofmask1, zprofmask2,        & 
     572               &               zglam1, zglam2, zgphi1, zgphi2,          & 
     573               &               nn_1dint, nn_2dint,                      & 
     574               &               kdailyavtypes = nn_profdavtypes ) 
     575 
    511576         END DO 
    512577 
    513578      ENDIF 
    514579 
    515       IF ( numsurftypes > 0 ) THEN 
    516          DO jtype = 1, numsurftypes 
    517        
    518             SELECT CASE ( TRIM(obstypessurf(jtype)) ) 
     580      IF ( nsurftypes > 0 ) THEN 
     581 
     582         DO jtype = 1, nsurftypes 
     583 
     584            SELECT CASE ( TRIM(cobstypessurf(jtype)) ) 
    519585            CASE('sst') 
    520                surfvar(:,:) = tsn(:,:,1,jp_tem) 
     586               zsurfvar(:,:) = tsn(:,:,1,jp_tem) 
     587               llnightav = ln_sstnight 
    521588            CASE('sla') 
    522                surfvar(:,:) = sshn(:,:) 
    523             CASE('sss') 
    524                surfvar(:,:) = tsn(:,:,1,jp_sal) 
     589               zsurfvar(:,:) = sshn(:,:) 
     590               llnightav = .FALSE. 
    525591#if defined key_lim2 || defined key_lim3 
    526             CASE('seaice') 
    527                surfvar(:,:) = 1._wp - frld(:,:) 
     592            CASE('sic') 
     593               zsurfvar(:,:) = 1._wp - frld(:,:) 
     594               llnightav = .FALSE. 
    528595#endif 
    529596            END SELECT 
    530           
    531             CALL obs_surf_opt( surfdatqc(jtype),             & 
    532                &               kstp, jpi, jpj, nit000, surfvar, & 
    533                &               tmask(:,:,1), n2dint, ld_sstnight ) 
    534              
     597 
     598            CALL obs_surf_opt( surfdataqc(jtype), kstp, jpi, jpj,       & 
     599               &               nit000, idaystp, zsurfvar, tmask(:,:,1), & 
     600               &               nn_2dint, llnightav ) 
     601 
    535602         END DO 
    536           
    537       ENDIF 
    538        
     603 
     604      ENDIF 
     605 
    539606#if ! defined key_lim2 && ! defined key_lim3 
    540607      CALL wrk_dealloc(jpi,jpj,frld)  
     
    542609 
    543610   END SUBROUTINE dia_obs 
    544    
     611 
    545612   SUBROUTINE dia_obs_wri  
    546613      !!---------------------------------------------------------------------- 
     
    559626      !!        !  07-03  (K. Mogensen) General handling of profiles 
    560627      !!        !  08-09  (M. Valdivieso) Velocity component (U,V) profiles 
     628      !!        !  15-08  (M. Martin) Combined writing for prof and surf types 
    561629      !!---------------------------------------------------------------------- 
    562630      IMPLICIT NONE 
    563631 
    564632      !! * Local declarations 
    565  
    566633      INTEGER :: jtype                    ! Data set loop variable 
     634 
    567635      !----------------------------------------------------------------------- 
    568636      ! Depending on switches call various observation output routines 
    569637      !----------------------------------------------------------------------- 
    570638 
    571       IF ( numproftypes > 0 ) THEN 
    572          DO jtype = 1, numproftypes 
    573        
     639      IF ( nproftypes > 0 ) THEN 
     640 
     641         DO jtype = 1, nproftypes 
     642 
    574643            CALL obs_prof_decompress( profdataqc(jtype), & 
    575644               &                      profdata(jtype), .TRUE., numout ) 
    576645 
    577             CALL obs_wri_prof( obstypesprof(jtype), profdata(jtype), n2dint ) 
    578           
     646            CALL obs_wri_prof( profdata(jtype), nn_2dint ) 
     647 
    579648         END DO 
    580           
    581       ENDIF 
    582  
    583       IF ( numsurftypes > 0 ) THEN 
    584          DO jtype = 1, numsurftypes 
    585        
    586             CALL obs_surf_decompress( surfdatqc(jtype), & 
     649 
     650      ENDIF 
     651 
     652      IF ( nsurftypes > 0 ) THEN 
     653 
     654         DO jtype = 1, nsurftypes 
     655 
     656            CALL obs_surf_decompress( surfdataqc(jtype), & 
    587657               &                      surfdata(jtype), .TRUE., numout ) 
    588658 
    589             CALL obs_wri_surf( obstypessurf(jtype), surfdata(jtype), n2dint ) 
     659            CALL obs_wri_surf( surfdata(jtype) ) 
    590660 
    591661         END DO 
    592           
    593       ENDIF 
    594  
     662 
     663      ENDIF 
    595664 
    596665   END SUBROUTINE dia_obs_wri 
     
    609678      !! 
    610679      !!---------------------------------------------------------------------- 
    611       !! obs_grid deallocation 
     680      ! obs_grid deallocation 
    612681      CALL obs_grid_deallocate 
    613682 
    614       !! diaobs deallocation 
    615       IF ( numproftypes > 0 ) DEALLOCATE(profdata, profdataqc, nvarsprof, nextrprof) 
    616       IF ( numsurftypes > 0 ) DEALLOCATE(surfdata, surfdataqc, nvarssurf, nextrsurf) 
    617        
     683      ! diaobs deallocation 
     684      IF ( nproftypes > 0 ) & 
     685         &   DEALLOCATE( cobstypesprof, profdata, profdataqc, nvarsprof, nextrprof ) 
     686 
     687      IF ( nsurftypes > 0 ) & 
     688         &   DEALLOCATE( cobstypessurf, surfdata, surfdataqc, nvarssurf, nextrsurf ) 
     689 
    618690   END SUBROUTINE dia_obs_dealloc 
    619691 
     
    621693      !!---------------------------------------------------------------------- 
    622694      !!                    ***  ROUTINE ini_date  *** 
    623       !!           
    624       !! ** Purpose : Get initial data in double precision YYYYMMDD.HHMMSS format 
    625       !! 
    626       !! ** Method  : Get initial data in double precision YYYYMMDD.HHMMSS format 
    627       !! 
    628       !! ** Action  : Get initial data in double precision YYYYMMDD.HHMMSS format 
     695      !! 
     696      !! ** Purpose : Get initial date in double precision YYYYMMDD.HHMMSS format 
     697      !! 
     698      !! ** Method  : Get initial date in double precision YYYYMMDD.HHMMSS format 
     699      !! 
     700      !! ** Action  : Get initial date in double precision YYYYMMDD.HHMMSS format 
    629701      !! 
    630702      !! History : 
     
    637709      USE phycst, ONLY : &            ! Physical constants 
    638710         & rday 
    639 !      USE daymod, ONLY : &            ! Time variables 
    640 !         & nmonth_len            
    641711      USE dom_oce, ONLY : &           ! Ocean space and time domain variables 
    642712         & rdt 
     
    645715 
    646716      !! * Arguments 
    647       REAL(KIND=dp), INTENT(OUT) :: ddobsini                         ! Initial date in YYYYMMDD.HHMMSS 
     717      REAL(dp), INTENT(OUT) :: ddobsini  ! Initial date in YYYYMMDD.HHMMSS 
    648718 
    649719      !! * Local declarations 
     
    653723      INTEGER :: ihou 
    654724      INTEGER :: imin 
    655       INTEGER :: imday         ! Number of days in month. 
    656       REAL(KIND=wp) :: zdayfrc ! Fraction of day 
    657  
    658       INTEGER, DIMENSION(12) ::   imonth_len    !: length in days of the months of the current year 
    659  
    660       !!---------------------------------------------------------------------- 
    661       !! Initial date initialization (year, month, day, hour, minute) 
    662       !! (This assumes that the initial date is for 00z)) 
    663       !!---------------------------------------------------------------------- 
     725      INTEGER :: imday       ! Number of days in month. 
     726      INTEGER, DIMENSION(12) :: & 
     727         &       imonth_len  ! Length in days of the months of the current year 
     728      REAL(wp) :: zdayfrc    ! Fraction of day 
     729 
     730      !---------------------------------------------------------------------- 
     731      ! Initial date initialization (year, month, day, hour, minute) 
     732      ! (This assumes that the initial date is for 00z)) 
     733      !---------------------------------------------------------------------- 
    664734      iyea =   ndate0 / 10000 
    665735      imon = ( ndate0 - iyea * 10000 ) / 100 
     
    668738      imin = 0 
    669739 
    670       !!---------------------------------------------------------------------- 
    671       !! Compute number of days + number of hours + min since initial time 
    672       !!---------------------------------------------------------------------- 
     740      !---------------------------------------------------------------------- 
     741      ! Compute number of days + number of hours + min since initial time 
     742      !---------------------------------------------------------------------- 
    673743      iday = iday + ( nit000 -1 ) * rdt / rday 
    674744      zdayfrc = ( nit000 -1 ) * rdt / rday 
     
    677747      imin = int( (zdayfrc * 24 - ihou) * 60 ) 
    678748 
    679       !!----------------------------------------------------------------------- 
    680       !! Convert number of days (iday) into a real date 
    681       !!---------------------------------------------------------------------- 
     749      !----------------------------------------------------------------------- 
     750      ! Convert number of days (iday) into a real date 
     751      !---------------------------------------------------------------------- 
    682752 
    683753      CALL calc_month_len( iyea, imonth_len ) 
    684        
     754 
    685755      DO WHILE ( iday > imonth_len(imon) ) 
    686756         iday = iday - imonth_len(imon) 
     
    693763      END DO 
    694764 
    695       !!---------------------------------------------------------------------- 
    696       !! Convert it into YYYYMMDD.HHMMSS format. 
    697       !!---------------------------------------------------------------------- 
     765      !---------------------------------------------------------------------- 
     766      ! Convert it into YYYYMMDD.HHMMSS format. 
     767      !---------------------------------------------------------------------- 
    698768      ddobsini = iyea * 10000_dp + imon * 100_dp + & 
    699769         &       iday + ihou * 0.01_dp + imin * 0.0001_dp 
     
    705775      !!---------------------------------------------------------------------- 
    706776      !!                    ***  ROUTINE fin_date  *** 
    707       !!           
    708       !! ** Purpose : Get final data in double precision YYYYMMDD.HHMMSS format 
    709       !! 
    710       !! ** Method  : Get final data in double precision YYYYMMDD.HHMMSS format 
    711       !! 
    712       !! ** Action  : Get final data in double precision YYYYMMDD.HHMMSS format 
     777      !! 
     778      !! ** Purpose : Get final date in double precision YYYYMMDD.HHMMSS format 
     779      !! 
     780      !! ** Method  : Get final date in double precision YYYYMMDD.HHMMSS format 
     781      !! 
     782      !! ** Action  : Get final date in double precision YYYYMMDD.HHMMSS format 
    713783      !! 
    714784      !! History : 
     
    720790      USE phycst, ONLY : &            ! Physical constants 
    721791         & rday 
    722 !      USE daymod, ONLY : &            ! Time variables 
    723 !         & nmonth_len                 
    724792      USE dom_oce, ONLY : &           ! Ocean space and time domain variables 
    725793         & rdt 
     
    728796 
    729797      !! * Arguments 
    730       REAL(KIND=dp), INTENT(OUT) :: ddobsfin                  ! Final date in YYYYMMDD.HHMMSS 
     798      REAL(dp), INTENT(OUT) :: ddobsfin ! Final date in YYYYMMDD.HHMMSS 
    731799 
    732800      !! * Local declarations 
     
    736804      INTEGER :: ihou 
    737805      INTEGER :: imin 
    738       INTEGER :: imday         ! Number of days in month. 
    739       REAL(KIND=wp) :: zdayfrc       ! Fraction of day 
    740           
    741       INTEGER, DIMENSION(12) ::   imonth_len    !: length in days of the months of the current year 
    742              
     806      INTEGER :: imday       ! Number of days in month. 
     807      INTEGER, DIMENSION(12) :: & 
     808         &       imonth_len  ! Length in days of the months of the current year 
     809      REAL(wp) :: zdayfrc    ! Fraction of day 
     810 
    743811      !----------------------------------------------------------------------- 
    744812      ! Initial date initialization (year, month, day, hour, minute) 
     
    750818      ihou = 0 
    751819      imin = 0 
    752        
     820 
    753821      !----------------------------------------------------------------------- 
    754822      ! Compute number of days + number of hours + min since initial time 
     
    765833 
    766834      CALL calc_month_len( iyea, imonth_len ) 
    767        
     835 
    768836      DO WHILE ( iday > imonth_len(imon) ) 
    769837         iday = iday - imonth_len(imon) 
     
    783851 
    784852    END SUBROUTINE fin_date 
    785      
     853 
    786854END MODULE diaobs 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_grid.F90

    r4990 r5682  
    5252 
    5353   !! Default values 
    54    REAL, PUBLIC :: grid_search_res = 0.5    ! Resolution of grid 
     54   REAL, PUBLIC :: rn_gridsearchres = 0.5   ! Resolution of grid 
    5555   INTEGER, PRIVATE :: gsearch_nlons_def    ! Num of longitudes 
    5656   INTEGER, PRIVATE :: gsearch_nlats_def    ! Num of latitudes 
     
    8383   LOGICAL, PUBLIC :: ln_grid_global         ! Use global distribution of observations 
    8484   CHARACTER(LEN=44), PUBLIC :: & 
    85       & grid_search_file    ! file name head for grid search lookup  
     85      & cn_gridsearchfile    ! file name head for grid search lookup  
    8686 
    8787   !!---------------------------------------------------------------------- 
     
    690690          
    691691         IF(lwp) WRITE(numout,*) 
    692          IF(lwp) WRITE(numout,*)'Grid search resolution : ', grid_search_res 
    693           
    694          gsearch_nlons_def  = NINT( 360.0_wp / grid_search_res )  
    695          gsearch_nlats_def  = NINT( 180.0_wp / grid_search_res ) 
    696          gsearch_lonmin_def = -180.0_wp + 0.5_wp * grid_search_res 
    697          gsearch_latmin_def =  -90.0_wp + 0.5_wp * grid_search_res 
    698          gsearch_dlon_def   = grid_search_res 
    699          gsearch_dlat_def   = grid_search_res 
     692         IF(lwp) WRITE(numout,*)'Grid search resolution : ', rn_gridsearchres 
     693          
     694         gsearch_nlons_def  = NINT( 360.0_wp / rn_gridsearchres )  
     695         gsearch_nlats_def  = NINT( 180.0_wp / rn_gridsearchres ) 
     696         gsearch_lonmin_def = -180.0_wp + 0.5_wp * rn_gridsearchres 
     697         gsearch_latmin_def =  -90.0_wp + 0.5_wp * rn_gridsearchres 
     698         gsearch_dlon_def   = rn_gridsearchres 
     699         gsearch_dlat_def   = rn_gridsearchres 
    700700          
    701701         IF (lwp) THEN 
     
    710710         IF ( ln_grid_global ) THEN 
    711711            WRITE(cfname, FMT="(A,'_',A)") & 
    712                &          TRIM(grid_search_file), 'global.nc' 
     712               &          TRIM(cn_gridsearchfile), 'global.nc' 
    713713         ELSE 
    714714            WRITE(cfname, FMT="(A,'_',I4.4,'of',I4.4,'by',I4.4,'.nc')") & 
    715                &          TRIM(grid_search_file), nproc, jpni, jpnj 
     715               &          TRIM(cn_gridsearchfile), nproc, jpni, jpnj 
    716716         ENDIF 
    717717 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_mpp.F90

    r2513 r5682  
    115115      !!               ***  ROUTINE obs_mpp_find_obs_proc *** 
    116116      !!           
    117       !! ** Purpose : From the array kobsp containing the results of the grid 
     117      !! ** Purpose : From the array kobsp containing the results of the 
    118118      !!              grid search on each processor the processor return a 
    119119      !!              decision of which processors should hold the observation. 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_oper.F90

    r5659 r5682  
    1111   !!---------------------------------------------------------------------- 
    1212 
    13    !! * Modules used    
     13   !! * Modules used 
    1414   USE par_kind, ONLY : &         ! Precision variables 
    1515      & wp 
    1616   USE in_out_manager             ! I/O manager 
    1717   USE obs_inter_sup              ! Interpolation support 
    18    USE obs_inter_h2d, ONLY : &    ! Horizontal interpolation to the observation pt 
     18   USE obs_inter_h2d, ONLY : &    ! Horizontal interpolation to the obs pt 
    1919      & obs_int_h2d, & 
    2020      & obs_int_h2d_init 
    21    USE obs_inter_z1d, ONLY : &    ! Vertical interpolation to the observation pt 
     21   USE obs_inter_z1d, ONLY : &    ! Vertical interpolation to the obs pt 
    2222      & obs_int_z1d,    & 
    2323      & obs_int_z1d_spl 
    24    USE obs_const,  ONLY :     & 
    25       & obfillflt      ! Fillvalue    
    26    USE dom_oce,       ONLY : & 
    27       & glamt, glamu, glamv, & 
    28       & gphit, gphiu, gphiv 
    29    USE lib_mpp,       ONLY : & 
     24   USE obs_const,  ONLY :    &    ! Obs fill value 
     25      & obfillflt 
     26   USE dom_oce,       ONLY : &    ! Model lats/lons 
     27      & glamt, & 
     28      & gphit 
     29   USE lib_mpp,       ONLY : &    ! Warning and stopping routines 
    3030      & ctl_warn, ctl_stop 
     31   USE sbcdcy,        ONLY : &    ! For calculation of where it is night-time 
     32      & sbc_dcy, nday_qsr 
    3133 
    3234   IMPLICIT NONE 
     
    3537   PRIVATE 
    3638 
    37    PUBLIC obs_prof_opt, &  ! Compute the model counterpart of profile observations 
    38       &   obs_surf_opt     ! Compute the model counterpart of surface observations 
    39  
    40    INTEGER, PARAMETER, PUBLIC :: imaxavtypes = 20 ! Max number of daily avgd obs types 
     39   PUBLIC obs_prof_opt, &  ! Compute the model counterpart of profile obs 
     40      &   obs_surf_opt     ! Compute the model counterpart of surface obs 
     41 
     42   INTEGER, PARAMETER, PUBLIC :: & 
     43      & imaxavtypes = 20   ! Max number of daily avgd obs types 
    4144 
    4245   !!---------------------------------------------------------------------- 
     
    4851CONTAINS 
    4952 
    50    SUBROUTINE obs_prof_opt( prodatqc, kt, kpi, kpj, kpk, kit000, kdaystp, & 
    51       &                     pvar1, pvar2, pgdept, pmask1, k1dint, k2dint, & 
    52       &                     kdailyavtypes ) 
     53   SUBROUTINE obs_prof_opt( prodatqc, kt, kpi, kpj, kpk,          & 
     54      &                     kit000, kdaystp,                      & 
     55      &                     pvar1, pvar2, pgdept, pmask1, pmask2, & 
     56      &                     plam1, plam2, pphi1, pphi2,           & 
     57      &                     k1dint, k2dint, kdailyavtypes ) 
     58 
    5359      !!----------------------------------------------------------------------- 
    5460      !! 
     
    99105      !!      ! 15-02 (M. Martin) Combined routine for all profile types 
    100106      !!----------------------------------------------------------------------- 
    101    
     107 
    102108      !! * Modules used 
    103109      USE obs_profiles_def ! Definition of storage space for profile obs. 
     
    106112 
    107113      !! * Arguments 
    108       TYPE(obs_prof), INTENT(INOUT) :: prodatqc  ! Subset of profile data not failing screening 
    109       INTEGER, INTENT(IN) :: kt        ! Time step 
    110       INTEGER, INTENT(IN) :: kpi       ! Model grid parameters 
     114      TYPE(obs_prof), INTENT(INOUT) :: & 
     115         & prodatqc                  ! Subset of profile data passing QC 
     116      INTEGER, INTENT(IN) :: kt      ! Time step 
     117      INTEGER, INTENT(IN) :: kpi     ! Model grid parameters 
    111118      INTEGER, INTENT(IN) :: kpj 
    112119      INTEGER, INTENT(IN) :: kpk 
    113       INTEGER, INTENT(IN) :: kit000    ! Number of the first time step  
    114                                        !   (kit000-1 = restart time) 
    115       INTEGER, INTENT(IN) :: k1dint    ! Vertical interpolation type (see header) 
    116       INTEGER, INTENT(IN) :: k2dint    ! Horizontal interpolation type (see header) 
    117       INTEGER, INTENT(IN) :: kdaystp   ! Number of time steps per day                     
     120      INTEGER, INTENT(IN) :: kit000  ! Number of the first time step 
     121                                     !   (kit000-1 = restart time) 
     122      INTEGER, INTENT(IN) :: k1dint  ! Vertical interpolation type (see header) 
     123      INTEGER, INTENT(IN) :: k2dint  ! Horizontal interpolation type (see header) 
     124      INTEGER, INTENT(IN) :: kdaystp ! Number of time steps per day 
    118125      REAL(KIND=wp), INTENT(IN), DIMENSION(kpi,kpj,kpk) :: & 
    119          & pvar1,    &    ! Model field 1 
    120          & pvar2,    &    ! Model field 2 
    121          & pmask1,   &    ! Land-sea mask 1 
    122          & pmask2         ! Land-sea mask 2 
     126         & pvar1,    &               ! Model field 1 
     127         & pvar2,    &               ! Model field 2 
     128         & pmask1,   &               ! Land-sea mask 1 
     129         & pmask2                    ! Land-sea mask 2 
     130      REAL(KIND=wp), INTENT(IN), DIMENSION(kpi,kpj) :: & 
     131         & plam1,    &               ! Model longitudes for variable 1 
     132         & plam2,    &               ! Model longitudes for variable 2 
     133         & pphi1,    &               ! Model latitudes for variable 1 
     134         & pphi2                     ! Model latitudes for variable 2 
    123135      REAL(KIND=wp), INTENT(IN), DIMENSION(kpk) :: & 
    124          & pgdept       ! Model array of depth levels 
     136         & pgdept                    ! Model array of depth levels 
    125137      INTEGER, DIMENSION(imaxavtypes), OPTIONAL :: & 
    126          & kdailyavtypes! Types for daily averages 
     138         & kdailyavtypes             ! Types for daily averages 
     139 
    127140      !! * Local declarations 
    128141      INTEGER ::   ji 
     
    138151      INTEGER, DIMENSION(imaxavtypes) :: & 
    139152         & idailyavtypes 
     153      INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: & 
     154         & igrdi1, & 
     155         & igrdi2, & 
     156         & igrdj1, & 
     157         & igrdj2 
    140158      REAL(KIND=wp) :: zlam 
    141159      REAL(KIND=wp) :: zphi 
     
    144162         & zobsmask1, & 
    145163         & zobsmask2, & 
    146          & zobsmask, & 
    147164         & zobsk,    & 
    148165         & zobs2k 
     
    162179         & zgphi1, & 
    163180         & zgphi2 
    164       INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: & 
    165          & igrdi1, & 
    166          & igrdi2, & 
    167          & igrdj1, & 
    168          & igrdj2 
     181      LOGICAL :: ld_dailyav 
    169182 
    170183      !------------------------------------------------------------------------ 
    171184      ! Local initialization  
    172185      !------------------------------------------------------------------------ 
    173       ! ... Record and data counters 
     186      ! Record and data counters 
    174187      inrc = kt - kit000 + 2 
    175188      ipro = prodatqc%npstp(inrc) 
    176   
     189 
    177190      ! Daily average types 
     191      ld_dailyav = .FALSE. 
    178192      IF ( PRESENT(kdailyavtypes) ) THEN 
    179193         idailyavtypes(:) = kdailyavtypes(:) 
     194         IF ( ANY (idailyavtypes(:) /= -1) ) ld_dailyav = .TRUE. 
    180195      ELSE 
    181196         idailyavtypes(:) = -1 
    182197      ENDIF 
    183198 
    184       ! Initialize daily mean for first timestep 
     199      ! Daily means are calculated for values over timesteps: 
     200      !  [1 <= kt <= kdaystp], [kdaystp+1 <= kt <= 2*kdaystp], ... 
    185201      idayend = MOD( kt - kit000 + 1, kdaystp ) 
    186202 
    187       ! Added kt == 0 test to catch restart case  
    188       IF ( idayend == 1 .OR. kt == 0) THEN 
    189          IF (lwp) WRITE(numout,*) 'Reset prodatqc%vdmean on time-step: ',kt 
     203      IF ( ld_dailyav ) THEN 
     204 
     205         ! Initialize daily mean for first timestep of the day 
     206         IF ( idayend == 1 .OR. kt == 0 ) THEN 
     207            DO jk = 1, jpk 
     208               DO jj = 1, jpj 
     209                  DO ji = 1, jpi 
     210                     prodatqc%vdmean(ji,jj,jk,1) = 0.0 
     211                     prodatqc%vdmean(ji,jj,jk,2) = 0.0 
     212                  END DO 
     213               END DO 
     214            END DO 
     215         ENDIF 
     216 
    190217         DO jk = 1, jpk 
    191218            DO jj = 1, jpj 
    192219               DO ji = 1, jpi 
    193                   prodatqc%vdmean(ji,jj,jk,1) = 0.0 
    194                   prodatqc%vdmean(ji,jj,jk,2) = 0.0 
     220                  ! Increment field 1 for computing daily mean 
     221                  prodatqc%vdmean(ji,jj,jk,1) = prodatqc%vdmean(ji,jj,jk,1) & 
     222                     &                        + pvar1(ji,jj,jk) 
     223                  ! Increment field 2 for computing daily mean 
     224                  prodatqc%vdmean(ji,jj,jk,2) = prodatqc%vdmean(ji,jj,jk,2) & 
     225                     &                        + pvar2(ji,jj,jk) 
    195226               END DO 
    196227            END DO 
    197228         END DO 
    198       ENDIF 
    199  
    200       DO jk = 1, jpk 
    201          DO jj = 1, jpj 
    202             DO ji = 1, jpi 
    203                ! Increment field 1 for computing daily mean 
    204                prodatqc%vdmean(ji,jj,jk,1) = prodatqc%vdmean(ji,jj,jk,1) & 
    205                   &                        + pvar1(ji,jj,jk) 
    206                ! Increment field 2 for computing daily mean 
    207                prodatqc%vdmean(ji,jj,jk,2) = prodatqc%vdmean(ji,jj,jk,2) & 
    208                   &                        + pvar2(ji,jj,jk) 
    209             END DO 
    210          END DO 
    211       END DO 
    212     
    213       ! Compute the daily mean at the end of day 
    214       zdaystp = 1.0 / REAL( kdaystp ) 
    215       IF ( idayend == 0 ) THEN 
    216          DO jk = 1, jpk 
    217             DO jj = 1, jpj 
    218                DO ji = 1, jpi 
    219                   prodatqc%vdmean(ji,jj,jk,1) = prodatqc%vdmean(ji,jj,jk,1) & 
    220                      &                        * zdaystp 
    221                   prodatqc%vdmean(ji,jj,jk,2) = prodatqc%vdmean(ji,jj,jk,2) & 
    222                   &                           * zdaystp 
     229 
     230         ! Compute the daily mean at the end of day 
     231         zdaystp = 1.0 / REAL( kdaystp ) 
     232         IF ( idayend == 0 ) THEN 
     233            IF (lwp) WRITE(numout,*) 'Calculating prodatqc%vdmean on time-step: ',kt 
     234            CALL FLUSH(numout) 
     235            DO jk = 1, jpk 
     236               DO jj = 1, jpj 
     237                  DO ji = 1, jpi 
     238                     prodatqc%vdmean(ji,jj,jk,1) = prodatqc%vdmean(ji,jj,jk,1) & 
     239                        &                        * zdaystp 
     240                     prodatqc%vdmean(ji,jj,jk,2) = prodatqc%vdmean(ji,jj,jk,2) & 
     241                        &                        * zdaystp 
     242                  END DO 
    223243               END DO 
    224244            END DO 
    225          END DO 
     245         ENDIF 
     246 
    226247      ENDIF 
    227248 
     
    262283      END DO 
    263284 
    264       CALL obs_int_comm_2d( 2, 2, ipro, igrdi1, igrdj1, glamt1, zglam1 ) 
    265       CALL obs_int_comm_2d( 2, 2, ipro, igrdi1, igrdj1, gphit1, zgphi1 ) 
     285      CALL obs_int_comm_2d( 2, 2, ipro, igrdi1, igrdj1, plam1, zglam1 ) 
     286      CALL obs_int_comm_2d( 2, 2, ipro, igrdi1, igrdj1, pphi1, zgphi1 ) 
    266287      CALL obs_int_comm_3d( 2, 2, ipro, kpk, igrdi1, igrdj1, pmask1, zmask1 ) 
    267288      CALL obs_int_comm_3d( 2, 2, ipro, kpk, igrdi1, igrdj1, pvar1,   zint1 ) 
    268289       
    269       CALL obs_int_comm_2d( 2, 2, ipro, igrdi2, igrdj2, glamt2, zglam2 ) 
    270       CALL obs_int_comm_2d( 2, 2, ipro, igrdi2, igrdj2, gphit2, zgphi2 ) 
    271       CALL obs_int_comm_3d( 2, 2, ipro, kpk, igrdi2, igrdj2, pmask1, zmask2 ) 
     290      CALL obs_int_comm_2d( 2, 2, ipro, igrdi2, igrdj2, plam2, zglam2 ) 
     291      CALL obs_int_comm_2d( 2, 2, ipro, igrdi2, igrdj2, pphi2, zgphi2 ) 
     292      CALL obs_int_comm_3d( 2, 2, ipro, kpk, igrdi2, igrdj2, pmask2, zmask2 ) 
    272293      CALL obs_int_comm_3d( 2, 2, ipro, kpk, igrdi2, igrdj2, pvar2,   zint2 ) 
    273294 
    274295      ! At the end of the day also get interpolated means 
    275       IF ( idayend == 0 ) THEN 
     296      IF ( ld_dailyav .AND. idayend == 0 ) THEN 
    276297 
    277298         ALLOCATE( & 
     
    292313 
    293314         IF ( kt /= prodatqc%mstp(jobs) ) THEN 
    294              
     315 
    295316            IF(lwp) THEN 
    296317               WRITE(numout,*) 
     
    307328            CALL ctl_stop( 'obs_pro_opt', 'Inconsistent time' ) 
    308329         ENDIF 
    309           
     330 
    310331         zlam = prodatqc%rlam(jobs) 
    311332         zphi = prodatqc%rphi(jobs) 
    312           
     333 
    313334         ! Horizontal weights and vertical mask 
    314335 
     
    333354            zobsk(:) = obfillflt 
    334355 
    335        IF ( ANY (idailyavtypes(:) == prodatqc%ntyp(jobs)) ) THEN 
     356            IF ( ANY (idailyavtypes(:) == prodatqc%ntyp(jobs)) ) THEN 
    336357 
    337358               IF ( idayend == 0 )  THEN 
    338                    
    339359                  ! Daily averaged data 
    340                    
    341360                  CALL obs_int_h2d( kpk, kpk,      & 
    342361                     &              zweig1, zinm1(:,:,:,iobs), zobsk ) 
    343                    
    344                    
    345                ELSE 
    346                 
    347                   CALL ctl_stop( ' A nonzero' //     & 
    348                      &           ' number of average profile data should' // & 
    349                      &           ' only occur at the end of a given day' ) 
    350362 
    351363               ENDIF 
    352            
     364 
    353365            ELSE  
    354                 
     366 
    355367               ! Point data 
    356  
    357368               CALL obs_int_h2d( kpk, kpk,      & 
    358369                  &              zweig1, zint1(:,:,:,iobs), zobsk ) 
     
    364375            ! polynomial at obs points 
    365376            !------------------------------------------------------------- 
    366              
     377 
    367378            IF ( k1dint == 1 ) THEN 
    368379               CALL obs_int_z1d_spl( kpk, zobsk, zobs2k,   & 
    369                   &                  pgdept, zobsmask ) 
     380                  &                  pgdept, zobsmask1 ) 
    370381            ENDIF 
    371              
     382 
    372383            !----------------------------------------------------------------- 
    373384            !  Vertical interpolation to the observation point 
     
    381392               & zobsk, zobs2k,                   & 
    382393               & prodatqc%var(1)%vmod(ista:iend), & 
    383                & pgdept, zobsmask ) 
     394               & pgdept, zobsmask1 ) 
    384395 
    385396         ENDIF 
     
    394405 
    395406                  ! Daily averaged data 
    396                    
    397407                  CALL obs_int_h2d( kpk, kpk,      & 
    398408                     &              zweig2, zinm2(:,:,:,iobs), zobsk ) 
    399                    
    400                ELSE 
    401  
    402                   CALL ctl_stop( ' A nonzero' //     & 
    403                      &           ' number of average profile data should' // & 
    404                      &           ' only occur at the end of a given day' ) 
    405409 
    406410               ENDIF 
    407411 
    408412            ELSE 
    409                 
     413 
    410414               ! Point data 
    411  
    412415               CALL obs_int_h2d( kpk, kpk,      & 
    413416                  &              zweig2, zint2(:,:,:,iobs), zobsk ) 
     
    420423            ! polynomial at obs points 
    421424            !------------------------------------------------------------- 
    422              
     425 
    423426            IF ( k1dint == 1 ) THEN 
    424427               CALL obs_int_z1d_spl( kpk, zobsk, zobs2k, & 
    425                   &                  pgdept, zobsmask ) 
     428                  &                  pgdept, zobsmask2 ) 
    426429            ENDIF 
    427              
     430 
    428431            !---------------------------------------------------------------- 
    429432            !  Vertical interpolation to the observation point 
     
    437440               & zobsk, zobs2k, & 
    438441               & prodatqc%var(2)%vmod(ista:iend),& 
    439                & pgdept, zobsmask ) 
     442               & pgdept, zobsmask2 ) 
    440443 
    441444         ENDIF 
    442445 
    443446      END DO 
    444   
     447 
    445448      ! Deallocate the data for interpolation 
    446449      DEALLOCATE( & 
     
    458461         & zint2   & 
    459462         & ) 
     463 
    460464      ! At the end of the day also get interpolated means 
    461       IF ( idayend == 0 ) THEN 
     465      IF ( ld_dailyav .AND. idayend == 0 ) THEN 
    462466         DEALLOCATE( & 
    463467            & zinm1,  & 
     
    467471 
    468472      prodatqc%nprofup = prodatqc%nprofup + ipro  
    469        
     473 
    470474   END SUBROUTINE obs_prof_opt 
    471475 
    472    SUBROUTINE obs_surf_opt( surfdataqc, kt, kpi, kpj, kit000, & 
    473       &                    psurf, psurfmask, k2dint, ld_nightav ) 
     476   SUBROUTINE obs_surf_opt( surfdataqc, kt, kpi, kpj,         & 
     477      &                    kit000, kdaystp, psurf, psurfmask, & 
     478      &                    k2dint, ldnightav ) 
     479 
    474480      !!----------------------------------------------------------------------- 
    475481      !! 
     
    491497      !!        - bilinear (quadrilateral grid)    (k2dint = 3) 
    492498      !!        - polynomial (quadrilateral grid)  (k2dint = 4) 
    493       !!   
     499      !! 
    494500      !! 
    495501      !! ** Action  : 
     
    499505      !!      ! 15-02 (M. Martin) Combined routine for surface types 
    500506      !!----------------------------------------------------------------------- 
    501    
     507 
    502508      !! * Modules used 
    503509      USE obs_surf_def  ! Definition of storage space for surface observations 
     
    506512 
    507513      !! * Arguments 
    508       TYPE(obs_surf), INTENT(INOUT) :: surfdataqc     ! Subset of surface data not failing screening 
    509       INTEGER, INTENT(IN) :: kt      ! Time step 
    510       INTEGER, INTENT(IN) :: kpi     ! Model grid parameters 
     514      TYPE(obs_surf), INTENT(INOUT) :: & 
     515         & surfdataqc                  ! Subset of surface data passing QC 
     516      INTEGER, INTENT(IN) :: kt        ! Time step 
     517      INTEGER, INTENT(IN) :: kpi       ! Model grid parameters 
    511518      INTEGER, INTENT(IN) :: kpj 
    512       INTEGER, INTENT(IN) :: kit000   ! Number of the first time step  
    513                                       !   (kit000-1 = restart time) 
    514       INTEGER, INTENT(IN) :: k2dint   ! Horizontal interpolation type (see header) 
    515       REAL(KIND=wp), INTENT(IN), DIMENSION(kpi,kpj) :: & 
    516          & psurf,  &    ! Model surface field 
    517          & psurfmask    ! Land-sea mask 
    518           
     519      INTEGER, INTENT(IN) :: kit000    ! Number of the first time step  
     520                                       !   (kit000-1 = restart time) 
     521      INTEGER, INTENT(IN) :: kdaystp   ! Number of time steps per day 
     522      INTEGER, INTENT(IN) :: k2dint    ! Horizontal interpolation type (see header) 
     523      REAL(wp), INTENT(IN), DIMENSION(kpi,kpj) :: & 
     524         & psurf,  &                   ! Model surface field 
     525         & psurfmask                   ! Land-sea mask 
     526      LOGICAL, INTENT(IN) :: ldnightav ! Logical for averaging night-time data 
     527 
    519528      !! * Local declarations 
    520529      INTEGER :: ji 
     
    524533      INTEGER :: isurf 
    525534      INTEGER :: iobs 
    526       REAL(KIND=wp) :: zlam 
    527       REAL(KIND=wp) :: zphi 
    528       REAL(KIND=wp) :: zext(1), zobsmask(1) 
    529       REAL(kind=wp), DIMENSION(2,2,1) :: & 
    530          & zweig 
    531       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: & 
    532          & zmask, & 
    533          & zsurf, & 
    534          & zglam, & 
    535          & zgphi 
     535      INTEGER :: idayend 
    536536      INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: & 
    537537         & igrdi, & 
    538538         & igrdj 
     539      INTEGER, DIMENSION(:,:), SAVE, ALLOCATABLE :: & 
     540         & icount_night,      & 
     541         & imask_night 
     542      REAL(wp) :: zlam 
     543      REAL(wp) :: zphi 
     544      REAL(wp), DIMENSION(1) :: zext, zobsmask 
     545      REAL(wp) :: zdaystp 
     546      REAL(wp), DIMENSION(2,2,1) :: & 
     547         & zweig 
     548      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: & 
     549         & zmask,  & 
     550         & zsurf,  & 
     551         & zsurfm, & 
     552         & zglam,  & 
     553         & zgphi 
     554      REAL(wp), DIMENSION(:,:), SAVE, ALLOCATABLE :: & 
     555         & zintmp,  & 
     556         & zouttmp, & 
     557         & zmeanday    ! to compute model sst in region of 24h daylight (pole) 
    539558 
    540559      !------------------------------------------------------------------------ 
    541560      ! Local initialization  
    542561      !------------------------------------------------------------------------ 
    543       ! ... Record and data counters 
     562      ! Record and data counters 
    544563      inrc = kt - kit000 + 2 
    545564      isurf = surfdataqc%nsstp(inrc) 
    546        
    547       IF ( ld_nightav ) THEN 
     565 
     566      IF ( ldnightav ) THEN 
    548567 
    549568      ! Initialize array for night mean 
    550          IF ( kt .EQ. 0 ) THEN 
     569         IF ( kt == 0 ) THEN 
    551570            ALLOCATE ( icount_night(kpi,kpj) ) 
    552571            ALLOCATE ( imask_night(kpi,kpj) ) 
     
    557576         ENDIF 
    558577 
    559          ! Initialize daily mean for first timestep 
     578         ! Night-time means are calculated for night-time values over timesteps: 
     579         !  [1 <= kt <= kdaystp], [kdaystp+1 <= kt <= 2*kdaystp], ..... 
    560580         idayend = MOD( kt - kit000 + 1, kdaystp ) 
    561581 
    562          ! Added kt == 0 test to catch restart case  
    563          IF ( idayend == 1 .OR. kt == 0) THEN 
    564             IF (lwp) WRITE(numout,*) 'Reset surfdataqc%vdmean on time-step: ',kt 
     582         ! Initialize night-time mean for first timestep of the day 
     583         IF ( idayend == 1 .OR. kt == 0 ) THEN 
    565584            DO jj = 1, jpj 
    566585               DO ji = 1, jpi 
     
    580599               ! Increment the temperature field for computing night mean and counter 
    581600               surfdataqc%vdmean(ji,jj) = surfdataqc%vdmean(ji,jj)  & 
    582                       &                        + psurf(ji,jj)*imask_night(ji,jj) 
    583                zmeanday(ji,jj)        = zmeanday(ji,jj) + psurf(ji,jj) 
    584                icount_night(ji,jj) = icount_night(ji,jj) + imask_night(ji,jj) 
     601                      &                    + psurf(ji,jj) * REAL( imask_night(ji,jj) ) 
     602               zmeanday(ji,jj)          = zmeanday(ji,jj) + psurf(ji,jj) 
     603               icount_night(ji,jj)      = icount_night(ji,jj) + imask_night(ji,jj) 
    585604            END DO 
    586605         END DO 
    587     
    588          ! Compute the daily mean at the end of day 
    589  
     606 
     607         ! Compute the night-time mean at the end of the day 
    590608         zdaystp = 1.0 / REAL( kdaystp ) 
    591  
    592          IF ( idayend == 0 ) THEN  
     609         IF ( idayend == 0 ) THEN 
     610            IF (lwp) WRITE(numout,*) 'Calculating surfdataqc%vdmean on time-step: ',kt 
    593611            DO jj = 1, jpj 
    594612               DO ji = 1, jpi 
    595613                  ! Test if "no night" point 
    596                   IF ( icount_night(ji,jj) .NE. 0 ) THEN 
     614                  IF ( icount_night(ji,jj) > 0 ) THEN 
    597615                     surfdataqc%vdmean(ji,jj) = surfdataqc%vdmean(ji,jj) & 
    598                        &                        / icount_night(ji,jj)  
     616                       &                        / REAL( icount_night(ji,jj) ) 
    599617                  ELSE 
     618                     !At locations where there is no night (e.g. poles), 
     619                     ! calculate daily mean instead of night-time mean. 
    600620                     surfdataqc%vdmean(ji,jj) = zmeanday(ji,jj) * zdaystp 
    601621                  ENDIF 
     
    616636         & zsurf(2,2,isurf)  & 
    617637         & ) 
    618        
     638 
    619639      DO jobs = surfdataqc%nsurfup + 1, surfdataqc%nsurfup + isurf 
    620640         iobs = jobs - surfdataqc%nsurfup 
     
    639659 
    640660      ! At the end of the day get interpolated means 
    641       IF ( idayend == 0 .AND. ld_nightav ) THEN 
     661      IF ( idayend == 0 .AND. ldnightav ) THEN 
    642662 
    643663         ALLOCATE( & 
     
    656676 
    657677         IF ( kt /= surfdataqc%mstp(jobs) ) THEN 
    658              
     678 
    659679            IF(lwp) THEN 
    660680               WRITE(numout,*) 
     
    669689                  &            ' ntyp    = ', surfdataqc%ntyp(jobs) 
    670690            ENDIF 
    671             CALL ctl_stop( 'obs_sla_opt', 'Inconsistent time' ) 
    672              
    673          ENDIF 
    674           
     691            CALL ctl_stop( 'obs_surf_opt', 'Inconsistent time' ) 
     692 
     693         ENDIF 
     694 
    675695         zlam = surfdataqc%rlam(jobs) 
    676696         zphi = surfdataqc%rphi(jobs) 
     
    680700            &                   zglam(:,:,iobs), zgphi(:,:,iobs), & 
    681701            &                   zmask(:,:,iobs), zweig, zobsmask ) 
    682           
    683702 
    684703         ! Interpolate the model field to the observation point 
    685          IF ( ld_nightav ) THEN 
    686  
    687            IF ( idayend == 0 )  THEN 
    688                ! Daily averaged data 
    689                CALL obs_int_h2d( 1, 1,      &  
    690                      &              zweig, zsurfm(:,:,iobs), zext ) 
    691             ELSE  
    692                CALL ctl_stop( ' ld_nightav is set to true: a nonzero' //     & 
    693                      &           ' number of night data should' // & 
    694                      &           ' only occur at the end of a given day' ) 
    695             ENDIF 
    696  
     704         IF ( ldnightav .AND. idayend == 0 ) THEN 
     705            ! Night-time averaged data 
     706            CALL obs_int_h2d( 1, 1, zweig, zsurfm(:,:,iobs), zext ) 
    697707         ELSE 
    698  
    699             CALL obs_int_h2d( 1, 1,      & 
    700                &              zweig, zsurf(:,:,iobs),  zext ) 
    701  
    702          ENDIF 
    703           
    704          IF ( surfdataqc%nextr == 2 ) THEN 
     708            CALL obs_int_h2d( 1, 1, zweig, zsurf(:,:,iobs),  zext ) 
     709         ENDIF 
     710 
     711         IF ( TRIM(surfdataqc%cvars(1)) == 'SLA' .AND. surfdataqc%nextra == 2 ) THEN 
    705712            ! ... Remove the MDT from the SSH at the observation point to get the SLA 
    706713            surfdataqc%rext(jobs,1) = zext(1) 
     
    722729         & ) 
    723730 
    724       ! At the end of the day also get interpolated means 
    725       IF ( idayend == 0 .AND. ld_nightav ) THEN 
     731      ! At the end of the day also deallocate night-time mean array 
     732      IF ( idayend == 0 .AND. ldnightav ) THEN 
    726733         DEALLOCATE( & 
    727734            & zsurfm  & 
     
    734741 
    735742END MODULE obs_oper 
    736  
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_prep.F90

    r5659 r5682  
    7171         & nproc 
    7272      !! * Arguments 
    73       TYPE(obs_surf), INTENT(INOUT) :: surfdata    ! Full set of SLA data 
    74       TYPE(obs_surf), INTENT(INOUT) :: surfdataqc   ! Subset of SLA data not failing screening 
     73      TYPE(obs_surf), INTENT(INOUT) :: surfdata    ! Full set of surface data 
     74      TYPE(obs_surf), INTENT(INOUT) :: surfdataqc   ! Subset of surface data not failing screening 
    7575      LOGICAL, INTENT(IN) :: ld_nea         ! Switch for rejecting observation near land 
    7676      !! * Local declarations 
     
    9999      INTEGER :: inrc         ! Time index variable 
    100100 
    101       IF(lwp) WRITE(numout,*)'obs_pre_sla : Preparing the SLA observations...' 
    102  
     101      IF(lwp) WRITE(numout,*)'obs_pre_surf : Preparing the surface observations...' 
     102      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 
     103       
    103104      ! Initial date initialization (year, month, day, hour, minute) 
    104105      iyea0 =   ndate0 / 10000 
     
    185186      IF(lwp) THEN 
    186187         WRITE(numout,*) 
    187          WRITE(numout,*) 'obs_pre_surf :' 
    188          WRITE(numout,*) '~~~~~~~~~~~' 
    189          WRITE(numout,*) 
    190          WRITE(numout,*) ' Surface data outside time domain               = ', & 
     188         WRITE(numout,*) ' '//surfdataqc%cvars(1)//' data outside time domain                  = ', & 
    191189            &            iotdobsmpp 
    192          WRITE(numout,*) ' Remaining surface data that failed grid search    = ', & 
     190         WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data that failed grid search    = ', & 
    193191            &            igrdobsmpp 
    194          WRITE(numout,*) ' Remaining surface data outside space domain       = ', & 
     192         WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data outside space domain       = ', & 
    195193            &            iosdsobsmpp 
    196          WRITE(numout,*) ' Remaining surface data at land points             = ', & 
     194         WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data at land points             = ', & 
    197195            &            ilansobsmpp 
    198196         IF (ld_nea) THEN 
    199             WRITE(numout,*) ' Remaining surface data near land points (removed) = ', & 
     197            WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data near land points (removed) = ', & 
    200198               &            inlasobsmpp 
    201199         ELSE 
    202             WRITE(numout,*) ' Remaining surface data near land points (kept)    = ', & 
     200            WRITE(numout,*) ' Remaining '//surfdataqc%cvars(1)//' data near land points (kept)    = ', & 
    203201               &            inlasobsmpp 
    204202         ENDIF 
    205          WRITE(numout,*) ' surface data accepted                             = ', & 
     203         WRITE(numout,*) ' '//surfdataqc%cvars(1)//' data accepted                             = ', & 
    206204            &            surfdataqc%nsurfmpp 
    207205 
     
    209207         WRITE(numout,*) ' Number of observations per time step :' 
    210208         WRITE(numout,*) 
    211          WRITE(numout,1997) 
    212          WRITE(numout,1998) 
     209         WRITE(numout,'(10X,A,10X,A)')'Time step',surfdataqc%cvars(1) 
     210         WRITE(numout,'(10X,A,5X,A)')'---------','-----------------' 
     211         CALL FLUSH(numout) 
    213212      ENDIF 
    214213       
     
    225224            inrc = jstp - nit000 + 2 
    226225            WRITE(numout,1999) jstp, surfdataqc%nsstpmpp(inrc) 
     226            CALL FLUSH(numout) 
    227227         END DO 
    228228      ENDIF 
    229229 
    230 1997  FORMAT(10X,'Time step',5X,'Sea level anomaly') 
    231 1998  FORMAT(10X,'---------',5X,'-----------------') 
    2322301999  FORMAT(10X,I9,5X,I17) 
    233231 
     
    235233 
    236234 
    237    SUBROUTINE obs_pre_prof( profdata, prodatqc, ld_vel3d, ld_nea, ld_dailyav ) 
    238       !!---------------------------------------------------------------------- 
     235   SUBROUTINE obs_pre_prof( profdata, prodatqc, ld_var1, ld_var2, & 
     236      &                     zmask1, pglam1, pgphi1, zmask2, pglam2, pgphi2,  & 
     237      &                     ld_nea, kdailyavtypes ) 
     238 
     239!!---------------------------------------------------------------------- 
    239240      !!                    ***  ROUTINE obs_pre_prof  *** 
    240241      !! 
     
    246247      !!        !  2007-06  (K. Mogensen) original : T and S profile data 
    247248      !!        !  2008-09  (M. Valdivieso) : TAO velocity data 
    248       !!        !  2009-01  (K. Mogensen) : New feedback strictuer 
     249      !!        !  2009-01  (K. Mogensen) : New feedback stricture 
    249250      !!        !  2015-02  (M. Martin) : Combined profile routine. 
    250251      !! 
     
    254255      USE par_oce             ! Ocean parameters 
    255256      USE dom_oce, ONLY : &   ! Geographical information 
    256          & glamt, glamu, glamv,    & 
    257          & gphit, gphiu, gphiv,    & 
    258257         & gdept_1d,             & 
    259          & tmask, umask, vmask,  & 
    260258         & nproc 
     259 
    261260      !! * Arguments 
    262261      TYPE(obs_prof), INTENT(INOUT) :: profdata   ! Full set of profile data 
    263262      TYPE(obs_prof), INTENT(INOUT) :: prodatqc   ! Subset of profile data not failing screening 
    264       LOGICAL, INTENT(IN) :: ld_vel3d      ! Switch for zonal and meridional velocity components 
    265       LOGICAL, INTENT(IN) :: ld_nea        ! Switch for rejecting observation near land 
    266       LOGICAL, INTENT(IN) :: ld_dailyav    ! Switch for daily average data 
     263      LOGICAL, INTENT(IN) :: ld_var1              ! Observed variables switches 
     264      LOGICAL, INTENT(IN) :: ld_var2 
     265      LOGICAL, INTENT(IN) :: ld_nea               ! Switch for rejecting observation near land 
     266      INTEGER, DIMENSION(imaxavtypes), OPTIONAL :: & 
     267         & kdailyavtypes                          ! Types for daily averages 
     268      REAL(wp), INTENT(IN), DIMENSION(jpi,jpj,jpk) :: & 
     269         & zmask1, & 
     270         & zmask2 
     271      REAL(wp), INTENT(IN), DIMENSION(jpi,jpj) :: & 
     272         & pglam1, & 
     273         & pglam2, & 
     274         & pgphi1, & 
     275         & pgphi2 
     276 
    267277      !! * Local declarations 
    268278      INTEGER :: iyea0        ! Initial date 
     
    272282      INTEGER :: imin0 
    273283      INTEGER :: icycle       ! Current assimilation cycle 
    274                               ! Counters for observations that 
     284                              ! Counters for observations that are 
    275285      INTEGER :: iotdobs      !  - outside time domain 
    276       INTEGER :: iosduobs     !  - outside space domain (zonal velocity component) 
    277       INTEGER :: iosdvobs     !  - outside space domain (meridional velocity component) 
    278       INTEGER :: ilanuobs     !  - within a model land cell (zonal velocity component) 
    279       INTEGER :: ilanvobs     !  - within a model land cell (meridional velocity component) 
    280       INTEGER :: inlauobs     !  - close to land (zonal velocity component) 
    281       INTEGER :: inlavobs     !  - close to land (meridional velocity component) 
     286      INTEGER :: iosdv1obs    !  - outside space domain (variable 1) 
     287      INTEGER :: iosdv2obs    !  - outside space domain (variable 2) 
     288      INTEGER :: ilanv1obs    !  - within a model land cell (variable 1) 
     289      INTEGER :: ilanv2obs    !  - within a model land cell (variable 2) 
     290      INTEGER :: inlav1obs    !  - close to land (variable 1) 
     291      INTEGER :: inlav2obs    !  - close to land (variable 2) 
    282292      INTEGER :: igrdobs      !  - fail the grid search 
    283293      INTEGER :: iuvchku      !  - reject u if v rejected and vice versa 
    284294      INTEGER :: iuvchkv      ! 
    285                               ! Global counters for observations that 
     295                              ! Global counters for observations that are 
    286296      INTEGER :: iotdobsmpp   !  - outside time domain 
    287       INTEGER :: iosduobsmpp  !  - outside space domain (zonal velocity component) 
    288       INTEGER :: iosdvobsmpp  !  - outside space domain (meridional velocity component) 
    289       INTEGER :: ilanuobsmpp  !  - within a model land cell (zonal velocity component) 
    290       INTEGER :: ilanvobsmpp  !  - within a model land cell (meridional velocity component) 
    291       INTEGER :: inlauobsmpp  !  - close to land (zonal velocity component) 
    292       INTEGER :: inlavobsmpp  !  - close to land (meridional velocity component) 
     297      INTEGER :: iosdv1obsmpp !  - outside space domain (variable 1) 
     298      INTEGER :: iosdv2obsmpp !  - outside space domain (variable 2) 
     299      INTEGER :: ilanv1obsmpp !  - within a model land cell (variable 1) 
     300      INTEGER :: ilanv2obsmpp !  - within a model land cell (variable 2) 
     301      INTEGER :: inlav1obsmpp !  - close to land (variable 1) 
     302      INTEGER :: inlav2obsmpp !  - close to land (variable 2) 
    293303      INTEGER :: igrdobsmpp   !  - fail the grid search 
    294       INTEGER :: iuvchkumpp   !  - reject u if v rejected and vice versa 
     304      INTEGER :: iuvchkumpp   !  - reject var1 if var2 rejected and vice versa 
    295305      INTEGER :: iuvchkvmpp   ! 
    296306      TYPE(obs_prof_valid) ::  llvalid      ! Profile selection  
    297307      TYPE(obs_prof_valid), DIMENSION(profdata%nvar) :: & 
    298          & llvvalid           ! U,V selection  
     308         & llvvalid           ! var1,var2 selection  
    299309      INTEGER :: jvar         ! Variable loop variable 
    300310      INTEGER :: jobs         ! Obs. loop variable 
     
    302312      INTEGER :: inrc         ! Time index variable 
    303313 
    304       IF(lwp) WRITE(numout,*)'obs_pre_prof: Preparing the profile data' 
     314      IF(lwp) WRITE(numout,*)'obs_pre_prof: Preparing the profile data...' 
     315      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' 
    305316 
    306317      ! Initial date initialization (year, month, day, hour, minute) 
     
    317328      iotdobs  = 0 
    318329      igrdobs  = 0 
    319       iosduobs = 0 
    320       iosdvobs = 0 
    321       ilanuobs = 0 
    322       ilanvobs = 0 
    323       inlauobs = 0 
    324       inlavobs = 0 
     330      iosdv1obs = 0 
     331      iosdv2obs = 0 
     332      ilanv1obs = 0 
     333      ilanv2obs = 0 
     334      inlav1obs = 0 
     335      inlav2obs = 0 
    325336      iuvchku  = 0 
    326337      iuvchkv = 0 
     
    330341      ! ----------------------------------------------------------------------- 
    331342 
    332       CALL obs_coo_tim_prof( icycle, & 
    333          &              iyea0,   imon0,   iday0,   ihou0,   imin0,      & 
    334          &              profdata%nprof,   profdata%nyea, profdata%nmon, & 
    335          &              profdata%nday,    profdata%nhou, profdata%nmin, & 
    336          &              profdata%ntyp,    profdata%nqc,  profdata%mstp, & 
    337          &              iotdobs, ld_dailyav = ld_dailyav        ) 
    338      
     343      IF ( PRESENT(kdailyavtypes) ) THEN 
     344         CALL obs_coo_tim_prof( icycle, & 
     345            &              iyea0,   imon0,   iday0,   ihou0,   imin0,      & 
     346            &              profdata%nprof,   profdata%nyea, profdata%nmon, & 
     347            &              profdata%nday,    profdata%nhou, profdata%nmin, & 
     348            &              profdata%ntyp,    profdata%nqc,  profdata%mstp, & 
     349            &              iotdobs, kdailyavtypes = kdailyavtypes ) 
     350      ELSE 
     351         CALL obs_coo_tim_prof( icycle, & 
     352            &              iyea0,   imon0,   iday0,   ihou0,   imin0,      & 
     353            &              profdata%nprof,   profdata%nyea, profdata%nmon, & 
     354            &              profdata%nday,    profdata%nhou, profdata%nmin, & 
     355            &              profdata%ntyp,    profdata%nqc,  profdata%mstp, & 
     356            &              iotdobs ) 
     357      ENDIF 
     358 
    339359      CALL obs_mpp_sum_integer( iotdobs, iotdobsmpp ) 
    340360       
     
    343363      ! ----------------------------------------------------------------------- 
    344364 
    345       CALL obs_coo_grd( profdata%nprof,   profdata%mi(:,1), profdata%mj(:,1), & 
    346          &              profdata%nqc,     igrdobs                         ) 
    347       CALL obs_coo_grd( profdata%nprof,   profdata%mi(:,2), profdata%mj(:,2), & 
    348          &              profdata%nqc,     igrdobs                         ) 
     365      CALL obs_coo_grd( profdata%nprof,   profdata%mi, profdata%mj, & 
     366         &              profdata%nqc,     igrdobs                ) 
    349367 
    350368      CALL obs_mpp_sum_integer( igrdobs, igrdobsmpp ) 
     
    361379      ! ----------------------------------------------------------------------- 
    362380 
    363       ! Zonal Velocity Component 
    364  
     381      ! Variable 1 
    365382      CALL obs_coo_spc_3d( profdata%nprof,        profdata%nvprot(1),   & 
    366383         &                 profdata%npvsta(:,1),  profdata%npvend(:,1), & 
    367384         &                 jpi,                   jpj,                  & 
    368385         &                 jpk,                                         & 
    369          &                 profdata%mi,           profdata%mj,          &  
     386         &                 profdata%mi,           profdata%mj,          & 
    370387         &                 profdata%var(1)%mvk,                         & 
    371388         &                 profdata%rlam,         profdata%rphi,        & 
    372389         &                 profdata%var(1)%vdep,                        & 
    373          &                 glamu,                 gphiu,                & 
    374          &                 gdept_1d,              umask,                & 
     390         &                 pglam1,                pgphi1,               & 
     391         &                 gdept_1d,              zmask1,               & 
    375392         &                 profdata%nqc,          profdata%var(1)%nvqc, & 
    376          &                 iosduobs,              ilanuobs,             & 
    377          &                 inlauobs,              ld_nea                ) 
    378  
    379       CALL obs_mpp_sum_integer( iosduobs, iosduobsmpp ) 
    380       CALL obs_mpp_sum_integer( ilanuobs, ilanuobsmpp ) 
    381       CALL obs_mpp_sum_integer( inlauobs, inlauobsmpp ) 
    382  
    383       ! Meridional Velocity Component 
    384  
     393         &                 iosdv1obs,              ilanv1obs,           & 
     394         &                 inlav1obs,              ld_nea                ) 
     395 
     396      CALL obs_mpp_sum_integer( iosdv1obs, iosdv1obsmpp ) 
     397      CALL obs_mpp_sum_integer( ilanv1obs, ilanv1obsmpp ) 
     398      CALL obs_mpp_sum_integer( inlav1obs, inlav1obsmpp ) 
     399 
     400      ! Variable 2 
    385401      CALL obs_coo_spc_3d( profdata%nprof,        profdata%nvprot(2),   & 
    386402         &                 profdata%npvsta(:,2),  profdata%npvend(:,2), & 
     
    391407         &                 profdata%rlam,         profdata%rphi,        & 
    392408         &                 profdata%var(2)%vdep,                        & 
    393          &                 glamv,                 gphiv,                & 
    394          &                 gdept_1d,              vmask,                & 
     409         &                 pglam2,                pgphi2,               & 
     410         &                 gdept_1d,              zmask2,               & 
    395411         &                 profdata%nqc,          profdata%var(2)%nvqc, & 
    396          &                 iosdvobs,              ilanvobs,             & 
    397          &                 inlavobs,              ld_nea                ) 
    398  
    399       CALL obs_mpp_sum_integer( iosdvobs, iosdvobsmpp ) 
    400       CALL obs_mpp_sum_integer( ilanvobs, ilanvobsmpp ) 
    401       CALL obs_mpp_sum_integer( inlavobs, inlavobsmpp ) 
     412         &                 iosdv2obs,              ilanv2obs,           & 
     413         &                 inlav2obs,              ld_nea                ) 
     414 
     415      CALL obs_mpp_sum_integer( iosdv2obs, iosdv2obsmpp ) 
     416      CALL obs_mpp_sum_integer( ilanv2obs, ilanv2obsmpp ) 
     417      CALL obs_mpp_sum_integer( inlav2obs, inlav2obsmpp ) 
    402418 
    403419      ! ----------------------------------------------------------------------- 
     
    405421      ! ----------------------------------------------------------------------- 
    406422 
    407       CALL obs_uv_rej( profdata, iuvchku, iuvchkv ) 
    408       CALL obs_mpp_sum_integer( iuvchku, iuvchkumpp ) 
    409       CALL obs_mpp_sum_integer( iuvchkv, iuvchkvmpp ) 
     423      IF ( TRIM(profdata%cvars(1)) == 'UVEL' ) THEN 
     424         CALL obs_uv_rej( profdata, iuvchku, iuvchkv ) 
     425         CALL obs_mpp_sum_integer( iuvchku, iuvchkumpp ) 
     426         CALL obs_mpp_sum_integer( iuvchkv, iuvchkvmpp ) 
     427      ENDIF 
    410428 
    411429      ! ----------------------------------------------------------------------- 
     
    446464       
    447465      IF(lwp) THEN 
     466       
    448467         WRITE(numout,*) 
    449          WRITE(numout,*) 'obs_pre_vel :' 
    450          WRITE(numout,*) '~~~~~~~~~~~' 
    451          WRITE(numout,*) 
    452          WRITE(numout,*) ' Profiles outside time domain                = ', & 
     468         WRITE(numout,*) ' Profiles outside time domain                     = ', & 
    453469            &            iotdobsmpp 
    454          WRITE(numout,*) ' Remaining profiles that failed grid search  = ', & 
     470         WRITE(numout,*) ' Remaining profiles that failed grid search       = ', & 
    455471            &            igrdobsmpp 
    456          WRITE(numout,*) ' Remaining U data outside space domain       = ', & 
    457             &            iosduobsmpp 
    458          WRITE(numout,*) ' Remaining U data at land points             = ', & 
    459             &            ilanuobsmpp 
     472         WRITE(numout,*) ' Remaining '//prodatqc%cvars(1)//' data outside space domain       = ', & 
     473            &            iosdv1obsmpp 
     474         WRITE(numout,*) ' Remaining '//prodatqc%cvars(1)//' data at land points             = ', & 
     475            &            ilanv1obsmpp 
    460476         IF (ld_nea) THEN 
    461             WRITE(numout,*) ' Remaining U data near land points (removed) = ',& 
    462                &            inlauobsmpp 
     477            WRITE(numout,*) ' Remaining '//prodatqc%cvars(1)//' data near land points (removed) = ',& 
     478               &            inlav1obsmpp 
    463479         ELSE 
    464             WRITE(numout,*) ' Remaining U data near land points (kept)    = ',& 
    465                &            inlauobsmpp 
    466          ENDIF 
    467          WRITE(numout,*) ' U observation rejected since V rejected     = ', & 
    468             &            iuvchku      
    469          WRITE(numout,*) ' U data accepted                             = ', & 
     480            WRITE(numout,*) ' Remaining '//prodatqc%cvars(1)//' data near land points (kept)    = ',& 
     481               &            inlav1obsmpp 
     482         ENDIF 
     483         IF ( TRIM(profdata%cvars(1)) == 'UVEL' ) THEN 
     484            WRITE(numout,*) ' U observation rejected since V rejected     = ', & 
     485               &            iuvchku 
     486         ENDIF 
     487         WRITE(numout,*) ' '//prodatqc%cvars(1)//' data accepted                             = ', & 
    470488            &            prodatqc%nvprotmpp(1) 
    471          WRITE(numout,*) ' Remaining V data outside space domain       = ', & 
    472             &            iosdvobsmpp 
    473          WRITE(numout,*) ' Remaining V data at land points             = ', & 
    474             &            ilanvobsmpp 
     489         WRITE(numout,*) ' Remaining '//prodatqc%cvars(2)//' data outside space domain       = ', & 
     490            &            iosdv2obsmpp 
     491         WRITE(numout,*) ' Remaining '//prodatqc%cvars(2)//' data at land points             = ', & 
     492            &            ilanv2obsmpp 
    475493         IF (ld_nea) THEN 
    476             WRITE(numout,*) ' Remaining V data near land points (removed) = ',& 
    477                &            inlavobsmpp 
     494            WRITE(numout,*) ' Remaining '//prodatqc%cvars(2)//' data near land points (removed) = ',& 
     495               &            inlav2obsmpp 
    478496         ELSE 
    479             WRITE(numout,*) ' Remaining V data near land points (kept)    = ',& 
    480                &            inlavobsmpp 
    481          ENDIF 
    482          WRITE(numout,*) ' V observation rejected since U rejected     = ', & 
    483             &            iuvchkv      
    484          WRITE(numout,*) ' V data accepted                             = ', & 
     497            WRITE(numout,*) ' Remaining '//prodatqc%cvars(2)//' data near land points (kept)    = ',& 
     498               &            inlav2obsmpp 
     499         ENDIF 
     500         IF ( TRIM(profdata%cvars(1)) == 'UVEL' ) THEN 
     501            WRITE(numout,*) ' V observation rejected since U rejected     = ', & 
     502               &            iuvchkv 
     503         ENDIF 
     504         WRITE(numout,*) ' '//prodatqc%cvars(2)//' data accepted                             = ', & 
    485505            &            prodatqc%nvprotmpp(2) 
    486506 
     
    488508         WRITE(numout,*) ' Number of observations per time step :' 
    489509         WRITE(numout,*) 
    490          WRITE(numout,997) 
     510         WRITE(numout,'(10X,A,5X,A,5X,A,A)')'Time step','Profiles', & 
     511            &                               '     '//prodatqc%cvars(1)//'     ', & 
     512            &                               '     '//prodatqc%cvars(2)//'     ' 
    491513         WRITE(numout,998) 
    492514      ENDIF 
     
    522544      ENDIF 
    523545 
    524 997   FORMAT(10X,'Time step',5X,'Profiles',5X,'Zonal Comp.',5X,'Meridional Comp.') 
    525546998   FORMAT(10X,'---------',5X,'--------',5X,'-----------',5X,'----------------') 
    526547999   FORMAT(10X,I9,5X,I8,5X,I11,5X,I8) 
     
    728749      &                    kobsno,                                        & 
    729750      &                    kobsyea, kobsmon, kobsday, kobshou, kobsmin,   & 
    730       &                    ktyp,    kobsqc,  kobsstp, kotdobs, kdailyavtypes, & 
    731       &                    ld_dailyav ) 
     751      &                    ktyp,    kobsqc,  kobsstp, kotdobs, kdailyavtypes ) 
    732752      !!---------------------------------------------------------------------- 
    733753      !!                    ***  ROUTINE obs_coo_tim *** 
     
    773793      INTEGER, DIMENSION(imaxavtypes), OPTIONAL :: & 
    774794         & kdailyavtypes    ! Types for daily averages 
    775       LOGICAL, OPTIONAL :: ld_dailyav    ! All types are daily averages 
    776795      !! * Local declarations 
    777796      INTEGER :: jobs 
     
    807826      ENDIF 
    808827 
    809       !------------------------------------------------------------------------ 
    810       ! If ld_dailyav is set then all data assumed to be daily averaged 
    811       !------------------------------------------------------------------------ 
    812        
    813       IF ( PRESENT( ld_dailyav) ) THEN 
    814          IF (ld_dailyav) THEN 
    815             DO jobs = 1, kobsno 
    816                 
    817                IF ( kobsqc(jobs) <= 10 ) THEN 
    818                    
    819                   IF ( kobsstp(jobs) == (nit000 - 1) ) THEN 
    820                      kobsqc(jobs) = kobsqc(jobs) + 14 
    821                      kotdobs      = kotdobs + 1 
    822                      CYCLE 
    823                   ENDIF 
    824                    
    825                ENDIF 
    826             END DO 
    827          ENDIF 
    828       ENDIF 
    829828 
    830829   END SUBROUTINE obs_coo_tim_prof 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_profiles_def.F90

    r2715 r5682  
    104104      ! Bookkeeping arrays with sizes equal to number of variables 
    105105 
     106      CHARACTER(len=6), POINTER, DIMENSION(:) :: & 
     107         & cvars          !: Variable names 
     108 
    106109      INTEGER, POINTER, DIMENSION(:) :: & 
    107110         & nvprot,   &    !: Local total number of profile T data 
     
    237240 
    238241      ALLOCATE( & 
     242         & prof%cvars(kvar),    & 
    239243         & prof%nvprot(kvar),   & 
    240244         & prof%nvprotmpp(kvar) & 
     
    242246          
    243247      DO jvar = 1, kvar 
     248         prof%cvars    (jvar) = "NotSet" 
    244249         prof%nvprot   (jvar) = ko3dt(jvar) 
    245250         prof%nvprotmpp(jvar) = 0 
     
    452457 
    453458      DEALLOCATE( & 
    454          & prof%nvprot,  & 
     459         & prof%cvars,    & 
     460         & prof%nvprot,   & 
    455461         & prof%nvprotmpp & 
    456462         ) 
     
    770776      newprof%npj      = prof%npj 
    771777      newprof%npk      = prof%npk 
     778      newprof%cvars(:) = prof%cvars(:) 
    772779  
    773780      ! Deallocate temporary data 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_altbias.F90

    r3294 r5682  
    5050CONTAINS 
    5151 
    52    SUBROUTINE obs_rea_altbias( kslano, sladata, k2dint, bias_file ) 
     52   SUBROUTINE obs_rea_altbias( sladata, k2dint, bias_file ) 
    5353      !!--------------------------------------------------------------------- 
    5454      !! 
     
    7070      ! 
    7171      !! * Arguments 
    72       INTEGER, INTENT(IN) :: kslano      ! Number of SLA Products 
    73       TYPE(obs_surf), DIMENSION(kslano), INTENT(INOUT) :: & 
     72      TYPE(obs_surf), INTENT(INOUT) :: & 
    7473         & sladata       ! SLA data 
    7574      INTEGER, INTENT(IN) :: k2dint 
     
    8079      CHARACTER(LEN=12), PARAMETER :: cpname = 'obs_rea_altbias' 
    8180 
    82       INTEGER :: jslano       ! Data set loop variable 
    8381      INTEGER :: jobs         ! Obs loop variable 
    8482      INTEGER :: jpialtbias   ! Number of grid point in latitude for the bias 
     
    144142      ! Intepolate the bias already on the model grid at the observation point 
    145143   
    146       DO jslano = 1, kslano 
    147  
    148          ALLOCATE( & 
    149             & igrdi(2,2,sladata(jslano)%nsurf), & 
    150             & igrdj(2,2,sladata(jslano)%nsurf), & 
    151             & zglam(2,2,sladata(jslano)%nsurf), & 
    152             & zgphi(2,2,sladata(jslano)%nsurf), & 
    153             & zmask(2,2,sladata(jslano)%nsurf), & 
    154             & zbias(2,2,sladata(jslano)%nsurf)  & 
    155             & ) 
    156           
    157          DO jobs = 1, sladata(jslano)%nsurf 
    158  
    159             igrdi(1,1,jobs) = sladata(jslano)%mi(jobs)-1 
    160             igrdj(1,1,jobs) = sladata(jslano)%mj(jobs)-1 
    161             igrdi(1,2,jobs) = sladata(jslano)%mi(jobs)-1 
    162             igrdj(1,2,jobs) = sladata(jslano)%mj(jobs) 
    163             igrdi(2,1,jobs) = sladata(jslano)%mi(jobs) 
    164             igrdj(2,1,jobs) = sladata(jslano)%mj(jobs)-1 
    165             igrdi(2,2,jobs) = sladata(jslano)%mi(jobs) 
    166             igrdj(2,2,jobs) = sladata(jslano)%mj(jobs) 
    167  
    168          END DO 
    169  
    170          CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, & 
    171             &                  igrdi, igrdj, glamt, zglam ) 
    172          CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, & 
    173             &                  igrdi, igrdj, gphit, zgphi ) 
    174          CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, & 
    175             &                  igrdi, igrdj, tmask(:,:,1), zmask ) 
    176          CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, & 
    177             &                  igrdi, igrdj, z_altbias, zbias ) 
    178  
    179          DO jobs = 1, sladata(jslano)%nsurf 
    180  
    181             zlam = sladata(jslano)%rlam(jobs) 
    182             zphi = sladata(jslano)%rphi(jobs) 
    183             iico = sladata(jslano)%mi(jobs) 
    184             ijco = sladata(jslano)%mj(jobs) 
     144      ALLOCATE( & 
     145         & igrdi(2,2,sladata%nsurf), & 
     146         & igrdj(2,2,sladata%nsurf), & 
     147         & zglam(2,2,sladata%nsurf), & 
     148         & zgphi(2,2,sladata%nsurf), & 
     149         & zmask(2,2,sladata%nsurf), & 
     150         & zbias(2,2,sladata%nsurf)  & 
     151         & ) 
     152          
     153      DO jobs = 1, sladata%nsurf 
     154 
     155         igrdi(1,1,jobs) = sladata%mi(jobs)-1 
     156         igrdj(1,1,jobs) = sladata%mj(jobs)-1 
     157         igrdi(1,2,jobs) = sladata%mi(jobs)-1 
     158         igrdj(1,2,jobs) = sladata%mj(jobs) 
     159         igrdi(2,1,jobs) = sladata%mi(jobs) 
     160         igrdj(2,1,jobs) = sladata%mj(jobs)-1 
     161         igrdi(2,2,jobs) = sladata%mi(jobs) 
     162         igrdj(2,2,jobs) = sladata%mj(jobs) 
     163 
     164      END DO 
     165 
     166      CALL obs_int_comm_2d( 2, 2, sladata%nsurf, & 
     167         &                  igrdi, igrdj, glamt, zglam ) 
     168      CALL obs_int_comm_2d( 2, 2, sladata%nsurf, & 
     169         &                  igrdi, igrdj, gphit, zgphi ) 
     170      CALL obs_int_comm_2d( 2, 2, sladata%nsurf, & 
     171         &                  igrdi, igrdj, tmask(:,:,1), zmask ) 
     172      CALL obs_int_comm_2d( 2, 2, sladata%nsurf, & 
     173         &                  igrdi, igrdj, z_altbias, zbias ) 
     174 
     175      DO jobs = 1, sladata%nsurf 
     176 
     177         zlam = sladata%rlam(jobs) 
     178         zphi = sladata%rphi(jobs) 
     179         iico = sladata%mi(jobs) 
     180         ijco = sladata%mj(jobs) 
    185181             
    186             CALL obs_int_h2d_init( 1, 1, k2dint, zlam, zphi,         & 
    187                &                   zglam(:,:,jobs), zgphi(:,:,jobs), & 
    188                &                   zmask(:,:,jobs), zweig, zobsmask ) 
     182         CALL obs_int_h2d_init( 1, 1, k2dint, zlam, zphi,         & 
     183            &                   zglam(:,:,jobs), zgphi(:,:,jobs), & 
     184            &                   zmask(:,:,jobs), zweig, zobsmask ) 
    189185             
    190             CALL obs_int_h2d( 1, 1,      & 
    191                &              zweig, zbias(:,:,jobs),  zext ) 
    192  
    193             ! adjust mdt with bias field 
    194             sladata(jslano)%rext(jobs,2) = & 
    195                sladata(jslano)%rext(jobs,2) - zext(1) 
     186         CALL obs_int_h2d( 1, 1,      & 
     187            &              zweig, zbias(:,:,jobs),  zext ) 
     188 
     189         ! adjust mdt with bias field 
     190         sladata%rext(jobs,2) = sladata%rext(jobs,2) - zext(1) 
    196191             
    197          END DO 
    198  
    199          DEALLOCATE( & 
    200             & igrdi, & 
    201             & igrdj, & 
    202             & zglam, & 
    203             & zgphi, & 
    204             & zmask, & 
    205             & zbias  & 
    206             & ) 
    207           
    208192      END DO 
    209193 
     194      DEALLOCATE( & 
     195         & igrdi, & 
     196         & igrdj, & 
     197         & zglam, & 
     198         & zgphi, & 
     199         & zmask, & 
     200         & zbias  & 
     201         & ) 
     202          
    210203      CALL wrk_dealloc(jpi,jpj,z_altbias)  
    211204 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_prof.F90

    r5659 r5682  
    2525   USE netcdf                   ! NetCDF library 
    2626   USE obs_oper                 ! Observation operators 
    27    USE obs_prof_io              ! Profile files I/O (non-FB files) 
    2827   USE lib_mpp                  ! For ctl_warn/stop 
     28   USE obs_fbm                  ! Feedback routines 
    2929 
    3030   IMPLICIT NONE 
     
    4242 
    4343CONTAINS 
    44   
    45    SUBROUTINE obs_rea_prof( profdata, knumfiles, cfilenames, & 
     44 
     45   SUBROUTINE obs_rea_prof( profdata, knumfiles, cdfilenames, & 
    4646      &                     kvars, kextr, kstp, ddobsini, ddobsend, & 
    47       &                     ldt3d, lds3d, ldignmis, ldsatt, ldavtimset, & 
     47      &                     ldvar1, ldvar2, ldignmis, ldsatt, & 
    4848      &                     ldmod, kdailyavtypes ) 
    4949      !!--------------------------------------------------------------------- 
     
    6262      !! History :   
    6363      !!      ! :  2009-09 (K. Mogensen) : New merged version of old routines 
     64      !!      ! :  2015-08 (M. Martin) : Merged profile and velocity routines 
    6465      !!---------------------------------------------------------------------- 
    65       !! * Modules used 
    66     
     66 
    6767      !! * Arguments 
    68       TYPE(obs_prof), INTENT(OUT) ::  profdata     ! Profile data to be read 
    69       INTEGER, INTENT(IN) :: knumfiles      ! Number of files to read in 
     68      TYPE(obs_prof), INTENT(OUT) :: & 
     69         & profdata                     ! Profile data to be read 
     70      INTEGER, INTENT(IN) :: knumfiles  ! Number of files to read 
    7071      CHARACTER(LEN=128), INTENT(IN) ::  & 
    71          & cfilenames(knumfiles)  ! File names to read in 
     72         & cdfilenames(knumfiles)        ! File names to read in 
    7273      INTEGER, INTENT(IN) :: kvars      ! Number of variables in profdata 
    73       INTEGER, INTENT(IN) :: kextr      ! Number of extra fields for each var in profdata 
    74       INTEGER, INTENT(IN) :: kstp        ! Ocean time-step index 
    75       LOGICAL, INTENT(IN) :: ldt3d       ! Observed variables switches 
    76       LOGICAL, INTENT(IN) :: lds3d 
    77       LOGICAL, INTENT(IN) :: ldignmis    ! Ignore missing files 
    78       LOGICAL, INTENT(IN) :: ldsatt      ! Compute salinity at all temperature points 
    79       LOGICAL, INTENT(IN) :: ldavtimset  ! Correct time for daily averaged data 
    80       LOGICAL, INTENT(IN) :: ldmod       ! Initialize model from input data 
    81       REAL(KIND=dp), INTENT(IN) :: ddobsini    ! Obs. ini time in YYYYMMDD.HHMMSS 
    82       REAL(KIND=dp), INTENT(IN) :: ddobsend    ! Obs. end time in YYYYMMDD.HHMMSS 
     74      INTEGER, INTENT(IN) :: kextr      ! Number of extra fields for each var 
     75      INTEGER, INTENT(IN) :: kstp       ! Ocean time-step index 
     76      LOGICAL, INTENT(IN) :: ldvar1     ! Observed variables switches 
     77      LOGICAL, INTENT(IN) :: ldvar2 
     78      LOGICAL, INTENT(IN) :: ldignmis   ! Ignore missing files 
     79      LOGICAL, INTENT(IN) :: ldsatt     ! Compute salinity at all temperature points 
     80      LOGICAL, INTENT(IN) :: ldmod      ! Initialize model from input data 
     81      REAL(dp), INTENT(IN) :: ddobsini  ! Obs. ini time in YYYYMMDD.HHMMSS 
     82      REAL(dp), INTENT(IN) :: ddobsend  ! Obs. end time in YYYYMMDD.HHMMSS 
    8383      INTEGER, DIMENSION(imaxavtypes), OPTIONAL :: & 
    84          & kdailyavtypes 
     84         & kdailyavtypes                ! Types of daily average observations 
    8585 
    8686      !! * Local declarations 
    8787      CHARACTER(LEN=15), PARAMETER :: cpname='obs_rea_prof' 
     88      CHARACTER(len=8) :: clrefdate 
     89      CHARACTER(len=6), DIMENSION(:), ALLOCATABLE :: clvars 
    8890      INTEGER :: jvar 
    8991      INTEGER :: ji 
     
    101103      INTEGER :: imin 
    102104      INTEGER :: isec 
     105      INTEGER :: iprof 
     106      INTEGER :: iproftot 
     107      INTEGER :: ivar1t0 
     108      INTEGER :: ivar2t0 
     109      INTEGER :: ivar1t 
     110      INTEGER :: ivar2t 
     111      INTEGER :: ip3dt 
     112      INTEGER :: ios 
     113      INTEGER :: ioserrcount 
     114      INTEGER :: ivar1tmpp 
     115      INTEGER :: ivar2tmpp 
     116      INTEGER :: ip3dtmpp 
     117      INTEGER :: itype 
    103118      INTEGER, DIMENSION(knumfiles) :: & 
    104119         & irefdate 
    105120      INTEGER, DIMENSION(ntyp1770+1) :: & 
    106          & itypt,    & 
    107          & ityptmpp, & 
    108          & ityps,    & 
    109          & itypsmpp  
    110       INTEGER :: it3dtmpp 
    111       INTEGER :: is3dtmpp 
    112       INTEGER :: ip3dtmpp 
     121         & itypvar1,    & 
     122         & itypvar1mpp, & 
     123         & itypvar2,    & 
     124         & itypvar2mpp  
    113125      INTEGER, DIMENSION(:), ALLOCATABLE :: & 
    114126         & iobsi,    & 
     
    118130         & ifileidx, & 
    119131         & iprofidx 
    120       INTEGER :: itype 
    121132      INTEGER, DIMENSION(imaxavtypes) :: & 
    122133         & idailyavtypes 
     134      INTEGER, DIMENSION(kvars) :: & 
     135         & iv3dt 
    123136      REAL(wp), DIMENSION(:), ALLOCATABLE :: & 
    124137         & zphi, & 
    125138         & zlam 
    126       real(wp), DIMENSION(:), ALLOCATABLE :: & 
     139      REAL(wp), DIMENSION(:), ALLOCATABLE :: & 
    127140         & zdat 
     141      REAL(wp), DIMENSION(knumfiles) :: & 
     142         & djulini, & 
     143         & djulend 
    128144      LOGICAL :: llvalprof 
     145      LOGICAL :: lldavtimset 
    129146      TYPE(obfbdata), POINTER, DIMENSION(:) :: & 
    130147         & inpfiles 
    131       real(wp), DIMENSION(knumfiles) :: & 
    132          & djulini, & 
    133          & djulend 
    134       INTEGER :: iprof 
    135       INTEGER :: iproftot 
    136       INTEGER :: it3dt0 
    137       INTEGER :: is3dt0 
    138       INTEGER :: it3dt 
    139       INTEGER :: is3dt 
    140       INTEGER :: ip3dt 
    141       INTEGER :: ios 
    142       INTEGER :: ioserrcount 
    143       INTEGER, DIMENSION(kvars) :: & 
    144          & iv3dt 
    145       CHARACTER(len=8) :: cl_refdate 
    146     
     148 
    147149      ! Local initialization 
    148150      iprof = 0 
    149       it3dt0 = 0 
    150       is3dt0 = 0 
     151      ivar1t0 = 0 
     152      ivar2t0 = 0 
    151153      ip3dt = 0 
    152154 
    153155      ! Daily average types 
     156      lldavtimset = .FALSE. 
    154157      IF ( PRESENT(kdailyavtypes) ) THEN 
    155158         idailyavtypes(:) = kdailyavtypes(:) 
     159         IF ( ANY (idailyavtypes(:) /= -1) ) lldavtimset = .TRUE. 
    156160      ELSE 
    157161         idailyavtypes(:) = -1 
     
    159163 
    160164      !----------------------------------------------------------------------- 
    161       ! Check data the model part is just with feedback data files 
    162       !----------------------------------------------------------------------- 
    163       IF ( ldmod .AND. ( kformat /= 0 ) ) THEN 
    164          CALL ctl_stop( 'Model can only be read from feedback data' ) 
    165          RETURN 
    166       ENDIF 
    167  
    168       !----------------------------------------------------------------------- 
    169165      ! Count the number of files needed and allocate the obfbdata type 
    170166      !----------------------------------------------------------------------- 
    171        
     167 
    172168      inobf = knumfiles 
    173        
     169 
    174170      ALLOCATE( inpfiles(inobf) ) 
    175171 
    176172      prof_files : DO jj = 1, inobf 
    177            
     173 
    178174         !--------------------------------------------------------------------- 
    179175         ! Prints 
     
    182178            WRITE(numout,*) 
    183179            WRITE(numout,*) ' obs_rea_pro_dri : Reading from file = ', & 
    184                & TRIM( TRIM( cfilenames(jj) ) ) 
     180               & TRIM( TRIM( cdfilenames(jj) ) ) 
    185181            WRITE(numout,*) ' ~~~~~~~~~~~~~~~' 
    186182            WRITE(numout,*) 
     
    190186         !  Initialization: Open file and get dimensions only 
    191187         !--------------------------------------------------------------------- 
    192           
    193          iflag = nf90_open( TRIM( cfilenames(jj) ), nf90_nowrite, & 
     188 
     189         iflag = nf90_open( TRIM( cdfilenames(jj) ), nf90_nowrite, & 
    194190            &                      i_file_id ) 
    195           
     191 
    196192         IF ( iflag /= nf90_noerr ) THEN 
    197193 
    198194            IF ( ldignmis ) THEN 
    199195               inpfiles(jj)%nobs = 0 
    200                CALL ctl_warn( 'File ' // TRIM( cfilenames(jj) ) // & 
     196               CALL ctl_warn( 'File ' // TRIM( cdfilenames(jj) ) // & 
    201197                  &           ' not found' ) 
    202198            ELSE  
    203                CALL ctl_stop( 'File ' // TRIM( cfilenames(jj) ) // & 
     199               CALL ctl_stop( 'File ' // TRIM( cdfilenames(jj) ) // & 
    204200                  &           ' not found' ) 
    205201            ENDIF 
    206202 
    207203         ELSE  
    208              
     204 
    209205            !------------------------------------------------------------------ 
    210             !  Close the file since it is opened in read_proffile 
     206            !  Close the file since it is opened in read_obfbdata 
    211207            !------------------------------------------------------------------ 
    212              
     208 
    213209            iflag = nf90_close( i_file_id ) 
    214210 
     
    217213            !------------------------------------------------------------------ 
    218214            CALL init_obfbdata( inpfiles(jj) ) 
    219             IF(lwp) THEN 
    220                WRITE(numout,*) 
    221                WRITE(numout,*)'Reading from feedback file :', & 
    222                   &           TRIM( cfilenames(jj) ) 
    223             ENDIF 
    224             CALL read_obfbdata( TRIM( cfilenames(jj) ), inpfiles(jj), & 
     215            CALL read_obfbdata( TRIM( cdfilenames(jj) ), inpfiles(jj), & 
    225216               &                ldgrid = .TRUE. ) 
    226                 
     217 
    227218            IF ( inpfiles(jj)%nvar < 2 ) THEN 
    228                CALL ctl_stop( 'Feedback format error' ) 
    229                RETURN 
    230             ENDIF 
     219               CALL ctl_stop( 'Feedback format error: ', & 
     220                  &           ' less than 2 vars in profile file' ) 
     221            ENDIF 
     222 
    231223            IF ( ldmod .AND. ( inpfiles(jj)%nadd == 0 ) ) THEN 
    232224               CALL ctl_stop( 'Model not in input data' ) 
    233                RETURN 
    234             ENDIF 
    235              
     225            ENDIF 
     226 
     227            IF ( jj == 1 ) THEN 
     228               ALLOCATE( clvars( inpfiles(jj)%nvar ) ) 
     229               DO ji = 1, inpfiles(jj)%nvar 
     230                 clvars(ji) = inpfiles(jj)%cname(ji) 
     231               END DO 
     232            ELSE 
     233               DO ji = 1, inpfiles(jj)%nvar 
     234                  IF ( inpfiles(jj)%cname(ji) /= clvars(ji) ) THEN 
     235                     CALL ctl_stop( 'Feedback file variables not consistent', & 
     236                        &           ' with previous files for this type' ) 
     237                  ENDIF 
     238               END DO 
     239            ENDIF 
     240 
    236241            !------------------------------------------------------------------ 
    237242            !  Change longitude (-180,180) 
     
    251256            !  Calculate the date  (change eventually) 
    252257            !------------------------------------------------------------------ 
    253             cl_refdate=inpfiles(jj)%cdjuldref(1:8) 
    254             READ(cl_refdate,'(I8)') irefdate(jj) 
    255              
     258            clrefdate=inpfiles(jj)%cdjuldref(1:8) 
     259            READ(clrefdate,'(I8)') irefdate(jj) 
     260 
    256261            CALL ddatetoymdhms( ddobsini, iyea, imon, iday, ihou, imin, isec ) 
    257262            CALL greg2jul( isec, imin, ihou, iday, imon, iyea, djulini(jj), & 
     
    262267 
    263268            ioserrcount=0 
    264             IF ( ldavtimset ) THEN 
     269            IF ( lldavtimset ) THEN 
     270 
     271               IF ( ANY ( idailyavtypes(:) /= -1 ) .AND. lwp) THEN 
     272                  WRITE(numout,*)' Resetting time of daily averaged', & 
     273                     &           ' observations to the end of the day' 
     274               ENDIF 
     275 
    265276               DO ji = 1, inpfiles(jj)%nobs 
    266                   !  
    267                   !  for daily averaged data for example 
    268                   !  MRB data (itype==820) force the time 
    269                   !  to be the  end of the day 
    270                   ! 
    271277                  READ( inpfiles(jj)%cdtyp(ji), '(I4)', IOSTAT = ios, ERR = 900 ) itype 
    272278900               IF ( ios /= 0 ) THEN 
    273                      itype = 0         ! Set type to zero if there is a problem in the string conversion 
     279                     ! Set type to zero if there is a problem in the string conversion 
     280                     itype = 0 
    274281                  ENDIF 
    275                   IF ( ANY (idailyavtypes == itype ) ) THEN 
    276                      inpfiles(jj)%ptim(ji) = & 
    277                      & INT(inpfiles(jj)%ptim(ji)) + 1 
     282 
     283                  IF ( ANY ( idailyavtypes(:) == itype ) ) THEN 
     284                  !  for daily averaged data force the time 
     285                  !  to be the last time-step of the day, but still within the day. 
     286                     IF ( inpfiles(jj)%ptim(ji) >= 0. ) THEN 
     287                        inpfiles(jj)%ptim(ji) = & 
     288                           & INT(inpfiles(jj)%ptim(ji)) + 0.9999 
     289                     ELSE 
     290                        inpfiles(jj)%ptim(ji) = & 
     291                           & INT(inpfiles(jj)%ptim(ji)) - 0.0001 
     292                     ENDIF 
    278293                  ENDIF 
     294 
    279295               END DO 
    280             ENDIF 
    281              
     296 
     297            ENDIF 
     298 
    282299            IF ( inpfiles(jj)%nobs > 0 ) THEN 
    283300               inpfiles(jj)%iproc = -1 
     
    342359                  ENDIF 
    343360                  llvalprof = .FALSE. 
    344                   IF ( ldt3d ) THEN 
     361                  IF ( ldvar1 ) THEN 
    345362                     loop_t_count : DO ij = 1,inpfiles(jj)%nlev 
    346363                        IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) & 
     
    348365                        IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. & 
    349366                           & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN 
    350                            it3dt0 = it3dt0 + 1 
     367                           ivar1t0 = ivar1t0 + 1 
    351368                        ENDIF 
    352369                     END DO loop_t_count 
    353370                  ENDIF 
    354                   IF ( lds3d ) THEN 
     371                  IF ( ldvar2 ) THEN 
    355372                     loop_s_count : DO ij = 1,inpfiles(jj)%nlev 
    356373                        IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) & 
     
    358375                        IF ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. & 
    359376                           & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN 
    360                            is3dt0 = is3dt0 + 1 
     377                           ivar2t0 = ivar2t0 + 1 
    361378                        ENDIF 
    362379                     END DO loop_s_count 
     
    367384                     IF ( ( ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. & 
    368385                        &     ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. & 
    369                         &     ldt3d ) .OR. & 
     386                        &     ldvar1 ) .OR. & 
    370387                        & ( ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. & 
    371388                        &     ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. & 
    372                         &     lds3d ) ) THEN 
     389                        &     ldvar2 ) ) THEN 
    373390                        ip3dt = ip3dt + 1 
    374391                        llvalprof = .TRUE. 
     
    384401 
    385402      END DO prof_files 
    386        
     403 
    387404      !----------------------------------------------------------------------- 
    388405      ! Get the time ordered indices of the input data 
     
    425442         &               zdat,     & 
    426443         &               iindx   ) 
    427        
     444 
    428445      iv3dt(:) = -1 
    429446      IF (ldsatt) THEN 
     
    431448         iv3dt(2) = ip3dt 
    432449      ELSE 
    433          iv3dt(1) = it3dt0 
    434          iv3dt(2) = is3dt0 
     450         iv3dt(1) = ivar1t0 
     451         iv3dt(2) = ivar2t0 
    435452      ENDIF 
    436453      CALL obs_prof_alloc( profdata, kvars, kextr, iprof, iv3dt, & 
    437454         &                 kstp, jpi, jpj, jpk ) 
    438        
     455 
    439456      ! * Read obs/positions, QC, all variable and assign to profdata 
    440457 
    441458      profdata%nprof     = 0 
    442459      profdata%nvprot(:) = 0 
    443  
     460      profdata%cvars(:)  = clvars(:) 
    444461      iprof = 0 
    445462 
    446463      ip3dt = 0 
    447       it3dt = 0 
    448       is3dt = 0 
    449       itypt   (:) = 0 
    450       ityptmpp(:) = 0 
    451        
    452       ityps   (:) = 0 
    453       itypsmpp(:) = 0 
    454        
    455       ioserrcount = 0       
     464      ivar1t = 0 
     465      ivar2t = 0 
     466      itypvar1   (:) = 0 
     467      itypvar1mpp(:) = 0 
     468 
     469      itypvar2   (:) = 0 
     470      itypvar2mpp(:) = 0 
     471 
     472      ioserrcount = 0 
    456473      DO jk = 1, iproftot 
    457           
     474 
    458475         jj = ifileidx(iindx(jk)) 
    459476         ji = iprofidx(iindx(jk)) 
     
    465482         IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND.  & 
    466483            & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN 
    467              
     484 
    468485            IF ( nproc == 0 ) THEN 
    469486               IF ( inpfiles(jj)%iproc(ji,1) >  nproc ) CYCLE 
     
    471488               IF ( inpfiles(jj)%iproc(ji,1) /= nproc ) CYCLE 
    472489            ENDIF 
    473              
     490 
    474491            llvalprof = .FALSE. 
    475492 
     
    480497 
    481498            loop_prof : DO ij = 1, inpfiles(jj)%nlev 
    482                 
     499 
    483500               IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) & 
    484501                  & CYCLE 
    485                 
     502 
    486503               IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. & 
    487504                  & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN 
    488                    
     505 
    489506                  llvalprof = .TRUE.  
    490507                  EXIT loop_prof 
    491                    
     508 
    492509               ENDIF 
    493                 
     510 
    494511               IF ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. & 
    495512                  & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN 
    496                    
     513 
    497514                  llvalprof = .TRUE.  
    498515                  EXIT loop_prof 
    499                    
     516 
    500517               ENDIF 
    501                 
     518 
    502519            END DO loop_prof 
    503              
     520 
    504521            ! Set profile information 
    505              
     522 
    506523            IF ( llvalprof ) THEN 
    507                 
     524 
    508525               iprof = iprof + 1 
    509526 
     
    524541               profdata%nhou(iprof) = ihou 
    525542               profdata%nmin(iprof) = imin 
    526                 
     543 
    527544               ! Profile space coordinates 
    528545               profdata%rlam(iprof) = inpfiles(jj)%plam(ji) 
     
    532549               profdata%mi  (iprof,:) = inpfiles(jj)%iobsi(ji,1) 
    533550               profdata%mj  (iprof,:) = inpfiles(jj)%iobsj(ji,1) 
    534                 
     551 
    535552               ! Profile WMO number 
    536553               profdata%cwmo(iprof) = inpfiles(jj)%cdwmo(ji) 
    537                 
     554 
    538555               ! Instrument type 
    539556               READ( inpfiles(jj)%cdtyp(ji), '(I4)', IOSTAT = ios, ERR = 901 ) itype 
     
    543560                  itype = 0 
    544561               ENDIF 
    545                 
     562 
    546563               profdata%ntyp(iprof) = itype 
    547                 
     564 
    548565               ! QC stuff 
    549566 
     
    564581               profdata%nqc(iprof)  = 0 !TODO 
    565582 
    566                loop_p : DO ij = 1, inpfiles(jj)%nlev             
    567                    
     583               loop_p : DO ij = 1, inpfiles(jj)%nlev 
     584 
    568585                  IF ( inpfiles(jj)%pdep(ij,ji) >= 6000. ) & 
    569586                     & CYCLE 
     
    573590                     IF ( ( ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. & 
    574591                        &     ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. & 
    575                         &     ldt3d ) .OR. & 
     592                        &     ldvar1 ) .OR. & 
    576593                        & ( ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. & 
    577594                        &     ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. & 
    578                         &     lds3d ) ) THEN 
     595                        &     ldvar2 ) ) THEN 
    579596                        ip3dt = ip3dt + 1 
    580597                     ELSE 
    581598                        CYCLE 
    582599                     ENDIF 
    583                       
     600 
    584601                  ENDIF 
    585602 
    586603                  IF ( ( ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. & 
    587604                     &     ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. & 
    588                      &       ldt3d ) .OR. ldsatt ) THEN 
    589                       
     605                     &       ldvar1 ) .OR. ldsatt ) THEN 
     606 
    590607                     IF (ldsatt) THEN 
    591608 
    592                         it3dt = ip3dt 
     609                        ivar1t = ip3dt 
    593610 
    594611                     ELSE 
    595612 
    596                         it3dt = it3dt + 1 
    597                          
     613                        ivar1t = ivar1t + 1 
     614 
    598615                     ENDIF 
    599616 
    600                      ! Depth of T observation 
    601                      profdata%var(1)%vdep(it3dt) = & 
     617                     ! Depth of var1 observation 
     618                     profdata%var(1)%vdep(ivar1t) = & 
    602619                        &                inpfiles(jj)%pdep(ij,ji) 
    603                       
    604                      ! Depth of T observation QC 
    605                      profdata%var(1)%idqc(it3dt) = & 
     620 
     621                     ! Depth of var1 observation QC 
     622                     profdata%var(1)%idqc(ivar1t) = & 
    606623                        &                inpfiles(jj)%idqc(ij,ji) 
    607                       
    608                      ! Depth of T observation QC flags 
    609                      profdata%var(1)%idqcf(:,it3dt) = & 
     624 
     625                     ! Depth of var1 observation QC flags 
     626                     profdata%var(1)%idqcf(:,ivar1t) = & 
    610627                        &                inpfiles(jj)%idqcf(:,ij,ji) 
    611                       
     628 
    612629                     ! Profile index 
    613                      profdata%var(1)%nvpidx(it3dt) = iprof 
    614                       
     630                     profdata%var(1)%nvpidx(ivar1t) = iprof 
     631 
    615632                     ! Vertical index in original profile 
    616                      profdata%var(1)%nvlidx(it3dt) = ij 
    617  
    618                      ! Profile potential T value 
     633                     profdata%var(1)%nvlidx(ivar1t) = ij 
     634 
     635                     ! Profile potential var1 value 
    619636                     IF ( ( inpfiles(jj)%ivlqc(ij,ji,1) <= 2 ) .AND. & 
    620637                        & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN 
    621                         profdata%var(1)%vobs(it3dt) = & 
     638                        profdata%var(1)%vobs(ivar1t) = & 
    622639                           &                inpfiles(jj)%pob(ij,ji,1) 
    623640                        IF ( ldmod ) THEN 
    624                            profdata%var(1)%vmod(it3dt) = & 
     641                           profdata%var(1)%vmod(ivar1t) = & 
    625642                              &                inpfiles(jj)%padd(ij,ji,1,1) 
    626643                        ENDIF 
    627                         ! Count number of profile T data as function of type 
    628                         itypt( profdata%ntyp(iprof) + 1 ) = & 
    629                            & itypt( profdata%ntyp(iprof) + 1 ) + 1 
     644                        ! Count number of profile var1 data as function of type 
     645                        itypvar1( profdata%ntyp(iprof) + 1 ) = & 
     646                           & itypvar1( profdata%ntyp(iprof) + 1 ) + 1 
    630647                     ELSE 
    631                         profdata%var(1)%vobs(it3dt) = fbrmdi 
     648                        profdata%var(1)%vobs(ivar1t) = fbrmdi 
    632649                     ENDIF 
    633650 
    634                      ! Profile T qc 
    635                      profdata%var(1)%nvqc(it3dt) = & 
     651                     ! Profile var1 qc 
     652                     profdata%var(1)%nvqc(ivar1t) = & 
    636653                        & inpfiles(jj)%ivlqc(ij,ji,1) 
    637654 
    638                      ! Profile T qc flags 
    639                      profdata%var(1)%nvqcf(:,it3dt) = & 
     655                     ! Profile var1 qc flags 
     656                     profdata%var(1)%nvqcf(:,ivar1t) = & 
    640657                        & inpfiles(jj)%ivlqcf(:,ij,ji,1) 
    641658 
    642659                     ! Profile insitu T value 
    643                      profdata%var(1)%vext(it3dt,1) = & 
     660                     profdata%var(1)%vext(ivar1t,1) = & 
    644661                        &                inpfiles(jj)%pext(ij,ji,1) 
    645                       
     662 
    646663                  ENDIF 
    647                    
     664 
    648665                  IF ( ( ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. & 
    649666                     &   ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) .AND. & 
    650                      &   lds3d ) .OR. ldsatt ) THEN 
    651                       
     667                     &   ldvar2 ) .OR. ldsatt ) THEN 
     668 
    652669                     IF (ldsatt) THEN 
    653670 
    654                         is3dt = ip3dt 
     671                        ivar2t = ip3dt 
    655672 
    656673                     ELSE 
    657674 
    658                         is3dt = is3dt + 1 
    659                          
     675                        ivar2t = ivar2t + 1 
     676 
    660677                     ENDIF 
    661678 
    662                      ! Depth of S observation 
    663                      profdata%var(2)%vdep(is3dt) = & 
     679                     ! Depth of var2 observation 
     680                     profdata%var(2)%vdep(ivar2t) = & 
    664681                        &                inpfiles(jj)%pdep(ij,ji) 
    665                       
    666                      ! Depth of S observation QC 
    667                      profdata%var(2)%idqc(is3dt) = & 
     682 
     683                     ! Depth of var2 observation QC 
     684                     profdata%var(2)%idqc(ivar2t) = & 
    668685                        &                inpfiles(jj)%idqc(ij,ji) 
    669                       
    670                      ! Depth of S observation QC flags 
    671                      profdata%var(2)%idqcf(:,is3dt) = & 
     686 
     687                     ! Depth of var2 observation QC flags 
     688                     profdata%var(2)%idqcf(:,ivar2t) = & 
    672689                        &                inpfiles(jj)%idqcf(:,ij,ji) 
    673                       
     690 
    674691                     ! Profile index 
    675                      profdata%var(2)%nvpidx(is3dt) = iprof 
    676                       
     692                     profdata%var(2)%nvpidx(ivar2t) = iprof 
     693 
    677694                     ! Vertical index in original profile 
    678                      profdata%var(2)%nvlidx(is3dt) = ij 
    679  
    680                      ! Profile S value 
     695                     profdata%var(2)%nvlidx(ivar2t) = ij 
     696 
     697                     ! Profile var2 value 
    681698                     IF ( ( inpfiles(jj)%ivlqc(ij,ji,2) <= 2 ) .AND. & 
    682699                        & ( inpfiles(jj)%idqc(ij,ji) <= 2 ) ) THEN 
    683                         profdata%var(2)%vobs(is3dt) = & 
     700                        profdata%var(2)%vobs(ivar2t) = & 
    684701                           &                inpfiles(jj)%pob(ij,ji,2) 
    685702                        IF ( ldmod ) THEN 
    686                            profdata%var(2)%vmod(is3dt) = & 
     703                           profdata%var(2)%vmod(ivar2t) = & 
    687704                              &                inpfiles(jj)%padd(ij,ji,1,2) 
    688705                        ENDIF 
    689                         ! Count number of profile S data as function of type 
    690                         ityps( profdata%ntyp(iprof) + 1 ) = & 
    691                            & ityps( profdata%ntyp(iprof) + 1 ) + 1 
     706                        ! Count number of profile var2 data as function of type 
     707                        itypvar2( profdata%ntyp(iprof) + 1 ) = & 
     708                           & itypvar2( profdata%ntyp(iprof) + 1 ) + 1 
    692709                     ELSE 
    693                         profdata%var(2)%vobs(is3dt) = fbrmdi 
     710                        profdata%var(2)%vobs(ivar2t) = fbrmdi 
    694711                     ENDIF 
    695                       
    696                      ! Profile S qc 
    697                      profdata%var(2)%nvqc(is3dt) = & 
     712 
     713                     ! Profile var2 qc 
     714                     profdata%var(2)%nvqc(ivar2t) = & 
    698715                        & inpfiles(jj)%ivlqc(ij,ji,2) 
    699716 
    700                      ! Profile S qc flags 
    701                      profdata%var(2)%nvqcf(:,is3dt) = & 
     717                     ! Profile var2 qc flags 
     718                     profdata%var(2)%nvqcf(:,ivar2t) = & 
    702719                        & inpfiles(jj)%ivlqcf(:,ij,ji,2) 
    703720 
    704721                  ENDIF 
    705              
     722 
    706723               END DO loop_p 
    707724 
     
    715732      ! Sum up over processors 
    716733      !----------------------------------------------------------------------- 
    717        
    718       CALL obs_mpp_sum_integer ( it3dt0, it3dtmpp ) 
    719       CALL obs_mpp_sum_integer ( is3dt0, is3dtmpp ) 
    720       CALL obs_mpp_sum_integer ( ip3dt, ip3dtmpp ) 
    721        
    722       CALL obs_mpp_sum_integers( itypt, ityptmpp, ntyp1770 + 1 ) 
    723       CALL obs_mpp_sum_integers( ityps, itypsmpp, ntyp1770 + 1 ) 
    724        
     734 
     735      CALL obs_mpp_sum_integer ( ivar1t0, ivar1tmpp ) 
     736      CALL obs_mpp_sum_integer ( ivar2t0, ivar2tmpp ) 
     737      CALL obs_mpp_sum_integer ( ip3dt,   ip3dtmpp ) 
     738 
     739      CALL obs_mpp_sum_integers( itypvar1, itypvar1mpp, ntyp1770 + 1 ) 
     740      CALL obs_mpp_sum_integers( itypvar2, itypvar2mpp, ntyp1770 + 1 ) 
     741 
    725742      !----------------------------------------------------------------------- 
    726743      ! Output number of observations. 
     
    728745      IF(lwp) THEN 
    729746         WRITE(numout,*)  
    730          WRITE(numout,'(1X,A)') 'Profile data' 
     747         WRITE(numout,'(A)') ' Profile data' 
    731748         WRITE(numout,'(1X,A)') '------------' 
    732749         WRITE(numout,*)  
    733          WRITE(numout,'(1X,A)') 'Profile T data' 
    734          WRITE(numout,'(1X,A)') '--------------' 
     750         WRITE(numout,'(1X,A)') 'Profile data, '//TRIM( profdata%cvars(1) ) 
     751         WRITE(numout,'(1X,A)') '------------------------' 
    735752         DO ji = 0, ntyp1770 
    736             IF ( ityptmpp(ji+1) > 0 ) THEN 
     753            IF ( itypvar1mpp(ji+1) > 0 ) THEN 
    737754               WRITE(numout,'(1X,A3,1X,A48,A3,I8)') ctypshort(ji), & 
    738755                  & cwmonam1770(ji)(1:52),' = ', & 
    739                   & ityptmpp(ji+1) 
     756                  & itypvar1mpp(ji+1) 
    740757            ENDIF 
    741758         END DO 
     
    743760            & '---------------------------------------------------------------' 
    744761         WRITE(numout,'(1X,A55,I8)') & 
    745             & 'Total profile T data                                 = ',& 
    746             & it3dtmpp 
     762            & 'Total profile data for variable '//TRIM( profdata%cvars(1) )// & 
     763            & '             = ', ivar1tmpp 
    747764         WRITE(numout,'(1X,A)') & 
    748765            & '---------------------------------------------------------------' 
    749766         WRITE(numout,*)  
    750          WRITE(numout,'(1X,A)') 'Profile S data' 
    751          WRITE(numout,'(1X,A)') '--------------' 
     767         WRITE(numout,'(1X,A)') 'Profile data, '//TRIM( profdata%cvars(2) ) 
     768         WRITE(numout,'(1X,A)') '------------------------' 
    752769         DO ji = 0, ntyp1770 
    753             IF ( itypsmpp(ji+1) > 0 ) THEN 
     770            IF ( itypvar2mpp(ji+1) > 0 ) THEN 
    754771               WRITE(numout,'(1X,A3,1X,A48,A3,I8)') ctypshort(ji), & 
    755772                  & cwmonam1770(ji)(1:52),' = ', & 
    756                   & itypsmpp(ji+1) 
     773                  & itypvar2mpp(ji+1) 
    757774            ENDIF 
    758775         END DO 
     
    760777            & '---------------------------------------------------------------' 
    761778         WRITE(numout,'(1X,A55,I8)') & 
    762             & 'Total profile S data                                 = ',& 
    763             & is3dtmpp 
     779            & 'Total profile data for variable '//TRIM( profdata%cvars(2) )// & 
     780            & '             = ', ivar2tmpp 
    764781         WRITE(numout,'(1X,A)') & 
    765782            & '---------------------------------------------------------------' 
    766783         WRITE(numout,*)  
    767784      ENDIF 
    768        
     785 
    769786      IF (ldsatt) THEN 
    770787         profdata%nvprot(1)    = ip3dt 
     
    773790         profdata%nvprotmpp(2) = ip3dtmpp 
    774791      ELSE 
    775          profdata%nvprot(1)    = it3dt 
    776          profdata%nvprot(2)    = is3dt 
    777          profdata%nvprotmpp(1) = it3dtmpp 
    778          profdata%nvprotmpp(2) = is3dtmpp 
     792         profdata%nvprot(1)    = ivar1t 
     793         profdata%nvprot(2)    = ivar2t 
     794         profdata%nvprotmpp(1) = ivar1tmpp 
     795         profdata%nvprotmpp(2) = ivar2tmpp 
    779796      ENDIF 
    780797      profdata%nprof        = iprof 
     
    783800      ! Model level search 
    784801      !----------------------------------------------------------------------- 
    785       IF ( ldt3d ) THEN 
     802      IF ( ldvar1 ) THEN 
    786803         CALL obs_level_search( jpk, gdept_1d, & 
    787804            & profdata%nvprot(1), profdata%var(1)%vdep, & 
    788805            & profdata%var(1)%mvk ) 
    789806      ENDIF 
    790       IF ( lds3d ) THEN 
     807      IF ( ldvar2 ) THEN 
    791808         CALL obs_level_search( jpk, gdept_1d, & 
    792809            & profdata%nvprot(2), profdata%var(2)%vdep, & 
    793810            & profdata%var(2)%mvk ) 
    794811      ENDIF 
    795        
     812 
    796813      !----------------------------------------------------------------------- 
    797814      ! Set model equivalent to 99999 
     
    805822      ! Deallocate temporary data 
    806823      !----------------------------------------------------------------------- 
    807       DEALLOCATE( ifileidx, iprofidx, zdat ) 
     824      DEALLOCATE( ifileidx, iprofidx, zdat, clvars ) 
    808825 
    809826      !----------------------------------------------------------------------- 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_read_surf.F90

    r5659 r5682  
    99   !!---------------------------------------------------------------------- 
    1010 
    11    !! * Modules used    
     11   !! * Modules used 
    1212   USE par_kind                 ! Precision variables 
    1313   USE in_out_manager           ! I/O manager 
     
    2020   USE obs_surf_def             ! Surface observation definitions 
    2121   USE obs_types                ! Observation type definitions 
     22   USE obs_fbm                  ! Feedback routines 
    2223   USE netcdf                   ! NetCDF library 
    2324 
     
    2829 
    2930   PUBLIC obs_rea_surf      ! Read the surface observations from the point data 
    30     
     31 
    3132   !!---------------------------------------------------------------------- 
    3233   !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     
    3738CONTAINS 
    3839 
    39    SUBROUTINE obs_rea_surf( surfdata, knumfiles, cfilenames, & 
     40   SUBROUTINE obs_rea_surf( surfdata, knumfiles, cdfilenames, & 
    4041      &                     kvars, kextr, kstp, ddobsini, ddobsend, & 
    41       &                     ldignmis, ldmod ) 
     42      &                     ldignmis, ldmod, ldnightav ) 
    4243      !!--------------------------------------------------------------------- 
    4344      !! 
     
    5960 
    6061      !! * Arguments 
    61       TYPE(obs_surf), INTENT(INOUT) :: surfdata   ! Surface data to be read 
    62       INTEGER, INTENT(IN) :: knumfiles    ! Number of corio format files to read in 
    63       CHARACTER(LEN=128), INTENT(IN) :: cfilenames(knumfiles) ! File names to read in 
     62      TYPE(obs_surf), INTENT(INOUT) :: & 
     63         & surfdata                     ! Surface data to be read 
     64      INTEGER, INTENT(IN) :: knumfiles  ! Number of corio format files to read 
     65      CHARACTER(LEN=128), INTENT(IN) :: & 
     66         & cdfilenames(knumfiles)       ! File names to read in 
    6467      INTEGER, INTENT(IN) :: kvars      ! Number of variables in surfdata 
    65       INTEGER, INTENT(IN) :: kextr      ! Number of extra fields for each var in surfdata 
     68      INTEGER, INTENT(IN) :: kextr      ! Number of extra fields for each var 
    6669      INTEGER, INTENT(IN) :: kstp       ! Ocean time-step index 
    6770      LOGICAL, INTENT(IN) :: ldignmis   ! Ignore missing files 
    6871      LOGICAL, INTENT(IN) :: ldmod      ! Initialize model from input data 
    69       REAL(KIND=dp), INTENT(IN) :: ddobsini   ! Obs. ini time in YYYYMMDD.HHMMSS 
    70       REAL(KIND=dp), INTENT(IN) :: ddobsend   ! Obs. end time in YYYYMMDD.HHMMSS 
    71           
     72      LOGICAL, INTENT(IN) :: ldnightav  ! Observations represent a night-time average 
     73      REAL(dp), INTENT(IN) :: ddobsini   ! Obs. ini time in YYYYMMDD.HHMMSS 
     74      REAL(dp), INTENT(IN) :: ddobsend   ! Obs. end time in YYYYMMDD.HHMMSS 
     75 
    7276      !! * Local declarations 
    7377      CHARACTER(LEN=11), PARAMETER :: cpname='obs_rea_surf' 
     78      CHARACTER(len=8) :: clrefdate 
     79      CHARACTER(len=6), DIMENSION(:), ALLOCATABLE :: clvars 
    7480      INTEGER :: ji 
    7581      INTEGER :: jj 
     
    8591      INTEGER :: imin 
    8692      INTEGER :: isec 
     93      INTEGER :: itype 
     94      INTEGER :: iobsmpp 
     95      INTEGER :: iobs 
     96      INTEGER :: iobstot 
     97      INTEGER :: ios 
     98      INTEGER :: ioserrcount 
     99      INTEGER, PARAMETER :: jpsurfmaxtype = 1024 
    87100      INTEGER, DIMENSION(knumfiles) :: irefdate 
    88       INTEGER :: iobsmpp 
    89       INTEGER, PARAMETER :: isurfmaxtype = 1024 
    90       INTEGER, DIMENSION(0:isurfmaxtype) :: & 
     101      INTEGER, DIMENSION(jpsurfmaxtype+1) :: & 
    91102         & ityp, & 
    92103         & itypmpp 
     
    98109         & ifileidx, & 
    99110         & isurfidx 
    100       INTEGER :: itype 
    101111      REAL(wp), DIMENSION(:), ALLOCATABLE :: & 
    102112         & zphi, & 
    103113         & zlam 
    104       real(wp), DIMENSION(:), ALLOCATABLE :: & 
     114      REAL(wp), DIMENSION(:), ALLOCATABLE :: & 
    105115         & zdat 
     116      REAL(wp), DIMENSION(knumfiles) :: & 
     117         & djulini, & 
     118         & djulend 
    106119      LOGICAL :: llvalprof 
    107120      TYPE(obfbdata), POINTER, DIMENSION(:) :: & 
    108121         & inpfiles 
    109       real(wp), DIMENSION(knumfiles) :: & 
    110          & djulini, & 
    111          & djulend 
    112       INTEGER :: iobs 
    113       INTEGER :: iobstot 
    114       INTEGER :: ios 
    115       INTEGER :: ioserrcount 
    116       CHARACTER(len=8) :: cl_refdate 
    117     
     122 
    118123      ! Local initialization 
    119124      iobs = 0 
    120   
    121       !----------------------------------------------------------------------- 
    122       ! Check data the model part is just with feedback data files 
    123       !----------------------------------------------------------------------- 
    124       IF ( ldmod .AND. ( kformat /= 0 ) ) THEN 
    125          CALL ctl_stop( 'Model can only be read from feedback data' ) 
    126          RETURN 
    127       ENDIF 
    128125 
    129126      !----------------------------------------------------------------------- 
    130127      ! Count the number of files needed and allocate the obfbdata type 
    131128      !----------------------------------------------------------------------- 
    132        
     129 
    133130      inobf = knumfiles 
    134        
     131 
    135132      ALLOCATE( inpfiles(inobf) ) 
    136133 
    137134      surf_files : DO jj = 1, inobf 
    138135 
    139          CALL init_obfbdata( inpfiles(jj) ) 
    140            
    141136         !--------------------------------------------------------------------- 
    142137         ! Prints 
     
    145140            WRITE(numout,*) 
    146141            WRITE(numout,*) ' obs_rea_surf : Reading from file = ', & 
    147                & TRIM( TRIM( cfilenames(jj) ) ) 
     142               & TRIM( TRIM( cdfilenames(jj) ) ) 
    148143            WRITE(numout,*) ' ~~~~~~~~~~~' 
    149144            WRITE(numout,*) 
     
    153148         !  Initialization: Open file and get dimensions only 
    154149         !--------------------------------------------------------------------- 
    155           
    156          iflag = nf90_open( TRIM( TRIM( cfilenames(jj) ) ), nf90_nowrite, & 
     150 
     151         iflag = nf90_open( TRIM( TRIM( cdfilenames(jj) ) ), nf90_nowrite, & 
    157152            &                      i_file_id ) 
    158           
     153 
    159154         IF ( iflag /= nf90_noerr ) THEN 
    160155 
    161156            IF ( ldignmis ) THEN 
    162157               inpfiles(jj)%nobs = 0 
    163                CALL ctl_warn( 'File ' // TRIM( TRIM( cfilenames(jj) ) ) // & 
     158               CALL ctl_warn( 'File ' // TRIM( TRIM( cdfilenames(jj) ) ) // & 
    164159                  &           ' not found' ) 
    165160            ELSE  
    166                CALL ctl_stop( 'File ' // TRIM( TRIM( cfilenames(jj) ) ) // & 
     161               CALL ctl_stop( 'File ' // TRIM( TRIM( cdfilenames(jj) ) ) // & 
    167162                  &           ' not found' ) 
    168163            ENDIF 
    169164 
    170165         ELSE  
    171              
    172             !------------------------------------------------------------------ 
    173             !  Close the file since it is opened in read_proffile 
    174             !------------------------------------------------------------------ 
    175              
     166 
     167            !------------------------------------------------------------------ 
     168            !  Close the file since it is opened in read_obfbdata 
     169            !------------------------------------------------------------------ 
     170 
    176171            iflag = nf90_close( i_file_id ) 
    177172 
     
    179174            !  Read the profile file into inpfiles 
    180175            !------------------------------------------------------------------ 
    181             IF(lwp) THEN 
    182                WRITE(numout,*) 
    183                WRITE(numout,*)'Reading from feedback file :', & 
    184                   &           TRIM( cfilenames(jj) ) 
    185             ENDIF 
    186             CALL read_obfbdata( TRIM( cfilenames(jj) ), inpfiles(jj), & 
     176            CALL init_obfbdata( inpfiles(jj) ) 
     177            CALL read_obfbdata( TRIM( cdfilenames(jj) ), inpfiles(jj), & 
    187178               &                ldgrid = .TRUE. ) 
     179 
    188180            IF ( ldmod .AND. ( inpfiles(jj)%nadd == 0 ) ) THEN 
    189181               CALL ctl_stop( 'Model not in input data' ) 
     
    191183            ENDIF 
    192184 
     185            IF ( jj == 1 ) THEN 
     186               ALLOCATE( clvars( inpfiles(jj)%nvar ) ) 
     187               DO ji = 1, inpfiles(jj)%nvar 
     188                 clvars(ji) = inpfiles(jj)%cname(ji) 
     189               END DO 
     190            ELSE 
     191               DO ji = 1, inpfiles(jj)%nvar 
     192                  IF ( inpfiles(jj)%cname(ji) /= clvars(ji) ) THEN 
     193                     CALL ctl_stop( 'Feedback file variables not consistent', & 
     194                        &           ' with previous files for this type' ) 
     195                  ENDIF 
     196               END DO 
     197            ENDIF 
     198 
    193199            !------------------------------------------------------------------ 
    194200            !  Change longitude (-180,180) 
    195201            !------------------------------------------------------------------ 
    196202 
    197             DO ji = 1, inpfiles(jj)%nobs  
     203            DO ji = 1, inpfiles(jj)%nobs 
    198204 
    199205               IF ( inpfiles(jj)%plam(ji) < -180. ) & 
     
    208214            !  Calculate the date  (change eventually) 
    209215            !------------------------------------------------------------------ 
    210             cl_refdate=inpfiles(jj)%cdjuldref(1:8) 
    211             READ(cl_refdate,'(I8)') irefdate(jj) 
    212              
     216            clrefdate=inpfiles(jj)%cdjuldref(1:8) 
     217            READ(clrefdate,'(I8)') irefdate(jj) 
     218 
    213219            CALL ddatetoymdhms( ddobsini, iyea, imon, iday, ihou, imin, isec ) 
    214220            CALL greg2jul( isec, imin, ihou, iday, imon, iyea, djulini(jj), & 
     
    217223            CALL greg2jul( isec, imin, ihou, iday, imon, iyea, djulend(jj), & 
    218224               &           krefdate = irefdate(jj) ) 
     225 
     226            IF ( ldnightav ) THEN 
     227 
     228               IF ( lwp ) THEN 
     229                  WRITE(numout,*)'Resetting time of night-time averaged observations', & 
     230                     &             ' to the end of the day' 
     231               ENDIF 
     232 
     233               DO ji = 1, inpfiles(jj)%nobs 
     234                  !  for night-time averaged data force the time 
     235                  !  to be the last time-step of the day, but still within the day. 
     236                  IF ( inpfiles(jj)%ptim(ji) >= 0. ) THEN 
     237                     inpfiles(jj)%ptim(ji) = & 
     238                        & INT(inpfiles(jj)%ptim(ji)) + 0.9999 
     239                  ELSE 
     240                     inpfiles(jj)%ptim(ji) = & 
     241                        & INT(inpfiles(jj)%ptim(ji)) - 0.0001 
     242                  ENDIF 
     243               END DO 
     244            ENDIF 
     245 
    219246            IF ( inpfiles(jj)%nobs > 0 ) THEN 
    220247               inpfiles(jj)%iproc = -1 
     
    312339         &               zdat,     & 
    313340         &               iindx   ) 
    314        
     341 
    315342      CALL obs_surf_alloc( surfdata, iobs, kvars, kextr, kstp, jpi, jpj ) 
    316        
    317       ! * Read obs/positions, QC, all variable and assign to surfdata 
    318   
     343 
     344      ! Read obs/positions, QC, all variable and assign to surfdata 
     345 
    319346      iobs = 0 
     347 
     348      surfdata%cvars(:)  = clvars(:) 
    320349 
    321350      ityp   (:) = 0 
    322351      itypmpp(:) = 0 
    323        
     352 
    324353      ioserrcount = 0 
    325        
     354 
    326355      DO jk = 1, iobstot 
    327           
     356 
    328357         jj = ifileidx(iindx(jk)) 
    329358         ji = isurfidx(iindx(jk)) 
    330359         IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND.  & 
    331360            & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN 
    332              
     361 
    333362            IF ( nproc == 0 ) THEN 
    334363               IF ( inpfiles(jj)%iproc(ji,1) >  nproc ) CYCLE 
     
    336365               IF ( inpfiles(jj)%iproc(ji,1) /= nproc ) CYCLE 
    337366            ENDIF 
    338              
     367 
    339368            ! Set observation information 
    340              
     369 
    341370            IF ( ( inpfiles(jj)%ivlqc(1,ji,1) == 1 ) .OR. & 
    342371               & ( inpfiles(jj)%ivlqc(1,ji,1) == 2 ) ) THEN 
     
    360389               surfdata%nhou(iobs) = ihou 
    361390               surfdata%nmin(iobs) = imin 
    362                 
     391 
    363392               ! Surface space coordinates 
    364393               surfdata%rlam(iobs) = inpfiles(jj)%plam(ji) 
     
    368397               surfdata%mi  (iobs) = inpfiles(jj)%iobsi(ji,1) 
    369398               surfdata%mj  (iobs) = inpfiles(jj)%iobsj(ji,1) 
    370                 
     399 
    371400               ! Instrument type 
    372401               READ( inpfiles(jj)%cdtyp(ji), '(I4)', IOSTAT = ios, ERR = 901 ) itype 
    373402901            IF ( ios /= 0 ) THEN 
    374                   IF (ioserrcount == 0) CALL ctl_warn ( 'Problem converting an instrument type to integer. Setting type to zero' )  
     403                  IF (ioserrcount == 0) THEN 
     404                     CALL ctl_warn ( 'Problem converting an instrument type ', & 
     405                        &            'to integer. Setting type to zero' ) 
     406                  ENDIF 
    375407                  ioserrcount = ioserrcount + 1 
    376408                  itype = 0 
    377409               ENDIF 
    378410               surfdata%ntyp(iobs) = itype 
    379                IF ( itype < isurfmaxtype + 1 ) THEN 
     411               IF ( itype < jpsurfmaxtype + 1 ) THEN 
    380412                  ityp(itype+1) = ityp(itype+1) + 1 
    381413               ELSE 
    382                   IF(lwp)WRITE(numout,*)'WARNING:Increase isurfmaxtype in ',& 
     414                  IF(lwp)WRITE(numout,*)'WARNING:Increase jpsurfmaxtype in ',& 
    383415                     &                  cpname 
    384416               ENDIF 
     
    398430               IF ( ldmod ) THEN 
    399431                  surfdata%rmod(iobs,1) = inpfiles(jj)%padd(1,ji,1,1) 
    400                ELSE 
     432                  IF ( TRIM(surfdata%cvars(1)) == 'SLA' ) THEN 
     433                     surfdata%rext(iobs,1) = inpfiles(jj)%padd(1,ji,2,1) 
     434                     surfdata%rext(iobs,2) = inpfiles(jj)%pext(1,ji,1) 
     435                  ENDIF 
     436                ELSE 
    401437                  surfdata%rmod(iobs,1) = fbrmdi 
     438                  IF ( TRIM(surfdata%cvars(1)) == 'SLA' ) surfdata%rext(iobs,:) = fbrmdi 
    402439               ENDIF 
    403440            ENDIF 
     
    409446      ! Sum up over processors 
    410447      !----------------------------------------------------------------------- 
    411        
     448 
    412449      CALL obs_mpp_sum_integer( iobs, iobsmpp ) 
    413        
     450      CALL obs_mpp_sum_integers( ityp, itypmpp, jpsurfmaxtype + 1 ) 
     451 
    414452      !----------------------------------------------------------------------- 
    415453      ! Output number of observations. 
     
    418456 
    419457         WRITE(numout,*) 
    420          WRITE(numout,'(1X,A)')'Surface data types' 
     458         WRITE(numout,'(1X,A)')TRIM( surfdata%cvars(1) )//' data' 
    421459         WRITE(numout,'(1X,A)')'--------------' 
    422460         DO jj = 1,8 
     
    425463            ENDIF 
    426464         END DO 
    427          WRITE(numout,'(1X,A50)')'--------------------------------------------------' 
    428          WRITE(numout,'(1X,A40,I10)')'Total                                 = ',iobsmpp 
     465         WRITE(numout,'(1X,A)') & 
     466            & '---------------------------------------------------------------' 
     467         WRITE(numout,'(1X,A,I8)') & 
     468            & 'Total data for variable '//TRIM( surfdata%cvars(1) )// & 
     469            & '           = ', iobsmpp 
     470         WRITE(numout,'(1X,A)') & 
     471            & '---------------------------------------------------------------' 
    429472         WRITE(numout,*) 
    430473 
     
    434477      ! Deallocate temporary data 
    435478      !----------------------------------------------------------------------- 
    436       DEALLOCATE( ifileidx, isurfidx, zdat ) 
     479      DEALLOCATE( ifileidx, isurfidx, zdat, clvars ) 
    437480 
    438481      !----------------------------------------------------------------------- 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_readmdt.F90

    r3294 r5682  
    3131   PRIVATE 
    3232    
    33    PUBLIC   obs_rea_mdt     ! called by ? 
    34    PUBLIC   obs_offset_mdt  ! called by ? 
    35  
    36    INTEGER , PUBLIC ::   nmsshc    = 1         ! MDT correction scheme 
    37    REAL(wp), PUBLIC ::   mdtcorr   = 1.61_wp   ! User specified MDT correction 
    38    REAL(wp), PUBLIC ::   mdtcutoff = 65.0_wp   ! MDT cutoff for computed correction 
     33   PUBLIC   obs_rea_mdt     ! called by dia_obs_init 
     34   PUBLIC   obs_offset_mdt  ! called by obs_rea_mdt 
     35 
     36   INTEGER , PUBLIC :: nn_msshc    = 1         ! MDT correction scheme 
     37   REAL(wp), PUBLIC :: rn_mdtcorr   = 1.61_wp  ! User specified MDT correction 
     38   REAL(wp), PUBLIC :: rn_mdtcutoff = 65.0_wp  ! MDT cutoff for computed correction 
    3939 
    4040   !!---------------------------------------------------------------------- 
     
    4545CONTAINS 
    4646 
    47    SUBROUTINE obs_rea_mdt( kslano, sladata, k2dint ) 
     47   SUBROUTINE obs_rea_mdt( sladata, k2dint ) 
    4848      !!--------------------------------------------------------------------- 
    4949      !! 
     
    5858      USE iom 
    5959      ! 
    60       INTEGER                          , INTENT(IN)    ::   kslano    ! Number of SLA Products 
    61       TYPE(obs_surf), DIMENSION(kslano), INTENT(inout) ::   sladata   ! SLA data 
    62       INTEGER                          , INTENT(in)    ::   k2dint    ! ? 
     60      TYPE(obs_surf), INTENT(inout) ::   sladata   ! SLA data 
     61      INTEGER       , INTENT(in)    ::   k2dint    ! ? 
    6362      ! 
    6463      CHARACTER(LEN=12), PARAMETER ::   cpname  = 'obs_rea_mdt' 
    6564      CHARACTER(LEN=20), PARAMETER ::   mdtname = 'slaReferenceLevel.nc' 
    6665 
    67       INTEGER ::   jslano              ! Data set loop variable 
    6866      INTEGER ::   jobs                ! Obs loop variable 
    6967      INTEGER ::   jpimdt, jpjmdt      ! Number of grid point in lat/lon for the MDT 
     
    8886      IF(lwp)WRITE(numout,*) ' obs_rea_mdt : Read MDT for referencing altimeter anomalies' 
    8987      IF(lwp)WRITE(numout,*) ' ------------- ' 
     88      CALL FLUSH(numout) 
    9089 
    9190      CALL iom_open( mdtname, nummdt )       ! Open the file 
     
    109108 
    110109      ! Remove the offset between the MDT used with the sla and the model MDT 
    111       IF( nmsshc == 1 .OR. nmsshc == 2 )   CALL obs_offset_mdt( z_mdt, zfill ) 
     110      IF( nn_msshc == 1 .OR. nn_msshc == 2 )   CALL obs_offset_mdt( z_mdt, zfill ) 
    112111 
    113112      ! Intepolate the MDT already on the model grid at the observation point 
    114113   
    115       DO jslano = 1, kslano 
    116          ALLOCATE( & 
    117             & igrdi(2,2,sladata(jslano)%nsurf), & 
    118             & igrdj(2,2,sladata(jslano)%nsurf), & 
    119             & zglam(2,2,sladata(jslano)%nsurf), & 
    120             & zgphi(2,2,sladata(jslano)%nsurf), & 
    121             & zmask(2,2,sladata(jslano)%nsurf), & 
    122             & zmdtl(2,2,sladata(jslano)%nsurf)  & 
    123             & ) 
     114      ALLOCATE( & 
     115         & igrdi(2,2,sladata%nsurf), & 
     116         & igrdj(2,2,sladata%nsurf), & 
     117         & zglam(2,2,sladata%nsurf), & 
     118         & zgphi(2,2,sladata%nsurf), & 
     119         & zmask(2,2,sladata%nsurf), & 
     120         & zmdtl(2,2,sladata%nsurf)  & 
     121         & ) 
    124122          
    125          DO jobs = 1, sladata(jslano)%nsurf 
    126  
    127             igrdi(1,1,jobs) = sladata(jslano)%mi(jobs)-1 
    128             igrdj(1,1,jobs) = sladata(jslano)%mj(jobs)-1 
    129             igrdi(1,2,jobs) = sladata(jslano)%mi(jobs)-1 
    130             igrdj(1,2,jobs) = sladata(jslano)%mj(jobs) 
    131             igrdi(2,1,jobs) = sladata(jslano)%mi(jobs) 
    132             igrdj(2,1,jobs) = sladata(jslano)%mj(jobs)-1 
    133             igrdi(2,2,jobs) = sladata(jslano)%mi(jobs) 
    134             igrdj(2,2,jobs) = sladata(jslano)%mj(jobs) 
    135  
    136          END DO 
    137  
    138          CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, igrdi, igrdj, glamt  , zglam ) 
    139          CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, igrdi, igrdj, gphit  , zgphi ) 
    140          CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, igrdi, igrdj, mdtmask, zmask ) 
    141          CALL obs_int_comm_2d( 2, 2, sladata(jslano)%nsurf, igrdi, igrdj, z_mdt  , zmdtl ) 
    142  
    143          DO jobs = 1, sladata(jslano)%nsurf 
     123      DO jobs = 1, sladata%nsurf 
     124 
     125         igrdi(1,1,jobs) = sladata%mi(jobs)-1 
     126         igrdj(1,1,jobs) = sladata%mj(jobs)-1 
     127         igrdi(1,2,jobs) = sladata%mi(jobs)-1 
     128         igrdj(1,2,jobs) = sladata%mj(jobs) 
     129         igrdi(2,1,jobs) = sladata%mi(jobs) 
     130         igrdj(2,1,jobs) = sladata%mj(jobs)-1 
     131         igrdi(2,2,jobs) = sladata%mi(jobs) 
     132         igrdj(2,2,jobs) = sladata%mj(jobs) 
     133 
     134      END DO 
     135 
     136      CALL obs_int_comm_2d( 2, 2, sladata%nsurf, igrdi, igrdj, glamt  , zglam ) 
     137      CALL obs_int_comm_2d( 2, 2, sladata%nsurf, igrdi, igrdj, gphit  , zgphi ) 
     138      CALL obs_int_comm_2d( 2, 2, sladata%nsurf, igrdi, igrdj, mdtmask, zmask ) 
     139      CALL obs_int_comm_2d( 2, 2, sladata%nsurf, igrdi, igrdj, z_mdt  , zmdtl ) 
     140 
     141      DO jobs = 1, sladata%nsurf 
    144142             
    145             zlam = sladata(jslano)%rlam(jobs) 
    146             zphi = sladata(jslano)%rphi(jobs) 
    147  
    148             CALL obs_int_h2d_init( 1, 1, k2dint, zlam, zphi,         & 
    149                &                   zglam(:,:,jobs), zgphi(:,:,jobs), & 
    150                &                   zmask(:,:,jobs), zweig, zobsmask ) 
     143         zlam = sladata%rlam(jobs) 
     144         zphi = sladata%rphi(jobs) 
     145 
     146         CALL obs_int_h2d_init( 1, 1, k2dint, zlam, zphi,         & 
     147            &                   zglam(:,:,jobs), zgphi(:,:,jobs), & 
     148            &                   zmask(:,:,jobs), zweig, zobsmask ) 
    151149             
    152             CALL obs_int_h2d( 1, 1, zweig, zmdtl(:,:,jobs),  zext ) 
     150         CALL obs_int_h2d( 1, 1, zweig, zmdtl(:,:,jobs),  zext ) 
    153151  
    154             sladata(jslano)%rext(jobs,2) = zext(1) 
     152         sladata%rext(jobs,2) = zext(1) 
    155153 
    156154! mark any masked data with a QC flag 
    157             IF( zobsmask(1) == 0 )   sladata(jslano)%nqc(jobs) = 11 
     155         IF( zobsmask(1) == 0 )   sladata%nqc(jobs) = 11 
    158156 
    159157         END DO 
    160158          
    161          DEALLOCATE( & 
    162             & igrdi, & 
    163             & igrdj, & 
    164             & zglam, & 
    165             & zgphi, & 
    166             & zmask, & 
    167             & zmdtl  & 
    168             & ) 
    169  
    170       END DO 
     159      DEALLOCATE( & 
     160         & igrdi, & 
     161         & igrdj, & 
     162         & zglam, & 
     163         & zgphi, & 
     164         & zmask, & 
     165         & zmdtl  & 
     166         & ) 
    171167 
    172168      CALL wrk_dealloc(jpi,jpj,z_mdt,mdtmask)  
     169      IF(lwp)WRITE(numout,*) ' ------------- ' 
     170      CALL FLUSH(numout) 
    173171      ! 
    174172   END SUBROUTINE obs_rea_mdt 
     
    205203        DO jj = 1, jpj 
    206204           zpromsk(ji,jj) = tmask_i(ji,jj) 
    207            IF (    ( gphit(ji,jj) .GT.  mdtcutoff ) & 
    208               &.OR.( gphit(ji,jj) .LT. -mdtcutoff ) & 
     205           IF (    ( gphit(ji,jj) .GT.  rn_mdtcutoff ) & 
     206              &.OR.( gphit(ji,jj) .LT. -rn_mdtcutoff ) & 
    209207              &.OR.( mdt(ji,jj) .EQ. zfill ) ) & 
    210208              &        zpromsk(ji,jj) = 0.0 
     
    212210      END DO  
    213211 
    214       ! Compute MSSH mean over [0,360] x [-mdtcutoff,mdtcutoff] 
     212      ! Compute MSSH mean over [0,360] x [-rn_mdtcutoff,rn_mdtcutoff] 
    215213 
    216214      zarea = 0.0 
     
    240238      !  Correct spatial mean of the MSSH 
    241239 
    242       IF( nmsshc == 1 )   mdt(:,:) = mdt(:,:) - zcorr   
     240      IF( nn_msshc == 1 )   mdt(:,:) = mdt(:,:) - zcorr   
    243241 
    244242      ! User defined value : 1.6 m for the Rio MDT compared to ORCA2 MDT 
    245243 
    246       IF( nmsshc == 2 )   mdt(:,:) = mdt(:,:) - mdtcorr 
     244      IF( nn_msshc == 2 )   mdt(:,:) = mdt(:,:) - rn_mdtcorr 
    247245 
    248246      IF(lwp) THEN 
    249247         WRITE(numout,*) 
    250          WRITE(numout,*) ' obs_readmdt : mdtcutoff     = ', mdtcutoff 
     248         WRITE(numout,*) ' obs_readmdt : rn_mdtcutoff     = ', rn_mdtcutoff 
    251249         WRITE(numout,*) ' -----------   zcorr_mdt     = ', zcorr_mdt 
    252250         WRITE(numout,*) '               zcorr_bcketa  = ', zcorr_bcketa 
    253251         WRITE(numout,*) '               zcorr         = ', zcorr 
    254          WRITE(numout,*) '               nmsshc        = ', nmsshc 
     252         WRITE(numout,*) '               nn_msshc        = ', nn_msshc 
    255253      ENDIF 
    256254 
    257       IF ( nmsshc == 0 ) WRITE(numout,*) '           MSSH correction is not applied' 
    258       IF ( nmsshc == 1 ) WRITE(numout,*) '           MSSH correction is applied' 
    259       IF ( nmsshc == 2 ) WRITE(numout,*) '           User defined MSSH correction'  
     255      IF ( nn_msshc == 0 ) WRITE(numout,*) '           MSSH correction is not applied' 
     256      IF ( nn_msshc == 1 ) WRITE(numout,*) '           MSSH correction is applied' 
     257      IF ( nn_msshc == 2 ) WRITE(numout,*) '           User defined MSSH correction'  
    260258 
    261259      CALL wrk_dealloc( jpi,jpj, zpromsk ) 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_surf_def.F90

    r3651 r5682  
    6767         & ntyp           !: Type of surface observation product 
    6868 
     69      CHARACTER(len=6), POINTER, DIMENSION(:) :: & 
     70         & cvars          !: Variable names 
     71 
    6972      CHARACTER(LEN=8), POINTER, DIMENSION(:) :: & 
    7073         & cwmo           !: WMO indentifier 
     
    130133      !!* Local variables 
    131134      INTEGER :: ji 
     135      INTEGER :: jvar 
    132136 
    133137      ! Set bookkeeping variables 
     
    140144      surf%npi      = kpi 
    141145      surf%npj      = kpj 
     146 
     147      ! Allocate arrays of size number of variables 
     148 
     149      ALLOCATE( & 
     150         & surf%cvars(kvar)    & 
     151         & ) 
     152 
     153      DO jvar = 1, kvar 
     154         surf%cvars(jvar) = "NotSet" 
     155      END DO 
    142156       
    143157      ! Allocate arrays of number of surface data size 
     
    271285         & ) 
    272286 
     287      ! Dellocate arrays of size number of variables 
     288 
     289      DEALLOCATE( & 
     290         & surf%cvars     & 
     291         & ) 
     292 
    273293   END SUBROUTINE obs_surf_dealloc 
    274294 
     
    392412      ! Set book keeping variables which do not depend on number of obs. 
    393413 
    394       newsurf%nstp  = surf%nstp 
     414      newsurf%nstp     = surf%nstp 
     415      newsurf%cvars(:) = surf%cvars(:) 
    395416  
    396417      ! Deallocate temporary data 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_types.F90

    r2358 r5682  
    117117 
    118118         cwmonam1770(ji) = 'Not defined' 
    119          ctypshort(ji) = 'XBT' 
     119         ctypshort(ji) = '---' 
    120120 
    121121!         IF ( ji < 1000 ) THEN 
  • branches/2015/dev_r5072_UKMO2_OBS_simplification/NEMOGCM/NEMO/OPA_SRC/OBS/obs_write.F90

    r5659 r5682  
    5555CONTAINS 
    5656 
    57    SUBROUTINE obs_wri_prof( cobstype, profdata, padd, pext ) 
     57   SUBROUTINE obs_wri_prof( profdata, k2dint, padd, pext ) 
    5858      !!----------------------------------------------------------------------- 
    5959      !! 
     
    7676      !!----------------------------------------------------------------------- 
    7777 
    78       !! * Modules used 
    79  
    8078      !! * Arguments 
    81       CHARACTER(LEN=*), INTENT(IN) :: cobstype        ! Prefix for output files 
    8279      TYPE(obs_prof), INTENT(INOUT) :: profdata      ! Full set of profile data 
     80      INTEGER, INTENT(IN)        :: k2dint           ! Horizontal interpolation method 
    8381      TYPE(obswriinfo), OPTIONAL :: padd             ! Additional info for each variable 
    8482      TYPE(obswriinfo), OPTIONAL :: pext             ! Extra info 
    85        
     83 
    8684      !! * Local declarations 
    8785      TYPE(obfbdata) :: fbdata 
    88       CHARACTER(LEN=40) :: cfname 
     86      CHARACTER(LEN=40) :: clfname 
     87      CHARACTER(LEN=6) :: clfiletype 
    8988      INTEGER :: ilevel 
    9089      INTEGER :: jvar 
     
    9493      INTEGER :: ja 
    9594      INTEGER :: je 
     95      INTEGER :: iadd 
     96      INTEGER :: iext 
    9697      REAL(wp) :: zpres 
    97       INTEGER :: nadd 
    98       INTEGER :: next 
     98      REAL(wp), DIMENSION(:), ALLOCATABLE :: & 
     99         & zu, & 
     100         & zv 
    99101 
    100102      IF ( PRESENT( padd ) ) THEN 
    101          nadd = padd%inum 
     103         iadd = padd%inum 
    102104      ELSE 
    103          nadd = 0 
     105         iadd = 0 
    104106      ENDIF 
    105107 
    106108      IF ( PRESENT( pext ) ) THEN 
    107          next = pext%inum 
     109         iext = pext%inum 
    108110      ELSE 
    109          next = 0 
    110       ENDIF 
    111        
     111         iext = 0 
     112      ENDIF 
     113 
    112114      CALL init_obfbdata( fbdata ) 
    113115 
     
    118120      END DO 
    119121 
    120       SELECT CASE ( TRIM(cobstype) ) 
    121       CASE('prof') 
    122  
     122      SELECT CASE ( TRIM(profdata%cvars(1)) ) 
     123      CASE('POTM') 
     124 
     125         clfiletype='profb' 
    123126         CALL alloc_obfbdata( fbdata, 2, profdata%nprof, ilevel, & 
    124             &                 1 + nadd, 1 + next, .TRUE. ) 
    125          fbdata%cname(1)      = 'POTM' 
    126          fbdata%cname(2)      = 'PSAL' 
     127            &                 1 + iadd, 1 + iext, .TRUE. ) 
     128         fbdata%cname(1)      = profdata%cvars(1) 
     129         fbdata%cname(2)      = profdata%cvars(2) 
    127130         fbdata%coblong(1)    = 'Potential temperature' 
    128131         fbdata%coblong(2)    = 'Practical salinity' 
     
    137140         fbdata%caddunit(1,2) = 'PSU' 
    138141         fbdata%cgrid(:)      = 'T' 
    139          DO je = 1, next 
     142         DO je = 1, iext 
    140143            fbdata%cextname(1+je) = pext%cdname(je) 
    141144            fbdata%cextlong(1+je) = pext%cdlong(je,1) 
    142145            fbdata%cextunit(1+je) = pext%cdunit(je,1) 
    143146         END DO 
    144          DO ja = 1, nadd 
     147         DO ja = 1, iadd 
    145148            fbdata%caddname(1+ja) = padd%cdname(ja) 
    146149            DO jvar = 1, 2 
     
    149152            END DO 
    150153         END DO 
    151        
    152       CASE('vel') 
    153        
     154 
     155      CASE('UVEL') 
     156 
     157         clfiletype='velfb' 
    154158         CALL alloc_obfbdata( fbdata, 2, profdata%nprof, ilevel, 2, 0, .TRUE. ) 
    155          fbdata%cname(1)      = 'UVEL' 
    156          fbdata%cname(2)      = 'VVEL' 
     159         fbdata%cname(1)      = profdata%cvars(1) 
     160         fbdata%cname(2)      = profdata%cvars(2) 
    157161         fbdata%coblong(1)    = 'Zonal velocity' 
    158162         fbdata%coblong(2)    = 'Meridional velocity' 
    159163         fbdata%cobunit(1)    = 'm/s' 
    160164         fbdata%cobunit(2)    = 'm/s' 
    161          DO je = 1, next 
     165         DO je = 1, iext 
    162166            fbdata%cextname(je) = pext%cdname(je) 
    163167            fbdata%cextlong(je) = pext%cdlong(je,1) 
     
    175179         fbdata%cgrid(1)      = 'U'  
    176180         fbdata%cgrid(2)      = 'V' 
    177          DO ja = 1, nadd 
     181         DO ja = 1, iadd 
    178182            fbdata%caddname(2+ja) = padd%cdname(ja) 
    179183            fbdata%caddlong(2+ja,1) = padd%cdlong(ja,1) 
     
    187191 
    188192      END SELECT 
    189           
     193 
    190194      fbdata%caddname(1)   = 'Hx' 
    191           
    192       WRITE(cfname, FMT="(A,'_fdbk_',I4.4,'.nc')") TRIM(cobstype), nproc 
     195 
     196      WRITE(clfname, FMT="(A,'_fdbk_',I4.4,'.nc')") TRIM(clfiletype), nproc 
    193197 
    194198      IF(lwp) THEN 
     
    196200         WRITE(numout,*)'obs_wri_prof :' 
    197201         WRITE(numout,*)'~~~~~~~~~~~~~' 
    198          WRITE(numout,*)'Writing profile feedback file : ',TRIM(cfname) 
     202         WRITE(numout,*)'Writing '//TRIM(clfiletype)//' feedback file : ',TRIM(clfname) 
    199203      ENDIF 
    200204 
     
    242246            DO jk = profdata%npvsta(jo,jvar), profdata%npvend(jo,jvar) 
    243247               ik = profdata%var(jvar)%nvlidx(jk) 
    244                IF ( TRIM(cobstype) == 'prof' ) THEN 
     248               IF ( TRIM(profdata%cvars(1)) == 'POTM' ) THEN 
    245249                  fbdata%padd(ik,jo,1,jvar) = profdata%var(jvar)%vmod(jk) 
    246                ELSE IF ( TRIM(cobstype) == 'vel' ) THEN 
     250               ELSE IF ( TRIM(profdata%cvars(1)) == 'UVEL' ) THEN 
    247251                  IF ( jvar == 1 ) THEN 
    248252                     fbdata%padd(ik,jo,1,jvar) = zu(jk) 
     
    265269               ENDIF 
    266270               fbdata%iobsk(ik,jo,jvar)  = profdata%var(jvar)%mvk(jk) 
    267                DO ja = 1, nadd 
     271               DO ja = 1, iadd 
    268272                  fbdata%padd(ik,jo,1+ja,jvar) = & 
    269273                     & profdata%var(jvar)%vext(jk,padd%ipoint(ja)) 
    270274               END DO 
    271                DO je = 1, next 
     275               DO je = 1, iext 
    272276                  fbdata%pext(ik,jo,1+je) = & 
    273277                     & profdata%var(jvar)%vext(jk,pext%ipoint(je)) 
     
    280284      END DO 
    281285 
    282       IF ( TRIM(cobstype) == 'prof' ) THEN 
     286      IF ( TRIM(profdata%cvars(1)) == 'POTM' ) THEN 
    283287         ! Convert insitu temperature to potential temperature using the model 
    284288         ! salinity if no potential temperature 
     
    301305         END DO 
    302306      ENDIF 
    303        
     307 
    304308      ! Write the obfbdata structure 
    305       CALL write_obfbdata( cfname, fbdata ) 
     309      CALL write_obfbdata( clfname, fbdata ) 
    306310 
    307311      ! Output some basic statistics 
     
    309313 
    310314      CALL dealloc_obfbdata( fbdata ) 
    311       
     315 
    312316   END SUBROUTINE obs_wri_prof 
    313317 
    314    SUBROUTINE obs_wri_surf( cobstype, surfdata, padd, pext ) 
     318   SUBROUTINE obs_wri_surf( surfdata, padd, pext ) 
    315319      !!----------------------------------------------------------------------- 
    316320      !! 
     
    332336 
    333337      !! * Arguments 
    334       CHARACTER(LEN=*), INTENT(IN) :: cobstype          ! Prefix for output files 
    335338      TYPE(obs_surf), INTENT(INOUT) :: surfdata         ! Full set of surface data 
    336339      TYPE(obswriinfo), OPTIONAL :: padd               ! Additional info for each variable 
     
    339342      !! * Local declarations 
    340343      TYPE(obfbdata) :: fbdata 
    341       CHARACTER(LEN=40) :: cfname         ! netCDF filename 
     344      CHARACTER(LEN=40) :: clfname         ! netCDF filename 
     345      CHARACTER(LEN=6)  :: clfiletype 
    342346      CHARACTER(LEN=12), PARAMETER :: cpname = 'obs_wri_surf' 
    343347      INTEGER :: jo 
    344348      INTEGER :: ja 
    345349      INTEGER :: je 
    346       INTEGER :: nadd 
    347       INTEGER :: next 
     350      INTEGER :: iadd 
     351      INTEGER :: iext 
    348352 
    349353      IF ( PRESENT( padd ) ) THEN 
    350          nadd = padd%inum 
     354         iadd = padd%inum 
    351355      ELSE 
    352          nadd = 0 
     356         iadd = 0 
    353357      ENDIF 
    354358 
    355359      IF ( PRESENT( pext ) ) THEN 
    356          next = pext%inum 
     360         iext = pext%inum 
    357361      ELSE 
    358          next = 0 
     362         iext = 0 
    359363      ENDIF 
    360364 
     
    362366 
    363367      CALL alloc_obfbdata( fbdata, 1, surfdata%nsurf, 1, & 
    364          &                 2 + nadd, 1 + next, .TRUE. ) 
    365  
    366       SELECT CASE ( TRIM(cobstype) ) 
    367       CASE('sla') 
    368  
    369          fbdata%cname(1)      = 'SLA' 
     368         &                 2 + iadd, 1 + iext, .TRUE. ) 
     369 
     370      SELECT CASE ( TRIM(surfdata%cvars(1)) ) 
     371      CASE('SLA') 
     372 
     373         clfiletype = 'slafb' 
     374         fbdata%cname(1)      = surfdata%cvars(1) 
    370375         fbdata%coblong(1)    = 'Sea level anomaly' 
    371376         fbdata%cobunit(1)    = 'Metres' 
     
    373378         fbdata%cextlong(1)   = 'Mean dynamic topography' 
    374379         fbdata%cextunit(1)   = 'Metres' 
    375          DO je = 1, next 
     380         DO je = 1, iext 
    376381            fbdata%cextname(je) = pext%cdname(je) 
    377382            fbdata%cextlong(je) = pext%cdlong(je,1) 
     
    384389         fbdata%caddunit(2,1) = 'Metres' 
    385390         fbdata%cgrid(1)      = 'T' 
    386          DO ja = 1, nadd 
     391         DO ja = 1, iadd 
    387392            fbdata%caddname(2+ja) = padd%cdname(ja) 
    388393            fbdata%caddlong(2+ja,1) = padd%cdlong(ja,1) 
     
    390395         END DO 
    391396 
    392       CASE('sst') 
    393  
    394          fbdata%cname(1)      = 'SST' 
     397      CASE('SST') 
     398 
     399         clfiletype = 'sstfb' 
     400         fbdata%cname(1)      = surfdata%cvars(1) 
    395401         fbdata%coblong(1)    = 'Sea surface temperature' 
    396402         fbdata%cobunit(1)    = 'Degree centigrade' 
    397          DO je = 1, next 
     403         DO je = 1, iext 
    398404            fbdata%cextname(je) = pext%cdname(je) 
    399405            fbdata%cextlong(je) = pext%cdlong(je,1) 
     
    403409         fbdata%caddunit(1,1) = 'Degree centigrade' 
    404410         fbdata%cgrid(1)      = 'T' 
    405          DO ja = 1, nadd 
     411         DO ja = 1, iadd 
    406412            fbdata%caddname(1+ja) = padd%cdname(ja) 
    407413            fbdata%caddlong(1+ja,1) = padd%cdlong(ja,1) 
     
    409415         END DO 
    410416 
    411       CASE('sss') 
    412  
    413          fbdata%cname(1)      = 'SSS' 
    414          fbdata%coblong(1)    = 'Sea surface salinity' 
    415          fbdata%cobunit(1)    = 'PSU' 
    416          DO je = 1, next 
     417      CASE('SEAICE') 
     418 
     419         clfiletype = 'sicfb' 
     420         fbdata%cname(1)      = surfdata%cvars(1) 
     421         fbdata%coblong(1)    = 'Sea ice' 
     422         fbdata%cobunit(1)    = 'Fraction' 
     423         DO je = 1, iext 
    417424            fbdata%cextname(je) = pext%cdname(je) 
    418425            fbdata%cextlong(je) = pext%cdlong(je,1) 
    419426            fbdata%cextunit(je) = pext%cdunit(je,1) 
    420427         END DO 
    421          fbdata%caddlong(1,1) = 'Model interpolated SSS' 
    422          fbdata%caddunit(1,1) = 'PSU' 
     428         fbdata%caddlong(1,1) = 'Model interpolated ICE' 
     429         fbdata%caddunit(1,1) = 'Fraction' 
    423430         fbdata%cgrid(1)      = 'T' 
    424          DO ja = 1, nadd 
     431         DO ja = 1, iadd 
    425432            fbdata%caddname(1+ja) = padd%cdname(ja) 
    426433            fbdata%caddlong(1+ja,1) = padd%cdlong(ja,1) 
     
    428435         END DO 
    429436 
    430       CASE('seaice') 
    431  
    432          fbdata%cname(1)      = 'SEAICE' 
    433          fbdata%coblong(1)    = 'Sea ice' 
    434          fbdata%cobunit(1)    = 'Fraction' 
    435          DO je = 1, next 
    436             fbdata%cextname(je) = pext%cdname(je) 
    437             fbdata%cextlong(je) = pext%cdlong(je,1) 
    438             fbdata%cextunit(je) = pext%cdunit(je,1) 
    439          END DO 
    440          fbdata%caddlong(1,1) = 'Model interpolated ICE' 
    441          fbdata%caddunit(1,1) = 'Fraction' 
    442          fbdata%cgrid(1)      = 'T' 
    443          DO ja = 1, nadd 
    444             fbdata%caddname(1+ja) = padd%cdname(ja) 
    445             fbdata%caddlong(1+ja,1) = padd%cdlong(ja,1) 
    446             fbdata%caddunit(1+ja,1) = padd%cdunit(ja,1) 
    447          END DO 
    448  
    449437      END SELECT 
    450438 
    451439      fbdata%caddname(1)   = 'Hx' 
    452440 
    453       WRITE(cfname, FMT="(A,'_fdbk_',I4.4,'.nc')") TRIM(cobstype), nproc 
     441      WRITE(clfname, FMT="(A,'_fdbk_',I4.4,'.nc')") TRIM(clfiletype), nproc 
    454442 
    455443      IF(lwp) THEN 
     
    457445         WRITE(numout,*)'obs_wri_surf :' 
    458446         WRITE(numout,*)'~~~~~~~~~~~~~' 
    459          WRITE(numout,*)'Writing surface feedback file : ',TRIM(cfname) 
     447         WRITE(numout,*)'Writing '//TRIM(surfdata%cvars(1))//' feedback file : ',TRIM(clfname) 
    460448      ENDIF 
    461449 
     
    498486            &           krefdate = 19500101 ) 
    499487         fbdata%padd(1,jo,1,1) = surfdata%rmod(jo,1) 
    500          IF ( TRIM(cobstype) == 'sla' ) fbdata%padd(1,jo,2,1) = surfdata%rext(jo,1) 
     488         IF ( TRIM(surfdata%cvars(1)) == 'SLA' ) fbdata%padd(1,jo,2,1) = surfdata%rext(jo,1) 
    501489         fbdata%pob(1,jo,1)    = surfdata%robs(jo,1)  
    502490         fbdata%pdep(1,jo)     = 0.0 
     
    514502         ENDIF 
    515503         fbdata%iobsk(1,jo,1)  = 0 
    516          IF ( TRIM(cobstype) == 'sla' ) fbdata%pext(1,jo,1) = surfdata%rext(jo,2) 
    517          DO ja = 1, nadd 
     504         IF ( TRIM(surfdata%cvars(1)) == 'SLA' ) fbdata%pext(1,jo,1) = surfdata%rext(jo,2) 
     505         DO ja = 1, iadd 
    518506            fbdata%padd(1,jo,2+ja,1) = & 
    519507               & surfdata%rext(jo,padd%ipoint(ja)) 
    520508         END DO 
    521          DO je = 1, next 
     509         DO je = 1, iext 
    522510            fbdata%pext(1,jo,1+je) = & 
    523511               & surfdata%rext(jo,pext%ipoint(je)) 
     
    526514 
    527515      ! Write the obfbdata structure 
    528       CALL write_obfbdata( cfname, fbdata ) 
     516      CALL write_obfbdata( clfname, fbdata ) 
    529517 
    530518      ! Output some basic statistics 
     
    556544      INTEGER :: jo 
    557545      INTEGER :: jk 
    558  
    559       INTEGER :: numgoodobs 
    560       INTEGER :: numgoodobsmpp 
     546      INTEGER :: inumgoodobs 
     547      INTEGER :: inumgoodobsmpp 
    561548      REAL(wp) :: zsumx 
    562549      REAL(wp) :: zsumx2 
     
    566553         WRITE(numout,*) '' 
    567554         WRITE(numout,*) 'obs_wri_stats :' 
    568          WRITE(numout,*) '~~~~~~~~~~~~~~~'  
     555         WRITE(numout,*) '~~~~~~~~~~~~~~~' 
    569556      ENDIF 
    570557 
     
    572559         zsumx=0.0_wp 
    573560         zsumx2=0.0_wp 
    574          numgoodobs=0 
     561         inumgoodobs=0 
    575562         DO jo = 1, fbdata%nobs 
    576563            DO jk = 1, fbdata%nlev 
     
    578565                  & ( fbdata%pdep(jk,jo) < 9999.0 ) .AND. & 
    579566                  & ( fbdata%padd(jk,jo,1,jvar) < 9999.0 ) ) THEN 
    580         
    581              zomb=fbdata%pob(jk, jo, jvar)-fbdata%padd(jk, jo, 1, jvar) 
     567 
     568                  zomb=fbdata%pob(jk, jo, jvar)-fbdata%padd(jk, jo, 1, jvar) 
    582569                  zsumx=zsumx+zomb 
    583570                  zsumx2=zsumx2+zomb**2 
    584                   numgoodobs=numgoodobs+1 
    585           ENDIF 
     571                  inumgoodobs=inumgoodobs+1 
     572               ENDIF 
    586573            ENDDO 
    587574         ENDDO 
    588575 
    589          CALL obs_mpp_sum_integer( numgoodobs, numgoodobsmpp ) 
     576         CALL obs_mpp_sum_integer( inumgoodobs, inumgoodobsmpp ) 
    590577         CALL mpp_sum(zsumx) 
    591578         CALL mpp_sum(zsumx2) 
    592579 
    593580         IF (lwp) THEN 
    594        WRITE(numout,*) 'Type: ',fbdata%cname(jvar),'  Total number of good observations: ',numgoodobsmpp  
    595        WRITE(numout,*) 'Overall mean obs minus model of the good observations: ',zsumx/numgoodobsmpp 
    596             WRITE(numout,*) 'Overall RMS obs minus model of the good observations: ',sqrt( zsumx2/numgoodobsmpp ) 
    597        WRITE(numout,*) '' 
     581            WRITE(numout,*) 'Type: ',fbdata%cname(jvar),'  Total number of good observations: ',inumgoodobsmpp  
     582            WRITE(numout,*) 'Overall mean obs minus model of the good observations: ',zsumx/inumgoodobsmpp 
     583            WRITE(numout,*) 'Overall RMS obs minus model of the good observations: ',sqrt( zsumx2/inumgoodobsmpp ) 
     584            WRITE(numout,*) '' 
    598585         ENDIF 
    599   
     586 
    600587      ENDDO 
    601588 
Note: See TracChangeset for help on using the changeset viewer.