From 2c81c84be0a689f13007bb99f00f1823461d4f4f Mon Sep 17 00:00:00 2001 From: Tracy Date: Thu, 4 Apr 2024 18:27:20 +0000 Subject: [PATCH 01/13] Update hera module for rocky8, remove shell setup scripts --- scm/etc/Cheyenne_setup_gnu.csh | 55 ------------------------------ scm/etc/Cheyenne_setup_gnu.sh | 47 ------------------------- scm/etc/Cheyenne_setup_intel.csh | 55 ------------------------------ scm/etc/Cheyenne_setup_intel.sh | 47 ------------------------- scm/etc/Desktop_setup_gfortran.csh | 51 --------------------------- scm/etc/Desktop_setup_gfortran.sh | 47 ------------------------- scm/etc/Hera_setup_intel.csh | 47 ------------------------- scm/etc/Hera_setup_intel.sh | 39 --------------------- scm/etc/modules/hera_gnu.lua | 4 +-- scm/etc/modules/hera_intel.lua | 4 +-- 10 files changed, 4 insertions(+), 392 deletions(-) delete mode 100755 scm/etc/Cheyenne_setup_gnu.csh delete mode 100755 scm/etc/Cheyenne_setup_gnu.sh delete mode 100755 scm/etc/Cheyenne_setup_intel.csh delete mode 100755 scm/etc/Cheyenne_setup_intel.sh delete mode 100755 scm/etc/Desktop_setup_gfortran.csh delete mode 100755 scm/etc/Desktop_setup_gfortran.sh delete mode 100755 scm/etc/Hera_setup_intel.csh delete mode 100755 scm/etc/Hera_setup_intel.sh diff --git a/scm/etc/Cheyenne_setup_gnu.csh b/scm/etc/Cheyenne_setup_gnu.csh deleted file mode 100755 index c37acbdc2..000000000 --- a/scm/etc/Cheyenne_setup_gnu.csh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/tcsh - -echo "Setting environment variables for CCPP-SCM on Cheyenne with gcc/gfortran" - -set called=($_) - -if ( "$called" != "") then ### called by source - set MYSCRIPT=`readlink -f -n $called[2]` -else ### called by direct execution of the script - set MYSCRIPT=`readlink -f -n '$0'` -endif -set MYDIR=`dirname $MYSCRIPT` -set MYDIR=`cd $MYDIR && pwd -P` - -setenv SCM_ROOT $MYDIR/../.. - -#start with a "clean" environment; activate and deactivate ncar_pylib in order to successfully deactivate previously activated environment without errors -module load ncarenv/1.3 -conda deactivate -module purge - -#load the modules in order to compile the CCPP SCM -echo "Loading gnu and netcdf modules..." -module load ncarenv/1.3 -module load gnu/11.2.0 -module load mpt/2.25 -module load ncarcompilers/0.5.0 -module load netcdf - -echo "Setting up NCEPLIBS" -module use /glade/work/epicufsrt/contrib/hpc-stack/gnu11.2.0/modulefiles/stack -module load hpc/1.2.0 -module load hpc-gnu/11.2.0 -module load hpc-mpt/2.25 -setenv bacio_ROOT /glade/work/epicufsrt/contrib/hpc-stack/gnu11.2.0/gnu-11.2.0/bacio/2.4.1 -setenv sp_ROOT /glade/work/epicufsrt/contrib/hpc-stack/gnu11.2.0/gnu-11.2.0/sp/2.3.3 -setenv w3emc_ROOT /glade/work/epicufsrt/contrib/hpc-stack/gnu11.2.0/gnu-11.2.0/w3emc/2.9.2 - -echo "Setting CC/CXX/FC environment variables" -setenv CC gcc -setenv CXX g++ -setenv FC gfortran - -echo "Loading cmake" -module load cmake/3.16.4 -setenv CMAKE_C_COMPILER gcc -setenv CMAKE_CXX_COMPILER g++ -setenv CMAKE_Fortran_COMPILER gfortran -setenv CMAKE_Platform cheyenne.gnu - -echo "Setting up python environment for running and plotting." -module load conda/latest - -conda activate /glade/p/ral/jntp/GMTB/CCPP_SCM/conda/ccpp-scm - diff --git a/scm/etc/Cheyenne_setup_gnu.sh b/scm/etc/Cheyenne_setup_gnu.sh deleted file mode 100755 index e1a190fcc..000000000 --- a/scm/etc/Cheyenne_setup_gnu.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -echo "Setting environment variables for CCPP-SCM on Cheyenne with gcc/gfortran" - -MYDIR=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P) - -export SCM_ROOT=$MYDIR/../.. - -#start with a "clean" environment; activate and deactivate ncar_pylib in order to successfully deactivate previously activated environment without errors -module load ncarenv/1.3 -conda deactivate -module purge - -#load the modules in order to compile the CCPP SCM -echo "Loading gnu and netcdf modules..." -module load ncarenv/1.3 -module load gnu/11.2.0 -module load mpt/2.25 -module load ncarcompilers/0.5.0 -module load netcdf - -echo "Setting up NCEPLIBS" -module use /glade/work/epicufsrt/contrib/hpc-stack/gnu11.2.0/modulefiles/stack -module load hpc/1.2.0 -module load hpc-gnu/11.2.0 -module load hpc-mpt/2.25 -export bacio_ROOT=/glade/work/epicufsrt/contrib/hpc-stack/gnu11.2.0/gnu-11.2.0/bacio/2.4.1 -export sp_ROOT=/glade/work/epicufsrt/contrib/hpc-stack/gnu11.2.0/gnu-11.2.0/sp/2.3.3 -export w3emc_ROOT=/glade/work/epicufsrt/contrib/hpc-stack/gnu11.2.0/gnu-11.2.0/w3emc/2.9.2 - -echo "Setting CC/CXX/FC environment variables" -export CC=gcc -export CXX=g++ -export FC=gfortran - -echo "Loading cmake" -module load cmake/3.22.0 -export CMAKE_C_COMPILER=gcc -export CMAKE_CXX_COMPILER=g++ -export CMAKE_Fortran_COMPILER=gfortran -export CMAKE_Platform=cheyenne.gnu - -echo "Setting up python environment for running and plotting." -module load conda/latest - -conda activate /glade/p/ral/jntp/GMTB/CCPP_SCM/conda/ccpp-scm - diff --git a/scm/etc/Cheyenne_setup_intel.csh b/scm/etc/Cheyenne_setup_intel.csh deleted file mode 100755 index d8bc17890..000000000 --- a/scm/etc/Cheyenne_setup_intel.csh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/tcsh - -echo "Setting environment variables for CCPP-SCM on Cheyenne with icc/ifort" - -set called=($_) - -if ( "$called" != "") then ### called by source - set MYSCRIPT=`readlink -f -n $called[2]` -else ### called by direct execution of the script - set MYSCRIPT=`readlink -f -n '$0'` -endif -set MYDIR=`dirname $MYSCRIPT` -set MYDIR=`cd $MYDIR && pwd -P` - -setenv SCM_ROOT $MYDIR/../.. - -#start with a "clean" environment; activate and deactivate ncar_pylib in order to successfully deactivate previously activated environment without errors -module load ncarenv/1.3 -conda deactivate -module purge - -#load the modules in order to compile the CCPP SCM -echo "Loading intel and netcdf modules..." -module load ncarenv/1.3 -module load intel/2022.1 -module load mpt/2.25 -module load ncarcompilers/0.5.0 -module load netcdf - -echo "Setting up NCEPLIBS" -module use /glade/work/epicufsrt/contrib/hpc-stack/intel2022.1/modulefiles/stack -module load hpc/1.2.0 -module load hpc-intel/2022.1 -module load hpc-mpt/2.25 -setenv bacio_ROOT /glade/work/epicufsrt/contrib/hpc-stack/intel2022.1/intel-2022.1/bacio/2.4.1 -setenv sp_ROOT /glade/work/epicufsrt/contrib/hpc-stack/intel2022.1/intel-2022.1/sp/2.3.3 -setenv w3emc_ROOT /glade/work/epicufsrt/contrib/hpc-stack/intel2022.1/intel-2022.1/w3emc/2.9.2 - -echo "Setting CC/CXX/FC environment variables" -setenv CC icc -setenv CXX icpc -setenv FC ifort - -echo "Loading cmake" -module load cmake/3.22.0 -setenv CMAKE_C_COMPILER icc -setenv CMAKE_CXX_COMPILER icpc -setenv CMAKE_Fortran_COMPILER ifort -setenv CMAKE_Platform cheyenne.intel - -echo "Setting up python environment for running and plotting." -module load conda/latest - -conda activate /glade/p/ral/jntp/GMTB/CCPP_SCM/conda/ccpp-scm - diff --git a/scm/etc/Cheyenne_setup_intel.sh b/scm/etc/Cheyenne_setup_intel.sh deleted file mode 100755 index 71727e034..000000000 --- a/scm/etc/Cheyenne_setup_intel.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -echo "Setting environment variables for CCPP-SCM on Cheyenne with icc/ifort" - -MYDIR=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P) - -export SCM_ROOT=$MYDIR/../.. - -#start with a "clean" environment; activate and deactivate ncar_pylib in order to successfully deactivate previously activated environment without errors -module load ncarenv/1.3 -conda deactivate -module purge - -#load the modules in order to compile the CCPP SCM -echo "Loading intel and netcdf modules..." -module load ncarenv/1.3 -module load intel/2022.1 -module load mpt/2.25 -module load ncarcompilers/0.5.0 -module load netcdf - -echo "Setting up NCEPLIBS" -module use /glade/work/epicufsrt/contrib/hpc-stack/intel2022.1/modulefiles/stack -module load hpc/1.2.0 -module load hpc-intel/2022.1 -module load hpc-mpt/2.25 -export bacio_ROOT=/glade/work/epicufsrt/contrib/hpc-stack/intel2022.1/intel-2022.1/bacio/2.4.1 -export sp_ROOT=/glade/work/epicufsrt/contrib/hpc-stack/intel2022.1/intel-2022.1/sp/2.3.3 -export w3emc_ROOT=/glade/work/epicufsrt/contrib/hpc-stack/intel2022.1/intel-2022.1/w3emc/2.9.2 - -echo "Setting CC/CXX/FC environment variables" -export CC=icc -export CXX=icpc -export FC=ifort - -echo "Loading cmake" -module load cmake/3.22.0 -export CMAKE_C_COMPILER=icc -export CMAKE_CXX_COMPILER=icpc -export CMAKE_Fortran_COMPILER=ifort -export CMAKE_Platform=cheyenne.intel - -echo "Setting up python environment for running and plotting." -module load conda/latest - -conda activate /glade/p/ral/jntp/GMTB/CCPP_SCM/conda/ccpp-scm - diff --git a/scm/etc/Desktop_setup_gfortran.csh b/scm/etc/Desktop_setup_gfortran.csh deleted file mode 100755 index d038405f4..000000000 --- a/scm/etc/Desktop_setup_gfortran.csh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/tcsh - -echo "Setting environment variables for CCPP-SCM on Desktop (MacOS) with gcc/gfortran" - -set called=($_) - -if ( "$called" != "") then ### called by source - set MYSCRIPT=`readlink -f -n $called[2]` -else ### called by direct execution of the script - set MYSCRIPT=`readlink -f -n '$0'` -endif -set MYDIR=`dirname $MYSCRIPT` -set MYDIR=`cd $MYDIR && pwd -P` - -setenv SCM_ROOT $MYDIR/../.. - -echo "Setting CC/CXX/FC environment variables" -setenv CC /opt/local/bin/gcc-mp-10 -setenv CXX /opt/local/bin/g++-mp-10 -setenv FC gfortran-mp-10 - -echo "Setting location of NETCDF" -setenv NETCDF /opt/local -setenv LDFLAGS "-I${NETCDF}/include -L${NETCDF}/lib -Wl,-rpath,${NETCDF}/lib" - -echo "Setting location of NCEPLIBS libraries" -setenv BACIO_LIB4 /Users/$USER/NCEPLIBS/lib/libbacio_v2.2.0_4.a -setenv SP_LIBd /Users/$USER/NCEPLIBS/lib/libsp_v2.1.0_d.a -setenv W3NCO_LIBd /Users/$USER/NCEPLIBS/lib/libw3nco_v2.1.0_d.a - -#check to see if CMake is installed locally -echo "Checking if CMake is installed" -cmake --version - -if ( $? != 0 ) then - echo "CMake not found; installing CMake" - pip install cmake -else - echo "CMake is installed" -endif - -#check to see if f90nml is installed locally -echo "Checking if f90nml python module is installed" -python -c "import f90nml" - -if ( $? != 0 ) then - echo "Not found; installing f90nml" - pip install --no-cache-dir f90nml==0.19 -else - echo "f90nml is installed" -endif diff --git a/scm/etc/Desktop_setup_gfortran.sh b/scm/etc/Desktop_setup_gfortran.sh deleted file mode 100755 index 37485a163..000000000 --- a/scm/etc/Desktop_setup_gfortran.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -echo "Setting environment variables for CCPP-SCM on Desktop (MacOS) with gcc/gfortran" - -if [[ $(uname -s) == Darwin ]]; then - MYDIR=$(cd "$(dirname "$(greadlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P) -else - MYDIR=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P) -fi - -export SCM_ROOT=$MYDIR/../.. - -echo "Setting CC/CXX/FC environment variables" -export CC=/opt/local/bin/gcc-mp-10 -export CXX=/opt/local/bin/g++-mp-10 -export FC=gfortran-mp-10 - -echo "Setting location of NETCDF" -export NETCDF=/opt/local -export LDFLAGS="-I${NETCDF}/include -L${NETCDF}/lib -Wl,-rpath,${NETCDF}/lib" - -echo "Setting location of NCEPLIBS libraries" -export BACIO_LIB4=/Users/$USER/NCEPLIBS/lib/libbacio_v2.2.0_4.a -export SP_LIBd=/Users/$USER/NCEPLIBS/lib/libsp_v2.1.0_d.a -export W3NCO_LIBd=/Users/$USER/NCEPLIBS/lib/libw3nco_v2.1.0_d.a - -#check to see if CMake is installed locally -echo "Checking if CMake is installed" -cmake --version - -if [ $? -ne 0 ]; then - echo "CMake not found; installing CMake" - pip install cmake -else - echo "CMake is installed" -fi - -#check to see if f90nml is installed locally -echo "Checking if f90nml python module is installed" -python -c "import f90nml" - -if [ $? -ne 0 ]; then - echo "Not found; installing f90nml" - pip install --no-cache-dir f90nml==0.19 -else - echo "f90nml is installed" -fi diff --git a/scm/etc/Hera_setup_intel.csh b/scm/etc/Hera_setup_intel.csh deleted file mode 100755 index 369f6e3af..000000000 --- a/scm/etc/Hera_setup_intel.csh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/tcsh - -echo "Setting environment variables for CCPP-SCM on Hera with icc/ifort" - -set called=($_) - -if ( "$called" != "") then ### called by source - set MYSCRIPT=`readlink -f -n $called[2]` -else ### called by direct execution of the script - set MYSCRIPT=`readlink -f -n '$0'` -endif -set MYDIR=`dirname $MYSCRIPT` -set MYDIR=`cd $MYDIR && pwd -P` - -setenv SCM_ROOT $MYDIR/../.. - -#load the modules in order to compile the CCPP SCM -echo "Loading intel and netcdf modules..." -module purge -module load intel/2022.1.2 -module load impi/2022.1.2 -module use /scratch1/NCEPDEV/nems/role.epic/hpc-stack/libs/intel-2022.1.2/modulefiles/stack -module load hpc/1.2.0 -module load hpc-intel/2022.1.2 -module load hpc-impi/2022.1.2 -module load netcdf - -echo "Setting up NCEPLIBS" -setenv bacio_ROOT /scratch1/NCEPDEV/nems/role.epic/hpc-stack/libs/intel-2022.1.2/intel-2022.1.2/bacio/2.4.1 -setenv sp_ROOT /scratch1/NCEPDEV/nems/role.epic/hpc-stack/libs/intel-2022.1.2/intel-2022.1.2/sp/2.3.3 -setenv w3emc_ROOT /scratch1/NCEPDEV/nems/role.epic/hpc-stack/libs/intel-2022.1.2/intel-2022.1.2/w3emc/2.9.2 - -echo "Setting CC/CXX/FC environment variables" -setenv CC icc -setenv CXX icpc -setenv FC ifort - -echo "Loading cmake" -module load cmake/3.20.1 -setenv CMAKE_C_COMPILER icc -setenv CMAKE_CXX_COMPILER icpc -setenv CMAKE_Fortran_COMPILER ifort -setenv CMAKE_Platform hera.intel - -echo "Loading the SCM python environment" -source /scratch1/BMC/gmtb/SCM_anaconda/etc/profile.d/conda.csh -conda activate pyccpp diff --git a/scm/etc/Hera_setup_intel.sh b/scm/etc/Hera_setup_intel.sh deleted file mode 100755 index 5d760260b..000000000 --- a/scm/etc/Hera_setup_intel.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -echo "Setting environment variables for CCPP-SCM on Hera with icc/ifort" - -MYDIR=$(cd "$(dirname "$(readlink -f -n "${BASH_SOURCE[0]}" )" )" && pwd -P) - -export SCM_ROOT=$MYDIR/../.. - -#load the modules in order to compile the CCPP SCM -echo "Loading intel and netcdf modules..." -module purge -module load intel/2022.1.2 -module load impi/2022.1.2 -module use /scratch1/NCEPDEV/nems/role.epic/hpc-stack/libs/intel-2022.1.2/modulefiles/stack -module load hpc/1.2.0 -module load hpc-intel/2022.1.2 -module load hpc-impi/2022.1.2 -module load netcdf - -echo "Setting up NCEPLIBS" -export bacio_ROOT=/scratch1/NCEPDEV/nems/role.epic/hpc-stack/libs/intel-2022.1.2/intel-2022.1.2/bacio/2.4.1 -export sp_ROOT=/scratch1/NCEPDEV/nems/role.epic/hpc-stack/libs/intel-2022.1.2/intel-2022.1.2/sp/2.3.3 -export w3emc_ROOT=/scratch1/NCEPDEV/nems/role.epic/hpc-stack/libs/intel-2022.1.2/intel-2022.1.2/w3emc/2.9.2 - -echo "Setting CC/CXX/FC environment variables" -export CC=icc -export CXX=icpc -export FC=ifort - -echo "Loading cmake" -module load cmake/3.20.1 -export CMAKE_C_COMPILER=icc -export CMAKE_CXX_COMPILER=icpc -export CMAKE_Fortran_COMPILER=ifort -export CMAKE_Platform=hera.intel - -echo "Loading the SCM python environment" -. "/scratch1/BMC/gmtb/SCM_anaconda/etc/profile.d/conda.sh" -conda activate pyccpp diff --git a/scm/etc/modules/hera_gnu.lua b/scm/etc/modules/hera_gnu.lua index 23867c4ac..7d45752fa 100644 --- a/scm/etc/modules/hera_gnu.lua +++ b/scm/etc/modules/hera_gnu.lua @@ -7,10 +7,10 @@ whatis([===[Loads libraries needed for building the CCPP SCM on Hera with GNU co prepend_path("MODULEPATH", "/scratch1/NCEPDEV/jcsda/jedipara/spack-stack/modulefiles") -load("cmake/3.20.1") +load("cmake/3.28.1") load("miniconda/3.9.12") -prepend_path("MODULEPATH", "/scratch1/NCEPDEV/nems/role.epic/spack-stack/spack-stack-1.5.1/envs/unified-env/install/modulefiles/Core") +prepend_path("MODULEPATH", "/scratch1/NCEPDEV/nems/role.epic/spack-stack/spack-stack-1.5.0/envs/unified-env-rocky8/install/modulefiles/Core") load("stack-gcc/9.2.0") load("stack-openmpi/4.1.5") diff --git a/scm/etc/modules/hera_intel.lua b/scm/etc/modules/hera_intel.lua index d84db665c..a97464934 100644 --- a/scm/etc/modules/hera_intel.lua +++ b/scm/etc/modules/hera_intel.lua @@ -6,10 +6,10 @@ the NOAA RDHPC machine Hera using Intel-2021.5.0 whatis([===[Loads libraries needed for building the CCPP SCM on Hera with Intel compilers ]===]) prepend_path("MODULEPATH", "/scratch1/NCEPDEV/jcsda/jedipara/spack-stack/modulefiles") -load("cmake/3.20.1") +load("cmake/3.28.1") load("miniconda/3.9.12") -prepend_path("MODULEPATH", "/scratch1/NCEPDEV/nems/role.epic/spack-stack/spack-stack-1.5.1/envs/unified-env/install/modulefiles/Core") +prepend_path("MODULEPATH", "/scratch1/NCEPDEV/nems/role.epic/spack-stack/spack-stack-1.5.0/envs/unified-env-rocky8/install/modulefiles/Core") load("stack-intel/2021.5.0") load("stack-intel-oneapi-mpi/2021.5.1") From 9da57a802aebe2c72c06b4facf6af5da0471d309 Mon Sep 17 00:00:00 2001 From: Tracy Date: Tue, 9 Apr 2024 21:00:38 +0000 Subject: [PATCH 02/13] update spack versio --- scm/etc/modules/hera_gnu.lua | 2 +- scm/etc/modules/hera_intel.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scm/etc/modules/hera_gnu.lua b/scm/etc/modules/hera_gnu.lua index 7d45752fa..0e28df2d0 100644 --- a/scm/etc/modules/hera_gnu.lua +++ b/scm/etc/modules/hera_gnu.lua @@ -10,7 +10,7 @@ prepend_path("MODULEPATH", "/scratch1/NCEPDEV/jcsda/jedipara/spack-stack/modulef load("cmake/3.28.1") load("miniconda/3.9.12") -prepend_path("MODULEPATH", "/scratch1/NCEPDEV/nems/role.epic/spack-stack/spack-stack-1.5.0/envs/unified-env-rocky8/install/modulefiles/Core") +prepend_path("MODULEPATH", "/scratch1/NCEPDEV/nems/role.epic/spack-stack/spack-stack-1.5.1/envs/unified-env-rocky8/install/modulefiles/Core") load("stack-gcc/9.2.0") load("stack-openmpi/4.1.5") diff --git a/scm/etc/modules/hera_intel.lua b/scm/etc/modules/hera_intel.lua index a97464934..6cdbf7d4c 100644 --- a/scm/etc/modules/hera_intel.lua +++ b/scm/etc/modules/hera_intel.lua @@ -9,7 +9,7 @@ prepend_path("MODULEPATH", "/scratch1/NCEPDEV/jcsda/jedipara/spack-stack/modulef load("cmake/3.28.1") load("miniconda/3.9.12") -prepend_path("MODULEPATH", "/scratch1/NCEPDEV/nems/role.epic/spack-stack/spack-stack-1.5.0/envs/unified-env-rocky8/install/modulefiles/Core") +prepend_path("MODULEPATH", "/scratch1/NCEPDEV/nems/role.epic/spack-stack/spack-stack-1.5.1/envs/unified-env-rocky8/install/modulefiles/Core") load("stack-intel/2021.5.0") load("stack-intel-oneapi-mpi/2021.5.1") From 936b89390029672e630c3b6fd8d10f837a1da4cd Mon Sep 17 00:00:00 2001 From: Tracy Date: Thu, 23 May 2024 15:45:33 +0000 Subject: [PATCH 03/13] add files for 2 MOSAiC cases from Amy Solomon --- scm/etc/case_config/MOSAiC-AMPS.nml | 17 + scm/etc/case_config/MOSAiC-SS.nml | 17 + .../MOSAiC_AMPS_forcing_file_generator.py | 554 ++++++++++++++++++ .../MOSAiC_SS_forcing_file_generator.py | 554 ++++++++++++++++++ scm/etc/scripts/plot_configs/MOSAiC-AMPS.ini | 63 ++ scm/etc/scripts/plot_configs/MOSAiC-SS.ini | 65 ++ scm/etc/scripts/scm_analysis.py | 4 +- scm/etc/scripts/scm_read_obs.py | 67 ++- 8 files changed, 1339 insertions(+), 2 deletions(-) create mode 100644 scm/etc/case_config/MOSAiC-AMPS.nml create mode 100644 scm/etc/case_config/MOSAiC-SS.nml create mode 100644 scm/etc/scripts/MOSAiC_AMPS_forcing_file_generator.py create mode 100644 scm/etc/scripts/MOSAiC_SS_forcing_file_generator.py create mode 100644 scm/etc/scripts/plot_configs/MOSAiC-AMPS.ini create mode 100644 scm/etc/scripts/plot_configs/MOSAiC-SS.ini diff --git a/scm/etc/case_config/MOSAiC-AMPS.nml b/scm/etc/case_config/MOSAiC-AMPS.nml new file mode 100644 index 000000000..ca3148a9f --- /dev/null +++ b/scm/etc/case_config/MOSAiC-AMPS.nml @@ -0,0 +1,17 @@ +$case_config +case_name = 'MOSAiC-AMPS', +runtime = 604800.0, +thermo_forcing_type = 2, +mom_forcing_type = 3, +relax_time = 3600.0, +sfc_flux_spec = .false., +sfc_type = 2, +sfc_roughness_length_cm = 0.02, +reference_profile_choice = 1, +year = 2019, +month = 10, +day = 31, +hour = 0, +column_area = 2.0E9, +lsm_ics = .true., +$end diff --git a/scm/etc/case_config/MOSAiC-SS.nml b/scm/etc/case_config/MOSAiC-SS.nml new file mode 100644 index 000000000..a2f5caa81 --- /dev/null +++ b/scm/etc/case_config/MOSAiC-SS.nml @@ -0,0 +1,17 @@ +$case_config +case_name = 'MOSAiC-SS', +runtime = 604800.0, +thermo_forcing_type = 2, +mom_forcing_type = 3, +relax_time = 3600.0, +sfc_flux_spec = .false., +sfc_type = 2, +sfc_roughness_length_cm = 0.02, +reference_profile_choice = 1, +year = 2020, +month = 3, +day = 2, +hour = 0, +column_area = 2.0E9, +lsm_ics = .true., +$end diff --git a/scm/etc/scripts/MOSAiC_AMPS_forcing_file_generator.py b/scm/etc/scripts/MOSAiC_AMPS_forcing_file_generator.py new file mode 100644 index 000000000..cfbb2d2ba --- /dev/null +++ b/scm/etc/scripts/MOSAiC_AMPS_forcing_file_generator.py @@ -0,0 +1,554 @@ +#!/usr/bin/env python + +from netCDF4 import Dataset +import numpy as np +import forcing_file_common as ffc +import scipy.interpolate +import scm_plotting_routines as spr + +#reload(ffc) + +#read in raw input file + +nc_fid = Dataset("../../data/raw_case_input/MOSAiC_31Oct20190Z_raw.nc", 'r') + +#ncdump to look at raw input file +#nc_attrs, nc_dims, nc_vars = ncdump(nc_fid, False) + +#netCDF how-to +#set attributes +#file_id.setncattr(file_id.variables['variable'].ncattr(), nc_fid.variables['time'].getncattr(ncattr)) +#get attributes +#file_id.variables['variable'].getncattr(index) + +#get raw input variables + +day = nc_fid.variables['day'][:] +hour = nc_fid.variables['hour'][:] +for t in range(day.size): + #find time index corresponding to October 29, 2019 at 0Z + if day[t] == 31 and hour[t] == 0: + start_t_index = t + break + +time = nc_fid.variables['time_offset'][:] #number of seconds since 00Z on 1/17/2006 (starts at 03Z) +#subtract the initial time_offset from all values to get elapsed time since the start of the simulation +time = time - time[start_t_index] +levels = nc_fid.variables['levels'][:] #pressure levels in mb +#convert levels to Pa +levels = 100.0*levels +ice_thickness = np.zeros((2),dtype=float) +#height = nc_fid.variables['alt'][:] +lat = nc_fid.variables['lat'][:] #degrees north +#convert latitutde to degrees north +lon = nc_fid.variables['lon'][:] #degrees east +#use upstream T +T_abs = nc_fid.variables['Tu'][:] #absolute temperature (time, lev) +T_abs = np.swapaxes(T_abs, 0, 1) +thetail = nc_fid.variables['thetail'][:] #theta_il (time, lev) +thetail = np.swapaxes(thetail, 0, 1) +#use unpstream theta instead of thetail +thetailu = nc_fid.variables['thetailu'][:] #theta (time, lev) +thetailu = np.swapaxes(thetailu, 0, 1) +#calculate theta_il from absolute temperature (assuming no condensate) +#thetal = np.zeros((levels.size,time.size),dtype=float) +#for t in range(time.size): +# thetal[:,t] = (ffc.p0/levels)**(ffc.R_dry/ffc.c_p)*T_abs[:,t] +qv = nc_fid.variables['qu'][:] #water vapor mixing ratio in kg/kg (time, lev) +qv = np.swapaxes(qv, 0, 1) +qt = np.zeros((levels.size,time.size),dtype=float) +qt_mr = nc_fid.variables['qt'][:] #water vapor mixing ratio in kg/kg (time, lev) +qt_mr = np.swapaxes(qt_mr, 0, 1) #swap the time and levels axis +qt = qt_mr/(1.0 + qt_mr) #convert to specific humidity from mixing ratio +qtu = np.zeros((levels.size,time.size),dtype=float) +#use upstream qv instead of qt +qtu_mr = nc_fid.variables['qtu'][:] #water vapor mixing ratio in kg/kg (time, lev) +qtu_mr = np.swapaxes(qtu_mr, 0, 1) #swap the time and levels axis +qtu = qtu_mr/(1.0 + qtu_mr) #convert to specific humidity from mixing ratio + +#ql and tke are not specified; set to zero +#ql = np.zeros((levels.size,time.size),dtype=float) +#qi = np.zeros((levels.size,time.size),dtype=float) +ql = nc_fid.variables['ql'][:] #ql (time, lev) +ql = np.swapaxes(ql, 0, 1) +qi = nc_fid.variables['qi'][:] #ql (time, lev) +qi = np.swapaxes(qi, 0, 1) +tke = np.zeros((levels.size,time.size),dtype=float) +# ozone_mmr = nc_fid.variables['o3mmr'][:] +u_wind = nc_fid.variables['u'][:] +u_wind = np.swapaxes(u_wind, 0, 1) #swap the time and levels axis +v_wind = nc_fid.variables['v'][:] +v_wind = np.swapaxes(v_wind, 0, 1) #swap the time and levels axis + +#w_sub = np.zeros((levels.size,time.size),dtype=float) +omega = nc_fid.variables['omega'][:] #vertical pressure velocity in Pa/s +omega = np.swapaxes(omega, 0, 1) #swap the time and levels axis +w_sub = nc_fid.variables['w'][:] #vertical velocity in m/s +w_sub = np.swapaxes(w_sub, 0, 1) #swap the time and levels axis +#convert to w +#for t in range(time.size): +# w_sub[:,t] = ffc.omega_to_w(omega[:,t],levels,T_abs[:,t]) + +T_surf = nc_fid.variables['T_skin'][:] +#T_surf = T_surf + 273.15 #convert to K +#T_surf = (29 + 273.15)*np.ones((time.size),dtype=float) #forcing instructions specify time-invariant 29 deg C. +p_surf = nc_fid.variables['p_srf'][:] #Pa +#p_surf = p_surf*100.0 #convert to Pa + +#h_advec_thil = np.zeros((levels.size,time.size),dtype=float) +h_advec_thil = nc_fid.variables['h_advec_thetail'][:] #K/s +h_advec_thil = np.swapaxes(h_advec_thil, 0, 1) #swap the time and levels axis +#for t in range(time.size): +# h_advec_thil[:,t] = (ffc.p0/levels)**(ffc.R_dry/ffc.c_p)*h_advec_T[:,t] #convert to potential temperature + +#v_advec_thil = np.zeros((levels.size,time.size),dtype=float) +v_advec_thil = nc_fid.variables['v_advec_thetail'][:] #K/s +v_advec_thil = np.swapaxes(v_advec_thil, 0, 1) #swap the time and levels axis +#for t in range(time.size): +# v_advec_thil[:,t] = (ffc.p0/levels)**(ffc.R_dry/ffc.c_p)*v_advec_T[:,t] #convert to potential temperature + +dT_dt = np.zeros((levels.size,time.size),dtype=float) + +# h_advec_T = h_advec_T*86400.0 +# v_advec_T = v_advec_T*86400.0 +# dT_dt = dT_dt*86400.0 +# spr.contour_plot_firl(time, levels, h_advec_T, np.min(h_advec_T), np.max(h_advec_T), 'h advec T', 'time', 'pressure', 'h_advec_T.eps', y_inverted = True) +# spr.contour_plot_firl(time, levels, v_advec_T, np.min(v_advec_T), np.max(v_advec_T), 'v advec T', 'time', 'pressure', 'v_advec_T.eps', y_inverted = True) +# spr.contour_plot_firl(time, levels, dT_dt, np.min(dT_dt), np.max(dT_dt), 'total T tend', 'time', 'pressure', 'dT_dt.eps', y_inverted = True) + +#h_advec_qt = np.zeros((levels.size,time.size),dtype=float) +h_advec_qt = nc_fid.variables['h_advec_qt'][:] #kg/kg/s +h_advec_qt = np.swapaxes(h_advec_qt, 0, 1) #swap the time and levels axis +h_advec_qt = h_advec_qt/(1.0 + qt_mr)**2 #convert to specific humidity + +h_advec_qi = np.zeros((levels.size,time.size),dtype=float) +h_advec_ql = np.zeros((levels.size,time.size),dtype=float) + +#v_advec_qt = np.zeros((levels.size,time.size),dtype=float) +v_advec_qt = nc_fid.variables['v_advec_qt'][:] #kg/kg/s +v_advec_qt = np.swapaxes(v_advec_qt, 0, 1) #swap the time and levels axis +v_advec_qt = v_advec_qt/(1.0 + qt_mr)**2 #convert to specific humidity + +dq_dt = np.zeros((levels.size,time.size),dtype=float) +#dq_dt = nc_fid.variables['dqdt'][:] +#dq_dt = np.swapaxes(dq_dt, 0, 1)*1.0E-3/3600.0 #swap the time and levels axis, convert to K/s + +#h_advec_qt = h_advec_qt*86400.0 +#v_advec_qt = v_advec_qt*86400.0 +#dq_dt = dq_dt*86400.0 +#spr.contour_plot_firl(time, levels, h_advec_qt, np.min(h_advec_qt), np.max(h_advec_qt), 'h advec q', 'time', 'pressure', 'h_advec_q.eps', y_inverted = True) +#spr.contour_plot_firl(time, levels, v_advec_qt, np.min(v_advec_qt), np.max(v_advec_qt), 'v advec q', 'time', 'pressure', 'v_advec_q.eps', y_inverted = True) +#spr.contour_plot_firl(time, levels, dq_dt, np.min(dq_dt), np.max(dq_dt), 'total q tend', 'time', 'pressure', 'dq_dt.eps', y_inverted = True) + +#phi_sfc = nc_fid.variables['phis'][:] +#z_sfc = nc_fid.variables['alt'][:] +height = nc_fid.variables['height'][:] +#height = ffc.get_height_from_pres(T_abs[:,0],levels,z_sfc) + +#the following variables are not in this forcing file, but are included in other cases +#rad_heating = nc_fid.variables['dT_dt_rad'][:] #K/s +#rad_heating = np.swapaxes(rad_heating, 0, 1) #swap the time and levels axis +rad_heating = np.zeros((levels.size,time.size),dtype=float) +u_g = np.zeros((levels.size,time.size),dtype=float) +v_g = np.zeros((levels.size,time.size),dtype=float) + +ozone = np.zeros((levels.size,time.size),dtype=float) +ozone = ozone + 2.e-8 + +tiice = np.zeros((ice_thickness.size),dtype=float) +##tiice[0] = T_surf[start_t_index] +tiice[0] = 271.35 + .75*(T_surf[start_t_index] - 271.35) +tiice[1] = 271.35 + .25*(T_surf[start_t_index] - 271.35) +stc = tiice[0] +smc = 0.33 +slc = 0.33 +hice = 0.3 +slmsk = 2.0 +tsfco = T_surf[start_t_index] +weasd = 200.0 +fice = 1.0 +tisfc = tsfco +snwdph = 2.e-4 +tg3 = 271.35 +zorl = 15.0 +alvsf = 0.23 +alnsf = 0.23 +alvwf = 0.23 +alnwf = 0.23 +facsf = 0.5055632 +facwf = 0.4944368 +vegfrac = 0.0 +canopy = 0.0 +vegtyp = 10 +soiltyp = 12 +uustar = 0.3828793 +shdmin = 0.01 +shdmax = 0.8 +slopetyp = 1 +snoalb = 0.7287961 + +# Open ozone file +#f = open('../../data/raw_case_input/twpice_CRM_ozone.txt', 'r') + +# Read and ignore header lines +#header1 = f.readline() + +#oz_pres = [] +#oz_data = [] +# Loop over lines and extract variables of interest +#for line in f: +# line = line.strip() +# columns = line.split() +# oz_pres.append(float(columns[1])) +# oz_data.append(float(columns[2])) + +#f.close() + +#oz_pres = 100.0*np.array(oz_pres) +#oz_data = np.array(oz_data) +#oz_f = scipy.interpolate.interp1d(oz_pres, oz_data) +#ozone_ppb = oz_f(levels[1:].tolist()) +#ozone_ppb = np.insert(ozone_ppb, 0, oz_data[0]) +#ozone_mmr = ozone_ppb*1.0E-9 + +# +#open processed input file for writing + +writefile_fid = Dataset('../../data/processed_case_input/MOSAiC.nc', 'w', format='NETCDF4') +writefile_fid.description = "CCPP SCM forcing file for MOSAiC case" + +#create groups for scalars, intitialization, and forcing + +writefile_scalar_grp = writefile_fid.createGroup("scalars") +writefile_initial_grp = writefile_fid.createGroup("initial") +writefile_forcing_grp = writefile_fid.createGroup("forcing") + +#create dimensions and write them out + +writefile_time_dim = writefile_fid.createDimension('time', None) +writefile_time_var = writefile_fid.createVariable('time', 'f4', ('time',)) +writefile_time_var[:] = time[start_t_index:] +writefile_time_var.units = 's' +writefile_time_var.description = 'elapsed time since the beginning of the simulation' + +writefile_levels_dim = writefile_fid.createDimension('levels', None) +writefile_levels_var = writefile_fid.createVariable('levels', 'f4', ('levels',)) +writefile_levels_var[:] = levels +writefile_levels_var.units = 'Pa' +writefile_levels_var.description = 'pressure levels' + +writefile_ice_thickness_dim = writefile_fid.createDimension('ice_thickness', None) +writefile_ice_thickness_var = writefile_fid.createVariable('ice_thickness', 'f4', ('ice_thickness',)) +writefile_ice_thickness_var[:] = ice_thickness +writefile_ice_thickness_var.units = 'm' +writefile_ice_thickness_var.description = 'depth of ice layers' + +#create variables and write them out + +#scalar group + +writefile_lat_var = writefile_scalar_grp.createVariable('lat', 'f4') +writefile_lat_var[:] = lat +writefile_lat_var.units = 'degrees N' +writefile_lat_var.description = 'latitude of column' + +writefile_lon_var = writefile_scalar_grp.createVariable('lon', 'f4') +writefile_lon_var[:] = lon +writefile_lon_var.units = 'degrees E' +writefile_lon_var.description = 'longitude of column' + +writefile_hice_var = writefile_scalar_grp.createVariable('hice', 'f4') +writefile_hice_var[:] = hice +writefile_hice_var.units = 'm' +writefile_hice_var.description = 'sea ice thickness' + +writefile_slmsk_var = writefile_scalar_grp.createVariable('slmsk', 'f4') +writefile_slmsk_var[:] = slmsk +writefile_slmsk_var.units = '' +writefile_slmsk_var.description = 'land-sea-ice mask' + +writefile_tsfco_var = writefile_scalar_grp.createVariable('tsfco', 'f4') +writefile_tsfco_var[:] = tsfco +writefile_tsfco_var.units = 'm' +writefile_tsfco_var.description = 'sea ice surface skin temperature' + +writefile_weasd_var = writefile_scalar_grp.createVariable('weasd', 'f4') +writefile_weasd_var[:] = weasd +writefile_weasd_var.units = 'mm' +writefile_weasd_var.description = 'water equivalent accumulated snow depth' + +writefile_fice_var = writefile_scalar_grp.createVariable('fice', 'f4') +writefile_fice_var[:] = fice +writefile_fice_var.units = '1' +writefile_fice_var.description = 'ice fraction' + +writefile_tisfc_var = writefile_scalar_grp.createVariable('tisfc', 'f4') +writefile_tisfc_var[:] = tisfc +writefile_tisfc_var.units = 'K' +writefile_tisfc_var.description = 'ice surface temperature' + +writefile_snwdph_var = writefile_scalar_grp.createVariable('snwdph', 'f4') +writefile_snwdph_var[:] = snwdph +writefile_snwdph_var.units = 'mm' +writefile_snwdph_var.description = 'water equivalent snow depth' + +writefile_tg3_var = writefile_scalar_grp.createVariable('tg3', 'f4') +writefile_tg3_var[:] = tg3 +writefile_tg3_var.units = 'K' +writefile_tg3_var.description = 'deep soil temperature' + +writefile_zorl_var = writefile_scalar_grp.createVariable('zorl', 'f4') +writefile_zorl_var[:] = zorl +writefile_zorl_var.units = 'cm' +writefile_zorl_var.description = 'composite surface roughness length' + +writefile_alvsf_var = writefile_scalar_grp.createVariable('alvsf', 'f4') +writefile_alvsf_var[:] = alvsf +writefile_alvsf_var.units = '' +writefile_alvsf_var.description = '60 degree vis albedo with strong cosz dependency' + +writefile_alnsf_var = writefile_scalar_grp.createVariable('alnsf', 'f4') +writefile_alnsf_var[:] = alnsf +writefile_alnsf_var.units = '' +writefile_alnsf_var.description = '60 degree nir albedo with strong cosz dependency' + +writefile_alvwf_var = writefile_scalar_grp.createVariable('alvwf', 'f4') +writefile_alvwf_var[:] = alvwf +writefile_alvwf_var.units = '' +writefile_alvwf_var.description = '60 degree vis albedo with weak cosz dependency' + +writefile_alnwf_var = writefile_scalar_grp.createVariable('alnwf', 'f4') +writefile_alnwf_var[:] = alnwf +writefile_alnwf_var.units = '' +writefile_alnwf_var.description = '60 degree nir albedo with weak cosz dependency' + +writefile_facsf_var = writefile_scalar_grp.createVariable('facsf', 'f4') +writefile_facsf_var[:] = facsf +writefile_facsf_var.units = '' +writefile_facsf_var.description = 'fractional coverage with strong cosz dependency' + +writefile_facwf_var = writefile_scalar_grp.createVariable('facwf', 'f4') +writefile_facwf_var[:] = facwf +writefile_facwf_var.units = '' +writefile_facwf_var.description = 'fractional coverage with weak cosz dependency' + +writefile_vegfrac_var = writefile_scalar_grp.createVariable('vegfrac', 'f4') +writefile_vegfrac_var[:] = vegfrac +writefile_vegfrac_var.units = '1' +writefile_vegfrac_var.description = 'vegetation fraction' + +writefile_canopy_var = writefile_scalar_grp.createVariable('canopy', 'f4') +writefile_canopy_var[:] = canopy +writefile_canopy_var.units = 'kg m-2' +writefile_canopy_var.description = 'amount of water stored in camopy' + +writefile_vegtyp_var = writefile_scalar_grp.createVariable('vegtyp', 'f4') +writefile_vegtyp_var[:] = vegtyp +writefile_vegtyp_var.units = '' +writefile_vegtyp_var.description = 'vegetation type 1-12' + +writefile_soiltyp_var = writefile_scalar_grp.createVariable('soiltyp', 'f4') +writefile_soiltyp_var[:] = soiltyp +writefile_soiltyp_var.units = '' +writefile_soiltyp_var.description = 'soil type 1-12' + +writefile_uustar_var = writefile_scalar_grp.createVariable('uustar', 'f4') +writefile_uustar_var[:] = uustar +writefile_uustar_var.units = 'm s-1' +writefile_uustar_var.description = 'friction velocity' + +writefile_shdmin_var = writefile_scalar_grp.createVariable('shdmin', 'f4') +writefile_shdmin_var[:] = shdmin +writefile_shdmin_var.units = '1' +writefile_shdmin_var.description = 'minimum vegetation fraction' + +writefile_shdmax_var = writefile_scalar_grp.createVariable('shdmax', 'f4') +writefile_shdmax_var[:] = shdmax +writefile_shdmax_var.units = '1' +writefile_shdmax_var.description = 'maximum vegetation fraction' + +writefile_slopetyp_var = writefile_scalar_grp.createVariable('slopetyp', 'f4') +writefile_slopetyp_var[:] = slopetyp +writefile_slopetyp_var.units = '' +writefile_slopetyp_var.description = 'slope type 1-9' + +writefile_snoalb_var = writefile_scalar_grp.createVariable('snoalb', 'f4') +writefile_snoalb_var[:] = snoalb +writefile_snoalb_var.units = '1' +writefile_snoalb_var.description = 'maximum snow albedo' + +#initial group + +writefile_height_var = writefile_initial_grp.createVariable('height', 'f4', ('levels',)) +writefile_height_var[:] = height +writefile_height_var.units = 'm' +writefile_height_var.description = 'physical height at pressure levels' + +writefile_tiice_var = writefile_initial_grp.createVariable('tiice', 'f4', ('ice_thickness',)) +writefile_tiice_var[:] = tiice +writefile_tiice_var.units = 'K' +writefile_tiice_var.description = 'initial profile of sea ice internal temperature' + +writefile_stc_var = writefile_initial_grp.createVariable('stc', 'f4') +writefile_stc_var[:] = stc +writefile_stc_var.units = 'K' +writefile_stc_var.description = 'initial profile of sea ice internal temperature' + +writefile_smc_var = writefile_initial_grp.createVariable('smc', 'f4') +writefile_smc_var[:] = smc +writefile_smc_var.units = 'm3 m-3' +writefile_smc_var.description = 'initial profile of soil moisture' + +writefile_slc_var = writefile_initial_grp.createVariable('slc', 'f4') +writefile_slc_var[:] = slc +writefile_slc_var.units = 'm3 m-3' +writefile_slc_var.description = 'initial profile of soil liquid water' + +writefile_thetail_var = writefile_initial_grp.createVariable('thetail', 'f4', ('levels',)) +writefile_thetail_var[:] = thetail[:,start_t_index] +writefile_thetail_var.units = 'K' +writefile_thetail_var.description = 'initial profile of ice-liquid water potential temperature' + +writefile_qt_var = writefile_initial_grp.createVariable('qt', 'f4', ('levels',)) +writefile_qt_var[:] = qt[:,start_t_index] +writefile_qt_var.units = 'kg kg^-1' +writefile_qt_var.description = 'initial profile of total water specific humidity' + +writefile_ql_var = writefile_initial_grp.createVariable('ql', 'f4', ('levels',)) +writefile_ql_var[:] = ql[:,start_t_index] +writefile_ql_var.units = 'kg kg^-1' +writefile_ql_var.description = 'initial profile of liquid water specific humidity' + +writefile_qi_var = writefile_initial_grp.createVariable('qi', 'f4', ('levels',)) +writefile_qi_var[:] = qi[:,start_t_index] +writefile_qi_var.units = 'kg kg^-1' +writefile_qi_var.description = 'initial profile of ice water specific humidity' + +writefile_u_var = writefile_initial_grp.createVariable('u', 'f4', ('levels',)) +writefile_u_var[:] = u_wind[:,start_t_index] +writefile_u_var.units = 'm s^-1' +writefile_u_var.description = 'initial profile of E-W horizontal wind' + +writefile_v_var = writefile_initial_grp.createVariable('v', 'f4', ('levels',)) +writefile_v_var[:] = v_wind[:,start_t_index] +writefile_v_var.units = 'm s^-1' +writefile_v_var.description = 'initial profile of N-S horizontal wind' + +writefile_tke_var = writefile_initial_grp.createVariable('tke', 'f4', ('levels',)) +writefile_tke_var[:] = tke[:,start_t_index] +writefile_tke_var.units = 'm^2 s^-2' +writefile_tke_var.description = 'initial profile of turbulence kinetic energy' + +writefile_ozone_var = writefile_initial_grp.createVariable('ozone', 'f4', ('levels',)) +writefile_ozone_var[:] = ozone[:,start_t_index] +writefile_ozone_var.units = 'kg kg^-1' +writefile_ozone_var.description = 'initial profile of ozone mass mixing ratio' + +#forcing group + +writefile_p_surf_var = writefile_forcing_grp.createVariable('p_surf', 'f4', ('time',)) +writefile_p_surf_var[:] = p_surf[start_t_index:] +writefile_p_surf_var.units = 'Pa' +writefile_p_surf_var.description = 'surface pressure' + +writefile_T_surf_var = writefile_forcing_grp.createVariable('T_surf', 'f4', ('time',)) +writefile_T_surf_var[:] = T_surf[start_t_index:] +writefile_T_surf_var.units = 'K' +writefile_T_surf_var.description = 'surface absolute temperature' + +writefile_w_ls_var = writefile_forcing_grp.createVariable('w_ls', 'f4', ('levels','time',)) +writefile_w_ls_var[:] = w_sub[:,start_t_index:] +writefile_w_ls_var.units = 'm s^-1' +writefile_w_ls_var.description = 'large scale vertical velocity' + +writefile_omega_var = writefile_forcing_grp.createVariable('omega', 'f4', ('levels','time',)) +writefile_omega_var[:] = omega[:,start_t_index:] +writefile_omega_var.units = 'Pa s^-1' +writefile_omega_var.description = 'large scale pressure vertical velocity' + +writefile_u_g_var = writefile_forcing_grp.createVariable('u_g', 'f4', ('levels','time',)) +writefile_u_g_var[:] = u_g[:,start_t_index:] +writefile_u_g_var.units = 'm s^-1' +writefile_u_g_var.description = 'large scale geostrophic E-W wind' + +writefile_v_g_var = writefile_forcing_grp.createVariable('v_g', 'f4', ('levels','time',)) +writefile_v_g_var[:] = v_g[:,start_t_index:] +writefile_v_g_var.units = 'm s^-1' +writefile_v_g_var.description = 'large scale geostrophic N-S wind' + +writefile_u_nudge_var = writefile_forcing_grp.createVariable('u_nudge', 'f4', ('levels','time',)) +writefile_u_nudge_var[:] = u_wind[:,start_t_index:] +writefile_u_nudge_var.units = 'm s^-1' +writefile_u_nudge_var.description = 'E-W wind to nudge toward' + +writefile_v_nudge_var = writefile_forcing_grp.createVariable('v_nudge', 'f4', ('levels','time',)) +writefile_v_nudge_var[:] = v_wind[:,start_t_index:] +writefile_v_nudge_var.units = 'm s^-1' +writefile_v_nudge_var.description = 'N-S wind to nudge toward' + +writefile_T_nudge_var = writefile_forcing_grp.createVariable('T_nudge', 'f4', ('levels','time',)) +writefile_T_nudge_var[:] = T_abs[:,start_t_index:] +writefile_T_nudge_var.units = 'K' +writefile_T_nudge_var.description = 'absolute temperature to nudge toward' + +writefile_thil_nudge_var = writefile_forcing_grp.createVariable('thil_nudge', 'f4', ('levels','time',)) +writefile_thil_nudge_var[:] = thetailu[:,start_t_index:] +writefile_thil_nudge_var.units = 'K' +writefile_thil_nudge_var.description = 'potential temperature to nudge toward' + +writefile_qt_nudge_var = writefile_forcing_grp.createVariable('qt_nudge', 'f4', ('levels','time',)) +writefile_qt_nudge_var[:] = qtu[:,start_t_index:] +writefile_qt_nudge_var.units = 'kg kg^-1' +writefile_qt_nudge_var.description = 'q_t to nudge toward' + +writefile_qi_nudge_var = writefile_forcing_grp.createVariable('qi_nudge', 'f4', ('levels','time',)) +writefile_qi_nudge_var[:] = qi[:,start_t_index:] +writefile_qi_nudge_var.units = 'kg kg^-1' +writefile_qi_nudge_var.description = 'q_i to nudge toward' + +writefile_ql_nudge_var = writefile_forcing_grp.createVariable('ql_nudge', 'f4', ('levels','time',)) +writefile_ql_nudge_var[:] = ql[:,start_t_index:] +writefile_ql_nudge_var.units = 'kg kg^-1' +writefile_ql_nudge_var.description = 'q_l to nudge toward' + +writefile_rad_heating_var = writefile_forcing_grp.createVariable('dT_dt_rad', 'f4', ('levels','time',)) +writefile_rad_heating_var[:] = rad_heating[:,start_t_index:] +writefile_rad_heating_var.units = 'K s^-1' +writefile_rad_heating_var.description = 'prescribed radiative heating rate' + +writefile_h_advec_thil_var = writefile_forcing_grp.createVariable('h_advec_thetail', 'f4', ('levels','time',)) +writefile_h_advec_thil_var[:] = h_advec_thil[:,start_t_index:] +writefile_h_advec_thil_var.units = 'K s^-1' +writefile_h_advec_thil_var.description = 'prescribed theta_il tendency due to horizontal advection' + +writefile_v_advec_thil_var = writefile_forcing_grp.createVariable('v_advec_thetail', 'f4', ('levels','time',)) +writefile_v_advec_thil_var[:] = v_advec_thil[:,start_t_index:] +writefile_v_advec_thil_var.units = 'K s^-1' +writefile_v_advec_thil_var.description = 'prescribed theta_il tendency due to vertical advection' + +writefile_h_advec_qt_var = writefile_forcing_grp.createVariable('h_advec_qt', 'f4', ('levels','time',)) +writefile_h_advec_qt_var[:] = h_advec_qt[:,start_t_index:] +writefile_h_advec_qt_var.units = 'kg kg^-1 s^-1' +writefile_h_advec_qt_var.description = 'prescribed q_t tendency due to horizontal advection' + +writefile_h_advec_qi_var = writefile_forcing_grp.createVariable('h_advec_qi', 'f4', ('levels','time',)) +writefile_h_advec_qi_var[:] = h_advec_qi[:,start_t_index:] +writefile_h_advec_qi_var.units = 'kg kg^-1 s^-1' +writefile_h_advec_qi_var.description = 'prescribed q_i tendency due to horizontal advection' + +writefile_h_advec_ql_var = writefile_forcing_grp.createVariable('h_advec_ql', 'f4', ('levels','time',)) +writefile_h_advec_ql_var[:] = h_advec_ql[:,start_t_index:] +writefile_h_advec_ql_var.units = 'kg kg^-1 s^-1' +writefile_h_advec_ql_var.description = 'prescribed q_l tendency due to horizontal advection' + +writefile_v_advec_qt_var = writefile_forcing_grp.createVariable('v_advec_qt', 'f4', ('levels','time',)) +writefile_v_advec_qt_var[:] = v_advec_qt[:,start_t_index:] +writefile_v_advec_qt_var.units = 'kg kg^-1 s^-1' +writefile_v_advec_qt_var.description = 'prescribed q_t tendency due to vertical advection' + + +#close processed input file +writefile_fid.close() + +#close raw input file +nc_fid.close() diff --git a/scm/etc/scripts/MOSAiC_SS_forcing_file_generator.py b/scm/etc/scripts/MOSAiC_SS_forcing_file_generator.py new file mode 100644 index 000000000..918eea33e --- /dev/null +++ b/scm/etc/scripts/MOSAiC_SS_forcing_file_generator.py @@ -0,0 +1,554 @@ +#!/usr/bin/env python + +from netCDF4 import Dataset +import numpy as np +import forcing_file_common as ffc +import scipy.interpolate +import scm_plotting_routines as spr + +#reload(ffc) + +#read in raw input file + +nc_fid = Dataset("../../data/raw_case_input/MOSAiC_2Mar20200Z_raw.nc", 'r') + +#ncdump to look at raw input file +#nc_attrs, nc_dims, nc_vars = ncdump(nc_fid, False) + +#netCDF how-to +#set attributes +#file_id.setncattr(file_id.variables['variable'].ncattr(), nc_fid.variables['time'].getncattr(ncattr)) +#get attributes +#file_id.variables['variable'].getncattr(index) + +#get raw input variables + +day = nc_fid.variables['day'][:] +hour = nc_fid.variables['hour'][:] +for t in range(day.size): + #find time index corresponding to October 29, 2019 at 0Z + if day[t] == 2 and hour[t] == 0: + start_t_index = t + break + +time = nc_fid.variables['time_offset'][:] #number of seconds since 00Z on 1/17/2006 (starts at 03Z) +#subtract the initial time_offset from all values to get elapsed time since the start of the simulation +time = time - time[start_t_index] +levels = nc_fid.variables['levels'][:] #pressure levels in mb +#convert levels to Pa +levels = 100.0*levels +ice_thickness = np.zeros((2),dtype=float) +#height = nc_fid.variables['alt'][:] +lat = nc_fid.variables['lat'][:] #degrees north +#convert latitutde to degrees north +lon = nc_fid.variables['lon'][:] #degrees east +#use upstream T +T_abs = nc_fid.variables['Tu'][:] #absolute temperature (time, lev) +T_abs = np.swapaxes(T_abs, 0, 1) +thetailu = nc_fid.variables['thetailu'][:] #theta_il (time, lev) +thetailu = np.swapaxes(thetailu, 0, 1) +#use unpstream theta instead of thetail +thetail = nc_fid.variables['thetail'][:] #theta (time, lev) +thetail = np.swapaxes(thetail, 0, 1) +#calculate theta_il from absolute temperature (assuming no condensate) +#thetal = np.zeros((levels.size,time.size),dtype=float) +#for t in range(time.size): +# thetal[:,t] = (ffc.p0/levels)**(ffc.R_dry/ffc.c_p)*T_abs[:,t] +qv = nc_fid.variables['qu'][:] #water vapor mixing ratio in kg/kg (time, lev) +qv = np.swapaxes(qv, 0, 1) +qt = np.zeros((levels.size,time.size),dtype=float) +qt_mr = nc_fid.variables['qt'][:] #water vapor mixing ratio in kg/kg (time, lev) +qt_mr = np.swapaxes(qt_mr, 0, 1) #swap the time and levels axis +qt = qt_mr/(1.0 + qt_mr) #convert to specific humidity from mixing ratio +qtu = np.zeros((levels.size,time.size),dtype=float) +#use upstream qv instead of qt +qtu_mr = nc_fid.variables['qtu'][:] #water vapor mixing ratio in kg/kg (time, lev) +qtu_mr = np.swapaxes(qtu_mr, 0, 1) #swap the time and levels axis +qtu = qtu_mr/(1.0 + qtu_mr) #convert to specific humidity from mixing ratio + +#ql and tke are not specified; set to zero +#ql = np.zeros((levels.size,time.size),dtype=float) +#qi = np.zeros((levels.size,time.size),dtype=float) +ql = nc_fid.variables['ql'][:] #ql (time, lev) +ql = np.swapaxes(ql, 0, 1) +qi = nc_fid.variables['qi'][:] #ql (time, lev) +qi = np.swapaxes(qi, 0, 1) +tke = np.zeros((levels.size,time.size),dtype=float) +# ozone_mmr = nc_fid.variables['o3mmr'][:] +u_wind = nc_fid.variables['u'][:] +u_wind = np.swapaxes(u_wind, 0, 1) #swap the time and levels axis +v_wind = nc_fid.variables['v'][:] +v_wind = np.swapaxes(v_wind, 0, 1) #swap the time and levels axis + +#w_sub = np.zeros((levels.size,time.size),dtype=float) +omega = nc_fid.variables['omega'][:] #vertical pressure velocity in Pa/s +omega = np.swapaxes(omega, 0, 1) #swap the time and levels axis +w_sub = nc_fid.variables['w'][:] #vertical velocity in m/s +w_sub = np.swapaxes(w_sub, 0, 1) #swap the time and levels axis +#convert to w +#for t in range(time.size): +# w_sub[:,t] = ffc.omega_to_w(omega[:,t],levels,T_abs[:,t]) + +T_surf = nc_fid.variables['T_skin'][:] +#T_surf = T_surf + 273.15 #convert to K +#T_surf = (29 + 273.15)*np.ones((time.size),dtype=float) #forcing instructions specify time-invariant 29 deg C. +p_surf = nc_fid.variables['p_srf'][:] #Pa +#p_surf = p_surf*100.0 #convert to Pa + +#h_advec_thil = np.zeros((levels.size,time.size),dtype=float) +h_advec_thil = nc_fid.variables['h_advec_thetail'][:] #K/s +h_advec_thil = np.swapaxes(h_advec_thil, 0, 1) #swap the time and levels axis +#for t in range(time.size): +# h_advec_thil[:,t] = (ffc.p0/levels)**(ffc.R_dry/ffc.c_p)*h_advec_T[:,t] #convert to potential temperature + +#v_advec_thil = np.zeros((levels.size,time.size),dtype=float) +v_advec_thil = nc_fid.variables['v_advec_thetail'][:] #K/s +v_advec_thil = np.swapaxes(v_advec_thil, 0, 1) #swap the time and levels axis +#for t in range(time.size): +# v_advec_thil[:,t] = (ffc.p0/levels)**(ffc.R_dry/ffc.c_p)*v_advec_T[:,t] #convert to potential temperature + +dT_dt = np.zeros((levels.size,time.size),dtype=float) + +# h_advec_T = h_advec_T*86400.0 +# v_advec_T = v_advec_T*86400.0 +# dT_dt = dT_dt*86400.0 +# spr.contour_plot_firl(time, levels, h_advec_T, np.min(h_advec_T), np.max(h_advec_T), 'h advec T', 'time', 'pressure', 'h_advec_T.eps', y_inverted = True) +# spr.contour_plot_firl(time, levels, v_advec_T, np.min(v_advec_T), np.max(v_advec_T), 'v advec T', 'time', 'pressure', 'v_advec_T.eps', y_inverted = True) +# spr.contour_plot_firl(time, levels, dT_dt, np.min(dT_dt), np.max(dT_dt), 'total T tend', 'time', 'pressure', 'dT_dt.eps', y_inverted = True) + +#h_advec_qt = np.zeros((levels.size,time.size),dtype=float) +h_advec_qt = nc_fid.variables['h_advec_qt'][:] #kg/kg/s +h_advec_qt = np.swapaxes(h_advec_qt, 0, 1) #swap the time and levels axis +h_advec_qt = h_advec_qt/(1.0 + qt_mr)**2 #convert to specific humidity + +h_advec_qi = np.zeros((levels.size,time.size),dtype=float) +h_advec_ql = np.zeros((levels.size,time.size),dtype=float) + +#v_advec_qt = np.zeros((levels.size,time.size),dtype=float) +v_advec_qt = nc_fid.variables['v_advec_qt'][:] #kg/kg/s +v_advec_qt = np.swapaxes(v_advec_qt, 0, 1) #swap the time and levels axis +v_advec_qt = v_advec_qt/(1.0 + qt_mr)**2 #convert to specific humidity + +dq_dt = np.zeros((levels.size,time.size),dtype=float) +#dq_dt = nc_fid.variables['dqdt'][:] +#dq_dt = np.swapaxes(dq_dt, 0, 1)*1.0E-3/3600.0 #swap the time and levels axis, convert to K/s + +#h_advec_qt = h_advec_qt*86400.0 +#v_advec_qt = v_advec_qt*86400.0 +#dq_dt = dq_dt*86400.0 +#spr.contour_plot_firl(time, levels, h_advec_qt, np.min(h_advec_qt), np.max(h_advec_qt), 'h advec q', 'time', 'pressure', 'h_advec_q.eps', y_inverted = True) +#spr.contour_plot_firl(time, levels, v_advec_qt, np.min(v_advec_qt), np.max(v_advec_qt), 'v advec q', 'time', 'pressure', 'v_advec_q.eps', y_inverted = True) +#spr.contour_plot_firl(time, levels, dq_dt, np.min(dq_dt), np.max(dq_dt), 'total q tend', 'time', 'pressure', 'dq_dt.eps', y_inverted = True) + +#phi_sfc = nc_fid.variables['phis'][:] +#z_sfc = nc_fid.variables['alt'][:] +height = nc_fid.variables['height'][:] +#height = ffc.get_height_from_pres(T_abs[:,0],levels,z_sfc) + +#the following variables are not in this forcing file, but are included in other cases +#rad_heating = nc_fid.variables['dT_dt_rad'][:] #K/s +#rad_heating = np.swapaxes(rad_heating, 0, 1) #swap the time and levels axis +rad_heating = np.zeros((levels.size,time.size),dtype=float) +u_g = np.zeros((levels.size,time.size),dtype=float) +v_g = np.zeros((levels.size,time.size),dtype=float) + +ozone = np.zeros((levels.size,time.size),dtype=float) +ozone = ozone + 2.e-8 + +tiice = np.zeros((ice_thickness.size),dtype=float) +##tiice[0] = T_surf[start_t_index] +tiice[0] = 271.35 + .75*(T_surf[start_t_index] - 271.35) +tiice[1] = 271.35 + .25*(T_surf[start_t_index] - 271.35) +stc = tiice[0] +smc = 0.33 +slc = 0.33 +hice = 0.3 +slmsk = 2.0 +tsfco = T_surf[start_t_index] +weasd = 200.0 +fice = 1.0 +tisfc = tsfco +snwdph = 2.e-4 +tg3 = 271.35 +zorl = 15.0 +alvsf = 0.23 +alnsf = 0.23 +alvwf = 0.23 +alnwf = 0.23 +facsf = 0.5055632 +facwf = 0.4944368 +vegfrac = 0.0 +canopy = 0.0 +vegtyp = 10 +soiltyp = 12 +uustar = 0.3828793 +shdmin = 0.01 +shdmax = 0.8 +slopetyp = 1 +snoalb = 0.7287961 + +# Open ozone file +#f = open('../../data/raw_case_input/twpice_CRM_ozone.txt', 'r') + +# Read and ignore header lines +#header1 = f.readline() + +#oz_pres = [] +#oz_data = [] +# Loop over lines and extract variables of interest +#for line in f: +# line = line.strip() +# columns = line.split() +# oz_pres.append(float(columns[1])) +# oz_data.append(float(columns[2])) + +#f.close() + +#oz_pres = 100.0*np.array(oz_pres) +#oz_data = np.array(oz_data) +#oz_f = scipy.interpolate.interp1d(oz_pres, oz_data) +#ozone_ppb = oz_f(levels[1:].tolist()) +#ozone_ppb = np.insert(ozone_ppb, 0, oz_data[0]) +#ozone_mmr = ozone_ppb*1.0E-9 + +# +#open processed input file for writing + +writefile_fid = Dataset('../../data/processed_case_input/MOSAiC.nc', 'w', format='NETCDF4') +writefile_fid.description = "CCPP SCM forcing file for MOSAiC case" + +#create groups for scalars, intitialization, and forcing + +writefile_scalar_grp = writefile_fid.createGroup("scalars") +writefile_initial_grp = writefile_fid.createGroup("initial") +writefile_forcing_grp = writefile_fid.createGroup("forcing") + +#create dimensions and write them out + +writefile_time_dim = writefile_fid.createDimension('time', None) +writefile_time_var = writefile_fid.createVariable('time', 'f4', ('time',)) +writefile_time_var[:] = time[start_t_index:] +writefile_time_var.units = 's' +writefile_time_var.description = 'elapsed time since the beginning of the simulation' + +writefile_levels_dim = writefile_fid.createDimension('levels', None) +writefile_levels_var = writefile_fid.createVariable('levels', 'f4', ('levels',)) +writefile_levels_var[:] = levels +writefile_levels_var.units = 'Pa' +writefile_levels_var.description = 'pressure levels' + +writefile_ice_thickness_dim = writefile_fid.createDimension('ice_thickness', None) +writefile_ice_thickness_var = writefile_fid.createVariable('ice_thickness', 'f4', ('ice_thickness',)) +writefile_ice_thickness_var[:] = ice_thickness +writefile_ice_thickness_var.units = 'm' +writefile_ice_thickness_var.description = 'depth of ice layers' + +#create variables and write them out + +#scalar group + +writefile_lat_var = writefile_scalar_grp.createVariable('lat', 'f4') +writefile_lat_var[:] = lat +writefile_lat_var.units = 'degrees N' +writefile_lat_var.description = 'latitude of column' + +writefile_lon_var = writefile_scalar_grp.createVariable('lon', 'f4') +writefile_lon_var[:] = lon +writefile_lon_var.units = 'degrees E' +writefile_lon_var.description = 'longitude of column' + +writefile_hice_var = writefile_scalar_grp.createVariable('hice', 'f4') +writefile_hice_var[:] = hice +writefile_hice_var.units = 'm' +writefile_hice_var.description = 'sea ice thickness' + +writefile_slmsk_var = writefile_scalar_grp.createVariable('slmsk', 'f4') +writefile_slmsk_var[:] = slmsk +writefile_slmsk_var.units = '' +writefile_slmsk_var.description = 'land-sea-ice mask' + +writefile_tsfco_var = writefile_scalar_grp.createVariable('tsfco', 'f4') +writefile_tsfco_var[:] = tsfco +writefile_tsfco_var.units = 'm' +writefile_tsfco_var.description = 'sea ice surface skin temperature' + +writefile_weasd_var = writefile_scalar_grp.createVariable('weasd', 'f4') +writefile_weasd_var[:] = weasd +writefile_weasd_var.units = 'mm' +writefile_weasd_var.description = 'water equivalent accumulated snow depth' + +writefile_fice_var = writefile_scalar_grp.createVariable('fice', 'f4') +writefile_fice_var[:] = fice +writefile_fice_var.units = '1' +writefile_fice_var.description = 'ice fraction' + +writefile_tisfc_var = writefile_scalar_grp.createVariable('tisfc', 'f4') +writefile_tisfc_var[:] = tisfc +writefile_tisfc_var.units = 'K' +writefile_tisfc_var.description = 'ice surface temperature' + +writefile_snwdph_var = writefile_scalar_grp.createVariable('snwdph', 'f4') +writefile_snwdph_var[:] = snwdph +writefile_snwdph_var.units = 'mm' +writefile_snwdph_var.description = 'water equivalent snow depth' + +writefile_tg3_var = writefile_scalar_grp.createVariable('tg3', 'f4') +writefile_tg3_var[:] = tg3 +writefile_tg3_var.units = 'K' +writefile_tg3_var.description = 'deep soil temperature' + +writefile_zorl_var = writefile_scalar_grp.createVariable('zorl', 'f4') +writefile_zorl_var[:] = zorl +writefile_zorl_var.units = 'cm' +writefile_zorl_var.description = 'composite surface roughness length' + +writefile_alvsf_var = writefile_scalar_grp.createVariable('alvsf', 'f4') +writefile_alvsf_var[:] = alvsf +writefile_alvsf_var.units = '' +writefile_alvsf_var.description = '60 degree vis albedo with strong cosz dependency' + +writefile_alnsf_var = writefile_scalar_grp.createVariable('alnsf', 'f4') +writefile_alnsf_var[:] = alnsf +writefile_alnsf_var.units = '' +writefile_alnsf_var.description = '60 degree nir albedo with strong cosz dependency' + +writefile_alvwf_var = writefile_scalar_grp.createVariable('alvwf', 'f4') +writefile_alvwf_var[:] = alvwf +writefile_alvwf_var.units = '' +writefile_alvwf_var.description = '60 degree vis albedo with weak cosz dependency' + +writefile_alnwf_var = writefile_scalar_grp.createVariable('alnwf', 'f4') +writefile_alnwf_var[:] = alnwf +writefile_alnwf_var.units = '' +writefile_alnwf_var.description = '60 degree nir albedo with weak cosz dependency' + +writefile_facsf_var = writefile_scalar_grp.createVariable('facsf', 'f4') +writefile_facsf_var[:] = facsf +writefile_facsf_var.units = '' +writefile_facsf_var.description = 'fractional coverage with strong cosz dependency' + +writefile_facwf_var = writefile_scalar_grp.createVariable('facwf', 'f4') +writefile_facwf_var[:] = facwf +writefile_facwf_var.units = '' +writefile_facwf_var.description = 'fractional coverage with weak cosz dependency' + +writefile_vegfrac_var = writefile_scalar_grp.createVariable('vegfrac', 'f4') +writefile_vegfrac_var[:] = vegfrac +writefile_vegfrac_var.units = '1' +writefile_vegfrac_var.description = 'vegetation fraction' + +writefile_canopy_var = writefile_scalar_grp.createVariable('canopy', 'f4') +writefile_canopy_var[:] = canopy +writefile_canopy_var.units = 'kg m-2' +writefile_canopy_var.description = 'amount of water stored in camopy' + +writefile_vegtyp_var = writefile_scalar_grp.createVariable('vegtyp', 'f4') +writefile_vegtyp_var[:] = vegtyp +writefile_vegtyp_var.units = '' +writefile_vegtyp_var.description = 'vegetation type 1-12' + +writefile_soiltyp_var = writefile_scalar_grp.createVariable('soiltyp', 'f4') +writefile_soiltyp_var[:] = soiltyp +writefile_soiltyp_var.units = '' +writefile_soiltyp_var.description = 'soil type 1-12' + +writefile_uustar_var = writefile_scalar_grp.createVariable('uustar', 'f4') +writefile_uustar_var[:] = uustar +writefile_uustar_var.units = 'm s-1' +writefile_uustar_var.description = 'friction velocity' + +writefile_shdmin_var = writefile_scalar_grp.createVariable('shdmin', 'f4') +writefile_shdmin_var[:] = shdmin +writefile_shdmin_var.units = '1' +writefile_shdmin_var.description = 'minimum vegetation fraction' + +writefile_shdmax_var = writefile_scalar_grp.createVariable('shdmax', 'f4') +writefile_shdmax_var[:] = shdmax +writefile_shdmax_var.units = '1' +writefile_shdmax_var.description = 'maximum vegetation fraction' + +writefile_slopetyp_var = writefile_scalar_grp.createVariable('slopetyp', 'f4') +writefile_slopetyp_var[:] = slopetyp +writefile_slopetyp_var.units = '' +writefile_slopetyp_var.description = 'slope type 1-9' + +writefile_snoalb_var = writefile_scalar_grp.createVariable('snoalb', 'f4') +writefile_snoalb_var[:] = snoalb +writefile_snoalb_var.units = '1' +writefile_snoalb_var.description = 'maximum snow albedo' + +#initial group + +writefile_height_var = writefile_initial_grp.createVariable('height', 'f4', ('levels',)) +writefile_height_var[:] = height +writefile_height_var.units = 'm' +writefile_height_var.description = 'physical height at pressure levels' + +writefile_tiice_var = writefile_initial_grp.createVariable('tiice', 'f4', ('ice_thickness',)) +writefile_tiice_var[:] = tiice +writefile_tiice_var.units = 'K' +writefile_tiice_var.description = 'initial profile of sea ice internal temperature' + +writefile_stc_var = writefile_initial_grp.createVariable('stc', 'f4') +writefile_stc_var[:] = stc +writefile_stc_var.units = 'K' +writefile_stc_var.description = 'initial profile of sea ice internal temperature' + +writefile_smc_var = writefile_initial_grp.createVariable('smc', 'f4') +writefile_smc_var[:] = smc +writefile_smc_var.units = 'm3 m-3' +writefile_smc_var.description = 'initial profile of soil moisture' + +writefile_slc_var = writefile_initial_grp.createVariable('slc', 'f4') +writefile_slc_var[:] = slc +writefile_slc_var.units = 'm3 m-3' +writefile_slc_var.description = 'initial profile of soil liquid water' + +writefile_thetail_var = writefile_initial_grp.createVariable('thetail', 'f4', ('levels',)) +writefile_thetail_var[:] = thetail[:,start_t_index] +writefile_thetail_var.units = 'K' +writefile_thetail_var.description = 'initial profile of ice-liquid water potential temperature' + +writefile_qt_var = writefile_initial_grp.createVariable('qt', 'f4', ('levels',)) +writefile_qt_var[:] = qt[:,start_t_index] +writefile_qt_var.units = 'kg kg^-1' +writefile_qt_var.description = 'initial profile of total water specific humidity' + +writefile_ql_var = writefile_initial_grp.createVariable('ql', 'f4', ('levels',)) +writefile_ql_var[:] = ql[:,start_t_index] +writefile_ql_var.units = 'kg kg^-1' +writefile_ql_var.description = 'initial profile of liquid water specific humidity' + +writefile_qi_var = writefile_initial_grp.createVariable('qi', 'f4', ('levels',)) +writefile_qi_var[:] = qi[:,start_t_index] +writefile_qi_var.units = 'kg kg^-1' +writefile_qi_var.description = 'initial profile of ice water specific humidity' + +writefile_u_var = writefile_initial_grp.createVariable('u', 'f4', ('levels',)) +writefile_u_var[:] = u_wind[:,start_t_index] +writefile_u_var.units = 'm s^-1' +writefile_u_var.description = 'initial profile of E-W horizontal wind' + +writefile_v_var = writefile_initial_grp.createVariable('v', 'f4', ('levels',)) +writefile_v_var[:] = v_wind[:,start_t_index] +writefile_v_var.units = 'm s^-1' +writefile_v_var.description = 'initial profile of N-S horizontal wind' + +writefile_tke_var = writefile_initial_grp.createVariable('tke', 'f4', ('levels',)) +writefile_tke_var[:] = tke[:,start_t_index] +writefile_tke_var.units = 'm^2 s^-2' +writefile_tke_var.description = 'initial profile of turbulence kinetic energy' + +writefile_ozone_var = writefile_initial_grp.createVariable('ozone', 'f4', ('levels',)) +writefile_ozone_var[:] = ozone[:,start_t_index] +writefile_ozone_var.units = 'kg kg^-1' +writefile_ozone_var.description = 'initial profile of ozone mass mixing ratio' + +#forcing group + +writefile_p_surf_var = writefile_forcing_grp.createVariable('p_surf', 'f4', ('time',)) +writefile_p_surf_var[:] = p_surf[start_t_index:] +writefile_p_surf_var.units = 'Pa' +writefile_p_surf_var.description = 'surface pressure' + +writefile_T_surf_var = writefile_forcing_grp.createVariable('T_surf', 'f4', ('time',)) +writefile_T_surf_var[:] = T_surf[start_t_index:] +writefile_T_surf_var.units = 'K' +writefile_T_surf_var.description = 'surface absolute temperature' + +writefile_w_ls_var = writefile_forcing_grp.createVariable('w_ls', 'f4', ('levels','time',)) +writefile_w_ls_var[:] = w_sub[:,start_t_index:] +writefile_w_ls_var.units = 'm s^-1' +writefile_w_ls_var.description = 'large scale vertical velocity' + +writefile_omega_var = writefile_forcing_grp.createVariable('omega', 'f4', ('levels','time',)) +writefile_omega_var[:] = omega[:,start_t_index:] +writefile_omega_var.units = 'Pa s^-1' +writefile_omega_var.description = 'large scale pressure vertical velocity' + +writefile_u_g_var = writefile_forcing_grp.createVariable('u_g', 'f4', ('levels','time',)) +writefile_u_g_var[:] = u_g[:,start_t_index:] +writefile_u_g_var.units = 'm s^-1' +writefile_u_g_var.description = 'large scale geostrophic E-W wind' + +writefile_v_g_var = writefile_forcing_grp.createVariable('v_g', 'f4', ('levels','time',)) +writefile_v_g_var[:] = v_g[:,start_t_index:] +writefile_v_g_var.units = 'm s^-1' +writefile_v_g_var.description = 'large scale geostrophic N-S wind' + +writefile_u_nudge_var = writefile_forcing_grp.createVariable('u_nudge', 'f4', ('levels','time',)) +writefile_u_nudge_var[:] = u_wind[:,start_t_index:] +writefile_u_nudge_var.units = 'm s^-1' +writefile_u_nudge_var.description = 'E-W wind to nudge toward' + +writefile_v_nudge_var = writefile_forcing_grp.createVariable('v_nudge', 'f4', ('levels','time',)) +writefile_v_nudge_var[:] = v_wind[:,start_t_index:] +writefile_v_nudge_var.units = 'm s^-1' +writefile_v_nudge_var.description = 'N-S wind to nudge toward' + +writefile_T_nudge_var = writefile_forcing_grp.createVariable('T_nudge', 'f4', ('levels','time',)) +writefile_T_nudge_var[:] = T_abs[:,start_t_index:] +writefile_T_nudge_var.units = 'K' +writefile_T_nudge_var.description = 'absolute temperature to nudge toward' + +writefile_thil_nudge_var = writefile_forcing_grp.createVariable('thil_nudge', 'f4', ('levels','time',)) +writefile_thil_nudge_var[:] = thetailu[:,start_t_index:] +writefile_thil_nudge_var.units = 'K' +writefile_thil_nudge_var.description = 'potential temperature to nudge toward' + +writefile_qt_nudge_var = writefile_forcing_grp.createVariable('qt_nudge', 'f4', ('levels','time',)) +writefile_qt_nudge_var[:] = qtu[:,start_t_index:] +writefile_qt_nudge_var.units = 'kg kg^-1' +writefile_qt_nudge_var.description = 'q_t to nudge toward' + +writefile_qi_nudge_var = writefile_forcing_grp.createVariable('qi_nudge', 'f4', ('levels','time',)) +writefile_qi_nudge_var[:] = qi[:,start_t_index:] +writefile_qi_nudge_var.units = 'kg kg^-1' +writefile_qi_nudge_var.description = 'q_i to nudge toward' + +writefile_ql_nudge_var = writefile_forcing_grp.createVariable('ql_nudge', 'f4', ('levels','time',)) +writefile_ql_nudge_var[:] = ql[:,start_t_index:] +writefile_ql_nudge_var.units = 'kg kg^-1' +writefile_ql_nudge_var.description = 'q_l to nudge toward' + +writefile_rad_heating_var = writefile_forcing_grp.createVariable('dT_dt_rad', 'f4', ('levels','time',)) +writefile_rad_heating_var[:] = rad_heating[:,start_t_index:] +writefile_rad_heating_var.units = 'K s^-1' +writefile_rad_heating_var.description = 'prescribed radiative heating rate' + +writefile_h_advec_thil_var = writefile_forcing_grp.createVariable('h_advec_thetail', 'f4', ('levels','time',)) +writefile_h_advec_thil_var[:] = h_advec_thil[:,start_t_index:] +writefile_h_advec_thil_var.units = 'K s^-1' +writefile_h_advec_thil_var.description = 'prescribed theta_il tendency due to horizontal advection' + +writefile_v_advec_thil_var = writefile_forcing_grp.createVariable('v_advec_thetail', 'f4', ('levels','time',)) +writefile_v_advec_thil_var[:] = v_advec_thil[:,start_t_index:] +writefile_v_advec_thil_var.units = 'K s^-1' +writefile_v_advec_thil_var.description = 'prescribed theta_il tendency due to vertical advection' + +writefile_h_advec_qt_var = writefile_forcing_grp.createVariable('h_advec_qt', 'f4', ('levels','time',)) +writefile_h_advec_qt_var[:] = h_advec_qt[:,start_t_index:] +writefile_h_advec_qt_var.units = 'kg kg^-1 s^-1' +writefile_h_advec_qt_var.description = 'prescribed q_t tendency due to horizontal advection' + +writefile_h_advec_qi_var = writefile_forcing_grp.createVariable('h_advec_qi', 'f4', ('levels','time',)) +writefile_h_advec_qi_var[:] = h_advec_qi[:,start_t_index:] +writefile_h_advec_qi_var.units = 'kg kg^-1 s^-1' +writefile_h_advec_qi_var.description = 'prescribed q_i tendency due to horizontal advection' + +writefile_h_advec_ql_var = writefile_forcing_grp.createVariable('h_advec_ql', 'f4', ('levels','time',)) +writefile_h_advec_ql_var[:] = h_advec_ql[:,start_t_index:] +writefile_h_advec_ql_var.units = 'kg kg^-1 s^-1' +writefile_h_advec_ql_var.description = 'prescribed q_l tendency due to horizontal advection' + +writefile_v_advec_qt_var = writefile_forcing_grp.createVariable('v_advec_qt', 'f4', ('levels','time',)) +writefile_v_advec_qt_var[:] = v_advec_qt[:,start_t_index:] +writefile_v_advec_qt_var.units = 'kg kg^-1 s^-1' +writefile_v_advec_qt_var.description = 'prescribed q_t tendency due to vertical advection' + + +#close processed input file +writefile_fid.close() + +#close raw input file +nc_fid.close() diff --git a/scm/etc/scripts/plot_configs/MOSAiC-AMPS.ini b/scm/etc/scripts/plot_configs/MOSAiC-AMPS.ini new file mode 100644 index 000000000..0ce84096a --- /dev/null +++ b/scm/etc/scripts/plot_configs/MOSAiC-AMPS.ini @@ -0,0 +1,63 @@ +scm_datasets = output_MOSAiC-AMPS_SCM_RRFS_v1beta/output.nc, output_MOSAiC-AMPS_SCM_GFS_v17_p8/output.nc, output_MOSAiC-AMPS_SCM_GFS_v16/output.nc +scm_datasets_labels = RRFS_v1beta, GFSv17p8, GFSv16 +plot_dir = plots_MOSAiC-AMPS_all_suites/ +obs_file = ../data/raw_case_input/MOSAiC_31Oct20190Z_raw.nc +obs_compare = True +plot_ind_datasets = True +time_series_resample = False + +[time_slices] + [[active]] + start = 2019, 11, 1, 0 + end = 2019, 11, 2, 0 + +[time_snapshots] + +[plots] + [[profiles_mean]] + vars = ql, qc, qi, qv, T, dT_dt_pbl, T_force_tend, dT_dt_conv, dT_dt_micro, dT_dt_lwrad, dT_dt_phys, qv_force_tend, dq_dt_pbl, dq_dt_shalconv, dq_dt_micro, dq_dt_phys, dq_dt_nonphys, rad_cloud_iwp, rad_cloud_swp, rad_cloud_rwp, rad_cloud_lwp + vars_labels = 'cloud water mixing ratio ($g$ $kg^{-1}$)', 'total cloud water mixing ratio ($g$ $kg^{-1}$)', 'ice+snow+graup mixing ratio ($g$ $kg^{-1}$)', 'specific humidity ($g$ $kg^{-1}$)', 'T (K)', 'PBL tendency (K/day)', 'force (K/day)', 'conv. tendency (K/day)', 'microphysics tendency (K/day)', 'LW tendency (K/day)', 'PHYS (K/day)', 'force (kg/kg/day)', 'PBL tendency (kg/kg/day)', 'ShalConv tendency (kg/kg/day)', 'microphysics tendency (kg/kg/day)', 'PHYS (kg/kg/day)', 'NONPHYS (kg/kg/day)', 'IWC (g/m3)', 'SWC (g/m3)', 'RWC (g/m3)', 'LWC (g/m3)' + vert_axis = pres_l + vert_axis_label = 'average pressure (Pa)' + y_inverted = True + y_log = False +# y_min_option = min #min, max, val (if val, add y_min = float value) + y_min_option = val #min, max, val (if val, add y_min = float value) + y_min = 70000.0 #min, max, val (if val, add y_min = float value) + y_max_option = max #min, max, val (if val, add y_max = float value) + conversion_factor = 1000.0, 1000.0, 1000.0, 1000.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 + + [[profiles_mean_multi]] + [[[T_forcing]]] + vars = T_force_tend, dT_dt_pbl, dT_dt_conv, dT_dt_micro, dT_dt_lwrad + vars_labels = 'force', 'PBL', 'Conv', 'MP', 'LW' + x_label = 'K/day' + [[[QV_forcing]]] + vars = qv_force_tend, dq_dt_pbl, dq_dt_shalconv, dq_dt_micro, dq_dt_phys, dq_dt_nonphys + vars_labels = 'force', 'PBL', 'ShalConv', 'MP', 'PHYS', 'NONPHYS' + x_label = 'kg/kg/day' + [[[conv_tendencies]]] + vars = dT_dt_deepconv, dT_dt_shalconv + vars_labels = 'deep', 'shallow' + x_label = 'K/day' + + [[profiles_instant]] + + [[time_series]] + vars = 'pres_s','lhf','shf','tprcp_rate_inst','t2m','q2m','u10m','v10m','gflux','sfc_dwn_lw','tsfc' + vars_labels = 'surface pressure (Pa)','latent heat flux ($W$ $m^{-2}$)','sensible heat flux ($W$ $m^{-2}$)','surface rainfall rate ($mm$ $hr{-1}$)','2m temperature ($K$)','2m specific humidity ($g$ $kg{-1}$)','10m zonal wind ($m$ $s{-1}$)','10m meridional wind ($m$ $s{-1}$)','ground flux ($W$ $m{-2}$)','downward longwave flux ($W$ $m{-2}$)','surface temperature ($K$)' + + [[contours]] + vars = qv, T, h_advec_qt, h_advec_thil, qi, ql + vars_labels = 'Water Vapor ($g$ $kg^{-1}$)','Temperature ($K$)','Horizontal total water advection ($g$ $kg^{-1}$ $s^{-1}$)','Horizontal thetail advection ($K$ $s^{-1}$)','QI ($g$ $kg^{-1}$)','QL ($g$ $kg^{-1}$)' + vert_axis = pres_l + vert_axis_label = 'p (Pa)' + y_inverted = True + y_log = False + y_min_option = val #min, max, val (if val, add y_min = float value) + y_min = 10000.0 + y_max_option = val #min, max, val (if val, add y_max = float value) + y_max = 100000.0 + x_ticks_num = 10 + y_ticks_num = 10 + conversion_factor = 1000.0, 1.0, 1.0, 1.0, 1000.0, 1000.0 diff --git a/scm/etc/scripts/plot_configs/MOSAiC-SS.ini b/scm/etc/scripts/plot_configs/MOSAiC-SS.ini new file mode 100644 index 000000000..82672321c --- /dev/null +++ b/scm/etc/scripts/plot_configs/MOSAiC-SS.ini @@ -0,0 +1,65 @@ +scm_datasets = output_MOSAiC-SS_SCM_RRFS_v1beta/output.nc, output_MOSAiC-SS_SCM_GFS_v17_p8/output.nc, output_MOSAiC-SS_SCM_GFS_v16/output.nc +##scm_datasets = output_MOSAiC-SS_SCM_GFS_v17_p8/output.nc, output_MOSAiC-SS_SCM_GFS_v16/output.nc +##scm_datasets_labels = GFSv17p8, GFSv16 +scm_datasets_labels = RRFS_v1beta, GFSv17p8, GFSv16 +plot_dir = plots_MOSAiC-SS_all_suites/ +obs_file = ../data/raw_case_input/MOSAiC_2Mar20200Z_raw.nc +obs_compare = True +plot_ind_datasets = True +time_series_resample = False + +[time_slices] + [[active]] + start = 2020, 3, 4, 0 + end = 2020, 3, 5, 0 + +[time_snapshots] + +[plots] + [[profiles_mean]] + vars = ql, qc, qi, qv, T, dT_dt_pbl, T_force_tend, dT_dt_conv, dT_dt_micro, dT_dt_lwrad, dT_dt_phys, qv_force_tend, dq_dt_pbl, dq_dt_shalconv, dq_dt_micro, dq_dt_phys, dq_dt_nonphys, rad_cloud_iwp, rad_cloud_swp, rad_cloud_rwp, rad_cloud_lwp + vars_labels = 'cloud water mixing ratio ($g$ $kg^{-1}$)', 'total cloud water mixing ratio ($g$ $kg^{-1}$)', 'ice+snow+graup mixing ratio ($g$ $kg^{-1}$)', 'specific humidity ($g$ $kg^{-1}$)', 'T (K)', 'PBL tendency (K/day)', 'force (K/day)', 'conv. tendency (K/day)', 'microphysics tendency (K/day)', 'LW tendency (K/day)', 'PHYS (K/day)', 'force (kg/kg/day)', 'PBL tendency (kg/kg/day)', 'ShalConv tendency (kg/kg/day)', 'microphysics tendency (kg/kg/day)', 'PHYS (kg/kg/day)', 'NONPHYS (kg/kg/day)', 'IWC (g/m3)', 'SWC (g/m3)', 'RWC (g/m3)', 'LWC (g/m3)' + vert_axis = pres_l + vert_axis_label = 'average pressure (Pa)' + y_inverted = True + y_log = False +# y_min_option = min #min, max, val (if val, add y_min = float value) + y_min_option = val #min, max, val (if val, add y_min = float value) + y_min = 70000.0 #min, max, val (if val, add y_min = float value) + y_max_option = max #min, max, val (if val, add y_max = float value) + conversion_factor = 1000.0, 1000.0, 1000.0, 1000.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 + + [[profiles_mean_multi]] + [[[T_forcing]]] + vars = T_force_tend, dT_dt_pbl, dT_dt_conv, dT_dt_micro, dT_dt_lwrad + vars_labels = 'force', 'PBL', 'Conv', 'MP', 'LW' + x_label = 'K/day' + [[[QV_forcing]]] + vars = qv_force_tend, dq_dt_pbl, dq_dt_shalconv, dq_dt_micro, dq_dt_phys, dq_dt_nonphys + vars_labels = 'force', 'PBL', 'ShalConv', 'MP', 'PHYS', 'NONPHYS' + x_label = 'kg/kg/day' + [[[conv_tendencies]]] + vars = dT_dt_deepconv, dT_dt_shalconv + vars_labels = 'deep', 'shallow' + x_label = 'K/day' + + [[profiles_instant]] + + [[time_series]] + vars = 'pres_s','lhf','shf','tprcp_rate_inst','t2m','q2m','u10m','v10m','gflux','sfc_dwn_lw','tsfc' + vars_labels = 'surface pressure (Pa)','latent heat flux ($W$ $m^{-2}$)','sensible heat flux ($W$ $m^{-2}$)','surface rainfall rate ($mm$ $hr{-1}$)','2m temperature ($K$)','2m specific humidity ($g$ $kg{-1}$)','10m zonal wind ($m$ $s{-1}$)','10m meridional wind ($m$ $s{-1}$)','ground flux ($W$ $m{-2}$)','downward longwave flux ($W$ $m{-2}$)','surface temperature ($K$)' + + [[contours]] + vars = qv, T, h_advec_qt, h_advec_thil, qi, ql + vars_labels = 'Water Vapor ($g$ $kg^{-1}$)','Temperature ($K$)','Horizontal total water advection ($g$ $kg^{-1}$ $s^{-1}$)','Horizontal thetail advection ($K$ $s^{-1}$)','QI ($g$ $kg^{-1}$)','QL ($g$ $kg^{-1}$)' + vert_axis = pres_l + vert_axis_label = 'p (Pa)' + y_inverted = True + y_log = False + y_min_option = val #min, max, val (if val, add y_min = float value) + y_min = 10000.0 + y_max_option = val #min, max, val (if val, add y_max = float value) + y_max = 100000.0 + x_ticks_num = 10 + y_ticks_num = 10 + conversion_factor = 1000.0, 1.0, 1.0, 1.0, 1000.0, 1000.0 diff --git a/scm/etc/scripts/scm_analysis.py b/scm/etc/scripts/scm_analysis.py index 34c85c529..d6516dc7a 100755 --- a/scm/etc/scripts/scm_analysis.py +++ b/scm/etc/scripts/scm_analysis.py @@ -856,6 +856,8 @@ def replace_fill_with_nan(nc_ds, var_name, var, group, time_diag, pres_l, datase obs_dict = sro.read_LASSO_obs(obs_file, time_slices, date_inst) elif('gabls3' in case_name.strip()): obs_dict = sro.read_gabls3_obs(obs_file, time_slices, date_inst) + elif('MOSAiC' in case_name.strip()): + obs_dict = sro.read_MOSAiC_obs(obs_file, time_slices, date_inst) try: os.makedirs(plot_dir) @@ -1378,7 +1380,7 @@ def replace_fill_with_nan(nc_ds, var_name, var, group, time_diag, pres_l, datase else: y_max_val = profiles_mean['y_max'] y_lim_val = [y_min_val, y_max_val] - + #plot mean profiles for k in range(len(profiles_mean['vars'])): #get the python variable associated with the vars listed in the config file diff --git a/scm/etc/scripts/scm_read_obs.py b/scm/etc/scripts/scm_read_obs.py index 59ac43c34..ac6b80100 100644 --- a/scm/etc/scripts/scm_read_obs.py +++ b/scm/etc/scripts/scm_read_obs.py @@ -6,6 +6,71 @@ import math import forcing_file_common as ffc +def read_MOSAiC_obs(obs_file, time_slices, date): + obs_time_slice_indices = [] + + obs_fid = Dataset(obs_file, 'r') + + obs_year = obs_fid.variables['year'][:] + obs_month = obs_fid.variables['month'][:] + obs_day = obs_fid.variables['day'][:] + obs_hour = obs_fid.variables['hour'][:] + obs_time = obs_fid.variables['time_offset'][:] + + obs_date = [] + for i in range(obs_hour.size): + obs_date.append(datetime.datetime(obs_year[i], obs_month[i], obs_day[i], obs_hour[i], 0, 0, 0)) + obs_date = np.array(obs_date) + + for time_slice in time_slices: + start_date = datetime.datetime(time_slices[time_slice]['start'][0], time_slices[time_slice]['start'][1],time_slices[time_slice]['start'][2], time_slices[time_slice]['start'][3], time_slices[time_slice]['start'][4]) + end_date = datetime.datetime(time_slices[time_slice]['end'][0], time_slices[time_slice]['end'][1],time_slices[time_slice]['end'][2], time_slices[time_slice]['end'][3], time_slices[time_slice]['end'][4]) + start_date_index = np.where(obs_date == start_date)[0][0] + end_date_index = np.where(obs_date == end_date)[0][0] + obs_time_slice_indices.append([start_date_index, end_date_index]) + +#print(start_date, end_date, start_date_index, end_date_index, obs_date[start_date_index], obs_date[end_date_index]) + + #find the index corresponding to the start of the simulations + obs_start_index = np.where(obs_date == date[0][0])[0] + obs_time = obs_time - obs_time[obs_start_index] + + obs_pres_l = obs_fid.variables['levels'][:]*100.0 #pressure levels in mb + + obs_T = obs_fid.variables['T'][:] + obs_q = obs_fid.variables['q'][:] + obs_qi= obs_fid.variables['qi'][:] + obs_ql= obs_fid.variables['ql'][:] + obs_u = obs_fid.variables['u'][:] + obs_v = obs_fid.variables['v'][:] + obs_rad_net_srf = obs_fid.variables['rad_net_srf'][:] + obs_lw_dn_srf = obs_fid.variables['lw_dn_srf'][:] + obs_tsk = obs_fid.variables['T_skin'][:] + obs_shf = obs_fid.variables['SH'][:] + obs_lhf = obs_fid.variables['LH'][:] + obs_t2m = obs_fid.variables['T_srf'][:] + obs_q2m = obs_fid.variables['q_srf'][:] + + obs_time_h = obs_time/3600.0 + + Rd = 287.0 + Rv = 461.0 + + e_s = 6.1078*np.exp(17.2693882*(obs_T - 273.16)/(obs_T - 35.86))*100.0 #Tetens formula produces e_s in mb (convert to Pa) + e = obs_q*obs_pres_l/(obs_q + (Rd/Rv)*(1.0 - obs_q)) #compute vapor pressure from specific humidity + obs_rh = np.clip(e/e_s, 0.0, 1.0) + + return_dict = {'year': obs_year, 'month': obs_month, 'day': obs_day, 'hour': obs_hour, + 'time': obs_time, 'date': obs_date, 'time_slice_indices': obs_time_slice_indices, + 'pres_l': obs_pres_l, 'T': obs_T, 'q': obs_q, 'rh': obs_rh, 'u': obs_u, 'v': obs_v, 'shf': obs_shf, + 'lhf': obs_lhf, 't2m': obs_t2m, 'q2m': obs_q2m, 'time_h': obs_time_h, 'tsfc': obs_tsk, + 'qv': obs_q, 'qi': obs_qi, 'ql': obs_ql, 'rad_net_srf': obs_rad_net_srf, 'sfc_dwn_lw': obs_lw_dn_srf} +# 'lwp': obs_lwp, 'T_force_tend': obs_T_forcing, 'qv_force_tend': obs_q_forcing} + + obs_fid.close() + + return return_dict + def read_twpice_obs(obs_file, time_slices, date): obs_time_slice_indices = [] @@ -337,4 +402,4 @@ def read_gabls3_obs(obs_file, time_slices, date): 'sfc_dwn_sw': obs_sw_dn, 'sfc_up_sw': obs_sw_up, 'sfc_rad_net_land': obs_sfc_rad_net, 'gflux': -1*obs_gflux, 't2m':obs_t2m, 'q2m':obs_q2m, 'ustar':obs_ustar,'u10m':obs_u10m, 'v10m':obs_v10m, 'hpbl':obs_hpbl, 'tsfc':obs_tsk} - return return_dict \ No newline at end of file + return return_dict From dd673f222aa9204672d0b287fbb9e4d3593d3ac5 Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Thu, 11 Jul 2024 10:36:22 -0400 Subject: [PATCH 04/13] add dephy_converter.py --- scm/etc/scripts/dephy_converter.py | 1241 ++++++++++++++++++++++++++++ 1 file changed, 1241 insertions(+) create mode 100755 scm/etc/scripts/dephy_converter.py diff --git a/scm/etc/scripts/dephy_converter.py b/scm/etc/scripts/dephy_converter.py new file mode 100755 index 000000000..63595540c --- /dev/null +++ b/scm/etc/scripts/dephy_converter.py @@ -0,0 +1,1241 @@ +#!/usr/bin/env python + +import argparse +import logging +import f90nml +import os +from netCDF4 import Dataset +import numpy as np +from datetime import datetime, timedelta + + +############################################################################### +# Global settings # +############################################################################### + +# Path to the directory containing processed case input files +CASE_NML_DIR = '../case_config' + +# Path to the directory containing processed case input files +PROCESSED_CASE_DIR = '../../data/processed_case_input' + +# For developers: set logging level to DEBUG for additional output +LOGLEVEL = logging.DEBUG +#LOGLEVEL = logging.INFO + +DEFAULT_MISSING_VALUE = -9999.0 +DEFAULT_NUDGING_TIMESCALE = 7200.0 #s + +############################################################################### +# Command line arguments # +############################################################################### + +parser = argparse.ArgumentParser() +parser.add_argument('-n', '--case_name', help='name of case', required=True) +parser.add_argument('-a', '--use_area', help='use column_area namelist attribute as forcing_scale', action='store_true') + + +######################################################################################## +# +######################################################################################## +def parse_arguments(): + """Parse command line arguments""" + args = parser.parse_args() + case_name = args.case_name + use_area = args.use_area + + + return (case_name, use_area) + +######################################################################################## +# +######################################################################################## +def setup_logging(): + """Sets up the logging module.""" + logging.basicConfig(format='%(levelname)s: %(message)s', level=LOGLEVEL) + +class Case_Data(object): + def __init__(self, name, missing_value, time, levels, lat, lon, height, theta_il, qt, ql, qi, u, v, tke, ozone, \ + p_surf, T_surf, w_ls, omega, u_g, v_g, u_nudge, v_nudge, T_nudge, thil_nudge, qt_nudge, \ + dT_dt_rad, h_advec_thil, v_advec_thil, h_advec_qt, v_advec_qt, sh_flux_sfc, lh_flux_sfc): + self._name = name + self._missing_value = missing_value + self._time = time + self._levels = levels + self._lat = lat + self._lon = lon + self._height = height + self._theta_il = theta_il + self._qt = qt + self._ql = ql + self._qi = qi + self._u = u + self._v = v + self._tke = tke + self._ozone = ozone + self._p_surf = p_surf + self._T_surf = T_surf + self._w_ls = w_ls + self._omega = omega + self._u_g = u_g + self._v_g = v_g + self._u_nudge = u_nudge + self._v_nudge = v_nudge + self._T_nudge = T_nudge + self._thil_nudge = thil_nudge + self._qt_nudge = qt_nudge + self._dT_dt_rad = dT_dt_rad + self._h_advec_thil = h_advec_thil + self._v_advec_thil = v_advec_thil + self._h_advec_qt = h_advec_qt + self._v_advec_qt = v_advec_qt + self._sh_flux_sfc = sh_flux_sfc + self._lh_flux_sfc = lh_flux_sfc + + def __repr__(self): + return "Case_Data \n Globals: \n" \ + " name:% s \n" \ + " missing_value:% s \n" \ + " Dimensions: \n" \ + " time:% s \n" \ + " levels: % s \n" \ + " Scalars: \n" \ + " lat: % s \n" \ + " lon: % s \n" \ + " Initial: \n" \ + " height: % s \n" \ + " theta_il: % s \n" \ + " qt: % s \n" \ + " ql: % s \n" \ + " qi: % s \n" \ + " u: % s \n" \ + " v: % s \n" \ + " tke: %s \n" \ + " ozone: %s \n" \ + " Forcing: \n" \ + " p_surf: %s \n" \ + " T_surf: %s \n" \ + " w_ls (time avg): %s \n" \ + " omega (time avg): %s \n" \ + " u_g (time avg): %s \n" \ + " v_g (time avg): %s \n" \ + " u_nudge (time avg): %s \n" \ + " v_nudge (time avg): %s \n" \ + " T_nudge (time avg): %s \n" \ + " thil_nudge (time avg): %s \n" \ + " qt_nudge (time avg): %s \n" \ + " dT_dt_rad (time avg): %s \n" \ + " h_advec_thil (time avg): %s \n" \ + " v_advec_thil (time avg): %s \n" \ + " h_advec_qt (time avg): %s \n" \ + " v_advec_qt (time avg): %s \n" \ + " sh_flux_sfc: %s \n" \ + " lh_flux_sfc: %s \n" \ + % (self._name, self._missing_value, self._time, self._levels, + self._lat, self._lon, self._height, self._theta_il, + self._qt, self._ql, self._qi, self._u, self._v, + self._tke, self._ozone, + self._p_surf, self._T_surf, np.mean(self._w_ls, axis=1), + np.mean(self._omega, axis=1), np.mean(self._u_g, axis=1), + np.mean(self._v_g, axis=1), np.mean(self._u_nudge, axis=1), + np.mean(self._v_nudge, axis=1), np.mean(self._T_nudge, axis=1), + np.mean(self._thil_nudge, axis=1),np.mean(self._qt_nudge, axis=1), + np.mean(self._dT_dt_rad, axis=1), + np.mean(self._h_advec_thil, axis=1),np.mean(self._v_advec_thil, axis=1), + np.mean(self._h_advec_qt, axis=1),np.mean(self._v_advec_qt, axis=1), + self._sh_flux_sfc, self._lh_flux_sfc) + +def get_case_nml(case_name): + """Returns case configuration Fortran namelist""" + + filename = os.path.join(CASE_NML_DIR, case_name + '.nml') + + print(filename) + + error = False + nml = '' + if (os.path.exists(filename)): + nml = f90nml.read(filename) + else: + error = True + + return (nml, error) + +def get_case_data(case_name): + """Returns proprietery CCPP SCM case data in NetCDF Dataset format""" + + #TODO: need to handle LSM ICs + + filename = os.path.join(PROCESSED_CASE_DIR, case_name + '.nc') + + error = False + try: + nc_fid = Dataset(filename , 'r') + except: + error = True + + if (not error): + #read global variables + try: + missing_value = nc_fid.getncattr('missing_value') + except: + missing_value = DEFAULT_MISSING_VALUE + + time = nc_fid.variables['time'][:] + levels = nc_fid.variables['levels'][:] + + #read variables from scalar group + scalars_grp = nc_fid.groups['scalars'] + lat = scalars_grp.variables['lat'][:] + lon = scalars_grp.variables['lon'][:] + + #read variables from initial group + initial_grp = nc_fid.groups['initial'] + height = initial_grp.variables['height'][:] + theta_il = initial_grp.variables['thetail'][:] + qt = initial_grp.variables['qt'][:] + ql = initial_grp.variables['ql'][:] + qi = initial_grp.variables['qi'][:] + u = initial_grp.variables['u'][:] + v = initial_grp.variables['v'][:] + tke = initial_grp.variables['tke'][:] + ozone = initial_grp.variables['ozone'][:] + + #read variables from forcing group + forcing_grp = nc_fid.groups['forcing'] + p_surf = forcing_grp.variables['p_surf'][:] + T_surf = forcing_grp.variables['T_surf'][:] + w_ls = forcing_grp.variables['w_ls'][:] + omega = forcing_grp.variables['omega'][:] + u_g = forcing_grp.variables['u_g'][:] + v_g = forcing_grp.variables['v_g'][:] + u_nudge = forcing_grp.variables['u_nudge'][:] + v_nudge = forcing_grp.variables['v_nudge'][:] + T_nudge = forcing_grp.variables['T_nudge'][:] + thil_nudge = forcing_grp.variables['thil_nudge'][:] + qt_nudge = forcing_grp.variables['qt_nudge'][:] + dT_dt_rad = forcing_grp.variables['dT_dt_rad'][:] + h_advec_thil = forcing_grp.variables['h_advec_thetail'][:] + v_advec_thil = forcing_grp.variables['v_advec_thetail'][:] + h_advec_qt = forcing_grp.variables['h_advec_qt'][:] + v_advec_qt = forcing_grp.variables['v_advec_qt'][:] + try: + sh_flux_sfc = forcing_grp.variables['sh_flux_sfc'][:] + except KeyError: + sh_flux_sfc = '' + try: + lh_flux_sfc = forcing_grp.variables['lh_flux_sfc'][:] + except KeyError: + lh_flux_sfc = '' + + nc_fid.close() + + case_data = Case_Data(case_name, missing_value, time, levels, lat, lon, + height, theta_il, qt, ql, qi, u, v, tke, ozone, + p_surf, T_surf, w_ls, omega, u_g, v_g, + u_nudge, v_nudge, T_nudge, thil_nudge, qt_nudge, + dT_dt_rad, h_advec_thil, v_advec_thil, h_advec_qt, + v_advec_qt, sh_flux_sfc, lh_flux_sfc) + + return(case_data, error) + +def write_SCM_case_file(case_nml, case_data, use_area): + """Write all data to a netCDF file in the DEPHY-SCM format""" + + #TODO: need to handle LSM ICs + + # Working types + wp = np.float64 + wi = np.int32 + + # Local switches + forcing_on = 1 + forcing_off = 0 + + nml_filename = os.path.join(CASE_NML_DIR, case_nml['case_config']['case_name'] + '.nml') + + # Output file + com = 'mkdir -p ' + PROCESSED_CASE_DIR + logging.info(com) + os.system(com) + fileOUT = os.path.join(PROCESSED_CASE_DIR, case_nml['case_config']['case_name'] + '_SCM_driver.nc') + + nc_file = Dataset(fileOUT, 'w', format='NETCDF3_CLASSIC') + nc_file.description = "Case data for {} from CCPP SCM".format(case_nml['case_config']['case_name']) + + nc_file.missing_value = case_data._missing_value + + #not all namelists will have minutes, set to 0 if nml doesn't have + try: + minute = case_nml['case_config']['minute'] + except KeyError: + minute = 0 + + start_date = datetime(case_nml['case_config']['year'],case_nml['case_config']['month'],case_nml['case_config']['day'],case_nml['case_config']['hour'],minute,0) + start_date_string = start_date.strftime("%Y-%m-%d %H:%M:%S") + runtime = case_nml['case_config']['runtime'] + delta = timedelta(seconds=runtime) + end_date = start_date + delta + end_date_string = end_date.strftime("%Y-%m-%d %H:%M:%S") + loc_string = str(case_data._lon) + "E" + str(case_data._lat) + "N" + case_string = case_nml['case_config']['case_name'] + '_' + start_date_string + '_' + loc_string + + logging.debug('Case string: {}'.format(case_string)) + logging.debug('Case start date: {}'.format(start_date)) + logging.debug('Case duration: {}'.format(delta)) + logging.debug('Case end date: {}'.format(end_date)) + + if (case_nml['case_config']['sfc_type'] == 0): + surface_string = 'ocean' + elif (case_nml['case_config']['sfc_type'] == 1): + surface_string = 'land' + elif (case_nml['case_config']['sfc_type'] == 2): + surface_string = 'ice' + + + #DEPHY v1 format specifies the global attributes in this order. Some attributes are rewritten below after the order is established in the file. + nc_file.case = case_string + nc_file.title = 'Forcing and Initial Conditions for ' + case_string + nc_file.reference = 'https://dtcenter.org/sites/default/files/paragraph/scm-ccpp-guide-v6-0-0.pdf' + nc_file.author = 'Grant J. Firl and Dustin Swales' + nc_file.version = 'Created on ' + datetime.today().strftime('%Y-%m-%d %H:%M:%S') + nc_file.format_version = 'DEPHY SCM format version 1' + nc_file.modifications = '' + nc_file.script = os.path.basename(__file__) + nc_file.comment = 'converted from ' + case_nml['case_config']['case_name'] + '.nc' + nc_file.start_date = start_date_string + nc_file.end_date = end_date_string + + if (use_area and case_nml['case_config']['column_area']): + nc_file.forcing_scale = case_nml['case_config']['column_area'] + else: + nc_file.forcing_scale = -1 + + nc_file.adv_ta = forcing_off + nc_file.adv_qv = forcing_off + nc_file.adv_ua = forcing_off #no mom_forcing_type implemented this (providing pre-calculated advective terms for u) + nc_file.adv_va = forcing_off #no mom_forcing_type implemented this (providing pre-calculated advective terms for v) + nc_file.adv_theta = forcing_off + nc_file.adv_thetal = forcing_off + nc_file.adv_qt = forcing_off + nc_file.adv_rv = forcing_off + nc_file.adv_rt = forcing_off + nc_file.radiation = "on" #not implemented in CCPP SCM - controlled by CCPP SDF and/or namelist + nc_file.forc_wap = forcing_off + nc_file.forc_wa = forcing_off + nc_file.forc_geo = forcing_off + nc_file.nudging_ua = forcing_off + nc_file.nudging_va = forcing_off + nc_file.nudging_ta = forcing_off + nc_file.nudging_theta = forcing_off + nc_file.nudging_thetal = forcing_off + nc_file.nudging_qv = forcing_off + nc_file.nudging_qt = forcing_off + nc_file.nudging_rv = forcing_off + nc_file.nudging_rt = forcing_off + nc_file.zh_nudging_ta = forcing_off + nc_file.zh_nudging_theta = forcing_off + nc_file.zh_nudging_thetal = forcing_off + nc_file.zh_nudging_qv = forcing_off + nc_file.zh_nudging_qt = forcing_off + nc_file.zh_nudging_rv = forcing_off + nc_file.zh_nudging_rt = forcing_off + nc_file.zh_nudging_ua = forcing_off + nc_file.zh_nudging_va = forcing_off + nc_file.pa_nudging_ta = forcing_off + nc_file.pa_nudging_theta = forcing_off + nc_file.pa_nudging_thetal = forcing_off + nc_file.pa_nudging_qv = forcing_off + nc_file.pa_nudging_qt = forcing_off + nc_file.pa_nudging_rv = forcing_off + nc_file.pa_nudging_rt = forcing_off + nc_file.pa_nudging_ua = forcing_off + nc_file.pa_nudging_va = forcing_off + # + nc_file.surface_type = surface_string + nc_file.surface_forcing_temp = 'none' + nc_file.surface_forcing_moisture = 'none' + nc_file.surface_forcing_wind = 'none' + + #rewrite forc_wa, forc_wap, forc_geo, nudging_ua, nudging_va depending on mom_forcing_type provided in case_config nml + if (case_nml['case_config']['mom_forcing_type'] == 2): + #CCPP SCM proprietery forcing interprets mom_forcing_type = 2 as calculating vertical advective terms from provided vertical velocity AND applying geostrophic winds + + #CCPP SCM proprietery cases could have either w or omega available (or both); use omega by default? + w_ls_avail = True if np.any(case_data._w_ls[:,:]) else False + omega_avail = True if np.any(case_data._omega[:,:]) else False + if omega_avail: + nc_file.forc_wap = forcing_on + nc_file.forc_wa = forcing_off + elif w_ls_avail: + nc_file.forc_wap = forcing_off + nc_file.forc_wa = forcing_on + else: + message = 'The case namelist ({0}) specifies the momentum variables should be forced using vertical velocity (through mom_forcing = 2), but neither w_ls or omega have nonzero values'.format(nml_filename) + logging.info(message) + nc_file.forc_wap = forcing_off + nc_file.forc_wa = forcing_off + #logging.critical(message) + #raise Exception(message) + + geostrophic_avail = True if (np.any(case_data._u_g[:,:]) or np.any(case_data._v_g[:,:])) else False + if geostrophic_avail: + nc_file.forc_geo = forcing_on + else: + message = 'The case namelist ({0}) specifies the momentum variables should be forced using geostrophic winds (through mom_forcing = 2), but neither u_g or v_g have nonzero values'.format(nml_filename) + logging.info(message) + nc_file.forc_geo = forcing_off + #logging.critical(message) + #raise Exception(message) + nc_file.nudging_ua = forcing_off + nc_file.nudging_va = forcing_off + + elif (case_nml['case_config']['mom_forcing_type'] == 3): + #CCPP SCM proprietery forcing interprets mom_forcing_type = 3 as calculating momentum forcing as nudging toward u and v profiles (only) + + nc_file.forc_wa = forcing_off + nc_file.forc_wap = forcing_off + nc_file.forc_geo = forcing_off + + u_nudge_avail = True if np.any(case_data._u_nudge[:,:]) else False + v_nudge_avail = True if np.any(case_data._v_nudge[:,:]) else False + relax_time_avail = True if case_nml['case_config']['relax_time'] else False + if relax_time_avail: + relax_time = case_nml['case_config']['relax_time'] + else: + relax_time = DEFAULT_NUDGING_TIMESCALE + message = 'The case namelist ({0}) specifies the momentum variables should be forced using nudging (through mom_forcing = 3), but relax_time was not provided -- using default value of {1}s '.format(nml_filename, DEFAULT_NUDGING_TIMESCALE) + logging.info(message) + + nc_file.nudging_ua = forcing_on*relax_time + nc_file.nudging_va = forcing_on*relax_time + + if (case_nml['case_config']['thermo_forcing_type'] == 1): + #total advective forcing + radiative heating + nc_file.adv_thetal = forcing_on + nc_file.adv_qt = forcing_on + #nc_file.radiation = 'tend' #radiation isn't turned off in the CCPP SCM through the forcing + elif (case_nml['case_config']['thermo_forcing_type'] == 2): + #horizontal advective forcing + (radiative heating) + vertical velocity + nc_file.adv_thetal = forcing_on + nc_file.adv_qt = forcing_on + #nc_file.radiation = 'tend' #radiation isn't turned off in the CCPP SCM through the forcing + + w_ls_avail = True if np.any(case_data._w_ls[:,:]) else False + omega_avail = True if np.any(case_data._omega[:,:]) else False + if omega_avail: + nc_file.forc_wap = forcing_on + nc_file.forc_wa = forcing_off + elif w_ls_avail: + nc_file.forc_wap = forcing_off + nc_file.forc_wa = forcing_on + else: + message = 'The case namelist ({0}) specifies the thermo variables should be forced using vertical velocity (through thermo_forcing = 2), but neither w_ls or omega have nonzero values'.format(nml_filename) + logging.info(message) + nc_file.forc_wap = forcing_off + nc_file.forc_wa = forcing_off + #logging.critical(message) + #raise Exception(message) + + elif (case_nml['case_config']['thermo_forcing_type'] == 3): + #nudging + vertical velocity + + T_nudge_avail = True if np.any(case_data._T_nudge[:,:]) else False + qt_nudge_avail = True if np.any(case_data._qt_nudge[:,:]) else False + relax_time_avail = True if case_nml['case_config']['relax_time'] else False + if relax_time_avail: + relax_time = case_nml['case_config']['relax_time'] + else: + relax_time = DEFAULT_NUDGING_TIMESCALE + message = 'The case namelist ({0}) specifies the thermo variables should be forced using nudging (through thermo_forcing = 3), but relax_time was not provided -- using default value of {1}s '.format(nml_filename, DEFAULT_NUDGING_TIMESCALE) + logging.info(message) + + nc_file.nudging_ta = forcing_on*relax_time + nc_file.nudging_qt = forcing_on*relax_time + + w_ls_avail = True if np.any(case_data._w_ls[:,:]) else False + omega_avail = True if np.any(case_data._omega[:,:]) else False + if omega_avail: + nc_file.forc_wap = forcing_on + nc_file.forc_wa = forcing_off + elif w_ls_avail: + nc_file.forc_wap = forcing_off + nc_file.forc_wa = forcing_on + else: + message = 'The case namelist ({0}) specifies the thermo variables should be forced using vertical velocity (through thermo_forcing = 2), but neither w_ls or omega have nonzero values'.format(nml_filename) + logging.info(message) + nc_file.forc_wap = forcing_off + nc_file.forc_wa = forcing_off + #logging.critical(message) + #raise Exception(message) + + if (case_nml['case_config']['sfc_flux_spec']): + nc_file.surface_forcing_temp = 'kinematic' + nc_file.surface_forcing_moisture = 'kinematic' + nc_file.surface_forcing_wind = 'z0' + else: + nc_file.surface_forcing_temp = 'ts' + nc_file.surface_forcing_wind = 'z0' + + time_dim = nc_file.createDimension('time', case_data._time.shape[0]) + timei_dim = nc_file.createDimension('t0', 1) + lev_dim = nc_file.createDimension('lev', case_data._levels.shape[0]) + + # + timei_var = nc_file.createVariable('t0', wp, ('t0')) + timei_var.units = 'seconds since ' + start_date_string + timei_var.standard_name = 'Initial time' + timei_var.calendar = 'gregorian' + timei_var[:] = 0.0 + # + timef_var = nc_file.createVariable('time', wp, ('time')) + timef_var.units = 'seconds since ' + start_date_string + timef_var.standard_name = 'Forcing time' + timef_var.calendar = 'gregorian' + timef_var[:] = case_data._time[:] + # + lev_var = nc_file.createVariable('lev', wp, ('lev')) + lev_var.units = 'Pa' + lev_var.standard_name = 'pressure' + lev_var[:] = case_data._levels[:] + + # + lon_var = nc_file.createVariable('lon', wp, ('time')) + lon_var.units = 'degrees_east' + lon_var.standard_name = 'longitude' + lon_var[:] = case_data._lon + + # + lat_var = nc_file.createVariable('lat', wp, ('time')) + lat_var.units = 'degrees_north' + lat_var.standard_name = 'latitude' + lat_var[:] = case_data._lat + + # + thetal_var = nc_file.createVariable('thetal', wp, ('t0','lev')) + thetal_var.units = 'K' + thetal_var.standard_name = 'air_liquid_potential_temperature' + thetal_var[:] = case_data._theta_il[:] + + # + qt_var = nc_file.createVariable('qt', wp, ('t0','lev')) + qt_var.units = 'kg kg-1' + qt_var.standard_name = 'mass_fraction_of_water_in_air' + qt_var[:] = case_data._qt[:] + + # + u_var = nc_file.createVariable('ua', wp, ('t0','lev')) + u_var.units = 'm s-1' + u_var.standard_name = 'eastward_wind' + u_var[:] = case_data._u[:] + + # + v_var = nc_file.createVariable('va', wp, ('t0','lev')) + v_var.units = 'm s-1' + v_var.standard_name = 'northward_wind' + v_var[:] = case_data._v[:] + + # + p_var = nc_file.createVariable('pa', wp, ('t0','lev')) + p_var.units = 'Pa' + p_var.standard_name = 'air_pressure' + p_var[:] = case_data._levels[:] + + # + z_var = nc_file.createVariable('zh', wp, ('t0','lev')) + z_var.units = 'm' + z_var.standard_name = 'height' + z_var[:] = case_data._height[:] + + # + ps_var = nc_file.createVariable('ps', wp, ('t0')) + ps_var.units = 'Pa' + ps_var.standard_name = 'surface_air_pressure' + ps_var[:] = case_data._p_surf[0] + + # + ql_var = nc_file.createVariable('ql', wp, ('t0','lev')) + ql_var.units = 'kg kg-1' + ql_var.standard_name = 'mass_fraction_of_cloud_liquid_water_in_air' + ql_var[:] = case_data._ql[:] + + # + qi_var = nc_file.createVariable('qi', wp, ('t0','lev')) + qi_var.units = 'kg kg-1' + qi_var.standard_name = 'mass_fraction_of_cloud_ice_water_in_air' + qi_var[:] = case_data._qi[:] + + # + tke_var = nc_file.createVariable('tke', wp, ('t0','lev')) + tke_var.units = 'm2 s-2' + tke_var.standard_name = 'specific_turbulent_kinetic_energy' + tke_var[:] = case_data._tke[:] + + # + ozone_var = nc_file.createVariable('o3', wp, ('t0','lev')) + ozone_var.units = 'kg kg-1' + ozone_var.standard_name = 'mole_fraction_of_ozone_in_air' + ozone_var[:] = case_data._ozone[:] + + if (nc_file.adv_ta == forcing_on): + message = 'adv_ta is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.' + logging.critical() + raise Exception(message) + # tnta_adv_var = nc_file.createVariable('tnta_adv', wp, ('time','lev')) + # tnta_adv_var.units = 'K s-1' + # tnta_adv_var.standard_name = 'tendency_of_air_temperature_due_to_advection' + # tnta_adv_var[:] = np.swapaxes(case_data._tnta_adv[:],0,1) + + if (nc_file.adv_qv == forcing_on): + message = 'adv_qv is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.' + logging.critical() + raise Exception(message) + # tnqv_adv_var = nc_file.createVariable('tnqv_adv', wp, ('time','lev')) + # tnqv_adv_var.units = 'kg kg-1 s-1' + # tnqv_adv_var.standard_name = 'tendency_of_specific_humidity_due_to_advection' + # tnqv_adv_var[:] = np.swapaxes(case_data._tnqv_adv[:],0,1) + + if (nc_file.adv_ua == forcing_on): + message = 'adv_ua is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.' + logging.critical() + raise Exception(message) + # tnua_adv_var = nc_file.createVariable('tnua_adv', wp, ('time','lev')) + # tnua_adv_var.units = 'm s-2' + # tnua_adv_var.standard_name = 'tendency_of_eastward_wind_due_to_advection' + # tnua_adv_var[:] = np.swapaxes(case_data._tnua_adv[:],0,1) + + if (nc_file.adv_va == forcing_on): + message = 'adv_va is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.' + logging.critical() + raise Exception(message) + # tnva_adv_var = nc_file.createVariable('tnva_adv', wp, ('time','lev')) + # tnva_adv_var.units = 'm s-2' + # tnva_adv_var.standard_name = 'tendency_of_northward_wind_due_to_advection' + # tnva_adv_var[:] = np.swapaxes(case_data._tnva_adv[:],0,1) + + if (nc_file.adv_theta == forcing_on): + message = 'adv_theta is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.' + logging.critical() + raise Exception(message) + # tntheta_adv_var = nc_file.createVariable('tntheta_adv', wp, ('time','lev')) + # tntheta_adv_var.units = 'K s-1' + # tntheta_adv_var.standard_name = 'tendency_of_air_potential_temperature_due_to_advection' + # tntheta_adv_var[:] = np.swapaxes(case_data._tntheta_adv[:],0,1) + + if (nc_file.adv_thetal == forcing_on): + tnthetal_adv_var = nc_file.createVariable('tnthetal_adv', wp, ('time','lev')) + tnthetal_adv_var.units = 'K s-1' + tnthetal_adv_var.standard_name = 'tendency_of_air_liquid_potential_temperature_due_to_advection' + tnthetal_adv_var[:] = np.swapaxes(case_data._h_advec_thil[:] + case_data._v_advec_thil[:],0,1) + + if (nc_file.adv_qt == forcing_on): + tnqt_adv_var = nc_file.createVariable('tnqt_adv', wp, ('time','lev')) + tnqt_adv_var.units = 'kg kg-1 s-1' + tnqt_adv_var.standard_name = 'tendency_of_mass_fraction_of_water_in_air_due_to_advection' + tnqt_adv_var[:] = np.swapaxes(case_data._h_advec_qt[:] + case_data._v_advec_qt[:],0,1) + + if (nc_file.adv_rv == forcing_on): + message = 'adv_rv is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.' + logging.critical() + raise Exception(message) + # tnrv_adv_var = nc_file.createVariable('tnrv_adv', wp, ('time','lev')) + # tnrv_adv_var.units = 'kg kg-1 s-1' + # tnrv_adv_var.standard_name = 'tendency_of_humidity_mixing_ratio_due_to_advection' + # tnrv_adv_var[:] = np.swapaxes(case_data._tnrv_adv[:],0,1) + + if (nc_file.adv_rt == forcing_on): + message = 'adv_rt is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.' + logging.critical() + raise Exception(message) + # tnrt_adv_var = nc_file.createVariable('tnrt_adv', wp, ('time','lev')) + # tnrt_adv_var.units = 'kg kg-1 s-1' + # tnrt_adv_var.standard_name = 'tendency_of_water_mixing_ratio_due_to_advection' + # tnrt_adv_var[:] = np.swapaxes(case_data._tnrt_adv[:],0,1) + + if (nc_file.forc_wap == forcing_on): + wap_var = nc_file.createVariable('wap', wp, ('time','lev')) + wap_var.units = 'Pa s-1' + wap_var.standard_name = 'lagrangian_tendency_of_air_pressure' + wap_var[:] = np.swapaxes(case_data._omega[:],0,1) + elif (nc_file.forc_wa == forcing_on): + wa_var = nc_file.createVariable('wa', wp, ('time','lev')) + wa_var.units = 'm s-1' + wa_var.standard_name = 'upward_air_velocity' + wa_var[:] = np.swapaxes(case_data._w_ls[:],0,1) + + if (nc_file.forc_geo == forcing_on): + ug_var = nc_file.createVariable('ug', wp, ('time','lev')) + ug_var.units = 'm s-1' + ug_var.standard_name = 'geostrophic_eastward_wind' + ug_var[:] = np.swapaxes(case_data._u_g[:],0,1) + + vg_var = nc_file.createVariable('vg', wp, ('time','lev')) + vg_var.units = 'm s-1' + vg_var.standard_name = 'geostrophic_northward_wind' + vg_var[:] = np.swapaxes(case_data._v_g[:],0,1) + + if (nc_file.nudging_ua == forcing_on): + ua_nud_var = nc_file.createVariable('ua_nud', wp, ('time','lev')) + ua_nud_var.units = 'm s-1' + ua_nud_var.standard_name = 'nudging_eastward_wind' + ua_nud_var[:] = np.swapaxes(case_data._u_nudge[:],0,1) + + if (nc_file.nudging_va == forcing_on): + va_nud_var = nc_file.createVariable('va_nud', wp, ('time','lev')) + va_nud_var.units = 'm s-1' + va_nud_var.standard_name = 'nudging_northward_wind' + va_nud_var[:] = np.swapaxes(case_data._v_nudge[:],0,1) + + if (nc_file.nudging_ta == forcing_on): + ta_nud_var = nc_file.createVariable('ta_nud', wp, ('time','lev')) + ta_nud_var.units = 'K' + ta_nud_var.standard_name = 'nudging_air_temperature' + ta_nud_var[:] = np.swapaxes(case_data._T_nudge[:],0,1) + + if (nc_file.nudging_qt == forcing_on): + qt_nud_var = nc_file.createVariable('qt_nud', wp, ('time','lev')) + qt_nud_var.units = 'kg kg-1' + qt_nud_var.standard_name = 'nudging_mass_fraction_of_water_in_air' + qt_nud_var[:] = np.swapaxes(case_data._qt_nudge[:],0,1) + + nc_file.close() + + return(fileOUT) + +def write_SCM_nml_file(case_nml): + filename = os.path.join(CASE_NML_DIR, case_nml['case_config']['case_name'] + '_dephy.nml') + + #Go through existing case namelist and only add necessary items to new DEPHY-based namelist + + #add _dephy to case (temporary - to differentiate from old format case) + int_dict = {'case_name':case_nml['case_config']['case_name']+'_dephy', + 'input_type':1} + + nml_keys = case_nml['case_config'].todict().keys() + if ('npz_type' in nml_keys): + int_dict['npz_type'] = case_nml['case_config']['npz_type'] + if int_dict['npz_type'] == 'input' and 'vert_coord_file' in nml_keys: + int_dict['vert_coord_file'] = case_nml['case_config']['vert_coord_file'] + + if ('dt' in nml_keys): + int_dict['dt'] = case_nml['case_config']['dt'] + + #runtime is in netCDF file + + if ('output_dir' in nml_keys): + int_dict['output_dir'] = case_nml['case_config']['output_dir'] + + if ('model_ics' in nml_keys): + int_dict['model_ics'] = case_nml['case_config']['model_ics'] + + if ('lsm_ics' in nml_keys): + int_dict['lsm_ics'] = case_nml['case_config']['lsm_ics'] + + if ('do_spinup' in nml_keys): + int_dict['do_spinup'] = case_nml['case_config']['do_spinup'] + + if ('spinup_timesteps' in nml_keys): + int_dict['spinup_timesteps'] = case_nml['case_config']['spinup_timesteps'] + + if ('C_RES' in nml_keys): + int_dict['C_RES'] = case_nml['case_config']['C_RES'] + + #relax_time is in netCDF file + + #sfc_type is in netCDF file + + #sfc_flux_spec is in netCDF file + + if ('sfc_roughness_length_cm' in nml_keys): + int_dict['sfc_roughness_length_cm'] = case_nml['case_config']['sfc_roughness_length_cm'] + + if ('reference_profile_choice' in nml_keys): + int_dict['reference_profile_choice'] = case_nml['case_config']['reference_profile_choice'] + + if ('column_area' in nml_keys): + int_dict['column_area'] = case_nml['case_config']['column_area'] + + nml_dict = {'case_config':int_dict} + + nml = f90nml.namelist.Namelist(nml_dict) + + #print(nml) + nml.write(filename) + + return(filename) + +######################################################################################## +# +######################################################################################## +def write_SCM_case_file_UFS(state, surface, oro, forcing, case, date, vertical_forcing): + """Write all data to a netCDF file in the DEPHY-SCM format""" + + # Working types + wp = np.float64 + wi = np.int32 + + # Local switches + forcing_on = 1 + forcing_off = 0 + + # Output file + com = 'mkdir -p ' + PROCESSED_CASE_DIR + print(com) + os.system(com) + fileOUT = os.path.join(PROCESSED_CASE_DIR, case + '_SCM_driver.nc') + + nc_file = Dataset(fileOUT, 'w', format='NETCDF3_CLASSIC') + nc_file.description = "FV3GFS model profile input (UFS forcings)" + + nc_file.missing_value = missing_value + + start_date = datetime(date["year"],date["month"],date["day"],date["hour"],date["minute"],date["second"]) + + # + # Create surface type string (Saved as GLOBAL attribute) + # + if surface["slmsk"] > 1.5: + surface_string = 'ice' + elif surface["slmsk"] > 0.5: + surface_string = 'land' + else: + surface_string = 'ocean' + + # + # Global file attributes. + # + runtime = timedelta(seconds=forcing['time'][-1]) + end_date = start_date + runtime + end_date_string = end_date.strftime("%Y-%m-%d %H:%M:%S") + start_date_string = start_date.strftime("%Y-%m-%d %H:%M:%S") + # + loc_string = str(round(surface["lon"],2)) + "E" + str(round(surface["lat"],2)) + "N" + case_string = 'UFS_' + start_date_string + '_' + loc_string + # + nc_file.case = case_string + nc_file.title = 'Forcing and Initial Conditions for ' + case_string + nc_file.reference = 'https://dtcenter.org/sites/default/files/paragraph/scm-ccpp-guide-v6-0-0.pdf' + nc_file.author = 'Grant J. Firl and Dustin Swales' + nc_file.version = 'Created on ' + datetime.today().strftime('%Y-%m-%d %H:%M:%S') + nc_file.format_version = 'DEPHY SCM format version 1' + nc_file.modifications = '' + nc_file.script = os.path.basename(__file__) + nc_file.comment = '' + nc_file.start_date = start_date_string + nc_file.end_date = end_date_string + nc_file.forcing_scale = -1 + nc_file.radiation = "off" + nc_file.adv_ta = forcing_off + nc_file.adv_qv = forcing_off + nc_file.adv_ua = forcing_off + nc_file.adv_va = forcing_off + nc_file.adv_theta = forcing_off + nc_file.adv_thetal = forcing_off + nc_file.adv_qt = forcing_off + nc_file.adv_rv = forcing_off + nc_file.adv_rt = forcing_off + if (vertical_forcing == 2): + nc_file.forc_wa = forcing_on + else: + nc_file.forc_wa = forcing_off + nc_file.forc_wap = forcing_off + nc_file.forc_geo = forcing_off + nc_file.nudging_ua = forcing_off + nc_file.nudging_va = forcing_off + nc_file.nudging_ta = forcing_off + nc_file.nudging_theta = forcing_off + nc_file.nudging_thetal = forcing_off + nc_file.nudging_qv = forcing_off + nc_file.nudging_qt = forcing_off + nc_file.nudging_rv = forcing_off + nc_file.nudging_rt = forcing_off + nc_file.zh_nudging_ta = forcing_off + nc_file.zh_nudging_theta = forcing_off + nc_file.zh_nudging_thetal = forcing_off + nc_file.zh_nudging_qv = forcing_off + nc_file.zh_nudging_qt = forcing_off + nc_file.zh_nudging_rv = forcing_off + nc_file.zh_nudging_rt = forcing_off + nc_file.zh_nudging_ua = forcing_off + nc_file.zh_nudging_va = forcing_off + nc_file.pa_nudging_ta = forcing_off + nc_file.pa_nudging_theta = forcing_off + nc_file.pa_nudging_thetal = forcing_off + nc_file.pa_nudging_qv = forcing_off + nc_file.pa_nudging_qt = forcing_off + nc_file.pa_nudging_rv = forcing_off + nc_file.pa_nudging_rt = forcing_off + nc_file.pa_nudging_ua = forcing_off + nc_file.pa_nudging_va = forcing_off + # + nc_file.surface_type = surface_string + # + nc_file.adv_ta = forcing_on + nc_file.adv_qv = forcing_on + nc_file.adv_ua = forcing_on + nc_file.adv_va = forcing_on + # + nc_file.surface_forcing_temp = 'none' + nc_file.surface_forcing_moisture = 'none' + nc_file.surface_forcing_wind = 'none' + nc_file.surface_forcing_lsm = 'none' #'noah' #'noahmp' #'ruc' + nc_file.surface_forcing_lsm = 'lsm' + # Set file dimension + time_dim = nc_file.createDimension('time', len(forcing['time'])) + timei_dim = nc_file.createDimension('t0', 1) + lev_dim = nc_file.createDimension('lev', state["nlevs"]) + soil_dim = nc_file.createDimension('nsoil', len(surface["stc"])) + snow_dim = nc_file.createDimension('nsnow', len(surface["snicexy"])) + nslsnw_dim = nc_file.createDimension('nsoil_plus_nsnow',len(surface["snicexy"]) + len(surface["stc"])) + ice_dim = nc_file.createDimension('nice', len(surface["tiice"])) + + # + timei_var = nc_file.createVariable('t0', wp, ('t0')) + timei_var.units = 'seconds since ' + start_date_string + timei_var.standard_name = 'Initial time' + timei_var.calendar = 'gregorian' + timei_var[:] = 0.0 + # + timef_var = nc_file.createVariable('time', wp, ('time')) + timef_var.units = 'seconds since ' + start_date_string + timef_var.standard_name = 'Forcing time' + timef_var.calendar = 'gregorian' + timef_var[:] = forcing['time'] + # + lev_var = nc_file.createVariable('lev', wp, ('lev')) + lev_var.units = 'm' + lev_var.standard_name = 'height' + lev_var[:] = 0.0 + + # + lon_var = nc_file.createVariable('lon', wp, ('time')) + lon_var.units = 'degrees_east' + lon_var.standard_name = 'longitude' + lon_var[:] = surface["lon"] + + # + lat_var = nc_file.createVariable('lat', wp, ('time')) + lat_var.units = 'degrees_north' + lat_var.standard_name = 'latitude' + lat_var[:] = surface["lat"] + + # + soil_depth_var = nc_file.createVariable('soil_depth', wp, ('nsoil')) + soil_depth_var.units = 'm' + soil_depth_var.standard_name = 'depth of bottom of soil layers' + soil_depth_var[:] = [0.1,0.4,1.0,2.0] + # + theta_oro = nc_file.createVariable('theta_oro',wp, ('t0')) + theta_oro.units = "deg" + theta_oro.standard_name = "angle with respect to east of maximum subgrid orographic variations" + theta_oro[:] = oro["theta"] + # + z0_var = nc_file.createVariable('zorl', wp, ('time')) + z0_var.units = "cm" + z0_var.standard_name = 'surface_roughness_length_for_momentum_in_air' + z0_var[:] = surface["z0"] + # + zorlw_var = nc_file.createVariable('zorlw', wp, ('t0')) + zorlw_var.units = "cm" + zorlw_var.standard_name = "surface roughness length over ocean" + zorlw_var[:] = surface["z0"] + # + zorll_var = nc_file.createVariable('zorll', wp, ('t0')) + zorll_var.units = "cm" + zorll_var.standard_name = "surface roughness length over land" + zorll_var[:] = surface["zorll"] + # + zorli_var = nc_file.createVariable('zorli', wp, ('t0')) + zorli_var.units = "cm" + zorli_var.standard_name = "surface roughness length over ice" + zorli_var[:] = surface["zorli"] + # + zorlwav_var = nc_file.createVariable('zorlwav', wp, ('time')) + zorlwav_var.units = "cm" + zorlwav_var.standard_name = 'surface_roughness_length_from_wave_model' + zorlwav_var[:] = surface["zorlw"] + + # + # Variables to be output to SCM input file. Only fields that come directly from forcing, + # surface, state, and oro. Fields that get renamed are done above. + # + dict = {} + dict.update(date) + dict.update(surface) + dict.update(state) + dict.update(oro) + dict.update(forcing) + + ######################################################################################## + # + # Dictonary format: + # {"name": "", "type", "dimd": (), "units": "", "desc": ""} + # + ######################################################################################## + var_dict = [{"name": "orog", "type":wp, "dimd": ('t0' ), "units": "m", "desc": "surface_altitude"},\ + {"name": "zh", "type":wp, "dimd": ('t0', 'lev'), "units": "m", "desc": "height"},\ + {"name": "pa", "type":wp, "dimd": ('t0', 'lev'), "units": "Pa", "desc": "air_pressure"}, \ + {"name": "ta", "type":wp, "dimd": ('t0', 'lev'), "units": "K", "desc": "air_temperature"}, \ + {"name": "theta", "type":wp, "dimd": ('t0', 'lev'), "units": "K", "desc": "air_potential_temperature"}, \ + {"name": "thetal", "type":wp, "dimd": ('t0', 'lev'), "units": "K", "desc": "air_liquid_potential_temperature"}, \ + {"name": "rv", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "humidity_mixing_ratio"}, \ + {"name": "rl", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "cloud_liquid_water_mixing_ratio"}, \ + {"name": "ri", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "cloud_ice_water_mixing_ratio"}, \ + {"name": "rt", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "water_mixing_ratio"}, \ + {"name": "qv", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "specific_humidity"}, \ + {"name": "ql", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "mass_fraction_of_cloud_liquid_water_in_air"}, \ + {"name": "qi", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "mass_fraction_of_cloud_ice_water_in_air", "default_value": 0.0}, \ + {"name": "qt", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "mass_fraction_of_water_in_air"}, \ + {"name": "hur", "type":wp, "dimd": ('t0', 'lev'), "units": "%", "desc": "relative_humidity"}, \ + {"name": "tke", "type":wp, "dimd": ('t0', 'lev'), "units": "m2 s-2", "desc": "specific_turbulen_kinetic_energy", "default_value": 0.0}, \ + {"name": "ua", "type":wp, "dimd": ('t0', 'lev'), "units": "m s-1", "desc": "eastward_wind"}, \ + {"name": "va", "type":wp, "dimd": ('t0', 'lev'), "units": "m s-1", "desc": "northward_wind"}, \ + {"name": "ts", "type":wp, "dimd": ('t0' ), "units": "K", "desc": "surface_temperature"},\ + {"name": "tskin", "type":wp, "dimd": ('t0' ), "units": "K", "desc": "surface_skin_temperature"}, \ + {"name": "ps", "type":wp, "dimd": ('t0' ), "units": "Pa", "desc": "surface_air_pressure"}, \ + {"name": "beta", "type":wp, "dimd": ('t0' ), "units": "m", "desc": "soil_water_stress_factor"}, \ + {"name": "mrsos", "type":wp, "dimd": ('t0' ), "units": "kg m-2", "desc": "mass_content_of_water_in_soil_layer"}, \ + {"name": "o3", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "mole_fraction_of_ozone_in_air"}, \ + {"name": "sza", "type":wp, "dimd": ('t0' ), "units": "degree", "desc": "solar_zenith_angle"}, \ + {"name": "io", "type":wp, "dimd": ('t0' ), "units": "W m-2", "desc": "solar_irradiance"}, \ + {"name": "alb", "type":wp, "dimd": ('t0' ), "units": "1", "desc": "surface_albedo"}, \ + {"name": "emis", "type":wp, "dimd": ('t0' ), "units": "1", "desc": "surface_longwave_emissivity"}, \ + {"name": "slmsk", "type":wp, "dimd": ('t0' ), "units": "none", "desc": "land_sea_ice_mask"}] + # + var_frc = [{"name": "zh_forc", "type":wp, "dimd": ('time', 'lev'), "units": "m", "desc": "height_forcing","default_value": 1.},\ + {"name": "pa_forc", "type":wp, "dimd": ('time', 'lev'), "units": "Pa", "desc": "air_pressure_forcing"}, \ + {"name": "wa", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "upward_air_velocity"}, \ + {"name": "wap", "type":wp, "dimd": ('time', 'lev'), "units": "Pa s-1", "desc": "lagrangian_tendency_of_air_pressure"}, \ + {"name": "ug", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "geostrophic_eastward_wind"}, \ + {"name": "vg", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "geostrophic_northward_wind"}, \ + {"name": "tnua_adv", "type":wp, "dimd": ('time', 'lev'), "units": "m s-2", "desc": "tendency_of_eastward_wind_due_to_advection"},\ + {"name": "tnva_adv", "type":wp, "dimd": ('time', 'lev'), "units": "m s-2", "desc": "tendency_of_northward_wind_due_to_advection"}, \ + {"name": "tnta_adv", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_air_temperature_due_to_advection"}, \ + {"name": "tntheta_adv", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_air_potential_temperature_due_to_advection"}, \ + {"name": "tnthetal_adv", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_air_liquid_potential_temperature_due_to_advection"}, \ + {"name": "tnqv_adv", "type":wp, "dimd": ('time', 'lev'), "units": "kg kg-1 s-1", "desc": "tendency_of_specific_humidity_due_to_advection"},\ + {"name": "tnqt_adv", "type":wp, "dimd": ('time', 'lev'), "units": "kg kg-1 s-1", "desc": "tendency_of_mass_fraction_of_water_in_air_due_to_advection"},\ + {"name": "tnrv_adv", "type":wp, "dimd": ('time', 'lev'), "units": "kg kg-1 s-1", "desc": "tendency_of_humidity_mixing_ratio_due_to_advection"},\ + {"name": "tnrt_adv", "type":wp, "dimd": ('time', 'lev'), "units": "kg kg-1 s-1", "desc": "tendency_of_water_mixing_ratio_due_to_advection"},\ + {"name": "tnta_rad", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_air_temperature_due_to_radiative_heating"}, \ + {"name": "tntheta_rad", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_potential_air_temperature_due_to_radiative_heating"}, \ + {"name": "tnthetal_rad", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_air_liquid_potential_temperature_due_to_radiative_heating"}, \ + {"name": "ta_nud", "type":wp, "dimd": ('time', 'lev'), "units": "K", "desc": "nudging_air_temperature"}, \ + {"name": "theta_nud", "type":wp, "dimd": ('time', 'lev'), "units": "K", "desc": "nudging_air_potential_temperature"}, \ + {"name": "thetal_nud", "type":wp, "dimd": ('time', 'lev'), "units": "K", "desc": "nudging_air_liquid_potential_temperature"}, \ + {"name": "qt_nud", "type":wp, "dimd": ('time', 'lev'), "units": "kg kg-1", "desc": "nudging_mass_fraction_of_water_in_air"}, \ + {"name": "rv_nud", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "nudging_humidity_mixing_ratio"}, \ + {"name": "rt_nud", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "nudging_water_mixing_ratio"}, \ + {"name": "ua_nud", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "nudging_eastward_wind"}, \ + {"name": "va_nud", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "nudging_northward_wind"}, \ + {"name": "hfss", "type":wp, "dimd": ('time' ), "units": "W m-2", "desc": "surface_upward_sensible_heat_flux"}, \ + {"name": "hfls", "type":wp, "dimd": ('time' ), "units": "W m-2", "desc": "surface_upward_latent_heat_flux"}, \ + {"name": "wpthetap_s", "type":wp, "dimd": ('time' ), "units": "K m s-1", "desc": "surface_upward_potential_temperature_flux"}, \ + {"name": "wpqvp_s", "type":wp, "dimd": ('time' ), "units": "m s-1", "desc": "surface_upward_specific_humidity_flux"}, \ + {"name": "wpqtp_s", "type":wp, "dimd": ('time' ), "units": "m s-1", "desc": "surface_upward_water_mass_fraction_flux"}, \ + {"name": "wprvp_s", "type":wp, "dimd": ('time' ), "units": "m s-1", "desc": "surface_upward_humidity_mixing_ratio_flux"}, \ + {"name": "wprtp_s", "type":wp, "dimd": ('time' ), "units": "m s-1", "desc": "surface_upward_water_mixing_ratio_flux"}, \ + {"name": "ts_forc", "type":wp, "dimd": ('time' ), "units": "K", "desc": "forcing_surface_temperature"},\ + {"name": "ps_forc", "type":wp, "dimd": ('time' ), "units": "Pa", "desc": "forcing_surface_air_pressure"},\ + {"name": "uustar", "type":wp, "dimd": ('time' ), "units": "m s-1", "desc": "surface_friction_velocity"}, \ + {"name": "z0h", "type":wp, "dimd": ('time' ), "units": "m", "desc": "surface_roughness_length_for_heat_in_air"}, \ + {"name": "z0q", "type":wp, "dimd": ('time' ), "units": "m", "desc": "surface_roughness_length_for_humidity_in_air"}, \ + {"name": "mrsos_forc", "type":wp, "dimd": ('time' ), "units": "kg m-2", "desc": "forcing_mass_content_of_water_in_soil_layer"}] + + # + var_oro = [{"name": "area", "type":wp, "dimd": ('t0'), "units": "m2", "desc": "grid_cell_area"},\ + {"name": "stddev", "type":wp, "dimd": ('t0'), "units": "m", "desc": "standard deviation of subgrid orography"}, \ + {"name": "convexity", "type":wp, "dimd": ('t0'), "units": "none", "desc": "convexity of subgrid orography"}, \ + {"name": "oa1", "type":wp, "dimd": ('t0'), "units": "none", "desc": "assymetry of subgrid orography 1"}, \ + {"name": "oa2", "type":wp, "dimd": ('t0'), "units": "none", "desc": "assymetry of subgrid orography 2"}, \ + {"name": "oa3", "type":wp, "dimd": ('t0'), "units": "none", "desc": "assymetry of subgrid orography 3"}, \ + {"name": "oa4", "type":wp, "dimd": ('t0'), "units": "none", "desc": "assymetry of subgrid orography 4"}, \ + {"name": "ol1", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of grid box with subgrid orography higher than critical height 1"}, \ + {"name": "ol2", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of grid box with subgrid orography higher than critical height 2"}, \ + {"name": "ol3", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of grid box with subgrid orography higher than critical height 3"}, \ + {"name": "ol4", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of grid box with subgrid orography higher than critical height 4"}, \ + {"name": "sigma", "type":wp, "dimd": ('t0'), "units": "none", "desc": "slope of subgrid orography"}, \ + {"name": "gamma", "type":wp, "dimd": ('t0'), "units": "none", "desc": "anisotropy of subgrid orography"}, \ + {"name": "elvmax", "type":wp, "dimd": ('t0'), "units": "m", "desc": "maximum of subgrid orography"}, \ + {"name": "oro", "type":wp, "dimd": ('t0'), "units": "m", "desc": "orography"}, \ + {"name": "oro_uf", "type":wp, "dimd": ('t0'), "units": "m", "desc": "unfiltered orography"}, \ + {"name": "landfrac", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of horizontal grid area occupied by land"}, \ + {"name": "lakefrac", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of horizontal grid area occupied by lake", "default_value":0}, \ + {"name": "lakedepth", "type":wp, "dimd": ('t0'), "units": "none", "desc": "lake depth", "default_value":0}] + # + var_nsst = [{"name": "tref", "type":wp, "dimd": ('t0'), "units": "K", "desc": "sea surface reference temperature for NSST"}, \ + {"name": "z_c", "type":wp, "dimd": ('t0'), "units": "m", "desc": "sub-layer cooling thickness for NSST"}, \ + {"name": "c_0", "type":wp, "dimd": ('t0'), "units": "none", "desc": "coefficient 1 to calculate d(Tz)/d(Ts) for NSST"}, \ + {"name": "c_d", "type":wp, "dimd": ('t0'), "units": "nonw", "desc": "coefficient 2 to calculate d(Tz)/d(Ts) for NSST"}, \ + {"name": "w_0", "type":wp, "dimd": ('t0'), "units": "none", "desc": "coefficient 3 to calculate d(Tz)/d(Ts) for NSST"}, \ + {"name": "w_d", "type":wp, "dimd": ('t0'), "units": "none", "desc": "coefficient 4 to calculate d(Tz)/d(Ts) for NSST"}, \ + {"name": "xt", "type":wp, "dimd": ('t0'), "units": "K m", "desc": "heat content in diurnal thermocline layer for NSST"}, \ + {"name": "xs", "type":wp, "dimd": ('t0'), "units": "ppt m", "desc": "salinity content in diurnal thermocline layer for NSST"}, \ + {"name": "xu", "type":wp, "dimd": ('t0'), "units": "m2 s-1", "desc": "u-current in diurnal thermocline layer for NSST"}, \ + {"name": "xv", "type":wp, "dimd": ('t0'), "units": "m2 s-1", "desc": "v-current in diurnal thermocline layer for NSST"}, \ + {"name": "xz", "type":wp, "dimd": ('t0'), "units": "m", "desc": "thickness of diurnal thermocline layer for NSST"}, \ + {"name": "zm" , "type":wp, "dimd": ('t0'), "units": "m", "desc": "thickness of ocean mixed layer for NSST"}, \ + {"name": "xtts", "type":wp, "dimd": ('t0'), "units": "m", "desc": "sensitivity of diurnal thermocline layer heat content to surface temperature [d(xt)/d(ts)] for NSST"},\ + {"name": "xzts", "type":wp, "dimd": ('t0'), "units": "m K-1", "desc": "sensitivity of diurnal thermocline layer thickness to surface temperature [d(xz)/d(ts)] for NSST"}, \ + {"name": "d_conv", "type":wp, "dimd": ('t0'), "units": "m", "desc": "thickness of free convection layer for NSST"}, \ + {"name": "ifd", "type":wp, "dimd": ('t0'), "units": "none", "desc": "index to start DTM run for NSST"}, \ + {"name": "dt_cool", "type":wp, "dimd": ('t0'), "units": "K", "desc": "sub-layer cooling amount for NSST"}, \ + {"name": "qrain", "type":wp, "dimd": ('t0'), "units": "W m-2", "desc": "sensible heat due to rainfall for NSST"}] + # + var_frgd = [{"name": "tiice", "type":wp, "dimd": ('t0','nice'), "units": "K", "desc": "sea ice internal temperature"}] + # + var_noah = [{"name": "vegsrc", "type":wi, "dimd": ('t0'), "units": "none", "desc": "vegetation source (1-2)", "default_value": 1}, \ + {"name": "tsfco", "type":wp, "dimd": ('t0'), "units": "K", "desc": "sea/skin/ice surface temperature"}, \ + {"name": "weasd", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "water equivalent accumulated snow depth"}, \ + {"name": "tg3", "type":wp, "dimd": ('t0'), "units": "K", "desc": "deep soil temperature"}, \ + {"name": "alvsf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "60 degree vis albedo with strong cosz dependency"}, \ + {"name": "alnsf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "60 degree nir albedo with strong cosz dependency"}, \ + {"name": "alvwf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "60 degree vis albedo with weak cosz dependency"}, \ + {"name": "alnwf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "60 degree nir albedo with weak cosz dependency"}, \ + {"name": "facsf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fractional coverage with strong cosz dependency"}, \ + {"name": "facwf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fractional coverage with weak cosz dependency"}, \ + {"name": "vegfrac", "type":wp, "dimd": ('t0'), "units": "none", "desc": "vegetation fraction"}, \ + {"name": "canopy", "type":wp, "dimd": ('t0'), "units": "kg m-2", "desc": "amount of water stored in canopy"}, \ + {"name": "f10m", "type":wp, "dimd": ('t0'), "units": "none", "desc": "ratio of sigma level 1 wind and 10m wind"}, \ + {"name": "t2m", "type":wp, "dimd": ('t0'), "units": "K", "desc": "2-meter absolute temperature"}, \ + {"name": "q2m", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "2-meter specific humidity"}, \ + {"name": "vegtyp", "type":wi, "dimd": ('t0'), "units": "none", "desc": "vegetation type (1-12)"}, \ + {"name": "soiltyp", "type":wi, "dimd": ('t0'), "units": "none", "desc": "soil type (1-12)"}, \ + {"name": "scolor", "type":wp, "dimd": ('t0'), "units": "none", "desc": "soil color"}, \ + {"name": "ffmm", "type":wp, "dimd": ('t0'), "units": "none", "desc": "Monin-Obukhov similarity function for momentum"}, \ + {"name": "ffhh", "type":wp, "dimd": ('t0'), "units": "none", "desc": "Monin-Obukhov similarity function for heat"}, \ + {"name": "hice", "type":wp, "dimd": ('t0'), "units": "m", "desc": "sea ice thickness"}, \ + {"name": "fice", "type":wp, "dimd": ('t0'), "units": "none", "desc": "ice fraction"}, \ + {"name": "tisfc", "type":wp, "dimd": ('t0'), "units": "K", "desc": "ice surface temperature"}, \ + {"name": "tprcp", "type":wp, "dimd": ('t0'), "units": "m", "desc": "instantaneous total precipitation amount"}, \ + {"name": "srflag", "type":wp, "dimd": ('t0'), "units": "none", "desc": "snow/rain flag for precipitation"}, \ + {"name": "snowd", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "water equivalent snow depth"}, \ + {"name": "shdmin", "type":wp, "dimd": ('t0'), "units": "none", "desc": "minimum vegetation fraction"}, \ + {"name": "shdmax", "type":wp, "dimd": ('t0'), "units": "none", "desc": "maximum vegetation fraction"}, \ + {"name": "slopetyp", "type":wi, "dimd": ('t0'), "units": "none", "desc": "slope type (1-9)"}, \ + {"name": "snoalb", "type":wp, "dimd": ('t0'), "units": "none", "desc": "maximum snow albedo"}, \ + {"name": "sncovr", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface snow area fraction"}, \ + {"name": "tsfcl", "type":wp, "dimd": ('t0'), "units": "K", "desc": "surface skin temperature over land"}, \ + {"name": "stc", "type":wp, "dimd": ('t0','nsoil'), "units": "K", "desc": "initial profile of soil liquid moisture"}, \ + {"name": "smc", "type":wp, "dimd": ('t0','nsoil'), "units": "kg", "desc": "initial profile of soil moisture"}, \ + {"name": "slc", "type":wp, "dimd": ('t0','nsoil'), "units": "kg", "desc": "initial profile of soil temperature"}] + # + var_noahmp=[{"name": "tvxy", "type":wp, "dimd": ('t0'), "units": "K", "desc": "vegetation temperature for NoahMP"}, \ + {"name": "tgxy", "type":wp, "dimd": ('t0'), "units": "K", "desc": "ground temperature for NoahMP"}, \ + {"name": "tahxy", "type":wp, "dimd": ('t0'), "units": "K", "desc": "canopy air temperature for NoahMP"}, \ + {"name": "canicexy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "canopy intercepted ice mass for NoahMP"}, \ + {"name": "canliqxy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "canopy intercepted liquid water for NoahMP"}, \ + {"name": "eahxy", "type":wp, "dimd": ('t0'), "units": "Pa", "desc": "canopy air vapor pressure for NoahMP"}, \ + {"name": "cmxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface drag coefficient for momentum for NoahMP"}, \ + {"name": "chxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface exchange coeff heat & moisture for NoahMP"}, \ + {"name": "fwetxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "area fraction of canopy that is wetted/snowed for NoahMP"}, \ + {"name": "sneqvoxy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "snow mass at previous time step for NoahMP"}, \ + {"name": "alboldxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "snow albedo at previous time step for NoahMP"}, \ + {"name": "qsnowxy", "type":wp, "dimd": ('t0'), "units": "mm s-1", "desc": "snow precipitation rate at surface for NoahMP"}, \ + {"name": "wslakexy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "lake water storage for NoahMP"}, \ + {"name": "taussxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "non-dimensional snow age for NoahMP"}, \ + {"name": "waxy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "water storage in aquifer for NoahMP"}, \ + {"name": "wtxy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "water storage in aquifer and saturated soil for NoahMP"}, \ + {"name": "zwtxy", "type":wp, "dimd": ('t0'), "units": "m", "desc": "water table depth for NoahMP"}, \ + {"name": "xlaixy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "leaf area index for NoahMP"}, \ + {"name": "xsaixy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "stem area index for NoahMP"}, \ + {"name": "lfmassxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "leaf mass for NoahMP"}, \ + {"name": "stmassxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "stem mass for NoahMP"}, \ + {"name": "rtmassxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "fine root mass for NoahMP"}, \ + {"name": "woodxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "wood mass including woody roots for NoahMP"}, \ + {"name": "stblcpxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "stable carbon in deep soil for NoahMP"}, \ + {"name": "fastcpxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "short-lived carbon in shallow soil for NoahMP"}, \ + {"name": "smcwtdxy", "type":wp, "dimd": ('t0'), "units": "m3 m-3", "desc": "soil water content between the bottom of the soil and the water table for NoahMP"}, \ + {"name": "deeprechxy", "type":wp, "dimd": ('t0'), "units": "m", "desc": "recharge to or from the water table when deep for NoahMP"}, \ + {"name": "rechxy", "type":wp, "dimd": ('t0'), "units": "m", "desc": "recharge to or from the water table when shallow for NoahMP"}, \ + {"name": "snowxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "number of snow layers for NoahMP"}, \ + {"name": "snicexy", "type":wp, "dimd": ('t0','nsnow'), "units": "mm", "desc": "initial profile of snow layer ice"}, \ + {"name": "snliqxy", "type":wp, "dimd": ('t0','nsnow'), "units": "mm", "desc": "initial profile of snow layer liquid"}, \ + {"name": "tsnoxy", "type":wp, "dimd": ('t0','nsnow'), "units": "K", "desc": "initial profile of snow layer temperature"}, \ + {"name": "smoiseq", "type":wp, "dimd": ('t0','nsoil'), "units": "m3 m-3", "desc": "initial profile of equilibrium soil water content"}, \ + {"name": "zsnsoxy", "type":wp, "dimd": ('t0','nsoil_plus_nsnow'), "units": "m","desc": "layer bottom depth from snow surface"}] + # + var_ruc = [{"name": "wetness", "type":wp, "dimd": ('t0'), "units": "none", "desc": "normalized soil wetness for RUC LSM"}, \ + {"name": "lai", "type":wp, "dimd": ('t0'), "units": "none", "desc": "leaf area index for RUC LSM"}, \ + {"name": "clw_surf_land", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "cloud condensed water mixing ratio at surface over land for RUC LSM"},\ + {"name": "clw_surf_ice", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "cloud condensed water mixing ratio at surface over ice for RUC LSM"},\ + {"name": "qwv_surf_land", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "water vapor mixing ratio at surface over land for RUC LSM"},\ + {"name": "qwv_surf_ice", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "water vapor mixing ratio at surface over ice for RUC LSM"},\ + {"name": "tsnow_land", "type":wp, "dimd": ('t0'), "units": "K", "desc": "snow temperature at the bottom of the first snow layer over land for RUC LSM"},\ + {"name": "tsnow_ice", "type":wp, "dimd": ('t0'), "units": "K", "desc": "snow temperature at the bottom of the first snow layer over ice for RUC LSM"},\ + {"name": "snowfall_acc_land","type":wp, "dimd": ('t0'), "units": "kg m-2", "desc": "run-total snow accumulation on the ground over land for RUC LSM"},\ + {"name": "snowfall_acc_ice", "type":wp, "dimd": ('t0'), "units": "kg m-2", "desc": "run-total snow accumulation on the ground over ice for RUC LSM"},\ + {"name": "sfalb_lnd", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface albedo over land for RUC LSM"},\ + {"name": "sfalb_lnd_bck", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface snow-free albedo over land for RUC LSM"},\ + {"name": "sfalb_ice", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface albedo over ice for RUC LSM"},\ + {"name": "emis_lnd", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface emissivity over land for RUC LSM"},\ + {"name": "emis_ice", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface emissivity over ice for RUC LSM"}, \ + {"name": "tslb", "type":wp, "dimd": ('t0','nsoil'), "units": "K", "desc": "soil temperature for RUC LSM"}, \ + {"name": "smois", "type":wp, "dimd": ('t0','nsoil'), "units": "none", "desc": "volume fraction of soil moisture for RUC LSM"}, \ + {"name": "sh2o", "type":wp, "dimd": ('t0','nsoil'), "units": "none", "desc": "volume fraction of unfrozen soil moisture for RUC LSM"}, \ + {"name": "smfr", "type":wp, "dimd": ('t0','nsoil'), "units": "none", "desc": "volume fraction of frozen soil moisture for RUC LSM"}, + {"name": "flfr", "type":wp, "dimd": ('t0','nsoil'), "units": "none", "desc": "flag for frozen soil physics for RUC LSM"}] + + # + var_dict.extend(var_frc) + var_dict.extend(var_oro) + var_dict.extend(var_nsst) + var_dict.extend(var_frgd) + var_dict.extend(var_ruc) + var_dict.extend(var_noah) + var_dict.extend(var_noahmp) + + # + for var in var_dict: + if (var["name"] in dict): + var_temp = nc_file.createVariable(var["name"], var["type"], var["dimd"]) + var_temp.units = var["units"] + var_temp.standard_name = var["desc"] + var_temp[:] = dict[var["name"]] + elif "default_value" in var: + var_temp = nc_file.createVariable(var["name"], var["type"], var["dimd"]) + var_temp.units = var["units"] + var_temp.standard_name = var["desc"] + var_temp[:] = var["default_value"] + if "override" in var: + var_temp[:] = var["default_value"] + # + # Close file + # + nc_file.close() + + return(fileOUT) + +######################################################################################## +# +######################################################################################## +def main(): + setup_logging() + + #read in arguments + (case_name, use_area) = parse_arguments() + + (case_nml, error) = get_case_nml(case_name) + if (error): + message = 'The directory {0} does not contain a config file for case {1}'.format(CASE_NML_DIR, case_name) + logging.critical(message) + raise Exception(message) + else: + logging.info(case_nml) + + (case_data, error) = get_case_data(case_name) + if (error): + message = 'The directory {0} does not contain a data file for case {1}'.format(PROCESSED_CASE_DIR, case_name) + logging.critical(message) + raise Exception(message) + else: + logging.debug(case_data) + + fileOUT = write_SCM_case_file(case_nml, case_data, use_area) + logging.debug("Created {}".format(fileOUT)) + + write_SCM_nml_file(case_nml) + #logging.debug("Created {}".format(nmlOUT)) + +if __name__ == '__main__': + main() From 19aea49617b13c27c74dfe5504b4e0f640c11928 Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Thu, 18 Jul 2024 16:46:17 -0400 Subject: [PATCH 05/13] working version (at least for bomex) --- scm/etc/scripts/dephy_converter.py | 78 ++++++++++++++++++++++++------ scm/src/run_scm.py | 2 +- scm/src/scm_forcing.F90 | 2 +- scm/src/scm_input.F90 | 18 +++---- 4 files changed, 75 insertions(+), 25 deletions(-) diff --git a/scm/etc/scripts/dephy_converter.py b/scm/etc/scripts/dephy_converter.py index 63595540c..fb32c2aa6 100755 --- a/scm/etc/scripts/dephy_converter.py +++ b/scm/etc/scripts/dephy_converter.py @@ -258,7 +258,7 @@ def write_SCM_case_file(case_nml, case_data, use_area): com = 'mkdir -p ' + PROCESSED_CASE_DIR logging.info(com) os.system(com) - fileOUT = os.path.join(PROCESSED_CASE_DIR, case_nml['case_config']['case_name'] + '_SCM_driver.nc') + fileOUT = os.path.join(PROCESSED_CASE_DIR, case_nml['case_config']['case_name'] + '_dephy' + '_SCM_driver.nc') nc_file = Dataset(fileOUT, 'w', format='NETCDF3_CLASSIC') nc_file.description = "Case data for {} from CCPP SCM".format(case_nml['case_config']['case_name']) @@ -469,14 +469,6 @@ def write_SCM_case_file(case_nml, case_data, use_area): #logging.critical(message) #raise Exception(message) - if (case_nml['case_config']['sfc_flux_spec']): - nc_file.surface_forcing_temp = 'kinematic' - nc_file.surface_forcing_moisture = 'kinematic' - nc_file.surface_forcing_wind = 'z0' - else: - nc_file.surface_forcing_temp = 'ts' - nc_file.surface_forcing_wind = 'z0' - time_dim = nc_file.createDimension('time', case_data._time.shape[0]) timei_dim = nc_file.createDimension('t0', 1) lev_dim = nc_file.createDimension('lev', case_data._levels.shape[0]) @@ -577,6 +569,21 @@ def write_SCM_case_file(case_nml, case_data, use_area): ozone_var.standard_name = 'mole_fraction_of_ozone_in_air' ozone_var[:] = case_data._ozone[:] + ps_forc_var = nc_file.createVariable('ps_forc', wp, ('time')) + ps_forc_var.units = 'Pa' + ps_forc_var.standard_name = 'forcing_surface_air_pressure' + ps_forc_var[:] = case_data._p_surf[:] + + pa_forc_var = nc_file.createVariable('pa_forc', wp, ('time','lev')) + pa_forc_var.units = 'Pa' + pa_forc_var.standard_name = 'air_pressure_forcing' + pa_forc_var[:] = case_data._levels[:] + + zh_forc_var = nc_file.createVariable('zh_forc', wp, ('time','lev')) + zh_forc_var.units = 'm' + zh_forc_var.standard_name = 'height_forcing' + zh_forc_var[:] = case_data._height[:] + if (nc_file.adv_ta == forcing_on): message = 'adv_ta is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.' logging.critical() @@ -674,30 +681,73 @@ def write_SCM_case_file(case_nml, case_data, use_area): vg_var.standard_name = 'geostrophic_northward_wind' vg_var[:] = np.swapaxes(case_data._v_g[:],0,1) - if (nc_file.nudging_ua == forcing_on): + if (nc_file.nudging_ua != forcing_off): ua_nud_var = nc_file.createVariable('ua_nud', wp, ('time','lev')) ua_nud_var.units = 'm s-1' ua_nud_var.standard_name = 'nudging_eastward_wind' ua_nud_var[:] = np.swapaxes(case_data._u_nudge[:],0,1) - if (nc_file.nudging_va == forcing_on): + if (nc_file.nudging_va != forcing_off): va_nud_var = nc_file.createVariable('va_nud', wp, ('time','lev')) va_nud_var.units = 'm s-1' va_nud_var.standard_name = 'nudging_northward_wind' va_nud_var[:] = np.swapaxes(case_data._v_nudge[:],0,1) - if (nc_file.nudging_ta == forcing_on): + if (nc_file.nudging_ta != forcing_off): ta_nud_var = nc_file.createVariable('ta_nud', wp, ('time','lev')) ta_nud_var.units = 'K' ta_nud_var.standard_name = 'nudging_air_temperature' ta_nud_var[:] = np.swapaxes(case_data._T_nudge[:],0,1) - if (nc_file.nudging_qt == forcing_on): + if (nc_file.nudging_qt != forcing_off): qt_nud_var = nc_file.createVariable('qt_nud', wp, ('time','lev')) qt_nud_var.units = 'kg kg-1' qt_nud_var.standard_name = 'nudging_mass_fraction_of_water_in_air' qt_nud_var[:] = np.swapaxes(case_data._qt_nudge[:],0,1) + if (case_nml['case_config']['sfc_flux_spec']): + nc_file.surface_forcing_temp = 'kinematic' + nc_file.surface_forcing_moisture = 'kinematic' + nc_file.surface_forcing_wind = 'z0' + + wpthetap_s_var = nc_file.createVariable('wpthetap_s', wp, ('time')) + wpthetap_s_var.units = 'K m s-1' + wpthetap_s_var.standard_name = 'surface_upward_potential_temperature_flux' + wpthetap_s_var[:] = case_data._sh_flux_sfc[:] + + wpqtp_s_var = nc_file.createVariable('wpqvp_s', wp, ('time')) + wpqtp_s_var.units = 'kg kg-1 m s-1' + wpqtp_s_var.standard_name = 'surface_upward_specific_humidity_flux' + wpqtp_s_var[:] = case_data._lh_flux_sfc[:] + + z0_var = nc_file.createVariable('z0', wp, ('time')) + z0_var.units = 'm' + z0_var.standard_name = 'surface_roughness_length_for_momentum_in_air' + z0_var[:] = case_nml['case_config']['sfc_roughness_length_cm']*1.0E-2 + + + ts_var = nc_file.createVariable('ts_forc', wp, ('time')) + ts_var.units = 'K' + ts_var.standard_name = 'forcing_surface_temperature' + if np.any(case_data._T_surf[:]): + ts_var[:] = case_data._T_surf[:] + else: + ts_var[:] = case_data._missing_value + + else: + nc_file.surface_forcing_temp = 'ts' + nc_file.surface_forcing_wind = 'z0' + + z0_var = nc_file.createVariable('z0', wp, ('time')) + z0_var.units = 'm' + z0_var.standard_name = 'surface_roughness_length_for_momentum_in_air' + z0_var[:] = case_nml['case_config']['sfc_roughness_length_cm']*1.0E-2 + + ts_var = nc_file.createVariable('ts_forc', wp, ('time')) + ts_var.units = 'K' + ts_var.standard_name = 'forcing_surface_temperature' + ts_var[:] = case_data._T_surf[:] + nc_file.close() return(fileOUT) @@ -760,7 +810,7 @@ def write_SCM_nml_file(case_nml): nml = f90nml.namelist.Namelist(nml_dict) #print(nml) - nml.write(filename) + nml.write(filename, force=True) return(filename) diff --git a/scm/src/run_scm.py b/scm/src/run_scm.py index b499fafac..6c2cb20d8 100755 --- a/scm/src/run_scm.py +++ b/scm/src/run_scm.py @@ -498,7 +498,7 @@ def setup_rundir(self): nc_fid = Dataset(os.path.join(SCM_ROOT, self._case_data_dir) + '/' + self._case + '_SCM_driver.nc' , 'r') surfaceForcing = nc_fid.getncattr('surface_forcing_temp') nc_fid.close() - if (surfaceForcing.lower() == 'flux' or surfaceForcing.lower() == 'surface_flux'): + if (surfaceForcing.lower() == 'kinematic' or surfaceForcing.lower() == 'surface_flux'): surface_flux_spec = True except KeyError: # if not using DEPHY format, check to see if surface fluxes are specified in the case configuration file (default is False) diff --git a/scm/src/scm_forcing.F90 b/scm/src/scm_forcing.F90 index ad7a47b4f..2d4258ab6 100644 --- a/scm/src/scm_forcing.F90 +++ b/scm/src/scm_forcing.F90 @@ -155,7 +155,7 @@ subroutine interpolate_forcing(scm_input, scm_state, in_spinup) scm_input%input_omega(scm_input%input_ntimes,:), scm_state%pres_l(i,:), scm_state%n_levels, & omega_bracket(1,:), top_index, 3) if (top_index < scm_state%n_levels .and. top_index > 0) then - w_ls_bracket(1,top_index+1:scm_state%n_levels) = 0.0!w_ls_bracket(1,top_index) + omega_bracket(1,top_index+1:scm_state%n_levels) = 0.0!w_ls_bracket(1,top_index) end if scm_state%omega(i,:) = omega_bracket(1,:) end do diff --git a/scm/src/scm_input.F90 b/scm/src/scm_input.F90 index cc3effcd5..73f277717 100644 --- a/scm/src/scm_input.F90 +++ b/scm/src/scm_input.F90 @@ -2399,7 +2399,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) end if end do else - scm_input%input_k_T_nudge = 1 + scm_input%input_k_T_nudge(:) = 1 end if else if (nudging_theta > 0) then !assume no cloud water since there is no associate [ql,qi]_nudge in the input? @@ -2425,7 +2425,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) end if end do else - scm_input%input_k_thil_nudge = 1 + scm_input%input_k_thil_nudge(:) = 1 end if else if (nudging_thetal > 0) then !assume no cloud water since there is no associate [ql,qi]_nudge in the input? @@ -2451,7 +2451,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) end if end do else - scm_input%input_k_thil_nudge = 1 + scm_input%input_k_thil_nudge(:) = 1 end if end if @@ -2478,7 +2478,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) end if end do else - scm_input%input_k_qt_nudge = 1 + scm_input%input_k_qt_nudge(:) = 1 end if else if (nudging_qt > 0) then do i=1, input_n_forcing_times @@ -2503,7 +2503,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) end if end do else - scm_input%input_k_qt_nudge = 1 + scm_input%input_k_qt_nudge(:) = 1 end if else if (nudging_rv > 0) then do i=1, input_n_forcing_times @@ -2531,7 +2531,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) end if end do else - scm_input%input_k_qt_nudge = 1 + scm_input%input_k_qt_nudge(:) = 1 end if else if (nudging_rt > 0) then do i=1, input_n_forcing_times @@ -2559,7 +2559,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) end if end do else - scm_input%input_k_qt_nudge = 1 + scm_input%input_k_qt_nudge(:) = 1 end if end if @@ -2586,7 +2586,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) end if end do else - scm_input%input_k_u_nudge = 1 + scm_input%input_k_u_nudge(:) = 1 end if end if @@ -2613,7 +2613,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) end if end do else - scm_input%input_k_v_nudge = 1 + scm_input%input_k_v_nudge(:) = 1 end if end if From b25af2145b879866570791bbc27b8d4c88d793a5 Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Fri, 19 Jul 2024 14:18:04 -0400 Subject: [PATCH 06/13] only add vertical advective forcing if forc_w or forc_wap are not on --- scm/etc/scripts/dephy_converter.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scm/etc/scripts/dephy_converter.py b/scm/etc/scripts/dephy_converter.py index fb32c2aa6..b559824fd 100755 --- a/scm/etc/scripts/dephy_converter.py +++ b/scm/etc/scripts/dephy_converter.py @@ -633,13 +633,19 @@ def write_SCM_case_file(case_nml, case_data, use_area): tnthetal_adv_var = nc_file.createVariable('tnthetal_adv', wp, ('time','lev')) tnthetal_adv_var.units = 'K s-1' tnthetal_adv_var.standard_name = 'tendency_of_air_liquid_potential_temperature_due_to_advection' - tnthetal_adv_var[:] = np.swapaxes(case_data._h_advec_thil[:] + case_data._v_advec_thil[:],0,1) + if (nc_file.forc_wap == forcing_on or nc_file.forc_wa == forcing_on): + tnthetal_adv_var[:] = np.swapaxes(case_data._h_advec_thil[:],0,1) + else: + tnthetal_adv_var[:] = np.swapaxes(case_data._h_advec_thil[:] + case_data._v_advec_thil[:],0,1) if (nc_file.adv_qt == forcing_on): tnqt_adv_var = nc_file.createVariable('tnqt_adv', wp, ('time','lev')) tnqt_adv_var.units = 'kg kg-1 s-1' tnqt_adv_var.standard_name = 'tendency_of_mass_fraction_of_water_in_air_due_to_advection' - tnqt_adv_var[:] = np.swapaxes(case_data._h_advec_qt[:] + case_data._v_advec_qt[:],0,1) + if (nc_file.forc_wap == forcing_on or nc_file.forc_wa == forcing_on): + tnqt_adv_var[:] = np.swapaxes(case_data._h_advec_qt[:],0,1) + else: + tnqt_adv_var[:] = np.swapaxes(case_data._h_advec_qt[:] + case_data._v_advec_qt[:],0,1) if (nc_file.adv_rv == forcing_on): message = 'adv_rv is turned on, but is not implemented in the proprietery CCPP SCM case format and cannot be used.' From cc937f5dadb7d6d7c5312cdb0959f03c7597e761 Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Wed, 24 Jul 2024 16:44:41 -0400 Subject: [PATCH 07/13] add surface variables and updated case_config namelists --- scm/etc/case_config/LASSO_2016051812.nml | 23 +- scm/etc/case_config/LASSO_2016051812_MSDA.nml | 23 +- scm/etc/case_config/LASSO_2016051812_VARA.nml | 23 +- scm/etc/case_config/LASSO_20180514_s02.nml | 23 +- scm/etc/case_config/LASSO_20180522_s02.nml | 23 +- scm/etc/case_config/LASSO_20180606_s02.nml | 23 +- scm/etc/case_config/LASSO_20180618_s02.nml | 23 +- scm/etc/case_config/LASSO_20180619_s02.nml | 23 +- scm/etc/case_config/LASSO_20180705_s02.nml | 23 +- scm/etc/case_config/LASSO_20180707_s02.nml | 23 +- scm/etc/case_config/LASSO_20180709_s02.nml | 23 +- scm/etc/case_config/LASSO_20180712_s02.nml | 23 +- scm/etc/case_config/LASSO_20180731_s02.nml | 23 +- scm/etc/case_config/LASSO_20180911_s02.nml | 23 +- scm/etc/case_config/LASSO_20180914_s02.nml | 23 +- scm/etc/case_config/LASSO_20180916_s02.nml | 23 +- scm/etc/case_config/LASSO_20180917_s02.nml | 23 +- scm/etc/case_config/LASSO_20180918_s02.nml | 23 +- scm/etc/case_config/LASSO_20181002_s02.nml | 23 +- scm/etc/case_config/arm_sgp_summer_1997_A.nml | 23 +- scm/etc/case_config/arm_sgp_summer_1997_B.nml | 23 +- scm/etc/case_config/arm_sgp_summer_1997_C.nml | 23 +- scm/etc/case_config/arm_sgp_summer_1997_R.nml | 23 +- scm/etc/case_config/arm_sgp_summer_1997_S.nml | 23 +- scm/etc/case_config/arm_sgp_summer_1997_T.nml | 23 +- scm/etc/case_config/arm_sgp_summer_1997_U.nml | 23 +- scm/etc/case_config/arm_sgp_summer_1997_X.nml | 23 +- scm/etc/case_config/astex.nml | 23 +- scm/etc/case_config/bomex.nml | 23 +- scm/etc/case_config/gabls3.nml | 29 +- scm/etc/case_config/gabls3_noahmp.nml | 29 +- scm/etc/case_config/gabls3_ruc.nml | 29 +- scm/etc/case_config/twpice.nml | 23 +- scm/etc/scripts/dephy_converter.py | 2231 +++++++++++++---- scm/src/scm_input.F90 | 308 +-- 35 files changed, 2156 insertions(+), 1160 deletions(-) diff --git a/scm/etc/case_config/LASSO_2016051812.nml b/scm/etc/case_config/LASSO_2016051812.nml index 75eff16b8..31df86d63 100644 --- a/scm/etc/case_config/LASSO_2016051812.nml +++ b/scm/etc/case_config/LASSO_2016051812.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_2016051812', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2016, -month = 5, -day = 18, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_2016051812' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_2016051812_MSDA.nml b/scm/etc/case_config/LASSO_2016051812_MSDA.nml index 900c70b9e..ec6edbf08 100644 --- a/scm/etc/case_config/LASSO_2016051812_MSDA.nml +++ b/scm/etc/case_config/LASSO_2016051812_MSDA.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_2016051812_MSDA', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2016, -month = 5, -day = 18, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_2016051812_MSDA' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_2016051812_VARA.nml b/scm/etc/case_config/LASSO_2016051812_VARA.nml index 2f0374372..139278616 100644 --- a/scm/etc/case_config/LASSO_2016051812_VARA.nml +++ b/scm/etc/case_config/LASSO_2016051812_VARA.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_2016051812_VARA', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2016, -month = 5, -day = 18, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_2016051812_VARA' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180514_s02.nml b/scm/etc/case_config/LASSO_20180514_s02.nml index 432c77ed1..61f9a7f3e 100644 --- a/scm/etc/case_config/LASSO_20180514_s02.nml +++ b/scm/etc/case_config/LASSO_20180514_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180514_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 5, -day = 14, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180514_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180522_s02.nml b/scm/etc/case_config/LASSO_20180522_s02.nml index 4f69ef9b1..2a561bbb4 100644 --- a/scm/etc/case_config/LASSO_20180522_s02.nml +++ b/scm/etc/case_config/LASSO_20180522_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180522_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 5, -day = 22, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180522_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180606_s02.nml b/scm/etc/case_config/LASSO_20180606_s02.nml index feeadc334..2e8a13eb4 100644 --- a/scm/etc/case_config/LASSO_20180606_s02.nml +++ b/scm/etc/case_config/LASSO_20180606_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180606_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 6, -day = 06, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180606_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180618_s02.nml b/scm/etc/case_config/LASSO_20180618_s02.nml index a5b261a3c..1a609b659 100644 --- a/scm/etc/case_config/LASSO_20180618_s02.nml +++ b/scm/etc/case_config/LASSO_20180618_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180618_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 6, -day = 18, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180618_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180619_s02.nml b/scm/etc/case_config/LASSO_20180619_s02.nml index e32bc294d..33c6c1981 100644 --- a/scm/etc/case_config/LASSO_20180619_s02.nml +++ b/scm/etc/case_config/LASSO_20180619_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180619_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 6, -day = 19, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180619_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180705_s02.nml b/scm/etc/case_config/LASSO_20180705_s02.nml index 5648360e8..fac051533 100644 --- a/scm/etc/case_config/LASSO_20180705_s02.nml +++ b/scm/etc/case_config/LASSO_20180705_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180705_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 7, -day = 05, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180705_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180707_s02.nml b/scm/etc/case_config/LASSO_20180707_s02.nml index af73e1d62..2df38195d 100644 --- a/scm/etc/case_config/LASSO_20180707_s02.nml +++ b/scm/etc/case_config/LASSO_20180707_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180707_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 7, -day = 07, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180707_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180709_s02.nml b/scm/etc/case_config/LASSO_20180709_s02.nml index ac68594cd..5fd786d63 100644 --- a/scm/etc/case_config/LASSO_20180709_s02.nml +++ b/scm/etc/case_config/LASSO_20180709_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180709_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 7, -day = 09, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180709_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180712_s02.nml b/scm/etc/case_config/LASSO_20180712_s02.nml index 6917a1851..7aa611c0a 100644 --- a/scm/etc/case_config/LASSO_20180712_s02.nml +++ b/scm/etc/case_config/LASSO_20180712_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180712_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 7, -day = 12, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180712_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180731_s02.nml b/scm/etc/case_config/LASSO_20180731_s02.nml index 6ac93bbad..654037d69 100644 --- a/scm/etc/case_config/LASSO_20180731_s02.nml +++ b/scm/etc/case_config/LASSO_20180731_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180731_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 7, -day = 31, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180731_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180911_s02.nml b/scm/etc/case_config/LASSO_20180911_s02.nml index e4fc92955..68e9fcb43 100644 --- a/scm/etc/case_config/LASSO_20180911_s02.nml +++ b/scm/etc/case_config/LASSO_20180911_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180911_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 9, -day = 11, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180911_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180914_s02.nml b/scm/etc/case_config/LASSO_20180914_s02.nml index 66d28362d..6a6c834c6 100644 --- a/scm/etc/case_config/LASSO_20180914_s02.nml +++ b/scm/etc/case_config/LASSO_20180914_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180914_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 9, -day = 14, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180914_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180916_s02.nml b/scm/etc/case_config/LASSO_20180916_s02.nml index 6197652b8..3e486717f 100644 --- a/scm/etc/case_config/LASSO_20180916_s02.nml +++ b/scm/etc/case_config/LASSO_20180916_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180916_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 9, -day = 16, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180916_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180917_s02.nml b/scm/etc/case_config/LASSO_20180917_s02.nml index 896a32225..0ff786d1b 100644 --- a/scm/etc/case_config/LASSO_20180917_s02.nml +++ b/scm/etc/case_config/LASSO_20180917_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180917_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 9, -day = 17, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180917_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20180918_s02.nml b/scm/etc/case_config/LASSO_20180918_s02.nml index 09deb06aa..383cad945 100644 --- a/scm/etc/case_config/LASSO_20180918_s02.nml +++ b/scm/etc/case_config/LASSO_20180918_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20180918_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 9, -day = 18, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20180918_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/LASSO_20181002_s02.nml b/scm/etc/case_config/LASSO_20181002_s02.nml index b63d206de..9a10ff357 100644 --- a/scm/etc/case_config/LASSO_20181002_s02.nml +++ b/scm/etc/case_config/LASSO_20181002_s02.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'LASSO_20181002_s02', -runtime = 54000, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 2018, -month = 10, -day = 02, -hour = 12, -column_area = 2.0E9, -$end +&case_config + case_name = 'LASSO_20181002_s02' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/arm_sgp_summer_1997_A.nml b/scm/etc/case_config/arm_sgp_summer_1997_A.nml index 375d0c4cb..912c3ba2f 100644 --- a/scm/etc/case_config/arm_sgp_summer_1997_A.nml +++ b/scm/etc/case_config/arm_sgp_summer_1997_A.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'arm_sgp_summer_1997_A', -runtime = 345600, -thermo_forcing_type = 1, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 1997, -month = 6, -day = 26, -hour = 23, -column_area = 2.0E9, -$end +&case_config + case_name = 'arm_sgp_summer_1997_A' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/arm_sgp_summer_1997_B.nml b/scm/etc/case_config/arm_sgp_summer_1997_B.nml index 0ac151cc4..f72393b48 100644 --- a/scm/etc/case_config/arm_sgp_summer_1997_B.nml +++ b/scm/etc/case_config/arm_sgp_summer_1997_B.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'arm_sgp_summer_1997_B', -runtime = 432000, -thermo_forcing_type = 1, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 1997, -month = 7, -day = 7, -hour = 23, -column_area = 2.0E9, -$end +&case_config + case_name = 'arm_sgp_summer_1997_B' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/arm_sgp_summer_1997_C.nml b/scm/etc/case_config/arm_sgp_summer_1997_C.nml index ace0b4dd2..4ed84bab0 100644 --- a/scm/etc/case_config/arm_sgp_summer_1997_C.nml +++ b/scm/etc/case_config/arm_sgp_summer_1997_C.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'arm_sgp_summer_1997_C', -runtime = 432000, -thermo_forcing_type = 1, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 1997, -month = 7, -day = 12, -hour = 23, -column_area = 2.0E9, -$end +&case_config + case_name = 'arm_sgp_summer_1997_C' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/arm_sgp_summer_1997_R.nml b/scm/etc/case_config/arm_sgp_summer_1997_R.nml index c3da579ce..79632258b 100644 --- a/scm/etc/case_config/arm_sgp_summer_1997_R.nml +++ b/scm/etc/case_config/arm_sgp_summer_1997_R.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'arm_sgp_summer_1997_R', -runtime = 345600, -thermo_forcing_type = 1, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 1997, -month = 6, -day = 18, -hour = 23, -column_area = 2.0E9, -$end +&case_config + case_name = 'arm_sgp_summer_1997_R' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/arm_sgp_summer_1997_S.nml b/scm/etc/case_config/arm_sgp_summer_1997_S.nml index ba26818be..25f21da4c 100644 --- a/scm/etc/case_config/arm_sgp_summer_1997_S.nml +++ b/scm/etc/case_config/arm_sgp_summer_1997_S.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'arm_sgp_summer_1997_S', -runtime = 345600, -thermo_forcing_type = 1, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 1997, -month = 6, -day = 22, -hour = 23, -column_area = 2.0E9, -$end +&case_config + case_name = 'arm_sgp_summer_1997_S' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/arm_sgp_summer_1997_T.nml b/scm/etc/case_config/arm_sgp_summer_1997_T.nml index d68aaa82a..6b5cc9f3f 100644 --- a/scm/etc/case_config/arm_sgp_summer_1997_T.nml +++ b/scm/etc/case_config/arm_sgp_summer_1997_T.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'arm_sgp_summer_1997_T', -runtime = 259200, -thermo_forcing_type = 1, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 1997, -month = 6, -day = 30, -hour = 23, -column_area = 2.0E9, -$end +&case_config + case_name = 'arm_sgp_summer_1997_T' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/arm_sgp_summer_1997_U.nml b/scm/etc/case_config/arm_sgp_summer_1997_U.nml index 2d599f4f8..1abc438f5 100644 --- a/scm/etc/case_config/arm_sgp_summer_1997_U.nml +++ b/scm/etc/case_config/arm_sgp_summer_1997_U.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'arm_sgp_summer_1997_U', -runtime = 345600, -thermo_forcing_type = 1, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 1997, -month = 7, -day = 4, -hour = 23, -column_area = 2.0E9, -$end +&case_config + case_name = 'arm_sgp_summer_1997_U' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/arm_sgp_summer_1997_X.nml b/scm/etc/case_config/arm_sgp_summer_1997_X.nml index cc90d4b91..b207a781f 100644 --- a/scm/etc/case_config/arm_sgp_summer_1997_X.nml +++ b/scm/etc/case_config/arm_sgp_summer_1997_X.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'arm_sgp_summer_1997_X', -runtime = 2505600, -thermo_forcing_type = 1, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 10.0 -sfc_type = 1, -reference_profile_choice = 2, -year = 1997, -month = 6, -day = 18, -hour = 23, -column_area = 2.0E9, -$end +&case_config + case_name = 'arm_sgp_summer_1997_X' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 2 + sfc_roughness_length_cm = 10.0 +/ diff --git a/scm/etc/case_config/astex.nml b/scm/etc/case_config/astex.nml index 3a9e99a3b..1cfb03bfb 100644 --- a/scm/etc/case_config/astex.nml +++ b/scm/etc/case_config/astex.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'astex', -runtime = 144000, -thermo_forcing_type = 2, -mom_forcing_type = 2, -relax_time = 7200.0, -sfc_flux_spec = .false., -sfc_type = 0, -sfc_roughness_length_cm = 0.02, -reference_profile_choice = 1, -year = 1992, -month = 6, -day = 13, -hour = 0, -column_area = 3.7E5, -$end +&case_config + case_name = 'astex' + column_area = 370000.0 + input_type = 1 + reference_profile_choice = 1 + sfc_roughness_length_cm = 0.02 +/ diff --git a/scm/etc/case_config/bomex.nml b/scm/etc/case_config/bomex.nml index 093c31353..e6f68378a 100644 --- a/scm/etc/case_config/bomex.nml +++ b/scm/etc/case_config/bomex.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'bomex', -runtime = 21600, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .true., -sfc_roughness_length_cm = 0.012, -sfc_type = 0, -reference_profile_choice = 1, -year = 1969, -month = 6, -day = 22, -hour = 13, -column_area = 2.0E9, -$end +&case_config + case_name = 'bomex' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 1 + sfc_roughness_length_cm = 0.012 +/ diff --git a/scm/etc/case_config/gabls3.nml b/scm/etc/case_config/gabls3.nml index 727b9eced..0e48db674 100644 --- a/scm/etc/case_config/gabls3.nml +++ b/scm/etc/case_config/gabls3.nml @@ -1,19 +1,10 @@ -$case_config -case_name = 'gabls3', -runtime = 86400, -thermo_forcing_type = 2, -mom_forcing_type = 2, -relax_time = 7200.0, -sfc_flux_spec = .false., -lsm_ics = .true., -do_spinup = .true., -spinup_timesteps = 12, -sfc_roughness_length_cm = 15.0, -sfc_type = 1, -reference_profile_choice = 2, -year = 2006, -month = 7, -day = 1, -hour = 12, -column_area = 1.45E8, -$end +&case_config + case_name = 'gabls3' + column_area = 145000000.0 + do_spinup = .true. + input_type = 1 + lsm_ics = .true. + reference_profile_choice = 2 + sfc_roughness_length_cm = 15.0 + spinup_timesteps = 12 +/ diff --git a/scm/etc/case_config/gabls3_noahmp.nml b/scm/etc/case_config/gabls3_noahmp.nml index 5775d65f5..4b7267352 100644 --- a/scm/etc/case_config/gabls3_noahmp.nml +++ b/scm/etc/case_config/gabls3_noahmp.nml @@ -1,19 +1,10 @@ -$case_config -case_name = 'gabls3_noahmp', -runtime = 86400, -thermo_forcing_type = 2, -mom_forcing_type = 2, -relax_time = 7200.0, -sfc_flux_spec = .false., -lsm_ics = .true., -do_spinup = .true., -spinup_timesteps = 12, -sfc_roughness_length_cm = 15.0, -sfc_type = 1, -reference_profile_choice = 2, -year = 2006, -month = 7, -day = 1, -hour = 12, -column_area = 1.45E8, -$end +&case_config + case_name = 'gabls3_noahmp' + column_area = 145000000.0 + do_spinup = .true. + input_type = 1 + lsm_ics = .true. + reference_profile_choice = 2 + sfc_roughness_length_cm = 15.0 + spinup_timesteps = 12 +/ diff --git a/scm/etc/case_config/gabls3_ruc.nml b/scm/etc/case_config/gabls3_ruc.nml index a13a4dcf0..4a1ff01da 100644 --- a/scm/etc/case_config/gabls3_ruc.nml +++ b/scm/etc/case_config/gabls3_ruc.nml @@ -1,19 +1,10 @@ -$case_config -case_name = 'gabls3_ruc', -runtime = 86400, -thermo_forcing_type = 2, -mom_forcing_type = 2, -relax_time = 7200.0, -sfc_flux_spec = .false., -lsm_ics = .true., -do_spinup = .true., -spinup_timesteps = 12, -sfc_roughness_length_cm = 15.0, -sfc_type = 1, -reference_profile_choice = 2, -year = 2006, -month = 7, -day = 1, -hour = 12, -column_area = 1.45E8, -$end +&case_config + case_name = 'gabls3_ruc' + column_area = 145000000.0 + do_spinup = .true. + input_type = 1 + lsm_ics = .true. + reference_profile_choice = 2 + sfc_roughness_length_cm = 15.0 + spinup_timesteps = 12 +/ diff --git a/scm/etc/case_config/twpice.nml b/scm/etc/case_config/twpice.nml index 23a5ceea0..bd3374c36 100644 --- a/scm/etc/case_config/twpice.nml +++ b/scm/etc/case_config/twpice.nml @@ -1,16 +1,7 @@ -$case_config -case_name = 'twpice', -runtime = 2138400, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 7200.0, -sfc_flux_spec = .false., -sfc_type = 0, -sfc_roughness_length_cm = 0.02, -reference_profile_choice = 1, -year = 2006, -month = 1, -day = 19, -hour = 3, -column_area = 2.0E9, -$end +&case_config + case_name = 'twpice' + column_area = 2000000000.0 + input_type = 1 + reference_profile_choice = 1 + sfc_roughness_length_cm = 0.02 +/ diff --git a/scm/etc/scripts/dephy_converter.py b/scm/etc/scripts/dephy_converter.py index b559824fd..42b745d00 100755 --- a/scm/etc/scripts/dephy_converter.py +++ b/scm/etc/scripts/dephy_converter.py @@ -55,17 +55,159 @@ def setup_logging(): logging.basicConfig(format='%(levelname)s: %(message)s', level=LOGLEVEL) class Case_Data(object): - def __init__(self, name, missing_value, time, levels, lat, lon, height, theta_il, qt, ql, qi, u, v, tke, ozone, \ + def __init__(self, name, missing_value, time, levels, soil_depth, lat, lon, slmsk, vegsrc, vegtyp, soiltyp, \ + scolor, slopetyp, tsfco, vegfrac, shdmin, shdmax, canopy, hice, fice, tisfc, snowd, snoalb, tg3, \ + uustar, alvsf, alnsf, alvwf, alnwf, facsf, facwf, weasd, f10m, t2m, q2m, ffmm, ffhh, \ + tprcp, srflag, sncovr, tsfcl, zorl, zorll, zorli, zorlw, zorlwav, tvxy, tgxy, tahxy, canicexy, canliqxy, eahxy, \ + cmxy, chxy, fwetxy, sneqvoxy, alboldxy, qsnowxy, wslakexy, taussxy, waxy, wtxy, zwtxy, xlaixy, xsaixy, \ + lfmassxy, stmassxy, rtmassxy, woodxy, stblcpxy, fastcpxy, smcwtdxy, deeprechxy, rechxy, snowxy, \ + wetness, clw_surf_land, clw_surf_ice, qwv_surf_land, qwv_surf_ice, tsnow_land, tsnow_ice, \ + snowfallac_land, snowfallac_ice, sncovr_ice, sfalb_lnd, sfalb_lnd_bck, emis_ice, lai, area, \ + stddev, convexity, oa1, oa2, oa3, oa4, ol1, ol2, ol3, ol4, theta_oro, gamma, sigma, elvmax, \ + oro, oro_uf, landfrac, lakefrac, lakedepth, tref, z_c, c_0, c_d, w_0, w_d, xt, xs, xu, xv, xz, zm, \ + xtts, xzts, d_conv, ifd, dt_cool, qrain, height, theta_il, t,\ + qt, ql, qi, u, v, tke, ozone, stc, smc, slc, snicexy, snliqxy, tsnoxy, smoiseq, zsnsoxy, tiice, \ + tslb, smois, sh2o, smfr, flfr, \ p_surf, T_surf, w_ls, omega, u_g, v_g, u_nudge, v_nudge, T_nudge, thil_nudge, qt_nudge, \ dT_dt_rad, h_advec_thil, v_advec_thil, h_advec_qt, v_advec_qt, sh_flux_sfc, lh_flux_sfc): self._name = name self._missing_value = missing_value + #dimensions self._time = time self._levels = levels + self._soil_depth = soil_depth + #scalars self._lat = lat self._lon = lon + #NOAH LSM scalars + self._slmsk = slmsk + self._vegsrc = vegsrc + self._vegtyp = vegtyp + self._soiltyp = soiltyp + self._scolor = scolor + self._slopetyp = slopetyp + self._tsfco = tsfco + self._vegfrac = vegfrac + self._shdmin = shdmin + self._shdmax = shdmax + self._canopy = canopy + self._hice = hice + self._fice = fice + self._tisfc = tisfc + self._snowd = snowd + self._snoalb = snoalb + self._tg3 = tg3 + self._uustar = uustar + self._alvsf = alvsf + self._alnsf = alnsf + self._alvwf = alvwf + self._alnwf = alnwf + self._facsf = facsf + self._facwf = facwf + self._weasd = weasd + self._f10m = f10m + self._t2m = t2m + self._q2m = q2m + self._ffmm = ffmm + self._ffhh = ffhh + self._tprcp = tprcp + self._srflag = srflag + self._sncovr = sncovr + self._tsfcl = tsfcl + self._zorl = zorl + self._zorll = zorll + self._zorli = zorli + self._zorlw = zorlw + self._zorlwav = zorlwav + self._area = area + #NOAHMP scalars + self._tvxy = tvxy + self._tgxy = tgxy + self._tahxy = tahxy + self._canicexy = canicexy + self._canliqxy = canliqxy + self._eahxy = eahxy + self._cmxy = cmxy + self._chxy = chxy + self._fwetxy = fwetxy + self._sneqvoxy = sneqvoxy + self._alboldxy = alboldxy + self._qsnowxy = qsnowxy + self._wslakexy = wslakexy + self._taussxy = taussxy + self._waxy = waxy + self._wtxy = wtxy + self._zwtxy = zwtxy + self._xlaixy = xlaixy + self._xsaixy = xsaixy + self._lfmassxy = lfmassxy + self._stmassxy = stmassxy + self._rtmassxy = rtmassxy + self._woodxy = woodxy + self._stblcpxy = stblcpxy + self._fastcpxy = fastcpxy + self._smcwtdxy = smcwtdxy + self._deeprechxy = deeprechxy + self._rechxy = rechxy + self._snowxy = snowxy + #RUC LSM scalars + self._wetness = wetness + self._clw_surf_land = clw_surf_land + self._clw_surf_ice = clw_surf_ice + self._qwv_surf_land = qwv_surf_land + self._qwv_surf_ice = qwv_surf_ice + self._tsnow_land = tsnow_land + self._tsnow_ice = tsnow_ice + self._snowfallac_land = snowfallac_land + self._snowfallac_ice = snowfallac_ice + self._sncovr_ice = sncovr_ice + self._sfalb_lnd = sfalb_lnd + self._sfalb_lnd_bck = sfalb_lnd_bck + self._emis_ice = emis_ice + self._lai = lai + #orographic variables + self._stddev = stddev + self._convexity = convexity + self._oa1 = oa1 + self._oa2 = oa2 + self._oa3 = oa3 + self._oa4 = oa4 + self._ol1 = ol1 + self._ol2 = ol2 + self._ol3 = ol3 + self._ol4 = ol4 + self._theta_oro = theta_oro + self._gamma = gamma + self._sigma = sigma + self._elvmax = elvmax + self._oro = oro + self._oro_uf = oro_uf + self._landfrac = landfrac + self._lakefrac = lakefrac + self._lakedepth = lakedepth + #NSST vars + self._tref = tref + self._z_c = z_c + self._c_0 = c_0 + self._c_d = c_d + self._w_0 = w_0 + self._w_d = w_d + self._xt = xt + self._xs = xs + self._xu = xu + self._xv = xv + self._xz = xz + self._zm = zm + self._xtts = xtts + self._xzts = xzts + self._d_conv = d_conv + self._ifd = ifd + self._dt_cool = dt_cool + self._qrain = qrain + #initial conditions (profiles for t0) self._height = height self._theta_il = theta_il + self._t = t self._qt = qt self._ql = ql self._qi = qi @@ -73,8 +215,24 @@ def __init__(self, name, missing_value, time, levels, lat, lon, height, theta_il self._v = v self._tke = tke self._ozone = ozone + self._stc = stc + self._smc = smc + self._slc = slc + self._snicexy = snicexy + self._snliqxy = snliqxy + self._tsnoxy = tsnoxy + self._smoiseq = smoiseq + self._zsnsoxy = zsnsoxy + self._tiice = tiice + self._tslb = tslb + self._smois = smois + self._sh2o = sh2o + self._smfr = smfr + self._flfr = flfr + #time series self._p_surf = p_surf self._T_surf = T_surf + #2D forcing vars (vert, time) self._w_ls = w_ls self._omega = omega self._u_g = u_g @@ -99,12 +257,134 @@ def __repr__(self): " Dimensions: \n" \ " time:% s \n" \ " levels: % s \n" \ + " soil_depth: % s \n" \ " Scalars: \n" \ " lat: % s \n" \ " lon: % s \n" \ + " area: % s \n" \ + " slmsk: % s \n" \ + " vegsrc: % s \n" \ + " vegtyp: % s \n" \ + " soiltyp: % s \n" \ + " scolor: % s \n" \ + " slopetyp: % s \n" \ + " tsfco: % s \n" \ + " vegfrac: % s \n" \ + " shdmin: % s \n" \ + " shdmax: % s \n" \ + " canopy: % s \n" \ + " hice: % s \n" \ + " fice: % s \n" \ + " tisfc: % s \n" \ + " snowd: % s \n" \ + " snoalb: % s \n" \ + " tg3: % s \n" \ + " uustar: % s \n" \ + " alvsf: % s \n" \ + " alnsf: % s \n" \ + " alvwf: % s \n" \ + " alnwf: % s \n" \ + " facsf: % s \n" \ + " facwf: % s \n" \ + " weasd: % s \n" \ + " f10m: % s \n" \ + " t2m: % s \n" \ + " q2m: % s \n" \ + " ffmm: % s \n" \ + " ffhh: % s \n" \ + " tprcp: % s \n" \ + " srflag: % s \n" \ + " sncovr: % s \n" \ + " tsfcl: % s \n" \ + " zorl: % s \n" \ + " zorll: % s \n" \ + " zorli: % s \n" \ + " zorlw: % s \n" \ + " zorlwav: % s \n" \ + " tvxy: % s \n" \ + " tgxy: % s \n" \ + " tahxy: % s \n" \ + " canicexy: % s \n" \ + " canliqxy: % s \n" \ + " eahxy: % s \n" \ + " cmxy: % s \n" \ + " chxy: % s \n" \ + " fwetxy: % s \n" \ + " sneqvoxy: % s \n" \ + " alboldxy: % s \n" \ + " qsnowxy: % s \n" \ + " wslakexy: % s \n" \ + " taussxy: % s \n" \ + " waxy: % s \n" \ + " wtxy: % s \n" \ + " zwtxy: % s \n" \ + " xlaixy: % s \n" \ + " xsaixy: % s \n" \ + " lfmassxy: % s \n" \ + " stmassxy: % s \n" \ + " rtmassxy: % s \n" \ + " woodxy: % s \n" \ + " stblcpxy: % s \n" \ + " fastcpxy: % s \n" \ + " smcwtdxy: % s \n" \ + " deeprechxy: % s \n" \ + " rechxy: % s \n" \ + " snowxy: % s \n" \ + " wetness: % s \n" \ + " clw_surf_land: % s \n" \ + " clw_surf_ice: % s \n" \ + " qwv_surf_land: % s \n" \ + " qwv_surf_ice: % s \n" \ + " tsnow_land: % s \n" \ + " tsnow_ice: % s \n" \ + " snowfallac_land: % s \n" \ + " snowfallac_ice: % s \n" \ + " sncovr_ice: % s \n" \ + " sfalb_lnd: % s \n" \ + " sfalb_lnd_bck: % s \n" \ + " emis_ice: % s \n" \ + " lai: % s \n" \ + " stddev: % s \n" \ + " convexity: % s \n" \ + " oa1: % s \n" \ + " oa2: % s \n" \ + " oa3: % s \n" \ + " oa4: % s \n" \ + " ol1: % s \n" \ + " ol2: % s \n" \ + " ol3: % s \n" \ + " ol4: % s \n" \ + " theta_oro: % s \n" \ + " gamma: % s \n" \ + " sigma: % s \n" \ + " elvmax: % s \n" \ + " oro: % s \n" \ + " oro_uf: % s \n" \ + " landfrac: % s \n" \ + " lakefrac: % s \n" \ + " lakedepth: % s \n" \ + " tref: % s \n" \ + " z_c: % s \n" \ + " c_0: % s \n" \ + " c_d: % s \n" \ + " w_0: % s \n" \ + " w_d: % s \n" \ + " xt: % s \n" \ + " xs: % s \n" \ + " xu: % s \n" \ + " xv: % s \n" \ + " xz: % s \n" \ + " zm: % s \n" \ + " xtts: % s \n" \ + " xzts: % s \n" \ + " d_conv: % s \n" \ + " ifd: % s \n" \ + " dt_cool: % s \n" \ + " qrain: % s \n" \ " Initial: \n" \ " height: % s \n" \ " theta_il: % s \n" \ + " t: % s \n" \ " qt: % s \n" \ " ql: % s \n" \ " qi: % s \n" \ @@ -112,6 +392,20 @@ def __repr__(self): " v: % s \n" \ " tke: %s \n" \ " ozone: %s \n" \ + " stc: %s \n" \ + " smc: %s \n" \ + " slc: %s \n" \ + " snicexy: % s \n" \ + " snliqxy: % s \n" \ + " tsnoxy: % s \n" \ + " smoiseq: % s \n" \ + " zsnsoxy: % s \n" \ + " tiice: % s \n" \ + " tslb: % s \n" \ + " smois: % s \n" \ + " sh2o: % s \n" \ + " smfr: % s \n" \ + " flfr: % s \n" \ " Forcing: \n" \ " p_surf: %s \n" \ " T_surf: %s \n" \ @@ -132,9 +426,27 @@ def __repr__(self): " sh_flux_sfc: %s \n" \ " lh_flux_sfc: %s \n" \ % (self._name, self._missing_value, self._time, self._levels, - self._lat, self._lon, self._height, self._theta_il, + self._soil_depth, self._lat, self._lon, self._area, self._slmsk, self._vegsrc, + self._vegtyp, self._soiltyp, self._scolor, + self._slopetyp, self._tsfco, self._vegfrac, self._shdmin, + self._shdmax, self._canopy, self._hice, self._fice, self._tisfc, self._snowd, self._snoalb, + self._tg3, self._uustar, self._alvsf, self._alnsf, self._alvwf, self._alnwf, self._facsf, self._facwf, + self._weasd, self._f10m, self._t2m, self._q2m, self._ffmm, self._ffhh, + self._tprcp, self._srflag, self._sncovr, self._tsfcl, self._zorl, self._zorll, self._zorli, self._zorlw, self._zorlwav, + self._tvxy, self._tgxy, self._tahxy, self._canicexy, self._canliqxy, self._eahxy, + self._cmxy, self._chxy, self._fwetxy, self._sneqvoxy, self._alboldxy, self._qsnowxy, self._wslakexy, self._taussxy, + self._waxy, self._wtxy, self._zwtxy, self._xlaixy, self._xsaixy, self._lfmassxy, self._stmassxy, self._rtmassxy, + self._woodxy, self._stblcpxy, self._fastcpxy, self._smcwtdxy, self._deeprechxy, self._rechxy, self._snowxy, + self._wetness, self._clw_surf_land, self._clw_surf_ice, self._qwv_surf_land, self._qwv_surf_ice, self._tsnow_land, self._tsnow_ice, + self._snowfallac_land, self._snowfallac_ice, self._sncovr_ice, self._sfalb_lnd, self._sfalb_lnd_bck, self._emis_ice, self._lai, + self._stddev, self._convexity, self._oa1, self._oa2, self._oa3, self._oa4, self._ol1, self._ol2, self._ol3, self._ol4, + self._theta_oro, self._gamma, self._sigma, self._elvmax, self._oro, self._oro_uf, self._landfrac, self._lakefrac, self._lakedepth, + self._tref, self._z_c, self._c_0, self._c_d, self._w_0, self._w_d, self._xt, self._xs, self._xu, self._xv, self._xz, self._zm, + self._xtts, self._xzts, self._d_conv, self._ifd, self._dt_cool, self._qrain, + self._height, self._theta_il, self._t, self._qt, self._ql, self._qi, self._u, self._v, - self._tke, self._ozone, + self._tke, self._ozone, self._stc, self._smc, self._slc, self._snicexy, self._snliqxy, self._tsnoxy, + self._smoiseq, self._zsnsoxy, self._tiice, self._tslb, self._smois, self._sh2o, self._smfr, self._flfr, self._p_surf, self._T_surf, np.mean(self._w_ls, axis=1), np.mean(self._omega, axis=1), np.mean(self._u_g, axis=1), np.mean(self._v_g, axis=1), np.mean(self._u_nudge, axis=1), @@ -183,16 +495,513 @@ def get_case_data(case_name): time = nc_fid.variables['time'][:] levels = nc_fid.variables['levels'][:] + try: + soil_depth = nc_fid.variables['soil_depth'][:] + except KeyError: + soil_depth = [missing_value] #read variables from scalar group scalars_grp = nc_fid.groups['scalars'] lat = scalars_grp.variables['lat'][:] lon = scalars_grp.variables['lon'][:] - + try: + slmsk = scalars_grp.variables['slmsk'][:] + except KeyError: + slmsk = missing_value + try: + vegsrc = scalars_grp.variables['vegsrc'][:] + except KeyError: + vegsrc = missing_value + try: + vegtyp = scalars_grp.variables['vegtyp'][:] + except KeyError: + vegtyp = missing_value + try: + soiltyp = scalars_grp.variables['soiltyp'][:] + except KeyError: + soiltyp = missing_value + try: + scolor = scalars_grp.variables['scolor'][:] + except KeyError: + scolor = missing_value + try: + slopetyp = scalars_grp.variables['slopetyp'][:] + except KeyError: + slopetyp = missing_value + try: + tsfco = scalars_grp.variables['tsfco'][:] + except KeyError: + tsfco = missing_value + try: + vegfrac = scalars_grp.variables['vegfrac'][:] + except KeyError: + vegfrac = missing_value + try: + shdmin = scalars_grp.variables['shdmin'][:] + except KeyError: + shdmin = missing_value + try: + shdmax = scalars_grp.variables['shdmax'][:] + except KeyError: + shdmax = missing_value + try: + canopy = scalars_grp.variables['canopy'][:] + except KeyError: + canopy = missing_value + try: + hice = scalars_grp.variables['hice'][:] + except KeyError: + hice = missing_value + try: + fice = scalars_grp.variables['fice'][:] + except KeyError: + fice = missing_value + try: + tisfc = scalars_grp.variables['tisfc'][:] + except KeyError: + tisfc = missing_value + try: + snowd = scalars_grp.variables['snowd'][:] + except KeyError: + try: + snowd = scalars_grp.variables['snwdph'][:] + except KeyError: + snowd = missing_value + try: + snoalb = scalars_grp.variables['snoalb'][:] + except KeyError: + snoalb = missing_value + try: + tg3 = scalars_grp.variables['tg3'][:] + except KeyError: + tg3 = missing_value + try: + uustar = scalars_grp.variables['uustar'][:] + except KeyError: + uustar = missing_value + try: + alvsf = scalars_grp.variables['alvsf'][:] + except KeyError: + alvsf = missing_value + try: + alnsf = scalars_grp.variables['alnsf'][:] + except KeyError: + alnsf = missing_value + try: + alvwf = scalars_grp.variables['alvwf'][:] + except KeyError: + alvwf = missing_value + try: + alnwf = scalars_grp.variables['alnwf'][:] + except KeyError: + alnwf = missing_value + try: + facsf = scalars_grp.variables['facsf'][:] + except KeyError: + facsf = missing_value + try: + facwf = scalars_grp.variables['facwf'][:] + except KeyError: + facwf = missing_value + try: + weasd = scalars_grp.variables['weasd'][:] + except KeyError: + weasd = missing_value + try: + f10m = scalars_grp.variables['f10m'][:] + except KeyError: + f10m = missing_value + try: + t2m = scalars_grp.variables['t2m'][:] + except KeyError: + t2m = missing_value + try: + q2m = scalars_grp.variables['q2m'][:] + except KeyError: + q2m = missing_value + try: + ffmm = scalars_grp.variables['ffmm'][:] + except KeyError: + ffmm = missing_value + try: + ffhh = scalars_grp.variables['ffhh'][:] + except KeyError: + ffhh = missing_value + try: + tprcp = scalars_grp.variables['tprcp'][:] + except KeyError: + tprcp = missing_value + try: + srflag = scalars_grp.variables['srflag'][:] + except KeyError: + srflag = missing_value + try: + sncovr = scalars_grp.variables['sncovr'][:] + except KeyError: + sncovr = missing_value + try: + tsfcl = scalars_grp.variables['tsfcl'][:] + except KeyError: + tsfcl = missing_value + try: + zorl = scalars_grp.variables['zorl'][:] + except KeyError: + zorl = missing_value + try: + zorll = scalars_grp.variables['zorll'][:] + except KeyError: + zorll = missing_value + try: + zorli = scalars_grp.variables['zorli'][:] + except KeyError: + zorli = missing_value + try: + zorlw = scalars_grp.variables['zorlw'][:] + except KeyError: + zorlw = missing_value + try: + zorlwav = scalars_grp.variables['zorlwav'][:] + except KeyError: + zorlwav = missing_value + try: + tvxy = scalars_grp.variables['tvxy'][:] + except KeyError: + tvxy = missing_value + try: + tgxy = scalars_grp.variables['tgxy'][:] + except KeyError: + tgxy = missing_value + try: + tahxy = scalars_grp.variables['tahxy'][:] + except KeyError: + tahxy = missing_value + try: + canicexy = scalars_grp.variables['canicexy'][:] + except KeyError: + canicexy = missing_value + try: + canliqxy = scalars_grp.variables['canliqxy'][:] + except KeyError: + canliqxy = missing_value + try: + eahxy = scalars_grp.variables['eahxy'][:] + except KeyError: + eahxy = missing_value + try: + cmxy = scalars_grp.variables['cmxy'][:] + except KeyError: + cmxy = missing_value + try: + chxy = scalars_grp.variables['chxy'][:] + except KeyError: + chxy = missing_value + try: + fwetxy = scalars_grp.variables['fwetxy'][:] + except KeyError: + fwetxy = missing_value + try: + sneqvoxy = scalars_grp.variables['sneqvoxy'][:] + except KeyError: + sneqvoxy = missing_value + try: + alboldxy = scalars_grp.variables['alboldxy'][:] + except KeyError: + alboldxy = missing_value + try: + qsnowxy = scalars_grp.variables['qsnowxy'][:] + except KeyError: + qsnowxy = missing_value + try: + wslakexy = scalars_grp.variables['wslakexy'][:] + except KeyError: + wslakexy = missing_value + try: + taussxy = scalars_grp.variables['taussxy'][:] + except KeyError: + taussxy = missing_value + try: + waxy = scalars_grp.variables['waxy'][:] + except KeyError: + waxy = missing_value + try: + wtxy = scalars_grp.variables['wtxy'][:] + except KeyError: + wtxy = missing_value + try: + zwtxy = scalars_grp.variables['zwtxy'][:] + except KeyError: + zwtxy = missing_value + try: + xlaixy = scalars_grp.variables['xlaixy'][:] + except KeyError: + xlaixy = missing_value + try: + xsaixy = scalars_grp.variables['xsaixy'][:] + except KeyError: + xsaixy = missing_value + try: + lfmassxy = scalars_grp.variables['lfmassxy'][:] + except KeyError: + lfmassxy = missing_value + try: + stmassxy = scalars_grp.variables['stmassxy'][:] + except KeyError: + stmassxy = missing_value + try: + rtmassxy = scalars_grp.variables['rtmassxy'][:] + except KeyError: + rtmassxy = missing_value + try: + woodxy = scalars_grp.variables['woodxy'][:] + except KeyError: + woodxy = missing_value + try: + stblcpxy = scalars_grp.variables['stblcpxy'][:] + except KeyError: + stblcpxy = missing_value + try: + fastcpxy = scalars_grp.variables['fastcpxy'][:] + except KeyError: + fastcpxy = missing_value + try: + smcwtdxy = scalars_grp.variables['smcwtdxy'][:] + except KeyError: + smcwtdxy = missing_value + try: + deeprechxy = scalars_grp.variables['deeprechxy'][:] + except KeyError: + deeprechxy = missing_value + try: + rechxy = scalars_grp.variables['rechxy'][:] + except KeyError: + rechxy = missing_value + try: + snowxy = scalars_grp.variables['snowxy'][:] + except KeyError: + snowxy = missing_value + try: + wetness = scalars_grp.variables['wetness'][:] + except KeyError: + wetness = missing_value + try: + clw_surf_land = scalars_grp.variables['clw_surf_land'][:] + except KeyError: + clw_surf_land = missing_value + try: + clw_surf_ice = scalars_grp.variables['clw_surf_ice'][:] + except KeyError: + clw_surf_ice = missing_value + try: + qwv_surf_land = scalars_grp.variables['qwv_surf_land'][:] + except KeyError: + qwv_surf_land = missing_value + try: + qwv_surf_ice = scalars_grp.variables['qwv_surf_ice'][:] + except KeyError: + qwv_surf_ice = missing_value + try: + tsnow_land = scalars_grp.variables['tsnow_land'][:] + except KeyError: + tsnow_land = missing_value + try: + tsnow_ice = scalars_grp.variables['tsnow_ice'][:] + except KeyError: + tsnow_ice = missing_value + try: + snowfallac_land = scalars_grp.variables['snowfallac_land'][:] + except KeyError: + snowfallac_land = missing_value + try: + snowfallac_ice = scalars_grp.variables['snowfallac_ice'][:] + except KeyError: + snowfallac_ice = missing_value + try: + sncovr_ice = scalars_grp.variables['sncovr_ice'][:] + except KeyError: + sncovr_ice = missing_value + try: + sfalb_lnd = scalars_grp.variables['sfalb_lnd'][:] + except KeyError: + sfalb_lnd = missing_value + try: + sfalb_lnd_bck = scalars_grp.variables['sfalb_lnd_bck'][:] + except KeyError: + sfalb_lnd_bck = missing_value + try: + emis_ice = scalars_grp.variables['emis_ice'][:] + except KeyError: + emis_ice = missing_value + try: + lai = scalars_grp.variables['lai'][:] + except KeyError: + lai = missing_value + try: + area = scalars_grp.variables['area'][:] + except KeyError: + area = missing_value + try: + stddev = scalars_grp.variables['stddev'][:] + except KeyError: + stddev = missing_value + try: + convexity = scalars_grp.variables['convexity'][:] + except KeyError: + convexity = missing_value + try: + oa1 = scalars_grp.variables['oa1'][:] + except KeyError: + oa1 = missing_value + try: + oa2 = scalars_grp.variables['oa2'][:] + except KeyError: + oa2 = missing_value + try: + oa3 = scalars_grp.variables['oa3'][:] + except KeyError: + oa3 = missing_value + try: + oa4 = scalars_grp.variables['oa4'][:] + except KeyError: + oa4 = missing_value + try: + ol1 = scalars_grp.variables['ol1'][:] + except KeyError: + ol1 = missing_value + try: + ol2 = scalars_grp.variables['ol2'][:] + except KeyError: + ol2 = missing_value + try: + ol3 = scalars_grp.variables['ol3'][:] + except KeyError: + ol3 = missing_value + try: + ol4 = scalars_grp.variables['ol4'][:] + except KeyError: + ol4 = missing_value + try: + theta_oro = scalars_grp.variables['theta_oro'][:] + except KeyError: + theta_oro = missing_value + try: + gamma = scalars_grp.variables['gamma'][:] + except KeyError: + gamma = missing_value + try: + sigma = scalars_grp.variables['sigma'][:] + except KeyError: + sigma = missing_value + try: + elvmax = scalars_grp.variables['elvmax'][:] + except KeyError: + elvmax = missing_value + try: + oro = scalars_grp.variables['oro'][:] + except KeyError: + oro = missing_value + try: + oro_uf = scalars_grp.variables['oro_uf'][:] + except KeyError: + oro_uf = missing_value + try: + landfrac = scalars_grp.variables['landfrac'][:] + except KeyError: + landfrac = missing_value + try: + lakefrac = scalars_grp.variables['lakefrac'][:] + except KeyError: + lakefrac = missing_value + try: + lakedepth = scalars_grp.variables['lakedepth'][:] + except KeyError: + lakedepth = missing_value + try: + tref = scalars_grp.variables['tref'][:] + except KeyError: + tref = missing_value + try: + z_c = scalars_grp.variables['z_c'][:] + except KeyError: + z_c = missing_value + try: + c_0 = scalars_grp.variables['c_0'][:] + except KeyError: + c_0 = missing_value + try: + c_d = scalars_grp.variables['c_d'][:] + except KeyError: + c_d = missing_value + try: + w_0 = scalars_grp.variables['w_0'][:] + except KeyError: + w_0 = missing_value + try: + w_d = scalars_grp.variables['w_0'][:] + except KeyError: + w_d = missing_value + try: + xt = scalars_grp.variables['xt'][:] + except KeyError: + xt = missing_value + try: + xs = scalars_grp.variables['xs'][:] + except KeyError: + xs = missing_value + try: + xu = scalars_grp.variables['xu'][:] + except KeyError: + xu = missing_value + try: + xv = scalars_grp.variables['xv'][:] + except KeyError: + xv = missing_value + try: + xz = scalars_grp.variables['xz'][:] + except KeyError: + xz = missing_value + try: + zm = scalars_grp.variables['zm'][:] + except KeyError: + zm = missing_value + try: + xtts = scalars_grp.variables['xtts'][:] + except KeyError: + xtts = missing_value + try: + xzts = scalars_grp.variables['xzts'][:] + except KeyError: + xzts = missing_value + try: + d_conv = scalars_grp.variables['d_conv'][:] + except KeyError: + d_conv = missing_value + try: + ifd = scalars_grp.variables['ifd'][:] + except KeyError: + ifd = missing_value + try: + dt_cool = scalars_grp.variables['dt_cool'][:] + except KeyError: + dt_cool = missing_value + try: + qrain = scalars_grp.variables['qrains'][:] + except KeyError: + qrain = missing_value + #read variables from initial group initial_grp = nc_fid.groups['initial'] - height = initial_grp.variables['height'][:] - theta_il = initial_grp.variables['thetail'][:] + try: + height = initial_grp.variables['height'][:] + except KeyError: + height = [missing_value] + try: + theta_il = initial_grp.variables['thetail'][:] + except KeyError: + theta_il = [missing_value] + try: + t = initial_grp.variables['temp'][:] + except KeyError: + t = [missing_value] qt = initial_grp.variables['qt'][:] ql = initial_grp.variables['ql'][:] qi = initial_grp.variables['qi'][:] @@ -200,6 +1009,62 @@ def get_case_data(case_name): v = initial_grp.variables['v'][:] tke = initial_grp.variables['tke'][:] ozone = initial_grp.variables['ozone'][:] + try: + stc = initial_grp.variables['stc'][:] + except KeyError: + stc = [missing_value] + try: + smc = initial_grp.variables['smc'][:] + except KeyError: + smc = [missing_value] + try: + slc = initial_grp.variables['slc'][:] + except KeyError: + slc = [missing_value] + try: + snicexy = initial_grp.variables['snicexy'][:] + except KeyError: + snicexy = [missing_value] + try: + snliqxy = initial_grp.variables['snliqxy'][:] + except KeyError: + snliqxy = [missing_value] + try: + tsnoxy = initial_grp.variables['tsnoxy'][:] + except KeyError: + tsnoxy = [missing_value] + try: + smoiseq = initial_grp.variables['smoiseq'][:] + except KeyError: + smoiseq = [missing_value] + try: + zsnsoxy = initial_grp.variables['zsnsoxy'][:] + except KeyError: + zsnsoxy = [missing_value] + try: + tiice = initial_grp.variables['tiice'][:] + except KeyError: + tiice = [missing_value] + try: + tslb = initial_grp.variables['tslb'][:] + except KeyError: + tslb = [missing_value] + try: + smois = initial_grp.variables['smois'][:] + except KeyError: + smois = [missing_value] + try: + sh2o = initial_grp.variables['sh2o'][:] + except KeyError: + sh2o = [missing_value] + try: + smfr = initial_grp.variables['smfr'][:] + except KeyError: + smfr = [missing_value] + try: + flfr = initial_grp.variables['flfr'][:] + except KeyError: + flfr = [missing_value] #read variables from forcing group forcing_grp = nc_fid.groups['forcing'] @@ -230,8 +1095,20 @@ def get_case_data(case_name): nc_fid.close() - case_data = Case_Data(case_name, missing_value, time, levels, lat, lon, - height, theta_il, qt, ql, qi, u, v, tke, ozone, + case_data = Case_Data(case_name, missing_value, time, levels, soil_depth, lat, lon, + slmsk, vegsrc, vegtyp, soiltyp, scolor, slopetyp, tsfco, vegfrac, shdmin, shdmax, + canopy, hice, fice, tisfc, snowd, snoalb, tg3, uustar, + alvsf, alnsf, alvwf, alnwf, facsf, facwf, weasd, f10m, t2m, q2m, ffmm, ffhh, + tprcp, srflag, sncovr, tsfcl, zorl, zorll, zorli, zorlw, zorlwav, tvxy, tgxy, tahxy, canicexy, canliqxy, eahxy, + cmxy, chxy, fwetxy, sneqvoxy, alboldxy, qsnowxy, wslakexy, taussxy, + waxy, wtxy, zwtxy, xlaixy, xsaixy, + lfmassxy, stmassxy, rtmassxy, woodxy, stblcpxy, fastcpxy, smcwtdxy, deeprechxy, rechxy, snowxy, + wetness, clw_surf_land, clw_surf_ice, qwv_surf_land, qwv_surf_ice, tsnow_land, tsnow_ice, + snowfallac_land, snowfallac_ice, sncovr_ice, sfalb_lnd, sfalb_lnd_bck, emis_ice, lai, area, + stddev, convexity, oa1, oa2, oa3, oa4, ol1, ol3, ol3, ol4, theta_oro, gamma, sigma, elvmax, oro, oro_uf, landfrac, lakefrac, lakedepth, + tref, z_c, c_0, c_d, w_0, w_d, xt, xs, xu, xv, xz, zm, xtts, xzts, d_conv, ifd, dt_cool, qrain, + height, theta_il, t, qt, ql, qi, u, v, tke, ozone, stc, smc, slc, + snicexy, snliqxy, tsnoxy, smoiseq, zsnsoxy, tiice, tslb, smois, sh2o, smfr, flfr, p_surf, T_surf, w_ls, omega, u_g, v_g, u_nudge, v_nudge, T_nudge, thil_nudge, qt_nudge, dT_dt_rad, h_advec_thil, v_advec_thil, h_advec_qt, @@ -252,6 +1129,7 @@ def write_SCM_case_file(case_nml, case_data, use_area): forcing_on = 1 forcing_off = 0 + nml_keys = case_nml['case_config'].todict().keys() nml_filename = os.path.join(CASE_NML_DIR, case_nml['case_config']['case_name'] + '.nml') # Output file @@ -285,13 +1163,22 @@ def write_SCM_case_file(case_nml, case_data, use_area): logging.debug('Case duration: {}'.format(delta)) logging.debug('Case end date: {}'.format(end_date)) - if (case_nml['case_config']['sfc_type'] == 0): - surface_string = 'ocean' - elif (case_nml['case_config']['sfc_type'] == 1): - surface_string = 'land' - elif (case_nml['case_config']['sfc_type'] == 2): + if (case_nml['case_config']['sfc_type'] > 1.5): surface_string = 'ice' + elif (case_nml['case_config']['sfc_type'] > 0.5): + surface_string = 'land' + else: + surface_string = 'ocean' + #override case nml with LSM/model data + if ('lsm_ics' in nml_keys): + if (case_nml['case_config']['lsm_ics']): + if (case_data._slmsk > 1.5): + surface_string = 'ice' + elif (case_data._slmsk > 0.5): + surface_string = 'land' + else: + surface_string = 'ocean' #DEPHY v1 format specifies the global attributes in this order. Some attributes are rewritten below after the order is established in the file. nc_file.case = case_string @@ -356,6 +1243,7 @@ def write_SCM_case_file(case_nml, case_data, use_area): nc_file.surface_forcing_temp = 'none' nc_file.surface_forcing_moisture = 'none' nc_file.surface_forcing_wind = 'none' + nc_file.surface_forcing_lsm = 'none' #rewrite forc_wa, forc_wap, forc_geo, nudging_ua, nudging_va depending on mom_forcing_type provided in case_config nml if (case_nml['case_config']['mom_forcing_type'] == 2): @@ -473,6 +1361,23 @@ def write_SCM_case_file(case_nml, case_data, use_area): timei_dim = nc_file.createDimension('t0', 1) lev_dim = nc_file.createDimension('lev', case_data._levels.shape[0]) + if ('lsm_ics' in nml_keys or 'model_ics' in nml_keys): + nc_file.surface_forcing_lsm = 'lsm' + if (('lsm_ics' in nml_keys and case_nml['case_config']['lsm_ics']) or ('model_ics' in nml_keys and case_nml['case_config']['model_ics'])): + if (case_data._soil_depth[0] != case_data._missing_value): + soil_dim = nc_file.createDimension('nsoil', case_data._soil_depth.shape[0]) + else: + message = 'LSM ICs are expected from the case_nml file, but no soil depth is provided.' + logging.critical(message) + raise Exception(message) + + if (case_data._snicexy[0] != case_data._missing_value): + snow_dim = nc_file.createDimension('nsnow', case_data._snicexy.shape[0]) + nslsnw_dim = nc_file.createDimension('nsoil_plus_nsnow',case_data._snicexy.shape[0] + case_data._soil_depth.shape[0]) + + if (case_data._tiice[0] != case_data._missing_value): + ice_dim = nc_file.createDimension('nice', case_data._tiice[0]) + # timei_var = nc_file.createVariable('t0', wp, ('t0')) timei_var.units = 'seconds since ' + start_date_string @@ -491,6 +1396,12 @@ def write_SCM_case_file(case_nml, case_data, use_area): lev_var.standard_name = 'pressure' lev_var[:] = case_data._levels[:] + if (case_data._soil_depth[0] != case_data._missing_value): + soil_depth_var = nc_file.createVariable('soil_depth', wp, ('nsoil')) + soil_depth_var.units = 'm' + soil_depth_var.standard_name = 'depth of bottom of soil layers' + soil_depth_var[:] = case_data._soil_depth[:] + # lon_var = nc_file.createVariable('lon', wp, ('time')) lon_var.units = 'degrees_east' @@ -503,11 +1414,742 @@ def write_SCM_case_file(case_nml, case_data, use_area): lat_var.standard_name = 'latitude' lat_var[:] = case_data._lat - # - thetal_var = nc_file.createVariable('thetal', wp, ('t0','lev')) - thetal_var.units = 'K' - thetal_var.standard_name = 'air_liquid_potential_temperature' - thetal_var[:] = case_data._theta_il[:] + if (case_data._slmsk != case_data._missing_value): + slmsk_var = nc_file.createVariable('slmsk', wp) + slmsk_var.units = 'none' + slmsk_var.standard_name = 'land_sea_ice_mask' + slmsk_var[:] = case_data._slmsk + + if (case_data._vegsrc != case_data._missing_value): + vegsrc_var = nc_file.createVariable('vegsrc', wp) + vegsrc_var.units = 'none' + vegsrc_var.standard_name = 'vegetation source (1-2)' + vegsrc_var[:] = case_data._vegsrc + + if (case_data._vegtyp != case_data._missing_value): + vegtyp_var = nc_file.createVariable('vegtyp', wp) + vegtyp_var.units = 'none' + vegtyp_var.standard_name = 'vegetation type (1-12)' + vegtyp_var[:] = case_data._vegtyp + + if (case_data._soiltyp != case_data._missing_value): + soiltyp_var = nc_file.createVariable('soiltyp', wp) + soiltyp_var.units = 'none' + soiltyp_var.standard_name = 'soil type (1-12)' + soiltyp_var[:] = case_data._soiltyp + + if (case_data._scolor != case_data._missing_value): + scolor_var = nc_file.createVariable('scolor', wp) + scolor_var.units = 'none' + scolor_var.standard_name = 'soil color' + scolor_var[:] = case_data._scolor + + if (case_data._slopetyp != case_data._missing_value): + slopetyp_var = nc_file.createVariable('slopetyp', wp) + slopetyp_var.units = 'none' + slopetyp_var.standard_name = 'slope type (1-9)' + slopetyp_var[:] = case_data._slopetyp + + if (case_data._tsfco != case_data._missing_value): + tsfco_var = nc_file.createVariable('tsfco', wp) + tsfco_var.units = 'none' + tsfco_var.standard_name = 'slope type (1-9)' + tsfco_var[:] = case_data._tsfco + + if (case_data._vegfrac != case_data._missing_value): + vegfrac_var = nc_file.createVariable('vegfrac', wp) + vegfrac_var.units = 'none' + vegfrac_var.standard_name = 'slope type (1-9)' + vegfrac_var[:] = case_data._vegfrac + + if (case_data._shdmin != case_data._missing_value): + shdmin_var = nc_file.createVariable('shdmin', wp) + shdmin_var.units = 'none' + shdmin_var.standard_name = 'slope type (1-9)' + shdmin_var[:] = case_data._shdmin + + if (case_data._shdmax != case_data._missing_value): + shdmax_var = nc_file.createVariable('shdmax', wp) + shdmax_var.units = 'none' + shdmax_var.standard_name = 'slope type (1-9)' + shdmax_var[:] = case_data._shdmax + + if (case_data._canopy != case_data._missing_value): + canopy_var = nc_file.createVariable('canopy', wp) + canopy_var.units = 'kg m-2' + canopy_var.standard_name = 'amount of water stored in canopy' + canopy_var[:] = case_data._canopy + + if (case_data._hice != case_data._missing_value): + hice_var = nc_file.createVariable('hice', wp) + hice_var.units = 'm' + hice_var.standard_name = 'sea ice thickness' + hice_var[:] = case_data._hice + + if (case_data._fice != case_data._missing_value): + fice_var = nc_file.createVariable('fice', wp) + fice_var.units = 'none' + fice_var.standard_name = 'ice fraction' + fice_var[:] = case_data._fice + + if (case_data._tisfc != case_data._missing_value): + tisfc_var = nc_file.createVariable('tisfc', wp) + tisfc_var.units = 'K' + tisfc_var.standard_name = 'ice surface temperature' + tisfc_var[:] = case_data._tisfc + + if (case_data._snowd != case_data._missing_value): + snowd_var = nc_file.createVariable('snowd', wp) + snowd_var.units = 'mm' + snowd_var.standard_name = 'water equivalent snow depth' + snowd_var[:] = case_data._snowd + + if (case_data._snoalb != case_data._missing_value): + snoalb_var = nc_file.createVariable('snoalb', wp) + snoalb_var.units = 'none' + snoalb_var.standard_name = 'maximum snow albedo' + snoalb_var[:] = case_data._snoalb + + if (case_data._tg3 != case_data._missing_value): + tg3_var = nc_file.createVariable('tg3', wp) + tg3_var.units = 'K' + tg3_var.standard_name = 'deep soil temperature' + tg3_var[:] = case_data._tg3 + + if (case_data._uustar != case_data._missing_value): + uustar_var = nc_file.createVariable('uustar', wp) + uustar_var.units = 'm s-1' + uustar_var.standard_name = 'surface_friction_velocity' + uustar_var[:] = case_data._uustar + + if (case_data._alvsf != case_data._missing_value): + alvsf_var = nc_file.createVariable('alvsf', wp) + alvsf_var.units = 'none' + alvsf_var.standard_name = '60 degree vis albedo with strong cosz dependency' + alvsf_var[:] = case_data._alvsf + + if (case_data._alnsf != case_data._missing_value): + alnsf_var = nc_file.createVariable('alnsf', wp) + alnsf_var.units = 'none' + alnsf_var.standard_name = '60 degree nir albedo with strong cosz dependency' + alnsf_var[:] = case_data._alnsf + + if (case_data._alvwf != case_data._missing_value): + alvwf_var = nc_file.createVariable('alvwf', wp) + alvwf_var.units = 'none' + alvwf_var.standard_name = '60 degree vis albedo with weak cosz dependency' + alvwf_var[:] = case_data._alvwf + + if (case_data._alnwf != case_data._missing_value): + alnwf_var = nc_file.createVariable('alnwf', wp) + alnwf_var.units = 'none' + alnwf_var.standard_name = '60 degree nir albedo with weak cosz dependency' + alnwf_var[:] = case_data._alnwf + + if (case_data._facsf != case_data._missing_value): + facsf_var = nc_file.createVariable('facsf', wp) + facsf_var.units = 'none' + facsf_var.standard_name = 'fractional coverage with strong cosz dependency' + facsf_var[:] = case_data._facsf + + if (case_data._facwf != case_data._missing_value): + facwf_var = nc_file.createVariable('facwf', wp) + facwf_var.units = 'none' + facwf_var.standard_name = 'fractional coverage with weak cosz dependency' + facwf_var[:] = case_data._facwf + + if (case_data._weasd != case_data._missing_value): + weasd_var = nc_file.createVariable('weasd', wp) + weasd_var.units = 'mm' + weasd_var.standard_name = 'water equivalent accumulated snow depth' + weasd_var[:] = case_data._weasd + + if (case_data._f10m != case_data._missing_value): + f10m_var = nc_file.createVariable('f10m', wp) + f10m_var.units = 'none' + f10m_var.standard_name = 'ratio of sigma level 1 wind and 10m wind' + f10m_var[:] = case_data._f10m + + if (case_data._t2m != case_data._missing_value): + t2m_var = nc_file.createVariable('t2m', wp) + t2m_var.units = 'K' + t2m_var.standard_name = '2-meter absolute temperature' + t2m_var[:] = case_data._t2m + + if (case_data._q2m != case_data._missing_value): + q2m_var = nc_file.createVariable('q2m', wp) + q2m_var.units = 'kg kg-1' + q2m_var.standard_name = '2-meter specific humidity' + q2m_var[:] = case_data._q2m + + if (case_data._ffmm != case_data._missing_value): + ffmm_var = nc_file.createVariable('ffmm', wp) + ffmm_var.units = 'none' + ffmm_var.standard_name = 'Monin-Obukhov similarity function for momentum' + ffmm_var[:] = case_data._ffmm + + if (case_data._ffhh != case_data._missing_value): + ffhh_var = nc_file.createVariable('ffhh', wp) + ffhh_var.units = 'none' + ffhh_var.standard_name = 'Monin-Obukhov similarity function for heat' + ffhh_var[:] = case_data._ffhh + + if (case_data._tprcp != case_data._missing_value): + tprcp_var = nc_file.createVariable('tprcp', wp) + tprcp_var.units = 'm' + tprcp_var.standard_name = 'instantaneous total precipitation amount' + tprcp_var[:] = case_data._tprcp + + if (case_data._srflag != case_data._missing_value): + srflag_var = nc_file.createVariable('srflag', wp) + srflag_var.units = 'none' + srflag_var.standard_name = 'snow/rain flag for precipitation' + srflag_var[:] = case_data._srflag + + if (case_data._sncovr != case_data._missing_value): + sncovr_var = nc_file.createVariable('sncovr', wp) + sncovr_var.units = 'none' + sncovr_var.standard_name = 'surface snow area fraction' + sncovr_var[:] = case_data._sncovr + + if (case_data._tsfcl != case_data._missing_value): + tsfcl_var = nc_file.createVariable('tsfcl', wp) + tsfcl_var.units = 'K' + tsfcl_var.standard_name = 'surface skin temperature over land' + tsfcl_var[:] = case_data._tsfcl + + if (case_data._zorl != case_data._missing_value): + zorl_var = nc_file.createVariable('zorl', wp) + zorl_var.units = 'cm' + zorl_var.standard_name = 'surface roughness length' + zorl_var[:] = case_data._zorl + + if (case_data._zorll != case_data._missing_value): + zorll_var = nc_file.createVariable('zorll', wp) + zorll_var.units = 'cm' + zorll_var.standard_name = 'surface roughness length over land' + zorll_var[:] = case_data._zorll + + if (case_data._zorli != case_data._missing_value): + zorli_var = nc_file.createVariable('zorli', wp) + zorli_var.units = 'cm' + zorli_var.standard_name = 'surface roughness length over ice' + zorli_var[:] = case_data._zorli + + if (case_data._zorlw != case_data._missing_value): + zorlw_var = nc_file.createVariable('zorlw', wp) + zorlw_var.units = 'cm' + zorlw_var.standard_name = 'surface roughness length over ocean' + zorlw_var[:] = case_data._zorlw + + if (case_data._zorlwav != case_data._missing_value): + zorlwav_var = nc_file.createVariable('zorlwav', wp) + zorlwav_var.units = 'cm' + zorlwav_var.standard_name = 'surface_roughness_length_from_wave_model' + zorlwav_var[:] = case_data._zorlwav + + if (case_data._tvxy != case_data._missing_value): + tvxy_var = nc_file.createVariable('tvxy', wp) + tvxy_var.units = 'K' + tvxy_var.standard_name = 'vegetation temperature for NoahMP' + tvxy_var[:] = case_data._tvxy + + if (case_data._tgxy != case_data._missing_value): + tgxy_var = nc_file.createVariable('tgxy', wp) + tgxy_var.units = 'K' + tgxy_var.standard_name = 'ground temperature for NoahMP' + tgxy_var[:] = case_data._tgxy + + if (case_data._tahxy != case_data._missing_value): + tahxy_var = nc_file.createVariable('tahxy', wp) + tahxy_var.units = 'K' + tahxy_var.standard_name = 'canopy air temperature for NoahMP' + tahxy_var[:] = case_data._tahxy + + if (case_data._canicexy != case_data._missing_value): + canicexy_var = nc_file.createVariable('canicexy', wp) + canicexy_var.units = 'mm' + canicexy_var.standard_name = 'canopy intercepted ice mass for NoahMP' + canicexy_var[:] = case_data._canicexy + + if (case_data._canliqxy != case_data._missing_value): + canliqxy_var = nc_file.createVariable('canliqxy', wp) + canliqxy_var.units = 'mm' + canliqxy_var.standard_name = 'canopy intercepted liquid water for NoahMP' + canliqxy_var[:] = case_data._canliqxy + + if (case_data._eahxy != case_data._missing_value): + eahxy_var = nc_file.createVariable('eahxy', wp) + eahxy_var.units = 'Pa' + eahxy_var.standard_name = 'canopy air vapor pressure for NoahMP' + eahxy_var[:] = case_data._eahxy + + if (case_data._cmxy != case_data._missing_value): + cmxy_var = nc_file.createVariable('cmxy', wp) + cmxy_var.units = 'none' + cmxy_var.standard_name = 'surface drag coefficient for momentum for NoahMP' + cmxy_var[:] = case_data._cmxy + + if (case_data._chxy != case_data._missing_value): + chxy_var = nc_file.createVariable('chxy', wp) + chxy_var.units = 'none' + chxy_var.standard_name = 'surface exchange coeff heat & moisture for NoahMP' + chxy_var[:] = case_data._chxy + + if (case_data._fwetxy != case_data._missing_value): + fwetxy_var = nc_file.createVariable('fwetxy', wp) + fwetxy_var.units = 'none' + fwetxy_var.standard_name = 'area fraction of canopy that is wetted/snowed for NoahMP' + fwetxy_var[:] = case_data._fwetxy + + if (case_data._sneqvoxy != case_data._missing_value): + sneqvoxy_var = nc_file.createVariable('sneqvoxy', wp) + sneqvoxy_var.units = 'mm' + sneqvoxy_var.standard_name = 'snow mass at previous time step for NoahMP' + sneqvoxy_var[:] = case_data._sneqvoxy + + if (case_data._alboldxy != case_data._missing_value): + alboldxy_var = nc_file.createVariable('alboldxy', wp) + alboldxy_var.units = 'none' + alboldxy_var.standard_name = 'snow albedo at previous time step for NoahMP' + alboldxy_var[:] = case_data._alboldxy + + if (case_data._qsnowxy != case_data._missing_value): + qsnowxy_var = nc_file.createVariable('qsnowxy', wp) + qsnowxy_var.units = 'mm s-1' + qsnowxy_var.standard_name = 'snow precipitation rate at surface for NoahMP' + qsnowxy_var[:] = case_data._qsnowxy + + if (case_data._wslakexy != case_data._missing_value): + wslakexy_var = nc_file.createVariable('wslakexy', wp) + wslakexy_var.units = 'mm' + wslakexy_var.standard_name = 'lake water storage for NoahMP' + wslakexy_var[:] = case_data._wslakexy + + if (case_data._taussxy != case_data._missing_value): + taussxy_var = nc_file.createVariable('taussxy', wp) + taussxy_var.units = 'none' + taussxy_var.standard_name = 'non-dimensional snow age for NoahMP' + taussxy_var[:] = case_data._taussxy + + + if (case_data._waxy != case_data._missing_value): + waxy_var = nc_file.createVariable('waxy', wp) + waxy_var.units = 'mm' + waxy_var.standard_name = 'water storage in aquifer for NoahMP' + waxy_var[:] = case_data._waxy + + if (case_data._wtxy != case_data._missing_value): + wtxy_var = nc_file.createVariable('wtxy', wp) + wtxy_var.units = 'mm' + wtxy_var.standard_name = 'ater storage in aquifer and saturated soil for NoahMP' + wtxy_var[:] = case_data._wtxy + + if (case_data._zwtxy != case_data._missing_value): + zwtxy_var = nc_file.createVariable('zwtxy', wp) + zwtxy_var.units = 'm' + zwtxy_var.standard_name = 'water table depth for NoahMP' + zwtxy_var[:] = case_data._zwtxy + + if (case_data._xlaixy != case_data._missing_value): + xlaixy_var = nc_file.createVariable('xlaixy', wp) + xlaixy_var.units = 'none' + xlaixy_var.standard_name = 'leaf area index for NoahMP' + xlaixy_var[:] = case_data._xlaixy + + if (case_data._xsaixy != case_data._missing_value): + xsaixy_var = nc_file.createVariable('xsaixy', wp) + xsaixy_var.units = 'none' + xsaixy_var.standard_name = 'stem area index for NoahMP' + xsaixy_var[:] = case_data._xsaixy + + if (case_data._lfmassxy != case_data._missing_value): + lfmassxy_var = nc_file.createVariable('lfmassxy', wp) + lfmassxy_var.units = 'g m-2' + lfmassxy_var.standard_name = 'leaf mass for NoahMP' + lfmassxy_var[:] = case_data._lfmassxy + + if (case_data._stmassxy != case_data._missing_value): + stmassxy_var = nc_file.createVariable('stmassxy', wp) + stmassxy_var.units = 'g m-2' + stmassxy_var.standard_name = 'stem mass for NoahMP' + stmassxy_var[:] = case_data._stmassxy + + if (case_data._rtmassxy != case_data._missing_value): + rtmassxy_var = nc_file.createVariable('rtmassxy', wp) + rtmassxy_var.units = 'g m-2' + rtmassxy_var.standard_name = 'fine root mass for NoahMP' + rtmassxy_var[:] = case_data._rtmassxy + + if (case_data._woodxy != case_data._missing_value): + woodxy_var = nc_file.createVariable('woodxy', wp) + woodxy_var.units = 'g m-2' + woodxy_var.standard_name = 'wood mass including woody roots for NoahMP' + woodxy_var[:] = case_data._woodxy + + if (case_data._stblcpxy != case_data._missing_value): + stblcpxy_var = nc_file.createVariable('stblcpxy', wp) + stblcpxy_var.units = 'g m-2' + stblcpxy_var.standard_name = 'stable carbon in deep soil for NoahMP' + stblcpxy_var[:] = case_data._stblcpxy + + if (case_data._fastcpxy != case_data._missing_value): + fastcpxy_var = nc_file.createVariable('fastcpxy', wp) + fastcpxy_var.units = 'g m-2' + fastcpxy_var.standard_name = 'short-lived carbon in shallow soil for NoahMP' + fastcpxy_var[:] = case_data._fastcpxy + + if (case_data._smcwtdxy != case_data._missing_value): + smcwtdxy_var = nc_file.createVariable('smcwtdxy', wp) + smcwtdxy_var.units = 'm3 m-3' + smcwtdxy_var.standard_name = 'oil water content between the bottom of the soil and the water table for NoahMP' + smcwtdxy_var[:] = case_data._smcwtdxy + + if (case_data._deeprechxy != case_data._missing_value): + deeprechxy_var = nc_file.createVariable('deeprechxy', wp) + deeprechxy_var.units = 'm' + deeprechxy_var.standard_name = 'echarge to or from the water table when deep for NoahMP' + deeprechxy_var[:] = case_data._deeprechxy + + if (case_data._rechxy != case_data._missing_value): + rechxy_var = nc_file.createVariable('rechxy', wp) + rechxy_var.units = 'm' + rechxy_var.standard_name = 'recharge to or from the water table when shallow for NoahMP' + rechxy_var[:] = case_data._rechxy + + if (case_data._snowxy != case_data._missing_value): + snowxy_var = nc_file.createVariable('snowxy', wp) + snowxy_var.units = 'none' + snowxy_var.standard_name = 'number of snow layers for NoahMP' + snowxy_var[:] = case_data._snowxy + + if (case_data._wetness != case_data._missing_value): + wetness_var = nc_file.createVariable('wetness', wp) + wetness_var.units = 'none' + wetness_var.standard_name = 'normalized soil wetness for RUC LSM' + wetness_var[:] = case_data._wetness + + if (case_data._clw_surf_land != case_data._missing_value): + clw_surf_land_var = nc_file.createVariable('clw_surf_land', wp) + clw_surf_land_var.units = 'kg kg-1' + clw_surf_land_var.standard_name = 'cloud condensed water mixing ratio at surface over land for RUC LSM' + clw_surf_land_var[:] = case_data._clw_surf_land + + if (case_data._clw_surf_ice != case_data._missing_value): + clw_surf_ice_var = nc_file.createVariable('clw_surf_ice', wp) + clw_surf_ice_var.units = 'kg kg-1' + clw_surf_ice_var.standard_name = 'cloud condensed water mixing ratio at surface over ice for RUC LSM' + clw_surf_ice_var[:] = case_data._clw_surf_ice + + if (case_data._qwv_surf_land != case_data._missing_value): + qwv_surf_land_var = nc_file.createVariable('qwv_surf_land', wp) + qwv_surf_land_var.units = 'kg kg-1' + qwv_surf_land_var.standard_name = 'water vapor mixing ratio at surface over land for RUC LSM' + qwv_surf_land_var[:] = case_data._qwv_surf_land + + if (case_data._qwv_surf_ice != case_data._missing_value): + qwv_surf_ice_var = nc_file.createVariable('qwv_surf_ice', wp) + qwv_surf_ice_var.units = 'kg kg-1' + qwv_surf_ice_var.standard_name = 'water vapor mixing ratio at surface over ice for RUC LSM' + qwv_surf_ice_var[:] = case_data._qwv_surf_ice + + if (case_data._tsnow_land != case_data._missing_value): + tsnow_land_var = nc_file.createVariable('tsnow_land', wp) + tsnow_land_var.units = 'K' + tsnow_land_var.standard_name = 'snow temperature at the bottom of the first snow layer over land for RUC LSM' + tsnow_land_var[:] = case_data._tsnow_land + + if (case_data._tsnow_ice != case_data._missing_value): + tsnow_ice_var = nc_file.createVariable('tsnow_ice', wp) + tsnow_ice_var.units = 'K' + tsnow_ice_var.standard_name = 'snow temperature at the bottom of the first snow layer over land for RUC LSM' + tsnow_ice_var[:] = case_data._tsnow_ice + + if (case_data._snowfallac_land != case_data._missing_value): + snowfallac_land_var = nc_file.createVariable('snowfallac_land', wp) + snowfallac_land_var.units = 'kg m-2' + snowfallac_land_var.standard_name = 'run-total snow accumulation on the ground over land for RUC LSM' + snowfallac_land_var[:] = case_data._snowfallac_land + + if (case_data._snowfallac_ice != case_data._missing_value): + snowfallac_ice_var = nc_file.createVariable('snowfallac_ice', wp) + snowfallac_ice_var.units = 'kg m-2' + snowfallac_ice_var.standard_name = 'run-total snow accumulation on the ground over land for RUC LSM' + snowfallac_ice_var[:] = case_data._snowfallac_ice + + if (case_data._sncovr_ice != case_data._missing_value): + sncovr_ice_var = nc_file.createVariable('sncovr_ice', wp) + sncovr_ice_var.units = 'none' + sncovr_ice_var.standard_name = 'surface snow area fraction over ice' + sncovr_ice_var[:] = case_data._sncovr_ice + + if (case_data._sfalb_lnd != case_data._missing_value): + sfalb_lnd_var = nc_file.createVariable('sfalb_lnd', wp) + sfalb_lnd_var.units = 'none' + sfalb_lnd_var.standard_name = 'surface albedo over land for RUC LSM' + sfalb_lnd_var[:] = case_data._sfalb_lnd + + if (case_data._sfalb_lnd_bck != case_data._missing_value): + sfalb_lnd_bck_var = nc_file.createVariable('sfalb_lnd_bckß', wp) + sfalb_lnd_bck_var.units = 'none' + sfalb_lnd_bck_var.standard_name = 'surface snow-free albedo over land for RUC LSM' + sfalb_lnd_bck_var[:] = case_data._sfalb_lnd_bck + + if (case_data._emis_ice != case_data._missing_value): + emis_ice_var = nc_file.createVariable('emis_ice', wp) + emis_ice_var.units = 'none' + emis_ice_var.standard_name = 'surface emissivity over ice for RUC LSM' + emis_ice_var[:] = case_data._emis_ice + + if (case_data._lai != case_data._missing_value): + lai_var = nc_file.createVariable('lai', wp) + lai_var.units = 'none' + lai_var.standard_name = 'leaf area index for RUC LSM' + lai_var[:] = case_data._lai + + area_var = nc_file.createVariable('area', wp) + area_var.units = 'm2' + area_var.standard_name = 'grid cell area' + if ('column_area' in nml_keys and case_nml['case_config']['column_area']): + area_var[:] = case_nml['case_config']['column_area'] + message = 'Since column_area was supplied in the case namelist, it will be used instead of the data from the case data file (if it exists).' + logging.info(message) + elif (case_data._area != case_data._missing_value): + area_var[:] = case_data._area + + if (case_data._stddev != case_data._missing_value): + stddev_var = nc_file.createVariable('stddev', wp) + stddev_var.units = 'm' + stddev_var.standard_name = 'standard deviation of subgrid orography' + stddev_var[:] = case_data._stddev + + if (case_data._convexity != case_data._missing_value): + convexity_var = nc_file.createVariable('convexity', wp) + convexity_var.units = 'none' + convexity_var.standard_name = 'convexity of subgrid orography' + convexity_var[:] = case_data._convexity + + if (case_data._oa1 != case_data._missing_value): + oa1_var = nc_file.createVariable('oa1', wp) + oa1_var.units = 'none' + oa1_var.standard_name = 'assymetry of subgrid orography 1' + oa1_var[:] = case_data._oa1 + + if (case_data._oa2 != case_data._missing_value): + oa2_var = nc_file.createVariable('oa2', wp) + oa2_var.units = 'none' + oa2_var.standard_name = 'assymetry of subgrid orography 2' + oa2_var[:] = case_data._oa2 + + if (case_data._oa3 != case_data._missing_value): + oa3_var = nc_file.createVariable('oa3', wp) + oa3_var.units = 'none' + oa3_var.standard_name = 'assymetry of subgrid orography 3' + oa3_var[:] = case_data._oa3 + + if (case_data._oa4 != case_data._missing_value): + oa4_var = nc_file.createVariable('oa4', wp) + oa4_var.units = 'none' + oa4_var.standard_name = 'assymetry of subgrid orography 4' + oa4_var[:] = case_data._oa4 + + if (case_data._ol1 != case_data._missing_value): + ol1_var = nc_file.createVariable('ol1', wp) + ol1_var.units = 'none' + ol1_var.standard_name = 'fraction of grid box with subgrid orography higher than critical height 1' + ol1_var[:] = case_data._ol1 + + if (case_data._ol2 != case_data._missing_value): + ol2_var = nc_file.createVariable('ol2', wp) + ol2_var.units = 'none' + ol2_var.standard_name = 'fraction of grid box with subgrid orography higher than critical height 2' + ol2_var[:] = case_data._ol2 + + if (case_data._ol3 != case_data._missing_value): + ol3_var = nc_file.createVariable('ol3', wp) + ol3_var.units = 'none' + ol3_var.standard_name = 'fraction of grid box with subgrid orography higher than critical height 3' + ol3_var[:] = case_data._ol3 + + if (case_data._ol4 != case_data._missing_value): + ol4_var = nc_file.createVariable('ol4', wp) + ol4_var.units = 'none' + ol4_var.standard_name = 'fraction of grid box with subgrid orography higher than critical height 4' + ol4_var[:] = case_data._ol4 + + if (case_data._theta_oro != case_data._missing_value): + theta_oro_var = nc_file.createVariable('theta_oro', wp) + theta_oro_var.units = 'deg' + theta_oro_var.standard_name = 'angle with respect to east of maximum subgrid orographic variations' + theta_oro_var[:] = case_data._theta_oro + + if (case_data._gamma != case_data._missing_value): + gamma_var = nc_file.createVariable('gamma', wp) + gamma_var.units = 'none' + gamma_var.standard_name = 'anisotropy of subgrid orography' + gamma_var[:] = case_data._gamma + + if (case_data._sigma != case_data._missing_value): + sigma_var = nc_file.createVariable('sigma', wp) + sigma_var.units = 'none' + sigma_var.standard_name = 'slope of subgrid orography' + sigma_var[:] = case_data._sigma + + if (case_data._elvmax != case_data._missing_value): + elvmax_var = nc_file.createVariable('elvmax', wp) + elvmax_var.units = 'm' + elvmax_var.standard_name = 'maximum of subgrid orography' + elvmax_var[:] = case_data._elvmax + + if (case_data._oro != case_data._missing_value): + oro_var = nc_file.createVariable('oro', wp) + oro_var.units = 'm' + oro_var.standard_name = 'orography' + oro_var[:] = case_data._oro + + if (case_data._oro_uf != case_data._missing_value): + oro_uf_var = nc_file.createVariable('oro_uf', wp) + oro_uf_var.units = 'm' + oro_uf_var.standard_name = 'unfiltered orography' + oro_uf_var[:] = case_data._oro_uf + + if (case_data._landfrac != case_data._missing_value): + landfrac_var = nc_file.createVariable('landfrac', wp) + landfrac_var.units = 'none' + landfrac_var.standard_name = 'fraction of horizontal grid area occupied by land' + landfrac_var[:] = case_data._landfrac + + if (case_data._lakefrac != case_data._missing_value): + lakefrac_var = nc_file.createVariable('lakefrac', wp) + lakefrac_var.units = 'none' + lakefrac_var.standard_name = 'fraction of horizontal grid area occupied by lake' + lakefrac_var[:] = case_data._lakefrac + + if (case_data._lakedepth != case_data._missing_value): + lakedepth_var = nc_file.createVariable('lakedepth', wp) + lakedepth_var.units = 'none' + lakedepth_var.standard_name = 'lake depth' + lakedepth_var[:] = case_data._lakedepth + + if (case_data._tref != case_data._missing_value): + tref_var = nc_file.createVariable('tref', wp) + tref_var.units = 'K' + tref_var.standard_name = 'sea surface reference temperature for NSST' + tref_var[:] = case_data._tref + + if (case_data._z_c != case_data._missing_value): + z_c_var = nc_file.createVariable('z_c', wp) + z_c_var.units = 'm' + z_c_var.standard_name = 'sub-layer cooling thickness for NSST' + z_c_var[:] = case_data._z_c + + if (case_data._c_0 != case_data._missing_value): + c_0_var = nc_file.createVariable('c_0', wp) + c_0_var.units = 'none' + c_0_var.standard_name = 'coefficient 1 to calculate d(Tz)/d(Ts) for NSST' + c_0_var[:] = case_data._c_0 + + if (case_data._c_d != case_data._missing_value): + c_d_var = nc_file.createVariable('c_d', wp) + c_d_var.units = 'none' + c_d_var.standard_name = 'coefficient 2 to calculate d(Tz)/d(Ts) for NSST' + c_d_var[:] = case_data._c_d + + if (case_data._w_0!= case_data._missing_value): + w_0_var = nc_file.createVariable('w_0', wp) + w_0_var.units = 'none' + w_0_var.standard_name = 'coefficient 3 to calculate d(Tz)/d(Ts) for NSST' + w_0_var[:] = case_data._w_0 + + if (case_data._w_d != case_data._missing_value): + w_d_var = nc_file.createVariable('w_d', wp) + w_d_var.units = 'none' + w_d_var.standard_name = 'coefficient 4 to calculate d(Tz)/d(Ts) for NSST' + w_d_var[:] = case_data._w_d + + if (case_data._xt != case_data._missing_value): + xt_var = nc_file.createVariable('xt', wp) + xt_var.units = 'K m' + xt_var.standard_name = 'heat content in diurnal thermocline layer for NSST' + xt_var[:] = case_data._xt + + if (case_data._xs != case_data._missing_value): + xs_var = nc_file.createVariable('xs', wp) + xs_var.units = 'ppt m' + xs_var.standard_name = 'salinity content in diurnal thermocline layer for NSST' + xs_var[:] = case_data._xs + + if (case_data._xu != case_data._missing_value): + xu_var = nc_file.createVariable('xu', wp) + xu_var.units = 'm2 s-1' + xu_var.standard_name = 'u-current in diurnal thermocline layer for NSST' + xu_var[:] = case_data._xu + + if (case_data._xv != case_data._missing_value): + xv_var = nc_file.createVariable('xv', wp) + xv_var.units = 'm2 s-1' + xv_var.standard_name = 'v-current in diurnal thermocline layer for NSST' + xv_var[:] = case_data._xv + + if (case_data._xz != case_data._missing_value): + xz_var = nc_file.createVariable('xz', wp) + xz_var.units = 'm' + xz_var.standard_name = 'thickness of diurnal thermocline layer for NSST' + xz_var[:] = case_data._xz + + if (case_data._zm != case_data._missing_value): + zm_var = nc_file.createVariable('zm', wp) + zm_var.units = 'm' + zm_var.standard_name = 'thickness of ocean mixed layer for NSST' + zm_var[:] = case_data._zm + + if (case_data._xtts != case_data._missing_value): + xtts_var = nc_file.createVariable('xtts', wp) + xtts_var.units = 'm' + xtts_var.standard_name = 'sensitivity of diurnal thermocline layer heat content to surface temperature [d(xt)/d(ts)] for NSST' + xtts_var[:] = case_data._xtts + + if (case_data._xzts != case_data._missing_value): + xzts_var = nc_file.createVariable('xzts', wp) + xzts_var.units = 'm K-1' + xzts_var.standard_name = 'sensitivity of diurnal thermocline layer thickness to surface temperature [d(xz)/d(ts)] for NSST' + xzts_var[:] = case_data._xzts + + if (case_data._d_conv != case_data._missing_value): + d_conv_var = nc_file.createVariable('d_conv', wp) + d_conv_var.units = 'm' + d_conv_var.standard_name = 'thickness of free convection layer for NSST' + d_conv_var[:] = case_data._d_conv + + if (case_data._ifd != case_data._missing_value): + ifd_var = nc_file.createVariable('ifd', wp) + ifd_var.units = 'none' + ifd_var.standard_name = 'index to start DTM run for NSST' + ifd_var[:] = case_data._ifd + + if (case_data._dt_cool != case_data._missing_value): + dt_cool_var = nc_file.createVariable('dt_cool', wp) + dt_cool_var.units = 'K' + dt_cool_var.standard_name = 'sub-layer cooling amount for NSST' + dt_cool_var[:] = case_data._dt_cool + + if (case_data._qrain != case_data._missing_value): + qrain_var = nc_file.createVariable('qrain', wp) + qrain_var.units = 'W m-2' + qrain_var.standard_name = 'sensible heat due to rainfall for NSST' + qrain_var[:] = case_data._qrain + + if (case_data._theta_il[0] != case_data._missing_value): + thetal_var = nc_file.createVariable('thetal', wp, ('t0','lev')) + thetal_var.units = 'K' + thetal_var.standard_name = 'air_liquid_potential_temperature' + thetal_var[:] = case_data._theta_il[:] + + if (case_data._t[0] != case_data._missing_value): + t_var = nc_file.createVariable('t', wp, ('t0','lev')) + t_var.units = 'K' + t_var.standard_name = 'absolute temperature' + t_var[:] = case_data._t[:] # qt_var = nc_file.createVariable('qt', wp, ('t0','lev')) @@ -569,6 +2211,90 @@ def write_SCM_case_file(case_nml, case_data, use_area): ozone_var.standard_name = 'mole_fraction_of_ozone_in_air' ozone_var[:] = case_data._ozone[:] + if (case_data._stc[0] != case_data._missing_value): + stc_var = nc_file.createVariable('stc', wp, ('t0','nsoil')) + stc_var.units = 'K' + stc_var.standard_name = 'initial profile of soil temperature' + stc_var[:] = case_data._stc[:] + + if (case_data._smc[0] != case_data._missing_value): + smc_var = nc_file.createVariable('smc', wp, ('t0','nsoil')) + smc_var.units = 'kg' + smc_var.standard_name = 'initial profile of soil moisture' + smc_var[:] = case_data._smc[:] + + if (case_data._slc[0] != case_data._missing_value): + slc_var = nc_file.createVariable('slc', wp, ('t0','nsoil')) + slc_var.units = 'kg' + slc_var.standard_name = 'initial profile of soil liquid moisture' + slc_var[:] = case_data._slc[:] + + if (case_data._snicexy[0] != case_data._missing_value): + snicexy_var = nc_file.createVariable('snicexy', wp, ('t0','nsnow')) + snicexy_var.units = 'mm' + snicexy_var.standard_name = 'initial profile of snow layer ice' + snicexy_var[:] = case_data._snicexy[:] + + if (case_data._snliqxy[0] != case_data._missing_value): + snliqxy_var = nc_file.createVariable('snliqxy', wp, ('t0','nsnow')) + snliqxy_var.units = 'mm' + snliqxy_var.standard_name = 'initial profile of snow layer liquid' + snliqxy_var[:] = case_data._snliqxy[:] + + if (case_data._tsnoxy[0] != case_data._missing_value): + tsnoxy_var = nc_file.createVariable('tsnoxy', wp, ('t0','nsnow')) + tsnoxy_var.units = 'K' + tsnoxy_var.standard_name = 'initial profile of snow layer temperature' + tsnoxy_var[:] = case_data._tsnoxy[:] + + if (case_data._smoiseq[0] != case_data._missing_value): + smoiseq_var = nc_file.createVariable('smoiseq', wp, ('t0','nsoil')) + smoiseq_var.units = 'm3 m-3' + smoiseq_var.standard_name = 'initial profile of equilibrium soil water content' + smoiseq_var[:] = case_data._smoiseq[:] + + if (case_data._zsnsoxy[0] != case_data._missing_value): + zsnsoxy_var = nc_file.createVariable('zsnxosy', wp, ('t0','nsoil_plus_nsnow')) + zsnsoxy_var.units = 'm' + zsnsoxy_var.standard_name = 'layer bottom depth from snow surface' + zsnsoxy_var[:] = case_data._zsnsoxy[:] + + if (case_data._tiice[0] != case_data._missing_value): + tiice_var = nc_file.createVariable('tiice', wp, ('t0','nice')) + tiice_var.units = 'K' + tiice_var.standard_name = 'sea ice internal temperature' + tiice_var[:] = case_data._tiice[:] + + if (case_data._tslb[0] != case_data._missing_value): + tslb_var = nc_file.createVariable('tslb', wp, ('t0','nsoil')) + tslb_var.units = 'K' + tslb_var.standard_name = 'soil temperature for RUC LSM' + tslb_var[:] = case_data._tslb[:] + + if (case_data._smois[0] != case_data._missing_value): + smois_var = nc_file.createVariable('smois', wp, ('t0','nsoil')) + smois_var.units = 'none' + smois_var.standard_name = 'volume fraction of soil moisture for RUC LSM' + smois_var[:] = case_data._smois[:] + + if (case_data._sh2o[0] != case_data._missing_value): + sh2o_var = nc_file.createVariable('sh2o', wp, ('t0','nsoil')) + sh2o_var.units = 'none' + sh2o_var.standard_name = 'volume fraction of unfrozen soil moisture for RUC LSM' + sh2o_var[:] = case_data._sh2o[:] + + if (case_data._smfr[0] != case_data._missing_value): + smfr_var = nc_file.createVariable('smfr', wp, ('t0','nsoil')) + smfr_var.units = 'none' + smfr_var.standard_name = 'volume fraction of frozen soil moisture for RUC LSM' + smfr_var[:] = case_data._smfr[:] + + if (case_data._flfr[0] != case_data._missing_value): + flfr_var = nc_file.createVariable('flfr', wp, ('t0','nsoil')) + flfr_var.units = 'none' + flfr_var.standard_name = 'flag for frozen soil physics for RUC LSM' + flfr_var[:] = case_data._flfr[:] + ps_forc_var = nc_file.createVariable('ps_forc', wp, ('time')) ps_forc_var.units = 'Pa' ps_forc_var.standard_name = 'forcing_surface_air_pressure' @@ -739,20 +2465,21 @@ def write_SCM_case_file(case_nml, case_data, use_area): ts_var[:] = case_data._T_surf[:] else: ts_var[:] = case_data._missing_value - else: - nc_file.surface_forcing_temp = 'ts' - nc_file.surface_forcing_wind = 'z0' - - z0_var = nc_file.createVariable('z0', wp, ('time')) - z0_var.units = 'm' - z0_var.standard_name = 'surface_roughness_length_for_momentum_in_air' - z0_var[:] = case_nml['case_config']['sfc_roughness_length_cm']*1.0E-2 - - ts_var = nc_file.createVariable('ts_forc', wp, ('time')) - ts_var.units = 'K' - ts_var.standard_name = 'forcing_surface_temperature' - ts_var[:] = case_data._T_surf[:] + if (nc_file.surface_forcing_lsm != 'lsm'): + + nc_file.surface_forcing_temp = 'ts' + nc_file.surface_forcing_wind = 'z0' + + z0_var = nc_file.createVariable('z0', wp, ('time')) + z0_var.units = 'm' + z0_var.standard_name = 'surface_roughness_length_for_momentum_in_air' + z0_var[:] = case_nml['case_config']['sfc_roughness_length_cm']*1.0E-2 + + ts_var = nc_file.createVariable('ts_forc', wp, ('time')) + ts_var.units = 'K' + ts_var.standard_name = 'forcing_surface_temperature' + ts_var[:] = case_data._T_surf[:] nc_file.close() @@ -820,448 +2547,6 @@ def write_SCM_nml_file(case_nml): return(filename) -######################################################################################## -# -######################################################################################## -def write_SCM_case_file_UFS(state, surface, oro, forcing, case, date, vertical_forcing): - """Write all data to a netCDF file in the DEPHY-SCM format""" - - # Working types - wp = np.float64 - wi = np.int32 - - # Local switches - forcing_on = 1 - forcing_off = 0 - - # Output file - com = 'mkdir -p ' + PROCESSED_CASE_DIR - print(com) - os.system(com) - fileOUT = os.path.join(PROCESSED_CASE_DIR, case + '_SCM_driver.nc') - - nc_file = Dataset(fileOUT, 'w', format='NETCDF3_CLASSIC') - nc_file.description = "FV3GFS model profile input (UFS forcings)" - - nc_file.missing_value = missing_value - - start_date = datetime(date["year"],date["month"],date["day"],date["hour"],date["minute"],date["second"]) - - # - # Create surface type string (Saved as GLOBAL attribute) - # - if surface["slmsk"] > 1.5: - surface_string = 'ice' - elif surface["slmsk"] > 0.5: - surface_string = 'land' - else: - surface_string = 'ocean' - - # - # Global file attributes. - # - runtime = timedelta(seconds=forcing['time'][-1]) - end_date = start_date + runtime - end_date_string = end_date.strftime("%Y-%m-%d %H:%M:%S") - start_date_string = start_date.strftime("%Y-%m-%d %H:%M:%S") - # - loc_string = str(round(surface["lon"],2)) + "E" + str(round(surface["lat"],2)) + "N" - case_string = 'UFS_' + start_date_string + '_' + loc_string - # - nc_file.case = case_string - nc_file.title = 'Forcing and Initial Conditions for ' + case_string - nc_file.reference = 'https://dtcenter.org/sites/default/files/paragraph/scm-ccpp-guide-v6-0-0.pdf' - nc_file.author = 'Grant J. Firl and Dustin Swales' - nc_file.version = 'Created on ' + datetime.today().strftime('%Y-%m-%d %H:%M:%S') - nc_file.format_version = 'DEPHY SCM format version 1' - nc_file.modifications = '' - nc_file.script = os.path.basename(__file__) - nc_file.comment = '' - nc_file.start_date = start_date_string - nc_file.end_date = end_date_string - nc_file.forcing_scale = -1 - nc_file.radiation = "off" - nc_file.adv_ta = forcing_off - nc_file.adv_qv = forcing_off - nc_file.adv_ua = forcing_off - nc_file.adv_va = forcing_off - nc_file.adv_theta = forcing_off - nc_file.adv_thetal = forcing_off - nc_file.adv_qt = forcing_off - nc_file.adv_rv = forcing_off - nc_file.adv_rt = forcing_off - if (vertical_forcing == 2): - nc_file.forc_wa = forcing_on - else: - nc_file.forc_wa = forcing_off - nc_file.forc_wap = forcing_off - nc_file.forc_geo = forcing_off - nc_file.nudging_ua = forcing_off - nc_file.nudging_va = forcing_off - nc_file.nudging_ta = forcing_off - nc_file.nudging_theta = forcing_off - nc_file.nudging_thetal = forcing_off - nc_file.nudging_qv = forcing_off - nc_file.nudging_qt = forcing_off - nc_file.nudging_rv = forcing_off - nc_file.nudging_rt = forcing_off - nc_file.zh_nudging_ta = forcing_off - nc_file.zh_nudging_theta = forcing_off - nc_file.zh_nudging_thetal = forcing_off - nc_file.zh_nudging_qv = forcing_off - nc_file.zh_nudging_qt = forcing_off - nc_file.zh_nudging_rv = forcing_off - nc_file.zh_nudging_rt = forcing_off - nc_file.zh_nudging_ua = forcing_off - nc_file.zh_nudging_va = forcing_off - nc_file.pa_nudging_ta = forcing_off - nc_file.pa_nudging_theta = forcing_off - nc_file.pa_nudging_thetal = forcing_off - nc_file.pa_nudging_qv = forcing_off - nc_file.pa_nudging_qt = forcing_off - nc_file.pa_nudging_rv = forcing_off - nc_file.pa_nudging_rt = forcing_off - nc_file.pa_nudging_ua = forcing_off - nc_file.pa_nudging_va = forcing_off - # - nc_file.surface_type = surface_string - # - nc_file.adv_ta = forcing_on - nc_file.adv_qv = forcing_on - nc_file.adv_ua = forcing_on - nc_file.adv_va = forcing_on - # - nc_file.surface_forcing_temp = 'none' - nc_file.surface_forcing_moisture = 'none' - nc_file.surface_forcing_wind = 'none' - nc_file.surface_forcing_lsm = 'none' #'noah' #'noahmp' #'ruc' - nc_file.surface_forcing_lsm = 'lsm' - # Set file dimension - time_dim = nc_file.createDimension('time', len(forcing['time'])) - timei_dim = nc_file.createDimension('t0', 1) - lev_dim = nc_file.createDimension('lev', state["nlevs"]) - soil_dim = nc_file.createDimension('nsoil', len(surface["stc"])) - snow_dim = nc_file.createDimension('nsnow', len(surface["snicexy"])) - nslsnw_dim = nc_file.createDimension('nsoil_plus_nsnow',len(surface["snicexy"]) + len(surface["stc"])) - ice_dim = nc_file.createDimension('nice', len(surface["tiice"])) - - # - timei_var = nc_file.createVariable('t0', wp, ('t0')) - timei_var.units = 'seconds since ' + start_date_string - timei_var.standard_name = 'Initial time' - timei_var.calendar = 'gregorian' - timei_var[:] = 0.0 - # - timef_var = nc_file.createVariable('time', wp, ('time')) - timef_var.units = 'seconds since ' + start_date_string - timef_var.standard_name = 'Forcing time' - timef_var.calendar = 'gregorian' - timef_var[:] = forcing['time'] - # - lev_var = nc_file.createVariable('lev', wp, ('lev')) - lev_var.units = 'm' - lev_var.standard_name = 'height' - lev_var[:] = 0.0 - - # - lon_var = nc_file.createVariable('lon', wp, ('time')) - lon_var.units = 'degrees_east' - lon_var.standard_name = 'longitude' - lon_var[:] = surface["lon"] - - # - lat_var = nc_file.createVariable('lat', wp, ('time')) - lat_var.units = 'degrees_north' - lat_var.standard_name = 'latitude' - lat_var[:] = surface["lat"] - - # - soil_depth_var = nc_file.createVariable('soil_depth', wp, ('nsoil')) - soil_depth_var.units = 'm' - soil_depth_var.standard_name = 'depth of bottom of soil layers' - soil_depth_var[:] = [0.1,0.4,1.0,2.0] - # - theta_oro = nc_file.createVariable('theta_oro',wp, ('t0')) - theta_oro.units = "deg" - theta_oro.standard_name = "angle with respect to east of maximum subgrid orographic variations" - theta_oro[:] = oro["theta"] - # - z0_var = nc_file.createVariable('zorl', wp, ('time')) - z0_var.units = "cm" - z0_var.standard_name = 'surface_roughness_length_for_momentum_in_air' - z0_var[:] = surface["z0"] - # - zorlw_var = nc_file.createVariable('zorlw', wp, ('t0')) - zorlw_var.units = "cm" - zorlw_var.standard_name = "surface roughness length over ocean" - zorlw_var[:] = surface["z0"] - # - zorll_var = nc_file.createVariable('zorll', wp, ('t0')) - zorll_var.units = "cm" - zorll_var.standard_name = "surface roughness length over land" - zorll_var[:] = surface["zorll"] - # - zorli_var = nc_file.createVariable('zorli', wp, ('t0')) - zorli_var.units = "cm" - zorli_var.standard_name = "surface roughness length over ice" - zorli_var[:] = surface["zorli"] - # - zorlwav_var = nc_file.createVariable('zorlwav', wp, ('time')) - zorlwav_var.units = "cm" - zorlwav_var.standard_name = 'surface_roughness_length_from_wave_model' - zorlwav_var[:] = surface["zorlw"] - - # - # Variables to be output to SCM input file. Only fields that come directly from forcing, - # surface, state, and oro. Fields that get renamed are done above. - # - dict = {} - dict.update(date) - dict.update(surface) - dict.update(state) - dict.update(oro) - dict.update(forcing) - - ######################################################################################## - # - # Dictonary format: - # {"name": "", "type", "dimd": (), "units": "", "desc": ""} - # - ######################################################################################## - var_dict = [{"name": "orog", "type":wp, "dimd": ('t0' ), "units": "m", "desc": "surface_altitude"},\ - {"name": "zh", "type":wp, "dimd": ('t0', 'lev'), "units": "m", "desc": "height"},\ - {"name": "pa", "type":wp, "dimd": ('t0', 'lev'), "units": "Pa", "desc": "air_pressure"}, \ - {"name": "ta", "type":wp, "dimd": ('t0', 'lev'), "units": "K", "desc": "air_temperature"}, \ - {"name": "theta", "type":wp, "dimd": ('t0', 'lev'), "units": "K", "desc": "air_potential_temperature"}, \ - {"name": "thetal", "type":wp, "dimd": ('t0', 'lev'), "units": "K", "desc": "air_liquid_potential_temperature"}, \ - {"name": "rv", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "humidity_mixing_ratio"}, \ - {"name": "rl", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "cloud_liquid_water_mixing_ratio"}, \ - {"name": "ri", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "cloud_ice_water_mixing_ratio"}, \ - {"name": "rt", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "water_mixing_ratio"}, \ - {"name": "qv", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "specific_humidity"}, \ - {"name": "ql", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "mass_fraction_of_cloud_liquid_water_in_air"}, \ - {"name": "qi", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "mass_fraction_of_cloud_ice_water_in_air", "default_value": 0.0}, \ - {"name": "qt", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "mass_fraction_of_water_in_air"}, \ - {"name": "hur", "type":wp, "dimd": ('t0', 'lev'), "units": "%", "desc": "relative_humidity"}, \ - {"name": "tke", "type":wp, "dimd": ('t0', 'lev'), "units": "m2 s-2", "desc": "specific_turbulen_kinetic_energy", "default_value": 0.0}, \ - {"name": "ua", "type":wp, "dimd": ('t0', 'lev'), "units": "m s-1", "desc": "eastward_wind"}, \ - {"name": "va", "type":wp, "dimd": ('t0', 'lev'), "units": "m s-1", "desc": "northward_wind"}, \ - {"name": "ts", "type":wp, "dimd": ('t0' ), "units": "K", "desc": "surface_temperature"},\ - {"name": "tskin", "type":wp, "dimd": ('t0' ), "units": "K", "desc": "surface_skin_temperature"}, \ - {"name": "ps", "type":wp, "dimd": ('t0' ), "units": "Pa", "desc": "surface_air_pressure"}, \ - {"name": "beta", "type":wp, "dimd": ('t0' ), "units": "m", "desc": "soil_water_stress_factor"}, \ - {"name": "mrsos", "type":wp, "dimd": ('t0' ), "units": "kg m-2", "desc": "mass_content_of_water_in_soil_layer"}, \ - {"name": "o3", "type":wp, "dimd": ('t0', 'lev'), "units": "kg kg-1", "desc": "mole_fraction_of_ozone_in_air"}, \ - {"name": "sza", "type":wp, "dimd": ('t0' ), "units": "degree", "desc": "solar_zenith_angle"}, \ - {"name": "io", "type":wp, "dimd": ('t0' ), "units": "W m-2", "desc": "solar_irradiance"}, \ - {"name": "alb", "type":wp, "dimd": ('t0' ), "units": "1", "desc": "surface_albedo"}, \ - {"name": "emis", "type":wp, "dimd": ('t0' ), "units": "1", "desc": "surface_longwave_emissivity"}, \ - {"name": "slmsk", "type":wp, "dimd": ('t0' ), "units": "none", "desc": "land_sea_ice_mask"}] - # - var_frc = [{"name": "zh_forc", "type":wp, "dimd": ('time', 'lev'), "units": "m", "desc": "height_forcing","default_value": 1.},\ - {"name": "pa_forc", "type":wp, "dimd": ('time', 'lev'), "units": "Pa", "desc": "air_pressure_forcing"}, \ - {"name": "wa", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "upward_air_velocity"}, \ - {"name": "wap", "type":wp, "dimd": ('time', 'lev'), "units": "Pa s-1", "desc": "lagrangian_tendency_of_air_pressure"}, \ - {"name": "ug", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "geostrophic_eastward_wind"}, \ - {"name": "vg", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "geostrophic_northward_wind"}, \ - {"name": "tnua_adv", "type":wp, "dimd": ('time', 'lev'), "units": "m s-2", "desc": "tendency_of_eastward_wind_due_to_advection"},\ - {"name": "tnva_adv", "type":wp, "dimd": ('time', 'lev'), "units": "m s-2", "desc": "tendency_of_northward_wind_due_to_advection"}, \ - {"name": "tnta_adv", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_air_temperature_due_to_advection"}, \ - {"name": "tntheta_adv", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_air_potential_temperature_due_to_advection"}, \ - {"name": "tnthetal_adv", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_air_liquid_potential_temperature_due_to_advection"}, \ - {"name": "tnqv_adv", "type":wp, "dimd": ('time', 'lev'), "units": "kg kg-1 s-1", "desc": "tendency_of_specific_humidity_due_to_advection"},\ - {"name": "tnqt_adv", "type":wp, "dimd": ('time', 'lev'), "units": "kg kg-1 s-1", "desc": "tendency_of_mass_fraction_of_water_in_air_due_to_advection"},\ - {"name": "tnrv_adv", "type":wp, "dimd": ('time', 'lev'), "units": "kg kg-1 s-1", "desc": "tendency_of_humidity_mixing_ratio_due_to_advection"},\ - {"name": "tnrt_adv", "type":wp, "dimd": ('time', 'lev'), "units": "kg kg-1 s-1", "desc": "tendency_of_water_mixing_ratio_due_to_advection"},\ - {"name": "tnta_rad", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_air_temperature_due_to_radiative_heating"}, \ - {"name": "tntheta_rad", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_potential_air_temperature_due_to_radiative_heating"}, \ - {"name": "tnthetal_rad", "type":wp, "dimd": ('time', 'lev'), "units": "K s-1", "desc": "tendency_of_air_liquid_potential_temperature_due_to_radiative_heating"}, \ - {"name": "ta_nud", "type":wp, "dimd": ('time', 'lev'), "units": "K", "desc": "nudging_air_temperature"}, \ - {"name": "theta_nud", "type":wp, "dimd": ('time', 'lev'), "units": "K", "desc": "nudging_air_potential_temperature"}, \ - {"name": "thetal_nud", "type":wp, "dimd": ('time', 'lev'), "units": "K", "desc": "nudging_air_liquid_potential_temperature"}, \ - {"name": "qt_nud", "type":wp, "dimd": ('time', 'lev'), "units": "kg kg-1", "desc": "nudging_mass_fraction_of_water_in_air"}, \ - {"name": "rv_nud", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "nudging_humidity_mixing_ratio"}, \ - {"name": "rt_nud", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "nudging_water_mixing_ratio"}, \ - {"name": "ua_nud", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "nudging_eastward_wind"}, \ - {"name": "va_nud", "type":wp, "dimd": ('time', 'lev'), "units": "m s-1", "desc": "nudging_northward_wind"}, \ - {"name": "hfss", "type":wp, "dimd": ('time' ), "units": "W m-2", "desc": "surface_upward_sensible_heat_flux"}, \ - {"name": "hfls", "type":wp, "dimd": ('time' ), "units": "W m-2", "desc": "surface_upward_latent_heat_flux"}, \ - {"name": "wpthetap_s", "type":wp, "dimd": ('time' ), "units": "K m s-1", "desc": "surface_upward_potential_temperature_flux"}, \ - {"name": "wpqvp_s", "type":wp, "dimd": ('time' ), "units": "m s-1", "desc": "surface_upward_specific_humidity_flux"}, \ - {"name": "wpqtp_s", "type":wp, "dimd": ('time' ), "units": "m s-1", "desc": "surface_upward_water_mass_fraction_flux"}, \ - {"name": "wprvp_s", "type":wp, "dimd": ('time' ), "units": "m s-1", "desc": "surface_upward_humidity_mixing_ratio_flux"}, \ - {"name": "wprtp_s", "type":wp, "dimd": ('time' ), "units": "m s-1", "desc": "surface_upward_water_mixing_ratio_flux"}, \ - {"name": "ts_forc", "type":wp, "dimd": ('time' ), "units": "K", "desc": "forcing_surface_temperature"},\ - {"name": "ps_forc", "type":wp, "dimd": ('time' ), "units": "Pa", "desc": "forcing_surface_air_pressure"},\ - {"name": "uustar", "type":wp, "dimd": ('time' ), "units": "m s-1", "desc": "surface_friction_velocity"}, \ - {"name": "z0h", "type":wp, "dimd": ('time' ), "units": "m", "desc": "surface_roughness_length_for_heat_in_air"}, \ - {"name": "z0q", "type":wp, "dimd": ('time' ), "units": "m", "desc": "surface_roughness_length_for_humidity_in_air"}, \ - {"name": "mrsos_forc", "type":wp, "dimd": ('time' ), "units": "kg m-2", "desc": "forcing_mass_content_of_water_in_soil_layer"}] - - # - var_oro = [{"name": "area", "type":wp, "dimd": ('t0'), "units": "m2", "desc": "grid_cell_area"},\ - {"name": "stddev", "type":wp, "dimd": ('t0'), "units": "m", "desc": "standard deviation of subgrid orography"}, \ - {"name": "convexity", "type":wp, "dimd": ('t0'), "units": "none", "desc": "convexity of subgrid orography"}, \ - {"name": "oa1", "type":wp, "dimd": ('t0'), "units": "none", "desc": "assymetry of subgrid orography 1"}, \ - {"name": "oa2", "type":wp, "dimd": ('t0'), "units": "none", "desc": "assymetry of subgrid orography 2"}, \ - {"name": "oa3", "type":wp, "dimd": ('t0'), "units": "none", "desc": "assymetry of subgrid orography 3"}, \ - {"name": "oa4", "type":wp, "dimd": ('t0'), "units": "none", "desc": "assymetry of subgrid orography 4"}, \ - {"name": "ol1", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of grid box with subgrid orography higher than critical height 1"}, \ - {"name": "ol2", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of grid box with subgrid orography higher than critical height 2"}, \ - {"name": "ol3", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of grid box with subgrid orography higher than critical height 3"}, \ - {"name": "ol4", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of grid box with subgrid orography higher than critical height 4"}, \ - {"name": "sigma", "type":wp, "dimd": ('t0'), "units": "none", "desc": "slope of subgrid orography"}, \ - {"name": "gamma", "type":wp, "dimd": ('t0'), "units": "none", "desc": "anisotropy of subgrid orography"}, \ - {"name": "elvmax", "type":wp, "dimd": ('t0'), "units": "m", "desc": "maximum of subgrid orography"}, \ - {"name": "oro", "type":wp, "dimd": ('t0'), "units": "m", "desc": "orography"}, \ - {"name": "oro_uf", "type":wp, "dimd": ('t0'), "units": "m", "desc": "unfiltered orography"}, \ - {"name": "landfrac", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of horizontal grid area occupied by land"}, \ - {"name": "lakefrac", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of horizontal grid area occupied by lake", "default_value":0}, \ - {"name": "lakedepth", "type":wp, "dimd": ('t0'), "units": "none", "desc": "lake depth", "default_value":0}] - # - var_nsst = [{"name": "tref", "type":wp, "dimd": ('t0'), "units": "K", "desc": "sea surface reference temperature for NSST"}, \ - {"name": "z_c", "type":wp, "dimd": ('t0'), "units": "m", "desc": "sub-layer cooling thickness for NSST"}, \ - {"name": "c_0", "type":wp, "dimd": ('t0'), "units": "none", "desc": "coefficient 1 to calculate d(Tz)/d(Ts) for NSST"}, \ - {"name": "c_d", "type":wp, "dimd": ('t0'), "units": "nonw", "desc": "coefficient 2 to calculate d(Tz)/d(Ts) for NSST"}, \ - {"name": "w_0", "type":wp, "dimd": ('t0'), "units": "none", "desc": "coefficient 3 to calculate d(Tz)/d(Ts) for NSST"}, \ - {"name": "w_d", "type":wp, "dimd": ('t0'), "units": "none", "desc": "coefficient 4 to calculate d(Tz)/d(Ts) for NSST"}, \ - {"name": "xt", "type":wp, "dimd": ('t0'), "units": "K m", "desc": "heat content in diurnal thermocline layer for NSST"}, \ - {"name": "xs", "type":wp, "dimd": ('t0'), "units": "ppt m", "desc": "salinity content in diurnal thermocline layer for NSST"}, \ - {"name": "xu", "type":wp, "dimd": ('t0'), "units": "m2 s-1", "desc": "u-current in diurnal thermocline layer for NSST"}, \ - {"name": "xv", "type":wp, "dimd": ('t0'), "units": "m2 s-1", "desc": "v-current in diurnal thermocline layer for NSST"}, \ - {"name": "xz", "type":wp, "dimd": ('t0'), "units": "m", "desc": "thickness of diurnal thermocline layer for NSST"}, \ - {"name": "zm" , "type":wp, "dimd": ('t0'), "units": "m", "desc": "thickness of ocean mixed layer for NSST"}, \ - {"name": "xtts", "type":wp, "dimd": ('t0'), "units": "m", "desc": "sensitivity of diurnal thermocline layer heat content to surface temperature [d(xt)/d(ts)] for NSST"},\ - {"name": "xzts", "type":wp, "dimd": ('t0'), "units": "m K-1", "desc": "sensitivity of diurnal thermocline layer thickness to surface temperature [d(xz)/d(ts)] for NSST"}, \ - {"name": "d_conv", "type":wp, "dimd": ('t0'), "units": "m", "desc": "thickness of free convection layer for NSST"}, \ - {"name": "ifd", "type":wp, "dimd": ('t0'), "units": "none", "desc": "index to start DTM run for NSST"}, \ - {"name": "dt_cool", "type":wp, "dimd": ('t0'), "units": "K", "desc": "sub-layer cooling amount for NSST"}, \ - {"name": "qrain", "type":wp, "dimd": ('t0'), "units": "W m-2", "desc": "sensible heat due to rainfall for NSST"}] - # - var_frgd = [{"name": "tiice", "type":wp, "dimd": ('t0','nice'), "units": "K", "desc": "sea ice internal temperature"}] - # - var_noah = [{"name": "vegsrc", "type":wi, "dimd": ('t0'), "units": "none", "desc": "vegetation source (1-2)", "default_value": 1}, \ - {"name": "tsfco", "type":wp, "dimd": ('t0'), "units": "K", "desc": "sea/skin/ice surface temperature"}, \ - {"name": "weasd", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "water equivalent accumulated snow depth"}, \ - {"name": "tg3", "type":wp, "dimd": ('t0'), "units": "K", "desc": "deep soil temperature"}, \ - {"name": "alvsf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "60 degree vis albedo with strong cosz dependency"}, \ - {"name": "alnsf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "60 degree nir albedo with strong cosz dependency"}, \ - {"name": "alvwf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "60 degree vis albedo with weak cosz dependency"}, \ - {"name": "alnwf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "60 degree nir albedo with weak cosz dependency"}, \ - {"name": "facsf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fractional coverage with strong cosz dependency"}, \ - {"name": "facwf", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fractional coverage with weak cosz dependency"}, \ - {"name": "vegfrac", "type":wp, "dimd": ('t0'), "units": "none", "desc": "vegetation fraction"}, \ - {"name": "canopy", "type":wp, "dimd": ('t0'), "units": "kg m-2", "desc": "amount of water stored in canopy"}, \ - {"name": "f10m", "type":wp, "dimd": ('t0'), "units": "none", "desc": "ratio of sigma level 1 wind and 10m wind"}, \ - {"name": "t2m", "type":wp, "dimd": ('t0'), "units": "K", "desc": "2-meter absolute temperature"}, \ - {"name": "q2m", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "2-meter specific humidity"}, \ - {"name": "vegtyp", "type":wi, "dimd": ('t0'), "units": "none", "desc": "vegetation type (1-12)"}, \ - {"name": "soiltyp", "type":wi, "dimd": ('t0'), "units": "none", "desc": "soil type (1-12)"}, \ - {"name": "scolor", "type":wp, "dimd": ('t0'), "units": "none", "desc": "soil color"}, \ - {"name": "ffmm", "type":wp, "dimd": ('t0'), "units": "none", "desc": "Monin-Obukhov similarity function for momentum"}, \ - {"name": "ffhh", "type":wp, "dimd": ('t0'), "units": "none", "desc": "Monin-Obukhov similarity function for heat"}, \ - {"name": "hice", "type":wp, "dimd": ('t0'), "units": "m", "desc": "sea ice thickness"}, \ - {"name": "fice", "type":wp, "dimd": ('t0'), "units": "none", "desc": "ice fraction"}, \ - {"name": "tisfc", "type":wp, "dimd": ('t0'), "units": "K", "desc": "ice surface temperature"}, \ - {"name": "tprcp", "type":wp, "dimd": ('t0'), "units": "m", "desc": "instantaneous total precipitation amount"}, \ - {"name": "srflag", "type":wp, "dimd": ('t0'), "units": "none", "desc": "snow/rain flag for precipitation"}, \ - {"name": "snowd", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "water equivalent snow depth"}, \ - {"name": "shdmin", "type":wp, "dimd": ('t0'), "units": "none", "desc": "minimum vegetation fraction"}, \ - {"name": "shdmax", "type":wp, "dimd": ('t0'), "units": "none", "desc": "maximum vegetation fraction"}, \ - {"name": "slopetyp", "type":wi, "dimd": ('t0'), "units": "none", "desc": "slope type (1-9)"}, \ - {"name": "snoalb", "type":wp, "dimd": ('t0'), "units": "none", "desc": "maximum snow albedo"}, \ - {"name": "sncovr", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface snow area fraction"}, \ - {"name": "tsfcl", "type":wp, "dimd": ('t0'), "units": "K", "desc": "surface skin temperature over land"}, \ - {"name": "stc", "type":wp, "dimd": ('t0','nsoil'), "units": "K", "desc": "initial profile of soil liquid moisture"}, \ - {"name": "smc", "type":wp, "dimd": ('t0','nsoil'), "units": "kg", "desc": "initial profile of soil moisture"}, \ - {"name": "slc", "type":wp, "dimd": ('t0','nsoil'), "units": "kg", "desc": "initial profile of soil temperature"}] - # - var_noahmp=[{"name": "tvxy", "type":wp, "dimd": ('t0'), "units": "K", "desc": "vegetation temperature for NoahMP"}, \ - {"name": "tgxy", "type":wp, "dimd": ('t0'), "units": "K", "desc": "ground temperature for NoahMP"}, \ - {"name": "tahxy", "type":wp, "dimd": ('t0'), "units": "K", "desc": "canopy air temperature for NoahMP"}, \ - {"name": "canicexy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "canopy intercepted ice mass for NoahMP"}, \ - {"name": "canliqxy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "canopy intercepted liquid water for NoahMP"}, \ - {"name": "eahxy", "type":wp, "dimd": ('t0'), "units": "Pa", "desc": "canopy air vapor pressure for NoahMP"}, \ - {"name": "cmxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface drag coefficient for momentum for NoahMP"}, \ - {"name": "chxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface exchange coeff heat & moisture for NoahMP"}, \ - {"name": "fwetxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "area fraction of canopy that is wetted/snowed for NoahMP"}, \ - {"name": "sneqvoxy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "snow mass at previous time step for NoahMP"}, \ - {"name": "alboldxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "snow albedo at previous time step for NoahMP"}, \ - {"name": "qsnowxy", "type":wp, "dimd": ('t0'), "units": "mm s-1", "desc": "snow precipitation rate at surface for NoahMP"}, \ - {"name": "wslakexy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "lake water storage for NoahMP"}, \ - {"name": "taussxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "non-dimensional snow age for NoahMP"}, \ - {"name": "waxy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "water storage in aquifer for NoahMP"}, \ - {"name": "wtxy", "type":wp, "dimd": ('t0'), "units": "mm", "desc": "water storage in aquifer and saturated soil for NoahMP"}, \ - {"name": "zwtxy", "type":wp, "dimd": ('t0'), "units": "m", "desc": "water table depth for NoahMP"}, \ - {"name": "xlaixy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "leaf area index for NoahMP"}, \ - {"name": "xsaixy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "stem area index for NoahMP"}, \ - {"name": "lfmassxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "leaf mass for NoahMP"}, \ - {"name": "stmassxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "stem mass for NoahMP"}, \ - {"name": "rtmassxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "fine root mass for NoahMP"}, \ - {"name": "woodxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "wood mass including woody roots for NoahMP"}, \ - {"name": "stblcpxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "stable carbon in deep soil for NoahMP"}, \ - {"name": "fastcpxy", "type":wp, "dimd": ('t0'), "units": "g m-2", "desc": "short-lived carbon in shallow soil for NoahMP"}, \ - {"name": "smcwtdxy", "type":wp, "dimd": ('t0'), "units": "m3 m-3", "desc": "soil water content between the bottom of the soil and the water table for NoahMP"}, \ - {"name": "deeprechxy", "type":wp, "dimd": ('t0'), "units": "m", "desc": "recharge to or from the water table when deep for NoahMP"}, \ - {"name": "rechxy", "type":wp, "dimd": ('t0'), "units": "m", "desc": "recharge to or from the water table when shallow for NoahMP"}, \ - {"name": "snowxy", "type":wp, "dimd": ('t0'), "units": "none", "desc": "number of snow layers for NoahMP"}, \ - {"name": "snicexy", "type":wp, "dimd": ('t0','nsnow'), "units": "mm", "desc": "initial profile of snow layer ice"}, \ - {"name": "snliqxy", "type":wp, "dimd": ('t0','nsnow'), "units": "mm", "desc": "initial profile of snow layer liquid"}, \ - {"name": "tsnoxy", "type":wp, "dimd": ('t0','nsnow'), "units": "K", "desc": "initial profile of snow layer temperature"}, \ - {"name": "smoiseq", "type":wp, "dimd": ('t0','nsoil'), "units": "m3 m-3", "desc": "initial profile of equilibrium soil water content"}, \ - {"name": "zsnsoxy", "type":wp, "dimd": ('t0','nsoil_plus_nsnow'), "units": "m","desc": "layer bottom depth from snow surface"}] - # - var_ruc = [{"name": "wetness", "type":wp, "dimd": ('t0'), "units": "none", "desc": "normalized soil wetness for RUC LSM"}, \ - {"name": "lai", "type":wp, "dimd": ('t0'), "units": "none", "desc": "leaf area index for RUC LSM"}, \ - {"name": "clw_surf_land", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "cloud condensed water mixing ratio at surface over land for RUC LSM"},\ - {"name": "clw_surf_ice", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "cloud condensed water mixing ratio at surface over ice for RUC LSM"},\ - {"name": "qwv_surf_land", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "water vapor mixing ratio at surface over land for RUC LSM"},\ - {"name": "qwv_surf_ice", "type":wp, "dimd": ('t0'), "units": "kg kg-1", "desc": "water vapor mixing ratio at surface over ice for RUC LSM"},\ - {"name": "tsnow_land", "type":wp, "dimd": ('t0'), "units": "K", "desc": "snow temperature at the bottom of the first snow layer over land for RUC LSM"},\ - {"name": "tsnow_ice", "type":wp, "dimd": ('t0'), "units": "K", "desc": "snow temperature at the bottom of the first snow layer over ice for RUC LSM"},\ - {"name": "snowfall_acc_land","type":wp, "dimd": ('t0'), "units": "kg m-2", "desc": "run-total snow accumulation on the ground over land for RUC LSM"},\ - {"name": "snowfall_acc_ice", "type":wp, "dimd": ('t0'), "units": "kg m-2", "desc": "run-total snow accumulation on the ground over ice for RUC LSM"},\ - {"name": "sfalb_lnd", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface albedo over land for RUC LSM"},\ - {"name": "sfalb_lnd_bck", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface snow-free albedo over land for RUC LSM"},\ - {"name": "sfalb_ice", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface albedo over ice for RUC LSM"},\ - {"name": "emis_lnd", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface emissivity over land for RUC LSM"},\ - {"name": "emis_ice", "type":wp, "dimd": ('t0'), "units": "none", "desc": "surface emissivity over ice for RUC LSM"}, \ - {"name": "tslb", "type":wp, "dimd": ('t0','nsoil'), "units": "K", "desc": "soil temperature for RUC LSM"}, \ - {"name": "smois", "type":wp, "dimd": ('t0','nsoil'), "units": "none", "desc": "volume fraction of soil moisture for RUC LSM"}, \ - {"name": "sh2o", "type":wp, "dimd": ('t0','nsoil'), "units": "none", "desc": "volume fraction of unfrozen soil moisture for RUC LSM"}, \ - {"name": "smfr", "type":wp, "dimd": ('t0','nsoil'), "units": "none", "desc": "volume fraction of frozen soil moisture for RUC LSM"}, - {"name": "flfr", "type":wp, "dimd": ('t0','nsoil'), "units": "none", "desc": "flag for frozen soil physics for RUC LSM"}] - - # - var_dict.extend(var_frc) - var_dict.extend(var_oro) - var_dict.extend(var_nsst) - var_dict.extend(var_frgd) - var_dict.extend(var_ruc) - var_dict.extend(var_noah) - var_dict.extend(var_noahmp) - - # - for var in var_dict: - if (var["name"] in dict): - var_temp = nc_file.createVariable(var["name"], var["type"], var["dimd"]) - var_temp.units = var["units"] - var_temp.standard_name = var["desc"] - var_temp[:] = dict[var["name"]] - elif "default_value" in var: - var_temp = nc_file.createVariable(var["name"], var["type"], var["dimd"]) - var_temp.units = var["units"] - var_temp.standard_name = var["desc"] - var_temp[:] = var["default_value"] - if "override" in var: - var_temp[:] = var["default_value"] - # - # Close file - # - nc_file.close() - - return(fileOUT) - ######################################################################################## # ######################################################################################## diff --git a/scm/src/scm_input.F90 b/scm/src/scm_input.F90 index 73f277717..1b2dab265 100644 --- a/scm/src/scm_input.F90 +++ b/scm/src/scm_input.F90 @@ -1162,6 +1162,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) real(kind=sp) :: exner, exner_inv, rho, elapsed_sec, missing_value_eps real(kind=dp) :: rinc(5) integer :: jdat(1:8), idat(1:8) !(yr, mon, day, t-zone, hr, min, sec, mil-sec) + logical :: needed_for_lsm_ics, needed_for_model_ics integer :: input_n_init_times, input_n_forcing_times, input_n_lev, input_n_snow, input_n_ice, input_n_soil @@ -1302,15 +1303,16 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) input_ri (input_n_lev, input_n_init_times), & input_rh (input_n_lev, input_n_init_times), & input_tke (input_n_lev, input_n_init_times), & + input_ozone (input_n_lev, input_n_init_times), & stat=allocate_status) if (trim(input_surfaceForcingLSM) == "lsm") then !if model ICs are included in the file scm_state%lsm_ics = .true. + endif !variables with vertical extent - allocate(input_ozone (input_n_lev, input_n_init_times), & - input_stc (input_n_soil, input_n_init_times), & + allocate(input_stc (input_n_soil, input_n_init_times), & input_smc (input_n_soil, input_n_init_times), & input_slc (input_n_soil, input_n_init_times), & input_snicexy (input_n_snow, input_n_init_times), & @@ -1452,8 +1454,12 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) input_sfalb_ice ( input_n_init_times), & input_emis_ice ( input_n_init_times), & stat=allocate_status) - end if - + + needed_for_lsm_ics = .False. + needed_for_model_ics = .False. + if (scm_state%lsm_ics .or. trim(input_surfaceForcingLSM) == "lsm") needed_for_lsm_ics = .True. + if (scm_state%model_ics) needed_for_model_ics = .True. + !> - Read in the initial profiles. call NetCDF_read_var(ncid, "pa", .True., input_pres) call NetCDF_read_var(ncid, "zh", .True., input_height) @@ -1477,53 +1483,53 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) call NetCDF_read_var(ncid, "ri", .False., input_ri) call NetCDF_read_var(ncid, "hur", .False., input_rh) - call NetCDF_read_var(ncid, "tke", .True., input_tke) + call NetCDF_read_var(ncid, "tke", .False., input_tke) - if (trim(input_surfaceForcingLSM) == "lsm") then - call NetCDF_read_var(ncid, "o3", .True., input_ozone) - call NetCDF_read_var(ncid, "area", .True., input_area) + + call NetCDF_read_var(ncid, "o3", .False., input_ozone) + call NetCDF_read_var(ncid, "area", .False., input_area) - !orographic parameters - call NetCDF_read_var(ncid, "stddev", .True., input_stddev) - call NetCDF_read_var(ncid, "convexity", .True., input_convexity) - call NetCDF_read_var(ncid, "oa1", .True., input_oa1) - call NetCDF_read_var(ncid, "oa2", .True., input_oa2) - call NetCDF_read_var(ncid, "oa3", .True., input_oa3) - call NetCDF_read_var(ncid, "oa4", .True., input_oa4) - call NetCDF_read_var(ncid, "ol1", .True., input_ol1) - call NetCDF_read_var(ncid, "ol2", .True., input_ol2) - call NetCDF_read_var(ncid, "ol3", .True., input_ol3) - call NetCDF_read_var(ncid, "ol4", .True., input_ol4) - call NetCDF_read_var(ncid, "theta_oro", .True., input_theta_oro) - call NetCDF_read_var(ncid, "gamma", .True., input_gamma) - call NetCDF_read_var(ncid, "sigma", .True., input_sigma) - call NetCDF_read_var(ncid, "elvmax", .True., input_elvmax) - call NetCDF_read_var(ncid, "oro", .True., input_oro) - call NetCDF_read_var(ncid, "oro_uf", .True., input_oro_uf) - call NetCDF_read_var(ncid, "landfrac", .True., input_landfrac) - call NetCDF_read_var(ncid, "lakefrac", .True., input_lakefrac) - call NetCDF_read_var(ncid, "lakedepth", .True., input_lakedepth) + !orographic parameters + call NetCDF_read_var(ncid, "stddev", needed_for_model_ics, input_stddev) + call NetCDF_read_var(ncid, "convexity", needed_for_model_ics, input_convexity) + call NetCDF_read_var(ncid, "oa1", needed_for_model_ics, input_oa1) + call NetCDF_read_var(ncid, "oa2", needed_for_model_ics, input_oa2) + call NetCDF_read_var(ncid, "oa3", needed_for_model_ics, input_oa3) + call NetCDF_read_var(ncid, "oa4", needed_for_model_ics, input_oa4) + call NetCDF_read_var(ncid, "ol1", needed_for_model_ics, input_ol1) + call NetCDF_read_var(ncid, "ol2", needed_for_model_ics, input_ol2) + call NetCDF_read_var(ncid, "ol3", needed_for_model_ics, input_ol3) + call NetCDF_read_var(ncid, "ol4", needed_for_model_ics, input_ol4) + call NetCDF_read_var(ncid, "theta_oro", needed_for_model_ics, input_theta_oro) + call NetCDF_read_var(ncid, "gamma", needed_for_model_ics, input_gamma) + call NetCDF_read_var(ncid, "sigma", needed_for_model_ics, input_sigma) + call NetCDF_read_var(ncid, "elvmax", needed_for_model_ics, input_elvmax) + call NetCDF_read_var(ncid, "oro", needed_for_model_ics, input_oro) + call NetCDF_read_var(ncid, "oro_uf", needed_for_model_ics, input_oro_uf) + call NetCDF_read_var(ncid, "landfrac", needed_for_model_ics, input_landfrac) + call NetCDF_read_var(ncid, "lakefrac", needed_for_model_ics, input_lakefrac) + call NetCDF_read_var(ncid, "lakedepth", needed_for_model_ics, input_lakedepth) - !NSST variables - call NetCDF_read_var(ncid, "tref", .True., input_tref) - call NetCDF_read_var(ncid, "z_c", .True., input_z_c) - call NetCDF_read_var(ncid, "c_0", .True., input_c_0) - call NetCDF_read_var(ncid, "c_d", .True., input_c_d) - call NetCDF_read_var(ncid, "w_0", .True., input_w_0) - call NetCDF_read_var(ncid, "w_d", .True., input_w_d) - call NetCDF_read_var(ncid, "xt", .True., input_xt) - call NetCDF_read_var(ncid, "xs", .True., input_xs) - call NetCDF_read_var(ncid, "xu", .True., input_xu) - call NetCDF_read_var(ncid, "xv", .True., input_xv) - call NetCDF_read_var(ncid, "xz", .True., input_xz) - call NetCDF_read_var(ncid, "zm", .True., input_zm) - call NetCDF_read_var(ncid, "xtts", .True., input_xtts) - call NetCDF_read_var(ncid, "xzts", .True., input_xzts) - call NetCDF_read_var(ncid, "d_conv", .True., input_d_conv) - call NetCDF_read_var(ncid, "ifd", .True., input_ifd) - call NetCDF_read_var(ncid, "dt_cool", .True., input_dt_cool) - call NetCDF_read_var(ncid, "qrain", .True., input_qrain) - end if + !NSST variables + call NetCDF_read_var(ncid, "tref", needed_for_model_ics, input_tref) + call NetCDF_read_var(ncid, "z_c", needed_for_model_ics, input_z_c) + call NetCDF_read_var(ncid, "c_0", needed_for_model_ics, input_c_0) + call NetCDF_read_var(ncid, "c_d", needed_for_model_ics, input_c_d) + call NetCDF_read_var(ncid, "w_0", needed_for_model_ics, input_w_0) + call NetCDF_read_var(ncid, "w_d", needed_for_model_ics, input_w_d) + call NetCDF_read_var(ncid, "xt", needed_for_model_ics, input_xt) + call NetCDF_read_var(ncid, "xs", needed_for_model_ics, input_xs) + call NetCDF_read_var(ncid, "xu", needed_for_model_ics, input_xu) + call NetCDF_read_var(ncid, "xv", needed_for_model_ics, input_xv) + call NetCDF_read_var(ncid, "xz", needed_for_model_ics, input_xz) + call NetCDF_read_var(ncid, "zm", needed_for_model_ics, input_zm) + call NetCDF_read_var(ncid, "xtts", needed_for_model_ics, input_xtts) + call NetCDF_read_var(ncid, "xzts", needed_for_model_ics, input_xzts) + call NetCDF_read_var(ncid, "d_conv", needed_for_model_ics, input_d_conv) + call NetCDF_read_var(ncid, "ifd", needed_for_model_ics, input_ifd) + call NetCDF_read_var(ncid, "dt_cool", needed_for_model_ics, input_dt_cool) + call NetCDF_read_var(ncid, "qrain", needed_for_model_ics, input_qrain) + !> - Allocate the forcing variables. @@ -1645,106 +1651,108 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) ! ! Surface forcing Model LSM ICs ! - if (trim(input_surfaceForcingLSM) == "lsm") then - call NetCDF_read_var(ncid, "stc", .True., input_stc) - call NetCDF_read_var(ncid, "smc", .True., input_smc) - call NetCDF_read_var(ncid, "slc", .True., input_slc) - call NetCDF_read_var(ncid, "snicexy", .True., input_snicexy) - call NetCDF_read_var(ncid, "snliqxy", .True., input_snliqxy) - call NetCDF_read_var(ncid, "tsnoxy", .True., input_tsnoxy ) - call NetCDF_read_var(ncid, "smoiseq", .True., input_smoiseq) - call NetCDF_read_var(ncid, "zsnsoxy", .True., input_zsnsoxy) - call NetCDF_read_var(ncid, "tiice", .True., input_tiice) - call NetCDF_read_var(ncid, "tslb", .True., input_tslb ) - call NetCDF_read_var(ncid, "smois", .True., input_smois) - call NetCDF_read_var(ncid, "sh2o", .True., input_sh2o ) - call NetCDF_read_var(ncid, "smfr", .True., input_smfr ) - call NetCDF_read_var(ncid, "flfr", .True., input_flfr ) + + call NetCDF_read_var(ncid, "stc", .False., input_stc) + call NetCDF_read_var(ncid, "smc", .False., input_smc) + call NetCDF_read_var(ncid, "slc", .False., input_slc) + + call NetCDF_read_var(ncid, "tiice", .False., input_tiice) - call NetCDF_read_var(ncid, "vegsrc", .True., input_vegsrc ) - call NetCDF_read_var(ncid, "vegtyp", .True., input_vegtyp ) - call NetCDF_read_var(ncid, "soiltyp", .True., input_soiltyp ) - call NetCDF_read_var(ncid, "scolor", .True., input_scolor) - call NetCDF_read_var(ncid, "slopetyp", .True., input_slopetype) - call NetCDF_read_var(ncid, "tsfco", .True., input_tsfco) - call NetCDF_read_var(ncid, "vegfrac", .True., input_vegfrac) - call NetCDF_read_var(ncid, "shdmin", .True., input_shdmin) - call NetCDF_read_var(ncid, "shdmax", .True., input_shdmax) - call NetCDF_read_var(ncid, "slmsk", .True., input_slmsk) - call NetCDF_read_var(ncid, "canopy", .True., input_canopy) - call NetCDF_read_var(ncid, "hice", .True., input_hice) - call NetCDF_read_var(ncid, "fice", .True., input_fice) - call NetCDF_read_var(ncid, "tisfc", .True., input_tisfc) - call NetCDF_read_var(ncid, "snowd", .True., input_snwdph) - call NetCDF_read_var(ncid, "snoalb", .True., input_snoalb) - call NetCDF_read_var(ncid, "tg3", .True., input_tg3) - call NetCDF_read_var(ncid, "uustar", .True., input_uustar) - call NetCDF_read_var(ncid, "alvsf", .True., input_alvsf) - call NetCDF_read_var(ncid, "alnsf", .True., input_alnsf) - call NetCDF_read_var(ncid, "alvwf", .True., input_alvwf) - call NetCDF_read_var(ncid, "alnwf", .True., input_alnwf) - call NetCDF_read_var(ncid, "facsf", .True., input_facsf) - call NetCDF_read_var(ncid, "facwf", .True., input_facwf) - call NetCDF_read_var(ncid, "weasd", .True., input_weasd) - call NetCDF_read_var(ncid, "f10m", .True., input_f10m) - call NetCDF_read_var(ncid, "t2m", .True., input_t2m) - call NetCDF_read_var(ncid, "q2m", .True., input_q2m) - call NetCDF_read_var(ncid, "ffmm", .True., input_ffmm) - call NetCDF_read_var(ncid, "ffhh", .True., input_ffhh) - call NetCDF_read_var(ncid, "tprcp", .True., input_tprcp) - call NetCDF_read_var(ncid, "srflag", .True., input_srflag) - call NetCDF_read_var(ncid, "sncovr", .True., input_sncovr) - call NetCDF_read_var(ncid, "tsfcl", .True., input_tsfcl) - call NetCDF_read_var(ncid, "zorll", .True., input_zorll) - call NetCDF_read_var(ncid, "zorli", .True., input_zorli) - call NetCDF_read_var(ncid, "zorlw", .True., input_zorlw) + call NetCDF_read_var(ncid, "vegsrc", .False., input_vegsrc ) + call NetCDF_read_var(ncid, "vegtyp", .False., input_vegtyp ) + call NetCDF_read_var(ncid, "soiltyp", .False., input_soiltyp ) + call NetCDF_read_var(ncid, "scolor", .False., input_scolor) + call NetCDF_read_var(ncid, "slopetyp", .False., input_slopetype) + call NetCDF_read_var(ncid, "tsfco", .False., input_tsfco) + call NetCDF_read_var(ncid, "vegfrac", .False., input_vegfrac) + call NetCDF_read_var(ncid, "shdmin", .False., input_shdmin) + call NetCDF_read_var(ncid, "shdmax", .False., input_shdmax) + call NetCDF_read_var(ncid, "slmsk", .False., input_slmsk) + call NetCDF_read_var(ncid, "canopy", .False., input_canopy) + call NetCDF_read_var(ncid, "hice", .False., input_hice) + call NetCDF_read_var(ncid, "fice", .False., input_fice) + call NetCDF_read_var(ncid, "tisfc", .False., input_tisfc) + call NetCDF_read_var(ncid, "snowd", .False., input_snwdph) + call NetCDF_read_var(ncid, "snoalb", .False., input_snoalb) + call NetCDF_read_var(ncid, "tg3", .False., input_tg3) + call NetCDF_read_var(ncid, "uustar", .False., input_uustar) + call NetCDF_read_var(ncid, "alvsf", .False., input_alvsf) + call NetCDF_read_var(ncid, "alnsf", .False., input_alnsf) + call NetCDF_read_var(ncid, "alvwf", .False., input_alvwf) + call NetCDF_read_var(ncid, "alnwf", .False., input_alnwf) + call NetCDF_read_var(ncid, "facsf", .False., input_facsf) + call NetCDF_read_var(ncid, "facwf", .False., input_facwf) + call NetCDF_read_var(ncid, "weasd", .False., input_weasd) + call NetCDF_read_var(ncid, "f10m", .False., input_f10m) + call NetCDF_read_var(ncid, "t2m", .False., input_t2m) + call NetCDF_read_var(ncid, "q2m", .False., input_q2m) + call NetCDF_read_var(ncid, "ffmm", .False., input_ffmm) + call NetCDF_read_var(ncid, "ffhh", .False., input_ffhh) + call NetCDF_read_var(ncid, "tprcp", .False., input_tprcp) + call NetCDF_read_var(ncid, "srflag", .False., input_srflag) + call NetCDF_read_var(ncid, "sncovr", .False., input_sncovr) + call NetCDF_read_var(ncid, "tsfcl", .False., input_tsfcl) + call NetCDF_read_var(ncid, "zorll", .False., input_zorll) + call NetCDF_read_var(ncid, "zorli", .False., input_zorli) + call NetCDF_read_var(ncid, "zorlw", .False., input_zorlw) - !NoahMP parameters - call NetCDF_read_var(ncid, "tvxy", .False., input_tvxy) - call NetCDF_read_var(ncid, "tgxy", .False., input_tgxy) - call NetCDF_read_var(ncid, "tahxy", .False., input_tahxy) - call NetCDF_read_var(ncid, "canicexy", .False., input_canicexy) - call NetCDF_read_var(ncid, "canliqxy", .False., input_canliqxy) - call NetCDF_read_var(ncid, "eahxy", .False., input_eahxy) - call NetCDF_read_var(ncid, "cmxy", .False., input_cmxy) - call NetCDF_read_var(ncid, "chxy", .False., input_chxy) - call NetCDF_read_var(ncid, "fwetxy", .False., input_fwetxy) - call NetCDF_read_var(ncid, "sneqvoxy", .False., input_sneqvoxy) - call NetCDF_read_var(ncid, "alboldxy", .False., input_alboldxy) - call NetCDF_read_var(ncid, "qsnowxy", .False., input_qsnowxy) - call NetCDF_read_var(ncid, "wslakexy", .False., input_wslakexy) - call NetCDF_read_var(ncid, "taussxy", .False., input_taussxy) - call NetCDF_read_var(ncid, "waxy", .False., input_waxy) - call NetCDF_read_var(ncid, "wtxy", .False., input_wtxy) - call NetCDF_read_var(ncid, "zwtxy", .False., input_zwtxy) - call NetCDF_read_var(ncid, "xlaixy", .False., input_xlaixy) - call NetCDF_read_var(ncid, "xsaixy", .False., input_xsaixy) - call NetCDF_read_var(ncid, "lfmassxy", .False., input_lfmassxy) - call NetCDF_read_var(ncid, "stmassxy", .False., input_stmassxy) - call NetCDF_read_var(ncid, "rtmassxy", .False., input_rtmassxy) - call NetCDF_read_var(ncid, "woodxy", .False., input_woodxy) - call NetCDF_read_var(ncid, "stblcpxy", .False., input_stblcpxy) - call NetCDF_read_var(ncid, "fastcpxy", .False., input_fastcpxy) - call NetCDF_read_var(ncid, "smcwtdxy", .False., input_smcwtdxy) - call NetCDF_read_var(ncid, "deeprechxy",.False., input_deeprechxy) - call NetCDF_read_var(ncid, "rechxy", .False., input_rechxy) - call NetCDF_read_var(ncid, "snowxy", .False., input_snowxy) - !RUC LSM variables - call NetCDF_read_var(ncid, "wetness", .False., input_wetness) - call NetCDF_read_var(ncid, "clw_surf_land", .False., input_clw_surf_land) - call NetCDF_read_var(ncid, "clw_surf_ice", .False., input_clw_surf_ice) - call NetCDF_read_var(ncid, "qwv_surf_land", .False., input_qwv_surf_land) - call NetCDF_read_var(ncid, "qwv_surf_ice", .False., input_qwv_surf_ice) - call NetCDF_read_var(ncid, "tsnow_land", .False., input_tsnow_land) - call NetCDF_read_var(ncid, "tsnow_ice", .False., input_tsnow_ice) - call NetCDF_read_var(ncid, "snowfallac_land", .False., input_snowfallac_land) - call NetCDF_read_var(ncid, "snowfallac_ice", .False., input_snowfallac_ice) - call NetCDF_read_var(ncid, "sncovr_ice", .False., input_sncovr_ice) - call NetCDF_read_var(ncid, "sfalb_lnd", .False., input_sfalb_lnd) - call NetCDF_read_var(ncid, "sfalb_lnd_bck", .False., input_sfalb_lnd_bck) - call NetCDF_read_var(ncid, "emis_ice", .False., input_emis_ice) - call NetCDF_read_var(ncid, "lai", .False., input_lai) - end if + !NoahMP parameters + call NetCDF_read_var(ncid, "snicexy", .False., input_snicexy) + call NetCDF_read_var(ncid, "snliqxy", .False., input_snliqxy) + call NetCDF_read_var(ncid, "tsnoxy", .False., input_tsnoxy ) + call NetCDF_read_var(ncid, "smoiseq", .False., input_smoiseq) + call NetCDF_read_var(ncid, "zsnsoxy", .False., input_zsnsoxy) + + call NetCDF_read_var(ncid, "tvxy", .False., input_tvxy) + call NetCDF_read_var(ncid, "tgxy", .False., input_tgxy) + call NetCDF_read_var(ncid, "tahxy", .False., input_tahxy) + call NetCDF_read_var(ncid, "canicexy", .False., input_canicexy) + call NetCDF_read_var(ncid, "canliqxy", .False., input_canliqxy) + call NetCDF_read_var(ncid, "eahxy", .False., input_eahxy) + call NetCDF_read_var(ncid, "cmxy", .False., input_cmxy) + call NetCDF_read_var(ncid, "chxy", .False., input_chxy) + call NetCDF_read_var(ncid, "fwetxy", .False., input_fwetxy) + call NetCDF_read_var(ncid, "sneqvoxy", .False., input_sneqvoxy) + call NetCDF_read_var(ncid, "alboldxy", .False., input_alboldxy) + call NetCDF_read_var(ncid, "qsnowxy", .False., input_qsnowxy) + call NetCDF_read_var(ncid, "wslakexy", .False., input_wslakexy) + call NetCDF_read_var(ncid, "taussxy", .False., input_taussxy) + call NetCDF_read_var(ncid, "waxy", .False., input_waxy) + call NetCDF_read_var(ncid, "wtxy", .False., input_wtxy) + call NetCDF_read_var(ncid, "zwtxy", .False., input_zwtxy) + call NetCDF_read_var(ncid, "xlaixy", .False., input_xlaixy) + call NetCDF_read_var(ncid, "xsaixy", .False., input_xsaixy) + call NetCDF_read_var(ncid, "lfmassxy", .False., input_lfmassxy) + call NetCDF_read_var(ncid, "stmassxy", .False., input_stmassxy) + call NetCDF_read_var(ncid, "rtmassxy", .False., input_rtmassxy) + call NetCDF_read_var(ncid, "woodxy", .False., input_woodxy) + call NetCDF_read_var(ncid, "stblcpxy", .False., input_stblcpxy) + call NetCDF_read_var(ncid, "fastcpxy", .False., input_fastcpxy) + call NetCDF_read_var(ncid, "smcwtdxy", .False., input_smcwtdxy) + call NetCDF_read_var(ncid, "deeprechxy",.False., input_deeprechxy) + call NetCDF_read_var(ncid, "rechxy", .False., input_rechxy) + call NetCDF_read_var(ncid, "snowxy", .False., input_snowxy) + !RUC LSM variables + call NetCDF_read_var(ncid, "tslb", .False., input_tslb ) + call NetCDF_read_var(ncid, "smois", .False., input_smois) + call NetCDF_read_var(ncid, "sh2o", .False., input_sh2o ) + call NetCDF_read_var(ncid, "smfr", .False., input_smfr ) + call NetCDF_read_var(ncid, "flfr", .False., input_flfr ) + call NetCDF_read_var(ncid, "wetness", .False., input_wetness) + call NetCDF_read_var(ncid, "clw_surf_land", .False., input_clw_surf_land) + call NetCDF_read_var(ncid, "clw_surf_ice", .False., input_clw_surf_ice) + call NetCDF_read_var(ncid, "qwv_surf_land", .False., input_qwv_surf_land) + call NetCDF_read_var(ncid, "qwv_surf_ice", .False., input_qwv_surf_ice) + call NetCDF_read_var(ncid, "tsnow_land", .False., input_tsnow_land) + call NetCDF_read_var(ncid, "tsnow_ice", .False., input_tsnow_ice) + call NetCDF_read_var(ncid, "snowfallac_land", .False., input_snowfallac_land) + call NetCDF_read_var(ncid, "snowfallac_ice", .False., input_snowfallac_ice) + call NetCDF_read_var(ncid, "sncovr_ice", .False., input_sncovr_ice) + call NetCDF_read_var(ncid, "sfalb_lnd", .False., input_sfalb_lnd) + call NetCDF_read_var(ncid, "sfalb_lnd_bck", .False., input_sfalb_lnd_bck) + call NetCDF_read_var(ncid, "emis_ice", .False., input_emis_ice) + call NetCDF_read_var(ncid, "lai", .False., input_lai) + call check(NF90_CLOSE(NCID=ncid),"nf90_close()") @@ -2259,8 +2267,8 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) !set all individual w forcing controls to .true. until finer control is available from the input file scm_state%force_sub_for_T = .true. scm_state%force_sub_for_qv = .true. - scm_state%force_sub_for_u = .true. - scm_state%force_sub_for_v = .true. + !scm_state%force_sub_for_u = .true. + !scm_state%force_sub_for_v = .true. else if (forc_w > 0) then do i=1, input_n_forcing_times scm_input%input_w_ls(i,:) = input_force_w(:,i) @@ -2270,8 +2278,8 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) !set all individual w forcing controls to .true. until finer control is available from the input file scm_state%force_sub_for_T = .true. scm_state%force_sub_for_qv = .true. - scm_state%force_sub_for_u = .true. - scm_state%force_sub_for_v = .true. + ! scm_state%force_sub_for_u = .true. + ! scm_state%force_sub_for_v = .true. end if if (forc_geo > 0) then From 3ba2954545084e25fd9cbcc44155db141b22bf61 Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Wed, 31 Jul 2024 13:04:12 -0400 Subject: [PATCH 08/13] add COMBLE case configuration and changes to scm_input.F90 to work with non-conforming COMBLE case DEPHY file --- scm/etc/case_config/COMBLE.nml | 9 +++++ scm/src/scm_input.F90 | 61 ++++++++++++++++++++++++++++++---- 2 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 scm/etc/case_config/COMBLE.nml diff --git a/scm/etc/case_config/COMBLE.nml b/scm/etc/case_config/COMBLE.nml new file mode 100644 index 000000000..c408cd88a --- /dev/null +++ b/scm/etc/case_config/COMBLE.nml @@ -0,0 +1,9 @@ +$case_config +case_name = 'COMBLE', +input_type = 1 +lsm_ics = .false., +do_spinup = .false., +spinup_timesteps = 0, +reference_profile_choice = 2, +column_area = 1.45E8, +$end diff --git a/scm/src/scm_input.F90 b/scm/src/scm_input.F90 index 1b2dab265..1ab41cdfa 100644 --- a/scm/src/scm_input.F90 +++ b/scm/src/scm_input.F90 @@ -1158,11 +1158,12 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) integer :: ncid, varID, allocate_status, ierr, i, k integer :: active_lon, active_lat, active_init_time CHARACTER(LEN=nf90_max_name) :: tmpName + CHARACTER(LEN=nf90_max_name) :: tmpUnits real(kind=sp), parameter :: p0 = 100000.0 real(kind=sp) :: exner, exner_inv, rho, elapsed_sec, missing_value_eps real(kind=dp) :: rinc(5) integer :: jdat(1:8), idat(1:8) !(yr, mon, day, t-zone, hr, min, sec, mil-sec) - logical :: needed_for_lsm_ics, needed_for_model_ics + logical :: needed_for_lsm_ics, needed_for_model_ics, lev_in_altitude integer :: input_n_init_times, input_n_forcing_times, input_n_lev, input_n_snow, input_n_ice, input_n_soil @@ -1182,7 +1183,17 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) call check(NF90_INQUIRE_DIMENSION(ncid, varID, tmpName, input_n_lev),"nf90_inq_dim(lev)") !Check whether long_name = 'altitude', units='m' OR long_name = 'pressure', units='Pa'? !It may not matter, because 'lev' may not be needed when the IC pressure and height are BOTH already provided - + call check(NF90_INQ_VARID(ncid,"lev",varID),"nf90_inq_varid(lev)") + call check(NF90_GET_ATT(ncid, varID, "units", tmpUnits),"nf90_get_att(units)") + if (adjustl(trim(tmpUnits)) == 'pa' .or. adjustl(trim(tmpUnits)) == 'Pa') then + lev_in_altitude = .false. + else if (adjustl(trim(tmpUnits)) == 'm') then + lev_in_altitude = .true. + else + write(0,'(a,i0,a)') "The variable 'lev' in the case data file had units different than 'm', 'pa', or 'Pa', but it is expected to be altitude in m or pressure in Pa. Stopping..." + STOP + end if + !### TO BE USED IF DEPHY-SCM can be extended to include model ICs ### !possible dimensions (if using model ICs) ierr = NF90_INQ_DIMID(ncid,"nsoil",varID) @@ -1461,8 +1472,31 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) if (scm_state%model_ics) needed_for_model_ics = .True. !> - Read in the initial profiles. - call NetCDF_read_var(ncid, "pa", .True., input_pres) - call NetCDF_read_var(ncid, "zh", .True., input_height) + + if (lev_in_altitude) then + call NetCDF_read_var(ncid, "pa", .True., input_pres) + !zh could be defined in addition to lev, use if so + call NetCDF_read_var(ncid, "zh", .False., input_height) + if (input_height(1,1) == missing_value) then + do i=1, input_n_init_times + do k=1, input_n_lev + input_height(k,i) = input_lev(k) + end do + end do + end if + else + call NetCDF_read_var(ncid, "zh", .True., input_height) + !pa could be defined in addition to lev, use if so + call NetCDF_read_var(ncid, "pa", .False., input_pres) + if (input_pres(1,1) == missing_value) then + do i=1, input_n_init_times + do k=1, input_n_lev + input_pres(k,i) = input_lev(k) + end do + end do + end if + end if + call NetCDF_read_var(ncid, "ps", .True., input_pres_surf) call NetCDF_read_var(ncid, "ua", .True., input_u) call NetCDF_read_var(ncid, "va", .True., input_v) @@ -1580,8 +1614,23 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) call NetCDF_read_var(ncid, "lat", .True., input_lat) call NetCDF_read_var(ncid, "lon", .True., input_lon) call NetCDF_read_var(ncid, "ps_forc", .True., input_force_pres_surf) - call NetCDF_read_var(ncid, "zh_forc", .True., input_force_height) - call NetCDF_read_var(ncid, "pa_forc", .True., input_force_pres) + !zh_forc and pa_forc should be present according to the DEPHY standard; if not, assume that zh_forc = input_height and pa_forc = input_pres + call NetCDF_read_var(ncid, "zh_forc", .False., input_force_height) + if (input_force_height(1,1) == missing_value) then + do i=1, input_n_forcing_times + do k=1, input_n_lev + input_force_height(k,i) = input_height(k,1) + end do + end do + end if + call NetCDF_read_var(ncid, "pa_forc", .False., input_force_pres) + if (input_force_pres(1,1) == missing_value) then + do i=1, input_n_forcing_times + do k=1, input_n_lev + input_force_pres(k,i) = input_pres(k,1) + end do + end do + end if !conditionally read forcing vars (or set to missing); if the global attribute is set to expect a variable and it doesn't exist, stop the model call NetCDF_conditionally_read_var(adv_u, "adv_ua", "tnua_adv", trim(adjustl(scm_state%case_name))//'.nc', ncid, input_force_u_adv) From 7eae6383bc49bbbb426a7b3fc5a7dd2e8c009420 Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Thu, 1 Aug 2024 15:40:53 -0400 Subject: [PATCH 09/13] update and convert MOSAiC cases to DEPHY format; allow both surfaceforcingT to be true and surfaceforcinglsm to be true - ingests LSM data and a forcing surface T --- scm/etc/case_config/MOSAiC-AMPS.nml | 25 +++---- scm/etc/case_config/MOSAiC-SS.nml | 25 +++---- .../MOSAiC_AMPS_forcing_file_generator.py | 68 ++++++++++++++----- .../MOSAiC_SS_forcing_file_generator.py | 68 ++++++++++++++----- scm/etc/scripts/dephy_converter.py | 27 ++++---- scm/src/scm_input.F90 | 4 +- 6 files changed, 136 insertions(+), 81 deletions(-) mode change 100644 => 100755 scm/etc/scripts/MOSAiC_AMPS_forcing_file_generator.py mode change 100644 => 100755 scm/etc/scripts/MOSAiC_SS_forcing_file_generator.py diff --git a/scm/etc/case_config/MOSAiC-AMPS.nml b/scm/etc/case_config/MOSAiC-AMPS.nml index ca3148a9f..bbcbdf46e 100644 --- a/scm/etc/case_config/MOSAiC-AMPS.nml +++ b/scm/etc/case_config/MOSAiC-AMPS.nml @@ -1,17 +1,8 @@ -$case_config -case_name = 'MOSAiC-AMPS', -runtime = 604800.0, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 3600.0, -sfc_flux_spec = .false., -sfc_type = 2, -sfc_roughness_length_cm = 0.02, -reference_profile_choice = 1, -year = 2019, -month = 10, -day = 31, -hour = 0, -column_area = 2.0E9, -lsm_ics = .true., -$end +&case_config + case_name = 'MOSAiC-AMPS' + column_area = 2000000000.0 + input_type = 1 + lsm_ics = .true. + reference_profile_choice = 1 + sfc_roughness_length_cm = 0.02 +/ diff --git a/scm/etc/case_config/MOSAiC-SS.nml b/scm/etc/case_config/MOSAiC-SS.nml index a2f5caa81..ec995e675 100644 --- a/scm/etc/case_config/MOSAiC-SS.nml +++ b/scm/etc/case_config/MOSAiC-SS.nml @@ -1,17 +1,8 @@ -$case_config -case_name = 'MOSAiC-SS', -runtime = 604800.0, -thermo_forcing_type = 2, -mom_forcing_type = 3, -relax_time = 3600.0, -sfc_flux_spec = .false., -sfc_type = 2, -sfc_roughness_length_cm = 0.02, -reference_profile_choice = 1, -year = 2020, -month = 3, -day = 2, -hour = 0, -column_area = 2.0E9, -lsm_ics = .true., -$end +&case_config + case_name = 'MOSAiC-SS' + column_area = 2000000000.0 + input_type = 1 + lsm_ics = .true. + reference_profile_choice = 1 + sfc_roughness_length_cm = 0.02 +/ diff --git a/scm/etc/scripts/MOSAiC_AMPS_forcing_file_generator.py b/scm/etc/scripts/MOSAiC_AMPS_forcing_file_generator.py old mode 100644 new mode 100755 index cfbb2d2ba..b2c5a9381 --- a/scm/etc/scripts/MOSAiC_AMPS_forcing_file_generator.py +++ b/scm/etc/scripts/MOSAiC_AMPS_forcing_file_generator.py @@ -146,6 +146,9 @@ #height = ffc.get_height_from_pres(T_abs[:,0],levels,z_sfc) #the following variables are not in this forcing file, but are included in other cases +soil_depth = np.zeros(4,dtype=float) +soil_depth[:] = [0.1, 0.4, 1.0, 2.0] + #rad_heating = nc_fid.variables['dT_dt_rad'][:] #K/s #rad_heating = np.swapaxes(rad_heating, 0, 1) #swap the time and levels axis rad_heating = np.zeros((levels.size,time.size),dtype=float) @@ -163,29 +166,31 @@ smc = 0.33 slc = 0.33 hice = 0.3 -slmsk = 2.0 +slmsk = 2.0 #sea ice tsfco = T_surf[start_t_index] -weasd = 200.0 +weasd = 200.0 #mm water equivalent snow depth fice = 1.0 tisfc = tsfco snwdph = 2.e-4 tg3 = 271.35 zorl = 15.0 -alvsf = 0.23 -alnsf = 0.23 -alvwf = 0.23 -alnwf = 0.23 -facsf = 0.5055632 -facwf = 0.4944368 +alvsf = 0.06 +alnsf = 0.06 +alvwf = 0.06 +alnwf = 0.06 +facsf = 0.0 +facwf = 0.0 vegfrac = 0.0 canopy = 0.0 -vegtyp = 10 -soiltyp = 12 +vegtyp = 0 +soiltyp = 0 +scolor = 1 uustar = 0.3828793 -shdmin = 0.01 -shdmax = 0.8 +shdmin = 0.0 +shdmax = 0.0 slopetyp = 1 -snoalb = 0.7287961 +snoalb = 0.0 +sncovr = 1.0 # Open ozone file #f = open('../../data/raw_case_input/twpice_CRM_ozone.txt', 'r') @@ -237,6 +242,12 @@ writefile_levels_var.units = 'Pa' writefile_levels_var.description = 'pressure levels' +writefile_soil_depth_dim = writefile_fid.createDimension('soil_depth', None) +writefile_soil_depth_var = writefile_fid.createVariable('soil_depth', 'f4', ('soil_depth',)) +writefile_soil_depth_var[:] = soil_depth[:] +writefile_soil_depth_var.units = 'm' +writefile_soil_depth_var.description = 'soil depth' + writefile_ice_thickness_dim = writefile_fid.createDimension('ice_thickness', None) writefile_ice_thickness_var = writefile_fid.createVariable('ice_thickness', 'f4', ('ice_thickness',)) writefile_ice_thickness_var[:] = ice_thickness @@ -302,6 +313,21 @@ writefile_zorl_var.units = 'cm' writefile_zorl_var.description = 'composite surface roughness length' +writefile_zorll_var = writefile_scalar_grp.createVariable('zorll', 'f4') +writefile_zorll_var[:] = zorl +writefile_zorll_var.units = 'cm' +writefile_zorll_var.description = 'surface roughness length over land' + +writefile_zorlw_var = writefile_scalar_grp.createVariable('zorlw', 'f4') +writefile_zorlw_var[:] = zorl +writefile_zorlw_var.units = 'cm' +writefile_zorlw_var.description = 'surface roughness length over ocean' + +writefile_zorli_var = writefile_scalar_grp.createVariable('zorli', 'f4') +writefile_zorli_var[:] = zorl +writefile_zorli_var.units = 'cm' +writefile_zorli_var.description = 'surface roughness length over ice' + writefile_alvsf_var = writefile_scalar_grp.createVariable('alvsf', 'f4') writefile_alvsf_var[:] = alvsf writefile_alvsf_var.units = '' @@ -352,6 +378,11 @@ writefile_soiltyp_var.units = '' writefile_soiltyp_var.description = 'soil type 1-12' +writefile_scolor_var = writefile_scalar_grp.createVariable('scolor', 'f4') +writefile_scolor_var[:] = scolor +writefile_scolor_var.units = '' +writefile_scolor_var.description = 'soil color' + writefile_uustar_var = writefile_scalar_grp.createVariable('uustar', 'f4') writefile_uustar_var[:] = uustar writefile_uustar_var.units = 'm s-1' @@ -377,6 +408,11 @@ writefile_snoalb_var.units = '1' writefile_snoalb_var.description = 'maximum snow albedo' +writefile_sncovr_var = writefile_scalar_grp.createVariable('sncovr', 'f4') +writefile_sncovr_var[:] = sncovr +writefile_sncovr_var.units = '1' +writefile_sncovr_var.description = 'surface snow area fraction' + #initial group writefile_height_var = writefile_initial_grp.createVariable('height', 'f4', ('levels',)) @@ -389,17 +425,17 @@ writefile_tiice_var.units = 'K' writefile_tiice_var.description = 'initial profile of sea ice internal temperature' -writefile_stc_var = writefile_initial_grp.createVariable('stc', 'f4') +writefile_stc_var = writefile_initial_grp.createVariable('stc', 'f4', ('soil_depth',)) writefile_stc_var[:] = stc writefile_stc_var.units = 'K' writefile_stc_var.description = 'initial profile of sea ice internal temperature' -writefile_smc_var = writefile_initial_grp.createVariable('smc', 'f4') +writefile_smc_var = writefile_initial_grp.createVariable('smc', 'f4', ('soil_depth',)) writefile_smc_var[:] = smc writefile_smc_var.units = 'm3 m-3' writefile_smc_var.description = 'initial profile of soil moisture' -writefile_slc_var = writefile_initial_grp.createVariable('slc', 'f4') +writefile_slc_var = writefile_initial_grp.createVariable('slc', 'f4', ('soil_depth',)) writefile_slc_var[:] = slc writefile_slc_var.units = 'm3 m-3' writefile_slc_var.description = 'initial profile of soil liquid water' diff --git a/scm/etc/scripts/MOSAiC_SS_forcing_file_generator.py b/scm/etc/scripts/MOSAiC_SS_forcing_file_generator.py old mode 100644 new mode 100755 index 918eea33e..514c4dfe2 --- a/scm/etc/scripts/MOSAiC_SS_forcing_file_generator.py +++ b/scm/etc/scripts/MOSAiC_SS_forcing_file_generator.py @@ -146,6 +146,9 @@ #height = ffc.get_height_from_pres(T_abs[:,0],levels,z_sfc) #the following variables are not in this forcing file, but are included in other cases +soil_depth = np.zeros(4,dtype=float) +soil_depth[:] = [0.1, 0.4, 1.0, 2.0] + #rad_heating = nc_fid.variables['dT_dt_rad'][:] #K/s #rad_heating = np.swapaxes(rad_heating, 0, 1) #swap the time and levels axis rad_heating = np.zeros((levels.size,time.size),dtype=float) @@ -163,29 +166,31 @@ smc = 0.33 slc = 0.33 hice = 0.3 -slmsk = 2.0 +slmsk = 2.0 #sea ice tsfco = T_surf[start_t_index] -weasd = 200.0 +weasd = 200.0 #mm water equivalent snow depth fice = 1.0 tisfc = tsfco snwdph = 2.e-4 tg3 = 271.35 zorl = 15.0 -alvsf = 0.23 -alnsf = 0.23 -alvwf = 0.23 -alnwf = 0.23 -facsf = 0.5055632 -facwf = 0.4944368 +alvsf = 0.06 +alnsf = 0.06 +alvwf = 0.06 +alnwf = 0.06 +facsf = 0.0 +facwf = 0.0 vegfrac = 0.0 canopy = 0.0 -vegtyp = 10 -soiltyp = 12 +vegtyp = 0 +soiltyp = 0 +scolor = 1 uustar = 0.3828793 -shdmin = 0.01 -shdmax = 0.8 +shdmin = 0.0 +shdmax = 0.0 slopetyp = 1 -snoalb = 0.7287961 +snoalb = 0.0 +sncovr = 1.0 # Open ozone file #f = open('../../data/raw_case_input/twpice_CRM_ozone.txt', 'r') @@ -237,6 +242,12 @@ writefile_levels_var.units = 'Pa' writefile_levels_var.description = 'pressure levels' +writefile_soil_depth_dim = writefile_fid.createDimension('soil_depth', None) +writefile_soil_depth_var = writefile_fid.createVariable('soil_depth', 'f4', ('soil_depth',)) +writefile_soil_depth_var[:] = soil_depth[:] +writefile_soil_depth_var.units = 'm' +writefile_soil_depth_var.description = 'soil depth' + writefile_ice_thickness_dim = writefile_fid.createDimension('ice_thickness', None) writefile_ice_thickness_var = writefile_fid.createVariable('ice_thickness', 'f4', ('ice_thickness',)) writefile_ice_thickness_var[:] = ice_thickness @@ -302,6 +313,21 @@ writefile_zorl_var.units = 'cm' writefile_zorl_var.description = 'composite surface roughness length' +writefile_zorll_var = writefile_scalar_grp.createVariable('zorll', 'f4') +writefile_zorll_var[:] = zorl +writefile_zorll_var.units = 'cm' +writefile_zorll_var.description = 'surface roughness length over land' + +writefile_zorlw_var = writefile_scalar_grp.createVariable('zorlw', 'f4') +writefile_zorlw_var[:] = zorl +writefile_zorlw_var.units = 'cm' +writefile_zorlw_var.description = 'surface roughness length over ocean' + +writefile_zorli_var = writefile_scalar_grp.createVariable('zorli', 'f4') +writefile_zorli_var[:] = zorl +writefile_zorli_var.units = 'cm' +writefile_zorli_var.description = 'surface roughness length over ice' + writefile_alvsf_var = writefile_scalar_grp.createVariable('alvsf', 'f4') writefile_alvsf_var[:] = alvsf writefile_alvsf_var.units = '' @@ -352,6 +378,11 @@ writefile_soiltyp_var.units = '' writefile_soiltyp_var.description = 'soil type 1-12' +writefile_scolor_var = writefile_scalar_grp.createVariable('scolor', 'f4') +writefile_scolor_var[:] = scolor +writefile_scolor_var.units = '' +writefile_scolor_var.description = 'soil color' + writefile_uustar_var = writefile_scalar_grp.createVariable('uustar', 'f4') writefile_uustar_var[:] = uustar writefile_uustar_var.units = 'm s-1' @@ -377,6 +408,11 @@ writefile_snoalb_var.units = '1' writefile_snoalb_var.description = 'maximum snow albedo' +writefile_sncovr_var = writefile_scalar_grp.createVariable('sncovr', 'f4') +writefile_sncovr_var[:] = sncovr +writefile_sncovr_var.units = '1' +writefile_sncovr_var.description = 'surface snow area fraction' + #initial group writefile_height_var = writefile_initial_grp.createVariable('height', 'f4', ('levels',)) @@ -389,17 +425,17 @@ writefile_tiice_var.units = 'K' writefile_tiice_var.description = 'initial profile of sea ice internal temperature' -writefile_stc_var = writefile_initial_grp.createVariable('stc', 'f4') +writefile_stc_var = writefile_initial_grp.createVariable('stc', 'f4', ('soil_depth',)) writefile_stc_var[:] = stc writefile_stc_var.units = 'K' writefile_stc_var.description = 'initial profile of sea ice internal temperature' -writefile_smc_var = writefile_initial_grp.createVariable('smc', 'f4') +writefile_smc_var = writefile_initial_grp.createVariable('smc', 'f4', ('soil_depth',)) writefile_smc_var[:] = smc writefile_smc_var.units = 'm3 m-3' writefile_smc_var.description = 'initial profile of soil moisture' -writefile_slc_var = writefile_initial_grp.createVariable('slc', 'f4') +writefile_slc_var = writefile_initial_grp.createVariable('slc', 'f4', ('soil_depth',)) writefile_slc_var[:] = slc writefile_slc_var.units = 'm3 m-3' writefile_slc_var.description = 'initial profile of soil liquid water' diff --git a/scm/etc/scripts/dephy_converter.py b/scm/etc/scripts/dephy_converter.py index 42b745d00..4dba44be8 100755 --- a/scm/etc/scripts/dephy_converter.py +++ b/scm/etc/scripts/dephy_converter.py @@ -1376,7 +1376,7 @@ def write_SCM_case_file(case_nml, case_data, use_area): nslsnw_dim = nc_file.createDimension('nsoil_plus_nsnow',case_data._snicexy.shape[0] + case_data._soil_depth.shape[0]) if (case_data._tiice[0] != case_data._missing_value): - ice_dim = nc_file.createDimension('nice', case_data._tiice[0]) + ice_dim = nc_file.createDimension('nice', case_data._tiice.shape[0]) # timei_var = nc_file.createVariable('t0', wp, ('t0')) @@ -2466,20 +2466,19 @@ def write_SCM_case_file(case_nml, case_data, use_area): else: ts_var[:] = case_data._missing_value else: - if (nc_file.surface_forcing_lsm != 'lsm'): - - nc_file.surface_forcing_temp = 'ts' - nc_file.surface_forcing_wind = 'z0' - - z0_var = nc_file.createVariable('z0', wp, ('time')) - z0_var.units = 'm' - z0_var.standard_name = 'surface_roughness_length_for_momentum_in_air' - z0_var[:] = case_nml['case_config']['sfc_roughness_length_cm']*1.0E-2 + nc_file.surface_forcing_temp = 'ts' + nc_file.surface_forcing_wind = 'z0' - ts_var = nc_file.createVariable('ts_forc', wp, ('time')) - ts_var.units = 'K' - ts_var.standard_name = 'forcing_surface_temperature' - ts_var[:] = case_data._T_surf[:] + z0_var = nc_file.createVariable('z0', wp, ('time')) + z0_var.units = 'm' + z0_var.standard_name = 'surface_roughness_length_for_momentum_in_air' + z0_var[:] = case_nml['case_config']['sfc_roughness_length_cm']*1.0E-2 + + ts_var = nc_file.createVariable('ts_forc', wp, ('time')) + ts_var.units = 'K' + ts_var.standard_name = 'forcing_surface_temperature' + ts_var[:] = case_data._T_surf[:] + nc_file.close() diff --git a/scm/src/scm_input.F90 b/scm/src/scm_input.F90 index 1ab41cdfa..2233098bf 100644 --- a/scm/src/scm_input.F90 +++ b/scm/src/scm_input.F90 @@ -2195,7 +2195,9 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) else scm_input%input_lh_flux_sfc = input_force_sfc_lat_flx(:) end if - else if (trim(input_surfaceForcingLSM) == 'lsm') then + end if + + if (trim(input_surfaceForcingLSM) == 'lsm') then !these were considered required variables above, so they should not need to be checked for missing scm_input%input_stc = input_stc(:,active_init_time) scm_input%input_smc = input_smc(:,active_init_time) From 6e449c5dbc21537008d650e111d707d529bca89f Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Thu, 1 Aug 2024 16:04:53 -0400 Subject: [PATCH 10/13] add new cases to rt_test_cases.py --- test/rt_test_cases.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/rt_test_cases.py b/test/rt_test_cases.py index f1db91bf9..1660b48c9 100644 --- a/test/rt_test_cases.py +++ b/test/rt_test_cases.py @@ -27,6 +27,17 @@ {"case": "LASSO_2016051812", "suite": "SCM_GFS_v16"}, \ {"case": "LASSO_2016051812", "suite": "SCM_WoFS_v0"}, \ {"case": "LASSO_2016051812", "suite": "SCM_HRRR_gf"}, \ + {"case": "COMBLE", "suite": "SCM_GFS_v17_p8_ugwpv1"}, \ + {"case": "COMBLE", "suite": "SCM_GFS_v16_RRTMGP"}, \ + {"case": "COMBLE", "suite": "SCM_GFS_v16"}, \ + {"case": "COMBLE", "suite": "SCM_WoFS_v0"}, \ + {"case": "COMBLE", "suite": "SCM_HRRR_gf"}, \ + {"case": "MOSAiC-AMPS", "suite": "SCM_GFS_v17_p8_ugwpv1"}, \ + {"case": "MOSAiC-AMPS", "suite": "SCM_GFS_v16_RRTMGP"}, \ + {"case": "MOSAiC-AMPS", "suite": "SCM_GFS_v16"}, \ + {"case": "MOSAiC-AMPS", "suite": "SCM_WoFS_v0"}, \ + {"case": "MOSAiC-AMPS", "suite": "SCM_HRRR_gf"}, \ + {"case": "gabls3", "suite": "SCM_GFS_v16"}, \ #---------------------------------------------------------------------------------------------------------------------------------------------- # Unsupported suites (w/ supported cases) #---------------------------------------------------------------------------------------------------------------------------------------------- From 684448dbbe3ad5abf2213083586efd4e87d90891 Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Thu, 1 Aug 2024 16:09:22 -0400 Subject: [PATCH 11/13] update get_all_static_data.sh script to grab v7.0.0-beta release assets (with new DEPHY-format processed_case_input files) --- contrib/get_all_static_data.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/get_all_static_data.sh b/contrib/get_all_static_data.sh index b0e8006dd..99c0cd4de 100755 --- a/contrib/get_all_static_data.sh +++ b/contrib/get_all_static_data.sh @@ -21,7 +21,7 @@ for file in "${data_files[@]}"; do mkdir -p $BASEDIR/scm/data/$file cd $BASEDIR/scm/data/$file echo "Retrieving $file" - wget https://github.com/NCAR/ccpp-scm/releases/download/v6.0.0/${file}.tar.gz + wget https://github.com/NCAR/ccpp-scm/releases/download/v7.0.0-beta/${file}.tar.gz tar -xf ${file}.tar.gz rm -f ${file}.tar.gz done From 6e1b78ffe1e1f54ba9ec384c003d952787261f6c Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Wed, 7 Aug 2024 13:27:45 -0400 Subject: [PATCH 12/13] add vegtype_frac and soiltype_frac to UFS_case_gen and SCM input for RUC LSM --- scm/etc/scripts/UFS_case_gen.py | 19 ++++++++++++--- scm/src/scm_input.F90 | 43 ++++++++++++++++++++++++++++++--- scm/src/scm_type_defs.F90 | 18 +++++++++++--- 3 files changed, 69 insertions(+), 11 deletions(-) diff --git a/scm/etc/scripts/UFS_case_gen.py b/scm/etc/scripts/UFS_case_gen.py index 54802d3a7..c6f1dfab1 100755 --- a/scm/etc/scripts/UFS_case_gen.py +++ b/scm/etc/scripts/UFS_case_gen.py @@ -56,6 +56,8 @@ missing_variable_snow_layers = 3 missing_variable_soil_layers = 4 missing_variable_ice_layers = 2 +missing_variable_vegetation_categories = 20 +missing_variable_soil_categories = 16 # Path to the directory containing processed case input files PROCESSED_CASE_DIR = '../../data/processed_case_input' @@ -1686,7 +1688,7 @@ def get_UFS_surface_data(dir, tile, i, j, old_chgres, lam): ######################################################################################## # ######################################################################################## -def get_UFS_oro_data(dir, tile, i, j, lam): +def get_UFS_oro_data(dir, tile, i, j, lam, old_chgres): """Get the orographic data for the given tile and indices""" if lam: @@ -1721,6 +1723,9 @@ def get_UFS_oro_data(dir, tile, i, j, lam): #lake variables (optional) lake_frac_in = read_NetCDF_var(nc_file, "lake_frac", i, j) lake_depth_in = read_NetCDF_var(nc_file, "lake_depth", i, j) + + vegtype_frac_in = read_NetCDF_surface_var(nc_file, "vegetation_type_pct", i, j, old_chgres, missing_variable_vegetation_categories) + soiltype_frac_in = read_NetCDF_surface_var(nc_file, "soil_type_pct", i, j, old_chgres, missing_variable_soil_categories) # nc_file.close() @@ -1744,7 +1749,9 @@ def get_UFS_oro_data(dir, tile, i, j, lam): "oro_uf": orog_raw_in, "landfrac": land_frac_in, "lakefrac": lake_frac_in, - "lakedepth": lake_depth_in} + "lakedepth": lake_depth_in, + "vegtype_frac": vegtype_frac_in, + "soiltype_frac": soiltype_frac_in} return oro @@ -3208,6 +3215,8 @@ def write_SCM_case_file(state, surface, oro, forcing, init, case, date, forcing_ snow_dim = nc_file.createDimension('nsnow', len(surface["snicexy"])) nslsnw_dim = nc_file.createDimension('nsoil_plus_nsnow',len(surface["snicexy"]) + len(surface["stc"])) ice_dim = nc_file.createDimension('nice', len(surface["tiice"])) + vegcat_dim = nc_file.createDimension('nvegcat', len(oro["vegtype_frac"])) + soilcat_dim =nc_file.createDimension('nsoilcat', len(oro["soiltype_frac"])) # timei_var = nc_file.createVariable('t0', wp, ('t0')) @@ -3388,7 +3397,9 @@ def write_SCM_case_file(state, surface, oro, forcing, init, case, date, forcing_ {"name": "oro_uf", "type":wp, "dimd": ('t0'), "units": "m", "desc": "unfiltered orography"}, \ {"name": "landfrac", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of horizontal grid area occupied by land"}, \ {"name": "lakefrac", "type":wp, "dimd": ('t0'), "units": "none", "desc": "fraction of horizontal grid area occupied by lake", "default_value":0}, \ - {"name": "lakedepth", "type":wp, "dimd": ('t0'), "units": "none", "desc": "lake depth", "default_value":0}] + {"name": "lakedepth", "type":wp, "dimd": ('t0'), "units": "none", "desc": "lake depth", "default_value":0}, + {"name": "vegtype_frac", "type":wp, "dimd": ('t0', 'nvegcat'), "units": "none", "desc": "fraction of horizontal grid area occupied by given vegetation category"}, + {"name": "soiltype_frac","type":wp, "dimd": ('t0', 'nsoilcat'), "units": "none", "desc": "fraction of horizontal grid area occupied by given soil category"}] # var_nsst = [{"name": "tref", "type":wp, "dimd": ('t0'), "units": "K", "desc": "sea surface reference temperature for NSST"}, \ {"name": "z_c", "type":wp, "dimd": ('t0'), "units": "m", "desc": "sub-layer cooling thickness for NSST"}, \ @@ -3682,7 +3693,7 @@ def main(): check_IC_hist_surface_compatibility(forcing_dir, hist_i, hist_j, surface_data, lam, old_chgres, tile) #read in orographic data for the initial conditions at the IC point - oro_data = get_UFS_oro_data(in_dir, tile, IC_i, IC_j, lam) + oro_data = get_UFS_oro_data(in_dir, tile, IC_i, IC_j, lam, old_chgres) #read in the initial condition profiles diff --git a/scm/src/scm_input.F90 b/scm/src/scm_input.F90 index 2233098bf..13ca8d9be 100644 --- a/scm/src/scm_input.F90 +++ b/scm/src/scm_input.F90 @@ -13,6 +13,8 @@ module scm_input integer :: missing_snow_layers = 3 integer :: missing_soil_layers = 4 integer :: missing_ice_layers = 2 +integer :: missing_nvegcat = 20 +integer :: missing_nsoilcat = 16 contains @@ -219,6 +221,7 @@ subroutine get_case_init(scm_state, scm_input) integer :: input_nice !< number of sea ice levels in the input file integer :: input_ntimes !< number of times represented in the input file integer :: input_nsoil_plus_nsnow !< number of combined snow and soil levels in the input file + integer :: input_nvegcat, input_nsoilcat real(kind=dp) :: input_lat !< column latitude (deg) real(kind=dp) :: input_lon !< column longitude (deg) real(kind=dp) :: input_area !< surface area [m^2] @@ -458,7 +461,19 @@ subroutine get_case_init(scm_state, scm_input) input_nice = missing_ice_layers else call check(NF90_INQUIRE_DIMENSION(ncid, varID, tmpName, input_nice),"nf90_inq_dim(nice)") - end if + end if + ierr = NF90_INQ_DIMID(ncid,"nvegcat",varID) + if(ierr /= NF90_NOERR) then + input_nvegcat = missing_nvegcat + else + call check(NF90_INQUIRE_DIMENSION(ncid, varID, tmpName, input_nvegcat),"nf90_inq_dim(nvegcat)") + end if + ierr = NF90_INQ_DIMID(ncid,"nsoilcat",varID) + if(ierr /= NF90_NOERR) then + input_nsoilcat = missing_nsoilcat + else + call check(NF90_INQUIRE_DIMENSION(ncid, varID, tmpName, input_nsoilcat),"nf90_inq_dim(nsoilcat)") + end if !> - Allocate the dimension variables. allocate(input_pres(input_nlev),input_time(input_ntimes), stat=allocate_status) @@ -714,7 +729,7 @@ subroutine get_case_init(scm_state, scm_input) call check(NF90_CLOSE(NCID=ncid),"nf90_close()") - call scm_input%create(input_ntimes, input_nlev, input_nsoil, input_nsnow, input_nice) + call scm_input%create(input_ntimes, input_nlev, input_nsoil, input_nsnow, input_nice, input_nvegcat, input_nsoilcat) ! GJF already done in scm_input%create routine !scm_input%input_nlev = input_nlev @@ -1050,6 +1065,8 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) real(kind=dp), allocatable :: input_landfrac(:) !< fraction of horizontal grid area occupied by land real(kind=dp), allocatable :: input_lakefrac(:) !< fraction of horizontal grid area occupied by lake real(kind=dp), allocatable :: input_lakedepth(:) !< lake depth (m) + real(kind=dp), allocatable :: input_vegtype_frac(:,:) !< fraction of horizontal grid area occupied by given vegetation category + real(kind=dp), allocatable :: input_soiltype_frac(:,:) !< fraction of horizontal grid area occupied by given soil category real(kind=dp), allocatable :: input_tvxy(:) !< vegetation temperature (K) real(kind=dp), allocatable :: input_tgxy(:) !< ground temperature for Noahmp (K) @@ -1165,7 +1182,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) integer :: jdat(1:8), idat(1:8) !(yr, mon, day, t-zone, hr, min, sec, mil-sec) logical :: needed_for_lsm_ics, needed_for_model_ics, lev_in_altitude - integer :: input_n_init_times, input_n_forcing_times, input_n_lev, input_n_snow, input_n_ice, input_n_soil + integer :: input_n_init_times, input_n_forcing_times, input_n_lev, input_n_snow, input_n_ice, input_n_soil, input_nvegcat, input_nsoilcat missing_value_eps = missing_value + 0.01 @@ -1213,6 +1230,18 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) input_n_ice = missing_ice_layers else call check(NF90_INQUIRE_DIMENSION(ncid, varID, tmpName, input_n_ice),"nf90_inq_dim(nice)") + end if + ierr = NF90_INQ_DIMID(ncid,"nvegcat",varID) + if(ierr /= NF90_NOERR) then + input_nvegcat = missing_nvegcat + else + call check(NF90_INQUIRE_DIMENSION(ncid, varID, tmpName, input_nvegcat),"nf90_inq_dim(nvegcat)") + end if + ierr = NF90_INQ_DIMID(ncid,"nsoilcat",varID) + if(ierr /= NF90_NOERR) then + input_nsoilcat = missing_nsoilcat + else + call check(NF90_INQUIRE_DIMENSION(ncid, varID, tmpName, input_nsoilcat),"nf90_inq_dim(nsoilcat)") end if !> - Allocate the dimension variables. @@ -1399,6 +1428,8 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) input_landfrac ( input_n_init_times), & input_lakefrac ( input_n_init_times), & input_lakedepth ( input_n_init_times), & + input_vegtype_frac (input_nvegcat, input_n_init_times), & + input_soiltype_frac (input_nsoilcat, input_n_init_times),& stat=allocate_status) allocate(input_tvxy ( input_n_init_times), & input_tgxy ( input_n_init_times), & @@ -1543,6 +1574,8 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) call NetCDF_read_var(ncid, "landfrac", needed_for_model_ics, input_landfrac) call NetCDF_read_var(ncid, "lakefrac", needed_for_model_ics, input_lakefrac) call NetCDF_read_var(ncid, "lakedepth", needed_for_model_ics, input_lakedepth) + call NetCDF_read_var(ncid, "vegtype_frac", needed_for_model_ics, input_vegtype_frac) + call NetCDF_read_var(ncid, "soiltype_frac", needed_for_model_ics, input_soiltype_frac) !NSST variables call NetCDF_read_var(ncid, "tref", needed_for_model_ics, input_tref) @@ -1805,7 +1838,7 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) call check(NF90_CLOSE(NCID=ncid),"nf90_close()") - call scm_input%create(input_n_forcing_times, input_n_lev, input_n_soil, input_n_snow, input_n_ice) + call scm_input%create(input_n_forcing_times, input_n_lev, input_n_soil, input_n_snow, input_n_ice, input_nvegcat, input_nsoilcat) !fill the scm_input DDT @@ -2046,6 +2079,8 @@ subroutine get_case_init_DEPHY(scm_state, scm_input) scm_input%input_landfrac = input_landfrac(active_init_time) scm_input%input_lakefrac = input_lakefrac(active_init_time) scm_input%input_lakedepth= input_lakedepth(active_init_time) + scm_input%input_vegtype_frac = input_vegtype_frac(:,active_init_time) + scm_input%input_soiltype_frac = input_soiltype_frac(:,active_init_time) scm_input%input_tref = input_tref(active_init_time) scm_input%input_z_c = input_z_c(active_init_time) diff --git a/scm/src/scm_type_defs.F90 b/scm/src/scm_type_defs.F90 index 01629bacf..5302b7507 100644 --- a/scm/src/scm_type_defs.F90 +++ b/scm/src/scm_type_defs.F90 @@ -180,6 +180,8 @@ module scm_type_defs integer :: input_nsoil !< number of soil levels in the input file integer :: input_nsnow !< number of snow layers in the input file integer :: input_nice !< number of sea ice layers in the input file + integer :: input_nvegcat !< number of vegetation type categories + integer :: input_nsoilcat !< number of soil type categories integer :: input_ntimes !< number of times in the input file where forcing is available real(kind=dp) :: input_lat !< latitude of column center real(kind=dp) :: input_lon !< longitude of column center @@ -262,6 +264,8 @@ module scm_type_defs real(kind=dp) :: input_landfrac !< fraction of horizontal grid area occupied by land real(kind=dp) :: input_lakefrac !< fraction of horizontal grid area occupied by lake real(kind=dp) :: input_lakedepth !< lake depth (m) + real(kind=dp), allocatable :: input_vegtype_frac(:) !< fraction of horizontal grid area occupied by given vegetation category + real(kind=dp), allocatable :: input_soiltype_frac(:) !< fraction of horizontal grid area occupied by given soil category real(kind=dp) :: input_tvxy !< vegetation temperature (K) real(kind=dp) :: input_tgxy !< ground temperature for Noahmp (K) @@ -668,14 +672,16 @@ subroutine scm_state_create(scm_state, n_columns, n_levels, n_soil, n_snow, n_ti end subroutine scm_state_create - subroutine scm_input_create(scm_input, ntimes, nlev, nsoil, nsnow, nice) + subroutine scm_input_create(scm_input, ntimes, nlev, nsoil, nsnow, nice, nvegcat, nsoilcat) class(scm_input_type) :: scm_input - integer, intent(in) :: ntimes, nlev, nsoil, nsnow, nice + integer, intent(in) :: ntimes, nlev, nsoil, nsnow, nice, nvegcat, nsoilcat scm_input%input_nlev = nlev scm_input%input_nsoil = nsoil scm_input%input_nsnow = nsnow scm_input%input_nice = nice + scm_input%input_nvegcat = nvegcat + scm_input%input_nsoilcat = nsoilcat scm_input%input_ntimes = ntimes scm_input%input_lat = real_zero @@ -762,6 +768,10 @@ subroutine scm_input_create(scm_input, ntimes, nlev, nsoil, nsnow, nice) scm_input%input_landfrac = real_zero scm_input%input_lakefrac = real_zero scm_input%input_lakedepth = real_zero + allocate(scm_input%input_vegtype_frac(nvegcat)) + scm_input%input_vegtype_frac = real_zero + allocate(scm_input%input_soiltype_frac(nsoilcat)) + scm_input%input_soiltype_frac = real_zero scm_input%input_tvxy = real_zero scm_input%input_tgxy = real_zero @@ -1085,8 +1095,10 @@ subroutine physics_set(physics, scm_input, scm_state) call conditionally_set_var(scm_input%input_landfrac, physics%Sfcprop%landfrac(i), "landfrac", physics%Model%frac_grid, missing_var(17)) call conditionally_set_var(scm_input%input_lakefrac, physics%Sfcprop%lakefrac(i), "lakefrac", (physics%Model%lkm == 1), missing_var(18)) call conditionally_set_var(scm_input%input_lakedepth, physics%Sfcprop%lakedepth(i), "lakedepth", (physics%Model%lkm == 1), missing_var(19)) + call conditionally_set_var(scm_input%input_vegtype_frac(:), physics%Sfcprop%vegtype_frac(i,:), "vegtype_frac", .true., missing_var(20)) + call conditionally_set_var(scm_input%input_soiltype_frac(:), physics%Sfcprop%soiltype_frac(i,:), "soiltype_frac", .true., missing_var(21)) - n = 19 + n = 21 if ( i==1 .and. ANY( missing_var(1:n) ) ) then write(0,'(a)') "INPUT CHECK: Some missing input data was found related to (potentially non-required) orography and gravity wave drag parameters. This may lead to crashes or other strange behavior." write(0,'(a)') "Check scm_type_defs.F90/physics_set to see the names of variables that are missing, corresponding to the following indices:" From 98d9791a7f195b8cb80ba08de5eeb83340afbc7d Mon Sep 17 00:00:00 2001 From: Grant Firl Date: Thu, 8 Aug 2024 15:54:02 -0400 Subject: [PATCH 13/13] update namelists for HRRR_gf and GFS_v17_p8_ugwpv1 suites --- .../input_GFS_v17_p8_ugwpv1.nml | 40 ++++--- ccpp/physics_namelists/input_HRRR_gf.nml | 105 +++++++----------- 2 files changed, 70 insertions(+), 75 deletions(-) diff --git a/ccpp/physics_namelists/input_GFS_v17_p8_ugwpv1.nml b/ccpp/physics_namelists/input_GFS_v17_p8_ugwpv1.nml index 8d859e580..7076dc341 100644 --- a/ccpp/physics_namelists/input_GFS_v17_p8_ugwpv1.nml +++ b/ccpp/physics_namelists/input_GFS_v17_p8_ugwpv1.nml @@ -10,9 +10,9 @@ imp_physics = 8 iovr = 3 ltaerosol = .false. - lradar = .true. + lradar = .false. ttendlim = -999 - dt_inner = 150 + dt_inner = 720 sedi_semi = .true. decfl = 10 oz_phys = .false. @@ -32,16 +32,18 @@ do_ugwp_v0_orog_only = .false. do_ugwp_v0_nst_only = .false. do_gsl_drag_ls_bl = .true. - do_gsl_drag_ss = .true. + do_gsl_drag_ss = .false. + do_gwd_opt_psl = .true. + psl_gwd_dx_factor = 6.0 do_gsl_drag_tofd = .true. do_ugwp_v1_orog_only = .false. min_lakeice = 0.15 - min_seaice = 1.0e-6 - use_cice_alb = .true. + min_seaice = 0.15 + use_cice_alb = .false. pdfcld = .false. - fhswr = 1200. - fhlwr = 1200. - progsigma = .true. + fhswr = 3600. + fhlwr = 3600. + progsigma = .false. betascu = 8.0 betamcu = 1.0 betadcu = 2.0 @@ -63,7 +65,7 @@ hybedmf = .false. satmedmf = .true. isatmedmf = 1 - lheatstrg = .true. + lheatstrg = .false. lseaspray = .true. random_clds = .false. trans_trac = .true. @@ -71,7 +73,7 @@ imfshalcnv = 2 imfdeepcnv = 2 ras = .false. - cdmbgwd = 2.5,7.5,1.0,1.0 + cdmbgwd = 20.0,2.5,1.0,1.0 prslrd0 = 0. ivegsrc = 1 isot = 1 @@ -83,6 +85,7 @@ iopt_run = 1 iopt_sfc = 3 iopt_trs = 2 + iopt_diag = 2 iopt_frz = 1 iopt_inf = 1 iopt_rad = 3 @@ -91,7 +94,7 @@ iopt_tbot = 2 iopt_stc = 3 debug = .false. - nstf_name = 2,0,0,0,0 + nstf_name = 2,1,0,0,0 nst_anl = .true. psautco = 0.0008,0.0005 prautco = 0.00015,0.00015 @@ -101,9 +104,15 @@ do_sppt = .false. do_shum = .false. do_skeb = .false. + iaufhrs = -1 + iau_delthrs = 0 + iau_inc_files= '' + iau_drymassfixer = .false. + use_med_flux = .false. do_RRTMGP = .false. doGP_cldoptics_LUT = .true. doGP_lwscat = .true. + doGP_sgs_cnv = .true. active_gases = 'h2o_co2_o3_n2o_ch4_o2' ngases = 6 rrtmgp_root = '../../ccpp/physics/physics/rte-rrtmgp/' @@ -121,7 +130,9 @@ cplice = .false. cplwav = .false. cplwav2atm = .false. - do_ca = .false. + cpllnd = .false. + cpllnd2atm = .false. + do_ca = .true. ca_global = .false. ca_sgs = .true. nca = 1 @@ -132,7 +143,10 @@ nthresh = 18 ca_trigger = .true. nspinup = 1 - iseed_ca = 1448371824 + iseed_ca = 12345 + lndp_type = 0 + n_var_lndp = 0 + fscav_aero = "*:0.3","so2:0.0","msa:0.0","dms:0.0","nh3:0.4","nh4:0.6","bc1:0.6","bc2:0.6","oc1:0.4","oc2:0.4","dust1:0.6","dust2:0.6","dust3:0.6","dust4:0.6","dust5:0.6","seas1:0.5","seas2:0.5","seas3:0.5","seas4:0.5","seas5:0.5" / &cires_ugwp_nml diff --git a/ccpp/physics_namelists/input_HRRR_gf.nml b/ccpp/physics_namelists/input_HRRR_gf.nml index 60de83a4e..3dd5d01cb 100644 --- a/ccpp/physics_namelists/input_HRRR_gf.nml +++ b/ccpp/physics_namelists/input_HRRR_gf.nml @@ -1,19 +1,11 @@ &gfs_physics_nml - addsmoke_flag = 1 - aero_dir_fdb = .true. - aero_ind_fdb = .false. bl_mynn_edmf = 1 bl_mynn_edmf_mom = 1 bl_mynn_tkeadvect = .true. cal_pre = .false. - cdmbgwd = 3.5, 1.0 - clm_debug_print = .false. - clm_lake_debug = .false. - cnvcld = .false. - cnvgwd = .false. - coarsepm_settling = 1 - cplflx = .false. - diag_log = .true. + cdmbgwd = 0.14,1.8,1.0,1.0 + cnvcld = .true. + cnvgwd = .true. debug = .false. do_deep = .true. do_gsl_drag_ls_bl = .true. @@ -21,61 +13,47 @@ do_gsl_drag_tofd = .true. do_mynnedmf = .true. do_mynnsfclay = .true. - do_plumerise = .true. - do_smoke_transport = .true. do_tofd = .false. do_ugwp = .false. do_ugwp_v0 = .false. - do_ugwp_v0_nst_only = .false. do_ugwp_v0_orog_only = .false. - drydep_opt = 1 dspheat = .true. - dt_inner = 36 - dust_alpha = 10.0 - dust_drylimit_factor = 0.5 - dust_gamma = 1.3 - dust_moist_correction = 2.0 - dust_opt = 1 - ebb_dcycle = 2 + dt_inner = 60 effr_in = .true. - enh_mix = .false. fhcyc = 0 - fhlwr = 900.0 - fhswr = 900.0 + fhlwr = 3600.0 + fhswr = 3600.0 fhzero = 1.0 frac_ice = .true. gwd_opt = 3 h2o_phys = .true. hybedmf = .false. - iaer = 1011 + iaer = 5111 ialb = 2 - iau_delthrs = 6 - iau_inc_files = '' - iaufhrs = 30 - iccn = 2 - icliq_sw = 2 + icliq_sw = 1 icloud_bl = 1 ico2 = 2 iems = 2 imfdeepcnv = 3 - imfshalcnv = -1 + imfshalcnv = 3 imp_physics = 8 - iopt_alb = 2 + iopt_alb = 1 iopt_btr = 1 - iopt_crs = 1 - iopt_dveg = 2 + iopt_crs = 2 + iopt_dveg = 4 iopt_frz = 1 iopt_inf = 1 iopt_lake = 2 - iopt_rad = 1 + iopt_rad = 3 iopt_run = 1 - iopt_sfc = 1 + iopt_sfc = 4 iopt_snf = 4 - iopt_stc = 1 + iopt_stc = 3 iopt_tbot = 2 - iovr = 3 - isncond_opt = 2 - isncovr_opt = 3 + iopt_trs = 2 + iopt_diag = 2 + iovr = 1 + icloud = 0 isol = 2 isot = 1 isubc_lw = 2 @@ -84,49 +62,52 @@ kice = 9 ldiag3d = .true. ldiag_ugwp = .false. - lgfdlmprad = .false. + lgfdlmprad = .true. lheatstrg = .false. - lightning_threat = .true. lkm = 1 lradar = .true. - lrefres = .true. lsm = 3 - lsoil = 9 + lsoil = 4 lsoil_lsm = 9 ltaerosol = .true. lwhtr = .true. - min_lakeice = 0.15 - min_seaice = 0.15 - mix_chem = .true. - mosaic_lu = 1 - mosaic_soil = 1 - nsfullradar_diag = 3600 oz_phys = .false. oz_phys_2015 = .true. pdfcld = .false. - plume_wind_eff = 1 - plumerisefire_frq = 60 pre_rad = .false. print_diff_pgr = .true. prslrd0 = 0.0 qdiag3d = .true. random_clds = .false. redrag = .true. - rrfs_sd = .true. - rrfs_smoke_debug = .false. satmedmf = .false. - seas_opt = 0 sfclay_compute_flux = .true. - shal_cnv = .false. - smoke_conv_wet_coef = 0.5, 0.5, 0.5 - smoke_forecast = 1 + shal_cnv = .true. swhtr = .true. - thsfc_loc = .false. trans_trac = .true. ttendlim = -999 use_ufo = .true. - wetdep_ls_alpha = 0.5 - wetdep_ls_opt = 1 + progsigma = .false. + betascu = 8.0 + betamcu = 1.0 + betadcu = 2.0 + sedi_semi = .true. + decfl = 10 + nssl_cccn = 0.6e9 + nssl_alphah = 0.0 + nssl_alphahl = 1.0 + nssl_hail_on = .false. + nssl_ccn_on = .true. + nssl_invertccn = .true. + lseaspray = .false. + isatmedmf = 1 + nstf_name = 2,0,0,0,0 + nst_anl = .true. + psautco = 0.0008,0.0005 + prautco = 0.00015,0.00015 + lndp_type = 0 + n_var_lndp = 0 + fscav_aero = "*:0.3","so2:0.0","msa:0.0","dms:0.0","nh3:0.4","nh4:0.6","bc1:0.6","bc2:0.6","oc1:0.4","oc2:0.4","dust1:0.6","dust2:0.6","dust3:0.6","dust4:0.6","dust5:0.6","seas1:0.5","seas2:0.5","seas3:0.5","seas4:0.5","seas5:0.5" / &cires_ugwp_nml