[3] | 1 | MODULE geo2ocean |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE geo2ocean *** |
---|
[144] | 4 | !! Ocean mesh : ??? |
---|
[1218] | 5 | !!====================================================================== |
---|
| 6 | !! History : OPA ! 07-1996 (O. Marti) Original code |
---|
[6140] | 7 | !! NEMO 1.0 ! 06-2006 (G. Madec ) Free form, F90 + opt. |
---|
| 8 | !! ! 04-2007 (S. Masson) angle: Add T, F points and bugfix in cos lateral boundary |
---|
| 9 | !! 3.0 ! 07-2008 (G. Madec) geo2oce suppress lon/lat agruments |
---|
| 10 | !! 3.7 ! 11-2015 (G. Madec) remove the unused repere and repcmo routines |
---|
[1218] | 11 | !!---------------------------------------------------------------------- |
---|
[3] | 12 | |
---|
| 13 | !!---------------------------------------------------------------------- |
---|
[6140] | 14 | !! rot_rep : Rotate the Repere: geographic grid <==> stretched coordinates grid |
---|
| 15 | !! angle : |
---|
| 16 | !! geo2oce : |
---|
| 17 | !! oce2geo : |
---|
[3] | 18 | !!---------------------------------------------------------------------- |
---|
[6140] | 19 | USE dom_oce ! mesh and scale factors |
---|
| 20 | USE phycst ! physical constants |
---|
| 21 | ! |
---|
| 22 | USE in_out_manager ! I/O manager |
---|
| 23 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
| 24 | USE lib_mpp ! MPP library |
---|
[3] | 25 | |
---|
| 26 | IMPLICIT NONE |
---|
[1218] | 27 | PRIVATE |
---|
[3] | 28 | |
---|
[8734] | 29 | PUBLIC repcmo ! called in sbccpl |
---|
[6140] | 30 | PUBLIC rot_rep ! called in sbccpl, fldread, and cyclone |
---|
| 31 | PUBLIC geo2oce ! called in sbccpl |
---|
| 32 | PUBLIC oce2geo ! called in sbccpl |
---|
| 33 | PUBLIC obs_rot ! called in obs_rot_vel and obs_write |
---|
[3] | 34 | |
---|
[6140] | 35 | ! ! cos/sin between model grid lines and NP direction |
---|
| 36 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: gsint, gcost ! at T point |
---|
| 37 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: gsinu, gcosu ! at U point |
---|
| 38 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: gsinv, gcosv ! at V point |
---|
| 39 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) :: gsinf, gcosf ! at F point |
---|
[2528] | 40 | |
---|
[2715] | 41 | LOGICAL , SAVE, DIMENSION(4) :: linit = .FALSE. |
---|
| 42 | REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: gsinlon, gcoslon, gsinlat, gcoslat |
---|
| 43 | |
---|
[6140] | 44 | LOGICAL :: lmust_init = .TRUE. !: used to initialize the cos/sin variables (see above) |
---|
[672] | 45 | |
---|
[1218] | 46 | !! * Substitutions |
---|
[3] | 47 | # include "vectopt_loop_substitute.h90" |
---|
[1218] | 48 | !!---------------------------------------------------------------------- |
---|
[2528] | 49 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
[8730] | 50 | !! $Id$ |
---|
[2715] | 51 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
[1218] | 52 | !!---------------------------------------------------------------------- |
---|
[3] | 53 | CONTAINS |
---|
| 54 | |
---|
[8731] | 55 | SUBROUTINE repcmo ( pxu1, pyu1, pxv1, pyv1, & |
---|
| 56 | px2 , py2 , kchoix ) |
---|
| 57 | !!---------------------------------------------------------------------- |
---|
| 58 | !! *** ROUTINE repcmo *** |
---|
| 59 | !! |
---|
| 60 | !! ** Purpose : Change vector componantes from a geographic grid to a |
---|
| 61 | !! stretched coordinates grid. |
---|
| 62 | !! |
---|
| 63 | !! ** Method : Initialization of arrays at the first call. |
---|
| 64 | !! |
---|
| 65 | !! ** Action : - px2 : first componante (defined at u point) |
---|
| 66 | !! - py2 : second componante (defined at v point) |
---|
| 67 | !!---------------------------------------------------------------------- |
---|
| 68 | REAL(wp), INTENT(in ), DIMENSION(jpi,jpj) :: pxu1, pyu1 ! geographic vector componantes at u-point |
---|
| 69 | REAL(wp), INTENT(in ), DIMENSION(jpi,jpj) :: pxv1, pyv1 ! geographic vector componantes at v-point |
---|
| 70 | REAL(wp), INTENT( out), DIMENSION(jpi,jpj) :: px2 ! i-componante (defined at u-point) |
---|
| 71 | REAL(wp), INTENT( out), DIMENSION(jpi,jpj) :: py2 ! j-componante (defined at v-point) |
---|
| 72 | !!---------------------------------------------------------------------- |
---|
| 73 | INTEGER, INTENT( IN ) :: & |
---|
| 74 | kchoix ! type of transformation |
---|
| 75 | ! = 1 change from geographic to model grid. |
---|
| 76 | ! =-1 change from model to geographic grid |
---|
| 77 | !!---------------------------------------------------------------------- |
---|
| 78 | |
---|
| 79 | SELECT CASE (kchoix) |
---|
| 80 | CASE ( 1) |
---|
| 81 | ! Change from geographic to stretched coordinate |
---|
| 82 | ! ---------------------------------------------- |
---|
| 83 | |
---|
| 84 | CALL rot_rep( pxu1, pyu1, 'U', 'en->i',px2 ) |
---|
| 85 | CALL rot_rep( pxv1, pyv1, 'V', 'en->j',py2 ) |
---|
| 86 | CASE (-1) |
---|
| 87 | ! Change from stretched to geographic coordinate |
---|
| 88 | ! ---------------------------------------------- |
---|
| 89 | |
---|
| 90 | CALL rot_rep( pxu1, pyu1, 'U', 'ij->e',px2 ) |
---|
| 91 | CALL rot_rep( pxv1, pyv1, 'V', 'ij->n',py2 ) |
---|
| 92 | END SELECT |
---|
| 93 | |
---|
| 94 | END SUBROUTINE repcmo |
---|
| 95 | |
---|
[685] | 96 | SUBROUTINE rot_rep ( pxin, pyin, cd_type, cdtodo, prot ) |
---|
[672] | 97 | !!---------------------------------------------------------------------- |
---|
| 98 | !! *** ROUTINE rot_rep *** |
---|
| 99 | !! |
---|
| 100 | !! ** Purpose : Rotate the Repere: Change vector componantes between |
---|
| 101 | !! geographic grid <--> stretched coordinates grid. |
---|
| 102 | !!---------------------------------------------------------------------- |
---|
[6140] | 103 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: pxin, pyin ! vector componantes |
---|
| 104 | CHARACTER(len=1), INTENT(in ) :: cd_type ! define the nature of pt2d array grid-points |
---|
| 105 | CHARACTER(len=5), INTENT(in ) :: cdtodo ! type of transpormation: |
---|
| 106 | ! ! 'en->i' = east-north to i-component |
---|
| 107 | ! ! 'en->j' = east-north to j-component |
---|
| 108 | ! ! 'ij->e' = (i,j) components to east |
---|
| 109 | ! ! 'ij->n' = (i,j) components to north |
---|
| 110 | REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: prot |
---|
[672] | 111 | !!---------------------------------------------------------------------- |
---|
[6140] | 112 | ! |
---|
| 113 | IF( lmust_init ) THEN ! at 1st call only: set gsin. & gcos. |
---|
[3] | 114 | IF(lwp) WRITE(numout,*) |
---|
[6140] | 115 | IF(lwp) WRITE(numout,*) ' rot_rep: coordinate transformation : geographic <==> model (i,j)-components' |
---|
| 116 | IF(lwp) WRITE(numout,*) ' ~~~~~~~~ ' |
---|
[2715] | 117 | ! |
---|
[3] | 118 | CALL angle ! initialization of the transformation |
---|
[672] | 119 | lmust_init = .FALSE. |
---|
[3] | 120 | ENDIF |
---|
[6140] | 121 | ! |
---|
| 122 | SELECT CASE( cdtodo ) ! type of rotation |
---|
| 123 | ! |
---|
| 124 | CASE( 'en->i' ) ! east-north to i-component |
---|
[672] | 125 | SELECT CASE (cd_type) |
---|
[7753] | 126 | CASE ('T') ; prot(:,:) = pxin(:,:) * gcost(:,:) + pyin(:,:) * gsint(:,:) |
---|
| 127 | CASE ('U') ; prot(:,:) = pxin(:,:) * gcosu(:,:) + pyin(:,:) * gsinu(:,:) |
---|
| 128 | CASE ('V') ; prot(:,:) = pxin(:,:) * gcosv(:,:) + pyin(:,:) * gsinv(:,:) |
---|
| 129 | CASE ('F') ; prot(:,:) = pxin(:,:) * gcosf(:,:) + pyin(:,:) * gsinf(:,:) |
---|
[672] | 130 | CASE DEFAULT ; CALL ctl_stop( 'Only T, U, V and F grid points are coded' ) |
---|
| 131 | END SELECT |
---|
[6140] | 132 | CASE ('en->j') ! east-north to j-component |
---|
[672] | 133 | SELECT CASE (cd_type) |
---|
[7753] | 134 | CASE ('T') ; prot(:,:) = pyin(:,:) * gcost(:,:) - pxin(:,:) * gsint(:,:) |
---|
| 135 | CASE ('U') ; prot(:,:) = pyin(:,:) * gcosu(:,:) - pxin(:,:) * gsinu(:,:) |
---|
| 136 | CASE ('V') ; prot(:,:) = pyin(:,:) * gcosv(:,:) - pxin(:,:) * gsinv(:,:) |
---|
| 137 | CASE ('F') ; prot(:,:) = pyin(:,:) * gcosf(:,:) - pxin(:,:) * gsinf(:,:) |
---|
[672] | 138 | CASE DEFAULT ; CALL ctl_stop( 'Only T, U, V and F grid points are coded' ) |
---|
| 139 | END SELECT |
---|
[6140] | 140 | CASE ('ij->e') ! (i,j)-components to east |
---|
[672] | 141 | SELECT CASE (cd_type) |
---|
[7753] | 142 | CASE ('T') ; prot(:,:) = pxin(:,:) * gcost(:,:) - pyin(:,:) * gsint(:,:) |
---|
| 143 | CASE ('U') ; prot(:,:) = pxin(:,:) * gcosu(:,:) - pyin(:,:) * gsinu(:,:) |
---|
| 144 | CASE ('V') ; prot(:,:) = pxin(:,:) * gcosv(:,:) - pyin(:,:) * gsinv(:,:) |
---|
| 145 | CASE ('F') ; prot(:,:) = pxin(:,:) * gcosf(:,:) - pyin(:,:) * gsinf(:,:) |
---|
[672] | 146 | CASE DEFAULT ; CALL ctl_stop( 'Only T, U, V and F grid points are coded' ) |
---|
| 147 | END SELECT |
---|
[6140] | 148 | CASE ('ij->n') ! (i,j)-components to north |
---|
[672] | 149 | SELECT CASE (cd_type) |
---|
[7753] | 150 | CASE ('T') ; prot(:,:) = pyin(:,:) * gcost(:,:) + pxin(:,:) * gsint(:,:) |
---|
| 151 | CASE ('U') ; prot(:,:) = pyin(:,:) * gcosu(:,:) + pxin(:,:) * gsinu(:,:) |
---|
| 152 | CASE ('V') ; prot(:,:) = pyin(:,:) * gcosv(:,:) + pxin(:,:) * gsinv(:,:) |
---|
| 153 | CASE ('F') ; prot(:,:) = pyin(:,:) * gcosf(:,:) + pxin(:,:) * gsinf(:,:) |
---|
[672] | 154 | CASE DEFAULT ; CALL ctl_stop( 'Only T, U, V and F grid points are coded' ) |
---|
| 155 | END SELECT |
---|
| 156 | CASE DEFAULT ; CALL ctl_stop( 'rot_rep: Syntax Error in the definition of cdtodo' ) |
---|
[6140] | 157 | ! |
---|
[672] | 158 | END SELECT |
---|
[6140] | 159 | ! |
---|
[685] | 160 | END SUBROUTINE rot_rep |
---|
[3] | 161 | |
---|
| 162 | |
---|
| 163 | SUBROUTINE angle |
---|
| 164 | !!---------------------------------------------------------------------- |
---|
| 165 | !! *** ROUTINE angle *** |
---|
| 166 | !! |
---|
[672] | 167 | !! ** Purpose : Compute angles between model grid lines and the North direction |
---|
[3] | 168 | !! |
---|
[6140] | 169 | !! ** Method : sinus and cosinus of the angle between the north-south axe |
---|
| 170 | !! and the j-direction at t, u, v and f-points |
---|
| 171 | !! dot and cross products are used to obtain cos and sin, resp. |
---|
[3] | 172 | !! |
---|
[6140] | 173 | !! ** Action : - gsint, gcost, gsinu, gcosu, gsinv, gcosv, gsinf, gcosf |
---|
[3] | 174 | !!---------------------------------------------------------------------- |
---|
[6140] | 175 | INTEGER :: ji, jj ! dummy loop indices |
---|
| 176 | INTEGER :: ierr ! local integer |
---|
| 177 | REAL(wp) :: zlam, zphi ! local scalars |
---|
| 178 | REAL(wp) :: zlan, zphh ! - - |
---|
| 179 | REAL(wp) :: zxnpt, zynpt, znnpt ! x,y components and norm of the vector: T point to North Pole |
---|
| 180 | REAL(wp) :: zxnpu, zynpu, znnpu ! x,y components and norm of the vector: U point to North Pole |
---|
| 181 | REAL(wp) :: zxnpv, zynpv, znnpv ! x,y components and norm of the vector: V point to North Pole |
---|
| 182 | REAL(wp) :: zxnpf, zynpf, znnpf ! x,y components and norm of the vector: F point to North Pole |
---|
| 183 | REAL(wp) :: zxvvt, zyvvt, znvvt ! x,y components and norm of the vector: between V points below and above a T point |
---|
| 184 | REAL(wp) :: zxffu, zyffu, znffu ! x,y components and norm of the vector: between F points below and above a U point |
---|
| 185 | REAL(wp) :: zxffv, zyffv, znffv ! x,y components and norm of the vector: between F points left and right a V point |
---|
| 186 | REAL(wp) :: zxuuf, zyuuf, znuuf ! x,y components and norm of the vector: between U points below and above a F point |
---|
[3] | 187 | !!---------------------------------------------------------------------- |
---|
[6140] | 188 | ! |
---|
[2715] | 189 | ALLOCATE( gsint(jpi,jpj), gcost(jpi,jpj), & |
---|
| 190 | & gsinu(jpi,jpj), gcosu(jpi,jpj), & |
---|
| 191 | & gsinv(jpi,jpj), gcosv(jpi,jpj), & |
---|
| 192 | & gsinf(jpi,jpj), gcosf(jpi,jpj), STAT=ierr ) |
---|
| 193 | IF(lk_mpp) CALL mpp_sum( ierr ) |
---|
[6140] | 194 | IF( ierr /= 0 ) CALL ctl_stop( 'angle: unable to allocate arrays' ) |
---|
| 195 | ! |
---|
[3] | 196 | ! ============================= ! |
---|
| 197 | ! Compute the cosinus and sinus ! |
---|
| 198 | ! ============================= ! |
---|
| 199 | ! (computation done on the north stereographic polar plane) |
---|
[6140] | 200 | ! |
---|
[672] | 201 | DO jj = 2, jpjm1 |
---|
[3] | 202 | DO ji = fs_2, jpi ! vector opt. |
---|
[6140] | 203 | ! |
---|
| 204 | zlam = glamt(ji,jj) ! north pole direction & modulous (at t-point) |
---|
[672] | 205 | zphi = gphit(ji,jj) |
---|
| 206 | zxnpt = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
| 207 | zynpt = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
| 208 | znnpt = zxnpt*zxnpt + zynpt*zynpt |
---|
[6140] | 209 | ! |
---|
| 210 | zlam = glamu(ji,jj) ! north pole direction & modulous (at u-point) |
---|
[3] | 211 | zphi = gphiu(ji,jj) |
---|
| 212 | zxnpu = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
| 213 | zynpu = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
| 214 | znnpu = zxnpu*zxnpu + zynpu*zynpu |
---|
[6140] | 215 | ! |
---|
| 216 | zlam = glamv(ji,jj) ! north pole direction & modulous (at v-point) |
---|
[3] | 217 | zphi = gphiv(ji,jj) |
---|
| 218 | zxnpv = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
| 219 | zynpv = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
| 220 | znnpv = zxnpv*zxnpv + zynpv*zynpv |
---|
[6140] | 221 | ! |
---|
| 222 | zlam = glamf(ji,jj) ! north pole direction & modulous (at f-point) |
---|
[672] | 223 | zphi = gphif(ji,jj) |
---|
| 224 | zxnpf = 0. - 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
| 225 | zynpf = 0. - 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) |
---|
| 226 | znnpf = zxnpf*zxnpf + zynpf*zynpf |
---|
[6140] | 227 | ! |
---|
| 228 | zlam = glamv(ji,jj ) ! j-direction: v-point segment direction (around t-point) |
---|
[672] | 229 | zphi = gphiv(ji,jj ) |
---|
| 230 | zlan = glamv(ji,jj-1) |
---|
| 231 | zphh = gphiv(ji,jj-1) |
---|
| 232 | zxvvt = 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
| 233 | & - 2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
| 234 | zyvvt = 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
| 235 | & - 2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
| 236 | znvvt = SQRT( znnpt * ( zxvvt*zxvvt + zyvvt*zyvvt ) ) |
---|
| 237 | znvvt = MAX( znvvt, 1.e-14 ) |
---|
[6140] | 238 | ! |
---|
| 239 | zlam = glamf(ji,jj ) ! j-direction: f-point segment direction (around u-point) |
---|
[3] | 240 | zphi = gphif(ji,jj ) |
---|
| 241 | zlan = glamf(ji,jj-1) |
---|
| 242 | zphh = gphif(ji,jj-1) |
---|
| 243 | zxffu = 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
| 244 | & - 2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
| 245 | zyffu = 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
| 246 | & - 2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
[672] | 247 | znffu = SQRT( znnpu * ( zxffu*zxffu + zyffu*zyffu ) ) |
---|
| 248 | znffu = MAX( znffu, 1.e-14 ) |
---|
[6140] | 249 | ! |
---|
| 250 | zlam = glamf(ji ,jj) ! i-direction: f-point segment direction (around v-point) |
---|
[3] | 251 | zphi = gphif(ji ,jj) |
---|
| 252 | zlan = glamf(ji-1,jj) |
---|
| 253 | zphh = gphif(ji-1,jj) |
---|
| 254 | zxffv = 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
| 255 | & - 2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
| 256 | zyffv = 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
| 257 | & - 2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
[672] | 258 | znffv = SQRT( znnpv * ( zxffv*zxffv + zyffv*zyffv ) ) |
---|
| 259 | znffv = MAX( znffv, 1.e-14 ) |
---|
[6140] | 260 | ! |
---|
| 261 | zlam = glamu(ji,jj+1) ! j-direction: u-point segment direction (around f-point) |
---|
[672] | 262 | zphi = gphiu(ji,jj+1) |
---|
| 263 | zlan = glamu(ji,jj ) |
---|
| 264 | zphh = gphiu(ji,jj ) |
---|
| 265 | zxuuf = 2. * COS( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
| 266 | & - 2. * COS( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
| 267 | zyuuf = 2. * SIN( rad*zlam ) * TAN( rpi/4. - rad*zphi/2. ) & |
---|
| 268 | & - 2. * SIN( rad*zlan ) * TAN( rpi/4. - rad*zphh/2. ) |
---|
| 269 | znuuf = SQRT( znnpf * ( zxuuf*zxuuf + zyuuf*zyuuf ) ) |
---|
| 270 | znuuf = MAX( znuuf, 1.e-14 ) |
---|
[6140] | 271 | ! |
---|
| 272 | ! ! cosinus and sinus using dot and cross products |
---|
[672] | 273 | gsint(ji,jj) = ( zxnpt*zyvvt - zynpt*zxvvt ) / znvvt |
---|
| 274 | gcost(ji,jj) = ( zxnpt*zxvvt + zynpt*zyvvt ) / znvvt |
---|
[6140] | 275 | ! |
---|
[672] | 276 | gsinu(ji,jj) = ( zxnpu*zyffu - zynpu*zxffu ) / znffu |
---|
| 277 | gcosu(ji,jj) = ( zxnpu*zxffu + zynpu*zyffu ) / znffu |
---|
[6140] | 278 | ! |
---|
[672] | 279 | gsinf(ji,jj) = ( zxnpf*zyuuf - zynpf*zxuuf ) / znuuf |
---|
| 280 | gcosf(ji,jj) = ( zxnpf*zxuuf + zynpf*zyuuf ) / znuuf |
---|
[6140] | 281 | ! |
---|
[672] | 282 | gsinv(ji,jj) = ( zxnpv*zxffv + zynpv*zyffv ) / znffv |
---|
[6140] | 283 | gcosv(ji,jj) =-( zxnpv*zyffv - zynpv*zxffv ) / znffv ! (caution, rotation of 90 degres) |
---|
| 284 | ! |
---|
[3] | 285 | END DO |
---|
| 286 | END DO |
---|
| 287 | |
---|
| 288 | ! =============== ! |
---|
| 289 | ! Geographic mesh ! |
---|
| 290 | ! =============== ! |
---|
| 291 | |
---|
[672] | 292 | DO jj = 2, jpjm1 |
---|
[3] | 293 | DO ji = fs_2, jpi ! vector opt. |
---|
[672] | 294 | IF( MOD( ABS( glamv(ji,jj) - glamv(ji,jj-1) ), 360. ) < 1.e-8 ) THEN |
---|
| 295 | gsint(ji,jj) = 0. |
---|
| 296 | gcost(ji,jj) = 1. |
---|
| 297 | ENDIF |
---|
| 298 | IF( MOD( ABS( glamf(ji,jj) - glamf(ji,jj-1) ), 360. ) < 1.e-8 ) THEN |
---|
[3] | 299 | gsinu(ji,jj) = 0. |
---|
| 300 | gcosu(ji,jj) = 1. |
---|
| 301 | ENDIF |
---|
[672] | 302 | IF( ABS( gphif(ji,jj) - gphif(ji-1,jj) ) < 1.e-8 ) THEN |
---|
[3] | 303 | gsinv(ji,jj) = 0. |
---|
| 304 | gcosv(ji,jj) = 1. |
---|
| 305 | ENDIF |
---|
[672] | 306 | IF( MOD( ABS( glamu(ji,jj) - glamu(ji,jj+1) ), 360. ) < 1.e-8 ) THEN |
---|
| 307 | gsinf(ji,jj) = 0. |
---|
| 308 | gcosf(ji,jj) = 1. |
---|
| 309 | ENDIF |
---|
[3] | 310 | END DO |
---|
| 311 | END DO |
---|
| 312 | |
---|
| 313 | ! =========================== ! |
---|
| 314 | ! Lateral boundary conditions ! |
---|
| 315 | ! =========================== ! |
---|
[6140] | 316 | ! ! lateral boundary cond.: T-, U-, V-, F-pts, sgn |
---|
[1833] | 317 | CALL lbc_lnk( gcost, 'T', -1. ) ; CALL lbc_lnk( gsint, 'T', -1. ) |
---|
| 318 | CALL lbc_lnk( gcosu, 'U', -1. ) ; CALL lbc_lnk( gsinu, 'U', -1. ) |
---|
| 319 | CALL lbc_lnk( gcosv, 'V', -1. ) ; CALL lbc_lnk( gsinv, 'V', -1. ) |
---|
| 320 | CALL lbc_lnk( gcosf, 'F', -1. ) ; CALL lbc_lnk( gsinf, 'F', -1. ) |
---|
[6140] | 321 | ! |
---|
[3] | 322 | END SUBROUTINE angle |
---|
| 323 | |
---|
| 324 | |
---|
[6140] | 325 | SUBROUTINE geo2oce ( pxx, pyy, pzz, cgrid, pte, ptn ) |
---|
[3] | 326 | !!---------------------------------------------------------------------- |
---|
| 327 | !! *** ROUTINE geo2oce *** |
---|
| 328 | !! |
---|
| 329 | !! ** Purpose : |
---|
| 330 | !! |
---|
[6140] | 331 | !! ** Method : Change a vector from geocentric to east/north |
---|
[3] | 332 | !! |
---|
| 333 | !!---------------------------------------------------------------------- |
---|
[1218] | 334 | REAL(wp), DIMENSION(jpi,jpj), INTENT(in ) :: pxx, pyy, pzz |
---|
| 335 | CHARACTER(len=1) , INTENT(in ) :: cgrid |
---|
| 336 | REAL(wp), DIMENSION(jpi,jpj), INTENT( out) :: pte, ptn |
---|
[6140] | 337 | ! |
---|
[2715] | 338 | REAL(wp), PARAMETER :: rpi = 3.141592653e0 |
---|
[88] | 339 | REAL(wp), PARAMETER :: rad = rpi / 180.e0 |
---|
[1218] | 340 | INTEGER :: ig ! |
---|
[2715] | 341 | INTEGER :: ierr ! local integer |
---|
[1218] | 342 | !!---------------------------------------------------------------------- |
---|
[6140] | 343 | ! |
---|
[2715] | 344 | IF( .NOT. ALLOCATED( gsinlon ) ) THEN |
---|
| 345 | ALLOCATE( gsinlon(jpi,jpj,4) , gcoslon(jpi,jpj,4) , & |
---|
| 346 | & gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr ) |
---|
| 347 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
[4162] | 348 | IF( ierr /= 0 ) CALL ctl_stop('geo2oce: unable to allocate arrays' ) |
---|
[2715] | 349 | ENDIF |
---|
[6140] | 350 | ! |
---|
[1218] | 351 | SELECT CASE( cgrid) |
---|
[6140] | 352 | CASE ( 'T' ) |
---|
| 353 | ig = 1 |
---|
| 354 | IF( .NOT. linit(ig) ) THEN |
---|
| 355 | gsinlon(:,:,ig) = SIN( rad * glamt(:,:) ) |
---|
| 356 | gcoslon(:,:,ig) = COS( rad * glamt(:,:) ) |
---|
| 357 | gsinlat(:,:,ig) = SIN( rad * gphit(:,:) ) |
---|
| 358 | gcoslat(:,:,ig) = COS( rad * gphit(:,:) ) |
---|
| 359 | linit(ig) = .TRUE. |
---|
| 360 | ENDIF |
---|
| 361 | CASE ( 'U' ) |
---|
| 362 | ig = 2 |
---|
| 363 | IF( .NOT. linit(ig) ) THEN |
---|
| 364 | gsinlon(:,:,ig) = SIN( rad * glamu(:,:) ) |
---|
| 365 | gcoslon(:,:,ig) = COS( rad * glamu(:,:) ) |
---|
| 366 | gsinlat(:,:,ig) = SIN( rad * gphiu(:,:) ) |
---|
| 367 | gcoslat(:,:,ig) = COS( rad * gphiu(:,:) ) |
---|
| 368 | linit(ig) = .TRUE. |
---|
| 369 | ENDIF |
---|
| 370 | CASE ( 'V' ) |
---|
| 371 | ig = 3 |
---|
| 372 | IF( .NOT. linit(ig) ) THEN |
---|
| 373 | gsinlon(:,:,ig) = SIN( rad * glamv(:,:) ) |
---|
| 374 | gcoslon(:,:,ig) = COS( rad * glamv(:,:) ) |
---|
| 375 | gsinlat(:,:,ig) = SIN( rad * gphiv(:,:) ) |
---|
| 376 | gcoslat(:,:,ig) = COS( rad * gphiv(:,:) ) |
---|
| 377 | linit(ig) = .TRUE. |
---|
| 378 | ENDIF |
---|
| 379 | CASE ( 'F' ) |
---|
| 380 | ig = 4 |
---|
| 381 | IF( .NOT. linit(ig) ) THEN |
---|
| 382 | gsinlon(:,:,ig) = SIN( rad * glamf(:,:) ) |
---|
| 383 | gcoslon(:,:,ig) = COS( rad * glamf(:,:) ) |
---|
| 384 | gsinlat(:,:,ig) = SIN( rad * gphif(:,:) ) |
---|
| 385 | gcoslat(:,:,ig) = COS( rad * gphif(:,:) ) |
---|
| 386 | linit(ig) = .TRUE. |
---|
| 387 | ENDIF |
---|
| 388 | CASE default |
---|
| 389 | WRITE(ctmp1,*) 'geo2oce : bad grid argument : ', cgrid |
---|
| 390 | CALL ctl_stop( ctmp1 ) |
---|
[1218] | 391 | END SELECT |
---|
[6140] | 392 | ! |
---|
[2715] | 393 | pte = - gsinlon(:,:,ig) * pxx + gcoslon(:,:,ig) * pyy |
---|
| 394 | ptn = - gcoslon(:,:,ig) * gsinlat(:,:,ig) * pxx & |
---|
[6140] | 395 | & - gsinlon(:,:,ig) * gsinlat(:,:,ig) * pyy & |
---|
| 396 | & + gcoslat(:,:,ig) * pzz |
---|
[1218] | 397 | ! |
---|
| 398 | END SUBROUTINE geo2oce |
---|
| 399 | |
---|
[6140] | 400 | |
---|
| 401 | SUBROUTINE oce2geo ( pte, ptn, cgrid, pxx , pyy , pzz ) |
---|
[1218] | 402 | !!---------------------------------------------------------------------- |
---|
| 403 | !! *** ROUTINE oce2geo *** |
---|
| 404 | !! |
---|
| 405 | !! ** Purpose : |
---|
| 406 | !! |
---|
| 407 | !! ** Method : Change vector from east/north to geocentric |
---|
| 408 | !! |
---|
[6140] | 409 | !! History : ! (A. Caubel) oce2geo - Original code |
---|
[1218] | 410 | !!---------------------------------------------------------------------- |
---|
| 411 | REAL(wp), DIMENSION(jpi,jpj), INTENT( IN ) :: pte, ptn |
---|
| 412 | CHARACTER(len=1) , INTENT( IN ) :: cgrid |
---|
| 413 | REAL(wp), DIMENSION(jpi,jpj), INTENT( OUT ) :: pxx , pyy , pzz |
---|
| 414 | !! |
---|
| 415 | REAL(wp), PARAMETER :: rpi = 3.141592653E0 |
---|
| 416 | REAL(wp), PARAMETER :: rad = rpi / 180.e0 |
---|
[3] | 417 | INTEGER :: ig ! |
---|
[2715] | 418 | INTEGER :: ierr ! local integer |
---|
[3] | 419 | !!---------------------------------------------------------------------- |
---|
| 420 | |
---|
[4162] | 421 | IF( .NOT. ALLOCATED( gsinlon ) ) THEN |
---|
[2715] | 422 | ALLOCATE( gsinlon(jpi,jpj,4) , gcoslon(jpi,jpj,4) , & |
---|
| 423 | & gsinlat(jpi,jpj,4) , gcoslat(jpi,jpj,4) , STAT=ierr ) |
---|
| 424 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
[4162] | 425 | IF( ierr /= 0 ) CALL ctl_stop('oce2geo: unable to allocate arrays' ) |
---|
[2715] | 426 | ENDIF |
---|
| 427 | |
---|
[3] | 428 | SELECT CASE( cgrid) |
---|
[1226] | 429 | CASE ( 'T' ) |
---|
| 430 | ig = 1 |
---|
| 431 | IF( .NOT. linit(ig) ) THEN |
---|
[2715] | 432 | gsinlon(:,:,ig) = SIN( rad * glamt(:,:) ) |
---|
| 433 | gcoslon(:,:,ig) = COS( rad * glamt(:,:) ) |
---|
| 434 | gsinlat(:,:,ig) = SIN( rad * gphit(:,:) ) |
---|
| 435 | gcoslat(:,:,ig) = COS( rad * gphit(:,:) ) |
---|
[1226] | 436 | linit(ig) = .TRUE. |
---|
| 437 | ENDIF |
---|
| 438 | CASE ( 'U' ) |
---|
| 439 | ig = 2 |
---|
| 440 | IF( .NOT. linit(ig) ) THEN |
---|
[2715] | 441 | gsinlon(:,:,ig) = SIN( rad * glamu(:,:) ) |
---|
| 442 | gcoslon(:,:,ig) = COS( rad * glamu(:,:) ) |
---|
| 443 | gsinlat(:,:,ig) = SIN( rad * gphiu(:,:) ) |
---|
| 444 | gcoslat(:,:,ig) = COS( rad * gphiu(:,:) ) |
---|
[1226] | 445 | linit(ig) = .TRUE. |
---|
| 446 | ENDIF |
---|
| 447 | CASE ( 'V' ) |
---|
| 448 | ig = 3 |
---|
| 449 | IF( .NOT. linit(ig) ) THEN |
---|
[2715] | 450 | gsinlon(:,:,ig) = SIN( rad * glamv(:,:) ) |
---|
| 451 | gcoslon(:,:,ig) = COS( rad * glamv(:,:) ) |
---|
| 452 | gsinlat(:,:,ig) = SIN( rad * gphiv(:,:) ) |
---|
| 453 | gcoslat(:,:,ig) = COS( rad * gphiv(:,:) ) |
---|
[1226] | 454 | linit(ig) = .TRUE. |
---|
| 455 | ENDIF |
---|
| 456 | CASE ( 'F' ) |
---|
| 457 | ig = 4 |
---|
| 458 | IF( .NOT. linit(ig) ) THEN |
---|
[2715] | 459 | gsinlon(:,:,ig) = SIN( rad * glamf(:,:) ) |
---|
| 460 | gcoslon(:,:,ig) = COS( rad * glamf(:,:) ) |
---|
| 461 | gsinlat(:,:,ig) = SIN( rad * gphif(:,:) ) |
---|
| 462 | gcoslat(:,:,ig) = COS( rad * gphif(:,:) ) |
---|
[1226] | 463 | linit(ig) = .TRUE. |
---|
| 464 | ENDIF |
---|
| 465 | CASE default |
---|
| 466 | WRITE(ctmp1,*) 'geo2oce : bad grid argument : ', cgrid |
---|
[474] | 467 | CALL ctl_stop( ctmp1 ) |
---|
[1226] | 468 | END SELECT |
---|
[6140] | 469 | ! |
---|
| 470 | pxx = - gsinlon(:,:,ig) * pte - gcoslon(:,:,ig) * gsinlat(:,:,ig) * ptn |
---|
| 471 | pyy = gcoslon(:,:,ig) * pte - gsinlon(:,:,ig) * gsinlat(:,:,ig) * ptn |
---|
| 472 | pzz = gcoslat(:,:,ig) * ptn |
---|
| 473 | ! |
---|
[1218] | 474 | END SUBROUTINE oce2geo |
---|
[3] | 475 | |
---|
| 476 | |
---|
[6140] | 477 | SUBROUTINE obs_rot( psinu, pcosu, psinv, pcosv ) |
---|
[3] | 478 | !!---------------------------------------------------------------------- |
---|
[2528] | 479 | !! *** ROUTINE obs_rot *** |
---|
| 480 | !! |
---|
| 481 | !! ** Purpose : Copy gsinu, gcosu, gsinv and gsinv |
---|
| 482 | !! to input data for rotations of |
---|
| 483 | !! current at observation points |
---|
| 484 | !! |
---|
[6140] | 485 | !! History : 9.2 ! 09-02 (K. Mogensen) |
---|
[2528] | 486 | !!---------------------------------------------------------------------- |
---|
[2715] | 487 | REAL(wp), DIMENSION(jpi,jpj), INTENT( OUT ):: psinu, pcosu, psinv, pcosv ! copy of data |
---|
[2528] | 488 | !!---------------------------------------------------------------------- |
---|
[6140] | 489 | ! |
---|
[2528] | 490 | ! Initialization of gsin* and gcos* at first call |
---|
| 491 | ! ----------------------------------------------- |
---|
| 492 | IF( lmust_init ) THEN |
---|
| 493 | IF(lwp) WRITE(numout,*) |
---|
| 494 | IF(lwp) WRITE(numout,*) ' obs_rot : geographic <--> stretched' |
---|
| 495 | IF(lwp) WRITE(numout,*) ' ~~~~~~~ coordinate transformation' |
---|
| 496 | CALL angle ! initialization of the transformation |
---|
| 497 | lmust_init = .FALSE. |
---|
| 498 | ENDIF |
---|
[6140] | 499 | ! |
---|
[2528] | 500 | psinu(:,:) = gsinu(:,:) |
---|
| 501 | pcosu(:,:) = gcosu(:,:) |
---|
| 502 | psinv(:,:) = gsinv(:,:) |
---|
| 503 | pcosv(:,:) = gcosv(:,:) |
---|
[6140] | 504 | ! |
---|
[2528] | 505 | END SUBROUTINE obs_rot |
---|
| 506 | |
---|
[3] | 507 | !!====================================================================== |
---|
| 508 | END MODULE geo2ocean |
---|