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_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/SAS – NEMO

source: NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/SAS/nemogcm.F90 @ 10927

Last change on this file since 10927 was 10927, checked in by acc, 5 years ago

2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps : Tidy up the diurnal cycle code (DIU) to separate its stand-alone functionality from the cool skin and warm layer calculations. The latter can be called from step; the former needs to be kept out of step so that it can implement its own time-level indices.
The stand-alone functionality will need to be revisited once the new timestepping is finalised. SETTE tested (ORCA2_ICE and SAS).

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