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