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/DEV_r2006_merge_TRA_TRC/NEMO/OPA_SRC – NEMO

source: branches/DEV_r2006_merge_TRA_TRC/NEMO/OPA_SRC/opa.F90 @ 2082

Last change on this file since 2082 was 2082, checked in by cetlod, 14 years ago

Improve the merge of TRA-TRC, see ticket #717

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 20.3 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-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
28   !!----------------------------------------------------------------------
29
30   !!----------------------------------------------------------------------
31   !!   opa_model      : solve ocean dynamics, tracer and/or sea-ice
32   !!   opa_init       : initialization of the opa model
33   !!   opa_flg        : initialisation of algorithm flag
34   !!   opa_closefile  : close remaining files
35   !!----------------------------------------------------------------------
36
37   USE step_oce        ! Time stepping module definition
38   USE sbc_oce         ! surface boundary condition: ocean
39   USE domcfg          ! domain configuration               (dom_cfg routine)
40   USE mppini          ! shared/distributed memory setting (mpp_init routine)
41   USE domain          ! domain initialization             (dom_init routine)
42   USE obcini          ! open boundary cond. initialization (obc_ini routine)
43   USE bdyini          ! unstructured open boundary cond. initialization (bdy_init routine)
44   USE istate          ! initial state setting          (istate_init routine)
45   USE ldfdyn          ! lateral viscosity setting      (ldfdyn_init routine)
46   USE ldftra          ! lateral diffusivity setting    (ldftra_init routine)
47   USE zdfini
48   USE phycst          ! physical constant                  (par_cst routine)
49   USE step            ! OPA time-stepping                  (stp     routine)
50#if defined key_oasis3
51   USE cpl_oasis3      ! OASIS3 coupling
52#elif defined key_oasis4
53   USE cpl_oasis4      ! OASIS4 coupling (not working)
54#endif
55   USE c1d             ! 1D configuration
56   USE step_c1d        ! Time stepping loop for the 1D configuration
57#if defined key_top
58   USE trcini          ! passive tracer initialisation
59#endif
60
61   USE lib_mpp         ! distributed memory computing
62#if defined key_iomput
63   USE mod_ioclient
64#endif
65
66   PRIVATE
67
68   PUBLIC   opa_model   ! called by model.F90
69   PUBLIC   opa_init    ! needed by AGRIF
70
71   CHARACTER (len=64) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
72
73   !!----------------------------------------------------------------------
74   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
75   !! $Id$
76   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
77   !!----------------------------------------------------------------------
78
79CONTAINS
80
81   SUBROUTINE opa_model
82      !!----------------------------------------------------------------------
83      !!                     ***  ROUTINE opa  ***
84      !!
85      !! ** Purpose :   opa solves the primitive equations on an orthogonal
86      !!              curvilinear mesh on the sphere.
87      !!
88      !! ** Method  : - model general initialization
89      !!              - launch the time-stepping (stp routine)
90      !!              - finalize the run by closing files and communications
91      !!
92      !! References : Madec, Delecluse,Imbard, and Levy, 1997:  internal report, IPSL.
93      !!              Madec, 2008, internal report, IPSL.
94      !!----------------------------------------------------------------------
95      INTEGER ::   istp       ! time step index
96      !!----------------------------------------------------------------------
97
98#if defined key_agrif
99      CALL Agrif_Init_Grids()      ! AGRIF: set the meshes
100#endif
101
102      !                            !-----------------------!
103      CALL opa_init                !==  Initialisations  ==!
104      !                            !-----------------------!
105
106      ! check that all process are still there... If some process have an error,
107      ! they will never enter in step and other processes will wait until the end of the cpu time!
108      IF( lk_mpp )   CALL mpp_max( nstop )
109
110      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
111
112      !                            !-----------------------!
113      !                            !==   time stepping   ==!
114      !                            !-----------------------!
115      istp = nit000
116      IF( lk_c1d ) THEN                 !==  1D configuration  ==!
117         DO WHILE ( istp <= nitend .AND. nstop == 0 )
118            CALL stp_c1d( istp )
119            istp = istp + 1
120         END DO
121      ELSE                              !==  3D ocean with  ==!
122         DO WHILE ( istp <= nitend .AND. nstop == 0 )
123#if defined key_agrif
124            CALL Agrif_Step( stp )           ! AGRIF: time stepping
125#else
126            CALL stp( istp )                 ! standard time stepping
127#endif
128            istp = istp + 1
129            IF( lk_mpp )   CALL mpp_max( nstop )
130         END DO
131      ENDIF
132       
133      !                            !------------------------!
134      !                            !==  finalize the run  ==!
135      !                            !------------------------!
136      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
137      !
138      IF( nstop /= 0 .AND. lwp ) THEN   ! error print
139         WRITE(numout,cform_err)
140         WRITE(numout,*) nstop, ' error have been found' 
141      ENDIF
142      !
143      CALL opa_closefile
144#if defined key_oasis3 || defined key_oasis4
145      CALL cpl_prism_finalize           ! end coupling and mpp communications with OASIS
146#else
147      IF( lk_mpp )   CALL mppstop       ! end mpp communications
148#endif
149      !
150   END SUBROUTINE opa_model
151
152
153   SUBROUTINE opa_init
154      !!----------------------------------------------------------------------
155      !!                     ***  ROUTINE opa_init  ***
156      !!
157      !! ** Purpose :   initialization of the opa model
158      !!
159      !!----------------------------------------------------------------------
160      INTEGER :: ilocal_comm
161      CHARACTER(len=80),dimension(10) ::   cltxt = ''
162      INTEGER                         ::   ji   ! local loop indices
163      !!
164      NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
165         &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle, nn_bench
166      !!----------------------------------------------------------------------
167      !
168      !                             ! open Namelist file
169      CALL ctl_opn( numnam, 'namelist', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
170      !
171      READ( numnam, namctl )        ! Namelist namctl : Control prints & Benchmark
172      !
173      !                             !--------------------------------------------!
174      !                             !  set communicator & select the local node  !
175      !                             !--------------------------------------------!
176#if defined key_iomput
177# if defined key_oasis3 || defined key_oasis4
178      CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis
179      CALL init_ioclient()                    ! io_server will get its communicators (if needed) from oasis (we don't see it)
180# else
181      CALL init_ioclient( ilocal_comm )       ! nemo local communicator (used or not) given by the io_server
182# endif
183      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection
184
185#else
186# if defined key_oasis3 || defined key_oasis4
187      CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis
188      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection (control print return in cltxt)
189# else
190      ilocal_comm = 0
191      narea = mynode( cltxt )                 ! Nodes selection (control print return in cltxt)
192# endif
193#endif
194      narea = narea + 1                       ! mynode return the rank of proc (0 --> jpnij -1 )
195
196      lwp = (narea == 1) .OR. ln_ctl          ! control of all listing output print
197
198      IF(lwp) THEN                            ! open listing units
199         !
200         CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
201         !
202         WRITE(numout,*)
203         WRITE(numout,*) '         CNRS - NERC - Met OFFICE - MERCATOR-ocean'
204         WRITE(numout,*) '                       NEMO team'
205         WRITE(numout,*) '            Ocean General Circulation Model'
206         WRITE(numout,*) '                  version 3.2  (2009) '
207         WRITE(numout,*)
208         WRITE(numout,*)
209         DO ji = 1, SIZE(cltxt) 
210            IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) cltxt(ji)      ! control print of mynode
211         END DO
212         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
213         !
214      ENDIF
215      !                             !--------------------------------!
216      !                             !  Model general initialization  !
217      !                             !--------------------------------!
218
219      CALL opa_flg                           ! Control prints & Benchmark
220
221      !                                      ! Domain decomposition
222      IF( jpni*jpnj == jpnij ) THEN   ;   CALL mpp_init      ! standard cutting out
223      ELSE                            ;   CALL mpp_init2     ! eliminate land processors
224      ENDIF
225 
226
227
228     
229
230      !                                      ! General initialization
231                            CALL     phy_cst    ! Physical constants
232                            CALL     eos_init   ! Equation of state
233                            CALL     dom_cfg    ! Domain configuration
234                            CALL     dom_init   ! Domain
235
236      IF( ln_ctl        )   CALL prt_ctl_init   ! Print control
237
238      IF( lk_obc        )   CALL     obc_init   ! Open boundaries
239      IF( lk_bdy        )   CALL     bdy_init   ! Unstructured open boundaries
240
241      IF( ln_zps        )   CALL zps_hde_init   ! Partial steps:  horizontal derivative
242                            CALL  istate_init   ! ocean initial state (Dynamics and tracers)
243
244      !                                     ! Ocean physics
245                            CALL     sbc_init   !  Forcings : surface module
246
247      !                                         ! Vertical physics
248                            CALL     zdf_init      ! namelist read
249                            CALL zdf_bfr_init      ! bottom friction
250      IF( lk_zdfric     )   CALL zdf_ric_init      ! Richardson number dependent Kz
251      IF( lk_zdftke_old )   CALL zdf_tke_init      ! TKE closure scheme for Kz (old scheme)
252      IF( lk_zdftke     )   CALL     tke_init      ! TKE closure scheme for Kz
253      IF( lk_zdfkpp     )   CALL zdf_kpp_init      ! KPP closure scheme for Kz
254      IF( lk_zdftmx     )   CALL zdf_tmx_init      ! tidal vertical mixing
255      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   & 
256         &                  CALL zdf_ddm_init      ! double diffusive mixing
257      !                                         ! Lateral physics
258                            CALL ldf_tra_init      ! Lateral ocean tracer physics
259                            CALL ldf_dyn_init      ! Lateral ocean momentum physics
260      IF( lk_ldfslp )       CALL ldf_slp_init      ! slope of lateral mixing
261
262      !                                     ! Active tracers
263                            CALL tra_qsr_init   ! penetrative solar radiation qsr
264      IF( lk_trabbc     )   CALL tra_bbc_init   ! bottom heat flux
265      IF( lk_trabbl     )   CALL tra_bbl_init   ! advective (and/or diffusive) bottom boundary layer scheme
266      IF( lk_tradmp     )   CALL tra_dmp_init   ! internal damping trends
267                            CALL tra_adv_init   ! horizontal & vertical advection
268      IF( n_cla == 1    )   CALL tra_cla_init   ! Cross Land Advection (Update Hor. advection)
269                            CALL tra_ldf_init   ! lateral mixing
270                            CALL tra_zdf_init   ! vertical mixing and after tracer fields
271
272      !                                     ! Dynamics
273                            CALL dyn_adv_init   ! advection (vector or flux form)
274                            CALL     vor_init   ! vorticity term including Coriolis
275                            CALL dyn_ldf_init   ! lateral mixing
276                            CALL     hpg_init   ! horizontal gradient of Hydrostatic pressure
277                            CALL dyn_zdf_init   ! vertical diffusion
278                            CALL dyn_spg_init   ! surface pressure gradient
279#if defined key_top
280      !                                     ! Passive tracers
281                            CALL     trc_init
282#endif
283      !                                     ! diagnostics
284                            CALL     iom_init   ! iom_put initialization
285      IF( lk_floats    )    CALL     flo_init   ! drifting Floats
286      IF( lk_diaar5    )    CALL dia_ar5_init   ! ar5 diag
287                            CALL dia_ptr_init   ! Poleward TRansports initialization
288                            CALL trd_mod_init   ! Mixed-layer/Vorticity/Integral constraints trends
289      !
290   END SUBROUTINE opa_init
291
292
293   SUBROUTINE opa_flg
294      !!----------------------------------------------------------------------
295      !!                     ***  ROUTINE opa  ***
296      !!
297      !! ** Purpose :   Initialise logical flags that control the choice of
298      !!              some algorithm or control print
299      !!
300      !! ** Method  : - print namctl information
301      !!              - Read in namilist namflg logical flags
302      !!----------------------------------------------------------------------
303      NAMELIST/namdyn_hpg/ ln_hpg_zco   , ln_hpg_zps   , ln_hpg_sco, ln_hpg_hel,   &
304         &                 ln_hpg_wdj   , ln_hpg_djc   , ln_hpg_rot, rn_gamma  ,   &
305         &                 ln_dynhpg_imp, nn_dynhpg_rst
306      !!----------------------------------------------------------------------
307
308      IF(lwp) THEN                 ! Parameter print
309         WRITE(numout,*)
310         WRITE(numout,*) 'opa_flg: Control prints & Benchmark'
311         WRITE(numout,*) '~~~~~~~ '
312         WRITE(numout,*) '   Namelist namctl'
313         WRITE(numout,*) '      run control (for debugging)     ln_ctl     = ', ln_ctl
314         WRITE(numout,*) '      level of print                  nn_print   = ', nn_print
315         WRITE(numout,*) '      Start i indice for SUM control  nn_ictls   = ', nn_ictls
316         WRITE(numout,*) '      End i indice for SUM control    nn_ictle   = ', nn_ictle
317         WRITE(numout,*) '      Start j indice for SUM control  nn_jctls   = ', nn_jctls
318         WRITE(numout,*) '      End j indice for SUM control    nn_jctle   = ', nn_jctle
319         WRITE(numout,*) '      number of proc. following i     nn_isplt   = ', nn_isplt
320         WRITE(numout,*) '      number of proc. following j     nn_jsplt   = ', nn_jsplt
321         WRITE(numout,*) '      benchmark parameter (0/1)       nn_bench   = ', nn_bench
322      ENDIF
323
324      nprint    = nn_print          ! convert DOCTOR namelist names into OLD names
325      nictls    = nn_ictls
326      nictle    = nn_ictle
327      njctls    = nn_jctls
328      njctle    = nn_jctle
329      isplt     = nn_isplt
330      jsplt     = nn_jsplt
331      nbench    = nn_bench
332
333      !                           ! Parameter control
334      !
335      IF( ln_ctl ) THEN                 ! sub-domain area indices for the control prints
336         IF( lk_mpp ) THEN
337            isplt = jpni   ;   jsplt = jpnj   ;   ijsplt = jpni*jpnj   ! the domain is forced to the real splitted domain
338         ELSE
339            IF( isplt == 1 .AND. jsplt == 1  ) THEN
340               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
341                  &           ' - the print control will be done over the whole domain' )
342            ENDIF
343            ijsplt = isplt * jsplt            ! total number of processors ijsplt
344         ENDIF
345         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
346         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
347         !
348         !                              ! indices used for the SUM control
349         IF( nictls+nictle+njctls+njctle == 0 )   THEN    ! print control done over the default area
350            lsp_area = .FALSE.                       
351         ELSE                                             ! print control done over a specific  area
352            lsp_area = .TRUE.
353            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
354               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
355               nictls = 1
356            ENDIF
357            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
358               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
359               nictle = jpiglo
360            ENDIF
361            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
362               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
363               njctls = 1
364            ENDIF
365            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
366               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
367               njctle = jpjglo
368            ENDIF
369         ENDIF
370      ENDIF
371
372      IF( nbench == 1 )   THEN            ! Benchmark
373         SELECT CASE ( cp_cfg )
374         CASE ( 'gyre' )   ;   CALL ctl_warn( ' The Benchmark is activated ' )
375         CASE DEFAULT      ;   CALL ctl_stop( ' The Benchmark is based on the GYRE configuration:',   &
376            &                                 ' key_gyre must be used or set nbench = 0' )
377         END SELECT
378      ENDIF
379
380      REWIND( numnam )              ! Read Namelist namdyn_hpg : ln_dynhpg_imp must be read at the initialisation phase
381      READ  ( numnam, namdyn_hpg )
382      !
383   END SUBROUTINE opa_flg
384
385
386   SUBROUTINE opa_closefile
387      !!----------------------------------------------------------------------
388      !!                     ***  ROUTINE opa_closefile  ***
389      !!
390      !! ** Purpose :   Close the files
391      !!----------------------------------------------------------------------
392      USE dtatem        ! temperature data
393      USE dtasal        ! salinity data
394      !!----------------------------------------------------------------------
395      !
396      IF( lk_mpp )   CALL mppsync
397      !
398      CALL iom_close                                 ! close all input/output files managed by iom_*
399      !
400      IF( numstp     /= -1 )   CLOSE( numstp     )   ! time-step file
401      IF( numsol     /= -1 )   CLOSE( numsol     )   ! solver file
402      IF( numnam     /= -1 )   CLOSE( numnam     )   ! oce namelist
403      IF( numnam_ice /= -1 )   CLOSE( numnam_ice )   ! ice namelist
404      IF( numevo_ice /= -1 )   CLOSE( numevo_ice )   ! ice variables (temp. evolution)
405      IF( numout     /=  6 )   CLOSE( numout     )   ! standard model output file
406      numout = 6   ! redefine numout in case it is used after this point...
407      !
408   END SUBROUTINE opa_closefile
409
410   !!======================================================================
411END MODULE opa
Note: See TracBrowser for help on using the repository browser.