[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) |
---|
| 8 | !! 7.1 ! 1993-03 (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, |
---|
[2104] | 9 | !! P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes) release 7.1 |
---|
[1593] | 10 | !! - ! 1992-06 (L.Terray) coupling implementation |
---|
| 11 | !! - ! 1993-11 (M.A. Filiberti) IGLOO sea-ice |
---|
| 12 | !! 8.0 ! 1996-03 (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar, |
---|
[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) |
---|
| 15 | !! 8.2 ! 1999-11 (M. Imbard, H. Goosse) LIM sea-ice model |
---|
| 16 | !! ! 1999-12 (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols) OPEN-MP |
---|
| 17 | !! ! 2000-07 (J-M Molines, M. Imbard) Open Boundary Conditions (CLIPPER) |
---|
| 18 | !! NEMO 1.0 ! 2002-08 (G. Madec) F90: Free form and modules |
---|
| 19 | !! - ! 2004-06 (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces |
---|
| 20 | !! - ! 2004-08 (C. Talandier) New trends organization |
---|
| 21 | !! - ! 2005-06 (C. Ethe) Add the 1D configuration possibility |
---|
| 22 | !! - ! 2005-11 (V. Garnier) Surface pressure gradient organization |
---|
| 23 | !! - ! 2006-03 (L. Debreu, C. Mazauric) Agrif implementation |
---|
| 24 | !! - ! 2006-04 (G. Madec, R. Benshila) Step reorganization |
---|
| 25 | !! - ! 2007-07 (J. Chanut, A. Sellar) Unstructured open boundaries (BDY) |
---|
| 26 | !! 3.2 ! 2009-08 (S. Masson) open/write in the listing file in mpp |
---|
[2236] | 27 | !! 3.3 ! 2010-05 (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface |
---|
| 28 | !! - ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase |
---|
[2597] | 29 | !! 4.0 ! 2011-01 (A. R. Porter, STFC Daresbury) dynamical allocation |
---|
[1593] | 30 | !!---------------------------------------------------------------------- |
---|
[3] | 31 | |
---|
| 32 | !!---------------------------------------------------------------------- |
---|
[2496] | 33 | !! nemo_gcm : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice |
---|
| 34 | !! nemo_init : initialization of the NEMO system |
---|
| 35 | !! nemo_ctl : initialisation of the contol print |
---|
| 36 | !! nemo_closefile : close remaining open files |
---|
[2597] | 37 | !! nemo_alloc : dynamical allocation |
---|
[2630] | 38 | !! nemo_partition : calculate MPP domain decomposition |
---|
| 39 | !! factorise : calculate the factors of the no. of MPI processes |
---|
[3] | 40 | !!---------------------------------------------------------------------- |
---|
[2382] | 41 | USE step_oce ! module used in the ocean time stepping module |
---|
[888] | 42 | USE sbc_oce ! surface boundary condition: ocean |
---|
[2392] | 43 | USE cla ! cross land advection (tra_cla routine) |
---|
[3] | 44 | USE domcfg ! domain configuration (dom_cfg routine) |
---|
| 45 | USE mppini ! shared/distributed memory setting (mpp_init routine) |
---|
| 46 | USE domain ! domain initialization (dom_init routine) |
---|
| 47 | USE obcini ! open boundary cond. initialization (obc_ini routine) |
---|
[911] | 48 | USE bdyini ! unstructured open boundary cond. initialization (bdy_init routine) |
---|
[3] | 49 | USE istate ! initial state setting (istate_init routine) |
---|
| 50 | USE ldfdyn ! lateral viscosity setting (ldfdyn_init routine) |
---|
| 51 | USE ldftra ! lateral diffusivity setting (ldftra_init routine) |
---|
[2392] | 52 | USE zdfini ! vertical physics setting (zdf_init routine) |
---|
[3] | 53 | USE phycst ! physical constant (par_cst routine) |
---|
[2236] | 54 | USE trdmod ! momentum/tracers trends (trd_mod_init routine) |
---|
| 55 | USE asminc ! assimilation increments (asm_inc_init routine) |
---|
| 56 | USE asmtrj ! writing out state trajectory |
---|
| 57 | USE sshwzv ! vertical velocity used in asm |
---|
| 58 | USE diaptr ! poleward transports (dia_ptr_init routine) |
---|
| 59 | USE diaobs ! Observation diagnostics (dia_obs_init routine) |
---|
[2496] | 60 | USE step ! NEMO time-stepping (stp routine) |
---|
[532] | 61 | #if defined key_oasis3 |
---|
[1359] | 62 | USE cpl_oasis3 ! OASIS3 coupling |
---|
[599] | 63 | #elif defined key_oasis4 |
---|
[1359] | 64 | USE cpl_oasis4 ! OASIS4 coupling (not working) |
---|
[532] | 65 | #endif |
---|
[900] | 66 | USE c1d ! 1D configuration |
---|
| 67 | USE step_c1d ! Time stepping loop for the 1D configuration |
---|
[1594] | 68 | #if defined key_top |
---|
[1593] | 69 | USE trcini ! passive tracer initialisation |
---|
[1594] | 70 | #endif |
---|
[1593] | 71 | USE lib_mpp ! distributed memory computing |
---|
[1412] | 72 | #if defined key_iomput |
---|
| 73 | USE mod_ioclient |
---|
[1359] | 74 | #endif |
---|
[268] | 75 | |
---|
[2590] | 76 | IMPLICIT NONE |
---|
[3] | 77 | PRIVATE |
---|
| 78 | |
---|
[2496] | 79 | PUBLIC nemo_gcm ! called by model.F90 |
---|
| 80 | PUBLIC nemo_init ! needed by AGRIF |
---|
[467] | 81 | |
---|
[2498] | 82 | CHARACTER(lc) :: cform_aaa="( /, 'AAAAAAAA', / ) " ! flag for output listing |
---|
[1593] | 83 | |
---|
[3] | 84 | !!---------------------------------------------------------------------- |
---|
[2597] | 85 | !! NEMO/OPA 4.0 , NEMO Consortium (2011) |
---|
[2392] | 86 | !! $Id$ |
---|
[2329] | 87 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
[3] | 88 | !!---------------------------------------------------------------------- |
---|
| 89 | CONTAINS |
---|
| 90 | |
---|
[2496] | 91 | SUBROUTINE nemo_gcm |
---|
[3] | 92 | !!---------------------------------------------------------------------- |
---|
[2496] | 93 | !! *** ROUTINE nemo_gcm *** |
---|
[3] | 94 | !! |
---|
[2496] | 95 | !! ** Purpose : NEMO solves the primitive equations on an orthogonal |
---|
[1593] | 96 | !! curvilinear mesh on the sphere. |
---|
[3] | 97 | !! |
---|
| 98 | !! ** Method : - model general initialization |
---|
| 99 | !! - launch the time-stepping (stp routine) |
---|
[1593] | 100 | !! - finalize the run by closing files and communications |
---|
[3] | 101 | !! |
---|
[2613] | 102 | !! References : Madec, Delecluse, Imbard, and Levy, 1997: internal report, IPSL. |
---|
[1593] | 103 | !! Madec, 2008, internal report, IPSL. |
---|
[3] | 104 | !!---------------------------------------------------------------------- |
---|
| 105 | INTEGER :: istp ! time step index |
---|
[389] | 106 | !!---------------------------------------------------------------------- |
---|
[2382] | 107 | ! |
---|
[392] | 108 | #if defined key_agrif |
---|
[1593] | 109 | CALL Agrif_Init_Grids() ! AGRIF: set the meshes |
---|
[389] | 110 | #endif |
---|
| 111 | |
---|
[1593] | 112 | ! !-----------------------! |
---|
[2496] | 113 | CALL nemo_init !== Initialisations ==! |
---|
[1593] | 114 | ! !-----------------------! |
---|
| 115 | |
---|
[682] | 116 | ! check that all process are still there... If some process have an error, |
---|
| 117 | ! they will never enter in step and other processes will wait until the end of the cpu time! |
---|
[900] | 118 | IF( lk_mpp ) CALL mpp_max( nstop ) |
---|
[682] | 119 | |
---|
[1593] | 120 | IF(lwp) WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
| 121 | |
---|
| 122 | ! !-----------------------! |
---|
| 123 | ! !== time stepping ==! |
---|
| 124 | ! !-----------------------! |
---|
[900] | 125 | istp = nit000 |
---|
[2236] | 126 | #if defined key_c1d |
---|
[389] | 127 | DO WHILE ( istp <= nitend .AND. nstop == 0 ) |
---|
[900] | 128 | CALL stp_c1d( istp ) |
---|
[389] | 129 | istp = istp + 1 |
---|
| 130 | END DO |
---|
[2236] | 131 | #else |
---|
| 132 | IF( lk_asminc ) THEN |
---|
| 133 | IF( ln_bkgwri ) CALL asm_bkg_wri( nit000 - 1 ) ! Output background fields |
---|
| 134 | IF( ln_trjwri ) CALL asm_trj_wri( nit000 - 1 ) ! Output trajectory fields |
---|
| 135 | IF( ln_asmdin ) THEN ! Direct initialization |
---|
| 136 | IF( ln_trainc ) CALL tra_asm_inc( nit000 - 1 ) ! Tracers |
---|
| 137 | IF( ln_dyninc ) THEN |
---|
| 138 | CALL dyn_asm_inc( nit000 - 1 ) ! Dynamics |
---|
| 139 | IF ( ln_asmdin ) CALL ssh_wzv ( nit000 - 1 ) ! update vertical velocity |
---|
| 140 | ENDIF |
---|
| 141 | IF( ln_sshinc ) CALL ssh_asm_inc( nit000 - 1 ) ! SSH |
---|
| 142 | ENDIF |
---|
| 143 | ENDIF |
---|
| 144 | |
---|
[389] | 145 | DO WHILE ( istp <= nitend .AND. nstop == 0 ) |
---|
[392] | 146 | #if defined key_agrif |
---|
[1593] | 147 | CALL Agrif_Step( stp ) ! AGRIF: time stepping |
---|
[389] | 148 | #else |
---|
[1593] | 149 | CALL stp( istp ) ! standard time stepping |
---|
[389] | 150 | #endif |
---|
| 151 | istp = istp + 1 |
---|
[900] | 152 | IF( lk_mpp ) CALL mpp_max( nstop ) |
---|
[389] | 153 | END DO |
---|
[2236] | 154 | #endif |
---|
| 155 | |
---|
| 156 | IF( lk_diaobs ) CALL dia_obs_wri |
---|
[1593] | 157 | |
---|
| 158 | ! !------------------------! |
---|
| 159 | ! !== finalize the run ==! |
---|
| 160 | ! !------------------------! |
---|
| 161 | IF(lwp) WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
| 162 | ! |
---|
| 163 | IF( nstop /= 0 .AND. lwp ) THEN ! error print |
---|
[682] | 164 | WRITE(numout,cform_err) |
---|
| 165 | WRITE(numout,*) nstop, ' error have been found' |
---|
[389] | 166 | ENDIF |
---|
[1593] | 167 | ! |
---|
[2496] | 168 | CALL nemo_closefile |
---|
[532] | 169 | #if defined key_oasis3 || defined key_oasis4 |
---|
[1976] | 170 | CALL cpl_prism_finalize ! end coupling and mpp communications with OASIS |
---|
[532] | 171 | #else |
---|
[1593] | 172 | IF( lk_mpp ) CALL mppstop ! end mpp communications |
---|
[532] | 173 | #endif |
---|
[900] | 174 | ! |
---|
[2496] | 175 | END SUBROUTINE nemo_gcm |
---|
[389] | 176 | |
---|
| 177 | |
---|
[2496] | 178 | SUBROUTINE nemo_init |
---|
[389] | 179 | !!---------------------------------------------------------------------- |
---|
[2496] | 180 | !! *** ROUTINE nemo_init *** |
---|
[389] | 181 | !! |
---|
[2496] | 182 | !! ** Purpose : initialization of the NEMO GCM |
---|
[389] | 183 | !!---------------------------------------------------------------------- |
---|
[2613] | 184 | INTEGER :: ji ! dummy loop indices |
---|
| 185 | INTEGER :: ilocal_comm ! local integer |
---|
[2496] | 186 | CHARACTER(len=80), DIMENSION(10) :: cltxt |
---|
[1593] | 187 | !! |
---|
[1601] | 188 | NAMELIST/namctl/ ln_ctl , nn_print, nn_ictls, nn_ictle, & |
---|
[1976] | 189 | & nn_isplt, nn_jsplt, nn_jctls, nn_jctle, nn_bench |
---|
[3] | 190 | !!---------------------------------------------------------------------- |
---|
[1593] | 191 | ! |
---|
[2496] | 192 | cltxt = '' |
---|
| 193 | ! |
---|
[1593] | 194 | ! ! open Namelist file |
---|
[1581] | 195 | CALL ctl_opn( numnam, 'namelist', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. ) |
---|
[1593] | 196 | ! |
---|
| 197 | READ( numnam, namctl ) ! Namelist namctl : Control prints & Benchmark |
---|
| 198 | ! |
---|
| 199 | ! !--------------------------------------------! |
---|
| 200 | ! ! set communicator & select the local node ! |
---|
| 201 | ! !--------------------------------------------! |
---|
[1412] | 202 | #if defined key_iomput |
---|
[2200] | 203 | IF( Agrif_Root() ) THEN |
---|
[1412] | 204 | # if defined key_oasis3 || defined key_oasis4 |
---|
[2625] | 205 | CALL cpl_prism_init( ilocal_comm ) ! nemo local communicator given by oasis |
---|
[1412] | 206 | # endif |
---|
[2625] | 207 | CALL init_ioclient( ilocal_comm ) ! exchange io_server nemo local communicator with the io_server |
---|
[2200] | 208 | ENDIF |
---|
[2625] | 209 | narea = mynode( cltxt, numnam, nstop, ilocal_comm ) ! Nodes selection |
---|
[532] | 210 | #else |
---|
[1412] | 211 | # if defined key_oasis3 || defined key_oasis4 |
---|
[2236] | 212 | IF( Agrif_Root() ) THEN |
---|
[2625] | 213 | CALL cpl_prism_init( ilocal_comm ) ! nemo local communicator given by oasis |
---|
[2236] | 214 | ENDIF |
---|
[2625] | 215 | narea = mynode( cltxt, numnam, nstop, ilocal_comm ) ! Nodes selection (control print return in cltxt) |
---|
[1412] | 216 | # else |
---|
[2082] | 217 | ilocal_comm = 0 |
---|
[2641] | 218 | narea = mynode( cltxt, numnam, nstop ) ! Nodes selection (control print return in cltxt) |
---|
[1412] | 219 | # endif |
---|
[532] | 220 | #endif |
---|
[2625] | 221 | narea = narea + 1 ! mynode return the rank of proc (0 --> jpnij -1 ) |
---|
[3] | 222 | |
---|
[2625] | 223 | lwp = (narea == 1) .OR. ln_ctl ! control of all listing output print |
---|
[1579] | 224 | |
---|
[2590] | 225 | ! Decide on size of grid now that we have our communicator size |
---|
| 226 | ! If we're not using dynamic memory then mpp_partition does nothing. |
---|
| 227 | |
---|
| 228 | #if defined key_mpp_mpi || defined key_mpp_shmem |
---|
| 229 | CALL nemo_partition(mppsize) |
---|
| 230 | #else |
---|
| 231 | jpni = 1 |
---|
| 232 | jpnj = 1 |
---|
| 233 | jpnij = jpni*jpnj |
---|
| 234 | #endif |
---|
| 235 | ! Calculate domain dimensions given calculated jpni and jpnj |
---|
| 236 | ! This used to be done in par_oce.F90 when they were parameters rather |
---|
| 237 | ! than variables |
---|
| 238 | jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci !: first dim. |
---|
| 239 | jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj !: second dim. |
---|
| 240 | jpim1 = jpi-1 !: inner domain indices |
---|
| 241 | jpjm1 = jpj-1 !: " " |
---|
| 242 | jpkm1 = jpk-1 !: " " |
---|
| 243 | jpij = jpi*jpj !: jpi x j |
---|
| 244 | |
---|
| 245 | ! Now we know the dimensions of the grid, allocate arrays |
---|
| 246 | CALL nemo_alloc() |
---|
| 247 | |
---|
[1593] | 248 | IF(lwp) THEN ! open listing units |
---|
| 249 | ! |
---|
[1581] | 250 | CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea ) |
---|
[1593] | 251 | ! |
---|
[1579] | 252 | WRITE(numout,*) |
---|
[1593] | 253 | WRITE(numout,*) ' CNRS - NERC - Met OFFICE - MERCATOR-ocean' |
---|
| 254 | WRITE(numout,*) ' NEMO team' |
---|
[1579] | 255 | WRITE(numout,*) ' Ocean General Circulation Model' |
---|
[2104] | 256 | WRITE(numout,*) ' version 3.3 (2010) ' |
---|
[1579] | 257 | WRITE(numout,*) |
---|
| 258 | WRITE(numout,*) |
---|
[1593] | 259 | DO ji = 1, SIZE(cltxt) |
---|
| 260 | IF( TRIM(cltxt(ji)) /= '' ) WRITE(numout,*) cltxt(ji) ! control print of mynode |
---|
[1579] | 261 | END DO |
---|
[1593] | 262 | WRITE(numout,cform_aaa) ! Flag AAAAAAA |
---|
| 263 | ! |
---|
[473] | 264 | ENDIF |
---|
[2496] | 265 | ! !-------------------------------! |
---|
| 266 | ! ! NEMO general initialization ! |
---|
| 267 | ! !-------------------------------! |
---|
[473] | 268 | |
---|
[2496] | 269 | CALL nemo_ctl ! Control prints & Benchmark |
---|
[531] | 270 | |
---|
[2082] | 271 | ! ! Domain decomposition |
---|
[1593] | 272 | IF( jpni*jpnj == jpnij ) THEN ; CALL mpp_init ! standard cutting out |
---|
| 273 | ELSE ; CALL mpp_init2 ! eliminate land processors |
---|
[3] | 274 | ENDIF |
---|
[2382] | 275 | ! |
---|
[2082] | 276 | ! ! General initialization |
---|
[2027] | 277 | CALL phy_cst ! Physical constants |
---|
| 278 | CALL eos_init ! Equation of state |
---|
| 279 | CALL dom_cfg ! Domain configuration |
---|
| 280 | CALL dom_init ! Domain |
---|
[413] | 281 | |
---|
[2027] | 282 | IF( ln_ctl ) CALL prt_ctl_init ! Print control |
---|
| 283 | |
---|
| 284 | IF( lk_obc ) CALL obc_init ! Open boundaries |
---|
| 285 | IF( lk_bdy ) CALL bdy_init ! Unstructured open boundaries |
---|
| 286 | |
---|
| 287 | CALL istate_init ! ocean initial state (Dynamics and tracers) |
---|
| 288 | |
---|
[3] | 289 | ! ! Ocean physics |
---|
[2104] | 290 | CALL sbc_init ! Forcings : surface module |
---|
[2082] | 291 | ! ! Vertical physics |
---|
| 292 | CALL zdf_init ! namelist read |
---|
| 293 | CALL zdf_bfr_init ! bottom friction |
---|
| 294 | IF( lk_zdfric ) CALL zdf_ric_init ! Richardson number dependent Kz |
---|
[2329] | 295 | IF( lk_zdftke ) CALL zdf_tke_init ! TKE closure scheme |
---|
| 296 | IF( lk_zdfgls ) CALL zdf_gls_init ! GLS closure scheme |
---|
| 297 | IF( lk_zdfkpp ) CALL zdf_kpp_init ! KPP closure scheme |
---|
[2082] | 298 | IF( lk_zdftmx ) CALL zdf_tmx_init ! tidal vertical mixing |
---|
[2027] | 299 | IF( lk_zdfddm .AND. .NOT. lk_zdfkpp ) & |
---|
[2082] | 300 | & CALL zdf_ddm_init ! double diffusive mixing |
---|
| 301 | ! ! Lateral physics |
---|
| 302 | CALL ldf_tra_init ! Lateral ocean tracer physics |
---|
| 303 | CALL ldf_dyn_init ! Lateral ocean momentum physics |
---|
[2392] | 304 | IF( lk_ldfslp ) CALL ldf_slp_init ! slope of lateral mixing |
---|
[2082] | 305 | |
---|
[2027] | 306 | ! ! Active tracers |
---|
| 307 | CALL tra_qsr_init ! penetrative solar radiation qsr |
---|
[2325] | 308 | CALL tra_bbc_init ! bottom heat flux |
---|
[2027] | 309 | IF( lk_trabbl ) CALL tra_bbl_init ! advective (and/or diffusive) bottom boundary layer scheme |
---|
| 310 | IF( lk_tradmp ) CALL tra_dmp_init ! internal damping trends |
---|
| 311 | CALL tra_adv_init ! horizontal & vertical advection |
---|
| 312 | CALL tra_ldf_init ! lateral mixing |
---|
| 313 | CALL tra_zdf_init ! vertical mixing and after tracer fields |
---|
| 314 | |
---|
| 315 | ! ! Dynamics |
---|
| 316 | CALL dyn_adv_init ! advection (vector or flux form) |
---|
[2104] | 317 | CALL dyn_vor_init ! vorticity term including Coriolis |
---|
[2027] | 318 | CALL dyn_ldf_init ! lateral mixing |
---|
[2104] | 319 | CALL dyn_hpg_init ! horizontal gradient of Hydrostatic pressure |
---|
[2027] | 320 | CALL dyn_zdf_init ! vertical diffusion |
---|
| 321 | CALL dyn_spg_init ! surface pressure gradient |
---|
[2392] | 322 | |
---|
| 323 | ! ! Misc. options |
---|
| 324 | IF( nn_cla == 1 ) CALL cla_init ! Cross Land Advection |
---|
| 325 | |
---|
[1594] | 326 | #if defined key_top |
---|
[2027] | 327 | ! ! Passive tracers |
---|
[2082] | 328 | CALL trc_init |
---|
[1594] | 329 | #endif |
---|
[2382] | 330 | ! ! Diagnostics |
---|
[2027] | 331 | CALL iom_init ! iom_put initialization |
---|
[2392] | 332 | IF( lk_floats ) CALL flo_init ! drifting Floats |
---|
| 333 | IF( lk_diaar5 ) CALL dia_ar5_init ! ar5 diag |
---|
[2027] | 334 | CALL dia_ptr_init ! Poleward TRansports initialization |
---|
[2148] | 335 | CALL dia_hsb_init ! heat content, salt content and volume budgets |
---|
[2027] | 336 | CALL trd_mod_init ! Mixed-layer/Vorticity/Integral constraints trends |
---|
[2392] | 337 | IF( lk_diaobs ) THEN ! Observation & model comparison |
---|
[2382] | 338 | CALL dia_obs_init ! Initialize observational data |
---|
| 339 | CALL dia_obs( nit000 - 1 ) ! Observation operator for restart |
---|
[2236] | 340 | ENDIF |
---|
[2382] | 341 | ! ! Assimilation increments |
---|
[2392] | 342 | IF( lk_asminc ) CALL asm_inc_init ! Initialize assimilation increments |
---|
[2382] | 343 | IF(lwp) WRITE(numout,*) 'Euler time step switch is ', neuler |
---|
[1593] | 344 | ! |
---|
[2496] | 345 | END SUBROUTINE nemo_init |
---|
[467] | 346 | |
---|
| 347 | |
---|
[2496] | 348 | SUBROUTINE nemo_ctl |
---|
[467] | 349 | !!---------------------------------------------------------------------- |
---|
[2496] | 350 | !! *** ROUTINE nemo_ctl *** |
---|
[467] | 351 | !! |
---|
[2442] | 352 | !! ** Purpose : control print setting |
---|
[467] | 353 | !! |
---|
[2442] | 354 | !! ** Method : - print namctl information and check some consistencies |
---|
[467] | 355 | !!---------------------------------------------------------------------- |
---|
[2442] | 356 | ! |
---|
[2496] | 357 | IF(lwp) THEN ! control print |
---|
[531] | 358 | WRITE(numout,*) |
---|
[2496] | 359 | WRITE(numout,*) 'nemo_ctl: Control prints & Benchmark' |
---|
[531] | 360 | WRITE(numout,*) '~~~~~~~ ' |
---|
[1593] | 361 | WRITE(numout,*) ' Namelist namctl' |
---|
[1601] | 362 | WRITE(numout,*) ' run control (for debugging) ln_ctl = ', ln_ctl |
---|
| 363 | WRITE(numout,*) ' level of print nn_print = ', nn_print |
---|
| 364 | WRITE(numout,*) ' Start i indice for SUM control nn_ictls = ', nn_ictls |
---|
| 365 | WRITE(numout,*) ' End i indice for SUM control nn_ictle = ', nn_ictle |
---|
| 366 | WRITE(numout,*) ' Start j indice for SUM control nn_jctls = ', nn_jctls |
---|
| 367 | WRITE(numout,*) ' End j indice for SUM control nn_jctle = ', nn_jctle |
---|
| 368 | WRITE(numout,*) ' number of proc. following i nn_isplt = ', nn_isplt |
---|
| 369 | WRITE(numout,*) ' number of proc. following j nn_jsplt = ', nn_jsplt |
---|
| 370 | WRITE(numout,*) ' benchmark parameter (0/1) nn_bench = ', nn_bench |
---|
[531] | 371 | ENDIF |
---|
[2442] | 372 | ! |
---|
[1601] | 373 | nprint = nn_print ! convert DOCTOR namelist names into OLD names |
---|
| 374 | nictls = nn_ictls |
---|
| 375 | nictle = nn_ictle |
---|
| 376 | njctls = nn_jctls |
---|
| 377 | njctle = nn_jctle |
---|
| 378 | isplt = nn_isplt |
---|
| 379 | jsplt = nn_jsplt |
---|
| 380 | nbench = nn_bench |
---|
[2442] | 381 | ! ! Parameter control |
---|
[1593] | 382 | ! |
---|
| 383 | IF( ln_ctl ) THEN ! sub-domain area indices for the control prints |
---|
| 384 | IF( lk_mpp ) THEN |
---|
[2496] | 385 | isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj ! the domain is forced to the real split domain |
---|
[531] | 386 | ELSE |
---|
| 387 | IF( isplt == 1 .AND. jsplt == 1 ) THEN |
---|
[1593] | 388 | CALL ctl_warn( ' - isplt & jsplt are equal to 1', & |
---|
| 389 | & ' - the print control will be done over the whole domain' ) |
---|
[531] | 390 | ENDIF |
---|
[1593] | 391 | ijsplt = isplt * jsplt ! total number of processors ijsplt |
---|
[531] | 392 | ENDIF |
---|
| 393 | IF(lwp) WRITE(numout,*)' - The total number of processors over which the' |
---|
| 394 | IF(lwp) WRITE(numout,*)' print control will be done is ijsplt : ', ijsplt |
---|
[1593] | 395 | ! |
---|
| 396 | ! ! indices used for the SUM control |
---|
| 397 | IF( nictls+nictle+njctls+njctle == 0 ) THEN ! print control done over the default area |
---|
| 398 | lsp_area = .FALSE. |
---|
| 399 | ELSE ! print control done over a specific area |
---|
[531] | 400 | lsp_area = .TRUE. |
---|
| 401 | IF( nictls < 1 .OR. nictls > jpiglo ) THEN |
---|
| 402 | CALL ctl_warn( ' - nictls must be 1<=nictls>=jpiglo, it is forced to 1' ) |
---|
| 403 | nictls = 1 |
---|
| 404 | ENDIF |
---|
| 405 | IF( nictle < 1 .OR. nictle > jpiglo ) THEN |
---|
| 406 | CALL ctl_warn( ' - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' ) |
---|
| 407 | nictle = jpiglo |
---|
| 408 | ENDIF |
---|
| 409 | IF( njctls < 1 .OR. njctls > jpjglo ) THEN |
---|
| 410 | CALL ctl_warn( ' - njctls must be 1<=njctls>=jpjglo, it is forced to 1' ) |
---|
| 411 | njctls = 1 |
---|
| 412 | ENDIF |
---|
| 413 | IF( njctle < 1 .OR. njctle > jpjglo ) THEN |
---|
| 414 | CALL ctl_warn( ' - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' ) |
---|
| 415 | njctle = jpjglo |
---|
| 416 | ENDIF |
---|
[1593] | 417 | ENDIF |
---|
| 418 | ENDIF |
---|
[2442] | 419 | ! |
---|
| 420 | IF( nbench == 1 ) THEN ! Benchmark |
---|
[531] | 421 | SELECT CASE ( cp_cfg ) |
---|
[1593] | 422 | CASE ( 'gyre' ) ; CALL ctl_warn( ' The Benchmark is activated ' ) |
---|
| 423 | CASE DEFAULT ; CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:', & |
---|
| 424 | & ' key_gyre must be used or set nbench = 0' ) |
---|
[531] | 425 | END SELECT |
---|
| 426 | ENDIF |
---|
[1593] | 427 | ! |
---|
[2496] | 428 | IF( lk_c1d .AND. .NOT.lk_iomput ) CALL ctl_stop( 'nemo_ctl: The 1D configuration must be used ', & |
---|
| 429 | & 'with the IOM Input/Output manager. ' , & |
---|
[2442] | 430 | & 'Compile with key_iomput enabled' ) |
---|
[2409] | 431 | ! |
---|
[2496] | 432 | END SUBROUTINE nemo_ctl |
---|
[467] | 433 | |
---|
| 434 | |
---|
[2496] | 435 | SUBROUTINE nemo_closefile |
---|
[467] | 436 | !!---------------------------------------------------------------------- |
---|
[2496] | 437 | !! *** ROUTINE nemo_closefile *** |
---|
[467] | 438 | !! |
---|
| 439 | !! ** Purpose : Close the files |
---|
| 440 | !!---------------------------------------------------------------------- |
---|
[1593] | 441 | ! |
---|
| 442 | IF( lk_mpp ) CALL mppsync |
---|
| 443 | ! |
---|
[1685] | 444 | CALL iom_close ! close all input/output files managed by iom_* |
---|
[1593] | 445 | ! |
---|
[1685] | 446 | IF( numstp /= -1 ) CLOSE( numstp ) ! time-step file |
---|
| 447 | IF( numsol /= -1 ) CLOSE( numsol ) ! solver file |
---|
| 448 | IF( numnam /= -1 ) CLOSE( numnam ) ! oce namelist |
---|
| 449 | IF( numnam_ice /= -1 ) CLOSE( numnam_ice ) ! ice namelist |
---|
| 450 | IF( numevo_ice /= -1 ) CLOSE( numevo_ice ) ! ice variables (temp. evolution) |
---|
| 451 | IF( numout /= 6 ) CLOSE( numout ) ! standard model output file |
---|
[1593] | 452 | ! |
---|
[2442] | 453 | numout = 6 ! redefine numout in case it is used after this point... |
---|
| 454 | ! |
---|
[2496] | 455 | END SUBROUTINE nemo_closefile |
---|
[467] | 456 | |
---|
[2590] | 457 | |
---|
| 458 | SUBROUTINE nemo_alloc |
---|
| 459 | !!---------------------------------------------------------------------- |
---|
| 460 | !! *** ROUTINE nemo_alloc *** |
---|
| 461 | !! |
---|
[2613] | 462 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
[2590] | 463 | !! |
---|
| 464 | !! ** Method : |
---|
| 465 | !!---------------------------------------------------------------------- |
---|
| 466 | USE diawri, ONLY: dia_wri_alloc |
---|
| 467 | USE dom_oce, ONLY: dom_oce_alloc |
---|
[2618] | 468 | USE ldfdyn_oce, ONLY: ldfdyn_oce_alloc |
---|
| 469 | USE ldftra_oce, ONLY: ldftra_oce_alloc |
---|
[2625] | 470 | USE trc_oce, ONLY: trc_oce_alloc |
---|
[2618] | 471 | |
---|
[2630] | 472 | USE wrk_nemo, ONLY: wrk_alloc |
---|
[2616] | 473 | |
---|
[2613] | 474 | INTEGER :: ierr |
---|
| 475 | INTEGER :: i |
---|
| 476 | !!---------------------------------------------------------------------- |
---|
[2590] | 477 | |
---|
[2625] | 478 | ierr = oce_alloc () ! ocean |
---|
[2618] | 479 | ierr = ierr + dia_wri_alloc () |
---|
[2625] | 480 | ierr = ierr + dom_oce_alloc () ! ocean domain |
---|
| 481 | ierr = ierr + ldfdyn_oce_alloc() ! ocean lateral physics : dynamics |
---|
| 482 | ierr = ierr + ldftra_oce_alloc() ! ocean lateral physics : tracers |
---|
| 483 | ierr = ierr + zdf_oce_alloc () ! ocean vertical physics |
---|
| 484 | ! |
---|
| 485 | ierr = ierr + lib_mpp_alloc (numout) ! mpp exchanges |
---|
| 486 | ierr = ierr + trc_oce_alloc () ! shared TRC / TRA arrays |
---|
[2616] | 487 | |
---|
[2647] | 488 | ierr = ierr + wrk_alloc(numout, lwp) ! workspace |
---|
[2616] | 489 | |
---|
| 490 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
[2613] | 491 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'nemo_alloc : unable to allocate standard ocean arrays' ) |
---|
| 492 | ! |
---|
[2590] | 493 | END SUBROUTINE nemo_alloc |
---|
| 494 | |
---|
| 495 | |
---|
[2613] | 496 | SUBROUTINE nemo_partition( num_pes ) |
---|
[2616] | 497 | !!---------------------------------------------------------------------- |
---|
| 498 | !! *** ROUTINE nemo_partition *** |
---|
| 499 | !! |
---|
| 500 | !! ** Purpose : |
---|
| 501 | !! |
---|
| 502 | !! ** Method : |
---|
| 503 | !!---------------------------------------------------------------------- |
---|
| 504 | USE par_oce |
---|
| 505 | INTEGER, INTENT(in) :: num_pes ! The number of MPI processes we have |
---|
| 506 | ! Local variables |
---|
| 507 | INTEGER, PARAMETER :: nfactmax = 20 |
---|
| 508 | INTEGER :: nfact ! The no. of factors returned |
---|
| 509 | INTEGER :: ierr ! Error flag |
---|
| 510 | INTEGER :: i |
---|
| 511 | INTEGER :: idiff, mindiff, imin ! For choosing pair of factors that are closest in value |
---|
| 512 | INTEGER, DIMENSION(nfactmax) :: ifact ! Array of factors |
---|
| 513 | !!---------------------------------------------------------------------- |
---|
[2590] | 514 | |
---|
[2616] | 515 | ierr = 0 |
---|
[2590] | 516 | |
---|
[2616] | 517 | CALL factorise( ifact, nfactmax, nfact, num_pes, ierr ) |
---|
[2590] | 518 | |
---|
[2616] | 519 | IF( nfact <= 1 ) THEN |
---|
| 520 | WRITE (numout, *) 'WARNING: factorisation of number of PEs failed' |
---|
| 521 | WRITE (numout, *) ' : using grid of ',num_pes,' x 1' |
---|
| 522 | jpnj = 1 |
---|
| 523 | jpni = num_pes |
---|
| 524 | ELSE |
---|
| 525 | ! Search through factors for the pair that are closest in value |
---|
| 526 | mindiff = 1000000 |
---|
| 527 | imin = 1 |
---|
| 528 | DO i=1,nfact-1,2 |
---|
| 529 | idiff = ABS(ifact(i) - ifact(i+1)) |
---|
| 530 | IF(idiff < mindiff)THEN |
---|
| 531 | mindiff = idiff |
---|
| 532 | imin = i |
---|
| 533 | END IF |
---|
| 534 | END DO |
---|
| 535 | jpnj = ifact(imin) |
---|
| 536 | jpni = ifact(imin + 1) |
---|
| 537 | ENDIF |
---|
| 538 | jpnij = jpni*jpnj |
---|
[2590] | 539 | |
---|
[2616] | 540 | WRITE(*,*) 'ARPDBG: jpni = ',jpni,'jpnj = ',jpnj,'jpnij = ',jpnij |
---|
| 541 | ! |
---|
[2590] | 542 | END SUBROUTINE nemo_partition |
---|
| 543 | |
---|
| 544 | |
---|
[2616] | 545 | SUBROUTINE factorise( ifax, maxfax, nfax, n, ierr ) |
---|
| 546 | !!---------------------------------------------------------------------- |
---|
| 547 | !! *** ROUTINE factorise *** |
---|
| 548 | !! |
---|
| 549 | !! ** Purpose : return the prime factors of n. |
---|
| 550 | !! nfax factors are returned in array ifax which is of |
---|
| 551 | !! maximum dimension maxfax. |
---|
| 552 | !! ** Method : |
---|
| 553 | !!---------------------------------------------------------------------- |
---|
| 554 | INTEGER, INTENT(in) :: n, maxfax |
---|
| 555 | INTEGER, INTENT(Out) :: ierr, nfax |
---|
| 556 | INTEGER, INTENT(out) :: ifax(maxfax) |
---|
| 557 | ! Local variables. |
---|
| 558 | INTEGER :: i, ifac, l, nu |
---|
| 559 | INTEGER, PARAMETER :: ntest = 14 |
---|
| 560 | INTEGER :: lfax(ntest) |
---|
[2590] | 561 | |
---|
[2616] | 562 | ! lfax contains the set of allowed factors. |
---|
| 563 | data (lfax(i),i=1,ntest) / 16384, 8192, 4096, 2048, 1024, 512, 256, & |
---|
| 564 | & 128, 64, 32, 16, 8, 4, 2 / |
---|
| 565 | !!---------------------------------------------------------------------- |
---|
[2590] | 566 | |
---|
[2616] | 567 | ! Clear the error flag and initialise output vars |
---|
| 568 | ierr = 0 |
---|
| 569 | ifax = 1 |
---|
| 570 | nfax = 0 |
---|
[2590] | 571 | |
---|
[2616] | 572 | ! Find the factors of n. |
---|
| 573 | IF( n == 1 ) GOTO 20 |
---|
[2590] | 574 | |
---|
[2616] | 575 | ! nu holds the unfactorised part of the number. |
---|
| 576 | ! nfax holds the number of factors found. |
---|
| 577 | ! l points to the allowed factor list. |
---|
| 578 | ! ifac holds the current factor. |
---|
[2590] | 579 | |
---|
[2616] | 580 | nu = n |
---|
[2590] | 581 | nfax = 0 |
---|
| 582 | |
---|
[2616] | 583 | DO l = ntest, 1, -1 |
---|
| 584 | ! |
---|
[2590] | 585 | ifac = lfax(l) |
---|
| 586 | IF(ifac > nu)CYCLE |
---|
| 587 | |
---|
| 588 | ! Test whether the factor will divide. |
---|
| 589 | |
---|
[2616] | 590 | IF( MOD(nu,ifac) == 0 ) THEN |
---|
| 591 | ! |
---|
| 592 | nfax = nfax+1 ! Add the factor to the list |
---|
| 593 | IF( nfax > maxfax ) THEN |
---|
[2590] | 594 | ierr = 6 |
---|
| 595 | write (*,*) 'FACTOR: insufficient space in factor array ',nfax |
---|
| 596 | return |
---|
[2616] | 597 | ENDIF |
---|
[2590] | 598 | ifax(nfax) = ifac |
---|
| 599 | ! Store the other factor that goes with this one |
---|
| 600 | nfax = nfax + 1 |
---|
[2616] | 601 | ifax(nfax) = nu / ifac |
---|
[2590] | 602 | !WRITE (*,*) 'ARPDBG, factors ',nfax-1,' & ',nfax,' are ', & |
---|
| 603 | ! ifax(nfax-1),' and ',ifax(nfax) |
---|
[2616] | 604 | ENDIF |
---|
| 605 | ! |
---|
[2590] | 606 | END DO |
---|
| 607 | |
---|
[2616] | 608 | 20 CONTINUE ! Label 20 is the exit point from the factor search loop. |
---|
| 609 | ! |
---|
| 610 | RETURN |
---|
| 611 | ! |
---|
[2620] | 612 | END SUBROUTINE factorise |
---|
[2590] | 613 | |
---|
[2620] | 614 | !!====================================================================== |
---|
[2496] | 615 | END MODULE nemogcm |
---|