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

source: branches/dev_004_VVL/NEMO/OPA_SRC/opa.F90 @ 1434

Last change on this file since 1434 was 1434, checked in by rblod, 15 years ago

dev_004_VVL:sync: synchro with trunk (r1420), see ticket #412

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 19.0 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
71#elif defined key_oasis4
72   USE cpl_oasis4      ! OASIS4 coupling (not working)
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   USE iom
82#if defined key_iomput
83   USE mod_ioclient
84#endif
85
86   IMPLICIT NONE
87   PRIVATE
88
89   !! * Module variables
90   CHARACTER (len=64) ::        &
91      cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
92
93   !! * Routine accessibility
94   PUBLIC opa_model      ! called by model.F90
95   PUBLIC opa_init
96   !!----------------------------------------------------------------------
97   !!  OPA 9.0 , LOCEAN-IPSL (2005)
98   !! $Id$
99   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
100   !!----------------------------------------------------------------------
101
102CONTAINS
103
104   SUBROUTINE opa_model
105      !!----------------------------------------------------------------------
106      !!                     ***  ROUTINE opa  ***
107      !!
108      !! ** Purpose :   opa solves the primitive equations on an orthogonal
109      !!      curvilinear mesh on the sphere.
110      !!
111      !! ** Method  : - model general initialization
112      !!              - launch the time-stepping (stp routine)
113      !!
114      !! References :
115      !!      Madec, Delecluse,Imbard, and Levy, 1997: reference manual.
116      !!              internal report, IPSL.
117      !!----------------------------------------------------------------------
118      INTEGER ::   istp       ! time step index
119      !!----------------------------------------------------------------------
120
121#if defined key_agrif
122      CALL Agrif_Init_Grids()
123#endif
124     
125      CALL opa_init  ! Initializations
126
127      ! check that all process are still there... If some process have an error,
128      ! they will never enter in step and other processes will wait until the end of the cpu time!
129      IF( lk_mpp )   CALL mpp_max( nstop )
130
131      istp = nit000
132      IF( lk_c1d ) THEN                 ! 1D configuration (no AGRIF zoom)
133         !
134         DO WHILE ( istp <= nitend .AND. nstop == 0 )
135            CALL stp_c1d( istp )
136            istp = istp + 1
137         END DO
138      ELSE                              ! 3D ocean with or without AGRIF zoom
139         !
140         DO WHILE ( istp <= nitend .AND. nstop == 0 )
141#if defined key_agrif
142            CALL Agrif_Step( stp )
143#else
144            CALL stp( istp )
145#endif
146            istp = istp + 1
147            IF( lk_mpp )   CALL mpp_max( nstop )
148         END DO
149      ENDIF
150      !                                     ! ========= !
151      !                                     !  Job end  !
152      !                                     ! ========= !
153
154      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
155
156      IF( nstop /= 0 .AND. lwp ) THEN                 ! error print
157         WRITE(numout,cform_err)
158         WRITE(numout,*) nstop, ' error have been found' 
159      ENDIF
160
161      CALL opa_closefile
162#if defined key_oasis3 || defined key_oasis4
163      call cpl_prism_finalize
164#else
165      IF( lk_mpp )   CALL mppstop                          ! Close all files (mpp)
166#endif
167      !
168   END SUBROUTINE opa_model
169
170
171   SUBROUTINE opa_init
172      !!----------------------------------------------------------------------
173      !!                     ***  ROUTINE opa_init  ***
174      !!
175      !! ** Purpose :   initialization of the opa model
176      !!
177      !!----------------------------------------------------------------------
178#if defined key_oasis3 || defined key_oasis4 || defined key_iomput
179      INTEGER :: localComm
180#endif
181      CHARACTER (len=20) ::   namelistname
182      CHARACTER (len=28) ::   file_out
183      NAMELIST/namctl/ ln_ctl, nprint, nictls, nictle,   &
184         &             isplt , jsplt , njctls, njctle, nbench, nbit_cmp
185      !!----------------------------------------------------------------------
186
187      ! Initializations
188      ! ===============
189
190      file_out = 'ocean.output'
191     
192      ! open listing and namelist units
193      CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
194         &         'SEQUENTIAL', 1, 6, .FALSE., 1 )
195
196      WRITE(numout,*)
197      WRITE(numout,*) '                 L O D Y C - I P S L'
198      WRITE(numout,*) '                     O P A model'
199      WRITE(numout,*) '            Ocean General Circulation Model'
200      WRITE(numout,*) '               version OPA 9.0  (2005) '
201      WRITE(numout,*)
202      WRITE(numout,*)
203
204      namelistname = 'namelist'
205      CALL ctlopn( numnam, namelistname, 'OLD', 'FORMATTED', 'SEQUENTIAL',   &
206         &         1, numout, .FALSE., 1 )
207
208      ! Namelist namctl : Control prints & Benchmark
209      REWIND( numnam )
210      READ  ( numnam, namctl )
211
212#if defined key_iomput
213# if defined key_oasis3 || defined key_oasis4
214      ! nemo local communicator given by oasis
215      CALL cpl_prism_init( localComm )
216      ! io_server will get its communicators (if needed) from oasis (we don't see it)
217      CALL init_ioclient()
218# else
219      ! nemo local communicator (used or not) given by the io_server
220      CALL init_ioclient( localcomm )
221# endif
222      ! Nodes selection
223      narea = mynode( localComm )
224#else
225# if defined key_oasis3 || defined key_oasis4
226      ! nemo local communicator given by oasis
227      CALL cpl_prism_init( localComm )
228      ! Nodes selection
229      narea = mynode( localComm )
230# else
231      ! Nodes selection
232      narea = mynode()
233# endif
234#endif
235      narea = narea + 1    ! mynode return the rank of proc (0 --> jpnij -1 )
236      lwp   = narea == 1
237
238      ! open additionnal listing
239      IF( ln_ctl )   THEN
240         IF( narea-1 > 0 )   THEN
241            WRITE(file_out,FMT="('ocean.output_',I4.4)") narea-1
242            CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
243               &         'SEQUENTIAL', 1, numout, .FALSE., 1 )
244            lwp = .TRUE.
245            !
246            WRITE(numout,*)
247            WRITE(numout,*) '                 L O D Y C - I P S L'
248            WRITE(numout,*) '                     O P A model'
249            WRITE(numout,*) '            Ocean General Circulation Model'
250            WRITE(numout,*) '               version OPA 9.0  (2005) '
251            WRITE(numout,*) '                   MPI Ocean output '
252            WRITE(numout,*)
253            WRITE(numout,*)
254         ENDIF
255      ENDIF
256
257      !                                     ! ============================== !
258      !                                     !  Model general initialization  !
259      !                                     ! ============================== !
260
261      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
262
263      CALL opa_flg                          ! Control prints & Benchmark
264
265                                            ! Domain decomposition
266      IF( jpni*jpnj == jpnij ) THEN
267         CALL mpp_init                          ! standard cutting out
268      ELSE
269         CALL mpp_init2                         ! eliminate land processors
270      ENDIF
271     
272      CALL phy_cst                          ! Physical constants
273
274      CALL dom_cfg                          ! Domain configuration
275     
276      CALL dom_init                         ! Domain
277
278      IF( lk_c1d    ) THEN                      ! adaptation for 1D configuration
279         CALL cor_c1d                                ! redefine Coriolis at T-point
280         umask(:,:,:) = tmask(:,:,:)                 ! U, V and T-points are the same
281         vmask(:,:,:) = tmask(:,:,:)                 !
282      ENDIF
283
284      IF( ln_ctl    )   CALL prt_ctl_init   ! Print control
285
286      IF( lk_obc    )   CALL obc_init       ! Open boundaries
287
288      IF( lk_bdy    )   CALL bdy_init       ! Unstructured open boundaries
289
290      CALL istate_init                      ! ocean initial state (Dynamics and tracers)
291
292      !                                     ! Ocean physics
293
294      CALL ldf_dyn_init                         ! Lateral ocean momentum physics
295
296      CALL ldf_tra_init                         ! Lateral ocean tracer physics
297
298      CALL zdf_init                             ! Vertical ocean physics
299
300      CALL trd_mod_init                         ! Mixed-layer/Vorticity/Integral constraints trends
301
302
303#if defined key_top
304      CALL trc_ini                          ! Passive tracers
305#endif
306
307      CALL dia_ptr_init                     ! Poleward TRansports initialization
308
309      CALL iom_init( fjulday - adatrj )     ! iom_put initialization
310
311      !                                     ! =============== !
312      !                                     !  time stepping  !
313      !                                     ! =============== !
314
315      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
316
317   END SUBROUTINE opa_init
318
319
320   SUBROUTINE opa_flg
321      !!----------------------------------------------------------------------
322      !!                     ***  ROUTINE opa  ***
323      !!
324      !! ** Purpose :   Initialize logical flags that control the choice of
325      !!      some algorithm or control print
326      !!
327      !! ** Method  :    Read in namilist namflg logical flags
328      !!
329      !! History :
330      !!   9.0  !  03-11  (G. Madec)  Original code
331      !!----------------------------------------------------------------------
332      !! * Local declarations
333
334      NAMELIST/namflg/ ln_dynhpg_imp, nn_dynhpg_rst
335      !!----------------------------------------------------------------------
336
337      ! Parameter control and print
338      ! ---------------------------
339      IF(lwp) THEN
340         WRITE(numout,*)
341         WRITE(numout,*) 'opa_flg: Control prints & Benchmark'
342         WRITE(numout,*) '~~~~~~~ '
343         WRITE(numout,*) '          Namelist namctl'
344         WRITE(numout,*) '             run control (for debugging)     ln_ctl    = ', ln_ctl
345         WRITE(numout,*) '             level of print                  nprint    = ', nprint
346         WRITE(numout,*) '             Start i indice for SUM control  nictls    = ', nictls
347         WRITE(numout,*) '             End i indice for SUM control    nictle    = ', nictle
348         WRITE(numout,*) '             Start j indice for SUM control  njctls    = ', njctls
349         WRITE(numout,*) '             End j indice for SUM control    njctle    = ', njctle
350         WRITE(numout,*) '             number of proc. following i     isplt     = ', isplt
351         WRITE(numout,*) '             number of proc. following j     jsplt     = ', jsplt
352         WRITE(numout,*) '             benchmark parameter (0/1)       nbench    = ', nbench
353         WRITE(numout,*) '             bit comparison mode (0/1)       nbit_cmp  = ', nbit_cmp
354      ENDIF
355
356      ! ... Control the sub-domain area indices for the control prints
357      IF( ln_ctl )   THEN
358         IF( lk_mpp )   THEN
359            ! the domain is forced to the real splitted domain in MPI
360            isplt = jpni ; jsplt = jpnj ; ijsplt = jpni*jpnj
361         ELSE
362            IF( isplt == 1 .AND. jsplt == 1  ) THEN
363               CALL ctl_warn( '          - isplt & jsplt are equal to 1',   &
364                    &         '          - the print control will be done over the whole domain' )
365            ENDIF
366
367            ! compute the total number of processors ijsplt
368            ijsplt = isplt*jsplt
369         ENDIF
370
371         IF(lwp) WRITE(numout,*)'          - The total number of processors over which the'
372         IF(lwp) WRITE(numout,*)'            print control will be done is ijsplt : ', ijsplt
373
374         ! Control the indices used for the SUM control
375         IF( nictls+nictle+njctls+njctle == 0 )   THEN
376            ! the print control is done over the default area
377            lsp_area = .FALSE.
378         ELSE
379            ! the print control is done over a specific  area
380            lsp_area = .TRUE.
381            IF( nictls < 1 .OR. nictls > jpiglo )   THEN
382               CALL ctl_warn( '          - nictls must be 1<=nictls>=jpiglo, it is forced to 1' )
383               nictls = 1
384            ENDIF
385
386            IF( nictle < 1 .OR. nictle > jpiglo )   THEN
387               CALL ctl_warn( '          - nictle must be 1<=nictle>=jpiglo, it is forced to jpiglo' )
388               nictle = jpiglo
389            ENDIF
390
391            IF( njctls < 1 .OR. njctls > jpjglo )   THEN
392               CALL ctl_warn( '          - njctls must be 1<=njctls>=jpjglo, it is forced to 1' )
393               njctls = 1
394            ENDIF
395
396            IF( njctle < 1 .OR. njctle > jpjglo )   THEN
397               CALL ctl_warn( '          - njctle must be 1<=njctle>=jpjglo, it is forced to jpjglo' )
398               njctle = jpjglo
399            ENDIF
400
401         ENDIF          ! IF( nictls+nictle+njctls+njctle == 0 )
402       ENDIF            ! IF(ln_ctl)
403
404      IF( nbench == 1 )   THEN
405         SELECT CASE ( cp_cfg )
406         CASE ( 'gyre' )
407            CALL ctl_warn( '          The Benchmark is activated ' )
408         CASE DEFAULT
409            CALL ctl_stop( '          The Benchmark is based on the GYRE configuration: key_gyre must &
410               &                      be used or set nbench = 0' )
411         END SELECT
412      ENDIF
413
414      IF( nbit_cmp == 1 )   THEN
415         CALL ctl_warn( '          Bit comparison enabled. Single and multiple processor results must bit compare', &
416              &         '          WARNING: RESULTS ARE NOT PHYSICAL.' )
417      ENDIF
418
419
420      ! Read Namelist namflg : algorithm FLaG
421      ! --------------------
422      REWIND ( numnam )
423      READ   ( numnam, namflg )
424
425      ! Parameter control and print
426      ! ---------------------------
427      IF(lwp) THEN
428         WRITE(numout,*)
429         WRITE(numout,*) 'opa_flg : Hydrostatic pressure gradient algorithm'
430         WRITE(numout,*) '~~~~~~~'
431         WRITE(numout,*) '          Namelist namflg : set algorithm flags'
432         WRITE(numout,*) '             centered (F) or semi-implicit (T)   ln_dynhpg_imp = ', ln_dynhpg_imp
433         WRITE(numout,*) '             hydrostatic pressure gradient'
434         WRITE(numout,*) '             add dynhpg implicit variable        nn_dynhpg_rst = ', nn_dynhpg_rst
435         WRITE(numout,*) '             in restart ot not nn_dynhpg_rst'
436      ENDIF
437      IF( .NOT. ln_dynhpg_imp )   nn_dynhpg_rst = 0      ! force no adding dynhpg implicit variables in restart
438
439   END SUBROUTINE opa_flg
440
441
442   SUBROUTINE opa_closefile
443      !!----------------------------------------------------------------------
444      !!                     ***  ROUTINE opa_closefile  ***
445      !!
446      !! ** Purpose :   Close the files
447      !!
448      !! ** Method  :
449      !!
450      !! History :
451      !!   9.0  !  05-01  (O. Le Galloudec)  Original code
452      !!----------------------------------------------------------------------
453      !! * Modules used
454      USE dtatem        ! temperature data
455      USE dtasal        ! salinity data
456      !!----------------------------------------------------------------------
457
458      IF ( lk_mpp ) CALL mppsync
459
460      CLOSE( numnam )           ! namelist
461      CLOSE( numout )           ! standard model output file
462
463      IF(lwp) CLOSE( numstp )   ! time-step file
464      IF(lwp) CLOSE( numsol )   ! solver file
465
466      CALL iom_close            ! close all input/output files
467
468   END SUBROUTINE opa_closefile
469
470   !!======================================================================
471END MODULE opa
Note: See TracBrowser for help on using the repository browser.