Browse Source

New feature: FABM support

master
Karsten Bolding 12 years ago
parent
commit
55d858cc37
  1. 0
      release.sh
  2. 3
      src/3d/Makefile
  3. 12
      src/3d/dynamic_declarations_3d.h
  4. 334
      src/3d/getm_fabm.F90
  5. 18
      src/3d/static_3d.h
  6. 25
      src/Rules.make
  7. 7
      src/getm/initialise.F90
  8. 7
      src/getm/integration.F90
  9. 2
      src/meteo/meteo.F90
  10. 54
      src/ncdf/init_3d_ncdf.F90
  11. 5
      src/ncdf/ncdf_3d.F90
  12. 2
      src/ncdf/ncdf_mean.F90
  13. 2
      src/ncdf/save_2d_ncdf.F90
  14. 45
      src/ncdf/save_3d_ncdf.F90

0
release.sh

3
src/3d/Makefile

@ -30,6 +30,9 @@ ifeq ($(GETM_SPM),true)
MOD += \
$(LIB)(spm.o)
endif
ifeq ($(FABM),true)
MOD += $(LIB)(getm_fabm.o)
endif
ifeq ($(GETM_BIO),true)
MOD += $(LIB)(getm_bio.o)
endif

12
src/3d/dynamic_declarations_3d.h

@ -9,16 +9,19 @@
integer, dimension(:,:), allocatable:: kmin,kumin,kvmin
integer, dimension(:,:), allocatable:: kmin_pmz,kumin_pmz,kvmin_pmz
REALTYPE, dimension(:,:,:), allocatable :: uu,vv,ww
REALTYPE, dimension(:,:,:), allocatable :: uu,vv
REALTYPE, dimension(:,:,:), allocatable, target :: ww
#ifdef STRUCTURE_FRICTION
REALTYPE, dimension(:,:,:), allocatable :: sf
#endif
REALTYPE, dimension(:,:,:), allocatable :: ho,hn
REALTYPE, dimension(:,:,:), allocatable, target :: hn
REALTYPE, dimension(:,:,:), allocatable :: ho
REALTYPE, dimension(:,:,:), allocatable :: huo,hun
REALTYPE, dimension(:,:,:), allocatable :: hvo,hvn
REALTYPE, dimension(:,:,:), allocatable :: hcc
REALTYPE, dimension(:,:,:), allocatable :: uuEx,vvEx
REALTYPE, dimension(:,:,:), allocatable :: num,nuh
REALTYPE, dimension(:,:,:), allocatable, target :: nuh
REALTYPE, dimension(:,:,:), allocatable :: num
REALTYPE, dimension(:,:,:), allocatable :: tke,eps
REALTYPE, dimension(:,:,:), allocatable :: SS
@ -26,7 +29,8 @@
REALTYPE, dimension(:,:,:), allocatable :: NN
! 3D baroclinic fields
REALTYPE, dimension(:,:,:), allocatable :: S,T,rho,buoy
REALTYPE, dimension(:,:,:), allocatable, target :: S,T,rho
REALTYPE, dimension(:,:,:), allocatable :: buoy
REALTYPE, dimension(:,:,:), allocatable :: alpha,beta
REALTYPE, dimension(:,:,:), allocatable :: idpdx,idpdy
REALTYPE, dimension(:,:,:), allocatable :: rad,light

334
src/3d/getm_fabm.F90

@ -0,0 +1,334 @@
#include "cppdefs.h"
!-----------------------------------------------------------------------
!BOP
!
! !MODULE: getm_fabm()
!
! !INTERFACE:
module getm_fabm
!
! !DESCRIPTION:
!
! !USES:
use domain, only: imin,imax,jmin,jmax,kmax
use domain, only: az,au,av
#if defined(SPHERICAL) || defined(CURVILINEAR)
use domain, only: dxu,dxv,dyu,dyv,arcd1
#else
use domain, only: dx,dy,ard1
#endif
use variables_3d, only: uu,vv,ww,hun,hvn,ho,hn
use variables_3d, only: nuh,T,S,rho,a,g1,g2
use advection_3d, only: do_advection_3d
use meteo, only: swr,u10,v10,evap,precip
use halo_zones, only: update_3d_halo,wait_halo,D_TAG
! JORN_FABM
use gotm_fabm, only: init_gotm_fabm,set_env_gotm_fabm,do_gotm_fabm
use gotm_fabm, only: fabm_calc, model, cc_col=>cc, cc_diag_col=>cc_diag, cc_diag_hz_col=>cc_diag_hz
use fabm_types,only: time_treatment_last
IMPLICIT NONE
!
! !PUBLIC DATA MEMBERS:
public init_getm_fabm, do_getm_fabm
integer, public :: fabm_init_method=0
!
! !PRIVATE DATA MEMBERS:
integer :: fabm_hor_adv=1
integer :: fabm_ver_adv=1
integer :: fabm_adv_split=1
REALTYPE :: fabm_AH=-1.
#ifdef STATIC
REALTYPE :: delxu(I2DFIELD),delxv(I2DFIELD)
REALTYPE :: delyu(I2DFIELD),delyv(I2DFIELD)
REALTYPE :: area_inv(I2DFIELD)
REALTYPE :: ff(I3DFIELD)
#else
REALTYPE, dimension(:,:), allocatable :: delxu,delxv
REALTYPE, dimension(:,:), allocatable :: delyu,delyv
REALTYPE, dimension(:,:), allocatable :: area_inv
REALTYPE, dimension(:,:,:), allocatable :: ff
#endif
REALTYPE, allocatable, dimension(:,:,:,:) :: cc_pel,cc_diag
REALTYPE, allocatable, dimension(:,:,:) :: cc_ben,cc_diag_hz
!
! !REVISION HISTORY:
! Original author(s): Hans Burchard & Karsten Bolding
!
!EOP
!-----------------------------------------------------------------------
contains
!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: init_getm_fabm
!
! !INTERFACE:
subroutine init_getm_fabm(nml_file)
IMPLICIT NONE
!
! !DESCRIPTION:
! Reads the namelist and makes calls to the init functions of the
! various model components.
!
! !INPUT PARAMETERS:
character(len=*), intent(in) :: nml_file
!
! !REVISION HISTORY:
! See the log for the module
!
! !LOCAL VARIABLES
integer, parameter :: unit_fabm=63
integer :: rc
integer :: i,j,n
character(len=PATH_MAX) :: fabm_init_file
integer :: fabm_init_format, fabm_field_no
namelist /getm_fabm_nml/ fabm_init_method, &
fabm_init_file,fabm_init_format,fabm_field_no, &
fabm_hor_adv,fabm_ver_adv,fabm_adv_split,fabm_AH
!EOP
!-------------------------------------------------------------------------
!BOC
LEVEL2 'init_getm_fabm()'
! Initialize FABM.
call init_gotm_fabm(kmax,NAMLST2,'fabm.nml')
if (fabm_calc) then
! Temporary: make sure diagnostic variables store the last value,
! not their time integral. This will be redundant when time-integrating/averaging
! is moved from FABM to the physical host.
do n=1,ubound(model%info%diagnostic_variables,1)
model%info%diagnostic_variables(n)%time_treatment = time_treatment_last
end do
do n=1,ubound(model%info%diagnostic_variables_hz,1)
model%info%diagnostic_variables_hz(n)%time_treatment = time_treatment_last
end do
! Allocate memory for pelagic state variables.
allocate(cc_pel(ubound(model%info%state_variables,1),I3DFIELD),stat=rc)
if (rc /= 0) stop 'init_getm_fabm: Error allocating memory (cc_pel)'
cc_pel = _ZERO_
! Allocate memory for benthic state variables.
allocate(cc_ben(ubound(model%info%state_variables_ben,1),I2DFIELD),stat=rc)
if (rc /= 0) stop 'init_getm_fabm: Error allocating memory (cc_ben)'
cc_ben = _ZERO_
! Allocate memory for 3D diagnostic variables.
allocate(cc_diag(ubound(model%info%diagnostic_variables,1),I3DFIELD),stat=rc)
if (rc /= 0) stop 'init_getm_fabm: Error allocating memory (cc_diag)'
cc_diag = _ZERO_
! Allocate memory for 2D [horizontal-only] diagnostic variables.
allocate(cc_diag_hz(ubound(model%info%diagnostic_variables_hz,1),I2DFIELD),stat=rc)
if (rc /= 0) stop 'init_getm_fabm: Error allocating memory (cc_diag_hz)'
cc_diag_hz = _ZERO_
! Read settings specific to GETM-FABM interaction.
open(NAMLST2,status='unknown',file=trim(nml_file))
read(NAMLST2,NML=getm_fabm_nml)
close(NAMLST2)
! Show settings specific to GETM-FABM interaction.
LEVEL2 "settings related to FABM calculations"
LEVEL3 'fabm_hor_adv= ',fabm_hor_adv
LEVEL3 'fabm_ver_adv= ',fabm_ver_adv
LEVEL3 'fabm_adv_split= ',fabm_adv_split
LEVEL3 'fabm_AH= ',fabm_AH
! Initialize biogeochemical state variables.
select case (fabm_init_method)
case(0)
LEVEL3 'getting initial biogeochemical fields from hotstart file'
case(1)
LEVEL3 "initial biogeochemical fields from namelists - fabm.nml"
do j=jmin,jmax
do i=imin,imax
if (az(i,j) .ge. 1 ) then
cc_pel(:,i,j,:) = cc_col(1:ubound(model%info%state_variables,1) ,:)
cc_ben(:,i,j) = cc_col(ubound(model%info%state_variables,1)+1:,1)
end if
end do
end do
case(2)
LEVEL3 'reading initial biogeochemical fields from ',trim(fabm_init_file)
do n=1,ubound(model%info%state_variables,1)
LEVEL4 'inquiring ',trim(model%info%state_variables(n)%name)
call get_field(fabm_init_file,trim(model%info%state_variables(n)%name),fabm_field_no, &
cc_pel(n,:,:,:))
end do
case default
FATAL 'Not valid fabm_init_method specified'
stop 'init_getm_fabm()'
end select
! Update halos with biogeochemical variable values (distribute initial values).
do n=1,ubound(model%info%state_variables,1)
call update_3d_halo(cc_pel(n,:,:,:),cc_pel(n,:,:,:),az, &
imin,jmin,imax,jmax,kmax,D_TAG)
call wait_halo(D_TAG)
end do
#ifndef STATIC
allocate(delxu(I2DFIELD),stat=rc)
if (rc /= 0) stop 'init_getm_fabm: Error allocating memory (delxu)'
allocate(delxv(I2DFIELD),stat=rc)
if (rc /= 0) stop 'init_getm_fabm: Error allocating memory (delxv)'
allocate(delyu(I2DFIELD),stat=rc)
if (rc /= 0) stop 'init_getm_fabm: Error allocating memory (delyu)'
allocate(delyv(I2DFIELD),stat=rc)
if (rc /= 0) stop 'init_getm_fabm: Error allocating memory (delyv)'
allocate(area_inv(I2DFIELD),stat=rc)
if (rc /= 0) stop 'init_getm_fabm: Error allocating memory (area_inv)'
allocate(ff(I3DFIELD),stat=rc)
if (rc /= 0) stop 'init_getm_fabm: Error allocating memory (ff)'
#endif
#if defined(SPHERICAL) || defined(CURVILINEAR)
delxu=dxu
delxv=dxv
delyu=dyu
delyv=dyv
area_inv=arcd1
#else
delxu=dx
delxv=dx
delyu=dy
delyv=dy
area_inv=ard1
#endif
end if
return
end subroutine init_getm_fabm
!EOC
!-----------------------------------------------------------------------
!BOP
!
! !IROUTINE: do_getm_fabm()
!
! !INTERFACE:
subroutine do_getm_fabm(dt)
!
! !DESCRIPTION:
!
! !USES:
use getm_timers, only: tic, toc, TIM_GETM_BIO
IMPLICIT NONE
!
! !INPUT PARAMETERS:
REALTYPE, intent(in) :: dt
!
! !REVISION HISTORY:
! See the log for the module
!
! !LOCAL VARIABLES:
integer :: n
integer :: i,j,k
REALTYPE :: bioshade(1:kmax)
REALTYPE :: wind_speed,I_0
REALTYPE :: z(1:kmax)
!EOP
!-----------------------------------------------------------------------
!BOC
call tic(TIM_GETM_BIO)
! First we do all the vertical processes
do j=jmin,jmax
do i=imin,imax
if (az(i,j) .ge. 1 ) then
! Calculate wind speed from wind vector components.
if (allocated(u10) .and. allocated(v10)) then
wind_speed = sqrt(u10(i,j)*u10(i,j)+v10(i,j)*v10(i,j))
else
wind_speed = _ZERO_
end if
! Get surface short-wave radiation.
if (allocated(swr)) then
I_0 = swr(i,j)
else
I_0 = _ZERO_
end if
! Calculate depths of cell centers from layer heights.
z(kmax) = -_HALF_*hn(i,j,kmax)
do k=kmax-1,1,-1
z(k) = z(k+1) - _HALF_*(hn(i,j,k+1)+hn(i,j,k))
end do
! Copy current values of biogeochemical variables from full 3D field to columns.
cc_col(1:ubound(model%info%state_variables,1) ,:) = cc_pel(:,i,j,:)
cc_col(ubound(model%info%state_variables,1)+1:,1) = cc_ben(:,i,j)
cc_diag_col = cc_diag(:,i,j,:)
cc_diag_hz_col = cc_diag_hz(:,i,j)
! Transfer pointers to physcial environment variables to FABM.
call set_env_gotm_fabm(dt,0,0,T(i,j,1:),S(i,j,1:), &
rho(i,j,1:),nuh(i,j,0:),hn(i,j,0:),ww(i,j,0:), &
bioshade,I_0,wind_speed,precip(i,j),evap(i,j),z,A(i,j),g1(i,j),g2(i,j))
! Update biogeochemical variable values.
call do_gotm_fabm(kmax)
! Copy updated column values of biogeochemical variables to full 3D field.
cc_pel (:,i,j,:) = cc_col(1:ubound(model%info%state_variables,1) ,:)
cc_ben (:,i,j) = cc_col(ubound(model%info%state_variables,1)+1:,1)
cc_diag (:,i,j,:) = cc_diag_col
cc_diag_hz(:,i,j) = cc_diag_hz_col
end if
end do
end do
! Advect pelagic biogeochemical variables.
do n=1,ubound(model%info%state_variables,1)
#if 1
ff = cc_pel(n,:,:,:)
call update_3d_halo(ff,ff,az, &
imin,jmin,imax,jmax,kmax,D_TAG)
call wait_halo(D_TAG)
call do_advection_3d(dt,ff,uu,vv,ww,hun,hvn,ho,hn, &
delxu,delxv,delyu,delyv,area_inv,az,au,av, &
fabm_hor_adv,fabm_ver_adv,fabm_adv_split,fabm_AH)
cc_pel(n,:,:,:) = ff
#else
call update_3d_halo(cc3d(n,:,:,:),cc3d(n,:,:,:),az, &
imin,jmin,imax,jmax,kmax,D_TAG)
call wait_halo(D_TAG)
call do_advection_3d(dt,cc3d(n,:,:,:),uu,vv,ww,hun,hvn,ho,hn, &
delxu,delxv,delyu,delyv,area_inv,az,au,av, &
fabm_hor_adv,fabm_ver_adv,fabm_adv_split,fabm_AH)
#endif
end do
call toc(TIM_GETM_BIO)
return
end subroutine do_getm_fabm
!EOC
!-----------------------------------------------------------------------
end module getm_fabm
!-----------------------------------------------------------------------
! Copyright (C) 2007 - Karsten Bolding and Hans Burchard !
!-----------------------------------------------------------------------

18
src/3d/static_3d.h

@ -22,12 +22,12 @@
REALTYPE :: uu(I3DFIELD)
REALTYPE :: vv(I3DFIELD)
REALTYPE :: ww(I3DFIELD)
REALTYPE, target :: ww(I3DFIELD)
#ifdef STRUCTURE_FRICTION
REALTYPE :: sf(I3DFIELD)
#endif
REALTYPE :: ho(I3DFIELD)
REALTYPE :: hn(I3DFIELD)
REALTYPE, target :: hn(I3DFIELD)
REALTYPE :: huo(I3DFIELD)
REALTYPE :: hun(I3DFIELD)
REALTYPE :: hvo(I3DFIELD)
@ -36,7 +36,7 @@
REALTYPE :: uuEx(I3DFIELD)
REALTYPE :: vvEx(I3DFIELD)
REALTYPE :: num(I3DFIELD)
REALTYPE :: nuh(I3DFIELD)
REALTYPE, target :: nuh(I3DFIELD)
! 3D turbulent fields
REALTYPE :: tke(I3DFIELD)
@ -46,10 +46,10 @@
#ifndef NO_BAROCLINIC
! 3D baroclinic fields
REALTYPE :: NN(I3DFIELD)
REALTYPE :: S(I3DFIELD)
REALTYPE :: T(I3DFIELD)
REALTYPE, target :: S(I3DFIELD)
REALTYPE, target :: T(I3DFIELD)
REALTYPE, target :: rho(I3DFIELD)
REALTYPE :: rad(I3DFIELD)
REALTYPE :: rho(I3DFIELD)
REALTYPE :: buoy(I3DFIELD)
REALTYPE :: alpha(I3DFIELD)
REALTYPE :: beta(I3DFIELD)
@ -101,7 +101,7 @@
REALTYPE :: taub(I2DFIELD)
! light attenuation
REALTYPE :: A(I2DFIELD)
REALTYPE :: g1(I2DFIELD)
REALTYPE :: g2(I2DFIELD)
REALTYPE,target :: A(I2DFIELD)
REALTYPE,target :: g1(I2DFIELD)
REALTYPE,target :: g2(I2DFIELD)

25
src/Rules.make

@ -1,4 +1,3 @@
#$Id: Rules.make,v 1.24 2009-10-02 06:43:51 kb Exp $
#
# This file contains rules which are shared between multiple Makefiles.
# This file is quite complicated - all compilation options are set in this
@ -56,11 +55,6 @@ ifeq ($(GETM_STRUCTURE_FRICTION),true)
DEFINES += -DSTRUCTURE_FRICTION
endif
# Bio-geochemical component
ifeq ($(GETM_BIO),true)
DEFINES += -DGETM_BIO
endif
# Remove timers
ifeq ($(GETM_NO_TIMERS),true)
DEFINES += -DNO_TIMERS
@ -82,6 +76,8 @@ endif
# Here you can put defines for the [c|f]pp - some will also be set depending
# on compilation mode - if STATIC is defined be careful.
# It is not necessary to set INPUT_DIR
ifdef INPUT_DIR
DEFINES += -DINPUT_DIR="'$(INPUT_DIR)/'"
endif
@ -118,7 +114,21 @@ INCDIRS = -I$(GETMDIR)/include -I$(MODDIR)
LINKDIRS = -L$(LIBDIR)
EXTRA_LIBS =
# FABM-geochemical component
ifeq ($(FABM),true)
DEFINES += -D_FABM_
ifndef FABMDIR
FABMDIR = $(HOME)/FABM/fabm-svn
endif
INCDIRS += -I$(FABMDIR)/include -I$(FABMDIR)/modules/gotm/$(FORTRAN_COMPILER) -I$(FABMDIR)/src/drivers/gotm
LINKDIRS += -L$(FABMDIR)/lib/gotm/$(FORTRAN_COMPILER)
EXTRA_LIBS += -lgotm_fabm$(buildtype) -lfabm$(buildtype)
unexport GETM_BIO
endif
# Old GOTM-BIO component - deprecated
ifeq ($(GETM_BIO),true)
DEFINES += -DGETM_BIO
EXTRA_LIBS += -lbio$(buildtype)
endif
@ -129,7 +139,6 @@ EXTRA_LIBS += -lturbulence$(buildtype) -lutil$(buildtype)
INCDIRS += -I$(GOTMDIR)/modules/$(FORTRAN_COMPILER)
# Where does the NetCDF include file and library reside.
ifeq ($(NETCDF_VERSION),NETCDF4)
DEFINES += -DNETCDF4
@ -156,7 +165,6 @@ endif
endif
EXTRA_LIBS += $(NETCDFLIB)
# NetCDF/HDF configuration done
# Where does the MPI library reside.
@ -243,7 +251,6 @@ PROTEX = protex -b -n -s
.SUFFIXES:
.SUFFIXES: .F90
CPPFLAGS = $(DEFINES) $(INCDIRS)
FFLAGS = $(DEFINES) $(FLAGS) $(MODULES) $(INCDIRS) $(EXTRAS)
F90FLAGS = $(FFLAGS)

7
src/getm/initialise.F90

@ -60,6 +60,9 @@
#ifdef SPM
use suspended_matter, only: init_spm
#endif
#ifdef _FABM_
use getm_fabm, only: init_getm_fabm
#endif
#ifdef GETM_BIO
use bio, only: bio_calc
use getm_bio, only: init_getm_bio
@ -231,6 +234,10 @@
#ifdef SPM
call init_spm(trim(input_dir) // 'spm.inp',runtype)
#endif
#ifdef _FABM_
call init_getm_fabm(trim(input_dir) // 'getm_fabm.inp')
!KB call init_rivers_bio
#endif
#ifdef GETM_BIO
call init_getm_bio(trim(input_dir) // 'getm_bio.inp')
call init_rivers_bio

7
src/getm/integration.F90

@ -52,6 +52,10 @@
#ifdef SPM
use suspended_matter, only: spm_calc,do_spm
#endif
#ifdef _FABM_
use gotm_fabm, only: fabm_calc
use getm_fabm, only: do_getm_fabm
#endif
#ifdef GETM_BIO
use bio, only: bio_calc
use getm_bio, only: do_getm_bio
@ -125,6 +129,9 @@
#ifdef SPM
if (spm_calc) call do_spm()
#endif
#ifdef _FABM_
if (fabm_calc) call do_getm_fabm(M*timestep)
#endif
#ifdef GETM_BIO
if (bio_calc) call do_getm_bio(M*timestep)
#endif

2
src/meteo/meteo.F90

@ -64,7 +64,7 @@
REALTYPE, public :: w,L,rho_air,qs,qa,ea,es
REALTYPE, public, dimension(:,:), allocatable :: airp,tausx,tausy,swr,shf
REALTYPE, public, dimension(:,:), allocatable :: u10,v10,t2,hum,tcc
REALTYPE, public, dimension(:,:), allocatable :: evap,precip
REALTYPE, public, dimension(:,:), allocatable, target :: evap,precip
REALTYPE, public :: cd_mom,cd_heat,cd_latent
REALTYPE, public :: cd_precip = _ZERO_
REALTYPE, public :: t_1=-_ONE_,t_2=-_ONE_

54
src/ncdf/init_3d_ncdf.F90

@ -25,6 +25,9 @@
#ifdef GETM_BIO
use bio_var, only: numc,var_names,var_units,var_long
#endif
#ifdef _FABM_
use gotm_fabm, only: model
#endif
IMPLICIT NONE
!
@ -390,6 +393,57 @@
end do
#endif
#ifdef _FABM_
fv = bio_missing
mv = bio_missing
vr(1) = _ZERO_
vr(2) = 9999.
allocate(fabm_ids(ubound(model%info%state_variables,1)),stat=rc)
if (rc /= 0) stop 'init_3d_ncdf(): Error allocating memory (fabm_ids)'
do n=1,ubound(model%info%state_variables,1)
err = nf90_def_var(ncid,model%info%state_variables(n)%name,NF90_REAL,f4_dims,fabm_ids(n))
if (err .NE. NF90_NOERR) go to 10
call set_attributes(ncid,fabm_ids(n), &
long_name=trim(model%info%state_variables(n)%longname), &
units=trim(model%info%state_variables(n)%units), &
FillValue=fv,missing_value=mv,valid_range=vr)
end do
allocate(fabm_ids_ben(ubound(model%info%state_variables_ben,1)),stat=rc)
if (rc /= 0) stop 'init_3d_ncdf(): Error allocating memory (fabm_ids_ben)'
do n=1,ubound(model%info%state_variables_ben,1)
err = nf90_def_var(ncid,model%info%state_variables_ben(n)%name,NF90_REAL,f4_dims,fabm_ids_ben(n))
if (err .NE. NF90_NOERR) go to 10
call set_attributes(ncid,fabm_ids_ben(n), &
long_name=trim(model%info%state_variables_ben(n)%longname), &
units=trim(model%info%state_variables_ben(n)%units), &
FillValue=fv,missing_value=mv,valid_range=vr)
end do
allocate(fabm_ids_diag(ubound(model%info%diagnostic_variables,1)),stat=rc)
if (rc /= 0) stop 'init_3d_ncdf(): Error allocating memory (fabm_ids_diag)'
do n=1,ubound(model%info%diagnostic_variables,1)
err = nf90_def_var(ncid,model%info%diagnostic_variables(n)%name,NF90_REAL,f4_dims,fabm_ids_diag(n))
if (err .NE. NF90_NOERR) go to 10
call set_attributes(ncid,fabm_ids_diag(n), &
long_name=trim(model%info%diagnostic_variables(n)%longname), &
units=trim(model%info%diagnostic_variables(n)%units), &
FillValue=fv,missing_value=mv,valid_range=vr)
end do
allocate(fabm_ids_diag_hz(ubound(model%info%diagnostic_variables_hz,1)),stat=rc)
if (rc /= 0) stop 'init_3d_ncdf(): Error allocating memory (fabm_ids_diag_hz)'
do n=1,ubound(model%info%diagnostic_variables_hz,1)
err = nf90_def_var(ncid,model%info%diagnostic_variables_hz(n)%name,NF90_REAL,f3_dims,fabm_ids_diag_hz(n))
if (err .NE. NF90_NOERR) go to 10
call set_attributes(ncid,fabm_ids_diag_hz(n), &
long_name=trim(model%info%diagnostic_variables_hz(n)%longname), &
units=trim(model%info%diagnostic_variables_hz(n)%units), &
FillValue=fv,missing_value=mv,valid_range=vr)
end do
#endif
! globals
err = nf90_put_att(ncid,NF90_GLOBAL,'title',trim(title))
if (err .NE. NF90_NOERR) go to 10

5
src/ncdf/ncdf_3d.F90

@ -33,6 +33,9 @@
#endif
#ifdef GETM_BIO
integer, allocatable :: bio_ids(:)
#endif
#ifdef _FABM_
integer, allocatable, dimension(:) :: fabm_ids,fabm_ids_diag,fabm_ids_ben,fabm_ids_diag_hz
#endif
integer :: nm3dS_id,nm3dT_id,nm2dS_id,nm2dT_id
integer :: pm3dS_id,pm3dT_id,pm2dS_id,pm2dT_id
@ -58,7 +61,7 @@
REALTYPE, parameter :: spmpool_missing=-9999.0
REALTYPE, parameter :: spm_missing =-9999.0
#endif
#ifdef GETM_BIO
#if (defined(GETM_BIO) || defined(_FABM_))
REALTYPE, parameter :: bio_missing=-9999.0
#endif
REALTYPE, parameter :: nummix_missing=-9999.0

2
src/ncdf/ncdf_mean.F90

@ -37,7 +37,7 @@
REALTYPE, parameter :: tke_missing=-9999.0
REALTYPE, parameter :: eps_missing=-9999.0
REALTYPE, parameter :: nummix_missing=-9999.0
#ifdef GETM_BIO
#if (defined(GETM_BIO) || defined(_FABM_))
REALTYPE, parameter :: bio_missing=-9999.0
#endif

2
src/ncdf/save_2d_ncdf.F90

@ -48,7 +48,7 @@
n2d = n2d + 1
if (n2d .eq. 1) then
call save_grid_ncdf(ncid,save3d,x_dim,y_dim)
call save_grid_ncdf(ncid,save3d)
end if
start(1) = n2d

45
src/ncdf/save_3d_ncdf.F90

@ -39,7 +39,11 @@
#endif
#ifdef GETM_BIO
use bio_var, only: numc
use variables_3d, only: cc3d,ws3d
use variables_3d, only: cc3d
#endif
#ifdef _FABM_
use gotm_fabm,only: model
use getm_fabm,only: cc_pel,cc_ben,cc_diag,cc_diag_hz
#endif
use parameters, only: g,rho_0
use m3d, only: calc_temp,calc_salt
@ -352,6 +356,45 @@
if (err .NE. NF90_NOERR) go to 10
end do
! end if
#endif
#ifdef _FABM_
! if (save_bio) then
start(1) = 1
start(2) = 1
start(3) = 1
start(4) = n3d
edges(1) = xlen
edges(2) = ylen
edges(3) = zlen
edges(4) = 1
do n=1,ubound(model%info%state_variables,1)
call cnv_3d(imin,jmin,imax,jmax,kmin,kmax,az,cc_pel(n,:,:,:), &
bio_missing,imin,imax,jmin,jmax,0,kmax,ws)
err = nf90_put_var(ncid,fabm_ids(n),ws(_3D_W_),start,edges)
if (err .NE. NF90_NOERR) go to 10
end do
do n=1,ubound(model%info%diagnostic_variables,1)
call cnv_3d(imin,jmin,imax,jmax,kmin,kmax,az,cc_diag(n,:,:,:), &
bio_missing,imin,imax,jmin,jmax,0,kmax,ws)
err = nf90_put_var(ncid,fabm_ids_diag(n),ws(_3D_W_),start,edges)
if (err .NE. NF90_NOERR) go to 10
end do
start(3) = n3d
edges(3) = 1
do n=1,ubound(model%info%state_variables_ben,1)
call cnv_2d(imin,jmin,imax,jmax,az,cc_ben(n,:,:), &
bio_missing,imin,imax,jmin,jmax,ws)
err = nf90_put_var(ncid,fabm_ids_ben(n),ws2d(_2D_W_),start(1:3),edges(1:3))
if (err .NE. NF90_NOERR) go to 10
end do
do n=1,ubound(model%info%diagnostic_variables_hz,1)
call cnv_2d(imin,jmin,imax,jmax,az,cc_diag_hz(n,:,:), &
bio_missing,imin,imax,jmin,jmax,ws)
err = nf90_put_var(ncid,fabm_ids_diag_hz(n),ws2d(_2D_W_),start(1:3),edges(1:3))
if (err .NE. NF90_NOERR) go to 10
end do
! end if
#endif
err = nf90_sync(ncid)

Loading…
Cancel
Save