Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct array constructor for strings in CABLE-POP_TRENDY #427

Open
wants to merge 7 commits into
base: CABLE-POP_TRENDY
Choose a base branch
from
6 changes: 3 additions & 3 deletions core/biogeochem/POPLUC.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1459,14 +1459,14 @@ SUBROUTINE POP_LUC_CASA_transfer(POPLUC, POP, LUC_EXPT, &
irp = ilu + j -1
! Update tile area
if (ilu == p) then
POPLUC%primf(g) = min(1.0, max(patch(irp)%frac + dA_r(ilu) + dA_d(ilu), 0.0_dp))
POPLUC%primf(g) = min(1.0_dp, max(patch(irp)%frac + dA_r(ilu) + dA_d(ilu), 0.0_dp))
elseif (ilu == s) then
POPLUC%secdf(g) = min(1.0, max(patch(irp)%frac + dA_r(ilu) + dA_d(ilu), 0.0_dp))
POPLUC%secdf(g) = min(1.0_dp, max(patch(irp)%frac + dA_r(ilu) + dA_d(ilu), 0.0_dp))
if (eq(POPLUC%secdf(g), 0.0_dp)) then
POPLUC%freq_age_secondary(g,:) = 0.0_dp
endif
elseif (ilu == gr) then
POPLUC%grass(g) = min(1.0, max(patch(irp)%frac + dA_r(ilu) + dA_d(ilu), 0.0_dp))
POPLUC%grass(g) = min(1.0_dp, max(patch(irp)%frac + dA_r(ilu) + dA_d(ilu), 0.0_dp))

! Update crop and pasture fraction within the grass land use type
POPLUC%past(g) = min(max(POPLUC%past(g) + (POPLUC%ptoq(g) + POPLUC%stoq(g) + POPLUC%ctoq(g) + POPLUC%rtoq(g)) &
Expand Down
8 changes: 2 additions & 6 deletions core/biogeochem/casa_inout.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,7 @@ subroutine write_casa_output_grid_nc(veg, casamet, casapool, casabal, casaflux,
use casavariable, only: casa_met, casa_pool, casa_balance, casa_flux, &
casafile, casa_timeunits
use cable_common_module, only: cable_user, filename, handle_err
use cable_def_types_mod, only: veg_parameter_type, mp
use cable_def_types_mod, only: veg_parameter_type
! use netcdf, only: nf90_noerr, &
! nf90_put_var, nf90_clobber, nf90_create, nf90_global, nf90_put_att, &
!#ifdef __NETCDF3__
Expand Down Expand Up @@ -2764,7 +2764,6 @@ SUBROUTINE put_casa_var_grid_patch(file_id,var_id,var_vals,cnt,tmp_array)

! writes casa vars to file with dimensions x,y,patch,t

use casadimension, only: mplant, mlitter, msoil, icycle
use cable_common_module, only: handle_err

implicit none
Expand Down Expand Up @@ -2810,7 +2809,6 @@ SUBROUTINE put_casa_var_grid_patch_average(file_id,var_id,var_vals,outdim,cnt,tm
! writes casa vars to file with dimensions x,y,outdim,t
! averages 3rd dimension (outdim) over patches

use casadimension, only: mplant, mlitter, msoil, icycle
use cable_common_module, only: handle_err

implicit none
Expand Down Expand Up @@ -2866,7 +2864,7 @@ subroutine write_casa_output_patch_nc(veg, casamet, casapool, casabal, casaflux,
use casavariable, only: casa_met, casa_pool, casa_balance, casa_flux, &
casafile, casa_timeunits
use cable_common_module, only: cable_user, filename, handle_err
use cable_def_types_mod, only: veg_parameter_type, mp
use cable_def_types_mod, only: veg_parameter_type
! use netcdf, only: nf90_noerr, &
! nf90_put_var, nf90_clobber, nf90_create, nf90_global, nf90_put_att, &
!#ifdef __NETCDF3__
Expand Down Expand Up @@ -3534,7 +3532,6 @@ SUBROUTINE put_casa_var_patch(file_id,var_id,var_vals,cnt,tmp_array)

! writes casa vars to file with dimensions land,patch,t

use casadimension, only: mplant, mlitter, msoil, icycle
use cable_common_module, only: handle_err

implicit none
Expand Down Expand Up @@ -3573,7 +3570,6 @@ SUBROUTINE put_casa_var_patch_average(file_id,var_id,var_vals,outdim,cnt,tmp_arr

! writes casa vars to file with dimensions land,outdim,t

use casadimension, only: mplant, mlitter, msoil, icycle
use cable_common_module, only: handle_err

implicit none
Expand Down
16 changes: 8 additions & 8 deletions core/biogeophys/cable_common.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ MODULE cable_common_module
INTEGER, SAVE :: CurYear ! current year of multiannual run

! Dimension name lists for searching NetCDF dimensions IDs
CHARACTER(LEN=16), DIMENSION(5), PARAMETER :: LatNames = &
["latitude", "lat", "lats", "y", "Latitude"]
CHARACTER(LEN=16), DIMENSION(5), PARAMETER :: LonNames = &
["longitude", "lon", "lons", "x", "Longitude"]
CHARACTER(LEN=16), DIMENSION(3), PARAMETER :: TimeNames = &
["time", "t", "Time"]
CHARACTER(LEN=*), DIMENSION(*), PARAMETER :: LatNames = &
[CHARACTER(LEN=8) :: "latitude", "lat", "lats", "y", "Latitude"]
CHARACTER(LEN=*), DIMENSION(*), PARAMETER :: LonNames = &
[CHARACTER(LEN=9) :: "longitude", "lon", "lons", "x", "Longitude"]
CHARACTER(LEN=*), DIMENSION(*), PARAMETER :: TimeNames = &
[CHARACTER(LEN=4) :: "time", "t", "Time"]

! user switches turned on/off by the user thru namelists

Expand Down Expand Up @@ -719,8 +719,8 @@ FUNCTION get_dimid(FileID, DimNames)
END IF
END DO CheckNames

CALL handle_err(ok, "Failed to find any "//TRIM(DimNames(1))//" dimensions&
from the list.")
CALL handle_err(ok, "Failed to find any "//TRIM(DimNames(1))// &
" dimensions from the list.")

END FUNCTION get_dimid

Expand Down
8 changes: 1 addition & 7 deletions offline/cable_cru_TRENDY.F90
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ MODULE CABLE_CRU
tmax = 6, tmin = 7, uwind = 8, vwind = 9, fdiff = 10,&
prevTmax = 11, nextTmin = 12
INTEGER, PRIVATE, PARAMETER :: sp = kind(1.0)
INTEGER, PRIVATE :: ErrStatus
! INTEGER, PRIVATE :: ErrStatus

CONTAINS

Expand All @@ -98,15 +98,11 @@ SUBROUTINE CRU_INIT(CRU)
! We want one filename for each variable, stored in a predefined index.
CHARACTER(LEN=256), dimension(13) :: InputFiles

! Landmask to spatially filter the data
INTEGER, DIMENSION(:,:), ALLOCATABLE :: LandMask

! Iterator variable for the variables
INTEGER :: VarIndx

! Checker for the NetCDF io
INTEGER :: ok
LOGICAL :: IsOpen

! Start with the things we want from the namelist. The namelist must set
! the filenames to read from, the method of choosing atmospheric carbon and
Expand Down Expand Up @@ -167,15 +163,13 @@ SUBROUTINE CRU_GET_SUBDIURNAL_MET(CRU, MET, CurYear, ktau, kend)
logical :: newday, LastDayOfYear ! Flags for occurence of a new day (0 hrs) and the last day of the year.
INTEGER :: iland ! Loop counter through 'land' cells (cells in the spatial domain)
INTEGER :: itimestep ! Loop counter through subdiurnal timesteps in a day
INTEGER :: imetvar ! Loop counter through met variables
INTEGER :: dM, dD ! Met date as year, month, and day returned from DOYSOD2YMDHMS
INTEGER :: is, ie ! Starting and ending vegetation type per land cell
REAL :: dt ! Timestep in seconds
! Store the CO2Air as an array
REAL, DIMENSION(:), ALLOCATABLE :: CO2air ! CO2 concentration in ppm
type(WEATHER_GENERATOR_TYPE), save :: WG
logical, save :: CALL1 = .true. ! A *local* variable recording the first call of this routine
INTEGER :: VarIter

! Purely for readability...
dt = CRU%DTsecs
Expand Down
9 changes: 3 additions & 6 deletions offline/cable_input.F90
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ MODULE cable_input_module
! The start and end years of each dataset
INTEGER, DIMENSION(:), ALLOCATABLE :: StartYear, EndYear
! List of possible variable names for the desired variable in the dataset
CHARACTER(LEN=16), DIMENSION(:), ALLOCATABLE :: VarNames
CHARACTER(LEN=32), DIMENSION(:), ALLOCATABLE :: VarNames

! Metadata about the currently open file
INTEGER :: CurrentFileID, CurrentVarID, CurrentFileIndx
Expand Down Expand Up @@ -2958,9 +2958,6 @@ SUBROUTINE prepare_spatiotemporal_dataset(FileTemplate, Dataset)
! without destroying the original template.
CHARACTER(len=256):: CurrentFile

! We read the start and end years to strings before writing them to the key.
CHARACTER(len=4) :: StartYear, EndYear

! Integers to store the status of the command.
INTEGER :: ExStat, CStat

Expand All @@ -2979,7 +2976,7 @@ SUBROUTINE prepare_spatiotemporal_dataset(FileTemplate, Dataset)
INTEGER :: FileCounter

! Iterators
INTEGER :: CharIndx, FileIndx
INTEGER :: FileIndx

! Get a unique file ID here.
CALL get_unit(InputUnit)
Expand Down Expand Up @@ -3246,7 +3243,7 @@ SUBROUTINE read_metvals(STD, DataArr, LandIDx, LandIDy, Year, DayOfYear,&
INTEGER :: YearIndex, TimeIndex

! Loop Iterators
INTEGER :: FileIndx, VarNameIndx, YearIter, LandCell
INTEGER :: YearIter, LandCell

! Status checker
INTEGER :: ok
Expand Down