C $Header: /home/ubuntu/mnt/e9_copy/MITgcm_contrib/heimbach/cs_adj_advdiff/code_ad/cost_test.F,v 1.5 2006/11/23 21:48:48 heimbach Exp $ #include "PACKAGES_CONFIG.h" #include "CPP_OPTIONS.h" subroutine cost_test( myThid ) C /==========================================================\ C | subroutine cost_test | C | o this routine computes the cost function for the tiles | C | of this processor | C |==========================================================| C | | C | Notes | C | ===== | C \==========================================================/ IMPLICIT NONE C == Global variables === #include "SIZE.h" #include "EEPARAMS.h" #include "PARAMS.h" #include "DYNVARS.h" #include "GRID.h" #include "cost.h" C == Routine arguments == C myThid - Thread number for this instance of the routine. integer bi, bj integer myThid #ifdef ALLOW_COST_TEST C == Local variables _RL thetaRef _RL sumcost(nSx,nSy) integer i, j, k integer ig, jg integer itlo,ithi integer jtlo,jthi jtlo = mybylo(mythid) jthi = mybyhi(mythid) itlo = mybxlo(mythid) ithi = mybxhi(mythid) if ( useCubedSphereExchange) then iLocOut = 3 jLocOut = 2 kLocOut = 1 else iLocOut = 80 jLocOut = 30 kLocOut = 1 endif ce some reference temperature thetaRef = 24.0D0 C-- Calculate mask for tracer cells (0 => land, 1 => water) k=1 C-- Calculate cost function on tile of this instance do bj = jtlo,jthi do bi = itlo,ithi sumcost(bi,bj) = 0. do j=1,sNy jg = myYGlobalLo-1+(bj-1)*sNy+j do i=1,sNx ig = myXGlobalLo-1+(bi-1)*sNx+i cph if ( ig .GE. (iLocOut-3) .AND. ig .LE. (iLocOut+3) .AND. cph & jg .GE. (jLocOut-3) .AND. jg .LE. (jLocOut+3) ) then if ( ig .GE. 1 .AND. ig .LE. 16 .AND. & jg .GE. 1 .AND. jg .LE. 16 ) then write(*,'(a,3(x,i4),a,4(x,i4))') & 'COST ',ig,jg,kLocOut,' TILE ',i,j,bi,bj objf_test(bi,bj) = objf_test(bi,bj) + & theta(i,j,kLocOut,bi,bj)*hFacC(i,j,kLocOut,bi,bj) sumcost(bi,bj) = sumcost(bi,bj)+hFacC(i,j,kLocOut,bi,bj) cph( print *, 'ph-cost ', ig, jg, kLocOut, & theta(i,j,kLocOut,bi,bj) cph) endif end do end do if ( sumcost(bi,bj) .NE. 0. ) then objf_test(bi,bj) = objf_test(bi,bj)/sumcost(bi,bj) print *, 'ph-cost ', bi,bj, objf_test(bi,bj) endif end do end do #endif END