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

source: branches/TAM_V3_2_2/NEMO/OPA_SRC/opa.F90 @ 3393

Last change on this file since 3393 was 2578, checked in by rblod, 13 years ago

first import of NEMOTAM 3.2.2

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