diff --git a/LICENSE.pdf b/LICENSE.pdf index 80ae31d51..da37344cf 100644 Binary files a/LICENSE.pdf and b/LICENSE.pdf differ diff --git a/README.md b/README.md index 45e4a6a1a..1ecd483fe 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ - -[![GHActions](https://github.com/CICE-Consortium/CICE/workflows/GHActions/badge.svg)](https://github.com/CICE-Consortium/CICE/actions) -[![Documentation Status](https://readthedocs.org/projects/cice-consortium-cice/badge/?version=main)](http://cice-consortium-cice.readthedocs.io/en/main/?badge=main) -[![lcov](https://img.shields.io/endpoint?url=https://apcraig.github.io/coverage.json)](https://apcraig.github.io) - - +[![Build Status](https://travis-ci.org/CICE-Consortium/CICE.svg?branch=master)](https://travis-ci.org/CICE-Consortium/CICE) +[![Documentation Status](https://readthedocs.org/projects/cice-consortium-cice/badge/?version=master)](http://cice-consortium-cice.readthedocs.io/en/master/?badge=master) +[![codecov](https://codecov.io/gh/apcraig/Test_CICE_Icepack/branch/master/graph/badge.svg)](https://codecov.io/gh/apcraig/Test_CICE_Icepack) ## The CICE Consortium sea-ice model CICE is a computationally efficient model for simulating the growth, melting, and movement of polar sea ice. Designed as one component of coupled atmosphere-ocean-land-ice global climate models, today’s CICE model is the outcome of more than two decades of community collaboration in building a sea ice model suitable for multiple uses including process studies, operational forecasting, and climate simulation. @@ -12,19 +9,21 @@ CICE is a computationally efficient model for simulating the growth, melting, an This repository contains the files and code needed to run the CICE sea ice numerical model starting with version 6. CICE is maintained by the CICE Consortium. Versions prior to v6 are found in the [CICE-svn-trunk repository](https://github.com/CICE-Consortium/CICE-svn-trunk). -CICE consists of a top level driver and dynamical core plus the [Icepack][icepack] column physics code], which is included in CICE as a Git submodule. Because Icepack is a submodule of CICE, Icepack and CICE development are handled independently with respect to the GitHub repositories even though development and testing may be done together. +CICE consists of a top level driver and dynamical core plus the [Icepack column physics code][icepack], which is included in CICE as a Git submodule. Because Icepack is a submodule of CICE, Icepack and CICE development are handled independently with respect to the GitHub repositories even though development and testing may be done together. [icepack]: https://github.com/CICE-Consortium/Icepack -The first point of contact with the CICE Consortium is the Consortium Community [Forum][forum]. +If you need help getting started using the model afer reviewing the [model documentation][doc-resources], the first point of contact with the CICE Consortium is the [Consortium Community Forum][forum]. This forum is monitored by Consortium members and also opened to the whole community. Please do not use our issue tracker for general support questions. +[doc-resources]: https://github.com/CICE-Consortium/About-Us/wiki/Resource-Index#model-documentation +[doc-running]: https://cice-consortium-cice.readthedocs.io/en/master/user_guide/ug_running.html [forum]: https://xenforo.cgd.ucar.edu/cesm/forums/cice-consortium.146/ If you expect to make any changes to the code, we recommend that you first fork both the CICE and Icepack repositories. In order to incorporate your developments into the Consortium code it is imperative you follow the guidance for Pull Requests and requisite testing. -Head over to our [Contributing][contributing] guide to learn more about how you can help improve CICE. +Head over to our [Contribution guide][contributing] to learn more about how you can help improve CICE. [contributing]: https://github.com/CICE-Consortium/About-Us/wiki/Contributing @@ -33,7 +32,7 @@ Head over to our [Contributing][contributing] guide to learn more about how you Information about the CICE model -* **CICE Release Table**: https://github.com/CICE-Consortium/CICE/wiki/CICE-Release-Table +* **CICE Version Index**: https://github.com/CICE-Consortium/CICE/wiki/CICE-Version-Index Numbered CICE releases since version 6 with associated documentation and DOIs. @@ -46,4 +45,4 @@ Head over to our [Contributing][contributing] guide to learn more about how you List of resources for information about the Consortium and its repositories as well as model documentation, testing, and development. ## License -See our [License](LICENSE.pdf) and [Distribution Policy](DistributionPolicy.pdf). +See our [License](License.pdf) and [Distribution Policy](DistributionPolicy.pdf). diff --git a/cice.setup b/cice.setup index 30da0ed2e..d70aece61 100755 --- a/cice.setup +++ b/cice.setup @@ -1,7 +1,5 @@ #!/bin/csh -f -#set pd0 = `date -u "+%s%N"` - set ICE_SANDBOX = `pwd` set ICE_VERSION = unknown if (-e cicecore/version.txt) then @@ -15,7 +13,7 @@ set dash = "-" set spval = "UnDeFiNeD" set machcomp = ${spval} set machine = ${spval} -set envnames = intel +set compilers = intel set case = ${spval} set test = ${spval} set grid = gx3 @@ -36,13 +34,12 @@ set stime = `date -u "+%H%M%S"` set docase = 0 set dotest = 0 set dosuite = 0 -set coverage = 0 # code coverage measurement and reporting -set coverageflag = false +set codecov = 0 # code coverage measurement and reporting +set codecovflag = false set suitebuild = true set suitereuse = true set suiterun = false set suitesubmit = true -set ignoreuserset = false if ($#argv < 1) then set helpheader = 1 @@ -87,7 +84,7 @@ SYNOPSIS --suite SUITE[,SUITE2] -m MACH --testid ID [-e ENV1,ENV2][--acct ACCT][--bdir DIR][--bgen DIR] - [--bcmp DIR][--tdir PATH][--report || --coverage] + [--bcmp DIR][--tdir PATH][--report || --codecov] [--setup-only || --setup-build || --setup-build-run || --setup-build-submit] DESCRIPTION @@ -96,12 +93,11 @@ DESCRIPTION --setvers : updates cice version number in sandbox --case, -c : case, case directory/name (not with --test or --suite) --mach, -m : machine, machine name (required) - --env, -e : compilation environment name(s), comma separated (default = $envnames) + --env, -e : compiler(s), comma separated (default = $compilers) --pes, -p : tasks x threads [x blocksize_x x blocksize_y [x maxblocks]] (default is ${pesx}) --acct : account number for the batch submission --grid, -g : grid, grid (default = ${grid}) --set, -s : case option setting(s), comma separated (default = " ") - --ignore-user-set: ignore ~/.cice_set if it exists --queue : queue for the batch submission For testing @@ -115,8 +111,8 @@ DESCRIPTION --testid : test ID, user-defined id for testing (REQUIRED with --test or --suite) --diff : generate comparison against another case --report : automatically post results when tests are complete - --coverage : generate and report test coverage metrics when tests are complete, - requires GNU compiler (ie. normally --env gnu) + --codecov : generate and report test coverage metrics when tests are complete, + requires GNU compiler (--env gnu) --setup-only : for suite, setup testcases, no build, no submission --setup-build : for suite, setup and build testcases, no submission --setup-build-run : for suite, setup, build, and run interactively @@ -233,9 +229,9 @@ while (1) set report = 1 shift argv - else if ("$option" == "--coverage") then - set coverage = 1 - set coverageflag = true + else if ("$option" == "--codecov") then + set codecov = 1 + set codecovflag = true set suitereuse = false shift argv @@ -267,10 +263,6 @@ while (1) set suitesubmit = true shift argv - else if ("$option" == "--ignore-user-set") then - set ignoreuserset = true - shift argv - # arguments with settings else shift argv @@ -289,7 +281,7 @@ while (1) else if ("$option" =~ --mach* || "$option" == "-m") then set machine = $argv[1] else if ("$option" =~ --env* || "$option" == "-e") then - set envnames = $argv[1] + set compilers = $argv[1] else if ("$option" == "--test") then set test = $argv[1] set dotest = 1 @@ -344,18 +336,18 @@ if (${dosum} > 1) then exit -1 endif -if ($coverage == 1 && $report == 1) then - echo "${0}: ERROR in arguments, not recommmended to set both --coverage and --report" +if ($codecov == 1 && $report == 1) then + echo "${0}: ERROR in arguments, not recommmended to set both --codecov and --report" exit -1 endif -if ($coverage == 1 && "$envnames" !~ "gnu*") then - echo "${0}: ERROR in arguments, must use --env gnu* with --coverage" +if ($codecov == 1 && "$compilers" != "gnu") then + echo "${0}: ERROR in arguments, must use --env gnu with --codecov" exit -1 endif -if ($coverage == 1 && `where curl` == "" && `where wget` == "") then - echo "${0}: ERROR 'curl' or 'wget' is required for --coverage" +if ($codecov == 1 && `where curl` == "" && `where wget` == "") then + echo "${0}: ERROR 'curl' or 'wget' is required for --codecov" exit -1 endif @@ -364,46 +356,31 @@ if (${dosuite} == 0) then echo "${0}: ERROR in arguments, must use --suite with --report" exit -1 endif - if ($coverage == 1) then - echo "${0}: ERROR in arguments, must use --suite with --coverage" + if ($codecov == 1) then + echo "${0}: ERROR in arguments, must use --suite with --codecov" exit -1 endif - if ("$envnames" =~ "*,*") then - echo "${0}: ERROR in arguments, cannot set multiple envnames without --suite" + if ("$compilers" =~ "*,*") then + echo "${0}: ERROR in arguments, cannot set multiple compilers without --suite" exit -1 else - set envname = ${envnames} - set machcomp = ${machine}_${envname} - endif -else - if ($coverage == 1) then - if ("$envnames" =~ "*,*") then - echo "${0}: ERROR in arguments, cannot set multiple envnamess with --coverage" - exit -1 - else - set envname = ${envnames} - set machcomp = ${machine}_${envname} - endif + set compiler = ${compilers} + set machcomp = ${machine}_${compiler} endif endif +# tcraig, lets find another way to validate argument +#if (${test} != ${spval} && ${test} != 'smoke' && ${test} != '10day' && ${test} != 'annual' \ +# && ${test} != 'restart') then +# echo "${0}: ERROR in arguments. ${test} is not a valid test" +# exit -1 +#endif + if ((${dosuite} == 1 || ${dotest} == 1) && ${testid} == ${spval}) then echo "${0}: ERROR in arguments. --testid must be passed if using --suite or --test" exit -1 endif -# This creates a new sandbox and modifies the source code for "improved" lcov analysis -# Turn this if block off if you don't want coverage to do that -if ($coverage == 1) then - set sandbox_lcov = ${ICE_SANDBOX}/../cice_lcov_${sdate}-${stime} - cp -p -r ${ICE_SANDBOX} ${sandbox_lcov} - echo "shifting to sandbox = ${sandbox_lcov}" - set ICE_SANDBOX = ${sandbox_lcov} - set ICE_SCRIPTS = "${ICE_SANDBOX}/configuration/scripts" - cd ${ICE_SANDBOX} - ${ICE_SCRIPTS}/tests/lcov_modify_source.sh -endif - #--------------------------------------------------------------------- # Setup tsfile and test suite support stuff @@ -432,17 +409,6 @@ set vers = ${ICE_VERSION} set shhash = `echo ${hash} | cut -c 1-10` if ( ${dosuite} == 0 ) then - # grab user defined default sets - if ("${ignoreuserset}" == "false" && -e ~/.cice_set) then - set setsu1 = `cat ~/.cice_set` - # get rid of spaces if they exist! - set setsuser = `echo ${setsu1} | sed 's/ //g'` - if ( ${sets} == "" ) then - set sets = "${setsuser}" - else - set sets = "${setsuser},${sets}" - endif - endif set teststring = "${test} ${grid} ${pesx} ${sets}" if ( $bfbcomp != ${spval} ) then if ( ${sets} == "" ) then @@ -455,25 +421,8 @@ if ( ${dosuite} == 0 ) then set sets = "" else - # generate unique set of suites in tarrays in order they are set - set tarrays0 = `echo ${testsuite} | sed 's/,/ /g' | fmt -1 ` - #echo "${0}: tarrays0 = ${tarrays0}" - set tarrays = $tarrays0[1] - foreach t1 ( ${tarrays0} ) - set found = 0 - foreach t2 ( ${tarrays} ) - if ( ${t1} == ${t2} ) then - set found = 1 - endif - end - if ( ${found} == 0 ) then - set tarrays = ( ${tarrays} ${t1} ) - endif - end - #echo "${0}: tarrays = ${tarrays}" - set testsuitecnt = 0 + set tarrays = `echo ${testsuite} | sed 's/,/ /g' | fmt -1 | sort -u` foreach tarray ( ${tarrays} ) - @ testsuitecnt = ${testsuitecnt} + 1 if (-e ${tarray}) then cat ${tarray} >> $tsfile else if (-e ${tarray}.ts) then @@ -497,14 +446,12 @@ else exit -1 endif cp -f ${ICE_SCRIPTS}/tests/report_results.csh ${tsdir} - cp -f ${ICE_SCRIPTS}/tests/create_fails.csh ${tsdir} cp -f ${ICE_SCRIPTS}/tests/poll_queue.csh ${tsdir} cat >! ${tsdir}/suite.submit << EOF0 #!/bin/csh -f set nonomatch && rm -f ciceexe.* && unset nonomatch -rm -f suite.jobs set dobuild = true set doreuse = true @@ -557,46 +504,30 @@ EOF0 cat >! ${tsdir}/report_codecov.csh << EOF0 #!/bin/csh -f -source ${ICE_SCRIPTS}/machines/env.${machcomp} +#setenv CODECOV_TOKEN "1d09241f-ed9e-47d8-847c-038bab024b53" # consortium cice +#setenv CODECOV_TOKEN "f3236008-0b92-4707-9ad5-ad906f5d2ba7" # apcraig cice +setenv CODECOV_TOKEN "0dcc6066-fdce-47b6-b84a-c55e2a0af4c0" # apcraig test_cice_icepack +set report_name = "${shhash}:${branch}:${machine} ${testsuite}" -set rn0 = "${sdate}-${stime}:${shhash}:${testsuitecnt}:${testsuite}" -set rn1 = \`echo \${rn0} | sed -e 's/ //g'\` -set report_name = \`echo \${rn1} | sed -e 's/_suite//g'\` - -#for codecov set use_curl = 1 -# define CODECOV_TOKEN env variable -if !(\$?CODECOV_TOKEN) then - if (-e ~/.codecov_cice_token) then - source ~/.codecov_cice_token - endif - if !(\$?CODECOV_TOKEN) then - echo "\${0}: ERROR, CODECOV_TOKEN env variable not defined" - exit 2 - endif -endif - -#for lcov -set lcovalist = "" EOF0 chmod +x ${tsdir}/suite.submit chmod +x ${tsdir}/results.csh chmod +x ${tsdir}/report_codecov.csh - cp -p -f ${tsdir}/report_codecov.csh ${tsdir}/report_lcov.csh endif #------------------------------------------------------------------- # Loop over cases/tests -set nenvnames = "`echo $envnames | sed -e 's/,/ /g'`" +set ncompilers = "`echo $compilers | sed -e 's/,/ /g'`" -# check that machines and envnames are valid before starting big loop +# check that machines and compilers are valid before starting big loop set doabort = false -foreach envname ( $nenvnames ) - set machcomp = ${machine}_${envname} +foreach compiler ( $ncompilers ) + set machcomp = ${machine}_${compiler} foreach file (env.${machcomp} Macros.${machcomp}) if !(-e ${ICE_SCRIPTS}/machines/$file) then echo "${0}: ERROR, ${ICE_SCRIPTS}/machines/$file not found" @@ -611,8 +542,8 @@ endif # Create a new sets_base variable to store sets passed to cice.setup set sets_base = "${sets}" set bfbcomp_base = "$bfbcomp" -foreach envname ( $nenvnames ) - set machcomp = ${machine}_${envname} +foreach compiler ( $ncompilers ) + set machcomp = ${machine}_${compiler} foreach line ( "`cat $tsfile`" ) # Check if line is a comment line @@ -634,15 +565,6 @@ EOF continue endif - # unset env variables that might not exist in env machine file - # to avoid any carry over during multi envname suites - unsetenv ICE_MACHINE_MAXTHREADS - unsetenv ICE_MACHINE_MAXPES - unsetenv ICE_MACHINE_QUIETMODE - unsetenv ICE_MACHINE_CPPDEFS - unsetenv ICE_MACHINE_QSTAT - unsetenv ICE_MACHINE_MACHINFO - unsetenv ICE_MACHINE_ENVINFO source ${ICE_SCRIPTS}/machines/env.${machcomp} -nomodules || exit 2 # Obtain the test name, sets, grid, and PE information from .ts file @@ -653,7 +575,7 @@ EOF set bfbcomp_tmp = `echo $line | cut -d' ' -f5` # Append sets from .ts file to the $sets variable - set sets = "$sets_tmp,$sets_base" + set sets = "$sets_base,$sets_tmp" # Create a new bfbcomp_base variable to store bfbcomp passed to cice.setup # Use bfbcomp_base or bfbcomp_tmp @@ -663,6 +585,11 @@ EOF set bfbcomp = "$bfbcomp_tmp" endif + set fbfbcomp = ${spval} + if ($bfbcomp != ${spval}) then + set fbfbcomp = ${machcomp}_${bfbcomp} + endif + #------------------------------------------------------------ # Parse pesx with strict checking, limit pes for machine @@ -765,18 +692,11 @@ EOF endif set testname_noid = ${spval} - # create case for test cases - - set fbfbcomp = ${spval} - if ($bfbcomp != ${spval}) then - set fbfbcomp = ${machcomp}_${bfbcomp} - endif - if (${docase} == 0) then set soptions = "" # Create sorted array and remove duplicates and "none" - set setsarray = `echo ${sets_tmp} | sed 's/,/ /g' | fmt -1 | sort -u` + set setsarray = `echo ${sets} | sed 's/,/ /g' | fmt -1 | sort -u` if ("${setsarray}" != "") then foreach field (${setsarray}) if (${field} != "none") then @@ -784,27 +704,11 @@ EOF endif end endif - # Add options from command line, sort and remove duplicates - set soptions_base = "" - set setsarray_base = `echo ${sets_base} | sed 's/,/ /g' | fmt -1 | sort -u` - if ("${setsarray_base}" != "") then - foreach field (${setsarray_base}) - set soptions = ${soptions}"_"${field} - set soptions_base = ${soptions_base}"_"${field} - end - endif # soptions starts with _ set testname_noid = "${machcomp}_${test}_${grid}_${pesx}${soptions}" set testname_base = "${machcomp}_${test}_${grid}_${pesx}${soptions}.${testid}" set testname = "${tsdir}/${testname_base}" set case = ${testname} - - if (${dosuite} == 1) then - # Add -s flags in cice.setup to bfbcomp name - if ($bfbcomp != ${spval}) then - set fbfbcomp = ${machcomp}_${bfbcomp}${soptions_base} - endif - endif endif if (-d ${case}) then @@ -833,8 +737,8 @@ EOF # set default test output as failure if (${docase} == 0) then echo "#---" >! test_output - echo "PEND ${testname_noid} build" >> test_output - echo "PEND ${testname_noid} run" >> test_output + echo "FAIL ${testname_noid} build" >> test_output + echo "FAIL ${testname_noid} run" >> test_output endif # from basic script dir to case @@ -843,7 +747,7 @@ EOF echo "${0}: ERROR, ${ICE_SCRIPTS}/$file not found" exit -1 endif - cp -f -p ${ICE_SCRIPTS}/$file ${casedir}/ + cp -f -p ${ICE_SCRIPTS}/$file ${casedir} end # from machines dir to case @@ -852,7 +756,7 @@ EOF echo "${0}: ERROR, ${ICE_SCRIPTS}/machines/$file not found" exit -1 endif - cp -f -p ${ICE_SCRIPTS}/machines/$file ${casedir}/ + cp -f -p ${ICE_SCRIPTS}/machines/$file ${casedir} end # from basic script dir to casescr @@ -861,16 +765,7 @@ EOF echo "${0}: ERROR, ${ICE_SCRIPTS}/$file not found" exit -1 endif - cp -f -p ${ICE_SCRIPTS}/$file ${casescr}/ - end - - # from tests dir to casescr - foreach file (cice.results.csh cice.codecov.csh cice.lcov.csh) - if !(-e ${ICE_SCRIPTS}/tests/$file) then - echo "${0}: ERROR, ${ICE_SCRIPTS}/$file not found" - exit -1 - endif - cp -f -p ${ICE_SCRIPTS}/tests/$file ${casescr}/ + cp -f -p ${ICE_SCRIPTS}/$file ${casescr} end cd ${casedir} @@ -880,11 +775,6 @@ EOF set quietmode = ${ICE_MACHINE_QUIETMODE} endif - set cppdefs = "" - if ($?ICE_MACHINE_CPPDEFS) then - set cppdefs = ${ICE_MACHINE_CPPDEFS} - endif - if (${acct} == ${spval}) then if (-e ~/.cice_proj) then set acct = `head -1 ~/.cice_proj` @@ -923,14 +813,11 @@ EOF echo "ICE_CASENAME = ${casename}" echo "ICE_CASEDIR = ${casedir}" echo "ICE_MACHINE = ${machine}" - echo "ICE_ENVNAME = ${envname}" + echo "ICE_COMPILER = ${compiler}" echo "ICE_RUNDIR = ${rundir}" echo "ICE_PES = ${task}x${thrd}" echo "ICE_GRID = ${grid} (${ICE_DECOMP_NXGLOB}x${ICE_DECOMP_NYGLOB}) blocksize=${ICE_DECOMP_BLCKX}x${ICE_DECOMP_BLCKY}x${ICE_DECOMP_MXBLCKS}" echo "ICE_DECOMP = ${ICE_DECOMP_DECOMP} ${ICE_DECOMP_DSHAPE}" - if ($fbfbcomp != ${spval}) then - echo "ICE_BFBCOMP = ${fbfbcomp}" - endif #------------------------------------------------------------ # Copy in and update cice.settings and ice_in files @@ -943,21 +830,9 @@ EOF if (-e ${fimods}) rm ${fimods} if (-e ${fsmods}) rm ${fsmods} - # Use an existing ice_in file from the suite if it exists - # to reduce time spent in parse_namelist - set skip_parse_namelist = spval - if (${dosuite} == 1) then - set iceinfn = ../ice_in_save_${grid}${soptions} - if (-e ${iceinfn}) then - echo "use ${iceinfn}" - cp ${iceinfn} ice_in - set skip_parse_namelist = true - endif - endif - - # Set decomp info in namelist cat >! ${fimods} << EOF1 # cice.setup settings + nprocs = ${task} nx_global = ${ICE_DECOMP_NXGLOB} ny_global = ${ICE_DECOMP_NYGLOB} @@ -986,22 +861,27 @@ EOF1 cat >! ${fsmods} << EOF1 # cice.setup settings + setenv ICE_SANDBOX ${ICE_SANDBOX} setenv ICE_SCRIPTS ${ICE_SCRIPTS} setenv ICE_CASENAME ${casename} setenv ICE_CASEDIR ${casedir} setenv ICE_MACHINE ${machine} -setenv ICE_ENVNAME ${envname} +setenv ICE_COMPILER ${compiler} setenv ICE_MACHCOMP ${machcomp} setenv ICE_RUNDIR ${rundir} setenv ICE_GRID ${grid} +#setenv ICE_NXGLOB ${ICE_DECOMP_NXGLOB} # moved to namelist +#setenv ICE_NYGLOB ${ICE_DECOMP_NYGLOB} # moved to namelist setenv ICE_NTASKS ${task} setenv ICE_NTHRDS ${thrd} +#setenv ICE_MXBLCKS ${ICE_DECOMP_MXBLCKS} # moved to namelist +#setenv ICE_BLCKX ${ICE_DECOMP_BLCKX} # moved to namelist +#setenv ICE_BLCKY ${ICE_DECOMP_BLCKY} # moved to namelist setenv ICE_BASELINE ${basedir_tmp} setenv ICE_BASEGEN ${baseGen} setenv ICE_BASECOM ${baseCom} setenv ICE_SPVAL ${spval} -setenv ICE_CPPDEFS ${cppdefs} setenv ICE_QUIETMODE ${quietmode} setenv ICE_TEST ${test} setenv ICE_TESTNAME ${testname_noid} @@ -1009,7 +889,7 @@ setenv ICE_TESTID ${testid} setenv ICE_BFBCOMP ${fbfbcomp} setenv ICE_ACCOUNT ${acct} setenv ICE_QUEUE ${queue} -setenv ICE_COVERAGE ${coverageflag} +setenv ICE_CODECOV ${codecovflag} EOF1 if (${sets} != "") then @@ -1054,59 +934,42 @@ EOF1 foreach name (${grid} $setsx) set found = 0 - if (-e ${ICE_SCRIPTS}/options/set_nml.${name}) then cat >> ${fimods} << EOF2 # set_nml.${name} + EOF2 - if ("${skip_parse_namelist}" == "true") then - # need to make sure the decomp info from the set_nml is picked up. each case - # has a slightly different decomp that is independent of the ice_in_save file. - # compute that then overwrite by set_nml as needed. - grep -i "distribution_type" ${ICE_SCRIPTS}/options/set_nml.${name} >> ${fimods} - grep -i "processor_shape" ${ICE_SCRIPTS}/options/set_nml.${name} >> ${fimods} - cat >> ${fimods} << EOF2 -# using saved ice_in -EOF2 - else - cat ${ICE_SCRIPTS}/options/set_nml.${name} >> ${fimods} - cat >> ${fimods} << EOF2 + cat ${ICE_SCRIPTS}/options/set_nml.${name} >> ${fimods} + cat >> ${fimods} << EOF2 + EOF2 - endif echo "adding namelist mods set_nml.${name}" echo "`date` ${0} adding namelist modes set_nml.${name}" >> ${casedir}/README.case set found = 1 endif - if (-e ${ICE_SCRIPTS}/options/set_env.${name}) then cat >> ${fsmods} << EOF2 # set_env.${name} + EOF2 cat ${ICE_SCRIPTS}/options/set_env.${name} >> ${fsmods} cat >> ${fsmods} << EOF2 + EOF2 echo "adding env mods set_env.${name}" echo "`date` ${0} adding namelist modes set_env.${name}" >> ${casedir}/README.case set found = 1 endif - if (${found} == 0) then echo "${0}: ERROR, ${ICE_SCRIPTS}/options/set_[nml,env].${name} not found" exit -1 endif end -#set pd1 = `date -u "+%s%N"` -#@ pdd = ( $pd1 - $pd0 ) / 1000000 -#echo "tcxp b4 parse $pdd" ${casescr}/parse_settings.sh cice.settings ${fsmods} - if ($status != 0) then - echo "${0}: ERROR, parse_settings.sh aborted" - exit -1 - endif ${casescr}/parse_namelist.sh ice_in ${fimods} if ($status != 0) then echo "${0}: ERROR, parse_namelist.sh aborted" @@ -1115,20 +978,6 @@ EOF2 source ./cice.settings source ./env.${machcomp} -nomodules || exit 2 ${casescr}/parse_namelist_from_env.sh ice_in - if ($status != 0) then - echo "${0}: ERROR, parse_namelist_from_env.sh aborted" - exit -1 - endif -#set pd1 = `date -u "+%s%N"` -#@ pdd = ( $pd1 - $pd0 ) / 1000000 -#echo "tcxp after parse $pdd" - - # Save ice_in in the suite to reduce time spent in parse_namelist - if (${dosuite} == 1) then - if !(-e ${iceinfn}) then - cp ice_in ${iceinfn} - endif - endif #------------------------------------------------------------ # Generate run script @@ -1170,14 +1019,6 @@ EOF mkdir ${testname_base}/codecov_output cp ${rundir}/compile/*.{gcno,gcda} ${testname_base}/codecov_output/ -EOF - - cat >> ${tsdir}/report_lcov.csh << EOF -lcov --gcov-tool gcov -c -d ${rundir}/compile -o ${testname_base}/lcov.info -if (-s ${testname_base}/lcov.info) then - set lcovalist = "\${lcovalist} -a ${testname_base}/lcov.info" -endif - EOF cat >> ${tsdir}/suite.submit << EOF @@ -1186,26 +1027,19 @@ echo "-------test--------------" echo "${testname_base}" cd ${testname_base} source ./cice.settings -set bldstat = 0 if (\${dobuild} == true) then if (\${doreuse} == true) then - set ciceexe = "../ciceexe.\${ICE_TARGET}.\${ICE_ENVNAME}.\${ICE_COMMDIR}.\${ICE_BLDDEBUG}.\${ICE_THREADED}.\${ICE_IOTYPE}" + set ciceexe = "../ciceexe.\${ICE_COMPILER}.\${ICE_COMMDIR}.\${ICE_BLDDEBUG}.\${ICE_THREADED}.\${ICE_IOTYPE}" ./cice.build --exe \${ciceexe} - set bldstat = \${status} if !(-e \${ciceexe}) cp -p \${ICE_RUNDIR}/cice \${ciceexe} else ./cice.build - set bldstat = \${status} endif endif -if (\$bldstat == 0) then - if (\${dosubmit} == true) then - set jobid = \`./cice.submit\` - echo "\$jobid" - echo "\$jobid \${ICE_TESTNAME} " >> ../suite.jobs - else if (\${dorun} == true) then - ./cice.test - endif +if (\${dosubmit} == true) then + ./cice.submit | tee -a ../suite.jobs +else if (\${dorun} == true) then + ./cice.test endif cd .. EOF @@ -1218,13 +1052,9 @@ EOF echo "" endif -#set pd1 = `date -u "+%s%N"` -#@ pdd = ( $pd1 - $pd0 ) / 1000000 -#echo "tcxp case done $pdd" - # This is the foreach end for the testsuite end -# This is the foreach end for the envnames +# This is the foreach end for the compilers end #----------------------------------------------------- @@ -1236,11 +1066,63 @@ if ( ${dosuite} == 1 ) then cat >> ${tsdir}/suite.submit << EOF0 set nonomatch && rm -f ciceexe.* && unset nonomatch -set nonomatch && rm -f ice_in_save* && unset nonomatch EOF0 - # Add code to post processing scripts + # Add code to results.csh to count the number of failures + cat >> ${tsdir}/results.csh << EOF +cat ./results.log +set pends = \`cat ./results.log | grep PEND | wc -l\` +set misses = \`cat ./results.log | grep MISS | wc -l\` +set failures = \`cat ./results.log | grep FAIL | wc -l\` +set failbuild = \`cat ./results.log | grep FAIL | grep " build " | wc -l\` +set failrun = \`cat ./results.log | grep FAIL | grep " run " | wc -l\` +set failtest = \`cat ./results.log | grep FAIL | grep " test " | wc -l\` +set failcomp = \`cat ./results.log | grep FAIL | grep " compare " | wc -l\` +set failbfbc = \`cat ./results.log | grep FAIL | grep " bfbcomp " | wc -l\` +set failgen = \`cat ./results.log | grep FAIL | grep " generate " | wc -l\` +set success = \`cat ./results.log | grep 'PASS\|COPY' | wc -l\` +set comments = \`cat ./results.log | grep "#" | wc -l\` +set alltotal = \`cat ./results.log | wc -l\` +@ total = \$alltotal - \$comments +@ chkcnt = \$pends + \$misses + \$failures + \$success + +echo "#------- " >> results.log +echo " " >> results.log +echo "#totl = \$total total" >> results.log +echo "#chkd = \$chkcnt checked" >> results.log +echo "#pass = \$success" >> results.log +echo "#pend = \$pends" >> results.log +echo "#miss = \$misses" >> results.log +echo "#fail = \$failures" >> results.log +echo " #failbuild = \$failbuild" >> results.log +echo " #failrun = \$failrun" >> results.log +echo " #failtest = \$failtest" >> results.log +echo " #failcomp = \$failcomp" >> results.log +echo " #failbfbc = \$failbfbc" >> results.log +echo " #failgen = \$failgen" >> results.log + +echo "" +echo "Descriptors:" +echo " PASS - successful completion" +echo " COPY - previously compiled code was copied for new test" +echo " MISS - comparison data is missing" +echo " PEND - status is undertermined; test may still be queued, running, or timed out" +echo " FAIL - test failed" +echo "" +echo "\$chkcnt measured results of \$total total results" +echo "\$success of \$chkcnt tests PASSED" +echo "\$pends of \$chkcnt tests PENDING" +echo "\$misses of \$chkcnt tests MISSING data" +echo "\$failures of \$chkcnt tests FAILED" +#echo " \$failbuild of \$failures FAILED build" +#echo " \$failrun of \$failures FAILED run" +#echo " \$failtest of \$failures FAILED test" +#echo " \$failcomp of \$failures FAILED compare" +#echo " \$failbfbc of \$failures FAILED bfbcomp" +#echo " \$failgen of \$failures FAILED generate" +exit \$failures +EOF if ($?ICE_MACHINE_QSTAT) then cat >! ${tsdir}/poll_queue.env << EOF0 @@ -1248,11 +1130,19 @@ setenv ICE_MACHINE_QSTAT ${ICE_MACHINE_QSTAT} EOF0 endif - cat ${casescr}/cice.results.csh >> ${tsdir}/results.csh +cat >> ${tsdir}/report_codecov.csh << EOF +source ${ICE_SCRIPTS}/machines/env.${machcomp} - cat ${casescr}/cice.codecov.csh >> ${tsdir}/report_codecov.csh +if ( \${use_curl} == 1 ) then + bash -c "bash <(curl -s https://codecov.io/bash) -n '\${report_name}' -y ./codecov.yml " +else + bash -c "bash <(wget -O - https://codecov.io/bash) -n '\${report_name}' -y ./codecov.yml " +endif - cat ${casescr}/cice.lcov.csh >> ${tsdir}/report_lcov.csh +sleep 10 +rm -r -f ./*/codecov_output + +EOF # build and submit tests cd ${tsdir} @@ -1267,11 +1157,10 @@ EOF0 ./results.csh ./report_results.csh endif - if ($coverage == 1) then - echo "Generating coverage reports" + if ($codecov == 1) then + echo "Generating codecov reports" ./poll_queue.csh - ./report_lcov.csh - #./report_codecov.csh + ./report_codecov.csh endif cd ${ICE_SANDBOX} @@ -1279,10 +1168,6 @@ endif #--------------------------------------------- -#set pd1 = `date -u "+%s%N"` -#@ pdd = ( $pd1 - $pd0 ) / 1000000 -#echo "tcxp done $pdd" - echo " " echo "${0} done" echo " " diff --git a/cicecore/cicedyn/analysis/ice_diagnostics.F90 b/cicecore/cicedyn/analysis/ice_diagnostics.F90 index 395cca98d..40da6cb64 100644 --- a/cicecore/cicedyn/analysis/ice_diagnostics.F90 +++ b/cicecore/cicedyn/analysis/ice_diagnostics.F90 @@ -11,11 +11,9 @@ module ice_diagnostics use ice_kinds_mod - use ice_blocks, only: nx_block, ny_block use ice_communicate, only: my_task, master_task use ice_constants, only: c0, c1 use ice_calendar, only: istep1 - use ice_domain_size, only: nslyr use ice_fileunits, only: nu_diag use ice_fileunits, only: flush_fileunit use ice_exit, only: abort_ice @@ -27,8 +25,9 @@ module ice_diagnostics implicit none private - public :: runtime_diags, init_mass_diags, init_diags, debug_ice, & - print_state, diagnostic_abort + public :: runtime_diags, init_mass_diags, init_diags, & + print_state, print_points_state, diagnostic_abort + ! diagnostic output file character (len=char_len), public :: diag_file @@ -36,13 +35,9 @@ module ice_diagnostics ! point print data logical (kind=log_kind), public :: & - debug_model , & ! if true, debug model at high level print_points , & ! if true, print point data print_global ! if true, print global data - integer (kind=int_kind), public :: & - debug_model_step = 0 ! begin printing at istep1=debug_model_step - integer (kind=int_kind), parameter, public :: & npnt = 2 ! total number of points to be printed @@ -53,7 +48,7 @@ module ice_diagnostics real (kind=dbl_kind), parameter :: & umax_stab = 1.0_dbl_kind , & ! ice speed threshold for instability (m/s) aice_extmin = 0.15_dbl_kind ! min aice value for ice extent calc - + real (kind=dbl_kind), dimension(npnt), public :: & latpnt , & ! latitude of diagnostic points lonpnt ! longitude of diagnostic points @@ -75,20 +70,12 @@ module ice_diagnostics integer (kind=int_kind), dimension(npnt), public :: & piloc, pjloc, pbloc, pmloc ! location of diagnostic points - integer (kind=int_kind), public :: & - debug_model_i = -1, & ! location of debug_model point, local i index - debug_model_j = -1, & ! location of debug_model point, local j index - debug_model_iblk = -1, & ! location of debug_model point, local block number - debug_model_task = -1 ! location of debug_model point, local task number - ! for hemispheric water and heat budgets real (kind=dbl_kind) :: & totmn , & ! total ice/snow water mass (nh) totms , & ! total ice/snow water mass (sh) totmin , & ! total ice water mass (nh) totmis , & ! total ice water mass (sh) - totsn , & ! total salt mass (nh) - totss , & ! total salt mass (sh) toten , & ! total ice/snow energy (J) totes ! total ice/snow energy (J) @@ -100,6 +87,16 @@ module ice_diagnostics totaeron , & ! total aerosol mass totaeros ! total aerosol mass + ! printing info for routine print_state + ! iblkp, ip, jp, mtask identify the grid cell to print +! character (char_len) :: plabel + integer (kind=int_kind), parameter, public :: & + check_step = 999999999, & ! begin printing at istep1=check_step + iblkp = 1, & ! block number + ip = 72, & ! i index + jp = 11, & ! j index + mtask = 0 ! my_task + !======================================================================= contains @@ -115,6 +112,7 @@ module ice_diagnostics subroutine runtime_diags (dt) use ice_arrays_column, only: floe_rad_c + use ice_blocks, only: nx_block, ny_block use ice_broadcast, only: broadcast_scalar use ice_constants, only: c1, c1000, c2, p001, p5, & field_loc_center, m2_to_km2 @@ -129,7 +127,7 @@ subroutine runtime_diags (dt) alvdr_init, alvdf_init, alidr_init, alidf_init use ice_flux_bgc, only: faero_atm, faero_ocn, fiso_atm, fiso_ocn use ice_global_reductions, only: global_sum, global_sum_prod, global_maxval - use ice_grid, only: lmask_n, lmask_s, tarean, tareas, grid_ice, grid_average_X2Y + use ice_grid, only: lmask_n, lmask_s, tarean, tareas use ice_state ! everything ! tcraig, this is likely to cause circular dependency because ice_prescribed_mod is high level routine #ifdef CESMCOUPLED @@ -145,29 +143,23 @@ subroutine runtime_diags (dt) i, j, k, n, iblk, nc, & ktherm, & nt_tsfc, nt_aero, nt_fbri, nt_apnd, nt_hpnd, nt_fsd, & - nt_isosno, nt_isoice, nt_rsnw, nt_rhos, nt_smice, nt_smliq + nt_isosno, nt_isoice logical (kind=log_kind) :: & - tr_pond_topo, tr_brine, tr_iso, tr_aero, calc_Tsfc, tr_fsd, & - tr_snow, snwgrain + tr_pond_topo, tr_brine, tr_iso, tr_aero, calc_Tsfc, tr_fsd real (kind=dbl_kind) :: & rhow, rhos, rhoi, puny, awtvdr, awtidr, awtvdf, awtidf, & rhofresh, lfresh, lvap, ice_ref_salinity, Tffresh - character (len=char_len) :: & - snwredist, saltflux_option - ! hemispheric state quantities real (kind=dbl_kind) :: & umaxn, hmaxn, shmaxn, arean, snwmxn, extentn, shmaxnt, & umaxs, hmaxs, shmaxs, areas, snwmxs, extents, shmaxst, & etotn, mtotn, micen, msnwn, pmaxn, ketotn, & etots, mtots, mices, msnws, pmaxs, ketots, & - stotn, & - stots, & urmsn, albtotn, arean_alb, mpndn, ptotn, spondn, & - urmss, albtots, areas_alb, mpnds, ptots, sponds + urmss, albtots, areas_alb, mpnds, ptots, sponds ! hemispheric flux quantities real (kind=dbl_kind) :: & @@ -195,42 +187,28 @@ subroutine runtime_diags (dt) ! fields at diagnostic points real (kind=dbl_kind), dimension(npnt) :: & - paice, pTair, pQa, pfsnow, pfrain, pfsw, pflw, & + paice, pTair, pQa, pfsnow, pfrain, pfsw, pflw, & pTsfc, pevap, pfswabs, pflwout, pflat, pfsens, & pfsurf, pfcondtop, psst, psss, pTf, hiavg, hsavg, hbravg, & pfhocn, psalt, fsdavg, & - pmeltt, pmeltb, pmeltl, psnoice, pdsnow, pfrazil, pcongel, & - prsnwavg, prhosavg, psmicetot, psmliqtot, psmtot + pmeltt, pmeltb, pmeltl, psnoice, pdsnow, pfrazil, pcongel real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks) :: & - uvelT, vvelT, & ! u,v on T points - work1, work2 ! temporary - - real (kind=dbl_kind), parameter :: & - maxval_spval = -0.9_dbl_kind*HUGE(0.0_dbl_kind) ! spval to detect - ! undefined values returned from global_maxval. if global_maxval - ! is applied to a region that does not exist (for instance - ! southern hemisphere in box cases), global_maxval - ! returns -HUGE which we want to avoid writing. The - ! return value is checked against maxval_spval before writing. + work1, work2 character(len=*), parameter :: subname = '(runtime_diags)' call icepack_query_parameters(ktherm_out=ktherm, calc_Tsfc_out=calc_Tsfc) call icepack_query_tracer_flags(tr_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_pond_topo_out=tr_pond_topo, tr_fsd_out=tr_fsd, tr_iso_out=tr_iso, & - tr_snow_out=tr_snow) + tr_pond_topo_out=tr_pond_topo, tr_fsd_out=tr_fsd, tr_iso_out=tr_iso) call icepack_query_tracer_indices(nt_fbri_out=nt_fbri, nt_Tsfc_out=nt_Tsfc, & nt_aero_out=nt_aero, nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, & - nt_fsd_out=nt_fsd,nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice, & - nt_rsnw_out=nt_rsnw, nt_rhos_out=nt_rhos, & - nt_smice_out=nt_smice, nt_smliq_out=nt_smliq) + nt_fsd_out=nt_fsd,nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) call icepack_query_parameters(Tffresh_out=Tffresh, rhos_out=rhos, & rhow_out=rhow, rhoi_out=rhoi, puny_out=puny, & awtvdr_out=awtvdr, awtidr_out=awtidr, awtvdf_out=awtvdf, awtidf_out=awtidf, & rhofresh_out=rhofresh, lfresh_out=lfresh, lvap_out=lvap, & - ice_ref_salinity_out=ice_ref_salinity,snwredist_out=snwredist, & - snwgrain_out=snwgrain, saltflux_option_out=saltflux_option) + ice_ref_salinity_out=ice_ref_salinity) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) @@ -241,8 +219,6 @@ subroutine runtime_diags (dt) ! hemispheric quantities ! total ice area - arean = c0 - areas = c0 arean = global_sum(aice, distrb_info, field_loc_center, tarean) areas = global_sum(aice, distrb_info, field_loc_center, tareas) arean = arean * m2_to_km2 @@ -259,22 +235,18 @@ subroutine runtime_diags (dt) enddo enddo !$OMP END PARALLEL DO - extentn = c0 - extents = c0 - extentn = global_sum(work1, distrb_info, field_loc_center, tarean) - extents = global_sum(work1, distrb_info, field_loc_center, tareas) + extentn = global_sum(work1, distrb_info, field_loc_center, & + tarean) + extents = global_sum(work1, distrb_info, field_loc_center, & + tareas) extentn = extentn * m2_to_km2 extents = extents * m2_to_km2 ! total ice volume - shmaxn = c0 - shmaxs = c0 shmaxn = global_sum(vice, distrb_info, field_loc_center, tarean) shmaxs = global_sum(vice, distrb_info, field_loc_center, tareas) ! total snow volume - snwmxn = c0 - snwmxs = c0 snwmxn = global_sum(vsno, distrb_info, field_loc_center, tarean) snwmxs = global_sum(vsno, distrb_info, field_loc_center, tareas) @@ -284,47 +256,35 @@ subroutine runtime_diags (dt) if (tr_pond_topo) then !$OMP PARALLEL DO PRIVATE(iblk,i,j,n) do iblk = 1, nblocks - do j = 1, ny_block - do i = 1, nx_block - work1(i,j,iblk) = c0 - do n = 1, ncat - work1(i,j,iblk) = work1(i,j,iblk) & - + aicen(i,j,n,iblk) & - * trcrn(i,j,nt_apnd,n,iblk) & - * trcrn(i,j,nt_hpnd,n,iblk) - enddo - enddo + do j = 1, ny_block + do i = 1, nx_block + work1(i,j,iblk) = c0 + do n = 1, ncat + work1(i,j,iblk) = work1(i,j,iblk) & + + aicen(i,j,n,iblk) & + * trcrn(i,j,nt_apnd,n,iblk) & + * trcrn(i,j,nt_hpnd,n,iblk) enddo enddo + enddo + enddo !$OMP END PARALLEL DO ptotn = global_sum(work1, distrb_info, field_loc_center, tarean) ptots = global_sum(work1, distrb_info, field_loc_center, tareas) endif - ! total ice-snow kinetic energy, on T points. - if (grid_ice == 'B') then - call grid_average_X2Y('A',uvel ,'U',uvelT,'T') - call grid_average_X2Y('A',vvel ,'U',vvelT,'T') - elseif (grid_ice == 'C') then - call grid_average_X2Y('A',uvelE,'E',uvelT,'T') - call grid_average_X2Y('A',vvelN,'N',vvelT,'T') - elseif (grid_ice == 'CD') then - call grid_average_X2Y('A',uvelE,'E',uvelN,'N',uvelT,'T') - call grid_average_X2Y('A',vvelE,'E',vvelN,'N',vvelT,'T') - endif - + ! total ice-snow kinetic energy !$OMP PARALLEL DO PRIVATE(iblk,i,j) do iblk = 1, nblocks do j = 1, ny_block do i = 1, nx_block - work1(i,j,iblk) = p5 * (rhos*vsno(i,j,iblk) + rhoi*vice(i,j,iblk)) & - * (uvelT(i,j,iblk)**2 + vvelT(i,j,iblk)**2) + work1(i,j,iblk) = p5 & + * (rhos*vsno(i,j,iblk) + rhoi*vice(i,j,iblk)) & + * (uvel(i,j,iblk)**2 + vvel(i,j,iblk)**2) enddo enddo enddo !$OMP END PARALLEL DO - ketotn = c0 - ketots = c0 ketotn = global_sum(work1, distrb_info, field_loc_center, tarean) ketots = global_sum(work1, distrb_info, field_loc_center, tareas) @@ -363,8 +323,8 @@ subroutine runtime_diags (dt) enddo enddo !$OMP END PARALLEL DO - - arean_alb = global_sum(aice, distrb_info, field_loc_center, work2) + + arean_alb = global_sum(aice, distrb_info, field_loc_center, work2) albtotn = global_sum_prod(aice, work1, distrb_info, & field_loc_center, work2) @@ -389,7 +349,7 @@ subroutine runtime_diags (dt) enddo !$OMP END PARALLEL DO - areas_alb = global_sum(aice, distrb_info, field_loc_center, work2) + areas_alb = global_sum(aice, distrb_info, field_loc_center, work2) albtots = global_sum_prod(aice, work1, distrb_info, & field_loc_center, work2) @@ -401,57 +361,23 @@ subroutine runtime_diags (dt) endif ! maximum ice volume (= mean thickness including open water) - hmaxn = c0 - hmaxs = c0 hmaxn = global_maxval(vice, distrb_info, lmask_n) hmaxs = global_maxval(vice, distrb_info, lmask_s) - if (hmaxn < maxval_spval) hmaxn = c0 - if (hmaxs < maxval_spval) hmaxs = c0 ! maximum ice speed - if (grid_ice == 'CD') then - !$OMP PARALLEL DO PRIVATE(iblk,i,j) - do iblk = 1, nblocks - do j = 1, ny_block - do i = 1, nx_block - work1(i,j,iblk) = max(sqrt(uvelE(i,j,iblk)**2 + vvelE(i,j,iblk)**2), & - sqrt(uvelN(i,j,iblk)**2 + vvelN(i,j,iblk)**2)) - enddo - enddo - enddo - !$OMP END PARALLEL DO - elseif (grid_ice == 'C') then - ! map uvelE to N and vvelN to E then compute max on E and N - call grid_average_X2Y('A',uvelE,'E',work1,'N') ! work1 =~ uvelN - call grid_average_X2Y('A',vvelN,'N',work2,'E') ! work2 =~ vvelE - !$OMP PARALLEL DO PRIVATE(iblk,i,j) - do iblk = 1, nblocks - do j = 1, ny_block - do i = 1, nx_block - work1(i,j,iblk) = max(sqrt(uvelE(i,j,iblk)**2 + work2(i,j,iblk)**2), & - sqrt(work1(i,j,iblk)**2 + vvelN(i,j,iblk)**2)) - enddo - enddo + !$OMP PARALLEL DO PRIVATE(iblk,i,j) + do iblk = 1, nblocks + do j = 1, ny_block + do i = 1, nx_block + work1(i,j,iblk) = sqrt(uvel(i,j,iblk)**2 & + + vvel(i,j,iblk)**2) enddo - !$OMP END PARALLEL DO - else - !$OMP PARALLEL DO PRIVATE(iblk,i,j) - do iblk = 1, nblocks - do j = 1, ny_block - do i = 1, nx_block - work1(i,j,iblk) = sqrt(uvel(i,j,iblk)**2 + vvel(i,j,iblk)**2) - enddo - enddo enddo - !$OMP END PARALLEL DO - endif + enddo + !$OMP END PARALLEL DO - umaxn = c0 - umaxs = c0 umaxn = global_maxval(work1, distrb_info, lmask_n) umaxs = global_maxval(work1, distrb_info, lmask_s) - if (umaxn < maxval_spval) umaxn = c0 - if (umaxs < maxval_spval) umaxs = c0 ! Write warning message if ice speed is too big ! (Ice speeds of ~1 m/s or more usually indicate instability) @@ -460,31 +386,31 @@ subroutine runtime_diags (dt) if (umaxn > umax_stab) then !$OMP PARALLEL DO PRIVATE(iblk,i,j) do iblk = 1, nblocks - do j = 1, ny_block - do i = 1, nx_block - if (abs(work1(i,j,iblk) - umaxn) < puny) then - write(nu_diag,*) ' ' - write(nu_diag,*) 'Warning, large ice speed' - write(nu_diag,*) 'my_task, iblk, i, j, umaxn:', & - my_task, iblk, i, j, umaxn - endif - enddo - enddo + do j = 1, ny_block + do i = 1, nx_block + if (abs(work1(i,j,iblk) - umaxn) < puny) then + write(nu_diag,*) ' ' + write(nu_diag,*) 'Warning, large ice speed' + write(nu_diag,*) 'my_task, iblk, i, j, umaxn:', & + my_task, iblk, i, j, umaxn + endif + enddo + enddo enddo !$OMP END PARALLEL DO elseif (umaxs > umax_stab) then !$OMP PARALLEL DO PRIVATE(iblk,i,j) do iblk = 1, nblocks - do j = 1, ny_block - do i = 1, nx_block - if (abs(work1(i,j,iblk) - umaxs) < puny) then - write(nu_diag,*) ' ' - write(nu_diag,*) 'Warning, large ice speed' - write(nu_diag,*) 'my_task, iblk, i, j, umaxs:', & - my_task, iblk, i, j, umaxs - endif - enddo - enddo + do j = 1, ny_block + do i = 1, nx_block + if (abs(work1(i,j,iblk) - umaxs) < puny) then + write(nu_diag,*) ' ' + write(nu_diag,*) 'Warning, large ice speed' + write(nu_diag,*) 'my_task, iblk, i, j, umaxs:', & + my_task, iblk, i, j, umaxs + endif + enddo + enddo enddo !$OMP END PARALLEL DO endif ! umax @@ -492,37 +418,22 @@ subroutine runtime_diags (dt) ! maximum ice strength - pmaxn = c0 - pmaxs = c0 pmaxn = global_maxval(strength, distrb_info, lmask_n) pmaxs = global_maxval(strength, distrb_info, lmask_s) - if (pmaxn < maxval_spval) pmaxn = c0 - if (pmaxs < maxval_spval) pmaxs = c0 pmaxn = pmaxn / c1000 ! convert to kN/m - pmaxs = pmaxs / c1000 + pmaxs = pmaxs / c1000 if (print_global) then ! total ice/snow internal energy call total_energy (work1) - - etotn = c0 - etots = c0 + etotn = global_sum(work1, distrb_info, & field_loc_center, tarean) etots = global_sum(work1, distrb_info, & field_loc_center, tareas) - ! total salt volume - call total_salt (work2) - - stotn = global_sum(work2, distrb_info, & - field_loc_center, tarean) - stots = global_sum(work2, distrb_info, & - field_loc_center, tareas) - - !----------------------------------------------------------------- ! various fluxes !----------------------------------------------------------------- @@ -532,8 +443,6 @@ subroutine runtime_diags (dt) ! evaporation - evpn = c0 - evps = c0 evpn = global_sum_prod(evap, aice, distrb_info, & field_loc_center, tarean) evps = global_sum_prod(evap, aice, distrb_info, & @@ -552,8 +461,6 @@ subroutine runtime_diags (dt) endif ! salt flux - sfsaltn = c0 - sfsalts = c0 sfsaltn = global_sum(fsalt_ai, distrb_info, & field_loc_center, tarean) sfsalts = global_sum(fsalt_ai, distrb_info, & @@ -562,8 +469,6 @@ subroutine runtime_diags (dt) sfsalts = sfsalts*dt ! fresh water flux - sfreshn = c0 - sfreshs = c0 sfreshn = global_sum(fresh_ai, distrb_info, & field_loc_center, tarean) sfreshs = global_sum(fresh_ai, distrb_info, & @@ -585,8 +490,6 @@ subroutine runtime_diags (dt) ! ocean heat ! Note: fswthru not included because it does not heat ice - fhocnn = c0 - fhocns = c0 fhocnn = global_sum(fhocn_ai, distrb_info, & field_loc_center, tarean) fhocns = global_sum(fhocn_ai, distrb_info, & @@ -620,14 +523,14 @@ subroutine runtime_diags (dt) enddo !$OMP END PARALLEL DO - else ! fsurf is computed by atmosphere model + else ! fsurf is computed by atmosphere model !$OMP PARALLEL DO PRIVATE(iblk,i,j) do iblk = 1, nblocks do j = 1, ny_block do i = 1, nx_block work1(i,j,iblk) = & - (fsurf(i,j,iblk) - flat(i,j,iblk)) & + (fsurf(i,j,iblk) - flat(i,j,iblk)) & * aice(i,j,iblk) enddo enddo @@ -636,13 +539,11 @@ subroutine runtime_diags (dt) endif ! calc_Tsfc - fhatmn = c0 - fhatms = c0 fhatmn = global_sum(work1, distrb_info, & field_loc_center, tarean) fhatms = global_sum(work1, distrb_info, & field_loc_center, tareas) - + !$OMP PARALLEL DO PRIVATE(iblk,i,j) do iblk = 1, nblocks do j = 1, ny_block @@ -654,8 +555,6 @@ subroutine runtime_diags (dt) enddo !$OMP END PARALLEL DO - fswnetn = c0 - fswnets = c0 fswnetn = global_sum(work1, distrb_info, & field_loc_center, tarean) fswnets = global_sum(work1, distrb_info, & @@ -674,8 +573,6 @@ subroutine runtime_diags (dt) enddo !$OMP END PARALLEL DO - fswdnn = c0 - fswdns = c0 fswdnn = global_sum(work1, distrb_info, & field_loc_center, tarean) fswdns = global_sum(work1, distrb_info, & @@ -691,17 +588,12 @@ subroutine runtime_diags (dt) enddo enddo !$OMP END PARALLEL DO - - fhfrzn = c0 - fhfrzs = c0 fhfrzn = global_sum(work1, distrb_info, & field_loc_center, tarean) fhfrzs = global_sum(work1, distrb_info, & field_loc_center, tareas) ! rain - rnn = c0 - rns = c0 rnn = global_sum_prod(frain, aice_init, distrb_info, & field_loc_center, tarean) rns = global_sum_prod(frain, aice_init, distrb_info, & @@ -710,8 +602,6 @@ subroutine runtime_diags (dt) rns = rns*dt ! snow - snn = c0 - sns = c0 snn = global_sum_prod(fsnow, aice_init, distrb_info, & field_loc_center, tarean) sns = global_sum_prod(fsnow, aice_init, distrb_info, & @@ -724,8 +614,6 @@ subroutine runtime_diags (dt) work1(:,:,:) = frazil(:,:,:)*rhoi/dt if (ktherm == 2 .and. .not.update_ocn_f) & work1(:,:,:) = (frazil(:,:,:)-frazil_diag(:,:,:))*rhoi/dt - frzn = c0 - frzs = c0 frzn = global_sum(work1, distrb_info, & field_loc_center, tarean) frzs = global_sum(work1, distrb_info, & @@ -744,7 +632,7 @@ subroutine runtime_diags (dt) ! total ice, snow and pond mass mtotn = micen + msnwn + mpndn mtots = mices + msnws + mpnds - + ! mass change since beginning of time step delmin = mtotn - totmn delmis = mtots - totms @@ -763,14 +651,14 @@ subroutine runtime_diags (dt) fluxs = c0 if( arean > c0) then ! water associated with frazil ice included in fresh - fluxn = rnn + snn + evpn - sfreshn + fluxn = rnn + snn + evpn - sfreshn if (.not. update_ocn_f) then fluxn = fluxn + frzn endif endif if( areas > c0) then ! water associated with frazil ice included in fresh - fluxs = rns + sns + evps - sfreshs + fluxs = rns + sns + evps - sfreshs if (.not. update_ocn_f) then fluxs = fluxs + frzs endif @@ -796,22 +684,12 @@ subroutine runtime_diags (dt) swerrs = (fswnets - fswdns) / (fswnets - c1) ! salt mass - if (saltflux_option == 'prognostic') then - ! compute the total salt mass - msltn = stotn*rhoi*p001 - mslts = stots*rhoi*p001 - - ! change in salt mass - delmsltn = rhoi*(stotn-totsn)*p001 - delmslts = rhoi*(stots-totss)*p001 - else - msltn = micen*ice_ref_salinity*p001 - mslts = mices*ice_ref_salinity*p001 + msltn = micen*ice_ref_salinity*p001 + mslts = mices*ice_ref_salinity*p001 - ! change in salt mass - delmsltn = delmxn*ice_ref_salinity*p001 - delmslts = delmxs*ice_ref_salinity*p001 - endif + ! change in salt mass + delmsltn = delmxn*ice_ref_salinity*p001 + delmslts = delmxs*ice_ref_salinity*p001 ! salt error serrn = (sfsaltn + delmsltn) / (msltn + c1) @@ -819,16 +697,6 @@ subroutine runtime_diags (dt) ! isotopes if (tr_iso) then - fisoan = c0 - fisoas = c0 - fisoon = c0 - fisoos = c0 - isototn = c0 - isotots = c0 - isomx1n = c0 - isomx1s = c0 - isorn = c0 - isors = c0 do n = 1, n_iso fisoan(n) = global_sum_prod(fiso_atm(:,:,n,:), aice_init, & distrb_info, field_loc_center, tarean) @@ -843,7 +711,7 @@ subroutine runtime_diags (dt) fisoon(n) = fisoon(n)*dt fisoos(n) = fisoos(n)*dt - !$OMP PARALLEL DO PRIVATE(iblk,i,j,k) + !$OMP PARALLEL DO PRIVATE(iblk,i,j) do iblk = 1, nblocks do j = 1, ny_block do i = 1, nx_block @@ -861,8 +729,6 @@ subroutine runtime_diags (dt) isotots(n) = global_sum(work1, distrb_info, field_loc_center, tareas) isomx1n(n) = global_maxval(work1, distrb_info, lmask_n) isomx1s(n) = global_maxval(work1, distrb_info, lmask_s) - if (isomx1n(n) < maxval_spval) isomx1n(n) = c0 - if (isomx1s(n) < maxval_spval) isomx1s(n) = c0 isorn(n) = (totison(n)-isototn(n)+fisoan(n)-fisoon(n))/(isototn(n)+c1) isors(n) = (totisos(n)-isotots(n)+fisoas(n)-fisoos(n))/(isotots(n)+c1) enddo ! n_iso @@ -870,16 +736,6 @@ subroutine runtime_diags (dt) ! aerosols if (tr_aero) then - faeran = c0 - faeras = c0 - faeron = c0 - faeros = c0 - aerototn = c0 - aerotots = c0 - aeromx1n = c0 - aeromx1s = c0 - aerrn = c0 - aerrs = c0 do n = 1, n_aero faeran(n) = global_sum_prod(faero_atm(:,:,n,:), aice_init, & distrb_info, field_loc_center, tarean) @@ -911,8 +767,6 @@ subroutine runtime_diags (dt) aerotots(n) = global_sum(work1, distrb_info, field_loc_center, tareas) aeromx1n(n) = global_maxval(work1, distrb_info, lmask_n) aeromx1s(n) = global_maxval(work1, distrb_info, lmask_s) - if (aeromx1n(n) < maxval_spval) aeromx1n(n) = c0 - if (aeromx1s(n) < maxval_spval) aeromx1s(n) = c0 aerrn(n) = (totaeron(n)-aerototn(n)+faeran(n)-faeron(n)) & / (aerototn(n) + c1) @@ -946,7 +800,7 @@ subroutine runtime_diags (dt) pfsw(n) = fsw(i,j,iblk) ! shortwave radiation pflw(n) = flw(i,j,iblk) ! longwave radiation paice(n) = aice(i,j,iblk) ! ice area - + fsdavg(n) = c0 ! avg floe effective radius hiavg(n) = c0 ! avg snow/ice thickness hsavg(n) = c0 @@ -972,27 +826,6 @@ subroutine runtime_diags (dt) enddo endif endif - if (tr_snow) then ! snow tracer quantities - prsnwavg (n) = c0 ! avg snow grain radius - prhosavg (n) = c0 ! avg snow density - psmicetot(n) = c0 ! total mass of ice in snow (kg/m2) - psmliqtot(n) = c0 ! total mass of liquid in snow (kg/m2) - psmtot (n) = c0 ! total mass of snow volume (kg/m2) - if (vsno(i,j,iblk) > c0) then - do k = 1, nslyr - prsnwavg (n) = prsnwavg (n) + trcr(i,j,nt_rsnw +k-1,iblk) ! snow grain radius - prhosavg (n) = prhosavg (n) + trcr(i,j,nt_rhos +k-1,iblk) ! compacted snow density - psmicetot(n) = psmicetot(n) + trcr(i,j,nt_smice+k-1,iblk) * vsno(i,j,iblk) - psmliqtot(n) = psmliqtot(n) + trcr(i,j,nt_smliq+k-1,iblk) * vsno(i,j,iblk) - end do - endif - psmtot (n) = rhos * vsno(i,j,iblk) ! mass of ice in standard density snow - prsnwavg (n) = prsnwavg (n) / real(nslyr,kind=dbl_kind) ! snow grain radius - prhosavg (n) = prhosavg (n) / real(nslyr,kind=dbl_kind) ! compacted snow density - psmicetot(n) = psmicetot(n) / real(nslyr,kind=dbl_kind) ! mass of ice in snow - psmliqtot(n) = psmliqtot(n) / real(nslyr,kind=dbl_kind) ! mass of liquid in snow - end if - psalt(n) = c0 if (vice(i,j,iblk) /= c0) psalt(n) = work2(i,j,iblk)/vice(i,j,iblk) pTsfc(n) = trcr(i,j,nt_Tsfc,iblk) ! ice/snow sfc temperature pevap(n) = evap(i,j,iblk)*dt/rhoi ! sublimation/condensation @@ -1011,7 +844,7 @@ subroutine runtime_diags (dt) pcongel(n) = congel(i,j,iblk) ! congelation ice pdhi(n) = vice(i,j,iblk) - pdhi(n) ! ice thickness change pdhs(n) = vsno(i,j,iblk) - pdhs(n) ! snow thickness change - pde(n) =-(work1(i,j,iblk)- pde(n))/dt ! ice/snow energy change + pde(n) =-(work1(i,j,iblk)- pde(n))/dt ! ice/snow energy change psst(n) = sst(i,j,iblk) ! sea surface temperature psss(n) = sss(i,j,iblk) ! sea surface salinity pTf(n) = Tf(i,j,iblk) ! freezing temperature @@ -1044,11 +877,6 @@ subroutine runtime_diags (dt) call broadcast_scalar(pmeltl (n), pmloc(n)) call broadcast_scalar(psnoice (n), pmloc(n)) call broadcast_scalar(pdsnow (n), pmloc(n)) - call broadcast_scalar(psmtot (n), pmloc(n)) - call broadcast_scalar(prsnwavg (n), pmloc(n)) - call broadcast_scalar(prhosavg (n), pmloc(n)) - call broadcast_scalar(psmicetot(n), pmloc(n)) - call broadcast_scalar(psmliqtot(n), pmloc(n)) call broadcast_scalar(pfrazil (n), pmloc(n)) call broadcast_scalar(pcongel (n), pmloc(n)) call broadcast_scalar(pdhi (n), pmloc(n)) @@ -1058,7 +886,7 @@ subroutine runtime_diags (dt) call broadcast_scalar(psss (n), pmloc(n)) call broadcast_scalar(pTf (n), pmloc(n)) call broadcast_scalar(pfhocn (n), pmloc(n)) - + enddo ! npnt endif ! print_points @@ -1106,7 +934,7 @@ subroutine runtime_diags (dt) write(nu_diag,901) 'arwt snw mass (kg) = ',msnwn,msnws if (tr_pond_topo) & write(nu_diag,901) 'arwt pnd mass (kg) = ',mpndn,mpnds - + write(nu_diag,901) 'arwt tot mass (kg) = ',mtotn,mtots write(nu_diag,901) 'arwt tot mass chng(kg) = ',delmin,delmis write(nu_diag,901) 'arwt water flux = ',fluxn,fluxs @@ -1232,26 +1060,6 @@ subroutine runtime_diags (dt) write(nu_diag,900) 'effective dhi (m) = ',pdhi(1),pdhi(2) write(nu_diag,900) 'effective dhs (m) = ',pdhs(1),pdhs(2) write(nu_diag,900) 'intnl enrgy chng(W/m^2)= ',pde (1),pde (2) - - if (tr_snow) then - if (trim(snwredist) /= 'none') then - write(nu_diag,900) 'avg snow density(kg/m3)= ',prhosavg(1) & - ,prhosavg(2) - endif - if (snwgrain) then - write(nu_diag,900) 'avg snow grain radius = ',prsnwavg(1) & - ,prsnwavg(2) - write(nu_diag,900) 'mass ice in snow(kg/m2)= ',psmicetot(1) & - ,psmicetot(2) - write(nu_diag,900) 'mass liq in snow(kg/m2)= ',psmliqtot(1) & - ,psmliqtot(2) - write(nu_diag,900) 'mass std snow (kg/m2)= ',psmtot(1) & - ,psmtot(2) - write(nu_diag,900) 'max ice+liq (kg/m2)= ',rhow * hsavg(1) & - ,rhow * hsavg(2) - endif - endif - write(nu_diag,*) '----------ocn----------' write(nu_diag,900) 'sst (C) = ',psst(1),psst(2) write(nu_diag,900) 'sss (ppt) = ',psss(1),psss(2) @@ -1262,6 +1070,9 @@ subroutine runtime_diags (dt) endif ! print_points endif ! my_task = master_task + 799 format (27x,a24) + 800 format (a25,2x,f24.17) + 801 format (a25,2x,1pe24.17) 899 format (27x,a24,2x,a24) 900 format (a25,2x,f24.17,2x,f24.17) 901 format (a25,2x,1pe24.17,2x,1pe24.17) @@ -1278,6 +1089,7 @@ end subroutine runtime_diags subroutine init_mass_diags + use ice_blocks, only: nx_block, ny_block use ice_constants, only: field_loc_center use ice_domain, only: distrb_info, nblocks use ice_domain_size, only: n_iso, n_aero, ncat, max_blocks @@ -1296,7 +1108,7 @@ subroutine init_mass_diags rhoi, rhos, rhofresh real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks) :: & - work1, work2 + work1 character(len=*), parameter :: subname = '(init_mass_diags)' @@ -1331,12 +1143,6 @@ subroutine init_mass_diags toten = global_sum(work1, distrb_info, field_loc_center, tarean) totes = global_sum(work1, distrb_info, field_loc_center, tareas) - ! north/south salt - call total_salt (work2) - totsn = global_sum(work2, distrb_info, field_loc_center, tarean) - totss = global_sum(work2, distrb_info, field_loc_center, tareas) - - if (print_points) then do n = 1, npnt if (my_task == pmloc(n)) then @@ -1353,7 +1159,7 @@ subroutine init_mass_diags if (tr_iso) then do n=1,n_iso - !$OMP PARALLEL DO PRIVATE(iblk,i,j,k) + !$OMP PARALLEL DO PRIVATE(iblk,i,j) do iblk = 1, nblocks do j = 1, ny_block do i = 1, nx_block @@ -1376,14 +1182,14 @@ subroutine init_mass_diags do n=1,n_aero !$OMP PARALLEL DO PRIVATE(iblk,i,j) do iblk = 1, nblocks - do j = 1, ny_block - do i = 1, nx_block - work1(i,j,iblk) = trcr(i,j,nt_aero +4*(n-1),iblk)*vsno(i,j,iblk) & - + trcr(i,j,nt_aero+1+4*(n-1),iblk)*vsno(i,j,iblk) & - + trcr(i,j,nt_aero+2+4*(n-1),iblk)*vice(i,j,iblk) & - + trcr(i,j,nt_aero+3+4*(n-1),iblk)*vice(i,j,iblk) - enddo - enddo + do j = 1, ny_block + do i = 1, nx_block + work1(i,j,iblk) = trcr(i,j,nt_aero +4*(n-1),iblk)*vsno(i,j,iblk) & + + trcr(i,j,nt_aero+1+4*(n-1),iblk)*vsno(i,j,iblk) & + + trcr(i,j,nt_aero+2+4*(n-1),iblk)*vice(i,j,iblk) & + + trcr(i,j,nt_aero+3+4*(n-1),iblk)*vice(i,j,iblk) + enddo + enddo enddo !$OMP END PARALLEL DO totaeron(n)= global_sum(work1, distrb_info, field_loc_center, tarean) @@ -1396,18 +1202,18 @@ subroutine init_mass_diags totps = c0 !$OMP PARALLEL DO PRIVATE(iblk,i,j,n) do iblk = 1, nblocks - do j = 1, ny_block - do i = 1, nx_block - work1(i,j,iblk) = c0 - do n = 1, ncat - work1(i,j,iblk) = work1(i,j,iblk) & - + aicen(i,j,n,iblk) & - * trcrn(i,j,nt_apnd,n,iblk) & - * trcrn(i,j,nt_hpnd,n,iblk) - enddo - enddo + do j = 1, ny_block + do i = 1, nx_block + work1(i,j,iblk) = c0 + do n = 1, ncat + work1(i,j,iblk) = work1(i,j,iblk) & + + aicen(i,j,n,iblk) & + * trcrn(i,j,nt_apnd,n,iblk) & + * trcrn(i,j,nt_hpnd,n,iblk) enddo enddo + enddo + enddo !$OMP END PARALLEL DO totpn = global_sum(work1, distrb_info, field_loc_center, tarean) totps = global_sum(work1, distrb_info, field_loc_center, tareas) @@ -1427,6 +1233,7 @@ end subroutine init_mass_diags subroutine total_energy (work) + use ice_blocks, only: nx_block, ny_block use ice_domain, only: nblocks use ice_domain_size, only: ncat, nilyr, nslyr, max_blocks use ice_grid, only: tmask @@ -1455,6 +1262,7 @@ subroutine total_energy (work) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) +! MHRI: CHECK THIS OMP !$OMP PARALLEL DO PRIVATE(iblk,i,j,n,k,ij,icells,indxi,indxj) do iblk = 1, nblocks @@ -1513,6 +1321,7 @@ end subroutine total_energy subroutine total_salt (work) + use ice_blocks, only: nx_block, ny_block use ice_domain, only: nblocks use ice_domain_size, only: ncat, nilyr, max_blocks use ice_grid, only: tmask @@ -1541,6 +1350,7 @@ subroutine total_salt (work) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) +! MHRI: CHECK THIS OMP !$OMP PARALLEL DO PRIVATE(iblk,i,j,n,k,ij,icells,indxi,indxj) do iblk = 1, nblocks @@ -1629,14 +1439,14 @@ subroutine init_diags write(nu_diag,*) ' Find indices of diagnostic points ' endif - piloc(:) = -1 - pjloc(:) = -1 - pbloc(:) = -1 + piloc(:) = 0 + pjloc(:) = 0 + pbloc(:) = 0 pmloc(:) = -999 plat(:) = -999._dbl_kind plon(:) = -999._dbl_kind - ! find minimum distance to diagnostic points on this processor + ! find minimum distance to diagnostic points on this processor do n = 1, npnt if (lonpnt(n) > c180) lonpnt(n) = lonpnt(n) - c360 @@ -1648,10 +1458,9 @@ subroutine init_diags if (abs(latpnt(n)) < c360 .and. abs(lonpnt(n)) < c360) then ! MDT, 09/2017: Comment out OpenMP directives since loop is not thread-safe - ! This is computing closest point, Could add a CRITICAL but it's just initialization - !!$XXXOMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,latdis,londis,totdis) + !!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,latdis,londis,totdis) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo @@ -1674,11 +1483,11 @@ subroutine init_diags enddo ! i enddo ! j enddo ! iblk - !!$XXXOMP END PARALLEL DO + !!$OMP END PARALLEL DO endif - ! find global minimum distance to diagnostic points + ! find global minimum distance to diagnostic points mindis_g = global_minval(mindis, distrb_info) ! save indices of minimum-distance grid cell @@ -1716,64 +1525,35 @@ end subroutine init_diags !======================================================================= -! This routine is useful for debugging -! author Elizabeth C. Hunke, LANL - - subroutine debug_ice(iblk, plabeld) - - character (char_len), intent(in) :: plabeld - integer (kind=int_kind), intent(in) :: iblk - - ! local - character(len=*), parameter :: subname='(debug_ice)' - - if (istep1 >= debug_model_step) then - - ! set debug point to 1st global point if not set as local values - if (debug_model_i < 0 .and. debug_model_j < 0 .and. & - debug_model_iblk < 0 .and. debug_model_task < 0) then - debug_model_i = piloc(1) - debug_model_j = pjloc(1) - debug_model_task = pmloc(1) - debug_model_iblk = pbloc(1) - endif - - ! if debug point is messed up, abort - if (debug_model_i < 0 .or. debug_model_j < 0 .or. & - debug_model_iblk < 0 .or. debug_model_task < 0) then - call abort_ice (subname//'ERROR: debug_model_[i,j,iblk,mytask] not set correctly') - endif - - ! write out debug info - if (debug_model_iblk == iblk .and. debug_model_task == my_task) then - call print_state(plabeld,debug_model_i,debug_model_j,debug_model_iblk) - endif - - endif - - end subroutine debug_ice - -!======================================================================= - ! This routine is useful for debugging. +! Calls to it should be inserted in the form (after thermo, for example) +! do iblk = 1, nblocks +! do j=jlo,jhi +! do i=ilo,ihi +! plabel = 'post thermo' +! if (istep1 >= check_step .and. iblk==iblkp .and i==ip & +! .and. j==jp .and. my_task == mtask) & +! call print_state(plabel,i,j,iblk) +! enddo +! enddo +! enddo +! +! 'use ice_diagnostics' may need to be inserted also ! author: Elizabeth C. Hunke, LANL subroutine print_state(plabel,i,j,iblk) - use ice_grid, only: grid_ice use ice_blocks, only: block, get_block use ice_domain, only: blocks_ice use ice_domain_size, only: ncat, nilyr, nslyr, nfsd - use ice_grid, only: TLAT, TLON - use ice_state, only: aice, aice0, aicen, vicen, vsnon, uvel, vvel, & - uvelE, vvelE, uvelN, vvelN, trcrn + use ice_state, only: aice0, aicen, vicen, vsnon, uvel, vvel, trcrn use ice_flux, only: uatm, vatm, potT, Tair, Qa, flw, frain, fsnow, & fsens, flat, evap, flwout, swvdr, swvdf, swidr, swidf, rhoa, & - frzmlt, sst, sss, Tf, Tref, Qref, Uref, uocn, vocn, strtltxU, strtltyU + frzmlt, sst, sss, Tf, Tref, Qref, Uref, uocn, vocn, strtltx, strtlty character (len=20), intent(in) :: plabel - integer (kind=int_kind), intent(in) :: & + integer (kind=int_kind), intent(in) :: & i, j , & ! horizontal indices iblk ! block index @@ -1781,25 +1561,23 @@ subroutine print_state(plabel,i,j,iblk) real (kind=dbl_kind) :: & eidebug, esdebug, & - qi, qs, Tsnow, si, & + qi, qs, Tsnow, & rad_to_deg, puny, rhoi, lfresh, rhos, cp_ice integer (kind=int_kind) :: n, k, nt_Tsfc, nt_qice, nt_qsno, nt_fsd, & - nt_isosno, nt_isoice, nt_sice, nt_smice, nt_smliq + nt_isosno, nt_isoice - logical (kind=log_kind) :: tr_fsd, tr_iso, tr_snow + logical (kind=log_kind) :: tr_fsd, tr_iso type (block) :: & this_block ! block information for current block character(len=*), parameter :: subname = '(print_state)' - call icepack_query_tracer_flags(tr_fsd_out=tr_fsd, tr_iso_out=tr_iso, & - tr_snow_out=tr_snow) + call icepack_query_tracer_flags(tr_fsd_out=tr_fsd, tr_iso_out=tr_iso) call icepack_query_tracer_indices(nt_Tsfc_out=nt_Tsfc, nt_qice_out=nt_qice, & - nt_qsno_out=nt_qsno, nt_sice_out=nt_sice, nt_fsd_out=nt_fsd, & - nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice, & - nt_smice_out=nt_smice, nt_smliq_out=nt_smliq) + nt_qsno_out=nt_qsno, nt_fsd_out=nt_fsd, & + nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) call icepack_query_parameters( & rad_to_deg_out=rad_to_deg, puny_out=puny, rhoi_out=rhoi, lfresh_out=lfresh, & rhos_out=rhos, cp_ice_out=cp_ice) @@ -1807,20 +1585,15 @@ subroutine print_state(plabel,i,j,iblk) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) - write(nu_diag,*) subname,' ',trim(plabel) - write(nu_diag,*) subname,' istep1, my_task, i, j, iblk:', & + write(nu_diag,*) plabel + write(nu_diag,*) 'istep1, my_task, i, j, iblk:', & istep1, my_task, i, j, iblk - write(nu_diag,*) subname,' Global block:', this_block%block_id - write(nu_diag,*) subname,' Global i and j:', & + write(nu_diag,*) 'Global i and j:', & this_block%i_glob(i), & - this_block%j_glob(j) - write (nu_diag,*) subname,' Lat, Lon (degrees):', & - TLAT(i,j,iblk)*rad_to_deg, & - TLON(i,j,iblk)*rad_to_deg + this_block%j_glob(j) write(nu_diag,*) ' ' - write(nu_diag,*) 'aice ', aice(i,j,iblk) write(nu_diag,*) 'aice0', aice0(i,j,iblk) do n = 1, ncat write(nu_diag,*) ' ' @@ -1834,23 +1607,21 @@ subroutine print_state(plabel,i,j,iblk) endif write(nu_diag,*) 'Tsfcn',trcrn(i,j,nt_Tsfc,n,iblk) if (tr_fsd) write(nu_diag,*) 'afsdn',trcrn(i,j,nt_fsd,n,iblk) ! fsd cat 1 -! layer 1 diagnostics -! if (tr_iso) write(nu_diag,*) 'isosno',trcrn(i,j,nt_isosno,n,iblk) ! isotopes in snow -! if (tr_iso) write(nu_diag,*) 'isoice',trcrn(i,j,nt_isoice,n,iblk) ! isotopes in ice -! if (tr_snow) write(nu_diag,*) 'smice', trcrn(i,j,nt_smice, n,iblk) ! ice mass in snow -! if (tr_snow) write(nu_diag,*) 'smliq', trcrn(i,j,nt_smliq, n,iblk) ! liquid mass in snow +! if (tr_iso) write(nu_diag,*) 'isosno',trcrn(i,j,nt_isosno,n,iblk) ! isotopes in snow +! if (tr_iso) write(nu_diag,*) 'isoice',trcrn(i,j,nt_isoice,n,iblk) ! isotopes in ice write(nu_diag,*) ' ' ! dynamics (transport and/or ridging) causes the floe size distribution to become non-normal ! if (tr_fsd) then ! if (abs(sum(trcrn(i,j,nt_fsd:nt_fsd+nfsd-1,n,iblk))-c1) > puny) & -! write(nu_diag,*) 'afsdn not normal', & +! print*,'afsdn not normal', & ! sum(trcrn(i,j,nt_fsd:nt_fsd+nfsd-1,n,iblk)), & ! trcrn(i,j,nt_fsd:nt_fsd+nfsd-1,n,iblk) ! endif enddo ! n + eidebug = c0 do n = 1,ncat do k = 1,nilyr @@ -1883,25 +1654,151 @@ subroutine print_state(plabel,i,j,iblk) write(nu_diag,*) 'qsnow(i,j)',esdebug write(nu_diag,*) ' ' + write(nu_diag,*) 'uvel(i,j)',uvel(i,j,iblk) + write(nu_diag,*) 'vvel(i,j)',vvel(i,j,iblk) + + write(nu_diag,*) ' ' + write(nu_diag,*) 'atm states and fluxes' + write(nu_diag,*) ' uatm = ',uatm (i,j,iblk) + write(nu_diag,*) ' vatm = ',vatm (i,j,iblk) + write(nu_diag,*) ' potT = ',potT (i,j,iblk) + write(nu_diag,*) ' Tair = ',Tair (i,j,iblk) + write(nu_diag,*) ' Qa = ',Qa (i,j,iblk) + write(nu_diag,*) ' rhoa = ',rhoa (i,j,iblk) + write(nu_diag,*) ' swvdr = ',swvdr(i,j,iblk) + write(nu_diag,*) ' swvdf = ',swvdf(i,j,iblk) + write(nu_diag,*) ' swidr = ',swidr(i,j,iblk) + write(nu_diag,*) ' swidf = ',swidf(i,j,iblk) + write(nu_diag,*) ' flw = ',flw (i,j,iblk) + write(nu_diag,*) ' frain = ',frain(i,j,iblk) + write(nu_diag,*) ' fsnow = ',fsnow(i,j,iblk) + write(nu_diag,*) ' ' + write(nu_diag,*) 'ocn states and fluxes' + write(nu_diag,*) ' frzmlt = ',frzmlt (i,j,iblk) + write(nu_diag,*) ' sst = ',sst (i,j,iblk) + write(nu_diag,*) ' sss = ',sss (i,j,iblk) + write(nu_diag,*) ' Tf = ',Tf (i,j,iblk) + write(nu_diag,*) ' uocn = ',uocn (i,j,iblk) + write(nu_diag,*) ' vocn = ',vocn (i,j,iblk) + write(nu_diag,*) ' strtltx = ',strtltx(i,j,iblk) + write(nu_diag,*) ' strtlty = ',strtlty(i,j,iblk) + write(nu_diag,*) ' ' + write(nu_diag,*) 'srf states and fluxes' + write(nu_diag,*) ' Tref = ',Tref (i,j,iblk) + write(nu_diag,*) ' Qref = ',Qref (i,j,iblk) + write(nu_diag,*) ' Uref = ',Uref (i,j,iblk) + write(nu_diag,*) ' fsens = ',fsens (i,j,iblk) + write(nu_diag,*) ' flat = ',flat (i,j,iblk) + write(nu_diag,*) ' evap = ',evap (i,j,iblk) + write(nu_diag,*) ' flwout = ',flwout(i,j,iblk) + write(nu_diag,*) ' ' + + end subroutine print_state + +!======================================================================= + +! This routine is useful for debugging. +! Calls can be inserted anywhere and it will print info on print_points points +! call print_points_state(plabel) +! +! 'use ice_diagnostics' may need to be inserted also + + subroutine print_points_state(plabel,ilabel) + + use ice_blocks, only: block, get_block + use ice_domain, only: blocks_ice + use ice_domain_size, only: ncat, nilyr, nslyr + use ice_state, only: aice0, aicen, vicen, vsnon, uvel, vvel, trcrn + use ice_flux, only: uatm, vatm, potT, Tair, Qa, flw, frain, fsnow, & + fsens, flat, evap, flwout, swvdr, swvdf, swidr, swidf, rhoa, & + frzmlt, sst, sss, Tf, Tref, Qref, Uref, uocn, vocn, strtltx, strtlty + + character (len=*), intent(in),optional :: plabel + integer , intent(in),optional :: ilabel + + ! local variables + + real (kind=dbl_kind) :: & + eidebug, esdebug, & + qi, qs, & + puny + + integer (kind=int_kind) :: m, n, k, i, j, iblk, nt_Tsfc, nt_qice, nt_qsno + character(len=256) :: llabel + + type (block) :: & + this_block ! block information for current block + + character(len=*), parameter :: subname = '(print_points_state)' + ! ---------------------- + + call icepack_query_tracer_indices(nt_Tsfc_out=nt_Tsfc, nt_qice_out=nt_qice, & + nt_qsno_out=nt_qsno) + call icepack_query_parameters(puny_out=puny) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) + + do m = 1, npnt + if (my_task == pmloc(m)) then + i = piloc(m) + j = pjloc(m) + iblk = pbloc(m) + this_block = get_block(blocks_ice(iblk),iblk) + + if (present(ilabel)) then + write(llabel,'(i6,a1,i3,a1)') ilabel,':',m,':' + else + write(llabel,'(i3,a1)') m,':' + endif + if (present(plabel)) then + write(llabel,'(a)') 'pps:'//trim(plabel)//':'//trim(llabel) + else + write(llabel,'(a)') 'pps:'//trim(llabel) + endif + + write(nu_diag,*) trim(llabel),'istep1, my_task, i, j, iblk=', & + istep1, my_task, i, j, iblk + write(nu_diag,*) trim(llabel),'Global i and j=', & + this_block%i_glob(i), & + this_block%j_glob(j) + write(nu_diag,*) trim(llabel),'aice0=', aice0(i,j,iblk) + + do n = 1, ncat + write(nu_diag,*) trim(llabel),'aicen=', n,aicen(i,j,n,iblk) + write(nu_diag,*) trim(llabel),'vicen=', n,vicen(i,j,n,iblk) + write(nu_diag,*) trim(llabel),'vsnon=', n,vsnon(i,j,n,iblk) + if (aicen(i,j,n,iblk) > puny) then + write(nu_diag,*) trim(llabel),'hin=', n,vicen(i,j,n,iblk)/aicen(i,j,n,iblk) + write(nu_diag,*) trim(llabel),'hsn=', n,vsnon(i,j,n,iblk)/aicen(i,j,n,iblk) + endif + write(nu_diag,*) trim(llabel),'Tsfcn=',n,trcrn(i,j,nt_Tsfc,n,iblk) + enddo + + eidebug = c0 do n = 1,ncat do k = 1,nilyr - si = trcrn(i,j,nt_sice+k-1,n,iblk) - write(nu_diag,*) 'sice, cat ',n,' layer ',k, si + qi = trcrn(i,j,nt_qice+k-1,n,iblk) + write(nu_diag,*) trim(llabel),'qice= ',n,k, qi + eidebug = eidebug + qi enddo enddo - write(nu_diag,*) ' ' + write(nu_diag,*) trim(llabel),'qice=',eidebug - write(nu_diag,*) 'uvel(i,j)',uvel(i,j,iblk) - write(nu_diag,*) 'vvel(i,j)',vvel(i,j,iblk) - if (grid_ice == 'C') then - write(nu_diag,*) 'uvelE(i,j)',uvelE(i,j,iblk) - write(nu_diag,*) 'uvelN(i,j)',uvelN(i,j,iblk) - elseif (grid_ice == 'CD') then - write(nu_diag,*) 'uvelE(i,j)',uvelE(i,j,iblk) - write(nu_diag,*) 'vvelE(i,j)',vvelE(i,j,iblk) - write(nu_diag,*) 'uvelN(i,j)',uvelN(i,j,iblk) - write(nu_diag,*) 'vvelN(i,j)',vvelN(i,j,iblk) - endif + esdebug = c0 + do n = 1,ncat + if (vsnon(i,j,n,iblk) > puny) then + do k = 1,nslyr + qs = trcrn(i,j,nt_qsno+k-1,n,iblk) + write(nu_diag,*) trim(llabel),'qsnow=',n,k, qs + esdebug = esdebug + qs + enddo + endif + enddo + write(nu_diag,*) trim(llabel),'qsnow=',esdebug + + write(nu_diag,*) trim(llabel),'uvel=',uvel(i,j,iblk) + write(nu_diag,*) trim(llabel),'vvel=',vvel(i,j,iblk) write(nu_diag,*) ' ' write(nu_diag,*) 'atm states and fluxes' @@ -1920,14 +1817,14 @@ subroutine print_state(plabel,i,j,iblk) write(nu_diag,*) ' fsnow = ',fsnow(i,j,iblk) write(nu_diag,*) ' ' write(nu_diag,*) 'ocn states and fluxes' - write(nu_diag,*) ' frzmlt = ',frzmlt (i,j,iblk) - write(nu_diag,*) ' sst = ',sst (i,j,iblk) - write(nu_diag,*) ' sss = ',sss (i,j,iblk) - write(nu_diag,*) ' Tf = ',Tf (i,j,iblk) - write(nu_diag,*) ' uocn = ',uocn (i,j,iblk) - write(nu_diag,*) ' vocn = ',vocn (i,j,iblk) - write(nu_diag,*) ' strtltxU= ',strtltxU(i,j,iblk) - write(nu_diag,*) ' strtltyU= ',strtltyU(i,j,iblk) + write(nu_diag,*) ' frzmlt = ',frzmlt (i,j,iblk) + write(nu_diag,*) ' sst = ',sst (i,j,iblk) + write(nu_diag,*) ' sss = ',sss (i,j,iblk) + write(nu_diag,*) ' Tf = ',Tf (i,j,iblk) + write(nu_diag,*) ' uocn = ',uocn (i,j,iblk) + write(nu_diag,*) ' vocn = ',vocn (i,j,iblk) + write(nu_diag,*) ' strtltx = ',strtltx(i,j,iblk) + write(nu_diag,*) ' strtlty = ',strtlty(i,j,iblk) write(nu_diag,*) ' ' write(nu_diag,*) 'srf states and fluxes' write(nu_diag,*) ' Tref = ',Tref (i,j,iblk) @@ -1938,26 +1835,30 @@ subroutine print_state(plabel,i,j,iblk) write(nu_diag,*) ' evap = ',evap (i,j,iblk) write(nu_diag,*) ' flwout = ',flwout(i,j,iblk) write(nu_diag,*) ' ' - call flush_fileunit(nu_diag) - end subroutine print_state + endif ! my_task + enddo ! ncnt + + end subroutine print_points_state !======================================================================= ! prints error information prior to aborting - subroutine diagnostic_abort(istop, jstop, iblk, stop_label) + subroutine diagnostic_abort(istop, jstop, iblk, istep1, stop_label) use ice_blocks, only: block, get_block + use ice_communicate, only: my_task use ice_domain, only: blocks_ice use ice_grid, only: TLAT, TLON use ice_state, only: aice integer (kind=int_kind), intent(in) :: & istop, jstop, & ! indices of grid cell where model aborts - iblk ! block index + iblk , & ! block index + istep1 ! time step number - character (len=*), intent(in) :: stop_label + character (char_len), intent(in) :: stop_label ! local variables @@ -1973,17 +1874,20 @@ subroutine diagnostic_abort(istop, jstop, iblk, stop_label) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - this_block = get_block(blocks_ice(iblk),iblk) - - call flush_fileunit(nu_diag) - if (istop > 0 .and. jstop > 0) then - call print_state(trim(stop_label),istop,jstop,iblk) - else - write (nu_diag,*) subname,' istep1, my_task, iblk =', & - istep1, my_task, iblk - write (nu_diag,*) subname,' Global block:', this_block%block_id - endif - call flush_fileunit(nu_diag) + this_block = get_block(blocks_ice(iblk),iblk) + + write (nu_diag,*) 'istep1, my_task, iblk =', & + istep1, my_task, iblk + write (nu_diag,*) 'Global block:', this_block%block_id + if (istop > 0 .and. jstop > 0) & + write (nu_diag,*) 'Global i and j:', & + this_block%i_glob(istop), & + this_block%j_glob(jstop) + write (nu_diag,*) 'Lat, Lon:', & + TLAT(istop,jstop,iblk)*rad_to_deg, & + TLON(istop,jstop,iblk)*rad_to_deg + write (nu_diag,*) 'aice:', & + aice(istop,jstop,iblk) call abort_ice (subname//'ERROR: '//trim(stop_label)) end subroutine diagnostic_abort diff --git a/cicecore/cicedyn/analysis/ice_history_bgc.F90 b/cicecore/cicedyn/analysis/ice_history_bgc.F90 index 7c87c1f70..1ae572b30 100644 --- a/cicecore/cicedyn/analysis/ice_history_bgc.F90 +++ b/cicecore/cicedyn/analysis/ice_history_bgc.F90 @@ -21,71 +21,74 @@ module ice_history_bgc icepack_query_tracer_indices, icepack_query_parameters, & icepack_query_parameters use ice_domain_size, only: max_nstrm, n_iso, n_aero, & - n_algae, n_dic, n_doc, n_don, n_zaero, n_fed, n_fep + n_algae, n_dic, n_doc, n_don, n_zaero, n_fed, n_fep implicit none private public :: init_hist_bgc_2D, init_hist_bgc_3Dc, & init_hist_bgc_3Db, init_hist_bgc_3Da,& accum_hist_bgc, init_history_bgc - + !--------------------------------------------------------------- ! flags: write to output file if true or histfreq value !--------------------------------------------------------------- ! specified in input_templates !-------------------------------------------------------------- - character (len=max_nstrm), public :: & + character (len=max_nstrm), public :: & f_fiso_atm = 'x', f_fiso_ocn = 'x', & f_iso = 'x', & f_faero_atm = 'x', f_faero_ocn = 'x', & f_aero = 'x', & - f_fbio = 'x', f_fbio_ai = 'x', & - f_zaero = 'x', f_bgc_S = 'x', & + f_fzsal = 'm', f_fzsal_ai = 'm', & + f_fzsal_g = 'm', f_fzsal_g_ai = 'm', & + f_zsal = 'x', & + f_fbio = 'x', f_fbio_ai = 'x', & + f_zaero = 'x', f_bgc_S = 'x', & f_bgc_N = 'x', f_bgc_C = 'x', & f_bgc_DOC = 'x', f_bgc_DIC = 'x', & f_bgc_chl = 'x', f_bgc_Nit = 'x', & f_bgc_Am = 'x', f_bgc_Sil = 'x', & f_bgc_DMSPp = 'x', f_bgc_DMSPd = 'x', & - f_bgc_DMS = 'x', f_bgc_DON = 'x', & + f_bgc_DMS = 'x', f_bgc_DON = 'x', & f_bgc_Fe = 'x', f_bgc_hum = 'x', & f_bgc_PON = 'x', f_bgc_ml = 'x', & - f_upNO = 'x', f_upNH = 'x', & - f_bTin = 'x', f_bphi = 'x', & - f_iDi = 'x', f_iki = 'x', & + f_upNO = 'x', f_upNH = 'x', & + f_bTin = 'x', f_bphi = 'x', & + f_iDi = 'x', f_iki = 'x', & f_fbri = 'x', f_hbri = 'x', & - f_zfswin = 'x', f_grownet = 'x', & - f_bionet = 'x', f_biosnow = 'x', & + f_zfswin = 'x', f_grownet = 'x', & + f_bionet = 'x', f_biosnow = 'x', & f_PPnet = 'x', f_algalpeak = 'x', & f_zbgc_frac = 'x', & !------------------------------------------------ ! specified by combinations of above values !------------------------------------------------- f_bgc_Fed = 'x', f_bgc_Fep = 'x', & - f_DONnet = 'x', & - f_DICnet = 'x', f_DOCnet = 'x', & - f_chlnet = 'x', f_Nitnet = 'x', & - f_Amnet = 'x', f_Cnet = 'x', & - f_Nnet = 'x', f_DMSPpnet = 'x', & - f_DMSPdnet = 'x', f_DMSnet = 'x', & - f_Fednet = 'x', f_Fepnet = 'x', & + f_DONnet = 'x', & + f_DICnet = 'x', f_DOCnet = 'x', & + f_chlnet = 'x', f_Nitnet = 'x', & + f_Amnet = 'x', f_Cnet = 'x', & + f_Nnet = 'x', f_DMSPpnet = 'x', & + f_DMSPdnet = 'x', f_DMSnet = 'x', & + f_Fednet = 'x', f_Fepnet = 'x', & f_Silnet = 'x', f_PONnet = 'x', & - f_zaeronet = 'x', f_humnet = 'x', & - f_chlsnow = 'x', f_Nitsnow = 'x', & - f_Amsnow = 'x', f_Csnow = 'x', & - f_Nsnow = 'x', f_DMSPpsnow = 'x', & - f_DMSPdsnow = 'x', f_DMSsnow = 'x', & - f_Fedsnow = 'x', f_Fepsnow = 'x', & - f_Silsnow = 'x', f_PONsnow = 'x', & + f_zaeronet = 'x', f_humnet = 'x', & + f_chlsnow = 'x', f_Nitsnow = 'x', & + f_Amsnow = 'x', f_Csnow = 'x', & + f_Nsnow = 'x', f_DMSPpsnow = 'x', & + f_DMSPdsnow = 'x', f_DMSsnow = 'x', & + f_Fedsnow = 'x', f_Fepsnow = 'x', & + f_Silsnow = 'x', f_PONsnow = 'x', & f_humsnow = 'x', & - f_DICsnow = 'x', f_DOCsnow = 'x', & + f_DICsnow = 'x', f_DOCsnow = 'x', & f_DONsnow = 'x', f_zaerosnow = 'x', & - f_chlfrac = 'x', f_Nitfrac = 'x', & - f_Amfrac = 'x', & - f_Nfrac = 'x', f_DMSPpfrac = 'x', & - f_DMSPdfrac = 'x', f_DMSfrac = 'x', & - f_Silfrac = 'x', f_PONfrac = 'x', & + f_chlfrac = 'x', f_Nitfrac = 'x', & + f_Amfrac = 'x', & + f_Nfrac = 'x', f_DMSPpfrac = 'x', & + f_DMSPdfrac = 'x', f_DMSfrac = 'x', & + f_Silfrac = 'x', f_PONfrac = 'x', & f_humfrac = 'x', & - f_DICfrac = 'x', f_DOCfrac = 'x', & + f_DICfrac = 'x', f_DOCfrac = 'x', & f_DONfrac = 'x', f_zaerofrac = 'x', & f_Fedfrac = 'x', f_Fepfrac = 'x', & f_fNit = 'x', f_fNit_ai = 'x', & @@ -96,13 +99,13 @@ module ice_history_bgc f_fDON = 'x', f_fDON_ai = 'x', & f_fFed = 'x', f_fFed_ai = 'x', & f_fFep = 'x', f_fFep_ai = 'x', & - f_fSil = 'x', f_fSil_ai = 'x', & - f_fPON = 'x', f_fPON_ai = 'x', & - f_fhum = 'x', f_fhum_ai = 'x', & - f_fDMSPp = 'x', f_fDMSPp_ai = 'x', & - f_fDMSPd = 'x', f_fDMSPd_ai = 'x', & - f_fDMS = 'x', f_fDMS_ai = 'x', & - f_fzaero = 'x', f_fzaero_ai = 'x', & + f_fSil = 'x', f_fSil_ai = 'x', & + f_fPON = 'x', f_fPON_ai = 'x', & + f_fhum = 'x', f_fhum_ai = 'x', & + f_fDMSPp = 'x', f_fDMSPp_ai = 'x', & + f_fDMSPd = 'x', f_fDMSPd_ai = 'x', & + f_fDMS = 'x', f_fDMS_ai = 'x', & + f_fzaero = 'x', f_fzaero_ai = 'x', & f_bgc_Sil_ml = 'x', & f_bgc_Nit_ml = 'x', f_bgc_Am_ml = 'x', & f_bgc_DMSP_ml = 'x', f_bgc_DMS_ml = 'x', & @@ -137,12 +140,12 @@ module ice_history_bgc f_bgc_DMS , f_bgc_DON , & f_bgc_Fe , f_bgc_hum , & f_bgc_PON , f_bgc_ml , & - f_upNO , f_upNH , & + f_upNO , f_upNH , & f_bTin , f_bphi , & - f_iDi , f_iki , & + f_iDi , f_iki , & f_fbri , f_hbri , & - f_zfswin , f_grownet , & - f_bionet , f_biosnow , & + f_zfswin , f_grownet , & + f_bionet , f_biosnow , & f_PPnet , f_algalpeak , & f_zbgc_frac @@ -150,6 +153,11 @@ module ice_history_bgc ! field indices !--------------------------------------------------------------- + integer (kind=int_kind), dimension(max_nstrm), public :: & + n_fzsal , n_fzsal_ai , & + n_fzsal_g , n_fzsal_g_ai , & + n_zsal + integer(kind=int_kind), dimension(icepack_max_iso,max_nstrm) :: & n_fiso_atm , & n_fiso_ocn , & @@ -208,6 +216,7 @@ module ice_history_bgc n_bgc_Fed_cat1, n_bgc_Fep_cat1 integer(kind=int_kind), dimension(max_nstrm) :: & + n_bgc_S , & n_fNit , n_fNit_ai , & n_fAm , n_fAm_ai , & n_fSil , n_fSil_ai , & @@ -224,25 +233,25 @@ module ice_history_bgc n_bgc_hum_ml , & n_bgc_Nit_ml , n_bgc_Am_ml , & n_bgc_DMSP_ml , n_bgc_DMS_ml , & - n_upNO , n_upNH , & + n_upNO , n_upNH , & n_bTin , n_bphi , & n_iDi , n_iki , & n_bgc_PON , & n_fbri , n_hbri , & - n_zfswin , n_Nitnet , & - n_Amnet , n_Silnet , & + n_zfswin , n_Nitnet , & + n_Amnet , n_Silnet , & n_humnet , & - n_DMSPpnet , n_DMSPdnet , & - n_DMSnet , n_PONnet , & + n_DMSPpnet , n_DMSPdnet , & + n_DMSnet , n_PONnet , & n_Nitsnow , n_Amsnow , & n_Silsnow , n_humsnow , & - n_DMSPpsnow , n_DMSPdsnow , & - n_DMSsnow , n_PONsnow , & + n_DMSPpsnow , n_DMSPdsnow , & + n_DMSsnow , n_PONsnow , & n_Nitfrac , n_Amfrac , & n_Silfrac , & n_humfrac , & - n_DMSPpfrac , n_DMSPdfrac , & - n_DMSfrac , n_PONfrac , & + n_DMSPpfrac , n_DMSPdfrac , & + n_DMSfrac , n_PONfrac , & n_grownet , n_PPnet , & n_bgc_Nit_cat1, n_bgc_Am_cat1 , & n_bgc_Sil_cat1, n_bgc_DMSPd_cat1,& @@ -258,11 +267,10 @@ module ice_history_bgc subroutine init_hist_bgc_2D use ice_broadcast, only: broadcast_scalar - use ice_calendar, only: nstreams, histfreq + use ice_calendar, only: nstreams use ice_communicate, only: my_task, master_task use ice_history_shared, only: tstr2D, tcstr, define_hist_field, & f_fsalt, f_fsalt_ai, f_sice - use ice_fileunits, only: goto_nml integer (kind=int_kind) :: n, ns integer (kind=int_kind) :: nml_error ! namelist i/o error flag @@ -273,15 +281,11 @@ subroutine init_hist_bgc_2D tr_bgc_DMS, tr_bgc_PON, & tr_bgc_N, tr_bgc_C, tr_bgc_chl, & tr_bgc_DON, tr_bgc_Fe, tr_bgc_hum, & - skl_bgc, z_tracers - - character(len=char_len) :: nml_name ! for namelist check - character(len=char_len_long) :: tmpstr2 ! for namelist check - - character(len=*), parameter :: subname = '(init_hist_bgc_2D)' + skl_bgc, solve_zsal, z_tracers + character(len=*), parameter :: subname = '(init_hist_bgc_2D)' call icepack_query_parameters(skl_bgc_out=skl_bgc, & - z_tracers_out=z_tracers) + solve_zsal_out=solve_zsal, z_tracers_out=z_tracers) call icepack_query_tracer_flags( & tr_iso_out =tr_iso, tr_zaero_out =tr_zaero, & tr_aero_out =tr_aero, tr_brine_out =tr_brine, & @@ -290,7 +294,7 @@ subroutine init_hist_bgc_2D tr_bgc_PON_out=tr_bgc_PON, & tr_bgc_N_out =tr_bgc_N, tr_bgc_C_out =tr_bgc_C, & tr_bgc_chl_out=tr_bgc_chl, tr_bgc_DON_out=tr_bgc_DON, & - tr_bgc_Fe_out =tr_bgc_Fe, tr_bgc_hum_out=tr_bgc_hum ) + tr_bgc_Fe_out =tr_bgc_Fe, tr_bgc_hum_out=tr_bgc_hum ) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) @@ -299,42 +303,25 @@ subroutine init_hist_bgc_2D ! read namelist !----------------------------------------------------------------- + call get_fileunit(nu_nml) if (my_task == master_task) then - nml_name = 'icefields_bgc_nml' - write(nu_diag,*) subname,' Reading ', trim(nml_name) - - ! check if can open file - call get_fileunit(nu_nml) - open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error) + open (nu_nml, file=nml_filename, status='old',iostat=nml_error) if (nml_error /= 0) then - call abort_ice(subname//'ERROR: '//trim(nml_name)//' open file '// & - trim(nml_filename), & - file=__FILE__, line=__LINE__) + nml_error = -1 + else + nml_error = 1 endif - - ! seek to namelist in file - call goto_nml(nu_nml,trim(nml_name),nml_error) - if (nml_error /= 0) then - call abort_ice(subname//'ERROR: searching for '// trim(nml_name), & - file=__FILE__, line=__LINE__) - endif - - ! read namelist - nml_error = 1 do while (nml_error > 0) read(nu_nml, nml=icefields_bgc_nml,iostat=nml_error) - ! check if error - if (nml_error /= 0) then - ! backspace and re-read erroneous line - backspace(nu_nml) - read(nu_nml,fmt='(A)') tmpstr2 - call abort_ice(subname//'ERROR: ' // trim(nml_name) // ' reading ' // & - trim(tmpstr2), file=__FILE__, line=__LINE__) - endif end do + if (nml_error == 0) close(nu_nml) + endif + call release_fileunit(nu_nml) - close(nu_nml) - call release_fileunit(nu_nml) + call broadcast_scalar(nml_error, master_task) + if (nml_error /= 0) then + close (nu_nml) + call abort_ice(subname//'ERROR: reading icefields_bgc_nml') endif if (.not. tr_iso) then @@ -346,14 +333,14 @@ subroutine init_hist_bgc_2D if (.not. tr_aero) then f_faero_atm = 'x' f_faero_ocn = 'x' - f_aero = 'x' + f_aero = 'x' endif - + if (.not. tr_brine) then f_fbri = 'x' f_hbri = 'x' endif - + f_zaeronet = f_bionet f_zaerosnow = f_biosnow f_zaerofrac = f_zbgc_frac @@ -362,7 +349,7 @@ subroutine init_hist_bgc_2D if (.not. tr_zaero) then f_zaero = 'x' - f_fzaero = 'x' + f_fzaero = 'x' f_fzaero_ai = 'x' f_zaeronet = 'x' f_zaerosnow = 'x' @@ -406,7 +393,7 @@ subroutine init_hist_bgc_2D f_DMSPdnet = f_bionet f_DMSnet = f_bionet f_PONnet = f_bionet - + f_Nitsnow = f_biosnow f_Amsnow = f_biosnow f_Nsnow = f_biosnow @@ -476,7 +463,7 @@ subroutine init_hist_bgc_2D f_fDMSPd_ai = f_fbio_ai f_fDMS_ai = f_fbio_ai - if (.not. tr_bgc_N) then + if (.not. tr_bgc_N) then f_bgc_N = 'x' f_bgc_N_ml = 'x' f_fN = 'x' @@ -488,8 +475,8 @@ subroutine init_hist_bgc_2D endif f_peakval = f_algalpeak - if (.not. tr_bgc_Nit) then - f_upNO = 'x' + if (.not. tr_bgc_Nit) then + f_upNO = 'x' f_bgc_Nit = 'x' f_bgc_Nit_ml= 'x' f_fNit = 'x' @@ -521,8 +508,8 @@ subroutine init_hist_bgc_2D f_chlsnow = 'x' f_chlfrac = 'x' endif - if (.not. tr_bgc_Am) then - f_upNH = 'x' + if (.not. tr_bgc_Am) then + f_upNH = 'x' f_bgc_Am = 'x' f_bgc_Am_ml = 'x' f_fAm = 'x' @@ -570,8 +557,8 @@ subroutine init_hist_bgc_2D f_DMSfrac = 'x' f_DMSPpfrac = 'x' f_DMSPdfrac = 'x' - endif - if (.not. tr_bgc_DON) then + endif + if (.not. tr_bgc_DON) then f_bgc_DON = 'x' f_bgc_DON_ml = 'x' f_DONsnow = 'x' @@ -579,8 +566,8 @@ subroutine init_hist_bgc_2D f_DONnet = 'x' f_fDON = 'x' f_fDON_ai = 'x' - endif - if (.not. tr_bgc_Fe ) then + endif + if (.not. tr_bgc_Fe ) then f_bgc_Fe = 'x' f_bgc_Fed = 'x' f_bgc_Fed_ml = 'x' @@ -597,7 +584,7 @@ subroutine init_hist_bgc_2D f_fFep = 'x' f_fFep_ai = 'x' endif - if (.not. tr_bgc_PON .or. skl_bgc) then + if (.not. tr_bgc_PON .or. skl_bgc) then f_bgc_PON = 'x' f_PONsnow = 'x' f_PONfrac = 'x' @@ -605,21 +592,40 @@ subroutine init_hist_bgc_2D f_fPON = 'x' f_fPON_ai = 'x' endif - - f_bgc_Nit_cat1 = f_bgc_Nit - f_bgc_Am_cat1 = f_bgc_Am + + f_bgc_Nit_cat1 = f_bgc_Nit + f_bgc_Am_cat1 = f_bgc_Am f_bgc_N_cat1 = f_bgc_N f_bgc_DOC_cat1 = f_bgc_DOC f_bgc_DIC_cat1 = f_bgc_DIC f_bgc_DON_cat1 = f_bgc_DON - f_bgc_Fed_cat1 = f_bgc_Fe - f_bgc_Fep_cat1 = f_bgc_Fe - f_bgc_Sil_cat1 = f_bgc_Sil - f_bgc_hum_cat1 = f_bgc_hum + f_bgc_Fed_cat1 = f_bgc_Fe + f_bgc_Fep_cat1 = f_bgc_Fe + f_bgc_Sil_cat1 = f_bgc_Sil + f_bgc_hum_cat1 = f_bgc_hum f_bgc_DMSPd_cat1 = f_bgc_DMSPd - f_bgc_DMS_cat1 = f_bgc_DMS + f_bgc_DMS_cat1 = f_bgc_DMS f_bgc_PON_cat1 = f_bgc_PON + if (solve_zsal) then + f_fzsal = f_fsalt + f_fzsal_g = f_fsalt + f_fzsal_ai = f_fsalt_ai + f_fzsal_g_ai = f_fsalt_ai + f_zsal = f_sice + f_fsalt = 'x' + f_fsalt_ai = 'x' + f_sice = 'x' + else + f_fzsal = 'x' + f_fzsal_g = 'x' + f_fzsal_ai = 'x' + f_fzsal_g_ai = 'x' + f_zsal = 'x' + f_bgc_S = 'x' + f_iki = 'x' + endif + call broadcast_scalar (f_fiso_atm, master_task) call broadcast_scalar (f_fiso_ocn, master_task) call broadcast_scalar (f_iso, master_task) @@ -628,6 +634,11 @@ subroutine init_hist_bgc_2D call broadcast_scalar (f_aero, master_task) call broadcast_scalar (f_fbri, master_task) call broadcast_scalar (f_hbri, master_task) + call broadcast_scalar (f_fzsal, master_task) + call broadcast_scalar (f_fzsal_ai, master_task) + call broadcast_scalar (f_fzsal_g, master_task) + call broadcast_scalar (f_fzsal_g_ai, master_task) + call broadcast_scalar (f_zsal, master_task) call broadcast_scalar (f_fNit, master_task) call broadcast_scalar (f_fNit_ai, master_task) call broadcast_scalar (f_fDOC, master_task) @@ -697,79 +708,79 @@ subroutine init_hist_bgc_2D call broadcast_scalar (f_bgc_Sil_ml, master_task) call broadcast_scalar (f_bgc_hum_ml, master_task) call broadcast_scalar (f_bgc_DMSP_ml, master_task) - call broadcast_scalar (f_bgc_DMS_ml, master_task) - call broadcast_scalar (f_bgc_DON_ml, master_task) - call broadcast_scalar (f_bgc_Fed_ml, master_task) - call broadcast_scalar (f_bgc_Fep_ml, master_task) - call broadcast_scalar (f_upNO, master_task) - call broadcast_scalar (f_upNH, master_task) + call broadcast_scalar (f_bgc_DMS_ml, master_task) + call broadcast_scalar (f_bgc_DON_ml, master_task) + call broadcast_scalar (f_bgc_Fed_ml, master_task) + call broadcast_scalar (f_bgc_Fep_ml, master_task) + call broadcast_scalar (f_upNO, master_task) + call broadcast_scalar (f_upNH, master_task) call broadcast_scalar (f_bTin, master_task) call broadcast_scalar (f_bphi, master_task) - call broadcast_scalar (f_iDi, master_task) - call broadcast_scalar (f_iki, master_task) - call broadcast_scalar (f_zfswin, master_task) - call broadcast_scalar (f_PPnet, master_task) - call broadcast_scalar (f_algalpeak, master_task) - call broadcast_scalar (f_zbgc_frac, master_task) - call broadcast_scalar (f_peakval, master_task) - call broadcast_scalar (f_grownet, master_task) - call broadcast_scalar (f_chlnet, master_task) - call broadcast_scalar (f_Nitnet, master_task) - call broadcast_scalar (f_Nnet, master_task) - call broadcast_scalar (f_Cnet, master_task) - call broadcast_scalar (f_DOCnet, master_task) - call broadcast_scalar (f_DICnet, master_task) - call broadcast_scalar (f_Amnet, master_task) - call broadcast_scalar (f_Silnet, master_task) - call broadcast_scalar (f_humnet, master_task) - call broadcast_scalar (f_DMSPpnet, master_task) - call broadcast_scalar (f_DMSPdnet, master_task) - call broadcast_scalar (f_DMSnet, master_task) - call broadcast_scalar (f_PONnet, master_task) - call broadcast_scalar (f_DONnet, master_task) - call broadcast_scalar (f_Fednet, master_task) - call broadcast_scalar (f_Fepnet, master_task) - call broadcast_scalar (f_zaeronet, master_task) - call broadcast_scalar (f_chlsnow, master_task) - call broadcast_scalar (f_Nitsnow, master_task) - call broadcast_scalar (f_Nsnow, master_task) - call broadcast_scalar (f_Csnow, master_task) - call broadcast_scalar (f_DOCsnow, master_task) - call broadcast_scalar (f_DICsnow, master_task) - call broadcast_scalar (f_Amsnow, master_task) - call broadcast_scalar (f_Silsnow, master_task) - call broadcast_scalar (f_humsnow, master_task) - call broadcast_scalar (f_DMSPpsnow, master_task) - call broadcast_scalar (f_DMSPdsnow, master_task) - call broadcast_scalar (f_DMSsnow, master_task) - call broadcast_scalar (f_PONsnow, master_task) - call broadcast_scalar (f_DONsnow, master_task) - call broadcast_scalar (f_Fedsnow, master_task) - call broadcast_scalar (f_Fepsnow, master_task) - call broadcast_scalar (f_zaerosnow, master_task) - call broadcast_scalar (f_chlfrac, master_task) - call broadcast_scalar (f_Nitfrac, master_task) - call broadcast_scalar (f_Nfrac, master_task) - call broadcast_scalar (f_DOCfrac, master_task) - call broadcast_scalar (f_DICfrac, master_task) - call broadcast_scalar (f_Amfrac, master_task) - call broadcast_scalar (f_Silfrac, master_task) - call broadcast_scalar (f_humfrac, master_task) - call broadcast_scalar (f_DMSPpfrac, master_task) - call broadcast_scalar (f_DMSPdfrac, master_task) - call broadcast_scalar (f_DMSfrac, master_task) - call broadcast_scalar (f_PONfrac, master_task) - call broadcast_scalar (f_DONfrac, master_task) - call broadcast_scalar (f_Fedfrac, master_task) - call broadcast_scalar (f_Fepfrac, master_task) - call broadcast_scalar (f_zaerofrac, master_task) + call broadcast_scalar (f_iDi, master_task) + call broadcast_scalar (f_iki, master_task) + call broadcast_scalar (f_bgc_S, master_task) + call broadcast_scalar (f_zfswin, master_task) + call broadcast_scalar (f_PPnet, master_task) + call broadcast_scalar (f_algalpeak, master_task) + call broadcast_scalar (f_zbgc_frac, master_task) + call broadcast_scalar (f_peakval, master_task) + call broadcast_scalar (f_grownet, master_task) + call broadcast_scalar (f_chlnet, master_task) + call broadcast_scalar (f_Nitnet, master_task) + call broadcast_scalar (f_Nnet, master_task) + call broadcast_scalar (f_Cnet, master_task) + call broadcast_scalar (f_DOCnet, master_task) + call broadcast_scalar (f_DICnet, master_task) + call broadcast_scalar (f_Amnet, master_task) + call broadcast_scalar (f_Silnet, master_task) + call broadcast_scalar (f_humnet, master_task) + call broadcast_scalar (f_DMSPpnet, master_task) + call broadcast_scalar (f_DMSPdnet, master_task) + call broadcast_scalar (f_DMSnet, master_task) + call broadcast_scalar (f_PONnet, master_task) + call broadcast_scalar (f_DONnet, master_task) + call broadcast_scalar (f_Fednet, master_task) + call broadcast_scalar (f_Fepnet, master_task) + call broadcast_scalar (f_zaeronet, master_task) + call broadcast_scalar (f_chlsnow, master_task) + call broadcast_scalar (f_Nitsnow, master_task) + call broadcast_scalar (f_Nsnow, master_task) + call broadcast_scalar (f_Csnow, master_task) + call broadcast_scalar (f_DOCsnow, master_task) + call broadcast_scalar (f_DICsnow, master_task) + call broadcast_scalar (f_Amsnow, master_task) + call broadcast_scalar (f_Silsnow, master_task) + call broadcast_scalar (f_humsnow, master_task) + call broadcast_scalar (f_DMSPpsnow, master_task) + call broadcast_scalar (f_DMSPdsnow, master_task) + call broadcast_scalar (f_DMSsnow, master_task) + call broadcast_scalar (f_PONsnow, master_task) + call broadcast_scalar (f_DONsnow, master_task) + call broadcast_scalar (f_Fedsnow, master_task) + call broadcast_scalar (f_Fepsnow, master_task) + call broadcast_scalar (f_zaerosnow, master_task) + call broadcast_scalar (f_chlfrac, master_task) + call broadcast_scalar (f_Nitfrac, master_task) + call broadcast_scalar (f_Nfrac, master_task) + call broadcast_scalar (f_DOCfrac, master_task) + call broadcast_scalar (f_DICfrac, master_task) + call broadcast_scalar (f_Amfrac, master_task) + call broadcast_scalar (f_Silfrac, master_task) + call broadcast_scalar (f_humfrac, master_task) + call broadcast_scalar (f_DMSPpfrac, master_task) + call broadcast_scalar (f_DMSPdfrac, master_task) + call broadcast_scalar (f_DMSfrac, master_task) + call broadcast_scalar (f_PONfrac, master_task) + call broadcast_scalar (f_DONfrac, master_task) + call broadcast_scalar (f_Fedfrac, master_task) + call broadcast_scalar (f_Fepfrac, master_task) + call broadcast_scalar (f_zaerofrac, master_task) ! 2D variables - if (tr_iso .or. tr_aero .or. tr_brine .or. skl_bgc) then + if (tr_iso .or. tr_aero .or. tr_brine .or. solve_zsal .or. skl_bgc) then - do ns = 1, nstreams - if (histfreq(ns) /= 'x') then + do ns = 1, nstreams if (f_iso(1:1) /= 'x') then do n=1,n_iso @@ -805,6 +816,33 @@ subroutine init_hist_bgc_2D enddo endif + ! zsalinity + + call define_hist_field(n_fzsal,"fzsal","kg/m^2/s",tstr2D, tcstr, & + "prognostic salt flux ice to ocn (cpl)", & + "if positive, ocean gains salt", c1, c0, & + ns, f_fzsal) + + call define_hist_field(n_fzsal_ai,"fzsal_ai","kg/m^2/s",tstr2D, tcstr, & + "prognostic salt flux ice to ocean", & + "weighted by ice area", c1, c0, & + ns, f_fzsal_ai) + + call define_hist_field(n_fzsal_g,"fzsal_g","kg/m^2/s",tstr2D, tcstr, & + "Gravity drainage salt flux ice to ocn (cpl)", & + "if positive, ocean gains salt", c1, c0, & + ns, f_fzsal_g) + + call define_hist_field(n_fzsal_g_ai,"fzsal_g_ai","kg/m^2/s",tstr2D, tcstr, & + "Gravity drainage salt flux ice to ocean", & + "weighted by ice area", c1, c0, & + ns, f_fzsal_g_ai) + + call define_hist_field(n_zsal,"zsal_tot","g/m^2",tstr2D, tcstr, & + "Total Salt content", & + "In ice volume*fbri", c1, c0, & + ns, f_zsal) + ! Aerosols if (f_aero(1:1) /= 'x') then do n=1,n_aero @@ -929,8 +967,8 @@ subroutine init_hist_bgc_2D "skeletal layer: bottom 3 cm", c1, c0, & ns, f_bgc_Fep ) enddo - endif !f_bgc_Fe - + endif !f_bgc_Fe + if (f_bgc_Nit(1:1) /= 'x') & call define_hist_field(n_bgc_Nit,"Nit","mmol/m^2",tstr2D, tcstr, & "Bulk skeletal nutrient (nitrate)", & @@ -971,7 +1009,7 @@ subroutine init_hist_bgc_2D "Bulk dissolved skl trace gas (DMS)", & "skeletal layer: bottom 3 cm", c1, c0, & ns, f_bgc_DMS) - + endif !skl_bgc ! vertical and skeletal layer biogeochemistry @@ -1007,7 +1045,7 @@ subroutine init_hist_bgc_2D enddo endif if (f_bgc_Fed_ml (1:1) /= 'x') then - do n = 1, n_fed + do n = 1, n_fed write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'ml_dFe', trim(nchar) call define_hist_field(n_bgc_Fed_ml (n,:),vname_in,"nM",tstr2D, tcstr, & @@ -1017,7 +1055,7 @@ subroutine init_hist_bgc_2D enddo endif if (f_bgc_Fep_ml (1:1) /= 'x') then - do n = 1, n_fep + do n = 1, n_fep write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'ml_pFe', trim(nchar) call define_hist_field(n_bgc_Fep_ml (n,:),vname_in,"nM",tstr2D, tcstr, & @@ -1055,7 +1093,7 @@ subroutine init_hist_bgc_2D call define_hist_field(n_bgc_hum_ml,"ml_hum","mmol/m^3",tstr2D, tcstr, & "mixed layer humic material (carbon)", & "upper ocean", c1, c0, & - ns, f_bgc_hum_ml) + ns, f_bgc_hum_ml) if (f_bgc_DMSP_ml(1:1) /= 'x') & call define_hist_field(n_bgc_DMSP_ml,"ml_DMSP","mmol/m^3",tstr2D, tcstr, & "mixed layer precursor (DMSP)", & @@ -1066,30 +1104,30 @@ subroutine init_hist_bgc_2D "mixed layer trace gas (DMS)", & "upper ocean", c1, c0, & ns, f_bgc_DMS_ml) - + if (f_fNit(1:1) /= 'x') & call define_hist_field(n_fNit,"fNit","mmol/m^2/s",tstr2D, tcstr, & "nitrate flux ice to ocn (cpl)", & "if positive, ocean gains nitrate", c1, c0, & ns, f_fNit) - + if (f_fNit_ai(1:1) /= 'x') & call define_hist_field(n_fNit_ai,"fNit_ai","mmol/m^2/s",tstr2D, tcstr, & "nitrate flux ice to ocean", & "weighted by ice area", c1, c0, & ns, f_fNit_ai) - + if (f_fAm(1:1) /= 'x') & call define_hist_field(n_fAm,"fAm","mmol/m^2/s",tstr2D, tcstr, & "ammonium flux ice to ocn (cpl)", & "if positive, ocean gains ammonium", c1, c0, & ns, f_fAm) - + if (f_fAm_ai(1:1) /= 'x') & call define_hist_field(n_fAm_ai,"fAm_ai","mmol/m^2/s",tstr2D, tcstr, & "ammonium flux ice to ocean", & "weighted by ice area", c1, c0, & - ns, f_fAm_ai) + ns, f_fAm_ai) if (f_fN(1:1) /= 'x') then do n = 1, n_algae write(nchar,'(i3.3)') n @@ -1129,7 +1167,7 @@ subroutine init_hist_bgc_2D "weighted by ice area", c1, c0, & ns, f_fDOC_ai) enddo - endif + endif if (f_fDIC(1:1) /= 'x') then do n = 1, n_dic write(nchar,'(i3.3)') n @@ -1149,7 +1187,7 @@ subroutine init_hist_bgc_2D "weighted by ice area", c1, c0, & ns, f_fDIC_ai) enddo - endif + endif if (f_fDON(1:1) /= 'x') then do n = 1, n_don write(nchar,'(i3.3)') n @@ -1169,7 +1207,7 @@ subroutine init_hist_bgc_2D "weighted by ice area", c1, c0, & ns, f_fDON_ai) enddo - endif + endif if (f_fFed(1:1) /= 'x') then do n = 1, n_fed write(nchar,'(i3.3)') n @@ -1179,9 +1217,9 @@ subroutine init_hist_bgc_2D "positive to ocean", c1, c0, & ns, f_fFed ) enddo - endif + endif if (f_fFed_ai (1:1) /= 'x') then - do n = 1, n_fed + do n = 1, n_fed write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'fdFe_ai', trim(nchar) call define_hist_field(n_fFed_ai (n,:),vname_in,"umol/m^2/s",tstr2D, tcstr, & @@ -1189,7 +1227,7 @@ subroutine init_hist_bgc_2D "weighted by ice area", c1, c0, & ns, f_fFed_ai ) enddo - endif + endif if (f_fFep(1:1) /= 'x') then do n = 1, n_fep write(nchar,'(i3.3)') n @@ -1201,7 +1239,7 @@ subroutine init_hist_bgc_2D enddo endif if (f_fFep_ai (1:1) /= 'x') then - do n = 1, n_fep + do n = 1, n_fep write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'fpFe_ai', trim(nchar) call define_hist_field(n_fFep_ai (n,:),vname_in,"umol/m^2/s",tstr2D, tcstr, & @@ -1209,25 +1247,25 @@ subroutine init_hist_bgc_2D "weighted by ice area", c1, c0, & ns, f_fFep_ai ) enddo - endif + endif if (f_fSil(1:1) /= 'x') & call define_hist_field(n_fSil,"fSil","mmol/m^2/s",tstr2D, tcstr, & "silicate flux ice to ocn (cpl)", & "positive into ocean", c1, c0, & ns, f_fSil) - + if (f_fSil_ai(1:1) /= 'x') & call define_hist_field(n_fSil_ai,"fSil_ai","mmol/m^2/s",tstr2D, tcstr, & "silicate flux ice to ocean", & "weighted by ice area", c1, c0, & ns, f_fSil_ai) - + if (f_fhum(1:1) /= 'x') & call define_hist_field(n_fhum,"fhum","mmol/m^2/s",tstr2D, tcstr, & "humic matter (carbon) flux ice to ocn (cpl)", & "positive into ocean", c1, c0, & ns, f_fhum) - + if (f_fhum_ai(1:1) /= 'x') & call define_hist_field(n_fhum_ai,"fhum_ai","mmol/m^2/s",tstr2D, tcstr, & "humic matter (carbon) flux ice to ocean", & @@ -1294,19 +1332,19 @@ subroutine init_hist_bgc_2D "weighted by brine or skl volume ", c1, c0, & ns, f_grownet) - if (f_upNO(1:1) /= 'x') & + if (f_upNO(1:1) /= 'x') & call define_hist_field(n_upNO,"upNO","mmol/m^2/d",tstr2D, tcstr, & "Tot algal Nit uptake rate", & "weighted by ice area", c1, c0, & ns, f_upNO) - if (f_upNH(1:1) /= 'x') & + if (f_upNH(1:1) /= 'x') & call define_hist_field(n_upNH,"upNH","mmol/m^2/d",tstr2D, tcstr, & "Tot algal Am uptake rate", & "weighted by ice area", c1, c0,& ns, f_upNH) - ! vertical biogeochemistry + ! vertical biogeochemistry if (z_tracers) then if (f_fzaero(1:1) /= 'x') then @@ -1421,7 +1459,7 @@ subroutine init_hist_bgc_2D enddo endif !f_DONnet if (f_Fednet (1:1) /= 'x') then - do n = 1, n_fed + do n = 1, n_fed write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'dFe_net', trim(nchar) call define_hist_field(n_Fednet (n,:),vname_in,"umol/m^2",tstr2D, tcstr, & @@ -1429,9 +1467,9 @@ subroutine init_hist_bgc_2D "weighted by ice area ", c1, c0, & ns, f_Fednet ) enddo - endif !f_Fednet + endif !f_Fednet if (f_Fepnet (1:1) /= 'x') then - do n = 1, n_fep + do n = 1, n_fep write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'pFe_net', trim(nchar) call define_hist_field(n_Fepnet (n,:),vname_in,"umol/m^2",tstr2D, tcstr, & @@ -1439,7 +1477,7 @@ subroutine init_hist_bgc_2D "weighted by ice area ", c1, c0, & ns, f_Fepnet ) enddo - endif !f_Fepnet + endif !f_Fepnet if (f_Nitnet(1:1) /= 'x') & call define_hist_field(n_Nitnet,"Nit_net","mmol/m^2",tstr2D, tcstr, & "Net Nitrate", & @@ -1459,7 +1497,7 @@ subroutine init_hist_bgc_2D call define_hist_field(n_humnet,"hum_net","mmol/m^2",tstr2D, tcstr, & "Net humic material (carbon)", & "weighted by ice area", c1, c0, & - ns, f_humnet) + ns, f_humnet) if (f_DMSPpnet(1:1) /= 'x') & call define_hist_field(n_DMSPpnet,"DMSPp_net","mmol/m^2",tstr2D, tcstr, & "Net DMSPp", & @@ -1482,7 +1520,7 @@ subroutine init_hist_bgc_2D ns, f_PONnet) if (f_zaerosnow(1:1) /= 'x') then - do n = 1, n_zaero + do n = 1, n_zaero write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'zaero_snow', trim(nchar) call define_hist_field(n_zaerosnow(n,:),vname_in,"kg/m^2",tstr2D, tcstr, & @@ -1552,7 +1590,7 @@ subroutine init_hist_bgc_2D enddo endif !f_DONsnow if (f_Fedsnow (1:1) /= 'x') then - do n = 1, n_fed + do n = 1, n_fed write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'dFe_snow', trim(nchar) call define_hist_field(n_Fedsnow (n,:),vname_in,"umol/m^2",tstr2D, tcstr, & @@ -1560,9 +1598,9 @@ subroutine init_hist_bgc_2D "weighted by ice area ", c1, c0, & ns, f_Fedsnow ) enddo - endif !f_Fedsnow + endif !f_Fedsnow if (f_Fepsnow (1:1) /= 'x') then - do n = 1, n_fed + do n = 1, n_fed write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'pFe_snow', trim(nchar) call define_hist_field(n_Fepsnow (n,:),vname_in,"umol/m^2",tstr2D, tcstr, & @@ -1570,7 +1608,7 @@ subroutine init_hist_bgc_2D "weighted by ice area ", c1, c0, & ns, f_Fepsnow ) enddo - endif !f_Fepsnow + endif !f_Fepsnow if (f_Nitsnow(1:1) /= 'x') & call define_hist_field(n_Nitsnow,"Nit_snow","mmol/m^2",tstr2D, tcstr, & "Snow Nitrate", & @@ -1590,7 +1628,7 @@ subroutine init_hist_bgc_2D call define_hist_field(n_humsnow,"hum_snow","mmol/m^2",tstr2D, tcstr, & "Snow humic material (carbon)", & "weighted by ice area", c1, c0, & - ns, f_humsnow) + ns, f_humsnow) if (f_DMSPpsnow(1:1) /= 'x') & call define_hist_field(n_DMSPpsnow,"DMSPp_snow","mmol/m^2",tstr2D, tcstr, & "Snow DMSPp", & @@ -1613,7 +1651,7 @@ subroutine init_hist_bgc_2D ns, f_PONsnow) if (f_zaerofrac(1:1) /= 'x') then - do n = 1, n_zaero + do n = 1, n_zaero write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'zaero_frac', trim(nchar) call define_hist_field(n_zaerofrac(n,:),vname_in,"1",tstr2D, tcstr, & @@ -1673,7 +1711,7 @@ subroutine init_hist_bgc_2D enddo endif !f_DONfrac if (f_Fedfrac (1:1) /= 'x') then - do n = 1, n_fed + do n = 1, n_fed write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'dFe_frac', trim(nchar) call define_hist_field(n_Fedfrac (n,:),vname_in,"1",tstr2D, tcstr, & @@ -1681,9 +1719,9 @@ subroutine init_hist_bgc_2D "averaged over depth ", c1, c0, & ns, f_Fedfrac ) enddo - endif !f_Fedfrac + endif !f_Fedfrac if (f_Fepfrac (1:1) /= 'x') then - do n = 1, n_fep + do n = 1, n_fep write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'pFe_frac', trim(nchar) call define_hist_field(n_Fepfrac (n,:),vname_in,"1",tstr2D, tcstr, & @@ -1691,7 +1729,7 @@ subroutine init_hist_bgc_2D "averaged over depth ", c1, c0, & ns, f_Fepfrac ) enddo - endif !f_Fepfrac + endif !f_Fepfrac if (f_Nitfrac(1:1) /= 'x') & call define_hist_field(n_Nitfrac,"Nit_frac","1",tstr2D, tcstr, & "Mobile frac Nitrate", & @@ -1711,7 +1749,7 @@ subroutine init_hist_bgc_2D call define_hist_field(n_humfrac,"hum_frac","1",tstr2D, tcstr, & "Mobile frac humic material", & "averaged over depth", c1, c0, & - ns, f_humfrac) + ns, f_humfrac) if (f_DMSPpfrac(1:1) /= 'x') & call define_hist_field(n_DMSPpfrac,"DMSPp_frac","1",tstr2D, tcstr, & "Mobile frac DMSPp", & @@ -1742,18 +1780,17 @@ subroutine init_hist_bgc_2D "distance from ice bottom to brine surface", c1, c0, & ns, f_hbri) - endif ! histfreq(ns) /= 'x' - enddo ! nstreams - - endif ! tr_aero, etc + enddo ! nstreams + endif ! tr_aero, etc + end subroutine init_hist_bgc_2D !======================================================================= subroutine init_hist_bgc_3Dc - use ice_calendar, only: nstreams, histfreq + use ice_calendar, only: nstreams use ice_history_shared, only: tstr3Dc, tcstr, define_hist_field integer (kind=int_kind) :: ns @@ -1765,19 +1802,18 @@ subroutine init_hist_bgc_3Dc if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - if (tr_brine) then + if (tr_brine) then ! 3D (category) variables must be looped separately do ns = 1, nstreams - if (histfreq(ns) /= 'x') then - if (f_fbri(1:1) /= 'x') & - call define_hist_field(n_fbri,"fbrine","1",tstr3Dc, tcstr, & + if (f_fbri(1:1) /= 'x') & + call define_hist_field(n_fbri,"fbrine","1",tstr3Dc, tcstr, & "brine tracer fraction of ice volume, cat", & - "none", c1, c0, ns, f_fbri) - endif ! histfreq /= 'x' + "none", c1, c0, & + ns, f_fbri) enddo ! ns - endif ! tr_brine + endif end subroutine init_hist_bgc_3Dc @@ -1785,27 +1821,27 @@ end subroutine init_hist_bgc_3Dc subroutine init_hist_bgc_3Db - use ice_calendar, only: nstreams,histfreq + use ice_calendar, only: nstreams use ice_history_shared, only: tstr3Db, tcstr, define_hist_field integer (kind=int_kind) :: ns real (kind=dbl_kind) :: secday - logical (kind=log_kind) :: z_tracers + logical (kind=log_kind) :: solve_zsal, z_tracers character(len=*), parameter :: subname = '(init_hist_bgc_3Db)' - + ! biology vertical grid call icepack_query_parameters(secday_out=secday) - call icepack_query_parameters(z_tracers_out=z_tracers) + call icepack_query_parameters( & + solve_zsal_out=solve_zsal, z_tracers_out=z_tracers) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - if (z_tracers) then + if (z_tracers .or. solve_zsal) then do ns = 1, nstreams - if (histfreq(ns) /= 'x') then - + if (f_bTin(1:1) /= 'x') & call define_hist_field(n_bTin,"bTizn","C",tstr3Db, tcstr, & "ice internal temperatures on bio grid", & @@ -1816,26 +1852,30 @@ subroutine init_hist_bgc_3Db call define_hist_field(n_bphi,"bphizn","%",tstr3Db, tcstr, & "porosity", "brine volume fraction", c100, c0, & ns, f_bphi) - - if (f_iDi(1:1) /= 'x') & + + if (f_iDi(1:1) /= 'x') & call define_hist_field(n_iDi,"iDin","m^2/d",tstr3Db, tcstr, & "interface diffusivity", "on bio interface grid", secday, c0, & ns, f_iDi) - - if (f_iki(1:1) /= 'x') & + + if (f_iki(1:1) /= 'x') & call define_hist_field(n_iki,"ikin","mm^2",tstr3Db, tcstr, & "permeability", "on bio interface grid", 1.0e6_dbl_kind, c0, & ns, f_iki) - + + if (f_bgc_S(1:1) /= 'x') & + call define_hist_field(n_bgc_S,"bgc_S","ppt",tstr3Db, tcstr, & + "bulk salinity", "on bio grid", c1, c0, & + ns, f_bgc_S) + if (f_zfswin(1:1) /= 'x') & call define_hist_field(n_zfswin,"zfswin","W/m^2",tstr3Db, tcstr, & "internal ice PAR", "on bio interface grid", c1, c0, & ns, f_zfswin) - - endif ! histfreq(ns) /= 'x' + enddo ! ns - endif ! z_tracers + endif ! z_tracers or solve_zsal end subroutine init_hist_bgc_3Db @@ -1847,16 +1887,16 @@ subroutine accum_hist_bgc (iblk) use ice_arrays_column, only: ocean_bio, & grow_net, PP_net, upNO, upNH, ice_bio_net, snow_bio_net, & - hbri, bTiz, bphi, zfswin, iDi, iki, & + hbri, bTiz, bphi, zfswin, iDi, iki, zsal_tot, fzsal, fzsal_g, & R_C2N, R_chl2N use ice_blocks, only: block, get_block, nx_block, ny_block use ice_domain, only: blocks_ice use ice_domain_size, only: nblyr use ice_flux, only: sss use ice_flux_bgc, only: fiso_atm, fiso_ocn, faero_atm, faero_ocn, & - flux_bio, flux_bio_ai - use ice_history_shared, only: n2D, a2D, a3Dc, & - n3Dzcum, n3Dbcum, a3Db, a3Da, & + flux_bio, flux_bio_ai, fzsal_ai, fzsal_g_ai + use ice_history_shared, only: n2D, a2D, a3Dc, & + n3Dzcum, n3Dbcum, a3Db, a3Da, & ncat_hist, accum_hist_field, nzblyr, nzalyr use ice_state, only: trcrn, trcr, aicen, aice, vicen @@ -1866,33 +1906,33 @@ subroutine accum_hist_bgc (iblk) ! local variables integer (kind=int_kind) :: & - i, j, n, k, & ! loop indices + i, j, n, k, & ! loop indices ilo,ihi,jlo,jhi ! beginning and end of physical domain - real (kind=dbl_kind), dimension (nx_block,ny_block,nblyr+4) :: & + real (kind=dbl_kind), dimension (nx_block,ny_block,nblyr+4) :: & workz, workz2 - real (kind=dbl_kind) :: & + real (kind=dbl_kind) :: & maxv, rhos, rhoi, rhow, puny, sk_l - real (kind=dbl_kind), dimension (nblyr+1) :: & + real (kind=dbl_kind), dimension (nblyr+1) :: & workv - real (kind=dbl_kind), dimension (nx_block,ny_block) :: & + real (kind=dbl_kind), dimension (nx_block,ny_block) :: & workni, worknj - integer (kind=int_kind), dimension (1) :: & + integer (kind=int_kind), dimension (1) :: & worki - integer (kind=int_kind) :: & + integer (kind=int_kind) :: & workii logical (kind=log_kind) :: & - skl_bgc, z_tracers, tr_iso, tr_aero, tr_brine + skl_bgc, z_tracers, tr_iso, tr_aero, tr_brine, solve_zsal integer(kind=int_kind) :: & nt_isosno, nt_isoice, nt_aero, nt_fbri, & nt_bgc_Nit, nt_bgc_Am, nt_bgc_Sil, nt_bgc_DMSPp, & - nt_bgc_DMSPd, nt_bgc_DMS, nt_bgc_PON, & + nt_bgc_DMSPd, nt_bgc_DMS, nt_bgc_PON, nt_bgc_S, & nt_zbgc_frac, nlt_chl_sw, & nlt_bgc_Nit, nlt_bgc_Am, nlt_bgc_Sil, & nlt_bgc_DMS, nlt_bgc_PON, & @@ -1901,9 +1941,9 @@ subroutine accum_hist_bgc (iblk) integer (kind=int_kind), dimension(icepack_max_aero) :: & nlt_zaero_sw ! points to aerosol in trcrn_sw - + integer (kind=int_kind), dimension(icepack_max_algae) :: & - nt_bgc_N, nlt_bgc_N, & ! algae + nt_bgc_N, nlt_bgc_N, & ! algae nt_bgc_C, nlt_bgc_C, & ! nt_bgc_chl, nlt_bgc_chl ! @@ -1933,7 +1973,7 @@ subroutine accum_hist_bgc (iblk) call icepack_query_tracer_flags(tr_iso_out=tr_iso, & tr_aero_out=tr_aero, tr_brine_out=tr_brine) call icepack_query_parameters(skl_bgc_out=skl_bgc, & - z_tracers_out=z_tracers) + solve_zsal_out=solve_zsal, z_tracers_out=z_tracers) call icepack_query_tracer_indices( & nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice, & nt_aero_out=nt_aero, & @@ -1945,7 +1985,7 @@ subroutine accum_hist_bgc (iblk) nt_bgc_Sil_out=nt_bgc_Sil, nt_bgc_DMSPp_out=nt_bgc_DMSPp, & nt_bgc_DMSPd_out=nt_bgc_DMSPd, nt_bgc_DMS_out=nt_bgc_DMS, & nt_bgc_PON_out=nt_bgc_PON, & - nt_bgc_Fed_out=nt_bgc_Fed, & + nt_bgc_S_out=nt_bgc_S, nt_bgc_Fed_out=nt_bgc_Fed, & nt_bgc_Fep_out=nt_bgc_Fep, nt_zbgc_frac_out=nt_zbgc_frac, & nlt_zaero_sw_out=nlt_zaero_sw, nlt_chl_sw_out=nlt_chl_sw, & nlt_bgc_Nit_out=nlt_bgc_Nit, nlt_bgc_Am_out=nlt_bgc_Am, & @@ -1961,8 +2001,8 @@ subroutine accum_hist_bgc (iblk) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - - this_block = get_block(blocks_ice(iblk),iblk) + + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo @@ -1972,10 +2012,21 @@ subroutine accum_hist_bgc (iblk) ! increment field !--------------------------------------------------------------- - ! 2d bgc fields - if (allocated(a2D)) then + if (tr_iso .or. tr_aero .or. tr_brine .or. solve_zsal .or. skl_bgc) then + ! 2d bgc fields - if (tr_iso .or. tr_aero .or. tr_brine .or. skl_bgc) then + + ! zsalinity + if (f_fzsal (1:1) /= 'x') & + call accum_hist_field(n_fzsal, iblk, fzsal(:,:,iblk), a2D) + if (f_fzsal_ai(1:1)/= 'x') & + call accum_hist_field(n_fzsal_ai, iblk, fzsal_ai(:,:,iblk), a2D) + if (f_fzsal_g (1:1) /= 'x') & + call accum_hist_field(n_fzsal_g, iblk, fzsal_g(:,:,iblk), a2D) + if (f_fzsal_g_ai(1:1)/= 'x') & + call accum_hist_field(n_fzsal_g_ai,iblk, fzsal_g_ai(:,:,iblk), a2D) + if (f_zsal (1:1) /= 'x') & + call accum_hist_field(n_zsal, iblk, zsal_tot(:,:,iblk), a2D) ! isotopes if (f_fiso_atm(1:1) /= 'x') then @@ -2025,7 +2076,7 @@ subroutine accum_hist_bgc (iblk) enddo endif - if (skl_bgc) then + if (skl_bgc) then ! skeletal layer bgc @@ -2060,13 +2111,13 @@ subroutine accum_hist_bgc (iblk) enddo endif if (f_bgc_Fed (1:1)/= 'x') then - do n=1,n_fed + do n=1,n_fed call accum_hist_field(n_bgc_Fed (n,:), iblk, & sk_l*trcr(:,:,nt_bgc_Fed (n), iblk), a2D) enddo endif if (f_bgc_Fep (1:1)/= 'x') then - do n=1,n_fep + do n=1,n_fep call accum_hist_field(n_bgc_Fep (n,:), iblk, & sk_l*trcr(:,:,nt_bgc_Fep (n), iblk), a2D) enddo @@ -2079,32 +2130,32 @@ subroutine accum_hist_bgc (iblk) endif if (f_bgc_Nit(1:1)/= 'x') & call accum_hist_field(n_bgc_Nit, iblk, & - sk_l*trcr(:,:,nt_bgc_Nit, iblk), a2D) + sk_l*trcr(:,:,nt_bgc_Nit, iblk), a2D) if (f_bgc_Am(1:1)/= 'x') & call accum_hist_field(n_bgc_Am, iblk, & - sk_l*trcr(:,:,nt_bgc_Am, iblk), a2D) + sk_l*trcr(:,:,nt_bgc_Am, iblk), a2D) if (f_bgc_Sil(1:1)/= 'x') & call accum_hist_field(n_bgc_Sil, iblk, & - sk_l*trcr(:,:,nt_bgc_Sil, iblk), a2D) + sk_l*trcr(:,:,nt_bgc_Sil, iblk), a2D) if (f_bgc_hum(1:1)/= 'x') & call accum_hist_field(n_bgc_hum, iblk, & - sk_l*trcr(:,:,nt_bgc_hum, iblk), a2D) + sk_l*trcr(:,:,nt_bgc_hum, iblk), a2D) if (f_bgc_PON(1:1)/= 'x') & call accum_hist_field(n_bgc_PON, iblk, & - sk_l*trcr(:,:,nt_bgc_PON, iblk), a2D) + sk_l*trcr(:,:,nt_bgc_PON, iblk), a2D) if (f_bgc_DMSPp(1:1)/= 'x') & call accum_hist_field(n_bgc_DMSPp,iblk, & - sk_l*trcr(:,:,nt_bgc_DMSPp,iblk), a2D) + sk_l*trcr(:,:,nt_bgc_DMSPp,iblk), a2D) if (f_bgc_DMSPd(1:1)/= 'x') & call accum_hist_field(n_bgc_DMSPd,iblk, & - sk_l*trcr(:,:,nt_bgc_DMSPd,iblk), a2D) + sk_l*trcr(:,:,nt_bgc_DMSPd,iblk), a2D) if (f_bgc_DMS(1:1)/= 'x') & call accum_hist_field(n_bgc_DMS, iblk, & - sk_l*trcr(:,:,nt_bgc_DMS, iblk), a2D) + sk_l*trcr(:,:,nt_bgc_DMS, iblk), a2D) - endif !skl_bgc + endif !skl_bgc - ! skeletal layer and vertical bgc + ! skeletal layer and vertical bgc if (f_bgc_DOC_ml(1:1)/= 'x') then do n=1,n_doc @@ -2125,13 +2176,13 @@ subroutine accum_hist_bgc (iblk) enddo endif if (f_bgc_Fed_ml (1:1)/= 'x') then - do n=1,n_fed + do n=1,n_fed call accum_hist_field(n_bgc_Fed_ml (n,:), iblk, & ocean_bio(:,:,nlt_bgc_Fed (n), iblk), a2D) enddo endif if (f_bgc_Fep_ml (1:1)/= 'x') then - do n=1,n_fep + do n=1,n_fep call accum_hist_field(n_bgc_Fep_ml (n,:), iblk, & ocean_bio(:,:,nlt_bgc_Fep (n), iblk), a2D) enddo @@ -2144,22 +2195,22 @@ subroutine accum_hist_bgc (iblk) endif if (f_bgc_Nit_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_Nit_ml, iblk, & - ocean_bio(:,:,nlt_bgc_Nit, iblk), a2D) + ocean_bio(:,:,nlt_bgc_Nit, iblk), a2D) if (f_bgc_Am_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_Am_ml, iblk, & - ocean_bio(:,:,nlt_bgc_Am, iblk), a2D) + ocean_bio(:,:,nlt_bgc_Am, iblk), a2D) if (f_bgc_Sil_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_Sil_ml, iblk, & - ocean_bio(:,:,nlt_bgc_Sil, iblk), a2D) + ocean_bio(:,:,nlt_bgc_Sil, iblk), a2D) if (f_bgc_hum_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_hum_ml, iblk, & - ocean_bio(:,:,nlt_bgc_hum, iblk), a2D) + ocean_bio(:,:,nlt_bgc_hum, iblk), a2D) if (f_bgc_DMSP_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_DMSP_ml, iblk, & - ocean_bio(:,:,nlt_bgc_DMSPd, iblk), a2D) + ocean_bio(:,:,nlt_bgc_DMSPd, iblk), a2D) if (f_bgc_DMS_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_DMS_ml, iblk, & - ocean_bio(:,:,nlt_bgc_DMS, iblk), a2D) + ocean_bio(:,:,nlt_bgc_DMS, iblk), a2D) if (f_fNit (1:1) /= 'x') & call accum_hist_field(n_fNit, iblk, & @@ -2223,25 +2274,25 @@ subroutine accum_hist_bgc (iblk) enddo endif if (f_fFed (1:1)/= 'x') then - do n=1,n_fed + do n=1,n_fed call accum_hist_field(n_fFed (n,:), iblk, & flux_bio(:,:,nlt_bgc_Fed (n),iblk), a2D) enddo endif if (f_fFed_ai (1:1)/= 'x') then - do n=1,n_fed + do n=1,n_fed call accum_hist_field(n_fFed_ai (n,:), iblk, & flux_bio_ai(:,:,nlt_bgc_Fed (n),iblk), a2D) enddo endif if (f_fFep (1:1)/= 'x') then - do n=1,n_fep + do n=1,n_fep call accum_hist_field(n_fFep (n,:), iblk, & flux_bio(:,:,nlt_bgc_Fep (n),iblk), a2D) enddo endif if (f_fFep_ai (1:1)/= 'x') then - do n=1,n_fep + do n=1,n_fep call accum_hist_field(n_fFep_ai (n,:), iblk, & flux_bio_ai(:,:,nlt_bgc_Fep (n),iblk), a2D) enddo @@ -2287,7 +2338,7 @@ subroutine accum_hist_bgc (iblk) PP_net(:,:,iblk), a2D) if (f_grownet (1:1) /= 'x') & call accum_hist_field(n_grownet, iblk, & - grow_net(:,:,iblk), a2D) + grow_net(:,:,iblk), a2D) if (f_upNO (1:1) /= 'x') & call accum_hist_field(n_upNO, iblk, & upNO(:,:,iblk), a2D) @@ -2295,9 +2346,9 @@ subroutine accum_hist_bgc (iblk) call accum_hist_field(n_upNH, iblk, & upNH(:,:,iblk), a2D) - ! vertical biogeochemistry + ! vertical biogeochemistry - if (z_tracers) then + if (z_tracers) then if (f_fzaero(1:1)/= 'x') then do n=1,n_zaero @@ -2336,7 +2387,7 @@ subroutine accum_hist_bgc (iblk) enddo ! n endif !f_algalpeak - ! + ! ! ice_bio_net ! if (f_zaeronet (1:1) /= 'x') then @@ -2364,35 +2415,35 @@ subroutine accum_hist_bgc (iblk) enddo endif !f_Cnet if (f_DOCnet (1:1) /= 'x') then - do n=1,n_doc + do n=1,n_doc call accum_hist_field(n_DOCnet(n,:), iblk, & ice_bio_net(:,:,nlt_bgc_DOC(n), iblk), a2D) enddo endif !f_DOCnet if (f_DICnet (1:1) /= 'x') then - do n=1,n_dic + do n=1,n_dic call accum_hist_field(n_DICnet(n,:), iblk, & ice_bio_net(:,:,nlt_bgc_DIC(n), iblk), a2D) enddo endif !f_DICnet if (f_DONnet (1:1) /= 'x') then - do n=1,n_don + do n=1,n_don call accum_hist_field(n_DONnet(n,:), iblk, & ice_bio_net(:,:,nlt_bgc_DON(n), iblk), a2D) enddo endif !f_DONnet if (f_Fednet (1:1) /= 'x') then - do n=1,n_fed + do n=1,n_fed call accum_hist_field(n_Fednet (n,:), iblk, & ice_bio_net(:,:,nlt_bgc_Fed (n), iblk), a2D) enddo - endif !f_Fednet + endif !f_Fednet if (f_Fepnet (1:1) /= 'x') then - do n=1,n_fep + do n=1,n_fep call accum_hist_field(n_Fepnet (n,:), iblk, & ice_bio_net(:,:,nlt_bgc_Fep (n), iblk), a2D) enddo - endif !f_Fepnet + endif !f_Fepnet if (f_Nitnet (1:1) /= 'x') & call accum_hist_field(n_Nitnet, iblk, & @@ -2420,7 +2471,7 @@ subroutine accum_hist_bgc (iblk) ice_bio_net(:,:,nlt_bgc_PON, iblk), a2D) ! ! snow_bio_net - ! + ! if (f_zaerosnow (1:1) /= 'x') then do n=1,n_zaero call accum_hist_field(n_zaerosnow(n,:), iblk, & @@ -2446,35 +2497,35 @@ subroutine accum_hist_bgc (iblk) enddo endif !f_Csnow if (f_DOCsnow (1:1) /= 'x') then - do n=1,n_doc + do n=1,n_doc call accum_hist_field(n_DOCsnow(n,:), iblk, & snow_bio_net(:,:,nlt_bgc_DOC(n), iblk), a2D) enddo endif !f_DOCsnow if (f_DICsnow (1:1) /= 'x') then - do n=1,n_dic + do n=1,n_dic call accum_hist_field(n_DICsnow(n,:), iblk, & snow_bio_net(:,:,nlt_bgc_DIC(n), iblk), a2D) enddo endif !f_DICsnow if (f_DONsnow (1:1) /= 'x') then - do n=1,n_don + do n=1,n_don call accum_hist_field(n_DONsnow(n,:), iblk, & snow_bio_net(:,:,nlt_bgc_DON(n), iblk), a2D) enddo endif !f_DONsnow if (f_Fedsnow (1:1) /= 'x') then - do n=1,n_fed + do n=1,n_fed call accum_hist_field(n_Fedsnow (n,:), iblk, & snow_bio_net(:,:,nlt_bgc_Fed (n), iblk), a2D) enddo - endif !f_Fedsnow + endif !f_Fedsnow if (f_Fepsnow (1:1) /= 'x') then - do n=1,n_fep + do n=1,n_fep call accum_hist_field(n_Fepsnow (n,:), iblk, & snow_bio_net(:,:,nlt_bgc_Fep (n), iblk), a2D) enddo - endif !f_Fepsnow + endif !f_Fepsnow if (f_Nitsnow (1:1) /= 'x') & call accum_hist_field(n_Nitsnow, iblk, & @@ -2502,7 +2553,7 @@ subroutine accum_hist_bgc (iblk) snow_bio_net(:,:,nlt_bgc_PON, iblk), a2D) ! ! mobile frac - ! + ! if (f_zaerofrac (1:1) /= 'x') then do n=1,n_zaero call accum_hist_field(n_zaerofrac(n,:), iblk, & @@ -2522,35 +2573,35 @@ subroutine accum_hist_bgc (iblk) enddo endif !f_Nfrac if (f_DOCfrac (1:1) /= 'x') then - do n=1,n_doc + do n=1,n_doc call accum_hist_field(n_DOCfrac(n,:), iblk, & trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DOC(n), iblk), a2D) enddo endif !f_DOCfrac if (f_DICfrac (1:1) /= 'x') then - do n=1,n_dic + do n=1,n_dic call accum_hist_field(n_DICfrac(n,:), iblk, & trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DIC(n), iblk), a2D) enddo endif !f_DICfrac if (f_DONfrac (1:1) /= 'x') then - do n=1,n_don + do n=1,n_don call accum_hist_field(n_DONfrac(n,:), iblk, & trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DON(n), iblk), a2D) enddo endif !f_DONfrac if (f_Fedfrac (1:1) /= 'x') then - do n=1,n_fed + do n=1,n_fed call accum_hist_field(n_Fedfrac (n,:), iblk, & trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Fed (n), iblk), a2D) enddo - endif !f_Fedfrac + endif !f_Fedfrac if (f_Fepfrac (1:1) /= 'x') then - do n=1,n_fep + do n=1,n_fep call accum_hist_field(n_Fepfrac (n,:), iblk, & trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Fep (n), iblk), a2D) enddo - endif !f_Fepfrac + endif !f_Fepfrac if (f_Nitfrac (1:1) /= 'x') & call accum_hist_field(n_Nitfrac, iblk, & @@ -2563,7 +2614,7 @@ subroutine accum_hist_bgc (iblk) trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Sil, iblk), a2D) if (f_humfrac (1:1) /= 'x') & call accum_hist_field(n_humfrac, iblk, & - trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_hum, iblk), a2D) + trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_hum, iblk), a2D) if (f_DMSPpfrac (1:1) /= 'x') & call accum_hist_field(n_DMSPpfrac, iblk, & trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DMSPp, iblk), a2D) @@ -2577,30 +2628,27 @@ subroutine accum_hist_bgc (iblk) call accum_hist_field(n_PONfrac, iblk, & trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_PON, iblk), a2D) - endif ! z_tracers + endif ! z_tracers ! brine if (f_hbri (1:1) /= 'x') & call accum_hist_field(n_hbri, iblk, & hbri(:,:,iblk), a2D) - endif ! 2d bgc tracers, tr_aero, tr_brine, skl_bgc - endif ! allocated(a2D) + endif ! 2d bgc tracers, tr_aero, tr_brine, solve_zsal, skl_bgc + ! 3D category fields - if (allocated(a3Dc)) then - if (tr_brine) then + if (tr_brine) then ! 3Dc bgc category fields if (f_fbri (1:1) /= 'x') & call accum_hist_field(n_fbri-n2D, iblk, ncat_hist, & trcrn(:,:,nt_fbri,1:ncat_hist,iblk), a3Dc) - endif - endif ! allocated(a3Dc) + endif - if (allocated(a3Db)) then - if (z_tracers) then + if (z_tracers .or. solve_zsal) then ! 3Db category fields if (f_bTin (1:1) /= 'x') then @@ -2635,6 +2683,21 @@ subroutine accum_hist_bgc (iblk) workz(:,:,1:nzblyr), a3Db) endif + if (f_bgc_S (1:1) /= 'x') then + workz(:,:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi + if (aice(i,j,iblk) > c0) then + workz(i,j,1) = trcr(i,j,nt_bgc_S,iblk) + workz(i,j,2:nblyr+1) = trcr(i,j,nt_bgc_S:nt_bgc_S+nblyr-1,iblk) + workz(i,j,nblyr+2) = sss(i,j,iblk) + endif + enddo ! i + enddo ! j + call accum_hist_field(n_bgc_S-n3Dzcum, iblk, nzblyr, & + workz(:,:,1:nzblyr), a3Db) + endif + if (f_zfswin (1:1) /= 'x') then workz(:,:,:) = c0 do n = 1, ncat_hist @@ -2661,11 +2724,11 @@ subroutine accum_hist_bgc (iblk) do i = ilo, ihi if (aicen(i,j,n,iblk) > c0) then workz(i,j,k) = workz(i,j,k) + iDi(i,j,k,n,iblk)*vicen(i,j,n,iblk)**2/aicen(i,j,n,iblk) - workz(i,j,nzblyr) = workz(i,j,nzblyr-1) + workz(i,j,nzblyr) = workz(i,j,nzblyr-1) endif enddo ! i enddo ! j - enddo ! k + enddo ! k enddo ! n call accum_hist_field(n_iDi-n3Dzcum, iblk, nzblyr, & workz(:,:,1:nzblyr), a3Db) @@ -2685,17 +2748,15 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - enddo ! k + enddo ! k enddo ! n call accum_hist_field(n_iki-n3Dzcum, iblk, nzblyr, & workz(:,:,1:nzblyr), a3Db) endif - endif ! 3Db fields - endif ! allocated(a3Db) + endif ! 3Db fields - if (allocated(a3Da)) then - if (z_tracers) then + if (z_tracers) then ! 3Da category fields if (f_zaero (1:1) /= 'x') then @@ -2703,7 +2764,7 @@ subroutine accum_hist_bgc (iblk) workz(:,:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) then + if (aice(i,j,iblk) > puny) then workz(i,j,1:2) = & !snow trcr(i,j,nt_zaero(k)+nblyr+1:nt_zaero(k)+nblyr+2,iblk)/rhos workz(i,j,3:nblyr+3) = & !ice @@ -2711,7 +2772,7 @@ subroutine accum_hist_bgc (iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_zaero(k),iblk)/rhow !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_zaeros(k,:)-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) enddo !k @@ -2722,14 +2783,14 @@ subroutine accum_hist_bgc (iblk) workz2(:,:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) then + if (aice(i,j,iblk) > puny) then workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_N(k)+nblyr+1:nt_bgc_N(k)+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice trcr(i,j,nt_bgc_N(k):nt_bgc_N(k)+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_N(k),iblk) !ocean endif - if (aicen(i,j,1,iblk) > puny) then + if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_N(k)+nblyr+1:nt_bgc_N(k)+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice @@ -2737,7 +2798,7 @@ subroutine accum_hist_bgc (iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_N(k),iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_N(k,:)-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_N_cat1(k,:)-n3Dbcum, iblk, nzalyr, & @@ -2749,7 +2810,7 @@ subroutine accum_hist_bgc (iblk) workz(:,:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) then + if (aice(i,j,iblk) > puny) then workz(i,j,1:2) = & !snow R_C2N(k)*trcr(i,j,nt_bgc_N(k)+nblyr+1:nt_bgc_N(k)+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice @@ -2757,25 +2818,25 @@ subroutine accum_hist_bgc (iblk) workz(i,j,nblyr+4) = R_C2N(k)*ocean_bio(i,j,nlt_bgc_N(k),iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_C(k,:)-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) enddo !k endif !f_bgc_C if (f_bgc_DOC (1:1) /= 'x') then - do k = 1,n_doc + do k = 1,n_doc workz(:,:,:) = c0 workz2(:,:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) then + if (aice(i,j,iblk) > puny) then workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_DOC(k)+nblyr+1:nt_bgc_DOC(k)+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice trcr(i,j,nt_bgc_DOC(k):nt_bgc_DOC(k)+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DOC(k),iblk) !ocean endif - if (aicen(i,j,1,iblk) > puny) then + if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_DOC(k)+nblyr+1:nt_bgc_DOC(k)+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice @@ -2783,7 +2844,7 @@ subroutine accum_hist_bgc (iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DOC(k),iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_DOC(k,:)-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_DOC_cat1(k,:)-n3Dbcum, iblk, nzalyr, & @@ -2791,19 +2852,19 @@ subroutine accum_hist_bgc (iblk) enddo !k endif !f_bgc_DOC if (f_bgc_DIC (1:1) /= 'x') then - do k = 1,n_dic + do k = 1,n_dic workz(:,:,:) = c0 workz2(:,:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) then + if (aice(i,j,iblk) > puny) then workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_DIC(k)+nblyr+1:nt_bgc_DIC(k)+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice trcr(i,j,nt_bgc_DIC(k):nt_bgc_DIC(k)+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DIC(k),iblk) !ocean endif - if (aicen(i,j,1,iblk) > puny) then + if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_DIC(k)+nblyr+1:nt_bgc_DIC(k)+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice @@ -2811,7 +2872,7 @@ subroutine accum_hist_bgc (iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DIC(k),iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_DIC(k,:)-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_DIC_cat1(k,:)-n3Dbcum, iblk, nzalyr, & @@ -2819,19 +2880,19 @@ subroutine accum_hist_bgc (iblk) enddo !k endif !f_bgc_DIC if (f_bgc_DON (1:1) /= 'x') then - do k = 1,n_don + do k = 1,n_don workz(:,:,:) = c0 workz2(:,:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) then + if (aice(i,j,iblk) > puny) then workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_DON(k)+nblyr+1:nt_bgc_DON(k)+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice trcr(i,j,nt_bgc_DON(k):nt_bgc_DON(k)+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DON(k),iblk) !ocean endif - if (aicen(i,j,1,iblk) > puny) then + if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_DON(k)+nblyr+1:nt_bgc_DON(k)+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice @@ -2839,7 +2900,7 @@ subroutine accum_hist_bgc (iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DON(k),iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_DON(k,:)-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_DON_cat1(k,:)-n3Dbcum, iblk, nzalyr, & @@ -2847,19 +2908,19 @@ subroutine accum_hist_bgc (iblk) enddo !k endif !f_bgc_DON if (f_bgc_Fed (1:1) /= 'x') then - do k = 1,n_fed + do k = 1,n_fed workz(:,:,:) = c0 workz2(:,:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) then + if (aice(i,j,iblk) > puny) then workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_Fed (k)+nblyr+1:nt_bgc_Fed (k)+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice trcr(i,j,nt_bgc_Fed (k):nt_bgc_Fed (k)+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_Fed (k),iblk) !ocean endif - if (aicen(i,j,1,iblk) > puny) then + if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_Fed (k)+nblyr+1:nt_bgc_Fed (k)+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice @@ -2867,27 +2928,27 @@ subroutine accum_hist_bgc (iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_Fed (k),iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_Fed (k,:)-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_Fed_cat1 (k,:)-n3Dbcum, iblk, nzalyr, & workz2(:,:,1:nzalyr), a3Da) enddo !k - endif !f_bgc_Fed + endif !f_bgc_Fed if (f_bgc_Fep (1:1) /= 'x') then - do k = 1,n_fep + do k = 1,n_fep workz(:,:,:) = c0 workz2(:,:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) then + if (aice(i,j,iblk) > puny) then workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_Fep (k)+nblyr+1:nt_bgc_Fep (k)+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice trcr(i,j,nt_bgc_Fep (k):nt_bgc_Fep (k)+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_Fep (k),iblk) !ocean endif - if (aicen(i,j,1,iblk) > puny) then + if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_Fep (k)+nblyr+1:nt_bgc_Fep (k)+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice @@ -2895,19 +2956,19 @@ subroutine accum_hist_bgc (iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_Fep (k),iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_Fep (k,:)-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_Fep_cat1 (k,:)-n3Dbcum, iblk, nzalyr, & workz2(:,:,1:nzalyr), a3Da) enddo !k - endif !f_bgc_Fep + endif !f_bgc_Fep if (f_bgc_chl (1:1) /= 'x') then do k = 1,n_algae workz(:,:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) then + if (aice(i,j,iblk) > puny) then workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_chl(k)+nblyr+1:nt_bgc_chl(k)+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice @@ -2915,12 +2976,12 @@ subroutine accum_hist_bgc (iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_chl(k),iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_chl(k,:)-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) enddo !k endif !f_bgc_chl - + if (f_bgc_Nit (1:1) /= 'x') then workz(:,:,:) = c0 workz2(:,:,:) = c0 @@ -2930,18 +2991,18 @@ subroutine accum_hist_bgc (iblk) workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_Nit+nblyr+2:nt_bgc_Nit+nblyr+3,iblk) workz(i,j,3:nblyr+3) = & !ice - trcr(i,j,nt_bgc_Nit:nt_bgc_Nit+nblyr,iblk) + trcr(i,j,nt_bgc_Nit:nt_bgc_Nit+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_Nit,iblk) !ocean endif if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_Nit+nblyr+2:nt_bgc_Nit+nblyr+3,1,iblk) workz2(i,j,3:nblyr+3) = & !ice - trcrn(i,j,nt_bgc_Nit:nt_bgc_Nit+nblyr,1,iblk) + trcrn(i,j,nt_bgc_Nit:nt_bgc_Nit+nblyr,1,iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_Nit,iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_Nit-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_Nit_cat1-n3Dbcum, iblk, nzalyr, & @@ -2957,18 +3018,18 @@ subroutine accum_hist_bgc (iblk) workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_Am+nblyr+1:nt_bgc_Am+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice - trcr(i,j,nt_bgc_Am:nt_bgc_Am+nblyr,iblk) + trcr(i,j,nt_bgc_Am:nt_bgc_Am+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_Am,iblk) !ocean endif if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_Am+nblyr+1:nt_bgc_Am+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice - trcrn(i,j,nt_bgc_Am:nt_bgc_Am+nblyr,1,iblk) + trcrn(i,j,nt_bgc_Am:nt_bgc_Am+nblyr,1,iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_Am,iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_Am-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_Am_cat1-n3Dbcum, iblk, nzalyr, & @@ -2984,24 +3045,24 @@ subroutine accum_hist_bgc (iblk) workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_Sil+nblyr+1:nt_bgc_Sil+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice - trcr(i,j,nt_bgc_Sil:nt_bgc_Sil+nblyr,iblk) + trcr(i,j,nt_bgc_Sil:nt_bgc_Sil+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_Sil,iblk) !ocean endif if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_Sil+nblyr+1:nt_bgc_Sil+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice - trcrn(i,j,nt_bgc_Sil:nt_bgc_Sil+nblyr,1,iblk) + trcrn(i,j,nt_bgc_Sil:nt_bgc_Sil+nblyr,1,iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_Sil,iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_Sil-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_Sil_cat1-n3Dbcum, iblk, nzalyr, & workz2(:,:,1:nzalyr), a3Da) endif - + if (f_bgc_hum (1:1) /= 'x') then workz(:,:,:) = c0 @@ -3012,24 +3073,24 @@ subroutine accum_hist_bgc (iblk) workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_hum+nblyr+1:nt_bgc_hum+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice - trcr(i,j,nt_bgc_hum:nt_bgc_hum+nblyr,iblk) + trcr(i,j,nt_bgc_hum:nt_bgc_hum+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_hum,iblk) !ocean endif if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_hum+nblyr+1:nt_bgc_hum+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice - trcrn(i,j,nt_bgc_hum:nt_bgc_hum+nblyr,1,iblk) + trcrn(i,j,nt_bgc_hum:nt_bgc_hum+nblyr,1,iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_hum,iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_hum-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_hum_cat1-n3Dbcum, iblk, nzalyr, & workz2(:,:,1:nzalyr), a3Da) endif - + if (f_bgc_DMSPd (1:1) /= 'x') then workz(:,:,:) = c0 workz2(:,:,:) = c0 @@ -3039,23 +3100,23 @@ subroutine accum_hist_bgc (iblk) workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_DMSPd+nblyr+1:nt_bgc_DMSPd+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice - trcr(i,j,nt_bgc_DMSPd:nt_bgc_DMSPd+nblyr,iblk) + trcr(i,j,nt_bgc_DMSPd:nt_bgc_DMSPd+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DMSPd,iblk) !ocean endif if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_DMSPd+nblyr+1:nt_bgc_DMSPd+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice - trcrn(i,j,nt_bgc_DMSPd:nt_bgc_DMSPd+nblyr,1,iblk) + trcrn(i,j,nt_bgc_DMSPd:nt_bgc_DMSPd+nblyr,1,iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DMSPd,iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_DMSPd-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_DMSPd_cat1-n3Dbcum, iblk, nzalyr, & workz2(:,:,1:nzalyr), a3Da) - endif + endif if (f_bgc_DMSPp (1:1) /= 'x') then workz(:,:,:) = c0 @@ -3065,11 +3126,11 @@ subroutine accum_hist_bgc (iblk) workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_DMSPp+nblyr+1:nt_bgc_DMSPp+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice - trcr(i,j,nt_bgc_DMSPp:nt_bgc_DMSPp+nblyr,iblk) + trcr(i,j,nt_bgc_DMSPp:nt_bgc_DMSPp+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DMSPp,iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_DMSPp-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) endif @@ -3083,18 +3144,18 @@ subroutine accum_hist_bgc (iblk) workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_DMS+nblyr+1:nt_bgc_DMS+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice - trcr(i,j,nt_bgc_DMS:nt_bgc_DMS+nblyr,iblk) + trcr(i,j,nt_bgc_DMS:nt_bgc_DMS+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DMS,iblk) !ocean endif if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_DMS+nblyr+1:nt_bgc_DMS+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice - trcrn(i,j,nt_bgc_DMS:nt_bgc_DMS+nblyr,1,iblk) + trcrn(i,j,nt_bgc_DMS:nt_bgc_DMS+nblyr,1,iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_DMS,iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_DMS-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_DMS_cat1-n3Dbcum, iblk, nzalyr, & @@ -3110,26 +3171,25 @@ subroutine accum_hist_bgc (iblk) workz(i,j,1:2) = & !snow trcr(i,j,nt_bgc_PON+nblyr+1:nt_bgc_PON+nblyr+2,iblk) workz(i,j,3:nblyr+3) = & !ice - trcr(i,j,nt_bgc_PON:nt_bgc_PON+nblyr,iblk) + trcr(i,j,nt_bgc_PON:nt_bgc_PON+nblyr,iblk) workz(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_PON,iblk) !ocean endif if (aicen(i,j,1,iblk) > puny) then workz2(i,j,1:2) = & !snow trcrn(i,j,nt_bgc_PON+nblyr+1:nt_bgc_PON+nblyr+2,1,iblk) workz2(i,j,3:nblyr+3) = & !ice - trcrn(i,j,nt_bgc_PON:nt_bgc_PON+nblyr,1,iblk) + trcrn(i,j,nt_bgc_PON:nt_bgc_PON+nblyr,1,iblk) workz2(i,j,nblyr+4) = ocean_bio(i,j,nlt_bgc_PON,iblk) !ocean endif enddo ! i - enddo ! j + enddo ! j call accum_hist_field(n_bgc_PON-n3Dbcum, iblk, nzalyr, & workz(:,:,1:nzalyr), a3Da) call accum_hist_field(n_bgc_PON_cat1-n3Dbcum, iblk, nzalyr, & workz2(:,:,1:nzalyr), a3Da) endif - endif ! z_tracers, 3Da tracers - endif ! allocated(a3Da) + endif ! z_tracers, 3Da tracers end subroutine accum_hist_bgc @@ -3137,7 +3197,7 @@ end subroutine accum_hist_bgc subroutine init_hist_bgc_3Da - use ice_calendar, only: nstreams, histfreq + use ice_calendar, only: nstreams use ice_history_shared, only: tstr3Da, tcstr, define_hist_field integer (kind=int_kind) :: ns, n @@ -3145,19 +3205,18 @@ subroutine init_hist_bgc_3Da character (len=3) :: nchar character (len=16):: vname_in ! variable name character(len=*), parameter :: subname = '(init_hist_bgc_3Da)' - + call icepack_query_parameters(z_tracers_out=z_tracers) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - ! snow+bio grid - - if (z_tracers) then + ! snow+bio grid - do ns = 1, nstreams - if (histfreq(ns) /= 'x') then + if (z_tracers) then + do ns = 1, nstreams + !---------------------------------------------------------------------------- ! snow+bio grid ==> ! 1:2 snow (surface layer +interior), 3:nblyr+2 ice (bio grid), nblyr+3 ocean @@ -3172,12 +3231,12 @@ subroutine init_hist_bgc_3Da ns, f_zaero) enddo endif - - if (f_bgc_Nit(1:1) /= 'x') & + + if (f_bgc_Nit(1:1) /= 'x') & call define_hist_field(n_bgc_Nit,"bgc_Nit","mmol/m^3",tstr3Da, tcstr, & "bulk nitrate ", "snow+bio grid", c1, c0, & ns, f_bgc_Nit) - + if (f_bgc_Am(1:1) /= 'x') & call define_hist_field(n_bgc_Am,"bgc_Am","mmol/m^3",tstr3Da, tcstr, & "bulk ammonia/um ", "snow+bio grid", c1, c0, & @@ -3238,7 +3297,7 @@ subroutine init_hist_bgc_3Da enddo endif if (f_bgc_Fed (1:1) /= 'x') then - do n=1,n_fed + do n=1,n_fed write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'bgc_Fed', trim(nchar) call define_hist_field(n_bgc_Fed (n,:),vname_in,"umol/m^3",tstr3Da, tcstr, & @@ -3247,7 +3306,7 @@ subroutine init_hist_bgc_3Da enddo endif if (f_bgc_Fep (1:1) /= 'x') then - do n=1,n_fep + do n=1,n_fep write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'bgc_Fep', trim(nchar) call define_hist_field(n_bgc_Fep (n,:),vname_in,"umol/m^3",tstr3Da, tcstr, & @@ -3255,32 +3314,32 @@ subroutine init_hist_bgc_3Da ns, f_bgc_Fep ) enddo endif - + if (f_bgc_Sil(1:1) /= 'x') & call define_hist_field(n_bgc_Sil,"bgc_Sil","mmol/m^3",tstr3Da, tcstr, & "bulk silicate ", "snow+bio grid", c1, c0, & ns, f_bgc_Sil) - + if (f_bgc_hum(1:1) /= 'x') & call define_hist_field(n_bgc_hum,"bgc_hum","mmol/m^3",tstr3Da, tcstr, & "bulk humic (carbon) material ", "snow+bio grid", c1, c0, & ns, f_bgc_hum) - + if (f_bgc_DMSPp(1:1) /= 'x') & call define_hist_field(n_bgc_DMSPp,"bgc_DMSPp","mmol/m^3",tstr3Da, tcstr, & "bulk algal DMSP ", "snow+bio grid", c1, c0,& ns, f_bgc_DMSPp) - + if (f_bgc_DMSPd(1:1) /= 'x') & call define_hist_field(n_bgc_DMSPd,"bgc_DMSPd","mmol/m^3",tstr3Da, tcstr, & "bulk dissolved DMSP ", "snow+bio grid", c1, c0, & ns, f_bgc_DMSPd) - + if (f_bgc_DMS(1:1) /= 'x') & call define_hist_field(n_bgc_DMS,"bgc_DMS","mmol/m^3",tstr3Da, tcstr, & "bulk DMS gas ", "snow+bio grid", c1, c0, & ns, f_bgc_DMS) - + if (f_bgc_PON(1:1) /= 'x') & call define_hist_field(n_bgc_PON,"bgc_PON","mmol/m^3",tstr3Da, tcstr, & "other bulk nitrogen pool ", "snow+bio grid", c1, c0, & @@ -3290,11 +3349,11 @@ subroutine init_hist_bgc_3Da ! Category 1 BGC !---------------------------------------------- - if (f_bgc_Nit_cat1(1:1) /= 'x') & + if (f_bgc_Nit_cat1(1:1) /= 'x') & call define_hist_field(n_bgc_Nit_cat1,"bgc_Nit_cat1","mmol/m^3",tstr3Da, tcstr, & "bulk nitrate in cat 1 ", "snow+bio grid", c1, c0, & ns, f_bgc_Nit_cat1) - + if (f_bgc_Am_cat1(1:1) /= 'x') & call define_hist_field(n_bgc_Am_cat1,"bgc_Am_cat1","mmol/m^3",tstr3Da, tcstr, & "bulk ammonia/um in cat 1", "snow+bio grid", c1, c0, & @@ -3337,7 +3396,7 @@ subroutine init_hist_bgc_3Da enddo endif if (f_bgc_Fed_cat1 (1:1) /= 'x') then - do n=1,n_fed + do n=1,n_fed write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'bgc_Fed_cat1', trim(nchar) call define_hist_field(n_bgc_Fed_cat1 (n,:),vname_in,"umol/m^3",tstr3Da, tcstr, & @@ -3346,7 +3405,7 @@ subroutine init_hist_bgc_3Da enddo endif if (f_bgc_Fep_cat1 (1:1) /= 'x') then - do n=1,n_fep + do n=1,n_fep write(nchar,'(i3.3)') n write(vname_in,'(a,a)') 'bgc_Fep_cat1', trim(nchar) call define_hist_field(n_bgc_Fep_cat1 (n,:),vname_in,"umol/m^3",tstr3Da, tcstr, & @@ -3354,33 +3413,32 @@ subroutine init_hist_bgc_3Da ns, f_bgc_Fep_cat1 ) enddo endif - + if (f_bgc_Sil_cat1(1:1) /= 'x') & call define_hist_field(n_bgc_Sil_cat1,"bgc_Sil_cat1","mmol/m^3",tstr3Da, tcstr, & "bulk silicate in cat 1", "snow+bio grid", c1, c0, & ns, f_bgc_Sil_cat1) - + if (f_bgc_hum_cat1(1:1) /= 'x') & call define_hist_field(n_bgc_hum,"bgc_hum_cat1","mmol/m^3",tstr3Da, tcstr, & "bulk humic (carbon) material in cat 1", "snow+bio grid", c1, c0, & ns, f_bgc_hum_cat1) - + if (f_bgc_DMSPd_cat1(1:1) /= 'x') & call define_hist_field(n_bgc_DMSPd_cat1,"bgc_DMSPd_cat1","mmol/m^3",tstr3Da, tcstr, & "bulk dissolved DMSP in cat 1", "snow+bio grid", c1, c0, & ns, f_bgc_DMSPd_cat1) - + if (f_bgc_DMS_cat1(1:1) /= 'x') & call define_hist_field(n_bgc_DMS_cat1,"bgc_DMS_cat1","mmol/m^3",tstr3Da, tcstr, & "bulk DMS gas in cat 1", "snow+bio grid", c1, c0, & ns, f_bgc_DMS_cat1) - + if (f_bgc_PON_cat1(1:1) /= 'x') & call define_hist_field(n_bgc_PON_cat1,"bgc_PON_cat1","mmol/m^3",tstr3Da, tcstr, & "other bulk nitrogen pool in cat 1", "snow+bio grid", c1, c0, & ns, f_bgc_PON_cat1) - - endif ! histfreq(ns) /= 'x' + enddo !ns endif ! z_tracers @@ -3398,7 +3456,7 @@ subroutine init_history_bgc use ice_arrays_column, only: PP_net, grow_net, hbri, & ice_bio_net, snow_bio_net, fbio_snoice, fbio_atmice, & - zfswin + fzsal, fzsal_g, zfswin use ice_flux_bgc, only: flux_bio, flux_bio_ai, fnit, fsil, & famm, fdmsp, fdms, fhum, fdust, falgalN, fdoc, fdic, & fdon, ffep, ffed @@ -3414,6 +3472,8 @@ subroutine init_history_bgc snow_bio_net(:,:,:,:) = c0 fbio_snoice (:,:,:,:) = c0 fbio_atmice (:,:,:,:) = c0 + fzsal (:,:,:) = c0 + fzsal_g (:,:,:) = c0 zfswin (:,:,:,:,:) = c0 fnit (:,:,:) = c0 fsil (:,:,:) = c0 diff --git a/cicecore/cicedyn/dynamics/ice_transport_driver.F90 b/cicecore/cicedyn/dynamics/ice_transport_driver.F90 index 8ff833086..7eaba64cf 100644 --- a/cicecore/cicedyn/dynamics/ice_transport_driver.F90 +++ b/cicecore/cicedyn/dynamics/ice_transport_driver.F90 @@ -2,12 +2,12 @@ ! ! Drivers for remapping and upwind ice transport ! -! authors: Elizabeth C. Hunke and William H. Lipscomb, LANL +! authors: Elizabeth C. Hunke and William H. Lipscomb, LANL ! ! 2004: Revised by William Lipscomb from ice_transport_mpdata. ! Stripped out mpdata, retained upwind, and added block structure. ! 2006: Incorporated remap transport driver and renamed from -! ice_transport_upwind. +! ice_transport_upwind. ! 2011: ECH moved edgearea arrays into ice_transport_remap.F90 module ice_transport_driver @@ -17,9 +17,7 @@ module ice_transport_driver use ice_constants, only: c0, c1, p5, & field_loc_center, & field_type_scalar, field_type_vector, & - field_loc_NEcorner, & field_loc_Nface, field_loc_Eface - use ice_diagnostics, only: diagnostic_abort use ice_fileunits, only: nu_diag use ice_exit, only: abort_ice use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted @@ -37,30 +35,30 @@ module ice_transport_driver ! 'upwind' => 1st order donor cell scheme ! 'remap' => remapping scheme + logical, parameter :: & ! if true, prescribe area flux across each edge + l_fixed_area = .false. + ! NOTE: For remapping, hice and hsno are considered tracers. ! ntrace is not equal to ntrcr! integer (kind=int_kind) :: & ntrace ! number of tracers in use - + integer (kind=int_kind), dimension(:), allocatable, public :: & - tracer_type , & ! = 1, 2, or 3 (depends on 0, 1 or 2 other tracers) + tracer_type ,&! = 1, 2, or 3 (depends on 0, 1 or 2 other tracers) depend ! tracer dependencies (see below) logical (kind=log_kind), dimension (:), allocatable, public :: & has_dependents ! true if a tracer has dependent tracers - logical (kind=log_kind), public :: & - conserv_check ! if true, check conservation - integer (kind=int_kind), parameter :: & - integral_order = 3 ! polynomial order of quadrature integrals - ! linear=1, quadratic=2, cubic=3 + integral_order = 3 ! polynomial order of quadrature integrals + ! linear=1, quadratic=2, cubic=3 logical (kind=log_kind), parameter :: & - l_dp_midpt = .true. ! if true, find departure points using - ! corrected midpoint velocity - + l_dp_midpt = .true. ! if true, find departure points using + ! corrected midpoint velocity + !======================================================================= contains @@ -78,161 +76,143 @@ subroutine init_transport use ice_state, only: trcr_depend use ice_timers, only: ice_timer_start, ice_timer_stop, timer_advect use ice_transport_remap, only: init_remap - use ice_grid, only: grid_ice integer (kind=int_kind) :: & k, nt, nt1 ! tracer indices - integer (kind=int_kind) :: & - ntrcr , nt_Tsfc , nt_qice , nt_qsno , & - nt_sice , nt_fbri , nt_iage , nt_FY , & - nt_alvl , nt_vlvl , & - nt_apnd , nt_hpnd , nt_ipnd , nt_fsd , & - nt_smice , nt_smliq , nt_rhos , nt_rsnw , & - nt_isosno, nt_isoice, nt_bgc_Nit + integer (kind=int_kind) :: ntrcr, nt_Tsfc, nt_qice, nt_qsno, & + nt_sice, nt_fbri, nt_iage, nt_FY, nt_alvl, nt_vlvl, & + nt_apnd, nt_hpnd, nt_ipnd, nt_fsd, nt_isosno, nt_isoice, nt_bgc_Nit, nt_bgc_S character(len=*), parameter :: subname = '(init_transport)' - call ice_timer_start(timer_advect) ! advection + call ice_timer_start(timer_advect) ! advection call icepack_query_tracer_sizes(ntrcr_out=ntrcr) call icepack_query_tracer_indices(nt_Tsfc_out=nt_Tsfc, nt_qice_out=nt_qice, & - nt_qsno_out=nt_qsno, nt_sice_out=nt_sice, nt_fbri_out=nt_fbri, & - nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_fsd_out=nt_fsd, & - nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, & - nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, & - nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, nt_rhos_out=nt_rhos, & - nt_rsnw_out=nt_rsnw, nt_bgc_Nit_out=nt_bgc_Nit, & - nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) + nt_qsno_out=nt_qsno, nt_sice_out=nt_sice, nt_fbri_out=nt_fbri, & + nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_alvl_out=nt_alvl, nt_fsd_out=nt_fsd, & + nt_vlvl_out=nt_vlvl, nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, & + nt_ipnd_out=nt_ipnd, nt_bgc_Nit_out=nt_bgc_Nit, nt_bgc_S_out=nt_bgc_S, & + nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) ntrace = 2 + ntrcr ! hice,hsno,trcr - if (allocated(tracer_type)) deallocate(tracer_type) - if (allocated(depend)) deallocate(depend) + if (allocated(tracer_type)) deallocate(tracer_type) + if (allocated(depend)) deallocate(depend) if (allocated(has_dependents)) deallocate(has_dependents) allocate (tracer_type (ntrace), & depend (ntrace), & has_dependents(ntrace)) - ! define tracer dependency arrays - ! see comments in remapping routine - - depend(1:2) = 0 ! hice, hsno - tracer_type(1:2) = 1 ! no dependency - - k = 2 - - do nt = 1, ntrcr - depend(k+nt) = trcr_depend(nt) ! 0 for ice area tracers - ! 1 for ice volume tracers - ! 2 for snow volume tracers - tracer_type(k+nt) = 2 ! depends on 1 other tracer - if (trcr_depend(nt) == 0) then - tracer_type(k+nt) = 1 ! depends on no other tracers - elseif (trcr_depend(nt) > 2) then - if (trcr_depend(trcr_depend(nt)-2) > 0) then - tracer_type(k+nt) = 3 ! depends on 2 other tracers - endif - endif - enddo - - has_dependents = .false. - do nt = 1, ntrace - if (depend(nt) > 0) then - nt1 = depend(nt) - has_dependents(nt1) = .true. - if (nt1 > nt) then - write(nu_diag,*) & - 'Tracer nt2 =',nt,' depends on tracer nt1 =',nt1 - call abort_ice(subname// & - 'ERROR: remap transport: Must have nt2 > nt1') - endif - endif - enddo ! ntrace - - ! diagnostic output - if (my_task == master_task) then - write (nu_diag, *) 'tracer index depend type has_dependents' - nt = 1 - write(nu_diag,1000) 'hi ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - nt = 2 - write(nu_diag,1000) 'hs ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - k=2 - do nt = k+1, k+ntrcr - if (nt-k==nt_Tsfc) & - write(nu_diag,1000) 'nt_Tsfc ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_qice) & - write(nu_diag,1000) 'nt_qice ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_qsno) & - write(nu_diag,1000) 'nt_qsno ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_sice) & - write(nu_diag,1000) 'nt_sice ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_fbri) & - write(nu_diag,1000) 'nt_fbri ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_iage) & - write(nu_diag,1000) 'nt_iage ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_FY) & - write(nu_diag,1000) 'nt_FY ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_alvl) & - write(nu_diag,1000) 'nt_alvl ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_vlvl) & - write(nu_diag,1000) 'nt_vlvl ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_apnd) & - write(nu_diag,1000) 'nt_apnd ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_hpnd) & - write(nu_diag,1000) 'nt_hpnd ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_ipnd) & - write(nu_diag,1000) 'nt_ipnd ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_smice) & - write(nu_diag,1000) 'nt_smice ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_smliq) & - write(nu_diag,1000) 'nt_smliq ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_rhos) & - write(nu_diag,1000) 'nt_rhos ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_rsnw) & - write(nu_diag,1000) 'nt_rsnw ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_fsd) & - write(nu_diag,1000) 'nt_fsd ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_isosno) & - write(nu_diag,1000) 'nt_isosno ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_isoice) & - write(nu_diag,1000) 'nt_isoice ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - if (nt-k==nt_bgc_Nit) & - write(nu_diag,1000) 'nt_bgc_Nit ',nt,depend(nt),tracer_type(nt),& - has_dependents(nt) - enddo - write(nu_diag,*) ' ' - endif ! master_task - 1000 format (1x,a,2x,i6,2x,i6,2x,i4,4x,l4) - - if (trim(advection)=='remap') call init_remap ! grid quantities - - call ice_timer_stop(timer_advect) ! advection + ! define tracer dependency arrays + ! see comments in remapping routine + + depend(1:2) = 0 ! hice, hsno + tracer_type(1:2) = 1 ! no dependency + + k = 2 + + do nt = 1, ntrcr + depend(k+nt) = trcr_depend(nt) ! 0 for ice area tracers + ! 1 for ice volume tracers + ! 2 for snow volume tracers + tracer_type(k+nt) = 2 ! depends on 1 other tracer + if (trcr_depend(nt) == 0) then + tracer_type(k+nt) = 1 ! depends on no other tracers + elseif (trcr_depend(nt) > 2) then + if (trcr_depend(trcr_depend(nt)-2) > 0) then + tracer_type(k+nt) = 3 ! depends on 2 other tracers + endif + endif + enddo + + has_dependents = .false. + do nt = 1, ntrace + if (depend(nt) > 0) then + nt1 = depend(nt) + has_dependents(nt1) = .true. + if (nt1 > nt) then + write(nu_diag,*) & + 'Tracer nt2 =',nt,' depends on tracer nt1 =',nt1 + call abort_ice(subname// & + 'ERROR: remap transport: Must have nt2 > nt1') + endif + endif + enddo ! ntrace + + ! diagnostic output + if (my_task == master_task) then + write (nu_diag, *) 'tracer index depend type has_dependents' + nt = 1 + write(nu_diag,*) ' hi ',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + nt = 2 + write(nu_diag,*) ' hs ',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + k=2 + do nt = k+1, k+ntrcr + if (nt-k==nt_Tsfc) & + write(nu_diag,*) 'nt_Tsfc',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_qice) & + write(nu_diag,*) 'nt_qice',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_qsno) & + write(nu_diag,*) 'nt_qsno',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_sice) & + write(nu_diag,*) 'nt_sice',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_fbri) & + write(nu_diag,*) 'nt_fbri',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_iage) & + write(nu_diag,*) 'nt_iage',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_FY) & + write(nu_diag,*) 'nt_FY ', nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_alvl) & + write(nu_diag,*) 'nt_alvl',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_vlvl) & + write(nu_diag,*) 'nt_vlvl',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_apnd) & + write(nu_diag,*) 'nt_apnd',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_hpnd) & + write(nu_diag,*) 'nt_hpnd',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_ipnd) & + write(nu_diag,*) 'nt_ipnd',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_fsd) & + write(nu_diag,*) 'nt_fsd ',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_isosno) & + write(nu_diag,*) 'nt_isosno',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_isoice) & + write(nu_diag,*) 'nt_isoice',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_bgc_Nit) & + write(nu_diag,*) 'nt_bgc_Nit',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + if (nt-k==nt_bgc_S) & + write(nu_diag,*) 'nt_bgc_S',nt,depend(nt),tracer_type(nt),& + has_dependents(nt) + enddo + endif ! master_task + + if (trim(advection)=='remap') call init_remap ! grid quantities + + call ice_timer_stop(timer_advect) ! advection end subroutine init_transport @@ -245,7 +225,7 @@ end subroutine init_transport ! ! This scheme preserves monotonicity of ice area and tracers. That is, ! it does not produce new extrema. It is second-order accurate in space, -! except where gradients are limited to preserve monotonicity. +! except where gradients are limited to preserve monotonicity. ! ! authors William H. Lipscomb, LANL @@ -258,8 +238,8 @@ subroutine transport_remap (dt) use ice_domain_size, only: ncat, max_blocks use ice_blocks, only: nx_block, ny_block, block, get_block, nghost use ice_state, only: aice0, aicen, vicen, vsnon, trcrn, & - uvel, vvel, bound_state, uvelE, vvelN - use ice_grid, only: tarea, grid_ice + uvel, vvel, bound_state + use ice_grid, only: tarea use ice_calendar, only: istep1 use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_advect, timer_bound @@ -270,105 +250,105 @@ subroutine transport_remap (dt) ! local variables - integer (kind=int_kind) :: & - iblk , & ! block index - ilo,ihi,jlo,jhi, & ! beginning and end of physical domain - n , & ! ice category index - nt, nt1, nt2 ! tracer indices - - real (kind=dbl_kind), dimension (nx_block,ny_block,0:ncat,max_blocks) :: & - aim , & ! mean ice category areas in each grid cell + integer (kind=int_kind) :: & + iblk ,&! block index + ilo,ihi,jlo,jhi,&! beginning and end of physical domain + n ,&! ice category index + nt, nt1, nt2 ! tracer indices + + real (kind=dbl_kind), & + dimension (nx_block,ny_block,0:ncat,max_blocks) :: & + aim ,&! mean ice category areas in each grid cell aimask ! = 1. if ice is present, = 0. otherwise - real (kind=dbl_kind), dimension (nx_block,ny_block,ntrace,ncat,max_blocks) :: & - trm , & ! mean tracer values in each grid cell + real (kind=dbl_kind), & + dimension (nx_block,ny_block,ntrace,ncat,max_blocks) :: & + trm ,&! mean tracer values in each grid cell trmask ! = 1. if tracer is present, = 0. otherwise - logical (kind=log_kind) :: & - ckflag ! if true, abort the model + logical (kind=log_kind) :: & + l_stop ! if true, abort the model - integer (kind=int_kind) :: & - istop, jstop ! indices of grid cell where model aborts + integer (kind=int_kind) :: & + istop, jstop ! indices of grid cell where model aborts - integer (kind=int_kind), dimension(0:ncat,max_blocks) :: & + integer (kind=int_kind), dimension(0:ncat,max_blocks) :: & icellsnc ! number of cells with ice - integer (kind=int_kind), dimension(nx_block*ny_block,0:ncat,max_blocks) :: & - indxinc, indxjnc ! compressed i/j indices + integer (kind=int_kind), & + dimension(nx_block*ny_block,0:ncat,max_blocks) :: & + indxinc, indxjnc ! compressed i/j indices integer (kind=int_kind) :: & - ntrcr ! number of tracers + ntrcr type (block) :: & - this_block ! block information for current block - + this_block ! block information for current block + ! variables related to optional bug checks - logical (kind=log_kind), parameter :: & + logical (kind=log_kind), parameter :: & + l_conservation_check = .false. ,&! if true, check conservation l_monotonicity_check = .false. ! if true, check monotonicity - real (kind=dbl_kind), dimension(0:ncat) :: & - asum_init , & ! initial global ice area + real (kind=dbl_kind), dimension(0:ncat) :: & + asum_init ,&! initial global ice area asum_final ! final global ice area - real (kind=dbl_kind), dimension(ntrace,ncat) :: & - atsum_init , & ! initial global ice area*tracer + real (kind=dbl_kind), dimension(ntrace,ncat) :: & + atsum_init ,&! initial global ice area*tracer atsum_final ! final global ice area*tracer - real (kind=dbl_kind), dimension (:,:,:,:,:), allocatable :: & - tmin , & ! local min tracer - tmax ! local max tracer + real (kind=dbl_kind), dimension (:,:,:,:,:), allocatable :: & + tmin ,&! local min tracer + tmax ! local max tracer - integer (kind=int_kind) :: & - alloc_error + integer (kind=int_kind) :: alloc_error real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks) :: & work1 - character(len=char_len_long) :: & - fieldid - character(len=*), parameter :: subname = '(transport_remap)' - call ice_timer_start(timer_advect) ! advection + call ice_timer_start(timer_advect) ! advection call icepack_query_tracer_sizes(ntrcr_out=ntrcr) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - !------------------------------------------------------------------- - ! Prepare for remapping. - ! Initialize, update ghost cells, fill tracer arrays. - !------------------------------------------------------------------- +!---!------------------------------------------------------------------- +!---! Prepare for remapping. +!---! Initialize, update ghost cells, fill tracer arrays. +!---!------------------------------------------------------------------- - ckflag = .false. + l_stop = .false. istop = 0 jstop = 0 - !------------------------------------------------------------------- - ! Compute open water area in each grid cell. - ! Note: An aggregate_area call is needed only if the open - ! water area has changed since the previous call. - ! Here we assume that aice0 is up to date. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Compute open water area in each grid cell. + ! Note: An aggregate_area call is needed only if the open + ! water area has changed since the previous call. + ! Here we assume that aice0 is up to date. + !------------------------------------------------------------------- -! !$OMP PARALLEL DO PRIVATE(i,j,iblk) SCHEDULE(runtime) +! !$OMP PARALLEL DO PRIVATE(i,j,iblk) ! do iblk = 1, nblocks ! do j = 1, ny_block ! do i = 1, nx_block ! call aggregate_area (ncat, ! aicen(i,j,:,iblk), & ! aice (i,j, iblk), & -! aice0(i,j, iblk)) +! aice0(i,j, iblk)) ! enddo ! enddo ! enddo ! !$OMP END PARALLEL DO - !------------------------------------------------------------------- - ! Ghost cell updates for state variables. - ! Commented out because ghost cells are updated after cleanup_itd. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Ghost cell updates for state variables. + ! Commented out because ghost cells are updated after cleanup_itd. + !------------------------------------------------------------------- ! call ice_timer_start(timer_bound) ! call ice_HaloUpdate (aice0, halo_info, & @@ -380,11 +360,11 @@ subroutine transport_remap (dt) ! call ice_timer_stop(timer_bound) - !------------------------------------------------------------------- - ! Ghost cell updates for ice velocity. - ! Commented out because ghost cell velocities are computed - ! in ice_dyn_evp. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Ghost cell updates for ice velocity. + ! Commented out because ghost cell velocities are computed + ! in ice_dyn_evp. + !------------------------------------------------------------------- ! call ice_timer_start(timer_bound) ! call ice_HaloUpdate (uvel, halo_info, & @@ -394,32 +374,33 @@ subroutine transport_remap (dt) ! call ice_timer_stop(timer_bound) - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) +! MHRI: CHECK THIS OMP ... maybe ok: Were trcrn(:,:,1:ntrcr,:,iblk) in my testcode + !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks - !------------------------------------------------------------------- - ! Fill arrays with fields to be remapped. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Fill arrays with fields to be remapped. + !------------------------------------------------------------------- - call state_to_tracers(nx_block, ny_block, & - ntrcr, ntrace, & - aice0(:,:, iblk), aicen(:,:,:, iblk), & - trcrn(:,:,:,:,iblk), & - vicen(:,:,:, iblk), vsnon(:,:,:, iblk), & - aim (:,:,:, iblk), trm (:,:,:,:,iblk)) + call state_to_tracers(nx_block, ny_block, & + ntrcr, ntrace, & + aice0(:,:, iblk), aicen(:,:,:,iblk), & + trcrn(:,:,:,:,iblk), & + vicen(:,:,:,iblk), vsnon(:,:, :,iblk), & + aim (:,:,:,iblk), trm (:,:,:,:,iblk)) enddo !$OMP END PARALLEL DO - !------------------------------------------------------------------- - ! Optional conservation and monotonicity checks. - !------------------------------------------------------------------- +!---!------------------------------------------------------------------- +!---! Optional conservation and monotonicity checks. +!---!------------------------------------------------------------------- - if (conserv_check) then + if (l_conservation_check) then - !------------------------------------------------------------------- - ! Compute initial values of globally conserved quantities. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Compute initial values of globally conserved quantities. + !------------------------------------------------------------------- do n = 0, ncat asum_init(n) = global_sum(aim(:,:,n,:), distrb_info, & @@ -453,8 +434,8 @@ subroutine transport_remap (dt) enddo ! nt enddo ! n - endif ! conserv_check - + endif ! l_conservation_check + if (l_monotonicity_check) then allocate(tmin(nx_block,ny_block,ntrace,ncat,max_blocks), & @@ -467,35 +448,35 @@ subroutine transport_remap (dt) tmin(:,:,:,:,:) = c0 tmax(:,:,:,:,:) = c0 - !$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block,n) SCHEDULE(runtime) + !$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block,n) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi - !------------------------------------------------------------------- - ! Compute masks. - ! Masks are used to prevent tracer values in cells without ice - ! from being used in the monotonicity check. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Compute masks. + ! Masks are used to prevent tracer values in cells without ice + ! from being used in the monotonicity check. + !------------------------------------------------------------------- call make_masks (nx_block, ny_block, & ilo, ihi, jlo, jhi, & nghost, ntrace, & has_dependents, & - icellsnc (:,iblk), & - indxinc(:,:,iblk), indxjnc(:,:, iblk), & - aim(:,:,:, iblk), aimask(:,:,:, iblk), & + icellsnc(:,iblk), & + indxinc(:,:,iblk), indxjnc(:,:,iblk), & + aim(:,:,:,iblk), aimask(:,:,:,iblk), & trm(:,:,:,:,iblk), trmask(:,:,:,:,iblk)) - !------------------------------------------------------------------- - ! Compute local max and min of tracer fields. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Compute local max and min of tracer fields. + !------------------------------------------------------------------- do n = 1, ncat - call local_max_min & + call local_max_min & (nx_block, ny_block, & ilo, ihi, jlo, jhi, & trm (:,:,:,n,iblk), & @@ -512,18 +493,18 @@ subroutine transport_remap (dt) field_loc_center, field_type_scalar) call ice_timer_stop(timer_bound) - !$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block,n) SCHEDULE(runtime) + !$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block,n) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi do n = 1, ncat - call quasilocal_max_min (nx_block, ny_block, & - ilo, ihi, jlo, jhi, & - tmin(:,:,:,n,iblk), & + call quasilocal_max_min (nx_block, ny_block, & + ilo, ihi, jlo, jhi, & + tmin(:,:,:,n,iblk), & tmax(:,:,:,n,iblk)) enddo enddo @@ -531,47 +512,39 @@ subroutine transport_remap (dt) endif ! l_monotonicity_check - !------------------------------------------------------------------- - ! Main remapping routine: Step ice area and tracers forward in time. - !------------------------------------------------------------------- - - if (grid_ice == 'CD' .or. grid_ice == 'C') then - call horizontal_remap (dt, ntrace, & - uvel (:,:,:), vvel (:,:,:), & - aim (:,:,:,:), trm(:,:,:,:,:), & - tracer_type, depend, & - has_dependents, integral_order, & - l_dp_midpt, & - uvelE (:,:,:), vvelN (:,:,:)) - else - call horizontal_remap (dt, ntrace, & - uvel (:,:,:), vvel (:,:,:), & - aim (:,:,:,:), trm(:,:,:,:,:), & - tracer_type, depend, & - has_dependents, integral_order, & - l_dp_midpt) - endif - - !------------------------------------------------------------------- - ! Given new fields, recompute state variables. - !------------------------------------------------------------------- - - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) + !------------------------------------------------------------------- + ! Main remapping routine: Step ice area and tracers forward in time. + !------------------------------------------------------------------- + + call horizontal_remap (dt, ntrace, & + uvel (:,:,:), vvel (:,:,:), & + aim (:,:,:,:), trm (:,:,:,:,:), & + l_fixed_area, & + tracer_type, depend, & + has_dependents, integral_order, & + l_dp_midpt) + + !------------------------------------------------------------------- + ! Given new fields, recompute state variables. + !------------------------------------------------------------------- + +! MHRI: CHECK THIS OMP ... maybe ok: Were trcrn(:,:,1:ntrcr,:,iblk) in my testcode + !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks - call tracers_to_state (nx_block, ny_block, & - ntrcr, ntrace, & - aim (:,:,:, iblk), trm (:,:,:,:,iblk), & - aice0(:,:, iblk), aicen(:,:,:, iblk), & - trcrn(:,:,:,:,iblk), & - vicen(:,:,:, iblk), vsnon(:,:, :,iblk)) + call tracers_to_state (nx_block, ny_block, & + ntrcr, ntrace, & + aim (:,:,:,iblk), trm (:,:,:,:,iblk), & + aice0(:,:, iblk), aicen(:,:,:,iblk), & + trcrn(:,:,:,:,iblk), & + vicen(:,:,:,iblk), vsnon(:,:, :,iblk)) enddo ! iblk !$OMP END PARALLEL DO - !------------------------------------------------------------------- - ! Ghost cell updates for state variables. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Ghost cell updates for state variables. + !------------------------------------------------------------------- call ice_timer_start(timer_bound) @@ -581,16 +554,16 @@ subroutine transport_remap (dt) call ice_timer_stop(timer_bound) - !------------------------------------------------------------------- - ! Optional conservation and monotonicity checks - !------------------------------------------------------------------- +!---!------------------------------------------------------------------- +!---! Optional conservation and monotonicity checks +!---!------------------------------------------------------------------- - !------------------------------------------------------------------- - ! Compute final values of globally conserved quantities. - ! Check global conservation of area and area*tracers. (Optional) - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Compute final values of globally conserved quantities. + ! Check global conservation of area and area*tracers. (Optional) + !------------------------------------------------------------------- - if (conserv_check) then + if (l_conservation_check) then do n = 0, ncat asum_final(n) = global_sum(aim(:,:,n,:), distrb_info, & @@ -625,27 +598,25 @@ subroutine transport_remap (dt) enddo ! n if (my_task == master_task) then - fieldid = subname//':000' - call global_conservation (ckflag, fieldid, & + call global_conservation (l_stop, & asum_init(0), asum_final(0)) - if (ckflag) then - write (nu_diag,*) 'istep1, my_task =', & - istep1, my_task + if (l_stop) then + write (nu_diag,*) 'istep1, my_task, iblk =', & + istep1, my_task, iblk write (nu_diag,*) 'transport: conservation error, cat 0' call abort_ice(subname//'ERROR: conservation error1') endif - do n = 1, ncat - write(fieldid,'(a,i3.3)') subname,n + do n = 1, ncat call global_conservation & - (ckflag, fieldid, & + (l_stop, & asum_init(n), asum_final(n), & atsum_init(:,n), atsum_final(:,n)) - if (ckflag) then - write (nu_diag,*) 'istep1, my_task, cat =', & - istep1, my_task, n + if (l_stop) then + write (nu_diag,*) 'istep1, my_task, iblk, cat =', & + istep1, my_task, iblk, n write (nu_diag,*) 'transport: conservation error, cat ',n call abort_ice(subname//'ERROR: conservation error2') endif @@ -653,37 +624,38 @@ subroutine transport_remap (dt) endif ! my_task = master_task - endif ! conserv_check + endif ! l_conservation_check - !------------------------------------------------------------------- - ! Check tracer monotonicity. (Optional) - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Check tracer monotonicity. (Optional) + !------------------------------------------------------------------- if (l_monotonicity_check) then - !$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block,n,ckflag,istop,jstop) SCHEDULE(runtime) + !$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block,n,l_stop,istop,jstop) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi - ckflag = .false. + l_stop = .false. istop = 0 jstop = 0 do n = 1, ncat - call check_monotonicity (nx_block, ny_block, & - ilo, ihi, jlo, jhi, & - tmin(:,:,:,n,iblk), tmax(:,:,:,n,iblk), & - aim (:,:, n,iblk), trm (:,:,:,n,iblk), & - ckflag, & - istop, jstop) - - if (ckflag) then + call check_monotonicity & + (nx_block, ny_block, & + ilo, ihi, jlo, jhi, & + tmin(:,:,:,n,iblk), tmax(:,:,:,n,iblk), & + aim (:,:, n,iblk), trm (:,:,:,n,iblk), & + l_stop, & + istop, jstop) + + if (l_stop) then write (nu_diag,*) 'istep1, my_task, iblk, cat =', & istep1, my_task, iblk, n - call diagnostic_abort(istop,jstop,iblk,' monotonicity error') + call abort_ice(subname//'ERROR: monotonicity error') endif enddo ! n @@ -695,8 +667,8 @@ subroutine transport_remap (dt) endif ! l_monotonicity_check - call ice_timer_stop(timer_advect) ! advection - + call ice_timer_stop(timer_advect) ! advection + end subroutine transport_remap !======================================================================= @@ -712,36 +684,37 @@ subroutine transport_upwind (dt) use ice_domain_size, only: ncat, max_blocks use ice_state, only: aice0, aicen, vicen, vsnon, trcrn, & uvel, vvel, trcr_depend, bound_state, trcr_base, & - n_trcr_strata, nt_strata, uvelE, vvelN - use ice_grid, only: HTE, HTN, tarea, tmask, grid_ice + n_trcr_strata, nt_strata + use ice_grid, only: HTE, HTN, tarea use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_bound, timer_advect - real (kind=dbl_kind), intent(in) :: & + real (kind=dbl_kind), intent(in) :: & dt ! time step ! local variables - integer (kind=int_kind) :: & - ntrcr , & ! + integer (kind=int_kind) :: & + ntrcr, & ! narr ! max number of state variable arrays - integer (kind=int_kind) :: & - i, j, iblk , & ! horizontal indices + integer (kind=int_kind) :: & + i, j, iblk ,&! horizontal indices ilo,ihi,jlo,jhi ! beginning and end of physical domain - real (kind=dbl_kind), dimension (nx_block,ny_block,nblocks) :: & + real (kind=dbl_kind), dimension (nx_block,ny_block,nblocks) :: & uee, vnn ! cell edge velocities - real (kind=dbl_kind), dimension (:,:,:,:), allocatable :: & + real (kind=dbl_kind), & + dimension (:,:,:,:), allocatable :: & works ! work array type (block) :: & - this_block ! block information for current block + this_block ! block information for current block character(len=*), parameter :: subname = '(transport_upwind)' - call ice_timer_start(timer_advect) ! advection + call ice_timer_start(timer_advect) ! advection call icepack_query_tracer_sizes(ntrcr_out=ntrcr) call icepack_warnings_flush(nu_diag) @@ -752,64 +725,54 @@ subroutine transport_upwind (dt) allocate (works(nx_block,ny_block,narr,max_blocks)) - !------------------------------------------------------------------- - ! Get ghost cell values of state variables. - ! (Assume velocities are already known for ghost cells, also.) - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Get ghost cell values of state variables. + ! (Assume velocities are already known for ghost cells, also.) + !------------------------------------------------------------------- ! call bound_state (aicen, & ! vicen, vsnon, & ! ntrcr, trcrn) -! call ice_timer_start(timer_bound) -! call ice_HaloUpdate (uvel, halo_info, & -! field_loc_NEcorner, field_type_vector) -! call ice_HaloUpdate (vvel, halo_info, & -! field_loc_NEcorner, field_type_vector) -! call ice_timer_stop(timer_bound) - - !------------------------------------------------------------------- - ! Average corner velocities to edges. - !------------------------------------------------------------------- - if (grid_ice == 'CD' .or. grid_ice == 'C') then - uee(:,:,:)=uvelE(:,:,:) - vnn(:,:,:)=vvelN(:,:,:) - else - !$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) SCHEDULE(runtime) - do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) - ilo = this_block%ilo - ihi = this_block%ihi - jlo = this_block%jlo - jhi = this_block%jhi + !------------------------------------------------------------------- + ! Average corner velocities to edges. + !------------------------------------------------------------------- + + !$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) + do iblk = 1, nblocks + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi - do j = jlo, jhi - do i = ilo, ihi - uee(i,j,iblk) = p5*(uvel(i,j,iblk) + uvel(i ,j-1,iblk)) - vnn(i,j,iblk) = p5*(vvel(i,j,iblk) + vvel(i-1,j ,iblk)) - enddo - enddo + do j = jlo, jhi + do i = ilo, ihi + uee(i,j,iblk) = p5*(uvel(i,j,iblk) + uvel(i,j-1,iblk)) + vnn(i,j,iblk) = p5*(vvel(i,j,iblk) + vvel(i-1,j,iblk)) enddo - !$OMP END PARALLEL DO + enddo + enddo + !$OMP END PARALLEL DO - call ice_timer_start(timer_bound) - call ice_HaloUpdate (uee, halo_info, & - field_loc_Eface, field_type_vector) - call ice_HaloUpdate (vnn, halo_info, & - field_loc_Nface, field_type_vector) - call ice_timer_stop(timer_bound) - endif + call ice_timer_start(timer_bound) + call ice_HaloUpdate (uee, halo_info, & + field_loc_Eface, field_type_vector) + call ice_HaloUpdate (vnn, halo_info, & + field_loc_Nface, field_type_vector) + call ice_timer_stop(timer_bound) - !$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block) SCHEDULE(runtime) + !$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi - !----------------------------------------------------------------- - ! fill work arrays with fields to be advected - !----------------------------------------------------------------- + + !----------------------------------------------------------------- + ! fill work arrays with fields to be advected + !----------------------------------------------------------------- call state_to_work (nx_block, ny_block, & ntrcr, & @@ -818,39 +781,38 @@ subroutine transport_upwind (dt) vicen (:,:, :,iblk), vsnon (:,:, :,iblk), & aice0 (:,:, iblk), works (:,:, :,iblk)) - !----------------------------------------------------------------- - ! advect - !----------------------------------------------------------------- + !----------------------------------------------------------------- + ! advect + !----------------------------------------------------------------- call upwind_field (nx_block, ny_block, & ilo, ihi, jlo, jhi, & dt, & narr, works(:,:,:,iblk), & - uee (:,:,iblk), vnn (:,:,iblk), & - HTE (:,:,iblk), HTN (:,:,iblk), & + uee(:,:,iblk), vnn (:,:,iblk), & + HTE(:,:,iblk), HTN (:,:,iblk), & tarea(:,:,iblk)) - !----------------------------------------------------------------- - ! convert work arrays back to state variables - !----------------------------------------------------------------- + !----------------------------------------------------------------- + ! convert work arrays back to state variables + !----------------------------------------------------------------- call work_to_state (nx_block, ny_block, & ntrcr, narr, & trcr_depend(:), trcr_base(:,:), & n_trcr_strata(:), nt_strata(:,:), & - tmask(:,:, iblk), & aicen(:,:, :,iblk), trcrn (:,:,:,:,iblk), & vicen(:,:, :,iblk), vsnon (:,:, :,iblk), & - aice0(:,:, iblk), works (:,:, :,iblk)) + aice0(:,:, iblk), works (:,:, :,iblk)) enddo ! iblk !$OMP END PARALLEL DO - + deallocate (works) - !------------------------------------------------------------------- - ! Ghost cell updates for state variables. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Ghost cell updates for state variables. + !------------------------------------------------------------------- call ice_timer_start(timer_bound) @@ -860,7 +822,7 @@ subroutine transport_upwind (dt) call ice_timer_stop(timer_bound) - call ice_timer_stop(timer_advect) ! advection + call ice_timer_stop(timer_advect) ! advection end subroutine transport_upwind @@ -870,7 +832,7 @@ end subroutine transport_upwind !======================================================================= ! ! Fill ice area and tracer arrays. -! Assume that the advected tracers are hicen, hsnon, trcrn, +! Assume that the advected tracers are hicen, hsnon, trcrn, ! qicen(1:nilyr), and qsnon(1:nslyr). ! This subroutine must be modified if a different set of tracers ! is to be transported. The rule for ordering tracers @@ -889,47 +851,47 @@ subroutine state_to_tracers (nx_block, ny_block, & use ice_domain_size, only: ncat, nslyr integer (kind=int_kind), intent(in) :: & - nx_block, ny_block, & ! block dimensions - ntrcr , & ! number of tracers in use - ntrace ! number of tracers in use incl. hi, hs + nx_block, ny_block, & ! block dimensions + ntrcr , & ! number of tracers in use + ntrace ! number of tracers in use incl. hi, hs real (kind=dbl_kind), dimension (nx_block,ny_block), intent(in) :: & - aice0 ! fractional open water area + aice0 ! fractional open water area real (kind=dbl_kind), dimension (nx_block,ny_block,ncat), intent(in) :: & - aicen , & ! fractional ice area - vicen , & ! volume per unit area of ice (m) - vsnon ! volume per unit area of snow (m) + aicen ,&! fractional ice area + vicen ,&! volume per unit area of ice (m) + vsnon ! volume per unit area of snow (m) real (kind=dbl_kind), dimension (nx_block,ny_block,ntrcr,ncat), intent(in) :: & - trcrn ! ice area tracers + trcrn ! ice area tracers real (kind=dbl_kind), dimension (nx_block,ny_block,0:ncat), intent(out) :: & - aim ! mean ice area in each grid cell + aim ! mean ice area in each grid cell real (kind=dbl_kind), dimension (nx_block,ny_block,ntrace,ncat), intent(out) :: & - trm ! mean tracer values in each grid cell + trm ! mean tracer values in each grid cell ! local variables integer (kind=int_kind) :: & - nt_qsno , & ! - i, j, n , & ! standard indices - it, kt , & ! tracer indices - ij ! combined i/j index + nt_qsno ,&! + i, j, n ,&! standard indices + it, kt ,&! tracer indices + ij ! combined i/j index real (kind=dbl_kind) :: & - puny , & ! - rhos , & ! snow density (km/m^3) - Lfresh , & ! latent heat of melting fresh ice (J/kg) - w1 ! work variable + puny ,&! + rhos ,&! + Lfresh ,&! + w1 ! work variable integer (kind=int_kind), dimension(nx_block*ny_block,0:ncat) :: & - indxi , & ! compressed i/j indices - indxj + indxi ,&! compressed i/j indices + indxj integer (kind=int_kind), dimension(0:ncat) :: & - icells ! number of cells with ice + icells ! number of cells with ice character(len=*), parameter :: subname = '(state_to_tracers)' @@ -946,9 +908,9 @@ subroutine state_to_tracers (nx_block, ny_block, & trm(:,:,:,n) = c0 - !------------------------------------------------------------------- - ! Find grid cells where ice is present and fill area array. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Find grid cells where ice is present and fill area array. + !------------------------------------------------------------------- icells(n) = 0 do j = 1, ny_block @@ -962,13 +924,13 @@ subroutine state_to_tracers (nx_block, ny_block, & endif ! aim > puny enddo enddo - - !------------------------------------------------------------------- - ! Fill tracer array - ! Note: If aice > 0, then hice > 0, but we can have hsno = 0. - ! Alse note: We transport qice*nilyr rather than qice, so as to - ! avoid extra operations here and in tracers_to_state. - !------------------------------------------------------------------- + + !------------------------------------------------------------------- + ! Fill tracer array + ! Note: If aice > 0, then hice > 0, but we can have hsno = 0. + ! Alse note: We transport qice*nilyr rather than qice, so as to + ! avoid extra operations here and in tracers_to_state. + !------------------------------------------------------------------- do ij = 1, icells(n) i = indxi(ij,n) @@ -995,7 +957,7 @@ subroutine state_to_tracers (nx_block, ny_block, & endif enddo enddo ! ncat - + end subroutine state_to_tracers !======================================================================= @@ -1014,42 +976,42 @@ subroutine tracers_to_state (nx_block, ny_block, & use ice_domain_size, only: ncat, nslyr integer (kind=int_kind), intent(in) :: & - nx_block, ny_block, & ! block dimensions - ntrcr , & ! number of tracers in use - ntrace ! number of tracers in use incl. hi, hs + nx_block, ny_block, & ! block dimensions + ntrcr , & ! number of tracers in use + ntrace ! number of tracers in use incl. hi, hs real (kind=dbl_kind), dimension (nx_block,ny_block,0:ncat), intent(in) :: & - aim ! fractional ice area + aim ! fractional ice area real (kind=dbl_kind), dimension (nx_block,ny_block,ntrace,ncat), intent(in) :: & - trm ! mean tracer values in each grid cell + trm ! mean tracer values in each grid cell real (kind=dbl_kind), dimension (nx_block,ny_block), intent(inout) :: & - aice0 ! fractional ice area + aice0 ! fractional ice area real (kind=dbl_kind), dimension (nx_block,ny_block,ncat), intent(inout) :: & - aicen , & ! fractional ice area - vicen , & ! volume per unit area of ice (m) - vsnon ! volume per unit area of snow (m) + aicen ,&! fractional ice area + vicen ,&! volume per unit area of ice (m) + vsnon ! volume per unit area of snow (m) real (kind=dbl_kind), dimension (nx_block,ny_block,ntrcr,ncat), intent(inout) :: & - trcrn ! tracers + trcrn ! tracers ! local variables integer (kind=int_kind) :: & - nt_qsno , & ! - i, j, n , & ! standard indices - it, kt , & ! tracer indices - icells , & ! number of cells with ice - ij + nt_qsno ,&! + i, j, n ,&! standard indices + it, kt ,&! tracer indices + icells ,&! number of cells with ice + ij real (kind=dbl_kind) :: & - rhos , & ! - Lfresh ! + rhos, & + Lfresh integer (kind=int_kind), dimension (nx_block*ny_block) :: & - indxi, indxj ! compressed indices + indxi, indxj ! compressed indices character(len=*), parameter :: subname = '(tracers_to_state)' @@ -1063,20 +1025,20 @@ subroutine tracers_to_state (nx_block, ny_block, & do n = 1, ncat - icells = 0 - do j = 1, ny_block - do i = 1, nx_block - if (aim(i,j,n) > c0) then - icells = icells + 1 - indxi(icells) = i - indxj(icells) = j - endif - enddo - enddo + icells = 0 + do j = 1, ny_block + do i = 1, nx_block + if (aim(i,j,n) > c0) then + icells = icells + 1 + indxi(icells) = i + indxj(icells) = j + endif + enddo + enddo - !------------------------------------------------------------------- - ! Compute state variables. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Compute state variables. + !------------------------------------------------------------------- do ij = 1, icells i = indxi(ij) @@ -1094,7 +1056,7 @@ subroutine tracers_to_state (nx_block, ny_block, & j = indxj(ij) trcrn(i,j,it,n) = trm(i,j,kt+it,n) - rhos*Lfresh ! snow enthalpy enddo - else + else do ij = 1, icells i = indxi(ij) j = indxj(ij) @@ -1113,32 +1075,29 @@ end subroutine tracers_to_state ! ! author William H. Lipscomb, LANL - subroutine global_conservation (ckflag, fieldid, & + subroutine global_conservation (l_stop, & asum_init, asum_final, & atsum_init, atsum_final) - character(len=*), intent(in) :: & - fieldid ! field information string - real (kind=dbl_kind), intent(in) :: & - asum_init , & ! initial global ice area + asum_init ,&! initial global ice area asum_final ! final global ice area real (kind=dbl_kind), dimension(ntrace), intent(in), optional :: & - atsum_init, & ! initial global ice area*tracer + atsum_init ,&! initial global ice area*tracer atsum_final ! final global ice area*tracer logical (kind=log_kind), intent(inout) :: & - ckflag ! if true, abort on return + l_stop ! if true, abort on return ! local variables integer (kind=int_kind) :: & - nt ! tracer index + nt ! tracer index real (kind=dbl_kind) :: & - puny , & ! - diff ! difference between initial and final values + puny ,&! + diff ! difference between initial and final values character(len=*), parameter :: subname = '(global_conservation)' @@ -1150,32 +1109,35 @@ subroutine global_conservation (ckflag, fieldid, & if (asum_init > puny) then diff = asum_final - asum_init if (abs(diff/asum_init) > puny) then - ckflag = .true. + l_stop = .true. write (nu_diag,*) - write (nu_diag,*) subname,'Ice area conserv error ', trim(fieldid) - write (nu_diag,*) subname,' Initial global area =', asum_init - write (nu_diag,*) subname,' Final global area =', asum_final - write (nu_diag,*) subname,' Fractional error =', abs(diff)/asum_init - write (nu_diag,*) subname,' asum_final-asum_init =', diff + write (nu_diag,*) 'Ice area conserv error' + write (nu_diag,*) 'Initial global area =', asum_init + write (nu_diag,*) 'Final global area =', asum_final + write (nu_diag,*) 'Fractional error =', abs(diff)/asum_init + write (nu_diag,*) 'asum_final-asum_init =', diff endif endif if (present(atsum_init)) then - do nt = 1, ntrace - if (abs(atsum_init(nt)) > puny) then - diff = atsum_final(nt) - atsum_init(nt) - if (abs(diff/atsum_init(nt)) > puny) then - ckflag = .true. - write (nu_diag,*) - write (nu_diag,*) subname,'Ice area*tracer conserv error ', trim(fieldid),nt - write (nu_diag,*) subname,' Tracer index =', nt - write (nu_diag,*) subname,' Initial global area*tracer =', atsum_init(nt) - write (nu_diag,*) subname,' Final global area*tracer =', atsum_final(nt) - write (nu_diag,*) subname,' Fractional error =', abs(diff)/atsum_init(nt) - write (nu_diag,*) subname,' atsum_final-atsum_init =', diff - endif + do nt = 1, ntrace + if (abs(atsum_init(nt)) > puny) then + diff = atsum_final(nt) - atsum_init(nt) + if (abs(diff/atsum_init(nt)) > puny) then + l_stop = .true. + write (nu_diag,*) + write (nu_diag,*) 'area*tracer conserv error' + write (nu_diag,*) 'tracer index =', nt + write (nu_diag,*) 'Initial global area*tracer =', & + atsum_init(nt) + write (nu_diag,*) 'Final global area*tracer =', & + atsum_final(nt) + write (nu_diag,*) 'Fractional error =', & + abs(diff)/atsum_init(nt) + write (nu_diag,*) 'atsum_final-atsum_init =', diff endif - enddo + endif + enddo endif ! present(atsum_init) end subroutine global_conservation @@ -1185,7 +1147,7 @@ end subroutine global_conservation ! At each grid point, compute the local max and min of a scalar ! field phi: i.e., the max and min values in the nine-cell region ! consisting of the home cell and its eight neighbors. -! +! ! To extend to the neighbors of the neighbors (25 cells in all), ! follow this call with a call to quasilocal_max_min. ! @@ -1198,33 +1160,33 @@ subroutine local_max_min (nx_block, ny_block, & aimask, trmask) integer (kind=int_kind), intent(in) :: & - nx_block, ny_block, & ! block dimensions - ilo,ihi,jlo,jhi ! beginning and end of physical domain + nx_block, ny_block,&! block dimensions + ilo,ihi,jlo,jhi ! beginning and end of physical domain real (kind=dbl_kind), intent(in), dimension(nx_block,ny_block) :: & - aimask ! ice area mask + aimask ! ice area mask real (kind=dbl_kind), intent(in), dimension (nx_block,ny_block,ntrace) :: & - trm , & ! tracer fields - trmask ! tracer mask + trm ,&! tracer fields + trmask ! tracer mask real (kind=dbl_kind), intent(out), dimension (nx_block,ny_block,ntrace) :: & - tmin , & ! local min tracer - tmax ! local max tracer + tmin ,&! local min tracer + tmax ! local max tracer ! local variables integer (kind=int_kind) :: & - i, j , & ! horizontal indices - nt, nt1 ! tracer indices + i, j ,&! horizontal indices + nt, nt1 ! tracer indices real (kind=dbl_kind), dimension(nx_block,ny_block) :: & - phimask ! aimask or trmask, as appropriate + phimask ! aimask or trmask, as appropriate real (kind=dbl_kind) :: & - phi_nw, phi_n, phi_ne , & ! field values in 8 neighbor cells - phi_w , phi_e , & - phi_sw, phi_s, phi_se + phi_nw, phi_n, phi_ne ,&! field values in 8 neighbor cells + phi_w, phi_e ,& + phi_sw, phi_s, phi_se character(len=*), parameter :: subname = '(local_max_min)' @@ -1249,46 +1211,46 @@ subroutine local_max_min (nx_block, ny_block, & endif - !----------------------------------------------------------------------- - ! Store values of trm in the 8 neighbor cells. - ! If aimask = 1, use the true value; otherwise use the home cell value - ! so that non-physical values of phi do not contribute to the gradient. - !----------------------------------------------------------------------- +!----------------------------------------------------------------------- +! Store values of trm in the 8 neighbor cells. +! If aimask = 1, use the true value; otherwise use the home cell value +! so that non-physical values of phi do not contribute to the gradient. +!----------------------------------------------------------------------- do j = jlo, jhi - do i = ilo, ihi + do i = ilo, ihi + + phi_nw = phimask(i-1,j+1) * trm(i-1,j+1,nt) & + + (c1-phimask(i-1,j+1))* trm(i, j, nt) + phi_n = phimask(i, j+1) * trm(i, j+1,nt) & + + (c1-phimask(i, j+1))* trm(i, j, nt) + phi_ne = phimask(i+1,j+1) * trm(i+1,j+1,nt) & + + (c1-phimask(i+1,j+1))* trm(i, j, nt) + phi_w = phimask(i-1,j) * trm(i-1,j, nt) & + + (c1-phimask(i-1,j)) * trm(i, j, nt) + phi_e = phimask(i+1,j) * trm(i+1,j, nt) & + + (c1-phimask(i+1,j)) * trm(i, j, nt) + phi_sw = phimask(i-1,j-1) * trm(i-1,j-1,nt) & + + (c1-phimask(i-1,j-1))* trm(i, j, nt) + phi_s = phimask(i, j-1) * trm(i, j-1,nt) & + + (c1-phimask(i, j-1))* trm(i, j, nt) + phi_se = phimask(i+1,j-1) * trm(i+1,j-1,nt) & + + (c1-phimask(i+1,j-1))* trm(i, j, nt) + +!----------------------------------------------------------------------- +! Compute the minimum and maximum among the nine local cells. +!----------------------------------------------------------------------- + + tmax(i,j,nt) = max (phi_nw, phi_n, phi_ne, phi_w, & + trm(i,j,nt), phi_e, phi_sw, phi_s, phi_se) + + tmin(i,j,nt) = min (phi_nw, phi_n, phi_ne, phi_w, & + trm(i,j,nt), phi_e, phi_sw, phi_s, phi_se) + + enddo ! i + enddo ! j - phi_nw = phimask(i-1,j+1) * trm(i-1,j+1,nt) & - + (c1-phimask(i-1,j+1))* trm(i, j, nt) - phi_n = phimask(i, j+1) * trm(i, j+1,nt) & - + (c1-phimask(i, j+1))* trm(i, j, nt) - phi_ne = phimask(i+1,j+1) * trm(i+1,j+1,nt) & - + (c1-phimask(i+1,j+1))* trm(i, j, nt) - phi_w = phimask(i-1,j) * trm(i-1,j, nt) & - + (c1-phimask(i-1,j)) * trm(i, j, nt) - phi_e = phimask(i+1,j) * trm(i+1,j, nt) & - + (c1-phimask(i+1,j)) * trm(i, j, nt) - phi_sw = phimask(i-1,j-1) * trm(i-1,j-1,nt) & - + (c1-phimask(i-1,j-1))* trm(i, j, nt) - phi_s = phimask(i, j-1) * trm(i, j-1,nt) & - + (c1-phimask(i, j-1))* trm(i, j, nt) - phi_se = phimask(i+1,j-1) * trm(i+1,j-1,nt) & - + (c1-phimask(i+1,j-1))* trm(i, j, nt) - - !----------------------------------------------------------------------- - ! Compute the minimum and maximum among the nine local cells. - !----------------------------------------------------------------------- - - tmax(i,j,nt) = max (phi_nw, phi_n, phi_ne, phi_w, & - trm(i,j,nt), phi_e, phi_sw, phi_s, phi_se) - - tmin(i,j,nt) = min (phi_nw, phi_n, phi_ne, phi_w, & - trm(i,j,nt), phi_e, phi_sw, phi_s, phi_se) - - enddo ! i - enddo ! j - - enddo ! nt + enddo ! nt end subroutine local_max_min @@ -1305,18 +1267,18 @@ subroutine quasilocal_max_min (nx_block, ny_block, & tmin, tmax) integer (kind=int_kind), intent(in) :: & - nx_block, ny_block, & ! block dimensions - ilo,ihi,jlo,jhi ! beginning and end of physical domain + nx_block, ny_block,&! block dimensions + ilo,ihi,jlo,jhi ! beginning and end of physical domain real (kind=dbl_kind), intent(inout), dimension (nx_block,ny_block,ntrace) :: & - tmin , & ! local min tracer - tmax ! local max tracer + tmin ,&! local min tracer + tmax ! local max tracer ! local variables integer (kind=int_kind) :: & - i, j , & ! horizontal indices - nt ! tracer index + i, j ,&! horizontal indices + nt ! tracer index character(len=*), parameter :: subname = '(quasilocal_max_min)' @@ -1353,41 +1315,41 @@ subroutine check_monotonicity (nx_block, ny_block, & ilo, ihi, jlo, jhi, & tmin, tmax, & aim, trm, & - ckflag, & + l_stop, & istop, jstop) integer (kind=int_kind), intent(in) :: & - nx_block, ny_block, & ! block dimensions - ilo,ihi,jlo,jhi ! beginning and end of physical domain + nx_block, ny_block,&! block dimensions + ilo,ihi,jlo,jhi ! beginning and end of physical domain real (kind=dbl_kind), intent(in), dimension (nx_block,ny_block) :: & - aim ! new ice area + aim ! new ice area real (kind=dbl_kind), intent(in), dimension (nx_block,ny_block,ntrace) :: & - trm ! new tracers + trm ! new tracers real (kind=dbl_kind), intent(in), dimension (nx_block,ny_block,ntrace) :: & - tmin , & ! local min tracer - tmax ! local max tracer + tmin ,&! local min tracer + tmax ! local max tracer logical (kind=log_kind), intent(inout) :: & - ckflag ! if true, abort on return + l_stop ! if true, abort on return integer (kind=int_kind), intent(inout) :: & - istop, jstop ! indices of grid cell where model aborts + istop, jstop ! indices of grid cell where model aborts ! local variables integer (kind=int_kind) :: & - i, j , & ! horizontal indices - nt, nt1, nt2 ! tracer indices + i, j ,&! horizontal indices + nt, nt1, nt2 ! tracer indices real (kind=dbl_kind) :: & - puny , & ! - w1, w2 ! work variables + puny ,&! + w1, w2 ! work variables logical (kind=log_kind), dimension (nx_block, ny_block) :: & - l_check ! if true, check monotonicity + l_check ! if true, check monotonicity character(len=*), parameter :: subname = '(check_monotonicity)' @@ -1398,15 +1360,15 @@ subroutine check_monotonicity (nx_block, ny_block, & do nt = 1, ntrace - !------------------------------------------------------------------- - ! Load logical array to identify tracers that need checking. - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Load logical array to identify tracers that need checking. + !------------------------------------------------------------------- if (tracer_type(nt)==1) then ! does not depend on another tracer do j = jlo, jhi do i = ilo, ihi - if (aim(i,j) > puny) then + if (aim(i,j) > puny) then l_check(i,j) = .true. else l_check(i,j) = .false. @@ -1443,9 +1405,9 @@ subroutine check_monotonicity (nx_block, ny_block, & enddo endif - !------------------------------------------------------------------- - ! Make sure new values lie between tmin and tmax - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! Make sure new values lie between tmin and tmax + !------------------------------------------------------------------- do j = jlo, jhi do i = ilo, ihi @@ -1455,7 +1417,7 @@ subroutine check_monotonicity (nx_block, ny_block, & w1 = max(c1, abs(tmin(i,j,nt))) w2 = max(c1, abs(tmax(i,j,nt))) if (trm(i,j,nt) < tmin(i,j,nt)-w1*puny) then - ckflag = .true. + l_stop = .true. istop = i jstop = j write (nu_diag,*) ' ' @@ -1465,7 +1427,7 @@ subroutine check_monotonicity (nx_block, ny_block, & write (nu_diag,*) 'tmin =' , tmin(i,j,nt) write (nu_diag,*) 'ice area =' , aim(i,j) elseif (trm(i,j,nt) > tmax(i,j,nt)+w2*puny) then - ckflag = .true. + l_stop = .true. istop = i jstop = j write (nu_diag,*) ' ' @@ -1502,24 +1464,24 @@ subroutine state_to_work (nx_block, ny_block, & integer (kind=int_kind), intent(in) :: & nx_block, ny_block, & ! block dimensions ntrcr , & ! number of tracers in use - narr ! number of 2D state variable arrays in works array + narr ! number of 2D state variable arrays in works array integer (kind=int_kind), dimension (ntrcr), intent(in) :: & trcr_depend ! = 0 for aicen tracers, 1 for vicen, 2 for vsnon real (kind=dbl_kind), dimension (nx_block,ny_block,ncat), intent(in) :: & - aicen , & ! concentration of ice - vicen , & ! volume per unit area of ice (m) - vsnon ! volume per unit area of snow (m) + aicen ,&! concentration of ice + vicen ,&! volume per unit area of ice (m) + vsnon ! volume per unit area of snow (m) real (kind=dbl_kind), dimension (nx_block,ny_block,ntrcr,ncat), intent(in) :: & - trcrn ! ice tracers + trcrn ! ice tracers real (kind=dbl_kind), dimension (nx_block,ny_block), intent(in) :: & - aice0 ! concentration of open water + aice0 ! concentration of open water real (kind=dbl_kind), dimension(nx_block,ny_block,narr), intent (out) :: & - works ! work array + works ! work array ! local variables @@ -1527,16 +1489,16 @@ subroutine state_to_work (nx_block, ny_block, & nt_alvl, nt_apnd, nt_fbri logical (kind=log_kind) :: & - tr_pond_lvl, tr_pond_topo + tr_pond_cesm, tr_pond_lvl, tr_pond_topo integer (kind=int_kind) :: & - i, j, n, it, & ! counting indices - narrays ! counter for number of state variable arrays + i, j, n, it ,&! counting indices + narrays ! counter for number of state variable arrays character(len=*), parameter :: subname = '(state_to_work)' - call icepack_query_tracer_flags(tr_pond_lvl_out=tr_pond_lvl, & - tr_pond_topo_out=tr_pond_topo) + call icepack_query_tracer_flags(tr_pond_cesm_out=tr_pond_cesm, & + tr_pond_lvl_out=tr_pond_lvl, tr_pond_topo_out=tr_pond_topo) call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_apnd_out=nt_apnd, & nt_fbri_out=nt_fbri) call icepack_warnings_flush(nu_diag) @@ -1590,36 +1552,36 @@ subroutine state_to_work (nx_block, ny_block, & elseif (trcr_depend(it) == 2+nt_alvl) then do j = 1, ny_block do i = 1, nx_block - works(i,j,narrays+it) = aicen(i,j ,n) & + works(i,j,narrays+it) = aicen(i,j,n) & * trcrn(i,j,nt_alvl,n) & - * trcrn(i,j,it ,n) + * trcrn(i,j,it,n) enddo enddo elseif (trcr_depend(it) == 2+nt_apnd .and. & - tr_pond_topo) then + tr_pond_cesm .or. tr_pond_topo) then do j = 1, ny_block do i = 1, nx_block - works(i,j,narrays+it) = aicen(i,j ,n) & + works(i,j,narrays+it) = aicen(i,j,n) & * trcrn(i,j,nt_apnd,n) & - * trcrn(i,j,it ,n) + * trcrn(i,j,it,n) enddo enddo elseif (trcr_depend(it) == 2+nt_apnd .and. & tr_pond_lvl) then do j = 1, ny_block do i = 1, nx_block - works(i,j,narrays+it) = aicen(i,j ,n) & + works(i,j,narrays+it) = aicen(i,j,n) & * trcrn(i,j,nt_alvl,n) & * trcrn(i,j,nt_apnd,n) & - * trcrn(i,j,it ,n) + * trcrn(i,j,it,n) enddo enddo elseif (trcr_depend(it) == 2+nt_fbri) then do j = 1, ny_block do i = 1, nx_block - works(i,j,narrays+it) = vicen(i,j ,n) & + works(i,j,narrays+it) = vicen(i,j,n) & * trcrn(i,j,nt_fbri,n) & - * trcrn(i,j,it ,n) + * trcrn(i,j,it,n) enddo enddo endif @@ -1637,23 +1599,22 @@ end subroutine state_to_work ! ! Convert work array back to state variables - subroutine work_to_state (nx_block, ny_block, & - ntrcr, narr, & - trcr_depend, & - trcr_base, & - n_trcr_strata, & - nt_strata, & - tmask, & - aicen, trcrn, & - vicen, vsnon, & - aice0, works) + subroutine work_to_state (nx_block, ny_block, & + ntrcr, narr, & + trcr_depend, & + trcr_base, & + n_trcr_strata, & + nt_strata, & + aicen, trcrn, & + vicen, vsnon, & + aice0, works) use ice_domain_size, only: ncat - integer (kind=int_kind), intent (in) :: & + integer (kind=int_kind), intent (in) :: & nx_block, ny_block, & ! block dimensions ntrcr , & ! number of tracers in use - narr ! number of 2D state variable arrays in works array + narr ! number of 2D state variable arrays in works array integer (kind=int_kind), dimension (ntrcr), intent(in) :: & trcr_depend, & ! = 0 for aicen tracers, 1 for vicen, 2 for vsnon @@ -1666,44 +1627,35 @@ subroutine work_to_state (nx_block, ny_block, & integer (kind=int_kind), dimension (ntrcr,2), intent(in) :: & nt_strata ! indices of underlying tracer layers - logical (kind=log_kind), intent (in) :: & - tmask (nx_block,ny_block) - - real (kind=dbl_kind), intent (in) :: & + real (kind=dbl_kind), intent (in) :: & works (nx_block,ny_block,narr) real (kind=dbl_kind), dimension (nx_block,ny_block,ncat), intent(out) :: & - aicen , & ! concentration of ice - vicen , & ! volume per unit area of ice (m) - vsnon ! volume per unit area of snow (m) + aicen ,&! concentration of ice + vicen ,&! volume per unit area of ice (m) + vsnon ! volume per unit area of snow (m) real (kind=dbl_kind), dimension (nx_block,ny_block,ntrcr,ncat),intent(out) :: & - trcrn ! ice tracers + trcrn ! ice tracers real (kind=dbl_kind), dimension (nx_block,ny_block), intent(out) :: & - aice0 ! concentration of open water + aice0 ! concentration of open water ! local variables - integer (kind=int_kind) :: & - i, j, ij, n, & ! counting indices - narrays , & ! counter for number of state variable arrays - nt_Tsfc , & ! Tsfc tracer number - icells ! number of ocean/ice cells + integer (kind=int_kind) :: & + i, j, ij, n ,&! counting indices + narrays ,&! counter for number of state variable arrays + icells ! number of ocean/ice cells - integer (kind=int_kind), dimension (nx_block*ny_block) :: & + integer (kind=int_kind), dimension (nx_block*ny_block) :: & indxi, indxj - real (kind=dbl_kind), dimension (nx_block*ny_block,narr) :: & - work + real (kind=dbl_kind), dimension (nx_block*ny_block,narr) :: & + work character(len=*), parameter :: subname = '(work_to_state)' - call icepack_query_tracer_indices(nt_Tsfc_out=nt_Tsfc) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - ! for call to compute_tracers icells = 0 do j = 1, ny_block @@ -1737,24 +1689,16 @@ subroutine work_to_state (nx_block, ny_block, & i = indxi(ij) j = indxj(ij) - call icepack_compute_tracers(ntrcr = ntrcr, & - trcr_depend = trcr_depend(:), & - atrcrn = work (ij,narrays+1:narrays+ntrcr), & - aicen = aicen(i,j,n), & - vicen = vicen(i,j,n), & - vsnon = vsnon(i,j,n), & + call icepack_compute_tracers(ntrcr=ntrcr, trcr_depend=trcr_depend(:), & + atrcrn = work (ij,narrays+1:narrays+ntrcr), & + aicen = aicen(i,j,n), & + vicen = vicen(i,j,n), & + vsnon = vsnon(i,j,n), & trcr_base = trcr_base(:,:), & n_trcr_strata = n_trcr_strata(:), & nt_strata = nt_strata(:,:), & - trcrn = trcrn(i,j,:,n)) - - ! tcraig, don't let land points get non-zero Tsfc - if (.not.tmask(i,j)) then - trcrn(i,j,nt_Tsfc,n) = c0 - endif - + trcrn = trcrn(i,j,:,n)) enddo - narrays = narrays + ntrcr enddo ! ncat @@ -1778,53 +1722,53 @@ subroutine upwind_field (nx_block, ny_block, & tarea) integer (kind=int_kind), intent (in) :: & - nx_block, ny_block, & ! block dimensions - ilo,ihi,jlo,jhi , & ! beginning and end of physical domain - narrays ! number of 2D arrays to be transported + nx_block, ny_block ,&! block dimensions + ilo,ihi,jlo,jhi ,&! beginning and end of physical domain + narrays ! number of 2D arrays to be transported real (kind=dbl_kind), intent(in) :: & - dt ! time step + dt ! time step real (kind=dbl_kind), dimension(nx_block,ny_block,narrays), intent(inout) :: & - phi ! scalar field + phi ! scalar field real (kind=dbl_kind), dimension(nx_block,ny_block), intent(in) :: & - uee, vnn ! cell edge velocities + uee, vnn ! cell edge velocities real (kind=dbl_kind), dimension(nx_block,ny_block), intent(in) :: & - HTE , & ! length of east cell edge - HTN , & ! length of north cell edge - tarea ! grid cell area + HTE ,&! length of east cell edge + HTN ,&! length of north cell edge + tarea ! grid cell area ! local variables integer (kind=int_kind) :: & - i, j, n ! standard indices + i, j, n ! standard indices real (kind=dbl_kind), dimension (nx_block,ny_block) :: & worka, workb character(len=*), parameter :: subname = '(upwind_field)' - !------------------------------------------------------------------- - ! upwind transport - !------------------------------------------------------------------- + !------------------------------------------------------------------- + ! upwind transport + !------------------------------------------------------------------- do n = 1, narrays do j = 1, jhi do i = 1, ihi worka(i,j)= & - upwind(phi(i,j,n),phi(i+1,j ,n),uee(i,j),HTE(i,j),dt) + upwind(phi(i,j,n),phi(i+1,j,n),uee(i,j),HTE(i,j),dt) workb(i,j)= & - upwind(phi(i,j,n),phi(i ,j+1,n),vnn(i,j),HTN(i,j),dt) + upwind(phi(i,j,n),phi(i,j+1,n),vnn(i,j),HTN(i,j),dt) enddo enddo do j = jlo, jhi do i = ilo, ihi - phi(i,j,n) = phi(i,j,n) - ( worka(i,j)-worka(i-1,j ) & - + workb(i,j)-workb(i ,j-1) ) & + phi(i,j,n) = phi(i,j,n) - ( worka(i,j)-worka(i-1,j) & + + workb(i,j)-workb(i,j-1) ) & / tarea(i,j) enddo enddo @@ -1834,9 +1778,10 @@ subroutine upwind_field (nx_block, ny_block, & end subroutine upwind_field !======================================================================= -! -! Define upwind function -! + + !------------------------------------------------------------------- + ! Define upwind function + !------------------------------------------------------------------- real(kind=dbl_kind) function upwind(y1,y2,a,h,dt) diff --git a/cicecore/cicedyn/general/ice_flux.F90 b/cicecore/cicedyn/general/ice_flux.F90 index 29f5c489b..607b763eb 100644 --- a/cicecore/cicedyn/general/ice_flux.F90 +++ b/cicecore/cicedyn/general/ice_flux.F90 @@ -33,41 +33,29 @@ module ice_flux !----------------------------------------------------------------- ! Dynamics component - ! All variables are assumed to be on the atm or ocn thermodynamic - ! grid except as noted - ! - ! scale_fluxes divides several of these by aice "in place", so - ! the state of some of these variables is not well defined. In the - ! future, we need to refactor and add "_iavg" versions of the - ! fields to clearly differentiate fields that have been divided - ! by aice and others that are not. The challenge is that we need - ! to go thru each field carefully to see which version is used. - ! For instance, in diagnostics, there are places where these - ! fields are multiplied by aice to compute things properly. - ! strocn[x,y]T_iavg is the first field defined using _iavg. !----------------------------------------------------------------- real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & - ! in from atmos (if .not.calc_strair) - strax , & ! wind stress components (N/m^2), on grid_atm_dynu - stray , & ! on grid_atm_dynv + ! in from atmos (if .not.calc_strair) + strax , & ! wind stress components (N/m^2) + stray , & ! ! in from ocean - uocn , & ! ocean current, x-direction (m/s), on grid_ocn_dynu - vocn , & ! ocean current, y-direction (m/s), on grid_ocn_dynv - ss_tltx , & ! sea surface slope, x-direction (m/m), on grid_ocn_dynu - ss_tlty , & ! sea surface slope, y-direction, on grid_ocn_dynv - hwater , & ! water depth for seabed stress calc (landfast ice) + uocn , & ! ocean current, x-direction (m/s) + vocn , & ! ocean current, y-direction (m/s) + ss_tltx , & ! sea surface slope, x-direction (m/m) + ss_tlty , & ! sea surface slope, y-direction + hwater , & ! water depth for basal stress calc (landfast ice) ! out to atmosphere - strairxT, & ! stress on ice by air, x-direction at T points, computed in icepack - strairyT, & ! stress on ice by air, y-direction at T points, computed in icepack + strairxT, & ! stress on ice by air, x-direction + strairyT, & ! stress on ice by air, y-direction ! out to ocean T-cell (kg/m s^2) ! Note, CICE_IN_NEMO uses strocnx and strocny for coupling - strocnxT_iavg, & ! ice-ocean stress, x-direction at T points, per ice fraction (scaled flux) - strocnyT_iavg ! ice-ocean stress, y-direction at T points, per ice fraction (scaled flux) + strocnxT, & ! ice-ocean stress, x-direction + strocnyT ! ice-ocean stress, y-direction ! diagnostic @@ -75,36 +63,16 @@ module ice_flux sig1 , & ! normalized principal stress component sig2 , & ! normalized principal stress component sigP , & ! internal ice pressure (N/m) - taubxU , & ! seabed stress (x) (N/m^2) - taubyU , & ! seabed stress (y) (N/m^2) - strairxU, & ! stress on ice by air, x-direction at U points - strairyU, & ! stress on ice by air, y-direction at U points - strocnxU, & ! ice-ocean stress, x-direction at U points, computed in dyn_finish - strocnyU, & ! ice-ocean stress, y-direction at U points, computed in dyn_finish - strtltxU, & ! stress due to sea surface slope, x-direction - strtltyU, & ! stress due to sea surface slope, y-direction - strintxU, & ! divergence of internal ice stress, x (N/m^2) - strintyU, & ! divergence of internal ice stress, y (N/m^2) - taubxN , & ! seabed stress (x) at N points (N/m^2) - taubyN , & ! seabed stress (y) at N points (N/m^2) - strairxN, & ! stress on ice by air, x-direction at N points - strairyN, & ! stress on ice by air, y-direction at N points - strocnxN, & ! ice-ocean stress, x-direction at N points, computed in dyn_finish - strocnyN, & ! ice-ocean stress, y-direction at N points, computed in dyn_finish - strtltxN, & ! stress due to sea surface slope, x-direction at N points - strtltyN, & ! stress due to sea surface slope, y-direction at N points - strintxN, & ! divergence of internal ice stress, x at N points (N/m^2) - strintyN, & ! divergence of internal ice stress, y at N points (N/m^2) - taubxE , & ! seabed stress (x) at E points (N/m^2) - taubyE , & ! seabed stress (y) at E points (N/m^2) - strairxE, & ! stress on ice by air, x-direction at E points - strairyE, & ! stress on ice by air, y-direction at E points - strocnxE, & ! ice-ocean stress, x-direction at E points, computed in dyn_finish - strocnyE, & ! ice-ocean stress, y-direction at E points, computed in dyn_finish - strtltxE, & ! stress due to sea surface slope, x-direction at E points - strtltyE, & ! stress due to sea surface slope, y-direction at E points - strintxE, & ! divergence of internal ice stress, x at E points (N/m^2) - strintyE, & ! divergence of internal ice stress, y at E points (N/m^2) + taubx , & ! basal stress (x) (N/m^2) + tauby , & ! basal stress (y) (N/m^2) + strairx , & ! stress on ice by air, x-direction + strairy , & ! stress on ice by air, y-direction + strocnx , & ! ice-ocean stress, x-direction + strocny , & ! ice-ocean stress, y-direction + strtltx , & ! stress due to sea surface slope, x-direction + strtlty , & ! stress due to sea surface slope, y-direction + strintx , & ! divergence of internal ice stress, x (N/m^2) + strinty , & ! divergence of internal ice stress, y (N/m^2) daidtd , & ! ice area tendency due to transport (1/s) dvidtd , & ! ice volume tendency due to transport (m/s) dagedtd , & ! ice age tendency due to transport (s/s) @@ -113,7 +81,7 @@ module ice_flux dvirdgdt, & ! rate of ice volume ridged (m/s) opening ! rate of opening due to divergence/shear (1/s) - real (kind=dbl_kind), & + real (kind=dbl_kind), & dimension (:,:,:,:), allocatable, public :: & ! ridging diagnostics in categories dardg1ndt, & ! rate of area loss by ridging ice (1/s) @@ -124,7 +92,7 @@ module ice_flux ardgn, & ! fractional area of ridged ice vrdgn, & ! volume of ridged ice araftn, & ! rafting ice area - vraftn, & ! rafting ice volume + vraftn, & ! rafting ice volume aredistn, & ! redistribution function: fraction of new ridge area vredistn ! redistribution function: fraction of new ridge volume @@ -134,20 +102,17 @@ module ice_flux ! ice stress tensor in each corner of T cell (kg/s^2) stressp_1, stressp_2, stressp_3, stressp_4 , & ! sigma11+sigma22 stressm_1, stressm_2, stressm_3, stressm_4 , & ! sigma11-sigma22 - stress12_1,stress12_2,stress12_3,stress12_4, & ! sigma12 - ! ice stress tensor at U and T locations (grid_ice = 'C|CD') (kg/s^2) - stresspT, stressmT, stress12T, & ! sigma11+sigma22, sigma11-sigma22, sigma12 - stresspU, stressmU, stress12U ! " + stress12_1,stress12_2,stress12_3,stress12_4 ! sigma12 + + logical (kind=log_kind), & + dimension (:,:,:), allocatable, public :: & + iceumask ! ice extent mask (U-cell) ! internal real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & - fmU , & ! Coriolis param. * mass in U-cell (kg/s) - TbU , & ! factor for seabed stress (N/m^2) - fmE , & ! Coriolis param. * mass in E-cell (kg/s) - TbE , & ! factor for seabed stress (N/m^2) - fmN , & ! Coriolis param. * mass in N-cell (kg/s) - TbN ! factor for seabed stress (N/m^2) + fm , & ! Coriolis param. * mass in U-cell (kg/s) + Tbu ! coefficient for basal stress (N/m^2) !----------------------------------------------------------------- ! Thermodynamic component @@ -156,11 +121,10 @@ module ice_flux ! in from atmosphere (if calc_Tsfc) real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & - zlvl , & ! atm level height (momentum) (m) - zlvs , & ! atm level height (scalar quantities) (m) - uatm , & ! wind velocity components (m/s), on grid_atm_dynu - vatm , & ! on grid_atm_dynv - wind , & ! wind speed (m/s) , on grid_atm_dynu + zlvl , & ! atm level height (m) + uatm , & ! wind velocity components (m/s) + vatm , & + wind , & ! wind speed (m/s) potT , & ! air potential temperature (K) Tair , & ! air temperature (K) Qa , & ! specific humidity (kg/kg) @@ -176,7 +140,7 @@ module ice_flux ! NOTE: when in CICE_IN_NEMO mode, these are gridbox mean fields, ! not per ice area. When in standalone mode, these are per ice area. - real (kind=dbl_kind), & + real (kind=dbl_kind), & dimension (:,:,:,:), allocatable, public :: & fsurfn_f , & ! net flux to top surface, excluding fcondtop fcondtopn_f, & ! downward cond flux at top surface (W m-2) @@ -199,7 +163,7 @@ module ice_flux Tf , & ! freezing temperature (C) qdp , & ! deep ocean heat flux (W/m^2), negative upward hmix , & ! mixed layer depth (m) - daice_da ! data assimilation concentration increment rate + daice_da ! data assimilation concentration increment rate ! (concentration s-1)(only used in hadgem drivers) ! out to atmosphere (if calc_Tsfc) @@ -245,20 +209,15 @@ module ice_flux dimension(:,:,:,:), allocatable, public :: & albcnt ! counter for zenith angle - ! out to ocean - ! (Note CICE_IN_NEMO does not use these for coupling. + ! out to ocean + ! (Note CICE_IN_NEMO does not use these for coupling. ! It uses fresh_ai,fsalt_ai,fhocn_ai and fswthru_ai) real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & fpond , & ! fresh water flux to ponds (kg/m^2/s) fresh , & ! fresh water flux to ocean (kg/m^2/s) fsalt , & ! salt flux to ocean (kg/m^2/s) fhocn , & ! net heat flux to ocean (W/m^2) - fsloss , & ! rate of snow loss to leads (kg/m^2/s) - fswthru , & ! shortwave penetrating to ocean (W/m^2) - fswthru_vdr , & ! vis dir shortwave penetrating to ocean (W/m^2) - fswthru_vdf , & ! vis dif shortwave penetrating to ocean (W/m^2) - fswthru_idr , & ! nir dir shortwave penetrating to ocean (W/m^2) - fswthru_idf ! nir dif shortwave penetrating to ocean (W/m^2) + fswthru ! shortwave penetrating to ocean (W/m^2) ! internal @@ -278,7 +237,7 @@ module ice_flux snoicen ! snow-ice formation in category n (m) real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & - keffn_top ! effective thermal conductivity of the top ice layer + keffn_top ! effective thermal conductivity of the top ice layer ! on categories (W/m^2/K) ! quantities passed from ocean mixed layer to atmosphere @@ -321,8 +280,8 @@ module ice_flux mlt_onset, &! day of year that sfc melting begins frz_onset, &! day of year that freezing begins (congel or frazil) frazil_diag ! frazil ice growth diagnostic (m/step-->cm/day) - - real (kind=dbl_kind), & + + real (kind=dbl_kind), & dimension (:,:,:,:), allocatable, public :: & fsurfn, & ! category fsurf fcondtopn,& ! category fcondtop @@ -330,17 +289,13 @@ module ice_flux fsensn, & ! category sensible heat flux flatn ! category latent heat flux - real (kind=dbl_kind), & - dimension (:,:,:,:), allocatable, public :: & - snwcnt ! counter for presence of snow - ! As above but these remain grid box mean values i.e. they are not ! divided by aice at end of ice_dynamics. These are used in ! CICE_IN_NEMO for coupling and also for generating - ! ice diagnostics and history files as these are more accurate. + ! ice diagnostics and history files as these are more accurate. ! (The others suffer from problem of incorrect values at grid boxes ! that change from an ice free state to an icy state.) - + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & fresh_ai, & ! fresh water flux to ocean (kg/m^2/s) fsalt_ai, & ! salt flux to ocean (kg/m^2/s) @@ -352,28 +307,20 @@ module ice_flux fresh_da, & ! fresh water flux to ocean due to data assim (kg/m^2/s) fsalt_da ! salt flux to ocean due to data assimilation(kg/m^2/s) - real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & - fswthrun_ai ! per-category fswthru * ai (W/m^2) - - logical (kind=log_kind), public :: send_i2x_per_cat = .false. - !----------------------------------------------------------------- ! internal !----------------------------------------------------------------- real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & - uatmT , & ! uatm on T grid (m/s) - vatmT , & ! vatm on T grid (m/s) rside , & ! fraction of ice that melts laterally fside , & ! lateral heat flux (W/m^2) - wlat , & ! lateral heat rate (m/s) fsw , & ! incoming shortwave radiation (W/m^2) - coszen , & ! cosine solar zenith angle, < 0 for sun below horizon + coszen , & ! cosine solar zenith angle, < 0 for sun below horizon rdg_conv, & ! convergence term for ridging (1/s) rdg_shear ! shear term for ridging (1/s) - + real (kind=dbl_kind), dimension(:,:,:,:), allocatable, public :: & - salinz ,& ! initial salinity profile (ppt) + salinz ,& ! initial salinity profile (ppt) Tmltz ! initial melting temperature (^oC) !======================================================================= @@ -382,39 +329,37 @@ module ice_flux !======================================================================= ! -! Allocate space for all variables +! Allocate space for all variables ! subroutine alloc_flux - use ice_grid, only : grid_ice - integer (int_kind) :: ierr allocate( & strax (nx_block,ny_block,max_blocks), & ! wind stress components (N/m^2) - stray (nx_block,ny_block,max_blocks), & ! + stray (nx_block,ny_block,max_blocks), & ! uocn (nx_block,ny_block,max_blocks), & ! ocean current, x-direction (m/s) vocn (nx_block,ny_block,max_blocks), & ! ocean current, y-direction (m/s) ss_tltx (nx_block,ny_block,max_blocks), & ! sea surface slope, x-direction (m/m) ss_tlty (nx_block,ny_block,max_blocks), & ! sea surface slope, y-direction - hwater (nx_block,ny_block,max_blocks), & ! water depth for seabed stress calc (landfast ice) + hwater (nx_block,ny_block,max_blocks), & ! water depth for basal stress calc (landfast ice) strairxT (nx_block,ny_block,max_blocks), & ! stress on ice by air, x-direction strairyT (nx_block,ny_block,max_blocks), & ! stress on ice by air, y-direction - strocnxT_iavg(nx_block,ny_block,max_blocks), & ! ice-ocean stress, x-direction, per ice area - strocnyT_iavg(nx_block,ny_block,max_blocks), & ! ice-ocean stress, y-direction, per ice area + strocnxT (nx_block,ny_block,max_blocks), & ! ice-ocean stress, x-direction + strocnyT (nx_block,ny_block,max_blocks), & ! ice-ocean stress, y-direction sig1 (nx_block,ny_block,max_blocks), & ! normalized principal stress component sig2 (nx_block,ny_block,max_blocks), & ! normalized principal stress component sigP (nx_block,ny_block,max_blocks), & ! internal ice pressure (N/m) - taubxU (nx_block,ny_block,max_blocks), & ! seabed stress (x) (N/m^2) - taubyU (nx_block,ny_block,max_blocks), & ! seabed stress (y) (N/m^2) - strairxU (nx_block,ny_block,max_blocks), & ! stress on ice by air, x-direction - strairyU (nx_block,ny_block,max_blocks), & ! stress on ice by air, y-direction - strocnxU (nx_block,ny_block,max_blocks), & ! ice-ocean stress, x-direction - strocnyU (nx_block,ny_block,max_blocks), & ! ice-ocean stress, y-direction - strtltxU (nx_block,ny_block,max_blocks), & ! stress due to sea surface slope, x-direction - strtltyU (nx_block,ny_block,max_blocks), & ! stress due to sea surface slope, y-direction - strintxU (nx_block,ny_block,max_blocks), & ! divergence of internal ice stress, x (N/m^2) - strintyU (nx_block,ny_block,max_blocks), & ! divergence of internal ice stress, y (N/m^2) + taubx (nx_block,ny_block,max_blocks), & ! basal stress (x) (N/m^2) + tauby (nx_block,ny_block,max_blocks), & ! basal stress (y) (N/m^2) + strairx (nx_block,ny_block,max_blocks), & ! stress on ice by air, x-direction + strairy (nx_block,ny_block,max_blocks), & ! stress on ice by air, y-direction + strocnx (nx_block,ny_block,max_blocks), & ! ice-ocean stress, x-direction + strocny (nx_block,ny_block,max_blocks), & ! ice-ocean stress, y-direction + strtltx (nx_block,ny_block,max_blocks), & ! stress due to sea surface slope, x-direction + strtlty (nx_block,ny_block,max_blocks), & ! stress due to sea surface slope, y-direction + strintx (nx_block,ny_block,max_blocks), & ! divergence of internal ice stress, x (N/m^2) + strinty (nx_block,ny_block,max_blocks), & ! divergence of internal ice stress, y (N/m^2) daidtd (nx_block,ny_block,max_blocks), & ! ice area tendency due to transport (1/s) dvidtd (nx_block,ny_block,max_blocks), & ! ice volume tendency due to transport (m/s) dagedtd (nx_block,ny_block,max_blocks), & ! ice age tendency due to transport (s/s) @@ -434,10 +379,10 @@ subroutine alloc_flux stress12_2 (nx_block,ny_block,max_blocks), & ! sigma12 stress12_3 (nx_block,ny_block,max_blocks), & ! sigma12 stress12_4 (nx_block,ny_block,max_blocks), & ! sigma12 - fmU (nx_block,ny_block,max_blocks), & ! Coriolis param. * mass in U-cell (kg/s) - TbU (nx_block,ny_block,max_blocks), & ! factor for seabed stress (landfast ice) - zlvl (nx_block,ny_block,max_blocks), & ! atm level height (momentum) (m) - zlvs (nx_block,ny_block,max_blocks), & ! atm level height (scalar quantities) (m) + iceumask (nx_block,ny_block,max_blocks), & ! ice extent mask (U-cell) + fm (nx_block,ny_block,max_blocks), & ! Coriolis param. * mass in U-cell (kg/s) + Tbu (nx_block,ny_block,max_blocks), & ! coefficient for basal stress (landfast ice) + zlvl (nx_block,ny_block,max_blocks), & ! atm level height (m) uatm (nx_block,ny_block,max_blocks), & ! wind velocity components (m/s) vatm (nx_block,ny_block,max_blocks), & wind (nx_block,ny_block,max_blocks), & ! wind speed (m/s) @@ -459,8 +404,7 @@ subroutine alloc_flux Tf (nx_block,ny_block,max_blocks), & ! freezing temperature (C) qdp (nx_block,ny_block,max_blocks), & ! deep ocean heat flux (W/m^2), negative upward hmix (nx_block,ny_block,max_blocks), & ! mixed layer depth (m) - daice_da (nx_block,ny_block,max_blocks), & ! data assimilation concentration increment rate (concentration s-1) - ! (only used in hadgem drivers) + daice_da (nx_block,ny_block,max_blocks), & ! data assimilation concentration increment rate (concentration s-1)(only used in hadgem drivers) fsens (nx_block,ny_block,max_blocks), & ! sensible heat flux (W/m^2) flat (nx_block,ny_block,max_blocks), & ! latent heat flux (W/m^2) fswabs (nx_block,ny_block,max_blocks), & ! shortwave flux absorbed in ice and ocean (W/m^2) @@ -493,12 +437,7 @@ subroutine alloc_flux fresh (nx_block,ny_block,max_blocks), & ! fresh water flux to ocean (kg/m^2/s) fsalt (nx_block,ny_block,max_blocks), & ! salt flux to ocean (kg/m^2/s) fhocn (nx_block,ny_block,max_blocks), & ! net heat flux to ocean (W/m^2) - fsloss (nx_block,ny_block,max_blocks), & ! rate of snow loss to leads (kg/m^2/s) fswthru (nx_block,ny_block,max_blocks), & ! shortwave penetrating to ocean (W/m^2) - fswthru_vdr (nx_block,ny_block,max_blocks), & ! vis dir shortwave penetrating to ocean (W/m^2) - fswthru_vdf (nx_block,ny_block,max_blocks), & ! vis dif shortwave penetrating to ocean (W/m^2) - fswthru_idr (nx_block,ny_block,max_blocks), & ! nir dir shortwave penetrating to ocean (W/m^2) - fswthru_idf (nx_block,ny_block,max_blocks), & ! nir dif shortwave penetrating to ocean (W/m^2) scale_factor (nx_block,ny_block,max_blocks), & ! scaling factor for shortwave components strairx_ocn(nx_block,ny_block,max_blocks), & ! stress on ocean by air, x-direction strairy_ocn(nx_block,ny_block,max_blocks), & ! stress on ocean by air, y-direction @@ -538,13 +477,10 @@ subroutine alloc_flux fswthru_ai (nx_block,ny_block,max_blocks), & ! shortwave penetrating to ocean (W/m^2) fresh_da (nx_block,ny_block,max_blocks), & ! fresh water flux to ocean due to data assim (kg/m^2/s) fsalt_da (nx_block,ny_block,max_blocks), & ! salt flux to ocean due to data assimilation(kg/m^2/s) - uatmT (nx_block,ny_block,max_blocks), & ! uatm on T grid - vatmT (nx_block,ny_block,max_blocks), & ! vatm on T grid rside (nx_block,ny_block,max_blocks), & ! fraction of ice that melts laterally - fside (nx_block,ny_block,max_blocks), & ! lateral melt flux (W/m^2) - wlat (nx_block,ny_block,max_blocks), & ! lateral melt rate (m/s) + fside (nx_block,ny_block,max_blocks), & ! lateral melt rate (W/m^2) fsw (nx_block,ny_block,max_blocks), & ! incoming shortwave radiation (W/m^2) - coszen (nx_block,ny_block,max_blocks), & ! cosine solar zenith angle, < 0 for sun below horizon + coszen (nx_block,ny_block,max_blocks), & ! cosine solar zenith angle, < 0 for sun below horizon rdg_conv (nx_block,ny_block,max_blocks), & ! convergence term for ridging (1/s) rdg_shear (nx_block,ny_block,max_blocks), & ! shear term for ridging (1/s) dardg1ndt (nx_block,ny_block,ncat,max_blocks), & ! rate of area loss by ridging ice (1/s) @@ -555,7 +491,7 @@ subroutine alloc_flux ardgn (nx_block,ny_block,ncat,max_blocks), & ! fractional area of ridged ice vrdgn (nx_block,ny_block,ncat,max_blocks), & ! volume of ridged ice araftn (nx_block,ny_block,ncat,max_blocks), & ! rafting ice area - vraftn (nx_block,ny_block,ncat,max_blocks), & ! rafting ice volume + vraftn (nx_block,ny_block,ncat,max_blocks), & ! rafting ice volume aredistn (nx_block,ny_block,ncat,max_blocks), & ! redistribution function: fraction of new ridge area vredistn (nx_block,ny_block,ncat,max_blocks), & ! redistribution function: fraction of new ridge volume fsurfn_f (nx_block,ny_block,ncat,max_blocks), & ! net flux to top surface, excluding fcondtop @@ -574,47 +510,11 @@ subroutine alloc_flux fsensn (nx_block,ny_block,ncat,max_blocks), & ! category sensible heat flux flatn (nx_block,ny_block,ncat,max_blocks), & ! category latent heat flux albcnt (nx_block,ny_block,max_blocks,max_nstrm), & ! counter for zenith angle - snwcnt (nx_block,ny_block,max_blocks,max_nstrm), & ! counter for snow - salinz (nx_block,ny_block,nilyr+1,max_blocks), & ! initial salinity profile (ppt) + salinz (nx_block,ny_block,nilyr+1,max_blocks), & ! initial salinity profile (ppt) Tmltz (nx_block,ny_block,nilyr+1,max_blocks), & ! initial melting temperature (^oC) stat=ierr) if (ierr/=0) call abort_ice('(alloc_flux): Out of memory') - if (grid_ice == "CD" .or. grid_ice == "C") & - allocate( & - taubxN (nx_block,ny_block,max_blocks), & ! seabed stress (x) at N points (N/m^2) - taubyN (nx_block,ny_block,max_blocks), & ! seabed stress (y) at N points (N/m^2) - strairxN (nx_block,ny_block,max_blocks), & ! stress on ice by air, x-direction at N points - strairyN (nx_block,ny_block,max_blocks), & ! stress on ice by air, y-direction at N points - strocnxN (nx_block,ny_block,max_blocks), & ! ice-ocean stress, x-direction at N points - strocnyN (nx_block,ny_block,max_blocks), & ! ice-ocean stress, y-direction at N points - strtltxN (nx_block,ny_block,max_blocks), & ! stress due to sea surface slope, x-direction at N points - strtltyN (nx_block,ny_block,max_blocks), & ! stress due to sea surface slope, y-direction at N points - strintxN (nx_block,ny_block,max_blocks), & ! divergence of internal ice stress, x at N points (N/m^2) - strintyN (nx_block,ny_block,max_blocks), & ! divergence of internal ice stress, y at N points (N/m^2) - fmN (nx_block,ny_block,max_blocks), & ! Coriolis param. * mass in N-cell (kg/s) - TbN (nx_block,ny_block,max_blocks), & ! factor for seabed stress (landfast ice) - taubxE (nx_block,ny_block,max_blocks), & ! seabed stress (x) at E points (N/m^2) - taubyE (nx_block,ny_block,max_blocks), & ! seabed stress (y) at E points (N/m^2) - strairxE (nx_block,ny_block,max_blocks), & ! stress on ice by air, x-direction at E points - strairyE (nx_block,ny_block,max_blocks), & ! stress on ice by air, y-direction at E points - strocnxE (nx_block,ny_block,max_blocks), & ! ice-ocean stress, x-direction at E points - strocnyE (nx_block,ny_block,max_blocks), & ! ice-ocean stress, y-direction at E points - strtltxE (nx_block,ny_block,max_blocks), & ! stress due to sea surface slope, x-direction at E points - strtltyE (nx_block,ny_block,max_blocks), & ! stress due to sea surface slope, y-direction at E points - strintxE (nx_block,ny_block,max_blocks), & ! divergence of internal ice stress, x at E points (N/m^2) - strintyE (nx_block,ny_block,max_blocks), & ! divergence of internal ice stress, y at E points (N/m^2) - fmE (nx_block,ny_block,max_blocks), & ! Coriolis param. * mass in E-cell (kg/s) - TbE (nx_block,ny_block,max_blocks), & ! factor for seabed stress (landfast ice) - stresspT (nx_block,ny_block,max_blocks), & ! sigma11+sigma22 - stressmT (nx_block,ny_block,max_blocks), & ! sigma11-sigma22 - stress12T (nx_block,ny_block,max_blocks), & ! sigma12 - stresspU (nx_block,ny_block,max_blocks), & ! sigma11+sigma22 - stressmU (nx_block,ny_block,max_blocks), & ! sigma11-sigma22 - stress12U (nx_block,ny_block,max_blocks), & ! sigma12 - stat=ierr) - if (ierr/=0) call abort_ice('(alloc_flux): Out of memory') - end subroutine alloc_flux !======================================================================= @@ -634,8 +534,7 @@ subroutine init_coupler_flux integer (kind=int_kind) :: n - integer (kind=int_kind), parameter :: max_d = 6 - real (kind=dbl_kind) :: fcondtopn_d(max_d), fsurfn_d(max_d) + real (kind=dbl_kind) :: fcondtopn_d(6), fsurfn_d(6) real (kind=dbl_kind) :: stefan_boltzmann, Tffresh real (kind=dbl_kind) :: vonkar, zref, iceruf @@ -657,8 +556,7 @@ subroutine init_coupler_flux !----------------------------------------------------------------- ! fluxes received from atmosphere !----------------------------------------------------------------- - zlvl (:,:,:) = c10 ! atm level height (momentum) (m) - zlvs (:,:,:) = c10 ! atm level height (scalar quantities) (m) + zlvl (:,:,:) = c10 ! atm level height (m) rhoa (:,:,:) = 1.3_dbl_kind ! air density (kg/m^3) uatm (:,:,:) = c5 ! wind velocity (m/s) vatm (:,:,:) = c5 @@ -678,7 +576,7 @@ subroutine init_coupler_flux flw (:,:,:) = c180 ! incoming longwave rad (W/m^2) frain (:,:,:) = c0 ! rainfall rate (kg/m2/s) do n = 1, ncat ! conductive heat flux (W/m^2) - fcondtopn_f(:,:,n,:) = fcondtopn_d(min(n,max_d)) + fcondtopn_f(:,:,n,:) = fcondtopn_d(n) enddo fsurfn_f = fcondtopn_f ! surface heat flux (W/m^2) flatn_f (:,:,:,:) = c0 ! latent heat flux (kg/m2/s) @@ -695,7 +593,7 @@ subroutine init_coupler_flux flw (:,:,:) = 280.0_dbl_kind ! incoming longwave rad (W/m^2) frain (:,:,:) = c0 ! rainfall rate (kg/m2/s) do n = 1, ncat ! surface heat flux (W/m^2) - fsurfn_f(:,:,n,:) = fsurfn_d(min(n,max_d)) + fsurfn_f(:,:,n,:) = fsurfn_d(n) enddo fcondtopn_f(:,:,:,:) = 0.0_dbl_kind ! conductive heat flux (W/m^2) flatn_f (:,:,:,:) = -2.0_dbl_kind ! latent heat flux (W/m^2) @@ -712,12 +610,12 @@ subroutine init_coupler_flux flw (:,:,:) = 230.0_dbl_kind ! incoming longwave rad (W/m^2) frain (:,:,:) = c0 ! rainfall rate (kg/m2/s) do n = 1, ncat ! surface heat flux (W/m^2) - fsurfn_f(:,:,n,:) = fsurfn_d(min(n,max_d)) + fsurfn_f(:,:,n,:) = fsurfn_d(n) enddo fcondtopn_f(:,:,:,:) = c0 ! conductive heat flux (W/m^2) flatn_f (:,:,:,:) = -1.0_dbl_kind ! latent heat flux (W/m^2) fsensn_f (:,:,:,:) = c0 ! sensible heat flux (W/m^2) - endif ! + endif ! fiso_atm (:,:,:,:) = c0 ! isotope deposition rate (kg/m2/s) faero_atm (:,:,:,:) = c0 ! aerosol deposition rate (kg/m2/s) @@ -727,13 +625,13 @@ subroutine init_coupler_flux ! fluxes received from ocean !----------------------------------------------------------------- - ss_tltx (:,:,:) = c0 ! sea surface tilt (m/m) - ss_tlty (:,:,:) = c0 - uocn (:,:,:) = c0 ! surface ocean currents (m/s) - vocn (:,:,:) = c0 - frzmlt (:,:,:) = c0 ! freezing/melting potential (W/m^2) - frzmlt_init(:,:,:) = c0 ! freezing/melting potential (W/m^2) - sss (:,:,:) = 34.0_dbl_kind ! sea surface salinity (ppt) + ss_tltx(:,:,:)= c0 ! sea surface tilt (m/m) + ss_tlty(:,:,:)= c0 + uocn (:,:,:) = c0 ! surface ocean currents (m/s) + vocn (:,:,:) = c0 + frzmlt(:,:,:) = c0 ! freezing/melting potential (W/m^2) + frzmlt_init(:,:,:) = c0 ! freezing/melting potential (W/m^2) + sss (:,:,:) = 34.0_dbl_kind ! sea surface salinity (ppt) do iblk = 1, size(Tf,3) do j = 1, size(Tf,2) @@ -743,7 +641,9 @@ subroutine init_coupler_flux enddo enddo +#ifndef CICE_IN_NEMO sst (:,:,:) = Tf(:,:,:) ! sea surface temp (C) +#endif qdp (:,:,:) = c0 ! deep ocean heat flux (W/m^2) hmix (:,:,:) = c20 ! ocean mixed layer depth (m) hwater(:,:,:) = bathymetry(:,:,:) ! ocean water depth (m) @@ -760,7 +660,7 @@ subroutine init_coupler_flux flat (:,:,:) = c0 fswabs (:,:,:) = c0 fswint_ai(:,:,:) = c0 - flwout (:,:,:) = -stefan_boltzmann*Tffresh**4 + flwout (:,:,:) = -stefan_boltzmann*Tffresh**4 ! in case atm model diagnoses Tsfc from flwout evap (:,:,:) = c0 evaps (:,:,:) = c0 @@ -777,17 +677,13 @@ subroutine init_coupler_flux ! fluxes sent to ocean !----------------------------------------------------------------- - strocnxT_iavg (:,:,:) = c0 ! ice-ocean stress, x-direction (T-cell) - strocnyT_iavg (:,:,:) = c0 ! ice-ocean stress, y-direction (T-cell) + strocnxT(:,:,:) = c0 ! ice-ocean stress, x-direction (T-cell) + strocnyT(:,:,:) = c0 ! ice-ocean stress, y-direction (T-cell) fresh (:,:,:) = c0 fsalt (:,:,:) = c0 fpond (:,:,:) = c0 fhocn (:,:,:) = c0 fswthru (:,:,:) = c0 - fswthru_vdr (:,:,:) = c0 - fswthru_vdf (:,:,:) = c0 - fswthru_idr (:,:,:) = c0 - fswthru_idf (:,:,:) = c0 fresh_da(:,:,:) = c0 ! data assimilation fsalt_da(:,:,:) = c0 flux_bio (:,:,:,:) = c0 ! bgc @@ -804,17 +700,14 @@ subroutine init_coupler_flux fdon (:,:,:,:)= c0 ffep (:,:,:,:)= c0 ffed (:,:,:,:)= c0 - - allocate(fswthrun_ai(nx_block,ny_block,ncat,max_blocks)) - fswthrun_ai(:,:,:,:) = c0 - + !----------------------------------------------------------------- ! derived or computed fields !----------------------------------------------------------------- coszen (:,:,:) = c0 ! Cosine of the zenith angle fsw (:,:,:) = c0 ! shortwave radiation (W/m^2) - scale_factor(:,:,:) = c1 ! shortwave scaling factor + scale_factor(:,:,:) = c1 ! shortwave scaling factor wind (:,:,:) = sqrt(uatm(:,:,:)**2 & + vatm(:,:,:)**2) ! wind speed, (m/s) Cdn_atm(:,:,:) = (vonkar/log(zref/iceruf)) & @@ -890,10 +783,6 @@ subroutine init_flux_ocn fpond (:,:,:) = c0 fhocn (:,:,:) = c0 fswthru (:,:,:) = c0 - fswthru_vdr (:,:,:) = c0 - fswthru_vdf (:,:,:) = c0 - fswthru_idr (:,:,:) = c0 - fswthru_idf (:,:,:) = c0 faero_ocn (:,:,:,:) = c0 fiso_ocn (:,:,:,:) = c0 @@ -901,10 +790,6 @@ subroutine init_flux_ocn H2_16O_ocn (:,:,:) = c0 H2_18O_ocn (:,:,:) = c0 - if (send_i2x_per_cat) then - fswthrun_ai(:,:,:,:) = c0 - endif - end subroutine init_flux_ocn !======================================================================= @@ -984,8 +869,8 @@ subroutine init_history_therm snowfrac (:,:,:) = c0 frazil_diag (:,:,:) = c0 - ! drag coefficients are computed prior to the atmo_boundary call, - ! during the thermodynamics section + ! drag coefficients are computed prior to the atmo_boundary call, + ! during the thermodynamics section Cdn_ocn(:,:,:) = dragio Cdn_atm(:,:,:) = (vonkar/log(zref/iceruf)) & * (vonkar/log(zref/iceruf)) ! atmo drag for RASM @@ -1021,7 +906,6 @@ end subroutine init_history_therm subroutine init_history_dyn use ice_state, only: aice, vice, trcr, strength - use ice_grid, only: grid_ice logical (kind=log_kind) :: & tr_iage @@ -1039,17 +923,17 @@ subroutine init_history_dyn sig1 (:,:,:) = c0 sig2 (:,:,:) = c0 - taubxU (:,:,:) = c0 - taubyU (:,:,:) = c0 + taubx (:,:,:) = c0 + tauby (:,:,:) = c0 strength (:,:,:) = c0 - strocnxU(:,:,:) = c0 - strocnyU(:,:,:) = c0 - strairxU(:,:,:) = c0 - strairyU(:,:,:) = c0 - strtltxU(:,:,:) = c0 - strtltyU(:,:,:) = c0 - strintxU(:,:,:) = c0 - strintyU(:,:,:) = c0 + strocnx (:,:,:) = c0 + strocny (:,:,:) = c0 + strairx (:,:,:) = c0 + strairy (:,:,:) = c0 + strtltx (:,:,:) = c0 + strtlty (:,:,:) = c0 + strintx (:,:,:) = c0 + strinty (:,:,:) = c0 dardg1dt(:,:,:) = c0 dardg2dt(:,:,:) = c0 dvirdgdt(:,:,:) = c0 @@ -1058,7 +942,7 @@ subroutine init_history_dyn dvidtd (:,:,:) = vice(:,:,:) ! temporary initial volume if (tr_iage) & dagedtd (:,:,:) = trcr(:,:,nt_iage,:) ! temporary initial age - fmU (:,:,:) = c0 + fm (:,:,:) = c0 ardgn (:,:,:,:) = c0 vrdgn (:,:,:,:) = c0 krdgn (:,:,:,:) = c1 @@ -1073,32 +957,6 @@ subroutine init_history_dyn aredistn (:,:,:,:) = c0 vredistn (:,:,:,:) = c0 - if (grid_ice == "CD" .or. grid_ice == "C") then - taubxE (:,:,:) = c0 - taubyE (:,:,:) = c0 - strocnxE (:,:,:) = c0 - strocnyE (:,:,:) = c0 - strairxE (:,:,:) = c0 - strairyE (:,:,:) = c0 - strtltxE (:,:,:) = c0 - strtltyE (:,:,:) = c0 - strintxE (:,:,:) = c0 - strintyE (:,:,:) = c0 - fmE (:,:,:) = c0 - TbE (:,:,:) = c0 - taubxN (:,:,:) = c0 - taubyN (:,:,:) = c0 - strocnxN (:,:,:) = c0 - strocnyN (:,:,:) = c0 - strairxN (:,:,:) = c0 - strairyN (:,:,:) = c0 - strtltxN (:,:,:) = c0 - strtltyN (:,:,:) = c0 - strintxN (:,:,:) = c0 - strintyN (:,:,:) = c0 - fmN (:,:,:) = c0 - TbN (:,:,:) = c0 - end if end subroutine init_history_dyn !======================================================================= @@ -1120,11 +978,10 @@ subroutine scale_fluxes (nx_block, ny_block, & Tref, Qref, & fresh, fsalt, & fhocn, fswthru, & - fswthru_vdr, fswthru_vdf, & - fswthru_idr, fswthru_idf, & faero_ocn, & alvdr, alidr, & alvdf, alidf, & + fzsal, fzsal_g, & flux_bio, & fsurf, fcondtop, & Uref, wind, & @@ -1165,10 +1022,6 @@ subroutine scale_fluxes (nx_block, ny_block, & fsalt , & ! salt flux to ocean (kg/m2/s) fhocn , & ! actual ocn/ice heat flx (W/m**2) fswthru , & ! sw radiation through ice bot (W/m**2) - fswthru_vdr , & ! vis dir sw radiation through ice bot (W/m**2) - fswthru_vdf , & ! vis dif sw radiation through ice bot (W/m**2) - fswthru_idr , & ! nir dir sw radiation through ice bot (W/m**2) - fswthru_idf , & ! nir dif sw radiation through ice bot (W/m**2) alvdr , & ! visible, direct (fraction) alidr , & ! near-ir, direct (fraction) alvdf , & ! visible, diffuse (fraction) @@ -1188,6 +1041,11 @@ subroutine scale_fluxes (nx_block, ny_block, & fsurf , & ! surface heat flux (W/m**2) fcondtop ! top surface conductive flux (W/m**2) + ! zsalinity fluxes + real (kind=dbl_kind), dimension(nx_block,ny_block), intent(inout) :: & + fzsal , & ! salt flux to ocean with prognositic salinity (kg/m2/s) + fzsal_g ! Gravity drainage salt flux to ocean (kg/m2/s) + ! isotopes real (kind=dbl_kind), dimension(nx_block,ny_block,icepack_max_iso), & optional, intent(inout) :: & @@ -1213,6 +1071,9 @@ subroutine scale_fluxes (nx_block, ny_block, & if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) +!DIR$ CONCURRENT !Cray +!cdir nodep !NEC +!ocl novrec !Fujitsu do j = 1, ny_block do i = 1, nx_block if (tmask(i,j) .and. aice(i,j) > c0) then @@ -1232,14 +1093,12 @@ subroutine scale_fluxes (nx_block, ny_block, & fsalt (i,j) = fsalt (i,j) * ar fhocn (i,j) = fhocn (i,j) * ar fswthru (i,j) = fswthru (i,j) * ar - fswthru_vdr (i,j) = fswthru_vdr (i,j) * ar - fswthru_vdf (i,j) = fswthru_vdf (i,j) * ar - fswthru_idr (i,j) = fswthru_idr (i,j) * ar - fswthru_idf (i,j) = fswthru_idf (i,j) * ar alvdr (i,j) = alvdr (i,j) * ar alidr (i,j) = alidr (i,j) * ar alvdf (i,j) = alvdf (i,j) * ar alidf (i,j) = alidf (i,j) * ar + fzsal (i,j) = fzsal (i,j) * ar + fzsal_g (i,j) = fzsal_g (i,j) * ar flux_bio (i,j,:) = flux_bio (i,j,:) * ar faero_ocn(i,j,:) = faero_ocn(i,j,:) * ar if (present(Qref_iso )) Qref_iso (i,j,:) = Qref_iso (i,j,:) * ar @@ -1262,14 +1121,12 @@ subroutine scale_fluxes (nx_block, ny_block, & fsalt (i,j) = c0 fhocn (i,j) = c0 fswthru (i,j) = c0 - fswthru_vdr (i,j) = c0 - fswthru_vdf (i,j) = c0 - fswthru_idr (i,j) = c0 - fswthru_idf (i,j) = c0 alvdr (i,j) = c0 ! zero out albedo where ice is absent alidr (i,j) = c0 - alvdf (i,j) = c0 + alvdf (i,j) = c0 alidf (i,j) = c0 + fzsal (i,j) = c0 + fzsal_g (i,j) = c0 flux_bio (i,j,:) = c0 faero_ocn(i,j,:) = c0 if (present(Qref_iso )) Qref_iso (i,j,:) = c0 @@ -1280,8 +1137,11 @@ subroutine scale_fluxes (nx_block, ny_block, & enddo ! j ! Scale fluxes for history output - if (present(fsurf) .and. present(fcondtop) ) then - + if (present(fsurf) .and. present(fcondtop) ) then + +!DIR$ CONCURRENT !Cray +!cdir nodep !NEC +!ocl novrec !Fujitsu do j = 1, ny_block do i = 1, nx_block if (tmask(i,j) .and. aice(i,j) > c0) then @@ -1294,9 +1154,9 @@ subroutine scale_fluxes (nx_block, ny_block, & endif ! tmask and aice > 0 enddo ! i enddo ! j - + endif ! present(fsurf & fcondtop) - + end subroutine scale_fluxes !======================================================================= diff --git a/cicecore/cicedyn/general/ice_flux_bgc.F90 b/cicecore/cicedyn/general/ice_flux_bgc.F90 index 9c07971ff..56e644431 100644 --- a/cicecore/cicedyn/general/ice_flux_bgc.F90 +++ b/cicecore/cicedyn/general/ice_flux_bgc.F90 @@ -26,13 +26,13 @@ module ice_flux_bgc real (kind=dbl_kind), & ! coupling variable for both tr_aero and tr_zaero dimension (:,:,:,:), allocatable, public :: & fiso_atm, & ! isotope deposition rate (kg/m^2 s) - faero_atm ! aerosol deposition rate (kg/m^2 s) + faero_atm ! aerosol deposition rate (kg/m^2 s) real (kind=dbl_kind), & dimension (:,:,:,:), allocatable, public :: & flux_bio_atm ! all bio fluxes to ice from atmosphere - ! out to ocean + ! out to ocean real (kind=dbl_kind), & dimension (:,:,:,:), allocatable, public :: & @@ -44,6 +44,10 @@ module ice_flux_bgc flux_bio , & ! all bio fluxes to ocean flux_bio_ai ! all bio fluxes to ocean, averaged over grid cell + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & + fzsal_ai, & ! salt flux to ocean from zsalinity (kg/m^2/s) + fzsal_g_ai ! gravity drainage salt flux to ocean (kg/m^2/s) + ! internal logical (kind=log_kind), public :: & @@ -54,7 +58,7 @@ module ice_flux_bgc dsnown ! change in snow thickness in category n (m) real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & - nit , & ! ocean nitrate (mmol/m^3) + nit , & ! ocean nitrate (mmol/m^3) amm , & ! ammonia/um (mmol/m^3) sil , & ! silicate (mmol/m^3) dmsp , & ! dmsp (mmol/m^3) @@ -81,15 +85,15 @@ module ice_flux_bgc fdon ! ice-ocean don flux (mmol/m^2/s) (proteins and amino acids) real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & - dic , & ! ocean dic (mmol/m^3) - fdic ! ice-ocean dic flux (mmol/m^2/s) + dic , & ! ocean dic (mmol/m^3) + fdic ! ice-ocean dic flux (mmol/m^2/s) real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & - fed, fep , & ! ocean dissolved and particulate fe (nM) - ffed, ffep ! ice-ocean dissolved and particulate fe flux (umol/m^2/s) + fed, fep , & ! ocean dissolved and particulate fe (nM) + ffed, ffep ! ice-ocean dissolved and particulate fe flux (umol/m^2/s) real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & - zaeros ! ocean aerosols (mmol/m^3) + zaeros ! ocean aerosols (mmol/m^3) ! isotopes real (kind=dbl_kind), & ! coupling variable for tr_iso @@ -110,14 +114,16 @@ module ice_flux_bgc !======================================================================= ! -! Allocate space for all variables +! Allocate space for all variables ! subroutine alloc_flux_bgc integer (int_kind) :: ierr allocate( & - nit (nx_block,ny_block,max_blocks), & ! ocean nitrate (mmol/m^3) + fzsal_ai (nx_block,ny_block,max_blocks), & ! salt flux to ocean from zsalinity (kg/m^2/s) + fzsal_g_ai (nx_block,ny_block,max_blocks), & ! gravity drainage salt flux to ocean (kg/m^2/s) + nit (nx_block,ny_block,max_blocks), & ! ocean nitrate (mmol/m^3) amm (nx_block,ny_block,max_blocks), & ! ammonia/um (mmol/m^3) sil (nx_block,ny_block,max_blocks), & ! silicate (mmol/m^3) dmsp (nx_block,ny_block,max_blocks), & ! dmsp (mmol/m^3) @@ -132,32 +138,32 @@ subroutine alloc_flux_bgc fdust (nx_block,ny_block,max_blocks), & ! ice-ocean dust flux (kg/m^2/s), positive to ocean hin_old (nx_block,ny_block,ncat,max_blocks), & ! old ice thickness dsnown (nx_block,ny_block,ncat,max_blocks), & ! change in snow thickness in category n (m) - HDO_ocn (nx_block,ny_block,max_blocks), & ! seawater concentration of HDO (kg/kg) - H2_16O_ocn (nx_block,ny_block,max_blocks), & ! seawater concentration of H2_16O (kg/kg) - H2_18O_ocn (nx_block,ny_block,max_blocks), & ! seawater concentration of H2_18O (kg/kg) - Qa_iso (nx_block,ny_block,icepack_max_iso,max_blocks), & ! isotope specific humidity (kg/kg) - Qref_iso (nx_block,ny_block,icepack_max_iso,max_blocks), & ! 2m atm reference isotope spec humidity (kg/kg) - fiso_atm (nx_block,ny_block,icepack_max_iso,max_blocks), & ! isotope deposition rate (kg/m^2 s) - fiso_evap (nx_block,ny_block,icepack_max_iso,max_blocks), & ! isotope evaporation rate (kg/m^2 s) - fiso_ocn (nx_block,ny_block,icepack_max_iso,max_blocks), & ! isotope flux to ocean (kg/m^2/s) - faero_atm (nx_block,ny_block,icepack_max_aero,max_blocks), & ! aerosol deposition rate (kg/m^2 s) + HDO_ocn (nx_block,ny_block,max_blocks), & ! seawater concentration of HDO (kg/kg) + H2_16O_ocn (nx_block,ny_block,max_blocks), & ! seawater concentration of H2_16O (kg/kg) + H2_18O_ocn (nx_block,ny_block,max_blocks), & ! seawater concentration of H2_18O (kg/kg) + Qa_iso (nx_block,ny_block,icepack_max_iso,max_blocks), & ! isotope specific humidity (kg/kg) + Qref_iso (nx_block,ny_block,icepack_max_iso,max_blocks), & ! 2m atm reference isotope spec humidity (kg/kg) + fiso_atm (nx_block,ny_block,icepack_max_iso,max_blocks), & ! isotope deposition rate (kg/m^2 s) + fiso_evap (nx_block,ny_block,icepack_max_iso,max_blocks), & ! isotope evaporation rate (kg/m^2 s) + fiso_ocn (nx_block,ny_block,icepack_max_iso,max_blocks), & ! isotope flux to ocean (kg/m^2/s) + faero_atm (nx_block,ny_block,icepack_max_aero,max_blocks), & ! aerosol deposition rate (kg/m^2 s) faero_ocn (nx_block,ny_block,icepack_max_aero,max_blocks), & ! aerosol flux to ocean (kg/m^2/s) - zaeros (nx_block,ny_block,icepack_max_aero,max_blocks), & ! ocean aerosols (mmol/m^3) + zaeros (nx_block,ny_block,icepack_max_aero,max_blocks), & ! ocean aerosols (mmol/m^3) flux_bio_atm(nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! all bio fluxes to ice from atmosphere flux_bio (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! all bio fluxes to ocean flux_bio_ai (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! all bio fluxes to ocean, averaged over grid cell algalN (nx_block,ny_block,icepack_max_algae,max_blocks), & ! ocean algal nitrogen (mmol/m^3) (diatoms, pico, phaeo) - falgalN (nx_block,ny_block,icepack_max_algae,max_blocks), & ! ice-ocn algalN flux (mmol/m^2/s) (diatoms, pico, phaeo) + falgalN (nx_block,ny_block,icepack_max_algae,max_blocks), & ! ice-ocean algal nitrogen flux (mmol/m^2/s) (diatoms, pico, phaeo) doc (nx_block,ny_block,icepack_max_doc,max_blocks), & ! ocean doc (mmol/m^3) (saccharids, lipids, tbd ) fdoc (nx_block,ny_block,icepack_max_doc,max_blocks), & ! ice-ocean doc flux (mmol/m^2/s) (saccharids, lipids, tbd) don (nx_block,ny_block,icepack_max_don,max_blocks), & ! ocean don (mmol/m^3) (proteins and amino acids) fdon (nx_block,ny_block,icepack_max_don,max_blocks), & ! ice-ocean don flux (mmol/m^2/s) (proteins and amino acids) - dic (nx_block,ny_block,icepack_max_dic,max_blocks), & ! ocean dic (mmol/m^3) - fdic (nx_block,ny_block,icepack_max_dic,max_blocks), & ! ice-ocean dic flux (mmol/m^2/s) - fed (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ocean dissolved fe (nM) - fep (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ocean particulate fe (nM) - ffed (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ice-ocean dissolved fe flux (umol/m^2/s) - ffep (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ice-ocean particulate fe flux (umol/m^2/s) + dic (nx_block,ny_block,icepack_max_dic,max_blocks), & ! ocean dic (mmol/m^3) + fdic (nx_block,ny_block,icepack_max_dic,max_blocks), & ! ice-ocean dic flux (mmol/m^2/s) + fed (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ocean dissolved fe (nM) + fep (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ocean particulate fe (nM) + ffed (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ice-ocean dissolved fe flux (umol/m^2/s) + ffep (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ice-ocean particulate fe flux (umol/m^2/s) stat=ierr) if (ierr/=0) call abort_ice('(alloc_flux_bgc): Out of memory') @@ -208,10 +214,10 @@ subroutine bgcflux_ice_to_ocn(nx_block, & ! local variables - integer (kind=int_kind) :: & + integer (kind=int_kind) :: & i,j , & ! horizontal indices k ! tracer index - + logical (kind=log_kind) :: & skl_bgc, solve_zbgc, & tr_bgc_Nit, tr_bgc_N, & @@ -220,14 +226,14 @@ subroutine bgcflux_ice_to_ocn(nx_block, & integer (kind=int_kind) :: & nlt_bgc_Nit, nlt_bgc_Am, & - nlt_bgc_Sil, nlt_bgc_DMSPd, nlt_bgc_DMS, nlt_bgc_hum + nlt_bgc_Sil, nlt_bgc_DMSPd, nlt_bgc_DMS, nlt_bgc_hum integer (kind=int_kind), dimension(icepack_max_algae) :: & nlt_bgc_N, nlt_bgc_C ! algae integer (kind=int_kind), dimension(icepack_max_doc) :: & nlt_bgc_DOC ! disolved organic carbon integer (kind=int_kind), dimension(icepack_max_don) :: & - nlt_bgc_DON ! + nlt_bgc_DON ! integer (kind=int_kind), dimension(icepack_max_dic) :: & nlt_bgc_DIC ! disolved inorganic carbon integer (kind=int_kind), dimension(icepack_max_fe) :: & diff --git a/cicecore/cicedyn/general/ice_step_mod.F90 b/cicecore/cicedyn/general/ice_step_mod.F90 index 89dba3d12..e389adc87 100644 --- a/cicecore/cicedyn/general/ice_step_mod.F90 +++ b/cicecore/cicedyn/general/ice_step_mod.F90 @@ -12,14 +12,7 @@ module ice_step_mod use ice_kinds_mod - use ice_blocks, only: block, get_block - use ice_blocks, only: nx_block, ny_block - use ice_constants, only: c0, c1, c1000, c4, p25 - use ice_constants, only: field_loc_center, field_loc_NEcorner, & - field_loc_Nface, field_loc_Eface, & - field_type_scalar, field_type_vector - use ice_domain, only: halo_info, nblocks, blocks_ice - use ice_domain_size, only: max_blocks + use ice_constants, only: c0, c1, c1000, c4 use ice_exit, only: abort_ice use ice_fileunits, only: nu_diag use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted @@ -43,12 +36,8 @@ module ice_step_mod private public :: step_therm1, step_therm2, step_dyn_horiz, step_dyn_ridge, & - step_snow, prep_radiation, step_radiation, ocean_mixed_layer, & - update_state, biogeochemistry, step_dyn_wave, step_prep - - real (kind=dbl_kind), dimension (:,:,:), allocatable :: & - uvelT_icep, & ! uvel for wind stress computation in icepack - vvelT_icep ! vvel for wind stress computation in icepack + prep_radiation, step_radiation, ocean_mixed_layer, & + update_state, biogeochemistry, save_init, step_dyn_wave !======================================================================= @@ -62,8 +51,6 @@ subroutine save_init use ice_state, only: aice, aicen, aice_init, aicen_init, & vicen, vicen_init, vsnon, vsnon_init - character(len=*), parameter :: subname = '(save_init)' - !----------------------------------------------------------------- ! Save the ice area passed to the coupler (so that history fields ! can be made consistent with coupler fields). @@ -77,54 +64,6 @@ subroutine save_init end subroutine save_init -!======================================================================= - - subroutine step_prep -! prep for step, called outside nblock loop - - use ice_flux, only: uatm, vatm, uatmT, vatmT - use ice_grid, only: grid_atm_dynu, grid_atm_dynv, grid_average_X2Y - use ice_state, only: uvel, vvel - - logical (kind=log_kind) :: & - highfreq ! highfreq flag - - logical (kind=log_kind), save :: & - first_call = .true. ! first call flag - - character(len=*), parameter :: subname = '(step_prep)' - - ! Save initial state - - call save_init - - ! Compute uatmT, vatmT - - call grid_average_X2Y('S',uatm,grid_atm_dynu,uatmT,'T') - call grid_average_X2Y('S',vatm,grid_atm_dynv,vatmT,'T') - - !----------------------------------------------------------------- - ! Compute uvelT_icep, vvelT_icep - !----------------------------------------------------------------- - - if (first_call) then - allocate(uvelT_icep(nx_block,ny_block,max_blocks)) - allocate(vvelT_icep(nx_block,ny_block,max_blocks)) - uvelT_icep = c0 - vvelT_icep = c0 - endif - - call icepack_query_parameters(highfreq_out=highfreq) - - if (highfreq) then - call grid_average_X2Y('A', uvel, 'U', uvelT_icep, 'T') - call grid_average_X2Y('A', vvel, 'U', vvelT_icep, 'T') - endif - - first_call = .false. - - end subroutine step_prep - !======================================================================= ! ! Scales radiation fields computed on the previous time step. @@ -133,12 +72,13 @@ end subroutine step_prep subroutine prep_radiation (iblk) + use ice_blocks, only: block, get_block + use ice_domain, only: blocks_ice use ice_domain_size, only: ncat, nilyr, nslyr use ice_flux, only: scale_factor, swvdr, swvdf, swidr, swidf, & alvdr_ai, alvdf_ai, alidr_ai, alidf_ai, & alvdr_init, alvdf_init, alidr_init, alidf_init - use ice_arrays_column, only: fswsfcn, fswintn, & - fswthrun, fswthrun_vdr, fswthrun_vdf, fswthrun_idr, fswthrun_idf, & + use ice_arrays_column, only: fswsfcn, fswintn, fswthrun, & fswpenln, Sswabsn, Iswabsn use ice_state, only: aice, aicen use ice_timers, only: ice_timer_start, ice_timer_stop, timer_sw @@ -157,14 +97,14 @@ subroutine prep_radiation (iblk) character(len=*), parameter :: subname = '(prep_radiation)' - call ice_timer_start(timer_sw,iblk) ! shortwave + call ice_timer_start(timer_sw) ! shortwave alvdr_init(:,:,iblk) = c0 alvdf_init(:,:,iblk) = c0 alidr_init(:,:,iblk) = c0 alidf_init(:,:,iblk) = c0 - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo @@ -190,12 +130,7 @@ subroutine prep_radiation (iblk) alvdr_ai = alvdr_ai(i,j, iblk), alvdf_ai = alvdf_ai(i,j, iblk), & alidr_ai = alidr_ai(i,j, iblk), alidf_ai = alidf_ai(i,j, iblk), & fswsfcn = fswsfcn (i,j, :,iblk), fswintn = fswintn (i,j, :,iblk), & - fswthrun = fswthrun(i,j, :,iblk), & - fswthrun_vdr = fswthrun_vdr(i,j, :,iblk), & - fswthrun_vdf = fswthrun_vdf(i,j, :,iblk), & - fswthrun_idr = fswthrun_idr(i,j, :,iblk), & - fswthrun_idf = fswthrun_idf(i,j, :,iblk), & - fswpenln = fswpenln(i,j,:,:,iblk), & + fswthrun = fswthrun(i,j, :,iblk), fswpenln = fswpenln(i,j,:,:,iblk), & Sswabsn = Sswabsn (i,j,:,:,iblk), Iswabsn = Iswabsn (i,j,:,:,iblk)) enddo ! i @@ -205,7 +140,7 @@ subroutine prep_radiation (iblk) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - call ice_timer_stop(timer_sw,iblk) ! shortwave + call ice_timer_stop(timer_sw) ! shortwave end subroutine prep_radiation @@ -222,46 +157,40 @@ subroutine step_therm1 (dt, iblk) Cdn_ocn, Cdn_ocn_skin, Cdn_ocn_floe, Cdn_ocn_keel, Cdn_atm_ratio, & Cdn_atm, Cdn_atm_skin, Cdn_atm_floe, Cdn_atm_rdg, Cdn_atm_pond, & hfreebd, hdraft, hridge, distrdg, hkeel, dkeel, lfloe, dfloe, & - fswsfcn, fswintn, Sswabsn, Iswabsn, meltsliqn, meltsliq, & - fswthrun, fswthrun_vdr, fswthrun_vdf, fswthrun_idr, fswthrun_idf + fswsfcn, fswintn, fswthrun, Sswabsn, Iswabsn + use ice_blocks, only: block, get_block, nx_block, ny_block use ice_calendar, only: yday + use ice_domain, only: blocks_ice use ice_domain_size, only: ncat, nilyr, nslyr, n_iso, n_aero - use ice_flux, only: frzmlt, sst, Tf, strocnxT_iavg, strocnyT_iavg, rside, fbot, Tbot, Tsnice, & - meltsn, melttn, meltbn, congeln, snoicen, uatmT, vatmT, fside, wlat, & - wind, rhoa, potT, Qa, zlvl, zlvs, strax, stray, flatn, fsensn, fsurfn, fcondtopn, & - flw, fsnow, fpond, sss, mlt_onset, frz_onset, fcondbotn, fcondbot, fsloss, & + use ice_flux, only: frzmlt, sst, Tf, strocnxT, strocnyT, rside, fbot, Tbot, Tsnice, & + meltsn, melttn, meltbn, congeln, snoicen, uatm, vatm, fside, & + wind, rhoa, potT, Qa, zlvl, strax, stray, flatn, fsensn, fsurfn, fcondtopn, & + flw, fsnow, fpond, sss, mlt_onset, frz_onset, fcondbotn, fcondbot, & frain, Tair, strairxT, strairyT, fsurf, fcondtop, fsens, & flat, fswabs, flwout, evap, evaps, evapi, Tref, Qref, Uref, fresh, fsalt, fhocn, & - fswthru, fswthru_vdr, fswthru_vdf, fswthru_idr, fswthru_idf, & - meltt, melts, meltb, congel, snoice, & - flatn_f, fsensn_f, fsurfn_f, fcondtopn_f, & - send_i2x_per_cat, fswthrun_ai, dsnow + fswthru, meltt, melts, meltb, congel, snoice, & + flatn_f, fsensn_f, fsurfn_f, fcondtopn_f use ice_flux_bgc, only: dsnown, faero_atm, faero_ocn, fiso_atm, fiso_ocn, & Qa_iso, Qref_iso, fiso_evap, HDO_ocn, H2_16O_ocn, H2_18O_ocn use ice_grid, only: lmask_n, lmask_s, tmask - use ice_state, only: aice, aicen, aicen_init, vicen_init, & - vice, vicen, vsno, vsnon, trcrn, vsnon_init -#ifdef CICE_IN_NEMO - use ice_state, only: aice_init -#endif + use ice_state, only: aice, aicen, aice_init, aicen_init, vicen_init, & + vice, vicen, vsno, vsnon, trcrn, uvel, vvel, vsnon_init #ifdef CESMCOUPLED use ice_prescribed_mod, only: prescribed_ice #else - logical (kind=log_kind) :: & - prescribed_ice ! if .true., use prescribed ice instead of computed + logical (kind=log_kind) :: & + prescribed_ice ! if .true., use prescribed ice instead of computed #endif + real (kind=dbl_kind), intent(in) :: & - dt ! time step (s) + dt ! time step integer (kind=int_kind), intent(in) :: & - iblk ! block index + iblk ! block index ! local variables -#ifdef CICE_IN_NEMO - real (kind=dbl_kind) :: & - raice ! reciprocal of ice concentration -#endif + integer (kind=int_kind) :: & ilo,ihi,jlo,jhi, & ! beginning and end of physical domain i, j , & ! horizontal indices @@ -271,36 +200,32 @@ subroutine step_therm1 (dt, iblk) integer (kind=int_kind) :: & ntrcr, nt_apnd, nt_hpnd, nt_ipnd, nt_alvl, nt_vlvl, nt_Tsfc, & nt_iage, nt_FY, nt_qice, nt_sice, nt_aero, nt_qsno, & - nt_isosno, nt_isoice, nt_rsnw, nt_smice, nt_smliq + nt_isosno, nt_isoice logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_iso, tr_aero, tr_pond, & - tr_pond_lvl, tr_pond_topo, calc_Tsfc, snwgrain + tr_iage, tr_FY, tr_iso, tr_aero, tr_pond, tr_pond_cesm, & + tr_pond_lvl, tr_pond_topo, calc_Tsfc real (kind=dbl_kind) :: & - puny ! a very small number + puny real (kind=dbl_kind), dimension(n_aero,2,ncat) :: & - aerosno, aeroice ! kg/m^2 + aerosno, aeroice ! kg/m^2 real (kind=dbl_kind), dimension(n_iso,ncat) :: & - isosno, isoice ! kg/m^2 - - real (kind=dbl_kind), dimension(nslyr,ncat) :: & - rsnwn, smicen, smliqn + isosno, isoice ! kg/m^2 type (block) :: & - this_block ! block information for current block + this_block ! block information for current block character(len=*), parameter :: subname = '(step_therm1)' call icepack_query_parameters(puny_out=puny) call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc) - call icepack_query_parameters(snwgrain_out=snwgrain) call icepack_query_tracer_sizes(ntrcr_out=ntrcr) call icepack_query_tracer_flags( & tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_iso_out=tr_iso, & - tr_aero_out=tr_aero, tr_pond_out=tr_pond, & + tr_aero_out=tr_aero, tr_pond_out=tr_pond, tr_pond_cesm_out=tr_pond_cesm, & tr_pond_lvl_out=tr_pond_lvl, tr_pond_topo_out=tr_pond_topo) call icepack_query_tracer_indices( & nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, & @@ -308,7 +233,6 @@ subroutine step_therm1 (dt, iblk) nt_iage_out=nt_iage, nt_FY_out=nt_FY, & nt_qice_out=nt_qice, nt_sice_out=nt_sice, & nt_aero_out=nt_aero, nt_qsno_out=nt_qsno, & - nt_rsnw_out=nt_rsnw, nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, & nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & @@ -318,9 +242,7 @@ subroutine step_therm1 (dt, iblk) prescribed_ice = .false. #endif - rsnwn (:,:) = c0 - smicen (:,:) = c0 - smliqn (:,:) = c0 + isosno (:,:) = c0 isoice (:,:) = c0 aerosno(:,:,:) = c0 aeroice(:,:,:) = c0 @@ -347,25 +269,15 @@ subroutine step_therm1 (dt, iblk) enddo ! j #endif - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi - + do j = jlo, jhi do i = ilo, ihi - if (snwgrain) then - do n = 1, ncat - do k = 1, nslyr - rsnwn (k,n) = trcrn(i,j,nt_rsnw +k-1,n,iblk) - smicen(k,n) = trcrn(i,j,nt_smice+k-1,n,iblk) - smliqn(k,n) = trcrn(i,j,nt_smliq+k-1,n,iblk) - enddo - enddo - endif ! snwgrain - if (tr_iso) then ! trcrn(nt_iso*) has units kg/m^3 do n=1,ncat do k=1,n_iso @@ -388,8 +300,7 @@ subroutine step_therm1 (dt, iblk) enddo endif ! tr_aero - if (tmask(i,j,iblk)) then - + if (tmask(i,j,iblk)) & call icepack_step_therm1(dt=dt, ncat=ncat, & nilyr=nilyr, nslyr=nslyr, & aicen_init = aicen_init (i,j,:,iblk), & @@ -401,31 +312,27 @@ subroutine step_therm1 (dt, iblk) vicen = vicen (i,j,:,iblk), & vsno = vsno (i,j, iblk), & vsnon = vsnon (i,j,:,iblk), & - uvel = uvelT_icep (i,j, iblk), & - vvel = vvelT_icep (i,j, iblk), & + uvel = uvel (i,j, iblk), & + vvel = vvel (i,j, iblk), & Tsfc = trcrn (i,j,nt_Tsfc,:,iblk), & - zqsn = trcrn (i,j,nt_qsno:nt_qsno+nslyr-1,:,iblk), & - zqin = trcrn (i,j,nt_qice:nt_qice+nilyr-1,:,iblk), & - zSin = trcrn (i,j,nt_sice:nt_sice+nilyr-1,:,iblk), & - alvl = trcrn (i,j,nt_alvl,:,iblk), & - vlvl = trcrn (i,j,nt_vlvl,:,iblk), & - apnd = trcrn (i,j,nt_apnd,:,iblk), & - hpnd = trcrn (i,j,nt_hpnd,:,iblk), & - ipnd = trcrn (i,j,nt_ipnd,:,iblk), & + zqsn = trcrn (i,j,nt_qsno:nt_qsno+nslyr-1,:,iblk), & + zqin = trcrn (i,j,nt_qice:nt_qice+nilyr-1,:,iblk), & + zSin = trcrn (i,j,nt_sice:nt_sice+nilyr-1,:,iblk), & + alvl = trcrn (i,j,nt_alvl,:,iblk), & + vlvl = trcrn (i,j,nt_vlvl,:,iblk), & + apnd = trcrn (i,j,nt_apnd,:,iblk), & + hpnd = trcrn (i,j,nt_hpnd,:,iblk), & + ipnd = trcrn (i,j,nt_ipnd,:,iblk), & iage = trcrn (i,j,nt_iage,:,iblk), & - FY = trcrn (i,j,nt_FY ,:,iblk), & - rsnwn = rsnwn (:,:), & - smicen = smicen (:,:), & - smliqn = smliqn (:,:), & + FY = trcrn (i,j,nt_FY ,:,iblk), & aerosno = aerosno (:,:,:), & aeroice = aeroice (:,:,:), & isosno = isosno (:,:), & isoice = isoice (:,:), & - uatm = uatmT (i,j, iblk), & - vatm = vatmT (i,j, iblk), & + uatm = uatm (i,j, iblk), & + vatm = vatm (i,j, iblk), & wind = wind (i,j, iblk), & zlvl = zlvl (i,j, iblk), & - zlvs = zlvs (i,j, iblk), & Qa = Qa (i,j, iblk), & Qa_iso = Qa_iso (i,j,:,iblk), & rhoa = rhoa (i,j, iblk), & @@ -460,19 +367,17 @@ subroutine step_therm1 (dt, iblk) sst = sst (i,j, iblk), & sss = sss (i,j, iblk), & Tf = Tf (i,j, iblk), & - strocnxT = strocnxT_iavg(i,j, iblk), & - strocnyT = strocnyT_iavg(i,j, iblk), & + strocnxT = strocnxT (i,j, iblk), & + strocnyT = strocnyT (i,j, iblk), & fbot = fbot (i,j, iblk), & Tbot = Tbot (i,j, iblk), & - Tsnice = Tsnice (i,j, iblk), & + Tsnice = Tsnice (i,j, iblk), & frzmlt = frzmlt (i,j, iblk), & rside = rside (i,j, iblk), & fside = fside (i,j, iblk), & - wlat = wlat (i,j, iblk), & fsnow = fsnow (i,j, iblk), & frain = frain (i,j, iblk), & fpond = fpond (i,j, iblk), & - fsloss = fsloss (i,j, iblk), & fsurf = fsurf (i,j, iblk), & fsurfn = fsurfn (i,j,:,iblk), & fcondtop = fcondtop (i,j, iblk), & @@ -482,10 +387,6 @@ subroutine step_therm1 (dt, iblk) fswsfcn = fswsfcn (i,j,:,iblk), & fswintn = fswintn (i,j,:,iblk), & fswthrun = fswthrun (i,j,:,iblk), & - fswthrun_vdr = fswthrun_vdr (i,j,:,iblk),& - fswthrun_vdf = fswthrun_vdf (i,j,:,iblk),& - fswthrun_idr = fswthrun_idr (i,j,:,iblk),& - fswthrun_idf = fswthrun_idf (i,j,:,iblk),& fswabs = fswabs (i,j, iblk), & flwout = flwout (i,j, iblk), & Sswabsn = Sswabsn (i,j,:,:,iblk), & @@ -502,10 +403,6 @@ subroutine step_therm1 (dt, iblk) fsalt = fsalt (i,j, iblk), & fhocn = fhocn (i,j, iblk), & fswthru = fswthru (i,j, iblk), & - fswthru_vdr = fswthru_vdr (i,j, iblk), & - fswthru_vdf = fswthru_vdf (i,j, iblk), & - fswthru_idr = fswthru_idr (i,j, iblk), & - fswthru_idf = fswthru_idf (i,j, iblk), & flatn_f = flatn_f (i,j,:,iblk), & fsensn_f = fsensn_f (i,j,:,iblk), & fsurfn_f = fsurfn_f (i,j,:,iblk), & @@ -530,41 +427,13 @@ subroutine step_therm1 (dt, iblk) congeln = congeln (i,j,:,iblk), & snoice = snoice (i,j, iblk), & snoicen = snoicen (i,j,:,iblk), & - dsnow = dsnow (i,j, iblk), & dsnown = dsnown (i,j,:,iblk), & - meltsliq = meltsliq (i,j, iblk), & - meltsliqn = meltsliqn (i,j,:,iblk), & lmask_n = lmask_n (i,j, iblk), & lmask_s = lmask_s (i,j, iblk), & mlt_onset = mlt_onset (i,j, iblk), & frz_onset = frz_onset (i,j, iblk), & yday=yday, prescribed_ice=prescribed_ice) - !----------------------------------------------------------------- - ! handle per-category i2x fields, no merging - !----------------------------------------------------------------- - - if (send_i2x_per_cat) then - do n = 1, ncat - ! TODO (mvertens, 2018-12-22): do we need to add the band separated quantities - ! for MOM6 here also? - - fswthrun_ai(i,j,n,iblk) = fswthrun(i,j,n,iblk)*aicen_init(i,j,n,iblk) - enddo ! ncat - endif - - endif - - if (snwgrain) then - do n = 1, ncat - do k = 1, nslyr - trcrn(i,j,nt_rsnw +k-1,n,iblk) = rsnwn (k,n) - trcrn(i,j,nt_smice+k-1,n,iblk) = smicen(k,n) - trcrn(i,j,nt_smliq+k-1,n,iblk) = smliqn(k,n) - enddo - enddo - endif ! snwgrain - if (tr_iso) then do n = 1, ncat if (vicen(i,j,n,iblk) > puny) & @@ -611,14 +480,16 @@ end subroutine step_therm1 subroutine step_therm2 (dt, iblk) - use ice_arrays_column, only: hin_max, ocean_bio, wave_sig_ht, & + use ice_arrays_column, only: hin_max, fzsal, ocean_bio, wave_sig_ht, & wave_spectrum, wavefreq, dwavefreq, & first_ice, bgrid, cgrid, igrid, floe_rad_c, floe_binwidth, & d_afsd_latg, d_afsd_newi, d_afsd_latm, d_afsd_weld + use ice_blocks, only: block, get_block use ice_calendar, only: yday - use ice_domain_size, only: ncat, nilyr, nslyr, nblyr, nfsd + use ice_domain, only: blocks_ice + use ice_domain_size, only: ncat, nilyr, nslyr, n_aero, nblyr, nfsd use ice_flux, only: fresh, frain, fpond, frzmlt, frazil, frz_onset, & - update_ocn_f, fsalt, Tf, sss, salinz, fhocn, rside, fside, wlat, & + update_ocn_f, fsalt, Tf, sss, salinz, fhocn, rside, fside, & meltl, frazil_diag use ice_flux_bgc, only: flux_bio, faero_ocn, & fiso_ocn, HDO_ocn, H2_16O_ocn, H2_18O_ocn @@ -644,7 +515,7 @@ subroutine step_therm2 (dt, iblk) logical (kind=log_kind) :: & tr_fsd, & ! floe size distribution tracers - z_tracers ! vertical biogeochemistry + z_tracers type (block) :: & this_block ! block information for current block @@ -658,14 +529,14 @@ subroutine step_therm2 (dt, iblk) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - ! nltrcr is only used as a zbgc flag in icepack (number of zbgc tracers > 0) + ! tcraig, nltrcr used to be the number of zbgc tracers, but it's used as a zbgc flag in icepack if (z_tracers) then nltrcr = 1 else nltrcr = 0 endif - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo @@ -682,7 +553,7 @@ subroutine step_therm2 (dt, iblk) call icepack_step_therm2(dt=dt, ncat=ncat, & nltrcr=nltrcr, nilyr=nilyr, nslyr=nslyr, nblyr=nblyr, & - hin_max = hin_max (:), & + hin_max = hin_max (:), & aicen = aicen (i,j,:,iblk), & vicen = vicen (i,j,:,iblk), & vsnon = vsnon (i,j,:,iblk), & @@ -701,7 +572,6 @@ subroutine step_therm2 (dt, iblk) rside = rside (i,j, iblk), & meltl = meltl (i,j, iblk), & fside = fside (i,j, iblk), & - wlat = wlat (i,j, iblk), & frzmlt = frzmlt (i,j, iblk), & frazil = frazil (i,j, iblk), & frain = frain (i,j, iblk), & @@ -715,6 +585,7 @@ subroutine step_therm2 (dt, iblk) igrid = igrid, & faero_ocn = faero_ocn (i,j,:,iblk), & first_ice = first_ice (i,j,:,iblk), & + fzsal = fzsal (i,j, iblk), & flux_bio = flux_bio (i,j,1:nbtrcr,iblk), & ocean_bio = ocean_bio (i,j,1:nbtrcr,iblk), & frazil_diag= frazil_diag(i,j,iblk), & @@ -754,26 +625,26 @@ end subroutine step_therm2 subroutine update_state (dt, daidt, dvidt, dagedt, offset) + use ice_blocks, only: nx_block, ny_block + use ice_domain, only: nblocks use ice_domain_size, only: ncat ! use ice_grid, only: tmask use ice_state, only: aicen, trcrn, vicen, vsnon, & aice, trcr, vice, vsno, aice0, trcr_depend, & bound_state, trcr_base, nt_strata, n_trcr_strata - use ice_timers, only: ice_timer_start, ice_timer_stop, timer_bound, timer_updstate + use ice_timers, only: ice_timer_start, ice_timer_stop, timer_bound real (kind=dbl_kind), intent(in) :: & - dt ! time step + dt , & ! time step + offset ! d(age)/dt time offset = dt for thermo, 0 for dyn - real (kind=dbl_kind), dimension(:,:,:), intent(inout), optional :: & - daidt, & ! change in ice area per time step - dvidt, & ! change in ice volume per time step - dagedt ! change in ice age per time step + real (kind=dbl_kind), dimension(:,:,:), intent(inout) :: & + daidt, & ! change in ice area per time step + dvidt, & ! change in ice volume per time step + dagedt ! change in ice age per time step - real (kind=dbl_kind), intent(in), optional :: & - offset ! d(age)/dt time offset = dt for thermo, 0 for dyn - - integer (kind=int_kind) :: & - iblk, & ! block index + integer (kind=int_kind) :: & + iblk, & ! block index i,j, & ! horizontal indices ntrcr, & ! nt_iage ! @@ -783,7 +654,6 @@ subroutine update_state (dt, daidt, dvidt, dagedt, offset) character(len=*), parameter :: subname='(update_state)' - call ice_timer_start(timer_updstate) call icepack_query_tracer_flags(tr_iage_out=tr_iage) call icepack_query_tracer_sizes(ntrcr_out=ntrcr) call icepack_query_tracer_indices(nt_iage_out=nt_iage) @@ -801,15 +671,15 @@ subroutine update_state (dt, daidt, dvidt, dagedt, offset) ntrcr, trcrn) call ice_timer_stop(timer_bound) - !$OMP PARALLEL DO PRIVATE(iblk,i,j) SCHEDULE(runtime) + !$OMP PARALLEL DO PRIVATE(iblk,i,j) do iblk = 1, nblocks do j = 1, ny_block do i = 1, nx_block !----------------------------------------------------------------- - ! Aggregate the updated state variables (includes ghost cells). - !----------------------------------------------------------------- - + ! Aggregate the updated state variables (includes ghost cells). + !----------------------------------------------------------------- + ! if (tmask(i,j,iblk)) & call icepack_aggregate(ncat = ncat, & aicen = aicen(i,j,:,iblk), & @@ -827,8 +697,6 @@ subroutine update_state (dt, daidt, dvidt, dagedt, offset) n_trcr_strata = n_trcr_strata(:), & nt_strata = nt_strata(:,:)) - if (present(offset)) then - !----------------------------------------------------------------- ! Compute thermodynamic area and volume tendencies. !----------------------------------------------------------------- @@ -844,8 +712,7 @@ subroutine update_state (dt, daidt, dvidt, dagedt, offset) dagedt(i,j,iblk) = (trcr(i,j,nt_iage,iblk) & - dagedt(i,j,iblk)) / dt endif - endif ! tr_iage - endif ! present(offset) + endif enddo ! i enddo ! j @@ -855,7 +722,6 @@ subroutine update_state (dt, daidt, dvidt, dagedt, offset) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - call ice_timer_stop(timer_updstate) end subroutine update_state @@ -868,8 +734,10 @@ end subroutine update_state subroutine step_dyn_wave (dt) - use ice_arrays_column, only: wave_spectrum, & + use ice_arrays_column, only: wave_spectrum, wave_sig_ht, & d_afsd_wave, floe_rad_l, floe_rad_c, wavefreq, dwavefreq + use ice_blocks, only: block, get_block + use ice_domain, only: blocks_ice, nblocks use ice_domain_size, only: ncat, nfsd, nfreq use ice_state, only: trcrn, aicen, aice, vice use ice_timers, only: ice_timer_start, ice_timer_stop, timer_column, & @@ -886,7 +754,9 @@ subroutine step_dyn_wave (dt) integer (kind=int_kind) :: & ilo,ihi,jlo,jhi, & ! beginning and end of physical domain iblk, & ! block index - i, j ! horizontal indices + i, j, & ! horizontal indices + ntrcr, & ! + nbtrcr ! character (len=char_len) :: wave_spec_type @@ -943,87 +813,37 @@ end subroutine step_dyn_wave subroutine step_dyn_horiz (dt) - use ice_boundary, only: ice_HaloUpdate use ice_dyn_evp, only: evp use ice_dyn_eap, only: eap - use ice_dyn_vp, only: implicit_solver - use ice_dyn_shared, only: kdyn - use ice_flux, only: strocnxU, strocnyU, strocnxT_iavg, strocnyT_iavg + use ice_dyn_shared, only: kdyn, ktransport use ice_flux, only: init_history_dyn - use ice_grid, only: grid_average_X2Y - use ice_state, only: aiU use ice_transport_driver, only: advection, transport_upwind, transport_remap real (kind=dbl_kind), intent(in) :: & dt ! dynamics time step - ! local variables - - type (block) :: & - this_block ! block information for current block - - integer (kind=int_kind) :: & - ilo,ihi,jlo,jhi, & ! beginning and end of physical domain - iblk, & ! block index - i, j ! horizontal indices - - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks) :: & - work1, & ! temporary - work2 ! temporary - character(len=*), parameter :: subname = '(step_dyn_horiz)' call init_history_dyn ! initialize dynamic history variables !----------------------------------------------------------------- - ! Ice dynamics (momentum equation) + ! Elastic-viscous-plastic ice dynamics !----------------------------------------------------------------- if (kdyn == 1) call evp (dt) if (kdyn == 2) call eap (dt) - if (kdyn == 3) call implicit_solver (dt) - - !----------------------------------------------------------------- - ! Compute strocnxT_iavg, strocnyT_iavg for thermo and coupling - !----------------------------------------------------------------- - - ! strocn computed on U, N, E as needed. Map strocn U divided by aiU to T - ! conservation requires aiU be divided before averaging - work1 = c0 - work2 = c0 - !$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) - do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk), iblk) - ilo = this_block%ilo - ihi = this_block%ihi - jlo = this_block%jlo - jhi = this_block%jhi - do j = jlo, jhi - do i = ilo, ihi - if (aiU(i,j,iblk) /= c0) then - work1(i,j,iblk) = strocnxU(i,j,iblk)/aiU(i,j,iblk) - work2(i,j,iblk) = strocnyU(i,j,iblk)/aiU(i,j,iblk) - endif - enddo - enddo - enddo - !$OMP END PARALLEL DO - call ice_HaloUpdate (work1, halo_info, & - field_loc_NEcorner, field_type_vector) - call ice_HaloUpdate (work2, halo_info, & - field_loc_NEcorner, field_type_vector) - call grid_average_X2Y('F', work1, 'U', strocnxT_iavg, 'T') ! shift - call grid_average_X2Y('F', work2, 'U', strocnyT_iavg, 'T') !----------------------------------------------------------------- ! Horizontal ice transport !----------------------------------------------------------------- + if (ktransport > 0) then if (advection == 'upwind') then call transport_upwind (dt) ! upwind - elseif (advection == 'remap') then + else call transport_remap (dt) ! incremental remapping endif + endif end subroutine step_dyn_horiz @@ -1036,7 +856,9 @@ end subroutine step_dyn_horiz subroutine step_dyn_ridge (dt, ndtd, iblk) - use ice_arrays_column, only: hin_max, first_ice + use ice_arrays_column, only: hin_max, fzsal, first_ice + use ice_blocks, only: block, get_block + use ice_domain, only: blocks_ice use ice_domain_size, only: ncat, nilyr, nslyr, n_aero, nblyr use ice_flux, only: & rdg_conv, rdg_shear, dardg1dt, dardg2dt, & @@ -1056,14 +878,14 @@ subroutine step_dyn_ridge (dt, ndtd, iblk) integer (kind=int_kind), intent(in) :: & ndtd, & ! number of dynamics subcycles - iblk ! block index + iblk ! block index ! local variables type (block) :: & this_block ! block information for current block - integer (kind=int_kind) :: & + integer (kind=int_kind) :: & ilo,ihi,jlo,jhi, & ! beginning and end of physical domain i, j, & ! horizontal indices ntrcr, & ! @@ -1075,8 +897,8 @@ subroutine step_dyn_ridge (dt, ndtd, iblk) ! Ridging !----------------------------------------------------------------- - call ice_timer_start(timer_column,iblk) - call ice_timer_start(timer_ridge,iblk) + call ice_timer_start(timer_column) + call ice_timer_start(timer_ridge) call icepack_query_tracer_sizes(ntrcr_out=ntrcr, nbtrcr_out=nbtrcr) call icepack_warnings_flush(nu_diag) @@ -1133,6 +955,7 @@ subroutine step_dyn_ridge (dt, ndtd, iblk) aice = aice (i,j, iblk), & fsalt = fsalt (i,j, iblk), & first_ice = first_ice(i,j,:,iblk), & + fzsal = fzsal (i,j, iblk), & flux_bio = flux_bio (i,j,1:nbtrcr,iblk)) endif ! tmask @@ -1144,119 +967,11 @@ subroutine step_dyn_ridge (dt, ndtd, iblk) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - call ice_timer_stop(timer_ridge,iblk) - call ice_timer_stop(timer_column,iblk) + call ice_timer_stop(timer_ridge) + call ice_timer_stop(timer_column) end subroutine step_dyn_ridge -!======================================================================= -! -! Updates snow tracers -! -! authors: Elizabeth C. Hunke, LANL -! Nicole Jeffery, LANL - - subroutine step_snow (dt, iblk) - - use ice_calendar, only: nstreams - use ice_domain_size, only: ncat, nslyr, nilyr - use ice_flux, only: snwcnt, wind, fresh, fhocn, fsloss, fsnow - use ice_state, only: trcrn, vsno, vsnon, vicen, aicen, aice - use icepack_intfc, only: icepack_step_snow - - real (kind=dbl_kind), intent(in) :: & - dt ! time step - - integer (kind=int_kind), intent(in) :: & - iblk ! block index - - ! local variables - - integer (kind=int_kind) :: & - nt_smice, nt_smliq, nt_rsnw, & - nt_Tsfc, nt_qice, nt_sice, nt_qsno, & - nt_alvl, nt_vlvl, nt_rhos - - integer (kind=int_kind) :: & - ilo,ihi,jlo,jhi, & ! beginning and end of physical domain - i, j, & ! horizontal indices - ns ! history streams index - - real (kind=dbl_kind) :: & - puny - - real (kind=dbl_kind) :: & - fhs ! flag for presence of snow - - character(len=*), parameter :: subname = '(step_snow)' - - type (block) :: & - this_block ! block information for current block - - this_block = get_block(blocks_ice(iblk),iblk) - ilo = this_block%ilo - ihi = this_block%ihi - jlo = this_block%jlo - jhi = this_block%jhi - - !----------------------------------------------------------------- - ! query icepack values - !----------------------------------------------------------------- - - call icepack_query_parameters(puny_out=puny) - call icepack_query_tracer_indices( & - nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, & - nt_rsnw_out=nt_rsnw, nt_Tsfc_out=nt_Tsfc, & - nt_qice_out=nt_qice, nt_sice_out=nt_sice, nt_qsno_out=nt_qsno, & - nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, nt_rhos_out=nt_rhos) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - - !----------------------------------------------------------------- - ! Snow redistribution and metamorphosis - !----------------------------------------------------------------- - - do j = jlo, jhi - do i = ilo, ihi - - call icepack_step_snow (dt, nilyr, & - nslyr, ncat, & - wind (i,j, iblk), & - aice (i,j, iblk), & - aicen(i,j,:,iblk), & - vicen(i,j,:,iblk), & - vsnon(i,j,:,iblk), & - trcrn(i,j,nt_Tsfc,:,iblk), & - trcrn(i,j,nt_qice,:,iblk), & ! top layer only - trcrn(i,j,nt_sice,:,iblk), & ! top layer only - trcrn(i,j,nt_qsno:nt_qsno+nslyr-1,:,iblk), & - trcrn(i,j,nt_alvl,:,iblk), & - trcrn(i,j,nt_vlvl,:,iblk), & - trcrn(i,j,nt_smice:nt_smice+nslyr-1,:,iblk), & - trcrn(i,j,nt_smliq:nt_smliq+nslyr-1,:,iblk), & - trcrn(i,j,nt_rsnw:nt_rsnw+nslyr-1,:,iblk), & - trcrn(i,j,nt_rhos:nt_rhos+nslyr-1,:,iblk), & - fresh (i,j,iblk), & - fhocn (i,j,iblk), & - fsloss (i,j,iblk), & - fsnow (i,j,iblk)) - enddo - enddo - - ! increment counter for history averaging - do j = jlo, jhi - do i = ilo, ihi - fhs = c0 - if (vsno(i,j,iblk) > puny) fhs = c1 - do ns = 1, nstreams - snwcnt(i,j,iblk,ns) = snwcnt(i,j,iblk,ns) + fhs - enddo - enddo - enddo - - end subroutine step_snow - !======================================================================= ! ! Computes radiation fields @@ -1268,13 +983,14 @@ end subroutine step_snow subroutine step_radiation (dt, iblk) use ice_arrays_column, only: ffracn, dhsn, & - fswsfcn, fswintn, fswpenln, Sswabsn, Iswabsn, & - fswthrun, fswthrun_vdr, fswthrun_vdf, fswthrun_idr, fswthrun_idf, & + fswsfcn, fswintn, fswthrun, fswpenln, Sswabsn, Iswabsn, & albicen, albsnon, albpndn, & alvdrn, alidrn, alvdfn, alidfn, apeffn, trcrn_sw, snowfracn, & kaer_tab, waer_tab, gaer_tab, kaer_bc_tab, waer_bc_tab, & gaer_bc_tab, bcenh, swgrid, igrid - use ice_calendar, only: calendar_type, days_per_year, nextsw_cday, yday, msec + use ice_blocks, only: block, get_block + use ice_calendar, only: calendar_type, days_per_year, nextsw_cday, yday, sec + use ice_domain, only: blocks_ice use ice_domain_size, only: ncat, n_aero, nilyr, nslyr, n_zaero, n_algae, nblyr use ice_flux, only: swvdr, swvdf, swidr, swidf, coszen, fsnow use ice_grid, only: TLAT, TLON, tmask @@ -1300,7 +1016,7 @@ subroutine step_radiation (dt, iblk) this_block ! block information for current block integer (kind=int_kind) :: & - nt_Tsfc, nt_alvl, nt_rsnw, & + nt_Tsfc, nt_alvl, & nt_apnd, nt_hpnd, nt_ipnd, nt_aero, nlt_chl_sw, & ntrcr, nbtrcr, nbtrcr_sw, nt_fbri @@ -1311,14 +1027,13 @@ subroutine step_radiation (dt, iblk) nlt_zaero_sw, nt_zaero logical (kind=log_kind) :: & - tr_bgc_N, tr_zaero, tr_brine, dEdd_algae, modal_aero, snwgrain + tr_bgc_N, tr_zaero, tr_brine, dEdd_algae, modal_aero real (kind=dbl_kind), dimension(ncat) :: & - fbri ! brine height to ice thickness + fbri ! brine height to ice thickness real(kind= dbl_kind), dimension(:,:), allocatable :: & - ztrcr_sw, & ! zaerosols (kg/m^3) and chla (mg/m^3) - rsnow ! snow grain radius tracer (10^-6 m) + ztrcr_sw logical (kind=log_kind) :: & debug, & ! flag for printing debugging information @@ -1326,27 +1041,25 @@ subroutine step_radiation (dt, iblk) character(len=*), parameter :: subname = '(step_radiation)' - call ice_timer_start(timer_sw,iblk) ! shortwave + call ice_timer_start(timer_sw) ! shortwave call icepack_query_tracer_sizes(ntrcr_out=ntrcr, & nbtrcr_out=nbtrcr, nbtrcr_sw_out=nbtrcr_sw) call icepack_query_tracer_flags( & tr_brine_out=tr_brine, tr_bgc_N_out=tr_bgc_N, tr_zaero_out=tr_zaero) call icepack_query_tracer_indices( & - nt_Tsfc_out=nt_Tsfc, nt_alvl_out=nt_alvl, nt_rsnw_out=nt_rsnw, & + nt_Tsfc_out=nt_Tsfc, nt_alvl_out=nt_alvl, & nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, nt_aero_out=nt_aero, & nlt_chl_sw_out=nlt_chl_sw, nlt_zaero_sw_out=nlt_zaero_sw, & nt_fbri_out=nt_fbri, nt_zaero_out=nt_zaero, nt_bgc_N_out=nt_bgc_N) - call icepack_query_parameters(dEdd_algae_out=dEdd_algae, modal_aero_out=modal_aero, & - snwgrain_out=snwgrain) + call icepack_query_parameters(dEdd_algae_out=dEdd_algae, modal_aero_out=modal_aero) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) allocate(ztrcr_sw(nbtrcr_sw,ncat)) - allocate(rsnow(nslyr,ncat)) - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo @@ -1366,16 +1079,10 @@ subroutine step_radiation (dt, iblk) write (nu_diag, *) 'my_task = ',my_task enddo ! ipoint endif - fbri (:) = c0 + fbri(:) = c0 ztrcr_sw(:,:) = c0 - rsnow (:,:) = c0 do n = 1, ncat - if (tr_brine) fbri(n) = trcrn(i,j,nt_fbri,n,iblk) - if (snwgrain) then - do k = 1, nslyr - rsnow(k,n) = trcrn(i,j,nt_rsnw+k-1,n,iblk) - enddo - endif + if (tr_brine) fbri(n) = trcrn(i,j,nt_fbri,n,iblk) enddo if (tmask(i,j,iblk)) then @@ -1401,7 +1108,7 @@ subroutine step_radiation (dt, iblk) calendar_type=calendar_type, & days_per_year=days_per_year, & nextsw_cday=nextsw_cday, yday=yday, & - sec=msec, & + sec=sec, & kaer_tab=kaer_tab, kaer_bc_tab=kaer_bc_tab(:,:), & waer_tab=waer_tab, waer_bc_tab=waer_bc_tab(:,:), & gaer_tab=gaer_tab, gaer_bc_tab=gaer_bc_tab(:,:), & @@ -1413,20 +1120,16 @@ subroutine step_radiation (dt, iblk) alvdrn =alvdrn (i,j,: ,iblk), alvdfn =alvdfn (i,j,: ,iblk), & alidrn =alidrn (i,j,: ,iblk), alidfn =alidfn (i,j,: ,iblk), & fswsfcn =fswsfcn (i,j,: ,iblk), fswintn =fswintn (i,j,: ,iblk), & - fswthrun =fswthrun (i,j,: ,iblk), & - fswthrun_vdr =fswthrun_vdr (i,j,: ,iblk), & - fswthrun_vdf =fswthrun_vdf (i,j,: ,iblk), & - fswthrun_idr =fswthrun_idr (i,j,: ,iblk), & - fswthrun_idf =fswthrun_idf (i,j,: ,iblk), & - fswpenln=fswpenln(i,j,:,:,iblk), & + fswthrun =fswthrun (i,j,: ,iblk), fswpenln=fswpenln(i,j,:,:,iblk), & Sswabsn =Sswabsn (i,j,:,:,iblk), Iswabsn =Iswabsn (i,j,:,:,iblk), & albicen =albicen (i,j,: ,iblk), albsnon =albsnon (i,j,: ,iblk), & albpndn =albpndn (i,j,: ,iblk), apeffn =apeffn (i,j,: ,iblk), & snowfracn=snowfracn(i,j,: ,iblk), & dhsn =dhsn (i,j,: ,iblk), ffracn =ffracn(i,j,:,iblk), & - rsnow =rsnow (:,:), l_print_point=l_print_point) - endif + l_print_point=l_print_point) + endif + if (dEdd_algae .and. (tr_zaero .or. tr_bgc_N)) then do n = 1, ncat do k = 1, nbtrcr_sw @@ -1443,9 +1146,8 @@ subroutine step_radiation (dt, iblk) file=__FILE__, line=__LINE__) deallocate(ztrcr_sw) - deallocate(rsnow) - call ice_timer_stop(timer_sw,iblk) ! shortwave + call ice_timer_stop(timer_sw) ! shortwave end subroutine step_radiation @@ -1462,7 +1164,8 @@ end subroutine step_radiation subroutine ocean_mixed_layer (dt, iblk) use ice_arrays_column, only: Cdn_atm, Cdn_atm_ratio - use ice_flux, only: sst, Tf, Qa, uatmT, vatmT, wind, potT, rhoa, zlvl, & + use ice_blocks, only: nx_block, ny_block + use ice_flux, only: sst, Tf, Qa, uatm, vatm, wind, potT, rhoa, zlvl, & frzmlt, fhocn, fswthru, flw, flwout_ocn, fsens_ocn, flat_ocn, evap_ocn, & alvdr_ocn, alidr_ocn, alvdf_ocn, alidf_ocn, swidf, swvdf, swidr, swvdr, & qdp, hmix, strairx_ocn, strairy_ocn, Tref_ocn, Qref_ocn @@ -1543,24 +1246,24 @@ subroutine ocean_mixed_layer (dt, iblk) j = indxj(ij) call icepack_atm_boundary(sfctype = 'ocn', & - Tsf = sst (i,j,iblk), & + Tsf = sst (i,j,iblk), & potT = potT (i,j,iblk), & - uatm = uatmT (i,j,iblk), & - vatm = vatmT (i,j,iblk), & - wind = wind (i,j,iblk), & - zlvl = zlvl (i,j,iblk), & - Qa = Qa (i,j,iblk), & + uatm = uatm (i,j,iblk), & + vatm = vatm (i,j,iblk), & + wind = wind (i,j,iblk), & + zlvl = zlvl (i,j,iblk), & + Qa = Qa (i,j,iblk), & rhoa = rhoa (i,j,iblk), & - strx = strairx_ocn(i,j,iblk), & - stry = strairy_ocn(i,j,iblk), & - Tref = Tref_ocn (i,j,iblk), & - Qref = Qref_ocn (i,j,iblk), & - delt = delt (i,j), & + strx = strairx_ocn(i,j,iblk), & + stry = strairy_ocn(i,j,iblk), & + Tref = Tref_ocn (i,j,iblk), & + Qref = Qref_ocn (i,j,iblk), & + delt = delt (i,j), & delq = delq (i,j), & lhcoef = lhcoef (i,j), & shcoef = shcoef (i,j), & - Cdn_atm = Cdn_atm (i,j,iblk), & - Cdn_atm_ratio_n = Cdn_atm_ratio(i,j,iblk)) + Cdn_atm = Cdn_atm (i,j,iblk), & + Cdn_atm_ratio_n = Cdn_atm_ratio(i,j,iblk)) enddo ! ij call icepack_warnings_flush(nu_diag) @@ -1581,6 +1284,9 @@ subroutine ocean_mixed_layer (dt, iblk) ! Compute ocean fluxes and update SST !----------------------------------------------------------------- +!DIR$ CONCURRENT !Cray +!cdir nodep !NEC +!ocl novrec !Fujitsu do ij = 1, icells i = indxi(ij) j = indxj(ij) @@ -1611,21 +1317,23 @@ end subroutine ocean_mixed_layer subroutine biogeochemistry (dt, iblk) use ice_arrays_column, only: upNO, upNH, iDi, iki, zfswin, & - darcy_V, grow_net, & + zsal_tot, darcy_V, grow_net, & PP_net, hbri,dhbr_bot, dhbr_top, Zoo,& fbio_snoice, fbio_atmice, ocean_bio, & first_ice, fswpenln, bphi, bTiz, ice_bio_net, & - snow_bio_net, fswthrun, & - ocean_bio_all, sice_rho, & + snow_bio_net, fswthrun, Rayleigh_criteria, & + ocean_bio_all, sice_rho, fzsal, fzsal_g, & bgrid, igrid, icgrid, cgrid + use ice_blocks, only: block, get_block + use ice_domain, only: blocks_ice use ice_domain_size, only: nblyr, nilyr, nslyr, n_algae, n_zaero, ncat, & n_doc, n_dic, n_don, n_fed, n_fep use ice_flux, only: meltbn, melttn, congeln, snoicen, & sst, sss, fsnow, meltsn - use ice_flux_bgc, only: hin_old, flux_bio, flux_bio_atm, faero_atm, & + use ice_flux_bgc, only: hin_old, flux_bio, flux_bio_atm, faero_atm, & nit, amm, sil, dmsp, dms, algalN, doc, don, dic, fed, fep, zaeros, hum use ice_state, only: aicen_init, vicen_init, aicen, vicen, vsnon, & - trcrn, vsnon_init, aice0 + trcrn, vsnon_init, aice0 use ice_timers, only: timer_bgc, ice_timer_start, ice_timer_stop real (kind=dbl_kind), intent(in) :: & @@ -1670,9 +1378,9 @@ subroutine biogeochemistry (dt, iblk) if (tr_brine .or. skl_bgc) then - call ice_timer_start(timer_bgc,iblk) ! biogeochemistry + call ice_timer_start(timer_bgc) ! biogeochemistry - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo @@ -1680,7 +1388,7 @@ subroutine biogeochemistry (dt, iblk) ! Define ocean concentrations for tracers used in simulation do j = jlo, jhi - do i = ilo, ihi + do i = ilo, ihi call icepack_load_ocean_bio_array(max_nbtrcr = icepack_max_nbtrcr, & max_algae = icepack_max_algae, max_don = icepack_max_don, & @@ -1696,8 +1404,8 @@ subroutine biogeochemistry (dt, iblk) ocean_bio_all = ocean_bio_all(i,j,:,iblk)) do mm = 1,nbtrcr - ocean_bio(i,j,mm,iblk) = ocean_bio_all(i,j,bio_index_o(mm),iblk) - enddo ! mm + ocean_bio(i,j,mm,iblk) = ocean_bio_all(i,j,bio_index_o(mm),iblk) + enddo ! mm if (tr_zaero) then do mm = 1, n_zaero ! update aerosols flux_bio_atm(i,j,nlt_zaero(mm),iblk) = faero_atm(i,j,mm,iblk) @@ -1713,6 +1421,7 @@ subroutine biogeochemistry (dt, iblk) iDi = iDi (i,j,:,:, iblk), & iki = iki (i,j,:,:, iblk), & zfswin = zfswin (i,j,:,:, iblk), & + zsal_tot = zsal_tot (i,j, iblk), & darcy_V = darcy_V (i,j,:, iblk), & grow_net = grow_net (i,j, iblk), & PP_net = PP_net (i,j, iblk), & @@ -1731,11 +1440,13 @@ subroutine biogeochemistry (dt, iblk) snow_bio_net = snow_bio_net(i,j,1:nbtrcr, iblk), & fswthrun = fswthrun (i,j,:, iblk), & sice_rho = sice_rho (i,j,:, iblk), & + fzsal = fzsal (i,j, iblk), & + fzsal_g = fzsal_g (i,j, iblk), & meltbn = meltbn (i,j,:, iblk), & melttn = melttn (i,j,:, iblk), & congeln = congeln (i,j,:, iblk), & - snoicen = snoicen (i,j,:, iblk), & - sst = sst (i,j, iblk), & + snoicen = snoicen (i,j,:, iblk), & + sst = sst (i,j, iblk), & sss = sss (i,j, iblk), & fsnow = fsnow (i,j, iblk), & meltsn = meltsn (i,j,:, iblk), & @@ -1750,6 +1461,7 @@ subroutine biogeochemistry (dt, iblk) aice0 = aice0 (i,j, iblk), & trcrn = trcrn (i,j,:,:, iblk), & vsnon_init = vsnon_init (i,j,:, iblk), & + Rayleigh_criteria = Rayleigh_criteria(i,j,iblk), & skl_bgc = skl_bgc) enddo ! i @@ -1759,7 +1471,7 @@ subroutine biogeochemistry (dt, iblk) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - call ice_timer_stop(timer_bgc,iblk) ! biogeochemistry + call ice_timer_stop(timer_bgc) ! biogeochemistry endif ! tr_brine .or. skl_bgc diff --git a/cicecore/cicedyn/infrastructure/ice_domain.F90 b/cicecore/cicedyn/infrastructure/ice_domain.F90 index 06d0d8ae1..3be2449f7 100644 --- a/cicecore/cicedyn/infrastructure/ice_domain.F90 +++ b/cicecore/cicedyn/infrastructure/ice_domain.F90 @@ -1,6 +1,3 @@ -#ifdef ncdf -#define USE_NETCDF -#endif !||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| module ice_domain @@ -17,20 +14,19 @@ module ice_domain use ice_kinds_mod use ice_constants, only: shlat, nhlat - use ice_communicate, only: my_task, master_task, get_num_procs, & - add_mpi_barriers, ice_barrier + use ice_communicate, only: my_task, master_task, get_num_procs use ice_broadcast, only: broadcast_scalar, broadcast_array use ice_blocks, only: block, get_block, create_blocks, nghost, & - nblocks_x, nblocks_y, nblocks_tot, nx_block, ny_block, debug_blocks + nblocks_x, nblocks_y, nblocks_tot, nx_block, ny_block use ice_distribution, only: distrb use ice_boundary, only: ice_halo use ice_exit, only: abort_ice use ice_fileunits, only: nu_nml, nml_filename, nu_diag, & - get_fileunit, release_fileunit, flush_fileunit + get_fileunit, release_fileunit use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted use icepack_intfc, only: icepack_query_parameters -#ifdef USE_NETCDF +#ifdef ncdf use netcdf #endif @@ -62,10 +58,7 @@ module ice_domain logical (kind=log_kind), public :: & maskhalo_dyn , & ! if true, use masked halo updates for dynamics maskhalo_remap , & ! if true, use masked halo updates for transport - maskhalo_bound , & ! if true, use masked halo updates for bound_state - halo_dynbundle , & ! if true, bundle halo update in dynamics - landblockelim , & ! if true, land block elimination is on - orca_halogrid ! if true, input fields are haloed as defined by orca grid + maskhalo_bound ! if true, use masked halo updates for bound_state !----------------------------------------------------------------------- ! @@ -79,9 +72,8 @@ module ice_domain distribution_type, &! method to use for distributing blocks ! 'cartesian', 'roundrobin', 'sectrobin', 'sectcart' ! 'rake', 'spacecurve', etc - distribution_wght ! method for weighting work per block + distribution_wght ! method for weighting work per block ! 'block' = POP default configuration - ! 'blockall' = no land block elimination ! 'latitude' = no. ocean points * |lat| ! 'file' = read distribution_wgth_file character (char_len_long) :: & @@ -104,7 +96,7 @@ subroutine init_domain_blocks use ice_distribution, only: processor_shape use ice_domain_size, only: ncat, nilyr, nslyr, max_blocks, & nx_global, ny_global, block_size_x, block_size_y - use ice_fileunits, only: goto_nml + !---------------------------------------------------------------------- ! ! local variables @@ -114,9 +106,6 @@ subroutine init_domain_blocks integer (int_kind) :: & nml_error ! namelist read error flag - character(len=char_len) :: nml_name ! text namelist name - character(len=char_len_long) :: tmpstr2 ! for namelist check - character(len=*), parameter :: subname = '(init_domain_blocks)' !---------------------------------------------------------------------- @@ -139,9 +128,7 @@ subroutine init_domain_blocks ns_boundary_type, & maskhalo_dyn, & maskhalo_remap, & - maskhalo_bound, & - add_mpi_barriers, & - debug_blocks + maskhalo_bound !---------------------------------------------------------------------- ! @@ -159,50 +146,30 @@ subroutine init_domain_blocks maskhalo_dyn = .false. ! if true, use masked halos for dynamics maskhalo_remap = .false. ! if true, use masked halos for transport maskhalo_bound = .false. ! if true, use masked halos for bound_state - halo_dynbundle = .true. ! if true, bundle halo updates in dynamics - add_mpi_barriers = .false. ! if true, throttle communication - debug_blocks = .false. ! if true, print verbose block information - max_blocks = -1 ! max number of blocks per processor + max_blocks = -1 ! max number of blocks per processor block_size_x = -1 ! size of block in first horiz dimension block_size_y = -1 ! size of block in second horiz dimension nx_global = -1 ! NXGLOB, i-axis size ny_global = -1 ! NYGLOB, j-axis size - landblockelim = .true. ! on by default + call get_fileunit(nu_nml) if (my_task == master_task) then - nml_name = 'domain_nml' - write(nu_diag,*) subname,' Reading ', trim(nml_name) - - call get_fileunit(nu_nml) - open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error) + open (nu_nml, file=nml_filename, status='old',iostat=nml_error) if (nml_error /= 0) then - call abort_ice(subname//'ERROR: domain_nml open file '// & - trim(nml_filename), & - file=__FILE__, line=__LINE__) + nml_error = -1 + else + nml_error = 1 endif - - call goto_nml(nu_nml,trim(nml_name),nml_error) - if (nml_error /= 0) then - call abort_ice(subname//'ERROR: searching for '// trim(nml_name), & - file=__FILE__, line=__LINE__) - endif - - nml_error = 1 do while (nml_error > 0) read(nu_nml, nml=domain_nml,iostat=nml_error) - ! check if error - if (nml_error /= 0) then - ! backspace and re-read erroneous line - backspace(nu_nml) - read(nu_nml,fmt='(A)') tmpstr2 - call abort_ice(subname//'ERROR: ' // trim(nml_name) // ' reading ' // & - trim(tmpstr2), file=__FILE__, line=__LINE__) - endif end do + if (nml_error == 0) close(nu_nml) + endif + call release_fileunit(nu_nml) - close(nu_nml) - call release_fileunit(nu_nml) - + call broadcast_scalar(nml_error, master_task) + if (nml_error /= 0) then + call abort_ice(subname//'ERROR: error reading domain_nml') endif call broadcast_scalar(nprocs, master_task) @@ -215,12 +182,12 @@ subroutine init_domain_blocks call broadcast_scalar(maskhalo_dyn, master_task) call broadcast_scalar(maskhalo_remap, master_task) call broadcast_scalar(maskhalo_bound, master_task) - call broadcast_scalar(add_mpi_barriers, master_task) - call broadcast_scalar(debug_blocks, master_task) if (my_task == master_task) then if (max_blocks < 1) then - max_blocks=( ((nx_global-1)/block_size_x + 1) * & - ((ny_global-1)/block_size_y + 1) - 1) / nprocs + 1 + max_blocks=int( & + ( (dble(nx_global-1)/dble(block_size_x + 1)) * & + (dble(ny_global-1)/dble(block_size_y + 1)) ) & + / dble(nprocs)) max_blocks=max(1,max_blocks) write(nu_diag,'(/,a52,i6,/)') & '(ice_domain): max_block < 1: max_block estimated to ',max_blocks @@ -250,7 +217,6 @@ subroutine init_domain_blocks #if (defined CESMCOUPLED) nprocs = get_num_procs() #else - write(nu_diag,*) subname,'ERROR: nprocs, get_num_procs = ',nprocs,get_num_procs() call abort_ice(subname//'ERROR: Input nprocs not same as system request') #endif else if (nghost < 1) then @@ -293,8 +259,6 @@ subroutine init_domain_blocks write(nu_diag,'(a,l6)') ' maskhalo_dyn = ', maskhalo_dyn write(nu_diag,'(a,l6)') ' maskhalo_remap = ', maskhalo_remap write(nu_diag,'(a,l6)') ' maskhalo_bound = ', maskhalo_bound - write(nu_diag,'(a,l6)') ' add_mpi_barriers = ', add_mpi_barriers - write(nu_diag,'(a,l6)') ' debug_blocks = ', debug_blocks write(nu_diag,'(a,2i6)') ' block_size_x,_y = ', block_size_x, block_size_y write(nu_diag,'(a,i6)') ' max_blocks = ', max_blocks write(nu_diag,'(a,i6,/)')' Number of ghost cells = ', nghost @@ -306,7 +270,7 @@ end subroutine init_domain_blocks !*********************************************************************** - subroutine init_domain_distribution(KMTG,ULATG,grid_ice) + subroutine init_domain_distribution(KMTG,ULATG) ! This routine calls appropriate setup routines to distribute blocks ! across processors and defines arrays with block ids for any local @@ -314,16 +278,13 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) ! initialized here through calls to the appropriate boundary routines. use ice_boundary, only: ice_HaloCreate - use ice_distribution, only: create_distribution, create_local_block_ids, ice_distributionGet + use ice_distribution, only: create_distribution, create_local_block_ids use ice_domain_size, only: max_blocks, nx_global, ny_global real (dbl_kind), dimension(nx_global,ny_global), intent(in) :: & KMTG ,&! global topography ULATG ! global latitude field (radians) - character(len=*), intent(in) :: & - grid_ice ! grid_ice, B, C, CD, etc - !---------------------------------------------------------------------- ! ! local variables @@ -341,11 +302,8 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) integer (int_kind) :: & i,j,n ,&! dummy loop indices ig,jg ,&! global indices - igm1,igp1,jgm1,jgp1,&! global indices - ninfo ,&! ice_distributionGet check - np, nlb, m ,&! debug blocks temporaries work_unit ,&! size of quantized work unit -#ifdef USE_NETCDF +#ifdef ncdf fid ,&! file id varid ,&! var id status ,&! netcdf return code @@ -359,7 +317,6 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) rad_to_deg ! radians to degrees integer (int_kind), dimension(:), allocatable :: & - blkinfo ,&! ice_distributionGet check nocn ,&! number of ocean points per block work_per_block ! number of work units per block @@ -375,7 +332,7 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) ! ! check that there are at least nghost+1 rows or columns of land cells ! for closed boundary conditions (otherwise grid lengths are zero in -! cells neighboring ocean points). +! cells neighboring ocean points). ! !---------------------------------------------------------------------- @@ -385,7 +342,6 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) file=__FILE__, line=__LINE__) if (trim(ns_boundary_type) == 'closed') then - call abort_ice(subname//'ERROR: ns_boundary_type = closed not supported') allocate(nocn(nblocks_tot)) nocn = 0 do n=1,nblocks_tot @@ -417,14 +373,13 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) enddo endif if (nocn(n) > 0) then - write(nu_diag,*) subname,'ns closed, Not enough land cells along ns edge' - call abort_ice(subname//'ERROR: Not enough land cells along ns edge for ns closed') + print*, 'ice: Not enough land cells along ns edge' + call abort_ice(subname//'ERROR: Not enough land cells along ns edge') endif enddo deallocate(nocn) endif if (trim(ew_boundary_type) == 'closed') then - call abort_ice(subname//'ERROR: ew_boundary_type = closed not supported') allocate(nocn(nblocks_tot)) nocn = 0 do n=1,nblocks_tot @@ -456,8 +411,8 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) enddo endif if (nocn(n) > 0) then - write(nu_diag,*) subname,'ew closed, Not enough land cells along ew edge' - call abort_ice(subname//'ERROR: Not enough land cells along ew edge for ew closed') + print*, 'ice: Not enough land cells along ew edge' + call abort_ice(subname//'ERROR: Not enough land cells along ew edge') endif enddo deallocate(nocn) @@ -471,20 +426,19 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) !---------------------------------------------------------------------- if (distribution_wght == 'latitude') then - flat = max(NINT(abs(ULATG*rad_to_deg), int_kind),1) ! linear function + flat = NINT(abs(ULATG*rad_to_deg), int_kind) ! linear function else flat = 1 endif - if (distribution_wght == 'blockall') landblockelim = .false. - allocate(nocn(nblocks_tot)) if (distribution_wght == 'file') then allocate(wght(nx_global,ny_global)) if (my_task == master_task) then ! cannot use ice_read_write due to circular dependency -#ifdef USE_NETCDF +#ifdef ncdf + write(nu_diag,*) 'read ',trim(distribution_wght_file),minval(wght),maxval(wght) status = nf90_open(distribution_wght_file, NF90_NOWRITE, fid) if (status /= nf90_noerr) then call abort_ice (subname//'ERROR: Cannot open '//trim(distribution_wght_file)) @@ -492,10 +446,8 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) status = nf90_inq_varid(fid, 'wght', varid) status = nf90_get_var(fid, varid, wght) status = nf90_close(fid) - write(nu_diag,*) 'read ',trim(distribution_wght_file),minval(wght),maxval(wght) #else - call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined', & - file=__FILE__, line=__LINE__) + call abort_ice (subname//'ERROR: distribution_wght file needs ncdf cpp ') #endif endif call broadcast_array(wght, master_task) @@ -533,25 +485,10 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) if (this_block%i_glob(i) > 0) then ig = this_block%i_glob(i) jg = this_block%j_glob(j) - if (grid_ice == 'C' .or. grid_ice == 'CD') then - ! Have to be careful about block elimination with C/CD - ! Use a bigger stencil - igm1 = mod(ig-2+nx_global,nx_global)+1 - igp1 = mod(ig,nx_global)+1 - jgm1 = max(jg-1,1) - jgp1 = min(jg+1,ny_global) - if ((KMTG(ig ,jg ) > puny .or. & - KMTG(igm1,jg ) > puny .or. KMTG(igp1,jg ) > puny .or. & - KMTG(ig ,jgp1) > puny .or. KMTG(ig ,jgm1) > puny) .and. & - (ULATG(ig,jg) < shlat/rad_to_deg .or. & - ULATG(ig,jg) > nhlat/rad_to_deg) ) & - nocn(n) = nocn(n) + flat(ig,jg) - else - if (KMTG(ig,jg) > puny .and. & - (ULATG(ig,jg) < shlat/rad_to_deg .or. & - ULATG(ig,jg) > nhlat/rad_to_deg) ) & - nocn(n) = nocn(n) + flat(ig,jg) - endif + if (KMTG(ig,jg) > puny .and. & + (ULATG(ig,jg) < shlat/rad_to_deg .or. & + ULATG(ig,jg) > nhlat/rad_to_deg) ) & + nocn(n) = nocn(n) + flat(ig,jg) endif end do endif @@ -561,15 +498,15 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) !*** points, so where the block is not completely land, !*** reset nocn to be the full size of the block - ! use processor_shape = 'square-pop' and distribution_wght = 'block' + ! use processor_shape = 'square-pop' and distribution_wght = 'block' ! to make CICE and POP decompositions/distributions identical. #ifdef CICE_IN_NEMO ! Keep all blocks even the ones only containing land points if (distribution_wght == 'block') nocn(n) = nx_block*ny_block #else - if (distribution_wght == 'block' .and. nocn(n) > 0) nocn(n) = nx_block*ny_block - if (.not. landblockelim) nocn(n) = max(nocn(n),1) + if (distribution_wght == 'block' .and. & ! POP style + nocn(n) > 0) nocn(n) = nx_block*ny_block #endif end do endif ! distribution_wght = file @@ -614,85 +551,6 @@ subroutine init_domain_distribution(KMTG,ULATG,grid_ice) call create_local_block_ids(blocks_ice, distrb_info) - ! write out block distribution - ! internal check of icedistributionGet as part of verification process - if (debug_blocks) then - - call flush_fileunit(nu_diag) - call ice_barrier() - if (my_task == master_task) then - write(nu_diag,*) ' ' - write(nu_diag,'(2a)') subname, ' Blocks by Proc:' - endif - call ice_distributionGet(distrb_info, nprocs=np, numLocalBlocks=nlb) - do m = 1, np - if (m == my_task+1) then - do n=1,nlb - write(nu_diag,'(2a,3i8)') & - subname,' my_task, local block ID, global block ID: ', & - my_task, n, distrb_info%blockGlobalID(n) - enddo - call flush_fileunit(nu_diag) - endif - call ice_barrier() - enddo - - if (my_task == master_task) then - write(nu_diag,*) ' ' - write(nu_diag,'(2a)') subname, ' Blocks by Global Block ID:' - do m = 1, nblocks_tot - write(nu_diag,'(2a,3i8)') & - subname,' global block id, proc, local block ID: ', & - m, distrb_info%blockLocation(m), distrb_info%blockLocalID(m) - enddo - call flush_fileunit(nu_diag) - endif - call ice_barrier() - - call ice_distributionGet(distrb_info, nprocs=ninfo) - if (ninfo /= distrb_info%nprocs) & - call abort_ice(subname//' ice_distributionGet nprocs ERROR', file=__FILE__, line=__LINE__) - - call ice_distributionGet(distrb_info, communicator=ninfo) - if (ninfo /= distrb_info%communicator) & - call abort_ice(subname//' ice_distributionGet communicator ERROR', file=__FILE__, line=__LINE__) - - call ice_distributionGet(distrb_info, numLocalBlocks=ninfo) - if (ninfo /= distrb_info%numLocalBlocks) & - call abort_ice(subname//' ice_distributionGet numLocalBlocks ERROR', file=__FILE__, line=__LINE__) - - allocate(blkinfo(ninfo)) - - call ice_distributionGet(distrb_info, blockGlobalID = blkinfo) - do n = 1, ninfo - if (blkinfo(n) /= distrb_info%blockGlobalID(n)) & - call abort_ice(subname//' ice_distributionGet blockGlobalID ERROR', file=__FILE__, line=__LINE__) - enddo - - deallocate(blkinfo) - allocate(blkinfo(nblocks_tot)) - - call ice_distributionGet(distrb_info, blockLocation = blkinfo) - do n = 1, nblocks_tot - if (blkinfo(n) /= distrb_info%blockLocation(n)) & - call abort_ice(subname//' ice_distributionGet blockLocation ERROR', file=__FILE__, line=__LINE__) - enddo - - call ice_distributionGet(distrb_info, blockLocalID = blkinfo) - do n = 1, nblocks_tot - if (blkinfo(n) /= distrb_info%blockLocalID(n)) & - call abort_ice(subname//' ice_distributionGet blockLocalID ERROR', file=__FILE__, line=__LINE__) - enddo - - deallocate(blkinfo) - - if (my_task == master_task) then - write(nu_diag,*) ' ' - write(nu_diag,'(2a)') subname,' ice_distributionGet checks pass' - write(nu_diag,*) ' ' - endif - endif - if (associated(blocks_ice)) then nblocks = size(blocks_ice) else diff --git a/cicecore/cicedyn/infrastructure/io/io_binary/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_binary/ice_restart.F90 index cc158fccc..8ecfeb6f1 100644 --- a/cicecore/cicedyn/infrastructure/io/io_binary/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_binary/ice_restart.F90 @@ -11,16 +11,15 @@ module ice_restart use ice_kinds_mod use ice_restart_shared, only: & restart, restart_ext, restart_dir, restart_file, pointer_file, & - runid, runtype, use_restart_time, lenstr + runid, runtype, use_restart_time, restart_format, lenstr use ice_fileunits, only: nu_diag, nu_rst_pointer use ice_fileunits, only: nu_dump, nu_dump_eap, nu_dump_FY, nu_dump_age use ice_fileunits, only: nu_dump_lvl, nu_dump_pond, nu_dump_hbrine - use ice_fileunits, only: nu_dump_iso, nu_dump_snow - use ice_fileunits, only: nu_dump_bgc, nu_dump_aero, nu_dump_fsd - use ice_fileunits, only: nu_restart, nu_restart_eap, nu_restart_FY, nu_restart_age + use ice_fileunits, only: nu_dump_bgc, nu_dump_aero, nu_dump_fsd, nu_dump_iso + use ice_fileunits, only: nu_restart, nu_restart_eap, nu_restart_FY, nu_restart_age use ice_fileunits, only: nu_restart_lvl, nu_restart_pond, nu_restart_hbrine use ice_fileunits, only: nu_restart_bgc, nu_restart_aero, nu_restart_fsd - use ice_fileunits, only: nu_restart_iso, nu_restart_snow + use ice_fileunits, only: nu_restart_iso use ice_exit, only: abort_ice use icepack_intfc, only: icepack_query_parameters use icepack_intfc, only: icepack_query_tracer_sizes @@ -30,10 +29,7 @@ module ice_restart implicit none private public :: init_restart_write, init_restart_read, & - read_restart_field, write_restart_field, final_restart, & - query_field - - real(kind=dbl_kind) :: time_forc = -99. ! historic now local + read_restart_field, write_restart_field, final_restart !======================================================================= @@ -46,8 +42,7 @@ module ice_restart subroutine init_restart_read(ice_ic) - use ice_calendar, only: istep0, istep1, timesecs, npt, myear, & - set_date_from_timesecs + use ice_calendar, only: istep0, istep1, time, time_forc, npt, nyr use ice_communicate, only: my_task, master_task use ice_dyn_shared, only: kdyn use ice_read_write, only: ice_open, ice_open_ext @@ -57,8 +52,9 @@ subroutine init_restart_read(ice_ic) ! local variables logical (kind=log_kind) :: & - tr_fsd, tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, & - tr_pond_topo, tr_pond_lvl, tr_brine, tr_snow + solve_zsal, tr_fsd, & + tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, tr_pond_cesm, & + tr_pond_topo, tr_pond_lvl, tr_brine character(len=char_len_long) :: & filename, filename0 @@ -76,18 +72,19 @@ subroutine init_restart_read(ice_ic) character(len=*), parameter :: subname = '(init_restart_read)' + call icepack_query_parameters( & + solve_zsal_out=solve_zsal) call icepack_query_tracer_sizes( & nbtrcr_out=nbtrcr) call icepack_query_tracer_flags( & tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_lvl_out=tr_lvl, tr_fsd_out=tr_fsd, & - tr_iso_out=tr_iso, tr_aero_out=tr_aero, & - tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, & - tr_snow_out=tr_snow, tr_brine_out=tr_brine) + tr_iso_out=tr_iso, tr_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, & + tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, tr_brine_out=tr_brine) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - if (present(ice_ic)) then + if (present(ice_ic)) then filename = trim(ice_ic) else if (my_task == master_task) then @@ -108,19 +105,18 @@ subroutine init_restart_read(ice_ic) call ice_open(nu_restart,trim(filename),0) endif if (use_restart_time) then - read (nu_restart) istep0,timesecs,time_forc,myear + read (nu_restart) istep0,time,time_forc,nyr else read (nu_restart) iignore,rignore,rignore ! use namelist values endif - write(nu_diag,*) 'Restart read at istep=',istep0,timesecs + write(nu_diag,*) 'Restart read at istep=',istep0,time,time_forc endif call broadcast_scalar(istep0,master_task) - call broadcast_scalar(timesecs,master_task) + call broadcast_scalar(time,master_task) call broadcast_scalar(time_forc,master_task) - call broadcast_scalar(myear,master_task) - call set_date_from_timesecs(timesecs) - + call broadcast_scalar(nyr,master_task) + istep1 = istep0 ! Supplemental restart files @@ -225,15 +221,15 @@ subroutine init_restart_read(ice_ic) endif endif - if (tr_pond_lvl) then + if (tr_pond_cesm) then if (my_task == master_task) then n = index(filename0,trim(restart_file)) - if (n == 0) call abort_ice(subname//'ERROR:pond_lvl restart: filename discrepancy') + if (n == 0) call abort_ice(subname//'ERROR: pond_cesm restart: filename discrepancy') string1 = trim(filename0(1:n-1)) string2 = trim(filename0(n+lenstr(restart_file):lenstr(filename0))) write(filename,'(a,a,a,a)') & string1(1:lenstr(string1)), & - restart_file(1:lenstr(restart_file)),'.pond_lvl', & + restart_file(1:lenstr(restart_file)),'.pond_cesm', & string2(1:lenstr(string2)) if (restart_ext) then call ice_open_ext(nu_restart_pond,filename,0) @@ -245,15 +241,15 @@ subroutine init_restart_read(ice_ic) endif endif - if (tr_pond_topo) then + if (tr_pond_lvl) then if (my_task == master_task) then n = index(filename0,trim(restart_file)) - if (n == 0) call abort_ice(subname//'ERROR: pond_topo restart: filename discrepancy') + if (n == 0) call abort_ice(subname//'ERROR:pond_lvl restart: filename discrepancy') string1 = trim(filename0(1:n-1)) string2 = trim(filename0(n+lenstr(restart_file):lenstr(filename0))) write(filename,'(a,a,a,a)') & string1(1:lenstr(string1)), & - restart_file(1:lenstr(restart_file)),'.pond_topo', & + restart_file(1:lenstr(restart_file)),'.pond_lvl', & string2(1:lenstr(string2)) if (restart_ext) then call ice_open_ext(nu_restart_pond,filename,0) @@ -265,22 +261,22 @@ subroutine init_restart_read(ice_ic) endif endif - if (tr_snow) then + if (tr_pond_topo) then if (my_task == master_task) then n = index(filename0,trim(restart_file)) - if (n == 0) call abort_ice(subname//'ERROR: snow restart: filename discrepancy') + if (n == 0) call abort_ice(subname//'ERROR: pond_topo restart: filename discrepancy') string1 = trim(filename0(1:n-1)) string2 = trim(filename0(n+lenstr(restart_file):lenstr(filename0))) write(filename,'(a,a,a,a)') & string1(1:lenstr(string1)), & - restart_file(1:lenstr(restart_file)),'.snow', & + restart_file(1:lenstr(restart_file)),'.pond_topo', & string2(1:lenstr(string2)) if (restart_ext) then - call ice_open_ext(nu_restart_snow,filename,0) + call ice_open_ext(nu_restart_pond,filename,0) else - call ice_open(nu_restart_snow,filename,0) + call ice_open(nu_restart_pond,filename,0) endif - read (nu_restart_snow) iignore,rignore,rignore + read (nu_restart_pond) iignore,rignore,rignore write(nu_diag,*) 'Reading ',filename(1:lenstr(filename)) endif endif @@ -305,7 +301,7 @@ subroutine init_restart_read(ice_ic) endif endif - if (nbtrcr > 0) then + if (solve_zsal .or. nbtrcr > 0) then if (my_task == master_task) then n = index(filename0,trim(restart_file)) if (n == 0) call abort_ice(subname//'ERROR: bgc restart: filename discrepancy') @@ -379,8 +375,8 @@ end subroutine init_restart_read subroutine init_restart_write(filename_spec) - use ice_calendar, only: msec, mmonth, mday, myear, istep1, & - timesecs + use ice_calendar, only: sec, month, mday, nyr, istep1, & + time, time_forc, year_init use ice_communicate, only: my_task, master_task use ice_dyn_shared, only: kdyn use ice_read_write, only: ice_open, ice_open_ext @@ -390,23 +386,26 @@ subroutine init_restart_write(filename_spec) ! local variables logical (kind=log_kind) :: & - tr_fsd, tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, & - tr_pond_topo, tr_pond_lvl, tr_brine, tr_snow + solve_zsal, tr_fsd, & + tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, tr_pond_cesm, & + tr_pond_topo, tr_pond_lvl, tr_brine integer (kind=int_kind) :: & - nbtrcr ! number of bgc tracers + nbtrcr, & ! number of bgc tracers + iyear, imonth, iday ! year, month, day character(len=char_len_long) :: filename character(len=*), parameter :: subname = '(init_restart_write)' + call icepack_query_parameters( & + solve_zsal_out=solve_zsal) call icepack_query_tracer_sizes( & nbtrcr_out=nbtrcr) call icepack_query_tracer_flags( & tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_lvl_out=tr_lvl, tr_fsd_out=tr_fsd, & - tr_iso_out=tr_iso, tr_aero_out=tr_aero, & - tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, & - tr_snow_out=tr_snow, tr_brine_out=tr_brine) + tr_iso_out=tr_iso, tr_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, & + tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, tr_brine_out=tr_brine) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) @@ -415,12 +414,16 @@ subroutine init_restart_write(filename_spec) if (present(filename_spec)) then filename = trim(filename_spec) else + iyear = nyr + year_init - 1 + imonth = month + iday = mday + write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec end if - + ! write pointer (path/file) if (my_task == master_task) then open(nu_rst_pointer,file=pointer_file) @@ -431,7 +434,7 @@ subroutine init_restart_write(filename_spec) else call ice_open(nu_dump,filename,0) endif - write(nu_dump) istep1,timesecs,time_forc,myear + write(nu_dump) istep1,time,time_forc,nyr write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif @@ -442,7 +445,7 @@ subroutine init_restart_write(filename_spec) write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.eap.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_eap,filename,0) @@ -451,7 +454,7 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_eap) istep1,timesecs,time_forc + write(nu_dump_eap) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif @@ -462,7 +465,7 @@ subroutine init_restart_write(filename_spec) write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.fsd.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_fsd,filename,0) @@ -471,7 +474,7 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_fsd) istep1,timesecs,time_forc + write(nu_dump_fsd) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif @@ -482,7 +485,7 @@ subroutine init_restart_write(filename_spec) write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.FY.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_FY,filename,0) @@ -491,7 +494,7 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_FY) istep1,timesecs,time_forc + write(nu_dump_FY) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif @@ -502,7 +505,7 @@ subroutine init_restart_write(filename_spec) write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.iage.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_age,filename,0) @@ -511,7 +514,7 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_age) istep1,timesecs,time_forc + write(nu_dump_age) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif @@ -522,7 +525,7 @@ subroutine init_restart_write(filename_spec) write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.lvl.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_lvl,filename,0) @@ -531,18 +534,18 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_lvl) istep1,timesecs,time_forc + write(nu_dump_lvl) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif endif - if (tr_pond_lvl) then + if (tr_pond_cesm) then write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & - restart_file(1:lenstr(restart_file)),'.pond_lvl.', & - myear,'-',mmonth,'-',mday,'-',msec + restart_file(1:lenstr(restart_file)),'.pond_cesm.', & + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_pond,filename,0) @@ -551,18 +554,18 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_pond) istep1,timesecs,time_forc + write(nu_dump_pond) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif endif - if (tr_pond_topo) then + if (tr_pond_lvl) then write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & - restart_file(1:lenstr(restart_file)),'.pond_topo.', & - myear,'-',mmonth,'-',mday,'-',msec + restart_file(1:lenstr(restart_file)),'.pond_lvl.', & + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_pond,filename,0) @@ -571,27 +574,27 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_pond) istep1,timesecs,time_forc + write(nu_dump_pond) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif endif - if (tr_snow) then + if (tr_pond_topo) then write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & - restart_file(1:lenstr(restart_file)),'.snow.', & - myear,'-',mmonth,'-',mday,'-',msec + restart_file(1:lenstr(restart_file)),'.pond_topo.', & + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then - call ice_open_ext(nu_dump_snow,filename,0) + call ice_open_ext(nu_dump_pond,filename,0) else - call ice_open(nu_dump_snow,filename,0) + call ice_open(nu_dump_pond,filename,0) endif if (my_task == master_task) then - write(nu_dump_snow) istep1,timesecs,time_forc + write(nu_dump_pond) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif @@ -602,7 +605,7 @@ subroutine init_restart_write(filename_spec) write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.brine.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_hbrine,filename,0) @@ -611,18 +614,18 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_hbrine) istep1,timesecs,time_forc + write(nu_dump_hbrine) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif endif - if (nbtrcr > 0) then + if (solve_zsal .or. nbtrcr > 0) then write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.bgc.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_bgc,filename,0) @@ -631,7 +634,7 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_bgc) istep1,timesecs,time_forc + write(nu_dump_bgc) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif endif @@ -641,7 +644,7 @@ subroutine init_restart_write(filename_spec) write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.iso.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_iso,filename,0) @@ -650,7 +653,7 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_iso) istep1,timesecs,time_forc + write(nu_dump_iso) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif @@ -661,7 +664,7 @@ subroutine init_restart_write(filename_spec) write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.aero.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec if (restart_ext) then call ice_open_ext(nu_dump_aero,filename,0) @@ -670,7 +673,7 @@ subroutine init_restart_write(filename_spec) endif if (my_task == master_task) then - write(nu_dump_aero) istep1,timesecs,time_forc + write(nu_dump_aero) istep1,time,time_forc write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif @@ -743,7 +746,7 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3, & endif end subroutine read_restart_field - + !======================================================================= ! Writes a single restart field. @@ -800,25 +803,27 @@ end subroutine write_restart_field subroutine final_restart() - use ice_calendar, only: istep1, timesecs + use ice_calendar, only: istep1, time, time_forc use ice_communicate, only: my_task, master_task logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, & - tr_pond_topo, tr_pond_lvl, tr_brine, tr_snow + solve_zsal, & + tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, tr_pond_cesm, & + tr_pond_topo, tr_pond_lvl, tr_brine integer (kind=int_kind) :: & nbtrcr ! number of bgc tracers character(len=*), parameter :: subname = '(final_restart)' + call icepack_query_parameters( & + solve_zsal_out=solve_zsal) call icepack_query_tracer_sizes( & nbtrcr_out=nbtrcr) call icepack_query_tracer_flags( & tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_lvl_out=tr_lvl, & - tr_iso_out=tr_iso, tr_aero_out=tr_aero, & - tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, & - tr_snow_out=tr_snow, tr_brine_out=tr_brine) + tr_iso_out=tr_iso, tr_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, & + tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, tr_brine_out=tr_brine) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) @@ -831,35 +836,18 @@ subroutine final_restart() if (tr_iage) close(nu_dump_age) if (tr_FY) close(nu_dump_FY) if (tr_lvl) close(nu_dump_lvl) + if (tr_pond_cesm) close(nu_dump_pond) if (tr_pond_lvl) close(nu_dump_pond) if (tr_pond_topo) close(nu_dump_pond) - if (tr_snow) close(nu_dump_snow) if (tr_brine) close(nu_dump_hbrine) - if (nbtrcr > 0) close(nu_dump_bgc) + if (solve_zsal .or. nbtrcr > 0) & + close(nu_dump_bgc) - write(nu_diag,*) 'Restart read/written ',istep1,timesecs + write(nu_diag,*) 'Restart read/written ',istep1,time,time_forc endif end subroutine final_restart -!======================================================================= - -! Inquire field existance, doesn't work in binary files so set to true and return -! author T. Craig - - logical function query_field(nu,vname) - - integer (kind=int_kind), intent(in) :: nu ! unit number - character (len=*) , intent(in) :: vname ! variable name - - ! local variables - - character(len=*), parameter :: subname = '(query_field)' - - query_field = .true. - - end function query_field - !======================================================================= end module ice_restart diff --git a/cicecore/cicedyn/infrastructure/io/io_netcdf/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_netcdf/ice_restart.F90 index 84fcbe5b7..d4decf6f7 100644 --- a/cicecore/cicedyn/infrastructure/io/io_netcdf/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_netcdf/ice_restart.F90 @@ -1,6 +1,3 @@ -#ifdef ncdf -#define USE_NETCDF -#endif !======================================================================= ! Read and write ice model restart files using netCDF or binary @@ -10,14 +7,11 @@ module ice_restart use ice_broadcast - use ice_communicate, only: my_task, master_task use ice_kinds_mod -#ifdef USE_NETCDF use netcdf -#endif use ice_restart_shared, only: & restart_ext, restart_dir, restart_file, pointer_file, & - runid, use_restart_time, lcdf64, lenstr, restart_coszen + runid, use_restart_time, lcdf64, lenstr use ice_fileunits, only: nu_diag, nu_rst_pointer use ice_exit, only: abort_ice use icepack_intfc, only: icepack_query_parameters @@ -28,8 +22,7 @@ module ice_restart implicit none private public :: init_restart_write, init_restart_read, & - read_restart_field, write_restart_field, final_restart, & - query_field + read_restart_field, write_restart_field, final_restart integer (kind=int_kind) :: ncid @@ -44,8 +37,9 @@ module ice_restart subroutine init_restart_read(ice_ic) - use ice_calendar, only: msec, mmonth, mday, myear, & - istep0, istep1, npt + use ice_calendar, only: sec, month, mday, nyr, istep0, istep1, & + time, time_forc, npt + use ice_communicate, only: my_task, master_task character(len=char_len_long), intent(in), optional :: ice_ic @@ -54,12 +48,11 @@ subroutine init_restart_read(ice_ic) character(len=char_len_long) :: & filename, filename0 - integer (kind=int_kind) :: status, status1 + integer (kind=int_kind) :: status character(len=*), parameter :: subname = '(init_restart_read)' -#ifdef USE_NETCDF - if (present(ice_ic)) then + if (present(ice_ic)) then filename = trim(ice_ic) else if (my_task == master_task) then @@ -78,48 +71,33 @@ subroutine init_restart_read(ice_ic) status = nf90_open(trim(filename), nf90_nowrite, ncid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: reading restart ncfile '//trim(filename)) - + if (use_restart_time) then - status1 = nf90_noerr - status = nf90_get_att(ncid, nf90_global, 'istep1', istep0) - if (status /= nf90_noerr) status1 = status -! status = nf90_get_att(ncid, nf90_global, 'time', time) -! status = nf90_get_att(ncid, nf90_global, 'time_forc', time_forc) - status = nf90_get_att(ncid, nf90_global, 'myear', myear) - if (status /= nf90_noerr) status = nf90_get_att(ncid, nf90_global, 'nyr', myear) - if (status /= nf90_noerr) status1 = status - status = nf90_get_att(ncid, nf90_global, 'mmonth', mmonth) - if (status /= nf90_noerr) status = nf90_get_att(ncid, nf90_global, 'month', mmonth) - if (status /= nf90_noerr) status1 = status + status = nf90_get_att(ncid, nf90_global, 'istep1', istep0) + status = nf90_get_att(ncid, nf90_global, 'time', time) + status = nf90_get_att(ncid, nf90_global, 'time_forc', time_forc) + status = nf90_get_att(ncid, nf90_global, 'nyr', nyr) + if (status == nf90_noerr) then + status = nf90_get_att(ncid, nf90_global, 'month', month) status = nf90_get_att(ncid, nf90_global, 'mday', mday) - if (status /= nf90_noerr) status1 = status - status = nf90_get_att(ncid, nf90_global, 'msec', msec) - if (status /= nf90_noerr) status = nf90_get_att(ncid, nf90_global, 'sec', msec) - if (status /= nf90_noerr) status1 = status - if (status1 /= nf90_noerr) call abort_ice(subname// & - 'ERROR: reading restart time '//trim(filename)) + status = nf90_get_att(ncid, nf90_global, 'sec', sec) + endif endif ! use namelist values if use_restart_time = F + write(nu_diag,*) 'Restart read at istep=',istep0,time,time_forc endif call broadcast_scalar(istep0,master_task) -! call broadcast_scalar(time,master_task) - call broadcast_scalar(myear,master_task) - call broadcast_scalar(mmonth,master_task) - call broadcast_scalar(mday,master_task) - call broadcast_scalar(msec,master_task) -! call broadcast_scalar(time_forc,master_task) - + call broadcast_scalar(time,master_task) + call broadcast_scalar(time_forc,master_task) + call broadcast_scalar(nyr,master_task) + istep1 = istep0 ! if runid is bering then need to correct npt for istep0 if (trim(runid) == 'bering') then npt = npt - istep0 endif -#else - call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined for '//trim(ice_ic), & - file=__FILE__, line=__LINE__) -#endif end subroutine init_restart_read @@ -131,22 +109,23 @@ end subroutine init_restart_read subroutine init_restart_write(filename_spec) use ice_blocks, only: nghost - use ice_calendar, only: msec, mmonth, mday, myear, istep1 + use ice_calendar, only: sec, month, mday, nyr, istep1, & + time, time_forc, year_init + use ice_communicate, only: my_task, master_task use ice_domain_size, only: nx_global, ny_global, ncat, nilyr, nslyr, & n_iso, n_aero, nblyr, n_zaero, n_algae, n_doc, & n_dic, n_don, n_fed, n_fep, nfsd use ice_arrays_column, only: oceanmixed_ice use ice_dyn_shared, only: kdyn - use ice_grid, only: grid_ice character(len=char_len_long), intent(in), optional :: filename_spec ! local variables logical (kind=log_kind) :: & - skl_bgc, z_tracers, tr_fsd, & - tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, & - tr_pond_topo, tr_pond_lvl, tr_brine, tr_snow, & + solve_zsal, skl_bgc, z_tracers, tr_fsd, & + tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, tr_pond_cesm, & + tr_pond_topo, tr_pond_lvl, tr_brine, & tr_bgc_N, tr_bgc_C, tr_bgc_Nit, & tr_bgc_Sil, tr_bgc_DMS, & tr_bgc_chl, tr_bgc_Am, & @@ -157,6 +136,7 @@ subroutine init_restart_write(filename_spec) integer (kind=int_kind) :: & k, n, & ! index nx, ny, & ! global array size + iyear, & ! year nbtrcr ! number of bgc tracers character(len=char_len_long) :: filename @@ -174,16 +154,14 @@ subroutine init_restart_write(filename_spec) character(len=*), parameter :: subname = '(init_restart_write)' -#ifdef USE_NETCDF call icepack_query_parameters( & - skl_bgc_out=skl_bgc, z_tracers_out=z_tracers) + solve_zsal_out=solve_zsal, skl_bgc_out=skl_bgc, z_tracers_out=z_tracers) call icepack_query_tracer_sizes( & nbtrcr_out=nbtrcr) call icepack_query_tracer_flags( & tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_lvl_out=tr_lvl, tr_fsd_out=tr_fsd, & - tr_iso_out=tr_iso, tr_aero_out=tr_aero, & - tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, & - tr_snow_out=tr_snow, tr_brine_out=tr_brine, & + tr_iso_out=tr_iso, tr_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, & + tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, tr_brine_out=tr_brine, & tr_bgc_N_out=tr_bgc_N, tr_bgc_C_out=tr_bgc_C, tr_bgc_Nit_out=tr_bgc_Nit, & tr_bgc_Sil_out=tr_bgc_Sil, tr_bgc_DMS_out=tr_bgc_DMS, & tr_bgc_chl_out=tr_bgc_chl, tr_bgc_Am_out=tr_bgc_Am, & @@ -198,10 +176,12 @@ subroutine init_restart_write(filename_spec) if (present(filename_spec)) then filename = trim(filename_spec) else + iyear = nyr + year_init - 1 + write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec end if ! write pointer (path/file) @@ -218,12 +198,12 @@ subroutine init_restart_write(filename_spec) 'ERROR: creating restart ncfile '//trim(filename)) status = nf90_put_att(ncid,nf90_global,'istep1',istep1) -! status = nf90_put_att(ncid,nf90_global,'time',time) -! status = nf90_put_att(ncid,nf90_global,'time_forc',time_forc) - status = nf90_put_att(ncid,nf90_global,'myear',myear) - status = nf90_put_att(ncid,nf90_global,'mmonth',mmonth) + status = nf90_put_att(ncid,nf90_global,'time',time) + status = nf90_put_att(ncid,nf90_global,'time_forc',time_forc) + status = nf90_put_att(ncid,nf90_global,'nyr',nyr) + status = nf90_put_att(ncid,nf90_global,'month',month) status = nf90_put_att(ncid,nf90_global,'mday',mday) - status = nf90_put_att(ncid,nf90_global,'msec',msec) + status = nf90_put_att(ncid,nf90_global,'sec',sec) nx = nx_global ny = ny_global @@ -248,20 +228,9 @@ subroutine init_restart_write(filename_spec) call define_rest_field(ncid,'uvel',dims) call define_rest_field(ncid,'vvel',dims) - if (grid_ice == 'CD') then - call define_rest_field(ncid,'uvelE',dims) - call define_rest_field(ncid,'vvelE',dims) - call define_rest_field(ncid,'uvelN',dims) - call define_rest_field(ncid,'vvelN',dims) - endif - - if (grid_ice == 'C') then - call define_rest_field(ncid,'uvelE',dims) - call define_rest_field(ncid,'vvelN',dims) - endif - - if (restart_coszen) call define_rest_field(ncid,'coszen',dims) - +#ifdef CESMCOUPLED + call define_rest_field(ncid,'coszen',dims) +#endif call define_rest_field(ncid,'scale_factor',dims) call define_rest_field(ncid,'swvdr',dims) call define_rest_field(ncid,'swvdf',dims) @@ -288,18 +257,6 @@ subroutine init_restart_write(filename_spec) call define_rest_field(ncid,'iceumask',dims) - if (grid_ice == 'CD' .or. grid_ice == 'C') then - call define_rest_field(ncid,'stresspT' ,dims) - call define_rest_field(ncid,'stressmT' ,dims) - call define_rest_field(ncid,'stress12T',dims) - call define_rest_field(ncid,'stresspU' ,dims) - call define_rest_field(ncid,'stressmU' ,dims) - call define_rest_field(ncid,'stress12U',dims) - call define_rest_field(ncid,'icenmask',dims) - call define_rest_field(ncid,'iceemask',dims) - endif - - if (oceanmixed_ice) then call define_rest_field(ncid,'sst',dims) call define_rest_field(ncid,'frzmlt',dims) @@ -359,11 +316,11 @@ subroutine init_restart_write(filename_spec) enddo endif if (tr_bgc_Fe ) then - do k=1,n_fed + do k=1,n_fed write(nchar,'(i3.3)') k call define_rest_field(ncid,'fed'//trim(nchar),dims) enddo - do k=1,n_fep + do k=1,n_fep write(nchar,'(i3.3)') k call define_rest_field(ncid,'fep'//trim(nchar),dims) enddo @@ -376,6 +333,8 @@ subroutine init_restart_write(filename_spec) endif endif !nbtrcr + if (solve_zsal) call define_rest_field(ncid,'sss',dims) + deallocate(dims) !----------------------------------------------------------------- @@ -406,6 +365,11 @@ subroutine init_restart_write(filename_spec) call define_rest_field(ncid,'vlvl',dims) end if + if (tr_pond_cesm) then + call define_rest_field(ncid,'apnd',dims) + call define_rest_field(ncid,'hpnd',dims) + end if + if (tr_pond_topo) then call define_rest_field(ncid,'apnd',dims) call define_rest_field(ncid,'hpnd',dims) @@ -465,22 +429,24 @@ subroutine init_restart_write(filename_spec) if (tr_bgc_PON) & call define_rest_field(ncid,'bgc_PON' ,dims) if (tr_bgc_DON) then - do k = 1, n_don + do k = 1, n_don write(nchar,'(i3.3)') k call define_rest_field(ncid,'bgc_DON'//trim(nchar) ,dims) enddo endif if (tr_bgc_Fe ) then - do k = 1, n_fed + do k = 1, n_fed write(nchar,'(i3.3)') k call define_rest_field(ncid,'bgc_Fed'//trim(nchar) ,dims) enddo - do k = 1, n_fep + do k = 1, n_fep write(nchar,'(i3.3)') k call define_rest_field(ncid,'bgc_Fep'//trim(nchar) ,dims) enddo endif endif !skl_bgc + if (solve_zsal) & + call define_rest_field(ncid,'Rayleigh',dims) !----------------------------------------------------------------- ! 4D restart fields, written as layers of 3D @@ -497,16 +463,6 @@ subroutine init_restart_write(filename_spec) call define_rest_field(ncid,'qsno'//trim(nchar),dims) enddo - if (tr_snow) then - do k=1,nslyr - write(nchar,'(i3.3)') k - call define_rest_field(ncid,'smice'//trim(nchar),dims) - call define_rest_field(ncid,'smliq'//trim(nchar),dims) - call define_rest_field(ncid, 'rhos'//trim(nchar),dims) - call define_rest_field(ncid, 'rsnw'//trim(nchar),dims) - enddo - endif - if (tr_fsd) then do k=1,nfsd write(nchar,'(i3.3)') k @@ -532,6 +488,13 @@ subroutine init_restart_write(filename_spec) enddo endif + if (solve_zsal) then + do k = 1, nblyr + write(nchar,'(i3.3)') k + call define_rest_field(ncid,'zSalinity'//trim(nchar),dims) + enddo + endif + if (z_tracers) then if (tr_zaero) then do n = 1, n_zaero @@ -631,14 +594,14 @@ subroutine init_restart_write(filename_spec) enddo endif if (tr_bgc_Fe ) then - do n = 1, n_fed + do n = 1, n_fed write(ncharb,'(i3.3)') n do k = 1, nblyr+3 write(nchar,'(i3.3)') k call define_rest_field(ncid,'bgc_Fed'//trim(ncharb)//trim(nchar),dims) enddo enddo - do n = 1, n_fep + do n = 1, n_fep write(ncharb,'(i3.3)') n do k = 1, nblyr+3 write(nchar,'(i3.3)') k @@ -658,11 +621,6 @@ subroutine init_restart_write(filename_spec) write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) endif ! master_task -#else - call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined for '//trim(filename_spec), & - file=__FILE__, line=__LINE__) -#endif - end subroutine init_restart_write !======================================================================= @@ -705,7 +663,6 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3, & character(len=*), parameter :: subname = '(read_restart_field)' -#ifdef USE_NETCDF if (present(field_loc)) then if (ndim3 == ncat) then if (restart_ext) then @@ -744,13 +701,8 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3, & endif endif -#else - call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined', & - file=__FILE__, line=__LINE__) -#endif - end subroutine read_restart_field - + !======================================================================= ! Writes a single restart field. @@ -790,9 +742,8 @@ subroutine write_restart_field(nu,nrec,work,atype,vname,ndim3,diag) character(len=*), parameter :: subname = '(write_restart_field)' -#ifdef USE_NETCDF status = nf90_inq_varid(ncid,trim(vname),varid) - if (ndim3 == ncat) then + if (ndim3 == ncat) then if (restart_ext) then call ice_write_nc(ncid, 1, varid, work, diag, restart_ext, varname=trim(vname)) else @@ -809,11 +760,6 @@ subroutine write_restart_field(nu,nrec,work,atype,vname,ndim3,diag) write(nu_diag,*) 'ndim3 not supported',ndim3 endif -#else - call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined', & - file=__FILE__, line=__LINE__) -#endif - end subroutine write_restart_field !======================================================================= @@ -823,22 +769,17 @@ end subroutine write_restart_field subroutine final_restart() - use ice_calendar, only: istep1, myear, mmonth, mday, msec + use ice_calendar, only: istep1, time, time_forc + use ice_communicate, only: my_task, master_task integer (kind=int_kind) :: status character(len=*), parameter :: subname = '(final_restart)' -#ifdef USE_NETCDF status = nf90_close(ncid) if (my_task == master_task) & - write(nu_diag,'(a,i8,4x,i4.4,a,i2.2,a,i2.2,a,i5.5)') 'Restart read/written ',istep1,myear,'-',mmonth,'-',mday,'-',msec - -#else - call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined', & - file=__FILE__, line=__LINE__) -#endif + write(nu_diag,*) 'Restart read/written ',istep1,time,time_forc end subroutine final_restart @@ -860,44 +801,10 @@ subroutine define_rest_field(ncid, vname, dims) character(len=*), parameter :: subname = '(define_rest_field)' -#ifdef USE_NETCDF status = nf90_def_var(ncid,trim(vname),nf90_double,dims,varid) -#else - call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined', & - file=__FILE__, line=__LINE__) -#endif - + end subroutine define_rest_field -!======================================================================= - -! Inquire field existance -! author T. Craig - - logical function query_field(nu,vname) - - integer (kind=int_kind), intent(in) :: nu ! unit number - character (len=*) , intent(in) :: vname ! variable name - - ! local variables - - integer (kind=int_kind) :: status, varid - character(len=*), parameter :: subname = '(query_field)' - - query_field = .false. -#ifdef USE_NETCDF - if (my_task == master_task) then - status = nf90_inq_varid(ncid,trim(vname),varid) - if (status == nf90_noerr) query_field = .true. - endif - call broadcast_scalar(query_field,master_task) -#else - call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined for '//trim(ice_ic), & - file=__FILE__, line=__LINE__) -#endif - - end function query_field - !======================================================================= end module ice_restart diff --git a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 index aefcf61f9..d673c7f7a 100644 --- a/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedyn/infrastructure/io/io_pio2/ice_restart.F90 @@ -6,14 +6,12 @@ module ice_restart use ice_broadcast - use ice_communicate, only: my_task, master_task use ice_exit, only: abort_ice use ice_fileunits, only: nu_diag, nu_restart, nu_rst_pointer use ice_kinds_mod use ice_restart_shared, only: & restart, restart_ext, restart_dir, restart_file, pointer_file, & - runid, runtype, use_restart_time, restart_format, lcdf64, lenstr, & - restart_coszen + runid, runtype, use_restart_time, restart_format, lcdf64, lenstr use ice_pio use pio use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted @@ -23,8 +21,7 @@ module ice_restart implicit none private public :: init_restart_write, init_restart_read, & - read_restart_field, write_restart_field, final_restart, & - query_field + read_restart_field, write_restart_field, final_restart type(file_desc_t) :: File type(var_desc_t) :: vardesc @@ -43,8 +40,9 @@ module ice_restart subroutine init_restart_read(ice_ic) - use ice_calendar, only: istep0, istep1, myear, mmonth, & - mday, msec, npt + use ice_calendar, only: istep0, istep1, time, time_forc, nyr, month, & + mday, sec, npt + use ice_communicate, only: my_task, master_task use ice_domain_size, only: ncat use ice_read_write, only: ice_open @@ -55,13 +53,11 @@ subroutine init_restart_read(ice_ic) character(len=char_len_long) :: & filename, filename0 - integer (kind=int_kind) :: status, status1 - - integer (kind=int_kind) :: iotype + integer (kind=int_kind) :: status character(len=*), parameter :: subname = '(init_restart_read)' - if (present(ice_ic)) then + if (present(ice_ic)) then filename = trim(ice_ic) else if (my_task == master_task) then @@ -78,51 +74,37 @@ subroutine init_restart_read(ice_ic) write(nu_diag,*) 'Using restart dump=', trim(filename) end if -! if (restart_format(1:3) == 'pio') then - iotype = PIO_IOTYPE_NETCDF - if (restart_format == 'pio_pnetcdf') iotype = PIO_IOTYPE_PNETCDF + if (restart_format == 'pio') then File%fh=-1 - call ice_pio_init(mode='read', filename=trim(filename), File=File, iotype=iotype) - - call ice_pio_initdecomp(iodesc=iodesc2d, precision=8) - call ice_pio_initdecomp(ndim3=ncat , iodesc=iodesc3d_ncat,remap=.true., precision=8) + call ice_pio_init(mode='read', filename=trim(filename), File=File) + + call ice_pio_initdecomp(iodesc=iodesc2d) + call ice_pio_initdecomp(ndim3=ncat , iodesc=iodesc3d_ncat,remap=.true.) if (use_restart_time) then - status1 = PIO_noerr - status = pio_get_att(File, pio_global, 'istep1', istep0) -! status = pio_get_att(File, pio_global, 'time', time) -! status = pio_get_att(File, pio_global, 'time_forc', time_forc) - call pio_seterrorhandling(File, PIO_BCAST_ERROR) - status = pio_get_att(File, pio_global, 'myear', myear) - if (status /= PIO_noerr) status = pio_get_att(File, pio_global, 'nyr', myear) - if (status /= PIO_noerr) status1 = status - status = pio_get_att(File, pio_global, 'mmonth', mmonth) - if (status /= PIO_noerr) status = pio_get_att(File, pio_global, 'month', mmonth) - if (status /= PIO_noerr) status1 = status + status = pio_get_att(File, pio_global, 'istep1', istep0) + status = pio_get_att(File, pio_global, 'time', time) + status = pio_get_att(File, pio_global, 'time_forc', time_forc) + call pio_seterrorhandling(File, PIO_BCAST_ERROR) + status = pio_get_att(File, pio_global, 'nyr', nyr) + call pio_seterrorhandling(File, PIO_INTERNAL_ERROR) + if (status == PIO_noerr) then + status = pio_get_att(File, pio_global, 'month', month) status = pio_get_att(File, pio_global, 'mday', mday) - if (status /= PIO_noerr) status1 = status - status = pio_get_att(File, pio_global, 'msec', msec) - if (status /= PIO_noerr) status = pio_get_att(File, pio_global, 'sec', msec) - if (status /= PIO_noerr) status1 = status - if (status1 /= PIO_noerr) & - call abort_ice(subname//"ERROR: reading restart time ") - call pio_seterrorhandling(File, PIO_INTERNAL_ERROR) + status = pio_get_att(File, pio_global, 'sec', sec) + endif endif ! use namelist values if use_restart_time = F -! endif + endif if (my_task == master_task) then - write(nu_diag,'(a,i8,4x,i4.4,a,i2.2,a,i2.2,a,i5.5)') 'Restart read at istep=',istep0,myear,'-',mmonth,'-',mday,'-',msec + write(nu_diag,*) 'Restart read at istep=',istep0,time,time_forc endif call broadcast_scalar(istep0,master_task) - call broadcast_scalar(myear,master_task) - call broadcast_scalar(mmonth,master_task) - call broadcast_scalar(mday,master_task) - call broadcast_scalar(msec,master_task) -! call broadcast_scalar(time,master_task) -! call broadcast_scalar(time_forc,master_task) - call broadcast_scalar(myear,master_task) - + call broadcast_scalar(time,master_task) + call broadcast_scalar(time_forc,master_task) + call broadcast_scalar(nyr,master_task) + istep1 = istep0 ! if runid is bering then need to correct npt for istep0 @@ -139,26 +121,27 @@ end subroutine init_restart_read subroutine init_restart_write(filename_spec) - use ice_calendar, only: msec, mmonth, mday, myear, istep1 + use ice_calendar, only: sec, month, mday, nyr, istep1, & + time, time_forc, year_init + use ice_communicate, only: my_task, master_task use ice_domain_size, only: nx_global, ny_global, ncat, nilyr, nslyr, & n_iso, n_aero, nblyr, n_zaero, n_algae, n_doc, & - n_dic, n_don, n_fed, n_fep, nfsd + n_dic, n_don, n_fed, n_fep use ice_dyn_shared, only: kdyn use ice_arrays_column, only: oceanmixed_ice - use ice_grid, only: grid_ice logical (kind=log_kind) :: & - skl_bgc, z_tracers + solve_zsal, skl_bgc, z_tracers logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, & - tr_pond_topo, tr_pond_lvl, tr_brine, tr_snow, & + tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, tr_pond_cesm, & + tr_pond_topo, tr_pond_lvl, tr_brine, & tr_bgc_N, tr_bgc_C, tr_bgc_Nit, & tr_bgc_Sil, tr_bgc_DMS, & - tr_bgc_chl, tr_bgc_Am, & + tr_bgc_chl, tr_bgc_Am, & tr_bgc_PON, tr_bgc_DON, & - tr_zaero, tr_bgc_Fe, & - tr_bgc_hum, tr_fsd + tr_zaero, tr_bgc_Fe, & + tr_bgc_hum integer (kind=int_kind) :: & nbtrcr @@ -167,6 +150,9 @@ subroutine init_restart_write(filename_spec) ! local variables + integer (kind=int_kind) :: & + iyear, imonth, iday ! year, month, day + character(len=char_len_long) :: filename integer (kind=int_kind) :: dimid_ni, dimid_nj, dimid_ncat, & @@ -174,8 +160,6 @@ subroutine init_restart_write(filename_spec) integer (kind=int_kind), allocatable :: dims(:) - integer (kind=int_kind) :: iotype - integer (kind=int_kind) :: & k, n, & ! loop index status ! status variable from netCDF routine @@ -187,16 +171,15 @@ subroutine init_restart_write(filename_spec) call icepack_query_tracer_sizes(nbtrcr_out=nbtrcr) call icepack_query_tracer_flags( & tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_lvl_out=tr_lvl, & - tr_iso_out=tr_iso, tr_aero_out=tr_aero, & - tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, & - tr_snow_out=tr_snow, tr_brine_out=tr_brine, & + tr_iso_out=tr_iso, tr_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, & + tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, tr_brine_out=tr_brine, & tr_bgc_N_out=tr_bgc_N, tr_bgc_C_out=tr_bgc_C, tr_bgc_Nit_out=tr_bgc_Nit, & tr_bgc_Sil_out=tr_bgc_Sil, tr_bgc_DMS_out=tr_bgc_DMS, & tr_bgc_chl_out=tr_bgc_chl, tr_bgc_Am_out=tr_bgc_Am, & tr_bgc_PON_out=tr_bgc_PON, tr_bgc_DON_out=tr_bgc_DON, & tr_zaero_out=tr_zaero, tr_bgc_Fe_out=tr_bgc_Fe, & - tr_bgc_hum_out=tr_bgc_hum, tr_fsd_out=tr_fsd) - call icepack_query_parameters(skl_bgc_out=skl_bgc, & + tr_bgc_hum_out=tr_bgc_hum) + call icepack_query_parameters(solve_zsal_out=solve_zsal, skl_bgc_out=skl_bgc, & z_tracers_out=z_tracers) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & @@ -206,13 +189,17 @@ subroutine init_restart_write(filename_spec) if (present(filename_spec)) then filename = trim(filename_spec) else + iyear = nyr + year_init - 1 + imonth = month + iday = mday + write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & restart_dir(1:lenstr(restart_dir)), & restart_file(1:lenstr(restart_file)),'.', & - myear,'-',mmonth,'-',mday,'-',msec + iyear,'-',month,'-',mday,'-',sec end if - - if (restart_format(1:3) /= 'bin') filename = trim(filename) // '.nc' + + if (restart_format /= 'bin') filename = trim(filename) // '.nc' ! write pointer (path/file) if (my_task == master_task) then @@ -221,21 +208,19 @@ subroutine init_restart_write(filename_spec) close(nu_rst_pointer) endif -! if (restart_format(1:3) == 'pio') then - - iotype = PIO_IOTYPE_NETCDF - if (restart_format == 'pio_pnetcdf') iotype = PIO_IOTYPE_PNETCDF + if (restart_format == 'pio') then + File%fh=-1 call ice_pio_init(mode='write',filename=trim(filename), File=File, & - clobber=.true., cdf64=lcdf64, iotype=iotype) + clobber=.true., cdf64=lcdf64 ) status = pio_put_att(File,pio_global,'istep1',istep1) -! status = pio_put_att(File,pio_global,'time',time) -! status = pio_put_att(File,pio_global,'time_forc',time_forc) - status = pio_put_att(File,pio_global,'myear',myear) - status = pio_put_att(File,pio_global,'mmonth',mmonth) + status = pio_put_att(File,pio_global,'time',time) + status = pio_put_att(File,pio_global,'time_forc',time_forc) + status = pio_put_att(File,pio_global,'nyr',nyr) + status = pio_put_att(File,pio_global,'month',month) status = pio_put_att(File,pio_global,'mday',mday) - status = pio_put_att(File,pio_global,'msec',msec) + status = pio_put_att(File,pio_global,'sec',sec) status = pio_def_dim(File,'ni',nx_global,dimid_ni) status = pio_def_dim(File,'nj',ny_global,dimid_nj) @@ -253,20 +238,9 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'uvel',dims) call define_rest_field(File,'vvel',dims) - if (grid_ice == 'CD') then - call define_rest_field(File,'uvelE',dims) - call define_rest_field(File,'vvelE',dims) - call define_rest_field(File,'uvelN',dims) - call define_rest_field(File,'vvelN',dims) - endif - - if (grid_ice == 'C') then - call define_rest_field(File,'uvelE',dims) - call define_rest_field(File,'vvelN',dims) - endif - - - if (restart_coszen) call define_rest_field(File,'coszen',dims) +#ifdef CESMCOUPLED + call define_rest_field(File,'coszen',dims) +#endif call define_rest_field(File,'scale_factor',dims) call define_rest_field(File,'swvdr',dims) call define_rest_field(File,'swvdf',dims) @@ -293,17 +267,6 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'iceumask',dims) - if (grid_ice == 'CD' .or. grid_ice == 'C') then - call define_rest_field(File,'stresspT' ,dims) - call define_rest_field(File,'stressmT' ,dims) - call define_rest_field(File,'stress12T',dims) - call define_rest_field(File,'stresspU' ,dims) - call define_rest_field(File,'stressmU' ,dims) - call define_rest_field(File,'stress12U',dims) - call define_rest_field(File,'icenmask',dims) - call define_rest_field(File,'iceemask',dims) - endif - if (oceanmixed_ice) then call define_rest_field(File,'sst',dims) call define_rest_field(File,'frzmlt',dims) @@ -380,6 +343,8 @@ subroutine init_restart_write(filename_spec) endif endif !nbtrcr + if (solve_zsal) call define_rest_field(File,'sss',dims) + deallocate(dims) !----------------------------------------------------------------- @@ -410,6 +375,11 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'vlvl',dims) end if + if (tr_pond_cesm) then + call define_rest_field(File,'apnd',dims) + call define_rest_field(File,'hpnd',dims) + end if + if (tr_pond_topo) then call define_rest_field(File,'apnd',dims) call define_rest_field(File,'hpnd',dims) @@ -485,6 +455,8 @@ subroutine init_restart_write(filename_spec) enddo endif endif !skl_bgc + if (solve_zsal) & + call define_rest_field(File,'Rayleigh',dims) !----------------------------------------------------------------- ! 4D restart fields, written as layers of 3D @@ -501,23 +473,6 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'qsno'//trim(nchar),dims) enddo - if (tr_snow) then - do k=1,nslyr - write(nchar,'(i3.3)') k - call define_rest_field(File,'smice'//trim(nchar),dims) - call define_rest_field(File,'smliq'//trim(nchar),dims) - call define_rest_field(File, 'rhos'//trim(nchar),dims) - call define_rest_field(File, 'rsnw'//trim(nchar),dims) - enddo - endif - - if (tr_fsd) then - do k=1,nfsd - write(nchar,'(i3.3)') k - call define_rest_field(File,'fsd'//trim(nchar),dims) - enddo - endif - if (tr_iso) then do k=1,n_iso write(nchar,'(i3.3)') k @@ -536,6 +491,12 @@ subroutine init_restart_write(filename_spec) enddo endif + if (solve_zsal) then + do k = 1, nblyr + write(nchar,'(i3.3)') k + call define_rest_field(File,'zSalinity'//trim(nchar),dims) + enddo + endif if (z_tracers) then if (tr_zaero) then do n = 1, n_zaero @@ -660,10 +621,10 @@ subroutine init_restart_write(filename_spec) deallocate(dims) status = pio_enddef(File) - call ice_pio_initdecomp(iodesc=iodesc2d, precision=8) - call ice_pio_initdecomp(ndim3=ncat , iodesc=iodesc3d_ncat, remap=.true., precision=8) + call ice_pio_initdecomp(iodesc=iodesc2d) + call ice_pio_initdecomp(ndim3=ncat , iodesc=iodesc3d_ncat, remap=.true.) -! endif ! restart_format + endif if (my_task == master_task) then write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) @@ -680,6 +641,7 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & field_loc, field_type) use ice_blocks, only: nx_block, ny_block + use ice_communicate, only: my_task, master_task use ice_constants, only: c0, field_loc_center use ice_boundary, only: ice_HaloUpdate use ice_domain, only: halo_info, distrb_info, nblocks @@ -687,7 +649,7 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & use ice_global_reductions, only: global_minval, global_maxval, global_sum integer (kind=int_kind), intent(in) :: & - nu , & ! unit number + nu , & ! unit number (not used for netcdf) ndim3 , & ! third dimension nrec ! record number (0 for sequential access) @@ -719,7 +681,7 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & character(len=*), parameter :: subname = '(read_restart_field)' -! if (restart_format(1:3) == "pio") then + if (restart_format == "pio") then if (my_task == master_task) & write(nu_diag,*)'Parallel restart file read: ',vname @@ -727,9 +689,8 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & status = pio_inq_varid(File,trim(vname),vardesc) - if (status /= PIO_noerr) then - call abort_ice(subname// & - "ERROR: CICE restart? Missing variable: "//trim(vname)) + if (status /= 0) then + call abort_ice(subname//"ERROR: CICE restart? Missing variable: "//trim(vname)) endif status = pio_inq_varndims(File, vardesc, ndims) @@ -739,9 +700,6 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & ! if (ndim3 == ncat .and. ncat>1) then if (ndim3 == ncat .and. ndims == 3) then call pio_read_darray(File, vardesc, iodesc3d_ncat, work, status) -#ifdef CESMCOUPLED - where (work == PIO_FILL_DOUBLE) work = c0 -#endif if (present(field_loc)) then do n=1,ndim3 call ice_HaloUpdate (work(:,:,n,:), halo_info, & @@ -751,9 +709,6 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & ! elseif (ndim3 == 1) then elseif (ndim3 == 1 .and. ndims == 2) then call pio_read_darray(File, vardesc, iodesc2d, work, status) -#ifdef CESMCOUPLED - where (work == PIO_FILL_DOUBLE) work = c0 -#endif if (present(field_loc)) then call ice_HaloUpdate (work(:,:,1,:), halo_info, & field_loc, field_type) @@ -769,7 +724,8 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & amax = global_maxval(work(:,:,n,:),distrb_info) asum = global_sum(work(:,:,n,:), distrb_info, field_loc_center) if (my_task == master_task) then - write(nu_diag,*) ' min, max, sum =', amin, amax, asum, trim(vname) + write(nu_diag,*) ' min and max =', amin, amax + write(nu_diag,*) ' sum =',asum endif enddo else @@ -777,17 +733,19 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & amax = global_maxval(work(:,:,1,:),distrb_info) asum = global_sum(work(:,:,1,:), distrb_info, field_loc_center) if (my_task == master_task) then - write(nu_diag,*) ' min, max, sum =', amin, amax, asum, trim(vname) + write(nu_diag,*) ' min and max =', amin, amax + write(nu_diag,*) ' sum =',asum + write(nu_diag,*) '' endif endif - + endif -! else -! call abort_ice(subname//"ERROR: Invalid restart_format: "//trim(restart_format)) -! endif ! restart_format + else + call abort_ice(subname//"ERROR: Invalid restart_format: "//trim(restart_format)) + endif end subroutine read_restart_field - + !======================================================================= ! Writes a single restart field. @@ -796,6 +754,7 @@ end subroutine read_restart_field subroutine write_restart_field(nu,nrec,work,atype,vname,ndim3,diag) use ice_blocks, only: nx_block, ny_block + use ice_communicate, only: my_task, master_task use ice_constants, only: c0, field_loc_center use ice_domain, only: distrb_info, nblocks use ice_domain_size, only: max_blocks, ncat @@ -830,15 +789,15 @@ subroutine write_restart_field(nu,nrec,work,atype,vname,ndim3,diag) character(len=*), parameter :: subname = '(write_restart_field)' -! if (restart_format(1:3) == "pio") then + if (restart_format == "pio") then if (my_task == master_task) & write(nu_diag,*)'Parallel restart file write: ',vname status = pio_inq_varid(File,trim(vname),vardesc) - + status = pio_inq_varndims(File, vardesc, ndims) - if (ndims==3) then + if (ndims==3) then call pio_write_darray(File, vardesc, iodesc3d_ncat,work(:,:,:,1:nblocks), & status, fillval=c0) elseif (ndims == 2) then @@ -855,7 +814,8 @@ subroutine write_restart_field(nu,nrec,work,atype,vname,ndim3,diag) amax = global_maxval(work(:,:,n,:),distrb_info) asum = global_sum(work(:,:,n,:), distrb_info, field_loc_center) if (my_task == master_task) then - write(nu_diag,*) ' min, max, sum =', amin, amax, asum, trim(vname) + write(nu_diag,*) ' min and max =', amin, amax + write(nu_diag,*) ' sum =',asum endif enddo else @@ -863,13 +823,14 @@ subroutine write_restart_field(nu,nrec,work,atype,vname,ndim3,diag) amax = global_maxval(work(:,:,1,:),distrb_info) asum = global_sum(work(:,:,1,:), distrb_info, field_loc_center) if (my_task == master_task) then - write(nu_diag,*) ' min, max, sum =', amin, amax, asum, trim(vname) + write(nu_diag,*) ' min and max =', amin, amax + write(nu_diag,*) ' sum =',asum endif endif endif -! else -! call abort_ice(subname//"ERROR: Invalid restart_format: "//trim(restart_format)) -! endif + else + call abort_ice(subname//"ERROR: Invalid restart_format: "//trim(restart_format)) + endif end subroutine write_restart_field @@ -880,18 +841,20 @@ end subroutine write_restart_field subroutine final_restart() - use ice_calendar, only: istep1, myear, mmonth, mday, msec + use ice_calendar, only: istep1, time, time_forc + use ice_communicate, only: my_task, master_task character(len=*), parameter :: subname = '(final_restart)' - call PIO_freeDecomp(File,iodesc2d) - call PIO_freeDecomp(File,iodesc3d_ncat) - call pio_closefile(File) - - if (my_task == master_task) then - write(nu_diag,'(a,i8,4x,i4.4,a,i2.2,a,i2.2,a,i5.5)') 'Restart read/written ',istep1,myear,'-',mmonth,'-',mday,'-',msec + if (restart_format == 'pio') then + call PIO_freeDecomp(File,iodesc2d) + call PIO_freeDecomp(File,iodesc3d_ncat) + call pio_closefile(File) endif + if (my_task == master_task) & + write(nu_diag,*) 'Restart read/written ',istep1,time,time_forc + end subroutine final_restart !======================================================================= @@ -911,31 +874,9 @@ subroutine define_rest_field(File, vname, dims) character(len=*), parameter :: subname = '(define_rest_field)' status = pio_def_var(File,trim(vname),pio_double,dims,vardesc) - + end subroutine define_rest_field -!======================================================================= - -! Inquire field existance -! author T. Craig - - logical function query_field(nu,vname) - - integer (kind=int_kind), intent(in) :: nu ! unit number - character (len=*) , intent(in) :: vname ! variable name - - ! local variables - - integer (kind=int_kind) :: status, varid - character(len=*), parameter :: subname = '(query_field)' - - query_field = .false. - - status = pio_inq_varid(File,trim(vname),vardesc) - if (status == PIO_noerr) query_field = .true. - - end function query_field - !======================================================================= end module ice_restart diff --git a/cicecore/cicedynB b/cicecore/cicedynB~HEAD similarity index 100% rename from cicecore/cicedynB rename to cicecore/cicedynB~HEAD diff --git a/cicecore/drivers/direct/nemo_concepts/CICE_RunMod.F90 b/cicecore/drivers/direct/nemo_concepts/CICE_RunMod.F90 deleted file mode 100644 index c9875d769..000000000 --- a/cicecore/drivers/direct/nemo_concepts/CICE_RunMod.F90 +++ /dev/null @@ -1,654 +0,0 @@ -!======================================================================= -! -! Main driver for time stepping of CICE. -! -! authors Elizabeth C. Hunke, LANL -! Philip W. Jones, LANL -! William H. Lipscomb, LANL -! -! 2006 ECH: moved exit timeLoop to prevent execution of unnecessary timestep -! 2006 ECH: Streamlined for efficiency -! 2006 ECH: Converted to free source form (F90) -! 2007 BPB: Modified Delta-Eddington shortwave interface -! 2008 ECH: moved ESMF code to its own driver - - module CICE_RunMod - - use ice_kinds_mod - use ice_fileunits, only: nu_diag - use ice_arrays_column, only: oceanmixed_ice - use ice_constants, only: c0, c1 - use ice_constants, only: field_loc_center, field_type_scalar - use ice_exit, only: abort_ice - use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted - use icepack_intfc, only: icepack_max_aero - use icepack_intfc, only: icepack_query_parameters - use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_sizes - - implicit none - private - public :: CICE_Run, ice_step - -!======================================================================= - - contains - -!======================================================================= -! -! This is the main driver routine for advancing CICE forward in time. -! -! author Elizabeth C. Hunke, LANL -! Philip W. Jones, LANL -! William H. Lipscomb, LANL - - subroutine CICE_Run - - use ice_calendar, only: stop_now, advance_timestep - use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & - get_wave_spec - use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, fzaero_data, & - faero_default - use ice_flux, only: init_flux_atm, init_flux_ocn - use ice_timers, only: ice_timer_start, ice_timer_stop, & - timer_couple, timer_step - logical (kind=log_kind) :: & - tr_aero, tr_zaero, skl_bgc, z_tracers, wave_spec, tr_fsd - - character(len=*), parameter :: subname = '(CICE_Run)' - - !-------------------------------------------------------------------- - ! initialize error code and step timer - !-------------------------------------------------------------------- - - call ice_timer_start(timer_step) ! start timing entire run - - call icepack_query_parameters(skl_bgc_out=skl_bgc, & - z_tracers_out=z_tracers, & - wave_spec_out=wave_spec) - call icepack_query_tracer_flags(tr_aero_out=tr_aero, & - tr_zaero_out=tr_zaero, & - tr_fsd_out=tr_fsd) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - -#ifndef CICE_IN_NEMO - !-------------------------------------------------------------------- - ! timestep loop - !-------------------------------------------------------------------- - - timeLoop: do -#endif - - call ice_step - - call advance_timestep() ! advance time - -#ifndef CICE_IN_NEMO - if (stop_now >= 1) exit timeLoop -#endif - - call ice_timer_start(timer_couple) ! atm/ocn coupling - -! standalone -! for now, wave_spectrum is constant in time -! if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice -! call get_forcing_atmo ! atmospheric forcing from data -! call get_forcing_ocn(dt) ! ocean forcing from data - -! ! aerosols -! ! if (tr_aero) call faero_data ! data file -! ! if (tr_zaero) call fzaero_data ! data file (gx1) -! if (tr_aero .or. tr_zaero) call faero_default ! default values - -! if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry - - if (z_tracers) call get_atm_bgc ! biogeochemistry - - call init_flux_atm ! initialize atmosphere fluxes sent to coupler - call init_flux_ocn ! initialize ocean fluxes sent to coupler - - call ice_timer_stop(timer_couple) ! atm/ocn coupling - -#ifndef CICE_IN_NEMO - enddo timeLoop -#endif - - !-------------------------------------------------------------------- - ! end of timestep loop - !-------------------------------------------------------------------- - - call ice_timer_stop(timer_step) ! end timestepping loop timer - - end subroutine CICE_Run - -!======================================================================= -! -! Calls drivers for physics components, some initialization, and output -! -! author Elizabeth C. Hunke, LANL -! William H. Lipscomb, LANL - - subroutine ice_step - - use ice_boundary, only: ice_HaloUpdate - use ice_calendar, only: dt, dt_dyn, ndtd, diagfreq, write_restart, istep - use ice_diagnostics, only: init_mass_diags, runtime_diags - use ice_diagnostics_bgc, only: hbrine_diags, zsal_diags, bgc_diags - use ice_domain, only: halo_info, nblocks - use ice_domain_size, only: nslyr - use ice_dyn_eap, only: write_restart_eap - use ice_dyn_shared, only: kdyn - use ice_flux, only: scale_factor, init_history_therm, & - daidtt, daidtd, dvidtt, dvidtd, dagedtt, dagedtd - use ice_history, only: accum_hist - use ice_history_bgc, only: init_history_bgc - use ice_restart, only: final_restart - use ice_restart_column, only: write_restart_age, write_restart_FY, & - write_restart_lvl, write_restart_pond_lvl, & - write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_bgc, write_restart_hbrine - use ice_restart_driver, only: dumpfile - use ice_restoring, only: restore_ice, ice_HaloRestore - use ice_state, only: trcrn - use ice_step_mod, only: prep_radiation, step_therm1, step_therm2, & - update_state, step_dyn_horiz, step_dyn_ridge, step_radiation, & - biogeochemistry, step_prep, step_dyn_wave - use ice_timers, only: ice_timer_start, ice_timer_stop, & - timer_diags, timer_column, timer_thermo, timer_bound, & - timer_hist, timer_readwrite - - integer (kind=int_kind) :: & - iblk , & ! block index - k , & ! dynamics supercycling index - ktherm ! thermodynamics is off when ktherm = -1 - - real (kind=dbl_kind) :: & - offset ! d(age)/dt time offset - - logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_fsd, & - tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero, & - calc_Tsfc, skl_bgc, solve_zsal, z_tracers, wave_spec - - character(len=*), parameter :: subname = '(ice_step)' - - call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc, skl_bgc_out=skl_bgc, & - solve_zsal_out=solve_zsal, z_tracers_out=z_tracers, ktherm_out=ktherm, & - wave_spec_out=wave_spec) - call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & - tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, & - tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_fsd_out=tr_fsd) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - -#ifdef ICE_DA - !--------------------------------------------------------------- - ! Update CICE state variables using data assimilation increments - !--------------------------------------------------------------- - call da_state_update -#endif - - !----------------------------------------------------------------- - ! restoring on grid boundaries - !----------------------------------------------------------------- - - if (restore_ice) call ice_HaloRestore - - !----------------------------------------------------------------- - ! initialize diagnostics and save initial state values - !----------------------------------------------------------------- - - call ice_timer_start(timer_diags) ! diagnostics/history - call init_mass_diags ! diagnostics per timestep - call init_history_therm - call init_history_bgc - call ice_timer_stop(timer_diags) ! diagnostics/history - - call ice_timer_start(timer_column) ! column physics - call ice_timer_start(timer_thermo) ! thermodynamics - - call step_prep - - !$OMP PARALLEL DO PRIVATE(iblk) - do iblk = 1, nblocks - - if (ktherm >= 0) then - - !----------------------------------------------------------------- - ! Scale radiation fields - !----------------------------------------------------------------- - - if (calc_Tsfc) call prep_radiation (iblk) - - !----------------------------------------------------------------- - ! thermodynamics and biogeochemistry - !----------------------------------------------------------------- - - call step_therm1 (dt, iblk) ! vertical thermodynamics - call biogeochemistry (dt, iblk) ! biogeochemistry - call step_therm2 (dt, iblk) ! ice thickness distribution thermo - - endif - - enddo ! iblk - !$OMP END PARALLEL DO - - ! clean up, update tendency diagnostics - offset = dt - call update_state (dt, daidtt, dvidtt, dagedtt, offset) - - call ice_timer_stop(timer_thermo) ! thermodynamics - call ice_timer_stop(timer_column) ! column physics - - !----------------------------------------------------------------- - ! dynamics, transport, ridging - !----------------------------------------------------------------- - - ! wave fracture of the floe size distribution - ! note this is called outside of the dynamics subcycling loop - if (tr_fsd .and. wave_spec) call step_dyn_wave(dt) - - do k = 1, ndtd - - ! momentum, stress, transport - call step_dyn_horiz (dt_dyn) - - ! ridging - !$OMP PARALLEL DO PRIVATE(iblk) - do iblk = 1, nblocks - call step_dyn_ridge (dt_dyn, ndtd, iblk) - enddo - !$OMP END PARALLEL DO - - ! clean up, update tendency diagnostics - offset = c0 - call update_state (dt_dyn, daidtd, dvidtd, dagedtd, offset) - - enddo - - !----------------------------------------------------------------- - ! albedo, shortwave radiation - !----------------------------------------------------------------- - - call ice_timer_start(timer_column) ! column physics - call ice_timer_start(timer_thermo) ! thermodynamics - - !$OMP PARALLEL DO PRIVATE(iblk) - do iblk = 1, nblocks - - if (ktherm >= 0) call step_radiation (dt, iblk) - - !----------------------------------------------------------------- - ! get ready for coupling and the next time step - !----------------------------------------------------------------- - - call coupling_prep (iblk) - - enddo ! iblk - !$OMP END PARALLEL DO - - call ice_timer_start(timer_bound) - call ice_HaloUpdate (scale_factor, halo_info, & - field_loc_center, field_type_scalar) - call ice_timer_stop(timer_bound) - - call ice_timer_stop(timer_thermo) ! thermodynamics - call ice_timer_stop(timer_column) ! column physics - - !----------------------------------------------------------------- - ! write data - !----------------------------------------------------------------- - - call ice_timer_start(timer_diags) ! diagnostics - if (mod(istep,diagfreq) == 0) then - call runtime_diags(dt) ! log file - if (solve_zsal) call zsal_diags - if (skl_bgc .or. z_tracers) call bgc_diags - if (tr_brine) call hbrine_diags - endif - call ice_timer_stop(timer_diags) ! diagnostics - - call ice_timer_start(timer_hist) ! history - call accum_hist (dt) ! history file - call ice_timer_stop(timer_hist) ! history - - call ice_timer_start(timer_readwrite) ! reading/writing - if (write_restart == 1) then - call dumpfile ! core variables for restarting - if (tr_iage) call write_restart_age - if (tr_FY) call write_restart_FY - if (tr_lvl) call write_restart_lvl - if (tr_pond_lvl) call write_restart_pond_lvl - if (tr_pond_topo) call write_restart_pond_topo - if (tr_fsd) call write_restart_fsd - if (tr_aero) call write_restart_aero - if (solve_zsal .or. skl_bgc .or. z_tracers) & - call write_restart_bgc - if (tr_brine) call write_restart_hbrine - if (kdyn == 2) call write_restart_eap - call final_restart - endif - - call ice_timer_stop(timer_readwrite) ! reading/writing - - end subroutine ice_step - -!======================================================================= -! -! Prepare for coupling -! -! authors: Elizabeth C. Hunke, LANL - - subroutine coupling_prep (iblk) - - use ice_arrays_column, only: alvdfn, alidfn, alvdrn, alidrn, & - albicen, albsnon, albpndn, apeffn, fzsal_g, fzsal, snowfracn - use ice_blocks, only: nx_block, ny_block, get_block, block - use ice_domain, only: blocks_ice - use ice_calendar, only: dt, nstreams - use ice_domain_size, only: ncat - use ice_flux, only: alvdf, alidf, alvdr, alidr, albice, albsno, & - albpnd, albcnt, apeff_ai, coszen, fpond, fresh, l_mpond_fresh, & - alvdf_ai, alidf_ai, alvdr_ai, alidr_ai, fhocn_ai, & - fresh_ai, fsalt_ai, fsalt, & - fswthru_ai, fhocn, fswthru, scale_factor, snowfrac, & - fswthru_vdr, fswthru_vdf, fswthru_idr, fswthru_idf, & - swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyt, & - fsens, flat, fswabs, flwout, evap, Tref, Qref, & - fsurfn_f, flatn_f, scale_fluxes, frzmlt_init, frzmlt - use ice_flux_bgc, only: faero_ocn, fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai - use ice_grid, only: tmask - use ice_state, only: aicen, aice, aice_init - use ice_step_mod, only: ocean_mixed_layer - use ice_timers, only: timer_couple, ice_timer_start, ice_timer_stop - - integer (kind=int_kind), intent(in) :: & - iblk ! block index - - ! local variables - - integer (kind=int_kind) :: & - ilo,ihi,jlo,jhi, & ! beginning and end of physical domain - n , & ! thickness category index - i,j , & ! horizontal indices - k , & ! tracer index - nbtrcr ! - - type (block) :: & - this_block ! block information for current block - - logical (kind=log_kind) :: & - calc_Tsfc ! - - real (kind=dbl_kind) :: & - cszn , & ! counter for history averaging - puny , & ! - rhofresh , & ! - netsw ! flag for shortwave radiation presence - - character(len=*), parameter :: subname = '(coupling_prep)' - - call icepack_query_parameters(puny_out=puny, rhofresh_out=rhofresh) - call icepack_query_tracer_sizes(nbtrcr_out=nbtrcr) - call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - - !----------------------------------------------------------------- - ! Save current value of frzmlt for diagnostics. - ! Update mixed layer with heat and radiation from ice. - !----------------------------------------------------------------- - - do j = 1, ny_block - do i = 1, nx_block - frzmlt_init (i,j,iblk) = frzmlt(i,j,iblk) - enddo - enddo - - call ice_timer_start(timer_couple) ! atm/ocn coupling - - if (oceanmixed_ice) & - call ocean_mixed_layer (dt,iblk) ! ocean surface fluxes and sst - - !----------------------------------------------------------------- - ! Aggregate albedos - !----------------------------------------------------------------- - - do j = 1, ny_block - do i = 1, nx_block - alvdf(i,j,iblk) = c0 - alidf(i,j,iblk) = c0 - alvdr(i,j,iblk) = c0 - alidr(i,j,iblk) = c0 - - albice(i,j,iblk) = c0 - albsno(i,j,iblk) = c0 - albpnd(i,j,iblk) = c0 - apeff_ai(i,j,iblk) = c0 - snowfrac(i,j,iblk) = c0 - - ! for history averaging - cszn = c0 - netsw = swvdr(i,j,iblk)+swidr(i,j,iblk)+swvdf(i,j,iblk)+swidf(i,j,iblk) - if (netsw > puny) cszn = c1 - do n = 1, nstreams - albcnt(i,j,iblk,n) = albcnt(i,j,iblk,n) + cszn - enddo - enddo - enddo - - this_block = get_block(blocks_ice(iblk),iblk) - ilo = this_block%ilo - ihi = this_block%ihi - jlo = this_block%jlo - jhi = this_block%jhi - - do n = 1, ncat - do j = jlo, jhi - do i = ilo, ihi - if (aicen(i,j,n,iblk) > puny) then - - alvdf(i,j,iblk) = alvdf(i,j,iblk) & - + alvdfn(i,j,n,iblk)*aicen(i,j,n,iblk) - alidf(i,j,iblk) = alidf(i,j,iblk) & - + alidfn(i,j,n,iblk)*aicen(i,j,n,iblk) - alvdr(i,j,iblk) = alvdr(i,j,iblk) & - + alvdrn(i,j,n,iblk)*aicen(i,j,n,iblk) - alidr(i,j,iblk) = alidr(i,j,iblk) & - + alidrn(i,j,n,iblk)*aicen(i,j,n,iblk) - - netsw = swvdr(i,j,iblk) + swidr(i,j,iblk) & - + swvdf(i,j,iblk) + swidf(i,j,iblk) - if (netsw > puny) then ! sun above horizon - albice(i,j,iblk) = albice(i,j,iblk) & - + albicen(i,j,n,iblk)*aicen(i,j,n,iblk) - albsno(i,j,iblk) = albsno(i,j,iblk) & - + albsnon(i,j,n,iblk)*aicen(i,j,n,iblk) - albpnd(i,j,iblk) = albpnd(i,j,iblk) & - + albpndn(i,j,n,iblk)*aicen(i,j,n,iblk) - endif - - apeff_ai(i,j,iblk) = apeff_ai(i,j,iblk) & ! for history - + apeffn(i,j,n,iblk)*aicen(i,j,n,iblk) - snowfrac(i,j,iblk) = snowfrac(i,j,iblk) & ! for history - + snowfracn(i,j,n,iblk)*aicen(i,j,n,iblk) - - endif ! aicen > puny - enddo - enddo - enddo - - do j = 1, ny_block - do i = 1, nx_block - - !----------------------------------------------------------------- - ! reduce fresh by fpond for coupling - !----------------------------------------------------------------- - - if (l_mpond_fresh) then - fpond(i,j,iblk) = fpond(i,j,iblk) * rhofresh/dt - fresh(i,j,iblk) = fresh(i,j,iblk) - fpond(i,j,iblk) - endif - - !---------------------------------------------------------------- - ! Store grid box mean albedos and fluxes before scaling by aice - !---------------------------------------------------------------- - - alvdf_ai (i,j,iblk) = alvdf (i,j,iblk) - alidf_ai (i,j,iblk) = alidf (i,j,iblk) - alvdr_ai (i,j,iblk) = alvdr (i,j,iblk) - alidr_ai (i,j,iblk) = alidr (i,j,iblk) - fresh_ai (i,j,iblk) = fresh (i,j,iblk) - fsalt_ai (i,j,iblk) = fsalt (i,j,iblk) - fhocn_ai (i,j,iblk) = fhocn (i,j,iblk) - fswthru_ai(i,j,iblk) = fswthru(i,j,iblk) - fzsal_ai (i,j,iblk) = fzsal (i,j,iblk) - fzsal_g_ai(i,j,iblk) = fzsal_g(i,j,iblk) - - if (nbtrcr > 0) then - do k = 1, nbtrcr - flux_bio_ai (i,j,k,iblk) = flux_bio (i,j,k,iblk) - enddo - endif - - !----------------------------------------------------------------- - ! Save net shortwave for scaling factor in scale_factor - !----------------------------------------------------------------- - scale_factor(i,j,iblk) = & - swvdr(i,j,iblk)*(c1 - alvdr_ai(i,j,iblk)) & - + swvdf(i,j,iblk)*(c1 - alvdf_ai(i,j,iblk)) & - + swidr(i,j,iblk)*(c1 - alidr_ai(i,j,iblk)) & - + swidf(i,j,iblk)*(c1 - alidf_ai(i,j,iblk)) - - enddo - enddo - - !----------------------------------------------------------------- - ! Divide fluxes by ice area - ! - the CESM coupler assumes fluxes are per unit ice area - ! - also needed for global budget in diagnostics - !----------------------------------------------------------------- - -! RM and froy -! Now use aice_init, more consistent, see merge_fluxes - call scale_fluxes (nx_block, ny_block, & - tmask (:,:,iblk), nbtrcr, icepack_max_aero, & - aice_init(:,:,iblk), Tf (:,:,iblk), & - Tair (:,:,iblk), Qa (:,:,iblk), & - strairxT (:,:,iblk), strairyT(:,:,iblk), & - fsens (:,:,iblk), flat (:,:,iblk), & - fswabs (:,:,iblk), flwout (:,:,iblk), & - evap (:,:,iblk), & - Tref (:,:,iblk), Qref (:,:,iblk), & - fresh (:,:,iblk), fsalt (:,:,iblk), & - fhocn (:,:,iblk), fswthru (:,:,iblk), & - fswthru_vdr(:,:,iblk), & - fswthru_vdf(:,:,iblk), & - fswthru_idr(:,:,iblk), & - fswthru_idf(:,:,iblk), & - faero_ocn(:,:,:,iblk), & - alvdr (:,:,iblk), alidr (:,:,iblk), & - alvdf (:,:,iblk), alidf (:,:,iblk), & - fzsal (:,:,iblk), fzsal_g (:,:,iblk), & - flux_bio(:,:,1:nbtrcr,iblk)) - -!echmod - comment this out for efficiency, if .not. calc_Tsfc - if (.not. calc_Tsfc) then - - !--------------------------------------------------------------- - ! If surface fluxes were provided, conserve these fluxes at ice - ! free points by passing to ocean. - !--------------------------------------------------------------- - - call sfcflux_to_ocn & - (nx_block, ny_block, & - tmask (:,:,iblk), aice_init(:,:,iblk), & - fsurfn_f (:,:,:,iblk), flatn_f(:,:,:,iblk), & - fresh (:,:,iblk), fhocn (:,:,iblk)) - endif -!echmod - - call ice_timer_stop(timer_couple) ! atm/ocn coupling - - end subroutine coupling_prep - -!======================================================================= -! -! If surface heat fluxes are provided to CICE instead of CICE calculating -! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can -! be provided at points which do not have ice. (This is could be due to -! the heat fluxes being calculated on a lower resolution grid or the -! heat fluxes not recalculated at every CICE timestep.) At ice free points, -! conserve energy and water by passing these fluxes to the ocean. -! -! author: A. McLaren, Met Office - - subroutine sfcflux_to_ocn(nx_block, ny_block, & - tmask, aice, & - fsurfn_f, flatn_f, & - fresh, fhocn) - - use ice_domain_size, only: ncat - - integer (kind=int_kind), intent(in) :: & - nx_block, ny_block ! block dimensions - - logical (kind=log_kind), dimension (nx_block,ny_block), intent(in) :: & - tmask ! land/boundary mask, thickness (T-cell) - - real (kind=dbl_kind), dimension(nx_block,ny_block), intent(in):: & - aice ! initial ice concentration - - real (kind=dbl_kind), dimension(nx_block,ny_block,ncat), intent(in) :: & - fsurfn_f, & ! net surface heat flux (provided as forcing) - flatn_f ! latent heat flux (provided as forcing) - - real (kind=dbl_kind), dimension(nx_block,ny_block), intent(inout):: & - fresh , & ! fresh water flux to ocean (kg/m2/s) - fhocn ! actual ocn/ice heat flx (W/m**2) - -#ifdef CICE_IN_NEMO - - ! local variables - integer (kind=int_kind) :: & - i, j, n ! horizontal indices - - real (kind=dbl_kind) :: & - puny, & ! - Lsub, & ! - rLsub ! 1/Lsub - - character(len=*), parameter :: subname = '(sfcflux_to_ocn)' - - call icepack_query_parameters(puny_out=puny, Lsub_out=Lsub) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - rLsub = c1 / Lsub - - do n = 1, ncat - do j = 1, ny_block - do i = 1, nx_block - if (tmask(i,j) .and. aice(i,j) <= puny) then - fhocn(i,j) = fhocn(i,j) & - + fsurfn_f(i,j,n) + flatn_f(i,j,n) - fresh(i,j) = fresh(i,j) & - + flatn_f(i,j,n) * rLsub - endif - enddo ! i - enddo ! j - enddo ! n - -#endif - - end subroutine sfcflux_to_ocn - -!======================================================================= - - end module CICE_RunMod - -!======================================================================= diff --git a/cicecore/drivers/mct/cesm1/CICE_InitMod.F90 b/cicecore/drivers/mct/cesm1/CICE_InitMod.F90 index 5efa18a28..b72745e30 100644 --- a/cicecore/drivers/mct/cesm1/CICE_InitMod.F90 +++ b/cicecore/drivers/mct/cesm1/CICE_InitMod.F90 @@ -15,11 +15,9 @@ module CICE_InitMod use ice_kinds_mod use ice_exit, only: abort_ice use ice_fileunits, only: init_fileunits, nu_diag - use ice_memusage, only: ice_memusage_init, ice_memusage_print use icepack_intfc, only: icepack_aggregate use icepack_intfc, only: icepack_init_itd, icepack_init_itd_hist use icepack_intfc, only: icepack_init_fsd_bounds, icepack_init_wave - use icepack_intfc, only: icepack_init_snow use icepack_intfc, only: icepack_configure use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted use icepack_intfc, only: icepack_query_parameters, icepack_query_tracer_flags, & @@ -66,20 +64,18 @@ subroutine cice_init(mpicom_ice) floe_binwidth, c_fsd_range use ice_state, only: alloc_state use ice_flux_bgc, only: alloc_flux_bgc - use ice_calendar, only: dt, dt_dyn, istep, istep1, write_ic, & - init_calendar, advance_timestep, calc_timesteps + use ice_calendar, only: dt, dt_dyn, time, istep, istep1, write_ic, & + init_calendar, calendar use ice_communicate, only: init_communicate, my_task, master_task use ice_diagnostics, only: init_diags use ice_domain, only: init_domain_blocks use ice_domain_size, only: ncat, nfsd - use ice_dyn_eap, only: init_eap - use ice_dyn_evp, only: init_evp - use ice_dyn_vp, only: init_vp - use ice_dyn_shared, only: kdyn + use ice_dyn_eap, only: init_eap, alloc_dyn_eap + use ice_dyn_shared, only: kdyn, init_evp, alloc_dyn_shared use ice_flux, only: init_coupler_flux, init_history_therm, & init_history_dyn, init_flux_atm, init_flux_ocn, alloc_flux use ice_forcing, only: init_forcing_ocn, init_forcing_atmo, & - get_forcing_atmo, get_forcing_ocn, get_wave_spec, init_snowtable + get_forcing_atmo, get_forcing_ocn, get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & faero_default, faero_optics, alloc_forcing_bgc, fiso_default use ice_grid, only: init_grid1, init_grid2, alloc_grid @@ -91,21 +87,20 @@ subroutine cice_init(mpicom_ice) use ice_restoring, only: ice_HaloRestore_init use ice_timers, only: timer_total, init_ice_timers, ice_timer_start use ice_transport_driver, only: init_transport +#ifdef popcice + use drv_forcing, only: sst_sss +#endif integer (kind=int_kind), optional, intent(in) :: & mpicom_ice ! communicator for sequential ccsm logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers, & - tr_iso, tr_fsd, wave_spec, tr_snow - character(len=char_len) :: snw_aging_table + tr_iso, tr_fsd, wave_spec character(len=*), parameter :: subname = '(cice_init)' call init_communicate(mpicom_ice) ! initial setup for message passing call init_fileunits ! unit numbers - ! tcx debug, this will create a different logfile for each pe - ! if (my_task /= master_task) nu_diag = 100+my_task - call icepack_configure() ! initialize icepack call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & @@ -115,17 +110,12 @@ subroutine cice_init(mpicom_ice) call input_zbgc ! vertical biogeochemistry namelist call count_tracers ! count tracers - ! Call this as early as possible, must be after memory_stats is read - if (my_task == master_task) then - call ice_memusage_init(nu_diag) - call ice_memusage_print(nu_diag,subname//':start') - endif - call init_domain_blocks ! set up block decomposition call init_grid1 ! domain distribution call alloc_grid ! allocate grid arrays call alloc_arrays_column ! allocate column arrays call alloc_state ! allocate state arrays + call alloc_dyn_shared ! allocate dyn shared arrays call alloc_flux_bgc ! allocate flux_bgc arrays call alloc_flux ! allocate flux arrays call init_ice_timers ! initialize all timers @@ -135,16 +125,18 @@ subroutine cice_init(mpicom_ice) call init_calendar ! initialize some calendar stuff call init_hist (dt) ! initialize output history file - if (kdyn == 1) then - call init_evp - else if (kdyn == 2) then - call init_eap ! define eap dynamics parameters, variables - else if (kdyn == 3) then - call init_vp ! define vp dynamics parameters, variables + if (kdyn == 2) then + call alloc_dyn_eap ! allocate dyn_eap arrays + call init_eap (dt_dyn) ! define eap dynamics parameters, variables + else ! for both kdyn = 0 or 1 + call init_evp (dt_dyn) ! define evp dynamics parameters, variables endif call init_coupler_flux ! initialize fluxes exchanged with coupler +#ifdef popcice + call sst_sss ! POP data for CICE initialization +#endif call init_thermo_vertical ! initialize vertical thermodynamics call icepack_init_itd(ncat=ncat, hin_max=hin_max) ! ice thickness distribution @@ -168,13 +160,15 @@ subroutine cice_init(mpicom_ice) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) + call calendar(time) ! determine the initial date + call init_forcing_ocn(dt) ! initialize sss and sst from data call init_state ! initialize the ice state call init_transport ! initialize horizontal transport call ice_HaloRestore_init ! restored boundary conditions call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers, & - wave_spec_out=wave_spec, snw_aging_table_out=snw_aging_table) + wave_spec_out=wave_spec) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) @@ -185,24 +179,26 @@ subroutine cice_init(mpicom_ice) call init_diags ! initialize diagnostic output points call init_history_therm ! initialize thermo history variables call init_history_dyn ! initialize dynamic history variables - call calc_timesteps ! update timestep counter if not using npt_unit="1" call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero) - call icepack_query_tracer_flags(tr_iso_out=tr_iso, tr_snow_out=tr_snow) + call icepack_query_tracer_flags(tr_iso_out=tr_iso) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) - if (tr_aero .or. tr_zaero) call faero_optics !initialize aerosol optical + if (tr_aero .or. tr_zaero) call faero_optics !initialize aerosol optical !property tables - ! Initialize shortwave components using swdn from previous timestep - ! if restarting. These components will be scaled to current forcing + ! Initialize shortwave components using swdn from previous timestep + ! if restarting. These components will be scaled to current forcing ! in prep_radiation. if (trim(runtype) == 'continue' .or. restart) & call init_shortwave ! initialize radiative transfer -! call advance_timestep() +! istep = istep + 1 ! update time step counters +! istep1 = istep1 + 1 +! time = time + dt ! determine the time and date +! call calendar(time) ! at the end of the first timestep !-------------------------------------------------------------------- ! coupler communication or forcing data initialization @@ -210,29 +206,21 @@ subroutine cice_init(mpicom_ice) call init_forcing_atmo ! initialize atmospheric forcing (standalone) -! if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice -! call get_forcing_atmo ! atmospheric forcing from data -! call get_forcing_ocn(dt) ! ocean forcing from data - - ! snow aging lookup table initialization - if (tr_snow) then ! advanced snow physics - call icepack_init_snow() - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - if (snw_aging_table(1:4) /= 'test') then - call init_snowtable() - endif - endif - -! ! isotopes -! if (tr_iso) call fiso_default ! default values +#ifndef coupled +#ifndef CESMCOUPLED + if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice + call get_forcing_atmo ! atmospheric forcing from data + call get_forcing_ocn(dt) ! ocean forcing from data -! ! aerosols -! ! if (tr_aero) call faero_data ! data file -! ! if (tr_zaero) call fzaero_data ! data file (gx1) -! if (tr_aero .or. tr_zaero) call faero_default ! default values -! if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry + ! isotopes + if (tr_iso) call fiso_default ! default values + ! aerosols + ! if (tr_aero) call faero_data ! data file + ! if (tr_zaero) call fzaero_data ! data file (gx1) + if (tr_aero .or. tr_zaero) call faero_default ! default values + if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry +#endif +#endif if (z_tracers) call get_atm_bgc ! biogeochemistry if (runtype == 'initial' .and. .not. restart) & @@ -241,11 +229,7 @@ subroutine cice_init(mpicom_ice) call init_flux_atm ! initialize atmosphere fluxes sent to coupler call init_flux_ocn ! initialize ocean fluxes sent to coupler - if (write_ic) call accum_hist(dt) ! write initial conditions - - if (my_task == master_task) then - call ice_memusage_print(nu_diag,subname//':end') - endif +! if (write_ic) call accum_hist(dt) ! write initial conditions end subroutine cice_init @@ -255,22 +239,22 @@ subroutine init_restart use ice_arrays_column, only: dhsn use ice_blocks, only: nx_block, ny_block - use ice_calendar, only: calendar + use ice_calendar, only: time, calendar use ice_constants, only: c0 use ice_domain, only: nblocks - use ice_domain_size, only: ncat, n_iso, n_aero, nfsd, nslyr + use ice_domain_size, only: ncat, n_iso, n_aero, nfsd use ice_dyn_eap, only: read_restart_eap use ice_dyn_shared, only: kdyn use ice_grid, only: tmask use ice_init, only: ice_ic - use ice_init_column, only: init_age, init_FY, init_lvl, init_snowtracers, & - init_meltponds_lvl, init_meltponds_topo, & + use ice_init_column, only: init_age, init_FY, init_lvl, & + init_meltponds_cesm, init_meltponds_lvl, init_meltponds_topo, & init_isotope, init_aerosol, init_hbrine, init_bgc, init_fsd use ice_restart_column, only: restart_age, read_restart_age, & restart_FY, read_restart_FY, restart_lvl, read_restart_lvl, & + restart_pond_cesm, read_restart_pond_cesm, & restart_pond_lvl, read_restart_pond_lvl, & restart_pond_topo, read_restart_pond_topo, & - restart_snow, read_restart_snow, & restart_fsd, read_restart_fsd, & restart_iso, read_restart_iso, & restart_aero, read_restart_aero, & @@ -284,14 +268,13 @@ subroutine init_restart i, j , & ! horizontal indices iblk ! block index logical(kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_pond_lvl, & - tr_pond_topo, tr_snow, tr_fsd, tr_iso, tr_aero, tr_brine, & + tr_iage, tr_FY, tr_lvl, tr_pond_cesm, tr_pond_lvl, & + tr_pond_topo, tr_fsd, tr_iso, tr_aero, tr_brine, & skl_bgc, z_tracers, solve_zsal integer(kind=int_kind) :: & ntrcr integer(kind=int_kind) :: & nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd, & - nt_smice, nt_smliq, nt_rhos, nt_rsnw, & nt_iage, nt_FY, nt_aero, nt_fsd, nt_isosno, nt_isoice character(len=*), parameter :: subname = '(init_restart)' @@ -304,23 +287,21 @@ subroutine init_restart call icepack_query_parameters(skl_bgc_out=skl_bgc, & z_tracers_out=z_tracers, solve_zsal_out=solve_zsal) call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & - tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & tr_pond_topo_out=tr_pond_topo, tr_aero_out=tr_aero, tr_brine_out=tr_brine, & - tr_snow_out=tr_snow, tr_fsd_out=tr_fsd, tr_iso_out=tr_iso) + tr_fsd_out=tr_fsd, tr_iso_out=tr_iso) call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, & nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, & nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_aero_out=nt_aero, nt_fsd_out=nt_fsd, & - nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, & - nt_rhos_out=nt_rhos, nt_rsnw_out=nt_rsnw, & nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - if (trim(runtype) == 'continue') then + if (trim(runtype) == 'continue') then ! start from core restart file call restartfile() ! given by pointer in ice_in - call calendar() ! update time parameters + call calendar(time) ! update time parameters if (kdyn == 2) call read_restart_eap ! EAP else if (restart) then ! ice_ic = core restart file call restartfile (ice_ic) ! or 'default' or 'none' @@ -328,17 +309,17 @@ subroutine init_restart ! call restartfile_v4 (ice_ic) ! CICE v4.1 binary restart file !!! uncomment if EAP restart data exists ! if (kdyn == 2) call read_restart_eap - endif + endif ! tracers - ! ice age tracer - if (tr_iage) then + ! ice age tracer + if (tr_iage) then if (trim(runtype) == 'continue') & restart_age = .true. if (restart_age) then call read_restart_age else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_age(trcrn(:,:,nt_iage,:,iblk)) enddo ! iblk endif @@ -349,7 +330,7 @@ subroutine init_restart if (restart_FY) then call read_restart_FY else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_FY(trcrn(:,:,nt_FY,:,iblk)) enddo ! iblk endif @@ -360,12 +341,25 @@ subroutine init_restart if (restart_lvl) then call read_restart_lvl else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_lvl(iblk,trcrn(:,:,nt_alvl,:,iblk), & trcrn(:,:,nt_vlvl,:,iblk)) enddo ! iblk endif endif + ! CESM melt ponds + if (tr_pond_cesm) then + if (trim(runtype) == 'continue') & + restart_pond_cesm = .true. + if (restart_pond_cesm) then + call read_restart_pond_cesm + else + do iblk = 1, nblocks + call init_meltponds_cesm(trcrn(:,:,nt_apnd,:,iblk), & + trcrn(:,:,nt_hpnd,:,iblk)) + enddo ! iblk + endif + endif ! level-ice melt ponds if (tr_pond_lvl) then if (trim(runtype) == 'continue') & @@ -373,7 +367,7 @@ subroutine init_restart if (restart_pond_lvl) then call read_restart_pond_lvl else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_meltponds_lvl(trcrn(:,:,nt_apnd,:,iblk), & trcrn(:,:,nt_hpnd,:,iblk), & trcrn(:,:,nt_ipnd,:,iblk), & @@ -388,29 +382,13 @@ subroutine init_restart if (restart_pond_topo) then call read_restart_pond_topo else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_meltponds_topo(trcrn(:,:,nt_apnd,:,iblk), & trcrn(:,:,nt_hpnd,:,iblk), & trcrn(:,:,nt_ipnd,:,iblk)) enddo ! iblk endif ! .not. restart_pond endif - - ! snow redistribution/metamorphism - if (tr_snow) then - if (trim(runtype) == 'continue') restart_snow = .true. - if (restart_snow) then - call read_restart_snow - else - do iblk = 1, nblocks - call init_snowtracers(trcrn(:,:,nt_smice:nt_smice+nslyr-1,:,iblk), & - trcrn(:,:,nt_smliq:nt_smliq+nslyr-1,:,iblk), & - trcrn(:,:,nt_rhos :nt_rhos +nslyr-1,:,iblk), & - trcrn(:,:,nt_rsnw :nt_rsnw +nslyr-1,:,iblk)) - enddo ! iblk - endif - endif - ! floe size distribution if (tr_fsd) then if (trim(runtype) == 'continue') restart_fsd = .true. @@ -427,7 +405,7 @@ subroutine init_restart if (restart_iso) then call read_restart_iso else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_isotope(trcrn(:,:,nt_isosno:nt_isosno+n_iso-1,:,iblk), & trcrn(:,:,nt_isoice:nt_isoice+n_iso-1,:,iblk)) enddo ! iblk @@ -439,7 +417,7 @@ subroutine init_restart if (restart_aero) then call read_restart_aero else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_aerosol(trcrn(:,:,nt_aero:nt_aero+4*n_aero-1,:,iblk)) enddo ! iblk endif ! .not. restart_aero diff --git a/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 b/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 index 5836479b4..09cffa0c7 100644 --- a/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 +++ b/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 @@ -7,7 +7,7 @@ ! William H. Lipscomb, LANL ! ! 2006 ECH: moved exit timeLoop to prevent execution of unnecessary timestep -! 2006 ECH: Streamlined for efficiency +! 2006 ECH: Streamlined for efficiency ! 2006 ECH: Converted to free source form (F90) ! 2007 BPB: Modified Delta-Eddington shortwave interface ! 2008 ECH: moved ESMF code to its own driver @@ -15,18 +15,16 @@ module CICE_RunMod use ice_kinds_mod - use ice_communicate, only: my_task, master_task + use perf_mod, only : t_startf, t_stopf, t_barrierf use ice_fileunits, only: nu_diag use ice_arrays_column, only: oceanmixed_ice use ice_constants, only: c0, c1 use ice_constants, only: field_loc_center, field_type_scalar use ice_exit, only: abort_ice - use ice_memusage, only: ice_memusage_print use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted use icepack_intfc, only: icepack_max_iso, icepack_max_aero use icepack_intfc, only: icepack_query_parameters use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_sizes - use perf_mod, only : t_startf, t_stopf, t_barrierf implicit none private @@ -46,7 +44,7 @@ module CICE_RunMod subroutine CICE_Run - use ice_calendar, only: istep, istep1, dt, stop_now, advance_timestep + use ice_calendar, only: istep, istep1, time, dt, stop_now, calendar use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & @@ -75,42 +73,58 @@ subroutine CICE_Run if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) -! tcraig, use advance_timestep now -! istep = istep + 1 ! update time step counters -! istep1 = istep1 + 1 -! time = time + dt ! determine the time and date + !-------------------------------------------------------------------- + ! timestep loop + !-------------------------------------------------------------------- + +! timeLoop: do + +! call ice_step + + istep = istep + 1 ! update time step counters + istep1 = istep1 + 1 + time = time + dt ! determine the time and date + ! call calendar(time) ! at the end of the timestep - call advance_timestep() ! advance time call ice_timer_start(timer_couple) ! atm/ocn coupling +#ifndef coupled +#ifndef CESMCOUPLED ! for now, wave_spectrum is constant in time ! if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice -! call get_forcing_atmo ! atmospheric forcing from data -! call get_forcing_ocn(dt) ! ocean forcing from data - -! ! isotopes -! if (tr_iso) call fiso_default ! default values -! ! aerosols -! ! if (tr_aero) call faero_data ! data file -! ! if (tr_zaero) call fzaero_data ! data file (gx1) -! if (tr_aero .or. tr_zaero) call faero_default ! default values - -! if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry + call get_forcing_atmo ! atmospheric forcing from data + call get_forcing_ocn(dt) ! ocean forcing from data + + ! isotopes + if (tr_iso) call fiso_default ! default values + ! aerosols + ! if (tr_aero) call faero_data ! data file + ! if (tr_zaero) call fzaero_data ! data file (gx1) + if (tr_aero .or. tr_zaero) call faero_default ! default values + + if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry +#endif +#endif if (z_tracers) call get_atm_bgc ! biogeochemistry call init_flux_atm ! Initialize atmosphere fluxes sent to coupler call init_flux_ocn ! initialize ocean fluxes sent to coupler + call calendar(time) ! at the end of the timestep + call ice_timer_stop(timer_couple) ! atm/ocn coupling call ice_step +! if (stop_now >= 1) exit timeLoop +! enddo timeLoop + !-------------------------------------------------------------------- ! end of timestep loop !-------------------------------------------------------------------- - call ice_timer_stop(timer_step) ! end timestepping loop timer + call ice_timer_stop(timer_step) ! end timestepping loop timer end subroutine CICE_Run @@ -125,8 +139,8 @@ subroutine ice_step use ice_boundary, only: ice_HaloUpdate use ice_calendar, only: dt, dt_dyn, ndtd, diagfreq, write_restart, istep - use ice_calendar, only: idate, msec - use ice_diagnostics, only: init_mass_diags, runtime_diags, debug_model, debug_ice + use ice_calendar, only: idate, sec + use ice_diagnostics, only: init_mass_diags, runtime_diags use ice_diagnostics_bgc, only: hbrine_diags, zsal_diags, bgc_diags use ice_domain, only: halo_info, nblocks use ice_dyn_eap, only: write_restart_eap @@ -137,15 +151,14 @@ subroutine ice_step use ice_history_bgc, only: init_history_bgc use ice_restart, only: final_restart use ice_restart_column, only: write_restart_age, write_restart_FY, & - write_restart_lvl, write_restart_pond_lvl, & + write_restart_lvl, write_restart_pond_cesm, write_restart_pond_lvl, & write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_iso, write_restart_bgc, write_restart_hbrine, & - write_restart_snow + write_restart_iso, write_restart_bgc, write_restart_hbrine use ice_restart_driver, only: dumpfile use ice_restoring, only: restore_ice, ice_HaloRestore use ice_step_mod, only: prep_radiation, step_therm1, step_therm2, & update_state, step_dyn_horiz, step_dyn_ridge, step_radiation, & - biogeochemistry, step_prep, step_dyn_wave, step_snow + biogeochemistry, save_init, step_dyn_wave use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_diags, timer_column, timer_thermo, timer_bound, & timer_hist, timer_readwrite @@ -153,7 +166,7 @@ subroutine ice_step use ice_prescribed_mod integer (kind=int_kind) :: & - iblk , & ! block index + iblk , & ! block index k , & ! dynamics supercycling index ktherm ! thermodynamics is off when ktherm = -1 @@ -161,28 +174,19 @@ subroutine ice_step offset ! d(age)/dt time offset logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_fsd, tr_snow, & - tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, & + tr_iage, tr_FY, tr_lvl, tr_fsd, & + tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, & calc_Tsfc, skl_bgc, solve_zsal, z_tracers, wave_spec character(len=*), parameter :: subname = '(ice_step)' - character (len=char_len) :: plabeld - - if (debug_model) then - plabeld = 'beginning time step' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - endif - call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc, skl_bgc_out=skl_bgc, & solve_zsal_out=solve_zsal, z_tracers_out=z_tracers, ktherm_out=ktherm, & wave_spec_out=wave_spec) call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & - tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_iso_out=tr_iso, tr_fsd_out=tr_fsd, tr_snow_out=tr_snow) + tr_iso_out=tr_iso, tr_fsd_out=tr_fsd) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) @@ -203,21 +207,22 @@ subroutine ice_step call init_history_bgc call ice_timer_stop(timer_diags) ! diagnostics/history - call ice_timer_start(timer_column) ! column physics - call ice_timer_start(timer_thermo) ! thermodynamics - if (prescribed_ice) then ! read prescribed ice call t_barrierf('cice_run_presc_BARRIER',MPI_COMM_ICE) call t_startf ('cice_run_presc') - call ice_prescribed_run(idate, msec) + call ice_prescribed_run(idate, sec) call t_stopf ('cice_run_presc') endif - call step_prep + call save_init - if (ktherm >= 0) then - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) - do iblk = 1, nblocks + call ice_timer_start(timer_column) ! column physics + call ice_timer_start(timer_thermo) ! thermodynamics + + !$OMP PARALLEL DO PRIVATE(iblk) + do iblk = 1, nblocks + + if (ktherm >= 0) then !----------------------------------------------------------------- ! scale radiation fields @@ -225,39 +230,19 @@ subroutine ice_step if (calc_Tsfc) call prep_radiation (iblk) - if (debug_model) then - plabeld = 'post prep_radiation' - call debug_ice (iblk, plabeld) - endif - !----------------------------------------------------------------- ! thermodynamics and biogeochemistry !----------------------------------------------------------------- - + call step_therm1 (dt, iblk) ! vertical thermodynamics - - if (debug_model) then - plabeld = 'post step_therm1' - call debug_ice (iblk, plabeld) - endif - call biogeochemistry (dt, iblk) ! biogeochemistry + if (.not.prescribed_ice) & + call step_therm2 (dt, iblk) ! ice thickness distribution thermo - if (debug_model) then - plabeld = 'post biogeochemistry' - call debug_ice (iblk, plabeld) - endif - - call step_therm2 (dt, iblk) ! ice thickness distribution thermo - - if (debug_model) then - plabeld = 'post step_therm2' - call debug_ice (iblk, plabeld) - endif + endif ! ktherm > 0 - enddo - !$OMP END PARALLEL DO - endif ! ktherm > 0 + enddo ! iblk + !$OMP END PARALLEL DO ! clean up, update tendency diagnostics offset = dt @@ -270,6 +255,8 @@ subroutine ice_step ! dynamics, transport, ridging !----------------------------------------------------------------- + if (.not.prescribed_ice) then + ! wave fracture of the floe size distribution ! note this is called outside of the dynamics subcycling loop if (tr_fsd .and. wave_spec) call step_dyn_wave(dt) @@ -279,81 +266,40 @@ subroutine ice_step ! momentum, stress, transport call step_dyn_horiz (dt_dyn) - if (debug_model) then - plabeld = 'post step_dyn_horiz' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo ! iblk - endif - ! ridging - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) + !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks if (kridge > 0) call step_dyn_ridge (dt_dyn, ndtd, iblk) enddo !$OMP END PARALLEL DO - if (debug_model) then - plabeld = 'post step_dyn_ridge' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo ! iblk - endif - ! clean up, update tendency diagnostics offset = c0 call update_state (dt_dyn, daidtd, dvidtd, dagedtd, offset) enddo - if (debug_model) then - plabeld = 'post dynamics' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - endif - - call ice_timer_start(timer_column) ! column physics - call ice_timer_start(timer_thermo) ! thermodynamics + endif ! not prescribed ice !----------------------------------------------------------------- - ! snow redistribution and metamorphosis + ! albedo, shortwave radiation !----------------------------------------------------------------- - if (tr_snow) then ! advanced snow physics - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) - do iblk = 1, nblocks - call step_snow (dt, iblk) - enddo - !$OMP END PARALLEL DO - call update_state (dt) ! clean up - endif + call ice_timer_start(timer_column) ! column physics + call ice_timer_start(timer_thermo) ! thermodynamics - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) +!MHRI: CHECK THIS OMP + !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks - !----------------------------------------------------------------- - ! albedo, shortwave radiation - !----------------------------------------------------------------- - if (ktherm >= 0) call step_radiation (dt, iblk) - if (debug_model) then - plabeld = 'post step_radiation' - call debug_ice (iblk, plabeld) - endif - !----------------------------------------------------------------- ! get ready for coupling and the next time step !----------------------------------------------------------------- call coupling_prep (iblk) - if (debug_model) then - plabeld = 'post coupling_prep' - call debug_ice (iblk, plabeld) - endif - enddo ! iblk !$OMP END PARALLEL DO @@ -375,9 +321,6 @@ subroutine ice_step if (solve_zsal) call zsal_diags if (skl_bgc .or. z_tracers) call bgc_diags if (tr_brine) call hbrine_diags - if (my_task == master_task) then - call ice_memusage_print(nu_diag,subname) - endif endif call ice_timer_stop(timer_diags) ! diagnostics @@ -391,22 +334,23 @@ subroutine ice_step if (tr_iage) call write_restart_age if (tr_FY) call write_restart_FY if (tr_lvl) call write_restart_lvl + if (tr_pond_cesm) call write_restart_pond_cesm if (tr_pond_lvl) call write_restart_pond_lvl if (tr_pond_topo) call write_restart_pond_topo - if (tr_snow) call write_restart_snow if (tr_fsd) call write_restart_fsd if (tr_iso) call write_restart_iso if (tr_aero) call write_restart_aero if (solve_zsal .or. skl_bgc .or. z_tracers) & - call write_restart_bgc + call write_restart_bgc if (tr_brine) call write_restart_hbrine if (kdyn == 2) call write_restart_eap call final_restart endif + call ice_timer_stop(timer_readwrite) ! reading/writing end subroutine ice_step - + !======================================================================= ! ! Prepare for coupling @@ -425,13 +369,12 @@ subroutine coupling_prep (iblk) albpnd, albcnt, apeff_ai, fpond, fresh, l_mpond_fresh, & alvdf_ai, alidf_ai, alvdr_ai, alidr_ai, fhocn_ai, & fresh_ai, fsalt_ai, fsalt, & - fswthru_ai, fhocn, scale_factor, snowfrac, & - fswthru, fswthru_vdr, fswthru_vdf, fswthru_idr, fswthru_idf, & + fswthru_ai, fhocn, fswthru, scale_factor, snowfrac, & swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyT, & fsens, flat, fswabs, flwout, evap, Tref, Qref, & scale_fluxes, frzmlt_init, frzmlt, Uref, wind use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, & - fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai, & + fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai fnit, fsil, famm, fdmsp, fdms, fhum, fdust, falgalN, & fdoc, fdic, fdon, ffep, ffed, bgcflux_ice_to_ocn use ice_grid, only: tmask @@ -441,12 +384,12 @@ subroutine coupling_prep (iblk) use ice_step_mod, only: ocean_mixed_layer use ice_timers, only: timer_couple, ice_timer_start, ice_timer_stop - integer (kind=int_kind), intent(in) :: & - iblk ! block index + integer (kind=int_kind), intent(in) :: & + iblk ! block index ! local variables - integer (kind=int_kind) :: & + integer (kind=int_kind) :: & ilo,ihi,jlo,jhi, & ! beginning and end of physical domain n , & ! thickness category index i,j , & ! horizontal indices @@ -468,6 +411,8 @@ subroutine coupling_prep (iblk) character(len=*), parameter :: subname = '(coupling_prep)' + !----------------------------------------------------------------- + call icepack_query_parameters(puny_out=puny, rhofresh_out=rhofresh) call icepack_query_parameters(skl_bgc_out=skl_bgc) call icepack_query_tracer_sizes(nbtrcr_out=nbtrcr) @@ -584,8 +529,8 @@ subroutine coupling_prep (iblk) fsalt_ai (i,j,iblk) = fsalt (i,j,iblk) fhocn_ai (i,j,iblk) = fhocn (i,j,iblk) fswthru_ai(i,j,iblk) = fswthru(i,j,iblk) - fzsal_ai (i,j,iblk) = fzsal (i,j,iblk) - fzsal_g_ai(i,j,iblk) = fzsal_g(i,j,iblk) + fzsal_ai (i,j,iblk) = fzsal (i,j,iblk) + fzsal_g_ai(i,j,iblk) = fzsal_g(i,j,iblk) if (nbtrcr > 0) then do k = 1, nbtrcr @@ -606,7 +551,7 @@ subroutine coupling_prep (iblk) enddo !----------------------------------------------------------------- - ! Divide fluxes by ice area + ! Divide fluxes by ice area ! - the CESM coupler assumes fluxes are per unit ice area ! - also needed for global budget in diagnostics !----------------------------------------------------------------- @@ -622,12 +567,7 @@ subroutine coupling_prep (iblk) evap (:,:,iblk), & Tref (:,:,iblk), Qref (:,:,iblk), & fresh (:,:,iblk), fsalt (:,:,iblk), & - fhocn (:,:,iblk), & - fswthru (:,:,iblk), & - fswthru_vdr (:,:,iblk), & - fswthru_vdf (:,:,iblk), & - fswthru_idr (:,:,iblk), & - fswthru_idf (:,:,iblk), & + fhocn (:,:,iblk), fswthru (:,:,iblk), & faero_ocn(:,:,:,iblk), & alvdr (:,:,iblk), alidr (:,:,iblk), & alvdf (:,:,iblk), alidf (:,:,iblk), & @@ -637,6 +577,10 @@ subroutine coupling_prep (iblk) fiso_evap=fiso_evap(:,:,:,iblk), & fiso_ocn =fiso_ocn (:,:,:,iblk), & Uref=Uref(:,:,iblk), wind=wind(:,:,iblk) ) + + !----------------------------------------------------------------- + ! Define ice-ocean bgc fluxes + !----------------------------------------------------------------- if (nbtrcr > 0 .or. skl_bgc) then call bgcflux_ice_to_ocn (nx_block, ny_block, & @@ -654,29 +598,28 @@ subroutine coupling_prep (iblk) if (.not. calc_Tsfc) then !--------------------------------------------------------------- - ! If surface fluxes were provided, conserve these fluxes at ice - ! free points by passing to ocean. + ! If surface fluxes were provided, conserve these fluxes at ice + ! free points by passing to ocean. !--------------------------------------------------------------- - call sfcflux_to_ocn & + call sfcflux_to_ocn & (nx_block, ny_block, & tmask (:,:,iblk), aice_init(:,:,iblk), & fsurfn_f (:,:,:,iblk), flatn_f(:,:,:,iblk), & fresh (:,:,iblk), fhocn (:,:,iblk)) - endif + endif !echmod call ice_timer_stop(timer_couple,iblk) ! atm/ocn coupling end subroutine coupling_prep - !======================================================================= ! ! If surface heat fluxes are provided to CICE instead of CICE calculating -! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can +! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can ! be provided at points which do not have ice. (This is could be due to ! the heat fluxes being calculated on a lower resolution grid or the -! heat fluxes not recalculated at every CICE timestep.) At ice free points, +! heat fluxes not recalculated at every CICE timestep.) At ice free points, ! conserve energy and water by passing these fluxes to the ocean. ! ! author: A. McLaren, Met Office @@ -705,19 +648,19 @@ subroutine sfcflux_to_ocn(nx_block, ny_block, & fresh , & ! fresh water flux to ocean (kg/m2/s) fhocn ! actual ocn/ice heat flx (W/m**2) +#ifdef CICE_IN_NEMO ! local variables integer (kind=int_kind) :: & i, j, n ! horizontal indices - + real (kind=dbl_kind) :: & puny, & ! - Lsub, & ! rLsub ! 1/Lsub character(len=*), parameter :: subname = '(sfcflux_to_ocn)' - call icepack_query_parameters(puny_out=puny, Lsub_out=Lsub) + call icepack_query_parameters(puny_out=puny) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) @@ -736,6 +679,7 @@ subroutine sfcflux_to_ocn(nx_block, ny_block, & enddo ! j enddo ! n +#endif end subroutine sfcflux_to_ocn diff --git a/cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90 b/cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90 index 270e7b371..b72745e30 100644 --- a/cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90 +++ b/cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90 @@ -1,467 +1,493 @@ -module CICE_InitMod +!======================================================================= +! +! This module contains the CICE initialization routine that sets model +! parameters and initializes the grid and CICE state variables. +! +! authors Elizabeth C. Hunke, LANL +! William H. Lipscomb, LANL +! Philip W. Jones, LANL +! +! 2006: Converted to free form source (F90) by Elizabeth Hunke +! 2008: E. Hunke moved ESMF code to its own driver + + module CICE_InitMod + + use ice_kinds_mod + use ice_exit, only: abort_ice + use ice_fileunits, only: init_fileunits, nu_diag + use icepack_intfc, only: icepack_aggregate + use icepack_intfc, only: icepack_init_itd, icepack_init_itd_hist + use icepack_intfc, only: icepack_init_fsd_bounds, icepack_init_wave + use icepack_intfc, only: icepack_configure + use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted + use icepack_intfc, only: icepack_query_parameters, icepack_query_tracer_flags, & + icepack_query_tracer_indices, icepack_query_tracer_sizes + + implicit none + private + public :: CICE_Initialize, cice_init - ! Initialize CICE model. +!======================================================================= - use ice_kinds_mod - use ice_exit , only: abort_ice - use ice_fileunits, only: init_fileunits, nu_diag - use icepack_intfc, only: icepack_aggregate - use icepack_intfc, only: icepack_init_itd, icepack_init_itd_hist - use icepack_intfc, only: icepack_init_fsd_bounds, icepack_init_wave - use icepack_intfc, only: icepack_init_snow - use icepack_intfc, only: icepack_configure - use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted - use icepack_intfc, only: icepack_query_parameters, icepack_query_tracer_flags - use icepack_intfc, only: icepack_query_tracer_indices, icepack_query_tracer_sizes + contains - implicit none - private - public :: cice_init1 - public :: cice_init2 +!======================================================================= - private :: init_restart +! Initialize the basic state, grid and all necessary parameters for +! running the CICE model. Return the initial state in routine +! export state. +! Note: This initialization driver is designed for standalone and +! CESM-coupled applications. For other +! applications (e.g., standalone CAM), this driver would be +! replaced by a different driver that calls subroutine cice_init, +! where most of the work is done. -!======================================================================= -contains -!======================================================================= + subroutine CICE_Initialize + + character(len=*), parameter :: subname='(CICE_Initialize)' + !-------------------------------------------------------------------- + ! model initialization + !-------------------------------------------------------------------- + + call cice_init - subroutine cice_init1() - - ! Initialize the basic state, grid and all necessary parameters for - ! running the CICE model. - - use ice_init , only: input_data - use ice_init_column , only: input_zbgc, count_tracers - use ice_grid , only: init_grid1, alloc_grid - use ice_domain , only: init_domain_blocks - use ice_arrays_column , only: alloc_arrays_column - use ice_state , only: alloc_state - use ice_flux_bgc , only: alloc_flux_bgc - use ice_flux , only: alloc_flux - use ice_timers , only: timer_total, init_ice_timers, ice_timer_start - - character(len=*), parameter :: subname = '(cice_init1)' - !---------------------------------------------------- - - call init_fileunits ! unit numbers - call icepack_configure() ! initialize icepack - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(trim(subname), & - file=__FILE__,line= __LINE__) - - call input_data ! namelist variables - call input_zbgc ! vertical biogeochemistry namelist - call count_tracers ! count tracers - - call init_domain_blocks ! set up block decomposition - call init_grid1 ! domain distribution - call alloc_grid ! allocate grid arrays - call alloc_arrays_column ! allocate column arrays - call alloc_state ! allocate state arrays - call alloc_flux_bgc ! allocate flux_bgc arrays - call alloc_flux ! allocate flux arrays - call init_ice_timers ! initialize all timers - call ice_timer_start(timer_total) ! start timing entire run - - end subroutine cice_init1 - - !======================================================================= - subroutine cice_init2() - - ! Initialize the basic state, and all necessary parameters for - ! running the CICE model. - - use ice_arrays_column , only: hin_max, c_hi_range - use ice_arrays_column , only: floe_rad_l, floe_rad_c, floe_binwidth, c_fsd_range - use ice_calendar , only: dt, dt_dyn, istep, istep1, write_ic, init_calendar, calendar - use ice_communicate , only: my_task, master_task - use ice_diagnostics , only: init_diags - use ice_domain_size , only: ncat, nfsd, nfreq - use ice_dyn_eap , only: init_eap - use ice_dyn_evp , only: init_evp - use ice_dyn_vp , only: init_vp - use ice_dyn_shared , only: kdyn - use ice_flux , only: init_coupler_flux, init_history_therm - use ice_flux , only: init_history_dyn, init_flux_atm, init_flux_ocn - use ice_forcing , only: init_snowtable - use ice_forcing_bgc , only: get_forcing_bgc, get_atm_bgc - use ice_forcing_bgc , only: faero_default, faero_optics, alloc_forcing_bgc, fiso_default - use ice_history , only: init_hist, accum_hist - use ice_restart_shared , only: restart, runtype - use ice_init , only: input_data, init_state - use ice_init_column , only: init_thermo_vertical, init_shortwave, init_zbgc - use ice_restoring , only: ice_HaloRestore_init - use ice_timers , only: timer_total, init_ice_timers, ice_timer_start - use ice_transport_driver , only: init_transport - use ice_arrays_column , only: wavefreq, dwavefreq - - logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers - logical(kind=log_kind) :: tr_iso, tr_fsd, wave_spec, tr_snow - character(len=char_len) :: snw_aging_table - real(kind=dbl_kind), dimension(25) :: wave_spectrum_profile ! hardwire for now - character(len=*), parameter :: subname = '(cice_init2)' - !---------------------------------------------------- - - call init_zbgc ! vertical biogeochemistry initialization - call init_calendar ! initialize some calendar stuff - call init_hist (dt) ! initialize output history file - - if (kdyn == 1) then - call init_evp ! define evp dynamics parameters, variables - elseif (kdyn == 2) then - call init_eap ! define eap dynamics parameters, variables - else if (kdyn == 3) then - call init_vp ! define vp dynamics parameters, variables - endif - - call init_coupler_flux ! initialize fluxes exchanged with coupler - call init_thermo_vertical ! initialize vertical thermodynamics - - call icepack_init_itd(ncat=ncat, hin_max=hin_max) ! ice thickness distribution - if (my_task == master_task) then - call icepack_init_itd_hist(ncat=ncat, hin_max=hin_max, c_hi_range=c_hi_range) ! output - endif - - call icepack_query_tracer_flags(tr_fsd_out=tr_fsd) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(trim(subname), & - file=__FILE__,line= __LINE__) - - if (tr_fsd) call icepack_init_fsd_bounds (nfsd, & ! floe size distribution + end subroutine CICE_Initialize + +!======================================================================= +! +! Initialize CICE model. + + subroutine cice_init(mpicom_ice) + + use ice_arrays_column, only: hin_max, c_hi_range, alloc_arrays_column + use ice_arrays_column, only: floe_rad_l, floe_rad_c, & + floe_binwidth, c_fsd_range + use ice_state, only: alloc_state + use ice_flux_bgc, only: alloc_flux_bgc + use ice_calendar, only: dt, dt_dyn, time, istep, istep1, write_ic, & + init_calendar, calendar + use ice_communicate, only: init_communicate, my_task, master_task + use ice_diagnostics, only: init_diags + use ice_domain, only: init_domain_blocks + use ice_domain_size, only: ncat, nfsd + use ice_dyn_eap, only: init_eap, alloc_dyn_eap + use ice_dyn_shared, only: kdyn, init_evp, alloc_dyn_shared + use ice_flux, only: init_coupler_flux, init_history_therm, & + init_history_dyn, init_flux_atm, init_flux_ocn, alloc_flux + use ice_forcing, only: init_forcing_ocn, init_forcing_atmo, & + get_forcing_atmo, get_forcing_ocn, get_wave_spec + use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & + faero_default, faero_optics, alloc_forcing_bgc, fiso_default + use ice_grid, only: init_grid1, init_grid2, alloc_grid + use ice_history, only: init_hist, accum_hist + use ice_restart_shared, only: restart, runtype + use ice_init, only: input_data, init_state + use ice_init_column, only: init_thermo_vertical, init_shortwave, init_zbgc, input_zbgc, count_tracers + use ice_kinds_mod + use ice_restoring, only: ice_HaloRestore_init + use ice_timers, only: timer_total, init_ice_timers, ice_timer_start + use ice_transport_driver, only: init_transport +#ifdef popcice + use drv_forcing, only: sst_sss +#endif + + integer (kind=int_kind), optional, intent(in) :: & + mpicom_ice ! communicator for sequential ccsm + + logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers, & + tr_iso, tr_fsd, wave_spec + character(len=*), parameter :: subname = '(cice_init)' + + call init_communicate(mpicom_ice) ! initial setup for message passing + call init_fileunits ! unit numbers + + call icepack_configure() ! initialize icepack + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(trim(subname), & + file=__FILE__,line= __LINE__) + + call input_data ! namelist variables + call input_zbgc ! vertical biogeochemistry namelist + call count_tracers ! count tracers + + call init_domain_blocks ! set up block decomposition + call init_grid1 ! domain distribution + call alloc_grid ! allocate grid arrays + call alloc_arrays_column ! allocate column arrays + call alloc_state ! allocate state arrays + call alloc_dyn_shared ! allocate dyn shared arrays + call alloc_flux_bgc ! allocate flux_bgc arrays + call alloc_flux ! allocate flux arrays + call init_ice_timers ! initialize all timers + call ice_timer_start(timer_total) ! start timing entire run + call init_grid2 ! grid variables + call init_zbgc ! vertical biogeochemistry initialization + call init_calendar ! initialize some calendar stuff + call init_hist (dt) ! initialize output history file + + if (kdyn == 2) then + call alloc_dyn_eap ! allocate dyn_eap arrays + call init_eap (dt_dyn) ! define eap dynamics parameters, variables + else ! for both kdyn = 0 or 1 + call init_evp (dt_dyn) ! define evp dynamics parameters, variables + endif + + call init_coupler_flux ! initialize fluxes exchanged with coupler + +#ifdef popcice + call sst_sss ! POP data for CICE initialization +#endif + call init_thermo_vertical ! initialize vertical thermodynamics + + call icepack_init_itd(ncat=ncat, hin_max=hin_max) ! ice thickness distribution + if (my_task == master_task) then + call icepack_init_itd_hist(ncat=ncat, hin_max=hin_max, c_hi_range=c_hi_range) ! output + endif + + call icepack_query_tracer_flags(tr_fsd_out=tr_fsd) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(trim(subname), & + file=__FILE__,line= __LINE__) + + if (tr_fsd) call icepack_init_fsd_bounds (nfsd, & ! floe size distribution floe_rad_l, & ! fsd size lower bound in m (radius) floe_rad_c, & ! fsd size bin centre in m (radius) floe_binwidth, & ! fsd size bin width in m (radius) c_fsd_range, & ! string for history output write_diags=(my_task == master_task)) ! write diag on master only - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - call calendar() ! determine the initial date + call calendar(time) ! determine the initial date - call init_state ! initialize the ice state - call init_transport ! initialize horizontal transport - call ice_HaloRestore_init ! restored boundary conditions + call init_forcing_ocn(dt) ! initialize sss and sst from data + call init_state ! initialize the ice state + call init_transport ! initialize horizontal transport + call ice_HaloRestore_init ! restored boundary conditions - call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers, & - wave_spec_out=wave_spec, snw_aging_table_out=snw_aging_table) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(trim(subname), & - file=__FILE__,line= __LINE__) + call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers, & + wave_spec_out=wave_spec) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(trim(subname), & + file=__FILE__,line= __LINE__) - if (skl_bgc .or. z_tracers) call alloc_forcing_bgc ! allocate biogeochemistry arrays + if (skl_bgc .or. z_tracers) call alloc_forcing_bgc ! allocate biogeochemistry arrays - call init_restart ! initialize restart variables - call init_diags ! initialize diagnostic output points - call init_history_therm ! initialize thermo history variables - call init_history_dyn ! initialize dynamic history variables + call init_restart ! initialize restart variables + call init_diags ! initialize diagnostic output points + call init_history_therm ! initialize thermo history variables + call init_history_dyn ! initialize dynamic history variables - call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero) - call icepack_query_tracer_flags(tr_iso_out=tr_iso, tr_snow_out=tr_snow) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(trim(subname), & - file=__FILE__,line= __LINE__) + call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero) + call icepack_query_tracer_flags(tr_iso_out=tr_iso) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(trim(subname), & + file=__FILE__,line= __LINE__) - if (tr_aero .or. tr_zaero) then - call faero_optics !initialize aerosol optical property tables - end if + if (tr_aero .or. tr_zaero) call faero_optics !initialize aerosol optical + !property tables - ! snow aging lookup table initialization - if (tr_snow) then ! advanced snow physics - call icepack_init_snow() - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - if (snw_aging_table(1:4) /= 'test') then - call init_snowtable() - endif - endif - - if (wave_spec) then - call icepack_init_wave(nfreq=nfreq, & - wave_spectrum_profile=wave_spectrum_profile, wavefreq=wavefreq, dwavefreq=dwavefreq) - end if - - ! Initialize shortwave components using swdn from previous timestep - ! if restarting. These components will be scaled to current forcing - ! in prep_radiation. - - if (trim(runtype) == 'continue' .or. restart) then - call init_shortwave ! initialize radiative transfer - end if - - !-------------------------------------------------------------------- - ! coupler communication or forcing data initialization - !-------------------------------------------------------------------- - - if (z_tracers) call get_atm_bgc ! biogeochemistry - - if (runtype == 'initial' .and. .not. restart) then - call init_shortwave ! initialize radiative transfer using current swdn - end if - - call init_flux_atm ! initialize atmosphere fluxes sent to coupler - call init_flux_ocn ! initialize ocean fluxes sent to coupler - - end subroutine cice_init2 - - !======================================================================= - - subroutine init_restart() - - use ice_arrays_column, only: dhsn - use ice_blocks, only: nx_block, ny_block - use ice_calendar, only: calendar - use ice_constants, only: c0 - use ice_domain, only: nblocks - use ice_domain_size, only: ncat, n_iso, n_aero, nfsd, nslyr - use ice_dyn_eap, only: read_restart_eap - use ice_dyn_shared, only: kdyn - use ice_grid, only: tmask - use ice_init, only: ice_ic - use ice_init_column, only: init_age, init_FY, init_lvl, init_snowtracers, & - init_meltponds_lvl, init_meltponds_topo, & - init_isotope, init_aerosol, init_hbrine, init_bgc, init_fsd - use ice_restart_column, only: restart_age, read_restart_age, & - restart_FY, read_restart_FY, restart_lvl, read_restart_lvl, & - restart_pond_lvl, read_restart_pond_lvl, & - restart_pond_topo, read_restart_pond_topo, & - restart_snow, read_restart_snow, & - restart_fsd, read_restart_fsd, & - restart_iso, read_restart_iso, & - restart_aero, read_restart_aero, & - restart_hbrine, read_restart_hbrine, & - restart_bgc - use ice_restart_driver, only: restartfile - use ice_restart_shared, only: runtype, restart - use ice_state ! almost everything - - integer(kind=int_kind) :: & + ! Initialize shortwave components using swdn from previous timestep + ! if restarting. These components will be scaled to current forcing + ! in prep_radiation. + if (trim(runtype) == 'continue' .or. restart) & + call init_shortwave ! initialize radiative transfer + +! istep = istep + 1 ! update time step counters +! istep1 = istep1 + 1 +! time = time + dt ! determine the time and date +! call calendar(time) ! at the end of the first timestep + + !-------------------------------------------------------------------- + ! coupler communication or forcing data initialization + !-------------------------------------------------------------------- + + call init_forcing_atmo ! initialize atmospheric forcing (standalone) + +#ifndef coupled +#ifndef CESMCOUPLED + if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice + call get_forcing_atmo ! atmospheric forcing from data + call get_forcing_ocn(dt) ! ocean forcing from data + + ! isotopes + if (tr_iso) call fiso_default ! default values + ! aerosols + ! if (tr_aero) call faero_data ! data file + ! if (tr_zaero) call fzaero_data ! data file (gx1) + if (tr_aero .or. tr_zaero) call faero_default ! default values + if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry +#endif +#endif + if (z_tracers) call get_atm_bgc ! biogeochemistry + + if (runtype == 'initial' .and. .not. restart) & + call init_shortwave ! initialize radiative transfer using current swdn + + call init_flux_atm ! initialize atmosphere fluxes sent to coupler + call init_flux_ocn ! initialize ocean fluxes sent to coupler + +! if (write_ic) call accum_hist(dt) ! write initial conditions + + end subroutine cice_init + +!======================================================================= + + subroutine init_restart + + use ice_arrays_column, only: dhsn + use ice_blocks, only: nx_block, ny_block + use ice_calendar, only: time, calendar + use ice_constants, only: c0 + use ice_domain, only: nblocks + use ice_domain_size, only: ncat, n_iso, n_aero, nfsd + use ice_dyn_eap, only: read_restart_eap + use ice_dyn_shared, only: kdyn + use ice_grid, only: tmask + use ice_init, only: ice_ic + use ice_init_column, only: init_age, init_FY, init_lvl, & + init_meltponds_cesm, init_meltponds_lvl, init_meltponds_topo, & + init_isotope, init_aerosol, init_hbrine, init_bgc, init_fsd + use ice_restart_column, only: restart_age, read_restart_age, & + restart_FY, read_restart_FY, restart_lvl, read_restart_lvl, & + restart_pond_cesm, read_restart_pond_cesm, & + restart_pond_lvl, read_restart_pond_lvl, & + restart_pond_topo, read_restart_pond_topo, & + restart_fsd, read_restart_fsd, & + restart_iso, read_restart_iso, & + restart_aero, read_restart_aero, & + restart_hbrine, read_restart_hbrine, & + restart_zsal, restart_bgc + use ice_restart_driver, only: restartfile + use ice_restart_shared, only: runtype, restart + use ice_state ! almost everything + + integer(kind=int_kind) :: & i, j , & ! horizontal indices iblk ! block index - logical(kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_pond_lvl, & - tr_pond_topo, tr_fsd, tr_iso, tr_aero, tr_brine, tr_snow, & - skl_bgc, z_tracers - integer(kind=int_kind) :: & - ntrcr - integer(kind=int_kind) :: & - nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd, & - nt_smice, nt_smliq, nt_rhos, nt_rsnw, & - nt_iage, nt_FY, nt_aero, nt_fsd, nt_isosno, nt_isoice - - character(len=*), parameter :: subname = '(init_restart)' - !---------------------------------------------------- - - call icepack_query_tracer_sizes(ntrcr_out=ntrcr) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) + logical(kind=log_kind) :: & + tr_iage, tr_FY, tr_lvl, tr_pond_cesm, tr_pond_lvl, & + tr_pond_topo, tr_fsd, tr_iso, tr_aero, tr_brine, & + skl_bgc, z_tracers, solve_zsal + integer(kind=int_kind) :: & + ntrcr + integer(kind=int_kind) :: & + nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd, & + nt_iage, nt_FY, nt_aero, nt_fsd, nt_isosno, nt_isoice + + character(len=*), parameter :: subname = '(init_restart)' + + call icepack_query_tracer_sizes(ntrcr_out=ntrcr) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) - call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers) - call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & - tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, & - tr_pond_topo_out=tr_pond_topo, tr_aero_out=tr_aero, tr_brine_out=tr_brine, & - tr_snow_out=tr_snow, tr_fsd_out=tr_fsd, tr_iso_out=tr_iso) - call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, & - nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, & - nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_aero_out=nt_aero, nt_fsd_out=nt_fsd, & - nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, & - nt_rhos_out=nt_rhos, nt_rsnw_out=nt_rsnw, & - nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + call icepack_query_parameters(skl_bgc_out=skl_bgc, & + z_tracers_out=z_tracers, solve_zsal_out=solve_zsal) + call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & + tr_pond_topo_out=tr_pond_topo, tr_aero_out=tr_aero, tr_brine_out=tr_brine, & + tr_fsd_out=tr_fsd, tr_iso_out=tr_iso) + call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, & + nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, & + nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_aero_out=nt_aero, nt_fsd_out=nt_fsd, & + nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - if (trim(runtype) == 'continue') then - ! start from core restart file - call restartfile() ! given by pointer in ice_in - call calendar() ! update time parameters - if (kdyn == 2) call read_restart_eap ! EAP - else if (restart) then ! ice_ic = core restart file - call restartfile (ice_ic) ! or 'default' or 'none' -!!! uncomment to create netcdf - ! call restartfile_v4 (ice_ic) ! CICE v4.1 binary restart file -!!! uncomment if EAP restart data exists - ! if (kdyn == 2) call read_restart_eap - endif - - ! tracers - ! ice age tracer - if (tr_iage) then - if (trim(runtype) == 'continue') & - restart_age = .true. - if (restart_age) then - call read_restart_age - else - do iblk = 1, nblocks - call init_age(trcrn(:,:,nt_iage,:,iblk)) - enddo ! iblk - endif - endif - ! first-year area tracer - if (tr_FY) then - if (trim(runtype) == 'continue') restart_FY = .true. - if (restart_FY) then - call read_restart_FY - else - do iblk = 1, nblocks - call init_FY(trcrn(:,:,nt_FY,:,iblk)) - enddo ! iblk - endif - endif - ! level ice tracer - if (tr_lvl) then - if (trim(runtype) == 'continue') restart_lvl = .true. - if (restart_lvl) then - call read_restart_lvl - else - do iblk = 1, nblocks - call init_lvl(iblk,trcrn(:,:,nt_alvl,:,iblk), & - trcrn(:,:,nt_vlvl,:,iblk)) - enddo ! iblk - endif - endif - ! level-ice melt ponds - if (tr_pond_lvl) then - if (trim(runtype) == 'continue') & - restart_pond_lvl = .true. - if (restart_pond_lvl) then - call read_restart_pond_lvl - else - do iblk = 1, nblocks - call init_meltponds_lvl(trcrn(:,:,nt_apnd,:,iblk), & - trcrn(:,:,nt_hpnd,:,iblk), & - trcrn(:,:,nt_ipnd,:,iblk), & - dhsn(:,:,:,iblk)) - enddo ! iblk - endif - endif - ! topographic melt ponds - if (tr_pond_topo) then - if (trim(runtype) == 'continue') & - restart_pond_topo = .true. - if (restart_pond_topo) then - call read_restart_pond_topo - else - do iblk = 1, nblocks - call init_meltponds_topo(trcrn(:,:,nt_apnd,:,iblk), & - trcrn(:,:,nt_hpnd,:,iblk), & - trcrn(:,:,nt_ipnd,:,iblk)) - enddo ! iblk - endif ! .not. restart_pond - endif - ! snow redistribution/metamorphism - if (tr_snow) then - if (trim(runtype) == 'continue') restart_snow = .true. - if (restart_snow) then - call read_restart_snow - else - do iblk = 1, nblocks - call init_snowtracers(trcrn(:,:,nt_smice:nt_smice+nslyr-1,:,iblk), & - trcrn(:,:,nt_smliq:nt_smliq+nslyr-1,:,iblk), & - trcrn(:,:,nt_rhos :nt_rhos +nslyr-1,:,iblk), & - trcrn(:,:,nt_rsnw :nt_rsnw +nslyr-1,:,iblk)) - enddo ! iblk - endif - endif - - ! floe size distribution - if (tr_fsd) then - if (trim(runtype) == 'continue') restart_fsd = .true. - if (restart_fsd) then - call read_restart_fsd - else - call init_fsd(trcrn(:,:,nt_fsd:nt_fsd+nfsd-1,:,:)) - endif - endif - ! isotopes - if (tr_iso) then - if (trim(runtype) == 'continue') restart_iso = .true. - if (restart_iso) then - call read_restart_iso - else - do iblk = 1, nblocks - call init_isotope(trcrn(:,:,nt_isosno:nt_isosno+n_iso-1,:,iblk), & - trcrn(:,:,nt_isoice:nt_isoice+n_iso-1,:,iblk)) - enddo ! iblk - endif - endif - - if (tr_aero) then ! ice aerosol - if (trim(runtype) == 'continue') restart_aero = .true. - if (restart_aero) then - call read_restart_aero - else - do iblk = 1, nblocks - call init_aerosol(trcrn(:,:,nt_aero:nt_aero+4*n_aero-1,:,iblk)) - enddo ! iblk - endif ! .not. restart_aero - endif - - if (trim(runtype) == 'continue') then - if (tr_brine) & - restart_hbrine = .true. - if (skl_bgc .or. z_tracers) & - restart_bgc = .true. - endif - - if (tr_brine .or. skl_bgc) then ! brine height tracer - call init_hbrine - if (tr_brine .and. restart_hbrine) call read_restart_hbrine - endif - - if (skl_bgc .or. z_tracers) then ! biogeochemistry - if (tr_fsd) then - write (nu_diag,*) 'FSD implementation incomplete for use with BGC' - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + if (trim(runtype) == 'continue') then + ! start from core restart file + call restartfile() ! given by pointer in ice_in + call calendar(time) ! update time parameters + if (kdyn == 2) call read_restart_eap ! EAP + else if (restart) then ! ice_ic = core restart file + call restartfile (ice_ic) ! or 'default' or 'none' + !!! uncomment to create netcdf + ! call restartfile_v4 (ice_ic) ! CICE v4.1 binary restart file + !!! uncomment if EAP restart data exists + ! if (kdyn == 2) call read_restart_eap + endif + + ! tracers + ! ice age tracer + if (tr_iage) then + if (trim(runtype) == 'continue') & + restart_age = .true. + if (restart_age) then + call read_restart_age + else + do iblk = 1, nblocks + call init_age(trcrn(:,:,nt_iage,:,iblk)) + enddo ! iblk + endif + endif + ! first-year area tracer + if (tr_FY) then + if (trim(runtype) == 'continue') restart_FY = .true. + if (restart_FY) then + call read_restart_FY + else + do iblk = 1, nblocks + call init_FY(trcrn(:,:,nt_FY,:,iblk)) + enddo ! iblk + endif + endif + ! level ice tracer + if (tr_lvl) then + if (trim(runtype) == 'continue') restart_lvl = .true. + if (restart_lvl) then + call read_restart_lvl + else + do iblk = 1, nblocks + call init_lvl(iblk,trcrn(:,:,nt_alvl,:,iblk), & + trcrn(:,:,nt_vlvl,:,iblk)) + enddo ! iblk + endif + endif + ! CESM melt ponds + if (tr_pond_cesm) then + if (trim(runtype) == 'continue') & + restart_pond_cesm = .true. + if (restart_pond_cesm) then + call read_restart_pond_cesm + else + do iblk = 1, nblocks + call init_meltponds_cesm(trcrn(:,:,nt_apnd,:,iblk), & + trcrn(:,:,nt_hpnd,:,iblk)) + enddo ! iblk + endif + endif + ! level-ice melt ponds + if (tr_pond_lvl) then + if (trim(runtype) == 'continue') & + restart_pond_lvl = .true. + if (restart_pond_lvl) then + call read_restart_pond_lvl + else + do iblk = 1, nblocks + call init_meltponds_lvl(trcrn(:,:,nt_apnd,:,iblk), & + trcrn(:,:,nt_hpnd,:,iblk), & + trcrn(:,:,nt_ipnd,:,iblk), & + dhsn(:,:,:,iblk)) + enddo ! iblk + endif + endif + ! topographic melt ponds + if (tr_pond_topo) then + if (trim(runtype) == 'continue') & + restart_pond_topo = .true. + if (restart_pond_topo) then + call read_restart_pond_topo + else + do iblk = 1, nblocks + call init_meltponds_topo(trcrn(:,:,nt_apnd,:,iblk), & + trcrn(:,:,nt_hpnd,:,iblk), & + trcrn(:,:,nt_ipnd,:,iblk)) + enddo ! iblk + endif ! .not. restart_pond + endif + ! floe size distribution + if (tr_fsd) then + if (trim(runtype) == 'continue') restart_fsd = .true. + if (restart_fsd) then + call read_restart_fsd + else + call init_fsd(trcrn(:,:,nt_fsd:nt_fsd+nfsd-1,:,:)) + endif + endif + + ! isotopes + if (tr_iso) then + if (trim(runtype) == 'continue') restart_iso = .true. + if (restart_iso) then + call read_restart_iso + else + do iblk = 1, nblocks + call init_isotope(trcrn(:,:,nt_isosno:nt_isosno+n_iso-1,:,iblk), & + trcrn(:,:,nt_isoice:nt_isoice+n_iso-1,:,iblk)) + enddo ! iblk + endif + endif + + if (tr_aero) then ! ice aerosol + if (trim(runtype) == 'continue') restart_aero = .true. + if (restart_aero) then + call read_restart_aero + else + do iblk = 1, nblocks + call init_aerosol(trcrn(:,:,nt_aero:nt_aero+4*n_aero-1,:,iblk)) + enddo ! iblk + endif ! .not. restart_aero + endif + + if (trim(runtype) == 'continue') then + if (tr_brine) & + restart_hbrine = .true. + if (solve_zsal) & + restart_zsal = .true. + if (skl_bgc .or. z_tracers) & + restart_bgc = .true. + endif + + if (tr_brine .or. skl_bgc) then ! brine height tracer + call init_hbrine + if (tr_brine .and. restart_hbrine) call read_restart_hbrine + endif + + if (solve_zsal .or. skl_bgc .or. z_tracers) then ! biogeochemistry + if (tr_fsd) then + write (nu_diag,*) 'FSD implementation incomplete for use with BGC' + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - endif - call init_bgc - endif - - !----------------------------------------------------------------- - ! aggregate tracers - !----------------------------------------------------------------- - - !$OMP PARALLEL DO PRIVATE(iblk) - do iblk = 1, nblocks - do j = 1, ny_block - do i = 1, nx_block - if (tmask(i,j,iblk)) then - call icepack_aggregate(ncat = ncat, & - aicen = aicen(i,j,:,iblk), & - trcrn = trcrn(i,j,:,:,iblk), & - vicen = vicen(i,j,:,iblk), & - vsnon = vsnon(i,j,:,iblk), & - aice = aice (i,j, iblk), & - trcr = trcr (i,j,:,iblk), & - vice = vice (i,j, iblk), & - vsno = vsno (i,j, iblk), & - aice0 = aice0(i,j, iblk), & - ntrcr = ntrcr, & - trcr_depend = trcr_depend, & - trcr_base = trcr_base, & - n_trcr_strata = n_trcr_strata, & - nt_strata = nt_strata) - else - ! tcraig, reset all tracer values on land to zero - trcrn(i,j,:,:,iblk) = c0 - endif - enddo - enddo - enddo - !$OMP END PARALLEL DO - - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + endif + call init_bgc + endif + + !----------------------------------------------------------------- + ! aggregate tracers + !----------------------------------------------------------------- + + !$OMP PARALLEL DO PRIVATE(iblk) + do iblk = 1, nblocks + do j = 1, ny_block + do i = 1, nx_block + if (tmask(i,j,iblk)) then + call icepack_aggregate(ncat = ncat, & + aicen = aicen(i,j,:,iblk), & + trcrn = trcrn(i,j,:,:,iblk), & + vicen = vicen(i,j,:,iblk), & + vsnon = vsnon(i,j,:,iblk), & + aice = aice (i,j, iblk), & + trcr = trcr (i,j,:,iblk), & + vice = vice (i,j, iblk), & + vsno = vsno (i,j, iblk), & + aice0 = aice0(i,j, iblk), & + ntrcr = ntrcr, & + trcr_depend = trcr_depend, & + trcr_base = trcr_base, & + n_trcr_strata = n_trcr_strata, & + nt_strata = nt_strata) + else + ! tcraig, reset all tracer values on land to zero + trcrn(i,j,:,:,iblk) = c0 + endif + enddo + enddo + enddo + !$OMP END PARALLEL DO + + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - end subroutine init_restart - !======================================================================= + end subroutine init_restart + +!======================================================================= -end module CICE_InitMod + end module CICE_InitMod !======================================================================= diff --git a/cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90 b/cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90 index 483048051..09cffa0c7 100644 --- a/cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90 +++ b/cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90 @@ -7,7 +7,7 @@ ! William H. Lipscomb, LANL ! ! 2006 ECH: moved exit timeLoop to prevent execution of unnecessary timestep -! 2006 ECH: Streamlined for efficiency +! 2006 ECH: Streamlined for efficiency ! 2006 ECH: Converted to free source form (F90) ! 2007 BPB: Modified Delta-Eddington shortwave interface ! 2008 ECH: moved ESMF code to its own driver @@ -15,8 +15,7 @@ module CICE_RunMod use ice_kinds_mod - use cice_wrapper_mod, only : t_startf, t_stopf, t_barrierf - use cice_wrapper_mod, only : ufs_logfhour + use perf_mod, only : t_startf, t_stopf, t_barrierf use ice_fileunits, only: nu_diag use ice_arrays_column, only: oceanmixed_ice use ice_constants, only: c0, c1 @@ -45,7 +44,7 @@ module CICE_RunMod subroutine CICE_Run - use ice_calendar, only: istep, istep1, dt, calendar, advance_timestep + use ice_calendar, only: istep, istep1, time, dt, stop_now, calendar use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & @@ -57,9 +56,9 @@ subroutine CICE_Run tr_iso, tr_aero, tr_zaero, skl_bgc, z_tracers, wave_spec, tr_fsd character(len=*), parameter :: subname = '(CICE_Run)' - !-------------------------------------------------------------------- - ! initialize error code and step timer - !-------------------------------------------------------------------- + !-------------------------------------------------------------------- + ! initialize error code and step timer + !-------------------------------------------------------------------- call ice_timer_start(timer_step) ! start timing entire run @@ -74,28 +73,58 @@ subroutine CICE_Run if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - !-------------------------------------------------------------------- - ! timestep loop - !-------------------------------------------------------------------- + !-------------------------------------------------------------------- + ! timestep loop + !-------------------------------------------------------------------- - call ice_timer_start(timer_couple) ! atm/ocn coupling +! timeLoop: do - call advance_timestep() ! advance timestep and update calendar data +! call ice_step - if (z_tracers) call get_atm_bgc ! biogeochemistry + istep = istep + 1 ! update time step counters + istep1 = istep1 + 1 + time = time + dt ! determine the time and date - call init_flux_atm ! Initialize atmosphere fluxes sent to coupler - call init_flux_ocn ! initialize ocean fluxes sent to coupler +! call calendar(time) ! at the end of the timestep - call ice_timer_stop(timer_couple) ! atm/ocn coupling + call ice_timer_start(timer_couple) ! atm/ocn coupling - call ice_step +#ifndef coupled +#ifndef CESMCOUPLED +! for now, wave_spectrum is constant in time +! if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice + call get_forcing_atmo ! atmospheric forcing from data + call get_forcing_ocn(dt) ! ocean forcing from data - !-------------------------------------------------------------------- - ! end of timestep loop - !-------------------------------------------------------------------- + ! isotopes + if (tr_iso) call fiso_default ! default values + ! aerosols + ! if (tr_aero) call faero_data ! data file + ! if (tr_zaero) call fzaero_data ! data file (gx1) + if (tr_aero .or. tr_zaero) call faero_default ! default values - call ice_timer_stop(timer_step) ! end timestepping loop timer + if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry +#endif +#endif + if (z_tracers) call get_atm_bgc ! biogeochemistry + + call init_flux_atm ! Initialize atmosphere fluxes sent to coupler + call init_flux_ocn ! initialize ocean fluxes sent to coupler + + call calendar(time) ! at the end of the timestep + + call ice_timer_stop(timer_couple) ! atm/ocn coupling + + call ice_step + +! if (stop_now >= 1) exit timeLoop +! enddo timeLoop + + !-------------------------------------------------------------------- + ! end of timestep loop + !-------------------------------------------------------------------- + + call ice_timer_stop(timer_step) ! end timestepping loop timer end subroutine CICE_Run @@ -108,13 +137,11 @@ end subroutine CICE_Run subroutine ice_step - use ice_constants, only: c3600 use ice_boundary, only: ice_HaloUpdate use ice_calendar, only: dt, dt_dyn, ndtd, diagfreq, write_restart, istep - use ice_calendar, only: idate, myear, mmonth, mday, msec, timesecs - use ice_calendar, only: calendar_sec2hms, write_history, nstreams, histfreq - use ice_diagnostics, only: init_mass_diags, runtime_diags, debug_model, debug_ice - use ice_diagnostics_bgc, only: hbrine_diags, bgc_diags + use ice_calendar, only: idate, sec + use ice_diagnostics, only: init_mass_diags, runtime_diags + use ice_diagnostics_bgc, only: hbrine_diags, zsal_diags, bgc_diags use ice_domain, only: halo_info, nblocks use ice_dyn_eap, only: write_restart_eap use ice_dyn_shared, only: kdyn, kridge @@ -124,23 +151,22 @@ subroutine ice_step use ice_history_bgc, only: init_history_bgc use ice_restart, only: final_restart use ice_restart_column, only: write_restart_age, write_restart_FY, & - write_restart_lvl, write_restart_pond_lvl, & + write_restart_lvl, write_restart_pond_cesm, write_restart_pond_lvl, & write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_iso, write_restart_bgc, write_restart_hbrine, & - write_restart_snow + write_restart_iso, write_restart_bgc, write_restart_hbrine use ice_restart_driver, only: dumpfile use ice_restoring, only: restore_ice, ice_HaloRestore use ice_step_mod, only: prep_radiation, step_therm1, step_therm2, & update_state, step_dyn_horiz, step_dyn_ridge, step_radiation, & - biogeochemistry, step_prep, step_dyn_wave, step_snow + biogeochemistry, save_init, step_dyn_wave use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_diags, timer_column, timer_thermo, timer_bound, & timer_hist, timer_readwrite - use ice_communicate, only: MPI_COMM_ICE, my_task, master_task + use ice_communicate, only: MPI_COMM_ICE use ice_prescribed_mod integer (kind=int_kind) :: & - iblk , & ! block index + iblk , & ! block index k , & ! dynamics supercycling index ktherm ! thermodynamics is off when ktherm = -1 @@ -148,29 +174,19 @@ subroutine ice_step offset ! d(age)/dt time offset logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_fsd, tr_snow, & - tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, & - calc_Tsfc, skl_bgc, z_tracers, wave_spec + tr_iage, tr_FY, tr_lvl, tr_fsd, & + tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, & + calc_Tsfc, skl_bgc, solve_zsal, z_tracers, wave_spec character(len=*), parameter :: subname = '(ice_step)' - character (len=char_len) :: plabeld - integer (kind=int_kind) :: hh,mm,ss,ns - character (len=char_len) :: logmsg - - if (debug_model) then - plabeld = 'beginning time step' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - endif - call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc, skl_bgc_out=skl_bgc, & - z_tracers_out=z_tracers, ktherm_out=ktherm, wave_spec_out=wave_spec) + solve_zsal_out=solve_zsal, z_tracers_out=z_tracers, ktherm_out=ktherm, & + wave_spec_out=wave_spec) call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & - tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_iso_out=tr_iso, tr_fsd_out=tr_fsd, tr_snow_out=tr_snow) + tr_iso_out=tr_iso, tr_fsd_out=tr_fsd) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) @@ -191,16 +207,14 @@ subroutine ice_step call init_history_bgc call ice_timer_stop(timer_diags) ! diagnostics/history -#ifdef CESMCOUPLED if (prescribed_ice) then ! read prescribed ice call t_barrierf('cice_run_presc_BARRIER',MPI_COMM_ICE) call t_startf ('cice_run_presc') - call ice_prescribed_run(idate, msec) + call ice_prescribed_run(idate, sec) call t_stopf ('cice_run_presc') endif -#endif - call step_prep + call save_init call ice_timer_start(timer_column) ! column physics call ice_timer_start(timer_thermo) ! thermodynamics @@ -215,33 +229,15 @@ subroutine ice_step !----------------------------------------------------------------- if (calc_Tsfc) call prep_radiation (iblk) - if (debug_model) then - plabeld = 'post prep_radiation' - call debug_ice (iblk, plabeld) - endif !----------------------------------------------------------------- ! thermodynamics and biogeochemistry !----------------------------------------------------------------- - + call step_therm1 (dt, iblk) ! vertical thermodynamics - if (debug_model) then - plabeld = 'post step_therm1' - call debug_ice (iblk, plabeld) - endif - call biogeochemistry (dt, iblk) ! biogeochemistry - if (debug_model) then - plabeld = 'post biogeochemistry' - call debug_ice (iblk, plabeld) - endif - if (.not.prescribed_ice) & call step_therm2 (dt, iblk) ! ice thickness distribution thermo - if (debug_model) then - plabeld = 'post step_therm2' - call debug_ice (iblk, plabeld) - endif endif ! ktherm > 0 @@ -269,12 +265,6 @@ subroutine ice_step ! momentum, stress, transport call step_dyn_horiz (dt_dyn) - if (debug_model) then - plabeld = 'post step_dyn_horiz' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo ! iblk - endif ! ridging !$OMP PARALLEL DO PRIVATE(iblk) @@ -282,24 +272,12 @@ subroutine ice_step if (kridge > 0) call step_dyn_ridge (dt_dyn, ndtd, iblk) enddo !$OMP END PARALLEL DO - if (debug_model) then - plabeld = 'post step_dyn_ridge' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo ! iblk - endif ! clean up, update tendency diagnostics offset = c0 call update_state (dt_dyn, daidtd, dvidtd, dagedtd, offset) enddo - if (debug_model) then - plabeld = 'post dynamics' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - endif endif ! not prescribed ice @@ -310,36 +288,18 @@ subroutine ice_step call ice_timer_start(timer_column) ! column physics call ice_timer_start(timer_thermo) ! thermodynamics - !----------------------------------------------------------------- - ! snow redistribution and metamorphosis - !----------------------------------------------------------------- - - if (tr_snow) then ! advanced snow physics - do iblk = 1, nblocks - call step_snow (dt, iblk) - enddo - call update_state (dt) ! clean up - endif - !MHRI: CHECK THIS OMP !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks if (ktherm >= 0) call step_radiation (dt, iblk) - if (debug_model) then - plabeld = 'post step_radiation' - call debug_ice (iblk, plabeld) - endif !----------------------------------------------------------------- ! get ready for coupling and the next time step !----------------------------------------------------------------- call coupling_prep (iblk) - if (debug_model) then - plabeld = 'post coupling_prep' - call debug_ice (iblk, plabeld) - endif + enddo ! iblk !$OMP END PARALLEL DO @@ -358,6 +318,7 @@ subroutine ice_step call ice_timer_start(timer_diags) ! diagnostics if (mod(istep,diagfreq) == 0) then call runtime_diags(dt) ! log file + if (solve_zsal) call zsal_diags if (skl_bgc .or. z_tracers) call bgc_diags if (tr_brine) call hbrine_diags endif @@ -373,31 +334,23 @@ subroutine ice_step if (tr_iage) call write_restart_age if (tr_FY) call write_restart_FY if (tr_lvl) call write_restart_lvl + if (tr_pond_cesm) call write_restart_pond_cesm if (tr_pond_lvl) call write_restart_pond_lvl if (tr_pond_topo) call write_restart_pond_topo - if (tr_snow) call write_restart_snow if (tr_fsd) call write_restart_fsd if (tr_iso) call write_restart_iso if (tr_aero) call write_restart_aero - if (skl_bgc .or. z_tracers) & - call write_restart_bgc + if (solve_zsal .or. skl_bgc .or. z_tracers) & + call write_restart_bgc if (tr_brine) call write_restart_hbrine if (kdyn == 2) call write_restart_eap call final_restart endif call ice_timer_stop(timer_readwrite) ! reading/writing - if (my_task == master_task) then - do ns = 1,nstreams - if (write_history(ns) .and. histfreq(ns) .eq. 'h') then - call calendar_sec2hms(msec,hh,mm,ss) - write(logmsg,'(6(i4,2x))')myear,mmonth,mday,hh,mm,ss - call ufs_logfhour(trim(logmsg),timesecs/c3600) - end if - end do - end if - end subroutine ice_step + end subroutine ice_step + !======================================================================= ! ! Prepare for coupling @@ -407,7 +360,7 @@ end subroutine ice_step subroutine coupling_prep (iblk) use ice_arrays_column, only: alvdfn, alidfn, alvdrn, alidrn, & - albicen, albsnon, albpndn, apeffn, snowfracn + albicen, albsnon, albpndn, apeffn, fzsal_g, fzsal, snowfracn use ice_blocks, only: nx_block, ny_block, get_block, block use ice_domain, only: blocks_ice use ice_calendar, only: dt, nstreams @@ -417,13 +370,13 @@ subroutine coupling_prep (iblk) alvdf_ai, alidf_ai, alvdr_ai, alidr_ai, fhocn_ai, & fresh_ai, fsalt_ai, fsalt, & fswthru_ai, fhocn, fswthru, scale_factor, snowfrac, & - fswthru_vdr, fswthru_vdf, fswthru_idr, fswthru_idf, & swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyT, & fsens, flat, fswabs, flwout, evap, Tref, Qref, & scale_fluxes, frzmlt_init, frzmlt, Uref, wind use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, & - flux_bio, flux_bio_ai, fnit, fsil, famm, fdmsp, fdms, fhum, & - fdust, falgalN, fdoc, fdic, fdon, ffep, ffed, bgcflux_ice_to_ocn + fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai + fnit, fsil, famm, fdmsp, fdms, fhum, fdust, falgalN, & + fdoc, fdic, fdon, ffep, ffed, bgcflux_ice_to_ocn use ice_grid, only: tmask use ice_state, only: aicen, aice use ice_state, only: aice_init @@ -431,12 +384,12 @@ subroutine coupling_prep (iblk) use ice_step_mod, only: ocean_mixed_layer use ice_timers, only: timer_couple, ice_timer_start, ice_timer_stop - integer (kind=int_kind), intent(in) :: & - iblk ! block index + integer (kind=int_kind), intent(in) :: & + iblk ! block index ! local variables - integer (kind=int_kind) :: & + integer (kind=int_kind) :: & ilo,ihi,jlo,jhi, & ! beginning and end of physical domain n , & ! thickness category index i,j , & ! horizontal indices @@ -576,6 +529,8 @@ subroutine coupling_prep (iblk) fsalt_ai (i,j,iblk) = fsalt (i,j,iblk) fhocn_ai (i,j,iblk) = fhocn (i,j,iblk) fswthru_ai(i,j,iblk) = fswthru(i,j,iblk) + fzsal_ai (i,j,iblk) = fzsal (i,j,iblk) + fzsal_g_ai(i,j,iblk) = fzsal_g(i,j,iblk) if (nbtrcr > 0) then do k = 1, nbtrcr @@ -596,7 +551,7 @@ subroutine coupling_prep (iblk) enddo !----------------------------------------------------------------- - ! Divide fluxes by ice area + ! Divide fluxes by ice area ! - the CESM coupler assumes fluxes are per unit ice area ! - also needed for global budget in diagnostics !----------------------------------------------------------------- @@ -612,21 +567,17 @@ subroutine coupling_prep (iblk) evap (:,:,iblk), & Tref (:,:,iblk), Qref (:,:,iblk), & fresh (:,:,iblk), fsalt (:,:,iblk), & - fhocn (:,:,iblk), & - fswthru (:,:,iblk), & - fswthru_vdr(:,:,iblk), & - fswthru_vdf(:,:,iblk), & - fswthru_idr(:,:,iblk), & - fswthru_idf(:,:,iblk), & + fhocn (:,:,iblk), fswthru (:,:,iblk), & faero_ocn(:,:,:,iblk), & alvdr (:,:,iblk), alidr (:,:,iblk), & alvdf (:,:,iblk), alidf (:,:,iblk), & + fzsal (:,:,iblk), fzsal_g (:,:,iblk), & flux_bio (:,:,1:nbtrcr,iblk), & Qref_iso =Qref_iso (:,:,:,iblk), & fiso_evap=fiso_evap(:,:,:,iblk), & fiso_ocn =fiso_ocn (:,:,:,iblk), & Uref=Uref(:,:,iblk), wind=wind(:,:,iblk) ) - + !----------------------------------------------------------------- ! Define ice-ocean bgc fluxes !----------------------------------------------------------------- @@ -647,16 +598,16 @@ subroutine coupling_prep (iblk) if (.not. calc_Tsfc) then !--------------------------------------------------------------- - ! If surface fluxes were provided, conserve these fluxes at ice - ! free points by passing to ocean. + ! If surface fluxes were provided, conserve these fluxes at ice + ! free points by passing to ocean. !--------------------------------------------------------------- - call sfcflux_to_ocn & + call sfcflux_to_ocn & (nx_block, ny_block, & tmask (:,:,iblk), aice_init(:,:,iblk), & fsurfn_f (:,:,:,iblk), flatn_f(:,:,:,iblk), & fresh (:,:,iblk), fhocn (:,:,iblk)) - endif + endif !echmod call ice_timer_stop(timer_couple,iblk) ! atm/ocn coupling @@ -665,10 +616,10 @@ end subroutine coupling_prep !======================================================================= ! ! If surface heat fluxes are provided to CICE instead of CICE calculating -! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can +! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can ! be provided at points which do not have ice. (This is could be due to ! the heat fluxes being calculated on a lower resolution grid or the -! heat fluxes not recalculated at every CICE timestep.) At ice free points, +! heat fluxes not recalculated at every CICE timestep.) At ice free points, ! conserve energy and water by passing these fluxes to the ocean. ! ! author: A. McLaren, Met Office @@ -702,15 +653,14 @@ subroutine sfcflux_to_ocn(nx_block, ny_block, & ! local variables integer (kind=int_kind) :: & i, j, n ! horizontal indices - + real (kind=dbl_kind) :: & puny, & ! - Lsub, & ! rLsub ! 1/Lsub character(len=*), parameter :: subname = '(sfcflux_to_ocn)' - call icepack_query_parameters(puny_out=puny, Lsub_out=Lsub) + call icepack_query_parameters(puny_out=puny) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) diff --git a/cicecore/drivers/nuopc/dmi/CICE_InitMod.F90 b/cicecore/drivers/nuopc/dmi/CICE_InitMod.F90 index dc83c7703..986189f96 100644 --- a/cicecore/drivers/nuopc/dmi/CICE_InitMod.F90 +++ b/cicecore/drivers/nuopc/dmi/CICE_InitMod.F90 @@ -15,11 +15,9 @@ module CICE_InitMod use ice_kinds_mod use ice_exit, only: abort_ice use ice_fileunits, only: init_fileunits, nu_diag - use ice_memusage, only: ice_memusage_init, ice_memusage_print use icepack_intfc, only: icepack_aggregate use icepack_intfc, only: icepack_init_itd, icepack_init_itd_hist use icepack_intfc, only: icepack_init_fsd_bounds, icepack_init_wave - use icepack_intfc, only: icepack_init_snow use icepack_intfc, only: icepack_configure use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted use icepack_intfc, only: icepack_query_parameters, icepack_query_tracer_flags, & @@ -71,20 +69,18 @@ subroutine cice_init(mpi_comm) floe_binwidth, c_fsd_range use ice_state, only: alloc_state use ice_flux_bgc, only: alloc_flux_bgc - use ice_calendar, only: dt, dt_dyn, write_ic, & - init_calendar, advance_timestep, calc_timesteps + use ice_calendar, only: dt, dt_dyn, time, istep, istep1, write_ic, & + init_calendar, calendar use ice_communicate, only: init_communicate, my_task, master_task use ice_diagnostics, only: init_diags use ice_domain, only: init_domain_blocks use ice_domain_size, only: ncat, nfsd - use ice_dyn_eap, only: init_eap - use ice_dyn_evp, only: init_evp - use ice_dyn_vp, only: init_vp - use ice_dyn_shared, only: kdyn + use ice_dyn_eap, only: init_eap, alloc_dyn_eap + use ice_dyn_shared, only: kdyn, init_evp, alloc_dyn_shared use ice_flux, only: init_coupler_flux, init_history_therm, & init_history_dyn, init_flux_atm, init_flux_ocn, alloc_flux use ice_forcing, only: init_forcing_ocn, init_forcing_atmo, & - get_forcing_atmo, get_forcing_ocn, get_wave_spec, init_snowtable + get_forcing_atmo, get_forcing_ocn, get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & faero_default, faero_optics, alloc_forcing_bgc, fiso_default use ice_grid, only: init_grid1, init_grid2, alloc_grid @@ -96,13 +92,15 @@ subroutine cice_init(mpi_comm) use ice_restoring, only: ice_HaloRestore_init use ice_timers, only: timer_total, init_ice_timers, ice_timer_start use ice_transport_driver, only: init_transport +#ifdef popcice + use drv_forcing, only: sst_sss +#endif integer (kind=int_kind), optional, intent(in) :: & mpi_comm ! communicator for sequential ccsm logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers, & - tr_iso, tr_fsd, wave_spec, tr_snow - character(len=char_len) :: snw_aging_table + tr_iso, tr_fsd, wave_spec character(len=*), parameter :: subname = '(cice_init)' if (present(mpi_comm)) then @@ -124,17 +122,12 @@ subroutine cice_init(mpi_comm) call input_zbgc ! vertical biogeochemistry namelist call count_tracers ! count tracers - ! Call this as early as possible, must be after memory_stats is read - if (my_task == master_task) then - call ice_memusage_init(nu_diag) - call ice_memusage_print(nu_diag,subname//':start') - endif - call init_domain_blocks ! set up block decomposition call init_grid1 ! domain distribution call alloc_grid ! allocate grid arrays call alloc_arrays_column ! allocate column arrays call alloc_state ! allocate state arrays + call alloc_dyn_shared ! allocate dyn shared arrays call alloc_flux_bgc ! allocate flux_bgc arrays call alloc_flux ! allocate flux arrays call init_ice_timers ! initialize all timers @@ -144,16 +137,18 @@ subroutine cice_init(mpi_comm) call init_calendar ! initialize some calendar stuff call init_hist (dt) ! initialize output history file - if (kdyn == 1) then - call init_evp - else if (kdyn == 2) then - call init_eap ! define eap dynamics parameters, variables - else if (kdyn == 3) then - call init_vp ! define vp dynamics parameters, variables + if (kdyn == 2) then + call alloc_dyn_eap ! allocate dyn_eap arrays + call init_eap (dt_dyn) ! define eap dynamics parameters, variables + else ! for both kdyn = 0 or 1 + call init_evp (dt_dyn) ! define evp dynamics parameters, variables endif call init_coupler_flux ! initialize fluxes exchanged with coupler +#ifdef popcice + call sst_sss ! POP data for CICE initialization +#endif call init_thermo_vertical ! initialize vertical thermodynamics call icepack_init_itd(ncat=ncat, hin_max=hin_max) ! ice thickness distribution @@ -176,15 +171,16 @@ subroutine cice_init(mpi_comm) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) -#ifndef CICE_IN_NEMO + +! call calendar(time) ! determine the initial date + call init_forcing_ocn(dt) ! initialize sss and sst from data -#endif call init_state ! initialize the ice state call init_transport ! initialize horizontal transport call ice_HaloRestore_init ! restored boundary conditions call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers, & - wave_spec_out=wave_spec, snw_aging_table_out=snw_aging_table) + wave_spec_out=wave_spec) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) @@ -195,32 +191,32 @@ subroutine cice_init(mpi_comm) call init_diags ! initialize diagnostic output points call init_history_therm ! initialize thermo history variables call init_history_dyn ! initialize dynamic history variables - call calc_timesteps ! update timestep counter if not using npt_unit="1" call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero) - call icepack_query_tracer_flags(tr_iso_out=tr_iso, tr_snow_out=tr_snow) + call icepack_query_tracer_flags(tr_iso_out=tr_iso) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) - if (tr_aero .or. tr_zaero) call faero_optics !initialize aerosol optical + if (tr_aero .or. tr_zaero) call faero_optics !initialize aerosol optical !property tables - ! Initialize shortwave components using swdn from previous timestep - ! if restarting. These components will be scaled to current forcing + ! Initialize shortwave components using swdn from previous timestep + ! if restarting. These components will be scaled to current forcing ! in prep_radiation. if (trim(runtype) == 'continue' .or. restart) & call init_shortwave ! initialize radiative transfer - call advance_timestep() + istep = istep + 1 ! update time step counters + istep1 = istep1 + 1 + time = time + dt ! determine the time and date + call calendar(time) ! at the end of the first timestep !-------------------------------------------------------------------- ! coupler communication or forcing data initialization !-------------------------------------------------------------------- -#ifndef CICE_IN_NEMO call init_forcing_atmo ! initialize atmospheric forcing (standalone) -#endif #ifndef coupled #ifndef CESMCOUPLED @@ -230,20 +226,8 @@ subroutine cice_init(mpi_comm) call get_forcing_ocn(dt) ! ocean forcing from data #endif - ! snow aging lookup table initialization - if (tr_snow) then ! advanced snow physics - call icepack_init_snow() - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - if (snw_aging_table(1:4) /= 'test') then - call init_snowtable() - endif - endif - ! isotopes if (tr_iso) call fiso_default ! default values - ! aerosols ! if (tr_aero) call faero_data ! data file ! if (tr_zaero) call fzaero_data ! data file (gx1) @@ -259,11 +243,7 @@ subroutine cice_init(mpi_comm) call init_flux_atm ! initialize atmosphere fluxes sent to coupler call init_flux_ocn ! initialize ocean fluxes sent to coupler - if (write_ic) call accum_hist(dt) ! write initial conditions - - if (my_task == master_task) then - call ice_memusage_print(nu_diag,subname//':end') - endif + if (write_ic) call accum_hist(dt) ! write initial conditions end subroutine cice_init @@ -273,22 +253,22 @@ subroutine init_restart use ice_arrays_column, only: dhsn use ice_blocks, only: nx_block, ny_block - use ice_calendar, only: calendar + use ice_calendar, only: time, calendar use ice_constants, only: c0 use ice_domain, only: nblocks - use ice_domain_size, only: ncat, n_iso, n_aero, nfsd, nslyr + use ice_domain_size, only: ncat, n_iso, n_aero, nfsd use ice_dyn_eap, only: read_restart_eap use ice_dyn_shared, only: kdyn use ice_grid, only: tmask use ice_init, only: ice_ic - use ice_init_column, only: init_age, init_FY, init_lvl, init_snowtracers, & - init_meltponds_lvl, init_meltponds_topo, & + use ice_init_column, only: init_age, init_FY, init_lvl, & + init_meltponds_cesm, init_meltponds_lvl, init_meltponds_topo, & init_isotope, init_aerosol, init_hbrine, init_bgc, init_fsd use ice_restart_column, only: restart_age, read_restart_age, & restart_FY, read_restart_FY, restart_lvl, read_restart_lvl, & + restart_pond_cesm, read_restart_pond_cesm, & restart_pond_lvl, read_restart_pond_lvl, & restart_pond_topo, read_restart_pond_topo, & - restart_snow, read_restart_snow, & restart_fsd, read_restart_fsd, & restart_iso, read_restart_iso, & restart_aero, read_restart_aero, & @@ -302,14 +282,13 @@ subroutine init_restart i, j , & ! horizontal indices iblk ! block index logical(kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_pond_lvl, & - tr_pond_topo, tr_snow, tr_fsd, tr_iso, tr_aero, tr_brine, & + tr_iage, tr_FY, tr_lvl, tr_pond_cesm, tr_pond_lvl, & + tr_pond_topo, tr_fsd, tr_iso, tr_aero, tr_brine, & skl_bgc, z_tracers, solve_zsal integer(kind=int_kind) :: & ntrcr integer(kind=int_kind) :: & nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd, & - nt_smice, nt_smliq, nt_rhos, nt_rsnw, & nt_iage, nt_FY, nt_aero, nt_fsd, nt_isosno, nt_isoice character(len=*), parameter :: subname = '(init_restart)' @@ -322,23 +301,21 @@ subroutine init_restart call icepack_query_parameters(skl_bgc_out=skl_bgc, & z_tracers_out=z_tracers, solve_zsal_out=solve_zsal) call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & - tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & tr_pond_topo_out=tr_pond_topo, tr_aero_out=tr_aero, tr_brine_out=tr_brine, & - tr_snow_out=tr_snow, tr_fsd_out=tr_fsd, tr_iso_out=tr_iso) + tr_fsd_out=tr_fsd, tr_iso_out=tr_iso) call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, & nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, & nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_aero_out=nt_aero, nt_fsd_out=nt_fsd, & - nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, & - nt_rhos_out=nt_rhos, nt_rsnw_out=nt_rsnw, & nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - if (trim(runtype) == 'continue') then + if (trim(runtype) == 'continue') then ! start from core restart file call restartfile() ! given by pointer in ice_in - call calendar() ! update time parameters + call calendar(time) ! update time parameters if (kdyn == 2) call read_restart_eap ! EAP else if (restart) then ! ice_ic = core restart file call restartfile (ice_ic) ! or 'default' or 'none' @@ -346,17 +323,17 @@ subroutine init_restart ! call restartfile_v4 (ice_ic) ! CICE v4.1 binary restart file !!! uncomment if EAP restart data exists ! if (kdyn == 2) call read_restart_eap - endif + endif ! tracers - ! ice age tracer - if (tr_iage) then + ! ice age tracer + if (tr_iage) then if (trim(runtype) == 'continue') & restart_age = .true. if (restart_age) then call read_restart_age else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_age(trcrn(:,:,nt_iage,:,iblk)) enddo ! iblk endif @@ -367,7 +344,7 @@ subroutine init_restart if (restart_FY) then call read_restart_FY else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_FY(trcrn(:,:,nt_FY,:,iblk)) enddo ! iblk endif @@ -378,12 +355,25 @@ subroutine init_restart if (restart_lvl) then call read_restart_lvl else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_lvl(iblk,trcrn(:,:,nt_alvl,:,iblk), & trcrn(:,:,nt_vlvl,:,iblk)) enddo ! iblk endif endif + ! CESM melt ponds + if (tr_pond_cesm) then + if (trim(runtype) == 'continue') & + restart_pond_cesm = .true. + if (restart_pond_cesm) then + call read_restart_pond_cesm + else + do iblk = 1, nblocks + call init_meltponds_cesm(trcrn(:,:,nt_apnd,:,iblk), & + trcrn(:,:,nt_hpnd,:,iblk)) + enddo ! iblk + endif + endif ! level-ice melt ponds if (tr_pond_lvl) then if (trim(runtype) == 'continue') & @@ -391,7 +381,7 @@ subroutine init_restart if (restart_pond_lvl) then call read_restart_pond_lvl else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_meltponds_lvl(trcrn(:,:,nt_apnd,:,iblk), & trcrn(:,:,nt_hpnd,:,iblk), & trcrn(:,:,nt_ipnd,:,iblk), & @@ -406,29 +396,13 @@ subroutine init_restart if (restart_pond_topo) then call read_restart_pond_topo else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_meltponds_topo(trcrn(:,:,nt_apnd,:,iblk), & trcrn(:,:,nt_hpnd,:,iblk), & trcrn(:,:,nt_ipnd,:,iblk)) enddo ! iblk endif ! .not. restart_pond endif - - ! snow redistribution/metamorphism - if (tr_snow) then - if (trim(runtype) == 'continue') restart_snow = .true. - if (restart_snow) then - call read_restart_snow - else - do iblk = 1, nblocks - call init_snowtracers(trcrn(:,:,nt_smice:nt_smice+nslyr-1,:,iblk), & - trcrn(:,:,nt_smliq:nt_smliq+nslyr-1,:,iblk), & - trcrn(:,:,nt_rhos :nt_rhos +nslyr-1,:,iblk), & - trcrn(:,:,nt_rsnw :nt_rsnw +nslyr-1,:,iblk)) - enddo ! iblk - endif - endif - ! floe size distribution if (tr_fsd) then if (trim(runtype) == 'continue') restart_fsd = .true. @@ -445,7 +419,7 @@ subroutine init_restart if (restart_iso) then call read_restart_iso else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_isotope(trcrn(:,:,nt_isosno:nt_isosno+n_iso-1,:,iblk), & trcrn(:,:,nt_isoice:nt_isoice+n_iso-1,:,iblk)) enddo ! iblk @@ -457,7 +431,7 @@ subroutine init_restart if (restart_aero) then call read_restart_aero else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_aerosol(trcrn(:,:,nt_aero:nt_aero+4*n_aero-1,:,iblk)) enddo ! iblk endif ! .not. restart_aero diff --git a/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90 b/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90 index 77bb7738e..ad575f714 100644 --- a/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90 +++ b/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90 @@ -7,7 +7,7 @@ ! William H. Lipscomb, LANL ! ! 2006 ECH: moved exit timeLoop to prevent execution of unnecessary timestep -! 2006 ECH: Streamlined for efficiency +! 2006 ECH: Streamlined for efficiency ! 2006 ECH: Converted to free source form (F90) ! 2007 BPB: Modified Delta-Eddington shortwave interface ! 2008 ECH: moved ESMF code to its own driver @@ -41,9 +41,9 @@ module CICE_RunMod ! Philip W. Jones, LANL ! William H. Lipscomb, LANL - subroutine CICE_Run(stop_now_cpl) + subroutine CICE_Run - use ice_calendar, only: istep, istep1, dt, stop_now, advance_timestep + use ice_calendar, only: istep, istep1, time, dt, stop_now, calendar use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & @@ -54,7 +54,6 @@ subroutine CICE_Run(stop_now_cpl) logical (kind=log_kind) :: & tr_iso, tr_aero, tr_zaero, skl_bgc, z_tracers, wave_spec, tr_fsd character(len=*), parameter :: subname = '(CICE_Run)' - logical (kind=log_kind), optional, intent(in) :: stop_now_cpl !-------------------------------------------------------------------- ! initialize error code and step timer @@ -74,20 +73,21 @@ subroutine CICE_Run(stop_now_cpl) file=__FILE__, line=__LINE__) #ifndef CICE_IN_NEMO - !-------------------------------------------------------------------- - ! timestep loop - !-------------------------------------------------------------------- + !-------------------------------------------------------------------- + ! timestep loop + !-------------------------------------------------------------------- #ifndef CICE_DMI - timeLoop: do + timeLoop: do #endif #endif call ice_step - call advance_timestep() ! advance time + istep = istep + 1 ! update time step counters + istep1 = istep1 + 1 + time = time + dt ! determine the time and date + + call calendar(time) ! at the end of the timestep - if (present(stop_now_cpl)) then - if (stop_now_cpl) return - endif #ifndef CICE_IN_NEMO #ifndef CICE_DMI if (stop_now >= 1) exit timeLoop @@ -131,7 +131,7 @@ subroutine CICE_Run(stop_now_cpl) ! end of timestep loop !-------------------------------------------------------------------- - call ice_timer_stop(timer_step) ! end timestepping loop timer + call ice_timer_stop(timer_step) ! end timestepping loop timer end subroutine CICE_Run @@ -146,7 +146,7 @@ subroutine ice_step use ice_boundary, only: ice_HaloUpdate use ice_calendar, only: dt, dt_dyn, ndtd, diagfreq, write_restart, istep - use ice_diagnostics, only: init_mass_diags, runtime_diags, debug_model, debug_ice + use ice_diagnostics, only: init_mass_diags, runtime_diags use ice_diagnostics_bgc, only: hbrine_diags, zsal_diags, bgc_diags use ice_domain, only: halo_info, nblocks use ice_dyn_eap, only: write_restart_eap @@ -157,21 +157,20 @@ subroutine ice_step use ice_history_bgc, only: init_history_bgc use ice_restart, only: final_restart use ice_restart_column, only: write_restart_age, write_restart_FY, & - write_restart_lvl, write_restart_pond_lvl, & + write_restart_lvl, write_restart_pond_cesm, write_restart_pond_lvl, & write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_iso, write_restart_bgc, write_restart_hbrine, & - write_restart_snow + write_restart_iso, write_restart_bgc, write_restart_hbrine use ice_restart_driver, only: dumpfile use ice_restoring, only: restore_ice, ice_HaloRestore use ice_step_mod, only: prep_radiation, step_therm1, step_therm2, & update_state, step_dyn_horiz, step_dyn_ridge, step_radiation, & - biogeochemistry, step_prep, step_dyn_wave, step_snow + biogeochemistry, save_init, step_dyn_wave use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_diags, timer_column, timer_thermo, timer_bound, & timer_hist, timer_readwrite integer (kind=int_kind) :: & - iblk , & ! block index + iblk , & ! block index k , & ! dynamics supercycling index ktherm ! thermodynamics is off when ktherm = -1 @@ -179,28 +178,19 @@ subroutine ice_step offset ! d(age)/dt time offset logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_fsd, tr_snow, & - tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, & + tr_iage, tr_FY, tr_lvl, tr_fsd, & + tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, & calc_Tsfc, skl_bgc, solve_zsal, z_tracers, wave_spec character(len=*), parameter :: subname = '(ice_step)' - character (len=char_len) :: plabeld - - if (debug_model) then - plabeld = 'beginning time step' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - endif - call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc, skl_bgc_out=skl_bgc, & solve_zsal_out=solve_zsal, z_tracers_out=z_tracers, ktherm_out=ktherm, & wave_spec_out=wave_spec) call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & - tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_iso_out=tr_iso, tr_fsd_out=tr_fsd, tr_snow_out=tr_snow) + tr_iso_out=tr_iso, tr_fsd_out=tr_fsd) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) @@ -224,7 +214,7 @@ subroutine ice_step call ice_timer_start(timer_column) ! column physics call ice_timer_start(timer_thermo) ! thermodynamics - call step_prep + call save_init !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks @@ -237,36 +227,14 @@ subroutine ice_step if (calc_Tsfc) call prep_radiation (iblk) - if (debug_model) then - plabeld = 'post prep_radiation' - call debug_ice (iblk, plabeld) - endif - !----------------------------------------------------------------- ! thermodynamics and biogeochemistry !----------------------------------------------------------------- - + call step_therm1 (dt, iblk) ! vertical thermodynamics - - if (debug_model) then - plabeld = 'post step_therm1' - call debug_ice (iblk, plabeld) - endif - call biogeochemistry (dt, iblk) ! biogeochemistry - - if (debug_model) then - plabeld = 'post biogeochemistry' - call debug_ice (iblk, plabeld) - endif - call step_therm2 (dt, iblk) ! ice thickness distribution thermo - if (debug_model) then - plabeld = 'post step_therm2' - call debug_ice (iblk, plabeld) - endif - endif ! ktherm > 0 enddo ! iblk @@ -292,13 +260,6 @@ subroutine ice_step ! momentum, stress, transport call step_dyn_horiz (dt_dyn) - if (debug_model) then - plabeld = 'post step_dyn_horiz' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo ! iblk - endif - ! ridging !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks @@ -306,66 +267,31 @@ subroutine ice_step enddo !$OMP END PARALLEL DO - if (debug_model) then - plabeld = 'post step_dyn_ridge' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo ! iblk - endif - ! clean up, update tendency diagnostics offset = c0 call update_state (dt_dyn, daidtd, dvidtd, dagedtd, offset) enddo - if (debug_model) then - plabeld = 'post dynamics' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - endif - - call ice_timer_start(timer_column) ! column physics - call ice_timer_start(timer_thermo) ! thermodynamics - !----------------------------------------------------------------- - ! snow redistribution and metamorphosis + ! albedo, shortwave radiation !----------------------------------------------------------------- - if (tr_snow) then ! advanced snow physics - do iblk = 1, nblocks - call step_snow (dt, iblk) - enddo - call update_state (dt) ! clean up - endif + call ice_timer_start(timer_column) ! column physics + call ice_timer_start(timer_thermo) ! thermodynamics !MHRI: CHECK THIS OMP !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks - !----------------------------------------------------------------- - ! albedo, shortwave radiation - !----------------------------------------------------------------- - if (ktherm >= 0) call step_radiation (dt, iblk) - if (debug_model) then - plabeld = 'post step_radiation' - call debug_ice (iblk, plabeld) - endif - !----------------------------------------------------------------- ! get ready for coupling and the next time step !----------------------------------------------------------------- call coupling_prep (iblk) - if (debug_model) then - plabeld = 'post coupling_prep' - call debug_ice (iblk, plabeld) - endif - enddo ! iblk !$OMP END PARALLEL DO @@ -400,14 +326,14 @@ subroutine ice_step if (tr_iage) call write_restart_age if (tr_FY) call write_restart_FY if (tr_lvl) call write_restart_lvl + if (tr_pond_cesm) call write_restart_pond_cesm if (tr_pond_lvl) call write_restart_pond_lvl if (tr_pond_topo) call write_restart_pond_topo - if (tr_snow) call write_restart_snow if (tr_fsd) call write_restart_fsd if (tr_iso) call write_restart_iso if (tr_aero) call write_restart_aero if (solve_zsal .or. skl_bgc .or. z_tracers) & - call write_restart_bgc + call write_restart_bgc if (tr_brine) call write_restart_hbrine if (kdyn == 2) call write_restart_eap call final_restart @@ -416,7 +342,7 @@ subroutine ice_step call ice_timer_stop(timer_readwrite) ! reading/writing end subroutine ice_step - + !======================================================================= ! ! Prepare for coupling @@ -435,8 +361,7 @@ subroutine coupling_prep (iblk) albpnd, albcnt, apeff_ai, fpond, fresh, l_mpond_fresh, & alvdf_ai, alidf_ai, alvdr_ai, alidr_ai, fhocn_ai, & fresh_ai, fsalt_ai, fsalt, & - fswthru_ai, fhocn, scale_factor, snowfrac, & - fswthru, fswthru_vdr, fswthru_vdf, fswthru_idr, fswthru_idf, & + fswthru_ai, fhocn, fswthru, scale_factor, snowfrac, & swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyT, & fsens, flat, fswabs, flwout, evap, Tref, Qref, & scale_fluxes, frzmlt_init, frzmlt @@ -451,12 +376,12 @@ subroutine coupling_prep (iblk) use ice_step_mod, only: ocean_mixed_layer use ice_timers, only: timer_couple, ice_timer_start, ice_timer_stop - integer (kind=int_kind), intent(in) :: & - iblk ! block index + integer (kind=int_kind), intent(in) :: & + iblk ! block index ! local variables - integer (kind=int_kind) :: & + integer (kind=int_kind) :: & ilo,ihi,jlo,jhi, & ! beginning and end of physical domain n , & ! thickness category index i,j , & ! horizontal indices @@ -495,7 +420,7 @@ subroutine coupling_prep (iblk) enddo enddo - call ice_timer_start(timer_couple,iblk) ! atm/ocn coupling + call ice_timer_start(timer_couple) ! atm/ocn coupling if (oceanmixed_ice) & call ocean_mixed_layer (dt,iblk) ! ocean surface fluxes and sst @@ -592,8 +517,8 @@ subroutine coupling_prep (iblk) fsalt_ai (i,j,iblk) = fsalt (i,j,iblk) fhocn_ai (i,j,iblk) = fhocn (i,j,iblk) fswthru_ai(i,j,iblk) = fswthru(i,j,iblk) - fzsal_ai (i,j,iblk) = fzsal (i,j,iblk) - fzsal_g_ai(i,j,iblk) = fzsal_g(i,j,iblk) + fzsal_ai (i,j,iblk) = fzsal (i,j,iblk) + fzsal_g_ai(i,j,iblk) = fzsal_g(i,j,iblk) if (nbtrcr > 0) then do k = 1, nbtrcr @@ -614,7 +539,7 @@ subroutine coupling_prep (iblk) enddo !----------------------------------------------------------------- - ! Divide fluxes by ice area + ! Divide fluxes by ice area ! - the CESM coupler assumes fluxes are per unit ice area ! - also needed for global budget in diagnostics !----------------------------------------------------------------- @@ -630,12 +555,7 @@ subroutine coupling_prep (iblk) evap (:,:,iblk), & Tref (:,:,iblk), Qref (:,:,iblk), & fresh (:,:,iblk), fsalt (:,:,iblk), & - fhocn (:,:,iblk), & - fswthru (:,:,iblk), & - fswthru_vdr (:,:,iblk), & - fswthru_vdf (:,:,iblk), & - fswthru_idr (:,:,iblk), & - fswthru_idf (:,:,iblk), & + fhocn (:,:,iblk), fswthru (:,:,iblk), & faero_ocn(:,:,:,iblk), & alvdr (:,:,iblk), alidr (:,:,iblk), & alvdf (:,:,iblk), alidf (:,:,iblk), & @@ -644,25 +564,25 @@ subroutine coupling_prep (iblk) Qref_iso =Qref_iso (:,:,:,iblk), & fiso_evap=fiso_evap(:,:,:,iblk), & fiso_ocn =fiso_ocn (:,:,:,iblk)) - + #ifdef CICE_IN_NEMO !echmod - comment this out for efficiency, if .not. calc_Tsfc if (.not. calc_Tsfc) then !--------------------------------------------------------------- - ! If surface fluxes were provided, conserve these fluxes at ice - ! free points by passing to ocean. + ! If surface fluxes were provided, conserve these fluxes at ice + ! free points by passing to ocean. !--------------------------------------------------------------- - call sfcflux_to_ocn & + call sfcflux_to_ocn & (nx_block, ny_block, & tmask (:,:,iblk), aice_init(:,:,iblk), & fsurfn_f (:,:,:,iblk), flatn_f(:,:,:,iblk), & fresh (:,:,iblk), fhocn (:,:,iblk)) - endif + endif !echmod #endif - call ice_timer_stop(timer_couple,iblk) ! atm/ocn coupling + call ice_timer_stop(timer_couple) ! atm/ocn coupling end subroutine coupling_prep @@ -671,10 +591,10 @@ end subroutine coupling_prep !======================================================================= ! ! If surface heat fluxes are provided to CICE instead of CICE calculating -! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can +! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can ! be provided at points which do not have ice. (This is could be due to ! the heat fluxes being calculated on a lower resolution grid or the -! heat fluxes not recalculated at every CICE timestep.) At ice free points, +! heat fluxes not recalculated at every CICE timestep.) At ice free points, ! conserve energy and water by passing these fluxes to the ocean. ! ! author: A. McLaren, Met Office @@ -707,15 +627,14 @@ subroutine sfcflux_to_ocn(nx_block, ny_block, & ! local variables integer (kind=int_kind) :: & i, j, n ! horizontal indices - + real (kind=dbl_kind) :: & puny, & ! - Lsub, & ! rLsub ! 1/Lsub character(len=*), parameter :: subname = '(sfcflux_to_ocn)' - call icepack_query_parameters(puny_out=puny, Lsub_out=Lsub) + call icepack_query_parameters(puny_out=puny) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) diff --git a/cicecore/drivers/standalone/cice/CICE_InitMod.F90 b/cicecore/drivers/standalone/cice/CICE_InitMod.F90 index dc9fece6e..59bbca31c 100644 --- a/cicecore/drivers/standalone/cice/CICE_InitMod.F90 +++ b/cicecore/drivers/standalone/cice/CICE_InitMod.F90 @@ -15,11 +15,9 @@ module CICE_InitMod use ice_kinds_mod use ice_exit, only: abort_ice use ice_fileunits, only: init_fileunits, nu_diag - use ice_memusage, only: ice_memusage_init, ice_memusage_print use icepack_intfc, only: icepack_aggregate use icepack_intfc, only: icepack_init_itd, icepack_init_itd_hist use icepack_intfc, only: icepack_init_fsd_bounds, icepack_init_wave - use icepack_intfc, only: icepack_init_snow use icepack_intfc, only: icepack_configure use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted use icepack_intfc, only: icepack_query_parameters, icepack_query_tracer_flags, & @@ -66,20 +64,18 @@ subroutine cice_init floe_binwidth, c_fsd_range use ice_state, only: alloc_state use ice_flux_bgc, only: alloc_flux_bgc - use ice_calendar, only: dt, dt_dyn, write_ic, & - init_calendar, advance_timestep, calc_timesteps + use ice_calendar, only: dt, dt_dyn, time, istep, istep1, write_ic, & + init_calendar, calendar use ice_communicate, only: init_communicate, my_task, master_task use ice_diagnostics, only: init_diags use ice_domain, only: init_domain_blocks use ice_domain_size, only: ncat, nfsd - use ice_dyn_eap, only: init_eap - use ice_dyn_evp, only: init_evp - use ice_dyn_vp, only: init_vp - use ice_dyn_shared, only: kdyn + use ice_dyn_eap, only: init_eap, alloc_dyn_eap + use ice_dyn_shared, only: kdyn, init_evp, alloc_dyn_shared use ice_flux, only: init_coupler_flux, init_history_therm, & init_history_dyn, init_flux_atm, init_flux_ocn, alloc_flux use ice_forcing, only: init_forcing_ocn, init_forcing_atmo, & - get_forcing_atmo, get_forcing_ocn, get_wave_spec, init_snowtable + get_forcing_atmo, get_forcing_ocn, get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & faero_default, faero_optics, alloc_forcing_bgc, fiso_default use ice_grid, only: init_grid1, init_grid2, alloc_grid @@ -91,10 +87,12 @@ subroutine cice_init use ice_restoring, only: ice_HaloRestore_init use ice_timers, only: timer_total, init_ice_timers, ice_timer_start use ice_transport_driver, only: init_transport +#ifdef popcice + use drv_forcing, only: sst_sss +#endif logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers, & - tr_iso, tr_fsd, wave_spec, tr_snow - character(len=char_len) :: snw_aging_table + tr_iso, tr_fsd, wave_spec character(len=*), parameter :: subname = '(cice_init)' call init_communicate ! initial setup for message passing @@ -112,17 +110,12 @@ subroutine cice_init call input_zbgc ! vertical biogeochemistry namelist call count_tracers ! count tracers - ! Call this as early as possible, must be after memory_stats is read - if (my_task == master_task) then - call ice_memusage_init(nu_diag) - call ice_memusage_print(nu_diag,subname//':start') - endif - call init_domain_blocks ! set up block decomposition call init_grid1 ! domain distribution call alloc_grid ! allocate grid arrays call alloc_arrays_column ! allocate column arrays call alloc_state ! allocate state arrays + call alloc_dyn_shared ! allocate dyn shared arrays call alloc_flux_bgc ! allocate flux_bgc arrays call alloc_flux ! allocate flux arrays call init_ice_timers ! initialize all timers @@ -132,16 +125,18 @@ subroutine cice_init call init_calendar ! initialize some calendar stuff call init_hist (dt) ! initialize output history file - if (kdyn == 1) then - call init_evp - else if (kdyn == 2) then - call init_eap ! define eap dynamics parameters, variables - else if (kdyn == 3) then - call init_vp ! define vp dynamics parameters, variables + if (kdyn == 2) then + call alloc_dyn_eap ! allocate dyn_eap arrays + call init_eap (dt_dyn) ! define eap dynamics parameters, variables + else ! for both kdyn = 0 or 1 + call init_evp (dt_dyn) ! define evp dynamics parameters, variables endif call init_coupler_flux ! initialize fluxes exchanged with coupler +#ifdef popcice + call sst_sss ! POP data for CICE initialization +#endif call init_thermo_vertical ! initialize vertical thermodynamics call icepack_init_itd(ncat=ncat, hin_max=hin_max) ! ice thickness distribution @@ -165,13 +160,15 @@ subroutine cice_init if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) +! call calendar(time) ! determine the initial date + call init_forcing_ocn(dt) ! initialize sss and sst from data call init_state ! initialize the ice state call init_transport ! initialize horizontal transport call ice_HaloRestore_init ! restored boundary conditions call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers, & - wave_spec_out=wave_spec, snw_aging_table_out=snw_aging_table) + wave_spec_out=wave_spec) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) @@ -182,31 +179,26 @@ subroutine cice_init call init_diags ! initialize diagnostic output points call init_history_therm ! initialize thermo history variables call init_history_dyn ! initialize dynamic history variables - call calc_timesteps ! update timestep counter if not using npt_unit="1" call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero) - call icepack_query_tracer_flags(tr_iso_out=tr_iso, tr_snow_out=tr_snow) + call icepack_query_tracer_flags(tr_iso_out=tr_iso) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) - if (tr_aero .or. tr_zaero) call faero_optics !initialize aerosol optical + if (tr_aero .or. tr_zaero) call faero_optics !initialize aerosol optical !property tables - ! Initialize shortwave components using swdn from previous timestep - ! if restarting. These components will be scaled to current forcing + ! Initialize shortwave components using swdn from previous timestep + ! if restarting. These components will be scaled to current forcing ! in prep_radiation. if (trim(runtype) == 'continue' .or. restart) & call init_shortwave ! initialize radiative transfer - if (write_ic) call accum_hist(dt) ! write initial conditions - -! tcraig, use advance_timestep here -! istep = istep + 1 ! update time step counters -! istep1 = istep1 + 1 -! time = time + dt ! determine the time and date -! call calendar(time) ! at the end of the first timestep - call advance_timestep() + istep = istep + 1 ! update time step counters + istep1 = istep1 + 1 + time = time + dt ! determine the time and date + call calendar(time) ! at the end of the first timestep !-------------------------------------------------------------------- ! coupler communication or forcing data initialization @@ -214,29 +206,21 @@ subroutine cice_init call init_forcing_atmo ! initialize atmospheric forcing (standalone) +#ifndef coupled +#ifndef CESMCOUPLED if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice call get_forcing_atmo ! atmospheric forcing from data call get_forcing_ocn(dt) ! ocean forcing from data - ! snow aging lookup table initialization - if (tr_snow) then ! advanced snow physics - call icepack_init_snow() - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - if (snw_aging_table(1:4) /= 'test') then - call init_snowtable() - endif - endif - ! isotopes if (tr_iso) call fiso_default ! default values - ! aerosols ! if (tr_aero) call faero_data ! data file ! if (tr_zaero) call fzaero_data ! data file (gx1) if (tr_aero .or. tr_zaero) call faero_default ! default values if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry +#endif +#endif if (z_tracers) call get_atm_bgc ! biogeochemistry if (runtype == 'initial' .and. .not. restart) & @@ -245,9 +229,7 @@ subroutine cice_init call init_flux_atm ! initialize atmosphere fluxes sent to coupler call init_flux_ocn ! initialize ocean fluxes sent to coupler - if (my_task == master_task) then - call ice_memusage_print(nu_diag,subname//':end') - endif + if (write_ic) call accum_hist(dt) ! write initial conditions end subroutine cice_init @@ -257,27 +239,27 @@ subroutine init_restart use ice_arrays_column, only: dhsn use ice_blocks, only: nx_block, ny_block - use ice_calendar, only: calendar + use ice_calendar, only: time, calendar use ice_constants, only: c0 use ice_domain, only: nblocks - use ice_domain_size, only: ncat, n_iso, n_aero, nfsd, nslyr + use ice_domain_size, only: ncat, n_iso, n_aero, nfsd use ice_dyn_eap, only: read_restart_eap use ice_dyn_shared, only: kdyn use ice_grid, only: tmask use ice_init, only: ice_ic - use ice_init_column, only: init_age, init_FY, init_lvl, init_snowtracers, & - init_meltponds_lvl, init_meltponds_topo, & + use ice_init_column, only: init_age, init_FY, init_lvl, & + init_meltponds_cesm, init_meltponds_lvl, init_meltponds_topo, & init_isotope, init_aerosol, init_hbrine, init_bgc, init_fsd use ice_restart_column, only: restart_age, read_restart_age, & restart_FY, read_restart_FY, restart_lvl, read_restart_lvl, & + restart_pond_cesm, read_restart_pond_cesm, & restart_pond_lvl, read_restart_pond_lvl, & restart_pond_topo, read_restart_pond_topo, & - restart_snow, read_restart_snow, & restart_fsd, read_restart_fsd, & restart_iso, read_restart_iso, & restart_aero, read_restart_aero, & restart_hbrine, read_restart_hbrine, & - restart_bgc + restart_zsal, restart_bgc use ice_restart_driver, only: restartfile use ice_restart_shared, only: runtype, restart use ice_state ! almost everything @@ -286,14 +268,13 @@ subroutine init_restart i, j , & ! horizontal indices iblk ! block index logical(kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_pond_lvl, & - tr_pond_topo, tr_snow, tr_fsd, tr_iso, tr_aero, tr_brine, & - skl_bgc, z_tracers + tr_iage, tr_FY, tr_lvl, tr_pond_cesm, tr_pond_lvl, & + tr_pond_topo, tr_fsd, tr_iso, tr_aero, tr_brine, & + skl_bgc, z_tracers, solve_zsal integer(kind=int_kind) :: & ntrcr integer(kind=int_kind) :: & nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd, & - nt_smice, nt_smliq, nt_rhos, nt_rsnw, & nt_iage, nt_FY, nt_aero, nt_fsd, nt_isosno, nt_isoice character(len=*), parameter :: subname = '(init_restart)' @@ -304,25 +285,23 @@ subroutine init_restart file=__FILE__, line=__LINE__) call icepack_query_parameters(skl_bgc_out=skl_bgc, & - z_tracers_out=z_tracers) + z_tracers_out=z_tracers, solve_zsal_out=solve_zsal) call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & - tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & tr_pond_topo_out=tr_pond_topo, tr_aero_out=tr_aero, tr_brine_out=tr_brine, & - tr_snow_out=tr_snow, tr_fsd_out=tr_fsd, tr_iso_out=tr_iso) + tr_fsd_out=tr_fsd, tr_iso_out=tr_iso) call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, & nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, & nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_aero_out=nt_aero, nt_fsd_out=nt_fsd, & - nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, & - nt_rhos_out=nt_rhos, nt_rsnw_out=nt_rsnw, & nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - if (trim(runtype) == 'continue') then + if (trim(runtype) == 'continue') then ! start from core restart file call restartfile() ! given by pointer in ice_in - call calendar() ! update time parameters + call calendar(time) ! update time parameters if (kdyn == 2) call read_restart_eap ! EAP else if (restart) then ! ice_ic = core restart file call restartfile (ice_ic) ! or 'default' or 'none' @@ -330,17 +309,17 @@ subroutine init_restart ! call restartfile_v4 (ice_ic) ! CICE v4.1 binary restart file !!! uncomment if EAP restart data exists ! if (kdyn == 2) call read_restart_eap - endif + endif ! tracers - ! ice age tracer - if (tr_iage) then + ! ice age tracer + if (tr_iage) then if (trim(runtype) == 'continue') & restart_age = .true. if (restart_age) then call read_restart_age else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_age(trcrn(:,:,nt_iage,:,iblk)) enddo ! iblk endif @@ -351,7 +330,7 @@ subroutine init_restart if (restart_FY) then call read_restart_FY else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_FY(trcrn(:,:,nt_FY,:,iblk)) enddo ! iblk endif @@ -362,12 +341,25 @@ subroutine init_restart if (restart_lvl) then call read_restart_lvl else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_lvl(iblk,trcrn(:,:,nt_alvl,:,iblk), & trcrn(:,:,nt_vlvl,:,iblk)) enddo ! iblk endif endif + ! CESM melt ponds + if (tr_pond_cesm) then + if (trim(runtype) == 'continue') & + restart_pond_cesm = .true. + if (restart_pond_cesm) then + call read_restart_pond_cesm + else + do iblk = 1, nblocks + call init_meltponds_cesm(trcrn(:,:,nt_apnd,:,iblk), & + trcrn(:,:,nt_hpnd,:,iblk)) + enddo ! iblk + endif + endif ! level-ice melt ponds if (tr_pond_lvl) then if (trim(runtype) == 'continue') & @@ -375,7 +367,7 @@ subroutine init_restart if (restart_pond_lvl) then call read_restart_pond_lvl else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_meltponds_lvl(trcrn(:,:,nt_apnd,:,iblk), & trcrn(:,:,nt_hpnd,:,iblk), & trcrn(:,:,nt_ipnd,:,iblk), & @@ -390,29 +382,13 @@ subroutine init_restart if (restart_pond_topo) then call read_restart_pond_topo else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_meltponds_topo(trcrn(:,:,nt_apnd,:,iblk), & trcrn(:,:,nt_hpnd,:,iblk), & trcrn(:,:,nt_ipnd,:,iblk)) enddo ! iblk endif ! .not. restart_pond endif - - ! snow redistribution/metamorphism - if (tr_snow) then - if (trim(runtype) == 'continue') restart_snow = .true. - if (restart_snow) then - call read_restart_snow - else - do iblk = 1, nblocks - call init_snowtracers(trcrn(:,:,nt_smice:nt_smice+nslyr-1,:,iblk), & - trcrn(:,:,nt_smliq:nt_smliq+nslyr-1,:,iblk), & - trcrn(:,:,nt_rhos :nt_rhos +nslyr-1,:,iblk), & - trcrn(:,:,nt_rsnw :nt_rsnw +nslyr-1,:,iblk)) - enddo ! iblk - endif - endif - ! floe size distribution if (tr_fsd) then if (trim(runtype) == 'continue') restart_fsd = .true. @@ -429,7 +405,7 @@ subroutine init_restart if (restart_iso) then call read_restart_iso else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_isotope(trcrn(:,:,nt_isosno:nt_isosno+n_iso-1,:,iblk), & trcrn(:,:,nt_isoice:nt_isoice+n_iso-1,:,iblk)) enddo ! iblk @@ -441,7 +417,7 @@ subroutine init_restart if (restart_aero) then call read_restart_aero else - do iblk = 1, nblocks + do iblk = 1, nblocks call init_aerosol(trcrn(:,:,nt_aero:nt_aero+4*n_aero-1,:,iblk)) enddo ! iblk endif ! .not. restart_aero @@ -450,6 +426,8 @@ subroutine init_restart if (trim(runtype) == 'continue') then if (tr_brine) & restart_hbrine = .true. + if (solve_zsal) & + restart_zsal = .true. if (skl_bgc .or. z_tracers) & restart_bgc = .true. endif @@ -459,7 +437,7 @@ subroutine init_restart if (tr_brine .and. restart_hbrine) call read_restart_hbrine endif - if (skl_bgc .or. z_tracers) then ! biogeochemistry + if (solve_zsal .or. skl_bgc .or. z_tracers) then ! biogeochemistry if (tr_fsd) then write (nu_diag,*) 'FSD implementation incomplete for use with BGC' call icepack_warnings_flush(nu_diag) diff --git a/cicecore/drivers/standalone/cice/CICE_RunMod.F90 b/cicecore/drivers/standalone/cice/CICE_RunMod.F90 index 42514e06c..7645c43f3 100644 --- a/cicecore/drivers/standalone/cice/CICE_RunMod.F90 +++ b/cicecore/drivers/standalone/cice/CICE_RunMod.F90 @@ -7,7 +7,7 @@ ! William H. Lipscomb, LANL ! ! 2006 ECH: moved exit timeLoop to prevent execution of unnecessary timestep -! 2006 ECH: Streamlined for efficiency +! 2006 ECH: Streamlined for efficiency ! 2006 ECH: Converted to free source form (F90) ! 2007 BPB: Modified Delta-Eddington shortwave interface ! 2008 ECH: moved ESMF code to its own driver @@ -15,13 +15,11 @@ module CICE_RunMod use ice_kinds_mod - use ice_communicate, only: my_task, master_task use ice_fileunits, only: nu_diag use ice_arrays_column, only: oceanmixed_ice use ice_constants, only: c0, c1 use ice_constants, only: field_loc_center, field_type_scalar use ice_exit, only: abort_ice - use ice_memusage, only: ice_memusage_print use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted use icepack_intfc, only: icepack_max_iso, icepack_max_aero use icepack_intfc, only: icepack_query_parameters @@ -45,7 +43,7 @@ module CICE_RunMod subroutine CICE_Run - use ice_calendar, only: dt, stop_now, advance_timestep + use ice_calendar, only: istep, istep1, time, dt, stop_now, calendar use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & @@ -84,12 +82,11 @@ subroutine CICE_Run call ice_step -! tcraig, use advance_timestep now -! istep = istep + 1 ! update time step counters -! istep1 = istep1 + 1 -! time = time + dt ! determine the time and date -! call calendar(time) ! at the end of the timestep - call advance_timestep() ! advance time + istep = istep + 1 ! update time step counters + istep1 = istep1 + 1 + time = time + dt ! determine the time and date + + call calendar(time) ! at the end of the timestep #ifndef CICE_IN_NEMO if (stop_now >= 1) exit timeLoop @@ -97,6 +94,8 @@ subroutine CICE_Run call ice_timer_start(timer_couple) ! atm/ocn coupling +#ifndef coupled +#ifndef CESMCOUPLED ! for now, wave_spectrum is constant in time ! if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice call get_forcing_atmo ! atmospheric forcing from data @@ -110,6 +109,8 @@ subroutine CICE_Run if (tr_aero .or. tr_zaero) call faero_default ! default values if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry +#endif +#endif if (z_tracers) call get_atm_bgc ! biogeochemistry call init_flux_atm ! Initialize atmosphere fluxes sent to coupler @@ -125,7 +126,7 @@ subroutine CICE_Run ! end of timestep loop !-------------------------------------------------------------------- - call ice_timer_stop(timer_step) ! end timestepping loop timer + call ice_timer_stop(timer_step) ! end timestepping loop timer end subroutine CICE_Run @@ -140,8 +141,8 @@ subroutine ice_step use ice_boundary, only: ice_HaloUpdate use ice_calendar, only: dt, dt_dyn, ndtd, diagfreq, write_restart, istep - use ice_diagnostics, only: init_mass_diags, runtime_diags, debug_model, debug_ice - use ice_diagnostics_bgc, only: hbrine_diags, bgc_diags + use ice_diagnostics, only: init_mass_diags, runtime_diags + use ice_diagnostics_bgc, only: hbrine_diags, zsal_diags, bgc_diags use ice_domain, only: halo_info, nblocks use ice_dyn_eap, only: write_restart_eap use ice_dyn_shared, only: kdyn, kridge @@ -151,21 +152,20 @@ subroutine ice_step use ice_history_bgc, only: init_history_bgc use ice_restart, only: final_restart use ice_restart_column, only: write_restart_age, write_restart_FY, & - write_restart_lvl, write_restart_pond_lvl, & + write_restart_lvl, write_restart_pond_cesm, write_restart_pond_lvl, & write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_iso, write_restart_bgc, write_restart_hbrine, & - write_restart_snow + write_restart_iso, write_restart_bgc, write_restart_hbrine use ice_restart_driver, only: dumpfile use ice_restoring, only: restore_ice, ice_HaloRestore use ice_step_mod, only: prep_radiation, step_therm1, step_therm2, & update_state, step_dyn_horiz, step_dyn_ridge, step_radiation, & - biogeochemistry, step_prep, step_dyn_wave, step_snow + biogeochemistry, save_init, step_dyn_wave use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_diags, timer_column, timer_thermo, timer_bound, & timer_hist, timer_readwrite integer (kind=int_kind) :: & - iblk , & ! block index + iblk , & ! block index k , & ! dynamics supercycling index ktherm ! thermodynamics is off when ktherm = -1 @@ -173,27 +173,19 @@ subroutine ice_step offset ! d(age)/dt time offset logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_fsd, tr_snow, & - tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, & - calc_Tsfc, skl_bgc, z_tracers, wave_spec + tr_iage, tr_FY, tr_lvl, tr_fsd, & + tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, & + calc_Tsfc, skl_bgc, solve_zsal, z_tracers, wave_spec character(len=*), parameter :: subname = '(ice_step)' - character (len=char_len) :: plabeld - - if (debug_model) then - plabeld = 'beginning time step' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - endif - call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc, skl_bgc_out=skl_bgc, & - z_tracers_out=z_tracers, ktherm_out=ktherm, wave_spec_out=wave_spec) + solve_zsal_out=solve_zsal, z_tracers_out=z_tracers, ktherm_out=ktherm, & + wave_spec_out=wave_spec) call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & - tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_iso_out=tr_iso, tr_fsd_out=tr_fsd, tr_snow_out=tr_snow) + tr_iso_out=tr_iso, tr_fsd_out=tr_fsd) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) @@ -217,11 +209,12 @@ subroutine ice_step call ice_timer_start(timer_column) ! column physics call ice_timer_start(timer_thermo) ! thermodynamics - call step_prep + call save_init - if (ktherm >= 0) then - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) - do iblk = 1, nblocks + !$OMP PARALLEL DO PRIVATE(iblk) + do iblk = 1, nblocks + + if (ktherm >= 0) then !----------------------------------------------------------------- ! scale radiation fields @@ -229,39 +222,18 @@ subroutine ice_step if (calc_Tsfc) call prep_radiation (iblk) - if (debug_model) then - plabeld = 'post prep_radiation' - call debug_ice (iblk, plabeld) - endif - !----------------------------------------------------------------- ! thermodynamics and biogeochemistry !----------------------------------------------------------------- - + call step_therm1 (dt, iblk) ! vertical thermodynamics - - if (debug_model) then - plabeld = 'post step_therm1' - call debug_ice (iblk, plabeld) - endif - call biogeochemistry (dt, iblk) ! biogeochemistry - - if (debug_model) then - plabeld = 'post biogeochemistry' - call debug_ice (iblk, plabeld) - endif - call step_therm2 (dt, iblk) ! ice thickness distribution thermo - if (debug_model) then - plabeld = 'post step_therm2' - call debug_ice (iblk, plabeld) - endif + endif ! ktherm > 0 - enddo - !$OMP END PARALLEL DO - endif ! ktherm > 0 + enddo ! iblk + !$OMP END PARALLEL DO ! clean up, update tendency diagnostics offset = dt @@ -283,81 +255,38 @@ subroutine ice_step ! momentum, stress, transport call step_dyn_horiz (dt_dyn) - if (debug_model) then - plabeld = 'post step_dyn_horiz' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo ! iblk - endif - ! ridging - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) + !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks if (kridge > 0) call step_dyn_ridge (dt_dyn, ndtd, iblk) enddo !$OMP END PARALLEL DO - if (debug_model) then - plabeld = 'post step_dyn_ridge' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo ! iblk - endif - ! clean up, update tendency diagnostics offset = c0 call update_state (dt_dyn, daidtd, dvidtd, dagedtd, offset) enddo - if (debug_model) then - plabeld = 'post dynamics' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - endif - - call ice_timer_start(timer_column) ! column physics - call ice_timer_start(timer_thermo) ! thermodynamics - !----------------------------------------------------------------- - ! snow redistribution and metamorphosis + ! albedo, shortwave radiation !----------------------------------------------------------------- - if (tr_snow) then ! advanced snow physics - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) - do iblk = 1, nblocks - call step_snow (dt, iblk) - enddo - !$OMP END PARALLEL DO - call update_state (dt) ! clean up - endif + call ice_timer_start(timer_column) ! column physics + call ice_timer_start(timer_thermo) ! thermodynamics - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) +!MHRI: CHECK THIS OMP + !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks - !----------------------------------------------------------------- - ! albedo, shortwave radiation - !----------------------------------------------------------------- - if (ktherm >= 0) call step_radiation (dt, iblk) - if (debug_model) then - plabeld = 'post step_radiation' - call debug_ice (iblk, plabeld) - endif - !----------------------------------------------------------------- ! get ready for coupling and the next time step !----------------------------------------------------------------- call coupling_prep (iblk) - if (debug_model) then - plabeld = 'post coupling_prep' - call debug_ice (iblk, plabeld) - endif - enddo ! iblk !$OMP END PARALLEL DO @@ -376,11 +305,9 @@ subroutine ice_step call ice_timer_start(timer_diags) ! diagnostics if (mod(istep,diagfreq) == 0) then call runtime_diags(dt) ! log file + if (solve_zsal) call zsal_diags if (skl_bgc .or. z_tracers) call bgc_diags if (tr_brine) call hbrine_diags - if (my_task == master_task) then - call ice_memusage_print(nu_diag,subname) - endif endif call ice_timer_stop(timer_diags) ! diagnostics @@ -394,22 +321,23 @@ subroutine ice_step if (tr_iage) call write_restart_age if (tr_FY) call write_restart_FY if (tr_lvl) call write_restart_lvl + if (tr_pond_cesm) call write_restart_pond_cesm if (tr_pond_lvl) call write_restart_pond_lvl if (tr_pond_topo) call write_restart_pond_topo - if (tr_snow) call write_restart_snow if (tr_fsd) call write_restart_fsd if (tr_iso) call write_restart_iso if (tr_aero) call write_restart_aero - if (skl_bgc .or. z_tracers) & - call write_restart_bgc + if (solve_zsal .or. skl_bgc .or. z_tracers) & + call write_restart_bgc if (tr_brine) call write_restart_hbrine if (kdyn == 2) call write_restart_eap call final_restart endif + call ice_timer_stop(timer_readwrite) ! reading/writing end subroutine ice_step - + !======================================================================= ! ! Prepare for coupling @@ -419,7 +347,7 @@ end subroutine ice_step subroutine coupling_prep (iblk) use ice_arrays_column, only: alvdfn, alidfn, alvdrn, alidrn, & - albicen, albsnon, albpndn, apeffn, snowfracn + albicen, albsnon, albpndn, apeffn, fzsal_g, fzsal, snowfracn use ice_blocks, only: nx_block, ny_block, get_block, block use ice_domain, only: blocks_ice use ice_calendar, only: dt, nstreams @@ -428,13 +356,12 @@ subroutine coupling_prep (iblk) albpnd, albcnt, apeff_ai, fpond, fresh, l_mpond_fresh, & alvdf_ai, alidf_ai, alvdr_ai, alidr_ai, fhocn_ai, & fresh_ai, fsalt_ai, fsalt, & - fswthru_ai, fhocn, scale_factor, snowfrac, & - fswthru, fswthru_vdr, fswthru_vdf, fswthru_idr, fswthru_idf, & + fswthru_ai, fhocn, fswthru, scale_factor, snowfrac, & swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyT, & fsens, flat, fswabs, flwout, evap, Tref, Qref, & scale_fluxes, frzmlt_init, frzmlt use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, & - flux_bio, flux_bio_ai + fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai use ice_grid, only: tmask use ice_state, only: aicen, aice #ifdef CICE_IN_NEMO @@ -444,12 +371,12 @@ subroutine coupling_prep (iblk) use ice_step_mod, only: ocean_mixed_layer use ice_timers, only: timer_couple, ice_timer_start, ice_timer_stop - integer (kind=int_kind), intent(in) :: & - iblk ! block index + integer (kind=int_kind), intent(in) :: & + iblk ! block index ! local variables - integer (kind=int_kind) :: & + integer (kind=int_kind) :: & ilo,ihi,jlo,jhi, & ! beginning and end of physical domain n , & ! thickness category index i,j , & ! horizontal indices @@ -488,7 +415,7 @@ subroutine coupling_prep (iblk) enddo enddo - call ice_timer_start(timer_couple,iblk) ! atm/ocn coupling + call ice_timer_start(timer_couple) ! atm/ocn coupling if (oceanmixed_ice) & call ocean_mixed_layer (dt,iblk) ! ocean surface fluxes and sst @@ -585,6 +512,8 @@ subroutine coupling_prep (iblk) fsalt_ai (i,j,iblk) = fsalt (i,j,iblk) fhocn_ai (i,j,iblk) = fhocn (i,j,iblk) fswthru_ai(i,j,iblk) = fswthru(i,j,iblk) + fzsal_ai (i,j,iblk) = fzsal (i,j,iblk) + fzsal_g_ai(i,j,iblk) = fzsal_g(i,j,iblk) if (nbtrcr > 0) then do k = 1, nbtrcr @@ -605,7 +534,7 @@ subroutine coupling_prep (iblk) enddo !----------------------------------------------------------------- - ! Divide fluxes by ice area + ! Divide fluxes by ice area ! - the CESM coupler assumes fluxes are per unit ice area ! - also needed for global budget in diagnostics !----------------------------------------------------------------- @@ -621,38 +550,34 @@ subroutine coupling_prep (iblk) evap (:,:,iblk), & Tref (:,:,iblk), Qref (:,:,iblk), & fresh (:,:,iblk), fsalt (:,:,iblk), & - fhocn (:,:,iblk), & - fswthru (:,:,iblk), & - fswthru_vdr (:,:,iblk), & - fswthru_vdf (:,:,iblk), & - fswthru_idr (:,:,iblk), & - fswthru_idf (:,:,iblk), & + fhocn (:,:,iblk), fswthru (:,:,iblk), & faero_ocn(:,:,:,iblk), & alvdr (:,:,iblk), alidr (:,:,iblk), & alvdf (:,:,iblk), alidf (:,:,iblk), & - flux_bio =flux_bio (:,:,1:nbtrcr,iblk), & + fzsal (:,:,iblk), fzsal_g (:,:,iblk), & + flux_bio (:,:,1:nbtrcr,iblk), & Qref_iso =Qref_iso (:,:,:,iblk), & fiso_evap=fiso_evap(:,:,:,iblk), & fiso_ocn =fiso_ocn (:,:,:,iblk)) - + #ifdef CICE_IN_NEMO !echmod - comment this out for efficiency, if .not. calc_Tsfc if (.not. calc_Tsfc) then !--------------------------------------------------------------- - ! If surface fluxes were provided, conserve these fluxes at ice - ! free points by passing to ocean. + ! If surface fluxes were provided, conserve these fluxes at ice + ! free points by passing to ocean. !--------------------------------------------------------------- - call sfcflux_to_ocn & + call sfcflux_to_ocn & (nx_block, ny_block, & tmask (:,:,iblk), aice_init(:,:,iblk), & fsurfn_f (:,:,:,iblk), flatn_f(:,:,:,iblk), & fresh (:,:,iblk), fhocn (:,:,iblk)) - endif + endif !echmod #endif - call ice_timer_stop(timer_couple,iblk) ! atm/ocn coupling + call ice_timer_stop(timer_couple) ! atm/ocn coupling end subroutine coupling_prep @@ -661,10 +586,10 @@ end subroutine coupling_prep !======================================================================= ! ! If surface heat fluxes are provided to CICE instead of CICE calculating -! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can +! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can ! be provided at points which do not have ice. (This is could be due to ! the heat fluxes being calculated on a lower resolution grid or the -! heat fluxes not recalculated at every CICE timestep.) At ice free points, +! heat fluxes not recalculated at every CICE timestep.) At ice free points, ! conserve energy and water by passing these fluxes to the ocean. ! ! author: A. McLaren, Met Office @@ -697,15 +622,14 @@ subroutine sfcflux_to_ocn(nx_block, ny_block, & ! local variables integer (kind=int_kind) :: & i, j, n ! horizontal indices - + real (kind=dbl_kind) :: & puny, & ! - Lsub, & ! rLsub ! 1/Lsub character(len=*), parameter :: subname = '(sfcflux_to_ocn)' - call icepack_query_parameters(puny_out=puny, Lsub_out=Lsub) + call icepack_query_parameters(puny_out=puny) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) diff --git a/cicecore/drivers/unittest/opticep/CICE_RunMod.F90 b/cicecore/drivers/unittest/opticep/CICE_RunMod.F90 index 42514e06c..7ca555433 100644 --- a/cicecore/drivers/unittest/opticep/CICE_RunMod.F90 +++ b/cicecore/drivers/unittest/opticep/CICE_RunMod.F90 @@ -7,7 +7,7 @@ ! William H. Lipscomb, LANL ! ! 2006 ECH: moved exit timeLoop to prevent execution of unnecessary timestep -! 2006 ECH: Streamlined for efficiency +! 2006 ECH: Streamlined for efficiency ! 2006 ECH: Converted to free source form (F90) ! 2007 BPB: Modified Delta-Eddington shortwave interface ! 2008 ECH: moved ESMF code to its own driver @@ -15,13 +15,11 @@ module CICE_RunMod use ice_kinds_mod - use ice_communicate, only: my_task, master_task use ice_fileunits, only: nu_diag use ice_arrays_column, only: oceanmixed_ice use ice_constants, only: c0, c1 use ice_constants, only: field_loc_center, field_type_scalar use ice_exit, only: abort_ice - use ice_memusage, only: ice_memusage_print use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted use icepack_intfc, only: icepack_max_iso, icepack_max_aero use icepack_intfc, only: icepack_query_parameters @@ -45,7 +43,7 @@ module CICE_RunMod subroutine CICE_Run - use ice_calendar, only: dt, stop_now, advance_timestep + use ice_calendar, only: istep, istep1, time, dt, stop_now, calendar use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & @@ -84,12 +82,11 @@ subroutine CICE_Run call ice_step -! tcraig, use advance_timestep now -! istep = istep + 1 ! update time step counters -! istep1 = istep1 + 1 -! time = time + dt ! determine the time and date -! call calendar(time) ! at the end of the timestep - call advance_timestep() ! advance time + istep = istep + 1 ! update time step counters + istep1 = istep1 + 1 + time = time + dt ! determine the time and date + + call calendar(time) ! at the end of the timestep #ifndef CICE_IN_NEMO if (stop_now >= 1) exit timeLoop @@ -97,6 +94,8 @@ subroutine CICE_Run call ice_timer_start(timer_couple) ! atm/ocn coupling +#ifndef coupled +#ifndef CESMCOUPLED ! for now, wave_spectrum is constant in time ! if (tr_fsd .and. wave_spec) call get_wave_spec ! wave spectrum in ice call get_forcing_atmo ! atmospheric forcing from data @@ -110,6 +109,8 @@ subroutine CICE_Run if (tr_aero .or. tr_zaero) call faero_default ! default values if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry +#endif +#endif if (z_tracers) call get_atm_bgc ! biogeochemistry call init_flux_atm ! Initialize atmosphere fluxes sent to coupler @@ -125,7 +126,7 @@ subroutine CICE_Run ! end of timestep loop !-------------------------------------------------------------------- - call ice_timer_stop(timer_step) ! end timestepping loop timer + call ice_timer_stop(timer_step) ! end timestepping loop timer end subroutine CICE_Run @@ -140,8 +141,8 @@ subroutine ice_step use ice_boundary, only: ice_HaloUpdate use ice_calendar, only: dt, dt_dyn, ndtd, diagfreq, write_restart, istep - use ice_diagnostics, only: init_mass_diags, runtime_diags, debug_model, debug_ice - use ice_diagnostics_bgc, only: hbrine_diags, bgc_diags + use ice_diagnostics, only: init_mass_diags, runtime_diags + use ice_diagnostics_bgc, only: hbrine_diags, zsal_diags, bgc_diags use ice_domain, only: halo_info, nblocks use ice_dyn_eap, only: write_restart_eap use ice_dyn_shared, only: kdyn, kridge @@ -151,21 +152,20 @@ subroutine ice_step use ice_history_bgc, only: init_history_bgc use ice_restart, only: final_restart use ice_restart_column, only: write_restart_age, write_restart_FY, & - write_restart_lvl, write_restart_pond_lvl, & + write_restart_lvl, write_restart_pond_cesm, write_restart_pond_lvl, & write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_iso, write_restart_bgc, write_restart_hbrine, & - write_restart_snow + write_restart_iso, write_restart_bgc, write_restart_hbrine use ice_restart_driver, only: dumpfile use ice_restoring, only: restore_ice, ice_HaloRestore use ice_step_mod, only: prep_radiation, step_therm1, step_therm2, & update_state, step_dyn_horiz, step_dyn_ridge, step_radiation, & - biogeochemistry, step_prep, step_dyn_wave, step_snow + biogeochemistry, save_init, step_dyn_wave use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_diags, timer_column, timer_thermo, timer_bound, & timer_hist, timer_readwrite integer (kind=int_kind) :: & - iblk , & ! block index + iblk , & ! block index k , & ! dynamics supercycling index ktherm ! thermodynamics is off when ktherm = -1 @@ -173,27 +173,26 @@ subroutine ice_step offset ! d(age)/dt time offset logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_fsd, tr_snow, & - tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, & - calc_Tsfc, skl_bgc, z_tracers, wave_spec + tr_iage, tr_FY, tr_lvl, tr_fsd, & + tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, & + calc_Tsfc, skl_bgc, solve_zsal, z_tracers, wave_spec character(len=*), parameter :: subname = '(ice_step)' character (len=char_len) :: plabeld - if (debug_model) then - plabeld = 'beginning time step' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - endif + plabeld = 'beginning time step' + do iblk = 1, nblocks + call debug_ice (iblk, plabeld) + enddo call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc, skl_bgc_out=skl_bgc, & - z_tracers_out=z_tracers, ktherm_out=ktherm, wave_spec_out=wave_spec) + solve_zsal_out=solve_zsal, z_tracers_out=z_tracers, ktherm_out=ktherm, & + wave_spec_out=wave_spec) call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & - tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_iso_out=tr_iso, tr_fsd_out=tr_fsd, tr_snow_out=tr_snow) + tr_iso_out=tr_iso, tr_fsd_out=tr_fsd) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) @@ -217,11 +216,12 @@ subroutine ice_step call ice_timer_start(timer_column) ! column physics call ice_timer_start(timer_thermo) ! thermodynamics - call step_prep + call save_init - if (ktherm >= 0) then - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) - do iblk = 1, nblocks + !$OMP PARALLEL DO PRIVATE(iblk) + do iblk = 1, nblocks + + if (ktherm >= 0) then !----------------------------------------------------------------- ! scale radiation fields @@ -229,39 +229,32 @@ subroutine ice_step if (calc_Tsfc) call prep_radiation (iblk) - if (debug_model) then - plabeld = 'post prep_radiation' - call debug_ice (iblk, plabeld) - endif + plabeld = 'post prep_radiation' + call debug_ice (iblk, plabeld) !----------------------------------------------------------------- ! thermodynamics and biogeochemistry !----------------------------------------------------------------- - + call step_therm1 (dt, iblk) ! vertical thermodynamics - if (debug_model) then - plabeld = 'post step_therm1' - call debug_ice (iblk, plabeld) - endif + plabeld = 'post step_therm1' + call debug_ice (iblk, plabeld) call biogeochemistry (dt, iblk) ! biogeochemistry - if (debug_model) then - plabeld = 'post biogeochemistry' - call debug_ice (iblk, plabeld) - endif + plabeld = 'post biogeochemistry' + call debug_ice (iblk, plabeld) call step_therm2 (dt, iblk) ! ice thickness distribution thermo - if (debug_model) then - plabeld = 'post step_therm2' - call debug_ice (iblk, plabeld) - endif + plabeld = 'post step_therm2' + call debug_ice (iblk, plabeld) - enddo - !$OMP END PARALLEL DO - endif ! ktherm > 0 + endif + + enddo ! iblk + !$OMP END PARALLEL DO ! clean up, update tendency diagnostics offset = dt @@ -283,26 +276,22 @@ subroutine ice_step ! momentum, stress, transport call step_dyn_horiz (dt_dyn) - if (debug_model) then - plabeld = 'post step_dyn_horiz' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo ! iblk - endif + do iblk = 1, nblocks + plabeld = 'post step_dyn_horiz' + call debug_ice (iblk, plabeld) + enddo ! iblk ! ridging - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) + !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks if (kridge > 0) call step_dyn_ridge (dt_dyn, ndtd, iblk) enddo !$OMP END PARALLEL DO - if (debug_model) then - plabeld = 'post step_dyn_ridge' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo ! iblk - endif + do iblk = 1, nblocks + plabeld = 'post step_dyn_ridge' + call debug_ice (iblk, plabeld) + enddo ! iblk ! clean up, update tendency diagnostics offset = c0 @@ -310,42 +299,26 @@ subroutine ice_step enddo - if (debug_model) then - plabeld = 'post dynamics' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - endif - - call ice_timer_start(timer_column) ! column physics - call ice_timer_start(timer_thermo) ! thermodynamics + plabeld = 'post dynamics' + do iblk = 1, nblocks + call debug_ice (iblk, plabeld) + enddo !----------------------------------------------------------------- - ! snow redistribution and metamorphosis + ! albedo, shortwave radiation !----------------------------------------------------------------- - if (tr_snow) then ! advanced snow physics - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) - do iblk = 1, nblocks - call step_snow (dt, iblk) - enddo - !$OMP END PARALLEL DO - call update_state (dt) ! clean up - endif + call ice_timer_start(timer_column) ! column physics + call ice_timer_start(timer_thermo) ! thermodynamics - !$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime) +!MHRI: CHECK THIS OMP + !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks - !----------------------------------------------------------------- - ! albedo, shortwave radiation - !----------------------------------------------------------------- - if (ktherm >= 0) call step_radiation (dt, iblk) - if (debug_model) then - plabeld = 'post step_radiation' - call debug_ice (iblk, plabeld) - endif + plabeld = 'post step_radiation' + call debug_ice (iblk, plabeld) !----------------------------------------------------------------- ! get ready for coupling and the next time step @@ -353,10 +326,8 @@ subroutine ice_step call coupling_prep (iblk) - if (debug_model) then - plabeld = 'post coupling_prep' - call debug_ice (iblk, plabeld) - endif + plabeld = 'post coupling_prep' + call debug_ice (iblk, plabeld) enddo ! iblk !$OMP END PARALLEL DO @@ -376,11 +347,9 @@ subroutine ice_step call ice_timer_start(timer_diags) ! diagnostics if (mod(istep,diagfreq) == 0) then call runtime_diags(dt) ! log file + if (solve_zsal) call zsal_diags if (skl_bgc .or. z_tracers) call bgc_diags if (tr_brine) call hbrine_diags - if (my_task == master_task) then - call ice_memusage_print(nu_diag,subname) - endif endif call ice_timer_stop(timer_diags) ! diagnostics @@ -394,22 +363,23 @@ subroutine ice_step if (tr_iage) call write_restart_age if (tr_FY) call write_restart_FY if (tr_lvl) call write_restart_lvl + if (tr_pond_cesm) call write_restart_pond_cesm if (tr_pond_lvl) call write_restart_pond_lvl if (tr_pond_topo) call write_restart_pond_topo - if (tr_snow) call write_restart_snow if (tr_fsd) call write_restart_fsd if (tr_iso) call write_restart_iso if (tr_aero) call write_restart_aero - if (skl_bgc .or. z_tracers) & - call write_restart_bgc + if (solve_zsal .or. skl_bgc .or. z_tracers) & + call write_restart_bgc if (tr_brine) call write_restart_hbrine if (kdyn == 2) call write_restart_eap call final_restart endif + call ice_timer_stop(timer_readwrite) ! reading/writing end subroutine ice_step - + !======================================================================= ! ! Prepare for coupling @@ -419,7 +389,7 @@ end subroutine ice_step subroutine coupling_prep (iblk) use ice_arrays_column, only: alvdfn, alidfn, alvdrn, alidrn, & - albicen, albsnon, albpndn, apeffn, snowfracn + albicen, albsnon, albpndn, apeffn, fzsal_g, fzsal, snowfracn use ice_blocks, only: nx_block, ny_block, get_block, block use ice_domain, only: blocks_ice use ice_calendar, only: dt, nstreams @@ -428,13 +398,12 @@ subroutine coupling_prep (iblk) albpnd, albcnt, apeff_ai, fpond, fresh, l_mpond_fresh, & alvdf_ai, alidf_ai, alvdr_ai, alidr_ai, fhocn_ai, & fresh_ai, fsalt_ai, fsalt, & - fswthru_ai, fhocn, scale_factor, snowfrac, & - fswthru, fswthru_vdr, fswthru_vdf, fswthru_idr, fswthru_idf, & + fswthru_ai, fhocn, fswthru, scale_factor, snowfrac, & swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyT, & fsens, flat, fswabs, flwout, evap, Tref, Qref, & scale_fluxes, frzmlt_init, frzmlt use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, & - flux_bio, flux_bio_ai + fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai use ice_grid, only: tmask use ice_state, only: aicen, aice #ifdef CICE_IN_NEMO @@ -444,12 +413,12 @@ subroutine coupling_prep (iblk) use ice_step_mod, only: ocean_mixed_layer use ice_timers, only: timer_couple, ice_timer_start, ice_timer_stop - integer (kind=int_kind), intent(in) :: & - iblk ! block index + integer (kind=int_kind), intent(in) :: & + iblk ! block index ! local variables - integer (kind=int_kind) :: & + integer (kind=int_kind) :: & ilo,ihi,jlo,jhi, & ! beginning and end of physical domain n , & ! thickness category index i,j , & ! horizontal indices @@ -488,7 +457,7 @@ subroutine coupling_prep (iblk) enddo enddo - call ice_timer_start(timer_couple,iblk) ! atm/ocn coupling + call ice_timer_start(timer_couple) ! atm/ocn coupling if (oceanmixed_ice) & call ocean_mixed_layer (dt,iblk) ! ocean surface fluxes and sst @@ -585,6 +554,8 @@ subroutine coupling_prep (iblk) fsalt_ai (i,j,iblk) = fsalt (i,j,iblk) fhocn_ai (i,j,iblk) = fhocn (i,j,iblk) fswthru_ai(i,j,iblk) = fswthru(i,j,iblk) + fzsal_ai (i,j,iblk) = fzsal (i,j,iblk) + fzsal_g_ai(i,j,iblk) = fzsal_g(i,j,iblk) if (nbtrcr > 0) then do k = 1, nbtrcr @@ -605,7 +576,7 @@ subroutine coupling_prep (iblk) enddo !----------------------------------------------------------------- - ! Divide fluxes by ice area + ! Divide fluxes by ice area ! - the CESM coupler assumes fluxes are per unit ice area ! - also needed for global budget in diagnostics !----------------------------------------------------------------- @@ -621,38 +592,34 @@ subroutine coupling_prep (iblk) evap (:,:,iblk), & Tref (:,:,iblk), Qref (:,:,iblk), & fresh (:,:,iblk), fsalt (:,:,iblk), & - fhocn (:,:,iblk), & - fswthru (:,:,iblk), & - fswthru_vdr (:,:,iblk), & - fswthru_vdf (:,:,iblk), & - fswthru_idr (:,:,iblk), & - fswthru_idf (:,:,iblk), & + fhocn (:,:,iblk), fswthru (:,:,iblk), & faero_ocn(:,:,:,iblk), & alvdr (:,:,iblk), alidr (:,:,iblk), & alvdf (:,:,iblk), alidf (:,:,iblk), & - flux_bio =flux_bio (:,:,1:nbtrcr,iblk), & + fzsal (:,:,iblk), fzsal_g (:,:,iblk), & + flux_bio (:,:,1:nbtrcr,iblk), & Qref_iso =Qref_iso (:,:,:,iblk), & fiso_evap=fiso_evap(:,:,:,iblk), & fiso_ocn =fiso_ocn (:,:,:,iblk)) - + #ifdef CICE_IN_NEMO !echmod - comment this out for efficiency, if .not. calc_Tsfc if (.not. calc_Tsfc) then !--------------------------------------------------------------- - ! If surface fluxes were provided, conserve these fluxes at ice - ! free points by passing to ocean. + ! If surface fluxes were provided, conserve these fluxes at ice + ! free points by passing to ocean. !--------------------------------------------------------------- - call sfcflux_to_ocn & + call sfcflux_to_ocn & (nx_block, ny_block, & tmask (:,:,iblk), aice_init(:,:,iblk), & fsurfn_f (:,:,:,iblk), flatn_f(:,:,:,iblk), & fresh (:,:,iblk), fhocn (:,:,iblk)) - endif + endif !echmod #endif - call ice_timer_stop(timer_couple,iblk) ! atm/ocn coupling + call ice_timer_stop(timer_couple) ! atm/ocn coupling end subroutine coupling_prep @@ -661,10 +628,10 @@ end subroutine coupling_prep !======================================================================= ! ! If surface heat fluxes are provided to CICE instead of CICE calculating -! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can +! them internally (i.e. .not. calc_Tsfc), then these heat fluxes can ! be provided at points which do not have ice. (This is could be due to ! the heat fluxes being calculated on a lower resolution grid or the -! heat fluxes not recalculated at every CICE timestep.) At ice free points, +! heat fluxes not recalculated at every CICE timestep.) At ice free points, ! conserve energy and water by passing these fluxes to the ocean. ! ! author: A. McLaren, Met Office @@ -697,15 +664,14 @@ subroutine sfcflux_to_ocn(nx_block, ny_block, & ! local variables integer (kind=int_kind) :: & i, j, n ! horizontal indices - + real (kind=dbl_kind) :: & puny, & ! - Lsub, & ! rLsub ! 1/Lsub character(len=*), parameter :: subname = '(sfcflux_to_ocn)' - call icepack_query_parameters(puny_out=puny, Lsub_out=Lsub) + call icepack_query_parameters(puny_out=puny) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) diff --git a/cicecore/shared/ice_init_column.F90 b/cicecore/shared/ice_init_column.F90 index 5b25dc165..fbcc8413b 100644 --- a/cicecore/shared/ice_init_column.F90 +++ b/cicecore/shared/ice_init_column.F90 @@ -7,10 +7,9 @@ module ice_init_column use ice_kinds_mod - use ice_blocks, only: nx_block, ny_block use ice_constants use ice_communicate, only: my_task, master_task, ice_barrier - use ice_domain_size, only: ncat, max_blocks + use ice_domain_size, only: ncat, max_blocks use ice_domain_size, only: nblyr, nilyr, nslyr use ice_domain_size, only: n_aero, n_zaero, n_algae use ice_domain_size, only: n_doc, n_dic, n_don @@ -35,7 +34,7 @@ module ice_init_column use icepack_intfc, only: icepack_init_zbgc use icepack_intfc, only: icepack_init_thermo use icepack_intfc, only: icepack_step_radiation, icepack_init_orbit - use icepack_intfc, only: icepack_init_bgc + use icepack_intfc, only: icepack_init_bgc, icepack_init_zsalinity use icepack_intfc, only: icepack_init_ocean_bio, icepack_load_ocean_bio_array use icepack_intfc, only: icepack_init_hbrine @@ -44,9 +43,9 @@ module ice_init_column private public :: init_thermo_vertical, init_shortwave, & init_age, init_FY, init_lvl, init_fsd, & - init_meltponds_lvl, init_meltponds_topo, & + init_meltponds_cesm, init_meltponds_lvl, init_meltponds_topo, & init_aerosol, init_bgc, init_hbrine, init_zbgc, input_zbgc, & - count_tracers, init_isotope, init_snowtracers + count_tracers, init_isotope ! namelist parameters needed locally @@ -130,6 +129,7 @@ module ice_init_column subroutine init_thermo_vertical + use ice_blocks, only: nx_block, ny_block use ice_flux, only: salinz, Tmltz integer (kind=int_kind) :: & @@ -145,7 +145,7 @@ subroutine init_thermo_vertical character(len=*), parameter :: subname='(init_thermo_vertical)' !----------------------------------------------------------------- - ! initialize + ! initialize heat_capacity, l_brine, and salinity profile !----------------------------------------------------------------- call icepack_query_parameters(depressT_out=depressT) @@ -181,14 +181,13 @@ end subroutine init_thermo_vertical subroutine init_shortwave use ice_arrays_column, only: fswpenln, Iswabsn, Sswabsn, albicen, & - albsnon, alvdrn, alidrn, alvdfn, alidfn, fswsfcn, & - fswthrun, fswthrun_vdr, fswthrun_vdf, fswthrun_idr, fswthrun_idf, & + albsnon, alvdrn, alidrn, alvdfn, alidfn, fswsfcn, fswthrun, & fswintn, albpndn, apeffn, trcrn_sw, dhsn, ffracn, snowfracn, & kaer_tab, waer_tab, gaer_tab, kaer_bc_tab, waer_bc_tab, gaer_bc_tab, bcenh, & swgrid, igrid - use ice_blocks, only: block, get_block + use ice_blocks, only: block, get_block, nx_block, ny_block use ice_calendar, only: dt, calendar_type, & - days_per_year, nextsw_cday, yday, msec + days_per_year, nextsw_cday, yday, sec use ice_diagnostics, only: npnt, print_points, pmloc, piloc, pjloc use ice_domain, only: nblocks, blocks_ice use ice_flux, only: alvdf, alidf, alvdr, alidr, & @@ -214,9 +213,8 @@ subroutine init_shortwave logical (kind=log_kind) :: & l_print_point, & ! flag to print designated grid point diagnostics debug, & ! if true, print diagnostics - dEdd_algae, & ! use prognostic chla in dEdd radiation - modal_aero, & ! use modal aerosol optical treatment - snwgrain ! use variable snow radius + dEdd_algae, & ! from icepack + modal_aero ! from icepack character (char_len) :: shortwave @@ -226,13 +224,12 @@ subroutine init_shortwave real (kind=dbl_kind), dimension(ncat) :: & fbri ! brine height to ice thickness - real(kind= dbl_kind), dimension(:,:), allocatable :: & - ztrcr_sw, & ! zaerosols (kg/m^3) and chla (mg/m^3) - rsnow ! snow grain radius tracer (10^-6 m) + real(kind=dbl_kind), allocatable :: & + ztrcr_sw(:,:) ! logical (kind=log_kind) :: tr_brine, tr_zaero, tr_bgc_n integer (kind=int_kind) :: nt_alvl, nt_apnd, nt_hpnd, nt_ipnd, nt_aero, & - nt_fbri, nt_tsfc, ntrcr, nbtrcr, nbtrcr_sw, nt_rsnw + nt_fbri, nt_tsfc, ntrcr, nbtrcr, nbtrcr_sw integer (kind=int_kind), dimension(icepack_max_algae) :: & nt_bgc_N integer (kind=int_kind), dimension(icepack_max_aero) :: & @@ -245,19 +242,17 @@ subroutine init_shortwave call icepack_query_parameters(shortwave_out=shortwave) call icepack_query_parameters(dEdd_algae_out=dEdd_algae) call icepack_query_parameters(modal_aero_out=modal_aero) - call icepack_query_parameters(snwgrain_out=snwgrain) call icepack_query_tracer_sizes(ntrcr_out=ntrcr, nbtrcr_out=nbtrcr, nbtrcr_sw_out=nbtrcr_sw) call icepack_query_tracer_flags(tr_brine_out=tr_brine, tr_zaero_out=tr_zaero, & tr_bgc_n_out=tr_bgc_n) call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, & nt_ipnd_out=nt_ipnd, nt_aero_out=nt_aero, nt_fbri_out=nt_fbri, nt_tsfc_out=nt_tsfc, & - nt_bgc_N_out=nt_bgc_N, nt_zaero_out=nt_zaero, nt_rsnw_out=nt_rsnw) + nt_bgc_N_out=nt_bgc_N, nt_zaero_out=nt_zaero) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__,line= __LINE__) allocate(ztrcr_sw(nbtrcr_sw, ncat)) - allocate(rsnow(nslyr,ncat)) do iblk=1,nblocks @@ -266,12 +261,12 @@ subroutine init_shortwave Iswabsn(:,:,:,:,iblk) = c0 Sswabsn(:,:,:,:,iblk) = c0 - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi - + do j = 1, ny_block ! can be jlo, jhi do i = 1, nx_block ! can be ilo, ihi @@ -309,10 +304,6 @@ subroutine init_shortwave fswsfcn(i,j,n,iblk) = c0 fswintn(i,j,n,iblk) = c0 fswthrun(i,j,n,iblk) = c0 - fswthrun_vdr(i,j,n,iblk) = c0 - fswthrun_vdf(i,j,n,iblk) = c0 - fswthrun_idr(i,j,n,iblk) = c0 - fswthrun_idf(i,j,n,iblk) = c0 enddo ! ncat enddo @@ -334,14 +325,8 @@ subroutine init_shortwave fbri(:) = c0 ztrcr_sw(:,:) = c0 - rsnow (:,:) = c0 do n = 1, ncat - if (tr_brine) fbri(n) = trcrn(i,j,nt_fbri,n,iblk) - if (snwgrain) then - do k = 1, nslyr - rsnow(k,n) = trcrn(i,j,nt_rsnw+k-1,n,iblk) - enddo - endif + if (tr_brine) fbri(n) = trcrn(i,j,nt_fbri,n,iblk) enddo if (tmask(i,j,iblk)) then @@ -366,7 +351,7 @@ subroutine init_shortwave calendar_type=calendar_type, & days_per_year=days_per_year, & nextsw_cday=nextsw_cday, yday=yday, & - sec=msec, & + sec=sec, & kaer_tab=kaer_tab, kaer_bc_tab=kaer_bc_tab(:,:), & waer_tab=waer_tab, waer_bc_tab=waer_bc_tab(:,:), & gaer_tab=gaer_tab, gaer_bc_tab=gaer_bc_tab(:,:), & @@ -378,22 +363,16 @@ subroutine init_shortwave alvdrn=alvdrn(i,j,:,iblk), alvdfn=alvdfn(i,j,:,iblk), & alidrn=alidrn(i,j,:,iblk), alidfn=alidfn(i,j,:,iblk), & fswsfcn=fswsfcn(i,j,:,iblk), fswintn=fswintn(i,j,:,iblk), & - fswthrun=fswthrun(i,j,:,iblk), & - fswthrun_vdr=fswthrun_vdr(i,j,:,iblk), & - fswthrun_vdf=fswthrun_vdf(i,j,:,iblk), & - fswthrun_idr=fswthrun_idr(i,j,:,iblk), & - fswthrun_idf=fswthrun_idf(i,j,:,iblk), & - fswpenln=fswpenln(i,j,:,:,iblk), & + fswthrun=fswthrun(i,j,:,iblk), fswpenln=fswpenln(i,j,:,:,iblk), & Sswabsn=Sswabsn(i,j,:,:,iblk), Iswabsn=Iswabsn(i,j,:,:,iblk), & albicen=albicen(i,j,:,iblk), albsnon=albsnon(i,j,:,iblk), & albpndn=albpndn(i,j,:,iblk), apeffn=apeffn(i,j,:,iblk), & snowfracn=snowfracn(i,j,:,iblk), & dhsn=dhsn(i,j,:,iblk), ffracn=ffracn(i,j,:,iblk), & - rsnow=rsnow(:,:), & l_print_point=l_print_point, & initonly = .true.) endif - + !----------------------------------------------------------------- ! Define aerosol tracer on shortwave grid !----------------------------------------------------------------- @@ -410,7 +389,7 @@ subroutine init_shortwave enddo ! j !----------------------------------------------------------------- - ! Aggregate albedos + ! Aggregate albedos ! Match loop order in coupling_prep for same order of operations !----------------------------------------------------------------- @@ -419,7 +398,7 @@ subroutine init_shortwave do i = ilo, ihi if (aicen(i,j,n,iblk) > puny) then - + alvdf(i,j,iblk) = alvdf(i,j,iblk) & + alvdfn(i,j,n,iblk)*aicen(i,j,n,iblk) alidf(i,j,iblk) = alidf(i,j,iblk) & @@ -428,7 +407,7 @@ subroutine init_shortwave + alvdrn(i,j,n,iblk)*aicen(i,j,n,iblk) alidr(i,j,iblk) = alidr(i,j,iblk) & + alidrn(i,j,n,iblk)*aicen(i,j,n,iblk) - + netsw = swvdr(i,j,iblk) + swidr(i,j,iblk) & + swvdf(i,j,iblk) + swidf(i,j,iblk) if (netsw > puny) then ! sun above horizon @@ -439,12 +418,12 @@ subroutine init_shortwave albpnd(i,j,iblk) = albpnd(i,j,iblk) & + albpndn(i,j,n,iblk)*aicen(i,j,n,iblk) endif - + apeff_ai(i,j,iblk) = apeff_ai(i,j,iblk) & + apeffn(i,j,n,iblk)*aicen(i,j,n,iblk) snowfrac(i,j,iblk) = snowfrac(i,j,iblk) & + snowfracn(i,j,n,iblk)*aicen(i,j,n,iblk) - + endif ! aicen > puny enddo ! i @@ -486,7 +465,6 @@ subroutine init_shortwave enddo ! iblk deallocate(ztrcr_sw) - deallocate(rsnow) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & @@ -524,7 +502,7 @@ end subroutine init_FY ! Initialize ice lvl tracers (call prior to reading restart data) - subroutine init_lvl(iblk, alvl, vlvl) + subroutine init_lvl(iblk, alvl, vlvl) use ice_constants, only: c0, c1 use ice_arrays_column, only: ffracn, dhsn @@ -545,6 +523,22 @@ end subroutine init_lvl !======================================================================= +! Initialize melt ponds. + + subroutine init_meltponds_cesm(apnd, hpnd) + + real(kind=dbl_kind), dimension(:,:,:), intent(out) :: & + apnd , & ! melt pond area fraction + hpnd ! melt pond depth + character(len=*),parameter :: subname='(init_meltponds_cesm)' + + apnd(:,:,:) = c0 + hpnd(:,:,:) = c0 + + end subroutine init_meltponds_cesm + +!======================================================================= + ! Initialize melt ponds. subroutine init_meltponds_lvl(apnd, hpnd, ipnd, dhsn) @@ -578,34 +572,11 @@ subroutine init_meltponds_topo(apnd, hpnd, ipnd) apnd(:,:,:) = c0 hpnd(:,:,:) = c0 ipnd(:,:,:) = c0 - + end subroutine init_meltponds_topo !======================================================================= -! Initialize snow redistribution/metamorphosis tracers (call prior to reading restart data) - - subroutine init_snowtracers(smice, smliq, rhos_cmp, rsnw) - - real(kind=dbl_kind), dimension(:,:,:,:), intent(out) :: & - smice, smliq, rhos_cmp, rsnw - character(len=*),parameter :: subname='(init_snowtracers)' - - real (kind=dbl_kind) :: & - rsnw_fall, & ! snow grain radius of new fallen snow (10^-6 m) - rhos ! snow density (kg/m^3) - - call icepack_query_parameters(rsnw_fall_out=rsnw_fall, rhos_out=rhos) - - rsnw (:,:,:,:) = rsnw_fall - rhos_cmp(:,:,:,:) = rhos - smice (:,:,:,:) = rhos - smliq (:,:,:,:) = c0 - - end subroutine init_snowtracers - -!======================================================================= - ! Initialize floe size distribution tracer (call prior to reading restart data) subroutine init_fsd(floesize) @@ -613,6 +584,7 @@ subroutine init_fsd(floesize) use ice_arrays_column, only: floe_rad_c, floe_binwidth, & wavefreq, dwavefreq, wave_sig_ht, wave_spectrum, & d_afsd_newi, d_afsd_latg, d_afsd_latm, d_afsd_wave, d_afsd_weld + use ice_blocks, only: nx_block, ny_block use ice_domain_size, only: ncat, max_blocks, nfsd use ice_init, only: ice_ic use ice_state, only: aicen @@ -730,18 +702,20 @@ end subroutine init_aerosol ! Initialize vertical profile for biogeochemistry - subroutine init_bgc() + subroutine init_bgc() use ice_arrays_column, only: zfswin, trcrn_sw, & ocean_bio_all, ice_bio_net, snow_bio_net, & - cgrid, igrid, bphi, iDi, bTiz, iki + cgrid, igrid, bphi, iDi, bTiz, iki, & + Rayleigh_criteria, Rayleigh_real use ice_blocks, only: block, get_block use ice_domain, only: nblocks, blocks_ice use ice_flux, only: sss use ice_flux_bgc, only: nit, amm, sil, dmsp, dms, algalN, & doc, don, dic, fed, fep, zaeros, hum use ice_forcing_bgc, only: init_bgc_data, get_forcing_bgc - use ice_restart_column, only: read_restart_bgc, restart_bgc + use ice_restart_column, only: restart_zsal, & + read_restart_bgc, restart_bgc use ice_state, only: trcrn ! local variables @@ -755,24 +729,33 @@ subroutine init_bgc() integer (kind=int_kind) :: & max_nbtrcr, max_algae, max_don, max_doc, max_dic, max_aero, max_fe + logical (kind=log_kind) :: & + RayleighC , & + solve_zsal + type (block) :: & this_block ! block information for current block real(kind=dbl_kind), allocatable :: & trcrn_bgc(:,:) - + real(kind=dbl_kind), dimension(nilyr,ncat) :: & - sicen + sicen + + real(kind=dbl_kind) :: & + RayleighR integer (kind=int_kind) :: & - nbtrcr, ntrcr, ntrcr_o, nt_sice + nbtrcr, ntrcr, ntrcr_o, & + nt_sice, nt_bgc_S character(len=*), parameter :: subname='(init_bgc)' ! Initialize + call icepack_query_parameters(solve_zsal_out=solve_zsal) call icepack_query_tracer_sizes(nbtrcr_out=nbtrcr, ntrcr_out=ntrcr, ntrcr_o_out=ntrcr_o) - call icepack_query_tracer_indices(nt_sice_out=nt_sice) + call icepack_query_tracer_indices(nt_sice_out=nt_sice, nt_bgc_S_out=nt_bgc_S) call icepack_query_tracer_sizes(max_nbtrcr_out=max_nbtrcr, & max_algae_out=max_algae, max_don_out=max_don, max_doc_out=max_doc, & max_dic_out=max_dic, max_aero_out=max_aero, max_fe_out=max_fe) @@ -782,31 +765,77 @@ subroutine init_bgc() allocate(trcrn_bgc(ntrcr,ncat)) - bphi(:,:,:,:,:) = c0 ! initial porosity for no ice + bphi(:,:,:,:,:) = c0 ! initial porosity for no ice iDi (:,:,:,:,:) = c0 ! interface diffusivity bTiz(:,:,:,:,:) = c0 ! initial bio grid ice temperature iki (:,:,:,:,:) = c0 ! permeability ocean_bio_all(:,:,:,:) = c0 - ice_bio_net (:,:,:,:) = c0 ! integrated ice tracer conc (mmol/m^2 or mg/m^2) + ice_bio_net (:,:,:,:) = c0 ! integrated ice tracer conc (mmol/m^2 or mg/m^2) snow_bio_net (:,:,:,:) = c0 ! integrated snow tracer conc (mmol/m^2 or mg/m^2) zfswin (:,:,:,:,:) = c0 ! shortwave flux on bio grid trcrn_sw (:,:,:,:,:) = c0 ! tracers active in the shortwave calculation trcrn_bgc (:,:) = c0 + RayleighR = c0 + RayleighC = .false. !----------------------------------------------------------------- - ! biogeochemistry initialization + ! zsalinity initialization !----------------------------------------------------------------- + + if (solve_zsal) then ! default values + + !$OMP PARALLEL DO PRIVATE(iblk,i,j,n,ilo,ihi,jlo,jhi,this_block) + do iblk = 1, nblocks + + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + + do j = jlo, jhi + do i = ilo, ihi + call icepack_init_zsalinity(nblyr=nblyr, ntrcr_o=ntrcr_o, & + Rayleigh_criteria = RayleighC, & + Rayleigh_real = RayleighR, & + trcrn_bgc = trcrn_bgc, & + nt_bgc_S = nt_bgc_S, & + ncat = ncat, & + sss = sss(i,j,iblk)) + if (.not. restart_zsal) then + Rayleigh_real (i,j,iblk) = RayleighR + Rayleigh_criteria(i,j,iblk) = RayleighC + do n = 1,ncat + do k = 1, nblyr + trcrn (i,j,nt_bgc_S+k-1, n,iblk) = & + trcrn_bgc( nt_bgc_S+k-1-ntrcr_o,n) + enddo + enddo + endif + enddo ! i + enddo ! j + enddo ! iblk + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) + endif ! solve_zsal + + if (.not. solve_zsal) restart_zsal = .false. - if (.not. restart_bgc) then + !----------------------------------------------------------------- + ! biogeochemistry initialization + !----------------------------------------------------------------- + if (.not. restart_bgc) then + !----------------------------------------------------------------- ! Initial Ocean Values if not coupled to the ocean bgc !----------------------------------------------------------------- !$OMP PARALLEL DO PRIVATE(iblk,i,j,n,ilo,ihi,jlo,jhi,this_block) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo @@ -826,7 +855,6 @@ subroutine init_bgc() enddo ! j enddo ! iblk - !$OMP END PARALLEL DO call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & @@ -840,14 +868,23 @@ subroutine init_bgc() !$OMP PARALLEL DO PRIVATE(iblk,i,j,n,ilo,ihi,jlo,jhi,this_block) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi do j = jlo, jhi - do i = ilo, ihi + do i = ilo, ihi + + do n = 1, ncat + do k = 1, nilyr + sicen(k,n) = trcrn(i,j,nt_sice+k-1,n,iblk) + enddo + do k = ntrcr_o+1, ntrcr + trcrn_bgc(k-ntrcr_o,n) = trcrn(i,j,k,n,iblk) + enddo + enddo call icepack_load_ocean_bio_array(max_nbtrcr=icepack_max_nbtrcr, & max_algae=icepack_max_algae, max_don=icepack_max_don, & @@ -855,7 +892,7 @@ subroutine init_bgc() max_dic=icepack_max_dic, max_aero=icepack_max_aero, & nit =nit (i,j, iblk), amm=amm(i,j, iblk), sil =sil (i,j, iblk), & dmsp=dmsp(i,j, iblk), dms=dms(i,j, iblk), algalN=algalN(i,j,:,iblk), & - doc =doc (i,j,:,iblk), don=don(i,j,:,iblk), dic =dic (i,j,:,iblk), & + doc =doc (i,j,:,iblk), don=don(i,j,:,iblk), dic =dic (i,j,:,iblk), & fed =fed (i,j,:,iblk), fep=fep(i,j,:,iblk), zaeros=zaeros(i,j,:,iblk), & hum=hum (i,j, iblk), ocean_bio_all=ocean_bio_all(i,j,:,iblk)) @@ -863,32 +900,24 @@ subroutine init_bgc() enddo ! j enddo ! iblk - !$OMP END PARALLEL DO call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - if (.not. restart_bgc) then - !$OMP PARALLEL DO PRIVATE(iblk,i,j,k,n,ilo,ihi,jlo,jhi,this_block,sicen,trcrn_bgc) + if (.not. restart_bgc) then + !$OMP PARALLEL DO PRIVATE(iblk,i,j,n,ilo,ihi,jlo,jhi,this_block) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi do j = jlo, jhi - do i = ilo, ihi - do n = 1, ncat - do k = 1, nilyr - sicen(k,n) = trcrn(i,j,nt_sice+k-1,n,iblk) - enddo - do k = ntrcr_o+1, ntrcr - trcrn_bgc(k-ntrcr_o,n) = trcrn(i,j,k,n,iblk) - enddo - enddo + do i = ilo, ihi + call icepack_init_bgc(ncat=ncat, nblyr=nblyr, nilyr=nilyr, ntrcr_o=ntrcr_o, & cgrid=cgrid, igrid=igrid, ntrcr=ntrcr, nbtrcr=nbtrcr, & sicen=sicen(:,:), trcrn=trcrn_bgc(:,:), sss=sss(i,j, iblk), & @@ -896,7 +925,6 @@ subroutine init_bgc() enddo ! i enddo ! j enddo ! iblk - !$OMP END PARALLEL DO call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & @@ -908,7 +936,7 @@ subroutine init_bgc() ! read restart to complete BGC initialization !----------------------------------------------------------------- - if (restart_bgc) call read_restart_bgc + if (restart_zsal .or. restart_bgc) call read_restart_bgc deallocate(trcrn_bgc) @@ -951,7 +979,7 @@ subroutine init_hbrine() if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__,line= __LINE__) - first_ice(:,:,:,:) = .true. + first_ice(:,:,:,:) = .true. if (tr_brine) trcrn(:,:,nt_fbri,:,:) = c1 end subroutine init_hbrine @@ -959,15 +987,16 @@ end subroutine init_hbrine !======================================================================= ! Namelist variables, set to default values; may be altered at run time -! +! ! author Elizabeth C. Hunke, LANL ! Nicole Jeffery, LANL subroutine input_zbgc - use ice_arrays_column, only: restore_bgc, optics_file, optics_file_fieldname + use ice_arrays_column, only: restore_bgc use ice_broadcast, only: broadcast_scalar - use ice_restart_column, only: restart_bgc, restart_hbrine + use ice_restart_column, only: restart_bgc, restart_zsal, & + restart_hbrine use ice_restart_shared, only: restart character (len=char_len) :: & @@ -980,13 +1009,13 @@ subroutine input_zbgc tr_bgc_N, tr_bgc_C, tr_bgc_chl, & tr_bgc_DON, tr_bgc_Fe, tr_zaero, & tr_bgc_hum, tr_aero - + integer (kind=int_kind) :: & ktherm logical (kind=log_kind) :: & solve_zsal, skl_bgc, z_tracers, scale_bgc, solve_zbgc, dEdd_algae, & - modal_aero, restart_zsal + modal_aero character (char_len) :: & bgc_flux_type @@ -1007,7 +1036,7 @@ subroutine input_zbgc restore_bgc, restart_bgc, scale_bgc, solve_zsal, restart_zsal, & tr_bgc_Nit, tr_bgc_C, tr_bgc_chl, tr_bgc_Am, tr_bgc_Sil, & tr_bgc_DMS, tr_bgc_PON, tr_bgc_hum, tr_bgc_DON, tr_bgc_Fe, & - grid_o, grid_o_t, l_sk, grid_oS, optics_file, optics_file_fieldname, & + grid_o, grid_o_t, l_sk, grid_oS, & l_skS, phi_snow, initbio_frac, frazil_scav, & ratio_Si2N_diatoms , ratio_Si2N_sp , ratio_Si2N_phaeo , & ratio_S2N_diatoms , ratio_S2N_sp , ratio_S2N_phaeo , & @@ -1044,9 +1073,9 @@ subroutine input_zbgc fedtype_1 , feptype_1 , zaerotype_bc1 , & zaerotype_bc2 , zaerotype_dust1 , zaerotype_dust2 , & zaerotype_dust3 , zaerotype_dust4 , ratio_C2N_diatoms , & - ratio_C2N_sp , ratio_C2N_phaeo , ratio_chl2N_diatoms, & + ratio_C2N_sp , ratio_C2N_phaeo , ratio_chl2N_diatoms, & ratio_chl2N_sp , ratio_chl2N_phaeo , F_abs_chl_diatoms , & - F_abs_chl_sp , F_abs_chl_phaeo , ratio_C2N_proteins + F_abs_chl_sp , F_abs_chl_phaeo , ratio_C2N_proteins !----------------------------------------------------------------- @@ -1064,29 +1093,27 @@ subroutine input_zbgc tr_brine = .false. ! brine height differs from ice height tr_zaero = .false. ! z aerosol tracers modal_aero = .false. ! use modal aerosol treatment of aerosols - optics_file = 'unknown_optics_file' ! modal aerosol optics file - optics_file_fieldname = 'unknown_optics_fieldname' ! modal aerosol optics file fieldname restore_bgc = .false. ! restore bgc if true solve_zsal = .false. ! update salinity tracer profile from solve_S_dt restart_bgc = .false. ! biogeochemistry restart restart_zsal = .false. ! salinity restart restart_hbrine = .false. ! hbrine restart - scale_bgc = .false. ! initial bgc tracers proportional to S - skl_bgc = .false. ! solve skeletal biochemistry + scale_bgc = .false. ! initial bgc tracers proportional to S + skl_bgc = .false. ! solve skeletal biochemistry z_tracers = .false. ! solve vertically resolved tracers dEdd_algae = .false. ! dynamic algae contributes to shortwave absorption ! in delta-Eddington calculation - solve_zbgc = .false. ! turn on z layer biochemistry - tr_bgc_PON = .false. !--------------------------------------------- + solve_zbgc = .false. ! turn on z layer biochemistry + tr_bgc_PON = .false. !--------------------------------------------- tr_bgc_Nit = .false. ! biogeochemistry (skl or zbgc) tr_bgc_C = .false. ! if skl_bgc = .true. then skl tr_bgc_chl = .false. ! if z_tracers = .true. then vertically resolved tr_bgc_Sil = .false. ! if z_tracers + solve_zbgc = .true. then - tr_bgc_Am = .false. ! vertically resolved with reactions + tr_bgc_Am = .false. ! vertically resolved with reactions tr_bgc_DMS = .false. !------------------------------------------------ - tr_bgc_DON = .false. ! + tr_bgc_DON = .false. ! tr_bgc_hum = .false. ! - tr_bgc_Fe = .false. ! + tr_bgc_Fe = .false. ! tr_bgc_N = .true. ! ! brine height parameter @@ -1095,17 +1122,17 @@ subroutine input_zbgc ! skl biology parameters bgc_flux_type = 'Jin2006'! type of ocean-ice poston velocity ('constant') - ! z biology parameters - grid_o = c5 ! for bottom flux - grid_o_t = c5 ! for top flux - l_sk = 7.0_dbl_kind ! characteristic diffusive scale (m) + ! z biology parameters + grid_o = c5 ! for bottom flux + grid_o_t = c5 ! for top flux + l_sk = 7.0_dbl_kind ! characteristic diffusive scale (m) initbio_frac = c1 ! fraction of ocean trcr concentration in bio trcrs - frazil_scav = c1 ! increase in initial bio tracer from ocean scavenging - ratio_Si2N_diatoms = 1.8_dbl_kind ! algal Si to N (mol/mol) + frazil_scav = c1 ! increase in initial bio tracer from ocean scavenging + ratio_Si2N_diatoms = 1.8_dbl_kind ! algal Si to N (mol/mol) ratio_Si2N_sp = c0 ! diatoms, small plankton, phaeocystis ratio_Si2N_phaeo = c0 ratio_S2N_diatoms = 0.03_dbl_kind ! algal S to N (mol/mol) - ratio_S2N_sp = 0.03_dbl_kind + ratio_S2N_sp = 0.03_dbl_kind ratio_S2N_phaeo = 0.03_dbl_kind ratio_Fe2C_diatoms = 0.0033_dbl_kind ! algal Fe to C (umol/mol) ratio_Fe2C_sp = 0.0033_dbl_kind @@ -1116,7 +1143,7 @@ subroutine input_zbgc ratio_Fe2DON = 0.023_dbl_kind ! Fe to N of DON (nmol/umol) ratio_Fe2DOC_s = p1 ! Fe to C of DOC (nmol/umol) saccharids ratio_Fe2DOC_l = 0.033_dbl_kind ! Fe to C of DOC (nmol/umol) lipids - fr_resp = 0.05_dbl_kind ! frac of algal growth lost due to respiration + fr_resp = 0.05_dbl_kind ! frac of algal growth lost due to respiration tau_min = 5200.0_dbl_kind ! rapid mobile to stationary exchanges (s) tau_max = 1.73e5_dbl_kind ! long time mobile to stationary exchanges (s) algal_vel = 1.11e-8_dbl_kind! 0.5 cm/d(m/s) Lavoie 2005 1.5 cm/day @@ -1125,13 +1152,13 @@ subroutine input_zbgc chlabs_diatoms = 0.03_dbl_kind ! chl absorption (1/m/(mg/m^3)) chlabs_sp = 0.01_dbl_kind chlabs_phaeo = 0.05_dbl_kind - alpha2max_low_diatoms = 0.8_dbl_kind ! light limitation (1/(W/m^2)) + alpha2max_low_diatoms = 0.8_dbl_kind ! light limitation (1/(W/m^2)) alpha2max_low_sp = 0.67_dbl_kind alpha2max_low_phaeo = 0.67_dbl_kind - beta2max_diatoms = 0.018_dbl_kind ! light inhibition (1/(W/m^2)) + beta2max_diatoms = 0.018_dbl_kind ! light inhibition (1/(W/m^2)) beta2max_sp = 0.0025_dbl_kind beta2max_phaeo = 0.01_dbl_kind - mu_max_diatoms = 1.2_dbl_kind ! maximum growth rate (1/day) + mu_max_diatoms = 1.2_dbl_kind ! maximum growth rate (1/day) mu_max_sp = 0.851_dbl_kind mu_max_phaeo = 0.851_dbl_kind grow_Tdep_diatoms = 0.06_dbl_kind ! Temperature dependence of growth (1/C) @@ -1161,10 +1188,10 @@ subroutine input_zbgc K_Fe_diatoms = c1 ! iron half saturation (nM) K_Fe_sp = 0.2_dbl_kind K_Fe_phaeo = p1 - f_don_protein = 0.6_dbl_kind ! fraction of spilled grazing to proteins - kn_bac_protein = 0.03_dbl_kind ! Bacterial degredation of DON (1/d) - f_don_Am_protein = 0.25_dbl_kind ! fraction of remineralized DON to ammonium - f_doc_s = 0.4_dbl_kind ! fraction of mortality to DOC + f_don_protein = 0.6_dbl_kind ! fraction of spilled grazing to proteins + kn_bac_protein = 0.03_dbl_kind ! Bacterial degredation of DON (1/d) + f_don_Am_protein = 0.25_dbl_kind ! fraction of remineralized DON to ammonium + f_doc_s = 0.4_dbl_kind ! fraction of mortality to DOC f_doc_l = 0.4_dbl_kind f_exude_s = c1 ! fraction of exudation to DOC f_exude_l = c1 @@ -1174,15 +1201,15 @@ subroutine input_zbgc fsal = c1 ! Salinity limitation (ppt) op_dep_min = p1 ! Light attenuates for optical depths exceeding min fr_graze_s = p5 ! fraction of grazing spilled or slopped - fr_graze_e = p5 ! fraction of assimilation excreted + fr_graze_e = p5 ! fraction of assimilation excreted fr_mort2min = p5 ! fractionation of mortality to Am fr_dFe = 0.3_dbl_kind ! fraction of remineralized nitrogen ! (in units of algal iron) - k_nitrif = c0 ! nitrification rate (1/day) + k_nitrif = c0 ! nitrification rate (1/day) t_iron_conv = 3065.0_dbl_kind ! desorption loss pFe to dFe (day) - max_loss = 0.9_dbl_kind ! restrict uptake to % of remaining value - max_dfe_doc1 = 0.2_dbl_kind ! max ratio of dFe to saccharides in the ice - !(nM Fe/muM C) + max_loss = 0.9_dbl_kind ! restrict uptake to % of remaining value + max_dfe_doc1 = 0.2_dbl_kind ! max ratio of dFe to saccharides in the ice + !(nM Fe/muM C) fr_resp_s = 0.75_dbl_kind ! DMSPd fraction of respiration loss as DMSPd y_sk_DMS = p5 ! fraction conversion given high yield t_sk_conv = 3.0_dbl_kind ! Stefels conversion time (d) @@ -1216,47 +1243,46 @@ subroutine input_zbgc F_abs_chl_diatoms = 2.0_dbl_kind ! scales absorbed radiation for dEdd F_abs_chl_sp = 4.0_dbl_kind F_abs_chl_phaeo = 5.0 - ratio_C2N_proteins = 7.0_dbl_kind ! ratio of C to N in proteins (mol/mol) + ratio_C2N_proteins = 7.0_dbl_kind ! ratio of C to N in proteins (mol/mol) ! z salinity parameters - grid_oS = c5 ! for bottom flux - l_skS = 7.0_dbl_kind ! characteristic diffusive scale (m) + grid_oS = c5 ! for bottom flux + l_skS = 7.0_dbl_kind ! characteristic diffusive scale (m) !----------------------------------------------------------------- ! read from input file !----------------------------------------------------------------- - if (my_task == master_task) then - write(nu_diag,*) subname,' Reading zbgc_nml' + call get_fileunit(nu_nml) - call get_fileunit(nu_nml) + if (my_task == master_task) then open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error) if (nml_error /= 0) then - call abort_ice(subname//'ERROR: zbgc_nml open file '// & - trim(nml_filename), & - file=__FILE__, line=__LINE__) - endif + nml_error = -1 + else + nml_error = 1 + endif - nml_error = 1 + print*,'Reading zbgc_nml' do while (nml_error > 0) read(nu_nml, nml=zbgc_nml,iostat=nml_error) end do - if (nml_error /= 0) then - call abort_ice(subname//'ERROR: zbgc_nml reading ', & - file=__FILE__, line=__LINE__) - endif - close(nu_nml) - call release_fileunit(nu_nml) + if (nml_error == 0) close(nu_nml) endif + call broadcast_scalar(nml_error, master_task) + if (nml_error /= 0) then + call abort_ice(subname//'ERROR: reading zbgc namelist') + endif + call release_fileunit(nu_nml) !----------------------------------------------------------------- ! broadcast !----------------------------------------------------------------- - call broadcast_scalar(solve_zsal, master_task) - call broadcast_scalar(restart_zsal, master_task) + call broadcast_scalar(solve_zsal, master_task) + call broadcast_scalar(restart_zsal, master_task) call broadcast_scalar(tr_brine, master_task) - call broadcast_scalar(restart_hbrine, master_task) + call broadcast_scalar(restart_hbrine, master_task) call broadcast_scalar(phi_snow, master_task) call broadcast_scalar(grid_oS, master_task) @@ -1274,17 +1300,15 @@ subroutine input_zbgc call broadcast_scalar(tr_bgc_Am, master_task) call broadcast_scalar(tr_bgc_Sil, master_task) call broadcast_scalar(tr_bgc_hum, master_task) - call broadcast_scalar(tr_bgc_DMS, master_task) - call broadcast_scalar(tr_bgc_PON, master_task) - call broadcast_scalar(tr_bgc_DON, master_task) - call broadcast_scalar(tr_bgc_Fe, master_task) + call broadcast_scalar(tr_bgc_DMS, master_task) + call broadcast_scalar(tr_bgc_PON, master_task) + call broadcast_scalar(tr_bgc_DON, master_task) + call broadcast_scalar(tr_bgc_Fe, master_task) call broadcast_scalar(z_tracers, master_task) call broadcast_scalar(tr_zaero, master_task) - call broadcast_scalar(dEdd_algae, master_task) + call broadcast_scalar(dEdd_algae, master_task) call broadcast_scalar(modal_aero, master_task) - call broadcast_scalar(optics_file, master_task) - call broadcast_scalar(optics_file_fieldname, master_task) call broadcast_scalar(grid_o, master_task) call broadcast_scalar(grid_o_t, master_task) call broadcast_scalar(l_sk, master_task) @@ -1315,31 +1339,31 @@ subroutine input_zbgc call broadcast_scalar(chlabs_diatoms , master_task) call broadcast_scalar(chlabs_sp , master_task) call broadcast_scalar(chlabs_phaeo , master_task) - call broadcast_scalar(alpha2max_low_diatoms , master_task) + call broadcast_scalar(alpha2max_low_diatoms , master_task) call broadcast_scalar(alpha2max_low_sp , master_task) call broadcast_scalar(alpha2max_low_phaeo , master_task) - call broadcast_scalar(beta2max_diatoms , master_task) - call broadcast_scalar(beta2max_sp , master_task) - call broadcast_scalar(beta2max_phaeo , master_task) - call broadcast_scalar(mu_max_diatoms , master_task) - call broadcast_scalar(mu_max_sp , master_task) - call broadcast_scalar(mu_max_phaeo , master_task) - call broadcast_scalar(grow_Tdep_diatoms, master_task) - call broadcast_scalar(grow_Tdep_sp , master_task) - call broadcast_scalar(grow_Tdep_phaeo , master_task) - call broadcast_scalar(fr_graze_diatoms , master_task) - call broadcast_scalar(fr_graze_sp , master_task) - call broadcast_scalar(fr_graze_phaeo , master_task) - call broadcast_scalar(mort_pre_diatoms , master_task) - call broadcast_scalar(mort_pre_sp , master_task) - call broadcast_scalar(mort_pre_phaeo , master_task) - call broadcast_scalar(mort_Tdep_diatoms, master_task) - call broadcast_scalar(mort_Tdep_sp , master_task) - call broadcast_scalar(mort_Tdep_phaeo , master_task) - call broadcast_scalar(k_exude_diatoms , master_task) - call broadcast_scalar(k_exude_sp , master_task) - call broadcast_scalar(k_exude_phaeo , master_task) - call broadcast_scalar(K_Nit_diatoms , master_task) + call broadcast_scalar(beta2max_diatoms , master_task) + call broadcast_scalar(beta2max_sp , master_task) + call broadcast_scalar(beta2max_phaeo , master_task) + call broadcast_scalar(mu_max_diatoms , master_task) + call broadcast_scalar(mu_max_sp , master_task) + call broadcast_scalar(mu_max_phaeo , master_task) + call broadcast_scalar(grow_Tdep_diatoms, master_task) + call broadcast_scalar(grow_Tdep_sp , master_task) + call broadcast_scalar(grow_Tdep_phaeo , master_task) + call broadcast_scalar(fr_graze_diatoms , master_task) + call broadcast_scalar(fr_graze_sp , master_task) + call broadcast_scalar(fr_graze_phaeo , master_task) + call broadcast_scalar(mort_pre_diatoms , master_task) + call broadcast_scalar(mort_pre_sp , master_task) + call broadcast_scalar(mort_pre_phaeo , master_task) + call broadcast_scalar(mort_Tdep_diatoms, master_task) + call broadcast_scalar(mort_Tdep_sp , master_task) + call broadcast_scalar(mort_Tdep_phaeo , master_task) + call broadcast_scalar(k_exude_diatoms , master_task) + call broadcast_scalar(k_exude_sp , master_task) + call broadcast_scalar(k_exude_phaeo , master_task) + call broadcast_scalar(K_Nit_diatoms , master_task) call broadcast_scalar(K_Nit_sp , master_task) call broadcast_scalar(K_Nit_phaeo , master_task) call broadcast_scalar(K_Am_diatoms , master_task) @@ -1355,17 +1379,17 @@ subroutine input_zbgc call broadcast_scalar(kn_bac_protein , master_task) call broadcast_scalar(f_don_Am_protein , master_task) call broadcast_scalar(f_doc_s , master_task) - call broadcast_scalar(f_doc_l , master_task) + call broadcast_scalar(f_doc_l , master_task) call broadcast_scalar(f_exude_s , master_task) call broadcast_scalar(f_exude_l , master_task) - call broadcast_scalar(k_bac_s , master_task) + call broadcast_scalar(k_bac_s , master_task) call broadcast_scalar(k_bac_l , master_task) call broadcast_scalar(T_max , master_task) call broadcast_scalar(fsal , master_task) call broadcast_scalar(op_dep_min , master_task) - call broadcast_scalar(fr_graze_s , master_task) - call broadcast_scalar(fr_graze_e , master_task) - call broadcast_scalar(fr_mort2min , master_task) + call broadcast_scalar(fr_graze_s , master_task) + call broadcast_scalar(fr_graze_e , master_task) + call broadcast_scalar(fr_mort2min , master_task) call broadcast_scalar(fr_dFe , master_task) call broadcast_scalar(k_nitrif , master_task) call broadcast_scalar(t_iron_conv , master_task) @@ -1373,18 +1397,18 @@ subroutine input_zbgc call broadcast_scalar(max_dfe_doc1 , master_task) call broadcast_scalar(fr_resp_s , master_task) call broadcast_scalar(y_sk_DMS , master_task) - call broadcast_scalar(t_sk_conv , master_task) + call broadcast_scalar(t_sk_conv , master_task) call broadcast_scalar(t_sk_ox , master_task) call broadcast_scalar(algaltype_diatoms, master_task) - call broadcast_scalar(algaltype_sp , master_task) - call broadcast_scalar(algaltype_phaeo , master_task) + call broadcast_scalar(algaltype_sp , master_task) + call broadcast_scalar(algaltype_phaeo , master_task) call broadcast_scalar(nitratetype , master_task) call broadcast_scalar(ammoniumtype , master_task) call broadcast_scalar(silicatetype , master_task) - call broadcast_scalar(dmspptype , master_task) - call broadcast_scalar(dmspdtype , master_task) + call broadcast_scalar(dmspptype , master_task) + call broadcast_scalar(dmspdtype , master_task) call broadcast_scalar(humtype , master_task) - call broadcast_scalar(doctype_s , master_task) + call broadcast_scalar(doctype_s , master_task) call broadcast_scalar(doctype_l , master_task) call broadcast_scalar(dontype_protein , master_task) call broadcast_scalar(fedtype_1 , master_task) @@ -1404,7 +1428,7 @@ subroutine input_zbgc call broadcast_scalar(F_abs_chl_diatoms , master_task) call broadcast_scalar(F_abs_chl_sp , master_task) call broadcast_scalar(F_abs_chl_phaeo , master_task) - call broadcast_scalar(ratio_C2N_proteins , master_task) + call broadcast_scalar(ratio_C2N_proteins , master_task) !----------------------------------------------------------------- ! zsalinity and brine @@ -1415,13 +1439,21 @@ subroutine input_zbgc write(nu_diag,*) subname//' WARNING: restart = false, setting bgc restart flags to false' restart_bgc = .false. restart_hbrine = .false. + restart_zsal = .false. endif - if (solve_zsal) then + if (solve_zsal .and. nblyr < 1) then if (my_task == master_task) then - write(nu_diag,*) subname,' ERROR: solve_zsal=T deprecated' + write(nu_diag,*) subname,' ERROR: solve_zsal=T but 0 zsalinity tracers' endif abort_flag = 101 + endif + + if (solve_zsal .and. ((.not. tr_brine) .or. (ktherm /= 1))) then + if (my_task == master_task) then + write(nu_diag,*) subname,' ERROR: solve_zsal needs tr_brine=T and ktherm=1' + endif + abort_flag = 102 endif if (tr_brine .and. nblyr < 1 ) then @@ -1429,7 +1461,7 @@ subroutine input_zbgc write(nu_diag,*) subname,' ERROR: tr_brine=T but no biology layers compiled' endif abort_flag = 103 - endif + endif !----------------------------------------------------------------- ! biogeochemistry @@ -1464,14 +1496,14 @@ subroutine input_zbgc abort_flag = 107 endif - if (dEdd_algae .AND. trim(shortwave) /= 'dEdd') then + if (dEdd_algae .AND. trim(shortwave) /= 'dEdd') then if (my_task == master_task) then write(nu_diag,*) subname,' ERROR: dEdd_algae = T but shortwave /= dEdd' endif abort_flag = 108 endif - if (dEdd_algae .AND. (.NOT. tr_bgc_N) .AND. (.NOT. tr_zaero)) then + if (dEdd_algae .AND. (.NOT. tr_bgc_N) .AND. (.NOT. tr_zaero)) then if (my_task == master_task) then write(nu_diag,*) subname,' ERROR: need tr_bgc_N or tr_zaero for dEdd_algae' endif @@ -1484,8 +1516,8 @@ subroutine input_zbgc endif abort_flag = 110 endif - - if (modal_aero .AND. trim(shortwave) /= 'dEdd') then + + if (modal_aero .AND. trim(shortwave) /= 'dEdd') then if (my_task == master_task) then write(nu_diag,*) subname,' ERROR: modal_aero = T but shortwave /= dEdd' endif @@ -1604,9 +1636,12 @@ subroutine input_zbgc write(nu_diag,1010) ' restart_hbrine = ', restart_hbrine write(nu_diag,1005) ' phi_snow = ', phi_snow endif - write(nu_diag,1010) ' solve_zsal (deprecated) = ', solve_zsal - write(nu_diag,* ) ' WARNING: zsalinity has been deprecated. Namelists and interfaces' - write(nu_diag,* ) ' will be removed in a future version' + write(nu_diag,1010) ' solve_zsal = ', solve_zsal + if (solve_zsal) then + write(nu_diag,1010) ' restart_zsal = ', restart_zsal + write(nu_diag,1000) ' grid_oS = ', grid_oS + write(nu_diag,1005) ' l_skS = ', l_skS + endif write(nu_diag,1010) ' skl_bgc = ', skl_bgc write(nu_diag,1010) ' restart_bgc = ', restart_bgc @@ -1643,8 +1678,6 @@ subroutine input_zbgc write(nu_diag,1010) ' solve_zbgc = ', solve_zbgc write(nu_diag,1010) ' tr_zaero = ', tr_zaero write(nu_diag,1020) ' number of aerosols = ', n_zaero - write(nu_diag,1031) ' optics_file = ', trim(optics_file) - write(nu_diag,1031) ' optics_file_fieldname = ', trim(optics_file_fieldname) ! bio parameters write(nu_diag,1000) ' grid_o = ', grid_o write(nu_diag,1000) ' grid_o_t = ', grid_o_t @@ -1674,7 +1707,7 @@ subroutine input_zbgc !----------------------------------------------------------------- call icepack_init_parameters( & - ktherm_in=ktherm, shortwave_in=shortwave, & + ktherm_in=ktherm, shortwave_in=shortwave, solve_zsal_in=solve_zsal, & skl_bgc_in=skl_bgc, z_tracers_in=z_tracers, scale_bgc_in=scale_bgc, & dEdd_algae_in=dEdd_algae, & solve_zbgc_in=solve_zbgc, & @@ -1702,7 +1735,6 @@ subroutine input_zbgc 1010 format (a30,2x,l6) ! logical 1020 format (a30,2x,i6) ! integer 1030 format (a30, a8) ! character - 1031 format (a30, a ) ! character end subroutine input_zbgc @@ -1726,18 +1758,16 @@ subroutine count_tracers integer (kind=int_kind) :: ntrcr logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_pond, tr_aero, tr_fsd - logical (kind=log_kind) :: tr_snow - logical (kind=log_kind) :: tr_iso, tr_pond_lvl, tr_pond_topo + logical (kind=log_kind) :: tr_iso, tr_pond_cesm, tr_pond_lvl, tr_pond_topo integer (kind=int_kind) :: nt_Tsfc, nt_sice, nt_qice, nt_qsno, nt_iage, nt_FY integer (kind=int_kind) :: nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd, nt_aero integer (kind=int_kind) :: nt_fsd, nt_isosno, nt_isoice - integer (kind=int_kind) :: nt_smice, nt_smliq, nt_rhos, nt_rsnw integer (kind=int_kind) :: & nbtrcr, nbtrcr_sw, & ntrcr_o, nt_fbri, & nt_bgc_Nit, nt_bgc_Am, nt_bgc_Sil, & - nt_bgc_DMS, nt_bgc_PON, & + nt_bgc_DMS, nt_bgc_PON, nt_bgc_S, & nt_bgc_DMSPp, nt_bgc_DMSPd, & nt_zbgc_frac, nlt_chl_sw, & nlt_bgc_Nit, nlt_bgc_Am, nlt_bgc_Sil, & @@ -1794,15 +1824,16 @@ subroutine count_tracers tr_bgc_N, tr_bgc_C, tr_bgc_chl, & tr_bgc_DON, tr_bgc_Fe, tr_zaero, & tr_bgc_hum - + logical (kind=log_kind) :: & - skl_bgc, z_tracers + solve_zsal, skl_bgc, z_tracers character(len=*), parameter :: subname='(count_tracers)' !----------------------------------------------------------------- call icepack_query_parameters( & + solve_zsal_out=solve_zsal, & skl_bgc_out=skl_bgc, z_tracers_out=z_tracers) call icepack_warnings_flush(nu_diag) @@ -1811,9 +1842,9 @@ subroutine count_tracers call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & tr_lvl_out=tr_lvl, tr_aero_out=tr_aero, tr_pond_out=tr_pond, & - tr_pond_lvl_out=tr_pond_lvl, & + tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_fsd_out=tr_fsd, & - tr_snow_out=tr_snow, tr_iso_out=tr_iso, & + tr_iso_out=tr_iso, & tr_bgc_Nit_out=tr_bgc_Nit, tr_bgc_Am_out =tr_bgc_Am, tr_bgc_Sil_out=tr_bgc_Sil, & tr_bgc_DMS_out=tr_bgc_DMS, tr_bgc_PON_out=tr_bgc_PON, & tr_bgc_N_out =tr_bgc_N, tr_bgc_C_out =tr_bgc_C, tr_bgc_chl_out=tr_bgc_chl, & @@ -1871,26 +1902,11 @@ subroutine count_tracers nt_ipnd = ntrcr ! on level-ice ponds (if frzpnd='hlid') endif if (tr_pond_topo) then - ntrcr = ntrcr + 1 ! + ntrcr = ntrcr + 1 ! nt_ipnd = ntrcr ! refrozen pond ice lid thickness endif endif - nt_smice = 0 - nt_smliq = 0 - nt_rhos = 0 - nt_rsnw = 0 - if (tr_snow) then - nt_smice = ntrcr + 1 - ntrcr = ntrcr + nslyr ! mass of ice in nslyr snow layers - nt_smliq = ntrcr + 1 - ntrcr = ntrcr + nslyr ! mass of liquid in nslyr snow layers - nt_rhos = ntrcr + 1 - ntrcr = ntrcr + nslyr ! snow density in nslyr layers - nt_rsnw = ntrcr + 1 - ntrcr = ntrcr + nslyr ! snow grain radius in nslyr layers - endif - nt_fsd = 0 if (tr_fsd) then nt_fsd = ntrcr + 1 ! floe size distribution @@ -1914,14 +1930,13 @@ subroutine count_tracers !tcx, modify code so we don't have to reset n_aero here n_aero = 0 !echmod - this is not getting set correctly (overwritten later?) endif - + !----------------------------------------------------------------- ! initialize zbgc tracer indices !----------------------------------------------------------------- nbtrcr = 0 nbtrcr_sw = 0 - nt_zbgc_frac = 0 ! vectors of size icepack_max_algae nlt_bgc_N(:) = 0 @@ -1980,6 +1995,12 @@ subroutine count_tracers ntrcr = ntrcr + 1 endif + nt_bgc_S = 0 + if (solve_zsal) then ! .true. only if tr_brine = .true. + nt_bgc_S = ntrcr + 1 + ntrcr = ntrcr + nblyr + endif + if (skl_bgc .or. z_tracers) then if (skl_bgc) then @@ -2163,6 +2184,7 @@ subroutine count_tracers enddo ! mm endif ! tr_zaero + nt_zbgc_frac = 0 if (nbtrcr > 0) then nt_zbgc_frac = ntrcr + 1 ntrcr = ntrcr + nbtrcr @@ -2172,7 +2194,7 @@ subroutine count_tracers !tcx, +1 here is the unused tracer, want to get rid of it ntrcr = ntrcr + 1 -!tcx, reset unused tracer index, eventually get rid of it. +!tcx, reset unusaed tracer index, eventually get rid of it. if (nt_iage <= 0) nt_iage = ntrcr if (nt_FY <= 0) nt_FY = ntrcr if (nt_alvl <= 0) nt_alvl = ntrcr @@ -2180,16 +2202,12 @@ subroutine count_tracers if (nt_apnd <= 0) nt_apnd = ntrcr if (nt_hpnd <= 0) nt_hpnd = ntrcr if (nt_ipnd <= 0) nt_ipnd = ntrcr - if (nt_smice <= 0) nt_smice = ntrcr - if (nt_smliq <= 0) nt_smliq = ntrcr - if (nt_rhos <= 0) nt_rhos = ntrcr - if (nt_rsnw <= 0) nt_rsnw = ntrcr if (nt_fsd <= 0) nt_fsd = ntrcr if (nt_isosno<= 0) nt_isosno= ntrcr if (nt_isoice<= 0) nt_isoice= ntrcr if (nt_aero <= 0) nt_aero = ntrcr if (nt_fbri <= 0) nt_fbri = ntrcr -! if (nt_bgc_S <= 0) nt_bgc_S = ntrcr + if (nt_bgc_S <= 0) nt_bgc_S = ntrcr if (my_task == master_task) then write(nu_diag,*) ' ' @@ -2210,10 +2228,9 @@ subroutine count_tracers nt_qice_in=nt_qice, nt_qsno_in=nt_qsno, nt_iage_in=nt_iage, nt_fy_in=nt_fy, & nt_alvl_in=nt_alvl, nt_vlvl_in=nt_vlvl, nt_apnd_in=nt_apnd, nt_hpnd_in=nt_hpnd, & nt_ipnd_in=nt_ipnd, nt_fsd_in=nt_fsd, nt_aero_in=nt_aero, & - nt_smice_in=nt_smice, nt_smliq_in=nt_smliq, nt_rhos_in=nt_rhos, nt_rsnw_in=nt_rsnw, & nt_isosno_in=nt_isosno, nt_isoice_in=nt_isoice, nt_fbri_in=nt_fbri, & nt_bgc_Nit_in=nt_bgc_Nit, nt_bgc_Am_in=nt_bgc_Am, nt_bgc_Sil_in=nt_bgc_Sil, & - nt_bgc_DMS_in=nt_bgc_DMS, nt_bgc_PON_in=nt_bgc_PON, & + nt_bgc_DMS_in=nt_bgc_DMS, nt_bgc_PON_in=nt_bgc_PON, nt_bgc_S_in=nt_bgc_S, & nt_bgc_N_in=nt_bgc_N, nt_bgc_chl_in=nt_bgc_chl, & nt_bgc_DOC_in=nt_bgc_DOC, nt_bgc_DON_in=nt_bgc_DON, nt_bgc_DIC_in=nt_bgc_DIC, & nt_zaero_in=nt_zaero, nt_bgc_DMSPp_in=nt_bgc_DMSPp, nt_bgc_DMSPd_in=nt_bgc_DMSPd, & @@ -2251,12 +2268,12 @@ subroutine init_zbgc use ice_state, only: trcr_base, trcr_depend, n_trcr_strata, & nt_strata - use ice_arrays_column, only: R_C2N, R_chl2N, R_C2N_DON, R_Si2N, trcrn_sw + use ice_arrays_column, only: R_C2N, R_chl2N, R_C2N_DON, R_Si2N integer (kind=int_kind) :: & nbtrcr, nbtrcr_sw, nt_fbri, & nt_bgc_Nit, nt_bgc_Am, nt_bgc_Sil, & - nt_bgc_DMS, nt_bgc_PON, & + nt_bgc_DMS, nt_bgc_PON, nt_bgc_S, & nt_bgc_DMSPp, nt_bgc_DMSPd, & nt_zbgc_frac, nlt_chl_sw, & nlt_bgc_Nit, nlt_bgc_Am, nlt_bgc_Sil, & @@ -2337,7 +2354,7 @@ subroutine init_zbgc tau_rel ! release timescale (s), stationary to mobile phase logical (kind=log_kind) :: & - skl_bgc, z_tracers, dEdd_algae + skl_bgc, z_tracers, dEdd_algae, solve_zsal real (kind=dbl_kind), dimension(icepack_max_algae) :: & F_abs_chl ! to scale absorption in Dedd @@ -2407,10 +2424,12 @@ subroutine init_zbgc !----------------------------------------------------------------- call icepack_query_parameters( & + solve_zsal_out=solve_zsal, & skl_bgc_out=skl_bgc, z_tracers_out=z_tracers, & dEdd_algae_out=dEdd_algae, & grid_o_out=grid_o, l_sk_out=l_sk, & initbio_frac_out=initbio_frac, & + grid_oS_out=grid_oS, l_skS_out=l_skS, & phi_snow_out=phi_snow, frazil_scav_out = frazil_scav) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & @@ -2436,7 +2455,7 @@ subroutine init_zbgc call icepack_query_tracer_indices( & nt_fbri_out=nt_fbri, & nt_bgc_Nit_out=nt_bgc_Nit, nt_bgc_Am_out=nt_bgc_Am, nt_bgc_Sil_out=nt_bgc_Sil, & - nt_bgc_DMS_out=nt_bgc_DMS, nt_bgc_PON_out=nt_bgc_PON, & + nt_bgc_DMS_out=nt_bgc_DMS, nt_bgc_PON_out=nt_bgc_PON, nt_bgc_S_out=nt_bgc_S, & nt_bgc_N_out=nt_bgc_N, nt_bgc_chl_out=nt_bgc_chl, & nt_bgc_DOC_out=nt_bgc_DOC, nt_bgc_DON_out=nt_bgc_DON, nt_bgc_DIC_out=nt_bgc_DIC, & nt_zaero_out=nt_zaero, nt_bgc_DMSPp_out=nt_bgc_DMSPp, nt_bgc_DMSPd_out=nt_bgc_DMSPd, & @@ -2620,6 +2639,18 @@ subroutine init_zbgc ntd = 0 ! if nt_fbri /= 0 then use fbri dependency if (nt_fbri == 0) ntd = -1 ! otherwise make tracers depend on ice volume + if (solve_zsal) then ! .true. only if tr_brine = .true. + do k = 1,nblyr + trcr_depend(nt_bgc_S + k - 1) = 2 + nt_fbri + ntd + trcr_base (nt_bgc_S,1) = c0 ! default: ice area + trcr_base (nt_bgc_S,2) = c1 + trcr_base (nt_bgc_S,3) = c0 + n_trcr_strata(nt_bgc_S) = 1 + nt_strata(nt_bgc_S,1) = nt_fbri + nt_strata(nt_bgc_S,2) = 0 + enddo + endif + bio_index(:) = 0 bio_index_o(:) = 0 @@ -2635,7 +2666,7 @@ subroutine init_zbgc if (skl_bgc .or. z_tracers) then if (tr_bgc_N) then - do mm = 1, n_algae + do mm = 1, n_algae call init_bgc_trcr(nk, nt_fbri, & nt_bgc_N(mm), nlt_bgc_N(mm), & algaltype(mm), nt_depend, & @@ -2655,14 +2686,14 @@ subroutine init_zbgc nt_strata, bio_index) bio_index_o(nlt_bgc_Nit) = icepack_max_algae + 1 endif ! tr_bgc_Nit - + if (tr_bgc_C) then ! ! Algal C is not yet distinct from algal N ! * Reqires exudation and/or changing C:N ratios ! for implementation ! - ! do mm = 1,n_algae + ! do mm = 1,n_algae ! call init_bgc_trcr(nk, nt_fbri, & ! nt_bgc_C(mm), nlt_bgc_C(mm), & ! algaltype(mm), nt_depend, & @@ -2712,7 +2743,7 @@ subroutine init_zbgc trcr_base, n_trcr_strata, & nt_strata, bio_index) bio_index_o(nlt_bgc_Am) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic + 2 - endif + endif if (tr_bgc_Sil) then call init_bgc_trcr(nk, nt_fbri, & nt_bgc_Sil, nlt_bgc_Sil, & @@ -2721,7 +2752,7 @@ subroutine init_zbgc trcr_base, n_trcr_strata, & nt_strata, bio_index) bio_index_o(nlt_bgc_Sil) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic + 3 - endif + endif if (tr_bgc_DMS) then ! all together call init_bgc_trcr(nk, nt_fbri, & nt_bgc_DMSPp, nlt_bgc_DMSPp, & @@ -2746,7 +2777,7 @@ subroutine init_zbgc trcr_base, n_trcr_strata, & nt_strata, bio_index) bio_index_o(nlt_bgc_DMS) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic + 6 - endif + endif if (tr_bgc_PON) then call init_bgc_trcr(nk, nt_fbri, & nt_bgc_PON, nlt_bgc_PON, & @@ -2788,8 +2819,8 @@ subroutine init_zbgc bio_index_o(nlt_bgc_Fep(mm)) = 2*icepack_max_algae + icepack_max_doc + icepack_max_dic & + icepack_max_don + icepack_max_fe + 7 + mm enddo ! mm - endif ! tr_bgc_Fe - + endif ! tr_bgc_Fe + if (tr_bgc_hum) then call init_bgc_trcr(nk, nt_fbri, & nt_bgc_hum, nlt_bgc_hum, & @@ -2798,7 +2829,7 @@ subroutine init_zbgc trcr_base, n_trcr_strata, & nt_strata, bio_index) bio_index_o(nlt_bgc_hum) = 2*icepack_max_algae + icepack_max_doc + 8 + icepack_max_dic & - + icepack_max_don + 2*icepack_max_fe + icepack_max_aero + + icepack_max_don + 2*icepack_max_fe + icepack_max_aero endif endif ! skl_bgc or z_tracers @@ -2822,7 +2853,7 @@ subroutine init_zbgc ! and 2 snow layers (snow surface + interior) nk = nblyr + 1 - nt_depend = 2 + nt_fbri + ntd + nt_depend = 2 + nt_fbri + ntd ! z layer aerosols if (tr_zaero) then @@ -2843,15 +2874,15 @@ subroutine init_zbgc endif ! tr_zaero if (nbtrcr > 0) then - do k = 1,nbtrcr - zbgc_frac_init(k) = c1 - trcr_depend(nt_zbgc_frac+k-1) = 2+nt_fbri + do k = 1,nbtrcr + zbgc_frac_init(k) = c1 + trcr_depend(nt_zbgc_frac+k-1) = 2+nt_fbri trcr_base(nt_zbgc_frac+ k - 1,1) = c0 trcr_base(nt_zbgc_frac+ k - 1,2) = c1 trcr_base(nt_zbgc_frac+ k - 1,3) = c0 - n_trcr_strata(nt_zbgc_frac+ k - 1)= 1 + n_trcr_strata(nt_zbgc_frac+ k - 1)= 1 nt_strata(nt_zbgc_frac+ k - 1,1) = nt_fbri - nt_strata(nt_zbgc_frac+ k - 1,2) = 0 + nt_strata(nt_zbgc_frac+ k - 1,2) = 0 tau_ret(k) = c1 tau_rel(k) = c1 if (bgc_tracer_type(k) >= c0 .and. bgc_tracer_type(k) < p5) then @@ -2879,7 +2910,7 @@ subroutine init_zbgc do k = 1, nbtrcr zbgc_init_frac(k) = frazil_scav if (bgc_tracer_type(k) < c0) zbgc_init_frac(k) = initbio_frac - enddo + enddo !----------------------------------------------------------------- ! set values in icepack @@ -2896,7 +2927,7 @@ subroutine init_zbgc !----------------------------------------------------------------- ! final consistency checks - !----------------------------------------------------------------- + !----------------------------------------------------------------- if (nbtrcr > icepack_max_nbtrcr) then write (nu_diag,*) subname,' ' write (nu_diag,*) subname,'nbtrcr > icepack_max_nbtrcr' @@ -2905,10 +2936,6 @@ subroutine init_zbgc endif if (.NOT. dEdd_algae) nbtrcr_sw = 1 - ! tcraig, added 6/1/21, why is nbtrcr_sw set here? - call icepack_init_tracer_sizes(nbtrcr_sw_in=nbtrcr_sw) - allocate(trcrn_sw(nx_block,ny_block,nbtrcr_sw,ncat,max_blocks)) ! bgc tracers active in the delta-Eddington shortwave - !----------------------------------------------------------------- ! spew !----------------------------------------------------------------- @@ -2917,13 +2944,13 @@ subroutine init_zbgc write(nu_diag,1020) ' number of bio tracers = ', nbtrcr write(nu_diag,1020) ' number of Isw tracers = ', nbtrcr_sw - + elseif (z_tracers) then - + write(nu_diag,1020) ' number of ztracers = ', nbtrcr write(nu_diag,1020) ' number of Isw tracers = ', nbtrcr_sw write(nu_diag,1000) ' initbio_frac = ', initbio_frac - write(nu_diag,1000) ' frazil_scav = ', frazil_scav + write(nu_diag,1000) ' frazil_scav = ', frazil_scav endif ! skl_bgc or solve_bgc endif ! master_task @@ -2972,7 +2999,7 @@ subroutine init_bgc_trcr(nk, nt_fbri, & integer (kind=int_kind) :: & k , & ! loop index n_strata , & ! temporary values - nt_strata1, & ! + nt_strata1, & ! nt_strata2 real (kind=dbl_kind) :: & @@ -2985,7 +3012,7 @@ subroutine init_bgc_trcr(nk, nt_fbri, & !-------- bgc_tracer_type(nlt_bgc) = bgctype - + if (nk > 1) then ! include vertical bgc in snow do k = nk, nk+1 trcr_depend (nt_bgc + k ) = 2 ! snow volume @@ -2997,10 +3024,10 @@ subroutine init_bgc_trcr(nk, nt_fbri, & nt_strata (nt_bgc + k,2) = 0 enddo - trcr_base1 = c0 - trcr_base2 = c1 + trcr_base1 = c0 + trcr_base2 = c1 trcr_base3 = c0 - n_strata = 1 + n_strata = 1 nt_strata1 = nt_fbri nt_strata2 = 0 else ! nk = 1 diff --git a/cicecore/shared/ice_restart_column.F90 b/cicecore/shared/ice_restart_column.F90 index 2c5b18c36..e830dd50b 100644 --- a/cicecore/shared/ice_restart_column.F90 +++ b/cicecore/shared/ice_restart_column.F90 @@ -12,7 +12,7 @@ module ice_restart_column use ice_communicate, only: my_task, master_task use ice_constants, only: c0, c1, p5 use ice_constants, only: field_loc_center, field_type_scalar - use ice_domain_size, only: ncat, nslyr, nfsd, nblyr + use ice_domain_size, only: ncat, nfsd, nblyr use ice_restart,only: read_restart_field, write_restart_field use ice_exit, only: abort_ice use ice_fileunits, only: nu_diag @@ -29,25 +29,26 @@ module ice_restart_column public :: write_restart_age, read_restart_age, & write_restart_FY, read_restart_FY, & write_restart_lvl, read_restart_lvl, & + write_restart_pond_cesm, read_restart_pond_cesm, & write_restart_pond_lvl, read_restart_pond_lvl, & write_restart_pond_topo, read_restart_pond_topo, & - write_restart_snow, read_restart_snow, & write_restart_fsd, read_restart_fsd, & write_restart_iso, read_restart_iso, & write_restart_aero, read_restart_aero, & write_restart_bgc, read_restart_bgc, & write_restart_hbrine, read_restart_hbrine - logical (kind=log_kind), public :: & + logical (kind=log_kind), public :: & restart_age , & ! if .true., read age tracer restart file restart_FY , & ! if .true., read FY tracer restart file restart_lvl , & ! if .true., read lvl tracer restart file + restart_pond_cesm, & ! if .true., read meltponds restart file restart_pond_lvl , & ! if .true., read meltponds restart file restart_pond_topo, & ! if .true., read meltponds restart file - restart_snow , & ! if .true., read snow tracer restart file restart_fsd , & ! if .true., read floe size restart file restart_iso , & ! if .true., read isotope tracer restart file restart_aero , & ! if .true., read aerosol tracer restart file + restart_zsal , & ! if .true., read Salinity from restart file restart_hbrine , & ! if .true., read hbrine from restart file restart_bgc ! if .true., read bgc restart file @@ -253,6 +254,73 @@ subroutine read_restart_lvl() end subroutine read_restart_lvl +!======================================================================= +! +! Dumps all values needed for restarting +! +! authors Elizabeth C. Hunke, LANL +! David A. Bailey, NCAR + + subroutine write_restart_pond_cesm() + + use ice_fileunits, only: nu_dump_pond + use ice_state, only: trcrn + + ! local variables + + logical (kind=log_kind) :: diag + integer (kind=int_kind) :: nt_apnd, nt_hpnd + character(len=*),parameter :: subname='(write_restart_pond_cesm)' + + call icepack_query_tracer_indices(nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) + + diag = .true. + + call write_restart_field(nu_dump_pond,0,trcrn(:,:,nt_apnd,:,:),'ruf8', & + 'apnd',ncat,diag) + call write_restart_field(nu_dump_pond,0,trcrn(:,:,nt_hpnd,:,:),'ruf8', & + 'hpnd',ncat,diag) + + end subroutine write_restart_pond_cesm + +!======================================================================= + +! Reads all values needed for a meltpond volume restart +! +! authors Elizabeth C. Hunke, LANL +! David A. Bailey, NCAR + + subroutine read_restart_pond_cesm() + + use ice_fileunits, only: nu_restart_pond + use ice_state, only: trcrn + + ! local variables + + logical (kind=log_kind) :: & + diag + integer (kind=int_kind) :: nt_apnd, nt_hpnd + character(len=*),parameter :: subname='(read_restart_pond_cesm)' + + call icepack_query_tracer_indices(nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) + + diag = .true. + + if (my_task == master_task) write(nu_diag,*) subname,'min/max cesm ponds' + + call read_restart_field(nu_restart_pond,0,trcrn(:,:,nt_apnd,:,:),'ruf8', & + 'apnd',ncat,diag,field_loc_center,field_type_scalar) + call read_restart_field(nu_restart_pond,0,trcrn(:,:,nt_hpnd,:,:),'ruf8', & + 'hpnd',ncat,diag,field_loc_center,field_type_scalar) + + end subroutine read_restart_pond_cesm + !======================================================================= ! ! Dumps all values needed for restarting @@ -304,7 +372,7 @@ end subroutine write_restart_pond_lvl subroutine read_restart_pond_lvl() use ice_arrays_column, only: dhsn, ffracn - use ice_fileunits, only: nu_restart_pond + use ice_fileunits, only: nu_restart_pond use ice_flux, only: fsnow use ice_state, only: trcrn @@ -384,7 +452,7 @@ end subroutine write_restart_pond_topo subroutine read_restart_pond_topo() - use ice_fileunits, only: nu_restart_pond + use ice_fileunits, only: nu_restart_pond use ice_state, only: trcrn ! local variables @@ -415,93 +483,6 @@ end subroutine read_restart_pond_topo !======================================================================= -! Dumps all values needed for restarting snow redistribution/metamorphism -! author Elizabeth C. Hunke, LANL - - subroutine write_restart_snow() - - use ice_fileunits, only: nu_dump_snow - use ice_state, only: trcrn - - ! local variables - - logical (kind=log_kind) :: diag - integer (kind=int_kind) :: nt_smice, nt_smliq, nt_rhos, nt_rsnw, k - character(len=3) :: ck - character(len=*),parameter :: subname='(write_restart_snow)' - - call icepack_query_tracer_indices(nt_smice_out=nt_smice, & - nt_smliq_out=nt_smliq, nt_rhos_out=nt_rhos, nt_rsnw_out=nt_rsnw) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - - diag = .true. - - !----------------------------------------------------------------- - - do k = 1,nslyr - write(ck,'(i3.3)') k - call write_restart_field(nu_dump_snow,0, trcrn(:,:,nt_smice+k-1,:,:), & - 'ruf8','smice'//trim(ck),ncat,diag) - call write_restart_field(nu_dump_snow,0, trcrn(:,:,nt_smliq+k-1,:,:), & - 'ruf8','smliq'//trim(ck),ncat,diag) - call write_restart_field(nu_dump_snow,0, trcrn(:,:,nt_rhos+k-1,:,:), & - 'ruf8','rhos'//trim(ck),ncat,diag) - call write_restart_field(nu_dump_snow,0, trcrn(:,:,nt_rsnw+k-1,:,:), & - 'ruf8','rsnw'//trim(ck),ncat,diag) - enddo - - end subroutine write_restart_snow - -!======================================================================= - -! Reads all values needed for a restart with snow redistribution/metamorphism -! author Elizabeth C. Hunke, LANL - - subroutine read_restart_snow() - - use ice_fileunits, only: nu_restart_snow - use ice_state, only: trcrn - - ! local variables - - logical (kind=log_kind) :: & - diag - integer (kind=int_kind) :: nt_smice, nt_smliq, nt_rhos, nt_rsnw, k - character(len=3) :: ck - character(len=*),parameter :: subname='(read_restart_snow)' - - call icepack_query_tracer_indices(nt_smice_out=nt_smice, & - nt_smliq_out=nt_smliq, nt_rhos_out=nt_rhos, nt_rsnw_out=nt_rsnw) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - - diag = .true. - - if (my_task == master_task) write(nu_diag,*) subname,'min/max snow tracers' - - do k=1,nslyr - write(ck,'(i3.3)') k - call read_restart_field(nu_restart_snow,0,trcrn(:,:,nt_smice+k-1,:,:), & - 'ruf8','smice'//trim(ck),ncat,diag, & - field_type=field_type_scalar,field_loc=field_loc_center) - call read_restart_field(nu_restart_snow,0,trcrn(:,:,nt_smliq+k-1,:,:), & - 'ruf8','smliq'//trim(ck),ncat,diag, & - field_type=field_type_scalar,field_loc=field_loc_center) - call read_restart_field(nu_restart_snow,0,trcrn(:,:,nt_rhos+k-1,:,:), & - 'ruf8','rhos'//trim(ck),ncat,diag, & - field_type=field_type_scalar,field_loc=field_loc_center) - call read_restart_field(nu_restart_snow,0,trcrn(:,:,nt_rsnw+k-1,:,:), & - 'ruf8','rsnw'//trim(ck),ncat,diag, & - field_type=field_type_scalar,field_loc=field_loc_center) - enddo - - end subroutine read_restart_snow - -!======================================================================= - ! Dumps all values needed for restarting ! author Elizabeth C. Hunke, LANL @@ -514,7 +495,7 @@ subroutine write_restart_fsd() logical (kind=log_kind) :: diag integer (kind=int_kind) :: nt_fsd, k - character(len=3) :: ck + character*3 ck character(len=*),parameter :: subname='(write_restart_fsd)' call icepack_query_tracer_indices(nt_fsd_out=nt_fsd) @@ -549,7 +530,7 @@ subroutine read_restart_fsd() logical (kind=log_kind) :: & diag integer (kind=int_kind) :: nt_fsd, k - character(len=3) :: ck + character*3 ck character(len=*),parameter :: subname='(read_restart_fsd)' call icepack_query_tracer_indices(nt_fsd_out=nt_fsd) @@ -585,7 +566,7 @@ subroutine write_restart_iso() logical (kind=log_kind) :: diag integer (kind=int_kind) :: nt_isosno, nt_isoice, k - character(len=3) :: ck + character*3 ck character(len=*),parameter :: subname='(write_restart_iso)' call icepack_query_tracer_indices(nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) @@ -627,7 +608,7 @@ subroutine read_restart_iso() logical (kind=log_kind) :: & diag integer (kind=int_kind) :: nt_isosno, nt_isoice, k - character(len=3) :: ck + character*3 ck character(len=*),parameter :: subname='(read_restart_iso)' call icepack_query_tracer_indices(nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice) @@ -810,14 +791,14 @@ subroutine read_restart_hbrine() !$OMP PARALLEL DO PRIVATE(iblk,i,j,n,ilo,ihi,jlo,jhi,this_block) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi do j = jlo, jhi - do i = ilo, ihi + do i = ilo, ihi do n = 1, ncat if (first_ice_real(i,j,n,iblk) >= p5) then first_ice (i,j,n,iblk) = .true. @@ -825,10 +806,9 @@ subroutine read_restart_hbrine() first_ice (i,j,n,iblk) = .false. endif enddo ! ncat - enddo ! i + enddo ! i enddo ! j enddo ! iblk - !$OMP END PARALLEL DO end subroutine read_restart_hbrine @@ -843,7 +823,6 @@ subroutine write_restart_hbrine() use ice_blocks, only: block, get_block use ice_domain, only: nblocks, blocks_ice use ice_fileunits, only: nu_dump_hbrine - use ice_grid, only: tmask use ice_state, only: trcrn use ice_restart,only: write_restart_field @@ -871,17 +850,16 @@ subroutine write_restart_hbrine() !$OMP PARALLEL DO PRIVATE(iblk,i,j,n,ilo,ihi,jlo,jhi,this_block) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi do j = jlo, jhi - do i = ilo, ihi + do i = ilo, ihi do n = 1, ncat - ! zero out first_ice over land - if (tmask(i,j,iblk) .and. first_ice (i,j,n,iblk)) then + if (first_ice (i,j,n,iblk)) then first_ice_real(i,j,n,iblk) = c1 else first_ice_real(i,j,n,iblk) = c0 @@ -890,7 +868,6 @@ subroutine write_restart_hbrine() enddo ! i enddo ! j enddo ! iblk - !$OMP END PARALLEL DO call write_restart_field(nu_dump_hbrine,0,trcrn(:,:,nt_fbri,:,:),'ruf8', & 'fbrn',ncat,diag) @@ -907,6 +884,7 @@ end subroutine write_restart_hbrine subroutine write_restart_bgc() + use ice_arrays_column, only: Rayleigh_criteria, Rayleigh_real use ice_blocks, only: block, get_block use ice_domain, only: nblocks, blocks_ice use ice_domain_size, only: ncat, n_algae, n_doc, n_dic, & @@ -914,9 +892,8 @@ subroutine write_restart_bgc() use ice_fileunits, only: nu_dump_bgc use ice_flux_bgc, only: nit, amm, sil, dmsp, dms, algalN, & doc, don, dic, fed, fep, zaeros, hum - use ice_grid, only: tmask use ice_state, only: trcrn - use ice_flux, only: sss + use ice_flux, only: sss use ice_restart, only: write_restart_field ! local variables @@ -930,45 +907,45 @@ subroutine write_restart_bgc() character (len=3) :: nchar, ncharb - integer (kind=int_kind) :: nt_bgc_Am, & + integer (kind=int_kind) :: nt_bgc_S, nt_bgc_Am, & nt_bgc_DMS, nt_bgc_DMSPd, & nt_bgc_DMSPp, nt_bgc_Nit, nt_bgc_Sil, & nt_bgc_PON, nt_zbgc_frac, nt_bgc_hum, nbtrcr - integer (kind=int_kind), dimension(icepack_max_algae) :: & - nt_bgc_N , & ! diatoms, phaeocystis, pico/small - nt_bgc_C , & ! diatoms, phaeocystis, pico/small - nt_bgc_chl ! diatoms, phaeocystis, pico/small + integer (kind=int_kind), dimension(icepack_max_algae) :: & + nt_bgc_N , & ! diatoms, phaeocystis, pico/small + nt_bgc_C , & ! diatoms, phaeocystis, pico/small + nt_bgc_chl ! diatoms, phaeocystis, pico/small - integer (kind=int_kind), dimension(icepack_max_doc) :: & + integer (kind=int_kind), dimension(icepack_max_doc) :: & nt_bgc_DOC ! dissolved organic carbon - integer (kind=int_kind), dimension(icepack_max_don) :: & + integer (kind=int_kind), dimension(icepack_max_don) :: & nt_bgc_DON ! dissolved organic nitrogen - integer (kind=int_kind), dimension(icepack_max_dic) :: & + integer (kind=int_kind), dimension(icepack_max_dic) :: & nt_bgc_DIC ! dissolved inorganic carbon - integer (kind=int_kind), dimension(icepack_max_fe) :: & + integer (kind=int_kind), dimension(icepack_max_fe) :: & nt_bgc_Fed, & ! dissolved iron nt_bgc_Fep ! particulate iron - integer (kind=int_kind), dimension(icepack_max_aero) :: & + integer (kind=int_kind), dimension(icepack_max_aero) :: & nt_zaero ! black carbon and other aerosols - + logical (kind=log_kind) :: tr_bgc_Nit, tr_bgc_Am, tr_bgc_Sil,& tr_bgc_DMS, tr_bgc_PON, tr_bgc_N, tr_bgc_C, & tr_bgc_DON, tr_bgc_Fe, tr_zaero , tr_bgc_chl, & tr_bgc_hum - logical (kind=log_kind) :: skl_bgc + logical (kind=log_kind) :: skl_bgc, solve_zsal type (block) :: & this_block ! block information for current block character(len=*),parameter :: subname='(write_restart_bgc)' - call icepack_query_parameters(skl_bgc_out=skl_bgc) + call icepack_query_parameters(skl_bgc_out=skl_bgc, solve_zsal_out=solve_zsal) call icepack_query_tracer_sizes(nbtrcr_out=nbtrcr) call icepack_query_tracer_flags(tr_bgc_Nit_out=tr_bgc_Nit, & tr_bgc_Am_out=tr_bgc_Am, tr_bgc_Sil_out=tr_bgc_Sil, & @@ -976,7 +953,7 @@ subroutine write_restart_bgc() tr_bgc_N_out=tr_bgc_N, tr_bgc_C_out=tr_bgc_C, & tr_bgc_DON_out=tr_bgc_DON, tr_bgc_Fe_out=tr_bgc_Fe, tr_zaero_out=tr_zaero, & tr_bgc_chl_out=tr_bgc_chl, tr_bgc_hum_out=tr_bgc_hum) - call icepack_query_tracer_indices(nt_bgc_Am_out=nt_bgc_Am, & + call icepack_query_tracer_indices(nt_bgc_S_out=nt_bgc_S, nt_bgc_Am_out=nt_bgc_Am, & nt_bgc_DMS_out=nt_bgc_DMS, nt_bgc_DMSPd_out=nt_bgc_DMSPd, & nt_bgc_C_out=nt_bgc_C, nt_bgc_chl_out=nt_bgc_chl, & nt_bgc_DMSPp_out=nt_bgc_DMSPp, nt_bgc_Nit_out=nt_bgc_Nit, & @@ -991,36 +968,39 @@ subroutine write_restart_bgc() diag = .true. !----------------------------------------------------------------- - ! Zero out tracers over land + ! Salinity and extras !----------------------------------------------------------------- + if (solve_zsal) then + + do k = 1,nblyr + write(nchar,'(i3.3)') k + call write_restart_field(nu_dump_bgc,0,trcrn(:,:,nt_bgc_S+k-1,:,:),'ruf8', & + 'zSalinity'//trim(nchar),ncat,diag) + enddo + + call write_restart_field(nu_dump_bgc,0,sss,'ruf8','sss',1,diag) !$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) do iblk = 1, nblocks - this_block = get_block(blocks_ice(iblk),iblk) + this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo ihi = this_block%ihi jlo = this_block%jlo jhi = this_block%jhi do j = jlo, jhi do i = ilo, ihi - if (.not. tmask(i,j,iblk)) then - if (tr_bgc_N ) algalN(i,j,:,iblk) = c0 - if (tr_bgc_C ) doc (i,j,:,iblk) = c0 - if (tr_bgc_C ) dic (i,j,:,iblk) = c0 - if (tr_bgc_Nit) nit (i,j ,iblk) = c0 - if (tr_bgc_Am ) amm (i,j ,iblk) = c0 - if (tr_bgc_Sil) sil (i,j ,iblk) = c0 - if (tr_bgc_hum) hum (i,j ,iblk) = c0 - if (tr_bgc_DMS) dms (i,j ,iblk) = c0 - if (tr_bgc_DMS) dmsp (i,j ,iblk) = c0 - if (tr_bgc_DON) don (i,j,:,iblk) = c0 - if (tr_bgc_Fe ) fed (i,j,:,iblk) = c0 - if (tr_bgc_Fe ) fep (i,j,:,iblk) = c0 + if (Rayleigh_criteria(i,j,iblk)) then + Rayleigh_real (i,j,iblk) = c1 + elseif (.NOT. Rayleigh_criteria(i,j,iblk)) then + Rayleigh_real (i,j,iblk) = c0 endif enddo enddo enddo - !$OMP END PARALLEL DO + + call write_restart_field(nu_dump_bgc,0,Rayleigh_real,'ruf8','Rayleigh',1,diag) + + endif ! solve_zsal !----------------------------------------------------------------- ! Skeletal layer BGC @@ -1075,7 +1055,7 @@ subroutine write_restart_bgc() if (tr_bgc_PON) & call write_restart_field(nu_dump_bgc,0,trcrn(:,:,nt_bgc_PON,:,:), & 'ruf8','bgc_PON',ncat,diag) - + if (tr_bgc_DON) then do k = 1, n_don write(nchar,'(i3.3)') k @@ -1084,19 +1064,19 @@ subroutine write_restart_bgc() enddo endif if (tr_bgc_Fe ) then - do k = 1, n_fed + do k = 1, n_fed write(nchar,'(i3.3)') k call write_restart_field(nu_dump_bgc,0,trcrn(:,:,nt_bgc_Fed (k),:,:), & 'ruf8','bgc_Fed'//trim(nchar),ncat,diag) enddo - do k = 1, n_fep + do k = 1, n_fep write(nchar,'(i3.3)') k call write_restart_field(nu_dump_bgc,0,trcrn(:,:,nt_bgc_Fep (k),:,:), & 'ruf8','bgc_Fep'//trim(nchar),ncat,diag) enddo endif - else + else !----------------------------------------------------------------- ! Z layer BGC @@ -1267,7 +1247,7 @@ subroutine write_restart_bgc() write(nchar,'(i3.3)') k call write_restart_field(nu_dump_bgc,0,dic(:,:,k,:),'ruf8','dic'//trim(nchar),1,diag) enddo !k - endif + endif if (tr_bgc_Nit) & call write_restart_field(nu_dump_bgc,0,nit, 'ruf8','nit', 1,diag) if (tr_bgc_Am) & @@ -1313,13 +1293,14 @@ end subroutine write_restart_bgc subroutine read_restart_bgc() + use ice_arrays_column, only: Rayleigh_real, Rayleigh_criteria use ice_blocks, only: block, get_block use ice_communicate, only: my_task, master_task use ice_domain, only: nblocks, blocks_ice use ice_domain_size, only: ncat, n_algae, n_doc, n_dic,& n_don, n_zaero, n_fed, n_fep use ice_fileunits, only: nu_restart_bgc - use ice_flux, only: sss + use ice_flux, only: sss use ice_flux_bgc, only: nit, amm, sil, dmsp, dms, algalN, & doc, don, dic, fed, fep, zaeros, hum use ice_state, only: trcrn @@ -1337,44 +1318,44 @@ subroutine read_restart_bgc() logical (kind=log_kind) :: diag - integer (kind=int_kind) :: nt_bgc_Am, & + integer (kind=int_kind) :: nt_bgc_S, nt_bgc_Am, & nt_bgc_DMS, nt_bgc_DMSPd, & nt_bgc_DMSPp, nt_bgc_Nit, nt_bgc_Sil, & nt_bgc_PON, nt_zbgc_frac, nt_bgc_hum, nbtrcr - integer (kind=int_kind), dimension(icepack_max_algae) :: & - nt_bgc_N , & ! diatoms, phaeocystis, pico/small - nt_bgc_C , & ! diatoms, phaeocystis, pico/small - nt_bgc_chl ! diatoms, phaeocystis, pico/small + integer (kind=int_kind), dimension(icepack_max_algae) :: & + nt_bgc_N , & ! diatoms, phaeocystis, pico/small + nt_bgc_C , & ! diatoms, phaeocystis, pico/small + nt_bgc_chl ! diatoms, phaeocystis, pico/small - integer (kind=int_kind), dimension(icepack_max_doc) :: & + integer (kind=int_kind), dimension(icepack_max_doc) :: & nt_bgc_DOC ! dissolved organic carbon - integer (kind=int_kind), dimension(icepack_max_don) :: & + integer (kind=int_kind), dimension(icepack_max_don) :: & nt_bgc_DON ! dissolved organic nitrogen - integer (kind=int_kind), dimension(icepack_max_dic) :: & + integer (kind=int_kind), dimension(icepack_max_dic) :: & nt_bgc_DIC ! dissolved inorganic carbon - integer (kind=int_kind), dimension(icepack_max_fe) :: & + integer (kind=int_kind), dimension(icepack_max_fe) :: & nt_bgc_Fed, & ! dissolved iron nt_bgc_Fep ! particulate iron - integer (kind=int_kind), dimension(icepack_max_aero) :: & + integer (kind=int_kind), dimension(icepack_max_aero) :: & nt_zaero ! black carbon and other aerosols - + logical (kind=log_kind) :: tr_bgc_Nit, tr_bgc_Am, tr_bgc_Sil,& tr_bgc_DMS, tr_bgc_PON, tr_bgc_N, tr_bgc_C, & tr_bgc_DON, tr_bgc_Fe, tr_zaero , tr_bgc_chl, & tr_bgc_hum - logical (kind=log_kind) :: skl_bgc + logical (kind=log_kind) :: skl_bgc, solve_zsal character (len=3) :: nchar, ncharb character(len=*),parameter :: subname='(read_restart_bgc)' - call icepack_query_parameters(skl_bgc_out=skl_bgc) + call icepack_query_parameters(skl_bgc_out=skl_bgc, solve_zsal_out=solve_zsal) call icepack_query_tracer_sizes(nbtrcr_out=nbtrcr) call icepack_query_tracer_flags(tr_bgc_Nit_out=tr_bgc_Nit, & tr_bgc_Am_out=tr_bgc_Am, tr_bgc_Sil_out=tr_bgc_Sil, & @@ -1382,7 +1363,7 @@ subroutine read_restart_bgc() tr_bgc_N_out=tr_bgc_N, tr_bgc_C_out=tr_bgc_C, & tr_bgc_DON_out=tr_bgc_DON, tr_bgc_Fe_out=tr_bgc_Fe, tr_zaero_out=tr_zaero, & tr_bgc_chl_out=tr_bgc_chl, tr_bgc_hum_out=tr_bgc_hum) - call icepack_query_tracer_indices(nt_bgc_Am_out=nt_bgc_Am, & + call icepack_query_tracer_indices(nt_bgc_S_out=nt_bgc_S, nt_bgc_Am_out=nt_bgc_Am, & nt_bgc_DMS_out=nt_bgc_DMS, nt_bgc_DMSPd_out=nt_bgc_DMSPd, & nt_bgc_C_out=nt_bgc_C, nt_bgc_chl_out=nt_bgc_chl, & nt_bgc_DMSPp_out=nt_bgc_DMSPp, nt_bgc_Nit_out=nt_bgc_Nit, & @@ -1396,6 +1377,43 @@ subroutine read_restart_bgc() diag = .true. + !----------------------------------------------------------------- + ! Salinity and extras + !----------------------------------------------------------------- + + if (restart_zsal) then + + if (my_task == master_task) write(nu_diag,*) subname,'zSalinity restart' + do k = 1,nblyr + write(nchar,'(i3.3)') k + call read_restart_field(nu_restart_bgc,0,trcrn(:,:,nt_bgc_S+k-1,:,:),'ruf8', & + 'zSalinity'//trim(nchar),ncat,diag,field_loc_center,field_type_scalar) + enddo + + if (my_task == master_task) write(nu_diag,*) subname,'sea surface salinity' + call read_restart_field(nu_restart_bgc,0,sss,'ruf8','sss',1,diag) + call read_restart_field(nu_restart_bgc,0,Rayleigh_real,'ruf8','Rayleigh',1,diag) + + !$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) + do iblk = 1, nblocks + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + + do j = jlo, jhi + do i = ilo, ihi + if (Rayleigh_real (i,j,iblk) .GE. c1) then + Rayleigh_criteria (i,j,iblk) = .true. + elseif (Rayleigh_real (i,j,iblk) < c1) then + Rayleigh_criteria (i,j,iblk) = .false. + endif + enddo + enddo + enddo + endif ! restart_zsal + !----------------------------------------------------------------- ! Skeletal Layer BGC !----------------------------------------------------------------- @@ -1466,13 +1484,13 @@ subroutine read_restart_bgc() enddo endif if (tr_bgc_Fe) then - do k = 1, n_fed + do k = 1, n_fed write(nchar,'(i3.3)') k call read_restart_field(nu_restart_bgc,0, & trcrn(:,:,nt_bgc_Fed (k),:,:), & 'ruf8','bgc_Fed'//trim(nchar),ncat,diag) enddo - do k = 1, n_fep + do k = 1, n_fep write(nchar,'(i3.3)') k call read_restart_field(nu_restart_bgc,0, & trcrn(:,:,nt_bgc_Fep (k),:,:), & @@ -1710,7 +1728,7 @@ subroutine read_restart_bgc() enddo !k endif endif ! restart_bgc - + end subroutine read_restart_bgc !======================================================================= diff --git a/configuration/scripts/cice.settings b/configuration/scripts/cice.settings old mode 100644 new mode 100755 index 76ae6ad9e..7d9bce65c --- a/configuration/scripts/cice.settings +++ b/configuration/scripts/cice.settings @@ -1,9 +1,9 @@ -#!/bin/csh -f +#! /bin/csh -f setenv ICE_CASENAME undefined setenv ICE_SANDBOX undefined setenv ICE_MACHINE undefined -setenv ICE_ENVNAME undefined +setenv ICE_COMPILER undefined setenv ICE_MACHCOMP undefined setenv ICE_SCRIPTS undefined setenv ICE_CASEDIR undefined @@ -13,15 +13,12 @@ setenv ICE_RSTDIR ${ICE_RUNDIR}/restart setenv ICE_HSTDIR ${ICE_RUNDIR}/history setenv ICE_LOGDIR ${ICE_CASEDIR}/logs setenv ICE_DRVOPT standalone/cice -setenv ICE_TARGET cice -setenv ICE_IOTYPE netcdf # binary, netcdf, pio1, pio2 +setenv ICE_IOTYPE netcdf # set to none if netcdf library is unavailable setenv ICE_CLEANBUILD true -setenv ICE_CPPDEFS "" setenv ICE_QUIETMODE false setenv ICE_GRID undefined setenv ICE_NTASKS undefined setenv ICE_NTHRDS undefined -setenv ICE_OMPSCHED "static,1" setenv ICE_TEST undefined setenv ICE_TESTNAME undefined setenv ICE_TESTID undefined @@ -29,10 +26,8 @@ setenv ICE_BASELINE undefined setenv ICE_BASEGEN undefined setenv ICE_BASECOM undefined setenv ICE_BFBCOMP undefined -setenv ICE_BFBTYPE restart setenv ICE_SPVAL undefined setenv ICE_RUNLENGTH -1 -setenv ICE_MEMUSE -1 setenv ICE_ACCOUNT undefined setenv ICE_QUEUE undefined @@ -45,5 +40,5 @@ if (${ICE_NTASKS} == 1) setenv ICE_COMMDIR serial ### Specialty code setenv ICE_BLDDEBUG false # build debug flags -setenv ICE_COVERAGE false # build coverage flags +setenv ICE_CODECOV false # build debug flags diff --git a/configuration/scripts/ice_in b/configuration/scripts/ice_in index 8fff799dc..dcfedf772 100644 --- a/configuration/scripts/ice_in +++ b/configuration/scripts/ice_in @@ -1,59 +1,42 @@ &setup_nml days_per_year = 365 - use_leap_years = .true. - year_init = 2005 - month_init = 1 - day_init = 1 - sec_init = 0 + use_leap_years = .false. + year_init = 1997 istep0 = 0 dt = 3600.0 - npt_unit = '1' npt = 24 ndtd = 1 runtype = 'initial' ice_ic = './restart/iced_gx3_v5.nc' + restart = .true. restart_ext = .false. - use_restart_time = .false. - restart_format = 'default' + use_restart_time = .true. + restart_format = 'nc' lcdf64 = .false. numin = 21 numax = 89 restart_dir = './restart/' restart_file = 'iced' pointer_file = './ice.restart_file' - dumpfreq = 'd','x','x','x','x' - dumpfreq_n = 1 , 1 , 1 , 1 , 1 - dumpfreq_base = 'init','init','init','init','init' + dumpfreq = 'd' + dumpfreq_n = 1 dump_last = .false. bfbflag = 'off' diagfreq = 24 diag_type = 'stdout' diag_file = 'ice_diag.d' - debug_model = .false. - debug_model_step = 0 - debug_model_i = -1 - debug_model_j = -1 - debug_model_iblk = -1 - debug_model_task = -1 - debug_forcing = .false. print_global = .true. print_points = .true. - timer_stats = .false. - memory_stats = .false. - conserv_check = .false. latpnt(1) = 90. lonpnt(1) = 0. latpnt(2) = -65. lonpnt(2) = -45. + dbug = .false. histfreq = 'm','x','x','x','x' histfreq_n = 1 , 1 , 1 , 1 , 1 - histfreq_base = 'zero','zero','zero','zero','zero' - hist_avg = .true.,.true.,.true.,.true.,.true. + hist_avg = .true. history_dir = './history/' history_file = 'iceh' - history_precision = 4 - history_format = 'default' - hist_time_axis = 'end' write_ic = .true. incond_dir = './history/' incond_file = 'iceh_ic' @@ -63,31 +46,20 @@ &grid_nml grid_format = 'bin' grid_type = 'displaced_pole' - grid_ice = 'B' - grid_atm = 'A' - grid_ocn = 'A' grid_file = 'grid' - kmt_type = 'file' kmt_file = 'kmt' bathymetry_file = 'unknown_bathymetry_file' - bathymetry_format = 'default' use_bathymetry = .false. gridcpl_file = 'unknown_gridcpl_file' kcatbound = 0 dxrect = 30.e5 dyrect = 30.e5 - lonrefrect = -156.50d0 - latrefrect = 71.35d0 - scale_dxdy = .false. - dxscale = 1.d0 - dyscale = 1.d0 close_boundaries = .false. ncat = 5 nfsd = 1 nilyr = 7 nslyr = 1 - nblyr = 1 - orca_halogrid = .false. + nblyr = 7 / &tracer_nml @@ -106,12 +78,12 @@ restart_FY = .false. tr_lvl = .true. restart_lvl = .false. + tr_pond_cesm = .false. + restart_pond_cesm = .false. tr_pond_topo = .false. restart_pond_topo = .false. tr_pond_lvl = .true. restart_pond_lvl = .false. - tr_snow = .false. - restart_snow = .false. tr_iso = .false. restart_iso = .false. tr_aero = .false. @@ -131,15 +103,13 @@ dSdt_slow_mode = -5.0e-8 phi_c_slow_mode = 0.05 phi_i_mushy = 0.85 - hfrazilmin = 0.05d0 - floediam = 300.0d0 / &dynamics_nml kdyn = 1 ndte = 240 revised_evp = .false. - evp_algorithm = 'standard_2d' + kevp_kernel = 0 brlx = 300.0 arlx = 300.0 advection = 'remap' @@ -147,42 +117,17 @@ krdg_partic = 1 krdg_redist = 1 mu_rdg = 3 - Pstar = 2.75e4 - Cstar = 20 Cf = 17. Ktens = 0. - e_yieldcurve = 2. - e_plasticpot = 2. - visc_method = 'avg_zeta' - elasticDamp = 0.36d0 - deltaminEVP = 1e-11 - deltaminVP = 2e-9 - capping_method = 'max' - seabed_stress = .false. - seabed_stress_method = 'LKD' - k1 = 7.5 + e_ratio = 2. + basalstress = .false. + k1 = 8. k2 = 15. alphab = 20. threshold_hw = 30. coriolis = 'latitude' kridge = 1 ktransport = 1 - ssh_stress = 'geostrophic' - maxits_nonlin = 10 - precond = 'pgmres' - dim_fgmres = 50 - dim_pgmres = 5 - maxits_fgmres = 1 - maxits_pgmres = 1 - monitor_nonlin = .false. - monitor_fgmres = .false. - monitor_pgmres = .false. - ortho_type = 'mgs' - reltol_nonlin = 1e-8 - reltol_fgmres = 1e-1 - reltol_pgmres = 1e-6 - algo_nonlin = 'picard' - use_mean_vrel = .true. / &shortwave_nml @@ -199,9 +144,6 @@ dT_mlt = 1.5 rsnw_mlt = 1500. kalg = 0.6 - sw_redist = .false. - sw_frac = 0.9d0 - sw_dtemp = 0.02d0 / &ponds_nml @@ -215,53 +157,23 @@ pndaspect = 0.8 / -&snow_nml - snwredist = 'none' - snwgrain = .false. - use_smliq_pnd = .false. - rsnw_fall = 100.0 - rsnw_tmax = 1500.0 - rhosnew = 100.0 - rhosmin = 100.0 - rhosmax = 450.0 - windmin = 10.0 - drhosdwind = 27.3 - snwlvlfac = 0.3 - snw_aging_table = 'test' - snw_filename = 'unknown' - snw_rhos_fname = 'unknown' - snw_Tgrd_fname = 'unknown' - snw_T_fname = 'unknown' - snw_tau_fname = 'unknown' - snw_kappa_fname = 'unknown' - snw_drdt0_fname = 'unknown' -/ - &forcing_nml formdrag = .false. - atmbndy = 'similarity' - rotate_wind = .true. + atmbndy = 'default' calc_strair = .true. calc_Tsfc = .true. highfreq = .false. natmiter = 5 - atmiter_conv = 0.0d0 ustar_min = 0.0005 - iceruf = 0.0005 - calc_dragio = .false. - iceruf_ocn = 0.03 - emissivity = 0.985 + emissivity = 0.95 fbot_xfer_type = 'constant' update_ocn_f = .false. l_mpond_fresh = .false. tfrz_option = 'mushy' - saltflux_option = 'constant' - ice_ref_salinity = 4.0 oceanmixed_ice = .true. wave_spec_type = 'none' wave_spec_file = 'unknown_wave_spec_file' nfreq = 25 - restart_coszen = .false. restore_ice = .false. restore_ocn = .false. trestore = 90 @@ -271,13 +183,11 @@ ocn_data_type = 'default' bgc_data_type = 'default' fe_data_type = 'default' - ice_data_type = 'latsst' - ice_data_conc = 'parabolic' - ice_data_dist = 'uniform' - fyear_init = 2005 + ice_data_type = 'default' + fyear_init = 1997 ycycle = 1 atm_data_format = 'bin' - atm_data_dir = 'unknown_atm_data_dir' + atm_data_dir = '/glade/u/home/tcraig/cice_data/' bgc_data_dir = 'unknown_bgc_data_dir' ocn_data_format = 'bin' ocn_data_dir = '/unknown_ocn_data_dir' @@ -294,14 +204,11 @@ processor_shape = 'slenderX2' distribution_type = 'cartesian' distribution_wght = 'latitude' - distribution_wght_file = 'unknown' ew_boundary_type = 'cyclic' ns_boundary_type = 'open' maskhalo_dyn = .false. maskhalo_remap = .false. maskhalo_bound = .false. - add_mpi_barriers = .false. - debug_blocks = .false. / &zbgc_nml @@ -309,8 +216,6 @@ restart_hbrine = .false. tr_zaero = .false. modal_aero = .false. - optics_file = 'ICE_MACHINE_INPUTDATA/CICE_data/forcing/snicar_optics_5bnd_snow_and_aerosols.nc' - optics_file_fieldname = 'modalBCabsorptionParameter5band' skl_bgc = .false. z_tracers = .false. dEdd_algae = .false. @@ -457,22 +362,13 @@ &icefields_nml f_tmask = .true. - f_umask = .false. - f_nmask = .false. - f_emask = .false. f_blkmask = .true. f_tarea = .true. f_uarea = .true. - f_narea = .false. - f_earea = .false. f_dxt = .false. f_dyt = .false. f_dxu = .false. f_dyu = .false. - f_dxe = .false. - f_dye = .false. - f_dxn = .false. - f_dyn = .false. f_HTN = .false. f_HTE = .false. f_ANGLE = .true. @@ -597,8 +493,7 @@ f_fcondtopn_ai = 'x' f_fmelttn_ai = 'x' f_flatn_ai = 'x' - f_fsensn_ai = 'x' - f_CMIP = 'x' + f_fsensn_ai = 'x' / &icefields_mechred_nml @@ -637,21 +532,6 @@ f_apeff_ai = 'm' / -&icefields_snow_nml - f_smassicen = 'x' - f_smassliqn = 'x' - f_rhos_cmpn = 'x' - f_rhos_cntn = 'x' - f_rsnwn = 'x' - f_smassice = 'm' - f_smassliq = 'm' - f_rhos_cmp = 'm' - f_rhos_cnt = 'm' - f_rsnw = 'm' - f_meltsliq = 'm' - f_fsloss = 'm' -/ - &icefields_bgc_nml f_fiso_atm = 'x' f_fiso_ocn = 'x' diff --git a/configuration/scripts/machines/Macros.gaffney_gnu b/configuration/scripts/machines/Macros.gaffney_gnu index 4ae235bc9..0d13560de 100644 --- a/configuration/scripts/machines/Macros.gaffney_gnu +++ b/configuration/scripts/machines/Macros.gaffney_gnu @@ -16,14 +16,14 @@ ifeq ($(ICE_BLDDEBUG), true) CFLAGS += -O0 endif -ifeq ($(ICE_COVERAGE), true) +ifeq ($(ICE_CODECOV), true) FFLAGS += -O0 -g -fprofile-arcs -ftest-coverage CFLAGS += -O0 -g -coverage LDFLAGS += -g -ftest-coverage -fprofile-arcs endif ifneq ($(ICE_BLDDEBUG), true) -ifneq ($(ICE_COVERAGE), true) +ifneq ($(ICE_CODECOV), true) FFLAGS += -O2 CFLAGS += -O2 endif @@ -66,3 +66,10 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -fopenmp endif +### if using parallel I/O, load all 3 libraries. PIO must be first! +ifeq ($(ICE_IOTYPE), pio) + PIO_PATH:=/glade/u/home/jedwards/pio1_6_5/pio + INCLDIR += -I$(PIO_PATH) + SLIBS := $(SLIBS) -L$(PIO_PATH) -lpio +endif + diff --git a/configuration/scripts/machines/Macros.izumi_gnu b/configuration/scripts/machines/Macros.izumi_gnu index 99df7a033..cdc6620f4 100644 --- a/configuration/scripts/machines/Macros.izumi_gnu +++ b/configuration/scripts/machines/Macros.izumi_gnu @@ -16,14 +16,14 @@ ifeq ($(ICE_BLDDEBUG), true) CFLAGS += -O0 endif -ifeq ($(ICE_COVERAGE), true) +ifeq ($(ICE_CODECOV), true) FFLAGS += -O0 -g -fprofile-arcs -ftest-coverage CFLAGS += -O0 -g -coverage LDFLAGS += -g -ftest-coverage -fprofile-arcs endif ifneq ($(ICE_BLDDEBUG), true) -ifneq ($(ICE_COVERAGE), true) +ifneq ($(ICE_CODECOV), true) FFLAGS += -O2 CFLAGS += -O2 endif @@ -55,3 +55,10 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -fopenmp endif +## if using parallel I/O, load all 3 libraries. PIO must be first! +ifeq ($(ICE_IOTYPE), pio) + PIO_PATH:= + INCLDIR += -I + SLIBS := $(SLIB) -L$(PIO_PATH) -lpiofS +endif + diff --git a/configuration/scripts/machines/Macros.narwhal_gnu b/configuration/scripts/machines/Macros.narwhal_gnu index e980c1e29..2e80f7364 100644 --- a/configuration/scripts/machines/Macros.narwhal_gnu +++ b/configuration/scripts/machines/Macros.narwhal_gnu @@ -1,5 +1,5 @@ #============================================================================== -# Macros file for NAVYDSRC narwhal, gnu compiler +# Macros file for NAVYDSRC gordon, gnu compiler #============================================================================== CPP := ftn -E @@ -8,22 +8,22 @@ CFLAGS := -c FIXEDFLAGS := -ffixed-line-length-132 FREEFLAGS := -ffree-form -FFLAGS := -fconvert=big-endian -fbacktrace -ffree-line-length-none -fallow-argument-mismatch +FFLAGS := -fconvert=big-endian -fbacktrace -ffree-line-length-none FFLAGS_NOOPT:= -O0 ifeq ($(ICE_BLDDEBUG), true) - FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow - CFLAGS += -O0 + FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow + CFLAGS += -O0 endif -ifeq ($(ICE_COVERAGE), true) +ifeq ($(ICE_CODECOV), true) FFLAGS += -O0 -g -fprofile-arcs -ftest-coverage CFLAGS += -O0 -g -coverage LDFLAGS += -g -ftest-coverage -fprofile-arcs endif ifneq ($(ICE_BLDDEBUG), true) -ifneq ($(ICE_COVERAGE), true) +ifneq ($(ICE_CODECOV), true) FFLAGS += -O2 CFLAGS += -O2 endif @@ -65,3 +65,10 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -fopenmp endif +### if using parallel I/O, load all 3 libraries. PIO must be first! +ifeq ($(ICE_IOTYPE), pio) + PIO_PATH:=/glade/u/home/jedwards/pio1_6_5/pio + INCLDIR += -I$(PIO_PATH) + SLIBS := $(SLIBS) -L$(PIO_PATH) -lpio +endif + diff --git a/configuration/scripts/machines/Macros.onyx_gnu b/configuration/scripts/machines/Macros.onyx_gnu index 31d0e64aa..d423cd9ab 100644 --- a/configuration/scripts/machines/Macros.onyx_gnu +++ b/configuration/scripts/machines/Macros.onyx_gnu @@ -8,7 +8,7 @@ CFLAGS := -c FIXEDFLAGS := -ffixed-line-length-132 FREEFLAGS := -ffree-form -FFLAGS := -fconvert=big-endian -fbacktrace -ffree-line-length-none -fallow-argument-mismatch +FFLAGS := -fconvert=big-endian -fbacktrace -ffree-line-length-none FFLAGS_NOOPT:= -O0 ifeq ($(ICE_BLDDEBUG), true) @@ -16,14 +16,14 @@ ifeq ($(ICE_BLDDEBUG), true) CFLAGS += -O0 endif -ifeq ($(ICE_COVERAGE), true) +ifeq ($(ICE_CODECOV), true) FFLAGS += -O0 -g -fprofile-arcs -ftest-coverage CFLAGS += -O0 -g -coverage LDFLAGS += -g -ftest-coverage -fprofile-arcs endif ifneq ($(ICE_BLDDEBUG), true) -ifneq ($(ICE_COVERAGE), true) +ifneq ($(ICE_CODECOV), true) FFLAGS += -O2 CFLAGS += -O2 endif @@ -65,3 +65,10 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -fopenmp endif +### if using parallel I/O, load all 3 libraries. PIO must be first! +ifeq ($(ICE_IOTYPE), pio) + PIO_PATH:=/glade/u/home/jedwards/pio1_6_5/pio + INCLDIR += -I$(PIO_PATH) + SLIBS := $(SLIBS) -L$(PIO_PATH) -lpio +endif + diff --git a/configuration/scripts/machines/Macros.travisCI_gnu b/configuration/scripts/machines/Macros.travisCI_gnu index 5d68fdceb..aa7b12c05 100644 --- a/configuration/scripts/machines/Macros.travisCI_gnu +++ b/configuration/scripts/machines/Macros.travisCI_gnu @@ -16,14 +16,14 @@ ifeq ($(ICE_BLDDEBUG), true) CFLAGS += -O0 endif -ifeq ($(ICE_COVERAGE), true) +ifeq ($(ICE_CODECOV), true) FFLAGS += -O0 -g -fprofile-arcs -ftest-coverage CFLAGS += -O0 -g -coverage LDFLAGS += -g -ftest-coverage -fprofile-arcs endif ifneq ($(ICE_BLDDEBUG), true) -ifneq ($(ICE_COVERAGE), true) +ifneq ($(ICE_CODECOV), true) FFLAGS += -O2 CFLAGS += -O2 endif diff --git a/configuration/scripts/tests/base_suite.ts b/configuration/scripts/tests/base_suite.ts old mode 100644 new mode 100755 index 906aae08d..fad8b22f3 --- a/configuration/scripts/tests/base_suite.ts +++ b/configuration/scripts/tests/base_suite.ts @@ -5,77 +5,46 @@ smoke gx3 1x4 debug,diag1,run2day smoke gx3 4x1 debug,diag1,run5day restart gx3 8x2 debug smoke gx3 8x2 diag24,run1year,medium -smoke gx3 7x2 diag1,bigdiag,run1day,diagpt1 -decomp gx3 4x2x25x29x5 none -smoke gx3 4x2 diag1,run5day smoke_gx3_8x2_diag1_run5day -smoke gx3 4x1 diag1,run5day,thread smoke_gx3_8x2_diag1_run5day -smoke gx3 1x8 diag1,run5day,evp1d -restart gx1 40x4 droundrobin,medium -restart tx1 40x4 dsectrobin,medium -restart tx1 40x4 dsectrobin,medium,jra55do +decomp gx3 4x2x25x29x5 +smoke gx3 4x2 diag1,run5day smoke_gx3_8x2_diag1_run5day +smoke gx3 4x1 diag1,run5day,thread smoke_gx3_8x2_diag1_run5day +restart gx1 40x4 droundrobin,medium +restart tx1 40x4 dsectrobin,medium restart gx3 4x4 none -restart gx3 10x4 maskhalo +restart gx3 4x4 iobinary restart gx3 6x2 alt01 restart gx3 8x2 alt02 restart gx3 4x2 alt03 -restart gx3 12x2 alt03,maskhalo,droundrobin restart gx3 4x4 alt04 restart gx3 4x4 alt05 -restart gx3 8x2 alt06 -restart gx3 8x3 alt07 -restart gx3 8x3 saltflux -restart gx3 18x2 debug,maskhalo restart gx3 6x2 alt01,debug,short restart gx3 8x2 alt02,debug,short restart gx3 4x2 alt03,debug,short -smoke gx3 12x2 alt03,debug,short,maskhalo,droundrobin smoke gx3 4x4 alt04,debug,short smoke gx3 4x4 alt05,debug,short -smoke gx3 8x2 alt06,debug,short -smoke gx3 8x3 alt07,debug,short -smoke gx3 10x2 debug,diag1,run5day,gx3sep2 -smoke gx3 7x2x5x29x12 diag1,bigdiag,run1day,debug -restart gbox128 4x2 short -restart gbox128 4x2 boxnodyn,short -restart gbox128 4x2 boxnodyn,short,debug -restart gbox128 2x2 boxadv,short -smoke gbox128 2x2 boxadv,short,debug -restart gbox128 4x4 boxrestore,short -smoke gbox128 4x4 boxrestore,short,debug -restart gbox80 1x1 box2001 -smoke gbox80 1x1 boxslotcyl -smoke gbox12 1x1x12x12x1 boxchan,diag1,debug -restart gx3 8x2 modal +restart gbox128 4x2 short +restart gbox128 4x2 boxdyn,short +restart gbox128 4x2 boxdyn,short,debug +restart gbox128 2x2 boxadv,short +smoke gbox128 2x2 boxadv,short,debug +restart gbox128 4x4 boxrestore,short +smoke gbox128 4x4 boxrestore,short,debug +restart gbox80 1x1 box2001 +smoke gbox80 1x1 boxslotcyl smoke gx3 8x2 bgcz -smoke gx3 8x2 jra55do -smoke gx3 8x2 bgczm,debug +smoke gx3 8x2 bgcz,debug smoke gx3 8x1 bgcskl,debug -#smoke gx3 4x1 bgcz,thread smoke_gx3_8x2_bgcz +#smoke gx3 4x1 bgcz,thread smoke_gx3_8x2_bgcz restart gx1 4x2 bgcsklclim,medium restart gx1 8x1 bgczclim,medium -smoke gx1 24x1 medium,run90day,yi2008 -smoke gx1 24x1 medium,run90day,yi2008,jra55do -smoke gx3 8x1 medium,run90day,yi2008 -restart gx1 24x1 short -restart gx1 16x2 seabedLKD,gx1apr,short,debug -restart gx1 15x2 seabedprob -restart gx1 32x1 gx1prod +smoke gx1 24x1 jra55_gx1_2008,medium,run90day +smoke gx3 8x1 jra55_gx3_2008,medium,run90day +restart gx1 24x1 jra55_gx1,short +restart gx3 8x1 jra55_gx3,short smoke gx3 4x2 fsd1,diag24,run5day,debug -smoke gx3 8x2 fsd12,diag24,run5day +smoke gx3 8x2 fsd12,diag24,run5day,short restart gx3 4x2 fsd12,debug,short -smoke gx3 8x2 fsd12ww3,diag24,run1day +smoke gx3 8x2 fsd12ww3,diag24,run1day,medium smoke gx3 4x1 isotope,debug restart gx3 8x2 isotope -smoke gx3 4x1 snwitdrdg,snwgrain,icdefault,debug -smoke gx3 4x1 snw30percent,icdefault,debug -restart gx3 8x2 snwitdrdg,icdefault,snwgrain -restart gx3 4x4 gx3ncarbulk,iobinary -restart gx3 4x4 histall,precision8,cdf64 -smoke gx3 30x1 bgcz,histall -smoke gx3 14x2 fsd12,histall -smoke gx3 4x1 dynpicard -restart gx3 8x2 gx3ncarbulk,debug -restart gx3 4x4 gx3ncarbulk,diag1 -smoke gx3 4x1 calcdragio -restart gx3 4x2 atmbndyconstant -restart gx3 4x2 atmbndymixed + diff --git a/configuration/scripts/tests/nothread_suite.ts b/configuration/scripts/tests/nothread_suite.ts index a262ec135..49f834a98 100644 --- a/configuration/scripts/tests/nothread_suite.ts +++ b/configuration/scripts/tests/nothread_suite.ts @@ -1,7 +1,7 @@ # Test Grid PEs Sets BFB-compare restart gx3 8x1x25x29x2 dslenderX2 -smoke gx3 8x1x25x29x2 dslenderX2,diag1,reprosum +logbfb gx3 8x1x25x29x2 dslenderX2,diag1,reprosum smoke gx3 16x1 diag1,run5day smoke gx3 1x1 debug,diag1,run2day @@ -14,22 +14,18 @@ smoke gx3 16x1 diag24,run1year,medium #restart tx1 160x1 dsectrobin,medium restart gx3 16x1 none -restart gx3 16x1 gx3ncarbulk,iobinary +restart gx3 16x1 iobinary restart gx3 12x1 alt01 restart gx3 16x1 alt02 restart gx3 8x1 alt03 -restart gx3 16x1x5x29x6 alt04 +restart gx3 16x1 alt04 restart gx3 16x1 alt05 -restart gx3 20x1 alt06 -restart gx3 18x1 alt07 restart gx3 18x1 alt01,debug,short restart gx3 20x1 alt02,debug,short restart gx3 24x1 alt03,debug,short smoke gx3 24x1 alt04,debug,short smoke gx3 32x1 alt05,debug,short -smoke gx3 16x1 alt06,debug,short -smoke gx3 20x1 alt07,debug,short restart gx3 16x1 isotope smoke gx3 6x1 isotope,debug smoke gx3 8x1 fsd1,diag24,run5day,debug @@ -38,8 +34,8 @@ restart gx3 12x1 fsd12,debug,short smoke gx3 20x1 fsd12ww3,diag24,run1day,medium restart gbox128 8x1 short -restart gbox128 16x1 boxnodyn,short -restart gbox128 24x1 boxnodyn,short,debug +restart gbox128 16x1 boxdyn,short +restart gbox128 24x1 boxdyn,short,debug restart gbox128 12x1 boxadv,short smoke gbox128 20x1 boxadv,short,debug restart gbox128 32x1 boxrestore,short @@ -47,20 +43,20 @@ smoke gbox128 24x1 boxrestore,short,debug restart gbox80 1x1 box2001 smoke gbox80 1x1 boxslotcyl -smoke gx3 16x1 medium,run90day,yi2008 -restart gx3 12x1 short +smoke gx3 16x1 jra55_gx3_2008,medium,run90day +restart gx3 12x1 jra55_gx3,short #tcraig, hangs nodes intermittently on izumi -#smoke gx1 24x1 medium,run90day,yi2008 -#restart gx1 24x1 short +#smoke gx1 24x1 jra55_gx1_2008,medium,run90day +#restart gx1 24x1 jra55_gx1,short smoke gx3 16x1 bgcz -smoke gx3 16x1 bgczm,debug +smoke gx3 16x1 bgcz,debug smoke gx3 24x1 bgcskl,debug #tcraig, hangs nodes intermittently on izumi #restart gx1 128x1 bgcsklclim,medium #restart gx1 256x1 bgczclim,medium -decomp gx3 8x1x5x29x20 none +decomp gx3 8x1x5x29x20 restart gx3 1x1x50x58x4 droundrobin restart_gx3_8x1x25x29x2_dslenderX2 restart gx3 4x1x25x116x1 dslenderX1 restart_gx3_8x1x25x29x2_dslenderX2 restart gx3 12x1x4x29x9 dspacecurve restart_gx3_8x1x25x29x2_dslenderX2 @@ -68,13 +64,13 @@ restart gx3 16x1x8x10x10 droundrobin restart_gx3_8x1x25x29x2_ restart gx3 6x1x50x58x1 droundrobin restart_gx3_8x1x25x29x2_dslenderX2 restart gx3 8x1x19x19x5 droundrobin restart_gx3_8x1x25x29x2_dslenderX2 restart gx3 20x1x5x29x20 dsectrobin,short restart_gx3_8x1x25x29x2_dslenderX2 -restart gx3 32x1x5x10x12 drakeX2 restart_gx3_8x1x25x29x2_dslenderX2 +restart gx3 32x1x5x10x10 drakeX2 restart_gx3_8x1x25x29x2_dslenderX2 restart gx3 16x1x8x10x10 droundrobin,maskhalo restart_gx3_8x1x25x29x2_dslenderX2 restart gx3 4x1x25x29x4 droundrobin restart_gx3_8x1x25x29x2_dslenderX2 -smoke gx3 1x1x50x58x4 droundrobin,diag1,maskhalo,reprosum,cmplog smoke_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum -smoke gx3 4x1x25x116x1 dslenderX1,diag1,maskhalo,reprosum,cmplog smoke_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum -smoke gx3 20x1x5x29x20 dsectrobin,diag1,short,reprosum,cmplog smoke_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum -smoke gx3 16x1x8x10x10 droundrobin,diag1,reprosum,cmplog smoke_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum -smoke gx3 6x1x50x58x1 droundrobin,diag1,reprosum,cmplog smoke_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum -smoke gx3 12x1x4x29x9 dspacecurve,diag1,maskhalo,reprosum,cmplog smoke_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum +logbfb gx3 1x1x50x58x4 droundrobin,diag1,maskhalo,reprosum logbfb_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum +logbfb gx3 4x1x25x116x1 dslenderX1,diag1,maskhalo,reprosum logbfb_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum +logbfb gx3 20x1x5x29x20 dsectrobin,diag1,short,reprosum logbfb_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum +logbfb gx3 16x1x8x10x10 droundrobin,diag1,reprosum logbfb_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum +logbfb gx3 6x1x50x58x1 droundrobin,diag1,reprosum logbfb_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum +logbfb gx3 12x1x4x29x9 dspacecurve,diag1,maskhalo,reprosum logbfb_gx3_8x1x25x29x2_diag1_dslenderX2_reprosum diff --git a/configuration/scripts/tests/report_results.csh b/configuration/scripts/tests/report_results.csh index e1f3a7342..4a64deff8 100755 --- a/configuration/scripts/tests/report_results.csh +++ b/configuration/scripts/tests/report_results.csh @@ -25,7 +25,7 @@ set wikirepo = "https://github.com/CICE-Consortium/Test-Results.wiki.git" set wikiname = Test-Results.wiki rm -r -f ${wikiname} -git clone --depth=1 ${wikirepo} ${wikiname} +git clone ${wikirepo} ${wikiname} if ($status != 0) then echo " " echo "${0}: ERROR git clone failed" @@ -49,7 +49,7 @@ set totl = `grep "#totl = " results.log | cut -c 9-` set pass = `grep "#pass = " results.log | cut -c 9-` set fail = `grep "#fail = " results.log | cut -c 9-` set cases = `grep -v "#" results.log | grep ${mach}_ | cut -d " " -f 2 | sort -u` -set envnames = `grep -v "#" results.log | grep ${mach}_ | cut -d "_" -f 2 | sort -u` +set compilers = `grep -v "#" results.log | grep ${mach}_ | cut -d "_" -f 2 | sort -u` #echo "debug ${repo}" #echo "debug ${bran}" @@ -82,26 +82,23 @@ if ("${shrepo}" !~ "*cice-consortium*") then endif set noglob -set green = "\![#00C000](images/00C000.png)" -set red = "\![#F00000](images/F00000.png)" -set orange = "\![#FFA500](images/FFA500.png)" -set yellow = "\![#FFE600](images/FFE600.png)" -set gray = "\![#AAAAAA](images/AAAAAA.png)" +set green = "\![#00C000](https://placehold.it/15/00C000/000000?text=+)" +set red = "\![#F00000](https://placehold.it/15/F00000/000000?text=+)" +set orange = "\![#FFA500](https://placehold.it/15/FFA500/000000?text=+)" +set yellow = "\![#FFE600](https://placehold.it/15/FFE600/000000?text=+)" +set gray = "\![#AAAAAA](https://placehold.it/15/AAAAAA/000000?text=+)" unset noglob #============================================================== # Create results table #============================================================== -foreach envname ( ${envnames} ) - - set machinfo = `grep -m 1 "#machinfo = " results.log | cut -d = -f 2` - set envinfo = `grep -m 1 "#envinfo ${envname} = " results.log | cut -d = -f 2` +foreach compiler ( ${compilers} ) set cnt = 0 set found = 1 while ($found == 1) - set ofile = "${shhash}.${mach}.${envname}.${xcdat}.${xctim}.$cnt" + set ofile = "${shhash}.${mach}.${compiler}.${xcdat}.${xctim}.$cnt" set outfile = "${wikiname}/${tsubdir}/${ofile}.md" if (-e ${outfile}) then @ cnt = $cnt + 1 @@ -129,7 +126,7 @@ EOF @ rothr = 0 foreach case ( ${cases} ) -if ( ${case} =~ *_${envname}_* ) then +if ( ${case} =~ *_${compiler}_* ) then # check that case results are meaningful set fbuild = `grep " ${case} " results.log | grep " build" | cut -c 1-4` @@ -295,9 +292,7 @@ cat >! ${outfile} << EOF - hash = ${hash} - hash created by ${hashuser} ${hashdate} - vers = ${vers} -- tested by ${user}, ${cdat} ${ctim} UTC -- ${mach} : ${machinfo} -- ${envname} : ${envinfo} +- tested on ${mach}, ${compiler}, ${user}, ${cdat} ${ctim} UTC - ${ttotl} total tests: ${tpass} pass, ${tfail} fail - ${ttotl} total regressions: ${rpass} pass, ${rfail} fail, ${rothr} other EOF @@ -331,9 +326,9 @@ if ($chk == 0) then cat >! ${hashfile} << EOF #### ${hash} -| machine | envname | version | date | test fail | comp fail | total | +| machine | compiler | version | date | test fail | comp fail | total | | ------ | ------ | ------ | ------ | ------ | ------ | ------ | -| ${mach} | ${envname} | ${vers} | ${cdat} | ${tcolor} ${tfail}, ${tunkn} | ${rcolor} ${rfail}, ${rothr} | [${ttotl}](${ofile}) | +| ${mach} | ${compiler} | ${vers} | ${cdat} | ${tcolor} ${tfail}, ${tunkn} | ${rcolor} ${rfail}, ${rothr} | [${ttotl}](${ofile}) | EOF if (-e ${hashfile}.prev) cat ${hashfile}.prev >> ${hashfile} @@ -341,7 +336,7 @@ if (-e ${hashfile}.prev) cat ${hashfile}.prev >> ${hashfile} else set oline = `grep -n "#### ${hash}" ${hashfile} | head -1 | cut -d : -f 1` @ nline = ${oline} + 3 - sed -i "$nline a | ${mach} | ${envname} | ${vers} | ${cdat} | ${tcolor} ${tfail}, ${tunkn} | ${rcolor} ${rfail}, ${rothr} | [${ttotl}](${ofile}) | " ${hashfile} + sed -i "$nline a | ${mach} | ${compiler} | ${vers} | ${cdat} | ${tcolor} ${tfail}, ${tunkn} | ${rcolor} ${rfail}, ${rothr} | [${ttotl}](${ofile}) | " ${hashfile} endif #===================== @@ -355,9 +350,9 @@ if ($chk == 0) then cat >! ${machfile} << EOF #### ${mach} -| version | hash | envname | date | test fail | comp fail | total | +| version | hash | compiler | date | test fail | comp fail | total | | ------ | ------ | ------ | ------ | ------ | ------ | ------ | -| ${vers} | ${shhash} | ${envname} | ${cdat} | ${tcolor} ${tfail}, ${tunkn} | ${rcolor} ${rfail}, ${rothr} | [${ttotl}](${ofile}) | +| ${vers} | ${shhash} | ${compiler} | ${cdat} | ${tcolor} ${tfail}, ${tunkn} | ${rcolor} ${rfail}, ${rothr} | [${ttotl}](${ofile}) | EOF if (-e ${machfile}.prev) cat ${machfile}.prev >> ${machfile} @@ -365,10 +360,10 @@ if (-e ${machfile}.prev) cat ${machfile}.prev >> ${machfile} else set oline = `grep -n "#### ${mach}" ${machfile} | head -1 | cut -d : -f 1` @ nline = ${oline} + 3 - sed -i "$nline a | ${vers} | ${shhash} | ${envname} | ${cdat} | ${tcolor} ${tfail}, ${tunkn} | ${rcolor} ${rfail}, ${rothr} | [${ttotl}](${ofile}) | " ${machfile} + sed -i "$nline a | ${vers} | ${shhash} | ${compiler} | ${cdat} | ${tcolor} ${tfail}, ${tunkn} | ${rcolor} ${rfail}, ${rothr} | [${ttotl}](${ofile}) | " ${machfile} endif -#foreach envname +#foreach compiler end #===================== diff --git a/doc/source/science_guide/sg_tracers.rst b/doc/source/science_guide/sg_tracers.rst index 5935fe67e..bbd18eb1f 100644 --- a/doc/source/science_guide/sg_tracers.rst +++ b/doc/source/science_guide/sg_tracers.rst @@ -78,6 +78,8 @@ is not in use. "tr_FY", "1", "aice", "nt_FY", " " "tr_lvl", "2", "aice", "nt_alvl", " " " ", " ", "vice", "nt_vlvl", " " + "tr_pond_cesm", "2", "aice", "nt_apnd", " " + " ", " ", "apnd", "nt_vpnd", " " "tr_pond_lvl", "3", "aice", "nt_apnd", " " " ", " ", "apnd", "nt_vpnd", " " " ", " ", "apnd", "nt_ipnd", " " @@ -88,10 +90,7 @@ is not in use. "tr_iso", "n_iso", "vice, vsno", "nt_iso"," " "tr_brine", " ", "vice", "nt_fbri", " " "tr_fsd","nfsd","aice","nt_fsd"," " - "tr_snow","nslyr","vsno","nt_rsnw"," " - " ","nslyr","vsno","nt_rhos"," " - " ","nslyr","vsno","nt_smice"," " - " ","nslyr","vsno","nt_smliq"," " + "solve_zsal", "n_trzs", "fbri or (a,v)ice", "nt_bgc_S", " " "tr_bgc_N", "n_algae", "fbri or (a,v)ice", "nt_bgc_N", "nlt_bgc_N" "tr_bgc_Nit", " ", "fbri or (a,v)ice", "nt_bgc_Nit", "nlt_bgc_Nit" "tr_bgc_C", "n_doc", "fbri or (a,v)ice", "nt_bgc_DOC", "nlt_bgc_DOC" @@ -110,13 +109,10 @@ is not in use. "tr_zaero", "n_zaero", "fbri or (a,v)ice", "nt_zaero", "nlt_zaero" " ", "1", "fbri", "nt_zbgc_frac", " " -.. - "solve_zsal", "n_trzs", "fbri or (a,v)ice", "nt_bgc_S", " " - "tr_pond_cesm", "2", "aice", "nt_apnd", " " - " ", " ", "apnd", "nt_vpnd", " " + Users may add any number of additional tracers that are transported conservatively, provided that the dependency ``trcr_depend`` is defined appropriately. See Section :ref:`addtrcr` for guidance on adding tracers. -Please see the `Icepack documentation `_ for additional information about tracers that depend on other tracers, the floe size distribution, advanced snow physics, age of the ice, aerosols, water isotopes, brine height, and the sea ice ecosystem. +Please see the `Icepack documentation `_ for additional information about tracers that depend on other tracers, the floe size distribution, age of the ice, aerosols, water isotopes, brine height, and the sea ice ecosystem. diff --git a/doc/source/user_guide/ug_case_settings.rst b/doc/source/user_guide/ug_case_settings.rst old mode 100644 new mode 100755 index ba596863c..b3088963d --- a/doc/source/user_guide/ug_case_settings.rst +++ b/doc/source/user_guide/ug_case_settings.rst @@ -8,67 +8,25 @@ Case Settings There are two important files that define the case, **cice.settings** and **ice_in**. **cice.settings** is a list of env variables that define many values used to setup, build and run the case. **ice_in** is the input namelist file -for CICE. Variables in both files are described below. In addition, the first -table lists available preprocessor macros to activate or deactivate various -features when compiling. - -.. _tabcpps: - -Table of C Preprocessor (CPP) Macros ---------------------------------------------------- - -The CICE model supports a number of C Preprocessor (CPP) Macros. These -can be turned on during compilation to activate different pieces of source -code. The main purpose is to introduce build-time code modifications to -include or exclude certain libraries or Fortran language features. More information -can be found in :ref:`cicecpps`. The following CPPs are available. - -.. csv-table:: **CPP Macros** - :header: "CPP name", "description" - :widths: 15, 60 - - "","" - "**General Macros**", "" - "CESM1_PIO", "Provide backwards compatible support for PIO interfaces/version released with CESM1 in about 2010" - "ESMF_INTERFACE", "Turns on ESMF support in a subset of driver code. Also USE_ESMF_LIB and USE_ESMF_METADATA" - "FORTRANUNDERSCORE", "Used in ice_shr_reprosum86.c to support Fortran-C interfaces. This should generally be turned on at all times. There are other CPPs (FORTRANDOUBULEUNDERSCORE, FORTRANCAPS, etc) in ice_shr_reprosum.c that are generally not used in CICE but could be useful if problems arise in the Fortran-C interfaces" - "GPTL", "Turns on GPTL initialization if needed for PIO" - "NO_F2003", "Turns off some Fortran 2003 features" - "NO_I8", "Converts integer*8 to integer*4. This could have adverse affects for certain algorithms including the ddpdd implementation associated with the ``bfbflag``" - "NO_R16", "Converts real*16 to real*8. This could have adverse affects for certain algorithms including the lsum16 implementation associated with the ``bfbflag``" - "USE_NETCDF", "Turns on netcdf code. This is normally on and is needed for released configurations. An older value, ncdf, is still supported" - "","" - "**Application Macros**", "" - "CESMCOUPLED", "Turns on code changes for the CESM coupled application " - "CICE_IN_NEMO", "Turns on code changes for coupling in the NEMO ocean model" - "CICE_DMI", "Turns on code changes for the DMI coupled model application" - "ICE_DA", "Turns on code changes in the hadgem driver" - "RASM_MODS", "Turns on code changes for the RASM coupled application" - "","" - "**Library Macros**", "" - "_OPENMP", "Automatically defined when compiling with OpenMP " - "_OPENACC", "Automatically defined when compiling with OpenACC " - +for CICE. Variables in both files are described below. .. _tabsettings: Table of CICE Settings -------------------------- -The **cice.settings** file contains a number of environment variables that define -configuration, file system, run, and build settings. Several variables are set -by the **cice.setup** script. This file is created on a case by case basis and -can be modified as needed. +The **cice.settings** file is reasonably well self documented. Several of +the variables defined in the file are not used in CICE. They exist +to support the CICE model. - -.. csv-table:: **CICE settings** - :header: "variable", "options/format", "description", "default value" +.. csv-table:: *CICE settings* + :header: "variable", "options/format", "description", "recommended value" :widths: 15, 15, 25, 20 "ICE_CASENAME", "string", "case name", "set by cice.setup" "ICE_SANDBOX", "string", "sandbox directory", "set by cice.setup" "ICE_MACHINE", "string", "machine name", "set by cice.setup" - "ICE_ENVNAME", "string", "environment name", "set by cice.setup" + "ICE_COMPILER", "string", "environment name", "set by cice.setup" "ICE_MACHCOMP", "string", "machine_environment name", "set by cice.setup" "ICE_SCRIPTS", "string", "scripts directory", "set by cice.setup" "ICE_CASEDIR", "string", "case directory", "set by cice.setup" @@ -77,38 +35,27 @@ can be modified as needed. "ICE_RSTDIR", "string", "unused", "${ICE_RUNDIR}/restart" "ICE_HSTDIR", "string", "unused", "${ICE_RUNDIR}/history" "ICE_LOGDIR", "string", "log directory", "${ICE_CASEDIR}/logs" - "ICE_DRVOPT", "string", "unused", "standalone/cice" - "ICE_TARGET", "string", "build target", "set by cice.setup" + "ICE_DRVOPT", "string", "unused", "cice" "ICE_IOTYPE", "string", "I/O format", "set by cice.setup" " ", "netcdf", "serial netCDF" - " ", "none", "netCDF library is not available" " ", "pio", "parallel netCDF" + " ", "none", "netCDF library is not available" "ICE_CLEANBUILD", "true, false", "automatically clean before building", "true" - "ICE_CPPDEFS", "user defined preprocessor macros for build", "null" "ICE_QUIETMODE", "true, false", "reduce build output to the screen", "false" "ICE_GRID", "string (see below)", "grid", "set by cice.setup" - " ", "gbox80", "80x80 box", " " - " ", "gbox128", "128x128 box", " " - " ", "gbox180", "180x180 box", " " - " ", "gx1", "1-deg displace-pole (Greenland) global grid", " " " ", "gx3", "3-deg displace-pole (Greenland) global grid", " " + " ", "gx1", "1-deg displace-pole (Greenland) global grid", " " " ", "tx1", "1-deg tripole global grid", " " - "ICE_NTASKS", "integer", "number of MPI tasks", "set by cice.setup" - "ICE_NTHRDS", "integer", "number of threads per task", "set by cice.setup" - "ICE_OMPSCHED", "string", "OpenMP SCHEDULE env setting", "static,1" + " ", "gbox80", "80x80 box", " " + " ", "gbox128", "128x128 box", " " + "ICE_NTASKS", "integer", "number of tasks, must be set to 1", "set by cice.setup" + "ICE_NTHRDS", "integer", "number of threads per task, must be set to 1", "set by cice.setup" "ICE_TEST", "string", "test setting if using a test", "set by cice.setup" "ICE_TESTNAME", "string", "test name if using a test", "set by cice.setup" - "ICE_TESTID", "string", "test name testid", "set by cice.setup" - "ICE_BASELINE", "string", "baseline directory name, associated with cice.setup --bdir ", "set by cice.setup" + "ICE_BASELINE", "string", "baseline directory name, associated with cice.setup -bdir ", "set by cice.setup" "ICE_BASEGEN", "string", "baseline directory name for regression generation, associated with cice.setup -bgen ", "set by cice.setup" "ICE_BASECOM", "string", "baseline directory name for regression comparison, associated with cice.setup -bcmp ", "set by cice.setup" - "ICE_BFBCOMP", "string", "location of case for comparison, associated with cice.setup --bcmp", "set by cice.setup" - "ICE_BFBTYPE", "string", "type and files used in BFBCOMP", "restart" - " ", "log", "log file comparison for bit for bit", " " - " ", "logrest", "log and restart files for bit for bit", " " - " ", "qcchk", "QC test for same climate", " " - " ", "qcchkf", "QC test for different climate", " " - " ", "restart", "restart files for bit for bit", " " + "ICE_BFBCOMP", "string", "location of case for comparison, associated with cice.setup -td", "set by cice.setup" "ICE_SPVAL", "string", "special value for cice.settings strings", "set by cice.setup" "ICE_RUNLENGTH", "integer (see below)", "batch run length default", "set by cice.setup" " ", "-1", "15 minutes (default)", " " @@ -120,9 +67,8 @@ can be modified as needed. "ICE_ACCOUNT", "string", "batch account number", "set by cice.setup, .cice_proj or by default" "ICE_QUEUE", "string", "batch queue name", "set by cice.setup or by default" "ICE_THREADED", "true, false", "force threading in compile, will always compile threaded if ICE_NTHRDS :math:`> 1`", "false" - "ICE_COMMDIR", "mpi, serial", "specify infrastructure comm version", "set by ICE_NTASKS" "ICE_BLDDEBUG", "true, false", "turn on compile debug flags", "false" - "ICE_COVERAGE", "true, false", "turn on code coverage flags", "false" + .. _tabnamelist: @@ -131,757 +77,345 @@ can be modified as needed. Table of namelist options ------------------------------- -CICE reads a namelist input file, **ice_in**, consisting of several namelist groups. The tables below -summarize the different groups and the variables in each group. The variables are organized alphabetically -and the default values listed are the values defined in the source code. Those values will be -used unless overridden by the CICE namelist file, **ice_in**. The source code default values as listed -in the table are not necessarily the recommended production values. - -setup_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. csv-table:: **setup_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``bfbflag``", "``off``", "local reduction then global scalar sum", "``off``" - "", "``lsum4``", "local reduction with real*4 then global scalar sum", "" - "", "``lsum8``", "local reduction with real*8 then global scalar sum", "" - "", "``lsum16``", "local reduction with real*16 then global scalar sum", "" - "", "``ddpdd``", "parallel double double algorithm", "" - "", "``reprosum``", "fixed point double integer sum", "" - "``conserv_check``", "logical", "check conservation", "``.false.``" - "``cpl_bgc``", "logical", "couple bgc thru driver", "``.false.``" - "``days_per_year``", "integer", "number of days in a model year", "365" - "``day_init``", "integer", "the initial day of the month if not using restart", "1" - "``debug_forcing``", "logical", "write extra forcing diagnostics", "``.false.``" - "``debug_model``", "logical", "write extended model point diagnostics", "``.false.``" - "``debug_model_i``", "integer", "local i index of debug_model point", "-1" - "``debug_model_iblk``", "integer", "iblk value for debug_model point", "-1" - "``debug_model_j``", "integer", "local j index of debug_model point", "-1" - "``debug_model_task``", "integer", "mpi task value for debug_model point", "-1" - "``debug_model_step``", "logical", "initial timestep to write ``debug_model`` output", "0" - "``diagfreq``", "integer", "frequency of diagnostic output in timesteps", "24" - "``diag_type``", "``stdout``", "write diagnostic output to stdout", "``stdout``" - "", "``file``", "write diagnostic output to file", "" - "``diag_file``", "string", "diagnostic output file", "'ice_diag.d'" - "``dt``", "real", "thermodynamics time step length in seconds", "3600." - "``dumpfreq``", "``d``", "write restart every ``dumpfreq_n`` days", "'y','x','x','x','x'" - "", "``d1``", "write restart once after ``dumpfreq_n`` days", "" - "", "``h``", "write restart every ``dumpfreq_n`` hours", "" - "", "``h1``", "write restart once after ``dumpfreq_n`` hours", "" - "", "``m``", "write restart every ``dumpfreq_n`` months", "" - "", "``m1``", "write restart once after ``dumpfreq_n`` months", "" - "", "``y``", "write restart every ``dumpfreq_n`` years", "" - "", "``y1``", "write restart once after ``dumpfreq_n`` years", "" - "", "``1``", "write restart every ``dumpfreq_n`` time steps", "" - "", "``11``", "write restart once after ``dumpfreq_n`` time steps", "" - "``dumpfreq_base``", "init", "restart output frequency relative to year_init, month_init, day_init", "'init','init','init','init','init'" - "", "zero", "restart output frequency relative to year-month-day of 0000-01-01", "" - "``dumpfreq_n``", "integer array", "write restart frequency with ``dumpfreq``", "1,1,1,1,1" - "``dump_last``", "logical", "write restart on last time step of simulation", "``.false.``" - "``hist_avg``", "logical", "write time-averaged data", "``.true.,.true.,.true.,.true.,.true.``" - "``histfreq``", "``d``", "write history every ``histfreq_n`` days", "'1','h','d','m','y'" - "", "``h``", "write history every ``histfreq_n`` hours", "" - "", "``m``", "write history every ``histfreq_n`` months", "" - "", "``x``", "unused frequency stream (not written)", "" - "", "``y``", "write history every ``histfreq_n`` years", "" - "", "``1``", "write history every ``histfreq_n`` time step", "" - "``histfreq_base``", "init", "history output frequency relative to year_init, month_init, day_init", "'zero','zero','zero','zero','zero'" - "", "zero", "history output frequency relative to year-month-day of 0000-01-01", "" - "``histfreq_n``", "integer array", "frequency history output is written with ``histfreq``", "1,1,1,1,1" - "``history_dir``", "string", "path to history output directory", "'./'" - "``history_file``", "string", "output file for history", "'iceh'" - "``history_format``", "``default``", "read/write history files in default format", "``default``" - "", "``pio_pnetcdf``", "read/write restart files with pnetcdf in pio", "" - "``history_precision``", "integer", "history file precision: 4 or 8 byte", "4" - "``hist_time_axis``","character","history file time axis interval location: begin, middle, end","end" - "``ice_ic``", "``default``", "equal to internal", "``default``" - "", "``internal``", "initial conditions set based on ice\_data\_type,conc,dist inputs", "" - "", "``none``", "no ice", "" - "", "'path/file'", "restart file name", "" - "``incond_dir``", "string", "path to initial condition directory", "'./'" - "``incond_file``", "string", "output file prefix for initial condition", "‘iceh_ic’" - "``istep0``", "integer", "initial time step number", "0" - "``latpnt``", "real", "latitude of (2) diagnostic points", "90.0,-65.0" - "``lcdf64``", "logical", "use 64-bit netcdf format", "``.false.``" - "``lonpnt``", "real", "longitude of (2) diagnostic points", "0.0,-45.0" - "``memory_stats``", "logical", "turns on memory use diagnostics", "``.false.``" - "``month_init``", "integer", "the initial month if not using restart", "1" - "``ndtd``", "integer", "number of dynamics/advection/ridging/steps per thermo timestep", "1" - "``npt``", "integer", "total number of npt_units to run the model", "99999" - "``npt_unit``", "``d``", "run ``npt`` days", "1" - "", "``h``", "run ``npt`` hours", "" - "", "``m``", "run ``npt`` months", "" - "", "``s``", "run ``npt`` seconds", "" - "", "``y``", "run ``npt`` years", "" - "", "``1``", "run ``npt`` timesteps", "" - "``numin``", "integer", "minimum internal IO unit number", "11" - "``numax``", "integer", "maximum internal IO unit number", "99" - "``pointer_file``", "string", "restart pointer filename", "'ice.restart_file'" - "``print_global``", "logical", "print global sums diagnostic data", "``.true.``" - "``print_points``", "logical", "print diagnostic data for two grid points", "``.false.``" - "``restart``", "logical", "exists but deprecated, now set internally based on other inputs", "" - "``restart_dir``", "string", "path to restart directory", "'./'" - "``restart_ext``", "logical", "read/write halo cells in restart files", "``.false.``" - "``restart_file``", "string", "output file prefix for restart dump", "'iced'" - "``restart_format``", "``default``", "read/write restart file with default format", "``default``" - "", "``pio_pnetcdf``", "read/write restart files with pnetcdf in pio", "" - "``runid``", "string", "label for run (currently CESM only)", "'unknown'" - "``runtype``", "``continue``", "restart using ``pointer_file``", "``initial``" - "", "``initial``", "start from ``ice_ic``", "" - "``sec_init``", "integer", "the initial second if not using restart", "0" - "``timer_stats``", "logical", "controls extra timer output", "``.false.``" - "``use_leap_years``", "logical", "include leap days", "``.false.``" - "``use_restart_time``", "logical", "set initial date using restart file on initial runtype only", "``.false.``" - "``version_name``", "string", "model version", "'unknown_version_name'" - "``write_ic``", "logical", "write initial condition", "``.false.``" - "``year_init``", "integer", "the initial year if not using restart", "0" - "", "", "", "" - -grid_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. csv-table:: **grid_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``bathymetry_file``", "string", "name of bathymetry file to be read", "'unknown_bathymetry_file'" - "``bathymetry_format``", "``default``", "NetCDF depth field", "'default'" - "", "``pop``", "pop thickness file in cm in ascii format", "" - "``close_boundaries``", "logical", "force two gridcell wide land mask on boundaries for rectangular grids", "``.false.``" - "``dxrect``", "real", "x-direction grid spacing for rectangular grid in cm", "0.0" - "``dxscale``", "real", "user defined rectgrid x-grid scale factor", "1.0" - "``dyrect``", "real", "y-direction grid spacing for rectangular grid in cm", "0.0" - "``dyscale``", "real", "user defined rectgrid y-grid scale factor", "1.0" - "``gridcpl_file``", "string", "input file for coupling grid info", "'unknown_gridcpl_file'" - "``grid_atm``", "``A``", "atm forcing/coupling grid, all fields on T grid", "``A``" - "", "``B``", "atm forcing/coupling grid, thermo fields on T grid, dyn fields on U grid", "" - "", "``C``", "atm forcing/coupling grid, thermo fields on T grid, dynu fields on E grid, dynv fields on N grid", "" - "", "``CD``", "atm forcing/coupling grid, thermo fields on T grid, dyn fields on N and E grid", "" - "``grid_file``", "string", "name of grid file to be read", "'unknown_grid_file'" - "``grid_format``", "``bin``", "read direct access grid and kmt files", "``bin``" - "", "``nc``", "read grid and kmt files", "" - "``grid_ice``", "``B``", "use B grid structure with T at center and U at NE corner", "``B``" - "", "``C``", "use C grid structure with T at center, U at E edge, V at N edge", "" - "``grid_ocn``", "``A``", "ocn forcing/coupling grid, all fields on T grid", "``A``" - "", "``B``", "ocn forcing/coupling grid, thermo fields on T grid, dyn fields on U grid", "" - "", "``C``", "ocn forcing/coupling grid, thermo fields on T grid, dynu fields on E grid, dynv fields on N grid", "" - "", "``CD``", "ocn forcing/coupling grid, thermo fields on T grid, dyn fields on N and E grid", "" - "``grid_type``", "``displaced_pole``", "read from file in *popgrid*", "``rectangular``" - "", "``rectangular``", "defined in *rectgrid*", "" - "", "``regional``", "read from file in *popgrid*", "" - "", "``tripole``", "read from file in *popgrid*", "" - "``kcatbound``", "``-1``", "single category formulation", "1" - "", "``0``", "old formulation", "" - "", "``1``", "new formulation with round numbers", "" - "", "``2``", "WMO standard categories", "" - "", "``3``", "asymptotic scheme", "" - "``kmt_file``", "string", "name of land mask file to be read", "``unknown_kmt_file``" - "``kmt_type``", "boxislands", "ocean/land mask set internally, complex test geometory", "file" - "", "channel", "ocean/land mask set internally as zonal channel", "" - "", "default", "ocean/land mask set internally, land in upper left and lower right of domain, ", "" - "", "file", "ocean/land mask setup read from file, see kmt_file", "" - "", "wall", "ocean/land mask set at right edge of domain", "" - "``latrefrect``","real","lower left corner lat for rectgrid in deg", "71.35" - "``lonrefrect``","real","lower left corner lon for rectgrid in deg", "-156.5" - "``nblyr``", "integer", "number of zbgc layers", "0" - "``ncat``", "integer", "number of ice thickness categories", "0" - "``nfsd``", "integer", "number of floe size categories", "1" - "``nilyr``", "integer", "number of vertical layers in ice", "0" - "``nslyr``", "integer", "number of vertical layers in snow", "0" - "``orca_halogrid``", "logical", "use orca haloed grid for data/grid read", "``.false.``" - "``scale_dxdy``", "logical", "apply dxscale, dyscale to rectgrid", "``false``" - "``use_bathymetry``", "logical", "use read in bathymetry file for seabedstress option", "``.false.``" - "", "", "", "" - -domain_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. csv-table:: **domain_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``add_mpi_barriers``", "logical", "throttle communication", "``.false.``" - "``block_size_x``", "integer", "block size in x direction", "-1" - "``block_size_y``", "integer", "block size in y direction", "-1" - "``debug_blocks``", "logical", "add additional print statements to debug the block decomposition", "``.false.``" - "``distribution_type``", "``cartesian``", "2D cartesian block distribution method", "``cartesian``" - "", "``rake``", "redistribute blocks among neighbors", "" - "", "``roundrobin``", "1 block per proc until blocks are used", "" - "", "``sectcart``", "blocks distributed to domain quadrants", "" - "", "``sectrobin``", "several blocks per proc until used", "" - "", "``spacecurve``", "distribute blocks via space-filling curves", "" - "", "``spiralcenter``", "distribute blocks via roundrobin from center of grid outward in a spiral", "" - "", "``wghtfile``", "distribute blocks based on weights specified in ``distribution_wght_file``", "" - "``distribution_wght``", "``block``", "full block weight method with land block elimination", "``latitude``" - "", "``blockall``", "full block weight method without land block elimination", "" - "", "``latitude``", "latitude/ocean sets ``work_per_block``", "" - "``distribution_wght_file``", "string", "distribution weight file when distribution_type is ``wghtfile``", "'unknown'" - "``ew_boundary_type``", "``cyclic``", "periodic boundary conditions in x-direction", "``cyclic``" - "", "``open``", "Dirichlet boundary conditions in x", "" - "``maskhalo_dyn``", "logical", "mask unused halo cells for dynamics", "``.false.``" - "``maskhalo_remap``", "logical", "mask unused halo cells for transport", "``.false.``" - "``maskhalo_bound``", "logical", "mask unused halo cells for boundary updates", "``.false.``" - "``max_blocks``", "integer", "maximum number of blocks per MPI task for memory allocation", "-1" - "``nprocs``", "integer", "number of processors to use", "-1" - "``ns_boundary_type``", "``cyclic``", "periodic boundary conditions in y-direction", "``open``" - "", "``open``", "Dirichlet boundary conditions in y", "" - "", "``tripole``", "U-fold tripole boundary conditions in y", "" - "", "``tripoleT``", "T-fold tripole boundary conditions in y", "" - "``nx_global``", "integer", "global grid size in x direction", "-1" - "``ny_global``", "integer", "global grid size in y direction", "-1" - "``processor_shape``", "``slenderX1``", "1 processor in the y direction used with ``distribution_type=cartesian``", "``slenderX2``" - "", "``slenderX1``", "1 processor in the y direction (tall, thin)", "" - "", "``slenderX2``", "2 processors in the y direction (thin)", "" - "", "``square-ice``", "more processors in x than y, :math:`\sim` square", "" - "", "``square-pop``", "more processors in y than x, :math:`\sim` square", "" - "", "", "", "" - -tracer_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. csv-table:: **tracer_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``n_aero``", "integer", "number of aerosol tracers", "0" - "``n_algae``", "0,1,2,3", "number of algal tracers", "0" - "``n_dic``", "0,1", "number of dissolved inorganic carbon", "0" - "``n_doc``", "0,1,2,3", "number of dissolved organic carbon", "0" - "``n_don``", "0,1", "number of dissolved organize nitrogen", "0" - "``n_fed``", "0,1,2", "number of dissolved iron tracers", "0" - "``n_fep``", "0,1,2", "number of particulate iron tracers", "0" - "``n_iso``", "integer", "number of isotope tracers", "0" - "``n_zaero``", "0,1,2,3,4,5,6", "number of z aerosol tracers in use", "0" - "``tr_aero``", "logical", "aerosols", "``.false.``" - "``tr_fsd``", "logical", "floe size distribution", "``.false.``" - "``tr_FY``", "logical", "first-year ice area", "``.false.``" - "``tr_iage``", "logical", "ice age", "``.false.``" - "``tr_iso``", "logical", "isotopes", "``.false.``" - "``tr_lvl``", "logical", "level ice area and volume", "``.false.``" - "``tr_pond_lvl``", "logical", "level-ice melt ponds", "``.false.``" - "``tr_pond_cesm``", " ", "DEPRECATED", " " - "``tr_pond_topo``", "logical", "topo melt ponds", "``.false.``" - "``tr_snow``", "logical", "advanced snow physics", "``.false.``" - "``restart_aero``", "logical", "restart tracer values from file", "``.false.``" - "``restart_age``", "logical", "restart tracer values from file", "``.false.``" - "``restart_fsd``", "logical", "restart floe size distribution values from file", "``.false.``" - "``restart_FY``", "logical", "restart tracer values from file", "``.false.``" - "``restart_iso``", "logical", "restart tracer values from file", "``.false.``" - "``restart_lvl``", "logical", "restart tracer values from file", "``.false.``" - "``restart_pond_lvl``", "logical", "restart tracer values from file", "``.false.``" - "``restart_pond_topo``", "logical", "restart tracer values from file", "``.false.``" - "``restart_snow``", "logical", "restart snow tracer values from file", "``.false.``" - "", "", "", "" - -.. - "``tr_pond_cesm``", "logical", "CESM melt ponds", "``.false.``" - "``restart_pond_cesm``", "logical", "restart tracer values from file", "``.false.``" - -thermo_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. csv-table:: **thermo_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``a_rapid_mode``", "real", "brine channel diameter in m", "0.5e-3" - "``aspect_rapid_mode``", "real", "brine convection aspect ratio", "1.0" - "``conduct``", "``bubbly``", "conductivity scheme :cite:`Pringle07`", "``bubbly``" - "", "``MU71``", "conductivity :cite:`Maykut71`", "" - "``dSdt_slow_mode``", "real", "slow drainage strength parameter m/s/K", "-1.5e-7" - "``floediam``", "real", "effective floe diameter for lateral melt in m", "300.0" - "``hfrazilmin``", "real", "min thickness of new frazil ice in m", "0.05" - "``kitd``", "``0``", "delta function ITD approximation", "1" - "", "``1``", "linear remapping ITD approximation", "" - "``ksno``", "real", "snow thermal conductivity", "0.3" - "``ktherm``", "``-1``", "thermodynamic model disabled", "1" - "", "``1``", "Bitz and Lipscomb thermodynamic model", "" - "", "``2``", "mushy-layer thermodynamic model", "" - "``phi_c_slow_mode``", ":math:`0<\phi_c < 1`", "critical liquid fraction", "0.05" - "``phi_i_mushy``", ":math:`0<\phi_i < 1`", "solid fraction at lower boundary", "0.85" - "``Rac_rapid_mode``", "real", "critical Rayleigh number", "10.0" - "", "", "", "" - - -.. _dynamics_nml: - -dynamics_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. - commented out - "``damping_andacc``", "integer", "damping factor for Anderson acceleration", "0" - "``dim_andacc``", "integer", "size of Anderson minimization matrix", "5" - "``fpfunc_andacc``", "``1``", "fix point function for Anderson acceleration, FMGRES(A(x),b(x))", "1" - "", "``2``", "fix point function for Anderson acceleration, x-A(x)x+b(x)", "" - "``reltol_andacc``", "real", "relative tolerance for Anderson acceleration", "1e-6" - "``start_andacc``", "integer", "acceleration delay factor for Anderson acceleration", "0" - commented out - -.. csv-table:: **dynamics_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``advection``", "``remap``", "linear remapping advection scheme", "``remap``" - "", "``upwind``", "donor cell advection", "" - "``algo_nonlin``", "``anderson``", "use nonlinear anderson algorithm for implicit solver", "picard" - "", "``picard``", "use picard algorithm", "" - "``alphab``", "real", ":math:`\alpha_{b}` factor in :cite:`Lemieux16`", "20.0" - "``arlx``", "real", "revised_evp value", "300.0" - "``brlx``", "real", "revised_evp value", "300.0" - "``capping_method``", "``max``", "max capping in :cite:`Hibler79`", "max" - "", "``sum``", "sum capping in :cite:`Kreyscher00`", "" - "``Cf``", "real", "ratio of ridging work to PE change in ridging", "17.0" - "``coriolis``", "``constant``", "constant coriolis value = 1.46e-4 s\ :math:`^{-1}`", "``latitude``" - "", "``latitude``", "coriolis variable by latitude", "" - "", "``zero``", "zero coriolis", "" - "``Cstar``", "real", "constant in Hibler strength formula", "20" - "``deltaminEVP``", "real", "minimum delta for viscosities", "1e-11" - "``deltaminVP``", "real", "minimum delta for viscosities", "2e-9" - "``dim_fgmres``", "integer", "maximum number of Arnoldi iterations for FGMRES solver", "50" - "``dim_pgmres``", "integer", "maximum number of Arnoldi iterations for PGMRES preconditioner", "5" - "``e_plasticpot``", "real", "aspect ratio of elliptical plastic potential", "2.0" - "``e_yieldcurve``", "real", "aspect ratio of elliptical yield curve", "2.0" - "``elasticDamp``", "real", "elastic damping parameter", "0.36" - "``evp_algorithm``", "``standard_2d``", "standard 2d EVP memory parallel solver", "standard_2d" - "", "``shared_mem_1d``", "1d shared memory solver", "" - "``kdyn``", "``-1``", "dynamics algorithm OFF", "1" - "", "``0``", "dynamics OFF", "" - "", "``1``", "EVP dynamics", "" - "", "``2``", "EAP dynamics", "" - "", "``3``", "VP dynamics", "" - "``kstrength``", "``0``", "ice strength formulation :cite:`Hibler79`", "1" - "", "``1``", "ice strength formulation :cite:`Rothrock75`", "" - "``krdg_partic``", "``0``", "old ridging participation function", "1" - "", "``1``", "new ridging participation function", "" - "``krdg_redist``", "``0``", "old ridging redistribution function", "1" - "", "``1``", "new ridging redistribution function", "" - "``kridge``", "``-1``", "ridging disabled", "1" - "", "``1``", "ridging enabled", "" - "``ktransport``", "``-1``", "transport disabled", "1" - "", "``1``", "transport enabled", "" - "``Ktens``", "real", "Tensile strength factor (see :cite:`Konig10`)", "0.0" - "``k1``", "real", "1st free parameter for landfast parameterization", "7.5" - "``k2``", "real", "2nd free parameter (N/m\ :math:`^3`) for landfast parameterization", "15.0" - "``maxits_fgmres``", "integer", "maximum number of restarts for FGMRES solver", "1" - "``maxits_nonlin``", "integer", "maximum number of nonlinear iterations for VP solver", "10" - "``maxits_pgmres``", "integer", "maximum number of restarts for PGMRES preconditioner", "1" - "``monitor_fgmres``", "logical", "write velocity norm at each FGMRES iteration", "``.false.``" - "``monitor_nonlin``", "logical", "write velocity norm at each nonlinear iteration", "``.false.``" - "``monitor_pgmres``", "logical", "write velocity norm at each PGMRES iteration", "``.false.``" - "``mu_rdg``", "real", "e-folding scale of ridged ice for ``krdg_partic`` = 1 in m^0.5", "3.0" - "``ndte``", "integer", "number of EVP subcycles", "120" - "``ortho_type``", "``cgs``", "Use classical Gram-Shchmidt in FGMRES solver", "``mgs``" - "", "``mgs``", "Use modified Gram-Shchmidt in FGMRES solver", "" - "``precond``", "``diag``", "Use Jacobi preconditioner for the FGMRES solver", "``pgmres``" - "", "``ident``", "Don't use a preconditioner for the FGMRES solver", "" - "", "``pgmres``", "Use GMRES as preconditioner for FGMRES solver", "" - "``Pstar``", "real", "constant in Hibler strength formula (N/m\ :math:`^2`)", "2.75e4" - "``reltol_fgmres``", "real", "relative tolerance for FGMRES solver", "1e-1" - "``reltol_nonlin``", "real", "relative tolerance for nonlinear solver", "1e-8" - "``reltol_pgmres``", "real", "relative tolerance for PGMRES preconditioner", "1e-6" - "``revised_evp``", "logical", "use revised EVP formulation", "``.false.``" - "``seabed_stress``", "logical", "use seabed stress parameterization for landfast ice", "``.false.``" - "``seabed_stress_method``", "``LKD``", "linear keel draft method :cite:`Lemieux16`", "``LKD``" - "", "``probabilistic``", "probability of contact method :cite:`Dupont22`", "" - "``ssh_stress``", "``coupled``", "computed from coupled sea surface height gradient", "``geostrophic``" - "", "``geostropic``", "computed from ocean velocity", "" - "``threshold_hw``", "real", "Max water depth for grounding (see :cite:`Amundrud04`)", "30." - "``use_mean_vrel``", "logical", "Use mean of two previous iterations for vrel in VP", "``.true.``" - "``visc_method``", "``avg_strength``", "average strength for viscosities on U grid", "``avg_zeta``" - "", "``avg_zeta``", "average zeta for viscosities on U grid", "" - "``yield_curve``", "``ellipse``", "elliptical yield curve", "``ellipse``" - "", "", "", "" - -shortwave_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. csv-table:: **shortwave_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``ahmax``", "real", "albedo is constant above this thickness in meters", "0.3" - "``albedo_type``", "`ccsm3``", "NCAR CCSM3 albedo implementation", "``ccsm3``" - "", "``constant``", "four constant albedos", "" - "``albicei``", ":math:`0<\alpha <1`", "near infrared ice albedo for thicker ice", "0.36" - "``albicev``", ":math:`0<\alpha <1`", "visible ice albedo for thicker ice", "0.78" - "``albsnowi``", ":math:`0<\alpha <1`", "near infrared, cold snow albedo", "0.70" - "``albsnowv``", ":math:`0<\alpha <1`", "visible, cold snow albedo", "0.98" - "``dT_mlt``", "real", ":math:`\Delta` temperature per :math:`\Delta` snow grain radius", "1.5" - "``kalg``", "real", "absorption coefficient for algae", "0.6" - "``rsnw_mlt``", "real", "maximum melting snow grain radius", "1500." - "``R_ice``", "real", "tuning parameter for sea ice albedo from Delta-Eddington shortwave", "0.0" - "``R_pnd``", "real", "tuning parameter for ponded sea ice albedo from Delta-Eddington shortwave", "0.0" - "``R_snw``", "real", "tuning parameter for snow (broadband albedo) from Delta-Eddington shortwave", "1.5" - "``shortwave``", "``ccsm3``", "NCAR CCSM3 shortwave distribution method", "``ccsm3``" - "", "``dEdd``", "Delta-Eddington method", "" - "``sw_dtemp``", "real", "temperature difference from melt to start redistributing", "0.02" - "``sw_frac``", "real", "fraction redistributed", "0.9" - "``sw_redist``", "logical", "redistribute internal shortwave to surface", "``.false.``" - "", "", "", "" - -ponds_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. csv-table:: **ponds_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``dpscale``", "real", "time scale for flushing in permeable ice", "1.0" - "``frzpnd``", "``cesm``", "CESM pond refreezing forumulation", "``cesm``" - "", "``hlid``", "Stefan refreezing with pond ice thickness", "" - "``hp1``", "real", "critical ice lid thickness for topo ponds in m", "0.01" - "``hs0``", "real", "snow depth of transition to bare sea ice in m", "" - "``hs1``", "real", "snow depth of transition to pond ice in m", "0.03" - "``pndaspect``", "real", "aspect ratio of pond changes (depth:area)", "0.8" - "``rfracmax``", ":math:`0 \le r_{max} \le 1`", "maximum melt water added to ponds", "0.85" - "``rfracmin``", ":math:`0 \le r_{min} \le 1`", "minimum melt water added to ponds", "0.15" - "", "", "", "" - -snow_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. csv-table:: **snow_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``drhosdwind``", "real", "wind compactions factor for now in kg-s/m^4", "27.3" - "``rhosmax``", "real", "maximum snow density in kg/m^3", "450." - "``rhosmin``", "real", "minimum snow density in kg/m^3", "100." - "``rhosnew``", "real", "new snow density in kg/m^3", "100." - "``rsnw_fall``", "real", "radius of new snow in 1.0e-6 m", "100." - "``rsnw_tmax``", "real", "maximum snow radius in 1.0e-6 m", "1500." - "``snwgrain``", "logical", "snow metamorophsis flag", "``.false.``" - "``snwlvlfac``", "real", "fractional increase in snow", "0.3" - "``snwredist``", "``bulk``", "bulk snow redistribution scheme", "``none``" - "", "``ITD``", "ITD snow redistribution scheme", "" - "", "``ITDrdg``", "ITDrdg snow redistribution scheme", "" - "", "``none``", "snow redistribution scheme off", "" - "``snw_aging_table``", "file", "read 1D and 3D fields for dry metamorophsis lookup table", "test" - "", "snicar", "read 3D fields for dry metamorophsis lookup table", "" - "", "test", "internally generated dry metamorophsis lookup table for testing", "" - "``snw_drdt0_fname``", "string", "snow aging file drdt0 fieldname", "unknown" - "``snw_filename``", "string", "snow aging table data filename", "unknown" - "``snw_kappa_fname``", "string", "snow aging file kappa fieldname", "unknown" - "``snw_rhos_fname``", "string", "snow aging file rhos fieldname", "unknown" - "``snw_T_fname``", "string", "snow aging file T fieldname", "unknown" - "``snw_tau_fname``", "string", "snow aging file tau fieldname", "unknown" - "``snw_Tgrd_fname``", "string", "snow aging file Tgrd fieldname", "unknown" - "``use_smliq_pnd``", "logical", "use liquid in snow for ponds", "``.false.``" - "``windmin``", "real", "minimum wind speed to compact snow in m/s", "10." - "", "", "", "" - -forcing_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. - commented out - "``calc_dragio``", "logical", "compute dragio from iceruf_ocean and thickness of first ocean level, not supported", "``.false.``" - "``iceruf_ocn``", "real", "under ice roughness in meters, not supported", "0.03" - commented out - -.. csv-table:: **forcing_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``atmbndy``", "string", "bulk transfer coefficients", "``similarity``" - "", "``similarity``", "stability-based boundary layer", "" - "", "``constant``", "constant-based boundary layer", "" - "", "``mixed``", "stability-based boundary layer for wind stress, constant-based for sensible+latent heat fluxes", "" - "``atmiter_conv``", "real", "convergence criteria for ustar", "0.0" - "``atm_data_dir``", "string", "path or partial path to atmospheric forcing data directory", "" - "``atm_data_format``", "``bin``", "read direct access binary atmo forcing file format", "``bin``" - "", "``nc``", "read netcdf atmo forcing files", "" - "``atm_data_type``", "``box2001``", "forcing data for :cite:`Hunke01` box problem", "``default``" - "", "``default``", "constant values defined in the code", "" - "", "``hycom``", "HYCOM atm forcing data in netcdf format", "" - "", "``JRA55``", "JRA55 forcing data :cite:`Tsujino18`", "" - "", "``JRA55do``", "JRA55do forcing data :cite:`Tsujino18`", "" - "", "``monthly``", "monthly forcing data", "" - "", "``ncar``", "NCAR bulk forcing data", "" - "", "``oned``", "column forcing data", "" - "``bgc_data_dir``", "string", "path to oceanic forcing data directory", "'unknown_bgc_data_dir'" - "``bgc_data_type``", "``clim``", "bgc climatological data", "``default``" - "", "``default``", "constant values defined in the code", "" - "", "``hycom``", "HYCOM ocean forcing data in netcdf format", "" - "", "``ncar``", "POP ocean forcing data", "" - "``calc_strair``", "``.false.``", "read wind stress and speed from files", "``.true.``" - "", "``.true.``", "calculate wind stress and speed", "" - "``calc_Tsfc``", "logical", "calculate surface temperature", "``.true.``" - "``default_season``", "``summer``", "forcing initial summer values", "``winter``" - "", "``winter``", "forcing initial winter values", "" - "``emissivity``", "real", "emissivity of snow and ice", "0.985" - "``fbot_xfer_type``", "``Cdn_ocn``", "variable ocean heat transfer coefficient scheme", "``constant``" - "", "``constant``", "constant ocean heat transfer coefficient", "" - "``fe_data_type``", "``clim``", "ocean climatology forcing value for iron", "``default``" - "", "``default``", "default forcing value for iron", "" - "``formdrag``", "logical", "calculate form drag", "``.false.``" - "``fyear_init``", "integer", "first year of atmospheric forcing data", "1900" - "``highfreq``", "logical", "high-frequency atmo coupling", "``.false.``" - "``ice_data_conc``", "``box2001``", "ice distribution ramped from 0 to 1 west to east consistent with :ref:`box2001` test (:cite:`Hunke01`)", "``default``" - "", "``c1``", "initial ice concentation of 1.0", "" - "", "``default``", "same as parabolic", "" - "", "``p5``", "initial concentration of 0.5", "" - "", "``p8``", "initial concentration of 0.8", "" - "", "``p9``", "initial concentration of 0.9", "" - "", "``parabolic``", "parabolic in ice thickness space with sum of aicen=1.0", "" - "``ice_data_dist``", "``box2001``", "ice distribution ramped from 0 to 1 west to east consistent with :ref:`box2001` test (:cite:`Hunke01`)", "``default``" - "", "``default``", "uniform distribution, equivalent to uniform", "" - "", "``gauss``", "gauss distbution of ice with a peak in the center of the domain", "" - "", "``uniform``", "uniform distribution, equivalent to default", "" - "``ice_data_type``", "``block``", "ice block covering about 25 percent of the area in center of domain", "``default``" - "", "``boxslotcyl``", "slot cylinder ice mask associated with :ref:`boxslotcyl` test (:cite:`Zalesak79`)", "" - "", "``box2001``", "box2001 ice mask associate with :ref:`box2001` test (:cite:`Hunke01`)", "" - "", "``channel``", "ice defined on entire grid in i-direction and 50% in j-direction in center of domain", "" - "", "``default``", "same as latsst", "" - "", "``eastblock``", "ice block covering about 25 percent of domain at the east edge of the domain", "" - "", "``latsst``", "ice dependent on latitude and ocean temperature", "" - "", "``uniform``", "ice defined at all grid points", "" - "``ice_ref_salinity``", "real", "sea ice salinity for coupling fluxes (ppt)", "4.0" - "``iceruf``", "real", "ice surface roughness at atmosphere interface in meters", "0.0005" - "``l_mpond_fresh``", "``.false.``", "release pond water immediately to ocean", "``.false.``" - "", "``true``", "retain (topo) pond water until ponds drain", "" - "``natmiter``", "integer", "number of atmo boundary layer iterations", "5" - "``nfreq``", "integer", "number of frequencies in ocean surface wave spectral forcing", "25" - "``oceanmixed_file``", "string", "data file containing ocean forcing data", "'unknown_oceanmixed_file'" - "``oceanmixed_ice``", "logical", "active ocean mixed layer calculation", "``.false.``" - "``ocn_data_dir``", "string", "path to oceanic forcing data directory", "'unknown_ocn_data_dir'" - "``ocn_data_format``", "``bin``", "read direct access binary ocean forcing files", "``bin``" - "", "``nc``", "read netcdf ocean forcing files", "" - "``ocn_data_type``", "``clim``", "ocean climatological data formulation", "``default``" - "", "``default``", "constant values defined in the code", "" - "", "``hycom``", "HYCOM ocean forcing data in netcdf format", "" - "", "``ncar``", "POP ocean forcing data", "" - "``precip_units``", "``mks``", "liquid precipitation data units", "``mks``" - "", "``mm_per_month``", "", "" - "", "``mm_per_sec``", "(same as MKS units)", "" - "", "``m_per_sec``", "", "" - "``restart_coszen``", "logical", "read/write coszen in restart files", "``.false.``" - "``restore_ocn``", "logical", "restore sst to data", "``.false.``" - "``restore_ice``", "logical", "restore ice state along lateral boundaries", "``.false.``" - "``rotate_wind``", "logical", "rotate wind from east/north to computation grid", "``.true.``" - "``saltflux_option``", "``constant``", "computed using ice_ref_salinity", "``constant``" - "", "``prognostic``", "computed using prognostic salinity", "" - "``tfrz_option``", "``linear_salt``", "linear function of salinity (ktherm=1)", "``mushy``" - "", "``minus1p8``", "constant ocean freezing temperature (:math:`-1.8^{\circ} C`)", "" - "", "``mushy``", "matches mushy-layer thermo (ktherm=2)", "" - "``trestore``", "integer", "sst restoring time scale (days)", "90" - "``ustar_min``", "real", "minimum value of ocean friction velocity in m/s", "0.0005" - "``update_ocn_f``", "``.false.``", "do not include frazil water/salt fluxes in ocn fluxes", "``.false.``" - "", "``true``", "include frazil water/salt fluxes in ocn fluxes", "" - "``wave_spec_file``", "string", "data file containing wave spectrum forcing data", "" - "``wave_spec_type``", "``constant``", "wave data file is provided, constant wave spectrum, for testing", "``none``" - "", "``none``", "no wave data provided, no wave-ice interactions", "" - "", "``profile``", "no wave data file is provided, use fixed dummy wave spectrum, for testing", "" - "", "``random``", "wave data file is provided, wave spectrum generated using random number", "" - "``ycycle``", "integer", "number of years in forcing data cycle", "1" - "", "", "", "" - -zbgc_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. csv-table:: **zbgc_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 - - "", "", "", "" - "``algaltype_diatoms``", "real", "mobility type between stationary and mobile algal diatoms", "0.0" - "``algaltype_phaeo``", "real", "mobility type between stationary and mobile algal phaeocystis", "0.5" - "``algaltype_sp``", "real", "mobility type between stationary and mobile small plankton", "0.5" - "``algal_vel``", "real", ":cite:`Lavoie05`", "1.11e-8" - "``alpha2max_low_diatoms``", "real", "light limitation diatoms 1/(W/m^2)", "0.8" - "``alpha2max_low_phaeo``", "real", "light limitation phaeocystis 1/(W/m^2)", "0.67" - "``alpha2max_low_sp``", "real", "light limitation small plankton 1/(W/m^2)", "0.67" - "``ammoniumtype``", "real", "mobility type between stationary and mobile ammonium", "1.0" - "``beta2max_diatoms``", "real", "light inhibition diatoms 1/(W/m^2)", "0.18" - "``beta2max_phaeo``", "real", "light inhibition phaeocystis 1/(W/m^2)", "0.01" - "``beta2max_sp``", "real", "light inhibition small plankton 1/(W/m^2)", "0.0025" - "``bgc_flux_type``", "``constant``", "constant ice–ocean flux velocity", "``Jin2006``" - "", "``Jin2006``", "ice–ocean flux velocity of :cite:`Jin06`", "" - "``chlabs_diatoms``", "real", "chl absorbtion diatoms 1/m/(mg/m^3)", "0.03" - "``chlabs_phaeo``", "real", "chl absorbtion phaeocystis 1/m/(mg/m^3)", "0.05" - "``chlabs_sp``", "real", "chl absorbtion small plankton 1/m/(mg/m^3)", "0.01" - "``dEdd_algae``", "logical", "", "``.false.``" - "``dmspdtype``", "real", "mobility type between stationary and mobile dmspd", "-1.0" - "``dmspptype``", "real", "mobility type between stationary and mobile dmspp", "0.5" - "``doctype_l``", "real", "mobility type between stationary and mobile doc lipids", "0.5" - "``doctype_s``", "real", "mobility type between stationary and mobile doc saccharids", "0.5" - "``dontype_protein``", "real", "mobility type between stationary and mobile don proteins", "0.5" - "``dustFe_sol``", "real", "solubility fraction", "0.005" - "``fedtype_1``", "real", "mobility type between stationary and mobile fed lipids", "0.5" - "``feptype_1``", "real", "mobility type between stationary and mobile fep lipids", "0.5" - "``frazil_scav``", "real", "increase in initial bio bracer from ocean scavenging", "1.0" - "``fr_dFe``", "real", "fraction of remineralized nitrogen in units of algal iron", "0.3" - "``fr_graze_diatoms``", "real", "fraction grazed diatoms", "0.01" - "``fr_graze_e``", "real", "fraction of assimilation excreted", "0.5" - "``fr_graze_phaeo``", "real", "fraction grazed phaeocystis", "0.1" - "``fr_graze_s``", "real", "fraction of grazing spilled or slopped", "0.5" - "``fr_graze_sp``", "real", "fraction grazed small plankton", "0.1" - "``fr_mort2min``", "real", "fractionation of mortality to Am", "0.5" - "``fr_resp``", "real", "frac of algal growth lost due to respiration", "0.05" - "``fr_resp_s``", "real", "DMSPd fraction of respiration loss as DMSPd", "0.75" - "``fsal``", "real", "salinity limitation ppt", "1.0" - "``F_abs_chl_diatoms``", "real", "scales absorbed radiation for dEdd chl diatoms", "2.0" - "``F_abs_chl_phaeo``", "real", "scales absorbed radiation for dEdd chl phaeocystis", "5.0" - "``F_abs_chl_sp``", "real", "scales absorbed radiation for dEdd small plankton", "4.0" - "``f_doc_l``", "real", "fraction of mortality to DOC lipids", "0.4" - "``f_doc_s``", "real", "fraction of mortality to DOC saccharides", "0.4" - "``f_don_Am_protein``", "real", "fraction of remineralized DON to ammonium", "0.25" - "``f_don_protein``", "real", "fraction of spilled grazing to proteins", "0.6" - "``f_exude_l``", "real", "fraction of exudation to DOC lipids", "1.0" - "``f_exude_s``", "real", "fraction of exudation to DOC saccharids", "1.0" - "``grid_o``", "real", "z biology for bottom flux", "5.0" - "``grid_o_t``", "real", "z biology for top flux", "5.0" - "``grid_oS``", "real", "zsalinity DEPRECATED", "" - "``grow_Tdep_diatoms``", "real", "temperature dependence growth diatoms per degC", "0.06" - "``grow_Tdep_phaeo``", "real", "temperature dependence growth phaeocystis per degC", "0.06" - "``grow_Tdep_sp``", "real", "temperature dependence growth small plankton per degC", "0.06" - "``humtype``", "real", "mobility type between stationary and mobile hum", "1.0" - "``initbio_frac``", "real", "fraction of ocean trcr concentration in bio tracers", "1.0" - "``K_Am_diatoms``", "real", "ammonium half saturation diatoms mmol/m^3", "0.3" - "``K_Am_phaeo``", "real", "ammonium half saturation phaeocystis mmol/m^3", "0.3" - "``K_Am_sp``", "real", "ammonium half saturation small plankton mmol/m^3", "0.3" - "``k_bac_l``", "real", "Bacterial degredation of DOC lipids per day", "0.03" - "``k_bac_s``", "real", "Bacterial degredation of DOC saccharids per day", "0.03" - "``k_exude_diatoms``", "real", "algal exudation diatoms per day", "0.0" - "``k_exude_phaeo``", "real", "algal exudation phaeocystis per day", "0.0" - "``k_exude_sp``", "real", "algal exudation small plankton per day", "0.0" - "``K_Fe_diatoms``", "real", "iron half saturation diatoms nM", "1.0" - "``K_Fe_phaeo``", "real", "iron half saturation phaeocystis nM", "0.1" - "``K_Fe_sp``", "real", "iron half saturation small plankton nM", "0.2" - "``k_nitrif``", "real", "nitrification rate per day", "0.0" - "``K_Nit_diatoms``", "real", "nitrate half saturation diatoms mmol/m^3", "1.0" - "``K_Nit_phaeo``", "real", "nitrate half saturation phaeocystis mmol/m^3", "1.0" - "``K_Nit_sp``", "real", "nitrate half saturation small plankton mmol/m^3", "1.0" - "``K_Sil_diatoms``", "real", "silicate half saturation diatoms mmol/m^3", "4.0" - "``K_Sil_phaeo``", "real", "silicate half saturation phaeocystis mmol/m^3", "0.0" - "``K_Sil_sp``", "real", "silicate half saturation small plankton mmol/m^3", "0.0" - "``kn_bac_protein``", "real", "bacterial degradation of DON per day", "0.03" - "``l_sk``", "real", "characteristic diffusive scale in m", "7.0" - "``l_skS``", "real", "zsalinity DEPRECATED", "" - "``max_dfe_doc1``", "real", "max ratio of dFe to saccharides in the ice in nm Fe / muM C", "0.2" - "``max_loss``", "real", "restrict uptake to percent of remaining value", "0.9" - "``modal_aero``", "logical", "modal aerosols", "``.false.``" - "``mort_pre_diatoms``", "real", "mortality diatoms", "0.007" - "``mort_pre_phaeo``", "real", "mortality phaeocystis", "0.007" - "``mort_pre_sp``", "real", "mortality small plankton", "0.007" - "``mort_Tdep_diatoms``", "real", "temperature dependence of mortality diatoms per degC", "0.03" - "``mort_Tdep_phaeo``", "real", "temperature dependence of mortality phaeocystis per degC", "0.03" - "``mort_Tdep_sp``", "real", "temperature dependence of mortality small plankton per degC", "0.03" - "``mu_max_diatoms``", "real", "maximum growth rate diatoms per day", "1.2" - "``mu_max_phaeo``", "real", "maximum growth rate phaeocystis per day", "0.851" - "``mu_max_sp``", "real", "maximum growth rate small plankton per day", "0.851" - "``nitratetype``", "real", "mobility type between stationary and mobile nitrate", "-1.0" - "``optics_file``", "string", "optics file associated with modal aerosols", "unknown_optics_file" - "``optics_file_fieldname``", "string", "optics file fieldname to read", "unknown_optics_fieldname" - "``op_dep_min``", "real", "light attenuates for optical depths exceeding min", "0.1" - "``phi_snow``", "real", "snow porosity for brine height tracer", "0.5" - "``ratio_chl2N_diatoms``", "real", "algal chl to N in mg/mmol diatoms", "2.1" - "``ratio_chl2N_phaeo``", "real", "algal chl to N in mg/mmol phaeocystis", "0.84" - "``ratio_chl2N_sp``", "real", "algal chl to N in mg/mmol small plankton", "1.1" - "``ratio_C2N_diatoms``", "real", "algal C to N in mol/mol diatoms", "7.0" - "``ratio_C2N_phaeo``", "real", "algal C to N in mol/mol phaeocystis", "7.0" - "``ratio_C2N_proteins``", "real", "algal C to N in mol/mol proteins", "7.0" - "``ratio_C2N_sp``", "real", "algal C to N in mol/mol small plankton", "7.0" - "``ratio_Fe2C_diatoms``", "real", "algal Fe to C in umol/mol diatoms", "0.0033" - "``ratio_Fe2C_phaeo``", "real", "algal Fe to C in umol/mol phaeocystis", "1.0" - "``ratio_Fe2C_sp``", "real", "algal Fe to C in umol/mol small plankton", "0.0033" - "``ratio_Fe2N_diatoms``", "real", "algal Fe to N in umol/mol diatoms", "0.23" - "``ratio_Fe2N_phaeo``", "real", "algal Fe to N in umol/mol phaeocystis", "0.7" - "``ratio_Fe2N_sp``", "real", "algal Fe to N in umol/mol small plankton", "0.23" - "``ratio_Fe2DOC_s``", "real", "Fe to C of DON saccharids nmol/umol", "1.0" - "``ratio_Fe2DOC_l``", "real", "Fe to C of DOC lipids nmol/umol", "0.033" - "``ratio_Fe2DON``", "real", "Fe to C of DON nmol/umol", "0.023" - "``ratio_Si2N_diatoms``", "real", "algal Si to N in mol/mol diatoms", "1.8" - "``ratio_Si2N_phaeo``", "real", "algal Si to N in mol/mol phaeocystis", "0.0" - "``ratio_Si2N_sp``", "real", "algal Si to N in mol/mol small plankton", "0.0" - "``ratio_S2N_diatoms``", "real", "algal S to N in mol/mol diatoms", "0.03" - "``ratio_S2N_phaeo``", "real", "algal S to N in mol/mol phaeocystis", "0.03" - "``ratio_S2N_sp``", "real", "algal S to N in mol/mol small plankton", "0.03" - "``restart_bgc``", "logical", "restart tracer values from file", "``.false.``" - "``restart_hbrine``", "logical", "", "``.false.``" - "``restart_zsal``", "logical", "zsalinity DEPRECATED", "``.false.``" - "``restore_bgc``", "logical", "restore bgc to data", "``.false.``" - "``R_dFe2dust``", "real", "g/g :cite:`Tagliabue09`", "0.035" - "``scale_bgc``", "logical", "", "``.false.``" - "``silicatetype``", "real", "mobility type between stationary and mobile silicate", "-1.0" - "``skl_bgc``", "logical", "biogeochemistry", "``.false.``" - "``solve_zbgc``", "logical", "", "``.false.``" - "``solve_zsal``", "logical", "zsalinity DEPRECATED, update salinity tracer profile", "``.false.``" - "``tau_max``", "real", "long time mobile to stationary exchanges", "1.73e-5" - "``tau_min``", "real", "rapid module to stationary exchanges", "5200." - "``tr_bgc_Am``", "logical", "ammonium tracer", "``.false.``" - "``tr_bgc_C``", "logical", "algal carbon tracer", "``.false.``" - "``tr_bgc_chl``", "logical", "algal chlorophyll tracer", "``.false.``" - "``tr_bgc_DMS``", "logical", "DMS tracer", "``.false.``" - "``tr_bgc_DON``", "logical", "DON tracer", "``.false.``" - "``tr_bgc_Fe``", "logical", "iron tracer", "``.false.``" - "``tr_bgc_hum``", "logical", "", "``.false.``" - "``tr_bgc_Nit``", "logical", "", "``.false.``" - "``tr_bgc_PON``", "logical", "PON tracer", "``.false.``" - "``tr_bgc_Sil``", "logical", "silicate tracer", "``.false.``" - "``tr_brine``", "logical", "brine height tracer", "``.false.``" - "``tr_zaero``", "logical", "vertical aerosol tracers", "``.false.``" - "``t_iron_conv``", "real", "desorption loss pFe to dFe in days", "3065." - "``t_sk_conv``", "real", "Stefels conversion time in days", "3.0" - "``t_sk_ox``", "real", "DMS oxidation time in days", "10.0" - "``T_max``", "real", "maximum temperature degC", "0.0" - "``y_sk_DMS``", "real", "fraction conversion given high yield", "0.5" - "``zaerotype_bc1``", "real", "mobility type between stationary and mobile zaero bc1", "1.0" - "``zaerotype_bc2``", "real", "mobility type between stationary and mobile zaero bc2", "1.0" - "``zaerotype_dust1``", "real", "mobility type between stationary and mobile zaero dust1", "1.0" - "``zaerotype_dust2``", "real", "mobility type between stationary and mobile zaero dust2", "1.0" - "``zaerotype_dust3``", "real", "mobility type between stationary and mobile zaero dust3", "1.0" - "``zaerotype_dust4``", "real", "mobility type between stationary and mobile zaero dust4", "1.0" - "``z_tracers``", "logical", "", "``.false.``" - "", "", "", "" - - -icefields_nml -~~~~~~~~~~~~~~~~~~~~~~~~~ - -There are several icefield namelist groups to control model history output. See the -source code for a full list of supported output fields. - -* ``icefields_nml`` is in **cicecore/cicedyn/analysis/ice_history_shared.F90** -* ``icefields_bgc_nml`` is in **cicecore/cicedyn/analysis/ice_history_bgc.F90** -* ``icefields_drag_nml`` is in **cicecore/cicedyn/analysis/ice_history_drag.F90** -* ``icefields_fsd_nml`` is in **cicecore/cicedyn/analysis/ice_history_fsd.F90** -* ``icefields_mechred_nml`` is in **cicecore/cicedyn/analysis/ice_history_mechred.F90** -* ``icefields_pond_nml`` is in **cicecore/cicedyn/analysis/ice_history_pond.F90** -* ``icefields_snow_nml`` is in **cicecore/cicedyn/analysis/ice_history_snow.F90** - -.. csv-table:: **icefields_nml namelist options** - :header: "variable", "options/format", "description", "default value" - :widths: 15, 15, 30, 15 +.. csv-table:: *Namelist options* + :header: "also in Icepack","variable", "options/format", "description", "recommended value" + :widths: 5, 15, 15, 30, 15 + + "","", "", "", "" + "","*setup_nml*", "", "", "" + "","", "", "**Time, Diagnostics**", "" + "\*","``days_per_year``", "``360`` or ``365``", "number of days in a model year", "365" + "\*","``use_leap_years``", "true/false", "if true, include leap days", "" + "\*","``year_init``", "yyyy", "the initial year, if not using restart", "" + "\*","``istep0``", "integer", "initial time step number", "0" + "\*","``dt``", "seconds", "thermodynamics time step length", "3600." + "\*","``npt``", "integer", "total number of time steps to take", "" + "\*","``ndtd``", "integer", "number of dynamics/advection/ridging/steps per thermo timestep", "1" + "","", "", "**Initialization/Restarting**", "" + "","``runtype``", "``initial``", "start from ``ice_ic``", "" + "","", "``continue``", "restart using ``pointer_file``", "" + "\*","``ice_ic``", "``default``", "latitude and sst dependent", "default" + "","", "``none``", "no ice", "" + "","", "path/file", "restart file name", "" + "","``restart``", "true/false", "initialize using restart file", "``.true.``" + "","``use_restart_time``", "true/false", "set initial date using restart file", "``.true.``" + "","``restart_format``", "nc", "read/write  restart files (use with PIO)", "" + "","", "bin", "read/write binary restart files", "" + "","``lcdf64``", "true/false", "if true, use 64-bit  format", "" + "","``numin``", "integer", "minimum internal IO unit number", "11" + "","``numax``", "integer", "maximum internal IO unit number", "99" + "\*","``restart_dir``", "path/", "path to restart directory", "" + "","``restart_ext``", "true/false", "read/write halo cells in restart files", "" + "","``restart_file``", "filename prefix", "output file for restart dump", "‘iced’" + "","``pointer_file``", "pointer filename", "contains restart filename", "" + "\*","``dumpfreq``", "``y``", "write restart every ``dumpfreq_n`` years", "y" + "","", "``m``", "write restart every ``dumpfreq_n`` months", "" + "","", "``d``", "write restart every ``dumpfreq_n`` days", "" + "","", "``h``", "write restart every ``dumpfreq_n`` hours", "" + "","", "``1``", "write restart every ``dumpfreq_n`` time step", "" + "","``dumpfreq_n``", "integer", "frequency restart data is written", "1" + "\*","``dump_last``", "true/false", "if true, write restart on last time step of simulation", "" + "","", "", "**Model Output**", "" + "","``bfbflag``", "off/lsum4/lsum8/lsum16/ddpdd/reprosum", "global sum methods", "off" + "\*","``diagfreq``", "integer", "frequency of diagnostic output in ``dt``", "24" + "","", "*e.g.*, 10", "once every 10 time steps", "" + "\*","``diag_type``", "``stdout``", "write diagnostic output to stdout", "" + "","", "``file``", "write diagnostic output to file", "" + "","``diag_file``", "filename", "diagnostic output file (script may reset)", "" + "","``print_global``", "true/false", "print diagnostic data, global sums", "``.false.``" + "","``print_points``", "true/false", "print diagnostic data for two grid points", "``.false.``" + "","``latpnt``", "real", "latitude of (2) diagnostic points", "" + "","``lonpnt``", "real", "longitude of (2) diagnostic points", "" + "","``dbug``", "true/false", "if true, write extra diagnostics", "``.false.``" + "","``histfreq``", "string array", "defines output frequencies", "" + "","", "``y``", "write history every ``histfreq_n`` years", "" + "","", "``m``", "write history every ``histfreq_n`` months", "" + "","", "``d``", "write history every ``histfreq_n`` days", "" + "","", "``h``", "write history every ``histfreq_n`` hours", "" + "","", "``1``", "write history every ``histfreq_n`` time step", "" + "","", "``x``", "unused frequency stream (not written)", "" + "","``histfreq_n``", "integer array", "frequency history output is written", "" + "","", "0", "do not write to history", "" + "","``hist_avg``", "true", "write time-averaged data", "``.true.``" + "","", "false", "write snapshots of data", "" + "","``history_dir``", "path/", "path to history output directory", "" + "","``history_file``", "filename prefix", "output file for history", "‘iceh’" + "","``write_ic``", "true/false", "write initial condition", "" + "","``incond_dir``", "path/", "path to initial condition directory", "" + "","``incond_file``", "filename prefix", "output file for initial condition", "‘iceh’" + "","``runid``", "string", "label for run (currently CESM only)", "" + "","", "", "", "" + "","*grid_nml*", "", "", "" + "","", "", "**Grid**", "" + "","``grid_format``", "``nc``", "read  grid and kmt files", "‘bin’" + "","", "``bin``", "read direct access, binary file", "" + "","``grid_type``", "``rectangular``", "defined in *rectgrid*", "" + "","", "``displaced_pole``", "read from file in *popgrid*", "" + "","", "``tripole``", "read from file in *popgrid*", "" + "","", "``regional``", "read from file in *popgrid*", "" + "","``grid_file``", "filename", "name of grid file to be read", "‘grid’" + "","``bathymetry_file``", "filename", "name of bathymetry file to be read", "‘grid’" + "","``use_bathymetry``", "true/false", "use read in bathymetry file for basalstress option", "" + "","``kmt_file``", "filename", "name of land mask file to be read", "‘kmt’" + "","``gridcpl_file``", "filename", "input file for coupling grid info", "" + "\*","``kcatbound``", "``0``", "original category boundary formula", "0" + "","", "``1``", "new formula with round numbers", "" + "","", "``2``", "WMO standard categories", "" + "","", "``-1``", "one category", "" + "","``dxrect``", "real", "x-direction grid spacing (cm) for rectangular grid", "" + "","``dyrect``", "real", "y-direction grid spacing (cm) for rectangular grid", "" + "","``ncat``", "integer", "number of ice thickness categories", "5" + "","``nfsd``", "integer", "number of floe size categories", "12 for prognostic FSD; 1 otherwise" + "","``nilyr``", "integer", "number of vertical layers in ice", "7" + "","``nslyr``", "integer", "number of vertical layers in snow", "1" + "","``nblyr``", "integer", "number of zbgc layers", "7" + "","", "", "", "" + "","*domain_nml*", "", "", "" + "","", "", "**Domain**", "" + "","``nprocs``", "integer", "number of processors to use", "" + "","``nx_global``", "integer", "global grid size in x direction", "" + "","``ny_global``", "integer", "global grid size in y direction", "" + "","``block_size_x``", "integer", "block size in x direction", "" + "","``block_size_y``", "integer", "block size in y direction", "" + "","``max_blocks``", "integer", "maximum number of blocks per MPI task for memory allocation", "" + "","``processor_shape``", "``slenderX1``", "1 processor in the y direction (tall, thin)", "" + "","", "``slenderX2``", "2 processors in the y direction (thin)", "" + "","", "``square-ice``", "more processors in x than y, :math:`\sim` square", "" + "","", "``square-pop``", "more processors in y than x, :math:`\sim` square", "" + "","``distribution_type``", "``cartesian``", "distribute blocks in 2D Cartesian array", "" + "","", "``roundrobin``", "1 block per proc until blocks are used", "" + "","", "``sectcart``", "blocks distributed to domain quadrants", "" + "","", "``sectrobin``", "several blocks per proc until used", "" + "","", "``rake``", "redistribute blocks among neighbors", "" + "","", "``spacecurve``", "distribute blocks via space-filling curves", "" + "","", "``spiralcenter``", "distribute blocks via roundrobin from center of grid outward in a spiral", "" + "","", "``wghtfile``", "distribute blocks based on weights specified in ``distribution_wght_file``", "" + "","``distribution_wght``", "``block``", "full block size sets ``work_per_block``", "" + "","", "``latitude``", "latitude/ocean sets ``work_per_block``", "" + "","``distribution_wght_file``", "filename", "distribution weight file when distribution_type is ``wghtfile``", "" + "","``ew_boundary_type``", "``cyclic``", "periodic boundary conditions in x-direction", "" + "","", "``open``", "Dirichlet boundary conditions in x", "" + "","``ns_boundary_type``", "``cyclic``", "periodic boundary conditions in y-direction", "" + "","", "``open``", "Dirichlet boundary conditions in y", "" + "","", "``tripole``", "U-fold tripole boundary conditions in y", "" + "","", "``tripoleT``", "T-fold tripole boundary conditions in y", "" + "","``maskhalo_dyn``", "true/false", "mask unused halo cells for dynamics", "" + "","``maskhalo_remap``", "true/false", "mask unused halo cells for transport", "" + "","``maskhalo_bound``", "true/false", "mask unused halo cells for boundary updates", "" + "","", "", "", "" + "","*tracer_nml*", "", "", "" + "","", "", "**Tracers**", "" + "","``n_aero``", "integer", "number of aerosol tracers", "1" + "","``n_iso``", "integer", "number of isotope tracers", "1" + "","``n_zaero``", "0,1,2,3,4,5,6", "number of z aerosol tracers in use", "0" + "","``n_algae``", "0,1,2,3", "number of algal tracers", "0" + "","``n_doc``", "0,1,2,3", "number of dissolved organic carbon", "0" + "","``n_dic``", "0,1", "number of dissolved inorganic carbon", "0" + "","``n_don``", "0,1", "number of dissolved organize nitrogen", "0" + "","``n_fed``", "0,1,2", "number of dissolved iron tracers", "0" + "","``n_fep``", "0,1,2", "number of particulate iron tracers", "0" + "\*","``tr_iage``", "true/false", "ice age", "" + "","``restart_age``", "true/false", "restart tracer values from file", "" + "\*","``tr_FY``", "true/false", "first-year ice area", "" + "","``restart_FY``", "true/false", "restart tracer values from file", "" + "\*","``tr_lvl``", "true/false", "level ice area and volume", "" + "","``restart_lvl``", "true/false", "restart tracer values from file", "" + "\*","``tr_pond_cesm``", "true/false", "CESM melt ponds", "" + "","``restart_pond_cesm``", "true/false", "restart tracer values from file", "" + "\*","``tr_pond_topo``", "true/false", "topo melt ponds", "" + "","``restart_pond_topo``", "true/false", "restart tracer values from file", "" + "\*","``tr_pond_lvl``", "true/false", "level-ice melt ponds", "" + "","``restart_pond_lvl``", "true/false", "restart tracer values from file", "" + "\*","``tr_aero``", "true/false", "aerosols", "" + "","``restart_aero``", "true/false", "restart tracer values from file", "" + "\*","``tr_iso``", "true/false", "isotopes", "" + "","``restart_iso``", "true/false", "restart tracer values from file", "" + "\*","``tr_fsd``", "true/false", "floe size distribution", "" + "","``restart_fsd``", "true/false", "restart floe size distribution values from file", "" + "","", "", "", "" + "","*thermo_nml*", "", "", "" + "","", "", "**Thermodynamics**", "" + "\*","``kitd``", "``0``", "delta function ITD approximation", "1" + "","", "``1``", "linear remapping ITD approximation", "" + "\*","``ktherm``", "``0``", "zero-layer thermodynamic model", "" + "","", "``1``", "Bitz and Lipscomb thermodynamic model", "" + "","", "``2``", "mushy-layer thermodynamic model", "" + "","", "``-1``", "thermodynamics disabled", "" + "\*","``conduct``", "``Maykut71``", "conductivity :cite:`Maykut71`", "" + "","", "``bubbly``", "conductivity :cite:`Pringle07`", "" + "\*","``ksno``", "real", "snow thermal conductivity", "0.3" + "\*","``a_rapid_mode``", "real", "brine channel diameter", "0.5x10 :math:`^{-3}` m" + "\*","``Rac_rapid_mode``", "real", "critical Rayleigh number", "10" + "\*","``aspect_rapid_mode``", "real", "brine convection aspect ratio", "1" + "\*","``dSdt_slow_mode``", "real", "drainage strength parameter", "-1.5x10 :math:`^{-7}` m/s/K" + "\*","``phi_c_slow_mode``", ":math:`0<\phi_c < 1`", "critical liquid fraction", "0.05" + "\*","``phi_i_mushy``", ":math:`0<\phi_i < 1`", "solid fraction at lower boundary", "0.85" + "","", "", "", "" + "","*dynamics_nml*", "", "", "" + "","", "", "**Dynamics**", "" + "","``kdyn``", "``-1``", "dynamics OFF", "1" + "","", "``0``", "dynamics OFF", "" + "","", "``1``", "EVP dynamics", "" + "","", "``2``", "EAP dynamics", "" + "","", "``1``", "dynamics ON", "" + "","``revised_evp``", "true/false", "use revised EVP formulation", "" + "","``ndte``", "integer", "number of EVP subcycles", "240" + "","``advection``", "``remap``", "linear remapping advection", "‘remap’" + "","", "``upwind``", "donor cell advection", "" + "\*","``kstrength``", "``0``", "ice strength formulation :cite:`Hibler79`", "1" + "","", "``1``", "ice strength formulation :cite:`Rothrock75`", "" + "\*","``krdg_partic``", "``0``", "old ridging participation function", "1" + "","", "``1``", "new ridging participation function", "" + "\*","``krdg_redist``", "``0``", "old ridging redistribution function", "1" + "","", "``1``", "new ridging redistribution function", "" + "\*","``mu_rdg``", "real", "e-folding scale of ridged ice", "" + "\*","``Cf``", "real", "ratio of ridging work to PE change in ridging", "17." + "","``coriolis``", "``latitude``", "Coriolis variable by latitude", "'latitude'" + "","", "``constant``", "Constant coriolis value = 1.46e-4", "" + "","", "``zero``", "Zero coriolis", "" + "","``kridge``", "``1``", "Ridging Enabled", "1" + "","", "``-1``", "Ridging Disabled", "" + "","``ktransport``", "``1``", "Transport Enabled", "1" + "","", "``-1``", "Transport Disabled", "" + "","``basalstress``", "true/false", "use basal stress parameterization for landfast ice", "" + "","``k1``", "real", "1st free parameter for landfast parameterization", "8." + "","``k2``", "real", "2nd free parameter (N/m^3) for landfast parameterization", "15." + "","``alphab``", "real", ":math:`\alpha_{b}` factor in :cite:`Lemieux16`", "20." + "","``threshold_hw``", "real", "Max water depth for grounding (see :cite:`Amundrud04`)", "30." + "","``e_ratio``", "real", "EVP ellipse aspect ratio", "2.0" + "","``Ktens``", "real", "Tensile strength factor (see :cite:`Konig10`)", "0.0" + "","", "", "", "" + "","*shortwave_nml*", "", "", "" + "","", "", "**Shortwave**", "" + "\*","``shortwave``", "``ccsm3``", "NCAR CCSM3 distribution method", "" + "","", "``dEdd``", "Delta-Eddington method", "" + "\*","``albedo_type``", "``ccsm3``", "NCAR CCSM3 albedos", "‘default’" + "","", "``constant``", "four constant albedos", "" + "\*","``albicev``", ":math:`0<\alpha <1`", "visible ice albedo for thicker ice", "" + "\*","``albicei``", ":math:`0<\alpha <1`", "near infrared ice albedo for thicker ice", "" + "\*","``albsnowv``", ":math:`0<\alpha <1`", "visible, cold snow albedo", "" + "\*","``albsnowi``", ":math:`0<\alpha <1`", "near infrared, cold snow albedo", "" + "\*","``ahmax``", "real", "albedo is constant above this thickness", "0.3 m" + "\*","``R_ice``", "real", "tuning parameter for sea ice albedo from Delta-Eddington shortwave", "" + "\*","``R_pnd``", "real", "... for ponded sea ice albedo …", "" + "\*","``R_snw``", "real", "... for snow (broadband albedo) …", "" + "\*","``dT_mlt``", "real", ":math:`\Delta` temperature per :math:`\Delta` snow grain radius", "" + "\*","``rsnw_mlt``", "real", "maximum melting snow grain radius", "" + "\*","``kalg``", "real", "absorption coefficient for algae", "" + "","", "", "", "" + "","*ponds_nml*", "", "", "" + "","", "", "**Melt Ponds**", "" + "\*","``hp1``", "real", "critical ice lid thickness for topo ponds", "0.01 m" + "\*","``hs0``", "real", "snow depth of transition to bare sea ice", "0.03 m" + "\*","``hs1``", "real", "snow depth of transition to pond ice", "0.03 m" + "\*","``dpscale``", "real", "time scale for flushing in permeable ice", ":math:`1\times 10^{-3}`" + "\*","``frzpnd``", "``hlid``", "Stefan refreezing with pond ice thickness", "‘hlid’" + "","", "``cesm``", "CESM refreezing empirical formula", "" + "\*","``rfracmin``", ":math:`0 \le r_{min} \le 1`", "minimum melt water added to ponds", "0.15" + "\*","``rfracmax``", ":math:`0 \le r_{max} \le 1`", "maximum melt water added to ponds", "1.0" + "\*","``pndaspect``", "real", "aspect ratio of pond changes (depth:area)", "0.8" + "","", "", "", "" + "","*forcing_nml*", "", "", "" + "","", "", "**Forcing**", "" + "\*","``formdrag``", "true/false", "calculate form drag", "" + "\*","``atmbndy``", "``default``", "stability-based boundary layer", "‘default’" + "","", "``constant``", "bulk transfer coefficients", "" + "\*","``fyear_init``", "yyyy", "first year of atmospheric forcing data", "" + "\*","``ycycle``", "integer", "number of years in forcing data cycle", "" + "\*","``calc_strair``", "true", "calculate wind stress and speed", "" + "","", "false", "read wind stress and speed from files", "" + "\*","``highfreq``", "true/false", "high-frequency atmo coupling", "" + "\*","``natmiter``", "integer", "number of atmo boundary layer iterations", "" + "\*","``calc_Tsfc``", "true/false", "calculate surface temperature", "``.true.``" + "\*","``default_season``","``winter``", "Sets initial values of forcing and is overwritten if forcing is read in.", "" + "\*","``precip_units``", "``mks``", "liquid precipitation data units", "" + "","", "``mm_per_month``", "", "" + "","", "``mm_per_sec``", "(same as MKS units)", "" + "","", "``m_per_sec``", "", "" + "\*","``tfrz_option``", "``minus1p8``", "constant ocean freezing temperature (:math:`-1.8^{\circ} C`)", "" + "","", "``linear_salt``", "linear function of salinity (ktherm=1)", "" + "","", "``mushy_layer``", "matches mushy-layer thermo (ktherm=2)", "" + "\*","``ustar_min``", "real", "minimum value of ocean friction velocity", "0.0005 m/s" + "\*","``emissivity``", "real", "emissivity of snow and ice", "0.95" + "\*","``fbot_xfer_type``", "``constant``", "constant ocean heat transfer coefficient", "" + "","", "``Cdn_ocn``", "variable ocean heat transfer coefficient", "" + "\*","``update_ocn_f``", "true", "include frazil water/salt fluxes in ocn fluxes", "" + "","", "false", "do not include (when coupling with POP)", "" + "\*","``l_mpond_fresh``", "true", "retain (topo) pond water until ponds drain", "" + "","", "false", "release (topo) pond water immediately to ocean", "" + "\*","``oceanmixed_ice``", "true/false", "active ocean mixed layer calculation", "``.true.`` (if uncoupled)" + "\*", "``wave_spec_type``", "``none``", "no wave data provided, no wave-ice interactions", "" + "", "", "``profile``", "no wave data file is provided, use fixed dummy wave spectrum, for testing", "" + "", "", "``constant``", "wave data file is provided, constant wave spectrum, for testing", "" + "", "", "``random``", "wave data file is provided, wave spectrum generated using random number", "" + "\*","``restore_ocn``", "true/false", "restore sst to data", "" + "\*","``trestore``", "integer", "sst restoring time scale (days)", "" + "","``restore_ice``", "true/false", "restore ice state along lateral boundaries", "" + "","``nfreq``", "25", "number of frequencies in ocean surface wave spectral forcing", "" + "\*","``atm_data_type``", "``default``", "constant values defined in the code", "" + "","", "``LYq``", "COREII Large-Yeager (AOMIP) forcing data", ":cite:`Large09`" + "","", "``JRA55_gx1``", "JRA55 forcing data for gx1 grid :cite:`Tsujino18`", "" + "","", "``JRA55_gx3``", "JRA55 forcing data for gx3 grid :cite:`Tsujino18`", "" + "","", "``monthly``", "monthly forcing data", "" + "","", "``ncar``", "NCAR bulk forcing data", "" + "","", "``box2001``", "forcing data for :cite:`Hunke01` box problem", "" + "","", "``oned``", "column forcing data", "" + "","", "``hycom``", "HYCOM atm forcing data in netcdf format", "" + "\*","``ocn_data_type``", "``default``", "constant values defined in the code", "" + "","", "``clim``", "climatological data", "" + "","", "``ncar``", "POP ocean forcing data", "" + "","", "``hycom``", "HYCOM ocean forcing data in netcdf format", "Constant initial forcing" + "","``bgc_data_type``", "``default``", "constant values defined in the code", "" + "","", "``clim``", "climatological data", "" + "","", "``ncar``", "POP ocean forcing data", "" + "","", "``hycom``", "HYCOM ocean forcing data in netcdf format", "Constant initial forcing" + "","``fe_data_type``", "``default``", "default forcing value for iron", "" + "","", "``clim``", "iron forcing from ocean climatology", "" + "","``ice_data_type``", "string", "ice initialization for special tests", "``default``" + "","", "``default``", "no special initialization", "" + "","", "``box2001``", "initialize ice concentration for :ref:`box2001` test (:cite:`Hunke01`)", "" + "","", "``boxslotcyl``", "initialize ice concentration and velocity for :ref:`boxslotcyl` test (:cite:`Zalesak79`)", "" + "","``atm_data_format``", "``nc``", "read  atmo forcing files", "" + "","", "``bin``", "read direct access, binary files", "" + "","``ocn_data_format``", "``nc``", "read  ocean forcing files", "" + "","", "``bin``", "read direct access, binary files", "" + "\*","``oceanmixed_file``", "filename", "data file containing ocean forcing data", "" + "\*","``wave_spec_file``", "filename", "data file containing wave spectrum forcing data", "" + "","``atm_data_dir``", "path/", "path to atmospheric forcing data directory", "" + "","``ocn_data_dir``", "path/", "path to oceanic forcing data directory", "" + "","``bgc_data_dir``", "path/", "path to oceanic forcing data directory", "" + "","", "", "", "" + "","*zbgc_nml*", "", "", "" + "","", "", "**Biogeochemistry**", "More information about the BGC tuning can be found in the `Icepack Documentation `_." + "\*","``tr_brine``", "true/false", "brine height tracer", "" + "\*","``tr_zaero``", "true/false", "vertical aerosol tracers", "" + "\*","``modal_aero``", "true/false", "modal aersols", "" + "","``restore_bgc``", "true/false", "restore bgc to data", "" + "","``solve_zsal``", "true/false", "update salinity tracer profile", "" + "\*","``skl_bgc``", "true/false", "biogeochemistry", "" + "","``bgc_flux_type``", "``Jin2006``", "ice–ocean flux velocity of :cite:`Jin06`", "" + "","", "``constant``", "constant ice–ocean flux velocity", "" + "","``restart_bgc``", "true/false", "restart tracer values from file", "" + "","``tr_bgc_C_sk``", "true/false", "algal carbon tracer", "" + "","``tr_bgc_chl_sk``", "true/false", "algal chlorophyll tracer", "" + "","``tr_bgc_Am_sk``", "true/false", "ammonium tracer", "" + "","``tr_bgc_Sil_sk``", "true/false", "silicate tracer", "" + "","``tr_bgc_DMSPp_sk``", "true/false", "particulate DMSP tracer", "" + "","``tr_bgc_DMSPd_sk``", "true/false", "dissolved DMSP tracer", "" + "","``tr_bgc_DMS_sk``", "true/false", "DMS tracer", "" + "","``phi_snow``", "real", "snow porosity for brine height tracer", "" + "","", "", "", "" + "","*icefields_nml*", "", "", "" + "","", "", "*History Fields*", "" + "","``f_``", "string", "frequency units for writing ```` to history", "" + "","", "``y``", "write history every ``histfreq_n`` years", "" + "","", "``m``", "write history every ``histfreq_n`` months", "" + "","", "``d``", "write history every ``histfreq_n`` days", "" + "","", "``h``", "write history every ``histfreq_n`` hours", "" + "","", "``1``", "write history every time step", "" + "","", "``x``", "do not write ```` to history", "" + "","", "``md``", "*e.g.,* write both monthly and daily files", "" + "","``f__ai``", "", "grid cell average of ```` (:math:`\times a_i`)", "" - "", "", "", "" - "``f_``", "``d``", "write field var every ``histfreq_n`` days", "" - "", "``h``", "write field var every ``histfreq_n`` hours", "" - "", "``m``", "write field var every ``histfreq_n`` months", "" - "", "``x``", "do not write var to history", "" - "", "``y``", "write field var every ``histfreq_n`` years", "" - "", "``1``", "write field var every time step", "" - "", "``md``", "*e.g.,* write both monthly and daily files", "" - "``f__ai``", "``d``", "write field cell average var every ``histfreq_n`` days", "" - "", "``h``", "write field cell average var every ``histfreq_n`` hours", "" - "", "``m``", "write field cell average var every ``histfreq_n`` months", "" - "", "``x``", "do not write cell average var to history", "" - "", "``y``", "write field cell average var every ``histfreq_n`` years", "" - "", "``1``", "write field cell average var every time step", "" - "", "``md``", "*e.g.,* write both monthly and daily files", "" - "", "", "", "" diff --git a/doc/source/user_guide/ug_testing.rst b/doc/source/user_guide/ug_testing.rst index e382eba17..52621d612 100644 --- a/doc/source/user_guide/ug_testing.rst +++ b/doc/source/user_guide/ug_testing.rst @@ -8,7 +8,7 @@ Testing CICE This section documents primarily how to use the CICE scripts to carry out CICE testing. Exactly what to test is a separate question and depends on the kinds of code changes being made. Prior to merging -changes to the CICE Consortium main, changes will be reviewed and +changes to the CICE Consortium master, changes will be reviewed and developers will need to provide a summary of the tests carried out. There is a base suite of tests provided by default with CICE and this @@ -23,8 +23,7 @@ The testing scripts support several features - Ability to compare results to prior baselines to verify bit-for-bit (``--bcmp``) - Ability to define where baseline tests are stored (``--bdir``) - Ability to compare tests against each other (``--diff``) - - Ability to set or overide the batch account number (``--acct``) and queue name (``--queue``) - - Ability to control how test suites execute (``--setup-only``, ``--setup-build``, ``--setup-build-run``, ``--setup-build-submit``) + - Ability to set account number (``--acct``), which is otherwise not set and may result in tests not being submitted .. _indtests: @@ -57,8 +56,6 @@ For individual tests, the following command line options can be set ``--set`` SET1,SET2,SET3 (see :ref:`case_options`) -``--ignore-user-set`` (see :ref:`case_options`) - ``--acct`` ACCOUNT (see :ref:`case_options`) ``--grid`` GRID (see :ref:`case_options`) @@ -229,10 +226,8 @@ boundary around the entire domain. It includes the following namelist modificat - ``dxrect``: ``16.e5`` cm - ``dyrect``: ``16.e5`` cm - ``ktherm``: ``-1`` (disables thermodynamics) -- ``coriolis``: ``constant`` (``f=1.46e-4`` s\ :math:`^{-1}`) -- ``ice_data_type`` : ``box2001`` (special initial ice mask) -- ``ice_data_conc`` : ``p5`` -- ``ice_data_dist`` : ``box2001`` (special ice concentration initialization) +- ``coriolis``: ``zero`` (zero coriolis force) +- ``ice_data_type`` : ``box2001`` (special ice concentration initialization) - ``atm_data_type`` : ``box2001`` (special atmospheric and ocean forcing) Ocean stresses are computed as in :cite:`Hunke01` where they are circular and centered @@ -260,9 +255,7 @@ boundary around the entire domain. It includes the following namelist modificat - ``ktherm``: ``-1`` (disables thermodynamics) - ``kridge``: ``-1`` (disables ridging) - ``kdyn``: ``-1`` (disables dynamics) -- ``ice_data_type`` : ``boxslotcyl`` (special initial ice mask) -- ``ice_data_conc`` : ``c1`` -- ``ice_data_dist`` : ``uniform`` +- ``ice_data_type`` : ``boxslotcyl`` (special ice concentration and velocity initialization) Dynamics is disabled because we directly impose a constant ice velocity. The ice velocity field is circular and centered in the square domain, and such that the slotted cylinder makes a complete revolution with a period :math:`T=` 12 days : @@ -302,6 +295,15 @@ results.csh script in the testsuite.[testid]:: cd testsuite.[testid] ./results.csh +To report the test results, as is required for Pull Requests to be accepted into +the master the CICE Consortium code see :ref:`testreporting`. + +If using the ``--tdir`` option, that directory must not exist before the script is run. The tdir directory will be +created by the script and it will be populated by all tests as well as scripts that support the +test suite:: + + ./cice.setup --suite base_suite --mach wolf --env gnu --testid myid --tdir /scratch/$user/testsuite.myid + Multiple suites are supported on the command line as comma separated arguments:: ./cice.setup --suite base_suite,decomp_suite --mach wolf --env gnu --testid myid @@ -310,52 +312,13 @@ If a user adds ``--set`` to the suite, all tests in that suite will add that opt ./cice.setup --suite base_suite,decomp_suite --mach wolf --env gnu --testid myid -s debug -The option settings defined at the command line have precedence over the test suite +The option settings defined in the suite have precendent over the command line values if there are conflicts. The predefined test suites are defined under **configuration/scripts/tests** and -the files defining the suites have a suffix of .ts in that directory. Some of the -available tests suites are - -``quick_suite`` - consists of a handful of basic CICE tests - -``base_suite`` - consists of a much large suite of tests covering much of the CICE functionality - -``decomp_suite`` - checks that different decompositions and pe counts produce bit-for-bit results - -``omp_suite`` - checks that OpenMP single thread and multi-thread cases are bit-for-bit identical - -``io_suite`` - tests the various IO options including binary, netcdf, and pio. PIO should be installed locally and accessible to the CICE build system to make full use of this suite. - -``perf_suite`` - runs a series of tests to evaluate model scaling and performance - -``reprosum_suite`` - verifies that CICE log files are bit-for-bit with different decompositions and pe counts when the bfbflag is set to reprosum - -``gridsys_suite`` - tests B, C, and CD grid_ice configurations - -``prod_suite`` - consists of a handful of tests running 5 to 10 model years and includes some QC testing. These tests will be relatively expensive and take more time compared to other suites. - -``unittest_suite`` - runs unit tests in the CICE repository - -``travis_suite`` - consists of a small suite of tests suitable for running on low pe counts. This is the suite used with Github Actions for CI in the workflow. - -``first_suite`` - this small suite of tests is redundant with tests in other suites. It runs several of the critical baseline tests that other test compare to. It can improve testing turnaround if listed first in a series of test suites. - -When running multiple suites on the command line (i.e. ``--suite first_suite,base_suite,omp_suite``) the suites will be run in the order defined by the user and redundant tests across multiple suites will be created and executed only once. - -The format for the test suite file is relatively simple. +the files defining the suites +have a suffix of .ts in that directory. The format for the test suite file +is relatively simple. It is a text file with white space delimited columns that define a handful of values in a specific order. The first column is the test name, the second the grid, the third the pe count, @@ -371,6 +334,7 @@ Lines that begin with # or are blank are ignored. For example, smoke col 1x1 debug,run1year restart col 1x1 debug restart col 1x1 diag1 + restart col 1x1 pondcesm restart col 1x1 pondlvl restart col 1x1 pondtopo @@ -416,8 +380,8 @@ following options are valid for suites, ``--report`` This is only used by ``--suite`` and when set, invokes a script that sends the test results to the results page when all tests are complete. Please see :ref:`testreporting` for more information. -``--coverage`` - When invoked, code coverage diagnostics are generated. This will modify the build and reduce optimization and generate coverage reports using lcov or codecov tools. General use is not recommended, this is mainly used as a diagnostic to periodically assess test coverage. Please see :ref:`codecoverage` for more information. +``--codecov`` + When invoked, code coverage diagnostics are generated. This will modify the build and reduce optimization. The results will be uploaded to the **codecov.io** website via the **report_codecov.csh** script. General use is not recommended, this is mainly used as a diagnostic to periodically assess test coverage. Please see :ref:`codecoverage` for more information. ``--setup-only`` This is only used by ``--suite`` and when set, just creates the suite testcases. It does not build or submit them to run. By default, the suites do ``--setup-build-submit``. @@ -445,26 +409,8 @@ The *cice.setup** options ``--setup-only``, ``--setup-build``, and ``--setup-bui which means by default the test suite builds and submits the jobs. By defining other values for those environment variables, users can control the suite script. When using **suite.submit** manually, the string ``true`` (all lowercase) is the only string that will turn on a feature, and both SUITE_RUN and SUITE_SUBMIT cannot be true at the same time. -By leveraging the **cice.setup** command line arguments ``--setup-only``, ``--setup-build``, and ``--setup-build-run`` as well as the environment variables SUITE_BUILD, SUITE_RUN, and SUITE_SUBMIT, users can run **cice.setup** and **suite.submit** in various combinations to quickly setup, setup and build, submit, resubmit, run interactively, or rebuild and resubmit full testsuites quickly and easily. See :ref:`examplesuites` for an example. - -The script **create_fails.csh** will process the output from results.csh and generate a new -test suite file, **fails.ts**, from the failed tests. -**fails.ts** can then be edited and passed into ``cice.setup --suite fails.ts ...`` to rerun -subsets of failed tests to more efficiently move thru the development, testing, and -validation process. However, a full test suite should be run on the final development -version of the code. - -To report the test results, as is required for Pull Requests to be accepted into -the main the CICE Consortium code see :ref:`testreporting`. - -If using the ``--tdir`` option, that directory must not exist before the script is run. The tdir directory will be -created by the script and it will be populated by all tests as well as scripts that support the -test suite:: - - ./cice.setup --suite base_suite --mach wolf --env gnu --testid myid --tdir /scratch/$user/testsuite.myid - +By leveraging the **cice.setup** command line arguments ``--setup-only``, ``--setup-build``, and ``--setup-build-run`` as well as the environment variables SUITE_BUILD, SUITE_RUN, and SUITE_SUBMIT, users can run **cice.setup** and **suite.submit** in various combinations to quickly setup, setup and build, submit, resubmit, run interactively, or rebuild and resubmit full testsuites quickly and easily. See below for an example. -.. _examplesuites: Test Suite Examples ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -513,7 +459,7 @@ Test Suite Examples ./results.csh If there are conflicts between the ``--set`` options in the suite and on the command line, - the command line options will take precedence. + the suite will take precedent. 5) **Multiple test suites from a single command line** @@ -577,8 +523,8 @@ Test Suite Examples This will compare to results saved in the baseline [bdir] directory under the subdirectory cice.v01a. With the ``--bcmp`` option, the results will be tested against prior baselines to verify bit-for-bit, which is an important step prior - to approval of many (not all, see :ref:`validation`) Pull Requests to incorporate code into - the CICE Consortium main branch. You can use other regression options as well. + to approval of many (not all, see :ref:`compliance`) Pull Requests to incorporate code into + the CICE Consortium master code. You can use other regression options as well. (``--bdir`` and ``--bgen``) 10) **Basic test suite, use of default string in regression testing** @@ -603,7 +549,7 @@ Test Suite Examples set mydate = `date -u "+%Y%m%d"` git clone https://github.com/myfork/cice cice.$mydate --recursive cd cice.$mydate - ./cice.setup --suite base_suite --mach conrad --env cray,gnu,intel,pgi --testid $mydate --bcmp default --bgen default --bdir /tmp/work/user/CICE_BASELINES_MAIN + ./cice.setup --suite base_suite --mach conrad --env cray,gnu,intel,pgi --testid $mydate --bcmp default --bgen default --bdir /tmp/work/user/CICE_BASELINES_MASTER When this is invoked, a new set of baselines will be generated and compared to the prior results each time without having to change the arguments. @@ -677,78 +623,6 @@ Test Suite Examples The setenv syntax is for csh/tcsh. In bash, the syntax would be SUITE_BUILD=true. -.. _unittesting: - -Unit Testing ---------------- - -Unit testing is supported in the CICE scripts. Unit tests are implemented -via a distinct top level driver that tests CICE model features explicitly. -These drivers can be found in **cicecore/drivers/unittest/**. In addition, -there are some script files that also support the unit testing. - -The unit tests build and run very much like the standard CICE model. -A case is created and model output is saved to the case logs directory. -Unit tests can be run as part of a test suite and the output is -compared against an earlier set of output using a simple diff of the -log files. - -For example, to run the existing calendar unit test as a case, - -.. code-block:: bash - - ./cice.setup -m onyx -e intel --case calchk01 -p 1x1 -s calchk - cd calchk01 - ./cice.build - ./cice.submit - -Or to run the existing calendar unit test as a test, - -.. code-block:: bash - - ./cice.setup -m onyx -e intel --test unittest -p 1x1 --testid cc01 -s calchk --bgen cice.cc01 - cd onyx_intel_unittest_gx3_1x1_calchk.cc01/ - ./cice.build - ./cice.submit - -To create a new unit test, add a new driver in **cicecore/driver/unittest**. -The directory name should be the name of the test. -Then create the appropriate set_nml or set_env files for the new unittest name -in **configuration/scripts/options**. In particular, **ICE_DRVOPT** and -**ICE_TARGET** need to be defined in a set_env file. Finally, edit -**configuration/scripts/Makefile** and create a target for the unit test. -The unit tests calchk or helloworld can be used as examples. - -The following strings should be written to the log file at the end of the unit test run. -The string "COMPLETED SUCCESSFULLY" will indicate the run ran to completion. The string -"TEST COMPLETED SUCCESSFULLY" will indicate all the unit testing passed during the run. -The unit test log file output is compared as part of regression testing. The string -"RunningUnitTest" indicates the start of the output to compare. -That string should be written to the log file at the start of the unit test model output. -These strings will be queried by the testing scripts and will impact the test reporting. -See other unit tests for examples about how these strings could be written. - -The following are brief descriptions of some of the current unit tests, - - - **bcstchk** is a unit test that exercises the methods in ice_broadcast.F90. This test does not - depend on the CICE grid to carry out the testing. By testing with a serial and mpi configuration, - both sets of software are tested independently and correctness is verified. - - **calchk** is a unit test that exercises the CICE calendar over 100,000 years and verifies correctness. - This test does not depend on the CICE initialization. - - **gridavgchk** is a unit test that exercises the CICE grid_average_X2Y methods and verifies results. - - **halochk** is a unit test that exercises the CICE haloUpdate methods and verifies results. - - **helloworld** is a simple test that writes out helloworld and uses no CICE infrastructure. - This tests exists to demonstrate how to build a unit test by specifying the object files directly - in the Makefile - - **optargs** is a unit test that tests passing optional arguments down a calling tree and verifying - that the optional attribute is preserved correctly. - - **opticep** is a cice test that turns off the icepack optional arguments passed into icepack. This - can only be run with a subset of CICE/Icepack cases to verify the optional arguments are working correctly. - - **sumchk** is a unit test that exercises the methods in ice_global_reductions.F90. This test requires - that a CICE grid and decomposition be initialized, so CICE_InitMod.F90 is leveraged to initialize - the model prior to running a suite of unit validation tests to verify correctness. - - .. _testreporting: Test Reporting @@ -759,7 +633,7 @@ to the official CICE Consortium Test-Results `wiki page `_. You may need write permission on the wiki. If you are interested in using the wiki, please contact the Consortium. Note that in order for code to be -accepted to the CICE main branch through a Pull Request it is necessary +accepted to the CICE master through a Pull Request it is necessary for the developer to provide proof that their code passes relevant tests. This can be accomplished by posting the full results to the wiki, or by copying the testing summary to the Pull Request comments. @@ -791,73 +665,54 @@ wait for all runs to be complete, and run the results and report_results scripts Code Coverage Testing ------------------------------ -The ``--coverage`` feature in **cice.setup** provides a method to diagnose code coverage. +The ``--codecov`` feature in **cice.setup** provides a method to diagnose code coverage. This argument turns on special compiler flags including reduced optimization and then -invokes the gcov tool. Once runs are complete, either lcov or codecov can be used -to analyze the results. -This option is currently only available with the gnu compiler and on a few systems -with modified Macros files. In the current implementation, when ``--coverage`` is -invoked, the sandbox is copied to a new sandbox called something like cice_lcov_yymmdd-hhmmss. -The source code in the new sandbox is modified slightly to improve coverage statistics -and the full coverage suite is run there. - -At the present time, the ``--coverage`` flag invokes the lcov analysis automatically -by running the **report_lcov.csh** script in the test suite directory. The output -will show up at the `CICE lcov website `__. To -use the tool, you should have write permission for that repository. The lcov tool -should be run on a full multi-suite test suite, and it can -take several hours to process the data once the test runs are complete. A typical -instantiation would be -:: - - ./cice.setup --suite first_suite,base_suite,travis_suite,decomp_suite,reprosum_suite,io_suite,quick_suite --mach cheyenne --env gnu --testid cc01 --coverage - -Alternatively, codecov analysis can be carried out by manually running the **report_codecov.csh** -script from the test suite directory, but there are several ongoing problems with this approach and -it is not generally recommended. A script that summarizes the end-to-end process for codecov -analysis can be found in ..**configuration/scripts/tests/cice_test_codecov.csh**. The codecov -analysis is largely identical to the analysis performed by lcov, codecov just provides a nicer -web experience to view the output. - -This is a special diagnostic test and is not part of the standard model testing. -General use is not recommended, this is mainly used as a diagnostic to periodically -assess test coverage. - -..Because codecov.io does not support git submodule analysis right now, a customized -..repository has to be created to test CICE with Icepack integrated directly. The repository -..https://github.com/apcraig/Test_CICE_Icepack serves as the current default test repository. -..In general, to setup the code coverage test in CICE, the current CICE main has -..to be copied into the Test_CICE_Icepack repository, then the full test suite -..can be run with the gnu compiler with the ``--coverage`` argument. - -..The test suite will run and then a report will be generated and uploaded to -..the `codecov.io site `_ by the -..**report_codecov.csh** script. The env variable CODECOV_TOKEN needs to be defined -..either in the environment or in a file named **~/.codecov_cice_token**. That -..token provides write permission to the Test_CICE_Icepack codecov.io site and is available -..by contacting the Consortium team directly. - -..A script that carries out the end-to-end testing can be found in -..**configuration/scripts/tests/cice_test_codecov.csh** - -..This is a special diagnostic test and does not constitute proper model testing. -..General use is not recommended, this is mainly used as a diagnostic to periodically -..assess test coverage. The interaction with codecov.io is not always robust and -..can be tricky to manage. Some constraints are that the output generated at runtime -..is copied into the directory where compilation took place. That means each -..test should be compiled separately. Tests that invoke multiple runs -..(such as exact restart and the decomp test) will only save coverage information -..for the last run, so some coverage information may be lost. The gcov tool can -..be a little slow to run on large test suites, and the codecov.io bash uploader -..(that runs gcov and uploads the data to codecov.io) is constantly evolving. -..Finally, gcov requires that the diagnostic output be copied into the git sandbox for -..analysis. These constraints are handled by the current scripts, but may change -..in the future. - - -.. _validation: - -Code Validation Test (non bit-for-bit validation) +invokes the gcov tool. +This option is currently only available with the gnu compiler and on a few systems. + +Because codecov.io does not support git submodule analysis right now, a customized +repository has to be created to test CICE with Icepack integrated directly. The repository +https://github.com/apcraig/Test_CICE_Icepack serves as the current default test repository. +In general, to setup the code coverage test in CICE, the current CICE master has +to be copied into the Test_CICE_Icepack repository, then the code coverage tool can +be run on that repository. A sample script to do that would be:: + + git clone https://github.com/cice-consortium/cice cice.master --recursive + + git clone https://github.com/apcraig/test_cice_icepack + cd test_cice_icepack + git rm -r * + cp -p -r ../cice.master/* . + git add . + git commit -m "update to current cice master" + git push origin master + + ./cice.setup --suite first_suite,base_suite,travis_suite,decomp_suite,reprosum_suite,quick_suite -m gordon -e gnu --codecov --testid cc01 + +To use, submit a full test suite using an updated Test_CICE_Icepack version +and the gnu compiler with the ``--codecov`` argument. +The test suite will run and then a report will be generated and uploaded to +the `codecov.io site `_ by the +**report_codecov.csh** script. + +This is a special diagnostic test and does not constitute proper model testing. +General use is not recommended, this is mainly used as a diagnostic to periodically +assess test coverage. The interaction with codecov.io is not always robust and +can be tricky to manage. Some constraints are that the output generated at runtime +is copied into the directory where compilation took place. That means each +test should be compiled separately. Tests that invoke multiple runs +(such as exact restart and the decomp test) will only save coverage information +for the last run, so some coverage information may be lost. The gcov tool can +be a little slow to run on large test suites, and the codecov.io bash uploader +(that runs gcov and uploads the data to codecov.io) is constantly evolving. +Finally, gcov requires that the diagnostic output be copied into the git sandbox for +analysis. These constraints are handled by the current scripts, but may change +in the future. + + +.. _compliance: + +Code Compliance Test (non bit-for-bit validation) ---------------------------------------------------- A core tenet of CICE dycore and CICE innovations is that they must not change @@ -982,7 +837,7 @@ autocorrelation :math:`r_1`. .. _quadratic: -Quadratic Skill Validation Test +Quadratic Skill Compliance Test ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In addition to the two-stage test of mean sea ice thickness, we also @@ -1066,12 +921,12 @@ hemispheres, and must exceed a critical value nominally set to test and the Two-Stage test described in the previous section are provided in :cite:`Hunke18`. -.. _CodeValidation: +.. _CodeCompliance: -Code Validation Testing Procedure +Code Compliance Testing Procedure ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The CICE code validation (QC) test is performed by running a python script +The CICE code compliance test is performed by running a python script (**configurations/scripts/tests/QC/cice.t-test.py**). In order to run the script, the following requirements must be met: @@ -1081,11 +936,7 @@ In order to run the script, the following requirements must be met: * matplotlib Python package (optional) * basemap Python package (optional) -QC testing should be carried out using configurations (ie. namelist settings) that -exercise the active code modifications. Multiple configurations may need to be tested -in some cases. Developers can contact the Consortium for guidance or if there are questions. - -In order to generate the files necessary for the validation test, test cases should be +In order to generate the files necessary for the compliance test, test cases should be created with the ``qc`` option (i.e., ``--set qc``) when running cice.setup. This option results in daily, non-averaged history files being written for a 5 year simulation. @@ -1096,16 +947,8 @@ To install the necessary Python packages, the ``pip`` Python utility can be used pip install --user netCDF4 pip install --user numpy pip install --user matplotlib - pip install --user cartopy - -You can also setup a conda env with the same utitities - -.. code-block:: bash - conda env create -f configuration/scripts/tests/qctest.yml - conda activate qctest - -To run the validation test, setup a baseline run with the original baseline model and then +To run the compliance test, setup a baseline run with the original baseline model and then a perturbation run based on recent model changes. Use ``--set qc`` in both runs in addition to other settings needed. Then use the QC script to compare history output, @@ -1148,7 +991,6 @@ Below is an example of a step-by-step procedure for testing a code change that m # Run a full regression test to verify bit-for-bit # Create a baseline dataset (only necessary if no baseline exists on the system) - # if you want to replace an existing baseline, you should first delete the directory cice.my.baseline in ${ICE_BASELINE}. # git clone the baseline code ./cice.setup -m onyx -e intel --suite base_suite --testid base0 --bgen cice.my.baseline @@ -1175,7 +1017,6 @@ If the regression comparisons fail, then you may want to run the QC test, # Create a QC baseline # From the baseline sandbox - # Generate the test case(s) using options or namelist changes to activate new code modifications ./cice.setup -m onyx -e intel --test smoke -g gx1 -p 44x1 --testid qc_base -s qc,medium cd onyx_intel_smoke_gx1_44x1_medium_qc.qc_base @@ -1184,10 +1025,9 @@ If the regression comparisons fail, then you may want to run the QC test, ./cice.submit # Create the t-test testing data - # From the updated sandbox - # Generate the same test case(s) as the baseline using options or namelist changes to activate new code modifications + # From the update sandbox - ./cice.setup -m onyx -e intel --test smoke -g gx1 -p 44x1 --testid qc_test -s qc,medium + ./cice.setup -m onyx -e intel --test smoke -g gx1 -p 44x1 -testid qc_test -s qc,medium cd onyx_intel_smoke_gx1_44x1_medium_qc.qc_test # modify ice_in to activate the namelist options that were determined above ./cice.build @@ -1196,8 +1036,7 @@ If the regression comparisons fail, then you may want to run the QC test, # Wait for runs to finish # Perform the QC test - # From the updated sandbox - cp configuration/scripts/tests/QC/cice.t-test.py . + cp configuration/scripts/tests/QC/cice.t-test.py ./cice.t-test.py /p/work/turner/CICE_RUNS/onyx_intel_smoke_gx1_44x1_medium_qc.qc_base \ /p/work/turner/CICE_RUNS/onyx_intel_smoke_gx1_44x1_medium_qc.qc_test @@ -1209,3 +1048,4 @@ If the regression comparisons fail, then you may want to run the QC test, INFO:__main__: INFO:__main__:Quality Control Test PASSED +