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.
opa.F90 in branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC – NEMO

source: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/opa.F90 @ 2435

Last change on this file since 2435 was 2435, checked in by cetlod, 13 years ago

Improve the 1D vertical configuration in v3.3beta

  • Property svn:keywords set to Id
File size: 22.0 KB
Line 
1MODULE opa
2   !!==============================================================================
3   !!                       ***  MODULE opa   ***
4   !! Ocean system   : OPA ocean dynamics (including on-line tracers and sea-ice)
5   !!==============================================================================
6   !! History :  OPA  ! 1990-10  (C. Levy, G. Madec)  Original code
7   !!            7.0  ! 1991-11  (M. Imbard, C. Levy, G. Madec)
8   !!            7.1  ! 1993-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar,
9   !!                             P. Delecluse, C. Perigaud, G. Caniaux, B. Colot, C. Maes) release 7.1
10   !!             -   ! 1992-06  (L.Terray)  coupling implementation
11   !!             -   ! 1993-11  (M.A. Filiberti) IGLOO sea-ice
12   !!            8.0  ! 1996-03  (M. Imbard, C. Levy, G. Madec, O. Marti, M. Guyon, A. Lazar,
13   !!                             P. Delecluse, L.Terray, M.A. Filiberti, J. Vialar, A.M. Treguier, M. Levy) release 8.0
14   !!            8.1  ! 1997-06  (M. Imbard, G. Madec)
15   !!            8.2  ! 1999-11  (M. Imbard, H. Goosse)  LIM sea-ice model
16   !!                 ! 1999-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP
17   !!                 ! 2000-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
18   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and modules
19   !!             -   ! 2004-06  (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces
20   !!             -   ! 2004-08  (C. Talandier) New trends organization
21   !!             -   ! 2005-06  (C. Ethe) Add the 1D configuration possibility
22   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
23   !!             -   ! 2006-03  (L. Debreu, C. Mazauric)  Agrif implementation
24   !!             -   ! 2006-04  (G. Madec, R. Benshila)  Step reorganization
25   !!             -   ! 2007-07  (J. Chanut, A. Sellar) Unstructured open boundaries (BDY)
26   !!            3.2  ! 2009-08  (S. Masson)  open/write in the listing file in mpp
27   !!            3.3  ! 2010-05  (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface
28   !!             -   ! 2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
29   !!----------------------------------------------------------------------
30
31   !!----------------------------------------------------------------------
32   !!   opa_model      : solve ocean dynamics, tracer and/or sea-ice
33   !!   opa_init       : initialization of the opa model
34   !!   opa_ctl        : initialisation of algorithm flag
35   !!   opa_closefile  : close remaining files
36   !!----------------------------------------------------------------------
37
38   USE step_oce        ! module used in the ocean time stepping module
39   USE sbc_oce         ! surface boundary condition: ocean
40   USE cla             ! cross land advection               (tra_cla routine)
41   USE domcfg          ! domain configuration               (dom_cfg routine)
42   USE mppini          ! shared/distributed memory setting (mpp_init routine)
43   USE domain          ! domain initialization             (dom_init routine)
44   USE obcini          ! open boundary cond. initialization (obc_ini routine)
45   USE bdyini          ! unstructured open boundary cond. initialization (bdy_init routine)
46   USE istate          ! initial state setting          (istate_init routine)
47   USE ldfdyn          ! lateral viscosity setting      (ldfdyn_init routine)
48   USE ldftra          ! lateral diffusivity setting    (ldftra_init routine)
49   USE zdfini          ! vertical physics setting          (zdf_init routine)
50   USE phycst          ! physical constant                  (par_cst routine)
51   USE trdmod          ! momentum/tracers trends       (trd_mod_init routine)
52   USE asminc          ! assimilation increments       (asm_inc_init routine)
53   USE asmtrj          ! writing out state trajectory
54   USE sshwzv          ! vertical velocity used in asm
55   USE diaptr          ! poleward transports           (dia_ptr_init routine)
56   USE diaobs          ! Observation diagnostics       (dia_obs_init routine)
57   USE step            ! OPA time-stepping                  (stp     routine)
58#if defined key_oasis3
59   USE cpl_oasis3      ! OASIS3 coupling
60#elif defined key_oasis4
61   USE cpl_oasis4      ! OASIS4 coupling (not working)
62#endif
63   USE c1d             ! 1D configuration
64   USE step_c1d        ! Time stepping loop for the 1D configuration
65#if defined key_top
66   USE trcini          ! passive tracer initialisation
67#endif
68   USE lib_mpp         ! distributed memory computing
69#if defined key_iomput
70   USE mod_ioclient
71#endif
72
73   PRIVATE
74
75   PUBLIC   opa_model   ! called by model.F90
76   PUBLIC   opa_init    ! needed by AGRIF
77
78   CHARACTER (len=64) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
79
80   !!----------------------------------------------------------------------
81   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
82   !! $Id$
83   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
84   !!----------------------------------------------------------------------
85CONTAINS
86
87   SUBROUTINE opa_model
88      !!----------------------------------------------------------------------
89      !!                     ***  ROUTINE opa  ***
90      !!
91      !! ** Purpose :   opa solves the primitive equations on an orthogonal
92      !!              curvilinear mesh on the sphere.
93      !!
94      !! ** Method  : - model general initialization
95      !!              - launch the time-stepping (stp routine)
96      !!              - finalize the run by closing files and communications
97      !!
98      !! References : Madec, Delecluse,Imbard, and Levy, 1997:  internal report, IPSL.
99      !!              Madec, 2008, internal report, IPSL.
100      !!----------------------------------------------------------------------
101      INTEGER ::   istp       ! time step index
102      !!----------------------------------------------------------------------
103      !
104#if defined key_agrif
105      CALL Agrif_Init_Grids()      ! AGRIF: set the meshes
106#endif
107
108      !                            !-----------------------!
109      CALL opa_init                !==  Initialisations  ==!
110      !                            !-----------------------!
111
112      ! check that all process are still there... If some process have an error,
113      ! they will never enter in step and other processes will wait until the end of the cpu time!
114      IF( lk_mpp )   CALL mpp_max( nstop )
115
116      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
117
118      !                            !-----------------------!
119      !                            !==   time stepping   ==!
120      !                            !-----------------------!
121      istp = nit000
122#if defined key_c1d
123         DO WHILE ( istp <= nitend .AND. nstop == 0 )
124            CALL stp_c1d( istp )
125            istp = istp + 1
126         END DO
127#else
128          IF( lk_asminc ) THEN
129             IF( ln_bkgwri ) CALL asm_bkg_wri( nit000 - 1 )    ! Output background fields
130             IF( ln_trjwri ) CALL asm_trj_wri( nit000 - 1 )    ! Output trajectory fields
131             IF( ln_asmdin ) THEN                        ! Direct initialization
132                IF( ln_trainc ) CALL tra_asm_inc( nit000 - 1 )    ! Tracers
133                IF( ln_dyninc ) THEN
134                   CALL dyn_asm_inc( nit000 - 1 )    ! Dynamics
135                   IF ( ln_asmdin ) CALL ssh_wzv ( nit000 - 1 )      ! update vertical velocity
136                ENDIF
137                IF( ln_sshinc ) CALL ssh_asm_inc( nit000 - 1 )    ! SSH
138             ENDIF
139          ENDIF
140       
141         DO WHILE ( istp <= nitend .AND. nstop == 0 )
142#if defined key_agrif
143            CALL Agrif_Step( stp )           ! AGRIF: time stepping
144#else
145            CALL stp( istp )                 ! standard time stepping
146#endif
147            istp = istp + 1
148            IF( lk_mpp )   CALL mpp_max( nstop )
149         END DO
150#endif
151
152      IF( lk_diaobs ) CALL dia_obs_wri
153       
154      !                            !------------------------!
155      !                            !==  finalize the run  ==!
156      !                            !------------------------!
157      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
158      !
159      IF( nstop /= 0 .AND. lwp ) THEN   ! error print
160         WRITE(numout,cform_err)
161         WRITE(numout,*) nstop, ' error have been found' 
162      ENDIF
163      !
164      CALL opa_closefile
165#if defined key_oasis3 || defined key_oasis4
166      CALL cpl_prism_finalize           ! end coupling and mpp communications with OASIS
167#else
168      IF( lk_mpp )   CALL mppstop       ! end mpp communications
169#endif
170      !
171   END SUBROUTINE opa_model
172
173
174   SUBROUTINE opa_init
175      !!----------------------------------------------------------------------
176      !!                     ***  ROUTINE opa_init  ***
177      !!
178      !! ** Purpose :   initialization of the opa model
179      !!
180      !!----------------------------------------------------------------------
181      INTEGER :: ilocal_comm
182      CHARACTER(len=80),dimension(10) ::   cltxt = ''
183      INTEGER                         ::   ji   ! local loop indices
184      !!
185      NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
186         &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle, nn_bench
187      !!----------------------------------------------------------------------
188      !
189      !                             ! open Namelist file
190      CALL ctl_opn( numnam, 'namelist', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
191      !
192      READ( numnam, namctl )        ! Namelist namctl : Control prints & Benchmark
193      !
194      !                             !--------------------------------------------!
195      !                             !  set communicator & select the local node  !
196      !                             !--------------------------------------------!
197#if defined key_iomput
198      IF( Agrif_Root() ) THEN
199# if defined key_oasis3 || defined key_oasis4
200         CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis
201# endif
202         CALL  init_ioclient( ilocal_comm )      ! exchange io_server nemo local communicator with the io_server
203      ENDIF
204      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection
205#else
206# if defined key_oasis3 || defined key_oasis4
207      IF( Agrif_Root() ) THEN
208         CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis
209      ENDIF
210      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection (control print return in cltxt)
211# else
212      ilocal_comm = 0
213      narea = mynode( cltxt )                 ! Nodes selection (control print return in cltxt)
214# endif
215#endif
216      narea = narea + 1                       ! mynode return the rank of proc (0 --> jpnij -1 )
217
218      lwp = (narea == 1) .OR. ln_ctl          ! control of all listing output print
219
220      IF(lwp) THEN                            ! open listing units
221         !
222         CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
223         !
224         WRITE(numout,*)
225         WRITE(numout,*) '         CNRS - NERC - Met OFFICE - MERCATOR-ocean'
226         WRITE(numout,*) '                       NEMO team'
227         WRITE(numout,*) '            Ocean General Circulation Model'
228         WRITE(numout,*) '                  version 3.3  (2010) '
229         WRITE(numout,*)
230         WRITE(numout,*)
231         DO ji = 1, SIZE(cltxt) 
232            IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) cltxt(ji)      ! control print of mynode
233         END DO
234         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
235         !
236      ENDIF
237      !                             !--------------------------------!
238      !                             !  Model general initialization  !
239      !                             !--------------------------------!
240
241      CALL opa_ctl                           ! Control prints & Benchmark
242
243      !                                      ! Domain decomposition
244      IF( jpni*jpnj == jpnij ) THEN   ;   CALL mpp_init      ! standard cutting out
245      ELSE                            ;   CALL mpp_init2     ! eliminate land processors
246      ENDIF
247      !
248      !                                      ! General initialization
249                            CALL     phy_cst    ! Physical constants
250                            CALL     eos_init   ! Equation of state
251                            CALL     dom_cfg    ! Domain configuration
252                            CALL     dom_init   ! Domain
253
254      IF( ln_ctl        )   CALL prt_ctl_init   ! Print control
255
256      IF( lk_obc        )   CALL     obc_init   ! Open boundaries
257      IF( lk_bdy        )   CALL     bdy_init   ! Unstructured open boundaries
258
259      IF( ln_zps        )   CALL zps_hde_init   ! Partial steps:  horizontal derivative
260                            CALL  istate_init   ! ocean initial state (Dynamics and tracers)
261
262      !                                     ! Ocean physics
263                            CALL     sbc_init   ! Forcings : surface module
264      !                                         ! Vertical physics
265                            CALL     zdf_init      ! namelist read
266                            CALL zdf_bfr_init      ! bottom friction
267      IF( lk_zdfric     )   CALL zdf_ric_init      ! Richardson number dependent Kz
268      IF( lk_zdftke     )   CALL zdf_tke_init      ! TKE closure scheme
269      IF( lk_zdfgls     )   CALL zdf_gls_init      ! GLS closure scheme
270      IF( lk_zdfkpp     )   CALL zdf_kpp_init      ! KPP closure scheme
271      IF( lk_zdftmx     )   CALL zdf_tmx_init      ! tidal vertical mixing
272      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   & 
273         &                  CALL zdf_ddm_init      ! double diffusive mixing
274      !                                         ! Lateral physics
275                            CALL ldf_tra_init      ! Lateral ocean tracer physics
276                            CALL ldf_dyn_init      ! Lateral ocean momentum physics
277      IF( lk_ldfslp     )   CALL ldf_slp_init      ! slope of lateral mixing
278
279      !                                     ! Active tracers
280                            CALL tra_qsr_init   ! penetrative solar radiation qsr
281                            CALL tra_bbc_init   ! bottom heat flux
282      IF( lk_trabbl     )   CALL tra_bbl_init   ! advective (and/or diffusive) bottom boundary layer scheme
283      IF( lk_tradmp     )   CALL tra_dmp_init   ! internal damping trends
284                            CALL tra_adv_init   ! horizontal & vertical advection
285                            CALL tra_ldf_init   ! lateral mixing
286                            CALL tra_zdf_init   ! vertical mixing and after tracer fields
287
288      !                                     ! Dynamics
289                            CALL dyn_adv_init   ! advection (vector or flux form)
290                            CALL dyn_vor_init   ! vorticity term including Coriolis
291                            CALL dyn_ldf_init   ! lateral mixing
292                            CALL dyn_hpg_init   ! horizontal gradient of Hydrostatic pressure
293                            CALL dyn_zdf_init   ! vertical diffusion
294                            CALL dyn_spg_init   ! surface pressure gradient
295                           
296      !                                     ! Misc. options
297      IF( nn_cla == 1   )   CALL cla_init       ! Cross Land Advection
298     
299#if defined key_top
300      !                                     ! Passive tracers
301                            CALL     trc_init
302#endif
303      !                                     ! Diagnostics
304                            CALL     iom_init   ! iom_put initialization
305      IF( lk_floats     )   CALL     flo_init   ! drifting Floats
306      IF( lk_diaar5     )   CALL dia_ar5_init   ! ar5 diag
307                            CALL dia_ptr_init   ! Poleward TRansports initialization
308                            CALL dia_hsb_init   ! heat content, salt content and volume budgets
309                            CALL trd_mod_init   ! Mixed-layer/Vorticity/Integral constraints trends
310      IF( lk_diaobs     ) THEN                  ! Observation & model comparison
311                            CALL dia_obs_init            ! Initialize observational data
312                            CALL dia_obs( nit000 - 1 )   ! Observation operator for restart
313      ENDIF     
314      !                                     ! Assimilation increments
315      IF( lk_asminc     )   CALL asm_inc_init   ! Initialize assimilation increments
316      IF(lwp) WRITE(numout,*) 'Euler time step switch is ', neuler
317      !
318   END SUBROUTINE opa_init
319
320
321   SUBROUTINE opa_ctl
322      !!----------------------------------------------------------------------
323      !!                     ***  ROUTINE opa  ***
324      !!
325      !! ** Purpose :   Initialise logical flags that control the choice of
326      !!              some algorithm or control print
327      !!
328      !! ** Method  : - print namctl information
329      !!              - Read in namilist namflg logical flags
330      !!----------------------------------------------------------------------
331      NAMELIST/namdyn_hpg/ ln_hpg_zco   , ln_hpg_zps   , ln_hpg_sco, ln_hpg_hel,   &
332         &                 ln_hpg_wdj   , ln_hpg_djc   , ln_hpg_rot, rn_gamma  ,   &
333         &                 ln_dynhpg_imp, nn_dynhpg_rst
334      !!----------------------------------------------------------------------
335
336      IF(lwp) THEN                 ! Parameter print
337         WRITE(numout,*)
338         WRITE(numout,*) 'opa_ctl: Control prints & Benchmark'
339         WRITE(numout,*) '~~~~~~~ '
340         WRITE(numout,*) '   Namelist namctl'
341         WRITE(numout,*) '      run control (for debugging)     ln_ctl     = ', ln_ctl
342         WRITE(numout,*) '      level of print                  nn_print   = ', nn_print
343         WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
344         WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
345         WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
346         WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
347         WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
348         WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
349         WRITE(numout,*) '      benchmark parameter (0/1)       nn_bench   = ', nn_bench
350      ENDIF
351
352      nprint    = nn_print          ! convert DOCTOR namelist names into OLD names
353      nictls    = nn_ictls
354      nictle    = nn_ictle
355      njctls    = nn_jctls
356      njctle    = nn_jctle
357      isplt     = nn_isplt
358      jsplt     = nn_jsplt
359      nbench    = nn_bench
360
361      !                           ! Parameter control
362      !
363      IF( ln_ctl ) THEN                 ! sub-domain area indices for the control prints
364         IF( lk_mpp ) THEN
365            isplt = jpni   ;   jsplt = jpnj   ;   ijsplt = jpni*jpnj   ! the domain is forced to the real splitted domain
366         ELSE
367            IF( isplt == 1 .AND. jsplt == 1  ) THEN
368               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
369                  &           ' - the print control will be done over the whole domain' )
370            ENDIF
371            ijsplt = isplt * jsplt            ! total number of processors ijsplt
372         ENDIF
373         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
374         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
375         !
376         !                              ! indices used for the SUM control
377         IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
378            lsp_area = .FALSE.                       
379         ELSE                                             ! print control done over a specific  area
380            lsp_area = .TRUE.
381            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
382               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
383               nictls = 1
384            ENDIF
385            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
386               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
387               nictle = jpiglo
388            ENDIF
389            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
390               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
391               njctls = 1
392            ENDIF
393            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
394               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
395               njctle = jpjglo
396            ENDIF
397         ENDIF
398      ENDIF
399
400      IF( nbench == 1 )   THEN            ! Benchmark
401         SELECT CASE ( cp_cfg )
402         CASE ( 'gyre' )   ;   CALL ctl_warn( ' The Benchmark is activated ' )
403         CASE DEFAULT      ;   CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:',   &
404            &                                 ' key_gyre must be used or set nbench = 0' )
405         END SELECT
406      ENDIF
407      !
408      IF( lk_c1d .AND. .NOT. lk_iomput )  &
409        CALL ctl_stop( ' The 1D vertical configuration must be used in conjunction',   &
410            &          ' with the IOM Input/Output manager. Compile with key_iomput enabled' )
411      !
412   END SUBROUTINE opa_ctl
413
414
415   SUBROUTINE opa_closefile
416      !!----------------------------------------------------------------------
417      !!                     ***  ROUTINE opa_closefile  ***
418      !!
419      !! ** Purpose :   Close the files
420      !!----------------------------------------------------------------------
421      !
422      IF( lk_mpp )   CALL mppsync
423      !
424      CALL iom_close                                 ! close all input/output files managed by iom_*
425      !
426      IF( numstp     /= -1 )   CLOSE( numstp     )   ! time-step file
427      IF( numsol     /= -1 )   CLOSE( numsol     )   ! solver file
428      IF( numnam     /= -1 )   CLOSE( numnam     )   ! oce namelist
429      IF( numnam_ice /= -1 )   CLOSE( numnam_ice )   ! ice namelist
430      IF( numevo_ice /= -1 )   CLOSE( numevo_ice )   ! ice variables (temp. evolution)
431      IF( numout     /=  6 )   CLOSE( numout     )   ! standard model output file
432      numout = 6   ! redefine numout in case it is used after this point...
433      !
434   END SUBROUTINE opa_closefile
435
436   !!======================================================================
437END MODULE opa
Note: See TracBrowser for help on using the repository browser.