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.
Changeset 13197 for NEMO/branches/2020/dev_r12563_ASINTER-06_ABL_improvement/tests/CANAL/MY_SRC/stpctl.F90 – NEMO

Ignore:
Timestamp:
2020-07-01T16:09:00+02:00 (4 years ago)
Author:
gsamson
Message:

merge with trunk@r13136 with a more recent svn version; pass all SETTE tests; results identical to trunk@r13136; ticket #2419

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2020/dev_r12563_ASINTER-06_ABL_improvement/tests/CANAL/MY_SRC/stpctl.F90

    r13159 r13197  
    1919   USE dom_oce         ! ocean space and time domain variables  
    2020   USE c1d             ! 1D vertical configuration 
    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    !   
    2421   USE diawri          ! Standard run outputs       (dia_wri_state routine) 
     22   ! 
    2523   USE in_out_manager  ! I/O manager 
    2624   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    2725   USE lib_mpp         ! distributed memory computing 
    28    ! 
     26   USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables 
     27   USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy 
     28 
    2929   USE netcdf          ! NetCDF library 
    3030   IMPLICIT NONE 
     
    3333   PUBLIC stp_ctl           ! routine called by step.F90 
    3434 
    35    INTEGER                ::   nrunid   ! netcdf file id 
    36    INTEGER, DIMENSION(8)  ::   nvarid   ! netcdf variable id 
     35   INTEGER  ::   idrun, idtime, idssh, idu, ids1, ids2, idt1, idt2, idc1, idw1, istatus 
     36   LOGICAL  ::   lsomeoce 
    3737   !!---------------------------------------------------------------------- 
    3838   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
     
    4242CONTAINS 
    4343 
    44    SUBROUTINE stp_ctl( kt, Kmm ) 
     44   SUBROUTINE stp_ctl( kt, Kbb, Kmm, kindic ) 
    4545      !!---------------------------------------------------------------------- 
    4646      !!                    ***  ROUTINE stp_ctl  *** 
     
    5050      !! ** Method  : - Save the time step in numstp 
    5151      !!              - Print it each 50 time steps 
    52       !!              - Stop the run IF problem encountered by setting nstop > 0 
     52      !!              - Stop the run IF problem encountered by setting indic=-3 
    5353      !!                Problems checked: |ssh| maximum larger than 10 m 
    5454      !!                                  |U|   maximum larger than 10 m/s  
     
    5757      !! ** Actions :   "time.step" file = last ocean time-step 
    5858      !!                "run.stat"  file = run statistics 
    59       !!                 nstop indicator sheared among all local domain 
     59      !!                nstop indicator sheared among all local domain (lk_mpp=T) 
    6060      !!---------------------------------------------------------------------- 
    6161      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index 
    62       INTEGER, INTENT(in   ) ::   Kmm      ! ocean time level index 
     62      INTEGER, INTENT(in   ) ::   Kbb, Kmm      ! ocean time level index 
     63      INTEGER, INTENT(inout) ::   kindic   ! error indicator 
    6364      !! 
    64       INTEGER                         ::   ji                                    ! dummy loop indices 
    65       INTEGER                         ::   idtime, istatus 
    66       INTEGER , DIMENSION(9)          ::   iareasum, iareamin, iareamax 
    67       INTEGER , DIMENSION(3,4)        ::   iloc                                  ! min/max loc indices 
    68       REAL(wp)                        ::   zzz                                   ! local real  
    69       REAL(wp), DIMENSION(9)          ::   zmax, zmaxlocal 
    70       LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns 
    71       LOGICAL, DIMENSION(jpi,jpj,jpk) ::   llmsk 
    72       CHARACTER(len=20)               ::   clname 
     65      INTEGER                ::   ji, jj, jk          ! dummy loop indices 
     66      INTEGER, DIMENSION(2)  ::   ih                  ! min/max loc indices 
     67      INTEGER, DIMENSION(3)  ::   iu, is1, is2        ! min/max loc indices 
     68      REAL(wp)               ::   zzz                 ! local real  
     69      REAL(wp), DIMENSION(9) ::   zmax 
     70      LOGICAL                ::   ll_wrtstp, ll_colruns, ll_wrtruns 
     71      CHARACTER(len=20) :: clname 
    7372      !!---------------------------------------------------------------------- 
    74       IF( nstop > 0 .AND. ngrdstop > -1 )   RETURN   !   stpctl was already called by a child grid 
    75       ! 
    76       ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 
    77       ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1  
    78       ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 
    79       ! 
    80       IF( kt == nit000 ) THEN 
    81          ! 
    82          IF( lwp ) THEN 
    83             WRITE(numout,*) 
    84             WRITE(numout,*) 'stp_ctl : time-stepping control' 
    85             WRITE(numout,*) '~~~~~~~' 
    86          ENDIF 
    87          !                                ! open time.step    ascii file, done only by 1st subdomain 
    88          IF( lwm )   CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 
    89          ! 
    90          IF( ll_wrtruns ) THEN 
    91             !                             ! open run.stat     ascii file, done only by 1st subdomain 
     73      ! 
     74      ll_wrtstp  = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 
     75      ll_colruns = ll_wrtstp .AND. ( sn_cfctl%l_runstat ) 
     76      ll_wrtruns = ll_colruns .AND. lwm 
     77      IF( kt == nit000 .AND. lwp ) THEN 
     78         WRITE(numout,*) 
     79         WRITE(numout,*) 'stp_ctl : time-stepping control' 
     80         WRITE(numout,*) '~~~~~~~' 
     81         !                                ! open time.step file 
     82         IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 
     83         !                                ! open run.stat file(s) at start whatever 
     84         !                                ! the value of sn_cfctl%ptimincr 
     85         IF( lwm .AND. ( sn_cfctl%l_runstat ) ) THEN 
    9286            CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 
    93             !                             ! open run.stat.nc netcdf file, done only by 1st subdomain 
    9487            clname = 'run.stat.nc' 
    9588            IF( .NOT. Agrif_Root() )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) 
    96             istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid ) 
    97             istatus = NF90_DEF_DIM( nrunid, 'time', NF90_UNLIMITED, idtime ) 
    98             istatus = NF90_DEF_VAR( nrunid, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), nvarid(1) ) 
    99             istatus = NF90_DEF_VAR( nrunid,   'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid(2) ) 
    100             istatus = NF90_DEF_VAR( nrunid,       's_min', NF90_DOUBLE, (/ idtime /), nvarid(3) ) 
    101             istatus = NF90_DEF_VAR( nrunid,       's_max', NF90_DOUBLE, (/ idtime /), nvarid(4) ) 
    102             istatus = NF90_DEF_VAR( nrunid,       't_min', NF90_DOUBLE, (/ idtime /), nvarid(5) ) 
    103             istatus = NF90_DEF_VAR( nrunid,       't_max', NF90_DOUBLE, (/ idtime /), nvarid(6) ) 
     89            istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, idrun ) 
     90            istatus = NF90_DEF_DIM( idrun, 'time', NF90_UNLIMITED, idtime ) 
     91            istatus = NF90_DEF_VAR( idrun, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), idssh ) 
     92            istatus = NF90_DEF_VAR( idrun,   'abs_u_max', NF90_DOUBLE, (/ idtime /), idu  ) 
     93            istatus = NF90_DEF_VAR( idrun,       's_min', NF90_DOUBLE, (/ idtime /), ids1 ) 
     94            istatus = NF90_DEF_VAR( idrun,       's_max', NF90_DOUBLE, (/ idtime /), ids2 ) 
     95            istatus = NF90_DEF_VAR( idrun,       't_min', NF90_DOUBLE, (/ idtime /), idt1 ) 
     96            istatus = NF90_DEF_VAR( idrun,       't_max', NF90_DOUBLE, (/ idtime /), idt2 ) 
    10497            IF( ln_zad_Aimp ) THEN 
    105                istatus = NF90_DEF_VAR( nrunid,   'Cf_max', NF90_DOUBLE, (/ idtime /), nvarid(7) ) 
    106                istatus = NF90_DEF_VAR( nrunid,'abs_wi_max',NF90_DOUBLE, (/ idtime /), nvarid(8) ) 
     98               istatus = NF90_DEF_VAR( idrun,   'abs_wi_max', NF90_DOUBLE, (/ idtime /), idw1 ) 
     99               istatus = NF90_DEF_VAR( idrun,       'Cf_max', NF90_DOUBLE, (/ idtime /), idc1 ) 
    107100            ENDIF 
    108             istatus = NF90_ENDDEF(nrunid) 
    109          ENDIF 
    110          !     
    111       ENDIF 
    112       ! 
    113       !                                   !==              write current time step              ==! 
    114       !                                   !==  done only by 1st subdomain at writting timestep  ==! 
    115       IF( lwm .AND. ll_wrtstp ) THEN 
     101            istatus = NF90_ENDDEF(idrun) 
     102            zmax(8:9) = 0._wp    ! initialise to zero in case ln_zad_Aimp option is not in use 
     103         ENDIF 
     104      ENDIF 
     105      IF( kt == nit000 )   lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0 
     106      ! 
     107      IF(lwm .AND. ll_wrtstp) THEN        !==  current time step  ==!   ("time.step" file) 
    116108         WRITE ( numstp, '(1x, i8)' )   kt 
    117109         REWIND( numstp ) 
    118110      ENDIF 
    119       !                                   !==            test of local extrema           ==! 
    120       !                                   !==  done by all processes at every time step  ==! 
    121       ! 
    122       ! define zmax default value. needed for land processors 
    123       IF( ll_colruns ) THEN    ! default value: must not be kept when calling mpp_max -> must be as small as possible 
    124          zmax(:) = -HUGE(1._wp) 
    125       ELSE                     ! default value: must not give true for any of the tests bellow (-> avoid manipulating HUGE...) 
    126          zmax(:) =  0._wp 
    127          zmax(3) = -1._wp      ! avoid salinity minimum at 0. 
    128       ENDIF 
    129       ! 
    130       llmsk(:,:,1) = ssmask(:,:) == 1._wp 
    131       IF( COUNT( llmsk(:,:,1) ) > 0 ) THEN   ! avoid huge values sent back for land processors... 
    132          IF( ll_wd ) THEN 
    133             zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref ), mask = llmsk(:,:,1) )   ! ssh max 
    134          ELSE 
    135             zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm)           ), mask = llmsk(:,:,1) )   ! ssh max 
    136          ENDIF 
    137       ENDIF 
    138       zmax(2) = MAXVAL( ABS( uu(:,:,:,Kmm) ) )                                       ! velocity max (zonal only) 
    139       llmsk(:,:,:) = tmask(:,:,:) == 1._wp 
    140       IF( COUNT( llmsk(:,:,:) ) > 0 ) THEN   ! avoid huge values sent back for land processors... 
    141          zmax(3) = MAXVAL( -ts(:,:,:,jp_sal,Kmm), mask = llmsk )                     ! minus salinity max 
    142          zmax(4) = MAXVAL(  ts(:,:,:,jp_sal,Kmm), mask = llmsk )                     !       salinity max 
    143          IF( ll_colruns .OR. jpnij == 1 ) THEN     ! following variables are used only in the netcdf file 
    144             zmax(5) = MAXVAL( -ts(:,:,:,jp_tem,Kmm), mask = llmsk )                  ! minus temperature max 
    145             zmax(6) = MAXVAL(  ts(:,:,:,jp_tem,Kmm), mask = llmsk )                  !       temperature max 
    146             IF( ln_zad_Aimp ) THEN 
    147                zmax(7) = MAXVAL(   Cu_adv(:,:,:)   , mask = llmsk )                  ! partitioning coeff. max 
    148                llmsk(:,:,:) = wmask(:,:,:) == 1._wp 
    149                IF( COUNT( llmsk(:,:,:) ) > 0 ) THEN   ! avoid huge values sent back for land processors... 
    150                   zmax(8) = MAXVAL(ABS( wi(:,:,:) ), mask = llmsk )                  ! implicit vertical vel. max 
    151                ENDIF 
    152             ENDIF 
    153          ENDIF 
    154       ENDIF 
    155       zmax(9) = REAL( nstop, wp )                                              ! stop indicator 
    156       !                                   !==               get global extrema             ==! 
    157       !                                   !==  done by all processes if writting run.stat  ==! 
     111      ! 
     112      !                                   !==  test of extrema  ==! 
     113      IF( ll_wd ) THEN 
     114         zmax(1) = MAXVAL(  ABS( ssh(:,:,Kmm) + ssh_ref*tmask(:,:,1) )  )        ! ssh max  
     115      ELSE 
     116         zmax(1) = MAXVAL(  ABS( ssh(:,:,Kmm) )  )                               ! ssh max 
     117      ENDIF 
     118      zmax(2) = MAXVAL(  ABS( uu(:,:,:,Kmm) )  )                                  ! velocity max (zonal only) 
     119      zmax(3) = MAXVAL( -ts(:,:,:,jp_sal,Kmm) , mask = tmask(:,:,:) == 1._wp )   ! minus salinity max 
     120      zmax(4) = MAXVAL(  ts(:,:,:,jp_sal,Kmm) , mask = tmask(:,:,:) == 1._wp )   !       salinity max 
     121      zmax(5) = MAXVAL( -ts(:,:,:,jp_tem,Kmm) , mask = tmask(:,:,:) == 1._wp )   ! minus temperature max 
     122      zmax(6) = MAXVAL(  ts(:,:,:,jp_tem,Kmm) , mask = tmask(:,:,:) == 1._wp )   !       temperature max 
     123      zmax(7) = REAL( nstop , wp )                                            ! stop indicator 
     124      IF( ln_zad_Aimp ) THEN 
     125         zmax(8) = MAXVAL(  ABS( wi(:,:,:) ) , mask = wmask(:,:,:) == 1._wp ) ! implicit vertical vel. max 
     126         zmax(9) = MAXVAL(   Cu_adv(:,:,:)   , mask = tmask(:,:,:) == 1._wp ) ! partitioning coeff. max 
     127      ENDIF 
     128      ! 
    158129      IF( ll_colruns ) THEN 
    159          zmaxlocal(:) = zmax(:) 
    160130         CALL mpp_max( "stpctl", zmax )          ! max over the global domain 
    161          nstop = NINT( zmax(9) )                 ! update nstop indicator (now sheared among all local domains) 
    162       ENDIF 
    163       !                                   !==              write "run.stat" files              ==! 
    164       !                                   !==  done only by 1st subdomain at writting timestep  ==! 
     131         nstop = NINT( zmax(7) )                 ! nstop indicator sheared among all local domains 
     132      ENDIF 
     133      !                                   !==  run statistics  ==!   ("run.stat" files) 
    165134      IF( ll_wrtruns ) THEN 
    166135         WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3), zmax(4) 
    167          istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) ) 
    168          istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) ) 
    169          istatus = NF90_PUT_VAR( nrunid, nvarid(3), (/-zmax(3)/), (/kt/), (/1/) ) 
    170          istatus = NF90_PUT_VAR( nrunid, nvarid(4), (/ zmax(4)/), (/kt/), (/1/) ) 
    171          istatus = NF90_PUT_VAR( nrunid, nvarid(5), (/-zmax(5)/), (/kt/), (/1/) ) 
    172          istatus = NF90_PUT_VAR( nrunid, nvarid(6), (/ zmax(6)/), (/kt/), (/1/) ) 
     136         istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) ) 
     137         istatus = NF90_PUT_VAR( idrun,   idu, (/ zmax(2)/), (/kt/), (/1/) ) 
     138         istatus = NF90_PUT_VAR( idrun,  ids1, (/-zmax(3)/), (/kt/), (/1/) ) 
     139         istatus = NF90_PUT_VAR( idrun,  ids2, (/ zmax(4)/), (/kt/), (/1/) ) 
     140         istatus = NF90_PUT_VAR( idrun,  idt1, (/-zmax(5)/), (/kt/), (/1/) ) 
     141         istatus = NF90_PUT_VAR( idrun,  idt2, (/ zmax(6)/), (/kt/), (/1/) ) 
    173142         IF( ln_zad_Aimp ) THEN 
    174             istatus = NF90_PUT_VAR( nrunid, nvarid(7), (/ zmax(7)/), (/kt/), (/1/) ) 
    175             istatus = NF90_PUT_VAR( nrunid, nvarid(8), (/ zmax(8)/), (/kt/), (/1/) ) 
    176          ENDIF 
    177          IF( kt == nitend )   istatus = NF90_CLOSE(nrunid) 
     143            istatus = NF90_PUT_VAR( idrun,  idw1, (/ zmax(8)/), (/kt/), (/1/) ) 
     144            istatus = NF90_PUT_VAR( idrun,  idc1, (/ zmax(9)/), (/kt/), (/1/) ) 
     145         ENDIF 
     146         IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun) 
     147         IF( kt == nitend         ) istatus = NF90_CLOSE(idrun) 
    178148      END IF 
    179       !                                   !==               error handling               ==! 
    180       !                                   !==  done by all processes at every time step  ==! 
    181       ! 
    182       IF(   zmax(1) >   20._wp .OR.   &                   ! too large sea surface height ( > 20 m ) 
    183          &  zmax(2) >   10._wp .OR.   &                   ! too large velocity ( > 10 m/s) 
    184 !!$         &  zmax(3) >=   0._wp .OR.   &                   ! negative or zero sea surface salinity 
    185 !!$         &  zmax(4) >= 100._wp .OR.   &                   ! too large sea surface salinity ( > 100 ) 
    186 !!$         &  zmax(4) <    0._wp .OR.   &                   ! too large sea surface salinity (keep this line for sea-ice) 
    187          &  ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR.   &               ! NaN encounter in the tests 
    188          &  ABS(   zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests 
     149      !                                   !==  error handling  ==! 
     150      IF( ( sn_cfctl%l_glochk .OR. lsomeoce ) .AND. (   &  ! domain contains some ocean points, check for sensible ranges 
     151         &  zmax(1) >   20._wp .OR.   &                    ! too large sea surface height ( > 20 m ) 
     152         &  zmax(2) >   10._wp .OR.   &                    ! too large velocity ( > 10 m/s) 
     153!!$         &  zmax(3) >=   0._wp .OR.   &                    ! negative or zero sea surface salinity 
     154!!$         &  zmax(4) >= 100._wp .OR.   &                    ! too large sea surface salinity ( > 100 ) 
     155!!$         &  zmax(4) <    0._wp .OR.   &                    ! too large sea surface salinity (keep this line for sea-ice) 
     156         &  ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) ) THEN   ! NaN encounter in the tests 
     157         IF( lk_mpp .AND. sn_cfctl%l_glochk ) THEN 
     158            ! have use mpp_max (because sn_cfctl%l_glochk=.T. and distributed) 
     159            CALL mpp_maxloc( 'stpctl', ABS(ssh(:,:,Kmm))        , ssmask(:,:)  , zzz, ih  ) 
     160            CALL mpp_maxloc( 'stpctl', ABS(uu(:,:,:,Kmm))          , umask (:,:,:), zzz, iu  ) 
     161            CALL mpp_minloc( 'stpctl', ts(:,:,:,jp_sal,Kmm), tmask (:,:,:), zzz, is1 ) 
     162            CALL mpp_maxloc( 'stpctl', ts(:,:,:,jp_sal,Kmm), tmask (:,:,:), zzz, is2 ) 
     163         ELSE 
     164            ! find local min and max locations 
     165            ih(:)  = MAXLOC( ABS( ssh(:,:,Kmm)   )                              ) + (/ nimpp - 1, njmpp - 1    /) 
     166            iu(:)  = MAXLOC( ABS( uu  (:,:,:,Kmm) )                              ) + (/ nimpp - 1, njmpp - 1, 0 /) 
     167            is1(:) = MINLOC( ts(:,:,:,jp_sal,Kmm), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 
     168            is2(:) = MAXLOC( ts(:,:,:,jp_sal,Kmm), mask = tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 
     169         ENDIF 
     170          
     171         WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests' 
     172         WRITE(ctmp2,9100) kt,   zmax(1), ih(1) , ih(2) 
     173         WRITE(ctmp3,9200) kt,   zmax(2), iu(1) , iu(2) , iu(3) 
     174         WRITE(ctmp4,9300) kt, - zmax(3), is1(1), is1(2), is1(3) 
     175         WRITE(ctmp5,9400) kt,   zmax(4), is2(1), is2(2), is2(3) 
     176         WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort.nc file' 
     177          
     178         CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file 
     179          
     180         IF( .NOT. sn_cfctl%l_glochk ) THEN 
     181            WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea 
     182            CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp8, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ctmp6 ) 
     183         ELSE 
     184            CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6, ' ' ) 
     185         ENDIF 
     186 
     187         kindic = -3 
    189188         ! 
    190          iloc(:,:) = 0 
    191          IF( ll_colruns ) THEN   ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc 
    192             ! first: close the netcdf file, so we can read it 
    193             IF( lwm .AND. kt /= nitend )   istatus = NF90_CLOSE(nrunid) 
    194             ! get global loc on the min/max 
    195             CALL mpp_maxloc( 'stpctl', ABS(ssh(:,:,         Kmm)), ssmask(:,:  ), zzz, iloc(1:2,1) )   ! mpp_maxloc ok if mask = F  
    196             CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:,       Kmm)),  umask(:,:,:), zzz, iloc(1:3,2) ) 
    197             CALL mpp_minloc( 'stpctl',      ts(:,:,:,jp_sal,Kmm) ,  tmask(:,:,:), zzz, iloc(1:3,3) ) 
    198             CALL mpp_maxloc( 'stpctl',      ts(:,:,:,jp_sal,Kmm) ,  tmask(:,:,:), zzz, iloc(1:3,4) ) 
    199             ! find which subdomain has the max. 
    200             iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0 
    201             DO ji = 1, 9 
    202                IF( zmaxlocal(ji) == zmax(ji) ) THEN 
    203                   iareamin(ji) = narea   ;   iareamax(ji) = narea   ;   iareasum(ji) = 1 
    204                ENDIF 
    205             END DO 
    206             CALL mpp_min( "stpctl", iareamin )         ! min over the global domain 
    207             CALL mpp_max( "stpctl", iareamax )         ! max over the global domain 
    208             CALL mpp_sum( "stpctl", iareasum )         ! sum over the global domain 
    209          ELSE                    ! find local min and max locations: 
    210             ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc 
    211             iloc(1:2,1) = MAXLOC( ABS( ssh(:,:,         Kmm)), mask = ssmask(:,:  ) == 1._wp ) + (/ nimpp - 1, njmpp - 1    /) 
    212             iloc(1:3,2) = MAXLOC( ABS(  uu(:,:,:,       Kmm)), mask =  umask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 
    213             iloc(1:3,3) = MINLOC(       ts(:,:,:,jp_sal,Kmm) , mask =  tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 
    214             iloc(1:3,4) = MAXLOC(       ts(:,:,:,jp_sal,Kmm) , mask =  tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 
    215             iareamin(:) = narea   ;   iareamax(:) = narea   ;   iareasum(:) = 1         ! this is local information 
    216          ENDIF 
    217          ! 
    218          WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests' 
    219          CALL wrt_line( ctmp2, kt, '|ssh| max',  zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 
    220          CALL wrt_line( ctmp3, kt, '|U|   max',  zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 
    221          CALL wrt_line( ctmp4, kt, 'Sal   min', -zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) ) 
    222          CALL wrt_line( ctmp5, kt, 'Sal   max',  zmax(4), iloc(:,4), iareasum(4), iareamin(4), iareamax(4) ) 
    223          IF( Agrif_Root() ) THEN 
    224             WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort* files' 
    225          ELSE 
    226             WRITE(ctmp6,*) '      ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files' 
    227          ENDIF 
    228          ! 
    229          CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file 
    230          ! 
    231          IF( ll_colruns .or. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files 
    232             IF(lwp) THEN   ;   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 
    233             ELSE           ;   nstop = MAX(1, nstop)   ! make sure nstop > 0 (automatically done when calling ctl_stop) 
    234             ENDIF 
    235          ELSE                                    ! only mpi subdomains with errors are here -> STOP now 
    236             CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 
    237          ENDIF 
    238          ! 
    239       ENDIF 
    240       ! 
    241       IF( nstop > 0 ) THEN                                                  ! an error was detected and we did not abort yet... 
    242          ngrdstop = Agrif_Fixed()                                           ! store which grid got this error 
    243          IF( .NOT. ll_colruns .AND. jpnij > 1 )   CALL ctl_stop( 'STOP' )   ! we must abort here to avoid MPI deadlock 
    244       ENDIF 
    245       ! 
     189      ENDIF 
     190      ! 
     1919100  FORMAT (' kt=',i8,'   |ssh| max: ',1pg11.4,', at  i j  : ',2i5) 
     1929200  FORMAT (' kt=',i8,'   |U|   max: ',1pg11.4,', at  i j k: ',3i5) 
     1939300  FORMAT (' kt=',i8,'   S     min: ',1pg11.4,', at  i j k: ',3i5) 
     1949400  FORMAT (' kt=',i8,'   S     max: ',1pg11.4,', at  i j k: ',3i5) 
    2461959500  FORMAT(' it :', i8, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16,' S_max: ', D23.16) 
    247196      ! 
    248197   END SUBROUTINE stp_ctl 
    249  
    250  
    251    SUBROUTINE wrt_line( cdline, kt, cdprefix, pval, kloc, ksum, kmin, kmax ) 
    252       !!---------------------------------------------------------------------- 
    253       !!                     ***  ROUTINE wrt_line  *** 
    254       !! 
    255       !! ** Purpose :   write information line 
    256       !! 
    257       !!---------------------------------------------------------------------- 
    258       CHARACTER(len=*),      INTENT(  out) ::   cdline 
    259       CHARACTER(len=*),      INTENT(in   ) ::   cdprefix 
    260       REAL(wp),              INTENT(in   ) ::   pval 
    261       INTEGER, DIMENSION(3), INTENT(in   ) ::   kloc 
    262       INTEGER,               INTENT(in   ) ::   kt, ksum, kmin, kmax 
    263       ! 
    264       CHARACTER(len=80) ::   clsuff 
    265       CHARACTER(len=9 ) ::   clkt, clsum, clmin, clmax 
    266       CHARACTER(len=9 ) ::   cli, clj, clk 
    267       CHARACTER(len=1 ) ::   clfmt 
    268       CHARACTER(len=4 ) ::   cl4   ! needed to be able to compile with Agrif, I don't know why 
    269       INTEGER           ::   ifmtk 
    270       !!---------------------------------------------------------------------- 
    271       WRITE(clkt , '(i9)') kt 
    272        
    273       WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij  ,wp))) + 1     ! how many digits to we need to write ? (we decide max = 9) 
    274       !!! WRITE(clsum, '(i'//clfmt//')') ksum                   ! this is creating a compilation error with AGRIF 
    275       cl4 = '(i'//clfmt//')'   ;   WRITE(clsum, cl4) ksum 
    276       WRITE(clfmt, '(i1)') INT(LOG10(REAL(MAX(1,jpnij-1),wp))) + 1    ! how many digits to we need to write ? (we decide max = 9) 
    277       cl4 = '(i'//clfmt//')'   ;   WRITE(clmin, cl4) kmin-1 
    278                                    WRITE(clmax, cl4) kmax-1 
    279       ! 
    280       WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpiglo,wp))) + 1      ! how many digits to we need to write jpiglo? (we decide max = 9) 
    281       cl4 = '(i'//clfmt//')'   ;   WRITE(cli, cl4) kloc(1)      ! this is ok with AGRIF 
    282       WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpjglo,wp))) + 1      ! how many digits to we need to write jpjglo? (we decide max = 9) 
    283       cl4 = '(i'//clfmt//')'   ;   WRITE(clj, cl4) kloc(2)      ! this is ok with AGRIF 
    284       ! 
    285       IF( ksum == 1 ) THEN   ;   WRITE(clsuff,9100) TRIM(clmin) 
    286       ELSE                   ;   WRITE(clsuff,9200) TRIM(clsum), TRIM(clmin), TRIM(clmax) 
    287       ENDIF 
    288       IF(kloc(3) == 0) THEN 
    289          ifmtk = INT(LOG10(REAL(jpk,wp))) + 1                   ! how many digits to we need to write jpk? (we decide max = 9) 
    290          clk = REPEAT(' ', ifmtk)                               ! create the equivalent in blank string 
    291          WRITE(cdline,9300) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), clk(1:ifmtk), TRIM(clsuff) 
    292       ELSE 
    293          WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpk,wp))) + 1      ! how many digits to we need to write jpk? (we decide max = 9) 
    294          !!! WRITE(clk, '(i'//clfmt//')') kloc(3)               ! this is creating a compilation error with AGRIF 
    295          cl4 = '(i'//clfmt//')'   ;   WRITE(clk, cl4) kloc(3)   ! this is ok with AGRIF 
    296          WRITE(cdline,9400) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj),    TRIM(clk), TRIM(clsuff) 
    297       ENDIF 
    298       ! 
    299 9100  FORMAT('MPI rank ', a) 
    300 9200  FORMAT('found in ', a, ' MPI tasks, spread out among ranks ', a, ' to ', a) 
    301 9300  FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j   ', a, ' ', a, ' ', a, ' ', a) 
    302 9400  FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j k ', a, ' ', a, ' ', a, ' ', a) 
    303       ! 
    304    END SUBROUTINE wrt_line 
    305  
    306198 
    307199   !!====================================================================== 
Note: See TracChangeset for help on using the changeset viewer.