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

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

Improve the merge TRA-TRC, see ticket:701

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