New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
nemogcm.F90 in NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/SAS – NEMO

source: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/SAS/nemogcm.F90 @ 13015

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

Extra_Halo: merge with trunk@13012, see #2366

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