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

source: NEMO/trunk/src/SAS/nemogcm.F90

Last change on this file was 15267, checked in by smasson, 3 years ago

trunk: new nogather nolding, #2724

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