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

Last change on this file since 1057 was 1037, checked in by ctlod, 16 years ago

trunk: replace freeze(:,:) variable with fr_i(:,:), use the tfreez function defined in eosbn2.F90 and remove the useless ocfzpt.F90 module, see ticket: #177

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