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