[3] | 1 | MODULE stpctl |
---|
[1489] | 2 | !!====================================================================== |
---|
[3] | 3 | !! *** MODULE stpctl *** |
---|
| 4 | !! Ocean run control : gross check of the ocean time stepping |
---|
[1489] | 5 | !!====================================================================== |
---|
| 6 | !! History : OPA ! 1991-03 (G. Madec) Original code |
---|
| 7 | !! 6.0 ! 1992-06 (M. Imbard) |
---|
| 8 | !! 8.0 ! 1997-06 (A.M. Treguier) |
---|
| 9 | !! NEMO 1.0 ! 2002-06 (G. Madec) F90: Free form and module |
---|
| 10 | !! 2.0 ! 2009-07 (G. Madec) Add statistic for time-spliting |
---|
[9019] | 11 | !! 3.7 ! 2016-09 (G. Madec) Remove solver |
---|
| 12 | !! 4.0 ! 2017-04 (G. Madec) regroup global communications |
---|
[1489] | 13 | !!---------------------------------------------------------------------- |
---|
[3] | 14 | |
---|
| 15 | !!---------------------------------------------------------------------- |
---|
| 16 | !! stp_ctl : Control the run |
---|
| 17 | !!---------------------------------------------------------------------- |
---|
| 18 | USE oce ! ocean dynamics and tracers variables |
---|
| 19 | USE dom_oce ! ocean space and time domain variables |
---|
[6140] | 20 | USE c1d ! 1D vertical configuration |
---|
[12933] | 21 | USE zdf_oce , ONLY : ln_zad_Aimp ! ocean vertical physics variables |
---|
| 22 | USE wet_dry, ONLY : ll_wd, ssh_ref ! reference depth for negative bathy |
---|
| 23 | ! |
---|
[9210] | 24 | USE diawri ! Standard run outputs (dia_wri_state routine) |
---|
[3] | 25 | USE in_out_manager ! I/O manager |
---|
| 26 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
| 27 | USE lib_mpp ! distributed memory computing |
---|
[14131] | 28 | USE eosbn2, ONLY: ln_SEOS, rn_b0 |
---|
[14127] | 29 | ! |
---|
[9441] | 30 | USE netcdf ! NetCDF library |
---|
[3] | 31 | IMPLICIT NONE |
---|
| 32 | PRIVATE |
---|
| 33 | |
---|
| 34 | PUBLIC stp_ctl ! routine called by step.F90 |
---|
[9441] | 35 | |
---|
[14318] | 36 | INTEGER, PARAMETER :: jpvar = 8 |
---|
| 37 | INTEGER :: nrunid ! netcdf file id |
---|
| 38 | INTEGER, DIMENSION(jpvar) :: nvarid ! netcdf variable id |
---|
[3] | 39 | !!---------------------------------------------------------------------- |
---|
[9598] | 40 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
[1489] | 41 | !! $Id$ |
---|
[10068] | 42 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
[1489] | 43 | !!---------------------------------------------------------------------- |
---|
[3] | 44 | CONTAINS |
---|
| 45 | |
---|
[12933] | 46 | SUBROUTINE stp_ctl( kt, Kmm ) |
---|
[3] | 47 | !!---------------------------------------------------------------------- |
---|
| 48 | !! *** ROUTINE stp_ctl *** |
---|
[14318] | 49 | !! |
---|
[3] | 50 | !! ** Purpose : Control the run |
---|
| 51 | !! |
---|
| 52 | !! ** Method : - Save the time step in numstp |
---|
[12933] | 53 | !! - Stop the run IF problem encountered by setting nstop > 0 |
---|
[10425] | 54 | !! Problems checked: |ssh| maximum larger than 10 m |
---|
[9019] | 55 | !! |U| maximum larger than 10 m/s |
---|
| 56 | !! negative sea surface salinity |
---|
[3] | 57 | !! |
---|
[9019] | 58 | !! ** Actions : "time.step" file = last ocean time-step |
---|
| 59 | !! "run.stat" file = run statistics |
---|
[12933] | 60 | !! nstop indicator sheared among all local domain |
---|
[3] | 61 | !!---------------------------------------------------------------------- |
---|
[6140] | 62 | INTEGER, INTENT(in ) :: kt ! ocean time-step index |
---|
[12933] | 63 | INTEGER, INTENT(in ) :: Kmm ! ocean time level index |
---|
[1489] | 64 | !! |
---|
[14318] | 65 | INTEGER, PARAMETER :: jptst = 4 |
---|
[12933] | 66 | INTEGER :: ji ! dummy loop indices |
---|
| 67 | INTEGER :: idtime, istatus |
---|
[14318] | 68 | INTEGER , DIMENSION(jptst) :: iareasum, iareamin, iareamax |
---|
| 69 | INTEGER , DIMENSION(3,jptst) :: iloc ! min/max loc indices |
---|
[14127] | 70 | REAL(wp) :: zzz, zminsal, zmaxsal ! local real |
---|
[14318] | 71 | REAL(wp), DIMENSION(jpvar+1) :: zmax |
---|
| 72 | REAL(wp), DIMENSION(jptst) :: zmaxlocal |
---|
[13616] | 73 | LOGICAL :: ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce |
---|
[12933] | 74 | LOGICAL, DIMENSION(jpi,jpj,jpk) :: llmsk |
---|
| 75 | CHARACTER(len=20) :: clname |
---|
[3] | 76 | !!---------------------------------------------------------------------- |
---|
[12933] | 77 | IF( nstop > 0 .AND. ngrdstop > -1 ) RETURN ! stpctl was already called by a child grid |
---|
[6140] | 78 | ! |
---|
[12933] | 79 | ll_wrtstp = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) |
---|
[14318] | 80 | ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 |
---|
[12933] | 81 | ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm |
---|
| 82 | ! |
---|
| 83 | IF( kt == nit000 ) THEN |
---|
| 84 | ! |
---|
| 85 | IF( lwp ) THEN |
---|
| 86 | WRITE(numout,*) |
---|
| 87 | WRITE(numout,*) 'stp_ctl : time-stepping control' |
---|
| 88 | WRITE(numout,*) '~~~~~~~' |
---|
| 89 | ENDIF |
---|
| 90 | ! ! open time.step ascii file, done only by 1st subdomain |
---|
| 91 | IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
| 92 | ! |
---|
| 93 | IF( ll_wrtruns ) THEN |
---|
| 94 | ! ! open run.stat ascii file, done only by 1st subdomain |
---|
[10425] | 95 | CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) |
---|
[12933] | 96 | ! ! open run.stat.nc netcdf file, done only by 1st subdomain |
---|
[9565] | 97 | clname = 'run.stat.nc' |
---|
| 98 | IF( .NOT. Agrif_Root() ) clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) |
---|
[12933] | 99 | istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid ) |
---|
| 100 | istatus = NF90_DEF_DIM( nrunid, 'time', NF90_UNLIMITED, idtime ) |
---|
| 101 | istatus = NF90_DEF_VAR( nrunid, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), nvarid(1) ) |
---|
| 102 | istatus = NF90_DEF_VAR( nrunid, 'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid(2) ) |
---|
| 103 | istatus = NF90_DEF_VAR( nrunid, 's_min', NF90_DOUBLE, (/ idtime /), nvarid(3) ) |
---|
| 104 | istatus = NF90_DEF_VAR( nrunid, 's_max', NF90_DOUBLE, (/ idtime /), nvarid(4) ) |
---|
| 105 | istatus = NF90_DEF_VAR( nrunid, 't_min', NF90_DOUBLE, (/ idtime /), nvarid(5) ) |
---|
| 106 | istatus = NF90_DEF_VAR( nrunid, 't_max', NF90_DOUBLE, (/ idtime /), nvarid(6) ) |
---|
[10364] | 107 | IF( ln_zad_Aimp ) THEN |
---|
[12933] | 108 | istatus = NF90_DEF_VAR( nrunid, 'Cf_max', NF90_DOUBLE, (/ idtime /), nvarid(7) ) |
---|
| 109 | istatus = NF90_DEF_VAR( nrunid,'abs_wi_max',NF90_DOUBLE, (/ idtime /), nvarid(8) ) |
---|
[10364] | 110 | ENDIF |
---|
[12933] | 111 | istatus = NF90_ENDDEF(nrunid) |
---|
[9441] | 112 | ENDIF |
---|
[14318] | 113 | ! |
---|
[3] | 114 | ENDIF |
---|
[6140] | 115 | ! |
---|
[12933] | 116 | ! !== write current time step ==! |
---|
| 117 | ! !== done only by 1st subdomain at writting timestep ==! |
---|
| 118 | IF( lwm .AND. ll_wrtstp ) THEN |
---|
[9019] | 119 | WRITE ( numstp, '(1x, i8)' ) kt |
---|
| 120 | REWIND( numstp ) |
---|
[3] | 121 | ENDIF |
---|
[12933] | 122 | ! !== test of local extrema ==! |
---|
| 123 | ! !== done by all processes at every time step ==! |
---|
[13458] | 124 | ! |
---|
| 125 | llmsk( 1:Nis1,:,:) = .FALSE. ! exclude halos from the checked region |
---|
| 126 | llmsk(Nie1: jpi,:,:) = .FALSE. |
---|
| 127 | llmsk(:, 1:Njs1,:) = .FALSE. |
---|
| 128 | llmsk(:,Nje1: jpj,:) = .FALSE. |
---|
| 129 | ! |
---|
| 130 | llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0) == 1._wp ! define only the inner domain |
---|
[13616] | 131 | ! |
---|
| 132 | ll_0oce = .NOT. ANY( llmsk(:,:,1) ) ! no ocean point in the inner domain? |
---|
| 133 | ! |
---|
[13216] | 134 | IF( ll_wd ) THEN |
---|
| 135 | zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref ), mask = llmsk(:,:,1) ) ! ssh max |
---|
| 136 | ELSE |
---|
| 137 | zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) ), mask = llmsk(:,:,1) ) ! ssh max |
---|
[9023] | 138 | ENDIF |
---|
[13458] | 139 | llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp ! define only the inner domain |
---|
[13216] | 140 | zmax(2) = MAXVAL( ABS( uu(:,:,:,Kmm) ), mask = llmsk ) ! velocity max (zonal only) |
---|
[13458] | 141 | llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp ! define only the inner domain |
---|
[13216] | 142 | zmax(3) = MAXVAL( -ts(:,:,:,jp_sal,Kmm), mask = llmsk ) ! minus salinity max |
---|
| 143 | zmax(4) = MAXVAL( ts(:,:,:,jp_sal,Kmm), mask = llmsk ) ! salinity max |
---|
| 144 | IF( ll_colruns .OR. jpnij == 1 ) THEN ! following variables are used only in the netcdf file |
---|
| 145 | zmax(5) = MAXVAL( -ts(:,:,:,jp_tem,Kmm), mask = llmsk ) ! minus temperature max |
---|
| 146 | zmax(6) = MAXVAL( ts(:,:,:,jp_tem,Kmm), mask = llmsk ) ! temperature max |
---|
| 147 | IF( ln_zad_Aimp ) THEN |
---|
| 148 | zmax(7) = MAXVAL( Cu_adv(:,:,:) , mask = llmsk ) ! partitioning coeff. max |
---|
| 149 | llmsk(:,:,:) = wmask(:,:,:) == 1._wp |
---|
| 150 | zmax(8) = MAXVAL( ABS( wi(:,:,:) ) , mask = llmsk ) ! implicit vertical vel. max |
---|
| 151 | ELSE |
---|
| 152 | zmax(7:8) = 0._wp |
---|
[12933] | 153 | ENDIF |
---|
[13216] | 154 | ELSE |
---|
| 155 | zmax(5:8) = 0._wp |
---|
[10364] | 156 | ENDIF |
---|
[14318] | 157 | zmax(jpvar+1) = REAL( nstop, wp ) ! stop indicator |
---|
[13616] | 158 | ! |
---|
[12933] | 159 | ! !== get global extrema ==! |
---|
| 160 | ! !== done by all processes if writting run.stat ==! |
---|
[10570] | 161 | IF( ll_colruns ) THEN |
---|
[14318] | 162 | zmaxlocal(:) = zmax(1:jptst) |
---|
[13616] | 163 | CALL mpp_max( "stpctl", zmax ) ! max over the global domain: ok even of ll_0oce = .true. |
---|
[14318] | 164 | nstop = NINT( zmax(jpvar+1) ) ! update nstop indicator (now sheared among all local domains) |
---|
[13616] | 165 | ELSE |
---|
| 166 | ! if no ocean point: MAXVAL returns -HUGE => we must overwrite this value to avoid error handling bellow. |
---|
[14318] | 167 | IF( ll_0oce ) zmax(1:jptst) = (/ 0._wp, 0._wp, -1._wp, 1._wp /) ! default "valid" values... |
---|
[9210] | 168 | ENDIF |
---|
[13616] | 169 | ! |
---|
[14318] | 170 | zmax(3) = -zmax(3) ! move back from max(-zz) to min(zz) : easier to manage! |
---|
| 171 | zmax(5) = -zmax(5) ! move back from max(-zz) to min(zz) : easier to manage! |
---|
| 172 | IF( ll_colruns ) zmaxlocal(3) = -zmaxlocal(3) ! move back from max(-zz) to min(zz) : easier to manage! |
---|
[13616] | 173 | ! |
---|
[12933] | 174 | ! !== write "run.stat" files ==! |
---|
| 175 | ! !== done only by 1st subdomain at writting timestep ==! |
---|
[10570] | 176 | IF( ll_wrtruns ) THEN |
---|
[14318] | 177 | WRITE(numrun,9500) kt, zmax(1:jptst) |
---|
| 178 | DO ji = 1, jpvar - 2 * COUNT( .NOT. (/ln_zad_Aimp/) ) |
---|
[13616] | 179 | istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) ) |
---|
| 180 | END DO |
---|
[12933] | 181 | IF( kt == nitend ) istatus = NF90_CLOSE(nrunid) |
---|
[14127] | 182 | END IF |
---|
[12933] | 183 | ! !== error handling ==! |
---|
| 184 | ! !== done by all processes at every time step ==! |
---|
| 185 | ! |
---|
[14131] | 186 | IF ( ln_SEOS.AND.(rn_b0==0._wp) ) THEN ! Discard checks on salinity |
---|
[14318] | 187 | zmaxsal = HUGE(1._wp) ! if not used in eos |
---|
| 188 | zminsal = -HUGE(1._wp) |
---|
[14127] | 189 | ELSE |
---|
| 190 | zmaxsal = 100._wp |
---|
| 191 | zminsal = 0._wp |
---|
| 192 | ENDIF |
---|
| 193 | ! |
---|
[14318] | 194 | IF( zmax(1) > 20._wp .OR. & ! too large sea surface height ( > 20 m ) |
---|
| 195 | & zmax(2) > 10._wp .OR. & ! too large velocity ( > 10 m/s) |
---|
| 196 | & zmax(3) <= zminsal .OR. & ! negative or zero sea surface salinity |
---|
| 197 | & zmax(4) >= zmaxsal .OR. & ! too large sea surface salinity ( > 100 ) |
---|
| 198 | & zmax(4) < zminsal .OR. & ! too large sea surface salinity (keep this line for sea-ice) |
---|
| 199 | & ISNAN( SUM(zmax(1:jptst)) ) .OR. & ! NaN encounter in the tests |
---|
| 200 | & ABS( SUM(zmax(1:jptst)) ) > HUGE(1._wp) ) THEN ! Infinity encounter in the tests |
---|
[12933] | 201 | ! |
---|
| 202 | iloc(:,:) = 0 |
---|
| 203 | IF( ll_colruns ) THEN ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc |
---|
| 204 | ! first: close the netcdf file, so we can read it |
---|
| 205 | IF( lwm .AND. kt /= nitend ) istatus = NF90_CLOSE(nrunid) |
---|
| 206 | ! get global loc on the min/max |
---|
[13458] | 207 | llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0 ) == 1._wp ! define only the inner domain |
---|
| 208 | CALL mpp_maxloc( 'stpctl', ABS(ssh(:,:, Kmm)), llmsk(:,:,1), zzz, iloc(1:2,1) ) ! mpp_maxloc ok if mask = F |
---|
| 209 | llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp ! define only the inner domain |
---|
| 210 | CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:, Kmm)), llmsk(:,:,:), zzz, iloc(1:3,2) ) |
---|
| 211 | llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp ! define only the inner domain |
---|
| 212 | CALL mpp_minloc( 'stpctl', ts(:,:,:,jp_sal,Kmm) , llmsk(:,:,:), zzz, iloc(1:3,3) ) |
---|
| 213 | CALL mpp_maxloc( 'stpctl', ts(:,:,:,jp_sal,Kmm) , llmsk(:,:,:), zzz, iloc(1:3,4) ) |
---|
[12933] | 214 | ! find which subdomain has the max. |
---|
| 215 | iareamin(:) = jpnij+1 ; iareamax(:) = 0 ; iareasum(:) = 0 |
---|
[14318] | 216 | DO ji = 1, jptst |
---|
[12933] | 217 | IF( zmaxlocal(ji) == zmax(ji) ) THEN |
---|
| 218 | iareamin(ji) = narea ; iareamax(ji) = narea ; iareasum(ji) = 1 |
---|
| 219 | ENDIF |
---|
| 220 | END DO |
---|
| 221 | CALL mpp_min( "stpctl", iareamin ) ! min over the global domain |
---|
| 222 | CALL mpp_max( "stpctl", iareamax ) ! max over the global domain |
---|
| 223 | CALL mpp_sum( "stpctl", iareasum ) ! sum over the global domain |
---|
| 224 | ELSE ! find local min and max locations: |
---|
| 225 | ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc |
---|
[13458] | 226 | llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0 ) == 1._wp ! define only the inner domain |
---|
| 227 | iloc(1:2,1) = MAXLOC( ABS( ssh(:,:, Kmm)), mask = llmsk(:,:,1) ) |
---|
| 228 | llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp ! define only the inner domain |
---|
| 229 | iloc(1:3,2) = MAXLOC( ABS( uu(:,:,:, Kmm)), mask = llmsk(:,:,:) ) |
---|
| 230 | llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp ! define only the inner domain |
---|
| 231 | iloc(1:3,3) = MINLOC( ts(:,:,:,jp_sal,Kmm) , mask = llmsk(:,:,:) ) |
---|
| 232 | iloc(1:3,4) = MAXLOC( ts(:,:,:,jp_sal,Kmm) , mask = llmsk(:,:,:) ) |
---|
[14318] | 233 | DO ji = 1, jptst ! local domain indices ==> global domain indices, excluding halos |
---|
[13458] | 234 | iloc(1:2,ji) = (/ mig0(iloc(1,ji)), mjg0(iloc(2,ji)) /) |
---|
| 235 | END DO |
---|
[12933] | 236 | iareamin(:) = narea ; iareamax(:) = narea ; iareasum(:) = 1 ! this is local information |
---|
[7852] | 237 | ENDIF |
---|
[12933] | 238 | ! |
---|
[10425] | 239 | WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m or |U| > 10 m/s or S <= 0 or S >= 100 or NaN encounter in the tests' |
---|
[13616] | 240 | CALL wrt_line( ctmp2, kt, '|ssh| max', zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) |
---|
| 241 | CALL wrt_line( ctmp3, kt, '|U| max', zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) |
---|
| 242 | CALL wrt_line( ctmp4, kt, 'Sal min', zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) ) |
---|
| 243 | CALL wrt_line( ctmp5, kt, 'Sal max', zmax(4), iloc(:,4), iareasum(4), iareamin(4), iareamax(4) ) |
---|
[12933] | 244 | IF( Agrif_Root() ) THEN |
---|
| 245 | WRITE(ctmp6,*) ' ===> output of last computed fields in output.abort* files' |
---|
[10425] | 246 | ELSE |
---|
[12933] | 247 | WRITE(ctmp6,*) ' ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files' |
---|
[7852] | 248 | ENDIF |
---|
[9210] | 249 | ! |
---|
[12933] | 250 | CALL dia_wri_state( Kmm, 'output.abort' ) ! create an output.abort file |
---|
| 251 | ! |
---|
[14318] | 252 | IF( ll_colruns .OR. jpnij == 1 ) THEN ! all processes synchronized -> use lwp to print in opened ocean.output files |
---|
[13115] | 253 | IF(lwp) THEN ; CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) |
---|
| 254 | ELSE ; nstop = MAX(1, nstop) ! make sure nstop > 0 (automatically done when calling ctl_stop) |
---|
| 255 | ENDIF |
---|
[12933] | 256 | ELSE ! only mpi subdomains with errors are here -> STOP now |
---|
| 257 | CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) |
---|
| 258 | ENDIF |
---|
| 259 | ! |
---|
[7852] | 260 | ENDIF |
---|
[10425] | 261 | ! |
---|
[13115] | 262 | IF( nstop > 0 ) THEN ! an error was detected and we did not abort yet... |
---|
| 263 | ngrdstop = Agrif_Fixed() ! store which grid got this error |
---|
| 264 | IF( .NOT. ll_colruns .AND. jpnij > 1 ) CALL ctl_stop( 'STOP' ) ! we must abort here to avoid MPI deadlock |
---|
| 265 | ENDIF |
---|
| 266 | ! |
---|
[9808] | 267 | 9500 FORMAT(' it :', i8, ' |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16,' S_max: ', D23.16) |
---|
[7852] | 268 | ! |
---|
[3] | 269 | END SUBROUTINE stp_ctl |
---|
| 270 | |
---|
[12933] | 271 | |
---|
| 272 | SUBROUTINE wrt_line( cdline, kt, cdprefix, pval, kloc, ksum, kmin, kmax ) |
---|
| 273 | !!---------------------------------------------------------------------- |
---|
| 274 | !! *** ROUTINE wrt_line *** |
---|
| 275 | !! |
---|
| 276 | !! ** Purpose : write information line |
---|
| 277 | !! |
---|
| 278 | !!---------------------------------------------------------------------- |
---|
| 279 | CHARACTER(len=*), INTENT( out) :: cdline |
---|
| 280 | CHARACTER(len=*), INTENT(in ) :: cdprefix |
---|
| 281 | REAL(wp), INTENT(in ) :: pval |
---|
| 282 | INTEGER, DIMENSION(3), INTENT(in ) :: kloc |
---|
| 283 | INTEGER, INTENT(in ) :: kt, ksum, kmin, kmax |
---|
| 284 | ! |
---|
| 285 | CHARACTER(len=80) :: clsuff |
---|
| 286 | CHARACTER(len=9 ) :: clkt, clsum, clmin, clmax |
---|
| 287 | CHARACTER(len=9 ) :: cli, clj, clk |
---|
| 288 | CHARACTER(len=1 ) :: clfmt |
---|
| 289 | CHARACTER(len=4 ) :: cl4 ! needed to be able to compile with Agrif, I don't know why |
---|
| 290 | INTEGER :: ifmtk |
---|
| 291 | !!---------------------------------------------------------------------- |
---|
| 292 | WRITE(clkt , '(i9)') kt |
---|
| 293 | |
---|
| 294 | WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij ,wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) |
---|
| 295 | !!! WRITE(clsum, '(i'//clfmt//')') ksum ! this is creating a compilation error with AGRIF |
---|
| 296 | cl4 = '(i'//clfmt//')' ; WRITE(clsum, cl4) ksum |
---|
[13009] | 297 | WRITE(clfmt, '(i1)') INT(LOG10(REAL(MAX(1,jpnij-1),wp))) + 1 ! how many digits to we need to write ? (we decide max = 9) |
---|
[12933] | 298 | cl4 = '(i'//clfmt//')' ; WRITE(clmin, cl4) kmin-1 |
---|
| 299 | WRITE(clmax, cl4) kmax-1 |
---|
| 300 | ! |
---|
| 301 | WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpiglo,wp))) + 1 ! how many digits to we need to write jpiglo? (we decide max = 9) |
---|
| 302 | cl4 = '(i'//clfmt//')' ; WRITE(cli, cl4) kloc(1) ! this is ok with AGRIF |
---|
| 303 | WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpjglo,wp))) + 1 ! how many digits to we need to write jpjglo? (we decide max = 9) |
---|
| 304 | cl4 = '(i'//clfmt//')' ; WRITE(clj, cl4) kloc(2) ! this is ok with AGRIF |
---|
| 305 | ! |
---|
| 306 | IF( ksum == 1 ) THEN ; WRITE(clsuff,9100) TRIM(clmin) |
---|
| 307 | ELSE ; WRITE(clsuff,9200) TRIM(clsum), TRIM(clmin), TRIM(clmax) |
---|
| 308 | ENDIF |
---|
| 309 | IF(kloc(3) == 0) THEN |
---|
| 310 | ifmtk = INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) |
---|
| 311 | clk = REPEAT(' ', ifmtk) ! create the equivalent in blank string |
---|
| 312 | WRITE(cdline,9300) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), clk(1:ifmtk), TRIM(clsuff) |
---|
| 313 | ELSE |
---|
| 314 | WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpk,wp))) + 1 ! how many digits to we need to write jpk? (we decide max = 9) |
---|
| 315 | !!! WRITE(clk, '(i'//clfmt//')') kloc(3) ! this is creating a compilation error with AGRIF |
---|
| 316 | cl4 = '(i'//clfmt//')' ; WRITE(clk, cl4) kloc(3) ! this is ok with AGRIF |
---|
| 317 | WRITE(cdline,9400) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), TRIM(clk), TRIM(clsuff) |
---|
| 318 | ENDIF |
---|
| 319 | ! |
---|
| 320 | 9100 FORMAT('MPI rank ', a) |
---|
| 321 | 9200 FORMAT('found in ', a, ' MPI tasks, spread out among ranks ', a, ' to ', a) |
---|
| 322 | 9300 FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j ', a, ' ', a, ' ', a, ' ', a) |
---|
| 323 | 9400 FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j k ', a, ' ', a, ' ', a, ' ', a) |
---|
| 324 | ! |
---|
| 325 | END SUBROUTINE wrt_line |
---|
| 326 | |
---|
| 327 | |
---|
[3] | 328 | !!====================================================================== |
---|
| 329 | END MODULE stpctl |
---|