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

source: NEMO/branches/2019/dev_r12072_MERGE_OPTION2_2019/src/SAS/nemogcm.F90 @ 12252

Last change on this file since 12252 was 12210, checked in by cetlod, 4 years ago

dev_merge_option2 : merge in fix_sn_cfctl_ticket2328 branch

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