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.
fbthin.F90 in branches/UKMO/icebergs_restart_single_file/NEMOGCM/TOOLS/OBSTOOLS/src – NEMO

source: branches/UKMO/icebergs_restart_single_file/NEMOGCM/TOOLS/OBSTOOLS/src/fbthin.F90 @ 6019

Last change on this file since 6019 was 6019, checked in by timgraham, 8 years ago

Reinstated svn keywords before upgrading to head of trunk

  • Property svn:keywords set to Id
File size: 4.2 KB
Line 
1PROGRAM fbthin
2   !!---------------------------------------------------------------------
3   !!
4   !!                     ** PROGRAM fbthin **
5   !!
6   !!  ** Purpose : Thin the data to 1 degree resolution
7   !!
8   !!  ** Method  : Use of utilities from obs_fbm.
9   !!
10   !!  ** Action  :
11   !!
12   !!   Usage:
13   !!     fbthin.exe inputfile outputfile
14   !!
15   !!   Required:
16   !!     namelist = namthin.in
17   !!
18   !!   History :
19   !!        ! 2010 (K. Mogensen) Initial version
20   !!----------------------------------------------------------------------
21   USE obs_fbm
22   IMPLICIT NONE
23   !
24   ! Command line arguments for output file and input file
25   !
26#ifndef NOIARGCPROTO
27   INTEGER,EXTERNAL :: iargc
28#endif
29   INTEGER :: nargs
30   CHARACTER(len=256) :: cdoutfile
31   CHARACTER(len=256) :: cdinfile
32   CHARACTER(len=256) :: cdtmp
33   INTEGER :: nout,ninn,nadd,next,i,j,k
34   LOGICAL :: lgrid
35   !
36   ! Feedback data
37   !
38   TYPE(obfbdata) :: fbdatain
39   !
40   ! Get number of command line arguments
41   !
42   nargs=IARGC()
43   IF ((nargs /= 2)) THEN
44      WRITE(*,'(A)')'Usage:'
45      WRITE(*,'(A)')'fbthin inputfile outputfile'
46      CALL abort()
47   ENDIF
48   CALL getarg(1,cdinfile)
49   CALL getarg(2,cdoutfile)
50   !
51   ! Initialize feedback data
52   !
53   CALL init_obfbdata( fbdatain )
54   !
55   ! Read the file
56   !
57   CALL read_obfbdata( TRIM(cdinfile), fbdatain )
58   !
59   ! Do the thining
60   !
61   CALL fb_thin( fbdatain )
62   !
63   ! Write the file
64   !
65   CALL write_obfbdata( TRIM(cdoutfile), fbdatain )
66
67CONTAINS
68   
69   SUBROUTINE fb_thin( fbdata )
70      !
71      ! Observation thinning
72      !
73      IMPLICIT NONE
74      TYPE(obfbdata) :: fbdata
75      ! Namelist parameters
76      INTEGER, PARAMETER :: nmaxtypes = 10
77      CHARACTER(len=ilentyp), DIMENSION(nmaxtypes) :: thintypes
78      REAL, DIMENSION(nmaxtypes) :: thindists, thindtime
79      ! Local variables
80      NAMELIST/namthin/thintypes, thindists, thindtime
81      INTEGER :: it,ii,ij,iv,iobs,irej
82      REAL :: zdist
83
84      ! Get namelist
85      thintypes(:) = 'XXXX'
86      ! Distance in km
87      thindists(:) = 100.0
88      ! Time difference in days
89      thindtime(:) = 0.99999999
90      OPEN(10,file='namthin.in')
91      READ(10,namthin)
92      CLOSE(10)
93      WRITE(*,namthin)
94     
95      ! Convert to meters
96      thindists(:) = thindists(:) * 1000.0
97
98      DO it = 1, nmaxtypes
99
100         IF ( TRIM(thintypes(it)) == 'XXXX' ) CYCLE
101
102         iobs = 0 
103         irej = 0
104
105         master_loop: DO ii= 1, fbdata%nobs 
106           
107            IF ( TRIM(ADJUSTL(thintypes(it))) /= 'all' ) THEN
108               IF ( TRIM(ADJUSTL(fbdata%cdtyp(ii))) /= &
109                  & TRIM(ADJUSTL(thintypes(it))) ) CYCLE
110            ENDIF
111           
112            iobs = iobs + 1
113
114            ! Skip data with missing lon and lat and observation flag rejected.
115
116            IF (fbdata%plam(ii)==fbrmdi) CYCLE
117            IF (fbdata%pphi(ii)==fbrmdi) CYCLE
118            IF (fbdata%ioqc(ii)>2) CYCLE
119           
120            DO ij=ii+1, fbdata%nobs
121
122               ! Skip data with missing lon and lat and observation flag rejected.
123               
124               IF (fbdata%plam(ij)==fbrmdi) CYCLE
125               IF (fbdata%pphi(ij)==fbrmdi) CYCLE
126               IF (fbdata%ioqc(ij)>2) CYCLE
127               
128               ! Skip different type unless thintypes is 'all'
129
130               IF ( TRIM(ADJUSTL(thintypes(it))) /= 'all' ) THEN
131                  IF ( TRIM(ADJUSTL(fbdata%cdtyp(ij))) /= &
132                     & TRIM(ADJUSTL(thintypes(it))) ) CYCLE
133               ENDIF
134
135               IF ( ABS( fbdata%ptim(ij) - fbdata%ptim(ii) ) &
136                  & >= thindtime(it) ) CYCLE
137
138               zdist = distance( fbdata%plam(ii), fbdata%pphi(ii), &
139                  &              fbdata%plam(ij), fbdata%pphi(ij) )
140
141               IF ( zdist < thindists(it) ) THEN
142
143                  irej = irej + 1
144                  fbdata%ioqc(ij)    = 4
145                  fbdata%ioqcf(2,ij) = fbdata%ioqcf(2,ij) + 32
146
147               ENDIF
148            ENDDO
149           
150         ENDDO master_loop
151
152         WRITE(*,*)'For type                = ',TRIM(thintypes(it))
153         WRITE(*,*)'Observations considered = ',iobs
154         WRITE(*,*)'Observations rejected   = ',irej
155
156      ENDDO
157
158
159     
160   END SUBROUTINE fb_thin
161
162#include "distance.h90"
163
164END PROGRAM fbthin
Note: See TracBrowser for help on using the repository browser.