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

source: trunk/NEMO/OPA_SRC/opa.F90 @ 1715

Last change on this file since 1715 was 1715, checked in by smasson, 14 years ago

move daymod public variables in dom_oce, see ticket:590

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