CABLE-LSM / CABLE-Trac-archive

Archive CABLE Trac contents as issues
Other
0 stars 0 forks source link

CASA-CNP fixes #228

Open penguian opened 4 years ago

penguian commented 4 years ago

keyword_keepgit owner:yxw599@nci.org.au type_defect | by mgk576


To get CASA to work in the trunk further fixes are needed.

Firstly (https://trac.nci.org.au/trac/cable/ticket/227).

In addition:

in cable_driver.F90, around line 851, below the comment "! WRITE CASA OUTPUT" ... this fix generates output files which currently are not written. There might be a better fix, Jhan do you understand the timestep stuff?

IF (.NOT.spinup) THEN
   ! mgk576, hack for now for CASA outputs
   IF(MOD((ktau-kstart+1),ktauday)==0) THEN  ! end of day
      ctime = ctime +1
      CALL update_sum_casa(sum_casapool, sum_casaflux, &
                                                casapool, casaflux, &
                                                .FALSE. , .TRUE. , count_sum_casa)

      IF (ktau == kend) THEN
         CALL WRITE_CASA_OUTPUT_NC (veg, casamet, &
                                                                    sum_casapool, casabal, &
                                                                    sum_casaflux, &
                                                                    CASAONLY, ctime, .TRUE. )
      ELSE
         CALL WRITE_CASA_OUTPUT_NC (veg, casamet, &
                                                                    sum_casapool, casabal, &
                                                                    sum_casaflux, &
                                                                    CASAONLY, ctime, .FALSE. )
      END IF

      count_sum_casa = 0
      CALL zero_sum_casa(sum_casapool, sum_casaflux)
   ENDIF
ENDIF

Finally, in casa_cnp.F90. YP's branch has this catch for non-physical behaviour. This hasn't made it across into the trunk. I'm not sure why it would be worth asking Vanessa if she feels it is unnecessary. Either way, I see no reason not to have it as it would only be used in erroneous scenarios so shouldn't mess anyone's simulations up.

WHERE(casaflux%Cnpp < 0.0)
     ! change made here by ypw on 11-7-2016 to include leaf maintenance respiration
      delcrmleaf(:)  = casaflux%Cnpp(:) * casaflux%crmplant(:,leaf) &
                     / max(0.01,(casaflux%crmplant(:,leaf)+casaflux%crmplant(:,wood) &
                               + casaflux%crmplant(:,froot)))
      delcrmwood(:)  = casaflux%Cnpp(:) * casaflux%crmplant(:,wood) &
                     / max(0.01,(casaflux%crmplant(:,leaf)+casaflux%crmplant(:,wood) &
                               + casaflux%crmplant(:,froot)))
      delcrmfroot(:) = casaflux%Cnpp(:) * casaflux%crmplant(:,froot) &
                     / max(0.01,(casaflux%crmplant(:,leaf)+casaflux%crmplant(:,wood) &
                               + casaflux%crmplant(:,froot)))

      casaflux%crmplant(:,leaf)  = casaflux%crmplant(:,leaf)  + delcrmleaf(:)
      casaflux%crmplant(:,wood)  = casaflux%crmplant(:,wood)  + delcrmwood(:)
      casaflux%crmplant(:,froot) = casaflux%crmplant(:,froot) + delcrmfroot(:)
     ! casaflux%Cnpp(:) = casaflux%Cnpp(:) -delcrmwood(:)-delcrmfroot(:)
      casaflux%crgplant(:) = 0.0

ENDWHERE

Issue migrated from trac:228 at 2023-11-27 11:29:59 +1100

penguian commented 4 years ago

@mgk576@nci.org.au commented


Fixes are here:

https://trac.nci.org.au/trac/cable/browser/branches/Users/mgk576/trunk

penguian commented 4 years ago

@mgk576@nci.org.au commented


Further additions are required to allow Pdep and Ndep to be passed via the met file. Doing this allows site runs to easily set their own inputs without altering the core functionality of the model (i.e. pre-processing) and allows users to replicate recent MIPs (e.g. FACE). The main changes are in cable_input.f90, fixes are also here: https://trac.nci.org.au/trac/cable/browser/branches/Users/mgk576/trunk

e.g.

    ! Look for Ndep
    ok = NF90_INQ_VARID(ncid_met,'Ndep',id%Ndep)
    IF(ok == NF90_NOERR) THEN ! If inquiry is okay
       exists%Ndep = .TRUE. ! Ndep is present in met file
       ! Get Ndep units:
       ok = NF90_GET_ATT(ncid_met,id%Ndep,'units',metunits%Ndep)
       IF(ok /= NF90_NOERR) CALL nc_abort &
            (ok,'Error finding Ndep units in met data file ' &
            _TRIM(filename%met)_' (SUBROUTINE open_met_file)')
       IF(metunits%Ndep(1:10)/='gN/m^2/d^1') THEN
          WRITE(*,*) metunits%Ndep, metunits%Ndep(1:10)
          CALL abort('Unknown units for Ndep'// &
               ' in '_TRIM(filename%met)_' (SUBROUTINE open_met_data)')
       END IF
    ELSE ! Ndep not present
       exists%Ndep = .FALSE. ! Ndep is not present in met file
       all_met=.FALSE. ! not all met variables are present in file
       ! Note this in log file:
       WRITE(logn,*) 'Ndep not present in met file'
    END IF

    ! Look for Pdep
    ok = NF90_INQ_VARID(ncid_met,'Pdep',id%Pdep)
    IF(ok == NF90_NOERR) THEN ! If inquiry is okay
       exists%Pdep = .TRUE. ! Ndep is present in met file
       ! Get Ndep units:
       ok = NF90_GET_ATT(ncid_met,id%Pdep,'units',metunits%Pdep)
       IF(ok /= NF90_NOERR) CALL nc_abort &
            (ok,'Error finding Ndep units in met data file ' &
            _TRIM(filename%met)_' (SUBROUTINE open_met_file)')
       IF(metunits%Pdep(1:10)/='gP/m^2/d^1') THEN
          WRITE(*,*) metunits%Pdep
          CALL abort('Unknown units for Pdep'// &
               ' in '_TRIM(filename%met)_' (SUBROUTINE open_met_data)')
       END IF
    ELSE ! Pdep not present
       exists%Pdep = .FALSE. ! Pdep is not present in met file
       all_met=.FALSE. ! not all met variables are present in file
       ! Note this in log file:
       WRITE(logn,*) 'Pdep not present in met file'
    END IF

and

! Get Ndep data for mask grid:- - - - - - - - - - - - - - - - - -
      IF(exists%Ndep) THEN ! If Ndep exists in met file
        ok= NF90_GET_VAR(ncid_met,id%Ndep,tmpDat4, &
             start=(/1,1,1,ktau/),count=(/xdimsize,ydimsize,1,1/))
        IF(ok /= NF90_NOERR) CALL nc_abort &
             (ok,'Error reading Ndep in met data file ' &
             _TRIM(filename%met)_' (SUBROUTINE get_met_data)')
        DO i=1,mland ! over all land points/grid cells
          met%ndep(landpt(i)%cstart:landpt(i)%cend) = &
                  REAL(tmpDat4(land_x(i),land_y(i),1,1))
        ENDDO

        ! gN m-2 d-1
        casaflux%Nmindep = met%ndep
      END IF

       ! Get Pdep data for mask grid:- - - - - - - - - - - - - - - - - -
      IF(exists%Pdep) THEN ! If Ndep exists in met file
        ok= NF90_GET_VAR(ncid_met,id%Pdep,tmpDat4, &
             start=(/1,1,1,ktau/),count=(/xdimsize,ydimsize,1,1/))
        IF(ok /= NF90_NOERR) CALL nc_abort &
             (ok,'Error reading Pdep in met data file ' &
             _TRIM(filename%met)_' (SUBROUTINE get_met_data)')
        DO i=1,mland ! over all land points/grid cells
          met%pdep(landpt(i)%cstart:landpt(i)%cend) = &
                  REAL(tmpDat4(land_x(i),land_y(i),1,1))
        ENDDO

        ! gP m-2 d-1
        casaflux%Pdep = met%pdep
      END IF

This also requires "casaflux" being passed to "get_met_data"

penguian commented 4 years ago

@mgk576@nci.org.au changed _comment0 which not transferred by tractive

penguian commented 4 years ago

@mgk576@nci.org.au changed _comment1 which not transferred by tractive

penguian commented 4 years ago

@mgk576@nci.org.au changed _comment2 which not transferred by tractive

penguian commented 4 years ago

@mgk576@nci.org.au changed _comment3 which not transferred by tractive

penguian commented 4 years ago

@mgk576@nci.org.au commented


Two further tickets are also relevant:

https://trac.nci.org.au/trac/cable/ticket/237 (needed for spin up)

https://trac.nci.org.au/trac/cable/ticket/238 (needed to stop confusing people)

penguian commented 4 years ago

@mgk576@nci.org.au changed _comment0 which not transferred by tractive

penguian commented 4 years ago

@jxs599@nci.org.au set milestone to 6. Report

penguian commented 4 years ago

@mgk576@nci.org.au commented


This ticket is also problematic...

https://trac.nci.org.au/trac/cable/ticket/239#ticket

penguian commented 1 year ago

@ccc561@nci.org.au set keywords to keepgit