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