[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 |
---|
[4829] | 31 | !! ! 2012-05 (C. Calone, J. Simeon, G. Madec, C. Ethe) Add grid coarsening |
---|
[1593] | 32 | !!---------------------------------------------------------------------- |
---|
[3] | 33 | |
---|
| 34 | !!---------------------------------------------------------------------- |
---|
[2496] | 35 | !! nemo_gcm : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice |
---|
| 36 | !! nemo_init : initialization of the NEMO system |
---|
[3764] | 37 | !! nemo_ctl : initialisation of the contol print |
---|
[2496] | 38 | !! nemo_closefile : close remaining open files |
---|
[2715] | 39 | !! nemo_alloc : dynamical allocation |
---|
| 40 | !! nemo_partition : calculate MPP domain decomposition |
---|
| 41 | !! factorise : calculate the factors of the no. of MPI processes |
---|
[3] | 42 | !!---------------------------------------------------------------------- |
---|
[2382] | 43 | USE step_oce ! module used in the ocean time stepping module |
---|
[3] | 44 | USE domcfg ! domain configuration (dom_cfg routine) |
---|
| 45 | USE mppini ! shared/distributed memory setting (mpp_init routine) |
---|
| 46 | USE domain ! domain initialization (dom_init routine) |
---|
[3625] | 47 | #if defined key_nemocice_decomp |
---|
| 48 | USE ice_domain_size, only: nx_global, ny_global |
---|
| 49 | #endif |
---|
[3] | 50 | USE istate ! initial state setting (istate_init routine) |
---|
| 51 | USE phycst ! physical constant (par_cst routine) |
---|
[2236] | 52 | USE diaobs ! Observation diagnostics (dia_obs_init routine) |
---|
[3764] | 53 | USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) |
---|
[2496] | 54 | USE step ! NEMO time-stepping (stp routine) |
---|
[1359] | 55 | USE cpl_oasis3 ! OASIS3 coupling |
---|
[1593] | 56 | USE lib_mpp ! distributed memory computing |
---|
[1412] | 57 | #if defined key_iomput |
---|
[3701] | 58 | USE xios |
---|
[1359] | 59 | #endif |
---|
[5600] | 60 | USE lbcnfd, ONLY: isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges |
---|
[268] | 61 | |
---|
[4846] | 62 | ! Stand Alone Observation operator modules |
---|
[4849] | 63 | USE sao_data |
---|
[4847] | 64 | USE sao_intp |
---|
[4829] | 65 | |
---|
[2715] | 66 | IMPLICIT NONE |
---|
[3] | 67 | PRIVATE |
---|
| 68 | |
---|
[4829] | 69 | PUBLIC nemo_gcm ! called by model.F90 |
---|
[2496] | 70 | PUBLIC nemo_init ! needed by AGRIF |
---|
[3764] | 71 | PUBLIC nemo_alloc ! needed by TAM |
---|
[467] | 72 | |
---|
[2498] | 73 | CHARACTER(lc) :: cform_aaa="( /, 'AAAAAAAA', / ) " ! flag for output listing |
---|
[1593] | 74 | |
---|
[3] | 75 | !!---------------------------------------------------------------------- |
---|
[2715] | 76 | !! NEMO/OPA 4.0 , NEMO Consortium (2011) |
---|
[2392] | 77 | !! $Id$ |
---|
[2329] | 78 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
[3] | 79 | !!---------------------------------------------------------------------- |
---|
| 80 | CONTAINS |
---|
| 81 | |
---|
[4120] | 82 | SUBROUTINE nemo_gcm |
---|
| 83 | !!---------------------------------------------------------------------- |
---|
| 84 | !! *** SUBROUTINE offline_obs_oper *** |
---|
| 85 | !! |
---|
| 86 | !! ** Purpose : To use NEMO components to interpolate model fields |
---|
| 87 | !! to observation space. |
---|
| 88 | !! |
---|
| 89 | !! ** Method : 1. Initialise NEMO |
---|
| 90 | !! 2. Initialise offline obs_oper |
---|
| 91 | !! 3. Cycle through match ups |
---|
| 92 | !! 4. Write results to file |
---|
| 93 | !! |
---|
| 94 | !!---------------------------------------------------------------------- |
---|
| 95 | !! Initialise NEMO |
---|
| 96 | CALL nemo_init |
---|
[4846] | 97 | !! Initialise Stand Alone Observation operator data |
---|
[5063] | 98 | CALL sao_data_init |
---|
| 99 | !! Initialise obs_oper |
---|
| 100 | CALL dia_obs_init |
---|
| 101 | !! Interpolate to observation space |
---|
| 102 | CALL sao_interp |
---|
| 103 | !! Pipe to output files |
---|
| 104 | CALL dia_obs_wri |
---|
| 105 | !! Reset the obs_oper between |
---|
| 106 | CALL dia_obs_dealloc |
---|
[4120] | 107 | !! Safely stop MPI |
---|
| 108 | IF(lk_mpp) CALL mppstop ! end mpp communications |
---|
| 109 | END SUBROUTINE nemo_gcm |
---|
[389] | 110 | |
---|
[4829] | 111 | |
---|
[2496] | 112 | SUBROUTINE nemo_init |
---|
[389] | 113 | !!---------------------------------------------------------------------- |
---|
[2496] | 114 | !! *** ROUTINE nemo_init *** |
---|
[389] | 115 | !! |
---|
[2496] | 116 | !! ** Purpose : initialization of the NEMO GCM |
---|
[389] | 117 | !!---------------------------------------------------------------------- |
---|
[2715] | 118 | INTEGER :: ji ! dummy loop indices |
---|
| 119 | INTEGER :: ilocal_comm ! local integer |
---|
[4829] | 120 | INTEGER :: ios |
---|
[2715] | 121 | CHARACTER(len=80), DIMENSION(16) :: cltxt |
---|
[5600] | 122 | ! |
---|
[4290] | 123 | NAMELIST/namctl/ ln_ctl, nn_print, nn_ictls, nn_ictle, & |
---|
[3294] | 124 | & nn_isplt, nn_jsplt, nn_jctls, nn_jctle, & |
---|
| 125 | & nn_bench, nn_timing |
---|
[4290] | 126 | NAMELIST/namcfg/ cp_cfg, cp_cfz, jp_cfg, jpidta, jpjdta, jpkdta, jpiglo, jpjglo, & |
---|
[5600] | 127 | & jpizoom, jpjzoom, jperio, ln_use_jattr |
---|
[3] | 128 | !!---------------------------------------------------------------------- |
---|
[1593] | 129 | ! |
---|
[2496] | 130 | cltxt = '' |
---|
[5600] | 131 | cxios_context = 'nemo' |
---|
[2496] | 132 | ! |
---|
[4290] | 133 | ! ! Open reference namelist and configuration namelist files |
---|
| 134 | CALL ctl_opn( numnam_ref, 'namelist_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) |
---|
| 135 | CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) |
---|
[1593] | 136 | ! |
---|
[4290] | 137 | REWIND( numnam_ref ) ! Namelist namctl in reference namelist : Control prints & Benchmark |
---|
| 138 | READ ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 ) |
---|
| 139 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. ) |
---|
| 140 | |
---|
| 141 | REWIND( numnam_cfg ) ! Namelist namctl in confguration namelist : Control prints & Benchmark |
---|
| 142 | READ ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 ) |
---|
| 143 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. ) |
---|
| 144 | |
---|
[1593] | 145 | ! |
---|
[4290] | 146 | REWIND( numnam_ref ) ! Namelist namcfg in reference namelist : Control prints & Benchmark |
---|
| 147 | READ ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 ) |
---|
| 148 | 903 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. ) |
---|
| 149 | |
---|
| 150 | REWIND( numnam_cfg ) ! Namelist namcfg in confguration namelist : Control prints & Benchmark |
---|
| 151 | READ ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 ) |
---|
| 152 | 904 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. ) |
---|
| 153 | |
---|
[4829] | 154 | ! Force values for AGRIF zoom (cf. agrif_user.F90) |
---|
| 155 | #if defined key_agrif |
---|
| 156 | IF( .NOT. Agrif_Root() ) THEN |
---|
| 157 | jpiglo = nbcellsx + 2 + 2*nbghostcells |
---|
| 158 | jpjglo = nbcellsy + 2 + 2*nbghostcells |
---|
| 159 | jpi = ( jpiglo-2*jpreci + (jpni-1+0) ) / jpni + 2*jpreci |
---|
| 160 | jpj = ( jpjglo-2*jprecj + (jpnj-1+0) ) / jpnj + 2*jprecj |
---|
| 161 | jpidta = jpiglo |
---|
| 162 | jpjdta = jpjglo |
---|
| 163 | jpizoom = 1 |
---|
| 164 | jpjzoom = 1 |
---|
| 165 | nperio = 0 |
---|
| 166 | jperio = 0 |
---|
[5600] | 167 | ln_use_jattr = .false. |
---|
[4829] | 168 | ENDIF |
---|
| 169 | #endif |
---|
| 170 | ! |
---|
[1593] | 171 | ! !--------------------------------------------! |
---|
| 172 | ! ! set communicator & select the local node ! |
---|
[4624] | 173 | ! ! NB: mynode also opens output.namelist.dyn ! |
---|
| 174 | ! ! on unit number numond on first proc ! |
---|
[1593] | 175 | ! !--------------------------------------------! |
---|
[1412] | 176 | #if defined key_iomput |
---|
[2200] | 177 | IF( Agrif_Root() ) THEN |
---|
[5600] | 178 | IF( lk_oasis ) THEN |
---|
| 179 | CALL cpl_init( "oceanx", ilocal_comm ) ! nemo local communicator given by oasis |
---|
| 180 | CALL xios_initialize( "not used",local_comm=ilocal_comm ) ! send nemo communicator to xios |
---|
| 181 | ELSE |
---|
| 182 | CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm ) ! nemo local communicator given by xios |
---|
| 183 | ENDIF |
---|
[2200] | 184 | ENDIF |
---|
[5600] | 185 | ! Nodes selection (control print return in cltxt) |
---|
| 186 | narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm ) |
---|
[532] | 187 | #else |
---|
[5600] | 188 | IF( lk_oasis ) THEN |
---|
| 189 | IF( Agrif_Root() ) THEN |
---|
| 190 | CALL cpl_init( "oceanx", ilocal_comm ) ! nemo local communicator given by oasis |
---|
| 191 | ENDIF |
---|
| 192 | ! Nodes selection (control print return in cltxt) |
---|
| 193 | narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm ) |
---|
| 194 | ELSE |
---|
| 195 | ilocal_comm = 0 |
---|
| 196 | ! Nodes selection (control print return in cltxt) |
---|
| 197 | narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop ) |
---|
[2236] | 198 | ENDIF |
---|
[532] | 199 | #endif |
---|
[2715] | 200 | narea = narea + 1 ! mynode return the rank of proc (0 --> jpnij -1 ) |
---|
[3] | 201 | |
---|
[4624] | 202 | lwm = (narea == 1) ! control of output namelists |
---|
[2715] | 203 | lwp = (narea == 1) .OR. ln_ctl ! control of all listing output print |
---|
[1579] | 204 | |
---|
[4624] | 205 | IF(lwm) THEN |
---|
| 206 | ! write merged namelists from earlier to output namelist now that the |
---|
| 207 | ! file has been opened in call to mynode. nammpp has already been |
---|
| 208 | ! written in mynode (if lk_mpp_mpi) |
---|
| 209 | WRITE( numond, namctl ) |
---|
| 210 | WRITE( numond, namcfg ) |
---|
| 211 | ENDIF |
---|
| 212 | |
---|
[3764] | 213 | ! If dimensions of processor grid weren't specified in the namelist file |
---|
[2715] | 214 | ! then we calculate them here now that we have our communicator size |
---|
| 215 | IF( (jpni < 1) .OR. (jpnj < 1) )THEN |
---|
| 216 | #if defined key_mpp_mpi |
---|
| 217 | IF( Agrif_Root() ) CALL nemo_partition(mppsize) |
---|
| 218 | #else |
---|
| 219 | jpni = 1 |
---|
| 220 | jpnj = 1 |
---|
| 221 | jpnij = jpni*jpnj |
---|
| 222 | #endif |
---|
| 223 | END IF |
---|
| 224 | |
---|
| 225 | ! Calculate domain dimensions given calculated jpni and jpnj |
---|
| 226 | ! This used to be done in par_oce.F90 when they were parameters rather |
---|
| 227 | ! than variables |
---|
| 228 | IF( Agrif_Root() ) THEN |
---|
[3294] | 229 | #if defined key_nemocice_decomp |
---|
[3625] | 230 | jpi = ( nx_global+2-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ! first dim. |
---|
| 231 | jpj = ( ny_global+2-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. |
---|
[3294] | 232 | #else |
---|
[3625] | 233 | jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ! first dim. |
---|
[2715] | 234 | jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. |
---|
[3294] | 235 | #endif |
---|
[4829] | 236 | ENDIF |
---|
[2715] | 237 | jpk = jpkdta ! third dim |
---|
| 238 | jpim1 = jpi-1 ! inner domain indices |
---|
| 239 | jpjm1 = jpj-1 ! " " |
---|
| 240 | jpkm1 = jpk-1 ! " " |
---|
| 241 | jpij = jpi*jpj ! jpi x j |
---|
| 242 | |
---|
[1593] | 243 | IF(lwp) THEN ! open listing units |
---|
| 244 | ! |
---|
[1581] | 245 | CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea ) |
---|
[1593] | 246 | ! |
---|
[1579] | 247 | WRITE(numout,*) |
---|
[3294] | 248 | WRITE(numout,*) ' CNRS - NERC - Met OFFICE - MERCATOR-ocean - INGV - CMCC' |
---|
[1593] | 249 | WRITE(numout,*) ' NEMO team' |
---|
[5042] | 250 | WRITE(numout,*) ' Stand Alone Observation operator' |
---|
| 251 | WRITE(numout,*) ' version 1.0 (2015) ' |
---|
[1579] | 252 | WRITE(numout,*) |
---|
| 253 | WRITE(numout,*) |
---|
[3764] | 254 | DO ji = 1, SIZE(cltxt) |
---|
[1593] | 255 | IF( TRIM(cltxt(ji)) /= '' ) WRITE(numout,*) cltxt(ji) ! control print of mynode |
---|
[1579] | 256 | END DO |
---|
[1593] | 257 | WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
| 258 | ! |
---|
[473] | 259 | ENDIF |
---|
[2715] | 260 | |
---|
[3764] | 261 | ! Now we know the dimensions of the grid and numout has been set we can |
---|
[2715] | 262 | ! allocate arrays |
---|
| 263 | CALL nemo_alloc() |
---|
| 264 | |
---|
[2496] | 265 | ! !-------------------------------! |
---|
| 266 | ! ! NEMO general initialization ! |
---|
| 267 | ! !-------------------------------! |
---|
[473] | 268 | |
---|
[2496] | 269 | CALL nemo_ctl ! Control prints & Benchmark |
---|
[531] | 270 | |
---|
[2082] | 271 | ! ! Domain decomposition |
---|
[1593] | 272 | IF( jpni*jpnj == jpnij ) THEN ; CALL mpp_init ! standard cutting out |
---|
| 273 | ELSE ; CALL mpp_init2 ! eliminate land processors |
---|
[3] | 274 | ENDIF |
---|
[2382] | 275 | ! |
---|
[3294] | 276 | IF( nn_timing == 1 ) CALL timing_init |
---|
| 277 | ! |
---|
[2082] | 278 | ! ! General initialization |
---|
[2027] | 279 | CALL phy_cst ! Physical constants |
---|
| 280 | CALL eos_init ! Equation of state |
---|
| 281 | CALL dom_cfg ! Domain configuration |
---|
| 282 | CALL dom_init ! Domain |
---|
[413] | 283 | |
---|
[3294] | 284 | IF( ln_nnogather ) CALL nemo_northcomms ! Initialise the northfold neighbour lists (must be done after the masks are defined) |
---|
| 285 | |
---|
[2027] | 286 | IF( ln_ctl ) CALL prt_ctl_init ! Print control |
---|
| 287 | |
---|
[3651] | 288 | CALL istate_init ! ocean initial state (Dynamics and tracers) |
---|
[2496] | 289 | END SUBROUTINE nemo_init |
---|
[467] | 290 | |
---|
| 291 | |
---|
[2496] | 292 | SUBROUTINE nemo_ctl |
---|
[467] | 293 | !!---------------------------------------------------------------------- |
---|
[2496] | 294 | !! *** ROUTINE nemo_ctl *** |
---|
[467] | 295 | !! |
---|
[3764] | 296 | !! ** Purpose : control print setting |
---|
[467] | 297 | !! |
---|
[2442] | 298 | !! ** Method : - print namctl information and check some consistencies |
---|
[467] | 299 | !!---------------------------------------------------------------------- |
---|
[2442] | 300 | ! |
---|
[2496] | 301 | IF(lwp) THEN ! control print |
---|
[531] | 302 | WRITE(numout,*) |
---|
[2496] | 303 | WRITE(numout,*) 'nemo_ctl: Control prints & Benchmark' |
---|
[531] | 304 | WRITE(numout,*) '~~~~~~~ ' |
---|
[1593] | 305 | WRITE(numout,*) ' Namelist namctl' |
---|
[1601] | 306 | WRITE(numout,*) ' run control (for debugging) ln_ctl = ', ln_ctl |
---|
| 307 | WRITE(numout,*) ' level of print nn_print = ', nn_print |
---|
| 308 | WRITE(numout,*) ' Start i indice for SUM control nn_ictls = ', nn_ictls |
---|
| 309 | WRITE(numout,*) ' End i indice for SUM control nn_ictle = ', nn_ictle |
---|
| 310 | WRITE(numout,*) ' Start j indice for SUM control nn_jctls = ', nn_jctls |
---|
| 311 | WRITE(numout,*) ' End j indice for SUM control nn_jctle = ', nn_jctle |
---|
| 312 | WRITE(numout,*) ' number of proc. following i nn_isplt = ', nn_isplt |
---|
| 313 | WRITE(numout,*) ' number of proc. following j nn_jsplt = ', nn_jsplt |
---|
| 314 | WRITE(numout,*) ' benchmark parameter (0/1) nn_bench = ', nn_bench |
---|
[3610] | 315 | WRITE(numout,*) ' timing activated (0/1) nn_timing = ', nn_timing |
---|
[531] | 316 | ENDIF |
---|
[2442] | 317 | ! |
---|
[1601] | 318 | nprint = nn_print ! convert DOCTOR namelist names into OLD names |
---|
| 319 | nictls = nn_ictls |
---|
| 320 | nictle = nn_ictle |
---|
| 321 | njctls = nn_jctls |
---|
| 322 | njctle = nn_jctle |
---|
| 323 | isplt = nn_isplt |
---|
| 324 | jsplt = nn_jsplt |
---|
| 325 | nbench = nn_bench |
---|
[4829] | 326 | |
---|
| 327 | IF(lwp) THEN ! control print |
---|
| 328 | WRITE(numout,*) |
---|
| 329 | WRITE(numout,*) 'namcfg : configuration initialization through namelist read' |
---|
| 330 | WRITE(numout,*) '~~~~~~~ ' |
---|
| 331 | WRITE(numout,*) ' Namelist namcfg' |
---|
| 332 | WRITE(numout,*) ' configuration name cp_cfg = ', TRIM(cp_cfg) |
---|
| 333 | WRITE(numout,*) ' configuration zoom name cp_cfz = ', TRIM(cp_cfz) |
---|
| 334 | WRITE(numout,*) ' configuration resolution jp_cfg = ', jp_cfg |
---|
| 335 | WRITE(numout,*) ' 1st lateral dimension ( >= jpi ) jpidta = ', jpidta |
---|
| 336 | WRITE(numout,*) ' 2nd " " ( >= jpj ) jpjdta = ', jpjdta |
---|
| 337 | WRITE(numout,*) ' 3nd " " jpkdta = ', jpkdta |
---|
| 338 | WRITE(numout,*) ' 1st dimension of global domain in i jpiglo = ', jpiglo |
---|
| 339 | WRITE(numout,*) ' 2nd - - in j jpjglo = ', jpjglo |
---|
| 340 | WRITE(numout,*) ' left bottom i index of the zoom (in data domain) jpizoom = ', jpizoom |
---|
| 341 | WRITE(numout,*) ' left bottom j index of the zoom (in data domain) jpizoom = ', jpjzoom |
---|
| 342 | WRITE(numout,*) ' lateral cond. type (between 0 and 6) jperio = ', jperio |
---|
[5600] | 343 | WRITE(numout,*) ' use file attribute if exists as i/p j-start ln_use_jattr = ', ln_use_jattr |
---|
[4829] | 344 | ENDIF |
---|
[2442] | 345 | ! ! Parameter control |
---|
[1593] | 346 | ! |
---|
| 347 | IF( ln_ctl ) THEN ! sub-domain area indices for the control prints |
---|
[3294] | 348 | IF( lk_mpp .AND. jpnij > 1 ) THEN |
---|
[2496] | 349 | isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj ! the domain is forced to the real split domain |
---|
[531] | 350 | ELSE |
---|
| 351 | IF( isplt == 1 .AND. jsplt == 1 ) THEN |
---|
[1593] | 352 | CALL ctl_warn( ' - isplt & jsplt are equal to 1', & |
---|
| 353 | & ' - the print control will be done over the whole domain' ) |
---|
[531] | 354 | ENDIF |
---|
[1593] | 355 | ijsplt = isplt * jsplt ! total number of processors ijsplt |
---|
[531] | 356 | ENDIF |
---|
| 357 | IF(lwp) WRITE(numout,*)' - The total number of processors over which the' |
---|
| 358 | IF(lwp) WRITE(numout,*)' print control will be done is ijsplt : ', ijsplt |
---|
[1593] | 359 | ! |
---|
| 360 | ! ! indices used for the SUM control |
---|
| 361 | IF( nictls+nictle+njctls+njctle == 0 ) THEN ! print control done over the default area |
---|
[3764] | 362 | lsp_area = .FALSE. |
---|
[1593] | 363 | ELSE ! print control done over a specific area |
---|
[531] | 364 | lsp_area = .TRUE. |
---|
| 365 | IF( nictls < 1 .OR. nictls > jpiglo ) THEN |
---|
| 366 | CALL ctl_warn( ' - nictls must be 1<=nictls>=jpiglo, it is forced to 1' ) |
---|
| 367 | nictls = 1 |
---|
| 368 | ENDIF |
---|
| 369 | IF( nictle < 1 .OR. nictle > jpiglo ) THEN |
---|
| 370 | CALL ctl_warn( ' - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' ) |
---|
| 371 | nictle = jpiglo |
---|
| 372 | ENDIF |
---|
| 373 | IF( njctls < 1 .OR. njctls > jpjglo ) THEN |
---|
| 374 | CALL ctl_warn( ' - njctls must be 1<=njctls>=jpjglo, it is forced to 1' ) |
---|
| 375 | njctls = 1 |
---|
| 376 | ENDIF |
---|
| 377 | IF( njctle < 1 .OR. njctle > jpjglo ) THEN |
---|
| 378 | CALL ctl_warn( ' - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' ) |
---|
| 379 | njctle = jpjglo |
---|
| 380 | ENDIF |
---|
[1593] | 381 | ENDIF |
---|
| 382 | ENDIF |
---|
[2442] | 383 | ! |
---|
[3764] | 384 | IF( nbench == 1 ) THEN ! Benchmark |
---|
[531] | 385 | SELECT CASE ( cp_cfg ) |
---|
[1593] | 386 | CASE ( 'gyre' ) ; CALL ctl_warn( ' The Benchmark is activated ' ) |
---|
| 387 | CASE DEFAULT ; CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:', & |
---|
[4829] | 388 | & ' cp_cfg = "gyre" in namelist &namcfg or set nbench = 0' ) |
---|
[531] | 389 | END SELECT |
---|
| 390 | ENDIF |
---|
[1593] | 391 | ! |
---|
[3764] | 392 | IF( 1_wp /= SIGN(1._wp,-0._wp) ) CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows ', & |
---|
| 393 | & 'f2003 standard. ' , & |
---|
| 394 | & 'Compile with key_nosignedzero enabled' ) |
---|
| 395 | ! |
---|
[2496] | 396 | END SUBROUTINE nemo_ctl |
---|
[467] | 397 | |
---|
| 398 | |
---|
[2496] | 399 | SUBROUTINE nemo_closefile |
---|
[467] | 400 | !!---------------------------------------------------------------------- |
---|
[2496] | 401 | !! *** ROUTINE nemo_closefile *** |
---|
[467] | 402 | !! |
---|
| 403 | !! ** Purpose : Close the files |
---|
| 404 | !!---------------------------------------------------------------------- |
---|
[1593] | 405 | ! |
---|
| 406 | IF( lk_mpp ) CALL mppsync |
---|
| 407 | ! |
---|
[1685] | 408 | CALL iom_close ! close all input/output files managed by iom_* |
---|
[1593] | 409 | ! |
---|
[4829] | 410 | IF( numstp /= -1 ) CLOSE( numstp ) ! time-step file |
---|
| 411 | IF( numsol /= -1 ) CLOSE( numsol ) ! solver file |
---|
| 412 | IF( numnam_ref /= -1 ) CLOSE( numnam_ref ) ! oce reference namelist |
---|
| 413 | IF( numnam_cfg /= -1 ) CLOSE( numnam_cfg ) ! oce configuration namelist |
---|
| 414 | IF( lwm.AND.numond /= -1 ) CLOSE( numond ) ! oce output namelist |
---|
| 415 | IF( numnam_ice_ref /= -1 ) CLOSE( numnam_ice_ref ) ! ice reference namelist |
---|
| 416 | IF( numnam_ice_cfg /= -1 ) CLOSE( numnam_ice_cfg ) ! ice configuration namelist |
---|
| 417 | IF( lwm.AND.numoni /= -1 ) CLOSE( numoni ) ! ice output namelist |
---|
| 418 | IF( numevo_ice /= -1 ) CLOSE( numevo_ice ) ! ice variables (temp. evolution) |
---|
| 419 | IF( numout /= 6 ) CLOSE( numout ) ! standard model output file |
---|
| 420 | IF( numdct_vol /= -1 ) CLOSE( numdct_vol ) ! volume transports |
---|
| 421 | IF( numdct_heat /= -1 ) CLOSE( numdct_heat ) ! heat transports |
---|
| 422 | IF( numdct_salt /= -1 ) CLOSE( numdct_salt ) ! salt transports |
---|
[3294] | 423 | |
---|
[1593] | 424 | ! |
---|
[2442] | 425 | numout = 6 ! redefine numout in case it is used after this point... |
---|
| 426 | ! |
---|
[2496] | 427 | END SUBROUTINE nemo_closefile |
---|
[467] | 428 | |
---|
[2715] | 429 | |
---|
| 430 | SUBROUTINE nemo_alloc |
---|
| 431 | !!---------------------------------------------------------------------- |
---|
| 432 | !! *** ROUTINE nemo_alloc *** |
---|
| 433 | !! |
---|
| 434 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
| 435 | !! |
---|
| 436 | !! ** Method : |
---|
| 437 | !!---------------------------------------------------------------------- |
---|
| 438 | USE diawri , ONLY: dia_wri_alloc |
---|
| 439 | USE dom_oce , ONLY: dom_oce_alloc |
---|
| 440 | ! |
---|
| 441 | INTEGER :: ierr |
---|
| 442 | !!---------------------------------------------------------------------- |
---|
| 443 | ! |
---|
[3764] | 444 | ierr = oce_alloc () ! ocean |
---|
[2715] | 445 | ierr = ierr + dia_wri_alloc () |
---|
| 446 | ierr = ierr + dom_oce_alloc () ! ocean domain |
---|
| 447 | ! |
---|
| 448 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
| 449 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'nemo_alloc : unable to allocate standard ocean arrays' ) |
---|
| 450 | ! |
---|
| 451 | END SUBROUTINE nemo_alloc |
---|
| 452 | |
---|
| 453 | |
---|
| 454 | SUBROUTINE nemo_partition( num_pes ) |
---|
| 455 | !!---------------------------------------------------------------------- |
---|
| 456 | !! *** ROUTINE nemo_partition *** |
---|
| 457 | !! |
---|
[3764] | 458 | !! ** Purpose : |
---|
[2715] | 459 | !! |
---|
| 460 | !! ** Method : |
---|
| 461 | !!---------------------------------------------------------------------- |
---|
| 462 | INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have |
---|
| 463 | ! |
---|
| 464 | INTEGER, PARAMETER :: nfactmax = 20 |
---|
| 465 | INTEGER :: nfact ! The no. of factors returned |
---|
| 466 | INTEGER :: ierr ! Error flag |
---|
| 467 | INTEGER :: ji |
---|
| 468 | INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value |
---|
| 469 | INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors |
---|
| 470 | !!---------------------------------------------------------------------- |
---|
[5600] | 471 | ! |
---|
[2715] | 472 | ierr = 0 |
---|
[5600] | 473 | ! |
---|
[2715] | 474 | CALL factorise( ifact, nfactmax, nfact, num_pes, ierr ) |
---|
[5600] | 475 | ! |
---|
[2715] | 476 | IF( nfact <= 1 ) THEN |
---|
| 477 | WRITE (numout, *) 'WARNING: factorisation of number of PEs failed' |
---|
| 478 | WRITE (numout, *) ' : using grid of ',num_pes,' x 1' |
---|
| 479 | jpnj = 1 |
---|
| 480 | jpni = num_pes |
---|
| 481 | ELSE |
---|
| 482 | ! Search through factors for the pair that are closest in value |
---|
| 483 | mindiff = 1000000 |
---|
| 484 | imin = 1 |
---|
| 485 | DO ji = 1, nfact-1, 2 |
---|
| 486 | idiff = ABS( ifact(ji) - ifact(ji+1) ) |
---|
| 487 | IF( idiff < mindiff ) THEN |
---|
| 488 | mindiff = idiff |
---|
| 489 | imin = ji |
---|
| 490 | ENDIF |
---|
| 491 | END DO |
---|
| 492 | jpnj = ifact(imin) |
---|
| 493 | jpni = ifact(imin + 1) |
---|
| 494 | ENDIF |
---|
| 495 | ! |
---|
| 496 | jpnij = jpni*jpnj |
---|
| 497 | ! |
---|
| 498 | END SUBROUTINE nemo_partition |
---|
| 499 | |
---|
| 500 | |
---|
| 501 | SUBROUTINE factorise( kfax, kmaxfax, knfax, kn, kerr ) |
---|
| 502 | !!---------------------------------------------------------------------- |
---|
| 503 | !! *** ROUTINE factorise *** |
---|
| 504 | !! |
---|
| 505 | !! ** Purpose : return the prime factors of n. |
---|
[3764] | 506 | !! knfax factors are returned in array kfax which is of |
---|
[2715] | 507 | !! maximum dimension kmaxfax. |
---|
| 508 | !! ** Method : |
---|
| 509 | !!---------------------------------------------------------------------- |
---|
| 510 | INTEGER , INTENT(in ) :: kn, kmaxfax |
---|
| 511 | INTEGER , INTENT( out) :: kerr, knfax |
---|
| 512 | INTEGER, DIMENSION(kmaxfax), INTENT( out) :: kfax |
---|
| 513 | ! |
---|
| 514 | INTEGER :: ifac, jl, inu |
---|
| 515 | INTEGER, PARAMETER :: ntest = 14 |
---|
| 516 | INTEGER :: ilfax(ntest) |
---|
[5600] | 517 | ! |
---|
[2715] | 518 | ! lfax contains the set of allowed factors. |
---|
| 519 | data (ilfax(jl),jl=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256, & |
---|
| 520 | & 128, 64, 32, 16, 8, 4, 2 / |
---|
| 521 | !!---------------------------------------------------------------------- |
---|
| 522 | |
---|
| 523 | ! Clear the error flag and initialise output vars |
---|
| 524 | kerr = 0 |
---|
| 525 | kfax = 1 |
---|
| 526 | knfax = 0 |
---|
| 527 | |
---|
| 528 | ! Find the factors of n. |
---|
| 529 | IF( kn == 1 ) GOTO 20 |
---|
| 530 | |
---|
| 531 | ! nu holds the unfactorised part of the number. |
---|
| 532 | ! knfax holds the number of factors found. |
---|
| 533 | ! l points to the allowed factor list. |
---|
| 534 | ! ifac holds the current factor. |
---|
| 535 | |
---|
| 536 | inu = kn |
---|
| 537 | knfax = 0 |
---|
| 538 | |
---|
| 539 | DO jl = ntest, 1, -1 |
---|
| 540 | ! |
---|
| 541 | ifac = ilfax(jl) |
---|
| 542 | IF( ifac > inu ) CYCLE |
---|
| 543 | |
---|
| 544 | ! Test whether the factor will divide. |
---|
| 545 | |
---|
| 546 | IF( MOD(inu,ifac) == 0 ) THEN |
---|
| 547 | ! |
---|
| 548 | knfax = knfax + 1 ! Add the factor to the list |
---|
| 549 | IF( knfax > kmaxfax ) THEN |
---|
| 550 | kerr = 6 |
---|
| 551 | write (*,*) 'FACTOR: insufficient space in factor array ', knfax |
---|
| 552 | return |
---|
| 553 | ENDIF |
---|
| 554 | kfax(knfax) = ifac |
---|
| 555 | ! Store the other factor that goes with this one |
---|
| 556 | knfax = knfax + 1 |
---|
| 557 | kfax(knfax) = inu / ifac |
---|
| 558 | !WRITE (*,*) 'ARPDBG, factors ',knfax-1,' & ',knfax,' are ', kfax(knfax-1),' and ',kfax(knfax) |
---|
| 559 | ENDIF |
---|
| 560 | ! |
---|
| 561 | END DO |
---|
| 562 | |
---|
| 563 | 20 CONTINUE ! Label 20 is the exit point from the factor search loop. |
---|
| 564 | ! |
---|
| 565 | END SUBROUTINE factorise |
---|
| 566 | |
---|
[3294] | 567 | #if defined key_mpp_mpi |
---|
[5600] | 568 | |
---|
[3294] | 569 | SUBROUTINE nemo_northcomms |
---|
| 570 | !!====================================================================== |
---|
| 571 | !! *** ROUTINE nemo_northcomms *** |
---|
[4829] | 572 | !! nemo_northcomms : Setup for north fold exchanges with explicit |
---|
| 573 | !! point-to-point messaging |
---|
[3294] | 574 | !!===================================================================== |
---|
| 575 | !!---------------------------------------------------------------------- |
---|
[3764] | 576 | !! |
---|
[3294] | 577 | !! ** Purpose : Initialization of the northern neighbours lists. |
---|
| 578 | !!---------------------------------------------------------------------- |
---|
[3764] | 579 | !! 1.0 ! 2011-10 (A. C. Coward, NOCS & J. Donners, PRACE) |
---|
[4829] | 580 | !! 2.0 ! 2013-06 Setup avoiding MPI communication (I. Epicoco, S. Mocavero, CMCC) |
---|
[3294] | 581 | !!---------------------------------------------------------------------- |
---|
| 582 | |
---|
[4829] | 583 | INTEGER :: sxM, dxM, sxT, dxT, jn |
---|
| 584 | INTEGER :: njmppmax |
---|
[3294] | 585 | |
---|
[4829] | 586 | njmppmax = MAXVAL( njmppt ) |
---|
| 587 | |
---|
| 588 | !initializes the north-fold communication variables |
---|
| 589 | isendto(:) = 0 |
---|
[3294] | 590 | nsndto = 0 |
---|
| 591 | |
---|
[4829] | 592 | !if I am a process in the north |
---|
| 593 | IF ( njmpp == njmppmax ) THEN |
---|
| 594 | !sxM is the first point (in the global domain) needed to compute the |
---|
| 595 | !north-fold for the current process |
---|
| 596 | sxM = jpiglo - nimppt(narea) - nlcit(narea) + 1 |
---|
| 597 | !dxM is the last point (in the global domain) needed to compute the |
---|
| 598 | !north-fold for the current process |
---|
| 599 | dxM = jpiglo - nimppt(narea) + 2 |
---|
[3294] | 600 | |
---|
[4829] | 601 | !loop over the other north-fold processes to find the processes |
---|
| 602 | !managing the points belonging to the sxT-dxT range |
---|
[5600] | 603 | |
---|
| 604 | DO jn = 1, jpni |
---|
[4829] | 605 | !sxT is the first point (in the global domain) of the jn |
---|
| 606 | !process |
---|
[5600] | 607 | sxT = nfiimpp(jn, jpnj) |
---|
[4829] | 608 | !dxT is the last point (in the global domain) of the jn |
---|
| 609 | !process |
---|
[5600] | 610 | dxT = nfiimpp(jn, jpnj) + nfilcit(jn, jpnj) - 1 |
---|
[4829] | 611 | IF ((sxM .gt. sxT) .AND. (sxM .lt. dxT)) THEN |
---|
| 612 | nsndto = nsndto + 1 |
---|
[5600] | 613 | isendto(nsndto) = jn |
---|
[4829] | 614 | ELSEIF ((sxM .le. sxT) .AND. (dxM .ge. dxT)) THEN |
---|
| 615 | nsndto = nsndto + 1 |
---|
[5600] | 616 | isendto(nsndto) = jn |
---|
[4829] | 617 | ELSEIF ((dxM .lt. dxT) .AND. (sxT .lt. dxM)) THEN |
---|
| 618 | nsndto = nsndto + 1 |
---|
[5600] | 619 | isendto(nsndto) = jn |
---|
[4829] | 620 | END IF |
---|
| 621 | END DO |
---|
[5600] | 622 | nfsloop = 1 |
---|
| 623 | nfeloop = nlci |
---|
| 624 | DO jn = 2,jpni-1 |
---|
| 625 | IF(nfipproc(jn,jpnj) .eq. (narea - 1)) THEN |
---|
| 626 | IF (nfipproc(jn - 1 ,jpnj) .eq. -1) THEN |
---|
| 627 | nfsloop = nldi |
---|
| 628 | ENDIF |
---|
| 629 | IF (nfipproc(jn + 1,jpnj) .eq. -1) THEN |
---|
| 630 | nfeloop = nlei |
---|
| 631 | ENDIF |
---|
| 632 | ENDIF |
---|
| 633 | END DO |
---|
| 634 | |
---|
[3294] | 635 | ENDIF |
---|
[4829] | 636 | l_north_nogather = .TRUE. |
---|
[3294] | 637 | END SUBROUTINE nemo_northcomms |
---|
| 638 | #else |
---|
| 639 | SUBROUTINE nemo_northcomms ! Dummy routine |
---|
| 640 | WRITE(*,*) 'nemo_northcomms: You should not have seen this print! error?' |
---|
| 641 | END SUBROUTINE nemo_northcomms |
---|
| 642 | #endif |
---|
[5600] | 643 | |
---|
[3] | 644 | !!====================================================================== |
---|
[2496] | 645 | END MODULE nemogcm |
---|
[4829] | 646 | |
---|
| 647 | |
---|