-
Notifications
You must be signed in to change notification settings - Fork 237
/
streamice_get_vel_fp_err.F
128 lines (109 loc) · 3.43 KB
/
streamice_get_vel_fp_err.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "STREAMICE_OPTIONS.h"
#ifdef ALLOW_AUTODIFF
# include "AUTODIFF_OPTIONS.h"
#endif
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
CBOP
SUBROUTINE STREAMICE_GET_VEL_FP_ERR ( err_max,
#ifdef ALLOW_AUTODIFF_TAMC
I ikey_nl,
#endif
I myThid )
C /============================================================\
C | SUBROUTINE |
C | o |
C |============================================================|
C | |
C \============================================================/
IMPLICIT NONE
C === Global variables ===
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#include "STREAMICE.h"
#include "STREAMICE_CG.h"
C !INPUT/OUTPUT ARGUMENTS
_RL err_max
#ifdef ALLOW_AUTODIFF_TAMC
INTEGER ikey_nl
#endif
INTEGER myThid
#ifdef ALLOW_STREAMICE
INTEGER i, j, bi, bj
_RL err_tempu, err_tempv
_RL err_sum
_RL err_sum_tile (nSx,nSy)
err_max = 0. _d 0
err_sum = 0. _d 0
DO bj = myByLo(myThid), myByHi(myThid)
DO bi = myBxLo(myThid), myBxHi(myThid)
err_sum_tile(bi,bj) = 0. _d 0
ENDDO
ENDDO
if (streamice_err_norm .lt. 1.0) then
DO bj = myByLo(myThid), myByHi(myThid)
DO bi = myBxLo(myThid), myBxHi(myThid)
DO j=1,sNy
DO i=1,sNx
#ifdef ALLOW_AUTODIFF_TAMC
!$TAF STORE err_max = comlev1_stream_nl, key=ikey_nl
#endif
err_tempu = 0. _d 0
err_tempv = 0. _d 0
IF (STREAMICE_umask(i,j,bi,bj).eq.1) THEN
err_tempu =
#ifdef ALLOW_STREAMICE_OAD_FP
& ABS (U_streamice(i,j,bi,bj)-u_new_SI(i,j,bi,bj))
#else
& ABS (U_streamice(i,j,bi,bj)-u_old_SI(i,j,bi,bj))
#endif
ENDIF
IF (STREAMICE_vmask(i,j,bi,bj).eq.1) THEN
err_tempv = MAX( err_tempu,
#ifdef ALLOW_STREAMICE_OAD_FP
& ABS (V_streamice(i,j,bi,bj)-v_new_SI(i,j,bi,bj)))
#else
& ABS (V_streamice(i,j,bi,bj)-v_old_SI(i,j,bi,bj)))
#endif
ENDIF
IF (err_tempv .ge. err_max) err_max = err_tempv
ENDDO
ENDDO
ENDDO
ENDDO
CALL GLOBAL_MAX_R8 (err_max, myThid)
ELSE
DO bj = myByLo(myThid), myByHi(myThid)
DO bi = myBxLo(myThid), myBxHi(myThid)
DO j=1,sNy
DO i=1,sNx
IF (STREAMICE_umask(i,j,bi,bj).eq.1) THEN
err_sum_tile(bi,bj) = err_sum_tile(bi,bj) +
#ifdef ALLOW_STREAMICE_OAD_FP
& (ABS(U_streamice(i,j,bi,bj)-
& u_new_SI(i,j,bi,bj)))**streamice_err_norm
#else
& (ABS(U_streamice(i,j,bi,bj)-
& u_old_SI(i,j,bi,bj)))**streamice_err_norm
#endif
ENDIF
IF (STREAMICE_vmask(i,j,bi,bj).eq.1) THEN
err_sum_tile(bi,bj) = err_sum_tile(bi,bj) +
#ifdef ALLOW_STREAMICE_OAD_FP
& (ABS(v_streamice(i,j,bi,bj)-
& v_new_SI(i,j,bi,bj)))**streamice_err_norm
#else
& (ABS(v_streamice(i,j,bi,bj)-
& v_old_SI(i,j,bi,bj)))**streamice_err_norm
#endif
ENDIF
ENDDO
ENDDO
ENDDO
ENDDO
CALL GLOBAL_SUM_TILE_RL( err_sum_tile, err_sum, myThid )
err_max = err_sum ** (1./streamice_err_norm)
ENDIF
#endif
RETURN
END