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

Last change on this file since 2083 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
RevLine 
[3]1MODULE opa
2   !!==============================================================================
3   !!                       ***  MODULE opa   ***
4   !! Ocean system   : OPA ocean dynamics (including on-line tracers and sea-ice)
5   !!==============================================================================
[1593]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
[2027]27   !!            3.3  ! 2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
[1593]28   !!----------------------------------------------------------------------
[3]29
30   !!----------------------------------------------------------------------
31   !!   opa_model      : solve ocean dynamics, tracer and/or sea-ice
[467]32   !!   opa_init       : initialization of the opa model
[3]33   !!   opa_flg        : initialisation of algorithm flag
[300]34   !!   opa_closefile  : close remaining files
[3]35   !!----------------------------------------------------------------------
[2027]36
37   USE step_oce        ! Time stepping module definition
[888]38   USE sbc_oce         ! surface boundary condition: ocean
[3]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)
[911]43   USE bdyini          ! unstructured open boundary cond. initialization (bdy_init routine)
[3]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)
[532]50#if defined key_oasis3
[1359]51   USE cpl_oasis3      ! OASIS3 coupling
[599]52#elif defined key_oasis4
[1359]53   USE cpl_oasis4      ! OASIS4 coupling (not working)
[532]54#endif
[900]55   USE c1d             ! 1D configuration
56   USE step_c1d        ! Time stepping loop for the 1D configuration
[1594]57#if defined key_top
[1593]58   USE trcini          ! passive tracer initialisation
[1594]59#endif
[2027]60
[1593]61   USE lib_mpp         ! distributed memory computing
[1412]62#if defined key_iomput
63   USE mod_ioclient
[1359]64#endif
[268]65
[3]66   PRIVATE
67
[1593]68   PUBLIC   opa_model   ! called by model.F90
69   PUBLIC   opa_init    ! needed by AGRIF
[467]70
[1593]71   CHARACTER (len=64) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
72
[3]73   !!----------------------------------------------------------------------
[1593]74   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)
[888]75   !! $Id$
[467]76   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
[3]77   !!----------------------------------------------------------------------
78
79CONTAINS
80
81   SUBROUTINE opa_model
82      !!----------------------------------------------------------------------
83      !!                     ***  ROUTINE opa  ***
84      !!
85      !! ** Purpose :   opa solves the primitive equations on an orthogonal
[1593]86      !!              curvilinear mesh on the sphere.
[3]87      !!
88      !! ** Method  : - model general initialization
89      !!              - launch the time-stepping (stp routine)
[1593]90      !!              - finalize the run by closing files and communications
[3]91      !!
[1593]92      !! References : Madec, Delecluse,Imbard, and Levy, 1997:  internal report, IPSL.
93      !!              Madec, 2008, internal report, IPSL.
[3]94      !!----------------------------------------------------------------------
95      INTEGER ::   istp       ! time step index
[389]96      !!----------------------------------------------------------------------
97
[392]98#if defined key_agrif
[1593]99      CALL Agrif_Init_Grids()      ! AGRIF: set the meshes
[389]100#endif
101
[1593]102      !                            !-----------------------!
103      CALL opa_init                !==  Initialisations  ==!
104      !                            !-----------------------!
105
[682]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!
[900]108      IF( lk_mpp )   CALL mpp_max( nstop )
[682]109
[1593]110      IF(lwp) WRITE(numout,cform_aaa)   ! Flag AAAAAAA
111
112      !                            !-----------------------!
113      !                            !==   time stepping   ==!
114      !                            !-----------------------!
[900]115      istp = nit000
[1593]116      IF( lk_c1d ) THEN                 !==  1D configuration  ==!
[389]117         DO WHILE ( istp <= nitend .AND. nstop == 0 )
[900]118            CALL stp_c1d( istp )
[389]119            istp = istp + 1
120         END DO
[1593]121      ELSE                              !==  3D ocean with  ==!
[389]122         DO WHILE ( istp <= nitend .AND. nstop == 0 )
[392]123#if defined key_agrif
[1593]124            CALL Agrif_Step( stp )           ! AGRIF: time stepping
[389]125#else
[1593]126            CALL stp( istp )                 ! standard time stepping
[389]127#endif
128            istp = istp + 1
[900]129            IF( lk_mpp )   CALL mpp_max( nstop )
[389]130         END DO
131      ENDIF
[1593]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
[682]139         WRITE(numout,cform_err)
140         WRITE(numout,*) nstop, ' error have been found' 
[389]141      ENDIF
[1593]142      !
[389]143      CALL opa_closefile
[532]144#if defined key_oasis3 || defined key_oasis4
[1976]145      CALL cpl_prism_finalize           ! end coupling and mpp communications with OASIS
[532]146#else
[1593]147      IF( lk_mpp )   CALL mppstop       ! end mpp communications
[532]148#endif
[900]149      !
[389]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      !!----------------------------------------------------------------------
[1593]160      INTEGER :: ilocal_comm
[1581]161      CHARACTER(len=80),dimension(10) ::   cltxt = ''
[1593]162      INTEGER                         ::   ji   ! local loop indices
163      !!
[1601]164      NAMELIST/namctl/ ln_ctl  , nn_print, nn_ictls, nn_ictle,   &
[1976]165         &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle, nn_bench
[3]166      !!----------------------------------------------------------------------
[1593]167      !
168      !                             ! open Namelist file
[1581]169      CALL ctl_opn( numnam, 'namelist', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE. )
[1593]170      !
171      READ( numnam, namctl )        ! Namelist namctl : Control prints & Benchmark
172      !
173      !                             !--------------------------------------------!
174      !                             !  set communicator & select the local node  !
175      !                             !--------------------------------------------!
[1412]176#if defined key_iomput
177# if defined key_oasis3 || defined key_oasis4
[1976]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)
[1412]180# else
[1976]181      CALL init_ioclient( ilocal_comm )       ! nemo local communicator (used or not) given by the io_server
[1412]182# endif
[1593]183      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection
184
[532]185#else
[1412]186# if defined key_oasis3 || defined key_oasis4
[1976]187      CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis
[1593]188      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection (control print return in cltxt)
[1412]189# else
[2082]190      ilocal_comm = 0
[1593]191      narea = mynode( cltxt )                 ! Nodes selection (control print return in cltxt)
[1412]192# endif
[532]193#endif
[1593]194      narea = narea + 1                       ! mynode return the rank of proc (0 --> jpnij -1 )
[3]195
[1593]196      lwp = (narea == 1) .OR. ln_ctl          ! control of all listing output print
[1579]197
[1593]198      IF(lwp) THEN                            ! open listing units
199         !
[1581]200         CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
[1593]201         !
[1579]202         WRITE(numout,*)
[1593]203         WRITE(numout,*) '         CNRS - NERC - Met OFFICE - MERCATOR-ocean'
204         WRITE(numout,*) '                       NEMO team'
[1579]205         WRITE(numout,*) '            Ocean General Circulation Model'
[1593]206         WRITE(numout,*) '                  version 3.2  (2009) '
[1579]207         WRITE(numout,*)
208         WRITE(numout,*)
[1593]209         DO ji = 1, SIZE(cltxt) 
210            IF( TRIM(cltxt(ji)) /= '' )   WRITE(numout,*) cltxt(ji)      ! control print of mynode
[1579]211         END DO
[1593]212         WRITE(numout,cform_aaa)                                         ! Flag AAAAAAA
213         !
[473]214      ENDIF
[1593]215      !                             !--------------------------------!
216      !                             !  Model general initialization  !
217      !                             !--------------------------------!
[473]218
[2082]219      CALL opa_flg                           ! Control prints & Benchmark
[531]220
[2082]221      !                                      ! Domain decomposition
[1593]222      IF( jpni*jpnj == jpnij ) THEN   ;   CALL mpp_init      ! standard cutting out
223      ELSE                            ;   CALL mpp_init2     ! eliminate land processors
[3]224      ENDIF
[2027]225 
[258]226
[3]227
[2027]228     
[253]229
[2082]230      !                                      ! General initialization
[2027]231                            CALL     phy_cst    ! Physical constants
232                            CALL     eos_init   ! Equation of state
233                            CALL     dom_cfg    ! Domain configuration
234                            CALL     dom_init   ! Domain
[413]235
[2027]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
[3]244      !                                     ! Ocean physics
[2082]245                            CALL     sbc_init   !  Forcings : surface module
[3]246
[2082]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
[2027]255      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   & 
[2082]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
[2027]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
[1594]279#if defined key_top
[2027]280      !                                     ! Passive tracers
[2082]281                            CALL     trc_init
[1594]282#endif
[1593]283      !                                     ! diagnostics
[2027]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
[1593]289      !
[389]290   END SUBROUTINE opa_init
[467]291
292
293   SUBROUTINE opa_flg
294      !!----------------------------------------------------------------------
295      !!                     ***  ROUTINE opa  ***
296      !!
[1593]297      !! ** Purpose :   Initialise logical flags that control the choice of
298      !!              some algorithm or control print
[467]299      !!
[1593]300      !! ** Method  : - print namctl information
301      !!              - Read in namilist namflg logical flags
[467]302      !!----------------------------------------------------------------------
[1601]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
[467]306      !!----------------------------------------------------------------------
307
[1601]308      IF(lwp) THEN                 ! Parameter print
[531]309         WRITE(numout,*)
310         WRITE(numout,*) 'opa_flg: Control prints & Benchmark'
311         WRITE(numout,*) '~~~~~~~ '
[1593]312         WRITE(numout,*) '   Namelist namctl'
[1601]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
[531]322      ENDIF
323
[1601]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
[1593]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
[531]338         ELSE
339            IF( isplt == 1 .AND. jsplt == 1  ) THEN
[1593]340               CALL ctl_warn( ' - isplt & jsplt are equal to 1',   &
341                  &           ' - the print control will be done over the whole domain' )
[531]342            ENDIF
[1593]343            ijsplt = isplt * jsplt            ! total number of processors ijsplt
[531]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
[1593]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
[531]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
[1593]369         ENDIF
370      ENDIF
[531]371
[1593]372      IF( nbench == 1 )   THEN            ! Benchmark
[531]373         SELECT CASE ( cp_cfg )
[1593]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' )
[531]377         END SELECT
378      ENDIF
379
[1601]380      REWIND( numnam )              ! Read Namelist namdyn_hpg : ln_dynhpg_imp must be read at the initialisation phase
381      READ  ( numnam, namdyn_hpg )
[1593]382      !
[467]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      !!----------------------------------------------------------------------
[1593]395      !
396      IF( lk_mpp )   CALL mppsync
397      !
[1685]398      CALL iom_close                                 ! close all input/output files managed by iom_*
[1593]399      !
[1685]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...
[1593]407      !
[467]408   END SUBROUTINE opa_closefile
409
[3]410   !!======================================================================
411END MODULE opa
Note: See TracBrowser for help on using the repository browser.