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/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/IOM – NEMO

source: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90 @ 2281

Last change on this file since 2281 was 2281, checked in by smasson, 14 years ago

set proper svn properties to all files...

  • Property svn:keywords set to Id
File size: 14.7 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
81   !                                              !: OLD namelist names
82   INTEGER ::   nprint, nictls, nictle, njctls, njctle, isplt, jsplt, nbench
83
84   INTEGER            ::   ijsplt     =    1      !: nb of local domain = nb of processors
85
86   !!----------------------------------------------------------------------
87   !!                        logical units
88   !!----------------------------------------------------------------------
89   INTEGER            ::   numstp     =   -1      !: logical unit for time step
90   INTEGER            ::   numout     =    6      !: logical unit for output print
91   INTEGER            ::   numnam     =   -1      !: logical unit for namelist
92   INTEGER            ::   numnam_ice =   -1      !: logical unit for ice namelist
93   INTEGER            ::   numevo_ice =   -1      !: logical unit for ice variables (temp. evolution)
94   INTEGER            ::   numsol     =   -1      !: logical unit for solver statistics
95
96   !!----------------------------------------------------------------------
97   !!                          Run control 
98   !!----------------------------------------------------------------------
99   INTEGER            ::   nstop = 0                !: error flag (=number of reason for a premature stop run)
100   INTEGER            ::   nwarn = 0                !: warning flag (=number of warning found during the run)
101   CHARACTER(len=200) ::   ctmp1, ctmp2, ctmp3      !: temporary characters 1 to 3
102   CHARACTER(len=200) ::   ctmp4, ctmp5, ctmp6      !: temporary characters 4 to 6
103   CHARACTER(len=200) ::   ctmp7, ctmp8, ctmp9      !: temporary characters 7 to 9
104   CHARACTER(len=200) ::   ctmp10                   !: temporary character 10
105   CHARACTER (len=64) ::   cform_err = "(/,' ===>>> : E R R O R',     /,'         ===========',/)"       !:
106   CHARACTER (len=64) ::   cform_war = "(/,' ===>>> : W A R N I N G', /,'         ===============',/)"   !:
107   LOGICAL            ::   lwp      = .FALSE.       !: boolean : true on the 1st processor only
108   LOGICAL            ::   lsp_area = .TRUE.        !: to make a control print over a specific area
109   !!----------------------------------------------------------------------
110   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008)
111   !! $Id$
112   !! Software governed by the CeCILL licence  (NEMOGCM/License_CeCILL.txt)
113   !!----------------------------------------------------------------------
114
115CONTAINS
116
117   SUBROUTINE ctl_stop( cd1, cd2, cd3, cd4, cd5,   &
118      &                 cd6, cd7, cd8, cd9, cd10 )
119      !!----------------------------------------------------------------------
120      !!                  ***  ROUTINE  stop_opa  ***
121      !!
122      !! ** Purpose :   print in ocean.outpput file a error message and
123      !!                increment the error number (nstop) by one.
124      !!----------------------------------------------------------------------
125      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
126      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
127      !!----------------------------------------------------------------------
128      !
129      nstop = nstop + 1 
130      IF(lwp) THEN
131         WRITE(numout,"(/,' ===>>> : E R R O R',     /,'         ===========',/)") 
132         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
133         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
134         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
135         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
136         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
137         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
138         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
139         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
140         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
141         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
142      ENDIF
143                               CALL FLUSH(numout    )
144      IF( numstp     /= -1 )   CALL FLUSH(numstp    )
145      IF( numsol     /= -1 )   CALL FLUSH(numsol    )
146      IF( numevo_ice /= -1 )   CALL FLUSH(numevo_ice)
147      !
148   END SUBROUTINE ctl_stop
149
150
151   SUBROUTINE ctl_warn( cd1, cd2, cd3, cd4, cd5,   &
152      &                 cd6, cd7, cd8, cd9, cd10 )
153      !!----------------------------------------------------------------------
154      !!                  ***  ROUTINE  stop_warn  ***
155      !!
156      !! ** Purpose :   print in ocean.outpput file a error message and
157      !!                increment the warning number (nwarn) by one.
158      !!----------------------------------------------------------------------
159      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
160      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
161      !!----------------------------------------------------------------------
162      !
163      nwarn = nwarn + 1 
164      IF(lwp) THEN
165         WRITE(numout,"(/,' ===>>> : W A R N I N G', /,'         ===============',/)") 
166         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
167         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
168         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
169         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
170         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
171         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
172         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
173         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
174         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
175         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
176      ENDIF
177      CALL FLUSH(numout)
178      !
179   END SUBROUTINE ctl_warn
180
181
182   SUBROUTINE ctl_opn ( knum, cdfile, cdstat, cdform, cdacce, klengh, kout, ldwp, karea )
183      !!----------------------------------------------------------------------
184      !!                  ***  ROUTINE ctl_opn  ***
185      !!
186      !! ** Purpose :   Open file and check if required file is available.
187      !!
188      !! ** Method  :   Fortan open
189      !!
190      !! History :
191      !!        !  1995-12  (G. Madec)  Original code
192      !!   8.5  !  2002-06  (G. Madec)  F90: Free form and module
193      !!----------------------------------------------------------------------
194
195      INTEGER          , INTENT(  out) ::   knum      ! logical unit to open
196      CHARACTER(len=*) , INTENT(in   ) ::   cdfile    ! file name to open
197      CHARACTER(len=*) , INTENT(in   ) ::   cdstat    ! disposition specifier
198      CHARACTER(len=*) , INTENT(in   ) ::   cdform    ! formatting specifier
199      CHARACTER(len=*) , INTENT(in   ) ::   cdacce    ! access specifier
200      INTEGER          , INTENT(in   ) ::   klengh    ! record length
201      INTEGER          , INTENT(in   ) ::   kout      ! number of logical units for write
202      LOGICAL          , INTENT(in   ) ::   ldwp      ! boolean term for print
203      INTEGER, OPTIONAL, INTENT(in   ) ::   karea     ! proc number
204      !!
205      CHARACTER(len=80) ::   clfile
206      INTEGER           ::   iost
207
208      ! adapt filename
209      ! ----------------
210      clfile = TRIM(cdfile)
211      IF( PRESENT( karea ) ) THEN
212         IF( karea > 1 )   WRITE(clfile, "(a,'_',i4.4)") TRIM(clfile), karea-1
213      ENDIF
214#if defined key_agrif
215      IF( .NOT. Agrif_Root() )   clfile = TRIM(Agrif_CFixed())//'_'//TRIM(clfile)
216      knum=Agrif_Get_Unit()
217#else
218      knum=getunit()
219#endif
220
221      iost=0
222      IF( cdacce(1:6) == 'DIRECT' )  THEN
223         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh, ERR=100, IOSTAT=iost )
224      ELSE
225         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat             , ERR=100, IOSTAT=iost )
226      ENDIF
227      IF( iost == 0 ) THEN
228         IF(ldwp) THEN
229            WRITE(kout,*) '     file   : ', clfile,' open ok'
230            WRITE(kout,*) '     unit   = ', knum
231            WRITE(kout,*) '     status = ', cdstat
232            WRITE(kout,*) '     form   = ', cdform
233            WRITE(kout,*) '     access = ', cdacce
234            WRITE(kout,*)
235         ENDIF
236      ENDIF
237100   CONTINUE
238      IF( iost /= 0 ) THEN
239         IF(ldwp) THEN
240            WRITE(kout,*)
241            WRITE(kout,*) ' ===>>>> : bad opening file: ', clfile
242            WRITE(kout,*) ' =======   ===  '
243            WRITE(kout,*) '           unit   = ', knum
244            WRITE(kout,*) '           status = ', cdstat
245            WRITE(kout,*) '           form   = ', cdform
246            WRITE(kout,*) '           access = ', cdacce
247            WRITE(kout,*) '           iostat = ', iost
248            WRITE(kout,*) '           we stop. verify the file '
249            WRITE(kout,*)
250         ENDIF
251         STOP 'ctl_opn bad opening'
252      ENDIF
253     
254   END SUBROUTINE ctl_opn
255
256
257   FUNCTION getunit()
258      !!----------------------------------------------------------------------
259      !!                  ***  FUNCTION  getunit  ***
260      !!
261      !! ** Purpose :   return the index of an unused logical unit
262      !!----------------------------------------------------------------------
263      INTEGER :: getunit
264      LOGICAL :: llopn 
265      !!----------------------------------------------------------------------
266      !
267      getunit = 15   ! choose a unit that is big enough then it is not already used in NEMO
268      llopn = .TRUE.
269      DO WHILE( (getunit < 998) .AND. llopn )
270         getunit = getunit + 1
271         INQUIRE( unit = getunit, opened = llopn )
272      END DO
273      IF( (getunit == 999) .AND. llopn ) THEN
274         CALL ctl_stop( 'getunit: All logical units until 999 are used...' )
275         getunit = -1
276      ENDIF
277      !
278   END FUNCTION getunit
279
280   !!=====================================================================
281END MODULE in_out_manager
Note: See TracBrowser for help on using the repository browser.