| 1 |
C $Header: /u/gcmpack/MITgcm/pkg/streamice/streamice_cost_surf_accum.F,v 1.3 2013/07/02 20:42:28 jmc Exp $ |
| 2 |
C $Name: $ |
| 3 |
|
| 4 |
#include "STREAMICE_OPTIONS.h" |
| 5 |
#ifdef ALLOW_COST |
| 6 |
# include "COST_OPTIONS.h" |
| 7 |
#endif |
| 8 |
|
| 9 |
subroutine streamice_cost_surf_accum ( myThid, myIter ) |
| 10 |
C *==========================================================* |
| 11 |
C | subroutine cost_test | |
| 12 |
C | o this routine computes the cost function for the tiles | |
| 13 |
C | of this processor | |
| 14 |
C *==========================================================* |
| 15 |
C | | |
| 16 |
C | Notes | |
| 17 |
C | ===== | |
| 18 |
C *==========================================================* |
| 19 |
IMPLICIT NONE |
| 20 |
|
| 21 |
C == Global variables === |
| 22 |
#include "SIZE.h" |
| 23 |
#include "EEPARAMS.h" |
| 24 |
#include "PARAMS.h" |
| 25 |
#include "DYNVARS.h" |
| 26 |
#include "GRID.h" |
| 27 |
#ifdef ALLOW_STREAMICE |
| 28 |
# include "STREAMICE.h" |
| 29 |
#endif |
| 30 |
|
| 31 |
#ifdef ALLOW_COST |
| 32 |
# include "cost.h" |
| 33 |
#endif |
| 34 |
#ifdef ALLOW_AUTODIFF_TAMC |
| 35 |
# include "tamc.h" |
| 36 |
#endif |
| 37 |
|
| 38 |
C == Routine arguments == |
| 39 |
C myThid - Thread number for this instance of the routine. |
| 40 |
integer myThid, myIter |
| 41 |
|
| 42 |
#ifdef ALLOW_COST_TEST |
| 43 |
C == Local variables |
| 44 |
_RL thetaRef, HAF |
| 45 |
|
| 46 |
integer i, j, k, bi, bj |
| 47 |
integer ig, jg |
| 48 |
integer itlo,ithi |
| 49 |
integer jtlo,jthi |
| 50 |
integer il |
| 51 |
INTEGER ILNBLNK |
| 52 |
EXTERNAL ILNBLNK |
| 53 |
CHARACTER*(MAX_LEN_FNAM) suff |
| 54 |
CHARACTER*(MAX_LEN_FNAM) STREAMICEsurfOptimFile |
| 55 |
_RL S_obs (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
| 56 |
|
| 57 |
jtlo = mybylo(myThid) |
| 58 |
jthi = mybyhi(myThid) |
| 59 |
itlo = mybxlo(myThid) |
| 60 |
ithi = mybxhi(myThid) |
| 61 |
|
| 62 |
WRITE(suff,'(a,I10.10,a)') 'land_ice_surf.',myIter, '.bin' |
| 63 |
|
| 64 |
CALL READ_FLD_XY_RL( suff, ' ', |
| 65 |
& S_obs, 0, myThid ) |
| 66 |
|
| 67 |
C-- Calculate mask for tracer cells (0 => land, 1 => water) |
| 68 |
! k=1 |
| 69 |
|
| 70 |
#ifdef ALLOW_AUTODIFF_TAMC |
| 71 |
CADJ STORE surf_el_streamice = comlev1, key = ikey_dynamics, |
| 72 |
CADJ & kind = isbyte |
| 73 |
CADJ STORE H_streamice_prev = comlev1, key = ikey_dynamics, |
| 74 |
CADJ & kind = isbyte |
| 75 |
CADJ STORE H_streamice = comlev1, key = ikey_dynamics, |
| 76 |
CADJ & kind = isbyte |
| 77 |
#endif |
| 78 |
|
| 79 |
C-- Calculate cost function on tile of this instance |
| 80 |
do bj = jtlo,jthi |
| 81 |
do bi = itlo,ithi |
| 82 |
do j=1,sNy |
| 83 |
do i=1,sNx |
| 84 |
|
| 85 |
! S_obs(i,j,bi,bj) = 0.0 |
| 86 |
if (streamice_cost_mask(i,j,bi,bj).eq.1.0) THEN |
| 87 |
cost_func1_streamice (bi,bj) = |
| 88 |
& cost_func1_streamice (bi,bj) + |
| 89 |
& streamice_wgt_surf * (S_obs(i,j,bi,bj)- |
| 90 |
& surf_el_streamice(i,j,bi,bj))**2 / Nx / Ny + |
| 91 |
& streamice_wgt_drift * (H_streamice(i,j,bi,bj)- |
| 92 |
& H_streamice_prev(i,j,bi,bj))**2 / Nx / Ny |
| 93 |
endif |
| 94 |
|
| 95 |
end do |
| 96 |
end do |
| 97 |
end do |
| 98 |
end do |
| 99 |
|
| 100 |
#endif |
| 101 |
|
| 102 |
RETURN |
| 103 |
END |