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

Last change on this file since 231 was 231, checked in by opalod, 19 years ago

CT : UPDATE156 : allow the possibility for each processor to write its own mpp.output_XXX ASCII file

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.2 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_flg        : initialisation of algorithm flag
10   !!----------------------------------------------------------------------
11   !! * Modules used
12   USE cpl_oce         ! ocean-atmosphere-sea ice coupled exchanges
13   USE dom_oce         ! ocean space domain variables
14   USE oce             ! dynamics and tracers variables
15   USE trdmod_oce      ! ocean variables trends
16   USE daymod          ! calendar
17   USE in_out_manager  ! I/O manager
18   USE lib_mpp         ! distributed memory computing
19
20   USE domcfg          ! domain configuration               (dom_cfg routine)
21   USE mppini          ! shared/distributed memory setting (mpp_init routine)
22   USE domain          ! domain initialization             (dom_init routine)
23   USE obc_par         ! open boundary cond. parameters
24   USE obcini          ! open boundary cond. initialization (obc_ini routine)
25   USE solver          ! solver initialization          (solver_init routine)
26   USE istate          ! initial state setting          (istate_init routine)
27   USE eosbn2          ! equation of state            (eos bn2 routine)
28   USE zpshde          ! partial step: hor. derivative (zps_hde routine)
29
30   ! ocean physics
31   USE traqsr          ! solar radiation penetration   (tra_qsr_init routine)
32   USE ldfdyn          ! lateral viscosity setting      (ldfdyn_init routine)
33   USE ldftra          ! lateral diffusivity setting    (ldftra_init routine)
34   USE zdfini
35!!!USE zdf_oce         ! ocean vertical physics            (zdf_init routine)
36
37   USE phycst          ! physical constant                  (par_cst routine)
38   USE iceini          ! initialization of sea-ice         (ice_init routine)
39   USE cpl             ! coupled ocean/atmos.              (cpl_init routine)
40   USE ocfzpt          ! ocean freezing point              (oc_fz_pt routine)
41   USE trdicp          ! momentum/tracers trends       (trd_icp_init routine)
42   USE trdvor          ! vorticity trends              (trd_vor_init routine)
43   USE trdmld          ! tracer mixed layer trends     (trd_mld_init routine)
44   USE flxfwb          !
45
46   USE diaptr          ! poleward transports           (dia_ptr_init routine)
47
48   USE step            ! OPA time-stepping                  (stp     routine)
49
50   IMPLICIT NONE
51   PRIVATE
52
53   !! * Routine accessibility
54   PUBLIC opa_model      ! called by model.F90
55   !!----------------------------------------------------------------------
56   !!  OPA 9.0 , LODYC-IPSL (2003)
57   !!----------------------------------------------------------------------
58
59CONTAINS
60
61   SUBROUTINE opa_model
62      !!----------------------------------------------------------------------
63      !!                     ***  ROUTINE opa  ***
64      !!
65      !! ** Purpose :   opa solves the primitive equations on an orthogonal
66      !!      curvilinear mesh on the sphere.
67      !!
68      !! ** Method  : - model general initialization
69      !!              - launch the time-stepping (stp routine)
70      !!
71      !! References :
72      !!      Madec, Delecluse,Imbard, and Levy, 1997: reference manual.
73      !!              internal report, IPSL.
74      !!
75      !! History :
76      !!   4.0  !  90-10  (C. Levy, G. Madec)  Original code
77      !!   7.0  !  91-11  (M. Imbard, C. Levy, G. Madec)
78      !!   7.1  !  93-03  (M. Imbard, C. Levy, G. Madec, O. Marti,
79      !!                   M. Guyon, A. Lazar, P. Delecluse, C. Perigaud,
80      !!                   G. Caniaux, B. Colot, C. Maes ) release 7.1
81      !!        !  92-06  (L.Terray) coupling implementation
82      !!        !  93-11  (M.A. Filiberti) IGLOO sea-ice
83      !!   8.0  !  96-03  (M. Imbard, C. Levy, G. Madec, O. Marti,
84      !!                   M. Guyon, A. Lazar, P. Delecluse, L.Terray,
85      !!                   M.A. Filiberti, J. Vialar, A.M. Treguier,
86      !!                   M. Levy)  release 8.0
87      !!   8.1  !  97-06  (M. Imbard, G. Madec)
88      !!   8.2  !  99-11  (M. Imbard, H. Goosse)  LIM sea-ice model
89      !!        !  99-12  (V. Thierry, A-M. Treguier, M. Imbard, M-A. Foujols)  OPEN-MP
90      !!        !  00-07  (J-M Molines, M. Imbard)  Open Boundary Conditions  (CLIPPER)
91      !!   9.0  !  02-08  (G. Madec)  F90: Free form and modules
92      !!    "   !  04-08  (C. Talandier) New trends organization
93      !!----------------------------------------------------------------------
94      !! * Local declarations
95      INTEGER ::   istp       ! time step index
96#if defined key_coupled
97      INTEGER ::   itro, istp0        ! ???
98#endif
99      CHARACTER (len=64) ::        &
100         cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
101      CHARACTER (len=28) :: file_out
102      !!----------------------------------------------------------------------
103     
104     
105      ! Initializations
106      ! ===============
107
108      file_out = 'ocean.output'
109     
110      ! open listing and namelist units
111      IF ( numout /= 0 .AND. numout /= 6 ) THEN
112         OPEN( UNIT=numout, FILE=TRIM(file_out), FORM='FORMATTED' )
113      ENDIF
114
115      OPEN( UNIT=numnam, FILE='namelist', FORM='FORMATTED', STATUS='OLD' )
116
117
118      ! Nodes selection
119      narea = mynode()
120      narea = narea + 1    ! mynode return the rank of proc (0 --> jpnij -1 )
121      lwp   = narea == 1
122
123      IF( lk_mpp )   THEN
124!! #############################  MPI debug  ###########################  !!
125!!  To allow each processor to write its own mpp.output_XXX file, decomment
126!!  the 5 following lines, else the output will be done only by the first
127!!  processor in the ocean.output file:
128!!  this one        numout = 80
129!!  this one        numout = numout + narea
130!!  this one        lwp    = .TRUE.
131!!  this one        WRITE(file_out,FMT="('mpp.output_',I3.3)") narea-1
132!!  this one        OPEN( UNIT=numout, FILE=TRIM(file_out),FORM='FORMATTED' )
133!! #############################  MPI debug  ###########################  !!
134      ENDIF
135
136      IF(lwp) THEN
137         WRITE(numout,*)
138         WRITE(numout,*) '                 L O D Y C - I P S L'
139         WRITE(numout,*) '                     O P A model'
140         WRITE(numout,*) '            Ocean General Circulation Model'
141         WRITE(numout,*) '               version OPA 9.0  (2003)'
142         WRITE(numout,*)
143         WRITE(numout,*) '                   PROC number: ', narea
144         WRITE(numout,*)
145      ENDIF
146
147      !                                     ! ============================== !
148      !                                     !  Model general initialization  !
149      !                                     ! ============================== !
150
151      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
152
153                                            ! Domain decomposition
154      IF( jpni*jpnj == jpnij ) THEN
155         CALL mpp_init                          ! standard cutting out
156      ELSE
157         CALL mpp_init2                         ! eliminate land processors
158      ENDIF
159     
160      CALL phy_cst                          ! Physical constants
161
162      CALL dom_cfg                          ! Domain configuration
163     
164      CALL dom_init                         ! Domain
165
166      IF( lk_obc    )   CALL obc_init        ! Open boundaries
167
168      CALL solver_init                      ! Elliptic solver
169
170      CALL day( nit000 )                    ! Calendar
171
172      CALL istate_init                      ! ocean initial state (Dynamics and tracers)
173!!add
174                       CALL eos( tb, sb, rhd, rhop )        ! before potential and in situ densities
175
176                       CALL bn2( tb, sb, rn2 )              ! before Brunt-Vaisala frequency
177
178      IF( lk_zps    )   CALL zps_hde( nit000, tb, sb, rhd,  &  ! Partial steps: before Horizontal DErivative
179                                          gtu, gsu, gru, &  ! of t, s, rd at the bottom ocean level
180                                          gtv, gsv, grv )
181
182!!add
183
184      CALL oc_fz_pt                         ! Surface freezing point
185
186#if defined key_ice_lim
187      CALL ice_init                         ! Sea ice model
188#endif
189
190#if defined key_passivetrc
191      CALL initrc                           ! Passive tracers
192#endif
193
194      !                                     ! Ocean scheme
195
196      CALL opa_flg                              ! Choice of algorithms
197
198      !                                     ! Ocean physics
199
200      CALL tra_qsr_init                         ! Solar radiation penetration
201
202      CALL ldf_dyn_init                         ! Lateral ocean momentum physics
203
204      CALL ldf_tra_init                         ! Lateral ocean tracer physics
205
206      CALL zdf_init                             ! Vertical ocean physics
207
208      !                                     ! Ocean trends
209      ! Control parameters
210      IF( lk_trdtra .OR. lk_trdmld )   l_trdtra = .TRUE.
211      IF( lk_trddyn .OR. lk_trdvor )   l_trddyn = .TRUE.
212
213      IF( lk_trddyn .OR. lk_trdtra )   &
214         &            CALL trd_icp_init         ! active tracers and/or momentum
215
216      IF( lk_trdmld ) CALL trd_mld_init         ! mixed layer
217
218      IF( lk_trdvor ) CALL trd_vor_init         ! vorticity
219
220#if defined key_coupled
221      itro  = nitend - nit000 + 1           ! Coupled
222      istp0 = NINT( rdt )
223      CALL cpl_init( itro, nexco, istp0 )   ! Signal processing and process id exchange
224#endif
225
226      CALL flx_fwb_init                     ! FreshWater Budget correction
227
228      CALL dia_ptr_init                     ! Poleward TRansports initialization
229
230      !                                     ! =============== !
231      !                                     !  time stepping  !
232      !                                     ! =============== !
233
234      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
235
236      istp = nit000
237      DO WHILE ( istp <= nitend .AND. nstop == 0 )
238         CALL stp( istp )
239         istp = istp + 1
240      END DO
241      !                                     ! ========= !
242      !                                     !  Job end  !
243      !                                     ! ========= !
244
245      IF(lwp) WRITE(numout,cform_aaa)       ! Flag AAAAAAA
246
247      IF( nstop /= 0 ) THEN                 ! error print
248      IF(lwp) WRITE(numout,cform_err)
249      IF(lwp) WRITE(numout,*) nstop, ' error have been found' 
250      ENDIF
251
252      CALL opa_closefile
253      IF( lk_mpp )   CALL mppstop                          ! Close all files (mpp)
254
255   END SUBROUTINE opa_model
256
257
258   SUBROUTINE opa_flg
259      !!----------------------------------------------------------------------
260      !!                     ***  ROUTINE opa  ***
261      !!
262      !! ** Purpose :   Initialize logical flags that control the choice of
263      !!      some algorithm or control print
264      !!
265      !! ** Method  :    Read in namilist namflg logical flags
266      !!
267      !! History :
268      !!   9.0  !  03-11  (G. Madec)  Original code
269      !!----------------------------------------------------------------------
270      !! * Local declarations
271
272      NAMELIST/namflg/ ln_dynhpg_imp
273      !!----------------------------------------------------------------------
274
275      ! Read Namelist namflg : algorithm FLaG
276      ! --------------------
277      REWIND ( numnam )
278      READ   ( numnam, namflg )
279
280      ! Parameter control and print
281      ! ---------------------------
282      ! Control print
283      IF(lwp) THEN
284         WRITE(numout,*)
285         WRITE(numout,*) 'opa_flg : algorithm flag initialization'
286         WRITE(numout,*) '~~~~~~~'
287         WRITE(numout,*) '          Namelist namflg : set algorithm flags'
288         WRITE(numout,*)
289         WRITE(numout,*) '             centered (F) or semi-implicit (T)   ln_dynhpg_imp = ', ln_dynhpg_imp
290         WRITE(numout,*) '             hydrostatic pressure gradient'
291      ENDIF
292
293   END SUBROUTINE opa_flg
294
295   SUBROUTINE opa_closefile
296      !!----------------------------------------------------------------------
297      !!                     ***  ROUTINE opa_closefile  ***
298      !!
299      !! ** Purpose :   Close the files
300      !!           
301      !! ** Method  :
302      !!
303      !! History :
304      !!   9.0  !  05-01  (O. Le Galloudec)  Original code
305      !!----------------------------------------------------------------------
306      !! * Modules used
307      USE dtatem        ! temperature data
308      USE dtasal        ! salinity data
309      USE dtasst        ! sea surface temperature data
310      !!----------------------------------------------------------------------
311
312      IF ( lk_mpp ) CALL mppsync
313
314      ! 1. Unit close
315      ! -------------
316
317      CLOSE( numnam )       ! namelist
318      CLOSE( numout )       ! standard model output file
319      CLOSE( numstp )       ! time-step file
320      CLOSE( numwrs )       ! ocean restart file
321
322      IF( lk_dtatem )   CLOSE( numtdt )
323      IF( lk_dtasal )   CLOSE( numsdt )
324      IF( lk_dtasst )   CLOSE( numsst )
325
326      IF(lwp) CLOSE( numsol )
327
328      IF( lk_cpl ) THEN
329         CLOSE( numlhf )
330         CLOSE( numlts )
331      ENDIF
332
333      CLOSE( numwri )
334
335   END SUBROUTINE opa_closefile
336
337   !!======================================================================
338END MODULE opa
Note: See TracBrowser for help on using the repository browser.