File indexing completed on 2023-07-14 05:10:22 UTC
view on githubraw file Latest commit de57a2ec on 2023-07-13 16:55:13 UTC
8f7d13d0c9 Jean*0001 #include "ECCO_OPTIONS.h"
3ad0d94cb0 Patr*0002
0003 subroutine cost_averagesgeneric(
951926fb9b Jean*0004 & localbarfile,
3ad0d94cb0 Patr*0005 & localbar, localfld, xx_localbar_mean_dummy,
0006 & first, last, startofloc, endofloc, inloc,
de57a2ec4b Mart*0007 & sum1loc, locrec, nnz, myThid )
3ad0d94cb0 Patr*0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 implicit none
0020
0021
0022
0023 #include "EEPARAMS.h"
0024 #include "SIZE.h"
0025 #include "PARAMS.h"
0026
49484c0542 Gael*0027 #ifdef ALLOW_ECCO
13d362b8c1 Ou W*0028 # include "ECCO_SIZE.h"
0029 # include "ECCO.h"
3ad0d94cb0 Patr*0030 #endif
0031
0032
0033
de57a2ec4b Mart*0034 integer myThid
3ad0d94cb0 Patr*0035 integer nnz
0036 integer locrec
0037 integer sum1loc
0038
de57a2ec4b Mart*0039 _RL localbar(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nnz,nSx,nSy)
0040 _RL localfld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nnz,nSx,nSy)
3ad0d94cb0 Patr*0041 _RL xx_localbar_mean_dummy
0042
0043 logical first
0044 logical last
0045 logical startofloc
0046 logical endofloc
0047 logical inloc
0048
cc9899cf30 Patr*0049 character*(MAX_LEN_FNAM) localbarfile
3ad0d94cb0 Patr*0050
0051
0052
0053 integer bi,bj
0054 integer i,j,k
0055 integer itlo,ithi
0056 integer jtlo,jthi
0057 integer jmin,jmax
0058 integer imin,imax
0059
0060 integer il
0061
0062 character*(128) fname
49484c0542 Gael*0063 #ifdef ALLOW_ECCO_DEBUG
0064 character*(max_len_mbuf) msgbuf
0065 #endif
3ad0d94cb0 Patr*0066
0067
0068
0069 integer ilnblnk
0070 external ilnblnk
0071
0072
0073
49484c0542 Gael*0074 #ifdef ALLOW_ECCO_DEBUG
0075 write(msgbuf,'(a)') '>> entering'
0076 call print_message( msgbuf, standardmessageunit,
de57a2ec4b Mart*0077 & SQUEEZE_RIGHT , myThid)
49484c0542 Gael*0078
0079 il=ilnblnk( localbarfile )
0080 write(msgbuf,'(a,a)')
0081 & 'cost_averagesgeneric, file : ',localbarfile(1:il)
0082 call print_message( msgbuf, standardmessageunit,
de57a2ec4b Mart*0083 & SQUEEZE_RIGHT , myThid)
49484c0542 Gael*0084
0085 write(msgbuf,'(a,5L5)')
0086 & 'cost_averagesgeneric, logicals : ',
0087 & first, last, startofloc, endofloc, inloc
0088 call print_message( msgbuf, standardmessageunit,
de57a2ec4b Mart*0089 & SQUEEZE_RIGHT , myThid)
49484c0542 Gael*0090
0091 write(msgbuf,'(a,3i5)')
0092 & 'cost_averagesgeneric, integers : ',
0093 & sum1loc, locrec, nnz
0094 call print_message( msgbuf, standardmessageunit,
de57a2ec4b Mart*0095 & SQUEEZE_RIGHT , myThid)
49484c0542 Gael*0096
0097 write(msgbuf,'(a)') '<< leaving'
0098 call print_message( msgbuf, standardmessageunit,
de57a2ec4b Mart*0099 & SQUEEZE_RIGHT , myThid)
49484c0542 Gael*0100 #endif
0101
de57a2ec4b Mart*0102 jtlo = myByLo(myThid)
0103 jthi = myByHi(myThid)
0104 itlo = myBxLo(myThid)
0105 ithi = myBxHi(myThid)
3ad0d94cb0 Patr*0106 jmin = 1
de57a2ec4b Mart*0107 jmax = sNy
3ad0d94cb0 Patr*0108 imin = 1
de57a2ec4b Mart*0109 imax = sNx
3ad0d94cb0 Patr*0110
e7d9258ace Gael*0111 if (startofloc .and. endofloc) then
0112
0113 do bj = jtlo,jthi
0114 do bi = itlo,ithi
0115 do k = 1,nnz
0116 do j = jmin,jmax
0117 do i = imin,imax
0118 localbar(i,j,k,bi,bj) = localfld(i,j,k,bi,bj)
0119 enddo
0120 enddo
0121 enddo
0122 enddo
0123 enddo
0124
0125 il=ilnblnk( localbarfile )
0126 write(fname,'(2a,i10.10)')
0127 & localbarfile(1:il), '.', eccoiter
101f75e5cd Gael*0128 #ifdef ALLOW_AUTODIFF
e7d9258ace Gael*0129 if ( nnz .EQ. 1 ) then
0130 call active_write_xy( fname, localbar, locrec, eccoiter,
de57a2ec4b Mart*0131 & myThid, xx_localbar_mean_dummy )
e7d9258ace Gael*0132 else
0133 call active_write_xyz( fname, localbar, locrec, eccoiter,
de57a2ec4b Mart*0134 & myThid, xx_localbar_mean_dummy )
e7d9258ace Gael*0135 endif
101f75e5cd Gael*0136 #else
0137 if ( nnz .EQ. 1 ) then
0138 CALL WRITE_REC_XY_RL( fname, localbar, locrec, 1, myThid )
0139 else
0140 CALL WRITE_REC_XYZ_RL( fname, localbar, locrec, 1, myThid )
0141 endif
0142 #endif
0143
e7d9258ace Gael*0144 elseif (first .or. startofloc) then
3ad0d94cb0 Patr*0145
0146 do bj = jtlo,jthi
0147 do bi = itlo,ithi
0148 do k = 1,nnz
0149 do j = jmin,jmax
0150 do i = imin,imax
0151 localbar(i,j,k,bi,bj) = localfld(i,j,k,bi,bj)
0152 enddo
0153 enddo
0154 enddo
0155 enddo
0156 enddo
0157 else if (last .or. endofloc) then
0158
0159 do bj = jtlo,jthi
0160 do bi = itlo,ithi
0161 do k = 1,nnz
0162 do j = jmin,jmax
0163 do i = imin,imax
951926fb9b Jean*0164 localbar(i,j,k,bi,bj) =
0165 & (localbar(i,j,k,bi,bj)
3ad0d94cb0 Patr*0166 & +localfld(i,j,k,bi,bj))/
0167 & float(sum1loc)
0168 enddo
0169 enddo
0170 enddo
0171 enddo
0172 enddo
0173
0174 il=ilnblnk( localbarfile )
951926fb9b Jean*0175 write(fname,'(2a,i10.10)')
49484c0542 Gael*0176 & localbarfile(1:il), '.', eccoiter
101f75e5cd Gael*0177 #ifdef ALLOW_AUTODIFF
3ad0d94cb0 Patr*0178 if ( nnz .EQ. 1 ) then
49484c0542 Gael*0179 call active_write_xy( fname, localbar, locrec, eccoiter,
de57a2ec4b Mart*0180 & myThid, xx_localbar_mean_dummy )
3ad0d94cb0 Patr*0181 else
49484c0542 Gael*0182 call active_write_xyz( fname, localbar, locrec, eccoiter,
de57a2ec4b Mart*0183 & myThid, xx_localbar_mean_dummy )
3ad0d94cb0 Patr*0184 endif
101f75e5cd Gael*0185 #else
0186 if ( nnz .EQ. 1 ) then
0187 CALL WRITE_REC_XY_RL( fname, localbar, locrec, 1, myThid )
0188 else
0189 CALL WRITE_REC_XYZ_RL( fname, localbar, locrec, 1, myThid )
0190 endif
0191 #endif
3ad0d94cb0 Patr*0192 else if ( ( inloc ) .and.
0193 & .not. (first .or. startofloc) .and.
0194 & .not. (last .or. endofloc ) ) then
0195
0196 do bj = jtlo,jthi
0197 do bi = itlo,ithi
0198 do j = jmin,jmax
0199 do k = 1,nnz
0200 do i = imin,imax
951926fb9b Jean*0201 localbar(i,j,k,bi,bj) =
3ad0d94cb0 Patr*0202 & localbar(i,j,k,bi,bj) + localfld(i,j,k,bi,bj)
0203 enddo
0204 enddo
0205 enddo
0206 enddo
0207 enddo
0208 else
0209 stop 'in cost_averagesgeneric'
0210 endif
0211
0212 return
0213 end