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