[6951] | 1 | MODULE domhgr |
---|
| 2 | !!============================================================================== |
---|
| 3 | !! *** MODULE domhgr *** |
---|
| 4 | !! Ocean initialization : domain initialization |
---|
| 5 | !!============================================================================== |
---|
| 6 | !! History : OPA ! 1988-03 (G. Madec) Original code |
---|
| 7 | !! 7.0 ! 1996-01 (G. Madec) terrain following coordinates |
---|
| 8 | !! 8.0 ! 1997-02 (G. Madec) print mesh informations |
---|
| 9 | !! 8.1 ! 1999-11 (M. Imbard) NetCDF format with IO-IPSL |
---|
| 10 | !! 8.2 ! 2000-08 (D. Ludicone) Reduced section at Bab el Mandeb |
---|
| 11 | !! - ! 2001-09 (M. Levy) eel config: grid in km, beta-plane |
---|
| 12 | !! NEMO 1.0 ! 2002-08 (G. Madec) F90: Free form and module, namelist |
---|
| 13 | !! - ! 2004-01 (A.M. Treguier, J.M. Molines) Case 4 (Mercator mesh) |
---|
| 14 | !! use of parameters in par_CONFIG-Rxx.h90, not in namelist |
---|
| 15 | !! - ! 2004-05 (A. Koch-Larrouy) Add Gyre configuration |
---|
| 16 | !! 3.7 ! 2015-09 (G. Madec, S. Flavoni) add cell surface and their inverse |
---|
| 17 | !! add optional read of e1e2u & e1e2v |
---|
| 18 | !!---------------------------------------------------------------------- |
---|
| 19 | |
---|
| 20 | !!---------------------------------------------------------------------- |
---|
| 21 | !! dom_hgr : initialize the horizontal mesh |
---|
| 22 | !! hgr_read : read "coordinate" NetCDF file |
---|
| 23 | !!---------------------------------------------------------------------- |
---|
| 24 | USE dom_oce ! ocean space and time domain |
---|
| 25 | USE phycst ! physical constants |
---|
| 26 | USE domwri ! write 'meshmask.nc' & 'coordinate_e1e2u_v.nc' files |
---|
| 27 | ! |
---|
| 28 | USE in_out_manager ! I/O manager |
---|
| 29 | USE lib_mpp ! MPP library |
---|
| 30 | |
---|
| 31 | IMPLICIT NONE |
---|
| 32 | PRIVATE |
---|
| 33 | |
---|
| 34 | REAL(wp) :: glam0, gphi0 ! variables corresponding to parameters ppglam0 ppgphi0 set in par_oce |
---|
| 35 | |
---|
| 36 | PUBLIC dom_hgr ! called by domain.F90 |
---|
| 37 | |
---|
| 38 | !!---------------------------------------------------------------------- |
---|
| 39 | !! NEMO/OPA 3.7 , NEMO Consortium (2014) |
---|
| 40 | !! $Id: domhgr.F90 6140 2015-12-21 11:35:23Z timgraham $ |
---|
[9598] | 41 | !! Software governed by the CeCILL licence (./LICENSE) |
---|
[6951] | 42 | !!---------------------------------------------------------------------- |
---|
| 43 | CONTAINS |
---|
| 44 | |
---|
| 45 | SUBROUTINE dom_hgr |
---|
| 46 | !!---------------------------------------------------------------------- |
---|
| 47 | !! *** ROUTINE dom_hgr *** |
---|
| 48 | !! |
---|
| 49 | !! ** Purpose : Compute the geographical position (in degre) of the |
---|
| 50 | !! model grid-points, the horizontal scale factors (in meters) and |
---|
| 51 | !! the Coriolis factor (in s-1). |
---|
| 52 | !! |
---|
| 53 | !! ** Method : The geographical position of the model grid-points is |
---|
| 54 | !! defined from analytical functions, fslam and fsphi, the deriva- |
---|
| 55 | !! tives of which gives the horizontal scale factors e1,e2. |
---|
| 56 | !! Defining two function fslam and fsphi and their derivatives in |
---|
| 57 | !! the two horizontal directions (fse1 and fse2), the model grid- |
---|
| 58 | !! point position and scale factors are given by: |
---|
| 59 | !! t-point: |
---|
| 60 | !! glamt(i,j) = fslam(i ,j ) e1t(i,j) = fse1(i ,j ) |
---|
| 61 | !! gphit(i,j) = fsphi(i ,j ) e2t(i,j) = fse2(i ,j ) |
---|
| 62 | !! u-point: |
---|
| 63 | !! glamu(i,j) = fslam(i+1/2,j ) e1u(i,j) = fse1(i+1/2,j ) |
---|
| 64 | !! gphiu(i,j) = fsphi(i+1/2,j ) e2u(i,j) = fse2(i+1/2,j ) |
---|
| 65 | !! v-point: |
---|
| 66 | !! glamv(i,j) = fslam(i ,j+1/2) e1v(i,j) = fse1(i ,j+1/2) |
---|
| 67 | !! gphiv(i,j) = fsphi(i ,j+1/2) e2v(i,j) = fse2(i ,j+1/2) |
---|
| 68 | !! f-point: |
---|
| 69 | !! glamf(i,j) = fslam(i+1/2,j+1/2) e1f(i,j) = fse1(i+1/2,j+1/2) |
---|
| 70 | !! gphif(i,j) = fsphi(i+1/2,j+1/2) e2f(i,j) = fse2(i+1/2,j+1/2) |
---|
| 71 | !! Where fse1 and fse2 are defined by: |
---|
| 72 | !! fse1(i,j) = ra * rad * SQRT( (cos(phi) di(fslam))**2 |
---|
| 73 | !! + di(fsphi) **2 )(i,j) |
---|
| 74 | !! fse2(i,j) = ra * rad * SQRT( (cos(phi) dj(fslam))**2 |
---|
| 75 | !! + dj(fsphi) **2 )(i,j) |
---|
| 76 | !! |
---|
| 77 | !! The coriolis factor is given at z-point by: |
---|
| 78 | !! ff = 2.*omega*sin(gphif) (in s-1) |
---|
| 79 | !! |
---|
| 80 | !! This routine is given as an example, it must be modified |
---|
| 81 | !! following the user s desiderata. nevertheless, the output as |
---|
| 82 | !! well as the way to compute the model grid-point position and |
---|
| 83 | !! horizontal scale factors must be respected in order to insure |
---|
| 84 | !! second order accuracy schemes. |
---|
| 85 | !! |
---|
| 86 | !! N.B. If the domain is periodic, verify that scale factors are also |
---|
| 87 | !! periodic, and the coriolis term again. |
---|
| 88 | !! |
---|
| 89 | !! ** Action : - define glamt, glamu, glamv, glamf: longitude of t-, |
---|
| 90 | !! u-, v- and f-points (in degre) |
---|
| 91 | !! - define gphit, gphiu, gphiv, gphit: latitude of t-, |
---|
| 92 | !! u-, v- and f-points (in degre) |
---|
| 93 | !! define e1t, e2t, e1u, e2u, e1v, e2v, e1f, e2f: horizontal |
---|
| 94 | !! scale factors (in meters) at t-, u-, v-, and f-points. |
---|
| 95 | !! define ff: coriolis factor at f-point |
---|
| 96 | !! |
---|
| 97 | !! References : Marti, Madec and Delecluse, 1992, JGR |
---|
| 98 | !! Madec, Imbard, 1996, Clim. Dyn. |
---|
| 99 | !!---------------------------------------------------------------------- |
---|
| 100 | INTEGER :: ji, jj ! dummy loop indices |
---|
| 101 | INTEGER :: ii0, ii1, ij0, ij1 ! temporary integers |
---|
| 102 | INTEGER :: ijeq ! index of equator T point (used in case 4) |
---|
| 103 | REAL(wp) :: zti, zui, zvi, zfi ! local scalars |
---|
| 104 | REAL(wp) :: ztj, zuj, zvj, zfj ! - - |
---|
| 105 | REAL(wp) :: zphi0, zbeta, znorme ! |
---|
| 106 | REAL(wp) :: zarg, zf0, zminff, zmaxff |
---|
| 107 | REAL(wp) :: zlam1, zcos_alpha, zim1 , zjm1 , ze1, ze1deg |
---|
| 108 | REAL(wp) :: zphi1, zsin_alpha, zim05, zjm05 |
---|
| 109 | INTEGER :: isrow ! index for ORCA1 starting row |
---|
| 110 | INTEGER :: ie1e2u_v ! fag for u- & v-surface read in coordinate file or not |
---|
| 111 | !!---------------------------------------------------------------------- |
---|
| 112 | ! |
---|
| 113 | IF(lwp) THEN |
---|
| 114 | WRITE(numout,*) |
---|
| 115 | WRITE(numout,*) 'dom_hgr : define the horizontal mesh from ithe following par_oce parameters ' |
---|
| 116 | WRITE(numout,*) '~~~~~~~ type of horizontal mesh jphgr_msh = ', jphgr_msh |
---|
| 117 | WRITE(numout,*) ' position of the first row and ppglam0 = ', ppglam0 |
---|
| 118 | WRITE(numout,*) ' column grid-point (degrees) ppgphi0 = ', ppgphi0 |
---|
| 119 | WRITE(numout,*) ' zonal grid-spacing (degrees) ppe1_deg = ', ppe1_deg |
---|
| 120 | WRITE(numout,*) ' meridional grid-spacing (degrees) ppe2_deg = ', ppe2_deg |
---|
| 121 | WRITE(numout,*) ' zonal grid-spacing (meters) ppe1_m = ', ppe1_m |
---|
| 122 | WRITE(numout,*) ' meridional grid-spacing (meters) ppe2_m = ', ppe2_m |
---|
| 123 | ENDIF |
---|
| 124 | ! |
---|
| 125 | ! |
---|
[14630] | 126 | #if defined key_agrif |
---|
| 127 | IF (agrif_root()) THEN |
---|
| 128 | #endif |
---|
| 129 | ! |
---|
[6951] | 130 | SELECT CASE( jphgr_msh ) ! type of horizontal mesh |
---|
| 131 | ! |
---|
| 132 | CASE ( 0 ) !== read in coordinate.nc file ==! |
---|
| 133 | ! |
---|
| 134 | IF(lwp) WRITE(numout,*) |
---|
| 135 | IF(lwp) WRITE(numout,*) ' curvilinear coordinate on the sphere read in "coordinate" file' |
---|
| 136 | ! |
---|
| 137 | ie1e2u_v = 0 ! set to unread e1e2u and e1e2v |
---|
| 138 | ! |
---|
| 139 | CALL hgr_read( ie1e2u_v ) ! read the coordinate.nc file |
---|
| 140 | ! |
---|
| 141 | IF( ie1e2u_v == 0 ) THEN ! e1e2u and e1e2v have not been read: compute them |
---|
| 142 | ! ! e2u and e1v does not include a reduction in some strait: apply reduction |
---|
| 143 | e1e2u (:,:) = e1u(:,:) * e2u(:,:) |
---|
| 144 | e1e2v (:,:) = e1v(:,:) * e2v(:,:) |
---|
| 145 | ENDIF |
---|
| 146 | ! |
---|
| 147 | CASE ( 1 ) !== geographical mesh on the sphere with regular (in degree) grid-spacing ==! |
---|
| 148 | ! |
---|
| 149 | IF(lwp) WRITE(numout,*) |
---|
| 150 | IF(lwp) WRITE(numout,*) ' geographical mesh on the sphere with regular grid-spacing' |
---|
| 151 | IF(lwp) WRITE(numout,*) ' given by ppe1_deg and ppe2_deg' |
---|
| 152 | ! |
---|
| 153 | DO jj = 1, jpj |
---|
| 154 | DO ji = 1, jpi |
---|
| 155 | zti = REAL( ji - 1 + nimpp - 1 ) ; ztj = REAL( jj - 1 + njmpp - 1 ) |
---|
| 156 | zui = REAL( ji - 1 + nimpp - 1 ) + 0.5 ; zuj = REAL( jj - 1 + njmpp - 1 ) |
---|
| 157 | zvi = REAL( ji - 1 + nimpp - 1 ) ; zvj = REAL( jj - 1 + njmpp - 1 ) + 0.5 |
---|
| 158 | zfi = REAL( ji - 1 + nimpp - 1 ) + 0.5 ; zfj = REAL( jj - 1 + njmpp - 1 ) + 0.5 |
---|
| 159 | ! Longitude |
---|
| 160 | glamt(ji,jj) = ppglam0 + ppe1_deg * zti |
---|
| 161 | glamu(ji,jj) = ppglam0 + ppe1_deg * zui |
---|
| 162 | glamv(ji,jj) = ppglam0 + ppe1_deg * zvi |
---|
| 163 | glamf(ji,jj) = ppglam0 + ppe1_deg * zfi |
---|
| 164 | ! Latitude |
---|
| 165 | gphit(ji,jj) = ppgphi0 + ppe2_deg * ztj |
---|
| 166 | gphiu(ji,jj) = ppgphi0 + ppe2_deg * zuj |
---|
| 167 | gphiv(ji,jj) = ppgphi0 + ppe2_deg * zvj |
---|
| 168 | gphif(ji,jj) = ppgphi0 + ppe2_deg * zfj |
---|
| 169 | ! e1 |
---|
| 170 | e1t(ji,jj) = ra * rad * COS( rad * gphit(ji,jj) ) * ppe1_deg |
---|
| 171 | e1u(ji,jj) = ra * rad * COS( rad * gphiu(ji,jj) ) * ppe1_deg |
---|
| 172 | e1v(ji,jj) = ra * rad * COS( rad * gphiv(ji,jj) ) * ppe1_deg |
---|
| 173 | e1f(ji,jj) = ra * rad * COS( rad * gphif(ji,jj) ) * ppe1_deg |
---|
| 174 | ! e2 |
---|
| 175 | e2t(ji,jj) = ra * rad * ppe2_deg |
---|
| 176 | e2u(ji,jj) = ra * rad * ppe2_deg |
---|
| 177 | e2v(ji,jj) = ra * rad * ppe2_deg |
---|
| 178 | e2f(ji,jj) = ra * rad * ppe2_deg |
---|
| 179 | END DO |
---|
| 180 | END DO |
---|
| 181 | ! |
---|
| 182 | CASE ( 2:3 ) !== f- or beta-plane with regular grid-spacing ==! |
---|
| 183 | ! |
---|
| 184 | IF(lwp) WRITE(numout,*) |
---|
| 185 | IF(lwp) WRITE(numout,*) ' f- or beta-plane with regular grid-spacing' |
---|
| 186 | IF(lwp) WRITE(numout,*) ' given by ppe1_m and ppe2_m' |
---|
| 187 | ! |
---|
| 188 | ! Position coordinates (in kilometers) |
---|
| 189 | ! ========== |
---|
[14952] | 190 | glam0 = - 0.5*ppe1_m * 1.e-3 |
---|
| 191 | gphi0 = - 0.5*ppe2_m * 1.e-3 |
---|
[6951] | 192 | ! |
---|
[14952] | 193 | IF ( cp_cfg=='DOME' ) THEN |
---|
| 194 | glam0 = glam0 - 1700._wp |
---|
| 195 | gphi0 = gphi0 - 800._wp |
---|
| 196 | ENDIF |
---|
| 197 | ! |
---|
[6951] | 198 | DO jj = 1, jpj |
---|
| 199 | DO ji = 1, jpi |
---|
[14952] | 200 | glamt(ji,jj) = glam0 + ppe1_m * 1.e-3 * REAL( mig0(ji)-1 ) |
---|
| 201 | glamu(ji,jj) = glam0 + ppe1_m * 1.e-3 * REAL( mig0(ji)-0.5 ) |
---|
[6951] | 202 | glamv(ji,jj) = glamt(ji,jj) |
---|
| 203 | glamf(ji,jj) = glamu(ji,jj) |
---|
| 204 | ! |
---|
[14952] | 205 | gphit(ji,jj) = gphi0 + ppe2_m * 1.e-3 * REAL( mjg0(jj) -1 ) |
---|
[6951] | 206 | gphiu(ji,jj) = gphit(ji,jj) |
---|
[14952] | 207 | gphiv(ji,jj) = gphi0 + ppe2_m * 1.e-3 * REAL( mjg0(jj) -0.5 ) |
---|
[6951] | 208 | gphif(ji,jj) = gphiv(ji,jj) |
---|
| 209 | END DO |
---|
| 210 | END DO |
---|
| 211 | ! |
---|
| 212 | ! Horizontal scale factors (in meters) |
---|
| 213 | ! ====== |
---|
| 214 | e1t(:,:) = ppe1_m ; e2t(:,:) = ppe2_m |
---|
| 215 | e1u(:,:) = ppe1_m ; e2u(:,:) = ppe2_m |
---|
| 216 | e1v(:,:) = ppe1_m ; e2v(:,:) = ppe2_m |
---|
| 217 | e1f(:,:) = ppe1_m ; e2f(:,:) = ppe2_m |
---|
| 218 | ! |
---|
| 219 | CASE ( 4 ) !== geographical mesh on the sphere, isotropic MERCATOR type ==! |
---|
| 220 | ! |
---|
| 221 | IF(lwp) WRITE(numout,*) |
---|
| 222 | IF(lwp) WRITE(numout,*) ' geographical mesh on the sphere, MERCATOR type' |
---|
| 223 | IF(lwp) WRITE(numout,*) ' longitudinal/latitudinal spacing given by ppe1_deg' |
---|
| 224 | IF ( ppgphi0 == -90 ) CALL ctl_stop( ' Mercator grid cannot start at south pole !!!! ' ) |
---|
| 225 | ! |
---|
| 226 | ! Find index corresponding to the equator, given the grid spacing e1_deg |
---|
| 227 | ! and the (approximate) southern latitude ppgphi0. |
---|
| 228 | ! This way we ensure that the equator is at a "T / U" point, when in the domain. |
---|
| 229 | ! The formula should work even if the equator is outside the domain. |
---|
| 230 | zarg = rpi / 4. - rpi / 180. * ppgphi0 / 2. |
---|
| 231 | ijeq = ABS( 180./rpi * LOG( COS( zarg ) / SIN( zarg ) ) / ppe1_deg ) |
---|
| 232 | IF( ppgphi0 > 0 ) ijeq = -ijeq |
---|
| 233 | ! |
---|
| 234 | IF(lwp) WRITE(numout,*) ' Index of the equator on the MERCATOR grid:', ijeq |
---|
| 235 | ! |
---|
| 236 | DO jj = 1, jpj |
---|
| 237 | DO ji = 1, jpi |
---|
| 238 | zti = REAL( ji - 1 + nimpp - 1 ) ; ztj = REAL( jj - ijeq + njmpp - 1 ) |
---|
| 239 | zui = REAL( ji - 1 + nimpp - 1 ) + 0.5 ; zuj = REAL( jj - ijeq + njmpp - 1 ) |
---|
| 240 | zvi = REAL( ji - 1 + nimpp - 1 ) ; zvj = REAL( jj - ijeq + njmpp - 1 ) + 0.5 |
---|
| 241 | zfi = REAL( ji - 1 + nimpp - 1 ) + 0.5 ; zfj = REAL( jj - ijeq + njmpp - 1 ) + 0.5 |
---|
| 242 | ! Longitude |
---|
| 243 | glamt(ji,jj) = ppglam0 + ppe1_deg * zti |
---|
| 244 | glamu(ji,jj) = ppglam0 + ppe1_deg * zui |
---|
| 245 | glamv(ji,jj) = ppglam0 + ppe1_deg * zvi |
---|
| 246 | glamf(ji,jj) = ppglam0 + ppe1_deg * zfi |
---|
| 247 | ! Latitude |
---|
| 248 | gphit(ji,jj) = 1./rad * ASIN ( TANH( ppe1_deg *rad* ztj ) ) |
---|
| 249 | gphiu(ji,jj) = 1./rad * ASIN ( TANH( ppe1_deg *rad* zuj ) ) |
---|
| 250 | gphiv(ji,jj) = 1./rad * ASIN ( TANH( ppe1_deg *rad* zvj ) ) |
---|
| 251 | gphif(ji,jj) = 1./rad * ASIN ( TANH( ppe1_deg *rad* zfj ) ) |
---|
| 252 | ! e1 |
---|
| 253 | e1t(ji,jj) = ra * rad * COS( rad * gphit(ji,jj) ) * ppe1_deg |
---|
| 254 | e1u(ji,jj) = ra * rad * COS( rad * gphiu(ji,jj) ) * ppe1_deg |
---|
| 255 | e1v(ji,jj) = ra * rad * COS( rad * gphiv(ji,jj) ) * ppe1_deg |
---|
| 256 | e1f(ji,jj) = ra * rad * COS( rad * gphif(ji,jj) ) * ppe1_deg |
---|
| 257 | ! e2 |
---|
| 258 | e2t(ji,jj) = ra * rad * COS( rad * gphit(ji,jj) ) * ppe1_deg |
---|
| 259 | e2u(ji,jj) = ra * rad * COS( rad * gphiu(ji,jj) ) * ppe1_deg |
---|
| 260 | e2v(ji,jj) = ra * rad * COS( rad * gphiv(ji,jj) ) * ppe1_deg |
---|
| 261 | e2f(ji,jj) = ra * rad * COS( rad * gphif(ji,jj) ) * ppe1_deg |
---|
| 262 | END DO |
---|
| 263 | END DO |
---|
| 264 | ! |
---|
| 265 | CASE ( 5 ) !== beta-plane with regular grid-spacing and rotated domain ==! (GYRE configuration) |
---|
| 266 | ! |
---|
| 267 | IF(lwp) WRITE(numout,*) |
---|
| 268 | IF(lwp) WRITE(numout,*) ' beta-plane with regular grid-spacing and rotated domain (GYRE configuration)' |
---|
| 269 | IF(lwp) WRITE(numout,*) ' given by ppe1_m and ppe2_m' |
---|
| 270 | ! |
---|
| 271 | ! Position coordinates (in kilometers) |
---|
| 272 | ! ========== |
---|
| 273 | ! |
---|
| 274 | ! angle 45deg and ze1=106.e+3 / jp_cfg forced -> zlam1 = -85deg, zphi1 = 29degN |
---|
| 275 | zlam1 = -85._wp |
---|
| 276 | zphi1 = 29._wp |
---|
| 277 | ! resolution in meters |
---|
| 278 | ze1 = 106000. / REAL( jp_cfg , wp ) |
---|
| 279 | ! benchmark: forced the resolution to be about 100 km |
---|
[10727] | 280 | ! IF( nbench /= 0 ) ze1 = 106000._wp |
---|
[6951] | 281 | zsin_alpha = - SQRT( 2._wp ) * 0.5_wp |
---|
| 282 | zcos_alpha = SQRT( 2._wp ) * 0.5_wp |
---|
| 283 | ze1deg = ze1 / (ra * rad) |
---|
[10727] | 284 | ! IF( nbench /= 0 ) ze1deg = ze1deg / REAL( jp_cfg , wp ) ! benchmark: keep the lat/+lon |
---|
[6951] | 285 | ! ! at the right jp_cfg resolution |
---|
| 286 | glam0 = zlam1 + zcos_alpha * ze1deg * REAL( jpjglo-2 , wp ) |
---|
| 287 | gphi0 = zphi1 + zsin_alpha * ze1deg * REAL( jpjglo-2 , wp ) |
---|
| 288 | ! |
---|
[13204] | 289 | ! WRITE(numout,*) ' ze1', ze1, 'cosalpha', zcos_alpha, 'sinalpha', zsin_alpha |
---|
| 290 | ! WRITE(numout,*) ' ze1deg', ze1deg, 'glam0', glam0, 'gphi0', gphi0 |
---|
[6951] | 291 | ! |
---|
| 292 | DO jj = 1, jpj |
---|
| 293 | DO ji = 1, jpi |
---|
| 294 | zim1 = REAL( ji + nimpp - 1 ) - 1. ; zim05 = REAL( ji + nimpp - 1 ) - 1.5 |
---|
| 295 | zjm1 = REAL( jj + njmpp - 1 ) - 1. ; zjm05 = REAL( jj + njmpp - 1 ) - 1.5 |
---|
| 296 | ! |
---|
| 297 | glamf(ji,jj) = glam0 + zim1 * ze1deg * zcos_alpha + zjm1 * ze1deg * zsin_alpha |
---|
| 298 | gphif(ji,jj) = gphi0 - zim1 * ze1deg * zsin_alpha + zjm1 * ze1deg * zcos_alpha |
---|
| 299 | ! |
---|
| 300 | glamt(ji,jj) = glam0 + zim05 * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha |
---|
| 301 | gphit(ji,jj) = gphi0 - zim05 * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha |
---|
| 302 | ! |
---|
| 303 | glamu(ji,jj) = glam0 + zim1 * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha |
---|
| 304 | gphiu(ji,jj) = gphi0 - zim1 * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha |
---|
| 305 | ! |
---|
| 306 | glamv(ji,jj) = glam0 + zim05 * ze1deg * zcos_alpha + zjm1 * ze1deg * zsin_alpha |
---|
| 307 | gphiv(ji,jj) = gphi0 - zim05 * ze1deg * zsin_alpha + zjm1 * ze1deg * zcos_alpha |
---|
| 308 | END DO |
---|
| 309 | END DO |
---|
| 310 | ! |
---|
| 311 | ! Horizontal scale factors (in meters) |
---|
| 312 | ! ====== |
---|
| 313 | e1t(:,:) = ze1 ; e2t(:,:) = ze1 |
---|
| 314 | e1u(:,:) = ze1 ; e2u(:,:) = ze1 |
---|
| 315 | e1v(:,:) = ze1 ; e2v(:,:) = ze1 |
---|
| 316 | e1f(:,:) = ze1 ; e2f(:,:) = ze1 |
---|
| 317 | ! |
---|
| 318 | CASE DEFAULT |
---|
| 319 | WRITE(ctmp1,*) ' bad flag value for jphgr_msh = ', jphgr_msh |
---|
| 320 | CALL ctl_stop( ctmp1 ) |
---|
| 321 | ! |
---|
| 322 | END SELECT |
---|
| 323 | |
---|
[14630] | 324 | #if defined key_agrif |
---|
| 325 | ELSE |
---|
| 326 | CALL Agrif_InitValues_cont() |
---|
| 327 | ENDIF |
---|
| 328 | #endif |
---|
[6951] | 329 | ! associated horizontal metrics |
---|
| 330 | ! ----------------------------- |
---|
| 331 | ! |
---|
| 332 | r1_e1t(:,:) = 1._wp / e1t(:,:) ; r1_e2t (:,:) = 1._wp / e2t(:,:) |
---|
| 333 | r1_e1u(:,:) = 1._wp / e1u(:,:) ; r1_e2u (:,:) = 1._wp / e2u(:,:) |
---|
| 334 | r1_e1v(:,:) = 1._wp / e1v(:,:) ; r1_e2v (:,:) = 1._wp / e2v(:,:) |
---|
| 335 | r1_e1f(:,:) = 1._wp / e1f(:,:) ; r1_e2f (:,:) = 1._wp / e2f(:,:) |
---|
| 336 | ! |
---|
| 337 | e1e2t (:,:) = e1t(:,:) * e2t(:,:) ; r1_e1e2t(:,:) = 1._wp / e1e2t(:,:) |
---|
| 338 | e1e2f (:,:) = e1f(:,:) * e2f(:,:) ; r1_e1e2f(:,:) = 1._wp / e1e2f(:,:) |
---|
| 339 | IF( jphgr_msh /= 0 ) THEN ! e1e2u and e1e2v have not been set: compute them |
---|
| 340 | e1e2u (:,:) = e1u(:,:) * e2u(:,:) |
---|
| 341 | e1e2v (:,:) = e1v(:,:) * e2v(:,:) |
---|
| 342 | ENDIF |
---|
| 343 | r1_e1e2u(:,:) = 1._wp / e1e2u(:,:) ! compute their invert in both cases |
---|
| 344 | r1_e1e2v(:,:) = 1._wp / e1e2v(:,:) |
---|
| 345 | ! |
---|
| 346 | e2_e1u(:,:) = e2u(:,:) / e1u(:,:) |
---|
| 347 | e1_e2v(:,:) = e1v(:,:) / e2v(:,:) |
---|
| 348 | |
---|
[13204] | 349 | IF( lwp ) THEN ! Control print : Grid informations (if not restart) |
---|
[6951] | 350 | WRITE(numout,*) |
---|
| 351 | WRITE(numout,*) ' longitude and e1 scale factors' |
---|
| 352 | WRITE(numout,*) ' ------------------------------' |
---|
| 353 | WRITE(numout,9300) ( ji, glamt(ji,1), glamu(ji,1), & |
---|
| 354 | glamv(ji,1), glamf(ji,1), & |
---|
| 355 | e1t(ji,1), e1u(ji,1), & |
---|
| 356 | e1v(ji,1), e1f(ji,1), ji = 1, jpi,10) |
---|
| 357 | 9300 FORMAT( 1x, i4, f8.2,1x, f8.2,1x, f8.2,1x, f8.2, 1x, & |
---|
| 358 | f19.10, 1x, f19.10, 1x, f19.10, 1x, f19.10 ) |
---|
| 359 | ! |
---|
| 360 | WRITE(numout,*) |
---|
| 361 | WRITE(numout,*) ' latitude and e2 scale factors' |
---|
| 362 | WRITE(numout,*) ' -----------------------------' |
---|
| 363 | WRITE(numout,9300) ( jj, gphit(1,jj), gphiu(1,jj), & |
---|
| 364 | & gphiv(1,jj), gphif(1,jj), & |
---|
| 365 | & e2t (1,jj), e2u (1,jj), & |
---|
| 366 | & e2v (1,jj), e2f (1,jj), jj = 1, jpj, 10 ) |
---|
| 367 | ENDIF |
---|
| 368 | |
---|
| 369 | |
---|
| 370 | ! ================= ! |
---|
| 371 | ! Coriolis factor ! |
---|
| 372 | ! ================= ! |
---|
| 373 | |
---|
| 374 | SELECT CASE( jphgr_msh ) ! type of horizontal mesh |
---|
| 375 | ! |
---|
| 376 | CASE ( 0, 1, 4 ) ! mesh on the sphere |
---|
| 377 | ! |
---|
| 378 | ff_f(:,:) = 2. * omega * SIN( rad * gphif(:,:) ) |
---|
| 379 | ff_t(:,:) = 2. * omega * SIN( rad * gphit(:,:) ) ! - - - at t-point |
---|
| 380 | ! |
---|
| 381 | CASE ( 2 ) ! f-plane at ppgphi0 |
---|
| 382 | ! |
---|
| 383 | ff_f(:,:) = 2. * omega * SIN( rad * ppgphi0 ) |
---|
| 384 | ff_t(:,:) = 2. * omega * SIN( rad * ppgphi0 ) |
---|
| 385 | ! |
---|
| 386 | IF(lwp) WRITE(numout,*) ' f-plane: Coriolis parameter = constant = ', ff_f(1,1) |
---|
| 387 | ! |
---|
| 388 | CASE ( 3 ) ! beta-plane |
---|
| 389 | ! |
---|
| 390 | zbeta = 2. * omega * COS( rad * ppgphi0 ) / ra ! beta at latitude ppgphi0 |
---|
| 391 | zphi0 = ppgphi0 - REAL( jpjglo/2) * ppe2_m / ( ra * rad ) ! latitude of the first row F-points |
---|
| 392 | ! |
---|
| 393 | zf0 = 2. * omega * SIN( rad * zphi0 ) ! compute f0 1st point south |
---|
| 394 | ! |
---|
| 395 | ff_f(:,:) = ( zf0 + zbeta * gphif(:,:) * 1.e+3 ) ! f = f0 +beta* y ( y=0 at south) |
---|
| 396 | ff_t(:,:) = ( zf0 + zbeta * gphit(:,:) * 1.e+3 ) ! f = f0 +beta* y ( y=0 at south) |
---|
| 397 | ! |
---|
| 398 | IF(lwp) THEN |
---|
| 399 | WRITE(numout,*) |
---|
[14623] | 400 | WRITE(numout,*) ' Beta-plane: Beta parameter = constant = ', ff_f(Nis0,Njs0) |
---|
| 401 | WRITE(numout,*) ' Coriolis parameter varies from ', ff_f(Nis0,Njs0),' to ', ff_f(Nis0,Nje0) |
---|
[6951] | 402 | ENDIF |
---|
| 403 | IF( lk_mpp ) THEN |
---|
[14623] | 404 | zminff=ff_f(Nis0,Njs0) |
---|
| 405 | zmaxff=ff_f(Nis0,Nje0) |
---|
[10727] | 406 | CALL mpp_min( 'toto',zminff ) ! min over the global domain |
---|
| 407 | CALL mpp_max( 'toto',zmaxff ) ! max over the global domain |
---|
[6951] | 408 | IF(lwp) WRITE(numout,*) ' Coriolis parameter varies globally from ', zminff,' to ', zmaxff |
---|
| 409 | END IF |
---|
| 410 | ! |
---|
| 411 | CASE ( 5 ) ! beta-plane and rotated domain (gyre configuration) |
---|
| 412 | ! |
---|
| 413 | zbeta = 2. * omega * COS( rad * ppgphi0 ) / ra ! beta at latitude ppgphi0 |
---|
| 414 | zphi0 = 15._wp ! latitude of the first row F-points |
---|
| 415 | zf0 = 2. * omega * SIN( rad * zphi0 ) ! compute f0 1st point south |
---|
| 416 | ! |
---|
| 417 | ff_f(:,:) = ( zf0 + zbeta * ABS( gphif(:,:) - zphi0 ) * rad * ra ) ! f = f0 +beta* y ( y=0 at south) |
---|
| 418 | ff_t(:,:) = ( zf0 + zbeta * ABS( gphit(:,:) - zphi0 ) * rad * ra ) ! f = f0 +beta* y ( y=0 at south) |
---|
| 419 | ! |
---|
| 420 | IF(lwp) THEN |
---|
| 421 | WRITE(numout,*) |
---|
| 422 | WRITE(numout,*) ' Beta-plane and rotated domain : ' |
---|
[14623] | 423 | WRITE(numout,*) ' Coriolis parameter varies in this processor from ', ff_f(Nis0,Njs0),' to ', ff_f(Nis0,Nje0) |
---|
[6951] | 424 | ENDIF |
---|
| 425 | ! |
---|
| 426 | IF( lk_mpp ) THEN |
---|
[14623] | 427 | zminff=ff_f(Nis0,Njs0) |
---|
| 428 | zmaxff=ff_f(Nis0,Nje0) |
---|
[10727] | 429 | CALL mpp_min('toto', zminff ) ! min over the global domain |
---|
| 430 | CALL mpp_max( 'toto',zmaxff ) ! max over the global domain |
---|
[6951] | 431 | IF(lwp) WRITE(numout,*) ' Coriolis parameter varies globally from ', zminff,' to ', zmaxff |
---|
| 432 | END IF |
---|
| 433 | ! |
---|
| 434 | END SELECT |
---|
| 435 | |
---|
| 436 | |
---|
| 437 | ! Control of domain for symetrical condition |
---|
| 438 | ! ------------------------------------------ |
---|
| 439 | ! The equator line must be the latitude coordinate axe |
---|
[13204] | 440 | !(PM) be carefull with nperio/jperio |
---|
[12101] | 441 | IF( jperio == 2 ) THEN |
---|
| 442 | znorme = SQRT( SUM( gphiu(:,2) * gphiu(:,2) ) ) / REAL( jpi ) |
---|
| 443 | IF( znorme > 1.e-13 ) CALL ctl_stop( ' ===>>>> : symmetrical condition: rerun with good equator line' ) |
---|
| 444 | ENDIF |
---|
[6951] | 445 | ! |
---|
| 446 | END SUBROUTINE dom_hgr |
---|
| 447 | |
---|
| 448 | |
---|
| 449 | SUBROUTINE hgr_read( ke1e2u_v ) |
---|
| 450 | !!--------------------------------------------------------------------- |
---|
| 451 | !! *** ROUTINE hgr_read *** |
---|
| 452 | !! |
---|
| 453 | !! ** Purpose : Read a coordinate file in NetCDF format using IOM |
---|
| 454 | !! |
---|
| 455 | !!---------------------------------------------------------------------- |
---|
| 456 | USE iom |
---|
| 457 | !! |
---|
| 458 | INTEGER, INTENT( inout ) :: ke1e2u_v ! fag: e1e2u & e1e2v read in coordinate file (=1) or not (=0) |
---|
| 459 | ! |
---|
| 460 | INTEGER :: inum ! temporary logical unit |
---|
[13204] | 461 | CHARACTER(LEN=135) :: coordinate_filename |
---|
[6951] | 462 | !!---------------------------------------------------------------------- |
---|
| 463 | ! |
---|
| 464 | IF(lwp) THEN |
---|
| 465 | WRITE(numout,*) |
---|
| 466 | WRITE(numout,*) 'hgr_read : read the horizontal coordinates' |
---|
| 467 | WRITE(numout,*) '~~~~~~~~ jpiglo = ', jpiglo, ' jpjglo = ', jpjglo, ' jpk = ', jpk |
---|
| 468 | ENDIF |
---|
| 469 | ! |
---|
[14623] | 470 | |
---|
[13204] | 471 | IF (ln_read_cfg) THEN |
---|
| 472 | coordinate_filename=TRIM(cn_domcfg) |
---|
| 473 | ELSE |
---|
[13390] | 474 | coordinate_filename=cn_fcoord |
---|
[13204] | 475 | ENDIF |
---|
| 476 | CALL iom_open( coordinate_filename, inum ) |
---|
[6951] | 477 | ! |
---|
[14623] | 478 | CALL iom_get( inum, jpdom_global, 'glamt', glamt, cd_type = 'T', psgn = 1._wp ) |
---|
| 479 | CALL iom_get( inum, jpdom_global, 'glamu', glamu, cd_type = 'U', psgn = 1._wp ) |
---|
| 480 | CALL iom_get( inum, jpdom_global, 'glamv', glamv, cd_type = 'V', psgn = 1._wp ) |
---|
| 481 | CALL iom_get( inum, jpdom_global, 'glamf', glamf, cd_type = 'F', psgn = 1._wp ) |
---|
[6951] | 482 | ! |
---|
[14623] | 483 | CALL iom_get( inum, jpdom_global, 'gphit', gphit, cd_type = 'T', psgn = 1._wp ) |
---|
| 484 | CALL iom_get( inum, jpdom_global, 'gphiu', gphiu, cd_type = 'U', psgn = 1._wp ) |
---|
| 485 | CALL iom_get( inum, jpdom_global, 'gphiv', gphiv, cd_type = 'V', psgn = 1._wp ) |
---|
| 486 | CALL iom_get( inum, jpdom_global, 'gphif', gphif, cd_type = 'F', psgn = 1._wp ) |
---|
[6951] | 487 | ! |
---|
[14623] | 488 | CALL iom_get( inum, jpdom_global, 'e1t' , e1t , cd_type = 'T', psgn = 1._wp, kfill = jpfillcopy ) |
---|
| 489 | CALL iom_get( inum, jpdom_global, 'e1u' , e1u , cd_type = 'U', psgn = 1._wp, kfill = jpfillcopy ) |
---|
| 490 | CALL iom_get( inum, jpdom_global, 'e1v' , e1v , cd_type = 'V', psgn = 1._wp, kfill = jpfillcopy ) |
---|
| 491 | CALL iom_get( inum, jpdom_global, 'e1f' , e1f , cd_type = 'F', psgn = 1._wp, kfill = jpfillcopy ) |
---|
[6951] | 492 | ! |
---|
[14623] | 493 | CALL iom_get( inum, jpdom_global, 'e2t' , e2t , cd_type = 'T', psgn = 1._wp, kfill = jpfillcopy ) |
---|
| 494 | CALL iom_get( inum, jpdom_global, 'e2u' , e2u , cd_type = 'U', psgn = 1._wp, kfill = jpfillcopy ) |
---|
| 495 | CALL iom_get( inum, jpdom_global, 'e2v' , e2v , cd_type = 'V', psgn = 1._wp, kfill = jpfillcopy ) |
---|
| 496 | CALL iom_get( inum, jpdom_global, 'e2f' , e2f , cd_type = 'F', psgn = 1._wp, kfill = jpfillcopy ) |
---|
[6951] | 497 | ! |
---|
| 498 | IF( iom_varid( inum, 'e1e2u', ldstop = .FALSE. ) > 0 ) THEN |
---|
| 499 | IF(lwp) WRITE(numout,*) 'hgr_read : e1e2u & e1e2v read in coordinates file' |
---|
[14623] | 500 | CALL iom_get( inum, jpdom_global, 'e1e2u', e1e2u, cd_type = 'U', psgn = 1._wp, kfill = jpfillcopy ) |
---|
| 501 | CALL iom_get( inum, jpdom_global, 'e1e2v', e1e2v, cd_type = 'V', psgn = 1._wp, kfill = jpfillcopy ) |
---|
[6951] | 502 | ke1e2u_v = 1 |
---|
| 503 | ELSE |
---|
| 504 | ke1e2u_v = 0 |
---|
| 505 | ENDIF |
---|
| 506 | ! |
---|
| 507 | CALL iom_close( inum ) |
---|
| 508 | |
---|
| 509 | END SUBROUTINE hgr_read |
---|
| 510 | |
---|
| 511 | !!====================================================================== |
---|
| 512 | END MODULE domhgr |
---|