/[MITgcm]/MITgcm/pkg/exf/exf_mapfields.F
ViewVC logotype

Diff of /MITgcm/pkg/exf/exf_mapfields.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3 by cheisey, Tue Dec 17 19:47:41 2002 UTC revision 1.21 by mlosch, Thu Sep 27 09:41:13 2007 UTC
# Line 1  Line 1 
1  c $Header$  C $Header$
2    C $Name$
3    
4  #include "EXF_CPPOPTIONS.h"  #include "EXF_OPTIONS.h"
5    
6          subroutine exf_mapfields( mytime, myiter, mythid )
       subroutine exf_mapfields( mythid )  
7    
8  c     ==================================================================  c     ==================================================================
9  c     SUBROUTINE exf_mapfields  c     SUBROUTINE exf_mapfields
10  c     ==================================================================  c     ==================================================================
11  c  c
12  c     o Map the external forcing fields on the ocean model arrays. This  c     o Map external forcing fields (ustress, vstress, hflux, sflux,
13  c       routine is included to separate the ocean state estimation tool  c       swflux, apressure, climsss, climsst, etc.) onto ocean model
14  c       as much as possible from the ocean model. Unit conversion factors  c       arrays (fu, fv, Qnet, EmPmR, Qsw, pload, sss, sst, etc.).
15  c       are to be set by the user.  c       This routine is included to separate the ocean state estimation
16  c  c       tool as much as possible from the ocean model.  Unit and sign
17  c       The units have to be such that the individual forcing record has  c       conventions can be customized using variables exf_outscal_*,
18  c       units equal to [quantity/s]. See the header file *FFIELDS.h* of  c       which are set in exf_readparms.F.  See the header files
19  c       the MITgcmuv.  c       EXF_FIELDS.h and FFIELDS.h for definitions of the various input
20  c  c       and output fields and for default unit and sign convetions.
 c       Required units such that no scaling has to be applied:  
 c  
 c       heat flux:          input file W/m^2  
 c       salt flux:          input file m/s  
 c       zonal wind stress:  input file N/m^2  
 c       merid. wind stress: input file N/m^2  
 c  
 c       To allow for such unit conversions this routine contains scaling  
 c       factors scal_quantity.  
21  c  c
22  c     started: Christian Eckert eckert@mit.edu  09-Aug-1999  c     started: Christian Eckert eckert@mit.edu  09-Aug-1999
23  c  c
24  c     changed: Christian Eckert eckert@mit.edu  11-Jan-2000  c     changed: Christian Eckert eckert@mit.edu  11-Jan-2000
 c  
25  c              - Restructured the code in order to create a package  c              - Restructured the code in order to create a package
26  c                for the MITgcmUV.  c                for the MITgcmUV.
27  c  c
28  c              Christian Eckert eckert@mit.edu  12-Feb-2000  c              Christian Eckert eckert@mit.edu  12-Feb-2000
 c  
29  c              - Changed Routine names (package prefix: exf_)  c              - Changed Routine names (package prefix: exf_)
30  c  c
31  c              Patrick Heimbach, heimbach@mit.edu  06-May-2000  c              Patrick Heimbach, heimbach@mit.edu  06-May-2000
 c  
32  c              - added and changed CPP flag structure for  c              - added and changed CPP flag structure for
33  c                ALLOW_BULKFORMULAE, ALLOW_ATM_TEMP  c                ALLOW_BULKFORMULAE, ALLOW_ATM_TEMP
34  c  c
35  c              Patrick Heimbach, heimbach@mit.edu  23-May-2000  c              Patrick Heimbach, heimbach@mit.edu  23-May-2000
 c  
36  c              - sign change of ustress/vstress incorporated into  c              - sign change of ustress/vstress incorporated into
37  c                scaling factors scal_ust, scal_vst  c                scaling factors exf_outscal_ust, exf_outscal_vst
38    c
39    c     mods for pkg/seaice: menemenlis@jpl.nasa.gov 20-Dec-2002
40  c  c
41  c     ==================================================================  c     ==================================================================
42  c     SUBROUTINE exf_mapfields  c     SUBROUTINE exf_mapfields
# Line 59  c     == global variables == Line 48  c     == global variables ==
48    
49  #include "EEPARAMS.h"  #include "EEPARAMS.h"
50  #include "SIZE.h"  #include "SIZE.h"
51    #include "PARAMS.h"
52  #include "FFIELDS.h"  #include "FFIELDS.h"
53  #include "exf_param.h"  #include "GRID.h"
54  #include "exf_constants.h"  
55  #include "exf_fields.h"  #include "EXF_PARAM.h"
56  #include "exf_clim_fields.h"  #include "EXF_CONSTANTS.h"
57    #include "EXF_FIELDS.h"
58  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
59  # include "tamc.h"  # include "tamc.h"
60  # include "tamc_keys.h"  # include "tamc_keys.h"
# Line 72  c     == routine arguments == Line 63  c     == routine arguments ==
63    
64  c     mythid - thread number for this instance of the routine.  c     mythid - thread number for this instance of the routine.
65    
66          _RL     mytime
67          integer myiter
68        integer mythid        integer mythid
69    
70  c     == local variables ==  c     == local variables ==
71    
72        integer bi,bj        integer bi,bj
73        integer i,j        integer i,j,k
74        integer jtlo        INTEGER imin, imax
75        integer jthi        INTEGER jmin, jmax
76        integer itlo        PARAMETER ( imin = 1-OLx , imax = sNx+OLx )
77        integer ithi        PARAMETER ( jmin = 1-OLy , jmax = sNy+OLy )
       integer jmin  
       integer jmax  
       integer imin  
       integer imax  
78    
79  c     == end of interface ==  c     == end of interface ==
80    
81        jtlo = mybylo(mythid)        DO bj = myByLo(myThid),myByHi(myThid)
82        jthi = mybyhi(mythid)          DO bi = myBxLo(myThid),myBxHi(myThid)
       itlo = mybxlo(mythid)  
       ithi = mybxhi(mythid)  
       jmin = 1-oly  
       jmax = sny+oly  
       imin = 1-olx  
       imax = snx+olx  
   
       do bj = jtlo,jthi  
         do bi = itlo,ithi  
83    
84  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
85            act1 = bi - myBxLo(myThid)            act1 = bi - myBxLo(myThid)
# Line 114  c     == end of interface == Line 94  c     == end of interface ==
94       &                      + act4*max1*max2*max3       &                      + act4*max1*max2*max3
95  #endif /* ALLOW_AUTODIFF_TAMC */  #endif /* ALLOW_AUTODIFF_TAMC */
96    
97    c     Heat flux.
98            do j = jmin,jmax            do j = jmin,jmax
99              do i = imin,imax              do i = imin,imax
100  c             Heat flux.               qnet(i,j,bi,bj) = exf_outscal_hflux*hflux(i,j,bi,bj)
               qnet(i,j,bi,bj)  = scal_hfl*hflux(i,j,bi,bj)  
101              enddo              enddo
102            enddo            enddo
103              if ( hfluxfile .EQ. ' ' ) then
104               do j = jmin,jmax
105                do i = imin,imax
106                      qnet(i,j,bi,bj) = qnet(i,j,bi,bj) -
107         &            exf_outscal_hflux * ( hflux_exfremo_intercept +
108         &            hflux_exfremo_slope*(mytime-starttime) )
109                enddo
110               enddo
111              endif
112    
113    c     Salt flux.
114            do j = jmin,jmax            do j = jmin,jmax
115              do i = imin,imax              do i = imin,imax
116  c             Salt flux.               empmr(i,j,bi,bj)= exf_outscal_sflux*sflux(i,j,bi,bj)
 #if (defined (ALLOW_BULKFORMULAE)  && defined (ALLOW_ATM_TEMP))  
               empmr(i,j,bi,bj) = scal_prc*precip(i,j,bi,bj)  
 #else  
               empmr(i,j,bi,bj) = scal_sfl*sflux(i,j,bi,bj)  
 #endif  
117              enddo              enddo
118            enddo            enddo
119              if ( sfluxfile .EQ. ' ' ) then
120               do j = jmin,jmax
121                do i = imin,imax
122                     empmr(i,j,bi,bj) = empmr(i,j,bi,bj) -
123         &            exf_outscal_sflux * ( sflux_exfremo_intercept +
124         &            sflux_exfremo_slope*(mytime-starttime) )
125                enddo
126               enddo
127              endif
128    
129  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
130  CADJ STORE ustress(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte  CADJ STORE ustress(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
# Line 139  CADJ STORE ustress(:,:,bi,bj) = comlev1_ Line 132  CADJ STORE ustress(:,:,bi,bj) = comlev1_
132            do j = jmin,jmax            do j = jmin,jmax
133              do i = imin,imax              do i = imin,imax
134  c             Zonal wind stress.  c             Zonal wind stress.
135                if (ustress(i,j,bi,bj).gt.2.0D0) then                if (ustress(i,j,bi,bj).gt.windstressmax) then
136                  ustress(i,j,bi,bj)=2.0D0                  ustress(i,j,bi,bj)=windstressmax
137                endif                endif
138              enddo              enddo
139            enddo            enddo
# Line 149  CADJ STORE ustress(:,:,bi,bj) = comlev1_ Line 142  CADJ STORE ustress(:,:,bi,bj) = comlev1_
142  #endif  #endif
143            do j = jmin,jmax            do j = jmin,jmax
144              do i = imin,imax              do i = imin,imax
145                if (ustress(i,j,bi,bj).lt.-2.0D0) then                if (ustress(i,j,bi,bj).lt.-windstressmax) then
146                  ustress(i,j,bi,bj)=-2.0D0                  ustress(i,j,bi,bj)=-windstressmax
147                endif                endif
148              enddo              enddo
149            enddo            enddo
150            do j = jmin,jmax            IF ( stressIsOnCgrid ) THEN
151              do i = imin,imax             do j = jmin,jmax
152                fu(i,j,bi,bj)    = scal_ust*ustress(i,j,bi,bj)              do i = imin+1,imax
153                  fu(i,j,bi,bj) = exf_outscal_ustress*ustress(i,j,bi,bj)
154                enddo
155               enddo
156              ELSE
157               do j = jmin,jmax
158                do i = imin+1,imax
159    c     Shift wind stresses calculated at Grid-center to W/S points
160                  fu(i,j,bi,bj) = exf_outscal_ustress*
161         &              (ustress(i,j,bi,bj)+ustress(i-1,j,bi,bj))
162         &              *exf_half*maskW(i,j,1,bi,bj)
163              enddo              enddo
164            enddo             enddo
165              ENDIF
166    
167  #ifdef ALLOW_AUTODIFF_TAMC  #ifdef ALLOW_AUTODIFF_TAMC
168  CADJ STORE vstress(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte  CADJ STORE vstress(:,:,bi,bj) = comlev1_bibj, key=ikey, byte=isbyte
# Line 166  CADJ STORE vstress(:,:,bi,bj) = comlev1_ Line 170  CADJ STORE vstress(:,:,bi,bj) = comlev1_
170            do j = jmin,jmax            do j = jmin,jmax
171              do i = imin,imax              do i = imin,imax
172  c             Meridional wind stress.  c             Meridional wind stress.
173                if (vstress(i,j,bi,bj).gt.2.0D0) then                if (vstress(i,j,bi,bj).gt.windstressmax) then
174                  vstress(i,j,bi,bj)=2.0D0                  vstress(i,j,bi,bj)=windstressmax
175                endif                endif
176              enddo              enddo
177            enddo            enddo
# Line 176  CADJ STORE vstress(:,:,bi,bj) = comlev1_ Line 180  CADJ STORE vstress(:,:,bi,bj) = comlev1_
180  #endif  #endif
181            do j = jmin,jmax            do j = jmin,jmax
182              do i = imin,imax              do i = imin,imax
183                if (vstress(i,j,bi,bj).lt.-2.0D0) then                if (vstress(i,j,bi,bj).lt.-windstressmax) then
184                  vstress(i,j,bi,bj)=-2.0D0                  vstress(i,j,bi,bj)=-windstressmax
185                endif                endif
186              enddo              enddo
187            enddo            enddo
188            do j = jmin,jmax            IF ( stressIsOnCgrid ) THEN
189               do j = jmin+1,jmax
190              do i = imin,imax              do i = imin,imax
191                fv(i,j,bi,bj)    = scal_vst*vstress(i,j,bi,bj)                fv(i,j,bi,bj) = exf_outscal_vstress*vstress(i,j,bi,bj)
192              enddo              enddo
193            enddo             enddo
194              ELSE
195               do j = jmin+1,jmax
196                do i = imin,imax
197    c     Shift wind stresses calculated at C-points to W/S points
198                  fv(i,j,bi,bj) = exf_outscal_vstress*
199         &              (vstress(i,j,bi,bj)+vstress(i,j-1,bi,bj))
200         &              *exf_half*maskS(i,j,1,bi,bj)
201                enddo
202               enddo
203              ENDIF
204    
205  #ifdef ALLOW_KPP || \  #ifdef SHORTWAVE_HEATING
  (defined (ALLOW_BULKFORMULAE) && defined (ALLOW_ATM_TEMP)))  
206  c             Short wave radiative flux.  c             Short wave radiative flux.
207            do j = jmin,jmax            do j = jmin,jmax
208              do i = imin,imax              do i = imin,imax
209                qsw(i,j,bi,bj)   = scal_swf*swflux(i,j,bi,bj)               qsw(i,j,bi,bj)  = exf_outscal_swflux*swflux(i,j,bi,bj)
210              enddo              enddo
211            enddo            enddo
212  #endif  #endif
# Line 200  c             Short wave radiative flux. Line 214  c             Short wave radiative flux.
214  #ifdef ALLOW_CLIMSST_RELAXATION  #ifdef ALLOW_CLIMSST_RELAXATION
215            do j = jmin,jmax            do j = jmin,jmax
216              do i = imin,imax              do i = imin,imax
217                sst(i,j,bi,bj)   = scal_sst*climsst(i,j,bi,bj)               sst(i,j,bi,bj)  = exf_outscal_sst*climsst(i,j,bi,bj)
218              enddo              enddo
219            enddo            enddo
220  #endif  #endif
# Line 208  c             Short wave radiative flux. Line 222  c             Short wave radiative flux.
222  #ifdef ALLOW_CLIMSSS_RELAXATION  #ifdef ALLOW_CLIMSSS_RELAXATION
223            do j = jmin,jmax            do j = jmin,jmax
224              do i = imin,imax              do i = imin,imax
225                sss(i,j,bi,bj)   = scal_sss*climsss(i,j,bi,bj)               sss(i,j,bi,bj)  = exf_outscal_sss*climsss(i,j,bi,bj)
226              enddo              enddo
227            enddo            enddo
228  #endif  #endif
# Line 216  c             Short wave radiative flux. Line 230  c             Short wave radiative flux.
230  #ifdef ATMOSPHERIC_LOADING  #ifdef ATMOSPHERIC_LOADING
231            do j = jmin,jmax            do j = jmin,jmax
232              do i = imin,imax              do i = imin,imax
233                pload(i,j,bi,bj) = scal_apressure*apressure(i,j,bi,bj)               pload(i,j,bi,bj)=exf_outscal_apressure*apressure(i,j,bi,bj)
234              enddo              enddo
235            enddo            enddo
236  #endif  #endif
237    
238            ENDDO
239          enddo        ENDDO
       enddo  
240    
241  c     Update the tile edges.  c     Update the tile edges.
242    
243        _EXCH_XY_R4(  qnet, mythid )        _EXCH_XY_R4(  qnet, mythid )
244        _EXCH_XY_R4( empmr, mythid )        _EXCH_XY_R4( empmr, mythid )
 c      _EXCH_XY_R4(    fu, mythid )  
 c      _EXCH_XY_R4(    fv, mythid )  
245         CALL EXCH_UV_XY_RS(fu, fv, .TRUE., myThid)         CALL EXCH_UV_XY_RS(fu, fv, .TRUE., myThid)
246  #ifdef ALLOW_KPP  #ifdef SHORTWAVE_HEATING
247        _EXCH_XY_R4(   qsw, mythid )        _EXCH_XY_R4(   qsw, mythid )
248  #endif  #endif
249  #ifdef ALLOW_CLIMSST_RELAXATION  #ifdef ALLOW_CLIMSST_RELAXATION
# Line 245  c      _EXCH_XY_R4(    fv, mythid ) Line 256  c      _EXCH_XY_R4(    fv, mythid )
256        _EXCH_XY_R4( pload, mythid )        _EXCH_XY_R4( pload, mythid )
257  #endif  #endif
258    
259        end        RETURN
260          END

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.22