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