Scheduled Downtime
On Wednesday 09 March 2022 from 6am to 10am MT, the website will be down for maintenance

Accumulating TEND_TEMP only at shallowest model level

sur23beeb

ST
Member
I have modified the POP2 source code before to write out variables only at select depths before and am trying the same for TEND_TEMP at the shallowest model level. My plan is to just create a new 2d variable. Here are the steps I have taken (steps 1 and 2 are from within passive_tracers.F90)
1.
Code:
integer (int_kind), dimension(1), public :: &
   tavg_temp_tend_5m         ! tavg id for temperature tendency at
                             ! shallowest model level

2.
Code:
      sname = 'TEND_' /&
           &/ trim(tracer_d(1)%short_name)//'_5m'
      lname = 'Tendency of Thickness Weighted '/&
           &/ trim(tracer_d(1)%short_name)//'at 5m'
      units = tracer_d(1)%tend_units
      grid_loc = '2111'
      coordinates = 'TLONG TLAT time'
      call define_tavg_field(tavg_temp_tend_5m(1),                  &
                             sname, 2, long_name=lname,             &
                             units=units, grid_loc=grid_loc,        &
                             scale_factor=tracer_d(1)%scale_factor, &
                             coordinates=coordinates)

3. This is the part where I need some help. Here is the pre-existing code to write out TEND_TEMP, the variable with 3 spatial dimensions. This part is inside a do n = 1,nt loop, where n is the tracer id (1 for temperature, 2 for salinity, etc.)
Code:
      if (accumulate_tavg_now(tavg_var_tend(n)) .or. accumulate_tavg_now(tavg_var_tend_zint_100m(n))) then
         k = 1
         if (sfc_layer_type == sfc_layer_varthick) then
            WORK = (c1 / c2dtt(k)) * &
                 ((c1 + grav_dz_r*PSURF(:,:,newtime,iblock))*TRACER(:,:,k,n,newtime,iblock) - &
                  (c1 + grav_dz_r*PSURF(:,:,oldtime,iblock))*TRACER(:,:,k,n,oldtime,iblock))
         else
            WORK = (c1 / c2dtt(k)) * &
                 (TRACER(:,:,k,n,newtime,iblock) - &
                  TRACER(:,:,k,n,oldtime,iblock))
         endif

         ! add curtime Robert filter terms and change in curtime TRACER from frazil ice formation
         ! oldtime Robert filter terms are already included in TRACER newtime
         ! Robert filter only works with sfc_layer_varthick, so we don't implement non-sfc_layer_varthick here
         if (lrobert_filter) then
           WORK = WORK + (dzr(1)*(robert_curtime)/c2dtt(k)) * STORE_RF(:,:,k,n,iblock)
           WORK = WORK - rf_conservation_factor(n)*((robert_curtime)/c2dtt(k)) * &
             (c1 + grav_dz_r*PSURF(:,:,curtime,iblock)) * RCALCT_OPEN_OCEAN_3D(:,:,k,iblock)
           WORK = WORK + (c1 / c2dtt(k)) * &
             (c1 + grav_dz_r*PSURF(:,:,curtime,iblock)) * dTRACER_CUR_FRAZIL(:,:,n,iblock)
         endif

         call accumulate_tavg_field(WORK, tavg_var_tend(n), iblock, k)

         WORK_ZINT = dz(k) * merge(WORK, c0, k<=KMT(:,:,iblock))
In my case, I only require temperature, so I am thinking of plucking out the code block above out of the do loop and pasting it just before the do loop begins, with the following changes:
(i) Change n to just 1.
(ii) Change the accumulating step to reflect the new tavg id for my new variable as follows:
Code:
call accumulate_tavg_field(WORK, tavg_temp_tend_5m(1), iblock, k)

4. Do I still need this line in the newly pasted block of code? It will already be there inside the do n = 1,nt loop which obviously I am not going to touch.
Code:
WORK_ZINT = dz(k) * merge(WORK, c0, k<=KMT(:,:,iblock))
 
Top