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/releases/r4.0/r4.0-HEAD/src/SAS – NEMO

source: NEMO/releases/r4.0/r4.0-HEAD/src/SAS/nemogcm.F90 @ 13849

Last change on this file since 13849 was 13849, checked in by clem, 3 years ago

4.0-HEAD: fix ticket #2577

  • Property svn:keywords set to Id
File size: 28.5 KB
Line 
1MODULE nemogcm
2   !!======================================================================
3   !!                       ***  MODULE nemogcm   ***
4   !! StandAlone Surface module : surface fluxes + sea-ice + iceberg floats
5   !!======================================================================
6   !! History :  3.6  ! 2011-11  (S. Alderson, G. Madec) original code
7   !!             -   ! 2013-06  (I. Epicoco, S. Mocavero, CMCC) nemo_northcomms: setup avoiding MPI communication
8   !!             -   ! 2014-12  (G. Madec) remove KPP scheme and cross-land advection (cla)
9   !!            4.0  ! 2016-10  (G. Madec, S. Flavoni)  domain configuration / user defined interface
10   !!----------------------------------------------------------------------
11
12   !!----------------------------------------------------------------------
13   !!   nemo_gcm      : solve ocean dynamics, tracer, biogeochemistry and/or sea-ice
14   !!   nemo_init     : initialization of the NEMO system
15   !!   nemo_ctl      : initialisation of the contol print
16   !!   nemo_closefile: close remaining open files
17   !!   nemo_alloc    : dynamical allocation
18   !!----------------------------------------------------------------------
19   USE step_oce       ! module used in the ocean time stepping module
20   USE sbc_oce        ! surface boundary condition: ocean
21   USE phycst         ! physical constant                  (par_cst routine)
22   USE domain         ! domain initialization   (dom_init & dom_cfg routines)
23   USE closea         ! treatment of closed seas (for ln_closea)
24   USE usrdef_nam     ! user defined configuration
25   USE daymod         ! calendar
26   USE restart        ! open  restart file
27   USE step           ! NEMO time-stepping                 (stp     routine)
28   USE cpl_oasis3     !
29   USE sbcssm         !
30   USE icbini         ! handle bergs, initialisation
31   USE icbstp         ! handle bergs, calving, themodynamics and transport
32   USE bdyini         ! open boundary cond. setting       (bdy_init routine). mandatory for sea-ice
33   USE bdydta         ! open boundary cond. setting   (bdy_dta_init routine). mandatory for sea-ice
34   !
35   USE in_out_manager ! I/O manager
36   USE lib_mpp        ! distributed memory computing
37   USE mppini         ! shared/distributed memory setting (mpp_init routine)
38   USE lbcnfd  , ONLY : isendto, nsndto, nfsloop, nfeloop   ! Setup of north fold exchanges
39   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
40#if defined key_iomput
41   USE xios           ! xIOserver
42#endif
43#if defined key_agrif && defined key_si3
44   USE agrif_ice_update ! ice update
45#endif
46
47   IMPLICIT NONE
48   PRIVATE
49
50   PUBLIC   nemo_gcm    ! called by model.F90
51   PUBLIC   nemo_init   ! needed by AGRIF
52
53   CHARACTER(lc) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
54
55#if defined key_mpp_mpi
56   ! need MPI_Wtime
57   INCLUDE 'mpif.h'
58#endif
59
60   !!----------------------------------------------------------------------
61   !! NEMO/SAS 4.0 , NEMO Consortium (2018)
62   !! $Id$
63   !! Software governed by the CeCILL license (see ./LICENSE)
64   !!----------------------------------------------------------------------
65CONTAINS
66
67   SUBROUTINE nemo_gcm
68      !!----------------------------------------------------------------------
69      !!                     ***  ROUTINE nemo_gcm  ***
70      !!
71      !! ** Purpose :   NEMO solves the primitive equations on an orthogonal
72      !!              curvilinear mesh on the sphere.
73      !!
74      !! ** Method  : - model general initialization
75      !!              - launch the time-stepping (stp routine)
76      !!              - finalize the run by closing files and communications
77      !!
78      !! References : Madec, Delecluse, Imbard, and Levy, 1997:  internal report, IPSL.
79      !!              Madec, 2008, internal report, IPSL.
80      !!----------------------------------------------------------------------
81      INTEGER ::   istp   ! time step index
82      REAL(wp)::   zstptiming   ! elapsed time for 1 time step
83      !!----------------------------------------------------------------------
84      !
85#if defined key_agrif
86      CALL Agrif_Init_Grids()      ! AGRIF: set the meshes
87#endif
88      !                            !-----------------------!
89      CALL nemo_init               !==  Initialisations  ==!
90      !                            !-----------------------!
91#if defined key_agrif
92      CALL Agrif_Declare_Var_dom   ! AGRIF: set the meshes for DOM
93      CALL Agrif_Declare_Var       !  "      "   "   "      "  DYN/TRA
94# if defined key_top
95      CALL Agrif_Declare_Var_top   !  "      "   "   "      "  TOP
96# endif
97# if defined key_si3
98      CALL Agrif_Declare_Var_ice   !  "      "   "   "      "  Sea ice
99# endif
100#endif
101      ! check that all process are still there... If some process have an error,
102      ! they will never enter in step and other processes will wait until the end of the cpu time!
103      CALL mpp_max( 'nemogcm', nstop )
104
105      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
106
107      !                            !-----------------------!
108      !                            !==   time stepping   ==!
109      !                            !-----------------------!
110      istp = nit000
111      !
112#if defined key_agrif
113      !                                               !==  AGRIF time-stepping  ==!
114      CALL Agrif_Regrid()
115      !
116#if defined key_si3
117      ! Recursive update from highest nested level to lowest:
118      CALL Agrif_step_child_adj(Agrif_update_ice)
119#endif
120      !
121      DO WHILE( istp <= nitend .AND. nstop == 0 )
122         CALL stp
123         istp = istp + 1
124      END DO
125      !
126      IF( .NOT. Agrif_Root() ) THEN
127         CALL Agrif_ParentGrid_To_ChildGrid()
128         IF( ln_timing )   CALL timing_finalize
129         CALL Agrif_ChildGrid_To_ParentGrid()
130      ENDIF
131      !
132#else
133      !
134      IF( .NOT.ln_diurnal_only ) THEN                 !==  Standard time-stepping  ==!
135         !
136         DO WHILE( istp <= nitend .AND. nstop == 0 )
137
138            ncom_stp = istp
139            IF( ln_timing ) THEN
140               zstptiming = MPI_Wtime()
141               IF ( istp == ( nit000 + 1 ) ) elapsed_time = zstptiming
142               IF ( istp ==         nitend ) elapsed_time = zstptiming - elapsed_time
143            ENDIF
144
145            CALL stp        ( istp ) 
146            istp = istp + 1
147
148            IF( lwp .AND. ln_timing )   WRITE(numtime,*) 'timing step ', istp-1, ' : ', MPI_Wtime() - zstptiming
149         END DO
150         !
151      ELSE                                            !==  diurnal SST time-steeping only  ==!
152         !
153         DO WHILE( istp <= nitend .AND. nstop == 0 )
154            CALL stp_diurnal( istp )   ! time step only the diurnal SST
155            istp = istp + 1
156         END DO
157         !
158      ENDIF
159      !
160#endif
161      !
162      IF( ln_icebergs )   CALL icb_end( nitend )
163
164      !                            !------------------------!
165      !                            !==  finalize the run  ==!
166      !                            !------------------------!
167      IF(lwp) WRITE(numout,cform_aaa)        ! Flag AAAAAAA
168      !
169      IF( nstop /= 0 .AND. lwp ) THEN        ! error print
170         WRITE(ctmp1,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
171         WRITE(ctmp2,*) '           Look for "E R R O R" messages in all existing ocean_output* files'
172         CALL ctl_stop( ' ', ctmp1, ' ', ctmp2 )
173      ENDIF
174      !
175      IF( ln_timing )   CALL timing_finalize
176      !
177      CALL nemo_closefile
178      !
179#if defined key_iomput
180                                    CALL xios_finalize  ! end mpp communications with xios
181      IF( lk_oasis     )            CALL cpl_finalize   ! end coupling and mpp communications with OASIS
182#else
183      IF    ( lk_oasis ) THEN   ;   CALL cpl_finalize   ! end coupling and mpp communications with OASIS
184      ELSEIF( lk_mpp   ) THEN   ;   CALL mppstop        ! end mpp communications
185      ENDIF
186#endif
187      !
188      IF(lwm) THEN
189         IF( nstop == 0 ) THEN   ;   STOP 0
190         ELSE                    ;   STOP 123
191         ENDIF
192      ENDIF
193      !
194   END SUBROUTINE nemo_gcm
195
196
197   SUBROUTINE nemo_init
198      !!----------------------------------------------------------------------
199      !!                     ***  ROUTINE nemo_init  ***
200      !!
201      !! ** Purpose :   initialization of the NEMO GCM
202      !!----------------------------------------------------------------------
203      INTEGER ::   ios, ilocal_comm   ! local integers
204      !!
205      NAMELIST/namctl/ ln_ctl   , sn_cfctl, nn_print, nn_ictls, nn_ictle,   &
206         &             nn_isplt , nn_jsplt, nn_jctls, nn_jctle,             &
207         &             ln_timing, ln_diacfl
208      NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_closea, ln_write_cfg, cn_domcfg_out, ln_use_jattr
209      !!----------------------------------------------------------------------
210      !
211      IF( lk_oasis ) THEN   ;   cxios_context = 'sas'
212      ELSE                  ;   cxios_context = 'nemo'
213      ENDIF
214      !
215      !                             !-------------------------------------------------!
216      !                             !     set communicator & select the local rank    !
217      !                             !  must be done as soon as possible to get narea  !
218      !                             !-------------------------------------------------!
219      !
220#if defined key_iomput
221      IF( Agrif_Root() ) THEN
222         IF( lk_oasis ) THEN
223            CALL cpl_init( "sas", ilocal_comm )                                  ! nemo local communicator given by oasis
224            CALL xios_initialize( "not used",local_comm=ilocal_comm )            ! send nemo communicator to xios
225         ELSE
226            CALL xios_initialize( "for_xios_mpi_id",return_comm=ilocal_comm )    ! nemo local communicator given by xios
227         ENDIF
228      ENDIF
229      CALL mpp_start( ilocal_comm )
230#else
231      IF( lk_oasis ) THEN
232         IF( Agrif_Root() ) THEN
233            CALL cpl_init( "sas", ilocal_comm )             ! nemo local communicator given by oasis
234         ENDIF
235         CALL mpp_start( ilocal_comm )
236      ELSE
237         CALL mpp_start( )
238      ENDIF
239#endif
240      !
241      narea = mpprank + 1                                   ! mpprank: the rank of proc (0 --> mppsize -1 )
242      lwm = (narea == 1)                ! control of output namelists
243      !
244      !                             !---------------------------------------------------------------!
245      !                             ! Open output files, reference and configuration namelist files !
246      !                             !---------------------------------------------------------------!
247      !
248      ! open ocean.output as soon as possible to get all output prints (including errors messages)
249      IF( lk_oasis ) THEN
250         IF( lwm )   CALL ctl_opn(     numout,              'sas.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
251         ! open reference and configuration namelist files
252                     CALL ctl_opn( numnam_ref,        'namelist_sas_ref',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
253                     CALL ctl_opn( numnam_cfg,        'namelist_sas_cfg',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
254         IF( lwm )   CALL ctl_opn(     numond, 'output.namelist_sas.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
255      ELSE
256         IF( lwm )   CALL ctl_opn(     numout,            'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
257         ! open reference and configuration namelist files
258                     CALL ctl_opn( numnam_ref,            'namelist_ref',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
259                     CALL ctl_opn( numnam_cfg,            'namelist_cfg',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
260         IF( lwm )   CALL ctl_opn(     numond,     'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
261      ENDIF
262      ! open /dev/null file to be able to supress output write easily
263      IF( Agrif_Root() ) THEN
264                     CALL ctl_opn(     numnul,               '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
265#ifdef key_agrif
266      ELSE
267                     numnul = Agrif_Parent(numnul)
268#endif
269      ENDIF
270      !
271      !                             !--------------------!
272      !                             ! Open listing units !  -> need ln_ctl from namctl to define lwp
273      !                             !--------------------!
274      !
275      REWIND( numnam_ref )              ! Namelist namctl in reference namelist
276      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
277901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist' )
278      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
279      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
280902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist' )
281      !
282      lwp = (narea == 1) .OR. ln_ctl    ! control of all listing output print
283      !
284      IF(lwp) THEN                      ! open listing units
285         !
286         IF( .NOT. lwm ) THEN           ! alreay opened for narea == 1
287            IF(lk_oasis) THEN   ;   CALL ctl_opn( numout,   'sas.output','REPLACE','FORMATTED','SEQUENTIAL',-1,-1, .FALSE., narea )
288            ELSE                ;   CALL ctl_opn( numout, 'ocean.output','REPLACE','FORMATTED','SEQUENTIAL',-1,-1, .FALSE., narea )
289            ENDIF
290         ENDIF
291         !
292         WRITE(numout,*)
293         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC'
294         WRITE(numout,*) '                       NEMO team'
295         WRITE(numout,*) '            Ocean General Circulation Model'
296         WRITE(numout,*) '                NEMO version 4.0  (2019) '
297         WRITE(numout,*) '             StandAlone Surface version (SAS) '
298         WRITE(numout,*) "           ._      ._      ._      ._      ._    "
299         WRITE(numout,*) "       _.-._)`\_.-._)`\_.-._)`\_.-._)`\_.-._)`\_ "
300         WRITE(numout,*)
301         WRITE(numout,*) "           o         _,           _,             "
302         WRITE(numout,*) "            o      .' (        .-' /             "
303         WRITE(numout,*) "           o     _/..._'.    .'   /              "
304         WRITE(numout,*) "      (    o .-'`      ` '-./  _.'               "
305         WRITE(numout,*) "       )    ( o)           ;= <_         (       "
306         WRITE(numout,*) "      (      '-.,\\__ __.-;`\   '.        )      "
307         WRITE(numout,*) "       )  )       \) |`\ \)  '.   \      (   (   "
308         WRITE(numout,*) "      (  (           \_/       '-._\      )   )  "
309         WRITE(numout,*) "       )  ) jgs                    `     (   (   "
310         WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
311         WRITE(numout,*)
312         WRITE(numout,*)
313         !
314         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
315         !
316      ENDIF
317     !
318      ! finalize the definition of namctl variables
319      IF( sn_cfctl%l_config ) THEN
320         ! Activate finer control of report outputs
321         ! optionally switch off output from selected areas (note this only
322         ! applies to output which does not involve global communications)
323         IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax  ) .OR. &
324           & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) )    &
325           &   CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. )
326      ELSE
327         ! Use ln_ctl to turn on or off all options.
328         CALL nemo_set_cfctl( sn_cfctl, ln_ctl, .TRUE. )
329      ENDIF
330      !
331      IF(lwm) WRITE( numond, namctl )
332      !
333      !                             !------------------------------------!
334      !                             !  Set global domain size parameters !
335      !                             !------------------------------------!
336      !
337      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
338      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
339903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist' )
340      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
341      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
342904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist' )   
343      !
344      IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
345         CALL domain_cfg ( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
346      ELSE                              ! user-defined namelist
347         CALL usr_def_nam( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
348      ENDIF
349      !
350      IF(lwm)   WRITE( numond, namcfg )
351      !
352      !                             !-----------------------------------------!
353      !                             ! mpp parameters and domain decomposition !
354      !                             !-----------------------------------------!
355      CALL mpp_init
356
357      ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
358      CALL nemo_alloc()
359
360      !                             !-------------------------------!
361      !                             !  NEMO general initialization  !
362      !                             !-------------------------------!
363
364      CALL nemo_ctl                          ! Control prints
365      !
366      !                                      ! General initialization
367      IF( ln_timing    )   CALL timing_init     ! timing
368      IF( ln_timing    )   CALL timing_start( 'nemo_init')
369
370                           CALL phy_cst         ! Physical constants
371                           CALL eos_init        ! Equation of seawater
372                           CALL dom_init('SAS') ! Domain
373      IF( ln_ctl      )    CALL prt_ctl_init    ! Print control
374     
375                           CALL day_init        ! model calendar (using both namelist and restart infos)
376      IF( ln_rstart )      CALL rst_read_open
377
378      !                                      ! external forcing
379                           CALL sbc_init        ! Forcings : surface module
380
381      ! ==> clem: open boundaries init. is mandatory for sea-ice because ice BDY is not decoupled from 
382      !           the environment of ocean BDY. Therefore bdy is called in both OPA and SAS modules.
383      !           This is not clean and should be changed in the future.
384                           CALL bdy_init
385      ! ==>
386                           CALL icb_init( rdt, nit000)   ! initialise icebergs instance
387      !
388      IF(lwp) WRITE(numout,cform_aaa)           ! Flag AAAAAAA
389      !
390      IF( ln_timing    )   CALL timing_stop( 'nemo_init')
391      !
392   END SUBROUTINE nemo_init
393
394
395   SUBROUTINE nemo_ctl
396      !!----------------------------------------------------------------------
397      !!                     ***  ROUTINE nemo_ctl  ***
398      !!
399      !! ** Purpose :   control print setting
400      !!
401      !! ** Method  : - print namctl information and check some consistencies
402      !!----------------------------------------------------------------------
403      !
404      IF(lwp) THEN                  ! control print
405         WRITE(numout,*)
406         WRITE(numout,*) 'nemo_ctl: Control prints'
407         WRITE(numout,*) '~~~~~~~~'
408         WRITE(numout,*) '   Namelist namctl'
409         WRITE(numout,*) '      run control (for debugging)     ln_ctl     = ', ln_ctl
410         WRITE(numout,*) '       finer control over o/p sn_cfctl%l_config  = ', sn_cfctl%l_config
411         WRITE(numout,*) '                              sn_cfctl%l_runstat = ', sn_cfctl%l_runstat
412         WRITE(numout,*) '                              sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat
413         WRITE(numout,*) '                              sn_cfctl%l_oceout  = ', sn_cfctl%l_oceout
414         WRITE(numout,*) '                              sn_cfctl%l_layout  = ', sn_cfctl%l_layout
415         WRITE(numout,*) '                              sn_cfctl%l_mppout  = ', sn_cfctl%l_mppout
416         WRITE(numout,*) '                              sn_cfctl%l_mpptop  = ', sn_cfctl%l_mpptop
417         WRITE(numout,*) '                              sn_cfctl%procmin   = ', sn_cfctl%procmin 
418         WRITE(numout,*) '                              sn_cfctl%procmax   = ', sn_cfctl%procmax 
419         WRITE(numout,*) '                              sn_cfctl%procincr  = ', sn_cfctl%procincr 
420         WRITE(numout,*) '                              sn_cfctl%ptimincr  = ', sn_cfctl%ptimincr 
421         WRITE(numout,*) '      level of print                  nn_print   = ', nn_print
422         WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
423         WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
424         WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
425         WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
426         WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
427         WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
428         WRITE(numout,*) '      timing by routine               ln_timing  = ', ln_timing
429         WRITE(numout,*) '      CFL diagnostics                 ln_diacfl  = ', ln_diacfl
430      ENDIF
431      !
432      nprint    = nn_print          ! convert DOCTOR namelist names into OLD names
433      nictls    = nn_ictls
434      nictle    = nn_ictle
435      njctls    = nn_jctls
436      njctle    = nn_jctle
437      isplt     = nn_isplt
438      jsplt     = nn_jsplt
439
440      IF(lwp) THEN                  ! control print
441         WRITE(numout,*)
442         WRITE(numout,*) '   Namelist namcfg'
443         WRITE(numout,*) '      read domain configuration file                ln_read_cfg      = ', ln_read_cfg
444         WRITE(numout,*) '         filename to be read                           cn_domcfg     = ', TRIM(cn_domcfg)
445         WRITE(numout,*) '         keep closed seas in the domain (if exist)     ln_closea     = ', ln_closea
446         WRITE(numout,*) '      create a configuration definition file        ln_write_cfg     = ', ln_write_cfg
447         WRITE(numout,*) '         filename to be written                        cn_domcfg_out = ', TRIM(cn_domcfg_out)
448         WRITE(numout,*) '      use file attribute if exists as i/p j-start   ln_use_jattr     = ', ln_use_jattr
449      ENDIF
450      IF( .NOT.ln_read_cfg )   ln_closea = .false.   ! dealing possible only with a domcfg file
451      !
452      !                             ! Parameter control
453      !
454      IF( ln_ctl ) THEN                 ! sub-domain area indices for the control prints
455         IF( lk_mpp .AND. jpnij > 1 ) THEN
456            isplt = jpni   ;   jsplt = jpnj   ;   ijsplt = jpni*jpnj   ! the domain is forced to the real split domain
457         ELSE
458            IF( isplt == 1 .AND. jsplt == 1  ) THEN
459               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
460                  &           ' - the print control will be done over the whole domain' )
461            ENDIF
462            ijsplt = isplt * jsplt            ! total number of processors ijsplt
463         ENDIF
464         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
465         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
466         !
467         !                              ! indices used for the SUM control
468         IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
469            lsp_area = .FALSE.
470         ELSE                                             ! print control done over a specific  area
471            lsp_area = .TRUE.
472            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
473               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
474               nictls = 1
475            ENDIF
476            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
477               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
478               nictle = jpiglo
479            ENDIF
480            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
481               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
482               njctls = 1
483            ENDIF
484            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
485               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
486               njctle = jpjglo
487            ENDIF
488         ENDIF
489      ENDIF
490      !
491      IF( 1._wp /= SIGN(1._wp,-0._wp)  )   CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows f2003 standard.',  &
492         &                                                'Compile with key_nosignedzero enabled:',   &
493         &                                                '--> add -Dkey_nosignedzero to the definition of %CPP in your arch file' )
494      !
495#if defined key_agrif
496      IF( ln_timing )   CALL ctl_stop( 'AGRIF not implemented with ln_timing = true')
497#endif
498      !
499   END SUBROUTINE nemo_ctl
500
501
502   SUBROUTINE nemo_closefile
503      !!----------------------------------------------------------------------
504      !!                     ***  ROUTINE nemo_closefile  ***
505      !!
506      !! ** Purpose :   Close the files
507      !!----------------------------------------------------------------------
508      !
509      IF( lk_mpp )   CALL mppsync
510      !
511      CALL iom_close                                 ! close all input/output files managed by iom_*
512      !
513      IF( numstp          /= -1 )   CLOSE( numstp          )   ! time-step file     
514      IF( numrun          /= -1 )   CLOSE( numrun          )   ! run statistics file
515      IF( numnam_ref      /= -1 )   CLOSE( numnam_ref      )   ! oce reference namelist
516      IF( numnam_cfg      /= -1 )   CLOSE( numnam_cfg      )   ! oce configuration namelist
517      IF( lwm.AND.numond  /= -1 )   CLOSE( numond          )   ! oce output namelist
518      IF( numnam_ice_ref  /= -1 )   CLOSE( numnam_ice_ref  )   ! ice reference namelist
519      IF( numnam_ice_cfg  /= -1 )   CLOSE( numnam_ice_cfg  )   ! ice configuration namelist
520      IF( lwm.AND.numoni  /= -1 )   CLOSE( numoni          )   ! ice output namelist
521      IF( numevo_ice      /= -1 )   CLOSE( numevo_ice      )   ! ice variables (temp. evolution)
522      IF( numout          /=  6 )   CLOSE( numout          )   ! standard model output file
523      !
524      numout = 6                                     ! redefine numout in case it is used after this point...
525      !
526   END SUBROUTINE nemo_closefile
527
528
529   SUBROUTINE nemo_alloc
530      !!----------------------------------------------------------------------
531      !!                     ***  ROUTINE nemo_alloc  ***
532      !!
533      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
534      !!
535      !! ** Method  :
536      !!----------------------------------------------------------------------
537      USE diawri    , ONLY : dia_wri_alloc
538      USE dom_oce   , ONLY : dom_oce_alloc
539      USE bdy_oce   , ONLY : ln_bdy, bdy_oce_alloc
540      USE oce       ! mandatory for sea-ice because needed for bdy arrays
541      !
542      INTEGER :: ierr
543      !!----------------------------------------------------------------------
544      !
545      ierr =        dia_wri_alloc()
546      ierr = ierr + dom_oce_alloc()          ! ocean domain
547      ierr = ierr + oce_alloc    ()          ! (tsn...) needed for agrif and/or SI3 and bdy
548      ierr = ierr + bdy_oce_alloc()          ! bdy masks (incl. initialization)
549      !
550      CALL mpp_sum( 'nemogcm', ierr )
551      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' )
552      !
553   END SUBROUTINE nemo_alloc
554
555   SUBROUTINE nemo_set_cfctl(sn_cfctl, setto, for_all )
556      !!----------------------------------------------------------------------
557      !!                     ***  ROUTINE nemo_set_cfctl  ***
558      !!
559      !! ** Purpose :   Set elements of the output control structure to setto.
560      !!                for_all should be .false. unless all areas are to be
561      !!                treated identically.
562      !!
563      !! ** Method  :   Note this routine can be used to switch on/off some
564      !!                types of output for selected areas but any output types
565      !!                that involve global communications (e.g. mpp_max, glob_sum)
566      !!                should be protected from selective switching by the
567      !!                for_all argument
568      !!----------------------------------------------------------------------
569      LOGICAL :: setto, for_all
570      TYPE(sn_ctl) :: sn_cfctl
571      !!----------------------------------------------------------------------
572      IF( for_all ) THEN
573         sn_cfctl%l_runstat = setto
574         sn_cfctl%l_trcstat = setto
575      ENDIF
576      sn_cfctl%l_oceout  = setto
577      sn_cfctl%l_layout  = setto
578      sn_cfctl%l_mppout  = setto
579      sn_cfctl%l_mpptop  = setto
580   END SUBROUTINE nemo_set_cfctl
581
582   !!======================================================================
583END MODULE nemogcm
584
Note: See TracBrowser for help on using the repository browser.