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/tickets_icb_1900/src/SAS – NEMO

source: NEMO/branches/2020/tickets_icb_1900/src/SAS/nemogcm.F90 @ 13365

Last change on this file since 13365 was 13365, checked in by mathiot, 4 years ago

ticket #1900: add compatibility check (nn_fsbc and ln_M2016, SAS and ln_M2016) and rm useless debug print

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