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

Last change on this file since 1146 was 1146, checked in by rblod, 16 years ago

Add svn Id (first try), see ticket #210

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