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

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

trunk: merge dev_r14312_MPI_Interface into the trunk, #2598

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