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.
in_out_manager.F90 in branches/dev_r2091_ZTC/NEMO/OPA_SRC/IOM – NEMO

source: branches/dev_r2091_ZTC/NEMO/OPA_SRC/IOM/in_out_manager.F90 @ 2116

Last change on this file since 2116 was 2116, checked in by mlelod, 14 years ago

ticket: #720 restart the branch from the latest DEV_r1837_MLF branch revision (2112)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.8 KB
Line 
1MODULE in_out_manager   
2   !!======================================================================
3   !!                       ***  MODULE  in_out_manager  ***
4   !! Ocean physics:  vertical mixing coefficient compute from the tke
5   !!                 turbulent closure parameterization
6   !!=====================================================================
7   !! History :   1.0  !  2002-06  (G. Madec)   original code
8   !!             2.0  !  2006-07  (S. Masson)  iom, add ctl_stop, ctl_warn
9   !!             3.0  !  2008-06  (G. Madec)   add ctmp4 to ctmp10
10   !!             3.2  !  2009-08  (S. MAsson)  add new ctl_opn
11   !!----------------------------------------------------------------------
12
13   !!----------------------------------------------------------------------
14   !!   ctl_stop   : update momentum and tracer Kz from a tke scheme
15   !!   ctl_warn   : initialization, namelist read, and parameters control
16   !!   getunit    : give the index of an unused logical unit
17   !!----------------------------------------------------------------------
18   USE par_kind        ! kind definition
19   USE par_oce         ! ocean parameter
20   USE lib_print       ! formated print library
21
22   IMPLICIT NONE
23   PUBLIC
24
25   !!----------------------------------------------------------------------
26   !!                   namrun namelist parameters
27   !!----------------------------------------------------------------------
28   CHARACTER(len=16)  ::   cn_exp        = "exp0"      !: experiment name used for output filename
29   CHARACTER(len=32)  ::   cn_ocerst_in  = "restart"   !: suffix of ocean restart name (input)
30   CHARACTER(len=32)  ::   cn_ocerst_out = "restart"   !: suffix of ocean restart name (output)
31   LOGICAL            ::   ln_rstart     = .FALSE.     !: start from (F) rest or (T) a restart file
32   INTEGER            ::   nn_no         = 0           !: job number
33   INTEGER            ::   nn_rstctl     = 0           !: control of the time step (0, 1 or 2)
34   INTEGER            ::   nn_rstssh     = 0           !: hand made initilization of ssh or not (1/0)
35   INTEGER            ::   nn_it000      = 1           !: index of the first time step
36   INTEGER            ::   nn_itend      = 10          !: index of the last time step
37   INTEGER            ::   nn_date0      = 961115      !: initial calendar date aammjj
38   INTEGER            ::   nn_leapy      = 0           !: Leap year calendar flag (0/1 or 30)
39   INTEGER            ::   nn_istate     = 0           !: initial state output flag (0/1)
40   INTEGER            ::   nn_write      =   10        !: model standard output frequency
41   INTEGER            ::   nn_stock      =   10        !: restart file frequency
42   LOGICAL            ::   ln_dimgnnn    = .FALSE.     !: type of dimgout. (F): 1 file for all proc
43                                                       !:                  (T): 1 file per proc
44   LOGICAL            ::   ln_mskland    = .FALSE.     !: mask land points in NetCDF outputs (costly: + ~15%)
45   LOGICAL            ::   ln_clobber    = .FALSE.     !: clobber (overwrite) an existing file
46   INTEGER            ::   nn_chunksz    = 0           !: chunksize (bytes) for NetCDF file (working only with iom_nf90 routines)
47
48   !! conversion of DOCTOR norm namelist name into model name
49   !! (this should disappear in a near futur)
50
51   CHARACTER(len=16)  ::   cexper                      !: experiment name used for output filename
52   INTEGER            ::   no                          !: job number
53   INTEGER            ::   nrstdt                      !: control of the time step (0, 1 or 2)
54   INTEGER            ::   nit000                      !: index of the first time step
55   INTEGER            ::   nitend                      !: index of the last time step
56   INTEGER            ::   ndate0                      !: initial calendar date aammjj
57   INTEGER            ::   nleapy                      !: Leap year calendar flag (0/1 or 30)
58   INTEGER            ::   ninist                      !: initial state output flag (0/1)
59   INTEGER            ::   nwrite                      !: model standard output frequency
60   INTEGER            ::   nstock                      !: restart file frequency
61
62   !!----------------------------------------------------------------------
63   !! was in restart but moved here because of the OFF line... better solution should be found...
64   !!----------------------------------------------------------------------
65   INTEGER            ::   nitrst                 !: time step at which restart file should be written
66
67   !!----------------------------------------------------------------------
68   !!                    output monitoring
69   !!----------------------------------------------------------------------
70   LOGICAL            ::   ln_ctl     = .FALSE.   !: run control for debugging
71   INTEGER            ::   nn_print     =    0    !: level of print (0 no print)
72   INTEGER            ::   nn_ictls     =    0    !: Start i indice for the SUM control
73   INTEGER            ::   nn_ictle     =    0    !: End   i indice for the SUM control
74   INTEGER            ::   nn_jctls     =    0    !: Start j indice for the SUM control
75   INTEGER            ::   nn_jctle     =    0    !: End   j indice for the SUM control
76   INTEGER            ::   nn_isplt     =    1    !: number of processors following i
77   INTEGER            ::   nn_jsplt     =    1    !: number of processors following j
78   INTEGER            ::   nn_bench     =    0    !: benchmark parameter (0/1)
79   INTEGER            ::   nn_bit_cmp   =    0    !: bit reproducibility  (0/1)
80   LOGICAL            ::   ln_hsb     = .FALSE.   !: check the heat and salt budgets
81
82   !                                              !: OLD namelist names
83   INTEGER ::   nprint, nictls, nictle, njctls, njctle, isplt, jsplt, nbench, nbit_cmp   
84
85   INTEGER            ::   ijsplt     =    1      !: nb of local domain = nb of processors
86
87   !!----------------------------------------------------------------------
88   !!                        logical units
89   !!----------------------------------------------------------------------
90   INTEGER            ::   numstp     =   -1      !: logical unit for time step
91   INTEGER            ::   numout     =    6      !: logical unit for output print
92   INTEGER            ::   numnam     =   -1      !: logical unit for namelist
93   INTEGER            ::   numnam_ice =   -1      !: logical unit for ice namelist
94   INTEGER            ::   numevo_ice =   -1      !: logical unit for ice variables (temp. evolution)
95   INTEGER            ::   numsol     =   -1      !: logical unit for solver statistics
96
97   !!----------------------------------------------------------------------
98   !!                          Run control 
99   !!----------------------------------------------------------------------
100   INTEGER            ::   nstop = 0                !: error flag (=number of reason for a premature stop run)
101   INTEGER            ::   nwarn = 0                !: warning flag (=number of warning found during the run)
102   CHARACTER(len=200) ::   ctmp1, ctmp2, ctmp3      !: temporary characters 1 to 3
103   CHARACTER(len=200) ::   ctmp4, ctmp5, ctmp6      !: temporary characters 4 to 6
104   CHARACTER(len=200) ::   ctmp7, ctmp8, ctmp9      !: temporary characters 7 to 9
105   CHARACTER(len=200) ::   ctmp10                   !: temporary character 10
106   CHARACTER (len=64) ::   cform_err = "(/,' ===>>> : E R R O R',     /,'         ===========',/)"       !:
107   CHARACTER (len=64) ::   cform_war = "(/,' ===>>> : W A R N I N G', /,'         ===============',/)"   !:
108   LOGICAL            ::   lwp      = .FALSE.       !: boolean : true on the 1st processor only
109   LOGICAL            ::   lsp_area = .TRUE.        !: to make a control print over a specific area
110   !!----------------------------------------------------------------------
111   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008)
112   !! $Id$
113   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
114   !!----------------------------------------------------------------------
115
116CONTAINS
117
118   SUBROUTINE ctl_stop( cd1, cd2, cd3, cd4, cd5,   &
119      &                 cd6, cd7, cd8, cd9, cd10 )
120      !!----------------------------------------------------------------------
121      !!                  ***  ROUTINE  stop_opa  ***
122      !!
123      !! ** Purpose :   print in ocean.outpput file a error message and
124      !!                increment the error number (nstop) by one.
125      !!----------------------------------------------------------------------
126      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
127      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
128      !!----------------------------------------------------------------------
129      !
130      nstop = nstop + 1 
131      IF(lwp) THEN
132         WRITE(numout,"(/,' ===>>> : E R R O R',     /,'         ===========',/)") 
133         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
134         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
135         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
136         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
137         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
138         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
139         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
140         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
141         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
142         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
143      ENDIF
144                               CALL FLUSH(numout    )
145      IF( numstp     /= -1 )   CALL FLUSH(numstp    )
146      IF( numsol     /= -1 )   CALL FLUSH(numsol    )
147      IF( numevo_ice /= -1 )   CALL FLUSH(numevo_ice)
148      !
149   END SUBROUTINE ctl_stop
150
151
152   SUBROUTINE ctl_warn( cd1, cd2, cd3, cd4, cd5,   &
153      &                 cd6, cd7, cd8, cd9, cd10 )
154      !!----------------------------------------------------------------------
155      !!                  ***  ROUTINE  stop_warn  ***
156      !!
157      !! ** Purpose :   print in ocean.outpput file a error message and
158      !!                increment the warning number (nwarn) by one.
159      !!----------------------------------------------------------------------
160      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
161      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
162      !!----------------------------------------------------------------------
163      !
164      nwarn = nwarn + 1 
165      IF(lwp) THEN
166         WRITE(numout,"(/,' ===>>> : W A R N I N G', /,'         ===============',/)") 
167         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
168         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
169         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
170         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
171         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
172         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
173         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
174         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
175         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
176         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
177      ENDIF
178      CALL FLUSH(numout)
179      !
180   END SUBROUTINE ctl_warn
181
182
183   SUBROUTINE ctl_opn ( knum, cdfile, cdstat, cdform, cdacce, klengh, kout, ldwp, karea )
184      !!----------------------------------------------------------------------
185      !!                  ***  ROUTINE ctl_opn  ***
186      !!
187      !! ** Purpose :   Open file and check if required file is available.
188      !!
189      !! ** Method  :   Fortan open
190      !!
191      !! History :
192      !!        !  1995-12  (G. Madec)  Original code
193      !!   8.5  !  2002-06  (G. Madec)  F90: Free form and module
194      !!----------------------------------------------------------------------
195
196      INTEGER          , INTENT(  out) ::   knum      ! logical unit to open
197      CHARACTER(len=*) , INTENT(in   ) ::   cdfile    ! file name to open
198      CHARACTER(len=*) , INTENT(in   ) ::   cdstat    ! disposition specifier
199      CHARACTER(len=*) , INTENT(in   ) ::   cdform    ! formatting specifier
200      CHARACTER(len=*) , INTENT(in   ) ::   cdacce    ! access specifier
201      INTEGER          , INTENT(in   ) ::   klengh    ! record length
202      INTEGER          , INTENT(in   ) ::   kout      ! number of logical units for write
203      LOGICAL          , INTENT(in   ) ::   ldwp      ! boolean term for print
204      INTEGER, OPTIONAL, INTENT(in   ) ::   karea     ! proc number
205      !!
206      CHARACTER(len=80) ::   clfile
207      INTEGER           ::   iost
208
209      ! adapt filename
210      ! ----------------
211      clfile = TRIM(cdfile)
212      IF( PRESENT( karea ) ) THEN
213         IF( karea > 1 )   WRITE(clfile, "(a,'_',i4.4)") TRIM(clfile), karea-1
214      ENDIF
215#if defined key_agrif
216      IF( .NOT. Agrif_Root() )   clfile = TRIM(Agrif_CFixed())//'_'//TRIM(clfile)
217      knum=Agrif_Get_Unit()
218#else
219      knum=getunit()
220#endif
221
222      iost=0
223      IF( cdacce(1:6) == 'DIRECT' )  THEN
224         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh, ERR=100, IOSTAT=iost )
225      ELSE
226         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat             , ERR=100, IOSTAT=iost )
227      ENDIF
228      IF( iost == 0 ) THEN
229         IF(ldwp) THEN
230            WRITE(kout,*) '     file   : ', clfile,' open ok'
231            WRITE(kout,*) '     unit   = ', knum
232            WRITE(kout,*) '     status = ', cdstat
233            WRITE(kout,*) '     form   = ', cdform
234            WRITE(kout,*) '     access = ', cdacce
235            WRITE(kout,*)
236         ENDIF
237      ENDIF
238100   CONTINUE
239      IF( iost /= 0 ) THEN
240         IF(ldwp) THEN
241            WRITE(kout,*)
242            WRITE(kout,*) ' ===>>>> : bad opening file: ', clfile
243            WRITE(kout,*) ' =======   ===  '
244            WRITE(kout,*) '           unit   = ', knum
245            WRITE(kout,*) '           status = ', cdstat
246            WRITE(kout,*) '           form   = ', cdform
247            WRITE(kout,*) '           access = ', cdacce
248            WRITE(kout,*) '           iostat = ', iost
249            WRITE(kout,*) '           we stop. verify the file '
250            WRITE(kout,*)
251         ENDIF
252         STOP 'ctl_opn bad opening'
253      ENDIF
254     
255   END SUBROUTINE ctl_opn
256
257
258   FUNCTION getunit()
259      !!----------------------------------------------------------------------
260      !!                  ***  FUNCTION  getunit  ***
261      !!
262      !! ** Purpose :   return the index of an unused logical unit
263      !!----------------------------------------------------------------------
264      INTEGER :: getunit
265      LOGICAL :: llopn 
266      !!----------------------------------------------------------------------
267      !
268      getunit = 15   ! choose a unit that is big enough then it is not already used in NEMO
269      llopn = .TRUE.
270      DO WHILE( (getunit < 998) .AND. llopn )
271         getunit = getunit + 1
272         INQUIRE( unit = getunit, opened = llopn )
273      END DO
274      IF( (getunit == 999) .AND. llopn ) THEN
275         CALL ctl_stop( 'getunit: All logical units until 999 are used...' )
276         getunit = -1
277      ENDIF
278      !
279   END FUNCTION getunit
280
281   !!=====================================================================
282END MODULE in_out_manager
Note: See TracBrowser for help on using the repository browser.