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