diff --git a/NMOa0.08/expt_01.1/blkdat.input b/NMOa0.08/expt_01.1/blkdat.input index 3f11397a..fafbe141 100644 --- a/NMOa0.08/expt_01.1/blkdat.input +++ b/NMOa0.08/expt_01.1/blkdat.input @@ -127,7 +127,7 @@ S-Z(15-11): dp00/f/x/i=3m/1.125/12m/1m; ds=1m/1.125/4m; src_2.2.12; 6.0 'thkriv' = nominal thickness of river inflow (m) 10.0 'thkcdw' = thickness for near-surface currents in ice-ocean stress (m) 20.0 'thkfrz' = maximum thickness of near-surface freezing zone (m) - 0 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf) + 0 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf,3=nextsim) 0.0 'tfrz_0' = ENLN: ice melting point (degC) at S=0psu -0.054 'tfrz_s' = ENLN: gradient of ice melting point (degC/psu) 0.25 'frzifq' = e-folding time scale back to tfrz (days or -ve time steps) diff --git a/TP0a1.00/expt_01.0/blkdat.input b/TP0a1.00/expt_01.0/blkdat.input index 0535d20f..05045cba 100644 --- a/TP0a1.00/expt_01.0/blkdat.input +++ b/TP0a1.00/expt_01.0/blkdat.input @@ -105,7 +105,7 @@ S-Z(15-11): dp00/f/x/i=3m/1.125/12m/1m; ds=1m/1.125/4m; src_2.2.12; 6.0 'thkriv' = nominal thickness of river inflow (m) 3.0 'thkcdw' = thickness for near-surface currents in ice-ocean stress (m) 20.0 'thkfrz' = maximum thickness of near-surface freezing zone (m) - 2 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf) + 2 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf,3=nextsim) 0.0 'tfrz_0' = ENLN: ice melting point (degC) at S=0psu -0.054 'tfrz_s' = ENLN: gradient of ice melting point (degC/psu) 0.25 'frzifq' = e-folding time scale back to tfrz (days or -ve time steps) diff --git a/TP0a1.00/expt_01.1/blkdat.input b/TP0a1.00/expt_01.1/blkdat.input index 7d8e6ebc..dcb1cfcb 100644 --- a/TP0a1.00/expt_01.1/blkdat.input +++ b/TP0a1.00/expt_01.1/blkdat.input @@ -105,7 +105,7 @@ S-Z(15-11): dp00/f/x/i=3m/1.125/12m/1m; ds=1m/1.125/4m; src_2.2.12; 6.0 'thkriv' = nominal thickness of river inflow (m) 3.0 'thkcdw' = thickness for near-surface currents in ice-ocean stress (m) 20.0 'thkfrz' = maximum thickness of near-surface freezing zone (m) - 0 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf) + 0 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf,3=nextsim) 0.0 'tfrz_0' = ENLN: ice melting point (degC) at S=0psu -0.054 'tfrz_s' = ENLN: gradient of ice melting point (degC/psu) 0.25 'frzifq' = e-folding time scale back to tfrz (days or -ve time steps) @@ -191,7 +191,6 @@ S-Z(15-11): dp00/f/x/i=3m/1.125/12m/1m; ds=1m/1.125/4m; src_2.2.12; 1 'relax ' = activate lateral boundary nudging (0=F,1=T) 1 'trcrlx' = activate lat. bound. tracer nudging (0=F,1=T) 1 'priver' = rivers as a precipitation bogas (0=F,1=T) - 0 'triver' = total river including Greenland (0=F,1=T) 0 'epmass' = treat evap-precip as a mass exchange (0=F,1=T) 0 'nmrsti' = 'restart' Restart filename. Dot and date appended. Empty: use old hycom name. 0 'nmrsto' = 'restart' Restart filename. Dot and date appended. Empty: use old hycom name. diff --git a/TP0a1.00/expt_01.1/pbsscript_chpc.sh b/TP0a1.00/expt_01.1/pbsscript_chpc.sh new file mode 100755 index 00000000..59fcaf12 --- /dev/null +++ b/TP0a1.00/expt_01.1/pbsscript_chpc.sh @@ -0,0 +1,77 @@ +#!/bin/bash -l + +#PBS -P ERTH0904 +#PBS -N AGUa010 + +#PBS -l select=1:ncpus=4:mpiprocs=4 + +## System message output file +#PBS -o log/HYCOM-CICE.out + +## System error message file +#PBS -e log/HYCOM-CICE.err + +## How long job takes, wallclock time hh:mm:ss +#PBS -l walltime=0:30:00 +#PBS -q test + +##PBS -m abe +##PBS -M + +module load chpc/python/3.7.0 +module load chpc/parallel_studio_xe/64/16.0.1/2016.1.150 +module load chpc/compmech/fftw/3.3.10_intel2020u1 +module load chpc/earth/netcdf/4.7.4/intel2020u1 +module load chpc/compmech/netlib-lapack/3.10.1 +module load chpc/earth/udunits2/udunits-2.2.28 + +export NMPI=$PBS_NP + +# Enter directory from where the job was submitted +cd $PBS_O_WORKDIR || { echo "Could not go to dir $PBS_O_WORKDIR "; exit 1; } + +# ------------------- Fetch Environment ------------------------------ +# -------- these are needed in preprocess scripts--------------------- +echo "PBS_JOBID = $PBS_JOBID " +echo "PBS_O_WORKDIR= $PBS_O_WORKDIR " +[ -z "$NOMP" ] && NOMP=0 + +# Enter directory from where the job was submitted +cd $PBS_O_WORKDIR || { echo "Could not go to dir $PBS_O_WORKDIR "; exit 1; } + + +# Initialize environment (sets Scratch dir ($S), Data dir $D ++ ) +source ../REGION.src || { echo "Could not source ../REGION.src "; exit 1; } +source ./EXPT.src || { echo "Could not source EXPT.src"; exit 1; } +echo "NMPI =$NMPI (Number of MPI tasks needed for running job) " + + START="2020-09-15T12:00:00" + END="2020-09-19T12:00:00" + INITFLG="--init" +# INITFLG="" +# ./bin/atmo_synoptic.sh era5+lw $START $END +# ./bin/expt_preprocess.sh $START $END $INITFLG + + echo "Start time in srjob.sh: $START" + echo "End time in srjob.sh: $END" + + # Generate atmospheric forcing : +# atmo_synoptic.sh era5+lw $START $END + + # Transfer data files to scratch - must be in "expt_XXX" dir for this script + expt_preprocess.sh $START $END $INITFLG || { echo "Preprocess had fatal errors "; exit 1; } + + # Enter Scratch/run dir and Run model + cd $S || { echo "Could not go to dir $S "; exit 1; } + mpirun -np $NMPI ./hycom_alone + + # Cleanup and move data files to data directory - must be in "expt_XXX" dir for this script + cd $P || { echo "Could not go to dir $P "; exit 1; } + expt_postprocess.sh + +done + +exit $? + + + diff --git a/TP2a0.10/expt_01.0/blkdat.input b/TP2a0.10/expt_01.0/blkdat.input index 995bec95..c5a16273 100644 --- a/TP2a0.10/expt_01.0/blkdat.input +++ b/TP2a0.10/expt_01.0/blkdat.input @@ -127,7 +127,7 @@ S-Z(15-11): dp00/f/x/i=3m/1.125/12m/1m; ds=1m/1.125/4m; src_2.2.12; 6.0 'thkriv' = nominal thickness of river inflow (m) 3.0 'thkcdw' = thickness for near-surface currents in ice-ocean stress (m) 20.0 'thkfrz' = maximum thickness of near-surface freezing zone (m) - 2 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf) + 2 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf,3=nextsim) 0.0 'tfrz_0' = ENLN: ice melting point (degC) at S=0psu -0.054 'tfrz_s' = ENLN: gradient of ice melting point (degC/psu) 0.25 'frzifq' = e-folding time scale back to tfrz (days or -ve time steps) @@ -213,7 +213,6 @@ S-Z(15-11): dp00/f/x/i=3m/1.125/12m/1m; ds=1m/1.125/4m; src_2.2.12; 1 'relax ' = activate lateral boundary nudging (0=F,1=T) 0 'trcrlx' = activate lat. bound. tracer nudging (0=F,1=T) 1 'priver' = rivers as a precipitation bogas (0=F,1=T) - 0 'triver' = total river including Greenland (0=F,1=T) 0 'epmass' = treat evap-precip as a mass exchange (0=F,1=T) 0 'nmrsti' = 'restart' Restart filename. Dot and date appended. Empty: use old hycom name. 0 'nmrsto' = 'restart' Restart filename. Dot and date appended. Empty: use old hycom name. diff --git a/TP5a0.06/expt_01.0/blkdat.input b/TP5a0.06/expt_01.0/blkdat.input index ba837475..2c42bd1e 100644 --- a/TP5a0.06/expt_01.0/blkdat.input +++ b/TP5a0.06/expt_01.0/blkdat.input @@ -127,7 +127,7 @@ S-Z(15-11): dp00/f/x/i=3m/1.125/12m/1m; ds=1m/1.125/4m; src_2.2.12; 6.0 'thkriv' = nominal thickness of river inflow (m) 10.0 'thkcdw' = thickness for near-surface currents in ice-ocean stress (m) 20.0 'thkfrz' = maximum thickness of near-surface freezing zone (m) - 2 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf) + 2 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf,3=nextsim) 0.0 'tfrz_0' = ENLN: ice melting point (degC) at S=0psu -0.054 'tfrz_s' = ENLN: gradient of ice melting point (degC/psu) 0.25 'frzifq' = e-folding time scale back to tfrz (days or -ve time steps) @@ -213,7 +213,6 @@ S-Z(15-11): dp00/f/x/i=3m/1.125/12m/1m; ds=1m/1.125/4m; src_2.2.12; 1 'relax ' = activate lateral boundary nudging (0=F,1=T) 0 'trcrlx' = activate lat. bound. tracer nudging (0=F,1=T) 0 'priver' = rivers as a precipitation bogas (0=F,1=T) - 0 'triver' = total river including Greenland (0=F,1=T) 0 'epmass' = treat evap-precip as a mass exchange (0=F,1=T) 1 'nmrsti' = 'TP5restart' Restart filename. Dot and date appended. Empty: use old hycom name. 1 'nmrsto' = 'TP5restart' Restart filename. Dot and date appended. Empty: use old hycom name. diff --git a/TP5a0.06/expt_01.1/blkdat.input b/TP5a0.06/expt_01.1/blkdat.input index 302e0077..1d800a01 100755 --- a/TP5a0.06/expt_01.1/blkdat.input +++ b/TP5a0.06/expt_01.1/blkdat.input @@ -127,7 +127,7 @@ S-Z(15-11): dp00/f/x/i=3m/1.125/12m/1m; ds=1m/1.125/4m; src_2.2.12; 6.0 'thkriv' = nominal thickness of river inflow (m) 3.0 'thkcdw' = thickness for near-surface currents in ice-ocean stress (m) 20.0 'thkfrz' = maximum thickness of near-surface freezing zone (m) - 2 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf) + 2 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf,3=nextsim) 0.0 'tfrz_0' = ENLN: ice melting point (degC) at S=0psu -0.054 'tfrz_s' = ENLN: gradient of ice melting point (degC/psu) 0.25 'frzifq' = e-folding time scale back to tfrz (days or -ve time steps) diff --git a/bin/atmo_synoptic.sh b/bin/atmo_synoptic.sh index cfbe9730..8bae2e65 100755 --- a/bin/atmo_synoptic.sh +++ b/bin/atmo_synoptic.sh @@ -48,6 +48,12 @@ if [ ${forcing:0:4} == "erai" ] ; then if [[ -n $ERAI_PATH ]] ; then ROOTPATH=$ERAI_PATH fi +elif [ ${forcing:0:9} == "era5_chpc" ] ; then + xmlfile=$INPUTDIR/era5_chpc.xml + # if ERA5_PATH is set, it will override rootPath in xml file + if [[ -n $ERA5_PATH ]] ; then + ROOTPATH=$ERA5_PATH + fi elif [ ${forcing:0:4} == "era5" ] ; then xmlfile=$INPUTDIR/era5.xml # if ERA5_PATH is set, it will override rootPath in xml file diff --git a/bin/common_functions.sh b/bin/common_functions.sh index 64f5f9c7..0ffac147 100644 --- a/bin/common_functions.sh +++ b/bin/common_functions.sh @@ -293,6 +293,7 @@ tellerror () { echo "[FATAL ] $1" let numerr=$numerr+1; #echo "[FATAL ] $1" >> $logfile + FATALERROR=$FATALERROR:$1 } tellwarn () { diff --git a/bin/compile_model.sh b/bin/compile_model.sh index 055dbff1..30291b9f 100755 --- a/bin/compile_model.sh +++ b/bin/compile_model.sh @@ -142,6 +142,9 @@ elif [ "${hostnamed:0:5}" == "betzy" ] ; then elif [ "${hostnamed:0:4}" == "fram" ] ; then # fram SITE="fram" MACROID=$ARCH.$SITE.$compiler +elif [ "${hostnamed:0:4}" == "cm.c" ] ; then # fram + SITE="chpc" + MACROID=$ARCH.$SITE.$compiler # Generic case. SITE is empty elif [[ "${ARCH}" == "Linux" ]] ; then SITE="" @@ -195,11 +198,14 @@ elif [ "$SITE" == "surfsara" ] ; then export ESMF_MOD_DIR=${ESMF_DIR}mod/ export ESMF_LIB_DIR=${ESMF_DIR}lib/ +elif [[ "${unames:0:5}" == "Linux" ]] && [[ "$SITE" == "chpc" ]] ; then + export ESMF_DIR=#${EBROOTESMF}/ + export ESMF_MOD_DIR=#${ESMF_DIR}mod/ + export ESMF_LIB_DIR=#${ESMF_DIR}lib/ elif [[ "${unames:0:5}" == "Linux" ]] && [[ "$SITE" == "fram" ]] ; then export ESMF_DIR=${EBROOTESMF}/ export ESMF_MOD_DIR=${ESMF_DIR}mod/ export ESMF_LIB_DIR=${ESMF_DIR}lib/ - # If site is not given, try to use a generic setup. Macro names composed of compiler name and mpi lib name (openmpi, mpich, lam, etc etc( elif [[ "${unames:0:5}" == "Linux" ]] && [[ "$SITE" == "" ]] ; then if [ -z "${ESMF_DIR}" ] ; then @@ -345,12 +351,25 @@ if [ $ICEFLG -ne 0 ] ; then echo "Error when compiling HYCOM, see above " exit $res fi -else - echo "Now compiling hycom in $targetdir." +elif [ $ICEFLG -eq 3 ] ; then + echo "Now compiling hycom with oasis in $targetdir." export ICEFLG=${ICEFLG} export ARCH=${MACROID} echo $ARCH + csh Make_hycom.csh ${MACROID} ${ICEFLG} + res=$? + if [ $res -ne 0 ] ; then + echo + echo "Error when compiling HYCOM, see above " + exit $res + fi +else + echo "Now compiling hycom alone in $targetdir." + export ICEFLG=${ICEFLG} + export ARCH=${MACROID} + echo $ARCH + csh Make_hycom.csh ${MACROID} ${ICEFLG} res=$? if [ $res -ne 0 ] ; then diff --git a/bin/create_ref_case.sh b/bin/create_ref_case.sh old mode 100644 new mode 100755 index 743e08c6..3cd8ac8f --- a/bin/create_ref_case.sh +++ b/bin/create_ref_case.sh @@ -13,8 +13,9 @@ else echo "Could not find EXPT.src. This script must be run in expt dir" exit 1 fi + EDIR=$(pwd)/ # Location of this script -BASEDIR=$(cd $(dirname $0)/.. && pwd)/ # Location of basedir +BASEDIR=$(cd .. && pwd)/ # Location of basedir source $BASEDIR/REGION.src source $EDIR/EXPT.src @@ -113,7 +114,7 @@ res=$? [ $res -ne 0 ] && echo "Failure..." echo ".." -iceclim=1 +iceclim=0 # Create a climatology ice cover used by initialization cd $EDIR echo "Prepare the sea ice cover from climatology:" @@ -140,14 +141,17 @@ fi # Create simple river forcing cd $EDIR echo "river forcing, if biology active, may take some time" -if [ $NTRACR -ne 0 ] ; then - river_nersc.sh 100 300 $INPUTDIR/rivers_ahype-ehype_clim_rev2.dat $INPUTDIR/biorivers.dat > $EDIR/log/ref_river_nersc.out 2>&1 - riverfolder=$(echo $X | cut -c1-2)$(echo $X | cut -c4) - python $BINDIR/spread_Ob_river_nutrients.py $BASEDIR/force/rivers/${riverfolder}/ > $EDIR/log/spread_river.out 2>&1  # Spreads Ob River nutrients to outer bay - python $BINDIR/add_atmdep_to_river.py $BASEDIR/force/rivers/${riverfolder}/ $INPUTDIR/emep_2010_annual_1degree_rv4_17gfecl1p0.nc > $EDIR/log/add_atmospheric_deposition.out 2>&1 -else - river_nersc.sh 100 300 $INPUTDIR/rivers_ahype-ehype_clim_rev2.dat > $EDIR/log/ref_river_nersc.out 2>&1 -fi +./bin/river_trip.sh -t 300 -n 150 era5 > $EDIR/log/ref_river_trip.out 2>&1 +cp ${BASEDIR}/force/rivers/$E/forcing.rivers.a ${BASEDIR}/force/rivers/$E/rivers.a +cp ${BASEDIR}/force/rivers/$E/forcing.rivers.b ${BASEDIR}/force/rivers/$E/rivers.b +#if [ $NTRACR -ne 0 ] ; then +# river_nersc.sh 100 300 $INPUTDIR/rivers_ahype-ehype_clim_rev2.dat $INPUTDIR/biorivers.dat > $EDIR/log/ref_river_nersc.out 2>&1 +# riverfolder=$(echo $X | cut -c1-2)$(echo $X | cut -c4) +# python $BINDIR/spread_Ob_river_nutrients.py $BASEDIR/force/rivers/${riverfolder}/ > $EDIR/log/spread_river.out 2>&1  # Spreads Ob River nutrients to outer bay +# python $BINDIR/add_atmdep_to_river.py $BASEDIR/force/rivers/${riverfolder}/ $INPUTDIR/emep_2010_annual_1degree_rv4_17gfecl1p0.nc > $EDIR/log/add_atmospheric_deposition.out 2>&1 +#else +# river_nersc.sh 100 300 $INPUTDIR/rivers_ahype-ehype_clim_rev2.dat > $EDIR/log/ref_river_nersc.out 2>&1 +#fi res=$? [ $res -eq 0 ] && echo "Success" diff --git a/bin/expt_preprocess.sh b/bin/expt_preprocess.sh index cb177d73..51d1aca6 100755 --- a/bin/expt_preprocess.sh +++ b/bin/expt_preprocess.sh @@ -240,7 +240,7 @@ echo "tstop is $tstop" echo "--------------------" # Check that start time is in September when starting from climatology -if [ "$initstr" == "--init" ] ;then +if [ "$initstr" == "--init" && $ICEFLG != 0] ;then if [ "$start_month" != "09" ]; then tellerror "We recommend starting the model in September when starting from \ climatology. You can override September initilization by commenting out \ @@ -289,8 +289,9 @@ ${pget} $BASEDIR/topo/regional.grid.b regional.grid.b || tellerror "no grid file ${pget} $BASEDIR/topo/depth_${R}_${T}.a regional.depth.a || tellerror "no topo file depth_${R}_${T}.a" ${pget} $BASEDIR/topo/depth_${R}_${T}.b regional.depth.b || tellerror "no topo file depth_${R}_${T}.b" ${pget} $BASEDIR/topo/kmt_${R}_${T}.nc cice_kmt.nc || tellerror "no kmt file $BASEDIR/topo/kmt_${R}_${T}.nc " -${pget} $BASEDIR/topo/cice_grid.nc cice_grid.nc || tellerror "no cice grid file $BASEDIR/topo/cice_grid.nc " - +if [ $ICEFLG != 0 ] ; then + ${pget} $BASEDIR/topo/cice_grid.nc cice_grid.nc || tellerror "no cice grid file $BASEDIR/topo/cice_grid.nc " +fi if [ "$SSTRLX" -eq 3 ] ; then [ -f $CLMDIR/seatmp.a ] || tellerror "File $CLMDIR/seatmp.a does not exist" @@ -714,9 +715,12 @@ compdir=$P/build/${compdir} if [ $ICEFLG -eq 2 ] ; then echo "Retrieving hycom_cice from $compdir" /bin/cp $compdir/hycom_cice . || tellerror "Could not get hycom_cice executable at " -elif [ $ICEFLG -eq 0 ] ; then +elif [ $ICEFLG -eq 3 ] ; then echo "Retrieving hycom_oasis from $compdir" /bin/cp $compdir/hycom_oasis . || tellerror "Could not get hycom_oasis executable at " +elif [ $ICEFLG -eq 0 ] ; then + echo "Retrieving hycom_alone from $compdir" + /bin/cp $compdir/hycom_alone . || tellerror "Could not get hycom_alone executable at " fi @@ -786,7 +790,9 @@ fi if [ $numerr -eq 0 ] ; then echo "No fatal errors. Ok to start model set up in $S" else - echo "Some fatal errors occured. See above" + echo "Some fatal errors occured. The error message is: " + echo $FATALERROR + echo "For more details see above." fi # Tell where stuff ended up diff --git a/bin/make_grid_nemoreg2hycom.py b/bin/make_grid_nemoreg2hycom.py new file mode 100644 index 00000000..3fbe7db9 --- /dev/null +++ b/bin/make_grid_nemoreg2hycom.py @@ -0,0 +1,206 @@ +#!/usr/bin/env python +import modeltools.nemo +import argparse +import modeltools.forcing.bathy +import abfile +import netCDF4 +import shutil +import numpy.matlib as matlib +import numpy as np +import numpy.ma as ma +import geopy.distance as gpd + + +# Code reads mesh filename and then generate both regional and bathy [ab] files. +# Note that information about native grid netcdffiles (their paths ,etc) can be found in REGION.src +# I have used hard-coded grid size which you need to change in the case using different subdomains. +# +# Usage: +# +# ../bin/make_grid_nemoreg2hycom.py /cluster/work/users/annettes/TestDownload/Grid/GLO-MFC_001_030_mask_bathy_sub.nc +# +# Mostafa Bakhoday-Paskyabi, 16 May 2019. +# History: +# Annette Samuelsen: modified from NEMO native to NEMO regular , March, 2022 +# +# + +def make_grid(meshfile): + + ncid0=netCDF4.Dataset(meshfile[:-17]+"coordinates_sub.nc","r") + np.seterr(invalid='ignore') + e3t=ncid0.variables["e3t"][:] #AS: Is not spatially dependent. + ncid0.close() + lev_bnds=np.cumsum(e3t) + + # Now acquire the data. P-cell data + ncid0=netCDF4.Dataset(meshfile,"r") + plon1d=ncid0.variables["longitude"][:] + tmp=np.diff(plon1d) + tmp=np.append(tmp,tmp[len(tmp)-1]) + ulon1d=plon1d-tmp + vlon1d=plon1d + qlon1d=plon1d-tmp + + plat1d=ncid0.variables["latitude"][:] + tmp=np.diff(plat1d) + tmp=np.append(tmp,tmp[len(tmp)-1]) + ulat1d=plat1d + vlat1d=plat1d-tmp + qlat1d=plat1d-tmp + + plon=matlib.repmat(plon1d,len(plat1d),1) + plat=np.transpose(matlib.repmat(plat1d,len(plon1d),1)) + + hdepw=ncid0.variables["deptho"][:,:] + hdepw=ma.masked_where(np.isnan(hdepw),hdepw) + mbathy=ncid0.variables["deptho"][:,:] + mbathy=ma.masked_where(np.isnan(mbathy),mbathy) +# tmp=hdepw[:,0] +# print(np.shape(tmp),tmp.mask) + + jdm,idm=np.shape(hdepw) + + ncid0.close() + +#C-grid +#--Q--V--Q-- +# | | | +#--U--P--U-- +# | | | +#--Q--V--Q-- +# | | | + + # Compute the grid length: + scpx=np.zeros((jdm,idm)) + scpy=np.zeros((jdm,idm)) + for i in range(idm-1): + for j in range(jdm-1): + scpx[j,i]=gpd.geodesic((plat[j,i],plon[j,i]),(plat[j,i+1],plon[j,i+1])).m + scpy[j,i]=gpd.geodesic((plat[j,i],plon[j,i]),(plat[j+1,i],plon[j+1,i])).m + scpx[:,idm-1]=scpx[:,idm-2] + scpy[:,idm-1]=scpy[:,idm-2] + scpx[jdm-1,:]=scpx[jdm-2,:] + scpy[jdm-1,:]=scpy[jdm-2,:] + + # U-cell data. + ulon=matlib.repmat(ulon1d,len(ulat1d),1) + ulat=np.transpose(matlib.repmat(ulat1d,len(ulon1d),1)) + + print("PLON",plon[0,0:2],ulon[0,0:2]) + print("PLAT",plat[0,0:2],ulat[0,0:2]) + + # Compute the grid length: + scux=np.zeros((jdm,idm)) + scuy=np.zeros((jdm,idm)) + for i in range(idm-1): + for j in range(jdm-1): + scux[j,i]=gpd.geodesic((ulat[j,i],ulon[j,i]),(ulat[j,i+1],ulon[j,i+1])).m + scuy[j,i]=gpd.geodesic((ulat[j,i],ulon[j,i]),(ulat[j+1,i],ulon[j+1,i])).m + scux[:,idm-1]=scpx[:,idm-2] + scuy[:,idm-1]=scpy[:,idm-2] + scux[jdm-1,:]=scpx[jdm-2,:] + scuy[jdm-1,:]=scpy[jdm-2,:] + + + # V-cell data. + # TODO: Proper extrapolation of data on grid edges (mainly bottom row) + vlon=matlib.repmat(vlon1d,len(vlat1d),1) + vlat=np.transpose(matlib.repmat(vlat1d,len(vlon1d),1)) + + # Compute the grid length: + scvx=np.zeros((jdm,idm)) + scvy=np.zeros((jdm,idm)) + for i in range(idm-1): + for j in range(jdm-1): + scvx[j,i]=gpd.geodesic((vlat[j,i],vlon[j,i]),(vlat[j,i+1],vlon[j,i+1])).m + scvy[j,i]=gpd.geodesic((vlat[j,i],vlon[j,i]),(vlat[j+1,i],vlon[j+1,i])).m + scvx[:,idm-1]=scpx[:,idm-2] + scvy[:,idm-1]=scpy[:,idm-2] + scvx[jdm-1,:]=scpx[jdm-2,:] + scvy[jdm-1,:]=scpy[jdm-2,:] + + # Q-cell data + # TODO: Proper extrapolation of data on grid edges (mainly bottom row) + qlon=matlib.repmat(qlon1d,len(qlat1d),1) + qlat=np.transpose(matlib.repmat(qlat1d,len(qlon1d),1)) + + # Compute the grid length: + scqx=np.zeros((jdm,idm)) + scqy=np.zeros((jdm,idm)) + for i in range(idm-1): + for j in range(jdm-1): + scqx[j,i]=gpd.geodesic((qlat[j,i],qlon[j,i]),(qlat[j,i+1],qlon[j,i+1])).m + scqy[j,i]=gpd.geodesic((qlat[j,i],qlon[j,i]),(qlat[j+1,i],qlon[j+1,i])).m + scqx[:,idm-1]=scpx[:,idm-2] + scqy[:,idm-1]=scpy[:,idm-2] + scqx[jdm-1,:]=scpx[jdm-2,:] + scqy[jdm-1,:]=scpy[jdm-2,:] + + print("MINX",np.min(scqx),"MAXX",np.max(scqx)) + print("MINY",np.min(scqy),"MAXY",np.max(scqy)) + + # Angle used for rotation +# ulon_rgt = np.copy(ulon) +# ulat_rgt = np.copy(ulat) +# ulon_lft = np.roll(ulon,1,axis=1) +# ulat_lft = np.roll(ulat,1,axis=1) + pang = modeltools.tools.p_azimuth(ulon,ulat,plon,plat) + + # Aspect ratio + asp = np.where(scpy==0.,99.0,scpx/scpy) + + # Coriolis + corio = np.sin(np.radians(qlat)) * 4. * np.pi / 86164.0 # Sidereal day + + # Put inside datadict for abfile writing + ddict={} + ddict["plon"]=plon + ddict["plat"]=plat + ddict["ulon"]=ulon + ddict["ulat"]=ulat + ddict["vlon"]=vlon + ddict["vlat"]=vlat + ddict["qlon"]=qlon + ddict["qlat"]=qlat + # + ddict["scpx"]=scpx + ddict["scpy"]=scpy + ddict["scux"]=scux + ddict["scuy"]=scuy + ddict["scvx"]=scvx + ddict["scvy"]=scvy + ddict["scqx"]=scqx + ddict["scqy"]=scqy + # + ddict["cori"]=corio + ddict["pang"] =pang + ddict["pasp"] =asp + abfile.write_regional_grid(ddict) + + # Bathymetry + tmp2 = np.where( mbathy>0. ,hdepw,0.) + tmp2 = np.where( mbathy>1.0e19,0.0 ,tmp2) + abfile.write_bathymetry("bathy",1,tmp2,0.) +# hdepw=np.where(np.isnan(hdepw),-1.0,hdepw) +# abfile.write_bathymetry("bathy",1,hdepw,0.) + + shutil.move("depth_bathy_01.a",'./dummped_depth_NMOc0.00_01.a') + shutil.move("depth_bathy_01.b",'./dummped_depth_NMOc0.00_01.b') + shutil.move("regional.grid.a","./dummped_regional.grid.a") + shutil.move("regional.grid.b","./dummped_regional.grid.b") + +if __name__ == "__main__" : + + parser = argparse.ArgumentParser( + description='This tool will convert NORESM netcdf files to hycom archive files. It will also create grid and topo files for hycom.' + ) + parser.add_argument('meshfile', type=str,help="NEMO mesh file in netcdf format") + parser.add_argument('--idm', type=int,default=360, help=" ") + parser.add_argument('--jdm', type=int,default=385, help=" ") + + args = parser.parse_args() + + make_grid(args.meshfile) + + diff --git a/hycom/GOMd0.08/expt_30.6/blkdat.input b/hycom/GOMd0.08/expt_30.6/blkdat.input index d67dcccc..46a8e076 100644 --- a/hycom/GOMd0.08/expt_30.6/blkdat.input +++ b/hycom/GOMd0.08/expt_30.6/blkdat.input @@ -97,7 +97,7 @@ S-Z(15-11): dp00/f/x/i=3m/1.125/12m/1m; ds=1m/1.125/4m; src_2.2.98; 5.0 'thkriv' = nominal thickness of river inflow (m) 3.0 'thkcdw' = thickness for near-surface currents in ice-ocean stress (m) 20.0 'thkfrz' = maximum thickness of near-surface freezing zone (m) - 0 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf) + 0 'iceflg' = sea ice model flag (0=none,1=energy loan,2=coupled/esmf,3=nextsim) 0.0 'tfrz_0' = ENLN: ice melting point (degC) at S=0psu -0.054 'tfrz_s' = ENLN: gradient of ice melting point (degC/psu) 0.125 'frzifq' = e-folding time scale back to tfrz (days or -ve time steps) diff --git a/hycom/MSCPROGS/src/Make.Inc/make.chpc.ifort b/hycom/MSCPROGS/src/Make.Inc/make.chpc.ifort new file mode 100755 index 00000000..66b26d7d --- /dev/null +++ b/hycom/MSCPROGS/src/Make.Inc/make.chpc.ifort @@ -0,0 +1,41 @@ +# include file for fimm, intel compilers +CF90 = ifort +CF77 = $(CF90) +CC = icc +LD = $(CF90) + +# CPP, used internally by compilers - note that some compilers +# need special options for this, consult compiler manual if in trouble +CPP= /usr/bin/cpp -P -traditional-cpp +CPPARCH = -DIA32 -DREA8 -DMPI -DSERIA_IO -DTIMER -DIARGC -DFFTW -DLAPACK +#NCAR graphics compiler wrappers +#NCARGCF90=ncargf90 +#NCARGCF77=ncargf77 +#NCARGCC=ncargcc +#NCARGLD=ncargf90 + +# Flags for fixed/free format +F90FLG= -free +F77FLG = -nofree + +##NETCDF_INCLUDE_OPTS=/cluster/software/netCDF-Fortran/4.4.4-intel-2018b/include + +# Compiler flags - real*8 version +#FFLAGS= -real_size 64 -convert big_endian -O2 -g +FFLAGS= -g -convert big_endian -assume byterecl -cm -vec_reprot0 -w -o2 -r8 + +CFLAGS= -O2 -no-multibyte-chars + +# Compiler flags - real*4 version (Needed for NCARG routines) +FFLAGSR4= -real_size 32 -convert big_endian -O2 -g +CFLAGSR4= -O2 + +# Linker flags +LINKFLAGS= $(FFLAGS) + +#Libraries, Netcdf, FFTW, LAPACK +LIBS = -lnetcdf -lnetcdff -lfftw3 -llapack +INCLUDE = + +# Define CPP flags consistent with libs above +CPPFLAGS=-DFFTW -DLAPACK diff --git a/hycom/RELO/config/Linux.chpc.ifort_hycom b/hycom/RELO/config/Linux.chpc.ifort_hycom new file mode 100644 index 00000000..02dcc416 --- /dev/null +++ b/hycom/RELO/config/Linux.chpc.ifort_hycom @@ -0,0 +1,83 @@ +# +# --------------------------------------------------------------------- +# intel compiler on Fram +# --------------------------------------------------------------------- +# +# MACROS DESCRIPTIONS: +# +# FC: Fortran 90 compiler. +# FCFFLAGS: Fortran 90 compilation flags. +# CC: C compiler. +# CCFLAGS: C compilation flags. +# CPP: cpp preprocessor (may be implied by FC). +# CPPFLAGS: cpp -D macro flags. +# LD: Loader. +# LDFLAGS: Loader flags. +# EXTRALIBS: Extra local libraries (if any). +# + +####INCLUDES = -I$(NETCFD_DIR)/include/ + +FC = mpiifort +FCFFLAGS = -g -convert big_endian -assume byterecl -cm -vec_report0 -w -tpp7 -xW -r8 +FCFFLAGS := $(FCFFLAGS) $(INCLUDES) + +CC = mpicc +CCFLAGS = -O + + +CPP = cpp -P +LD = $(FC) +LDFLAGS = $(FCFFLAGS) -mcmodel=medium + +# ENDIAN_IO not needed due to byteswap compiler flag +# NERSC_HYCOM_CICE Code changes specific to our version +#CPPFLAGS = -DIA32 -DREAL4 +# +# if no STOKES: +# --- Mostafa: flags required for standalone HYCOM + +CPPFLAGS = -DIA32 -DREAL8 -DMPI -DSERIAL_IO -DNAN2003 -DTIMER -DRELO -DNERSC_HYCOM_CICE -DOFFICEField +# for STOKES flag use +#CPPFLAGS = -DIA32 -DREAL8 -DMPI -DSERIAL_IO -DNAN2003 -DTIMER -DRELO -DUSE_ESMF -DUSE_ESMF_5 -DNERSC_HYCOM_CICE -DSTOKES +# --- Mostafa: flags required for standalone HYCOM +EXTRALIBS = $(LIBPSMILE) -lfftw3 -lnetcdff -lnetcdf -lmpi -lmpifort + +# if you want to include ECOSMO, then you should +# add to EXPT.src or execute in the shell the following: +# export COMPILE_BIOMODEL="yes" + +ifeq ($(COMPILE_BIOMODEL), yes) + CPPFLAGS += -D_FABM_ -I${HOME}/local/fabm/hycom/include + EXTRALIBS += -L${HOME}/local/fabm/hycom/lib64 -lfabm +endif + +# +# --- generic make definitions +# +SHELL = /bin/sh +RM = \rm -f + +# +# rules. +# + +.c.o: + $(CC) $(CPPFLAGS) $(CCFLAGS) -c $*.c + +.f.o: + $(FC) $(FCFFLAGS) -c $*.f + +.F.o: + $(FC) $(CPPFLAGS) $(FCFFLAGS) -c $*.F + + +#======= for Fabm use these + +.f90.o: + $(FC) $(CCFLAGS) $(FCFFLAGS) -c $*.f90 + +.F90.o: + $(FC) $(CPPFLAGS) $(FCFFLAGS) -c $*.F90 + + diff --git a/hycom/RELO/config/Linux.fram.ifort_hycom b/hycom/RELO/config/Linux.fram.ifort_hycom index 59dda464..2233d685 100644 --- a/hycom/RELO/config/Linux.fram.ifort_hycom +++ b/hycom/RELO/config/Linux.fram.ifort_hycom @@ -1,6 +1,6 @@ # # --------------------------------------------------------------------- -# intel compiler on hexagon +# intel compiler on Fram # --------------------------------------------------------------------- # # MACROS DESCRIPTIONS: @@ -15,25 +15,19 @@ # LDFLAGS: Loader flags. # EXTRALIBS: Extra local libraries (if any). # -#INCLUDES = -I/cluster/software/netCDF-Fortran/4.4.4-intel-2017a-HDF5-1.8.18/include -I${ESMF_MOD_DIR} -I${ESMF_DIR}include -I./CICE/rundir/compile -# --- Mostafa: flags required for standalone HYCOM -INCLUDES = -I${ESMF_MOD_DIR} -I${ESMF_DIR}include -I./CICE/rundir/compile +####INCLUDES = -I$(NETCFD_DIR)/include/ FC = mpiifort -#FCFFLAGS = -traceback -g -O2 -fp-model source -warn nogeneral -convert big_endian -assume byterecl -real-size 64 -integer-size 32 FCFFLAGS = -g -convert big_endian -assume byterecl -cm -vec_report0 -w -O3 -tpp7 -xW -r8 -#FCFFLAGS = -traceback -g -O2 -check all -fp-stack-check -fp-model source -warn nogeneral -convert big_endian -assume byterecl -real-size 64 -integer-size 32 -#FCFFLAGS = -O2 -fconvert=big-endian -fdefault-real-8 -fdefault-double-8 - -FCFFLAGS := $(FCFFLAGS) $(INCLUDES) +FCFFLAGS := $(FCFFLAGS) $(INCLUDES) CC = mpicc CCFLAGS = -O + CPP = cpp -P LD = $(FC) -#LDFLAGS = -V $(FCFFLAGS) -shared-intel -mcmodel=medium LDFLAGS = $(FCFFLAGS) -mcmodel=medium # ENDIAN_IO not needed due to byteswap compiler flag @@ -42,20 +36,21 @@ LDFLAGS = $(FCFFLAGS) -mcmodel=medium # # if no STOKES: # --- Mostafa: flags required for standalone HYCOM -CPPFLAGS = -DIA32 -DREAL8 -DMPI -DSERIAL_IO -DNAN2003 -DTIMER -DRELO -DNERSC_HYCOM_CICE -#CPPFLAGS = -DIA32 -DREAL8 -DMPI -DSERIAL_IO -DNAN2003 -DTIMER -DRELO -DUSE_ESMF -DUSE_ESMF_5 -DNERSC_HYCOM_CICE +CPPFLAGS = -DIA32 -DREAL8 -DMPI -DSERIAL_IO -DNAN2003 -DTIMER -DRELO -DNERSC_HYCOM_CICE -DOFFICEField # for STOKES flag use #CPPFLAGS = -DIA32 -DREAL8 -DMPI -DSERIAL_IO -DNAN2003 -DTIMER -DRELO -DUSE_ESMF -DUSE_ESMF_5 -DNERSC_HYCOM_CICE -DSTOKES -#EXTRALIBS = -L${ESMF_LIB_DIR}/ -lesmf -pgcpplibs -#EXTRALIBS = -L${ESMF_LIB_DIR}/ -lesmf -lfftw3 -lmkl -lnetcdff -lnetcdf -lmpi -lmpifort # --- Mostafa: flags required for standalone HYCOM -EXTRALIBS = -lfftw3 -lmkl -lnetcdff -lnetcdf -lmpi -lmpifort +EXTRALIBS = $(LIBPSMILE) -lfftw3 -lmkl -lnetcdff -lnetcdf -lmpi -lmpifort +# if you want to include ECOSMO, then you should +# add to EXPT.src or execute in the shell the following: +# export COMPILE_BIOMODEL="yes" -# from fabm -#CPPFLAGS += -D_FABM_ -I${HOME}/local/fabm/hycom/include -#EXTRALIBS += -L${HOME}/local/fabm/hycom/lib -lfabm +ifeq ($(COMPILE_BIOMODEL), yes) + CPPFLAGS += -D_FABM_ -I${HOME}/local/fabm/hycom/include + EXTRALIBS += -L${HOME}/local/fabm/hycom/lib64 -lfabm +endif # # --- generic make definitions @@ -73,14 +68,16 @@ RM = \rm -f .f.o: $(FC) $(FCFFLAGS) -c $*.f -.F.o: - $(FC) $(CPPFLAGS) $(FCFFLAGS) -c $*.F +.F.o: + $(FC) $(CPPFLAGS) $(FCFFLAGS) -c $*.F + #======= for Fabm use these .f90.o: - $(FC) $(FCFFLAGS) -c $*.f90 + $(FC) $(CCFLAGS) $(FCFFLAGS) -c $*.f90 .F90.o: $(FC) $(CPPFLAGS) $(FCFFLAGS) -c $*.F90 + diff --git a/hycom/RELO/src_2.2.98ZA-07Tsig0-i-sm-sse_relo_mpi/Make_hycom.csh b/hycom/RELO/src_2.2.98ZA-07Tsig0-i-sm-sse_relo_mpi/Make_hycom.csh index 2942c582..1642a76a 100755 --- a/hycom/RELO/src_2.2.98ZA-07Tsig0-i-sm-sse_relo_mpi/Make_hycom.csh +++ b/hycom/RELO/src_2.2.98ZA-07Tsig0-i-sm-sse_relo_mpi/Make_hycom.csh @@ -34,11 +34,16 @@ touch ./hycom_feature_flags # --- make HYCOM component, and update hycom_cice # # --- force a relink, because CICE is not in the dependencies -if ( $ICEFLG == 0 ) then +if ( $ICEFLG == 3 ) then /bin/rm hycom echo "only hycom" make ARCH=$ARCH TYPE=$TYPE hycom - mv -f hycom hycom_oasis + mv -f hycom hycom_nextsim +else if ( $ICEFLG == 0 ) then + /bin/rm hycom + echo "only hycom" + make ARCH=$ARCH TYPE=$TYPE hycom + mv -f hycom hycom_alone else echo "HYCOM-CICE" /bin/rm hycom_cice diff --git a/hycom/RELO/src_2.2.98ZA-07Tsig0-i-sm-sse_relo_mpi/Oasis/mod_hycom.F b/hycom/RELO/src_2.2.98ZA-07Tsig0-i-sm-sse_relo_mpi/Oasis/mod_hycom.F index 8ff77dcd..5b29b50c 100644 --- a/hycom/RELO/src_2.2.98ZA-07Tsig0-i-sm-sse_relo_mpi/Oasis/mod_hycom.F +++ b/hycom/RELO/src_2.2.98ZA-07Tsig0-i-sm-sse_relo_mpi/Oasis/mod_hycom.F @@ -1933,7 +1933,7 @@ subroutine HYCOM_Run !AS give hycom the sea ice concentration covice(1:idm,1:jdm)=cplts_recv(1:idm,1:jdm,i2o_sico) si_c(1:idm,1:jdm)=cplts_recv(1:idm,1:jdm,i2o_sico) -#elif +#else si_c(:,:) = covice(:,:) #endif si_h(:,:) = thkice(:,:) diff --git a/input/era5_chpc.xml b/input/era5_chpc.xml new file mode 100755 index 00000000..72418ccc --- /dev/null +++ b/input/era5_chpc.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/pythonlibs/modeltools/modeltools/tools/_indata.py b/pythonlibs/modeltools/modeltools/tools/_indata.py index 5f141b41..cf2790d5 100755 --- a/pythonlibs/modeltools/modeltools/tools/_indata.py +++ b/pythonlibs/modeltools/modeltools/tools/_indata.py @@ -220,12 +220,7 @@ def __init__(self,name,filenametemplate,varname,unit,format,accumulation_time=No logger.info("Converting accumulated field (varname=%s) to flux"%self._varname) self._units = self._units+ " s**-1" tmp= self._accumulation_time - if self._filenametemplate.find('/ERA5/') > 0 : - # Downloaded ERA5 at current using the hourly averaged precipitation - # future it could be 3-hoursly - self._accumulation_scale_factor = 1./(tmp.days*86400. + tmp.seconds/6) - else : - self._accumulation_scale_factor = 1./(tmp.days*86400. + tmp.seconds) + self._accumulation_scale_factor = 1./(tmp.days*86400. + tmp.seconds) else : self._accumulation_scale_factor = 1. self._accumulation_time=datetime.timedelta(0)