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