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

Last change on this file since 2372 was 2372, checked in by acc, 13 years ago

nemo_v3_3_beta. Minor changes to ensure code associated with key_netcdf4 changes (#755) compiles with key_agrif. See updated wiki/NetCdf4_changes page for details

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