1 |
C $Header: /u/gcmpack/MITgcm/pkg/longstep/longstep_check_iters.F,v 1.2 2009/06/28 04:58:41 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "LONGSTEP_OPTIONS.h" |
5 |
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
CBOP |
8 |
C !ROUTINE: LONGSTEP_CHECK_ITERS |
9 |
|
10 |
C !INTERFACE: |
11 |
SUBROUTINE LONGSTEP_CHECK_ITERS( myThid ) |
12 |
|
13 |
C !DESCRIPTION: |
14 |
C Check that starttime and endtime are multiples of long time step. |
15 |
C Fix endtime if not, abort if starttime is not. |
16 |
|
17 |
C !USES: |
18 |
IMPLICIT NONE |
19 |
#include "SIZE.h" |
20 |
#include "EEPARAMS.h" |
21 |
#include "LONGSTEP_PARAMS.h" |
22 |
#include "PARAMS.h" |
23 |
|
24 |
C !INPUT PARAMETERS: |
25 |
INTEGER myThid |
26 |
CEOP |
27 |
|
28 |
#ifdef ALLOW_LONGSTEP |
29 |
|
30 |
C !LOCAL VARIABLES: |
31 |
C extraIter :: extra iterations added to finish on a longstep |
32 |
C msgBuf :: message buffer |
33 |
INTEGER extraIter |
34 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
35 |
|
36 |
IF (MOD(nIter0, LS_nIter) .NE. 0) THEN |
37 |
C Restarting from a pickup in the middle of a longstep will lead |
38 |
C to invalid vel,... averages, so we abort |
39 |
WRITE(msgBuf,'(2A,2I10)') |
40 |
& ' LONGSTEP_CHECK_ITERS: nIter0 is not a multiple of', |
41 |
& ' LS_niter', nIter0, LS_niter |
42 |
CALL PRINT_ERROR( msgBuf, myThid ) |
43 |
STOP 'ABNORMAL END: S/R LONGSTEP_CHECK_ITERS' |
44 |
ENDIF |
45 |
|
46 |
IF (MOD(nEndIter, LS_nIter) .NE. 0) THEN |
47 |
C Add as many time steps as necessary to bring endtime to the end |
48 |
C of a long time step, so that the pickup will be valid. |
49 |
WRITE(msgBuf,'(3A)') '**WARNING** ', |
50 |
& ' LONGSTEP_CHECK_ITERS: nEndIter is not a multiple of', |
51 |
& ' LS_niter:' |
52 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
53 |
& SQUEEZE_RIGHT , myThid) |
54 |
WRITE(msgBuf,'(2A,2I10)') '**WARNING** ', |
55 |
& ' LONGSTEP_CHECK_ITERS: ', nEndIter, LS_niter |
56 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
57 |
& SQUEEZE_RIGHT , myThid) |
58 |
extraIter = LS_nIter - MOD(nEndIter, LS_nIter) |
59 |
nEndIter = nEndIter + extraIter |
60 |
nTimeSteps = nEndIter - nIter0 |
61 |
endTime = baseTime + deltaTClock*float(nEndIter) |
62 |
WRITE(msgBuf,'(2A)') '**WARNING** ', |
63 |
& ' LONGSTEP_CHECK_ITERS: adjusting to' |
64 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
65 |
& SQUEEZE_RIGHT , myThid) |
66 |
WRITE(msgBuf,'(2A,I10)') '**WARNING** ', |
67 |
& ' LONGSTEP_CHECK_ITERS: nEndIter =', nEndIter |
68 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
69 |
& SQUEEZE_RIGHT , myThid) |
70 |
WRITE(msgBuf,'(2A,I10)') '**WARNING** ', |
71 |
& ' LONGSTEP_CHECK_ITERS: nTimeSteps =', nTimeSteps |
72 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
73 |
& SQUEEZE_RIGHT , myThid) |
74 |
WRITE(msgBuf,'(2A,1PE23.15)') '**WARNING** ', |
75 |
& ' LONGSTEP_CHECK_ITERS: endTime =', endTime |
76 |
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit, |
77 |
& SQUEEZE_RIGHT , myThid) |
78 |
C log to standard output too |
79 |
WRITE(msgBuf,'(2A)') 'S/R LONGSTEP_CHECK_ITERS: ', |
80 |
& ' adjusting endTime:' |
81 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
82 |
& SQUEEZE_RIGHT , 1) |
83 |
CALL WRITE_0D_RL( endTime, INDEX_NONE,'endTime =', |
84 |
&' /* Integration ending time ( s ). */') |
85 |
CALL WRITE_0D_I( nTimeSteps, INDEX_NONE,'nTimeSteps =', |
86 |
&' /* Number of timesteps */') |
87 |
ENDIF |
88 |
|
89 |
#endif /* ALLOW_LONGSTEP */ |
90 |
|
91 |
RETURN |
92 |
END |