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

Last change on this file since 1226 was 1226, checked in by smasson, 15 years ago

bugfix of the coupling interface (commited during changeset:1218), see ticket:155

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 18.3 KB
Line 
1MODULE opa
2   !!==============================================================================
3   !!                       ***  MODULE opa   ***
4   !! Ocean system   : OPA ocean dynamics (including on-line tracers and sea-ice)
5   !!==============================================================================
6
7   !!----------------------------------------------------------------------
8   !!   opa_model      : solve ocean dynamics, tracer and/or sea-ice
9   !!   opa_init       : initialization of the opa model
10   !!   opa_flg        : initialisation of algorithm flag
11   !!   opa_closefile  : close remaining files
12   !!----------------------------------------------------------------------
13   !! History :
14   !!   4.0  !  90-10  (C. Levy, G. Madec)  Original code
15   !!   7.0  !  91-11  (M. Imbard, C. Levy, G. Madec)
16   !!   7.1  !  93-03  (M. Imbard, C. Levy, G. Madec, O. Marti,
17   !!                   M. Guyon, A. Lazar, P. Delecluse, C. Perigaud,
18   !!                   G. Caniaux, B. Colot, C. Maes ) release 7.1
19   !!        !  92-06  (L.Terray) coupling implementation
20   !!        !  93-11  (M.A. Filiberti) IGLOO sea-ice
21   !!   8.0  !  96-03  (M. Imbard, C. Levy, G. Madec, O. Marti,
22   !!                   M. Guyon, A. Lazar, P. Delecluse, L.Terray,
23   !!                   M.A. Filiberti, J. Vialar, A.M. Treguier,
24   !!                   M. Levy)  release 8.0
25   !!   8.1  !  97-06  (M. Imbard, G. Madec)
26   !!   8.2  !  99-11  (M. Imbard, H. Goosse)  LIM sea-ice model
27   !!        !  99-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP
28   !!        !  00-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
29   !!   9.0  !  02-08  (G. Madec)  F90: Free form and modules
30   !!    "   !  04-06  (R. Redler, NEC CCRLE, Germany) add OASIS[3/4] coupled interfaces
31   !!    "   !  04-08  (C. Talandier) New trends organization
32   !!    "   !  05-06  (C. Ethe) Add the 1D configuration possibility
33   !!    "   !  05-11  (V. Garnier) Surface pressure gradient organization
34   !!    "   !  06-03  (L. Debreu, C. Mazauric)  Agrif implementation
35   !!    "   !  06-04  (G. Madec, R. Benshila)  Step reorganization
36   !!    "   !  07-07  (J. Chanut, A. Sellar) Unstructured open boundaries (BDY)
37   !!----------------------------------------------------------------------
38   !! * Modules used
39   USE oce             ! dynamics and tracers variables
40   USE dom_oce         ! ocean space domain variables
41   USE sbc_oce         ! surface boundary condition: ocean
42   USE trdmod_oce      ! ocean variables trends
43   USE daymod          ! calendar
44   USE in_out_manager  ! I/O manager
45   USE lib_mpp         ! distributed memory computing
46
47   USE domcfg          ! domain configuration               (dom_cfg routine)
48   USE mppini          ! shared/distributed memory setting (mpp_init routine)
49   USE domain          ! domain initialization             (dom_init routine)
50   USE obc_par         ! open boundary cond. parameters
51   USE obcini          ! open boundary cond. initialization (obc_ini routine)
52   USE bdy_par         ! unstructured open boundary cond. parameters
53   USE bdyini          ! unstructured open boundary cond. initialization (bdy_init routine)
54   USE istate          ! initial state setting          (istate_init routine)
55   USE eosbn2          ! equation of state            (eos bn2 routine)
56   USE zpshde          ! partial step: hor. derivative (zps_hde routine)
57
58   ! ocean physics
59   USE ldfdyn          ! lateral viscosity setting      (ldfdyn_init routine)
60   USE ldftra          ! lateral diffusivity setting    (ldftra_init routine)
61   USE zdfini
62
63   USE phycst          ! physical constant                  (par_cst routine)
64   USE trdmod          ! momentum/tracers trends       (trd_mod_init routine)
65
66   USE diaptr          ! poleward transports           (dia_ptr_init routine)
67
68   USE step            ! OPA time-stepping                  (stp     routine)
69#if defined key_oasis3
70   USE cpl_oasis3      ! OASIS3 coupling (to ECHAM5)
71#elif defined key_oasis4
72   USE cpl_oasis4      ! OASIS4 coupling (to ECHAM5)
73#endif
74   USE dynspg_oce      ! Control choice of surface pressure gradient schemes
75   USE prtctl          ! Print control                 (prt_ctl_init routine)
76   USE c1d             ! 1D configuration
77   USE dyncor_c1d      ! Coriolis factor at T-point
78   USE step_c1d        ! Time stepping loop for the 1D configuration
79
80   USE trcini          ! Initialization of the passive tracers
81
82   IMPLICIT NONE
83   PRIVATE
84
85   !! * Module variables
86   CHARACTER (len=64) ::        &
87      cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
88
89   !! * Routine accessibility
90   PUBLIC opa_model      ! called by model.F90
91   PUBLIC opa_init
92   !!----------------------------------------------------------------------
93   !!  OPA 9.0 , LOCEAN-IPSL (2005)
94   !! $Id$
95   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
96   !!----------------------------------------------------------------------
97
98CONTAINS
99
100   SUBROUTINE opa_model
101      !!----------------------------------------------------------------------
102      !!                     ***  ROUTINE opa  ***
103      !!
104      !! ** Purpose :   opa solves the primitive equations on an orthogonal
105      !!      curvilinear mesh on the sphere.
106      !!
107      !! ** Method  : - model general initialization
108      !!              - launch the time-stepping (stp routine)
109      !!
110      !! References :
111      !!      Madec, Delecluse,Imbard, and Levy, 1997: reference manual.
112      !!              internal report, IPSL.
113      !!----------------------------------------------------------------------
114      INTEGER ::   istp       ! time step index
115      !!----------------------------------------------------------------------
116
117#if defined key_agrif
118      CALL Agrif_Init_Grids()
119#endif
120     
121      CALL opa_init  ! Initializations
122
123      ! check that all process are still there... If some process have an error,
124      ! they will never enter in step and other processes will wait until the end of the cpu time!
125      IF( lk_mpp )   CALL mpp_max( nstop )
126
127      istp = nit000
128      IF( lk_c1d ) THEN                 ! 1D configuration (no AGRIF zoom)
129         !
130         DO WHILE ( istp <= nitend .AND. nstop == 0 )
131            CALL stp_c1d( istp )
132            istp = istp + 1
133         END DO
134      ELSE                              ! 3D ocean with or without AGRIF zoom
135         !
136         DO WHILE ( istp <= nitend .AND. nstop == 0 )
137#if defined key_agrif
138            CALL Agrif_Step( stp )
139#else
140            CALL stp( istp )
141#endif
142            istp = istp + 1
143            IF( lk_mpp )   CALL mpp_max( nstop )
144         END DO
145      ENDIF
146      !                                     ! ========= !
147      !                                     !  Job end  !
148      !                                     ! ========= !
149
150      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
151
152      IF( nstop /= 0 .AND. lwp ) THEN                 ! error print
153         WRITE(numout,cform_err)
154         WRITE(numout,*) nstop, ' error have been found' 
155      ENDIF
156
157      CALL opa_closefile
158#if defined key_oasis3 || defined key_oasis4
159      call cpl_prism_finalize
160#else
161      IF( lk_mpp )   CALL mppstop                          ! Close all files (mpp)
162#endif
163      !
164   END SUBROUTINE opa_model
165
166
167   SUBROUTINE opa_init
168      !!----------------------------------------------------------------------
169      !!                     ***  ROUTINE opa_init  ***
170      !!
171      !! ** Purpose :   initialization of the opa model
172      !!
173      !!----------------------------------------------------------------------
174#if defined key_oasis3 || defined key_oasis4
175      INTEGER :: localComm
176#endif
177      CHARACTER (len=20) ::   namelistname
178      CHARACTER (len=28) ::   file_out
179      NAMELIST/namctl/ ln_ctl, nprint, nictls, nictle,   &
180         &             isplt , jsplt , njctls, njctle, nbench, nbit_cmp
181      !!----------------------------------------------------------------------
182
183      ! Initializations
184      ! ===============
185
186      file_out = 'ocean.output'
187     
188      ! open listing and namelist units
189      CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
190         &         'SEQUENTIAL', 1, 6, .FALSE., 1 )
191
192      WRITE(numout,*)
193      WRITE(numout,*) '                 L O D Y C - I P S L'
194      WRITE(numout,*) '                     O P A model'
195      WRITE(numout,*) '            Ocean General Circulation Model'
196      WRITE(numout,*) '               version OPA 9.0  (2005) '
197      WRITE(numout,*)
198      WRITE(numout,*)
199
200      namelistname = 'namelist'
201      CALL ctlopn( numnam, namelistname, 'OLD', 'FORMATTED', 'SEQUENTIAL',   &
202         &         1, numout, .FALSE., 1 )
203
204      ! Namelist namctl : Control prints & Benchmark
205      REWIND( numnam )
206      READ  ( numnam, namctl )
207
208#if defined key_oasis3 || defined key_oasis4
209      call cpl_prism_init(localComm)
210      ! Nodes selection
211      narea = mynode(localComm)
212#else
213      ! Nodes selection
214      narea = mynode()
215#endif
216      narea = narea + 1    ! mynode return the rank of proc (0 --> jpnij -1 )
217      lwp   = narea == 1
218
219      ! open additionnal listing
220      IF( ln_ctl )   THEN
221         IF( narea-1 > 0 )   THEN
222            WRITE(file_out,FMT="('ocean.output_',I4.4)") narea-1
223            CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
224               &         'SEQUENTIAL', 1, numout, .FALSE., 1 )
225            lwp = .TRUE.
226            !
227            WRITE(numout,*)
228            WRITE(numout,*) '                 L O D Y C - I P S L'
229            WRITE(numout,*) '                     O P A model'
230            WRITE(numout,*) '            Ocean General Circulation Model'
231            WRITE(numout,*) '               version OPA 9.0  (2005) '
232            WRITE(numout,*) '                   MPI Ocean output '
233            WRITE(numout,*)
234            WRITE(numout,*)
235         ENDIF
236      ENDIF
237
238      !                                     ! ============================== !
239      !                                     !  Model general initialization  !
240      !                                     ! ============================== !
241
242      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
243
244      CALL opa_flg                          ! Control prints & Benchmark
245
246                                            ! Domain decomposition
247      IF( jpni*jpnj == jpnij ) THEN
248         CALL mpp_init                          ! standard cutting out
249      ELSE
250         CALL mpp_init2                         ! eliminate land processors
251      ENDIF
252     
253      CALL phy_cst                          ! Physical constants
254
255      CALL dom_cfg                          ! Domain configuration
256     
257      CALL dom_init                         ! Domain
258
259      IF( lk_c1d    ) THEN                      ! adaptation for 1D configuration
260         CALL cor_c1d                                ! redefine Coriolis at T-point
261         umask(:,:,:) = tmask(:,:,:)                 ! U, V and T-points are the same
262         vmask(:,:,:) = tmask(:,:,:)                 !
263      ENDIF
264
265      IF( ln_ctl    )   CALL prt_ctl_init   ! Print control
266
267      IF( lk_obc    )   CALL obc_init       ! Open boundaries
268
269      IF( lk_bdy    )   CALL bdy_init       ! Unstructured open boundaries
270
271      CALL istate_init                      ! ocean initial state (Dynamics and tracers)
272
273      !                                     ! Ocean physics
274
275      CALL ldf_dyn_init                         ! Lateral ocean momentum physics
276
277      CALL ldf_tra_init                         ! Lateral ocean tracer physics
278
279      CALL zdf_init                             ! Vertical ocean physics
280
281      CALL trd_mod_init                         ! Mixed-layer/Vorticity/Integral constraints trends
282
283
284#if defined key_top
285      CALL trc_ini                           ! Passive tracers
286#endif
287
288      CALL dia_ptr_init                     ! Poleward TRansports initialization
289
290      !                                     ! =============== !
291      !                                     !  time stepping  !
292      !                                     ! =============== !
293
294      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
295
296   END SUBROUTINE opa_init
297
298
299   SUBROUTINE opa_flg
300      !!----------------------------------------------------------------------
301      !!                     ***  ROUTINE opa  ***
302      !!
303      !! ** Purpose :   Initialize logical flags that control the choice of
304      !!      some algorithm or control print
305      !!
306      !! ** Method  :    Read in namilist namflg logical flags
307      !!
308      !! History :
309      !!   9.0  !  03-11  (G. Madec)  Original code
310      !!----------------------------------------------------------------------
311      !! * Local declarations
312
313      NAMELIST/namflg/ ln_dynhpg_imp, nn_dynhpg_rst
314      !!----------------------------------------------------------------------
315
316      ! Parameter control and print
317      ! ---------------------------
318      IF(lwp) THEN
319         WRITE(numout,*)
320         WRITE(numout,*) 'opa_flg: Control prints & Benchmark'
321         WRITE(numout,*) '~~~~~~~ '
322         WRITE(numout,*) '          Namelist namctl'
323         WRITE(numout,*) '             run control (for debugging)     ln_ctl    = ', ln_ctl
324         WRITE(numout,*) '             level of print                  nprint    = ', nprint
325         WRITE(numout,*) '             Start i indice for SUM control  nictls    = ', nictls
326         WRITE(numout,*) '             End i indice for SUM control    nictle    = ', nictle
327         WRITE(numout,*) '             Start j indice for SUM control  njctls    = ', njctls
328         WRITE(numout,*) '             End j indice for SUM control    njctle    = ', njctle
329         WRITE(numout,*) '             number of proc. following i     isplt     = ', isplt
330         WRITE(numout,*) '             number of proc. following j     jsplt     = ', jsplt
331         WRITE(numout,*) '             benchmark parameter (0/1)       nbench    = ', nbench
332         WRITE(numout,*) '             bit comparison mode (0/1)       nbit_cmp  = ', nbit_cmp
333      ENDIF
334
335      ! ... Control the sub-domain area indices for the control prints
336      IF( ln_ctl )   THEN
337         IF( lk_mpp )   THEN
338            ! the domain is forced to the real splitted domain in MPI
339            isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj
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
346            ! compute the total number of processors ijsplt
347            ijsplt = isplt*jsplt
348         ENDIF
349
350         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
351         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
352
353         ! Control the indices used for the SUM control
354         IF( nictls+nictle+njctls+njctle == 0 )   THEN
355            ! the print control is done over the default area
356            lsp_area = .FALSE.
357         ELSE
358            ! the print control is done over a specific  area
359            lsp_area = .TRUE.
360            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
361               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
362               nictls = 1
363            ENDIF
364
365            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
366               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
367               nictle = jpiglo
368            ENDIF
369
370            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
371               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
372               njctls = 1
373            ENDIF
374
375            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
376               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
377               njctle = jpjglo
378            ENDIF
379
380         ENDIF          ! IF( nictls+nictle+njctls+njctle == 0 )
381       ENDIF            ! IF(ln_ctl)
382
383      IF( nbench == 1 )   THEN
384         SELECT CASE ( cp_cfg )
385         CASE ( 'gyre' )
386            CALL ctl_warn( '          The Benchmark is activated ' )
387         CASE DEFAULT
388            CALL ctl_stop( '          The Benchmark is based on the GYRE configuration: key_gyre must &
389               &                      be used or set nbench = 0' )
390         END SELECT
391      ENDIF
392
393      IF( nbit_cmp == 1 )   THEN
394         CALL ctl_warn( '          Bit comparison enabled. Single and multiple processor results must bit compare', &
395              &         '          WARNING: RESULTS ARE NOT PHYSICAL.' )
396      ENDIF
397
398
399      ! Read Namelist namflg : algorithm FLaG
400      ! --------------------
401      REWIND ( numnam )
402      READ   ( numnam, namflg )
403
404      ! Parameter control and print
405      ! ---------------------------
406      IF(lwp) THEN
407         WRITE(numout,*)
408         WRITE(numout,*) 'opa_flg : Hydrostatic pressure gradient algorithm'
409         WRITE(numout,*) '~~~~~~~'
410         WRITE(numout,*) '          Namelist namflg : set algorithm flags'
411         WRITE(numout,*) '             centered (F) or semi-implicit (T)   ln_dynhpg_imp = ', ln_dynhpg_imp
412         WRITE(numout,*) '             hydrostatic pressure gradient'
413         WRITE(numout,*) '             add dynhpg implicit variable        nn_dynhpg_rst = ', nn_dynhpg_rst
414         WRITE(numout,*) '             in restart ot not nn_dynhpg_rst'
415      ENDIF
416      IF( .NOT. ln_dynhpg_imp )   nn_dynhpg_rst = 0      ! force no adding dynhpg implicit variables in restart
417
418   END SUBROUTINE opa_flg
419
420
421   SUBROUTINE opa_closefile
422      !!----------------------------------------------------------------------
423      !!                     ***  ROUTINE opa_closefile  ***
424      !!
425      !! ** Purpose :   Close the files
426      !!
427      !! ** Method  :
428      !!
429      !! History :
430      !!   9.0  !  05-01  (O. Le Galloudec)  Original code
431      !!----------------------------------------------------------------------
432      !! * Modules used
433      USE dtatem        ! temperature data
434      USE dtasal        ! salinity data
435      !!----------------------------------------------------------------------
436
437      IF ( lk_mpp ) CALL mppsync
438
439      ! 1. Unit close
440      ! -------------
441
442      CLOSE( numnam )           ! namelist
443      CLOSE( numout )           ! standard model output file
444
445      IF(lwp) CLOSE( numstp )   ! time-step file
446      IF(lwp) CLOSE( numsol )
447
448   END SUBROUTINE opa_closefile
449
450   !!======================================================================
451END MODULE opa
Note: See TracBrowser for help on using the repository browser.