Changeset 5063 for branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_read.F90
- Timestamp:
- 2015-02-05T17:29:55+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/SAO_SRC/sao_read.F90
r4849 r5063 1 2 1 MODULE sao_read 3 2 !!================================================================== … … 5 4 !! Read routines : I/O for Stand Alone Observation operator 6 5 !!================================================================== 7 8 6 USE mppini 9 7 USE lib_mpp … … 28 26 !! 29 27 !! Purpose : To choose appropriate read method 30 !! Method : 28 !! Method : 31 29 !! 32 30 !! Author : A. Ryan Oct 2013 … … 36 34 & kfile !: File number 37 35 CHARACTER(len=lc) :: & 38 & cdfilename, & !: File name 39 & cmatchname !: Match name 36 & cdfilename !: File name 40 37 INTEGER :: & 41 & kindex !: File index to read 42 43 !! Filename, index and match-up kind 38 & kindex !: File index to read 39 44 40 cdfilename = TRIM(sao_files(kfile)) 45 cmatchname = TRIM(cl4_vars(kfile))46 41 kindex = nn_sao_idx(kfile) 47 48 !! Update model fields 49 !! Class 4 variables: forecast, persistence, 50 !! nrt_analysis, best_estimate 51 !! Feedback variables: empty string 52 IF ( (TRIM(cmatchname) == 'forecast') .OR. & 53 & (TRIM(cmatchname) == 'persistence') .OR. & 54 & (TRIM(cmatchname) == 'nrt_analysis') .OR. & 55 & (TRIM(cmatchname) == 'best_estimate').OR. & 56 & (TRIM(cmatchname) == '') ) THEN 57 CALL sao_read_file(TRIM(cdfilename), kindex) 58 CALL sao_read_juld(TRIM(cdfilename), kindex, cl4_modjuld) 59 ELSE IF (TRIM(cmatchname) == 'climatology') THEN 60 WRITE(numout,*) 'Interpolating climatologies' 61 ELSE IF (TRIM(cmatchname) == 'altimeter') THEN 62 CALL sao_read_altbias(TRIM(cdfilename)) 63 CALL sao_read_juld(TRIM(cdfilename), kindex, cl4_modjuld) 64 END IF 42 CALL sao_read_file(TRIM(cdfilename), kindex) 65 43 66 44 END SUBROUTINE sao_rea_dri 67 68 SUBROUTINE sao_read_altbias(filename)69 !!------------------------------------------------------------------------70 !! *** sao_read_altbias ***71 !!72 !! Purpose : To read altimeter bias and set tn,sn to missing values73 !! Method : Use subdomain indices to create start and count matrices74 !! for netcdf read.75 !!76 !! Author : A. Ryan Sept 201277 !!------------------------------------------------------------------------78 CHARACTER(len=*), INTENT(IN) :: filename79 INTEGER :: ncid, &80 & varid,&81 & istat,&82 & ntimes,&83 & tdim, &84 & xdim, &85 & ydim, &86 & zdim87 INTEGER :: ii, ij, ik88 INTEGER, DIMENSION(3) :: start_s, &89 & count_s90 REAL(fbdp), DIMENSION(:,:), ALLOCATABLE :: temp_sshn91 REAL(fbdp) :: fill_val92 93 IF (TRIM(filename) == 'nofile') THEN94 tsn(:,:,:,:) = fbrmdi95 sshn(:,:) = fbrmdi96 ELSE97 ! Open Netcdf file to find dimension id98 istat = nf90_open(trim(filename),nf90_nowrite,ncid)99 istat = nf90_inq_dimid(ncid,'x',xdim)100 istat = nf90_inq_dimid(ncid,'y',ydim)101 istat = nf90_inq_dimid(ncid,'deptht',zdim)102 istat = nf90_inq_dimid(ncid,'time',tdim)103 istat = nf90_inquire_dimension(ncid, tdim, len=ntimes)104 ! Allocate temporary temperature array105 ALLOCATE(temp_sshn(nlci,nlcj))106 ! Create start and count arrays107 start_s = (/ nimpp, njmpp, 1 /)108 count_s = (/ nlci, nlcj, 1 /)109 110 ! Altimeter bias111 istat = nf90_inq_varid(ncid,'altbias',varid)112 istat = nf90_get_att(ncid, varid, '_FillValue', fill_val)113 istat = nf90_get_var(ncid, varid, temp_sshn, start_s, count_s)114 WHERE(temp_sshn(:,:) == fill_val) temp_sshn(:,:) = fbrmdi115 116 ! Initialise tsn, sshn to fbrmdi117 tsn(:,:,:,:) = fbrmdi118 sshn(:,:) = fbrmdi119 120 ! Fill sshn with altimeter bias121 sshn(1:nlci,1:nlcj) = temp_sshn(:,:) * tmask(1:nlci,1:nlcj,1)122 123 ! Remove halo from tmask, sshn to prevent double obs counting124 IF (jpi > nlci) THEN125 tmask(nlci+1:,:,:) = 0126 sshn(nlci+1:,:) = 0127 END IF128 IF (jpj > nlcj) THEN129 tmask(:,nlcj+1:,:) = 0130 sshn(:,nlcj+1:) = 0131 END IF132 133 ! Deallocate arrays134 DEALLOCATE(temp_sshn)135 136 ! Close netcdf file137 istat = nf90_close(ncid)138 END IF139 140 END SUBROUTINE sao_read_altbias141 45 142 46 SUBROUTINE sao_read_file(filename, ifcst) … … 176 80 IF (TRIM(filename) == 'nofile') THEN 177 81 tsn(:,:,:,:) = fbrmdi 178 sshn(:,:) = fbrmdi 82 sshn(:,:) = fbrmdi 179 83 ELSE 180 84 WRITE(numout,*) "Opening :", TRIM(filename) … … 190 94 istat = nf90_inq_dimid(ncid,'time_counter',tdim) 191 95 istat = nf90_inquire_dimension(ncid, tdim, len=ntimes) 192 IF (ifcst .LE. ntimes) THEN 96 IF (ifcst .LE. ntimes) THEN 193 97 ! Allocate temporary temperature array 194 98 ALLOCATE(temp_tn(nlci,nlcj,jpk)) 195 99 ALLOCATE(temp_sn(nlci,nlcj,jpk)) 196 100 ALLOCATE(temp_sshn(nlci,nlcj)) 197 101 198 102 ! Set temp_tn, temp_sn to 0. 199 103 temp_tn(:,:,:) = fbrmdi 200 104 temp_sn(:,:,:) = fbrmdi 201 105 temp_sshn(:,:) = fbrmdi 202 106 203 107 ! Create start and count arrays 204 108 start_n = (/ nimpp, njmpp, 1, ifcst /) … … 206 110 start_s = (/ nimpp, njmpp, ifcst /) 207 111 count_s = (/ nlci, nlcj, 1 /) 208 112 209 113 ! Read information into temporary arrays 210 114 ! retrieve varid and read in temperature … … 213 117 istat = nf90_get_var(ncid, varid, temp_tn, start_n, count_n) 214 118 WHERE(temp_tn(:,:,:) == fill_val) temp_tn(:,:,:) = fbrmdi 215 119 216 120 ! retrieve varid and read in salinity 217 121 istat = nf90_inq_varid(ncid,'vosaline',varid) … … 219 123 istat = nf90_get_var(ncid, varid, temp_sn, start_n, count_n) 220 124 WHERE(temp_sn(:,:,:) == fill_val) temp_sn(:,:,:) = fbrmdi 221 125 222 126 ! retrieve varid and read in SSH 223 127 istat = nf90_inq_varid(ncid,'sossheig',varid) … … 226 130 istat = nf90_inq_varid(ncid,'altbias',varid) 227 131 END IF 228 132 229 133 istat = nf90_get_att(ncid, varid, '_FillValue', fill_val) 230 134 istat = nf90_get_var(ncid, varid, temp_sshn, start_s, count_s) 231 135 WHERE(temp_sshn(:,:) == fill_val) temp_sshn(:,:) = fbrmdi 232 136 233 137 ! Initialise tsn, sshn to fbrmdi 234 138 tsn(:,:,:,:) = fbrmdi 235 sshn(:,:) = fbrmdi 139 sshn(:,:) = fbrmdi 236 140 237 141 ! Mask out missing data index … … 256 160 ! Deallocate arrays 257 161 DEALLOCATE(temp_tn, temp_sn, temp_sshn) 258 ELSE 162 ELSE 259 163 ! Mark all as missing data 260 164 tsn(:,:,:,:) = fbrmdi 261 sshn(:,:) = fbrmdi 165 sshn(:,:) = fbrmdi 262 166 ENDIF 263 167 ! Close netcdf file … … 266 170 END IF 267 171 END SUBROUTINE sao_read_file 268 269 SUBROUTINE sao_read_juld(filename, ifcst, julian) 270 USE calendar 271 !!-------------------------------------------------------------------- 272 !! *** sao_read_juld *** 273 !! 274 !! Purpose : To read model julian day information from file 275 !! Author : A. Ryan Nov 2010 276 !!-------------------------------------------------------------------- 277 278 !! Routine arguments 279 CHARACTER(len=*), INTENT(IN) :: filename 280 INTEGER, INTENT(IN) :: ifcst 281 REAL, INTENT(OUT) :: julian !: Julian day 282 283 !! Local variables 284 INTEGER :: year, & !: Date information 285 & month, & 286 & day, & 287 & hour, & 288 & minute,& 289 & second 290 INTEGER :: istat, & !: Netcdf variables 291 & ncid, & 292 & dimid, & 293 & varid, & 294 & ntime 295 REAL,DIMENSION(:),ALLOCATABLE :: r_sec !: Remainder seconds 296 CHARACTER(len=120) :: time_str !: time string 297 298 time_str='' 299 !! Read in time_counter and remainder seconds 300 istat = nf90_open(trim(filename),nf90_nowrite,ncid) 301 istat = nf90_inq_dimid(ncid,'time_counter',dimid) 302 IF (istat /= nf90_noerr) THEN 303 istat = nf90_inq_dimid(ncid,'time',dimid) 304 ENDIF 305 istat = nf90_inquire_dimension(ncid,dimid,len=ntime) 306 istat = nf90_inq_varid(ncid,'time_counter',varid) 307 IF (istat /= nf90_noerr) THEN 308 istat = nf90_inq_dimid(ncid,'time',dimid) 309 ENDIF 310 istat = nf90_get_att(ncid,varid,'units',time_str) 311 ALLOCATE(r_sec(ntime)) 312 istat = nf90_get_var(ncid,varid, r_sec) 313 istat = nf90_close(ncid) 314 315 !! Fill yyyy-mm-dd hh:mm:ss 316 !! format(('seconds since ', I4.4,'-',I2.2,'-',I2.2,' ',I2.2,':',I2.2,':',I2.2)) 317 100 format((14x, I4.4,1x,I2.2,1x,I2.2,1x,I2.2,1x,I2.2,1x,I2.2)) 318 READ( time_str, 100 ) year, month, day, hour, minute, second 319 320 CALL ymds2ju(year, month, day, r_sec(ifcst), julian) 321 322 !! To take a comment from the ymds2ju subroutine 323 324 !- In the case of the Gregorian calendar we have chosen to use 325 !- the Lilian day numbers. This is the day counter which starts 326 !- on the 15th October 1582. 327 !- This is the day at which Pope Gregory XIII introduced the 328 !- Gregorian calendar. 329 !- Compared to the true Julian calendar, which starts some 330 !- 7980 years ago, the Lilian days are smaler and are dealt with 331 !- easily on 32 bit machines. With the true Julian days you can only 332 !- the fraction of the day in the real part to a precision of 333 !- a 1/4 of a day with 32 bits. 334 335 !! The obs operator routines prefer to calculate Julian days since 336 !! 01/01/1950 00:00:00 337 !! In order to convert to the 1950 version we must adjust by the number 338 !! of days between 15th October 1582 and 1st Jan 1950 339 340 julian = julian - 134123. 341 342 DEALLOCATE(r_sec) 343 344 END SUBROUTINE sao_read_juld 345 346 END MODULE sao_read 347 172 END MODULE sao_read
Note: See TracChangeset
for help on using the changeset viewer.