- Timestamp:
- 2021-08-11T13:24:27+02:00 (3 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/UKMO/NEMO_4.0.4_generic_obs/src/OCE/OBS/obs_bias.F90
r15179 r15180 1 MODULE obs_ sstbias1 MODULE obs_bias 2 2 !!====================================================================== 3 !! *** MODULE obs_ sstbias ***4 !! Observation diagnostics: Read the bias for SSTdata3 !! *** MODULE obs_bias *** 4 !! Observation diagnostics: Read the bias for observation data 5 5 !!====================================================================== 6 6 !!---------------------------------------------------------------------- 7 !! obs_app_ sstbias : Driver for reading and applying the SSTbias7 !! obs_app_bias : Driver for reading and applying the bias 8 8 !!---------------------------------------------------------------------- 9 9 !! * Modules used 10 10 USE par_kind, ONLY : & ! Precision variables 11 & wp, & 12 & dp, & 13 & sp 11 & wp 14 12 USE par_oce, ONLY : & ! Domain parameters 15 13 & jpi, & 16 & jpj, & 17 & jpim1 14 & jpj 18 15 USE in_out_manager, ONLY : & ! I/O manager 19 16 & lwp, & … … 22 19 USE dom_oce, ONLY : & ! Domain variables 23 20 & tmask, & 24 & tmask_i, &25 & e1t, &26 & e2t, &27 21 & gphit, & 28 22 & glamt 29 USE oce, ONLY : & ! Model variables30 & sshn31 23 USE obs_inter_h2d 32 24 USE obs_utils ! Various observation tools … … 35 27 !! * Routine accessibility 36 28 PRIVATE 37 PUBLIC obs_app_ sstbias ! Read the altimeterbias29 PUBLIC obs_app_bias ! Read the observation bias 38 30 CONTAINS 39 SUBROUTINE obs_app_ sstbias( sstdata, k2dint, knumtypes, &40 cl_bias_files)31 SUBROUTINE obs_app_bias( obsdata, kvar, k2dint, knumtypes, & 32 cl_bias_files, cd_biasname ) 41 33 !!--------------------------------------------------------------------- 42 34 !! 43 !! *** ROUTINE obs_app_ sstbias ***44 !! 45 !! ** Purpose : Read SSTbias data from files and apply correction to46 !! observations35 !! *** ROUTINE obs_app_bias *** 36 !! 37 !! ** Purpose : Read bias data from files and apply correction to 38 !! observations 47 39 !! 48 40 !! ** Method : … … 54 46 !! History : 55 47 !! ! : 2014-08 (J. While) Bias correction code for SST obs, 56 !! ! based on obs_rea_altbias 48 !! ! based on obs_rea_altbias 49 !! ! : 2021-07 (D. Ford) Renamed obs_app_bias and made generic 57 50 !!---------------------------------------------------------------------- 58 51 !! * Modules used … … 61 54 !! * Arguments 62 55 63 TYPE(obs_surf), INTENT(INOUT) :: sstdata ! SST data 56 TYPE(obs_surf), INTENT(INOUT) :: obsdata ! Observation data 57 INTEGER, INTENT(IN) :: kvar ! Index of obs type being bias corrected 64 58 INTEGER, INTENT(IN) :: k2dint 65 59 INTEGER, INTENT(IN) :: knumtypes !number of bias types to read in 66 60 CHARACTER(LEN=128), DIMENSION(knumtypes), INTENT(IN) :: & 67 61 cl_bias_files !List of files to read 62 CHARACTER(LEN=128), INTENT(IN) :: cd_biasname !Variable name in file 68 63 !! * Local declarations 69 64 INTEGER :: jobs ! Obs loop variable 70 INTEGER :: jpisstbias ! Number of grid point in latitude for the bias71 INTEGER :: jpjsstbias ! Number of grid point in longitude for the bias72 65 INTEGER :: iico ! Grid point indices 73 66 INTEGER :: ijco 74 67 INTEGER :: jt 75 INTEGER :: i_nx_id ! Index to read the NetCDF file76 INTEGER :: i_ny_id !77 INTEGER :: i_file_id !78 INTEGER :: i_var_id79 68 INTEGER, DIMENSION(knumtypes) :: & 80 69 & ibiastypes ! Array of the bias types in each file 81 70 REAL(wp), DIMENSION(jpi,jpj,knumtypes) :: & 82 & z_ sstbias ! Array to store the SSTbias values71 & z_obsbias ! Array to store the bias values 83 72 REAL(wp), DIMENSION(jpi,jpj) :: & 84 & z_ sstbias_2d ! Array to store the SSTbias values73 & z_obsbias_2d ! Array to store the bias values 85 74 REAL(wp), DIMENSION(1) :: & 86 75 & zext, & … … 105 94 & igrdi_tmp, & 106 95 & igrdj_tmp 107 INTEGER :: num sstbias96 INTEGER :: numobsbias 108 97 INTEGER(KIND=NF90_INT) :: ifile_source 109 98 … … 113 102 INTEGER :: inumtype 114 103 IF(lwp)WRITE(numout,*) 115 IF(lwp)WRITE(numout,*) 'obs_ rea_sstbias : '104 IF(lwp)WRITE(numout,*) 'obs_app_bias : ' 116 105 IF(lwp)WRITE(numout,*) '----------------- ' 117 IF(lwp)WRITE(numout,*) 'Read SST bias '106 IF(lwp)WRITE(numout,*) 'Read observation bias for ', TRIM(obsdata%cvars(kvar)) 118 107 ! Open and read the files 119 z_ sstbias(:,:,:)=0.0_wp108 z_obsbias(:,:,:)=0.0_wp 120 109 DO jtype = 1, knumtypes 121 110 122 num sstbias=0111 numobsbias=0 123 112 IF(lwp)WRITE(numout,*) 'Opening ',cl_bias_files(jtype) 124 CALL iom_open( cl_bias_files(jtype), num sstbias, ldstop=.FALSE. )125 IF (num sstbias > 0) THEN113 CALL iom_open( cl_bias_files(jtype), numobsbias, ldstop=.FALSE. ) 114 IF (numobsbias > 0) THEN 126 115 127 116 !Read the bias type from the file … … 130 119 !routines directly - should be upgraded in the future 131 120 iret=NF90_OPEN(TRIM(cl_bias_files(jtype)), NF90_NOWRITE, incfile) 132 iret=NF90_GET_ATT( incfile, NF90_GLOBAL, "SST_source", &121 iret=NF90_GET_ATT( incfile, NF90_GLOBAL, TRIM(obsdata%cvars(kvar))//"_source", & 133 122 ifile_source ) 134 123 ibiastypes(jtype) = ifile_source … … 136 125 137 126 IF ( iret /= 0 ) CALL ctl_stop( & 138 'obs_ rea_sstbias : Cannot read bias type from file '// &127 'obs_app_bias : Cannot read bias type from file '// & 139 128 cl_bias_files(jtype) ) 140 ! Get the SSTbias data141 CALL iom_get( num sstbias, jpdom_data, 'tn', z_sstbias_2d(:,:), 1 )142 z_ sstbias(:,:,jtype) = z_sstbias_2d(:,:)129 ! Get the bias data 130 CALL iom_get( numobsbias, jpdom_data, TRIM(cd_biasname), z_obsbias_2d(:,:), 1 ) 131 z_obsbias(:,:,jtype) = z_obsbias_2d(:,:) 143 132 ! Close the file 144 CALL iom_close(num sstbias)133 CALL iom_close(numobsbias) 145 134 ELSE 146 CALL ctl_stop('obs_ read_sstbias: File '// &135 CALL ctl_stop('obs_app_bias: File '// & 147 136 TRIM( cl_bias_files(jtype) )//' Not found') 148 137 ENDIF … … 151 140 ! Interpolate the bias already on the model grid at the observation point 152 141 ALLOCATE( & 153 & igrdi(2,2, sstdata%nsurf), &154 & igrdj(2,2, sstdata%nsurf), &155 & zglam(2,2, sstdata%nsurf), &156 & zgphi(2,2, sstdata%nsurf), &157 & zmask(2,2, sstdata%nsurf) )142 & igrdi(2,2,obsdata%nsurf), & 143 & igrdj(2,2,obsdata%nsurf), & 144 & zglam(2,2,obsdata%nsurf), & 145 & zgphi(2,2,obsdata%nsurf), & 146 & zmask(2,2,obsdata%nsurf) ) 158 147 159 DO jobs = 1, sstdata%nsurf160 igrdi(1,1,jobs) = sstdata%mi(jobs)-1161 igrdj(1,1,jobs) = sstdata%mj(jobs)-1162 igrdi(1,2,jobs) = sstdata%mi(jobs)-1163 igrdj(1,2,jobs) = sstdata%mj(jobs)164 igrdi(2,1,jobs) = sstdata%mi(jobs)165 igrdj(2,1,jobs) = sstdata%mj(jobs)-1166 igrdi(2,2,jobs) = sstdata%mi(jobs)167 igrdj(2,2,jobs) = sstdata%mj(jobs)148 DO jobs = 1, obsdata%nsurf 149 igrdi(1,1,jobs) = obsdata%mi(jobs)-1 150 igrdj(1,1,jobs) = obsdata%mj(jobs)-1 151 igrdi(1,2,jobs) = obsdata%mi(jobs)-1 152 igrdj(1,2,jobs) = obsdata%mj(jobs) 153 igrdi(2,1,jobs) = obsdata%mi(jobs) 154 igrdj(2,1,jobs) = obsdata%mj(jobs)-1 155 igrdi(2,2,jobs) = obsdata%mi(jobs) 156 igrdj(2,2,jobs) = obsdata%mj(jobs) 168 157 END DO 169 CALL obs_int_comm_2d( 2, 2, sstdata%nsurf, jpi, jpj, &158 CALL obs_int_comm_2d( 2, 2, obsdata%nsurf, jpi, jpj, & 170 159 & igrdi, igrdj, glamt, zglam ) 171 CALL obs_int_comm_2d( 2, 2, sstdata%nsurf, jpi, jpj, &160 CALL obs_int_comm_2d( 2, 2, obsdata%nsurf, jpi, jpj, & 172 161 & igrdi, igrdj, gphit, zgphi ) 173 CALL obs_int_comm_2d( 2, 2, sstdata%nsurf, jpi, jpj, &162 CALL obs_int_comm_2d( 2, 2, obsdata%nsurf, jpi, jpj, & 174 163 & igrdi, igrdj, tmask(:,:,1), zmask ) 175 164 DO jtype = 1, knumtypes 176 165 177 166 !Find the number observations of type and allocate tempory arrays 178 inumtype = COUNT( sstdata%ntyp(:) == ibiastypes(jtype) )167 inumtype = COUNT( obsdata%ntyp(:) == ibiastypes(jtype) ) 179 168 ALLOCATE( & 180 169 & igrdi_tmp(2,2,inumtype), & … … 185 174 & zbias( 2,2,inumtype ) ) 186 175 jt=1 187 DO jobs = 1, sstdata%nsurf188 IF ( sstdata%ntyp(jobs) == ibiastypes(jtype) ) THEN176 DO jobs = 1, obsdata%nsurf 177 IF ( obsdata%ntyp(jobs) == ibiastypes(jtype) ) THEN 189 178 igrdi_tmp(:,:,jt) = igrdi(:,:,jobs) 190 179 igrdj_tmp(:,:,jt) = igrdj(:,:,jobs) … … 198 187 CALL obs_int_comm_2d( 2, 2, inumtype, jpi, jpj, & 199 188 & igrdi_tmp(:,:,:), igrdj_tmp(:,:,:), & 200 & z_ sstbias(:,:,jtype), zbias(:,:,:) )189 & z_obsbias(:,:,jtype), zbias(:,:,:) ) 201 190 jt=1 202 DO jobs = 1, sstdata%nsurf203 IF ( sstdata%ntyp(jobs) == ibiastypes(jtype) ) THEN204 zlam = sstdata%rlam(jobs)205 zphi = sstdata%rphi(jobs)206 iico = sstdata%mi(jobs)207 ijco = sstdata%mj(jobs)191 DO jobs = 1, obsdata%nsurf 192 IF ( obsdata%ntyp(jobs) == ibiastypes(jtype) ) THEN 193 zlam = obsdata%rlam(jobs) 194 zphi = obsdata%rphi(jobs) 195 iico = obsdata%mi(jobs) 196 ijco = obsdata%mj(jobs) 208 197 CALL obs_int_h2d_init( 1, 1, k2dint, zlam, zphi, & 209 198 & zglam_tmp(:,:,jt), & … … 211 200 & zmask_tmp(:,:,jt), zweig, zobsmask ) 212 201 CALL obs_int_h2d( 1, 1, zweig, zbias(:,:,jt), zext ) 213 ! adjust sstwith bias field214 sstdata%robs(jobs,1) = sstdata%robs(jobs,1) - zext(1)202 ! adjust observations with bias field 203 obsdata%robs(jobs,kvar) = obsdata%robs(jobs,kvar) - zext(1) 215 204 jt=jt+1 216 205 ENDIF … … 235 224 IF(lwp) THEN 236 225 WRITE(numout,*) " " 237 WRITE(numout,*) " SST bias correction applied successfully"226 WRITE(numout,*) "Bias correction applied successfully" 238 227 WRITE(numout,*) "Obs types: ",ibiastypes(:), & 239 228 " Have all been bias corrected\n" 240 229 ENDIF 241 END SUBROUTINE obs_app_ sstbias230 END SUBROUTINE obs_app_bias 242 231 243 END MODULE obs_ sstbias232 END MODULE obs_bias
Note: See TracChangeset
for help on using the changeset viewer.