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/releases/r4.0/r4.0-HEAD/src/OFF – NEMO

source: NEMO/releases/r4.0/r4.0-HEAD/src/OFF/nemogcm.F90 @ 12640

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

r4.0-HEAD: numnul with Agrif, see #2378

  • Property svn:keywords set to Id
File size: 28.5 KB
Line 
1MODULE nemogcm
2   !!======================================================================
3   !!                       ***  MODULE nemogcm   ***
4   !! Off-line Ocean   : passive tracer evolution, dynamics read in files
5   !!======================================================================
6   !! History :  3.3  ! 2010-05  (C. Ethe)  Full reorganization of the off-line: phasing with the on-line
7   !!            3.4  ! 2011-01  (C. Ethe, A. R. Porter, STFC Daresbury) dynamical allocation
8   !!            4.0  ! 2016-10  (C. Ethe, G. Madec, S. Flavoni)  domain configuration / user defined interface
9   !!----------------------------------------------------------------------
10
11   !!----------------------------------------------------------------------
12   !!   nemo_gcm      : off-line: solve ocean tracer only
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   !!   istate_init   : simple initialization to zero of ocean fields
19   !!   stp_ctl       : reduced step control (no dynamics in off-line)
20   !!----------------------------------------------------------------------
21   USE dom_oce        ! ocean space domain variables
22   USE oce            ! dynamics and tracers variables
23   USE trc_oce        ! Shared ocean/passive tracers variables
24   USE c1d            ! 1D configuration
25   USE domain         ! domain initialization from coordinate & bathymetry (dom_init routine)
26   USE closea         ! treatment of closed seas (for ln_closea)
27   USE usrdef_nam     ! user defined configuration
28   USE eosbn2         ! equation of state            (eos bn2 routine)
29   !              ! ocean physics
30   USE ldftra         ! lateral diffusivity setting    (ldf_tra_init routine)
31   USE ldfslp         ! slopes of neutral surfaces     (ldf_slp_init routine)
32   USE traqsr         ! solar radiation penetration    (tra_qsr_init routine)
33   USE trabbl         ! bottom boundary layer          (tra_bbl_init routine)
34   USE traldf         ! lateral physics                (tra_ldf_init routine)
35   USE sbcmod         ! surface boundary condition     (sbc_init     routine)
36   USE phycst         ! physical constant                   (par_cst routine)
37   USE dtadyn         ! Lecture and Interpolation of the dynamical fields
38   USE trcini         ! Initilization of the passive tracers
39   USE daymod         ! calendar                            (day     routine)
40   USE trcstp         ! passive tracer time-stepping        (trc_stp routine)
41   USE dtadyn         ! Lecture and interpolation of the dynamical fields
42   !              ! Passive tracers needs
43   USE trc            ! passive tracer : variables
44   USE trcnam         ! passive tracer : namelist
45   USE trcrst         ! passive tracer restart
46   USE diaptr         ! Need to initialise this as some variables are used in if statements later
47   USE sbc_oce , ONLY : ln_rnf
48   USE sbcrnf         ! surface boundary condition : runoffs
49   !              ! I/O & MPP
50   USE iom            ! I/O library
51   USE in_out_manager ! I/O manager
52   USE mppini         ! shared/distributed memory setting (mpp_init routine)
53   USE lib_mpp        ! distributed memory computing
54#if defined key_iomput
55   USE xios           ! xIOserver
56#endif
57   USE prtctl         ! Print control                    (prt_ctl_init routine)
58   USE timing         ! Timing
59   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
60   USE lbcnfd  , ONLY : isendto, nsndto, nfsloop, nfeloop   ! Setup of north fold exchanges
61
62   IMPLICIT NONE
63   PRIVATE
64   
65   PUBLIC   nemo_gcm   ! called by nemo.F90
66
67   CHARACTER (len=64) ::   cform_aaa="( /, 'AAAAAAAA', / ) "   ! flag for output listing
68
69   !!----------------------------------------------------------------------
70   !! NEMO/OFF 4.0 , NEMO Consortium (2018)
71   !! $Id$
72   !! Software governed by the CeCILL license (see ./LICENSE)
73   !!----------------------------------------------------------------------
74CONTAINS
75
76   SUBROUTINE nemo_gcm
77      !!----------------------------------------------------------------------
78      !!                     ***  ROUTINE nemo_gcm  ***
79      !!
80      !! ** Purpose :   NEMO solves the primitive equations on an orthogonal
81      !!              curvilinear mesh on the sphere.
82      !!
83      !! ** Method  : - model general initialization
84      !!              - launch the time-stepping (dta_dyn and trc_stp)
85      !!              - finalize the run by closing files and communications
86      !!
87      !! References : Madec, Delecluse,Imbard, and Levy, 1997:  internal report, IPSL.
88      !!              Madec, 2008, internal report, IPSL.
89      !!----------------------------------------------------------------------
90      INTEGER :: istp, indic       ! time step index
91      !!----------------------------------------------------------------------
92
93      CALL nemo_init  ! Initializations
94
95      ! check that all process are still there... If some process have an error,
96      ! they will never enter in step and other processes will wait until the end of the cpu time!
97      CALL mpp_max( 'nemogcm', nstop )
98
99      !                            !-----------------------!
100      !                            !==   time stepping   ==!
101      !                            !-----------------------!
102      istp = nit000
103      !
104      IF( ln_rnf )   CALL sbc_rnf(istp)   ! runoffs initialization
105      !
106      CALL iom_init( cxios_context )      ! iom_put initialization (must be done after nemo_init for AGRIF+XIOS+OASIS)
107      !
108      DO WHILE ( istp <= nitend .AND. nstop == 0 )    !==  OFF time-stepping  ==!
109         !
110         IF( istp /= nit000 )   CALL day        ( istp )         ! Calendar (day was already called at nit000 in day_init)
111                                CALL iom_setkt  ( istp - nit000 + 1, cxios_context )   ! say to iom that we are at time step kstp
112#if defined key_sed_off
113                                CALL dta_dyn_sed( istp )         ! Interpolation of the dynamical fields
114#else
115                                CALL dta_dyn    ( istp )         ! Interpolation of the dynamical fields
116#endif
117                                CALL trc_stp    ( istp )         ! time-stepping
118#if ! defined key_sed_off
119         IF( .NOT.ln_linssh )   CALL dta_dyn_swp( istp )         ! swap of sea  surface height and vertical scale factors
120#endif
121                                CALL stp_ctl    ( istp, indic )  ! Time loop: control and print
122         istp = istp + 1
123      END DO
124      !
125#if defined key_iomput
126      CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF
127#endif
128
129      !                            !------------------------!
130      !                            !==  finalize the run  ==!
131      !                            !------------------------!
132      IF(lwp) WRITE(numout,cform_aaa)                 ! Flag AAAAAAA
133
134      IF( nstop /= 0 .AND. lwp ) THEN                 ! error print
135         WRITE(ctmp1,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
136         CALL ctl_stop( ctmp1 )
137      ENDIF
138      !
139      IF( ln_timing )   CALL timing_finalize
140      !
141      CALL nemo_closefile
142      !
143#if defined key_iomput
144                     CALL xios_finalize   ! end mpp communications with xios
145#else
146      IF( lk_mpp )   CALL mppstop         ! end mpp communications
147#endif
148      !
149      IF(lwm) THEN
150         IF( nstop == 0 ) THEN   ;   STOP 0
151         ELSE                    ;   STOP 123
152         ENDIF
153      ENDIF
154      !
155   END SUBROUTINE nemo_gcm
156
157
158   SUBROUTINE nemo_init
159      !!----------------------------------------------------------------------
160      !!                     ***  ROUTINE nemo_init  ***
161      !!
162      !! ** Purpose :   initialization of the nemo model in off-line mode
163      !!----------------------------------------------------------------------
164      INTEGER ::   ios, ilocal_comm   ! local integers
165      !!
166      NAMELIST/namctl/ ln_ctl   , sn_cfctl, nn_print, nn_ictls, nn_ictle,   &
167         &             nn_isplt , nn_jsplt, nn_jctls, nn_jctle,             &
168         &             ln_timing, ln_diacfl
169      NAMELIST/namcfg/ ln_read_cfg, cn_domcfg, ln_closea, ln_write_cfg, cn_domcfg_out, ln_use_jattr
170      !!----------------------------------------------------------------------
171      !
172      cxios_context = 'nemo'
173      !
174      !                             !-------------------------------------------------!
175      !                             !     set communicator & select the local rank    !
176      !                             !  must be done as soon as possible to get narea  !
177      !                             !-------------------------------------------------!
178      !
179#if defined key_iomput
180      CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
181      CALL mpp_start( ilocal_comm )
182#else
183      CALL mpp_start( )
184#endif
185      !
186      narea = mpprank + 1               ! mpprank: the rank of proc (0 --> mppsize -1 )
187      lwm = (narea == 1)                ! control of output namelists
188      !
189      !                             !---------------------------------------------------------------!
190      !                             ! Open output files, reference and configuration namelist files !
191      !                             !---------------------------------------------------------------!
192      !
193      ! open ocean.output as soon as possible to get all output prints (including errors messages)
194      IF( lwm )   CALL ctl_opn(     numout,        'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
195      ! open reference and configuration namelist files
196                  CALL ctl_opn( numnam_ref,        'namelist_ref',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
197                  CALL ctl_opn( numnam_cfg,        'namelist_cfg',     'OLD', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
198      IF( lwm )   CALL ctl_opn(     numond, 'output.namelist.dyn', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
199      ! open /dev/null file to be able to supress output write easily
200      IF( Agrif_Root() ) THEN
201                  CALL ctl_opn(     numnul,           '/dev/null', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE. )
202#ifdef key_agrif
203      ELSE
204                  numnul = Agrif_Parent(numnul)
205#endif
206      ENDIF
207      !
208      !                             !--------------------!
209      !                             ! Open listing units !  -> need ln_ctl from namctl to define lwp
210      !                             !--------------------!
211      !
212      REWIND( numnam_ref )              ! Namelist namctl in reference namelist
213      READ  ( numnam_ref, namctl, IOSTAT = ios, ERR = 901 )
214901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namctl in reference namelist' )
215      REWIND( numnam_cfg )              ! Namelist namctl in confguration namelist
216      READ  ( numnam_cfg, namctl, IOSTAT = ios, ERR = 902 )
217902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namctl in configuration namelist' )
218      !
219      lwp = (narea == 1) .OR. ln_ctl    ! control of all listing output print
220      !
221      IF(lwp) THEN                            ! open listing units
222         !
223         IF( .NOT. lwm )   &           ! alreay opened for narea == 1
224            &     CALL ctl_opn(     numout,        'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE., narea )
225         !
226         WRITE(numout,*)
227         WRITE(numout,*) '   CNRS - NERC - Met OFFICE - MERCATOR-ocean - CMCC'
228         WRITE(numout,*) '                       NEMO team'
229         WRITE(numout,*) '                   Off-line TOP Model'
230         WRITE(numout,*) '                NEMO version 4.0  (2019) '
231         WRITE(numout,*)
232         WRITE(numout,*) "           ._      ._      ._      ._      ._    "
233         WRITE(numout,*) "       _.-._)`\_.-._)`\_.-._)`\_.-._)`\_.-._)`\_ "
234         WRITE(numout,*)
235         WRITE(numout,*) "           o         _,           _,             "
236         WRITE(numout,*) "            o      .' (        .-' /             "
237         WRITE(numout,*) "           o     _/..._'.    .'   /              "
238         WRITE(numout,*) "      (    o .-'`      ` '-./  _.'               "
239         WRITE(numout,*) "       )    ( o)           ;= <_         (       "
240         WRITE(numout,*) "      (      '-.,\\__ __.-;`\   '.        )      "
241         WRITE(numout,*) "       )  )       \) |`\ \)  '.   \      (   (   "
242         WRITE(numout,*) "      (  (           \_/       '-._\      )   )  "
243         WRITE(numout,*) "       )  )                        `     (   (   "
244         WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
245         WRITE(numout,*)
246         !
247         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
248         !
249      ENDIF
250      !
251      ! finalize the definition of namctl variables
252      IF( sn_cfctl%l_config ) THEN
253         ! Activate finer control of report outputs
254         ! optionally switch off output from selected areas (note this only
255         ! applies to output which does not involve global communications)
256         IF( ( narea < sn_cfctl%procmin .OR. narea > sn_cfctl%procmax  ) .OR. &
257           & ( MOD( narea - sn_cfctl%procmin, sn_cfctl%procincr ) /= 0 ) )    &
258           &   CALL nemo_set_cfctl( sn_cfctl, .FALSE., .FALSE. )
259      ELSE
260         ! Use ln_ctl to turn on or off all options.
261         CALL nemo_set_cfctl( sn_cfctl, ln_ctl, .TRUE. )
262      ENDIF
263      !
264      IF(lwm) WRITE( numond, namctl )
265      !
266      !                             !------------------------------------!
267      !                             !  Set global domain size parameters !
268      !                             !------------------------------------!
269      !     
270      REWIND( numnam_ref )              ! Namelist namcfg in reference namelist
271      READ  ( numnam_ref, namcfg, IOSTAT = ios, ERR = 903 )
272903   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namcfg in reference namelist' )
273      REWIND( numnam_cfg )              ! Namelist namcfg in confguration namelist
274      READ  ( numnam_cfg, namcfg, IOSTAT = ios, ERR = 904 )
275904   IF( ios >  0 )   CALL ctl_nam ( ios , 'namcfg in configuration namelist' )   
276      !
277      IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
278         CALL domain_cfg ( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
279      ELSE                                ! user-defined namelist
280         CALL usr_def_nam( cn_cfg, nn_cfg, jpiglo, jpjglo, jpkglo, jperio )
281      ENDIF
282      !
283      IF(lwm)   WRITE( numond, namcfg )
284      l_offline = .true.                  ! passive tracers are run offline
285      !
286      !                             !-----------------------------------------!
287      !                             ! mpp parameters and domain decomposition !
288      !                             !-----------------------------------------!
289      !
290      CALL mpp_init
291
292      ! Now we know the dimensions of the grid and numout has been set: we can allocate arrays
293      CALL nemo_alloc()
294
295      !                             !-------------------------------!
296      !                             !  NEMO general initialization  !
297      !                             !-------------------------------!
298
299      CALL nemo_ctl                          ! Control prints
300      !
301      !                                      ! General initialization
302      IF( ln_timing    )   CALL timing_init
303      IF( ln_timing    )   CALL timing_start( 'nemo_init')
304      !
305                           CALL     phy_cst         ! Physical constants
306                           CALL     eos_init        ! Equation of state
307      IF( lk_c1d       )   CALL     c1d_init        ! 1D column configuration
308                           CALL     dom_init("OPA") ! Domain
309      IF( ln_ctl       )   CALL prt_ctl_init        ! Print control
310
311                           CALL  istate_init    ! ocean initial state (Dynamics and tracers)
312
313                           CALL     sbc_init    ! Forcings : surface module
314
315      !                                      ! Tracer physics
316                           CALL ldf_tra_init    ! Lateral ocean tracer physics
317                           CALL ldf_eiv_init    ! Eddy induced velocity param
318                           CALL tra_ldf_init    ! lateral mixing
319      IF( l_ldfslp     )   CALL ldf_slp_init    ! slope of lateral mixing
320      IF( ln_traqsr    )   CALL tra_qsr_init    ! penetrative solar radiation
321      IF( ln_trabbl    )   CALL tra_bbl_init    ! advective (and/or diffusive) bottom boundary layer scheme
322
323      !                                      ! Passive tracers
324                           CALL trc_nam_run    ! Needed to get restart parameters for passive tracers
325                           CALL trc_rst_cal( nit000, 'READ' )   ! calendar
326#if defined key_sed_off
327                           CALL dta_dyn_sed_init ! Initialization for the dynamics
328#else
329                           CALL dta_dyn_init   ! Initialization for the dynamics
330#endif
331
332                           CALL     trc_init   ! Passive tracers initialization
333                           CALL dia_ptr_init   ! Poleward TRansports initialization
334                           
335      IF(lwp) WRITE(numout,cform_aaa)           ! Flag AAAAAAA
336      !
337      IF( ln_timing    )   CALL timing_stop( 'nemo_init')
338      !
339   END SUBROUTINE nemo_init
340
341
342   SUBROUTINE nemo_ctl
343      !!----------------------------------------------------------------------
344      !!                     ***  ROUTINE nemo_ctl  ***
345      !!
346      !! ** Purpose :   control print setting
347      !!
348      !! ** Method  : - print namctl information and check some consistencies
349      !!----------------------------------------------------------------------
350      !
351      IF(lwp) THEN                  ! control print
352         WRITE(numout,*)
353         WRITE(numout,*) 'nemo_ctl: Control prints'
354         WRITE(numout,*) '~~~~~~~~'
355         WRITE(numout,*) '   Namelist namctl'
356         WRITE(numout,*) '      run control (for debugging)     ln_ctl     = ', ln_ctl
357         WRITE(numout,*) '       finer control over o/p sn_cfctl%l_config  = ', sn_cfctl%l_config
358         WRITE(numout,*) '                              sn_cfctl%l_runstat = ', sn_cfctl%l_runstat
359         WRITE(numout,*) '                              sn_cfctl%l_trcstat = ', sn_cfctl%l_trcstat
360         WRITE(numout,*) '                              sn_cfctl%l_oceout  = ', sn_cfctl%l_oceout
361         WRITE(numout,*) '                              sn_cfctl%l_layout  = ', sn_cfctl%l_layout
362         WRITE(numout,*) '                              sn_cfctl%l_mppout  = ', sn_cfctl%l_mppout
363         WRITE(numout,*) '                              sn_cfctl%l_mpptop  = ', sn_cfctl%l_mpptop
364         WRITE(numout,*) '                              sn_cfctl%procmin   = ', sn_cfctl%procmin 
365         WRITE(numout,*) '                              sn_cfctl%procmax   = ', sn_cfctl%procmax 
366         WRITE(numout,*) '                              sn_cfctl%procincr  = ', sn_cfctl%procincr 
367         WRITE(numout,*) '                              sn_cfctl%ptimincr  = ', sn_cfctl%ptimincr 
368         WRITE(numout,*) '      level of print                  nn_print   = ', nn_print
369         WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
370         WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
371         WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
372         WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
373         WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
374         WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
375         WRITE(numout,*) '      timing by routine               ln_timing  = ', ln_timing
376         WRITE(numout,*) '      CFL diagnostics                 ln_diacfl  = ', ln_diacfl
377      ENDIF
378      !
379      nprint    = nn_print          ! convert DOCTOR namelist names into OLD names
380      nictls    = nn_ictls
381      nictle    = nn_ictle
382      njctls    = nn_jctls
383      njctle    = nn_jctle
384      isplt     = nn_isplt
385      jsplt     = nn_jsplt
386
387      IF(lwp) THEN                  ! control print
388         WRITE(numout,*)
389         WRITE(numout,*) '   Namelist namcfg'
390         WRITE(numout,*) '      read domain configuration file              ln_read_cfg      = ', ln_read_cfg
391         WRITE(numout,*) '         filename to be read                         cn_domcfg     = ', TRIM(cn_domcfg)
392         WRITE(numout,*) '         keep closed seas in the domain (if exist)   ln_closea     = ', ln_closea
393         WRITE(numout,*) '      create a configuration definition file      ln_write_cfg     = ', ln_write_cfg
394         WRITE(numout,*) '         filename to be written                      cn_domcfg_out = ', TRIM(cn_domcfg_out)
395         WRITE(numout,*) '      use file attribute if exists as i/p j-start ln_use_jattr     = ', ln_use_jattr
396      ENDIF
397      IF( .NOT.ln_read_cfg )   ln_closea = .false.   ! dealing possible only with a domcfg file
398      !
399      !                             ! Parameter control
400      !
401      IF( ln_ctl ) THEN                 ! sub-domain area indices for the control prints
402         IF( lk_mpp .AND. jpnij > 1 ) THEN
403            isplt = jpni   ;   jsplt = jpnj   ;   ijsplt = jpni*jpnj   ! the domain is forced to the real split domain
404         ELSE
405            IF( isplt == 1 .AND. jsplt == 1  ) THEN
406               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
407                  &           ' - the print control will be done over the whole domain' )
408            ENDIF
409            ijsplt = isplt * jsplt            ! total number of processors ijsplt
410         ENDIF
411         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
412         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
413         !
414         !                              ! indices used for the SUM control
415         IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
416            lsp_area = .FALSE.
417         ELSE                                             ! print control done over a specific  area
418            lsp_area = .TRUE.
419            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
420               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
421               nictls = 1
422            ENDIF
423            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
424               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
425               nictle = jpiglo
426            ENDIF
427            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
428               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
429               njctls = 1
430            ENDIF
431            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
432               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
433               njctle = jpjglo
434            ENDIF
435         ENDIF
436      ENDIF
437      !
438      IF( 1._wp /= SIGN(1._wp,-0._wp)  )   CALL ctl_stop( 'nemo_ctl: The intrinsec SIGN function follows f2003 standard.',  &
439         &                                                'Compile with key_nosignedzero enabled' )
440      !
441   END SUBROUTINE nemo_ctl
442
443
444   SUBROUTINE nemo_closefile
445      !!----------------------------------------------------------------------
446      !!                     ***  ROUTINE nemo_closefile  ***
447      !!
448      !! ** Purpose :   Close the files
449      !!----------------------------------------------------------------------
450      !
451      IF( lk_mpp )   CALL mppsync
452      !
453      CALL iom_close                                 ! close all input/output files managed by iom_*
454      !
455      IF( numstp     /= -1 )   CLOSE( numstp     )   ! time-step file
456      IF( numnam_ref /= -1 )   CLOSE( numnam_ref )   ! oce reference namelist
457      IF( numnam_cfg /= -1 )   CLOSE( numnam_cfg )   ! oce configuration namelist
458      IF( numout     /=  6 )   CLOSE( numout     )   ! standard model output file
459      IF( lwm.AND.numond  /= -1 )   CLOSE( numond          )   ! oce output namelist
460      !
461      numout = 6                                     ! redefine numout in case it is used after this point...
462      !
463   END SUBROUTINE nemo_closefile
464
465
466   SUBROUTINE nemo_alloc
467      !!----------------------------------------------------------------------
468      !!                     ***  ROUTINE nemo_alloc  ***
469      !!
470      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
471      !!
472      !! ** Method  :
473      !!----------------------------------------------------------------------
474      USE diawri ,   ONLY : dia_wri_alloc
475      USE dom_oce,   ONLY : dom_oce_alloc
476      USE zdf_oce,   ONLY : zdf_oce_alloc
477      USE trc_oce,   ONLY : trc_oce_alloc
478      !
479      INTEGER :: ierr
480      !!----------------------------------------------------------------------
481      !
482      ierr =        oce_alloc    ()          ! ocean
483      ierr = ierr + dia_wri_alloc()
484      ierr = ierr + dom_oce_alloc()          ! ocean domain
485      ierr = ierr + zdf_oce_alloc()          ! ocean vertical physics
486      ierr = ierr + trc_oce_alloc()          ! shared TRC / TRA arrays
487      !
488      CALL mpp_sum( 'nemogcm', ierr )
489      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'nemo_alloc: unable to allocate standard ocean arrays' )
490      !
491   END SUBROUTINE nemo_alloc
492
493   SUBROUTINE nemo_set_cfctl(sn_cfctl, setto, for_all )
494      !!----------------------------------------------------------------------
495      !!                     ***  ROUTINE nemo_set_cfctl  ***
496      !!
497      !! ** Purpose :   Set elements of the output control structure to setto.
498      !!                for_all should be .false. unless all areas are to be
499      !!                treated identically.
500      !!
501      !! ** Method  :   Note this routine can be used to switch on/off some
502      !!                types of output for selected areas but any output types
503      !!                that involve global communications (e.g. mpp_max, glob_sum)
504      !!                should be protected from selective switching by the
505      !!                for_all argument
506      !!----------------------------------------------------------------------
507      LOGICAL :: setto, for_all
508      TYPE(sn_ctl) :: sn_cfctl
509      !!----------------------------------------------------------------------
510      IF( for_all ) THEN
511         sn_cfctl%l_runstat = setto
512         sn_cfctl%l_trcstat = setto
513      ENDIF
514      sn_cfctl%l_oceout  = setto
515      sn_cfctl%l_layout  = setto
516      sn_cfctl%l_mppout  = setto
517      sn_cfctl%l_mpptop  = setto
518   END SUBROUTINE nemo_set_cfctl
519
520   SUBROUTINE istate_init
521      !!----------------------------------------------------------------------
522      !!                   ***  ROUTINE istate_init  ***
523      !!
524      !! ** Purpose :   Initialization to zero of the dynamics and tracers.
525      !!----------------------------------------------------------------------
526      !
527      !     now fields         !     after fields      !
528      un   (:,:,:)   = 0._wp   ;   ua(:,:,:) = 0._wp   !
529      vn   (:,:,:)   = 0._wp   ;   va(:,:,:) = 0._wp   !
530      wn   (:,:,:)   = 0._wp   !                       !
531      hdivn(:,:,:)   = 0._wp   !                       !
532      tsn  (:,:,:,:) = 0._wp   !                       !
533      !
534      rhd  (:,:,:) = 0.e0
535      rhop (:,:,:) = 0.e0
536      rn2  (:,:,:) = 0.e0
537      !
538   END SUBROUTINE istate_init
539
540
541   SUBROUTINE stp_ctl( kt, kindic )
542      !!----------------------------------------------------------------------
543      !!                    ***  ROUTINE stp_ctl  ***
544      !!
545      !! ** Purpose :   Control the run
546      !!
547      !! ** Method  : - Save the time step in numstp
548      !!
549      !! ** Actions :   'time.step' file containing the last ocean time-step
550      !!----------------------------------------------------------------------
551      INTEGER, INTENT(in   ) ::   kt      ! ocean time-step index
552      INTEGER, INTENT(inout) ::   kindic  ! indicator of solver convergence
553      !!----------------------------------------------------------------------
554      !
555      IF( kt == nit000 .AND. lwm ) THEN
556         WRITE(numout,*)
557         WRITE(numout,*) 'stp_ctl : time-stepping control'
558         WRITE(numout,*) '~~~~~~~'
559         ! open time.step file
560         CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
561      ENDIF
562      !
563      IF(lwm) WRITE ( numstp, '(1x, i8)' )   kt      !* save the current time step in numstp
564      IF(lwm) REWIND( numstp )                       ! --------------------------
565      !
566   END SUBROUTINE stp_ctl
567   !!======================================================================
568END MODULE nemogcm
Note: See TracBrowser for help on using the repository browser.