| 1 |
C $Header: /u/gcmpack/MITgcm/verification/halfpipe_streamice/code_oad/cost_test.F,v 1.1 2013/12/17 19:08:33 heimbach Exp $ |
| 2 |
C $Name: $ |
| 3 |
|
| 4 |
#include "STREAMICE_OPTIONS.h" |
| 5 |
|
| 6 |
subroutine cost_test( myThid ) |
| 7 |
C /==========================================================\ |
| 8 |
C | subroutine cost_test | |
| 9 |
C | o this routine computes the cost function for the tiles | |
| 10 |
C | of this processor | |
| 11 |
C |==========================================================| |
| 12 |
C | | |
| 13 |
C | Notes | |
| 14 |
C | ===== | |
| 15 |
C \==========================================================/ |
| 16 |
IMPLICIT NONE |
| 17 |
|
| 18 |
C == Global variables === |
| 19 |
#include "SIZE.h" |
| 20 |
#include "EEPARAMS.h" |
| 21 |
#include "PARAMS.h" |
| 22 |
#include "DYNVARS.h" |
| 23 |
#include "GRID.h" |
| 24 |
#ifdef ALLOW_STREAMICE |
| 25 |
# include "STREAMICE.h" |
| 26 |
#endif |
| 27 |
#ifdef ALLOW_COST |
| 28 |
#include "cost.h" |
| 29 |
#endif |
| 30 |
|
| 31 |
|
| 32 |
C == Routine arguments == |
| 33 |
C myThid - Thread number for this instance of the routine. |
| 34 |
integer bi, bj |
| 35 |
integer myThid |
| 36 |
|
| 37 |
#ifdef ALLOW_COST_TEST |
| 38 |
C == Local variables |
| 39 |
_RL thetaRef, HAF |
| 40 |
|
| 41 |
integer i, j, k |
| 42 |
integer ig, jg |
| 43 |
integer itlo,ithi |
| 44 |
integer jtlo,jthi |
| 45 |
_RL i_numcells, dCdx, dCdy, dBdx, dBdy, dTdx, dTdy |
| 46 |
_RL utmp, vtmp, uotmp, votmp, cotmp |
| 47 |
INTEGER ILNBLNK |
| 48 |
EXTERNAL ILNBLNK |
| 49 |
CHARACTER*(MAX_LEN_FNAM) STREAMICExvelOptimFile |
| 50 |
CHARACTER*(MAX_LEN_FNAM) STREAMICEyvelOptimFile |
| 51 |
_RL U_obs (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
| 52 |
_RL V_obs (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
| 53 |
|
| 54 |
jtlo = mybylo(mythid) |
| 55 |
jthi = mybyhi(mythid) |
| 56 |
itlo = mybxlo(mythid) |
| 57 |
ithi = mybxhi(mythid) |
| 58 |
|
| 59 |
i_numcells = 1.0/(Nx*Ny) |
| 60 |
|
| 61 |
! STREAMICExvelOptimFile= |
| 62 |
! & STREAMICEvelOptimFile(1: |
| 63 |
! & ILNBLNK(STREAMICEvelOptimFile))//"u.bin" |
| 64 |
! STREAMICEyvelOptimFile= |
| 65 |
! & STREAMICEvelOptimFile(1: |
| 66 |
! & ILNBLNK(STREAMICEvelOptimFile))//"v.bin" |
| 67 |
|
| 68 |
! _BARRIER |
| 69 |
|
| 70 |
! CALL READ_FLD_XY_RS( STREAMICExvelOptimFile, ' ', |
| 71 |
! & U_obs, 0, myThid ) |
| 72 |
! CALL READ_FLD_XY_RS( STREAMICEyvelOptimFile, ' ', |
| 73 |
! & V_obs, 0, myThid ) |
| 74 |
|
| 75 |
C-- Calculate mask for tracer cells (0 => land, 1 => water) |
| 76 |
! k=1 |
| 77 |
|
| 78 |
C-- Calculate cost function on tile of this instance |
| 79 |
do bj = jtlo,jthi |
| 80 |
do bi = itlo,ithi |
| 81 |
do j=1,sNy |
| 82 |
do i=1,sNx |
| 83 |
|
| 84 |
|
| 85 |
if (streamice_hmask(i,j,bi,bj).eq.1.0) then |
| 86 |
objf_test (bi,bj) = objf_test (bi,bj) + |
| 87 |
& u_streamice(i,j,bi,bj)**2+v_streamice(i,j,bi,bj)**2 |
| 88 |
endif |
| 89 |
|
| 90 |
|
| 91 |
end do |
| 92 |
end do |
| 93 |
end do |
| 94 |
end do |
| 95 |
|
| 96 |
#endif |
| 97 |
|
| 98 |
RETURN |
| 99 |
END |