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

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

nemo_v3_3_beta. Changes to code relating to key_netcdf4 option to provide more robust compilation. See #755 and #754

  • Property svn:keywords set to Id
File size: 16.6 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   TYPE(snc4_ctl)     :: snc4set                       !: netcdf4 chunking control structure (always needed for decision making)
66
67
68   !! conversion of DOCTOR norm namelist name into model name
69   !! (this should disappear in a near futur)
70
71   CHARACTER(len=16)  ::   cexper                      !: experiment name used for output filename
72   INTEGER            ::   no                          !: job number
73   INTEGER            ::   nrstdt                      !: control of the time step (0, 1 or 2)
74   INTEGER            ::   nit000                      !: index of the first time step
75   INTEGER            ::   nitend                      !: index of the last time step
76   INTEGER            ::   ndate0                      !: initial calendar date aammjj
77   INTEGER            ::   nleapy                      !: Leap year calendar flag (0/1 or 30)
78   INTEGER            ::   ninist                      !: initial state output flag (0/1)
79   INTEGER            ::   nwrite                      !: model standard output frequency
80   INTEGER            ::   nstock                      !: restart file frequency
81
82   !!----------------------------------------------------------------------
83   !! was in restart but moved here because of the OFF line... better solution should be found...
84   !!----------------------------------------------------------------------
85   INTEGER            ::   nitrst                 !: time step at which restart file should be written
86
87   !!----------------------------------------------------------------------
88   !!                    output monitoring
89   !!----------------------------------------------------------------------
90   LOGICAL            ::   ln_ctl     = .FALSE.   !: run control for debugging
91   INTEGER            ::   nn_print     =    0    !: level of print (0 no print)
92   INTEGER            ::   nn_ictls     =    0    !: Start i indice for the SUM control
93   INTEGER            ::   nn_ictle     =    0    !: End   i indice for the SUM control
94   INTEGER            ::   nn_jctls     =    0    !: Start j indice for the SUM control
95   INTEGER            ::   nn_jctle     =    0    !: End   j indice for the SUM control
96   INTEGER            ::   nn_isplt     =    1    !: number of processors following i
97   INTEGER            ::   nn_jsplt     =    1    !: number of processors following j
98   INTEGER            ::   nn_bench     =    0    !: benchmark parameter (0/1)
99   INTEGER            ::   nn_bit_cmp   =    0    !: bit reproducibility  (0/1)
100
101   !                                              !: OLD namelist names
102   INTEGER ::   nprint, nictls, nictle, njctls, njctle, isplt, jsplt, nbench
103
104   INTEGER            ::   ijsplt     =    1      !: nb of local domain = nb of processors
105
106   !!----------------------------------------------------------------------
107   !!                        logical units
108   !!----------------------------------------------------------------------
109   INTEGER            ::   numstp     =   -1      !: logical unit for time step
110   INTEGER            ::   numout     =    6      !: logical unit for output print
111   INTEGER            ::   numnam     =   -1      !: logical unit for namelist
112   INTEGER            ::   numnam_ice =   -1      !: logical unit for ice namelist
113   INTEGER            ::   numevo_ice =   -1      !: logical unit for ice variables (temp. evolution)
114   INTEGER            ::   numsol     =   -1      !: logical unit for solver statistics
115
116   !!----------------------------------------------------------------------
117   !!                          Run control 
118   !!----------------------------------------------------------------------
119   INTEGER            ::   nstop = 0                !: error flag (=number of reason for a premature stop run)
120   INTEGER            ::   nwarn = 0                !: warning flag (=number of warning found during the run)
121   CHARACTER(len=200) ::   ctmp1, ctmp2, ctmp3      !: temporary characters 1 to 3
122   CHARACTER(len=200) ::   ctmp4, ctmp5, ctmp6      !: temporary characters 4 to 6
123   CHARACTER(len=200) ::   ctmp7, ctmp8, ctmp9      !: temporary characters 7 to 9
124   CHARACTER(len=200) ::   ctmp10                   !: temporary character 10
125   CHARACTER (len=64) ::   cform_err = "(/,' ===>>> : E R R O R',     /,'         ===========',/)"       !:
126   CHARACTER (len=64) ::   cform_war = "(/,' ===>>> : W A R N I N G', /,'         ===============',/)"   !:
127   LOGICAL            ::   lwp      = .FALSE.       !: boolean : true on the 1st processor only
128   LOGICAL            ::   lsp_area = .TRUE.        !: to make a control print over a specific area
129   !!----------------------------------------------------------------------
130   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
131   !! $Id$
132   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
133   !!----------------------------------------------------------------------
134
135CONTAINS
136
137   SUBROUTINE ctl_stop( cd1, cd2, cd3, cd4, cd5,   &
138      &                 cd6, cd7, cd8, cd9, cd10 )
139      !!----------------------------------------------------------------------
140      !!                  ***  ROUTINE  stop_opa  ***
141      !!
142      !! ** Purpose :   print in ocean.outpput file a error message and
143      !!                increment the error number (nstop) by one.
144      !!----------------------------------------------------------------------
145      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
146      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
147      !!----------------------------------------------------------------------
148      !
149      nstop = nstop + 1 
150      IF(lwp) THEN
151         WRITE(numout,"(/,' ===>>> : E R R O R',     /,'         ===========',/)") 
152         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
153         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
154         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
155         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
156         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
157         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
158         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
159         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
160         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
161         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
162      ENDIF
163                               CALL FLUSH(numout    )
164      IF( numstp     /= -1 )   CALL FLUSH(numstp    )
165      IF( numsol     /= -1 )   CALL FLUSH(numsol    )
166      IF( numevo_ice /= -1 )   CALL FLUSH(numevo_ice)
167      !
168   END SUBROUTINE ctl_stop
169
170
171   SUBROUTINE ctl_warn( cd1, cd2, cd3, cd4, cd5,   &
172      &                 cd6, cd7, cd8, cd9, cd10 )
173      !!----------------------------------------------------------------------
174      !!                  ***  ROUTINE  stop_warn  ***
175      !!
176      !! ** Purpose :   print in ocean.outpput file a error message and
177      !!                increment the warning number (nwarn) by one.
178      !!----------------------------------------------------------------------
179      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd1, cd2, cd3, cd4, cd5
180      CHARACTER(len=*), INTENT(in), OPTIONAL ::  cd6, cd7, cd8, cd9, cd10
181      !!----------------------------------------------------------------------
182      !
183      nwarn = nwarn + 1 
184      IF(lwp) THEN
185         WRITE(numout,"(/,' ===>>> : W A R N I N G', /,'         ===============',/)") 
186         IF( PRESENT(cd1 ) ) WRITE(numout,*) cd1
187         IF( PRESENT(cd2 ) ) WRITE(numout,*) cd2
188         IF( PRESENT(cd3 ) ) WRITE(numout,*) cd3
189         IF( PRESENT(cd4 ) ) WRITE(numout,*) cd4
190         IF( PRESENT(cd5 ) ) WRITE(numout,*) cd5
191         IF( PRESENT(cd6 ) ) WRITE(numout,*) cd6
192         IF( PRESENT(cd7 ) ) WRITE(numout,*) cd7
193         IF( PRESENT(cd8 ) ) WRITE(numout,*) cd8
194         IF( PRESENT(cd9 ) ) WRITE(numout,*) cd9
195         IF( PRESENT(cd10) ) WRITE(numout,*) cd10
196      ENDIF
197      CALL FLUSH(numout)
198      !
199   END SUBROUTINE ctl_warn
200
201
202   SUBROUTINE ctl_opn ( knum, cdfile, cdstat, cdform, cdacce, klengh, kout, ldwp, karea )
203      !!----------------------------------------------------------------------
204      !!                  ***  ROUTINE ctl_opn  ***
205      !!
206      !! ** Purpose :   Open file and check if required file is available.
207      !!
208      !! ** Method  :   Fortan open
209      !!
210      !! History :
211      !!        !  1995-12  (G. Madec)  Original code
212      !!   8.5  !  2002-06  (G. Madec)  F90: Free form and module
213      !!----------------------------------------------------------------------
214
215      INTEGER          , INTENT(  out) ::   knum      ! logical unit to open
216      CHARACTER(len=*) , INTENT(in   ) ::   cdfile    ! file name to open
217      CHARACTER(len=*) , INTENT(in   ) ::   cdstat    ! disposition specifier
218      CHARACTER(len=*) , INTENT(in   ) ::   cdform    ! formatting specifier
219      CHARACTER(len=*) , INTENT(in   ) ::   cdacce    ! access specifier
220      INTEGER          , INTENT(in   ) ::   klengh    ! record length
221      INTEGER          , INTENT(in   ) ::   kout      ! number of logical units for write
222      LOGICAL          , INTENT(in   ) ::   ldwp      ! boolean term for print
223      INTEGER, OPTIONAL, INTENT(in   ) ::   karea     ! proc number
224      !!
225      CHARACTER(len=80) ::   clfile
226      INTEGER           ::   iost
227
228      ! adapt filename
229      ! ----------------
230      clfile = TRIM(cdfile)
231      IF( PRESENT( karea ) ) THEN
232         IF( karea > 1 )   WRITE(clfile, "(a,'_',i4.4)") TRIM(clfile), karea-1
233      ENDIF
234#if defined key_agrif
235      IF( .NOT. Agrif_Root() )   clfile = TRIM(Agrif_CFixed())//'_'//TRIM(clfile)
236      knum=Agrif_Get_Unit()
237#else
238      knum=getunit()
239#endif
240
241      iost=0
242      IF( cdacce(1:6) == 'DIRECT' )  THEN
243         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat, RECL=klengh, ERR=100, IOSTAT=iost )
244      ELSE
245         OPEN( UNIT=knum, FILE=clfile, FORM=cdform, ACCESS=cdacce, STATUS=cdstat             , ERR=100, IOSTAT=iost )
246      ENDIF
247      IF( iost == 0 ) THEN
248         IF(ldwp) THEN
249            WRITE(kout,*) '     file   : ', clfile,' open ok'
250            WRITE(kout,*) '     unit   = ', knum
251            WRITE(kout,*) '     status = ', cdstat
252            WRITE(kout,*) '     form   = ', cdform
253            WRITE(kout,*) '     access = ', cdacce
254            WRITE(kout,*)
255         ENDIF
256      ENDIF
257100   CONTINUE
258      IF( iost /= 0 ) THEN
259         IF(ldwp) THEN
260            WRITE(kout,*)
261            WRITE(kout,*) ' ===>>>> : bad opening file: ', clfile
262            WRITE(kout,*) ' =======   ===  '
263            WRITE(kout,*) '           unit   = ', knum
264            WRITE(kout,*) '           status = ', cdstat
265            WRITE(kout,*) '           form   = ', cdform
266            WRITE(kout,*) '           access = ', cdacce
267            WRITE(kout,*) '           iostat = ', iost
268            WRITE(kout,*) '           we stop. verify the file '
269            WRITE(kout,*)
270         ENDIF
271         STOP 'ctl_opn bad opening'
272      ENDIF
273     
274   END SUBROUTINE ctl_opn
275
276
277   FUNCTION getunit()
278      !!----------------------------------------------------------------------
279      !!                  ***  FUNCTION  getunit  ***
280      !!
281      !! ** Purpose :   return the index of an unused logical unit
282      !!----------------------------------------------------------------------
283      INTEGER :: getunit
284      LOGICAL :: llopn 
285      !!----------------------------------------------------------------------
286      !
287      getunit = 15   ! choose a unit that is big enough then it is not already used in NEMO
288      llopn = .TRUE.
289      DO WHILE( (getunit < 998) .AND. llopn )
290         getunit = getunit + 1
291         INQUIRE( unit = getunit, opened = llopn )
292      END DO
293      IF( (getunit == 999) .AND. llopn ) THEN
294         CALL ctl_stop( 'getunit: All logical units until 999 are used...' )
295         getunit = -1
296      ENDIF
297      !
298   END FUNCTION getunit
299
300   !!=====================================================================
301END MODULE in_out_manager
Note: See TracBrowser for help on using the repository browser.