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

Last change on this file since 473 was 473, checked in by opalod, 18 years ago

nemo_v1_update_060: SM: IOM + 301 levels + CORE + begining of ctl_stop

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.1 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-08  (C. Talandier) New trends organization
31   !!    "   !  05-06  (C. Ethe) Add the 1D configuration possibility
32   !!    "   !  05-11  (V. Garnier) Surface pressure gradient organization
33   !!    "   !  06-03  (L. Debreu, C. Mazauric)  Agrif implementation
34   !!    "   !  06-04  (G. Madec, R. Benshila)  Step reorganization
35   !!----------------------------------------------------------------------
36   !! * Modules used
37   USE cpl_oce         ! ocean-atmosphere-sea ice coupled exchanges
38   USE dom_oce         ! ocean space domain variables
39   USE oce             ! dynamics and tracers variables
40   USE trdmod_oce      ! ocean variables trends
41   USE daymod          ! calendar
42   USE in_out_manager  ! I/O manager
43   USE lib_mpp         ! distributed memory computing
44
45   USE domcfg          ! domain configuration               (dom_cfg routine)
46   USE mppini          ! shared/distributed memory setting (mpp_init routine)
47   USE domain          ! domain initialization             (dom_init routine)
48   USE obc_par         ! open boundary cond. parameters
49   USE obcini          ! open boundary cond. initialization (obc_ini routine)
50   USE solver          ! solver initialization          (solver_init routine)
51   USE istate          ! initial state setting          (istate_init routine)
52   USE eosbn2          ! equation of state            (eos bn2 routine)
53   USE zpshde          ! partial step: hor. derivative (zps_hde routine)
54
55   ! ocean physics
56   USE ldfdyn          ! lateral viscosity setting      (ldfdyn_init routine)
57   USE ldftra          ! lateral diffusivity setting    (ldftra_init routine)
58   USE zdfini
59
60   USE phycst          ! physical constant                  (par_cst routine)
61   USE iceini          ! initialization of sea-ice         (ice_init routine)
62   USE cpl             ! coupled ocean/atmos.              (cpl_init routine)
63   USE ocfzpt          ! ocean freezing point              (oc_fz_pt routine)
64   USE trdicp          ! momentum/tracers trends       (trd_icp_init routine)
65   USE trdvor          ! vorticity trends              (trd_vor_init routine)
66   USE trdmld          ! tracer mixed layer trends     (trd_mld_init routine)
67   USE flxfwb          ! freshwater budget correction  (flx_fwb_init routine)
68   USE flxmod          ! thermohaline forcing of the ocean (flx_init routine)
69
70   USE diaptr          ! poleward transports           (dia_ptr_init routine)
71
72   USE step            ! OPA time-stepping                  (stp     routine)
73   USE dynspg_oce      ! Control choice of surface pressure gradient schemes
74   USE prtctl          ! Print control                 (prt_ctl_init routine)
75   USE ini1d           ! re-initialization of u-v mask for the 1D configuration
76   USE dyncor1d        ! Coriolis factor at T-point
77   USE step1d          ! Time stepping loop for the 1D configuration
78
79   USE initrc          ! Initialization of the passive tracers
80
81   IMPLICIT NONE
82   PRIVATE
83
84   !! * Module variables
85   CHARACTER (len=64) ::        &
86      cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
87
88   !! * Routine accessibility
89   PUBLIC opa_model      ! called by model.F90
90   PUBLIC opa_init
91   !!----------------------------------------------------------------------
92   !!  OPA 9.0 , LOCEAN-IPSL (2005)
93   !! $Header$
94   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
95   !!----------------------------------------------------------------------
96
97CONTAINS
98
99   SUBROUTINE opa_model
100      !!----------------------------------------------------------------------
101      !!                     ***  ROUTINE opa  ***
102      !!
103      !! ** Purpose :   opa solves the primitive equations on an orthogonal
104      !!      curvilinear mesh on the sphere.
105      !!
106      !! ** Method  : - model general initialization
107      !!              - launch the time-stepping (stp routine)
108      !!
109      !! References :
110      !!      Madec, Delecluse,Imbard, and Levy, 1997: reference manual.
111      !!              internal report, IPSL.
112      !!----------------------------------------------------------------------
113      INTEGER ::   istp       ! time step index
114      !!----------------------------------------------------------------------
115
116#if defined key_agrif
117      CALL Agrif_Init_Grids()
118#endif
119     
120      CALL opa_init  ! Initializations
121
122      IF( lk_cfg_1d ) THEN
123         istp = nit000
124         DO WHILE ( istp <= nitend .AND. nstop == 0 )
125#if defined key_agrif
126            CALL Agrif_Step(stp_1d)
127#else
128            CALL stp_1d( istp )
129#endif
130            istp = istp + 1
131         END DO
132      ELSE
133         istp = nit000
134         DO WHILE ( istp <= nitend .AND. nstop == 0 )
135#if defined key_agrif
136            CALL Agrif_Step(stp)
137#else
138            CALL stp( istp )
139#endif
140            istp = istp + 1
141         END DO
142      ENDIF
143      !                                     ! ========= !
144      !                                     !  Job end  !
145      !                                     ! ========= !
146
147      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
148
149      IF( nstop /= 0 ) THEN                 ! error print
150      IF(lwp) WRITE(numout,cform_err)
151      IF(lwp) WRITE(numout,*) nstop, ' error have been found' 
152      ENDIF
153
154      CALL opa_closefile
155      IF( lk_mpp )   CALL mppstop                          ! Close all files (mpp)
156
157   END SUBROUTINE opa_model
158
159
160   SUBROUTINE opa_init
161      !!----------------------------------------------------------------------
162      !!                     ***  ROUTINE opa_init  ***
163      !!
164      !! ** Purpose :   initialization of the opa model
165      !!
166      !!----------------------------------------------------------------------
167#if defined key_coupled
168      INTEGER ::   itro, istp0        ! ???
169#endif
170      CHARACTER (len=20) ::   namelistname
171      CHARACTER (len=28) ::   file_out
172      !!----------------------------------------------------------------------
173
174      ! Initializations
175      ! ===============
176
177      file_out = 'ocean.output'
178     
179      ! open listing and namelist units
180      IF ( numout /= 0 .AND. numout /= 6 ) THEN
181         CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
182            &         'SEQUENTIAL', 1, numout, .FALSE., 1 )
183      ENDIF
184
185      namelistname = 'namelist'
186      CALL ctlopn( numnam, namelistname, 'OLD', 'FORMATTED', 'SEQUENTIAL',   &
187         &           1, numout, .FALSE., 1 )
188
189      WRITE(numout,*)
190      WRITE(numout,*) '                 L O D Y C - I P S L'
191      WRITE(numout,*) '                     O P A model'
192      WRITE(numout,*) '            Ocean General Circulation Model'
193      WRITE(numout,*) '               version OPA 9.0  (2005) '
194      WRITE(numout,*)
195      WRITE(numout,*)
196
197      ! Nodes selection
198      narea = mynode()
199      narea = narea + 1    ! mynode return the rank of proc (0 --> jpnij -1 )
200      lwp   = narea == 1
201
202      IF( lk_mpp )   THEN
203         CLOSE( numout )       ! standard model output file
204         WRITE(file_out,FMT="('ocean.output_',I4.4)") narea-1
205         IF ( numout /= 0 .AND. numout /= 6 ) THEN
206            CALL ctlopn( numout, file_out, 'UNKNOWN', 'FORMATTED',   &
207                 &         'SEQUENTIAL', 1, numout, .FALSE., 1 )
208         ENDIF
209         !
210         WRITE(numout,*)
211         WRITE(numout,*) '                 L O D Y C - I P S L'
212         WRITE(numout,*) '                     O P A model'
213         WRITE(numout,*) '            Ocean General Circulation Model'
214         WRITE(numout,*) '               version OPA 9.0  (2005) '
215         WRITE(numout,*) '                   MPI Ocean output '
216         WRITE(numout,*)
217         WRITE(numout,*)
218      ENDIF
219
220      !                                     ! ============================== !
221      !                                     !  Model general initialization  !
222      !                                     ! ============================== !
223
224      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
225
226                                            ! Domain decomposition
227      IF( jpni*jpnj == jpnij ) THEN
228         CALL mpp_init                          ! standard cutting out
229      ELSE
230         CALL mpp_init2                         ! eliminate land processors
231      ENDIF
232     
233      CALL phy_cst                          ! Physical constants
234
235      CALL dom_cfg                          ! Domain configuration
236     
237      CALL dom_init                         ! Domain
238
239      IF( ln_ctl )      CALL prt_ctl_init   ! Print control
240
241      IF( lk_cfg_1d )   CALL fcorio_1d      ! redefine Coriolis at T-point
242
243      IF( lk_obc    )   CALL obc_init       ! Open boundaries
244
245      CALL day( nit000 )                    ! Calendar
246
247      CALL istate_init                      ! ocean initial state (Dynamics and tracers)
248
249      IF( lk_dynspg_flt .OR. lk_dynspg_rl ) THEN
250         CALL solver_init( nit000 )         ! Elliptic solver
251      ENDIF
252
253!!add
254                       CALL eos( tb, sb, rhd, rhop )        ! before potential and in situ densities
255
256                       CALL bn2( tb, sb, rn2 )              ! before Brunt-Vaisala frequency
257
258      IF( ln_zps .AND. .NOT. lk_cfg_1d )   &
259         &             CALL zps_hde( nit000, tb, sb, rhd,  &  ! Partial steps: before Horizontal DErivative
260                                            gtu, gsu, gru, &  ! of t, s, rd at the bottom ocean level
261                                            gtv, gsv, grv )
262!!add
263
264      CALL oc_fz_pt                         ! Surface freezing point
265
266#if defined key_ice_lim
267      CALL ice_init                         ! Sea ice model
268#endif
269
270      !                                     ! Ocean scheme
271
272      CALL opa_flg                              ! Choice of algorithms
273
274      !                                     ! Ocean physics
275
276      CALL ldf_dyn_init                         ! Lateral ocean momentum physics
277
278      CALL ldf_tra_init                         ! Lateral ocean tracer physics
279
280      CALL zdf_init                             ! Vertical ocean physics
281
282      !                                     ! Ocean trends
283      ! Control parameters
284      IF( lk_trdtra .OR. lk_trdmld )   l_trdtra = .TRUE.
285      IF( lk_trddyn .OR. lk_trdvor )   l_trddyn = .TRUE.
286
287      IF( lk_trddyn .OR. lk_trdtra )   &
288         &            CALL trd_icp_init         ! active tracers and/or momentum
289
290      IF( lk_trdmld ) CALL trd_mld_init         ! mixed layer
291
292      IF( lk_trdvor ) CALL trd_vor_init         ! vorticity
293
294#if defined key_passivetrc
295      CALL ini_trc                           ! Passive tracers
296#endif
297
298#if defined key_coupled
299      itro  = nitend - nit000 + 1           ! Coupled
300      istp0 = NINT( rdt )
301      CALL cpl_init( itro, nexco, istp0 )   ! Signal processing and process id exchange
302#endif
303
304      CALL flx_init                         ! Thermohaline forcing initialization
305
306      CALL flx_fwb_init                     ! FreshWater Budget correction
307
308      CALL dia_ptr_init                     ! Poleward TRansports initialization
309
310      !                                     ! =============== !
311      !                                     !  time stepping  !
312      !                                     ! =============== !
313
314      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
315
316      IF( lk_cfg_1d  )  THEN
317         CALL init_1d
318      ENDIF
319
320   END SUBROUTINE opa_init
321
322
323   SUBROUTINE opa_flg
324      !!----------------------------------------------------------------------
325      !!                     ***  ROUTINE opa  ***
326      !!
327      !! ** Purpose :   Initialize logical flags that control the choice of
328      !!      some algorithm or control print
329      !!
330      !! ** Method  :    Read in namilist namflg logical flags
331      !!
332      !! History :
333      !!   9.0  !  03-11  (G. Madec)  Original code
334      !!----------------------------------------------------------------------
335      !! * Local declarations
336
337      NAMELIST/namflg/ ln_dynhpg_imp
338      !!----------------------------------------------------------------------
339
340      ! Read Namelist namflg : algorithm FLaG
341      ! --------------------
342      REWIND ( numnam )
343      READ   ( numnam, namflg )
344
345      ! Parameter control and print
346      ! ---------------------------
347      ! Control print
348      IF(lwp) THEN
349         WRITE(numout,*)
350         WRITE(numout,*) 'opa_flg : algorithm flag initialization'
351         WRITE(numout,*) '~~~~~~~'
352         WRITE(numout,*) '          Namelist namflg : set algorithm flags'
353         WRITE(numout,*)
354         WRITE(numout,*) '             centered (F) or semi-implicit (T)   ln_dynhpg_imp = ', ln_dynhpg_imp
355         WRITE(numout,*) '             hydrostatic pressure gradient'
356      ENDIF
357
358   END SUBROUTINE opa_flg
359
360
361   SUBROUTINE opa_closefile
362      !!----------------------------------------------------------------------
363      !!                     ***  ROUTINE opa_closefile  ***
364      !!
365      !! ** Purpose :   Close the files
366      !!
367      !! ** Method  :
368      !!
369      !! History :
370      !!   9.0  !  05-01  (O. Le Galloudec)  Original code
371      !!----------------------------------------------------------------------
372      !! * Modules used
373      USE dtatem        ! temperature data
374      USE dtasal        ! salinity data
375      USE dtasst        ! sea surface temperature data
376      !!----------------------------------------------------------------------
377
378      IF ( lk_mpp ) CALL mppsync
379
380      ! 1. Unit close
381      ! -------------
382
383      CLOSE( numnam )       ! namelist
384      CLOSE( numout )       ! standard model output file
385      CLOSE( numstp )       ! time-step file
386
387      IF(lwp) CLOSE( numsol )
388
389   END SUBROUTINE opa_closefile
390
391   !!======================================================================
392END MODULE opa
Note: See TracBrowser for help on using the repository browser.