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 @ 12640

Last change on this file since 12640 was 12640, checked in by smasson, 4 years ago

r4.0-HEAD: numnul with Agrif, see #2378

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