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