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/UKMO/NEMO_4.0_GO8_coupled_iodef/src/OCE – NEMO

source: NEMO/branches/UKMO/NEMO_4.0_GO8_coupled_iodef/src/OCE/nemogcm.F90 @ 11355

Last change on this file since 11355 was 11355, checked in by dancopsey, 6 years ago

Add lots of print statements printing out values of files throughout the ocean_ice timestep.. New output will be in files crash_stats_419.out and crash_stats_68.out.

File size: 36.2 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 tideini        ! tidal components initialization   (tide_ini 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 step           ! NEMO time-stepping                 (stp     routine)
62   USE icbini         ! handle bergs, initialisation
63   USE icbstp         ! handle bergs, calving, themodynamics and transport
64   USE cpl_oasis3     ! OASIS3 coupling
65   USE c1d            ! 1D configuration
66   USE step_c1d       ! Time stepping loop for the 1D configuration
67   USE dyndmp         ! Momentum damping
68   USE stopar         ! Stochastic param.: ???
69   USE stopts         ! Stochastic param.: ???
70   USE diurnal_bulk   ! diurnal bulk SST
71   USE step_diu       ! diurnal bulk SST timestepping (called from here if run offline)
72   USE crsini         ! initialise grid coarsening utility
73   USE diatmb         ! Top,middle,bottom output
74   USE dia25h         ! 25h mean output
75   USE sbc_oce , ONLY : lk_oasis
76   USE wet_dry        ! Wetting and drying setting   (wad_init routine)
77#if defined key_top
78   USE trcini         ! passive tracer initialisation
79#endif
80#if defined key_nemocice_decomp
81   USE ice_domain_size, only: nx_global, ny_global
82#endif
83   !
84   USE lib_mpp        ! distributed memory computing
85   USE mppini         ! shared/distributed memory setting (mpp_init routine)
86   USE lbcnfd  , ONLY : isendto, nsndto, nfsloop, nfeloop   ! Setup of north fold exchanges
87   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
88#if defined key_iomput
89   USE xios           ! xIOserver
90#endif
91#if defined key_agrif
92   USE agrif_all_update   ! Master Agrif update
93#endif
94
95   IMPLICIT NONE
96   PRIVATE
97
98   PUBLIC   nemo_gcm    ! called by model.F90
99   PUBLIC   nemo_init   ! needed by AGRIF
100   PUBLIC   nemo_alloc  ! needed by TAM
101
102   CHARACTER(lc) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
103
104#if defined key_mpp_mpi
105   INCLUDE 'mpif.h'
106#endif
107
108   !!----------------------------------------------------------------------
109   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
110   !! $Id$
111   !! Software governed by the CeCILL license (see ./LICENSE)
112   !!----------------------------------------------------------------------
113CONTAINS
114
115   SUBROUTINE nemo_gcm
116      !!----------------------------------------------------------------------
117      !!                     ***  ROUTINE nemo_gcm  ***
118      !!
119      !! ** Purpose :   NEMO solves the primitive equations on an orthogonal
120      !!              curvilinear mesh on the sphere.
121      !!
122      !! ** Method  : - model general initialization
123      !!              - launch the time-stepping (stp routine)
124      !!              - finalize the run by closing files and communications
125      !!
126      !! References : Madec, Delecluse, Imbard, and Levy, 1997:  internal report, IPSL.
127      !!              Madec, 2008, internal report, IPSL.
128      !!----------------------------------------------------------------------
129      INTEGER ::   istp   ! time step index
130      !!----------------------------------------------------------------------
131      !
132#if defined key_agrif
133      CALL Agrif_Init_Grids()      ! AGRIF: set the meshes
134#endif
135      !                            !-----------------------!
136      CALL nemo_init               !==  Initialisations  ==!
137      !                            !-----------------------!
138#if defined key_agrif
139      CALL Agrif_Declare_Var_dom   ! AGRIF: set the meshes for DOM
140      CALL Agrif_Declare_Var       !  "      "   "   "      "  DYN/TRA
141# if defined key_top
142      CALL Agrif_Declare_Var_top   !  "      "   "   "      "  TOP
143# endif
144# if defined key_si3
145      CALL Agrif_Declare_Var_ice   !  "      "   "   "      "  Sea ice
146# endif
147#endif
148      ! check that all process are still there... If some process have an error,
149      ! they will never enter in step and other processes will wait until the end of the cpu time!
150      CALL mpp_max( 'nemogcm', nstop )
151
152      IF(narea == 419) THEN
153         OPEN(9419, file='crash_stats_419.out', status='replace')
154         WRITE(9419,*) 'Opening output file'
155      ENDIF
156
157      IF(narea == 68) THEN
158         OPEN(968, file='crash_stats_68.out', status='replace')
159         WRITE(968,*) 'Opening output file'
160      ENDIF
161
162      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
163
164      !                            !-----------------------!
165      !                            !==   time stepping   ==!
166      !                            !-----------------------!
167      istp = nit000
168
169      IF(narea == 419) THEN
170         WRITE(9419,*) 'max sshn nemogcm before any steps = ',MAXVAL(  ABS( sshn(:,:) )  )
171         WRITE(9419,*) 'max ssha = ',MAXVAL(  ABS( ssha(:,:) )  )
172         WRITE(9419,*) 'max emp_b = ',MAXVAL(  ABS( emp_b(:,:) )  )
173         WRITE(9419,*) 'max emp = ',MAXVAL(  ABS( emp(:,:) )  )
174      ENDIF
175
176      ! Initialise emp to zero
177      emp(:,:) = 0.0
178
179      !
180#if defined key_c1d
181      DO WHILE ( istp <= nitend .AND. nstop == 0 )    !==  C1D time-stepping  ==!
182         CALL stp_c1d( istp )
183         istp = istp + 1
184      END DO
185#else
186      !
187# if defined key_agrif
188      !                                               !==  AGRIF time-stepping  ==!
189      CALL Agrif_Regrid()
190      !
191      ! Recursive update from highest nested level to lowest:
192      CALL Agrif_step_child_adj(Agrif_Update_All)
193      !
194      DO WHILE( istp <= nitend .AND. nstop == 0 )
195         CALL stp
196         istp = istp + 1
197      END DO
198      !
199      IF( .NOT. Agrif_Root() ) THEN
200         CALL Agrif_ParentGrid_To_ChildGrid()
201         IF( ln_diaobs )   CALL dia_obs_wri
202         IF( ln_timing )   CALL timing_finalize
203         CALL Agrif_ChildGrid_To_ParentGrid()
204      ENDIF
205      !
206# else
207      !
208      IF( .NOT.ln_diurnal_only ) THEN                 !==  Standard time-stepping  ==!
209         !
210         DO WHILE( istp <= nitend .AND. nstop == 0 )
211#if defined key_mpp_mpi
212            ncom_stp = istp
213            IF ( istp == ( nit000 + 1 ) ) elapsed_time = MPI_Wtime()
214            IF ( istp ==         nitend ) elapsed_time = MPI_Wtime() - elapsed_time
215#endif
216            CALL stp        ( istp ) 
217            istp = istp + 1
218         END DO
219         !
220      ELSE                                            !==  diurnal SST time-steeping only  ==!
221         !
222         DO WHILE( istp <= nitend .AND. nstop == 0 )
223            CALL stp_diurnal( istp )   ! time step only the diurnal SST
224            istp = istp + 1
225         END DO
226         !
227      ENDIF
228      !
229# endif
230      !
231#endif
232      !
233      IF( ln_diaobs   )   CALL dia_obs_wri
234      !
235      IF( ln_icebergs )   CALL icb_end( nitend )
236
237      !                            !------------------------!
238      !                            !==  finalize the run  ==!
239      !                            !------------------------!
240      IF(lwp) WRITE(numout,cform_aaa)        ! Flag AAAAAAA
241      CLOSE(unit=9419)
242      CLOSE(unit=968)
243      !
244      IF( nstop /= 0 .AND. lwp ) THEN        ! error print
245         WRITE(numout,cform_err)
246         WRITE(numout,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
247         WRITE(numout,*)
248      ENDIF
249      !
250      IF( ln_timing )   CALL timing_finalize
251      !
252      CALL nemo_closefile
253      !
254#if defined key_iomput
255                                    CALL xios_finalize  ! end mpp communications with xios
256      IF( lk_oasis     )            CALL cpl_finalize   ! end coupling and mpp communications with OASIS
257#else
258      IF    ( lk_oasis ) THEN   ;   CALL cpl_finalize   ! end coupling and mpp communications with OASIS
259      ELSEIF( lk_mpp   ) THEN   ;   CALL mppstop( ldfinal = .TRUE. )   ! end mpp communications
260      ENDIF
261#endif
262      !
263      IF(lwm) THEN
264         IF( nstop == 0 ) THEN   ;   STOP 0
265         ELSE                    ;   STOP 999
266         ENDIF
267      ENDIF
268      !
269   END SUBROUTINE nemo_gcm
270
271
272   SUBROUTINE nemo_init
273      !!----------------------------------------------------------------------
274      !!                     ***  ROUTINE nemo_init  ***
275      !!
276      !! ** Purpose :   initialization of the NEMO GCM
277      !!----------------------------------------------------------------------
278      INTEGER  ::   ji                 ! dummy loop indices
279      INTEGER  ::   ios, ilocal_comm   ! local integers
280      CHARACTER(len=120), DIMENSION(60) ::   cltxt, cltxt2, clnam
281      !!
282      NAMELIST/namctl/ ln_ctl   , sn_cfctl, nn_print, nn_ictls, nn_ictle,   &
283         &             nn_isplt , nn_jsplt, nn_jctls, nn_jctle,             &
284         &             ln_timing, ln_diacfl
285      NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_closea, ln_write_cfg, cn_domcfg_out, ln_use_jattr
286      !!----------------------------------------------------------------------
287      !
288      cltxt  = ''
289      cltxt2 = ''
290      clnam  = '' 
291      cxios_context = 'nemo'
292      !
293      !                             ! Open reference namelist and configuration namelist files
294      CALL ctl_opn( numnam_ref, 'namelist_ref', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
295      CALL ctl_opn( numnam_cfg, 'namelist_cfg', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
296      !
297      REWIND( numnam_ref )              ! Namelist namctl in reference namelist
298      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
299901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist', .TRUE. )
300      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
301      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
302902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist', .TRUE. )
303      !
304      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
305      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
306903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist', .TRUE. )
307      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
308      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
309904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist', .TRUE. )   
310
311      !                             !--------------------------!
312      !                             !  Set global domain size  !   (control print return in cltxt2)
313      !                             !--------------------------!
314      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
315         CALL domain_cfg ( cltxt2,        cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
316         !
317      ELSE                                ! user-defined namelist
318         CALL usr_def_nam( cltxt2, clnam, cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
319      ENDIF
320      !
321      !
322      !                             !--------------------------------------------!
323      !                             !  set communicator & select the local node  !
324      !                             !  NB: mynode also opens output.namelist.dyn !
325      !                             !      on unit number numond on first proc   !
326      !                             !--------------------------------------------!
327#if defined key_iomput
328      IF( Agrif_Root() ) THEN
329         IF( lk_oasis ) THEN
330            CALL cpl_init( "oceanx", ilocal_comm )                               ! nemo local communicator given by oasis
331            CALL xios_initialize( "not used"       ,local_comm= ilocal_comm )    ! send nemo communicator to xios
332         ELSE
333            CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm )    ! nemo local communicator given by xios
334         ENDIF
335      ENDIF
336      ! Nodes selection (control print return in cltxt)
337      narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm )
338#else
339      IF( lk_oasis ) THEN
340         IF( Agrif_Root() ) THEN
341            CALL cpl_init( "oceanx", ilocal_comm )          ! nemo local communicator given by oasis
342         ENDIF
343         ! Nodes selection (control print return in cltxt)
344         narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop, ilocal_comm )
345      ELSE
346         ilocal_comm = 0                                    ! Nodes selection (control print return in cltxt)
347         narea = mynode( cltxt, 'output.namelist.dyn', numnam_ref, numnam_cfg, numond , nstop )
348      ENDIF
349#endif
350
351      narea = narea + 1                                     ! mynode return the rank of proc (0 --> jpnij -1 )
352
353      IF( sn_cfctl%l_config ) THEN
354         ! Activate finer control of report outputs
355         ! optionally switch off output from selected areas (note this only
356         ! applies to output which does not involve global communications)
357         IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax  ) .OR. &
358           & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) )    &
359           &   CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. )
360      ELSE
361         ! Use ln_ctl to turn on or off all options.
362         CALL nemo_set_cfctl( sn_cfctl, ln_ctl, .TRUE. )
363      ENDIF
364
365      lwm = (narea == 1)                                    ! control of output namelists
366      lwp = (narea == 1) .OR. ln_ctl                        ! control of all listing output print
367
368      IF(lwm) THEN               ! write merged namelists from earlier to output namelist
369         !                       ! now that the file has been opened in call to mynode.
370         !                       ! NB: nammpp has already been written in mynode (if lk_mpp_mpi)
371         WRITE( numond, namctl )
372         WRITE( numond, namcfg )
373         IF( .NOT.ln_read_cfg ) THEN
374            DO ji = 1, SIZE(clnam)
375               IF( TRIM(clnam(ji)) /= '' )   WRITE(numond, * ) clnam(ji)     ! namusr_def print
376            END DO
377         ENDIF
378      ENDIF
379
380      IF(lwp) THEN                            ! open listing units
381         !
382         CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
383         !
384         WRITE(numout,*)
385         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - INGV - CMCC'
386         WRITE(numout,*) '                       NEMO team'
387         WRITE(numout,*) '            Ocean General Circulation Model'
388         WRITE(numout,*) '                NEMO version 4.0  (2019) '
389         WRITE(numout,*)
390         WRITE(numout,*) "           ._      ._      ._      ._      ._    "
391         WRITE(numout,*) "       _.-._)`\_.-._)`\_.-._)`\_.-._)`\_.-._)`\_ "
392         WRITE(numout,*)
393         WRITE(numout,*) "           o         _,           _,             "
394         WRITE(numout,*) "            o      .' (        .-' /             "
395         WRITE(numout,*) "           o     _/..._'.    .'   /              "
396         WRITE(numout,*) "      (    o .-'`      ` '-./  _.'               "
397         WRITE(numout,*) "       )    ( o)           ;= <_         (       "
398         WRITE(numout,*) "      (      '-.,\\__ __.-;`\   '.        )      "
399         WRITE(numout,*) "       )  )       \) |`\ \)  '.   \      (   (   "
400         WRITE(numout,*) "      (  (           \_/       '-._\      )   )  "
401         WRITE(numout,*) "       )  ) jgs                     `    (   (   "
402         WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
403         WRITE(numout,*)
404         
405         DO ji = 1, SIZE(cltxt)
406            IF( TRIM(cltxt (ji)) /= '' )   WRITE(numout,*) TRIM(cltxt(ji))    ! control print of mynode
407         END DO
408         WRITE(numout,*)
409         WRITE(numout,*)
410         DO ji = 1, SIZE(cltxt2)
411            IF( TRIM(cltxt2(ji)) /= '' )   WRITE(numout,*) TRIM(cltxt2(ji))   ! control print of domain size
412         END DO
413         !
414         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
415         !
416      ENDIF
417      ! open /dev/null file to be able to supress output write easily
418      CALL ctl_opn( numnul, '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
419      !
420      !                                      ! Domain decomposition
421      CALL mpp_init                          ! MPP
422
423      ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
424      CALL nemo_alloc()
425
426      !                             !-------------------------------!
427      !                             !  NEMO general initialization  !
428      !                             !-------------------------------!
429
430      CALL nemo_ctl                          ! Control prints
431      !
432      !                                      ! General initialization
433      IF( ln_timing    )   CALL timing_init     ! timing
434      IF( ln_timing    )   CALL timing_start( 'nemo_init')
435      !
436                           CALL     phy_cst         ! Physical constants
437                           CALL     eos_init        ! Equation of state
438      IF( lk_c1d       )   CALL     c1d_init        ! 1D column configuration
439                           CALL     wad_init        ! Wetting and drying options
440                           CALL     dom_init("OPA") ! Domain
441      IF( ln_crs       )   CALL     crs_init        ! coarsened grid: domain initialization
442      IF( ln_ctl       )   CALL prt_ctl_init        ! Print control
443     
444      CALL diurnal_sst_bulk_init                ! diurnal sst
445      IF( ln_diurnal   )   CALL diurnal_sst_coolskin_init   ! cool skin   
446      !                           
447      IF( ln_diurnal_only ) THEN                   ! diurnal only: a subset of the initialisation routines
448         CALL  istate_init                            ! ocean initial state (Dynamics and tracers)
449         CALL     sbc_init                            ! Forcings : surface module
450         CALL tra_qsr_init                            ! penetrative solar radiation qsr
451         IF( ln_diaobs ) THEN                         ! Observation & model comparison
452            CALL dia_obs_init                            ! Initialize observational data
453            CALL dia_obs( nit000 - 1 )                   ! Observation operator for restart
454         ENDIF     
455         IF( lk_asminc )   CALL asm_inc_init          ! Assimilation increments
456         !
457         RETURN                                       ! end of initialization
458      ENDIF
459     
460                           CALL  istate_init    ! ocean initial state (Dynamics and tracers)
461
462      !                                      ! external forcing
463                           CALL    tide_init    ! tidal harmonics
464                           CALL     sbc_init    ! surface boundary conditions (including sea-ice)
465                           CALL     bdy_init    ! Open boundaries initialisation
466
467      !                                      ! Ocean physics
468                           CALL zdf_phy_init    ! Vertical physics
469                                     
470      !                                         ! Lateral physics
471                           CALL ldf_tra_init      ! Lateral ocean tracer physics
472                           CALL ldf_eiv_init      ! eddy induced velocity param.
473                           CALL ldf_dyn_init      ! Lateral ocean momentum physics
474
475      !                                      ! Active tracers
476      IF( ln_traqsr    )   CALL tra_qsr_init      ! penetrative solar radiation qsr
477                           CALL tra_bbc_init      ! bottom heat flux
478                           CALL tra_bbl_init      ! advective (and/or diffusive) bottom boundary layer scheme
479                           CALL tra_dmp_init      ! internal tracer damping
480                           CALL tra_adv_init      ! horizontal & vertical advection
481                           CALL tra_ldf_init      ! lateral mixing
482
483      !                                      ! Dynamics
484      IF( lk_c1d       )   CALL dyn_dmp_init      ! internal momentum damping
485                           CALL dyn_adv_init      ! advection (vector or flux form)
486                           CALL dyn_vor_init      ! vorticity term including Coriolis
487                           CALL dyn_ldf_init      ! lateral mixing
488                           CALL dyn_hpg_init      ! horizontal gradient of Hydrostatic pressure
489                           CALL dyn_spg_init      ! surface pressure gradient
490
491#if defined key_top
492      !                                      ! Passive tracers
493                           CALL     trc_init
494#endif
495      IF( l_ldfslp     )   CALL ldf_slp_init    ! slope of lateral mixing
496
497      !                                      ! Icebergs
498                           CALL icb_init( rdt, nit000)   ! initialise icebergs instance
499
500      !                                      ! Misc. options
501                           CALL sto_par_init    ! Stochastic parametrization
502      IF( ln_sto_eos   )   CALL sto_pts_init    ! RRandom T/S fluctuations
503     
504      !                                      ! Diagnostics
505      IF( lk_floats    )   CALL     flo_init    ! drifting Floats
506      IF( ln_diacfl    )   CALL dia_cfl_init    ! Initialise CFL diagnostics
507                           CALL dia_ptr_init    ! Poleward TRansports initialization
508      IF( lk_diadct    )   CALL dia_dct_init    ! Sections tranports
509                           CALL dia_hsb_init    ! heat content, salt content and volume budgets
510                           CALL     trd_init    ! Mixed-layer/Vorticity/Integral constraints trends
511                           CALL dia_obs_init    ! Initialize observational data
512                           CALL dia_tmb_init    ! TMB outputs
513                           CALL dia_25h_init    ! 25h mean  outputs
514      IF( ln_diaobs    )   CALL dia_obs( nit000-1 )   ! Observation operator for restart
515
516      !                                      ! Assimilation increments
517      IF( lk_asminc    )   CALL asm_inc_init    ! Initialize assimilation increments
518      !
519      IF(lwp) WRITE(numout,cform_aaa)           ! Flag AAAAAAA
520      !
521      IF( ln_timing    )   CALL timing_stop( 'nemo_init')
522      !
523   END SUBROUTINE nemo_init
524
525
526   SUBROUTINE nemo_ctl
527      !!----------------------------------------------------------------------
528      !!                     ***  ROUTINE nemo_ctl  ***
529      !!
530      !! ** Purpose :   control print setting
531      !!
532      !! ** Method  : - print namctl information and check some consistencies
533      !!----------------------------------------------------------------------
534      !
535      IF(lwp) THEN                  ! control print
536         WRITE(numout,*)
537         WRITE(numout,*) 'nemo_ctl: Control prints'
538         WRITE(numout,*) '~~~~~~~~'
539         WRITE(numout,*) '   Namelist namctl'
540         WRITE(numout,*) '      run control (for debugging)     ln_ctl     = ', ln_ctl
541         WRITE(numout,*) '       finer control over o/p sn_cfctl%l_config  = ', sn_cfctl%l_config
542         WRITE(numout,*) '                              sn_cfctl%l_runstat = ', sn_cfctl%l_runstat
543         WRITE(numout,*) '                              sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat
544         WRITE(numout,*) '                              sn_cfctl%l_oceout  = ', sn_cfctl%l_oceout
545         WRITE(numout,*) '                              sn_cfctl%l_layout  = ', sn_cfctl%l_layout
546         WRITE(numout,*) '                              sn_cfctl%l_mppout  = ', sn_cfctl%l_mppout
547         WRITE(numout,*) '                              sn_cfctl%l_mpptop  = ', sn_cfctl%l_mpptop
548         WRITE(numout,*) '                              sn_cfctl%procmin   = ', sn_cfctl%procmin 
549         WRITE(numout,*) '                              sn_cfctl%procmax   = ', sn_cfctl%procmax 
550         WRITE(numout,*) '                              sn_cfctl%procincr  = ', sn_cfctl%procincr 
551         WRITE(numout,*) '                              sn_cfctl%ptimincr  = ', sn_cfctl%ptimincr 
552         WRITE(numout,*) '      level of print                  nn_print   = ', nn_print
553         WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
554         WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
555         WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
556         WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
557         WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
558         WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
559         WRITE(numout,*) '      timing by routine               ln_timing  = ', ln_timing
560         WRITE(numout,*) '      CFL diagnostics                 ln_diacfl  = ', ln_diacfl
561      ENDIF
562      !
563      nprint    = nn_print          ! convert DOCTOR namelist names into OLD names
564      nictls    = nn_ictls
565      nictle    = nn_ictle
566      njctls    = nn_jctls
567      njctle    = nn_jctle
568      isplt     = nn_isplt
569      jsplt     = nn_jsplt
570
571      IF(lwp) THEN                  ! control print
572         WRITE(numout,*)
573         WRITE(numout,*) '   Namelist namcfg'
574         WRITE(numout,*) '      read domain configuration file                ln_read_cfg      = ', ln_read_cfg
575         WRITE(numout,*) '         filename to be read                           cn_domcfg     = ', TRIM(cn_domcfg)
576         WRITE(numout,*) '         keep closed seas in the domain (if exist)     ln_closea     = ', ln_closea
577         WRITE(numout,*) '      create a configuration definition file        ln_write_cfg     = ', ln_write_cfg
578         WRITE(numout,*) '         filename to be written                        cn_domcfg_out = ', TRIM(cn_domcfg_out)
579         WRITE(numout,*) '      use file attribute if exists as i/p j-start   ln_use_jattr     = ', ln_use_jattr
580      ENDIF
581      IF( .NOT.ln_read_cfg )   ln_closea = .false.   ! dealing possible only with a domcfg file
582      !
583      !                             ! Parameter control
584      !
585      IF( ln_ctl ) THEN                 ! sub-domain area indices for the control prints
586         IF( lk_mpp .AND. jpnij > 1 ) THEN
587            isplt = jpni   ;   jsplt = jpnj   ;   ijsplt = jpni*jpnj   ! the domain is forced to the real split domain
588         ELSE
589            IF( isplt == 1 .AND. jsplt == 1  ) THEN
590               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
591                  &           ' - the print control will be done over the whole domain' )
592            ENDIF
593            ijsplt = isplt * jsplt            ! total number of processors ijsplt
594         ENDIF
595         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
596         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
597         !
598         !                              ! indices used for the SUM control
599         IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
600            lsp_area = .FALSE.
601         ELSE                                             ! print control done over a specific  area
602            lsp_area = .TRUE.
603            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
604               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
605               nictls = 1
606            ENDIF
607            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
608               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
609               nictle = jpiglo
610            ENDIF
611            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
612               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
613               njctls = 1
614            ENDIF
615            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
616               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
617               njctle = jpjglo
618            ENDIF
619         ENDIF
620      ENDIF
621      !
622      IF( 1._wp /= SIGN(1._wp,-0._wp)  )   CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows f2003 standard.',  &
623         &                                                'Compile with key_nosignedzero enabled:',   &
624         &                                                '--> add -Dkey_nosignedzero to the definition of %CPP in your arch file' )
625      !
626#if defined key_agrif
627      IF( ln_timing )   CALL ctl_stop( 'AGRIF not implemented with ln_timing = true')
628#endif
629      !
630   END SUBROUTINE nemo_ctl
631
632
633   SUBROUTINE nemo_closefile
634      !!----------------------------------------------------------------------
635      !!                     ***  ROUTINE nemo_closefile  ***
636      !!
637      !! ** Purpose :   Close the files
638      !!----------------------------------------------------------------------
639      !
640      IF( lk_mpp )   CALL mppsync
641      !
642      CALL iom_close                                 ! close all input/output files managed by iom_*
643      !
644      IF( numstp          /= -1 )   CLOSE( numstp          )   ! time-step file
645      IF( numrun          /= -1 )   CLOSE( numrun          )   ! run statistics file
646      IF( numnam_ref      /= -1 )   CLOSE( numnam_ref      )   ! oce reference namelist
647      IF( numnam_cfg      /= -1 )   CLOSE( numnam_cfg      )   ! oce configuration namelist
648      IF( lwm.AND.numond  /= -1 )   CLOSE( numond          )   ! oce output namelist
649      IF( numnam_ice_ref  /= -1 )   CLOSE( numnam_ice_ref  )   ! ice reference namelist
650      IF( numnam_ice_cfg  /= -1 )   CLOSE( numnam_ice_cfg  )   ! ice configuration namelist
651      IF( lwm.AND.numoni  /= -1 )   CLOSE( numoni          )   ! ice output namelist
652      IF( numevo_ice      /= -1 )   CLOSE( numevo_ice      )   ! ice variables (temp. evolution)
653      IF( numout          /=  6 )   CLOSE( numout          )   ! standard model output file
654      IF( numdct_vol      /= -1 )   CLOSE( numdct_vol      )   ! volume transports
655      IF( numdct_heat     /= -1 )   CLOSE( numdct_heat     )   ! heat transports
656      IF( numdct_salt     /= -1 )   CLOSE( numdct_salt     )   ! salt transports
657      !
658      numout = 6                                     ! redefine numout in case it is used after this point...
659      !
660   END SUBROUTINE nemo_closefile
661
662
663   SUBROUTINE nemo_alloc
664      !!----------------------------------------------------------------------
665      !!                     ***  ROUTINE nemo_alloc  ***
666      !!
667      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
668      !!
669      !! ** Method  :
670      !!----------------------------------------------------------------------
671      USE diawri    , ONLY : dia_wri_alloc
672      USE dom_oce   , ONLY : dom_oce_alloc
673      USE trc_oce   , ONLY : trc_oce_alloc
674      USE bdy_oce   , ONLY : bdy_oce_alloc
675#if defined key_diadct 
676      USE diadct    , ONLY : diadct_alloc 
677#endif 
678      !
679      INTEGER :: ierr
680      !!----------------------------------------------------------------------
681      !
682      ierr =        oce_alloc    ()    ! ocean
683      ierr = ierr + dia_wri_alloc()
684      ierr = ierr + dom_oce_alloc()    ! ocean domain
685      ierr = ierr + zdf_oce_alloc()    ! ocean vertical physics
686      ierr = ierr + trc_oce_alloc()    ! shared TRC / TRA arrays
687      ierr = ierr + bdy_oce_alloc()    ! bdy masks (incl. initialization)
688      !
689#if defined key_diadct 
690      ierr = ierr + diadct_alloc ()    !
691#endif 
692      !
693      CALL mpp_sum( 'nemogcm', ierr )
694      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' )
695      !
696   END SUBROUTINE nemo_alloc
697
698   SUBROUTINE nemo_set_cfctl(sn_cfctl, setto, for_all )
699      !!----------------------------------------------------------------------
700      !!                     ***  ROUTINE nemo_set_cfctl  ***
701      !!
702      !! ** Purpose :   Set elements of the output control structure to setto.
703      !!                for_all should be .false. unless all areas are to be
704      !!                treated identically.
705      !!
706      !! ** Method  :   Note this routine can be used to switch on/off some
707      !!                types of output for selected areas but any output types
708      !!                that involve global communications (e.g. mpp_max, glob_sum)
709      !!                should be protected from selective switching by the
710      !!                for_all argument
711      !!----------------------------------------------------------------------
712      LOGICAL :: setto, for_all
713      TYPE(sn_ctl) :: sn_cfctl
714      !!----------------------------------------------------------------------
715      IF( for_all ) THEN
716         sn_cfctl%l_runstat = setto
717         sn_cfctl%l_trcstat = setto
718      ENDIF
719      sn_cfctl%l_oceout  = setto
720      sn_cfctl%l_layout  = setto
721      sn_cfctl%l_mppout  = setto
722      sn_cfctl%l_mpptop  = setto
723   END SUBROUTINE nemo_set_cfctl
724
725   !!======================================================================
726END MODULE nemogcm
727
Note: See TracBrowser for help on using the repository browser.