File indexing completed on 2024-03-19 05:10:16 UTC
view on githubraw file Latest commit 720a211d on 2024-03-18 17:10:23 UTC
8f7d13d0c9 Jean*0001 #include "ECCO_OPTIONS.h"
6805a315c1 Gael*0002 #ifdef ALLOW_CTRL
0003 # include "CTRL_OPTIONS.h"
0004 #endif
5001c65f45 Patr*0005
15f6a15ab5 Mart*0006
0007
0008
5001c65f45 Patr*0009 subroutine cost_obcse(
720a211d38 Ou W*0010 I startrec, endrec,
0011 I myTime, myIter, myThid )
5001c65f45 Patr*0012
15f6a15ab5 Mart*0013
5001c65f45 Patr*0014
0015
0016
0017
0018
0019
0020
0021
0022
15f6a15ab5 Mart*0023
0024
0025
5001c65f45 Patr*0026
0027 implicit none
0028
0029
0030 #include "EEPARAMS.h"
0031 #include "SIZE.h"
0032 #include "PARAMS.h"
0033 #include "GRID.h"
f75c953e99 Jean*0034
0035
0036
5001c65f45 Patr*0037
c509d7e04a Gael*0038 #ifdef ALLOW_CAL
0039 # include "cal.h"
0040 #endif
0041 #ifdef ALLOW_CTRL
0042 # include "CTRL_SIZE.h"
4d72283393 Mart*0043 # include "CTRL.h"
edcd27be69 Mart*0044 # include "CTRL_DUMMY.h"
65754df434 Mart*0045 # include "OPTIMCYCLE.h"
c509d7e04a Gael*0046 # include "CTRL_OBCS.h"
0047 #endif
5001c65f45 Patr*0048
15f6a15ab5 Mart*0049
720a211d38 Ou W*0050 integer startrec, endrec
0051 _RL myTime
0052 integer myIter
0053 integer myThid
5001c65f45 Patr*0054
c509d7e04a Gael*0055 #if (defined (ALLOW_CTRL) && defined (ALLOW_OBCS))
0056
f75c953e99 Jean*0057 #ifdef ALLOW_OBCSE_COST_CONTRIBUTION
720a211d38 Ou W*0058
f75c953e99 Jean*0059 integer ilnblnk
0060 external ilnblnk
0061
15f6a15ab5 Mart*0062
5001c65f45 Patr*0063 integer bi,bj
f75c953e99 Jean*0064 integer j,k
5001c65f45 Patr*0065 integer jmin,jmax
0066 integer irec
0067 integer iobcs
15f6a15ab5 Mart*0068 integer nrec
0069 integer ilfld
0070 integer igg
5001c65f45 Patr*0071 _RL fctile
0072 _RL fcthread
0073 _RL dummy
15f6a15ab5 Mart*0074 _RL gg
0075 _RL tmpx
0076
9f5240b52a Jean*0077 _RL tmpfield (1-OLy:sNy+OLy,Nr,nSx,nSy)
0078 _RL maskyz (1-OLy:sNy+OLy,Nr,nSx,nSy)
de57a2ec4b Mart*0079 character*(MAX_LEN_FNAM) fnamefld
5001c65f45 Patr*0080 logical doglobalread
0081 logical ladinit
0082 #ifdef ECCO_VERBOSE
0083 character*(MAX_LEN_MBUF) msgbuf
0084 #endif
15f6a15ab5 Mart*0085
5001c65f45 Patr*0086
0087 jmin = 1
9f5240b52a Jean*0088 jmax = sNy
5001c65f45 Patr*0089
0090
0091 doglobalread = .false.
0092 ladinit = .false.
0093
15f6a15ab5 Mart*0094
0095 nrec = endrec-startrec+1
0096
f75c953e99 Jean*0097
5001c65f45 Patr*0098 fcthread = 0. _d 0
0099
15f6a15ab5 Mart*0100 #ifdef ECCO_VERBOSE
720a211d38 Ou W*0101 _BEGIN_MASTER( myThid )
15f6a15ab5 Mart*0102 write(msgbuf,'(a)') ' '
720a211d38 Ou W*0103 call print_message( msgbuf, standardMessageUnit,
0104 & SQUEEZE_RIGHT, myThid )
15f6a15ab5 Mart*0105 write(msgbuf,'(a)') ' '
720a211d38 Ou W*0106 call print_message( msgbuf, standardMessageUnit,
0107 & SQUEEZE_RIGHT, myThid )
15f6a15ab5 Mart*0108 write(msgbuf,'(a,i9.8)')
0109 & ' cost_obcse: number of records to process: ',nrec
720a211d38 Ou W*0110 call print_message( msgbuf, standardMessageUnit,
0111 & SQUEEZE_RIGHT, myThid )
15f6a15ab5 Mart*0112 write(msgbuf,'(a)') ' '
720a211d38 Ou W*0113 call print_message( msgbuf, standardMessageUnit,
0114 & SQUEEZE_RIGHT, myThid )
0115 _END_MASTER( myThid )
15f6a15ab5 Mart*0116 #endif
0117
0118 if (optimcycle .ge. 0) then
0119 ilfld=ilnblnk( xx_obcse_file )
de57a2ec4b Mart*0120 write(fnamefld,'(2a,i10.10)')
15f6a15ab5 Mart*0121 & xx_obcse_file(1:ilfld), '.', optimcycle
0122 endif
0123
5001c65f45 Patr*0124
15f6a15ab5 Mart*0125 do irec = 1,nrec
5001c65f45 Patr*0126
720a211d38 Ou W*0127 #ifdef ALLOW_AUTODIFF
0128 call active_read_yz( fnamefld, tmpfield, irec,
0129 & doglobalread, ladinit, optimcycle,
0130 & myThid, xx_obcse_dummy )
0131 #else
0132 CALL READ_REC_YZ_RL( fnamefld, ctrlprec, Nr,
0133 & tmpfield, irec, 1, myThid )
0134 #endif
c9dc83bee0 Patr*0135
720a211d38 Ou W*0136
0137 gg = (irec-1)/nobcs
0138 igg = int(gg)
0139 iobcs = irec - igg*nobcs
0140
0141 #ifdef ALLOW_AUTODIFF
0142 call active_read_yz( 'maskobcse', maskyz, iobcs,
0143 & doglobalread, ladinit, 0,
0144 & myThid, dummy )
0145 #else
0146 CALL READ_REC_YZ_RL( 'maskobcse', ctrlprec, Nr,
0147 & maskyz, iobcs, 1, myThid )
0148 #endif
5001c65f45 Patr*0149
80451941d6 Jean*0150
9f5240b52a Jean*0151 do bj = myByLo(myThid), myByHi(myThid)
0152 do bi = myBxLo(myThid), myBxHi(myThid)
5001c65f45 Patr*0153
15f6a15ab5 Mart*0154
5001c65f45 Patr*0155 fctile = 0. _d 0
c9dc83bee0 Patr*0156
15f6a15ab5 Mart*0157 do k = 1, Nr
0158 do j = jmin,jmax
f75c953e99 Jean*0159
15f6a15ab5 Mart*0160
0161 tmpx = tmpfield(j,k,bi,bj)
0162
0163 fctile = fctile + wobcse(k,iobcs)
0164 & *tmpx*tmpx*maskyz(j,k,bi,bj)
0165
0166
0167 if (wobcse(k,iobcs)*maskyz(j,k,bi,bj).ne.0.)
0168 & num_obcse(bi,bj) = num_obcse(bi,bj) + 1. _d 0
0169 enddo
c9dc83bee0 Patr*0170 enddo
15f6a15ab5 Mart*0171
5001c65f45 Patr*0172 objf_obcse(bi,bj) = objf_obcse(bi,bj) + fctile
15f6a15ab5 Mart*0173 fcthread = fcthread + fctile
5001c65f45 Patr*0174 enddo
0175 enddo
0176
0177 #ifdef ECCO_VERBOSE
0178
6637358eea Jean*0179 _GLOBAL_SUM_RL( fcthread , myThid )
5001c65f45 Patr*0180 write(msgbuf,'(a)') ' '
720a211d38 Ou W*0181 call print_message( msgbuf, standardMessageUnit,
0182 & SQUEEZE_RIGHT, myThid )
5001c65f45 Patr*0183 write(msgbuf,'(a,i8.8)')
0184 & ' cost_obcse: irec = ',irec
720a211d38 Ou W*0185 call print_message( msgbuf, standardMessageUnit,
0186 & SQUEEZE_RIGHT, myThid )
5001c65f45 Patr*0187 write(msgbuf,'(a,a,d22.15)')
0188 & ' global cost function value',
0189 & ' (obcse) = ',fcthread
720a211d38 Ou W*0190 call print_message( msgbuf, standardMessageUnit,
0191 & SQUEEZE_RIGHT, myThid )
5001c65f45 Patr*0192 write(msgbuf,'(a)') ' '
720a211d38 Ou W*0193 call print_message( msgbuf, standardMessageUnit,
0194 & SQUEEZE_RIGHT, myThid )
5001c65f45 Patr*0195 #endif
0196
0197 enddo
0198
0199
f75c953e99 Jean*0200 #endif /* ALLOW_OBCSE_COST_CONTRIBUTION */
5001c65f45 Patr*0201
c509d7e04a Gael*0202 #endif /* ALLOW_CTRL and ALLOW_OBCS */
0203
5001c65f45 Patr*0204 return
0205 end