[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 |
---|
[544] | 11 | !!---------------------------------------------------------------------- |
---|
| 12 | |
---|
| 13 | !!---------------------------------------------------------------------- |
---|
| 14 | !! ctl_stop : update momentum and tracer Kz from a tke scheme |
---|
| 15 | !! ctl_warn : initialization, namelist read, and parameters control |
---|
[1056] | 16 | !! getunit : give the index of an unused logical unit |
---|
[544] | 17 | !!---------------------------------------------------------------------- |
---|
[1056] | 18 | USE par_kind ! kind definition |
---|
| 19 | USE par_oce ! ocean parameter |
---|
| 20 | USE lib_print ! formated print library |
---|
[544] | 21 | |
---|
| 22 | IMPLICIT NONE |
---|
| 23 | PUBLIC |
---|
| 24 | |
---|
| 25 | !!---------------------------------------------------------------------- |
---|
| 26 | !! namrun namelist parameters |
---|
| 27 | !!---------------------------------------------------------------------- |
---|
[1601] | 28 | CHARACTER(len=16) :: cn_exp = "exp0" !: experiment name used for output filename |
---|
[1229] | 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 |
---|
[1601] | 32 | INTEGER :: nn_no = 0 !: job number |
---|
| 33 | INTEGER :: nn_rstctl = 0 !: control of the time step (0, 1 or 2) |
---|
[1229] | 34 | INTEGER :: nn_rstssh = 0 !: hand made initilization of ssh or not (1/0) |
---|
[1601] | 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 |
---|
[1229] | 42 | LOGICAL :: ln_dimgnnn = .FALSE. !: type of dimgout. (F): 1 file for all proc |
---|
| 43 | !: (T): 1 file per proc |
---|
[1312] | 44 | LOGICAL :: ln_mskland = .FALSE. !: mask land points in NetCDF outputs (costly: + ~15%) |
---|
[1488] | 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) |
---|
[1601] | 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 | |
---|
[544] | 62 | !!---------------------------------------------------------------------- |
---|
[557] | 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 |
---|
[1601] | 66 | |
---|
[557] | 67 | !!---------------------------------------------------------------------- |
---|
[544] | 68 | !! output monitoring |
---|
| 69 | !!---------------------------------------------------------------------- |
---|
[556] | 70 | LOGICAL :: ln_ctl = .FALSE. !: run control for debugging |
---|
[1601] | 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 |
---|
[1685] | 76 | INTEGER :: nn_isplt = 1 !: number of processors following i |
---|
| 77 | INTEGER :: nn_jsplt = 1 !: number of processors following j |
---|
[1601] | 78 | INTEGER :: nn_bench = 0 !: benchmark parameter (0/1) |
---|
| 79 | INTEGER :: nn_bit_cmp = 0 !: bit reproducibility (0/1) |
---|
[2116] | 80 | LOGICAL :: ln_hsb = .FALSE. !: check the heat and salt budgets |
---|
[1601] | 81 | |
---|
| 82 | ! !: OLD namelist names |
---|
| 83 | INTEGER :: nprint, nictls, nictle, njctls, njctle, isplt, jsplt, nbench, nbit_cmp |
---|
| 84 | |
---|
[544] | 85 | INTEGER :: ijsplt = 1 !: nb of local domain = nb of processors |
---|
[1601] | 86 | |
---|
[544] | 87 | !!---------------------------------------------------------------------- |
---|
| 88 | !! logical units |
---|
| 89 | !!---------------------------------------------------------------------- |
---|
[1685] | 90 | INTEGER :: numstp = -1 !: logical unit for time step |
---|
[1579] | 91 | INTEGER :: numout = 6 !: logical unit for output print |
---|
[1685] | 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 |
---|
[544] | 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) |
---|
[1056] | 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 |
---|
[544] | 106 | CHARACTER (len=64) :: cform_err = "(/,' ===>>> : E R R O R', /,' ===========',/)" !: |
---|
| 107 | CHARACTER (len=64) :: cform_war = "(/,' ===>>> : W A R N I N G', /,' ===============',/)" !: |
---|
[1579] | 108 | LOGICAL :: lwp = .FALSE. !: boolean : true on the 1st processor only |
---|
[544] | 109 | LOGICAL :: lsp_area = .TRUE. !: to make a control print over a specific area |
---|
| 110 | !!---------------------------------------------------------------------- |
---|
[1056] | 111 | !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008) |
---|
[1146] | 112 | !! $Id$ |
---|
[544] | 113 | !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) |
---|
| 114 | !!---------------------------------------------------------------------- |
---|
| 115 | |
---|
| 116 | CONTAINS |
---|
| 117 | |
---|
| 118 | SUBROUTINE ctl_stop( cd1, cd2, cd3, cd4, cd5, & |
---|
| 119 | & cd6, cd7, cd8, cd9, cd10 ) |
---|
[1056] | 120 | !!---------------------------------------------------------------------- |
---|
[544] | 121 | !! *** ROUTINE stop_opa *** |
---|
| 122 | !! |
---|
[1056] | 123 | !! ** Purpose : print in ocean.outpput file a error message and |
---|
| 124 | !! increment the error number (nstop) by one. |
---|
| 125 | !!---------------------------------------------------------------------- |
---|
[544] | 126 | CHARACTER(len=*), INTENT(in), OPTIONAL :: cd1, cd2, cd3, cd4, cd5 |
---|
| 127 | CHARACTER(len=*), INTENT(in), OPTIONAL :: cd6, cd7, cd8, cd9, cd10 |
---|
[1056] | 128 | !!---------------------------------------------------------------------- |
---|
[544] | 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 |
---|
[1685] | 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) |
---|
[544] | 148 | ! |
---|
| 149 | END SUBROUTINE ctl_stop |
---|
| 150 | |
---|
| 151 | |
---|
| 152 | SUBROUTINE ctl_warn( cd1, cd2, cd3, cd4, cd5, & |
---|
| 153 | & cd6, cd7, cd8, cd9, cd10 ) |
---|
[1056] | 154 | !!---------------------------------------------------------------------- |
---|
[544] | 155 | !! *** ROUTINE stop_warn *** |
---|
| 156 | !! |
---|
[1056] | 157 | !! ** Purpose : print in ocean.outpput file a error message and |
---|
| 158 | !! increment the warning number (nwarn) by one. |
---|
| 159 | !!---------------------------------------------------------------------- |
---|
[544] | 160 | CHARACTER(len=*), INTENT(in), OPTIONAL :: cd1, cd2, cd3, cd4, cd5 |
---|
| 161 | CHARACTER(len=*), INTENT(in), OPTIONAL :: cd6, cd7, cd8, cd9, cd10 |
---|
[1056] | 162 | !!---------------------------------------------------------------------- |
---|
[544] | 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 | |
---|
[1581] | 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 |
---|
| 238 | 100 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 | |
---|
[544] | 258 | FUNCTION getunit() |
---|
[1056] | 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 | ! |
---|
[544] | 279 | END FUNCTION getunit |
---|
| 280 | |
---|
| 281 | !!===================================================================== |
---|
| 282 | END MODULE in_out_manager |
---|