New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
nemogcm.F90 in NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/src/SWE – NEMO

source: NEMO/branches/2020/dev_r12527_Gurvan_ShallowWater/src/SWE/nemogcm.F90 @ 12614

Last change on this file since 12614 was 12614, checked in by gm, 4 years ago

first Shallow Water Eq. update

  • Property svn:keywords set to Id
File size: 30.6 KB
Line 
1MODULE nemogcm
2   !!======================================================================
3   !!                       ***  MODULE nemogcm   ***
4   !! Ocean system   : NEMO GCM (ocean dynamics, on-line tracers, biochemistry and sea-ice)
5   !!======================================================================
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,
9   !!                             P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes) release 7.1
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,
13   !!                             P. Delecluse, L.Terray, M.A. Filiberti, J. Vialar, A.M. Treguier, M. Levy) release 8.0
14   !!            8.1  ! 1997-06  (M. Imbard, G. Madec)
15   !!            8.2  ! 1999-11  (M. Imbard, H. Goosse)  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
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
29   !!            3.3.1! 2011-01  (A. R. Porter, STFC Daresbury) dynamical allocation
30   !!             -   ! 2011-11  (C. Harris) decomposition changes for running with CICE
31   !!            3.6  ! 2012-05  (C. Calone, J. Simeon, G. Madec, C. Ethe) Add grid coarsening
32   !!             -   ! 2014-12  (G. Madec) remove KPP scheme and cross-land advection (cla)
33   !!            4.0  ! 2016-10  (G. Madec, S. Flavoni)  domain configuration / user defined interface
34   !!----------------------------------------------------------------------
35
36   !!----------------------------------------------------------------------
37   !!   nemo_gcm      : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice
38   !!   nemo_init     : initialization of the NEMO system
39   !!   nemo_ctl      : initialisation of the contol print
40   !!   nemo_closefile: close remaining open files
41   !!   nemo_alloc    : dynamical allocation
42   !!----------------------------------------------------------------------
43   USE step_oce       ! module used in the ocean time stepping module (step.F90)
44   USE phycst         ! physical constant                  (par_cst routine)
45   USE domain         ! domain initialization   (dom_init & dom_cfg routines)
46   USE closea         ! treatment of closed seas (for ln_closea)
47   USE usrdef_nam     ! user defined configuration
48   USE tide_mod, ONLY : tide_init ! tidal components initialization   (tide_init routine)
49   USE bdy_oce,  ONLY : ln_bdy
50   USE bdyini         ! open boundary cond. setting       (bdy_init routine)
51   USE istate         ! initial state setting          (istate_init routine)
52   USE ldfdyn         ! lateral viscosity setting      (ldfdyn_init routine)
53   USE ldftra         ! lateral diffusivity setting    (ldftra_init routine)
54   USE trdini         ! dyn/tra trends initialization     (trd_init routine)
55   USE asminc         ! assimilation increments     
56   USE asmbkg         ! writing out state trajectory
57   USE diaptr         ! poleward transports           (dia_ptr_init routine)
58   USE diadct         ! sections transports           (dia_dct_init routine)
59   USE diaobs         ! Observation diagnostics       (dia_obs_init routine)
60   USE diacfl         ! CFL diagnostics               (dia_cfl_init routine)
61   USE diamlr         ! IOM context management for multiple-linear-regression analysis
62   USE step           ! NEMO time-stepping                 (stp     routine)
63   USE isfstp         ! ice shelf                     (isf_stp_init routine)
64   USE icbini         ! handle bergs, initialisation
65   USE icbstp         ! handle bergs, calving, themodynamics and transport
66   USE cpl_oasis3     ! OASIS3 coupling
67   USE c1d            ! 1D configuration
68   USE step_c1d       ! Time stepping loop for the 1D configuration
69   USE dyndmp         ! Momentum damping
70   USE stopar         ! Stochastic param.: ???
71   USE stopts         ! Stochastic param.: ???
72   USE diu_layers     ! diurnal bulk SST and coolskin
73   USE crsini         ! initialise grid coarsening utility
74   USE dia25h         ! 25h mean output
75   USE diadetide      ! Weights computation for daily detiding of model diagnostics
76   USE sbc_oce , ONLY : lk_oasis
77   USE wet_dry        ! Wetting and drying setting   (wad_init routine)
78#if defined key_top
79   USE trcini         ! passive tracer initialisation
80#endif
81#if defined key_nemocice_decomp
82   USE ice_domain_size, only: nx_global, ny_global
83#endif
84   !
85   USE lib_mpp        ! distributed memory computing
86   USE mppini         ! shared/distributed memory setting (mpp_init routine)
87   USE lbcnfd  , ONLY : isendto, nsndto, nfsloop, nfeloop   ! Setup of north fold exchanges
88   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
89#if defined key_iomput
90   USE xios           ! xIOserver
91#endif
92#if defined key_agrif
93   USE agrif_all_update   ! Master Agrif update
94#endif
95
96   IMPLICIT NONE
97   PRIVATE
98
99   PUBLIC   nemo_gcm    ! called by model.F90
100   PUBLIC   nemo_init   ! needed by AGRIF
101   PUBLIC   nemo_alloc  ! needed by TAM
102
103   CHARACTER(lc) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
104
105#if defined key_mpp_mpi
106   ! need MPI_Wtime
107   INCLUDE 'mpif.h'
108#endif
109
110   !!----------------------------------------------------------------------
111   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
112   !! $Id$
113   !! Software governed by the CeCILL license (see ./LICENSE)
114   !!----------------------------------------------------------------------
115CONTAINS
116
117   SUBROUTINE nemo_gcm
118      !!----------------------------------------------------------------------
119      !!                     ***  ROUTINE nemo_gcm  ***
120      !!
121      !! ** Purpose :   NEMO solves the primitive equations on an orthogonal
122      !!              curvilinear mesh on the sphere.
123      !!
124      !! ** Method  : - model general initialization
125      !!              - launch the time-stepping (stp routine)
126      !!              - finalize the run by closing files and communications
127      !!
128      !! References : Madec, Delecluse, Imbard, and Levy, 1997:  internal report, IPSL.
129      !!              Madec, 2008, internal report, IPSL.
130      !!----------------------------------------------------------------------
131      INTEGER ::   istp   ! time step index
132      REAL(wp)::   zstptiming   ! elapsed time for 1 time step
133      !!----------------------------------------------------------------------
134      !
135#if defined key_agrif
136      CALL Agrif_Init_Grids()      ! AGRIF: set the meshes
137#endif
138      !                            !-----------------------!
139      CALL nemo_init               !==  Initialisations  ==!
140      !                            !-----------------------!
141     
142#if defined key_agrif
143      Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs   ! agrif_oce module copies of time level indices
144      CALL Agrif_Declare_Var_dom   ! AGRIF: set the meshes for DOM
145      CALL Agrif_Declare_Var       !  "      "   "   "      "  DYN/TRA
146# if defined key_top
147      CALL Agrif_Declare_Var_top   !  "      "   "   "      "  TOP
148# endif
149# if defined key_si3
150      CALL Agrif_Declare_Var_ice   !  "      "   "   "      "  Sea ice
151# endif
152#endif
153      ! check that all process are still there... If some process have an error,
154      ! they will never enter in step and other processes will wait until the end of the cpu time!
155      CALL mpp_max( 'nemogcm', nstop )
156
157      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
158
159      !                            !-----------------------!
160      !                            !==   time stepping   ==!
161      !                            !-----------------------!
162      !
163      !                                               !== set the model time-step  ==!
164      !
165      istp = nit000
166      !
167      !                                               !==  Standard time-stepping  ==!
168      !
169      DO WHILE( istp <= nitend .AND. nstop == 0 )
170
171         ncom_stp = istp
172         IF( ln_timing ) THEN
173            zstptiming = MPI_Wtime()
174            IF ( istp == ( nit000 + 1 ) ) elapsed_time = zstptiming
175            IF ( istp ==         nitend ) elapsed_time = zstptiming - elapsed_time
176         ENDIF
177         
178         CALL stp        ( istp ) 
179         istp = istp + 1
180
181         IF( lwp .AND. ln_timing )   WRITE(numtime,*) 'timing step ', istp-1, ' : ', MPI_Wtime() - zstptiming
182
183      END DO
184      !
185      !
186      !                            !------------------------!
187      !                            !==  finalize the run  ==!
188      !                            !------------------------!
189      IF(lwp) WRITE(numout,cform_aaa)        ! Flag AAAAAAA
190      !
191      IF( nstop /= 0 .AND. lwp ) THEN        ! error print
192         WRITE(ctmp1,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
193         CALL ctl_stop( ctmp1 )
194      ENDIF
195      !
196      IF( ln_timing )   CALL timing_finalize
197      !
198      CALL nemo_closefile
199      !
200#if defined key_iomput
201                       CALL xios_finalize  ! end mpp communications with xios
202#else
203      IF( lk_mpp   )   CALL mppstop      ! end mpp communications
204#endif
205      !
206      IF(lwm) THEN
207         IF( nstop == 0 ) THEN   ;   STOP 0
208         ELSE                    ;   STOP 123
209         ENDIF
210      ENDIF
211      !
212   END SUBROUTINE nemo_gcm
213
214
215   SUBROUTINE nemo_init
216      !!----------------------------------------------------------------------
217      !!                     ***  ROUTINE nemo_init  ***
218      !!
219      !! ** Purpose :   initialization of the NEMO GCM
220      !!----------------------------------------------------------------------
221      INTEGER ::   ios, ilocal_comm   ! local integers
222      !!
223      NAMELIST/namctl/ sn_cfctl,  nn_print, nn_ictls, nn_ictle,             &
224         &             nn_isplt , nn_jsplt, nn_jctls, nn_jctle,             &
225         &             ln_timing, ln_diacfl
226      NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_closea, ln_write_cfg, cn_domcfg_out, ln_use_jattr
227      !!----------------------------------------------------------------------
228      !
229      cxios_context = 'nemo'
230      !
231      !                             !-------------------------------------------------!
232      !                             !     set communicator & select the local rank    !
233      !                             !  must be done as soon as possible to get narea  !
234      !                             !-------------------------------------------------!
235      !
236#if defined key_iomput
237      IF( Agrif_Root() ) THEN
238         IF( lk_oasis ) THEN
239            CALL cpl_init( "oceanx", ilocal_comm )                               ! nemo local communicator given by oasis
240            CALL xios_initialize( "not used"       , local_comm =ilocal_comm )   ! send nemo communicator to xios
241         ELSE
242            CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
243         ENDIF
244      ENDIF
245      CALL mpp_start( ilocal_comm )
246#else
247      IF( lk_oasis ) THEN
248         IF( Agrif_Root() ) THEN
249            CALL cpl_init( "oceanx", ilocal_comm )          ! nemo local communicator given by oasis
250         ENDIF
251         CALL mpp_start( ilocal_comm )
252      ELSE
253         CALL mpp_start( )
254      ENDIF
255#endif
256      !
257      narea = mpprank + 1               ! mpprank: the rank of proc (0 --> mppsize -1 )
258      lwm = (narea == 1)                ! control of output namelists
259      !
260      !                             !---------------------------------------------------------------!
261      !                             ! Open output files, reference and configuration namelist files !
262      !                             !---------------------------------------------------------------!
263      !
264      ! open ocean.output as soon as possible to get all output prints (including errors messages)
265      IF( lwm )   CALL ctl_opn(     numout,        'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
266      ! open reference and configuration namelist files
267                  CALL load_nml( numnam_ref,        'namelist_ref',                                           -1, lwm )
268                  CALL load_nml( numnam_cfg,        'namelist_cfg',                                           -1, lwm )
269      IF( lwm )   CALL ctl_opn(     numond, 'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
270      ! open /dev/null file to be able to supress output write easily
271                  CALL ctl_opn(     numnul,           '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
272      !
273      !                             !--------------------!
274      !                             ! Open listing units !  -> need sn_cfctl from namctl to define lwp
275      !                             !--------------------!
276      !
277      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
278901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist' )
279      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
280902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist' )
281      !
282      ! finalize the definition of namctl variables
283      IF( sn_cfctl%l_allon ) THEN
284         ! Turn on all options.
285         CALL nemo_set_cfctl( sn_cfctl, .TRUE., .TRUE. )
286         ! Ensure all processors are active
287         sn_cfctl%procmin = 0 ; sn_cfctl%procmax = 1000000 ; sn_cfctl%procincr = 1
288      ELSEIF( sn_cfctl%l_config ) THEN
289         ! Activate finer control of report outputs
290         ! optionally switch off output from selected areas (note this only
291         ! applies to output which does not involve global communications)
292         IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax  ) .OR. &
293           & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) )    &
294           &   CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. )
295      ELSE
296         ! turn off all options.
297         CALL nemo_set_cfctl( sn_cfctl, .FALSE., .TRUE. )
298      ENDIF
299      !
300      lwp = (narea == 1) .OR. sn_cfctl%l_oceout    ! control of all listing output print
301      !
302      IF(lwp) THEN                      ! open listing units
303         !
304         IF( .NOT. lwm )   &            ! alreay opened for narea == 1
305            &            CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE., narea )
306         !
307         WRITE(numout,*)
308         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC'
309         WRITE(numout,*) '                       NEMO team'
310         WRITE(numout,*) '            Ocean General Circulation Model'
311         WRITE(numout,*) '                NEMO version 4.0  (2019) '
312         WRITE(numout,*)
313         WRITE(numout,*) "           ._      ._      ._      ._      ._    "
314         WRITE(numout,*) "       _.-._)`\_.-._)`\_.-._)`\_.-._)`\_.-._)`\_ "
315         WRITE(numout,*)
316         WRITE(numout,*) "           o         _,           _,             "
317         WRITE(numout,*) "            o      .' (        .-' /             "
318         WRITE(numout,*) "           o     _/..._'.    .'   /              "
319         WRITE(numout,*) "      (    o .-'`      ` '-./  _.'               "
320         WRITE(numout,*) "       )    ( o)           ;= <_         (       "
321         WRITE(numout,*) "      (      '-.,\\__ __.-;`\   '.        )      "
322         WRITE(numout,*) "       )  )       \) |`\ \)  '.   \      (   (   "
323         WRITE(numout,*) "      (  (           \_/       '-._\      )   )  "
324         WRITE(numout,*) "       )  ) jgs                     `    (   (   "
325         WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
326         WRITE(numout,*)
327         !
328         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
329         !
330      ENDIF
331      !
332      IF(lwm) WRITE( numond, namctl )
333      !
334      !                             !------------------------------------!
335      !                             !  Set global domain size parameters !
336      !                             !------------------------------------!
337      !
338      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
339903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist' )
340      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
341904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist' )   
342      !
343      IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
344         CALL domain_cfg ( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
345      ELSE                              ! user-defined namelist
346         CALL usr_def_nam( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
347      ENDIF
348      !
349      IF(lwm)   WRITE( numond, namcfg )
350      !
351      !                             !-----------------------------------------!
352      !                             ! mpp parameters and domain decomposition !
353      !                             !-----------------------------------------!
354      CALL mpp_init
355
356      ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
357      CALL nemo_alloc()
358
359      ! Initialise time level indices
360      Nbb = 1; Nnn = 2; Naa = 3; Nrhs = Naa
361
362      !                             !-------------------------------!
363      !                             !  NEMO general initialization  !
364      !                             !-------------------------------!
365
366      CALL nemo_ctl                          ! Control prints
367      !
368      !                                      ! General initialization
369      IF( ln_timing    )   CALL timing_init     ! timing
370      IF( ln_timing    )   CALL timing_start( 'nemo_init')
371      !
372                           CALL     phy_cst         ! Physical constants
373                           
374                           CALL     dom_init( Nbb, Nnn, Naa, "OPA") ! Domain
375
376      IF( sn_cfctl%l_prtctl )   &
377         &                 CALL prt_ctl_init        ! Print control
378
379                           CALL  istate_init( Nbb, Nnn, Naa )    ! ocean initial state (Dynamics and tracers)
380
381      !                                      ! external forcing
382                           CALL    tide_init                     ! tidal harmonics
383
384                           CALL     sbc_init( Nbb, Nnn, Naa )    ! surface boundary conditions (including sea-ice)
385                           
386
387      !                                      ! Ocean physics                                   
388      !                                         ! Lateral physics
389                           CALL ldf_dyn_init      ! Lateral ocean momentum physics
390                           
391                           
392      !                                      ! Dynamics
393                           CALL dyn_adv_init         ! advection (vector or flux form)
394
395                           CALL dyn_vor_init         ! vorticity term including Coriolis
396
397                           CALL dyn_ldf_init         ! lateral mixing
398
399                           CALL dyn_spg_init         ! surface pressure gradient
400
401      !                                      ! Diagnostics
402                           CALL     flo_init( Nnn )    ! drifting Floats
403                           
404      IF( ln_diacfl    )   CALL dia_cfl_init    ! Initialise CFL diagnostics
405
406                           CALL     trd_init( Nnn )    ! Mixed-layer/Vorticity/Integral constraints trends
407
408
409      IF(lwp) WRITE(numout,cform_aaa)           ! Flag AAAAAAA
410      !
411      IF( ln_timing    )   CALL timing_stop( 'nemo_init')
412      !
413
414   END SUBROUTINE nemo_init
415
416
417   SUBROUTINE nemo_ctl
418      !!----------------------------------------------------------------------
419      !!                     ***  ROUTINE nemo_ctl  ***
420      !!
421      !! ** Purpose :   control print setting
422      !!
423      !! ** Method  : - print namctl and namcfg information and check some consistencies
424      !!----------------------------------------------------------------------
425      !
426      IF(lwp) THEN                  ! control print
427         WRITE(numout,*)
428         WRITE(numout,*) 'nemo_ctl: Control prints'
429         WRITE(numout,*) '~~~~~~~~'
430         WRITE(numout,*) '   Namelist namctl'
431         WRITE(numout,*) '                              sn_cfctl%l_glochk  = ', sn_cfctl%l_glochk
432         WRITE(numout,*) '                              sn_cfctl%l_allon   = ', sn_cfctl%l_allon
433         WRITE(numout,*) '       finer control over o/p sn_cfctl%l_config  = ', sn_cfctl%l_config
434         WRITE(numout,*) '                              sn_cfctl%l_runstat = ', sn_cfctl%l_runstat
435         WRITE(numout,*) '                              sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat
436         WRITE(numout,*) '                              sn_cfctl%l_oceout  = ', sn_cfctl%l_oceout
437         WRITE(numout,*) '                              sn_cfctl%l_layout  = ', sn_cfctl%l_layout
438         WRITE(numout,*) '                              sn_cfctl%l_prtctl  = ', sn_cfctl%l_prtctl
439         WRITE(numout,*) '                              sn_cfctl%l_prttrc  = ', sn_cfctl%l_prttrc
440         WRITE(numout,*) '                              sn_cfctl%l_oasout  = ', sn_cfctl%l_oasout
441         WRITE(numout,*) '                              sn_cfctl%procmin   = ', sn_cfctl%procmin 
442         WRITE(numout,*) '                              sn_cfctl%procmax   = ', sn_cfctl%procmax 
443         WRITE(numout,*) '                              sn_cfctl%procincr  = ', sn_cfctl%procincr 
444         WRITE(numout,*) '                              sn_cfctl%ptimincr  = ', sn_cfctl%ptimincr 
445         WRITE(numout,*) '      level of print                  nn_print   = ', nn_print
446         WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
447         WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
448         WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
449         WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
450         WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
451         WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
452         WRITE(numout,*) '      timing by routine               ln_timing  = ', ln_timing
453         WRITE(numout,*) '      CFL diagnostics                 ln_diacfl  = ', ln_diacfl
454      ENDIF
455      !
456      nprint    = nn_print          ! convert DOCTOR namelist names into OLD names
457      nictls    = nn_ictls
458      nictle    = nn_ictle
459      njctls    = nn_jctls
460      njctle    = nn_jctle
461      isplt     = nn_isplt
462      jsplt     = nn_jsplt
463
464      IF(lwp) THEN                  ! control print
465         WRITE(numout,*)
466         WRITE(numout,*) '   Namelist namcfg'
467         WRITE(numout,*) '      read domain configuration file                ln_read_cfg      = ', ln_read_cfg
468         WRITE(numout,*) '         filename to be read                           cn_domcfg     = ', TRIM(cn_domcfg)
469         WRITE(numout,*) '         keep closed seas in the domain (if exist)     ln_closea     = ', ln_closea
470         WRITE(numout,*) '      create a configuration definition file        ln_write_cfg     = ', ln_write_cfg
471         WRITE(numout,*) '         filename to be written                        cn_domcfg_out = ', TRIM(cn_domcfg_out)
472         WRITE(numout,*) '      use file attribute if exists as i/p j-start   ln_use_jattr     = ', ln_use_jattr
473      ENDIF
474      IF( .NOT.ln_read_cfg )   ln_closea = .false.   ! dealing possible only with a domcfg file
475      !
476      !                             ! Parameter control
477      !
478      IF( sn_cfctl%l_prtctl .OR. sn_cfctl%l_prttrc ) THEN              ! sub-domain area indices for the control prints
479         IF( lk_mpp .AND. jpnij > 1 ) THEN
480            isplt = jpni   ;   jsplt = jpnj   ;   ijsplt = jpni*jpnj   ! the domain is forced to the real split domain
481         ELSE
482            IF( isplt == 1 .AND. jsplt == 1  ) THEN
483               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
484                  &           ' - the print control will be done over the whole domain' )
485            ENDIF
486            ijsplt = isplt * jsplt            ! total number of processors ijsplt
487         ENDIF
488         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
489         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
490         !
491         !                              ! indices used for the SUM control
492         IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
493            lsp_area = .FALSE.
494         ELSE                                             ! print control done over a specific  area
495            lsp_area = .TRUE.
496            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
497               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
498               nictls = 1
499            ENDIF
500            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
501               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
502               nictle = jpiglo
503            ENDIF
504            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
505               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
506               njctls = 1
507            ENDIF
508            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
509               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
510               njctle = jpjglo
511            ENDIF
512         ENDIF
513      ENDIF
514      !
515      IF( 1._wp /= SIGN(1._wp,-0._wp)  )   CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows f2003 standard.',  &
516         &                                                'Compile with key_nosignedzero enabled:',   &
517         &                                                '--> add -Dkey_nosignedzero to the definition of %CPP in your arch file' )
518      !
519#if defined key_agrif
520      IF( ln_timing )   CALL ctl_stop( 'AGRIF not implemented with ln_timing = true')
521#endif
522      !
523   END SUBROUTINE nemo_ctl
524
525
526   SUBROUTINE nemo_closefile
527      !!----------------------------------------------------------------------
528      !!                     ***  ROUTINE nemo_closefile  ***
529      !!
530      !! ** Purpose :   Close the files
531      !!----------------------------------------------------------------------
532      !
533      IF( lk_mpp )   CALL mppsync
534      !
535      CALL iom_close                                 ! close all input/output files managed by iom_*
536      !
537      IF( numstp          /= -1 )   CLOSE( numstp          )   ! time-step file
538      IF( numrun          /= -1 )   CLOSE( numrun          )   ! run statistics file
539      IF( lwm.AND.numond  /= -1 )   CLOSE( numond          )   ! oce output namelist
540      IF( lwm.AND.numoni  /= -1 )   CLOSE( numoni          )   ! ice output namelist
541      IF( numevo_ice      /= -1 )   CLOSE( numevo_ice      )   ! ice variables (temp. evolution)
542      IF( numout          /=  6 )   CLOSE( numout          )   ! standard model output file
543      IF( numdct_vol      /= -1 )   CLOSE( numdct_vol      )   ! volume transports
544      IF( numdct_heat     /= -1 )   CLOSE( numdct_heat     )   ! heat transports
545      IF( numdct_salt     /= -1 )   CLOSE( numdct_salt     )   ! salt transports
546      !
547      numout = 6                                     ! redefine numout in case it is used after this point...
548      !
549   END SUBROUTINE nemo_closefile
550
551
552   SUBROUTINE nemo_alloc
553      !!----------------------------------------------------------------------
554      !!                     ***  ROUTINE nemo_alloc  ***
555      !!
556      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
557      !!
558      !! ** Method  :
559      !!----------------------------------------------------------------------
560      USE diawri    , ONLY : dia_wri_alloc
561      USE dom_oce   , ONLY : dom_oce_alloc
562      USE trc_oce   , ONLY : trc_oce_alloc
563      USE bdy_oce   , ONLY : bdy_oce_alloc
564      !
565      INTEGER :: ierr
566      !!----------------------------------------------------------------------
567      !
568      ierr =        oce_alloc    ()    ! ocean
569      ierr = ierr + dia_wri_alloc()
570      ierr = ierr + dom_oce_alloc()    ! ocean domain
571      ierr = ierr + zdf_oce_alloc()    ! ocean vertical physics
572      ierr = ierr + trc_oce_alloc()    ! shared TRC / TRA arrays
573      ierr = ierr + bdy_oce_alloc()    ! bdy masks (incl. initialization)
574      !
575      CALL mpp_sum( 'nemogcm', ierr )
576      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' )
577      !
578   END SUBROUTINE nemo_alloc
579
580   
581   SUBROUTINE nemo_set_cfctl(sn_cfctl, setto, for_all )
582      !!----------------------------------------------------------------------
583      !!                     ***  ROUTINE nemo_set_cfctl  ***
584      !!
585      !! ** Purpose :   Set elements of the output control structure to setto.
586      !!                for_all should be .false. unless all areas are to be
587      !!                treated identically.
588      !!
589      !! ** Method  :   Note this routine can be used to switch on/off some
590      !!                types of output for selected areas but any output types
591      !!                that involve global communications (e.g. mpp_max, glob_sum)
592      !!                should be protected from selective switching by the
593      !!                for_all argument
594      !!----------------------------------------------------------------------
595      LOGICAL :: setto, for_all
596      TYPE(sn_ctl) :: sn_cfctl
597      !!----------------------------------------------------------------------
598      IF( for_all ) THEN
599         sn_cfctl%l_runstat = setto
600         sn_cfctl%l_trcstat = setto
601      ENDIF
602      sn_cfctl%l_oceout  = setto
603      sn_cfctl%l_layout  = setto
604      sn_cfctl%l_prtctl  = setto
605      sn_cfctl%l_prttrc  = setto
606      sn_cfctl%l_oasout  = setto
607   END SUBROUTINE nemo_set_cfctl
608
609   !!======================================================================
610END MODULE nemogcm
611
Note: See TracBrowser for help on using the repository browser.