[2496] | 1 | MODULE nemogcm |
---|
[2442] | 2 | !!====================================================================== |
---|
[2496] | 3 | !! *** MODULE nemogcm *** |
---|
| 4 | !! Ocean system : NEMO GCM (ocean dynamics, on-line tracers, biochemistry and sea-ice) |
---|
[2442] | 5 | !!====================================================================== |
---|
[1593] | 6 | !! History : OPA ! 1990-10 (C. Levy, G. Madec) Original code |
---|
| 7 | !! 7.0 ! 1991-11 (M. Imbard, C. Levy, G. Madec) |
---|
[3764] | 8 | !! 7.1 ! 1993-03 (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, |
---|
| 9 | !! P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes) release 7.1 |
---|
[1593] | 10 | !! - ! 1992-06 (L.Terray) coupling implementation |
---|
[3764] | 11 | !! - ! 1993-11 (M.A. Filiberti) IGLOO sea-ice |
---|
| 12 | !! 8.0 ! 1996-03 (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, |
---|
[2104] | 13 | !! P. Delecluse, L.Terray, M.A. Filiberti, J. Vialar, A.M. Treguier, M. Levy) release 8.0 |
---|
[1593] | 14 | !! 8.1 ! 1997-06 (M. Imbard, G. Madec) |
---|
[3764] | 15 | !! 8.2 ! 1999-11 (M. Imbard, H. Goosse) LIM sea-ice model |
---|
| 16 | !! ! 1999-12 (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols) OPEN-MP |
---|
[1593] | 17 | !! ! 2000-07 (J-M Molines, M. Imbard) Open Boundary Conditions (CLIPPER) |
---|
| 18 | !! NEMO 1.0 ! 2002-08 (G. Madec) F90: Free form and modules |
---|
| 19 | !! - ! 2004-06 (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces |
---|
| 20 | !! - ! 2004-08 (C. Talandier) New trends organization |
---|
| 21 | !! - ! 2005-06 (C. Ethe) Add the 1D configuration possibility |
---|
| 22 | !! - ! 2005-11 (V. Garnier) Surface pressure gradient organization |
---|
| 23 | !! - ! 2006-03 (L. Debreu, C. Mazauric) Agrif implementation |
---|
| 24 | !! - ! 2006-04 (G. Madec, R. Benshila) Step reorganization |
---|
| 25 | !! - ! 2007-07 (J. Chanut, A. Sellar) Unstructured open boundaries (BDY) |
---|
| 26 | !! 3.2 ! 2009-08 (S. Masson) open/write in the listing file in mpp |
---|
[3764] | 27 | !! 3.3 ! 2010-05 (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface |
---|
[2236] | 28 | !! - ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase |
---|
[3294] | 29 | !! 3.3.1! 2011-01 (A. R. Porter, STFC Daresbury) dynamical allocation |
---|
| 30 | !! 3.4 ! 2011-11 (C. Harris) decomposition changes for running with CICE |
---|
[1593] | 31 | !!---------------------------------------------------------------------- |
---|
[3] | 32 | |
---|
| 33 | !!---------------------------------------------------------------------- |
---|
[2496] | 34 | !! nemo_gcm : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice |
---|
| 35 | !! nemo_init : initialization of the NEMO system |
---|
[3764] | 36 | !! nemo_ctl : initialisation of the contol print |
---|
[2496] | 37 | !! nemo_closefile : close remaining open files |
---|
[2715] | 38 | !! nemo_alloc : dynamical allocation |
---|
| 39 | !! nemo_partition : calculate MPP domain decomposition |
---|
| 40 | !! factorise : calculate the factors of the no. of MPI processes |
---|
[3] | 41 | !!---------------------------------------------------------------------- |
---|
[2382] | 42 | USE step_oce ! module used in the ocean time stepping module |
---|
[3] | 43 | USE domcfg ! domain configuration (dom_cfg routine) |
---|
| 44 | USE mppini ! shared/distributed memory setting (mpp_init routine) |
---|
| 45 | USE domain ! domain initialization (dom_init routine) |
---|
[3625] | 46 | #if defined key_nemocice_decomp |
---|
| 47 | USE ice_domain_size, only: nx_global, ny_global |
---|
| 48 | #endif |
---|
[3] | 49 | USE istate ! initial state setting (istate_init routine) |
---|
| 50 | USE phycst ! physical constant (par_cst routine) |
---|
[2236] | 51 | USE diaobs ! Observation diagnostics (dia_obs_init routine) |
---|
[3764] | 52 | USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) |
---|
[2496] | 53 | USE step ! NEMO time-stepping (stp routine) |
---|
[3609] | 54 | USE icbini ! handle bergs, initialisation |
---|
| 55 | USE icbstp ! handle bergs, calving, themodynamics and transport |
---|
[1359] | 56 | USE cpl_oasis3 ! OASIS3 coupling |
---|
[1593] | 57 | USE lib_mpp ! distributed memory computing |
---|
[1412] | 58 | #if defined key_iomput |
---|
[3701] | 59 | USE xios |
---|
[1359] | 60 | #endif |
---|
[4120] | 61 | USE ooo_data ! Offline obs_oper data |
---|
| 62 | USE ooo_read ! Offline obs_oper read routines |
---|
| 63 | USE ooo_intp ! Offline obs_oper interpolation |
---|
[268] | 64 | |
---|
[2715] | 65 | IMPLICIT NONE |
---|
[3] | 66 | PRIVATE |
---|
| 67 | |
---|
[4120] | 68 | PUBLIC nemo_gcm ! called by nemo.f90 |
---|
[2496] | 69 | PUBLIC nemo_init ! needed by AGRIF |
---|
[3764] | 70 | PUBLIC nemo_alloc ! needed by TAM |
---|
[467] | 71 | |
---|
[2498] | 72 | CHARACTER(lc) :: cform_aaa="( /, 'AAAAAAAA', / ) " ! flag for output listing |
---|
[1593] | 73 | |
---|
[3] | 74 | !!---------------------------------------------------------------------- |
---|
[2715] | 75 | !! NEMO/OPA 4.0 , NEMO Consortium (2011) |
---|
[2392] | 76 | !! $Id$ |
---|
[2329] | 77 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
[3] | 78 | !!---------------------------------------------------------------------- |
---|
| 79 | CONTAINS |
---|
| 80 | |
---|
[4120] | 81 | SUBROUTINE nemo_gcm |
---|
| 82 | !!---------------------------------------------------------------------- |
---|
| 83 | !! *** SUBROUTINE offline_obs_oper *** |
---|
| 84 | !! |
---|
| 85 | !! ** Purpose : To use NEMO components to interpolate model fields |
---|
| 86 | !! to observation space. |
---|
| 87 | !! |
---|
| 88 | !! ** Method : 1. Initialise NEMO |
---|
| 89 | !! 2. Initialise offline obs_oper |
---|
| 90 | !! 3. Cycle through match ups |
---|
| 91 | !! 4. Write results to file |
---|
| 92 | !! |
---|
| 93 | !!---------------------------------------------------------------------- |
---|
| 94 | !! Class 4 output stream switch |
---|
| 95 | USE obs_fbm, ONLY: ln_cl4 |
---|
| 96 | !! Initialise NEMO |
---|
| 97 | CALL nemo_init |
---|
| 98 | !! Initialise Offline obs_oper data |
---|
| 99 | CALL ooo_data_init( ln_cl4 ) |
---|
| 100 | !! Loop over various model counterparts |
---|
| 101 | DO jimatch = 1, cl4_match_len |
---|
| 102 | IF (jimatch .GT. 1) THEN |
---|
| 103 | !! Initialise obs_oper |
---|
| 104 | CALL dia_obs_init |
---|
| 105 | END IF |
---|
| 106 | !! Interpolate to observation space |
---|
| 107 | CALL ooo_interp |
---|
| 108 | !! Pipe to output files |
---|
| 109 | CALL dia_obs_wri |
---|
| 110 | !! Reset the obs_oper between |
---|
| 111 | CALL dia_obs_dealloc |
---|
| 112 | END DO |
---|
| 113 | !! Safely stop MPI |
---|
| 114 | IF(lk_mpp) CALL mppstop ! end mpp communications |
---|
| 115 | END SUBROUTINE nemo_gcm |
---|
[389] | 116 | |
---|
[2496] | 117 | SUBROUTINE nemo_init |
---|
[389] | 118 | !!---------------------------------------------------------------------- |
---|
[2496] | 119 | !! *** ROUTINE nemo_init *** |
---|
[389] | 120 | !! |
---|
[2496] | 121 | !! ** Purpose : initialization of the NEMO GCM |
---|
[389] | 122 | !!---------------------------------------------------------------------- |
---|
[2715] | 123 | INTEGER :: ji ! dummy loop indices |
---|
| 124 | INTEGER :: ilocal_comm ! local integer |
---|
| 125 | CHARACTER(len=80), DIMENSION(16) :: cltxt |
---|
[1593] | 126 | !! |
---|
[4290] | 127 | NAMELIST/namctl/ ln_ctl, nn_print, nn_ictls, nn_ictle, & |
---|
[3294] | 128 | & nn_isplt, nn_jsplt, nn_jctls, nn_jctle, & |
---|
| 129 | & nn_bench, nn_timing |
---|
[4290] | 130 | NAMELIST/namcfg/ cp_cfg, cp_cfz, jp_cfg, jpidta, jpjdta, jpkdta, jpiglo, jpjglo, & |
---|
[5118] | 131 | & jpizoom, jpjzoom, jperio, ln_use_jattr |
---|
[3] | 132 | !!---------------------------------------------------------------------- |
---|
[1593] | 133 | ! |
---|
[2496] | 134 | cltxt = '' |
---|
[5407] | 135 | cxios_context = 'nemo' |
---|
[2496] | 136 | ! |
---|
[4290] | 137 | ! ! Open reference namelist and configuration namelist files |
---|
| 138 | CALL ctl_opn( numnam_ref, 'namelist_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) |
---|
| 139 | CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) |
---|
[1593] | 140 | ! |
---|
[4290] | 141 | REWIND( numnam_ref ) ! Namelist namctl in reference namelist : Control prints & Benchmark |
---|
| 142 | READ ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 ) |
---|
| 143 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. ) |
---|
| 144 | |
---|
| 145 | REWIND( numnam_cfg ) ! Namelist namctl in confguration namelist : Control prints & Benchmark |
---|
| 146 | READ ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 ) |
---|
| 147 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. ) |
---|
| 148 | |
---|
[1593] | 149 | ! |
---|
[4290] | 150 | REWIND( numnam_ref ) ! Namelist namcfg in reference namelist : Control prints & Benchmark |
---|
| 151 | READ ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 ) |
---|
| 152 | 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. ) |
---|
| 153 | |
---|
| 154 | REWIND( numnam_cfg ) ! Namelist namcfg in confguration namelist : Control prints & Benchmark |
---|
| 155 | READ ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 ) |
---|
| 156 | 904 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. ) |
---|
| 157 | |
---|
[1593] | 158 | ! !--------------------------------------------! |
---|
| 159 | ! ! set communicator & select the local node ! |
---|
[4624] | 160 | ! ! NB: mynode also opens output.namelist.dyn ! |
---|
| 161 | ! ! on unit number numond on first proc ! |
---|
[1593] | 162 | ! !--------------------------------------------! |
---|
[1412] | 163 | #if defined key_iomput |
---|
[2200] | 164 | IF( Agrif_Root() ) THEN |
---|
[5407] | 165 | IF( lk_oasis ) THEN |
---|
[4990] | 166 | CALL cpl_init( ilocal_comm ) ! nemo local communicator given by oasis |
---|
| 167 | CALL xios_initialize( "oceanx",local_comm=ilocal_comm ) ! send nemo communicator to xios |
---|
| 168 | ELSE |
---|
[5407] | 169 | CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm ) ! nemo local communicator given by xios |
---|
[4990] | 170 | ENDIF |
---|
[2200] | 171 | ENDIF |
---|
[4990] | 172 | ENDIF |
---|
[5407] | 173 | narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm ) ! Nodes selection |
---|
[532] | 174 | #else |
---|
[5407] | 175 | IF( lk_oasis ) THEN |
---|
[4990] | 176 | IF( Agrif_Root() ) THEN |
---|
| 177 | CALL cpl_init( ilocal_comm ) ! nemo local communicator given by oasis |
---|
| 178 | ENDIF |
---|
[5407] | 179 | narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm ) ! Nodes selection (control print return in cltxt) |
---|
[4990] | 180 | ELSE |
---|
| 181 | ilocal_comm = 0 |
---|
[5407] | 182 | narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop ) ! Nodes selection (control print return in cltxt) |
---|
[2236] | 183 | ENDIF |
---|
[532] | 184 | #endif |
---|
[2715] | 185 | narea = narea + 1 ! mynode return the rank of proc (0 --> jpnij -1 ) |
---|
[3] | 186 | |
---|
[4624] | 187 | lwm = (narea == 1) ! control of output namelists |
---|
[2715] | 188 | lwp = (narea == 1) .OR. ln_ctl ! control of all listing output print |
---|
[1579] | 189 | |
---|
[4624] | 190 | IF(lwm) THEN |
---|
| 191 | ! write merged namelists from earlier to output namelist now that the |
---|
| 192 | ! file has been opened in call to mynode. nammpp has already been |
---|
| 193 | ! written in mynode (if lk_mpp_mpi) |
---|
| 194 | WRITE( numond, namctl ) |
---|
| 195 | WRITE( numond, namcfg ) |
---|
| 196 | ENDIF |
---|
| 197 | |
---|
[3764] | 198 | ! If dimensions of processor grid weren't specified in the namelist file |
---|
[2715] | 199 | ! then we calculate them here now that we have our communicator size |
---|
| 200 | IF( (jpni < 1) .OR. (jpnj < 1) )THEN |
---|
| 201 | #if defined key_mpp_mpi |
---|
| 202 | IF( Agrif_Root() ) CALL nemo_partition(mppsize) |
---|
| 203 | #else |
---|
| 204 | jpni = 1 |
---|
| 205 | jpnj = 1 |
---|
| 206 | jpnij = jpni*jpnj |
---|
| 207 | #endif |
---|
| 208 | END IF |
---|
| 209 | |
---|
| 210 | ! Calculate domain dimensions given calculated jpni and jpnj |
---|
| 211 | ! This used to be done in par_oce.F90 when they were parameters rather |
---|
| 212 | ! than variables |
---|
| 213 | IF( Agrif_Root() ) THEN |
---|
[3294] | 214 | #if defined key_nemocice_decomp |
---|
[3625] | 215 | jpi = ( nx_global+2-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ! first dim. |
---|
| 216 | jpj = ( ny_global+2-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. |
---|
[3294] | 217 | #else |
---|
[3625] | 218 | jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ! first dim. |
---|
[2715] | 219 | jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. |
---|
[3294] | 220 | #endif |
---|
[2715] | 221 | jpk = jpkdta ! third dim |
---|
| 222 | jpim1 = jpi-1 ! inner domain indices |
---|
| 223 | jpjm1 = jpj-1 ! " " |
---|
| 224 | jpkm1 = jpk-1 ! " " |
---|
| 225 | jpij = jpi*jpj ! jpi x j |
---|
| 226 | ENDIF |
---|
| 227 | |
---|
[1593] | 228 | IF(lwp) THEN ! open listing units |
---|
| 229 | ! |
---|
[1581] | 230 | CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea ) |
---|
[1593] | 231 | ! |
---|
[1579] | 232 | WRITE(numout,*) |
---|
[3294] | 233 | WRITE(numout,*) ' CNRS - NERC - Met OFFICE - MERCATOR-ocean - INGV - CMCC' |
---|
[1593] | 234 | WRITE(numout,*) ' NEMO team' |
---|
[1579] | 235 | WRITE(numout,*) ' Ocean General Circulation Model' |
---|
[5120] | 236 | WRITE(numout,*) ' version 3.6 (2015) ' |
---|
[1579] | 237 | WRITE(numout,*) |
---|
| 238 | WRITE(numout,*) |
---|
[3764] | 239 | DO ji = 1, SIZE(cltxt) |
---|
[1593] | 240 | IF( TRIM(cltxt(ji)) /= '' ) WRITE(numout,*) cltxt(ji) ! control print of mynode |
---|
[1579] | 241 | END DO |
---|
[1593] | 242 | WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
| 243 | ! |
---|
[473] | 244 | ENDIF |
---|
[2715] | 245 | |
---|
[3764] | 246 | ! Now we know the dimensions of the grid and numout has been set we can |
---|
[2715] | 247 | ! allocate arrays |
---|
| 248 | CALL nemo_alloc() |
---|
| 249 | |
---|
[2496] | 250 | ! !-------------------------------! |
---|
| 251 | ! ! NEMO general initialization ! |
---|
| 252 | ! !-------------------------------! |
---|
[473] | 253 | |
---|
[2496] | 254 | CALL nemo_ctl ! Control prints & Benchmark |
---|
[531] | 255 | |
---|
[2082] | 256 | ! ! Domain decomposition |
---|
[1593] | 257 | IF( jpni*jpnj == jpnij ) THEN ; CALL mpp_init ! standard cutting out |
---|
| 258 | ELSE ; CALL mpp_init2 ! eliminate land processors |
---|
[3] | 259 | ENDIF |
---|
[2382] | 260 | ! |
---|
[3294] | 261 | IF( nn_timing == 1 ) CALL timing_init |
---|
| 262 | ! |
---|
[2082] | 263 | ! ! General initialization |
---|
[2027] | 264 | CALL phy_cst ! Physical constants |
---|
| 265 | CALL eos_init ! Equation of state |
---|
| 266 | CALL dom_cfg ! Domain configuration |
---|
| 267 | CALL dom_init ! Domain |
---|
[413] | 268 | |
---|
[3294] | 269 | IF( ln_nnogather ) CALL nemo_northcomms ! Initialise the northfold neighbour lists (must be done after the masks are defined) |
---|
| 270 | |
---|
[2027] | 271 | IF( ln_ctl ) CALL prt_ctl_init ! Print control |
---|
| 272 | |
---|
[3651] | 273 | CALL istate_init ! ocean initial state (Dynamics and tracers) |
---|
| 274 | |
---|
[2392] | 275 | IF( lk_diaobs ) THEN ! Observation & model comparison |
---|
[2382] | 276 | CALL dia_obs_init ! Initialize observational data |
---|
| 277 | CALL dia_obs( nit000 - 1 ) ! Observation operator for restart |
---|
[3764] | 278 | ENDIF |
---|
[2496] | 279 | END SUBROUTINE nemo_init |
---|
[467] | 280 | |
---|
| 281 | |
---|
[2496] | 282 | SUBROUTINE nemo_ctl |
---|
[467] | 283 | !!---------------------------------------------------------------------- |
---|
[2496] | 284 | !! *** ROUTINE nemo_ctl *** |
---|
[467] | 285 | !! |
---|
[3764] | 286 | !! ** Purpose : control print setting |
---|
[467] | 287 | !! |
---|
[2442] | 288 | !! ** Method : - print namctl information and check some consistencies |
---|
[467] | 289 | !!---------------------------------------------------------------------- |
---|
[2442] | 290 | ! |
---|
[2496] | 291 | IF(lwp) THEN ! control print |
---|
[531] | 292 | WRITE(numout,*) |
---|
[2496] | 293 | WRITE(numout,*) 'nemo_ctl: Control prints & Benchmark' |
---|
[531] | 294 | WRITE(numout,*) '~~~~~~~ ' |
---|
[1593] | 295 | WRITE(numout,*) ' Namelist namctl' |
---|
[1601] | 296 | WRITE(numout,*) ' run control (for debugging) ln_ctl = ', ln_ctl |
---|
| 297 | WRITE(numout,*) ' level of print nn_print = ', nn_print |
---|
| 298 | WRITE(numout,*) ' Start i indice for SUM control nn_ictls = ', nn_ictls |
---|
| 299 | WRITE(numout,*) ' End i indice for SUM control nn_ictle = ', nn_ictle |
---|
| 300 | WRITE(numout,*) ' Start j indice for SUM control nn_jctls = ', nn_jctls |
---|
| 301 | WRITE(numout,*) ' End j indice for SUM control nn_jctle = ', nn_jctle |
---|
| 302 | WRITE(numout,*) ' number of proc. following i nn_isplt = ', nn_isplt |
---|
| 303 | WRITE(numout,*) ' number of proc. following j nn_jsplt = ', nn_jsplt |
---|
| 304 | WRITE(numout,*) ' benchmark parameter (0/1) nn_bench = ', nn_bench |
---|
[3610] | 305 | WRITE(numout,*) ' timing activated (0/1) nn_timing = ', nn_timing |
---|
[531] | 306 | ENDIF |
---|
[2442] | 307 | ! |
---|
[1601] | 308 | nprint = nn_print ! convert DOCTOR namelist names into OLD names |
---|
| 309 | nictls = nn_ictls |
---|
| 310 | nictle = nn_ictle |
---|
| 311 | njctls = nn_jctls |
---|
| 312 | njctle = nn_jctle |
---|
| 313 | isplt = nn_isplt |
---|
| 314 | jsplt = nn_jsplt |
---|
| 315 | nbench = nn_bench |
---|
[2442] | 316 | ! ! Parameter control |
---|
[1593] | 317 | ! |
---|
| 318 | IF( ln_ctl ) THEN ! sub-domain area indices for the control prints |
---|
[3294] | 319 | IF( lk_mpp .AND. jpnij > 1 ) THEN |
---|
[2496] | 320 | isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj ! the domain is forced to the real split domain |
---|
[531] | 321 | ELSE |
---|
| 322 | IF( isplt == 1 .AND. jsplt == 1 ) THEN |
---|
[1593] | 323 | CALL ctl_warn( ' - isplt & jsplt are equal to 1', & |
---|
| 324 | & ' - the print control will be done over the whole domain' ) |
---|
[531] | 325 | ENDIF |
---|
[1593] | 326 | ijsplt = isplt * jsplt ! total number of processors ijsplt |
---|
[531] | 327 | ENDIF |
---|
| 328 | IF(lwp) WRITE(numout,*)' - The total number of processors over which the' |
---|
| 329 | IF(lwp) WRITE(numout,*)' print control will be done is ijsplt : ', ijsplt |
---|
[1593] | 330 | ! |
---|
| 331 | ! ! indices used for the SUM control |
---|
| 332 | IF( nictls+nictle+njctls+njctle == 0 ) THEN ! print control done over the default area |
---|
[3764] | 333 | lsp_area = .FALSE. |
---|
[1593] | 334 | ELSE ! print control done over a specific area |
---|
[531] | 335 | lsp_area = .TRUE. |
---|
| 336 | IF( nictls < 1 .OR. nictls > jpiglo ) THEN |
---|
| 337 | CALL ctl_warn( ' - nictls must be 1<=nictls>=jpiglo, it is forced to 1' ) |
---|
| 338 | nictls = 1 |
---|
| 339 | ENDIF |
---|
| 340 | IF( nictle < 1 .OR. nictle > jpiglo ) THEN |
---|
| 341 | CALL ctl_warn( ' - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' ) |
---|
| 342 | nictle = jpiglo |
---|
| 343 | ENDIF |
---|
| 344 | IF( njctls < 1 .OR. njctls > jpjglo ) THEN |
---|
| 345 | CALL ctl_warn( ' - njctls must be 1<=njctls>=jpjglo, it is forced to 1' ) |
---|
| 346 | njctls = 1 |
---|
| 347 | ENDIF |
---|
| 348 | IF( njctle < 1 .OR. njctle > jpjglo ) THEN |
---|
| 349 | CALL ctl_warn( ' - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' ) |
---|
| 350 | njctle = jpjglo |
---|
| 351 | ENDIF |
---|
[1593] | 352 | ENDIF |
---|
| 353 | ENDIF |
---|
[2442] | 354 | ! |
---|
[3764] | 355 | IF( nbench == 1 ) THEN ! Benchmark |
---|
[531] | 356 | SELECT CASE ( cp_cfg ) |
---|
[1593] | 357 | CASE ( 'gyre' ) ; CALL ctl_warn( ' The Benchmark is activated ' ) |
---|
| 358 | CASE DEFAULT ; CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:', & |
---|
| 359 | & ' key_gyre must be used or set nbench = 0' ) |
---|
[531] | 360 | END SELECT |
---|
| 361 | ENDIF |
---|
[1593] | 362 | ! |
---|
[2496] | 363 | IF( lk_c1d .AND. .NOT.lk_iomput ) CALL ctl_stop( 'nemo_ctl: The 1D configuration must be used ', & |
---|
| 364 | & 'with the IOM Input/Output manager. ' , & |
---|
[2442] | 365 | & 'Compile with key_iomput enabled' ) |
---|
[2409] | 366 | ! |
---|
[3764] | 367 | IF( 1_wp /= SIGN(1._wp,-0._wp) ) CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows ', & |
---|
| 368 | & 'f2003 standard. ' , & |
---|
| 369 | & 'Compile with key_nosignedzero enabled' ) |
---|
| 370 | ! |
---|
[2496] | 371 | END SUBROUTINE nemo_ctl |
---|
[467] | 372 | |
---|
| 373 | |
---|
[2496] | 374 | SUBROUTINE nemo_closefile |
---|
[467] | 375 | !!---------------------------------------------------------------------- |
---|
[2496] | 376 | !! *** ROUTINE nemo_closefile *** |
---|
[467] | 377 | !! |
---|
| 378 | !! ** Purpose : Close the files |
---|
| 379 | !!---------------------------------------------------------------------- |
---|
[1593] | 380 | ! |
---|
| 381 | IF( lk_mpp ) CALL mppsync |
---|
| 382 | ! |
---|
[1685] | 383 | CALL iom_close ! close all input/output files managed by iom_* |
---|
[1593] | 384 | ! |
---|
[3294] | 385 | IF( numstp /= -1 ) CLOSE( numstp ) ! time-step file |
---|
| 386 | IF( numsol /= -1 ) CLOSE( numsol ) ! solver file |
---|
| 387 | IF( numnam /= -1 ) CLOSE( numnam ) ! oce namelist |
---|
| 388 | IF( numnam_ice /= -1 ) CLOSE( numnam_ice ) ! ice namelist |
---|
| 389 | IF( numevo_ice /= -1 ) CLOSE( numevo_ice ) ! ice variables (temp. evolution) |
---|
| 390 | IF( numout /= 6 ) CLOSE( numout ) ! standard model output file |
---|
| 391 | IF( numdct_vol /= -1 ) CLOSE( numdct_vol ) ! volume transports |
---|
| 392 | IF( numdct_heat /= -1 ) CLOSE( numdct_heat ) ! heat transports |
---|
| 393 | IF( numdct_salt /= -1 ) CLOSE( numdct_salt ) ! salt transports |
---|
| 394 | |
---|
[1593] | 395 | ! |
---|
[2442] | 396 | numout = 6 ! redefine numout in case it is used after this point... |
---|
| 397 | ! |
---|
[2496] | 398 | END SUBROUTINE nemo_closefile |
---|
[467] | 399 | |
---|
[2715] | 400 | |
---|
| 401 | SUBROUTINE nemo_alloc |
---|
| 402 | !!---------------------------------------------------------------------- |
---|
| 403 | !! *** ROUTINE nemo_alloc *** |
---|
| 404 | !! |
---|
| 405 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
| 406 | !! |
---|
| 407 | !! ** Method : |
---|
| 408 | !!---------------------------------------------------------------------- |
---|
| 409 | USE diawri , ONLY: dia_wri_alloc |
---|
| 410 | USE dom_oce , ONLY: dom_oce_alloc |
---|
| 411 | ! |
---|
| 412 | INTEGER :: ierr |
---|
| 413 | !!---------------------------------------------------------------------- |
---|
| 414 | ! |
---|
[3764] | 415 | ierr = oce_alloc () ! ocean |
---|
[2715] | 416 | ierr = ierr + dia_wri_alloc () |
---|
| 417 | ierr = ierr + dom_oce_alloc () ! ocean domain |
---|
| 418 | ! |
---|
| 419 | ierr = ierr + lib_mpp_alloc (numout) ! mpp exchanges |
---|
| 420 | ! |
---|
| 421 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
| 422 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'nemo_alloc : unable to allocate standard ocean arrays' ) |
---|
| 423 | ! |
---|
| 424 | END SUBROUTINE nemo_alloc |
---|
| 425 | |
---|
| 426 | |
---|
| 427 | SUBROUTINE nemo_partition( num_pes ) |
---|
| 428 | !!---------------------------------------------------------------------- |
---|
| 429 | !! *** ROUTINE nemo_partition *** |
---|
| 430 | !! |
---|
[3764] | 431 | !! ** Purpose : |
---|
[2715] | 432 | !! |
---|
| 433 | !! ** Method : |
---|
| 434 | !!---------------------------------------------------------------------- |
---|
| 435 | INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have |
---|
| 436 | ! |
---|
| 437 | INTEGER, PARAMETER :: nfactmax = 20 |
---|
| 438 | INTEGER :: nfact ! The no. of factors returned |
---|
| 439 | INTEGER :: ierr ! Error flag |
---|
| 440 | INTEGER :: ji |
---|
| 441 | INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value |
---|
| 442 | INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors |
---|
| 443 | !!---------------------------------------------------------------------- |
---|
| 444 | |
---|
| 445 | ierr = 0 |
---|
| 446 | |
---|
| 447 | CALL factorise( ifact, nfactmax, nfact, num_pes, ierr ) |
---|
| 448 | |
---|
| 449 | IF( nfact <= 1 ) THEN |
---|
| 450 | WRITE (numout, *) 'WARNING: factorisation of number of PEs failed' |
---|
| 451 | WRITE (numout, *) ' : using grid of ',num_pes,' x 1' |
---|
| 452 | jpnj = 1 |
---|
| 453 | jpni = num_pes |
---|
| 454 | ELSE |
---|
| 455 | ! Search through factors for the pair that are closest in value |
---|
| 456 | mindiff = 1000000 |
---|
| 457 | imin = 1 |
---|
| 458 | DO ji = 1, nfact-1, 2 |
---|
| 459 | idiff = ABS( ifact(ji) - ifact(ji+1) ) |
---|
| 460 | IF( idiff < mindiff ) THEN |
---|
| 461 | mindiff = idiff |
---|
| 462 | imin = ji |
---|
| 463 | ENDIF |
---|
| 464 | END DO |
---|
| 465 | jpnj = ifact(imin) |
---|
| 466 | jpni = ifact(imin + 1) |
---|
| 467 | ENDIF |
---|
| 468 | ! |
---|
| 469 | jpnij = jpni*jpnj |
---|
| 470 | ! |
---|
| 471 | END SUBROUTINE nemo_partition |
---|
| 472 | |
---|
| 473 | |
---|
| 474 | SUBROUTINE factorise( kfax, kmaxfax, knfax, kn, kerr ) |
---|
| 475 | !!---------------------------------------------------------------------- |
---|
| 476 | !! *** ROUTINE factorise *** |
---|
| 477 | !! |
---|
| 478 | !! ** Purpose : return the prime factors of n. |
---|
[3764] | 479 | !! knfax factors are returned in array kfax which is of |
---|
[2715] | 480 | !! maximum dimension kmaxfax. |
---|
| 481 | !! ** Method : |
---|
| 482 | !!---------------------------------------------------------------------- |
---|
| 483 | INTEGER , INTENT(in ) :: kn, kmaxfax |
---|
| 484 | INTEGER , INTENT( out) :: kerr, knfax |
---|
| 485 | INTEGER, DIMENSION(kmaxfax), INTENT( out) :: kfax |
---|
| 486 | ! |
---|
| 487 | INTEGER :: ifac, jl, inu |
---|
| 488 | INTEGER, PARAMETER :: ntest = 14 |
---|
| 489 | INTEGER :: ilfax(ntest) |
---|
| 490 | |
---|
| 491 | ! lfax contains the set of allowed factors. |
---|
| 492 | data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256, & |
---|
| 493 | & 128, 64, 32, 16, 8, 4, 2 / |
---|
| 494 | !!---------------------------------------------------------------------- |
---|
| 495 | |
---|
| 496 | ! Clear the error flag and initialise output vars |
---|
| 497 | kerr = 0 |
---|
| 498 | kfax = 1 |
---|
| 499 | knfax = 0 |
---|
| 500 | |
---|
| 501 | ! Find the factors of n. |
---|
| 502 | IF( kn == 1 ) GOTO 20 |
---|
| 503 | |
---|
| 504 | ! nu holds the unfactorised part of the number. |
---|
| 505 | ! knfax holds the number of factors found. |
---|
| 506 | ! l points to the allowed factor list. |
---|
| 507 | ! ifac holds the current factor. |
---|
| 508 | |
---|
| 509 | inu = kn |
---|
| 510 | knfax = 0 |
---|
| 511 | |
---|
| 512 | DO jl = ntest, 1, -1 |
---|
| 513 | ! |
---|
| 514 | ifac = ilfax(jl) |
---|
| 515 | IF( ifac > inu ) CYCLE |
---|
| 516 | |
---|
| 517 | ! Test whether the factor will divide. |
---|
| 518 | |
---|
| 519 | IF( MOD(inu,ifac) == 0 ) THEN |
---|
| 520 | ! |
---|
| 521 | knfax = knfax + 1 ! Add the factor to the list |
---|
| 522 | IF( knfax > kmaxfax ) THEN |
---|
| 523 | kerr = 6 |
---|
| 524 | write (*,*) 'FACTOR: insufficient space in factor array ', knfax |
---|
| 525 | return |
---|
| 526 | ENDIF |
---|
| 527 | kfax(knfax) = ifac |
---|
| 528 | ! Store the other factor that goes with this one |
---|
| 529 | knfax = knfax + 1 |
---|
| 530 | kfax(knfax) = inu / ifac |
---|
| 531 | !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) |
---|
| 532 | ENDIF |
---|
| 533 | ! |
---|
| 534 | END DO |
---|
| 535 | |
---|
| 536 | 20 CONTINUE ! Label 20 is the exit point from the factor search loop. |
---|
| 537 | ! |
---|
| 538 | END SUBROUTINE factorise |
---|
| 539 | |
---|
[3294] | 540 | #if defined key_mpp_mpi |
---|
| 541 | SUBROUTINE nemo_northcomms |
---|
| 542 | !!====================================================================== |
---|
| 543 | !! *** ROUTINE nemo_northcomms *** |
---|
| 544 | !! nemo_northcomms : Setup for north fold exchanges with explicit peer to peer messaging |
---|
| 545 | !!===================================================================== |
---|
| 546 | !!---------------------------------------------------------------------- |
---|
[3764] | 547 | !! |
---|
[3294] | 548 | !! ** Purpose : Initialization of the northern neighbours lists. |
---|
| 549 | !!---------------------------------------------------------------------- |
---|
[3764] | 550 | !! 1.0 ! 2011-10 (A. C. Coward, NOCS & J. Donners, PRACE) |
---|
[3294] | 551 | !!---------------------------------------------------------------------- |
---|
| 552 | |
---|
| 553 | INTEGER :: ji, jj, jk, ij, jtyp ! dummy loop indices |
---|
| 554 | INTEGER :: ijpj ! number of rows involved in north-fold exchange |
---|
| 555 | INTEGER :: northcomms_alloc ! allocate return status |
---|
| 556 | REAL(wp), ALLOCATABLE, DIMENSION ( :,: ) :: znnbrs ! workspace |
---|
| 557 | LOGICAL, ALLOCATABLE, DIMENSION ( : ) :: lrankset ! workspace |
---|
| 558 | |
---|
| 559 | IF(lwp) WRITE(numout,*) |
---|
| 560 | IF(lwp) WRITE(numout,*) 'nemo_northcomms : Initialization of the northern neighbours lists' |
---|
| 561 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~' |
---|
| 562 | |
---|
| 563 | !!---------------------------------------------------------------------- |
---|
| 564 | ALLOCATE( znnbrs(jpi,jpj), stat = northcomms_alloc ) |
---|
| 565 | ALLOCATE( lrankset(jpnij), stat = northcomms_alloc ) |
---|
| 566 | IF( northcomms_alloc /= 0 ) THEN |
---|
| 567 | WRITE(numout,cform_war) |
---|
| 568 | WRITE(numout,*) 'northcomms_alloc : failed to allocate arrays' |
---|
| 569 | CALL ctl_stop( 'STOP', 'nemo_northcomms : unable to allocate temporary arrays' ) |
---|
| 570 | ENDIF |
---|
| 571 | nsndto = 0 |
---|
| 572 | isendto = -1 |
---|
| 573 | ijpj = 4 |
---|
| 574 | ! |
---|
| 575 | ! This routine has been called because ln_nnogather has been set true ( nammpp ) |
---|
| 576 | ! However, these first few exchanges have to use the mpi_allgather method to |
---|
| 577 | ! establish the neighbour lists to use in subsequent peer to peer exchanges. |
---|
| 578 | ! Consequently, set l_north_nogather to be false here and set it true only after |
---|
| 579 | ! the lists have been established. |
---|
| 580 | ! |
---|
| 581 | l_north_nogather = .FALSE. |
---|
| 582 | ! |
---|
| 583 | ! Exchange and store ranks on northern rows |
---|
| 584 | |
---|
| 585 | DO jtyp = 1,4 |
---|
| 586 | |
---|
| 587 | lrankset = .FALSE. |
---|
| 588 | znnbrs = narea |
---|
| 589 | SELECT CASE (jtyp) |
---|
| 590 | CASE(1) |
---|
| 591 | CALL lbc_lnk( znnbrs, 'T', 1. ) ! Type 1: T,W-points |
---|
| 592 | CASE(2) |
---|
| 593 | CALL lbc_lnk( znnbrs, 'U', 1. ) ! Type 2: U-point |
---|
| 594 | CASE(3) |
---|
| 595 | CALL lbc_lnk( znnbrs, 'V', 1. ) ! Type 3: V-point |
---|
| 596 | CASE(4) |
---|
| 597 | CALL lbc_lnk( znnbrs, 'F', 1. ) ! Type 4: F-point |
---|
| 598 | END SELECT |
---|
| 599 | |
---|
| 600 | IF ( njmppt(narea) .EQ. MAXVAL( njmppt ) ) THEN |
---|
| 601 | DO jj = nlcj-ijpj+1, nlcj |
---|
| 602 | ij = jj - nlcj + ijpj |
---|
| 603 | DO ji = 1,jpi |
---|
| 604 | IF ( INT(znnbrs(ji,jj)) .NE. 0 .AND. INT(znnbrs(ji,jj)) .NE. narea ) & |
---|
| 605 | & lrankset(INT(znnbrs(ji,jj))) = .true. |
---|
| 606 | END DO |
---|
| 607 | END DO |
---|
| 608 | |
---|
| 609 | DO jj = 1,jpnij |
---|
| 610 | IF ( lrankset(jj) ) THEN |
---|
| 611 | nsndto(jtyp) = nsndto(jtyp) + 1 |
---|
| 612 | IF ( nsndto(jtyp) .GT. jpmaxngh ) THEN |
---|
| 613 | CALL ctl_stop( ' Too many neighbours in nemo_northcomms ', & |
---|
| 614 | & ' jpmaxngh will need to be increased ') |
---|
| 615 | ENDIF |
---|
| 616 | isendto(nsndto(jtyp),jtyp) = jj-1 ! narea converted to MPI rank |
---|
| 617 | ENDIF |
---|
| 618 | END DO |
---|
| 619 | ENDIF |
---|
| 620 | |
---|
| 621 | END DO |
---|
| 622 | |
---|
| 623 | ! |
---|
| 624 | ! Type 5: I-point |
---|
| 625 | ! |
---|
| 626 | ! ICE point exchanges may involve some averaging. The neighbours list is |
---|
| 627 | ! built up using two exchanges to ensure that the whole stencil is covered. |
---|
| 628 | ! lrankset should not be reset between these 'J' and 'K' point exchanges |
---|
| 629 | |
---|
| 630 | jtyp = 5 |
---|
| 631 | lrankset = .FALSE. |
---|
[3764] | 632 | znnbrs = narea |
---|
[3294] | 633 | CALL lbc_lnk( znnbrs, 'J', 1. ) ! first ice U-V point |
---|
| 634 | |
---|
| 635 | IF ( njmppt(narea) .EQ. MAXVAL( njmppt ) ) THEN |
---|
| 636 | DO jj = nlcj-ijpj+1, nlcj |
---|
| 637 | ij = jj - nlcj + ijpj |
---|
| 638 | DO ji = 1,jpi |
---|
| 639 | IF ( INT(znnbrs(ji,jj)) .NE. 0 .AND. INT(znnbrs(ji,jj)) .NE. narea ) & |
---|
| 640 | & lrankset(INT(znnbrs(ji,jj))) = .true. |
---|
| 641 | END DO |
---|
| 642 | END DO |
---|
| 643 | ENDIF |
---|
| 644 | |
---|
[3764] | 645 | znnbrs = narea |
---|
[3294] | 646 | CALL lbc_lnk( znnbrs, 'K', 1. ) ! second ice U-V point |
---|
| 647 | |
---|
| 648 | IF ( njmppt(narea) .EQ. MAXVAL( njmppt )) THEN |
---|
| 649 | DO jj = nlcj-ijpj+1, nlcj |
---|
| 650 | ij = jj - nlcj + ijpj |
---|
| 651 | DO ji = 1,jpi |
---|
| 652 | IF ( INT(znnbrs(ji,jj)) .NE. 0 .AND. INT(znnbrs(ji,jj)) .NE. narea ) & |
---|
| 653 | & lrankset( INT(znnbrs(ji,jj))) = .true. |
---|
| 654 | END DO |
---|
| 655 | END DO |
---|
| 656 | |
---|
| 657 | DO jj = 1,jpnij |
---|
| 658 | IF ( lrankset(jj) ) THEN |
---|
| 659 | nsndto(jtyp) = nsndto(jtyp) + 1 |
---|
| 660 | IF ( nsndto(jtyp) .GT. jpmaxngh ) THEN |
---|
| 661 | CALL ctl_stop( ' Too many neighbours in nemo_northcomms ', & |
---|
| 662 | & ' jpmaxngh will need to be increased ') |
---|
| 663 | ENDIF |
---|
| 664 | isendto(nsndto(jtyp),jtyp) = jj-1 ! narea converted to MPI rank |
---|
| 665 | ENDIF |
---|
| 666 | END DO |
---|
| 667 | ! |
---|
[3764] | 668 | ! For northern row areas, set l_north_nogather so that all subsequent exchanges |
---|
[3294] | 669 | ! can use peer to peer communications at the north fold |
---|
| 670 | ! |
---|
| 671 | l_north_nogather = .TRUE. |
---|
| 672 | ! |
---|
| 673 | ENDIF |
---|
| 674 | DEALLOCATE( znnbrs ) |
---|
| 675 | DEALLOCATE( lrankset ) |
---|
| 676 | |
---|
| 677 | END SUBROUTINE nemo_northcomms |
---|
| 678 | #else |
---|
| 679 | SUBROUTINE nemo_northcomms ! Dummy routine |
---|
| 680 | WRITE(*,*) 'nemo_northcomms: You should not have seen this print! error?' |
---|
| 681 | END SUBROUTINE nemo_northcomms |
---|
| 682 | #endif |
---|
[3] | 683 | !!====================================================================== |
---|
[2496] | 684 | END MODULE nemogcm |
---|