From 1bf6e8dfcef581c9cf5fb2cbacb4f54f10978caf Mon Sep 17 00:00:00 2001 From: Elizabeth Hunke Date: Wed, 8 Apr 2020 11:38:15 -0600 Subject: [PATCH 01/19] Isotopes for CICE (#423) * initial changes to cice driver for isotopes * add isotope fluxes * forcing and restarts for isotopes * interim commit for isotopes * more isotopes code including ice_step * diagnostics and history for isotopes * update both RunMods * isotope testing option * fix diags and ice_in; add isotope tests * changing badger acct * fix isotope indexing * initialize trcrn(isotopes) * fix isotope restarts * Add isotope documentation * updating copyright to 2020 * update icepack version * update non standalone drivers for isotope changes Co-authored-by: apcraig Co-authored-by: David Bailey --- LICENSE.pdf | Bin 59402 -> 92397 bytes .../cicedynB/analysis/ice_diagnostics.F90 | 124 +++- .../cicedynB/analysis/ice_history_bgc.F90 | 119 ++- .../dynamics/ice_transport_driver.F90 | 11 +- cicecore/cicedynB/general/ice_flux.F90 | 37 +- cicecore/cicedynB/general/ice_flux_bgc.F90 | 31 +- cicecore/cicedynB/general/ice_forcing_bgc.F90 | 18 +- cicecore/cicedynB/general/ice_init.F90 | 55 +- cicecore/cicedynB/general/ice_step_mod.F90 | 70 +- .../io/io_binary/ice_restart.F90 | 56 +- .../io/io_netcdf/ice_restart.F90 | 18 +- .../infrastructure/io/io_pio/ice_restart.F90 | 14 +- .../infrastructure/io/io_pio2/ice_restart.F90 | 14 +- cicecore/drivers/mct/cesm1/CICE_InitMod.F90 | 37 +- cicecore/drivers/mct/cesm1/CICE_RunMod.F90 | 31 +- .../drivers/mct/cesm1/CICE_RunMod.F90_debug | 696 ------------------ cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90 | 42 +- cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90 | 31 +- cicecore/drivers/nuopc/dmi/CICE_InitMod.F90 | 46 +- cicecore/drivers/nuopc/dmi/CICE_RunMod.F90 | 32 +- .../drivers/nuopc/dmi/CICE_RunMod.F90_debug | 686 ----------------- .../drivers/standalone/cice/CICE_InitMod.F90 | 37 +- .../drivers/standalone/cice/CICE_RunMod.F90 | 31 +- .../standalone/cice/CICE_RunMod.F90_debug | 40 +- cicecore/shared/ice_domain_size.F90 | 7 +- cicecore/shared/ice_fileunits.F90 | 6 + cicecore/shared/ice_init_column.F90 | 39 +- cicecore/shared/ice_restart_column.F90 | 85 +++ configuration/scripts/ice_in | 8 +- .../scripts/machines/env.badger_intel | 3 +- configuration/scripts/options/set_nml.isotope | 2 + configuration/scripts/tests/base_suite.ts | 3 + doc/source/developer_guide/dg_other.rst | 4 +- doc/source/science_guide/sg_tracers.rst | 4 +- doc/source/user_guide/ug_case_settings.rst | 3 + icepack | 2 +- 36 files changed, 858 insertions(+), 1584 deletions(-) delete mode 100644 cicecore/drivers/mct/cesm1/CICE_RunMod.F90_debug delete mode 100644 cicecore/drivers/nuopc/dmi/CICE_RunMod.F90_debug create mode 100644 configuration/scripts/options/set_nml.isotope diff --git a/LICENSE.pdf b/LICENSE.pdf index 5be71376b88f9119eb9f3e5df50222734d8d0185..da37344cf0234bb32481f59a2268ef9ae91516cd 100644 GIT binary patch delta 33153 zcmcG%2SAQ(+W>4OJ2Da>kwW9%BMmA^N)io8+S+?*TxPN|LPbfU%t$I!GE%9?jFi$w zQ)y`EKaT6ZZ;$7BpXYu5@BQEZc|X^6Ugtc{V;{$Pc7F$6jBI%+baUKif+|UobhC1t zsI08GV#PXLr8Twzer}#NUXlztw5(Uu@U*q`c5rjmwDh)>)l{NUs2nPl#--9JEGl)= zVqUwOr>rpyTC6A-ExTAz&&}r77#fAbfd6qBEGAc;!jhp-WELx~^K`TE8EI|n8S%bm z;b_GT4&KhT5tnM_5vr;aZCz~;DB2&uX}Gz1+q!xKTr3hUJzE<8#V{^ ztDv6BB*^(!8B!&wlpm28JWus>@< zTW>SPb(&g=8*Kf(&7pEbfV(X~X>a?-CaE|Lp9Ffg-j;-orMIOdgGtVaUA_4GA;)S! zqqCd+AHzv__`}sLy=)OyMFV5)6*>k>H#oT1dabqfTkqy#>AKEPZ-b(yt(P?**V5G+ z`vEpdJSeVowRW>{aJ5%lZDUKgdOLUr$ZIPa`dE1*xVSDwaf91NR|n{2E6L#SHj8aI z%WtqC(0o{QZC&lXw@K3JOxmxRO!Rbl7{GnvHdR%hMT9YBvXMUZ%qLrbEyhc7M(?9 z$w>l#6C6bNqGVd)nA3t=H7zuLoZ$Qro<}-IWv-{rvnC z{OAg9p7x4VE|;rFp()a6^3X%xE5Oy;(qG=yYXNT(!8}L~PX~7tFiD)((#p+;@K%wM z!j*pg$KRQY`>&N;y%fk@DpEfdJ3k9%2Wf-DF>KI$p7OEuv z<*8J88g~Pgu0&xeftFEL{7bJtu=B@wH_r`jZqBNxhkonNul>sa&`l0@0sIAN6nP2* z{%-??tHc136R4t;C=}i-zjgiVBzzwJhiU#i%kO=En+K@yOXDh%>?J8FigZ`T7E(ik zf>ezttC1p<75`NC+blNLN_K9ZE|%V^mhSG(4%Vc?#@@<`e>DBMKZv-qEq_5ipOK8c z!rA-JwFnDxrn8s>a=enWrK`P)l)t=1vwSS(H1nIA< zBNg@Zlr-I}eUQOcYpVMAIM^t$ELj{oj+K=>)y|43Ph&EySs{l9(@l7DRZe?9ka^Znx@#BZJc zKNtUTm4BZ3zgYjjSmnQ1|9`s5KdnDb^1s;sKTY-vI4{$~Au z?fhTY2v+&$3H}%B|L0Zy7wi9jS>^xz`u}c~-y$6d#8jmGAdJCymmdi6BVRJg+-VhEx>9K#s*LQatRr@MTyH#d~ z{7|avbL;IYQWH*<9{B$5#>gkzCQmwfUTRifyYzuj-6|&4$Jq&g`srAG9ryKK$h9LyN)0T#D6+eUH1`c9(P)L>0!X%+mky;_PSR zsTT4bykzlO$zJz%W52IoHmW7(%&BX7c<|Jo<61vUMOO#sq-l<9Dt|D0 zHe+CP=IFVh)6Nc)a6clG*p)tFU9N|U`gL(HE-_V;rY8BiOKr68rMSMq$@g}=ym@e~ z#E6XDi;jMtubFT@?Aeve^>oo?Z%+iL?t8FyLQZE(jk!wqPsX7Gdl^d8t@X|=A3gkn z6;<^9&wxm}^2^7PI|GObBiBBr>^bcIVPBc_UH^Sk?V@}4GtH#BgFjzDcQbPRfZ+l!bNuVfIz z+h$Xom5w^r4Q7Z{1^Z38KTrC{vH`K<1(dPOzU3V)H6`5@rVss#Cd8@-t)OO7b$g#t zWa>sfo4S2*STf<@e9(=0^Tv+TrnV8PYUxxvdDRNxL-(Vb1LDOx$E2S&>YjVD$d_Ix zXJ?&%Es?3HrFo*LIAdzd;?l_3~$n#MG( z-4=iKroBh|5uemyGrFI*UaJ(LpYiK9NY)hqDQVwiCLo8;^G%(fN>F zSb5Yr;l*0pWBCi8zCN$(sY7FKDwG;DS@v0VXp604-tpL=3gO$&FBVU&SRTCn=#nNy z#q#>&(|Sa1uS=1<9e49SkWtmoaiWDIy`=Iri|5x`HqP;=qY)fvMsdlk+%YS67 zoaa=^ZCNZNwPE>zuq+dTq7+{$vS*{rWaXu|Bx5DntEbuz9?o*@FuiYR@o2E)P1&n~ zo#P*gMHOCs_LGyfNcgLn3}#Ms^ZcGWxoMa%p; zob2vQse3=Xq1*5COh-$ffcv?<=Fd4NWNLcDnSQPffrblSo1}^FmayDOOeom7Y}tX^ zSB{Su>Kys4a9L({a`l0UHp`u|BLmOAJ@M+tsHU|^Z?=s;*C%OqYP`3i?wDx<^?9Ci zE`43+Z2YNfXcf zr}60A47UKK_h*(I{&{^+OuX~1hwWWAf+{;}F6ZGKqid%_yoS+)tHWG}eQaAZq}e4q zOP|urW%v)~RoCXLUa@7I6Aht!bc`^6=P|`MsqkzDr_$!|8M{znJGrehV>ao{ao_5~ zs3=sOlu=lCy>fY}iGSIrX?N5c?#Mg)#tgd{{La(;%In+GQ{IWrk}IpO>gpaC>HEBa z2v4)JbC;MJ#uop%I%I6Z>zG%?172e?~>I9Z`bNYy>&M+`=qoqlqgFcf4Vf+CEuy7TQ=MELUJx^N#Ex2 zJ&|Isj2<4WmGD?m|5T!DLcOYsl6IExN^2Vn-|^Z96o%icG?l%SrhO@MX3NIMb(5W^ zo|x($=y1{N%`ovMySCym>+;!Qcjro!w6penHWR;8*5tkF!i%(>$2-D|hUqzG^j-1_ z?)dsF>KV~KdhgpATdvy$C*94L-+wOn@N=)dd&;BUN-wuah?)2NXkW*v6>O=k@X$ zm0`!G3AvY!F(1(;aw}`8)%1w`BYGFConB6SuNPq;+_yIAn9MhWm-7d=8hghSOncP* zHm^2;Hhk-mqT46Lf5g}i8%$MI-8b6$b?S-o$~}yUdhxeviCfw_$-x0LQYQ~vF)>A3 z%ST7CR_gAIQ4fw^&>bt^dT^TL#fvYV6{~8#@|F``(Gk}7GJvtmyEd)A?WDxVNAYL! z#)}6nc{Qpm@R4u0ave=xYt8939XC&iNHa`kE?!klJ(_9%$ofDYGwV))7DKUh;{+9x z5zSM4l8&FS$>3hRAwuX=KF@TW;x+3>XS|Syf2(!3(v6X2bjR-&|Z2xGrJD5yQA?np+i^mJgjc8#FXrE7Z@VI{b*rUbLQd`8L@9p`p z!G<&Z)4Y{MPA@|y#RVml9n1Hbv{1o^Vx=N%QF>(h{6Jz}Q;hgWmgyXc9p|D#&#f!#Z?E6T819%na9BTbvs0syuj%`% zy2LvBAMfLLXm^%X%yfFW+Eq6{c4yri$J7~d3kvMF)hv$}uXxorv+i_Daic6J#Y_FV zuvFV6=KZ`kQ46Ngyl<(@cdEGWp6z0Bv%JhZ`FsjB!!F|N*ae?kCrnLLFsjqYO8vf~ zL?myEcfc;=9nawvSoq?Wu}Dm$!~Mq8#Fu94{ICJbXdI%eUI1X0;%tuKFKSyVlsXt7rMzr?6J9H)_BNpcBt&> z(RIS?M%|?nXU&_x$=1#0E}W;u2{OO8pulzY7h#zR;?uTGoFqKgoB73V(J0fKhD~?c zI=5Rjlzh9pXwSXRjw03xkGbLpZ5|O}=M6T`I&G{VPq{-3Zcpla7&7}q#oOqQI5F)tZI@Uf#AYt6lBfB$;?H1LsGpH8;4eTCJ%ENoqJ;AkP*QHH{^y6bgkrJrLy4 z+&m?jyi*jxxdRNv;{`l^pz)3k$g>S&Gm06T4a793!NCX()?pB4bUIy1x%cMNG8pDet|W^$f<-mMX-KePZ{)67TuB1= zM1BB>SVm9TqCGbGtevW5-ov2nkWYz~PEvIyJf0Cc=T9Of^$5icB$BP4} z!B7$VNG%#1!2$AdIVzoM#-IT8=+K|egN;fD;E?1@APd_SkvJibO==JNsYGY82EenE;5V<&``20}su zDItZ84(J53(4n0Mq@lrJHVPhtNunPY$FaEJuSH~;r!hfY;2UTK49KQ{qF~d37f_8rALM8l%tb~52BZVy zk^O=3KtzG7C`=lhiL%Y<9Hchv54nm1>H@%LApwvzK_r=fu)GXPf9 zzYJIgm&83XfaT~+*gFN-3BiLh!v7nE1(g29UVp`-fG~f36MwBB`4*7=k8j{%wE{TrA3#uWshhbI(&8u%Bk5CDlPoxuWi1AL8j4AyU& zn2!U=*j_7GJwBvVGbx}HW)J+s5JaWfLIK=ITOiE;cXcBfM@@3G3>+!_7mti zvNP}k6Zn?g3Ggkc9gyYF(m{VFs2Q>i)C?Q61uiIW zMqncomF+@su-@MK=RdLme#6f{lWFFgz)(`a)4{1o<%9@@eK1IgM&tsxFfED{7`9T z$W@3>77!cjNTo%GD>EdbVITu^K9*TTp1!FB@A5zrAd8u&B}HY^E>6%oh)5LjG58YmZ1PH}(GkAX|`)h81? zJto}sVZwwoAOxwfaUnL>9I3{}1zcS0vA{ja+~so?`p0!;$^H^3q`a9(ovq{gIyX9-G)Ag>Xzf#z)Rg1|bViXoBB z0Cx%;40AS+0bMiz6vT-QsAU32u-P;->NVuiy6jR^hVViGVUiAQkCfFaRg zqjAl-upKTMCpySKmja#}uK}c!1Oqy-p&m3HEXt*D1?}L#!$9=-U{bir2mioqV;^ue z5bX#)*njv2@X2=Y7C;S?eZWEBqMFBg5JE0&lSbfR8u%%EByvGQxfo0V61gHE3sR5P4hg^oDS-=w;GAO}w&DC(2K~=PbYcU9 zkX+Q?*Z?etT7XKya0J+v3&PKV8Mq*GTu}D>2ACQclWYLOaKX=K0uI0hgSY{fhMAG| zNSgoo+nftpfs5=(Abe~)O4nbak_!CPIZBc+7$TBX7 zdYadQ$Og{E79c%5c-#&Jga<^5tVCJ?7x2aa`5{=u8=&w4?-f)56tD|3BOm}Cz`P(iPykq{s4;MTDvfPMr7Ee!L1nv2h%2K!2AZ74}hHx=?#I3|MMI2AN&fK z3iKjmNx=O;*@D}*0$GP9)P{7>gs8ls00Kk@UC09n6(SunO}sYHh*Y={%Wnhk7rwxP zljFc#!575h zA@~vi1J<8P2bId3lLJ>egH9;;4Q%vX$lZ8LvAfOrmVSt+Dx4|R~(1&Qmpnz={Wdbl%bgtk5 zo&~B;jAY<}kdR;46Z9Lu4QByU$8Uq}FhE1`+EA}CfXZYWfi5C^0#(u2K?&ypLZelK z0{K9F%4;NhphtrBNNEO88f_I6U{gTW->e>F%aFtnq=L(Z@PlC#*fU6^A=Hrn;I~1V z;kPzmcyyY1!`PrP`Q{O7aUviquZe@Qz_XlC3!7j7S@})ik^Ip_rtLuZNKip?L16>X zaAhA?0&>Cwj3d}NC_uJN;GRJxlM3n|BNtHa;86h)p+G*sVn925!Eg*A`E4*GT4R12 zEQ~=fzYS*r{lROaQq4HTpI7?BG32fMfBiNGQ-iRfr-Ylq-~b+=P{1dE0>Xyg60Z%a z2qu_wej@@$`sO$g*bE*#X95a14N#Xi5ZDa9AQ~Vi1vY~(o=X7*oCR2nlsG1uK{9Ly zg9-)giSaXvKNBeGw|e%74fU3J%o3dMGatE(;tJ*dOQ%cwl@7%!t7<6(e0z zWii3A{}=a!3EmMEgI(ULNOp*J`2)cJ7mR?ZQGl5s!2F(^KbkO0MrEPn5A=cp1Jx-c zY|%SH`-!a(jV$dabbb~3n?wK7H0yt z2WJBR7an|hWg!Y!Kvj~mEL6=HL-Qn(h1#D5WF;jM{u1G@GDy1r=mer?hx?+_a5bbL z3rI!!-&8P1zgQmQRA5k`Jo3&zcyRxz9#%lYKzz(2F2w79IE84bk?NqudGR+{K&Vh# zvp`#;IfVkozdXN)10gD}KgPk(0Z@)Yh)EX6ngf$Tv`kuED1gTYi_<`*p-B{&VqTn% zkr&@gBN&)}hUkN5%Xv2095V2Lel`Si$hcGtnMqTCo-u%f^WgG=Hzu8M4Gb_z1p#dU zHcW%8zy<}5sahxi#@WE=xFsmS2H6;y|;6JQ^cn^IOKECixZjY?_YerCj5`6!y|3fC1`Fs7-+P|=gQ4lTg7@zeBU*8}oLj3NfX^@E{kv^ijoC15bvI{tYA--~sM1Z&vV{NM7M0)yTX7xhl{Adc#8Lt{}gMS3atELL7A@u`?g&OPhoAgvI9%aXlbulc@Ct%zkOvwC zR0O|T01EmV6bM0h)no=9_X8M(2MG$~Un$_0@+L>KK|yOoP7bH8{AvURPq@iyJmV%I zgm@3~t^!cF0#Jahp;`b6oR9E&ga1s!Bm+4KBpG=Btmk)Nqi+9Kl zXqpKAa-@v{MZyMUgMOwUQ@}y>2dERgk?H~z;3N>80G>b@VmgZto#6dz4z!y{J%AkB zaC?F`A#e_UH(1=JOGgxkQ@F}@_3Sh7?*yOE(0Vf8OY+eEM2rw(@2|@uF z7M)c%_5%BZK_omto1raWfi|b{G%)r8X9ONVQt;}afDgPyc<>Yx z6tE5KC#pm!05o{Fh1?7L`6_;aC~>K{KDZ_{6iYlKfC6>}dE=nP!ZT1BDbiqIpa2;Q zCf6JaxF|X%n8}9{HljeI!DV5djs+SLV`V6iZFt&1w&Btc=fT+y7RdF%^C2364e3xVJ;sStYV|xMH;aY^K8UC zasnF=PtYL1;}HoDMd1s{iM_`^n#%lI|7Em|0GL5c}$y;7=+sa z@C8UkqXGp)75c&?Dgm+Z#WN&OV3|QI0Gtbq#s$}kjU(`|l$@44F~y@&k}vSAl!Hnf z4I;P}^{+;RDGBXo0Ye*Nv~xXav;aIJ_f;@&u9x<3VoV!B@x-g7I#)A@DQ| zGI(GD-QWxS9*hq#27_uCi)nETsjx3z&k?9j;6Y5g;9lUzOu&5r4Z?x*FX)En9LSy! zWRcM$x-%rWq#KFhAdCY#k*)^-3u8%F40Ctrk|F!R^$C~{X@!Ttq+H-BFl2DC8drhI zFfxJytO88R#D4_H01GyO`AZx`P6Y}MLEz=Gfhj;jNZbOSV@8+>ej>64nXZ6CbGQ@% z_{L*jyz&JFxI;jPOMF}uA&j>m?}Y{6KiC9jvB?AnXdwoZ03-ubV%`xl$j}H}2ObYM?NenDs04xYb~sWDLF&>u!4S@F!5hBa{T3kzVdh5;kM1fw4)pLn(osfrjDvUZjT! zgy&t~KqrsKu_y_c|AJ|NV(>s10gZ4<3&9bv7gRv%8k-UEV3H74CPchkxZ_BHEy07Q z9H0RAFhDARU$6;~4?i+Q_J_0wR3IY30RY~IW^n!K6aWIJBY=(I1E50nL%}eH0^&$! zN-n+=>GHCa28}HUK`GWUIN+11^)*= zL2AiHz%qOZfI$(&NRr=%(|`@-4}@v(;F@d$qx36x4z(}|oN)v0V1sZY^Yfhd*0VHAQgO=mBcD(Y6%K)!n&KnB2C*&094+UHX zSccz*dm_MN;Wy&apdU$yA#;yke7Zn}9lu~nFf35OX)sNLG()zB2cU-6hO?l$Bim3b zU|>m}2T_sL@J=@=RdA^rzd-+?Btr=wz+F6iBX{AoZXUjoyC4%tiWd|>JW!m#fWQZ? zjxH$h0u*o()P>Lv1x!hR5TjfGIAj-aCeR6BBlu8HBfwF>2GSTXKsxY#H#`L0fqif? zJQX2@8>ImkhMWav(0Iv3D1emVny?(4SzXk_jP=nB`!;S3P_ z@H9SP6uN-wg$L?s=u1Gz2xl|Ege1isK5H|oEo>;$=ERMpT1E(zowaEqvdfB~QYf8YT)ra}A97F*BS|MrT z(1wwg2zUzY6EuF`nKreG(2%HkFI8qM& zBNNzyI}|t_dH%yIpo@WP!TiXtsN(Us1%Ct#aY6^Zk2z+%ACA)@5Xd0-79c>tG=d2Q zZvnuVT85vIgN1;**4X;>*3eNyu3XFWXWF#TMWNd2EU<1{?3&o<+n-D4)OnZYz6*=nl}Uy6gK{O6a2;- z#NW6-_-iLicWqk-`)%HUM;iaf*1RRzlV^gy!6r1cm>Yw$ zNU~MS(#63!K$iURHc9yPHc9g5+ZOZM9Gq=Yp^&TLpF^#+bg@+={_*$Tu!|x5#G1GD zHpR908&S^WG{!t2;YNevYWO`l2kRBC_RhAF6h%Y$^DQID-u&_RR)73`mZAxNZy-*; zVFq?i2vGCSKUF{_f2ct4I|YtgCl4P(88$p}*vWtWvomsc|M3s?@D3K2|3e69e<4_8 z{pm0FHjdqJGJpEdR=GC#1pry)^ICJ2O*JQLR=8_a&p(iP-b!!O$&Kq4IzBjlX}*@o zohKTbJ*QoqdtmJ4fGEd`59eeOnR#Iz8fU_c4zIbIQtIDqQ1yMpYW-I|u|tHPUF$&S zv)E--<{R#CMs6{gMC`xxEn-2!%f4lg^gqN%A8fv^_jR0!qWuh;`iyjyxg+l>EWN?; z(%86B`bF~SqbtkAzj)1lXRbIZYq0FH17WVXljcL$`n^;B2^?n z*-5PIQY9nWtT$E4raiLqk)vIfSl9W;L+_Sxtsc(Y<)Pj9vZ_YZ=Rzgz`JSjLc1wFo zKgEAueE+CX!^^1&l<`gmPhQ^HF}wFz)+I%kq)mC^_ioINHlxk3Uffvk8@^?t>Z283 z^|JTsz2|IVeP2HA$n{ms8$)Af$wsfge3l3=bevN^*G@@%p4Y(=+Jx89)srOZnR5-M z^|z0sty5V4@r~4+!62bFcZKx$;r3Da)5H6Z_^VqUa;niwDb}TDK6}>Sy-#iQRw=u! z!%uzk83@PmPFQ_nWs}3yIp@}RuQt)#VIteA6REs7XXD^)R?2|1g?FvboTyM|)tzkahuHx+ znH~}{1^ad_-sR`Lvr%ovZp{(aksSHtf|H)v+Y_riEPRF@5576^u+Wrsy!PhId7jfk zBrO_V?DqV^y!X7A9i~?3dn?w7*PJ8euOMP* z@|twxY>8>c@ltB~t5x17!e5WQr*-7a{1M{u=i_EBs#$ryKy<12^z$n=PtLG4=B`qR zC=x&EnUi(l9C3oCbo$tZBA>(c7npBO+r+kfdz%_q0=QGnsR_+Y?Ps^@wI;Nh*T1nv-Wgeo|tfqae#Vi5pDg< z*V{%fh_y3hS&PdjWn4N@nV9x{%lP#6$}3++ekkcZF^T%zkeC{*@AoDC)500YQ@PrE z!nCPJ{bng@9r$J?x?qjm)@fntDSPxUX$475IxzlL!i3{fXyyth%ZWT`uccm>F7-01 zos#R=C05y^I?y5Jz$NrLA!&dc14?I+(CN8F#mJumT^*mx-9fJAt| z@V&5Fl?~StDFJIY)+Bm|5wAyn$i3omKZ*M*?-zD?u#DsHRucls>pRQ=q`(o6$&t39u;;G{oWS_^z z5w69Jv)9d6H+da%ZIS)rSt0L>w+|5o!52(Zd=eBIm9HMJj@l!eCAC)SR9l{2o_E&n zZ4xySn-9yT2ua&G4y;V+z%iSz8ENBSi)7MdPWZS^?+d|}~;_shWXxMvxLtJ)^DSUA7y7E&x> z%{4k`w4Rv!C^kHok-3!f?BcFDt5;8X=CVr3@50de1Dsq;Hw_4=TE>aa#WPvSwF|q`R&S3zcvy6wsN}+h zqdeER`|mN<9=1&S$=LY%muVMnx;ndzjg>8aU?OAiaO;jGX`9BccUymN)={0$pG}4? z_2uWS8;Uw$6!lqaG;#XeRH2%|=ROjmiF)O7L#;irow4~ny>t4{YTIX|U6Y;_-6S%~ zDq@M;hdZU8Z-r6w3&)phXeVSJmS%4{kbU_6&Q%)SpM$55+@HPrr1z7@WgoTt8oyqW z_Ri~_n@s7BbqWY^f7^d^|C7$y37J}EgX&T>AJ28#Nu{jG2+z=5Wk!q~5I<-+@u1L| zn*EEMv&0rVyS_~kD;Gbw$yte-u4=~T zo*%`pFE7m%dpXs`V8K>q?_rb1if_R}3sZv1`%hnXvX+ln(zn4_>3ZuMo`*g&Iu5HyaVZvh>Eo#wMEfto@^E`j` z>l!(Qjb`iDF~8@|+0{3DH#@J}ds0uqimpl3OYEPHdAYUZvk}MnWTe+F*~6D)gJN7V zlJu|mQ=iINr(V&J47L&XEEm6e=1`sRh^(x@79#gYw_s0><6`my}~jVUU=@&x*yxVEgxuGyJXVj_e5*__K1sljY)AS9y=cp+{MxNp4gYwRNtGm0Y@YT{)UC`ENWbbYLv(SFT{c(!!S{^vGVGKyYoT;Q=OY~0J- z25n`-pEh5M=jOb<%?_0;eXX?a%rS28=#L*?*}wXDz2)WWCCR3l<>vfM7yzRseS1LKw)j&xUhytJi8RjcIIk@h85Zh8%Bibgai7>*E6a<3n$!`LSm zyE}Hu&QnulK5E8ERo?8=8{FL|{k5gE8cUmmnwuTWgQcXM4G(R-XxQta2KT`+-4pC&R##C+`j z`C@I)&3BhS@~tokuMNE-RPsVJOT+*1`yA_UpG4CV8qYl0eZlgkrMr%8Ez4_4>{eab z*d14gRZ^m^jmqyoI4B*m!gpWCF4Orp8eT?8Og1;Kqn5o}Io>mVx~;~UZAVQWnQ7)@kRh?XToIoqW;NaFsZ~zFJy4N9}5%Q%(H0 zRa;gY7(}nXA-As5z{ZeR@9d}i#i7U5)7i)6ncDHLgB2Rd5vDR;YA02@21@()HjZzb zKA7zP&d@~r;7Yv?F~^mslipwDsF+q>t6Ac5w%fWS#QdA%p@5)G>5Cf2%!;rXa1xs# z>q?aw%Z^!_Dw!GoZZ#3R+VXVtb)EZzvs4nZlc+6+C=(^hdQ@%8q*vc7DW2aEck14| zJ8^z)eg|6@Zq&`#e=bOq-L=I$tSR3o(aHXcc{^p_X}gEBvaY(>_m^=i?%%gzNAGqx z68kXQ?n0??)9bgbCPA6j>sCH(5}xP%{S90B^Op#2xmrcrg~ph;W#Yt_&-?e@xYwbQ zmOQX&+#4EGrS4792i1w)Ca!}D8@K;ZZ{552S~x=P{n+Cxd*(#K?X#*Z<*cs$T7XK;O5pcdhIrEXKmc@Lq2Vebqr70MQi zijF#avP!zMep6OW_t6>eKkUeVIdrdgfoN`T;|tflL9uT|hYyb5X|`PG#kkMQ#fZs5 zGlnY;m!Ii0T&>#4MzVRq)ssouN#4gUz0z4fPHvBDn8h(qkMU!d$CZ@7cRRgKw=h2P zkx}9_>*gnKn6CME)(2MT6ql=Sw~RaNJLBk$<^>@I$`1~Q%q#sN-6MX>lv84@_i@ip zsR5H=gL7@B2E~rQJ7#cAe8~t;O48Z4iKXg<--@`s6?e|rkDOARS=6{SXi`vfX!bCd zynL%F32n7`2bo2Cir(lG;p3m$zLH5lHey-p!G)3e&#a&4<_IJ39*a*hVOZiHy{I)w<)T)&Z*rf2R?oR*aQIA7@1 zV%i)RLikhK!*|N+Tc)~Botl1gV6^{hJ-gJ!6kYw`q7dx^^^(#1{ExZOrrgix^gP%* zcIG?BlD0+CHO!jbuAVzOiFB_Mc|mXPi{F|OFmz`3h0!Tm3xrF#6Jzp&M7raOy&g2J zHJ%jv;QbBD{<$}WBwh{^X%2LrWIZYFNbuQDfft&VZy?U>9@aRQ!rWcmXLI!A&e$P8 zmubW2o*VtC|Nih8p;N=21WhQFf7C15`)yp~gvLdU!i}Nun^{jA4ido?m_8~KRKg5{D(8b3FZj0(+`^Ur>CR~`m@qJ*q{ZTKc z6LPf`jq52bGYg6L!!9?(=rt-WaG57Hpxi+}c1)b;{c*cw%!Ql#?*z2^f27kQ4o(S( z8D(jU*pL4+elLsO%EsWI;mXF($2erRUA z+hki@revS-)|RI=i)d3je?AQ^6E-$5A3l)vF}Qz(^uj&8)3s&yOt#L=-A2>19TdHf4&8k;aETNtPWuaKDITH83BOaBqy z<+9PpB75I<;ic_?7jwTYNPJurvA0#HL%;Q6sr3TmZD%5-lkT>C@=7YS@;e;xHoL0t z++x>F$v#DQA0M(Ud9JHOqm{|Np1HtRwPp7krMFc*H}$)O^iFWE7AQ8A_0Ksz@#0gB zULwJ+?{@jnCaXdJtB2kO-?Vm{pG+~nvbjTfRpDb*Y2V@z9YUG&dLJCh9%Jpb`}r3O z2Nza;_}vHIHubBoAK$FVyk=qb&hfaS-P^)DHmO{j&I8KPt@mY5x<(wT$$ao((9>#z z__tg8d&jf}9?fHU?Y?#Rtd8dPk3H!>*4ITo4LD$|Ti!*hG%r!E z%1u`4t=x9#naIy2kG);KDo*O0`fRF1pvBJzcOq@FDyeTD=FNVaG%>JzK>}k@Vrk00 z-O^_m>pQid&Auvm5{s-vVWbl$7w9swcDivWq?aI#ojZm^b%SxTVzjb7@t$`*Zjo#_1Y|P*C{WaHn%d&9QvohS~*Q$iQ zD*21|!#q+vJx7JO5~+uLo=CLlCry2LgJwNX=4>&cZ2G;`F-Ub|XRKUI8!gJohqFg5 zowZP7>WwqO1r51Pxh-bx7ncVp*H^y`(Q4Ej9GR}_8}k0Z=d<}uwe`JsyN!KWPqTET zmVHj&_x9B}|EZrvzIm3ed3COLnL~M5YV+Xvd3F&Aw=b`Kzty4S7NMr0Gu>Y9-i*&P zTP3_Bdp;Sj=>PDoEO*U|%&Q#zDF@>-vuDMLi1%+w=>M87)bjF&W}~Ruyzgf|w}h6} zrDk3f4Vd1s=2&r7s>hk|cPsB-$WTqmG$?x)Gokj!7yPZ{6t0e_HrCcFNPaZecqM?nN9Y;{2U7 z8>`|DRf=Y7XNtuC3<*`0398i;?H4~W_O5qI!->NFO7q9#ncrx z)};8K`!1HL<|Eg(K+8VwOUb72nxNcsqc5*tKlK?)`fOx(!N|VFJ&}!*ZcCIb8@)Na zUfO`W_DJ`gmX$wrcTV%3n&~%kWz~$zhT6Nt1&x8ZepMMai|6V+9i`^ZqF$X)TCG?x zMCi?L&tqP_+`q*rX@jjwa@&?v@$_{)!#(e(&!4Ar?a|#iRPz&U=VF>#ZUx)#Ep970 zTkCuE$K7WlW%MTDHp9V-Bfd(CoZTbz(zK~OB29#oGvlRSGP_)&+gC$QxY^jKNUxn! zFHzX**qNfgr)QI`T*#07_-O+J8-(J5Q~DtPqfnl7EM3b_rl&^ba=XOc51D0h>*6K_ zghbmcTO5(6CT2KSqslV({I}L+o~Lrun~Gg5uQ}>`EErfCHd2goBg(q+*|oq_Iq&iN zMP}D^KKK1L^Gu17XklpGK9&OUJno#e%@`k{&&Cbr3iXr~K6{HCmWe(0XgfLnW0QE% zzP zrS`3zeww(+jtouFRX3eC*yz9ZTp!i-wxQGgQ+Hh%3SEX)Uovbb^rx!PPxYKE=d?6z zY}hnAcY8$ZvE2-7*O8KT>;7 z)5$VISpVqwvWh)F&l>M+*$|cBXnjJa$@H?kY2c=nhrZVpwMyI_wP?HkQ_UV>+TJ14 zvX71M|B}b;%T@ch>)g=u-SsDQ#@-tJJaqe$K<%&G$1CPPzPVH9>Kb9+gnJW1wW1s3 zZ#E4ya%h@86Nu+8ZUqjDOT1}u{V$RI3`j_f5`a3eug%-xmvlmX?B}&LooU4BS@Vp^|b@ty~AXnekc&2CXU8-EpoNhA@iNWZmt*(^k#R(#ATf8Rw zAB&IuBuSE z(Da)nrS2c+?5zA^R5xb@;qq>1TYd{C+@o6O!>ak>Zd-OPCl$upAzSHsjF%pF#=O)`=|psbG~ovh_tMev9PR=Tdbq9^y1SQ;y1X5dv4d+ z>uK%Fw+R9V=6F$kPIDyTzVXTQ{F2PTw!nqbqb9GPwawFDz2vdT_DdUn%+J~?NnBhw zKj*>|hxyi9J`E30j8L|^J|pjg)iNvbc=abb>xHL?YA%{GO)JUwiuch+pI$gD`=FkZ zKIyu=Rjko8&wiD_p3um73lm=bd|76r+SYt_(4(jFqe}nBlEmA!1NVhbSDu>|bH*ln zV$O=%EWZvyxMk9-F(rwrTJ(L*4+2i??+_*~$<~`L>9%g}wX^sdlKyH_-j>2$gxHQ( zO^ze=rou=SQwH-Vh`D ze~1e0o3=ijpbBOB#NN6#GI#qMv+%y8b83m)d8b2y_6@sVP1EU;Yns?LyPe)%d~T!u zf|W$%8##9S`+L{lRX&`03F6dXpk5p;OXlEh%;_QK@P56LRtTtyApPOoq7%kL@MKcV8ji8&vnzSMF)+@U6EHY85ibh$)Kc za_#E~$RJF8Z# zn=G(hz5V^$h}|Z)cZPfY{QA}OvZ2bHkB@7(5f{@VO1VkR<%Mz2oeo>CbPHT*Z1HT% z#+-YzOj?N4*1=LUi=JB_`|c5$Sx0`hT6!cI{;0ecJZ#zeU>OIGjG0BV-lR&#rgHidsPp6}YT`&CcyO@;ZPyB=IS`{{Xm^v?F$ zT$|AMgA3Y(L>tBTCUBlehKgG6|9Q--N~E%XlT8+TGZZ4Z~%&~E)U zqO);B()UX0#lf?WRpTCQA6x&$H7lXqrg)_UC1l6U`cG?n{VK{oY)h?SK4D!P)R~^} z(p9bbtc~X6J~`R)k_Vlw!>{YORh{cNclB|X-;tJ?d9)RITMx=P(TE+clS^Jt^BCu( zyeCy6Y~F~^Ldt%pQVyxwpIVSJ_Cw*@c`NRUt&MkOemJqi@$zEV=}pPaE-43hS;f_A zpW9!&@>1M5dCqK>&>auf;o602}WIF=`G_wZ26H{{SOVb6?Y7dcV7B+`Rv(31@xZB zkrVsn+g*+})WBiswLS8?pQPq;-&16TG)~IfLdQa)nV#_WqW;vzfMFQi&_ZjBqg z*T#dmUv;T(O~lurTAexLPphPbH(2XG6RFtgBknt?|M^Qfuf>NS#3bJB*_S+(Xw6>v zRrbF1iJfx_avZ&1(MDUF%9gcC%$U0K)~UEt(X+Rm4H({YUuN6sGMz7_x-nPVUMM$d z&2p>M=YDQnx^>F#u1=BSa%BU(;Z?4Oq{j{!J9rl^4U1oA`hH%WX~LWbeOJumbW^uG z`ArvZqwCl9(F@x3_l8f0l({0L^RV=%l`aHWzY5dDJ{c9r`yT4_( zIolrZ*ca^-%Wiu-SiOic`%77HXH?PA^Z8kQ?AO;1afQ30F20B;zk7XI$?p0=TgEZ! zBI1*H^kCh)*O!*lTTfQ7oZ7R#$iZ6HglOR_WC~{rw-EbM4Jso{YL{N8M!uG?uMg={Xx;aI zR?sR9xmz}yEp;|baI}vx&-3qP6`3$TWXwq4eEdt`8Czm#76)jlu^EPLhZBW^H zt2d7??Y{GQS)H>{%97dk>rbW3*>Hu!n0{*i@Y%XGDzDO>JaO0+yyEN{p(SfQbEa?G z$7l+!%-}c?cHidavM)>MF0CF=OJ?lM_qaIq!W`YHi_$V*SOj0|(&-#kx_YwG@E&&Q zK&i*9#*cR?_IHD}m@TupcK82j?7V~F+TTAOac{6}LLqW2X<*@RdnELMq57GcA65hQwal33BAMf)C^`DW&u-#@?4nK|c~_w$}PbLPyP znKS3S-cR|V#7kIPF89>VSnq=tmes4!!aW=bR>HAzCm(pWA53)w$e$0x-OFtB?(-k` zOoF_-ms>bh-xQ(uSkG~qv|zXwWslL?Q(V6;w9YI3s0fyPq0&U z)-6P*3wPL`n=>MqgMYr9!`C_ir>LP%&(-GE( zrsOrhQVCw>9gTsVek5_HONR^74Rah#no`YxY7Gq2`jB=Q{*vj08OsrZYEbL<2~*I+ zOae=EsZkLv5e2gmKkMr$9M;QJY?VLpp(hv zQSC-SIOuuc+ltVyxhk8#Hc(vp^z#Vvta^z1YrP1)^NJtd-rrtG^uH#MxQp9-U4?Lf z4P80nu1NH;RP8Ehz4WRDpFUraCR%n6x=i?EX{r+g>g(ZXR8sO>J@r36ElUrJDSfMe z za>HQ!JfSL6&{*c0v;2+jUhFVeWTXi6*h%(%mV$t6$Dy)`q%P%AZWQxjNuymf1|El zp)u`w+;7jXdd2fHBX3dLlbN*H9#B-16&)9p64T*p)#(b!h>F2n_c zz}0adLZ9t=san=a_Vq5nqT+jXdbGksm*{s=hfea+3RSe@CuK0-2?%AH$GL8)10C}U{zM+0jwHz29 z%Dg=mV}x_4dRy9?^vir)1S9loqtVk9r@ZlRUvpas8ZCkNDsMnYe_jhn4-?z8tk26#r60 zrBEfSUN=B8V20B6!K24F+26pgM#icsoc(?*E%=YdFgwo>iJ|4BHEaf2o_#}X!}$@@ zpHmEo$3`SR@dy@II?Q_kM5ZQV3Kc=_ZmhBmN&6;wp@xsV7ibgAH{d;=*@r7vtdfBH zNRh-ygL?vtl5_#CUU%MtH%epno*qBot9Ue;WFJV{i6>hrd%g*SA0294xJpe}WK~GW z?6m(RWkJ>b$dT0XV^g8;qK?kKHCCdEDB*>wOaXIl7@=DGF>|p&cx?hzR-5ELIedUF z2~;s!*0e}ty;a$?xbEMBs^XWP?GhWN4?k`a6|_z2QG_-^1q|HcVqh6}R zjaE$~TrK@4j95d4)bV1q!Z*SG)$h!gH4H{ZIMQDto(x78u|^z`M|M?DJnpmczQ~#g zTDoxjH10M>sNKgIv%9NblwFD=>(?`P9453_^Y`+|`SgeamCus8YYcmDq8Db=4_E%0 zojrMxYJ;8ttAf)$s^o_ZU3{tXjZRDelcHDDfJ&H4l)S@E~7M((}H6kMr#?)^M8@JeFO?tqMAm@%h^XA7@=+QG!=CHIPZyaFM&(3Hb(kT zGc?u@!D8*sS9;Y~oDNj}(i0k(^~V!=-5rMDD(j1%%uWieSA_IWw5FGlO9h;AZ`52) zBK@=Dd$})%67QFntQt4)rh zs;TGJkP~+-OzS?d9T-{;lIK~Lf=s7g#^r~+UdslCTU8C`Uaw1@jHX0W4%eC~<-3B- z12)bx_bSn*3h*QmjlzPCIq$J+tkH`+N!jzAW{L=JwvS_QD|gm@)~fYXx$RTL=169V zT1Tq`yc26&U5VrPpoN8xdDcc^k%yhs-MfZE-rvK-(~G~;xYja!d5F}$SVX)P^x3`K zXd08+q%G{Bbm$~L8e8L4Gz@bkFr+P}3jRBm2GUUzBr8Iz@;54MB&KscoAmfrIVt9wgx_w2SfY5l5x4ZUJ1Awr!fez{L%@ zQ1Rzs_xPz?8Dw6f=jzVWd2`YYh7VCw|sKfIsHi!()pVT8Qv+VEf1BeTkSHbHX*s@ z5ruPjEyEGIq1qC)FAfH3JrQPxyP6jRRZj;z@W&X)aK|jJpfi?98k#4l{)lSfuoBa@ zD6P+U5OPou5ZK{N6sK0}ltgn~gMKUFM=z9c>@CqmzrbE!{-PrNT&OcP;?)sR>9Q=% zPWu!2s|IYWMe3GZzZ`21eO0)`8rQB#F2b*=g6)2LhJ9aEERx+S@Y>Qy|SOk_*O81j6+U zEJouFNB`xA9Cf0`FcPnsGjowMV&b!J3ZDc%fM+gosyr4m6k+R)lsB$A$KE|E(Ulp* z9CX3(v3VXN5o;T9N*nUW6ph#-cq3?5F^|Mgh?N#-kt7Fo`Nk;wwul+K1o2k4(sIGg zhuTiCg1hOa@yHfKsR>J_2bhJ<9IV^y3>D`52`J=(#hoWe#7g5(sh+cz3<4Sw-Yr+` z?vfitR6FoZc2?u 0 enddo ! i enddo ! j diff --git a/cicecore/cicedynB/general/ice_flux_bgc.F90 b/cicecore/cicedynB/general/ice_flux_bgc.F90 index 2ff193b2f..56e644431 100644 --- a/cicecore/cicedynB/general/ice_flux_bgc.F90 +++ b/cicecore/cicedynB/general/ice_flux_bgc.F90 @@ -12,7 +12,7 @@ module ice_flux_bgc use ice_fileunits, only: nu_diag use ice_exit, only: abort_ice use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted - use icepack_intfc, only: icepack_max_aero, icepack_max_nbtrcr, & + use icepack_intfc, only: icepack_max_iso, icepack_max_aero, icepack_max_nbtrcr, & icepack_max_algae, icepack_max_doc, icepack_max_don, icepack_max_dic, icepack_max_fe, & icepack_query_tracer_indices, icepack_query_tracer_flags, icepack_query_parameters @@ -23,22 +23,22 @@ module ice_flux_bgc ! in from atmosphere - real (kind=dbl_kind), & !coupling variable for both tr_aero and tr_zaero + 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) real (kind=dbl_kind), & dimension (:,:,:,:), allocatable, public :: & flux_bio_atm ! all bio fluxes to ice from atmosphere - ! in from ocean + ! out to ocean real (kind=dbl_kind), & dimension (:,:,:,:), allocatable, public :: & + fiso_ocn, & ! isotope flux to ocean (kg/m^2/s) faero_ocn ! aerosol flux to ocean (kg/m^2/s) - ! out to ocean - real (kind=dbl_kind), & dimension (:,:,:,:), allocatable, public :: & flux_bio , & ! all bio fluxes to ocean @@ -95,6 +95,19 @@ module ice_flux_bgc real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & zaeros ! ocean aerosols (mmol/m^3) + ! isotopes + real (kind=dbl_kind), & ! coupling variable for tr_iso + dimension (:,:,:,:), allocatable, public :: & + fiso_evap , & ! isotope evaporation rate (kg/m^2 s) + Qa_iso , & ! isotope specific humidity (kg/kg) + Qref_iso ! 2m atm reference isotope spec humidity (kg/kg) + + real (kind=dbl_kind), & ! coupling variable for tr_iso + dimension (:,:,:), allocatable, public :: & + HDO_ocn , & ! seawater concentration of HDO (kg/kg) + H2_16O_ocn, & ! seawater concentration of H2_16O (kg/kg) + H2_18O_ocn ! seawater concentration of H2_18O (kg/kg) + !======================================================================= contains @@ -125,6 +138,14 @@ 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) 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) diff --git a/cicecore/cicedynB/general/ice_forcing_bgc.F90 b/cicecore/cicedynB/general/ice_forcing_bgc.F90 index 6e543a056..9d49e4349 100644 --- a/cicecore/cicedynB/general/ice_forcing_bgc.F90 +++ b/cicecore/cicedynB/general/ice_forcing_bgc.F90 @@ -29,7 +29,8 @@ module ice_forcing_bgc implicit none private public :: get_forcing_bgc, get_atm_bgc, fzaero_data, alloc_forcing_bgc, & - init_bgc_data, faero_data, faero_default, faero_optics + init_bgc_data, faero_data, faero_default, faero_optics, & + fiso_default integer (kind=int_kind) :: & bgcrecnum = 0 ! old record number (save between steps) @@ -538,6 +539,21 @@ end subroutine get_atm_bgc !======================================================================= +! constant values for atmospheric water isotopes +! +! authors: David Bailey, NCAR + + subroutine fiso_default + + use ice_flux_bgc, only: fiso_atm + character(len=*), parameter :: subname='(fiso_default)' + + fiso_atm(:,:,:,:) = 1.e-14_dbl_kind ! kg/m^2 s + + end subroutine fiso_default + +!======================================================================= + ! constant values for atmospheric aerosols ! ! authors: Elizabeth Hunke, LANL diff --git a/cicecore/cicedynB/general/ice_init.F90 b/cicecore/cicedynB/general/ice_init.F90 index 41ff70aec..08476ca57 100644 --- a/cicecore/cicedynB/general/ice_init.F90 +++ b/cicecore/cicedynB/general/ice_init.F90 @@ -61,7 +61,7 @@ subroutine input_data use ice_diagnostics, only: diag_file, print_global, print_points, latpnt, lonpnt use ice_domain, only: close_boundaries use ice_domain_size, only: ncat, nilyr, nslyr, nblyr, nfsd, nfreq, & - n_aero, n_zaero, n_algae, & + n_iso, n_aero, n_zaero, n_algae, & n_doc, n_dic, n_don, n_fed, n_fep, & max_nstrm use ice_calendar, only: year_init, istep0, histfreq, histfreq_n, & @@ -71,7 +71,7 @@ subroutine input_data use ice_arrays_column, only: oceanmixed_ice use ice_restart_column, only: restart_age, restart_FY, restart_lvl, & restart_pond_cesm, restart_pond_lvl, restart_pond_topo, restart_aero, & - restart_fsd + restart_fsd, restart_iso use ice_restart_shared, only: & restart, restart_ext, restart_dir, restart_file, pointer_file, & runid, runtype, use_restart_time, restart_format, lcdf64 @@ -126,7 +126,8 @@ subroutine input_data logical (kind=log_kind) :: calc_Tsfc, formdrag, highfreq, calc_strair, wave_spec - logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_pond, tr_aero, tr_fsd + logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_pond + logical (kind=log_kind) :: tr_iso, tr_aero, tr_fsd logical (kind=log_kind) :: tr_pond_cesm, tr_pond_lvl, tr_pond_topo integer (kind=int_kind) :: numin, numax ! unit number limits @@ -168,9 +169,10 @@ subroutine input_data tr_pond_cesm, restart_pond_cesm, & tr_pond_lvl, restart_pond_lvl, & tr_pond_topo, restart_pond_topo, & + tr_iso, restart_iso, & tr_aero, restart_aero, & tr_fsd, restart_fsd, & - n_aero, n_zaero, n_algae, & + n_iso, n_aero, n_zaero, n_algae, & n_doc, n_dic, n_don, n_fed, n_fep namelist /thermo_nml/ & @@ -392,11 +394,14 @@ subroutine input_data restart_pond_lvl = .false. ! melt ponds restart tr_pond_topo = .false. ! explicit melt ponds (topographic) restart_pond_topo = .false. ! melt ponds restart + tr_iso = .false. ! isotopes + restart_iso = .false. ! isotopes restart tr_aero = .false. ! aerosols restart_aero = .false. ! aerosols restart tr_fsd = .false. ! floe size distribution restart_fsd = .false. ! floe size distribution restart + n_iso = 0 n_aero = 0 n_zaero = 0 n_algae = 0 @@ -660,6 +665,8 @@ subroutine input_data call broadcast_scalar(restart_pond_lvl, master_task) call broadcast_scalar(tr_pond_topo, master_task) call broadcast_scalar(restart_pond_topo, master_task) + call broadcast_scalar(tr_iso, master_task) + call broadcast_scalar(restart_iso, master_task) call broadcast_scalar(tr_aero, master_task) call broadcast_scalar(restart_aero, master_task) call broadcast_scalar(tr_fsd, master_task) @@ -669,6 +676,7 @@ subroutine input_data call broadcast_scalar(nilyr, master_task) call broadcast_scalar(nslyr, master_task) call broadcast_scalar(nblyr, master_task) + call broadcast_scalar(n_iso, master_task) call broadcast_scalar(n_aero, master_task) call broadcast_scalar(n_zaero, master_task) call broadcast_scalar(n_algae, master_task) @@ -721,6 +729,7 @@ subroutine input_data if (my_task == master_task) & write(nu_diag,*) subname//' WARNING: ice_ic = none or default, setting restart flags to .false.' restart = .false. + restart_iso = .false. restart_aero = .false. restart_fsd = .false. restart_age = .false. @@ -828,6 +837,15 @@ subroutine input_data abort_flag = 8 endif + if (tr_iso .and. n_iso==0) then + if (my_task == master_task) then + write(nu_diag,*) subname//' ERROR: isotopes activated but' + write(nu_diag,*) subname//' ERROR: not allocated in tracer array.' + write(nu_diag,*) subname//' ERROR: Activate in compilation script.' + endif + abort_flag = 31 + endif + if (tr_aero .and. n_aero==0) then if (my_task == master_task) then write(nu_diag,*) subname//' ERROR: aerosols activated but' @@ -1197,6 +1215,8 @@ subroutine input_data write(nu_diag,1010) ' restart_pond_lvl = ', restart_pond_lvl write(nu_diag,1010) ' tr_pond_topo = ', tr_pond_topo write(nu_diag,1010) ' restart_pond_topo = ', restart_pond_topo + write(nu_diag,1010) ' tr_iso = ', tr_iso + write(nu_diag,1010) ' restart_iso = ', restart_iso write(nu_diag,1010) ' tr_aero = ', tr_aero write(nu_diag,1010) ' restart_aero = ', restart_aero write(nu_diag,1010) ' tr_fsd = ', tr_fsd @@ -1207,6 +1227,7 @@ subroutine input_data write(nu_diag,1020) ' nilyr = ', nilyr write(nu_diag,1020) ' nslyr = ', nslyr write(nu_diag,1020) ' nblyr = ', nblyr + write(nu_diag,1020) ' n_iso = ', n_iso write(nu_diag,1020) ' n_aero = ', n_aero write(nu_diag,1020) ' n_zaero = ', n_zaero write(nu_diag,1020) ' n_algae = ', n_algae @@ -1270,10 +1291,12 @@ subroutine input_data wave_spec_in=wave_spec, nfreq_in=nfreq, & tfrz_option_in=tfrz_option, kalg_in=kalg, fbot_xfer_type_in=fbot_xfer_type) call icepack_init_tracer_flags(tr_iage_in=tr_iage, tr_FY_in=tr_FY, & - tr_lvl_in=tr_lvl, tr_aero_in=tr_aero, tr_fsd_in=tr_fsd, tr_pond_in=tr_pond, & + tr_lvl_in=tr_lvl, tr_iso_in=tr_iso, tr_aero_in=tr_aero, & + tr_fsd_in=tr_fsd, tr_pond_in=tr_pond, & tr_pond_cesm_in=tr_pond_cesm, tr_pond_lvl_in=tr_pond_lvl, tr_pond_topo_in=tr_pond_topo) call icepack_init_tracer_sizes(ncat_in=ncat, nilyr_in=nilyr, nslyr_in=nslyr, nblyr_in=nblyr, & - nfsd_in=nfsd, n_algae_in=n_algae, n_aero_in=n_aero, n_DOC_in=n_DOC, n_DON_in=n_DON, & + nfsd_in=nfsd, n_algae_in=n_algae, n_iso_in=n_iso, n_aero_in=n_aero, & + n_DOC_in=n_DOC, n_DON_in=n_DON, & n_DIC_in=n_DIC, n_fed_in=n_fed, n_fep_in=n_fep, n_zaero_in=n_zaero) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & @@ -1301,7 +1324,7 @@ subroutine init_state use ice_blocks, only: block, get_block, nx_block, ny_block use ice_domain, only: nblocks, blocks_ice - use ice_domain_size, only: ncat, nilyr, nslyr, n_aero, nfsd + use ice_domain_size, only: ncat, nilyr, nslyr, n_iso, n_aero, nfsd use ice_flux, only: sst, Tf, Tair, salinz, Tmltz use ice_grid, only: tmask, ULON, TLAT use ice_state, only: trcr_depend, aicen, trcrn, vicen, vsnon, & @@ -1322,11 +1345,11 @@ subroutine init_state heat_capacity ! from icepack integer (kind=int_kind) :: ntrcr - logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_aero, tr_fsd + logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero, tr_fsd logical (kind=log_kind) :: 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 + integer (kind=int_kind) :: nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd + integer (kind=int_kind) :: nt_isosno, nt_isoice, nt_aero, nt_fsd type (block) :: & this_block ! block information for current block @@ -1338,12 +1361,14 @@ subroutine init_state call icepack_query_parameters(heat_capacity_out=heat_capacity) call icepack_query_tracer_sizes(ntrcr_out=ntrcr) 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_fsd_out=tr_fsd, & + tr_lvl_out=tr_lvl, tr_iso_out=tr_iso, tr_aero_out=tr_aero, tr_fsd_out=tr_fsd, & 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_Tsfc_out=nt_Tsfc, nt_sice_out=nt_sice, & nt_qice_out=nt_qice, nt_qsno_out=nt_qsno, nt_iage_out=nt_iage, nt_fy_out=nt_fy, & 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_aero_out=nt_aero, nt_fsd_out=nt_fsd) + nt_ipnd_out=nt_ipnd, 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__) @@ -1423,6 +1448,12 @@ subroutine init_state trcr_depend(nt_fsd + it - 1) = 0 ! area-weighted floe size distribution enddo endif + if (tr_iso) then ! isotopes + do it = 1, n_iso + trcr_depend(nt_isosno+it-1) = 2 ! snow + trcr_depend(nt_isoice+it-1) = 1 ! ice + enddo + endif if (tr_aero) then ! volume-weighted aerosols do it = 1, n_aero trcr_depend(nt_aero+(it-1)*4 ) = 2 ! snow diff --git a/cicecore/cicedynB/general/ice_step_mod.F90 b/cicecore/cicedynB/general/ice_step_mod.F90 index b8d796710..e389adc87 100644 --- a/cicecore/cicedynB/general/ice_step_mod.F90 +++ b/cicecore/cicedynB/general/ice_step_mod.F90 @@ -27,7 +27,7 @@ module ice_step_mod use icepack_intfc, only: icepack_biogeochemistry, icepack_load_ocean_bio_array use icepack_intfc, only: icepack_max_algae, icepack_max_nbtrcr, icepack_max_don use icepack_intfc, only: icepack_max_doc, icepack_max_dic, icepack_max_aero - use icepack_intfc, only: icepack_max_fe + use icepack_intfc, only: icepack_max_fe, icepack_max_iso use icepack_intfc, only: icepack_query_parameters use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_sizes use icepack_intfc, only: icepack_query_tracer_indices @@ -161,7 +161,7 @@ subroutine step_therm1 (dt, iblk) 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_aero + use ice_domain_size, only: ncat, nilyr, nslyr, n_iso, n_aero 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, & @@ -170,7 +170,8 @@ subroutine step_therm1 (dt, iblk) flat, fswabs, flwout, evap, evaps, evapi, Tref, Qref, Uref, fresh, fsalt, fhocn, & fswthru, meltt, melts, meltb, congel, snoice, & flatn_f, fsensn_f, fsurfn_f, fcondtopn_f - use ice_flux_bgc, only: dsnown, faero_atm, faero_ocn + 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, aice_init, aicen_init, vicen_init, & vice, vicen, vsno, vsnon, trcrn, uvel, vvel, vsnon_init @@ -198,10 +199,11 @@ 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_iage, nt_FY, nt_qice, nt_sice, nt_aero, nt_qsno, & + nt_isosno, nt_isoice logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_aero, tr_pond, tr_pond_cesm, & + 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) :: & @@ -210,6 +212,9 @@ subroutine step_therm1 (dt, iblk) real (kind=dbl_kind), dimension(n_aero,2,ncat) :: & aerosno, aeroice ! kg/m^2 + real (kind=dbl_kind), dimension(n_iso,ncat) :: & + isosno, isoice ! kg/m^2 + type (block) :: & this_block ! block information for current block @@ -219,7 +224,7 @@ subroutine step_therm1 (dt, iblk) call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc) call icepack_query_tracer_sizes(ntrcr_out=ntrcr) call icepack_query_tracer_flags( & - tr_iage_out=tr_iage, tr_FY_out=tr_FY, & + 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_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( & @@ -227,7 +232,8 @@ subroutine step_therm1 (dt, iblk) nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, nt_Tsfc_out=nt_Tsfc, & 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_aero_out=nt_aero, nt_qsno_out=nt_qsno, & + 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__) @@ -236,6 +242,8 @@ subroutine step_therm1 (dt, iblk) prescribed_ice = .false. #endif + isosno (:,:) = c0 + isoice (:,:) = c0 aerosno(:,:,:) = c0 aeroice(:,:,:) = c0 @@ -270,8 +278,16 @@ subroutine step_therm1 (dt, iblk) do j = jlo, jhi do i = ilo, ihi - if (tr_aero) then - ! trcrn(nt_aero) has units kg/m^3 + if (tr_iso) then ! trcrn(nt_iso*) has units kg/m^3 + do n=1,ncat + do k=1,n_iso + isosno(k,n) = trcrn(i,j,nt_isosno+k-1,n,iblk) * vsnon_init(i,j,n,iblk) + isoice(k,n) = trcrn(i,j,nt_isoice+k-1,n,iblk) * vicen_init(i,j,n,iblk) + enddo + enddo + endif ! tr_iso + + if (tr_aero) then ! trcrn(nt_aero) has units kg/m^3 do n=1,ncat do k=1,n_aero aerosno (k,:,n) = & @@ -311,15 +327,19 @@ subroutine step_therm1 (dt, iblk) FY = trcrn (i,j,nt_FY ,:,iblk), & aerosno = aerosno (:,:,:), & aeroice = aeroice (:,:,:), & + isosno = isosno (:,:), & + isoice = isoice (:,:), & 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), & + Qa_iso = Qa_iso (i,j,:,iblk), & rhoa = rhoa (i,j, iblk), & Tair = Tair (i,j, iblk), & Tref = Tref (i,j, iblk), & Qref = Qref (i,j, iblk), & + Qref_iso = Qref_iso (i,j,:,iblk), & Uref = Uref (i,j, iblk), & Cdn_atm_ratio= Cdn_atm_ratio(i,j, iblk), & Cdn_ocn = Cdn_ocn (i,j, iblk), & @@ -389,6 +409,12 @@ subroutine step_therm1 (dt, iblk) fcondtopn_f = fcondtopn_f (i,j,:,iblk), & faero_atm = faero_atm (i,j,1:n_aero,iblk), & faero_ocn = faero_ocn (i,j,1:n_aero,iblk), & + fiso_atm = fiso_atm (i,j,:,iblk), & + fiso_ocn = fiso_ocn (i,j,:,iblk), & + fiso_evap = fiso_evap (i,j,:,iblk), & + HDO_ocn = HDO_ocn (i,j, iblk), & + H2_16O_ocn = H2_16O_ocn (i,j, iblk), & + H2_18O_ocn = H2_18O_ocn (i,j, iblk), & dhsn = dhsn (i,j,:,iblk), & ffracn = ffracn (i,j,:,iblk), & meltt = meltt (i,j, iblk), & @@ -408,6 +434,19 @@ subroutine step_therm1 (dt, iblk) frz_onset = frz_onset (i,j, iblk), & yday=yday, prescribed_ice=prescribed_ice) + if (tr_iso) then + do n = 1, ncat + if (vicen(i,j,n,iblk) > puny) & + isoice(:,n) = isoice(:,n)/vicen(i,j,n,iblk) + if (vsnon(i,j,n,iblk) > puny) & + isosno(:,n) = isosno(:,n)/vsnon(i,j,n,iblk) + do k = 1, n_iso + trcrn(i,j,nt_isosno+k-1,n,iblk) = isosno(k,n) + trcrn(i,j,nt_isoice+k-1,n,iblk) = isoice(k,n) + enddo + enddo + endif ! tr_iso + if (tr_aero) then do n = 1, ncat if (vicen(i,j,n,iblk) > puny) & @@ -452,7 +491,8 @@ subroutine step_therm2 (dt, iblk) use ice_flux, only: fresh, frain, fpond, frzmlt, frazil, frz_onset, & update_ocn_f, fsalt, Tf, sss, salinz, fhocn, rside, fside, & meltl, frazil_diag - use ice_flux_bgc, only: flux_bio, faero_ocn + use ice_flux_bgc, only: flux_bio, faero_ocn, & + fiso_ocn, HDO_ocn, H2_16O_ocn, H2_18O_ocn use ice_grid, only: tmask use ice_state, only: aice, aicen, aice0, trcr_depend, & aicen_init, vicen_init, trcrn, vicen, vsnon, & @@ -550,7 +590,12 @@ subroutine step_therm2 (dt, iblk) ocean_bio = ocean_bio (i,j,1:nbtrcr,iblk), & frazil_diag= frazil_diag(i,j,iblk), & frz_onset = frz_onset (i,j, iblk), & - yday = yday, nfsd=nfsd, & + yday = yday, & + fiso_ocn = fiso_ocn (i,j,:,iblk), & + HDO_ocn = HDO_ocn (i,j, iblk), & + H2_16O_ocn = H2_16O_ocn(i,j, iblk), & + H2_18O_ocn = H2_18O_ocn(i,j, iblk), & + nfsd = nfsd, & wave_sig_ht= wave_sig_ht(i,j,iblk), & wave_spectrum = wave_spectrum(i,j,:,iblk), & wavefreq = wavefreq(:), & @@ -820,7 +865,7 @@ subroutine step_dyn_ridge (dt, ndtd, iblk) dvirdgdt, opening, fpond, fresh, fhocn, & aparticn, krdgn, aredistn, vredistn, dardg1ndt, dardg2ndt, & dvirdgndt, araftn, vraftn, fsalt - use ice_flux_bgc, only: flux_bio, faero_ocn + use ice_flux_bgc, only: flux_bio, faero_ocn, fiso_ocn use ice_grid, only: tmask use ice_state, only: trcrn, vsnon, aicen, vicen, & aice, aice0, trcr_depend, n_trcr_strata, & @@ -897,6 +942,7 @@ subroutine step_dyn_ridge (dt, ndtd, iblk) fresh = fresh (i,j, iblk), & fhocn = fhocn (i,j, iblk), & faero_ocn = faero_ocn(i,j,:,iblk), & + fiso_ocn = fiso_ocn (i,j,:,iblk), & aparticn = aparticn (i,j,:,iblk), & krdgn = krdgn (i,j,:,iblk), & aredistn = aredistn (i,j,:,iblk), & diff --git a/cicecore/cicedynB/infrastructure/io/io_binary/ice_restart.F90 b/cicecore/cicedynB/infrastructure/io/io_binary/ice_restart.F90 index 9e9150b6c..8ecfeb6f1 100644 --- a/cicecore/cicedynB/infrastructure/io/io_binary/ice_restart.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_binary/ice_restart.F90 @@ -15,10 +15,11 @@ module ice_restart 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_bgc, nu_dump_aero, nu_dump_fsd + 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 use ice_exit, only: abort_ice use icepack_intfc, only: icepack_query_parameters use icepack_intfc, only: icepack_query_tracer_sizes @@ -52,7 +53,7 @@ subroutine init_restart_read(ice_ic) logical (kind=log_kind) :: & solve_zsal, tr_fsd, & - tr_iage, tr_FY, tr_lvl, tr_aero, tr_pond_cesm, & + 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) :: & @@ -77,7 +78,7 @@ subroutine init_restart_read(ice_ic) 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_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, & + 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, & @@ -320,6 +321,26 @@ subroutine init_restart_read(ice_ic) endif endif + if (tr_iso) then + if (my_task == master_task) then + n = index(filename0,trim(restart_file)) + if (n == 0) call abort_ice(subname//'ERROR: iso 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)),'.iso', & + string2(1:lenstr(string2)) + if (restart_ext) then + call ice_open_ext(nu_restart_iso,filename,0) + else + call ice_open(nu_restart_iso,filename,0) + endif + read (nu_restart_iso) iignore,rignore,rignore + write(nu_diag,*) 'Reading ',filename(1:lenstr(filename)) + endif + endif + if (tr_aero) then if (my_task == master_task) then n = index(filename0,trim(restart_file)) @@ -366,7 +387,7 @@ subroutine init_restart_write(filename_spec) logical (kind=log_kind) :: & solve_zsal, tr_fsd, & - tr_iage, tr_FY, tr_lvl, tr_aero, tr_pond_cesm, & + 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) :: & @@ -383,7 +404,7 @@ subroutine init_restart_write(filename_spec) 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_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, & + 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, & @@ -618,6 +639,26 @@ subroutine init_restart_write(filename_spec) endif endif + if (tr_iso) 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)),'.iso.', & + iyear,'-',month,'-',mday,'-',sec + + if (restart_ext) then + call ice_open_ext(nu_dump_iso,filename,0) + else + call ice_open(nu_dump_iso,filename,0) + endif + + if (my_task == master_task) then + write(nu_dump_iso) istep1,time,time_forc + write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) + endif + + endif + if (tr_aero) then write(filename,'(a,a,a,i4.4,a,i2.2,a,i2.2,a,i5.5)') & @@ -767,7 +808,7 @@ subroutine final_restart() logical (kind=log_kind) :: & solve_zsal, & - tr_iage, tr_FY, tr_lvl, tr_aero, tr_pond_cesm, & + 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) :: & @@ -781,7 +822,7 @@ subroutine final_restart() nbtrcr_out=nbtrcr) 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_cesm_out=tr_pond_cesm, & + 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, & @@ -790,6 +831,7 @@ subroutine final_restart() if (my_task == master_task) then close(nu_dump) + if (tr_iso) close(nu_dump_iso) if (tr_aero) close(nu_dump_aero) if (tr_iage) close(nu_dump_age) if (tr_FY) close(nu_dump_FY) diff --git a/cicecore/cicedynB/infrastructure/io/io_netcdf/ice_restart.F90 b/cicecore/cicedynB/infrastructure/io/io_netcdf/ice_restart.F90 index ecabcc089..d4decf6f7 100644 --- a/cicecore/cicedynB/infrastructure/io/io_netcdf/ice_restart.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_netcdf/ice_restart.F90 @@ -113,7 +113,7 @@ subroutine init_restart_write(filename_spec) 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_aero, nblyr, n_zaero, n_algae, n_doc, & + 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 @@ -124,13 +124,13 @@ subroutine init_restart_write(filename_spec) logical (kind=log_kind) :: & solve_zsal, skl_bgc, z_tracers, tr_fsd, & - tr_iage, tr_FY, tr_lvl, tr_aero, tr_pond_cesm, & + 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_zaero, tr_bgc_Fe, & tr_bgc_hum integer (kind=int_kind) :: & @@ -160,7 +160,7 @@ subroutine init_restart_write(filename_spec) 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_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, & + 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, & @@ -470,6 +470,14 @@ subroutine init_restart_write(filename_spec) enddo endif + if (tr_iso) then + do k=1,n_iso + write(nchar,'(i3.3)') k + call define_rest_field(ncid,'isosno'//trim(nchar),dims) + call define_rest_field(ncid,'isoice'//trim(nchar),dims) + enddo + endif + if (tr_aero) then do k=1,n_aero write(nchar,'(i3.3)') k diff --git a/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 b/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 index 8dc9e94a9..d673c7f7a 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 @@ -125,7 +125,7 @@ subroutine init_restart_write(filename_spec) 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_aero, nblyr, n_zaero, n_algae, n_doc, & + n_iso, n_aero, nblyr, n_zaero, n_algae, n_doc, & n_dic, n_don, n_fed, n_fep use ice_dyn_shared, only: kdyn use ice_arrays_column, only: oceanmixed_ice @@ -134,7 +134,7 @@ subroutine init_restart_write(filename_spec) solve_zsal, skl_bgc, z_tracers logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_aero, tr_pond_cesm, & + 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, & @@ -171,7 +171,7 @@ 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_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, & + 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, & @@ -473,6 +473,14 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'qsno'//trim(nchar),dims) enddo + if (tr_iso) then + do k=1,n_iso + write(nchar,'(i3.3)') k + call define_rest_field(File,'isosno'//nchar, dims) + call define_rest_field(File,'isoice'//nchar, dims) + enddo + endif + if (tr_aero) then do k=1,n_aero write(nchar,'(i3.3)') k diff --git a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 index 8dc9e94a9..d673c7f7a 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 @@ -125,7 +125,7 @@ subroutine init_restart_write(filename_spec) 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_aero, nblyr, n_zaero, n_algae, n_doc, & + n_iso, n_aero, nblyr, n_zaero, n_algae, n_doc, & n_dic, n_don, n_fed, n_fep use ice_dyn_shared, only: kdyn use ice_arrays_column, only: oceanmixed_ice @@ -134,7 +134,7 @@ subroutine init_restart_write(filename_spec) solve_zsal, skl_bgc, z_tracers logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, tr_aero, tr_pond_cesm, & + 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, & @@ -171,7 +171,7 @@ 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_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, & + 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, & @@ -473,6 +473,14 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'qsno'//trim(nchar),dims) enddo + if (tr_iso) then + do k=1,n_iso + write(nchar,'(i3.3)') k + call define_rest_field(File,'isosno'//nchar, dims) + call define_rest_field(File,'isoice'//nchar, dims) + enddo + endif + if (tr_aero) then do k=1,n_aero write(nchar,'(i3.3)') k diff --git a/cicecore/drivers/mct/cesm1/CICE_InitMod.F90 b/cicecore/drivers/mct/cesm1/CICE_InitMod.F90 index b5d2608a3..b72745e30 100644 --- a/cicecore/drivers/mct/cesm1/CICE_InitMod.F90 +++ b/cicecore/drivers/mct/cesm1/CICE_InitMod.F90 @@ -77,7 +77,7 @@ subroutine cice_init(mpicom_ice) 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 + 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 @@ -95,7 +95,7 @@ subroutine cice_init(mpicom_ice) mpicom_ice ! communicator for sequential ccsm logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers, & - tr_fsd, wave_spec + tr_iso, tr_fsd, wave_spec character(len=*), parameter :: subname = '(cice_init)' call init_communicate(mpicom_ice) ! initial setup for message passing @@ -122,7 +122,6 @@ subroutine cice_init(mpicom_ice) 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 @@ -134,6 +133,7 @@ subroutine cice_init(mpicom_ice) endif call init_coupler_flux ! initialize fluxes exchanged with coupler + #ifdef popcice call sst_sss ! POP data for CICE initialization #endif @@ -181,6 +181,7 @@ subroutine cice_init(mpicom_ice) 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) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) @@ -211,6 +212,8 @@ subroutine cice_init(mpicom_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) @@ -239,20 +242,21 @@ subroutine init_restart use ice_calendar, only: time, calendar use ice_constants, only: c0 use ice_domain, only: nblocks - use ice_domain_size, only: ncat, n_aero, nfsd + 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_aerosol, init_hbrine, init_bgc, init_fsd + 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 @@ -265,13 +269,13 @@ subroutine init_restart iblk ! block index logical(kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_pond_cesm, tr_pond_lvl, & - tr_pond_topo, tr_fsd, tr_aero, tr_brine, & + 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_iage, nt_FY, nt_aero, nt_fsd, nt_isosno, nt_isoice character(len=*), parameter :: subname = '(init_restart)' @@ -285,10 +289,11 @@ subroutine init_restart 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_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_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__) @@ -393,6 +398,20 @@ subroutine init_restart 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 diff --git a/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 b/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 index 26d40a431..09cffa0c7 100644 --- a/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 +++ b/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 @@ -22,7 +22,7 @@ module CICE_RunMod 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_max_iso, icepack_max_aero use icepack_intfc, only: icepack_query_parameters use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_sizes @@ -48,12 +48,12 @@ subroutine CICE_Run use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & - faero_default + fiso_default, 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 + tr_iso, tr_aero, tr_zaero, skl_bgc, z_tracers, wave_spec, tr_fsd character(len=*), parameter :: subname = '(CICE_Run)' !-------------------------------------------------------------------- @@ -65,7 +65,8 @@ subroutine CICE_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, & + call icepack_query_tracer_flags(tr_iso_out=tr_iso, & + tr_aero_out=tr_aero, & tr_zaero_out=tr_zaero, & tr_fsd_out=tr_fsd) call icepack_warnings_flush(nu_diag) @@ -95,6 +96,8 @@ subroutine CICE_Run 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) @@ -150,7 +153,7 @@ subroutine ice_step use ice_restart_column, only: write_restart_age, write_restart_FY, & write_restart_lvl, write_restart_pond_cesm, write_restart_pond_lvl, & write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_bgc, write_restart_hbrine + 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, & @@ -172,7 +175,7 @@ subroutine ice_step logical (kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_fsd, & - tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero, & + 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)' @@ -183,7 +186,7 @@ subroutine ice_step 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_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_fsd_out=tr_fsd) + 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__) @@ -236,7 +239,7 @@ subroutine ice_step if (.not.prescribed_ice) & call step_therm2 (dt, iblk) ! ice thickness distribution thermo - endif + endif ! ktherm > 0 enddo ! iblk !$OMP END PARALLEL DO @@ -335,6 +338,7 @@ subroutine ice_step 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_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 @@ -369,7 +373,8 @@ subroutine coupling_prep (iblk) 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, fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai, & + use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, & + 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 @@ -552,7 +557,8 @@ subroutine coupling_prep (iblk) !----------------------------------------------------------------- call scale_fluxes (nx_block, ny_block, & - tmask (:,:,iblk), nbtrcr, icepack_max_aero, & + tmask (:,:,iblk), nbtrcr, & + icepack_max_aero, & aice (:,:,iblk), Tf (:,:,iblk), & Tair (:,:,iblk), Qa (:,:,iblk), & strairxT (:,:,iblk), strairyT(:,:,iblk), & @@ -566,7 +572,10 @@ subroutine coupling_prep (iblk) alvdr (:,:,iblk), alidr (:,:,iblk), & alvdf (:,:,iblk), alidf (:,:,iblk), & fzsal (:,:,iblk), fzsal_g (:,:,iblk), & - flux_bio(:,:,1:nbtrcr,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) ) !----------------------------------------------------------------- diff --git a/cicecore/drivers/mct/cesm1/CICE_RunMod.F90_debug b/cicecore/drivers/mct/cesm1/CICE_RunMod.F90_debug deleted file mode 100644 index 4f8b0a352..000000000 --- a/cicecore/drivers/mct/cesm1/CICE_RunMod.F90_debug +++ /dev/null @@ -1,696 +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 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 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_numbers - - 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: istep, istep1, time, dt, stop_now, calendar - use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, atm_data_type - use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & - 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 - 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) - call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - - !-------------------------------------------------------------------- - ! timestep loop - !-------------------------------------------------------------------- - -! timeLoop: do - - istep = istep + 1 ! update time step counters - istep1 = istep1 + 1 - time = time + dt ! determine the time and date - - call ice_timer_start(timer_couple) ! atm/ocn coupling - -#ifndef coupled -#ifndef CESMCOUPLED - 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 -#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 - -!======================================================================= -! -! 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_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 - 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_cesm, write_restart_pond_lvl, & - write_restart_pond_topo, write_restart_aero, & - 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, save_init - 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 - use ice_prescribed_mod - - 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_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero, & - calc_Tsfc, skl_bgc, solve_zsal, z_tracers - - character(len=*), parameter :: subname = '(ice_step)' - - character (len=char_len) :: plabeld - - 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, & - solve_zsal_out=solve_zsal, z_tracers_out=z_tracers, ktherm_out=ktherm) - 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_brine_out=tr_brine, tr_aero_out=tr_aero) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - - !----------------------------------------------------------------- - ! 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 - - 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, sec) - call t_stopf ('cice_run_presc') - endif - - call save_init - - 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 - !----------------------------------------------------------------- - - if (calc_Tsfc) call prep_radiation (iblk) - - plabeld = 'post prep_radiation' - call debug_ice (iblk, plabeld) - - !----------------------------------------------------------------- - ! thermodynamics and biogeochemistry - !----------------------------------------------------------------- - - call step_therm1 (dt, iblk) ! vertical thermodynamics - - plabeld = 'post step_therm1' - call debug_ice (iblk, plabeld) - - call biogeochemistry (dt, iblk) ! biogeochemistry - - plabeld = 'post biogeochemistry' - call debug_ice (iblk, plabeld) - - if (.not.prescribed_ice) & - call step_therm2 (dt, iblk) ! ice thickness distribution thermo - - plabeld = 'post step_therm2' - call debug_ice (iblk, plabeld) - - 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 - !----------------------------------------------------------------- - - if (.not.prescribed_ice) then - do k = 1, ndtd - - ! momentum, stress, transport - call step_dyn_horiz (dt_dyn) - - plabeld = 'post step_dyn_horiz' - call debug_ice (iblk, plabeld) - - ! ridging - !$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 - - ! clean up, update tendency diagnostics - offset = c0 - call update_state (dt_dyn, daidtd, dvidtd, dagedtd, offset) - - enddo - - plabeld = 'post dynamics' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - - endif - - !----------------------------------------------------------------- - ! 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) - - plabeld = 'post step_radiation' - call debug_ice (iblk, plabeld) - - !----------------------------------------------------------------- - ! get ready for coupling and the next time step - !----------------------------------------------------------------- - - call coupling_prep (iblk) - - plabeld = 'post coupling_prep' - call debug_ice (iblk, plabeld) - - 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_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_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, 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, & - swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyT, & - fsens, flat, fswabs, flwout, evap, Tref, Qref, & - scale_fluxes, frzmlt_init, frzmlt, Uref, wind, fsurfn_f, flatn_f - use ice_flux_bgc, only: faero_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, 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) :: & - skl_bgc , & ! - 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_parameters(skl_bgc_out=skl_bgc) - call icepack_query_tracer_numbers(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,iblk) ! 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 - !----------------------------------------------------------------- - - call scale_fluxes (nx_block, ny_block, & - tmask (:,:,iblk), nbtrcr, icepack_max_aero, & - aice (:,:,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), & - faero_ocn(:,:,:,iblk), & - alvdr (:,:,iblk), alidr (:,:,iblk), & - alvdf (:,:,iblk), alidf (:,:,iblk), & - fzsal (:,:,iblk), fzsal_g (:,:,iblk), & - flux_bio(:,:,1:nbtrcr,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, & - flux_bio(:,:,1:nbtrcr,iblk), & - fnit(:,:,iblk), fsil(:,:,iblk), & - famm(:,:,iblk), fdmsp(:,:,iblk), & - fdms(:,:,iblk), fhum(:,:,iblk), & - fdust(:,:,iblk), falgalN(:,:,:,iblk), & - fdoc(:,:,:,iblk), fdic(:,:,:,iblk), & - fdon(:,:,:,iblk), ffep(:,:,:,iblk), & - ffed(:,:,:,iblk)) - endif - -!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,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 -! 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, & ! - rLsub ! 1/Lsub - - character(len=*), parameter :: subname = '(sfcflux_to_ocn)' - - 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__) - 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/nuopc/cmeps/CICE_InitMod.F90 b/cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90 index cb3e7bb98..b72745e30 100644 --- a/cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90 +++ b/cicecore/drivers/nuopc/cmeps/CICE_InitMod.F90 @@ -77,7 +77,7 @@ subroutine cice_init(mpicom_ice) 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 + 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 @@ -95,7 +95,7 @@ subroutine cice_init(mpicom_ice) mpicom_ice ! communicator for sequential ccsm logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers, & - tr_fsd, wave_spec + tr_iso, tr_fsd, wave_spec character(len=*), parameter :: subname = '(cice_init)' call init_communicate(mpicom_ice) ! initial setup for message passing @@ -122,7 +122,6 @@ subroutine cice_init(mpicom_ice) 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 @@ -134,6 +133,7 @@ subroutine cice_init(mpicom_ice) endif call init_coupler_flux ! initialize fluxes exchanged with coupler + #ifdef popcice call sst_sss ! POP data for CICE initialization #endif @@ -181,6 +181,7 @@ subroutine cice_init(mpicom_ice) 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) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) @@ -194,6 +195,11 @@ subroutine cice_init(mpicom_ice) 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 !-------------------------------------------------------------------- @@ -206,6 +212,8 @@ subroutine cice_init(mpicom_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) @@ -234,20 +242,21 @@ subroutine init_restart use ice_calendar, only: time, calendar use ice_constants, only: c0 use ice_domain, only: nblocks - use ice_domain_size, only: ncat, n_aero, nfsd + 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_aerosol, init_hbrine, init_bgc, init_fsd + 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 @@ -260,13 +269,13 @@ subroutine init_restart iblk ! block index logical(kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_pond_cesm, tr_pond_lvl, & - tr_pond_topo, tr_fsd, tr_aero, tr_brine, & + 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_iage, nt_FY, nt_aero, nt_fsd, nt_isosno, nt_isoice character(len=*), parameter :: subname = '(init_restart)' @@ -280,10 +289,11 @@ subroutine init_restart 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_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_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__) @@ -388,6 +398,20 @@ subroutine init_restart 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 diff --git a/cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90 b/cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90 index 26d40a431..09cffa0c7 100644 --- a/cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90 +++ b/cicecore/drivers/nuopc/cmeps/CICE_RunMod.F90 @@ -22,7 +22,7 @@ module CICE_RunMod 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_max_iso, icepack_max_aero use icepack_intfc, only: icepack_query_parameters use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_sizes @@ -48,12 +48,12 @@ subroutine CICE_Run use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & - faero_default + fiso_default, 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 + tr_iso, tr_aero, tr_zaero, skl_bgc, z_tracers, wave_spec, tr_fsd character(len=*), parameter :: subname = '(CICE_Run)' !-------------------------------------------------------------------- @@ -65,7 +65,8 @@ subroutine CICE_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, & + call icepack_query_tracer_flags(tr_iso_out=tr_iso, & + tr_aero_out=tr_aero, & tr_zaero_out=tr_zaero, & tr_fsd_out=tr_fsd) call icepack_warnings_flush(nu_diag) @@ -95,6 +96,8 @@ subroutine CICE_Run 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) @@ -150,7 +153,7 @@ subroutine ice_step use ice_restart_column, only: write_restart_age, write_restart_FY, & write_restart_lvl, write_restart_pond_cesm, write_restart_pond_lvl, & write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_bgc, write_restart_hbrine + 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, & @@ -172,7 +175,7 @@ subroutine ice_step logical (kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_fsd, & - tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero, & + 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)' @@ -183,7 +186,7 @@ subroutine ice_step 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_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_fsd_out=tr_fsd) + 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__) @@ -236,7 +239,7 @@ subroutine ice_step if (.not.prescribed_ice) & call step_therm2 (dt, iblk) ! ice thickness distribution thermo - endif + endif ! ktherm > 0 enddo ! iblk !$OMP END PARALLEL DO @@ -335,6 +338,7 @@ subroutine ice_step 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_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 @@ -369,7 +373,8 @@ subroutine coupling_prep (iblk) 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, fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai, & + use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, & + 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 @@ -552,7 +557,8 @@ subroutine coupling_prep (iblk) !----------------------------------------------------------------- call scale_fluxes (nx_block, ny_block, & - tmask (:,:,iblk), nbtrcr, icepack_max_aero, & + tmask (:,:,iblk), nbtrcr, & + icepack_max_aero, & aice (:,:,iblk), Tf (:,:,iblk), & Tair (:,:,iblk), Qa (:,:,iblk), & strairxT (:,:,iblk), strairyT(:,:,iblk), & @@ -566,7 +572,10 @@ subroutine coupling_prep (iblk) alvdr (:,:,iblk), alidr (:,:,iblk), & alvdf (:,:,iblk), alidf (:,:,iblk), & fzsal (:,:,iblk), fzsal_g (:,:,iblk), & - flux_bio(:,:,1:nbtrcr,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) ) !----------------------------------------------------------------- diff --git a/cicecore/drivers/nuopc/dmi/CICE_InitMod.F90 b/cicecore/drivers/nuopc/dmi/CICE_InitMod.F90 index fd9449efd..986189f96 100644 --- a/cicecore/drivers/nuopc/dmi/CICE_InitMod.F90 +++ b/cicecore/drivers/nuopc/dmi/CICE_InitMod.F90 @@ -16,8 +16,8 @@ module CICE_InitMod 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_fsd_bounds, icepack_init_wave 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, & @@ -49,6 +49,7 @@ subroutine CICE_Initialize(mpi_comm) !-------------------------------------------------------------------- ! model initialization !-------------------------------------------------------------------- + if (present(mpi_comm)) then call cice_init(mpi_comm) else @@ -81,7 +82,7 @@ subroutine cice_init(mpi_comm) 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 + 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 @@ -94,11 +95,14 @@ subroutine cice_init(mpi_comm) #ifdef popcice use drv_forcing, only: sst_sss #endif + integer (kind=int_kind), optional, intent(in) :: & - mpi_comm ! communicator for sequential ccsm + mpi_comm ! communicator for sequential ccsm + logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers, & - tr_fsd, wave_spec + tr_iso, tr_fsd, wave_spec character(len=*), parameter :: subname = '(cice_init)' + if (present(mpi_comm)) then call init_communicate(mpi_comm) ! initial setup for message passing else @@ -130,7 +134,6 @@ subroutine cice_init(mpi_comm) 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 @@ -142,6 +145,7 @@ subroutine cice_init(mpi_comm) endif call init_coupler_flux ! initialize fluxes exchanged with coupler + #ifdef popcice call sst_sss ! POP data for CICE initialization #endif @@ -189,6 +193,7 @@ subroutine cice_init(mpi_comm) 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) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) @@ -220,6 +225,9 @@ subroutine cice_init(mpi_comm) #ifndef CICE_DMI call get_forcing_ocn(dt) ! ocean forcing from data #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) @@ -248,20 +256,21 @@ subroutine init_restart use ice_calendar, only: time, calendar use ice_constants, only: c0 use ice_domain, only: nblocks - use ice_domain_size, only: ncat, n_aero, nfsd + 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_aerosol, init_hbrine, init_bgc, init_fsd + 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 @@ -274,13 +283,13 @@ subroutine init_restart iblk ! block index logical(kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_pond_cesm, tr_pond_lvl, & - tr_pond_topo, tr_fsd, tr_aero, tr_brine, & + 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_iage, nt_FY, nt_aero, nt_fsd, nt_isosno, nt_isoice character(len=*), parameter :: subname = '(init_restart)' @@ -294,10 +303,11 @@ subroutine init_restart 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_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_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__) @@ -402,6 +412,20 @@ subroutine init_restart 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 diff --git a/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90 b/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90 index 11587cd83..ad575f714 100644 --- a/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90 +++ b/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90 @@ -21,7 +21,7 @@ module CICE_RunMod 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_max_iso, icepack_max_aero use icepack_intfc, only: icepack_query_parameters use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_sizes @@ -47,12 +47,12 @@ subroutine CICE_Run use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & - faero_default + fiso_default, 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 + tr_iso, tr_aero, tr_zaero, skl_bgc, z_tracers, wave_spec, tr_fsd character(len=*), parameter :: subname = '(CICE_Run)' !-------------------------------------------------------------------- @@ -64,7 +64,8 @@ subroutine CICE_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, & + call icepack_query_tracer_flags(tr_iso_out=tr_iso, & + tr_aero_out=tr_aero, & tr_zaero_out=tr_zaero, & tr_fsd_out=tr_fsd) call icepack_warnings_flush(nu_diag) @@ -103,6 +104,9 @@ subroutine CICE_Run #ifndef CICE_DMI call get_forcing_ocn(dt) ! ocean forcing from data #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) @@ -155,7 +159,7 @@ subroutine ice_step use ice_restart_column, only: write_restart_age, write_restart_FY, & write_restart_lvl, write_restart_pond_cesm, write_restart_pond_lvl, & write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_bgc, write_restart_hbrine + 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, & @@ -175,7 +179,7 @@ subroutine ice_step logical (kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_fsd, & - tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero, & + 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)' @@ -186,7 +190,7 @@ subroutine ice_step 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_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_fsd_out=tr_fsd) + 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__) @@ -231,7 +235,7 @@ subroutine ice_step call biogeochemistry (dt, iblk) ! biogeochemistry call step_therm2 (dt, iblk) ! ice thickness distribution thermo - endif + endif ! ktherm > 0 enddo ! iblk !$OMP END PARALLEL DO @@ -326,6 +330,7 @@ subroutine ice_step 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_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 @@ -360,7 +365,8 @@ subroutine coupling_prep (iblk) 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, fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai + use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, & + 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 @@ -539,7 +545,8 @@ subroutine coupling_prep (iblk) !----------------------------------------------------------------- call scale_fluxes (nx_block, ny_block, & - tmask (:,:,iblk), nbtrcr, icepack_max_aero, & + tmask (:,:,iblk), nbtrcr, & + icepack_max_aero, & aice (:,:,iblk), Tf (:,:,iblk), & Tair (:,:,iblk), Qa (:,:,iblk), & strairxT (:,:,iblk), strairyT(:,:,iblk), & @@ -553,7 +560,10 @@ subroutine coupling_prep (iblk) alvdr (:,:,iblk), alidr (:,:,iblk), & alvdf (:,:,iblk), alidf (:,:,iblk), & fzsal (:,:,iblk), fzsal_g (:,:,iblk), & - flux_bio(:,:,1:nbtrcr,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 diff --git a/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90_debug b/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90_debug deleted file mode 100644 index 5de6b1cfd..000000000 --- a/cicecore/drivers/nuopc/dmi/CICE_RunMod.F90_debug +++ /dev/null @@ -1,686 +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_numbers - - 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: 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, & - 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 - - 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 -#endif - - 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 - - ! 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 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_dyn_eap, only: write_restart_eap - use ice_dyn_shared, only: kdyn, kridge - 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_cesm, 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_step_mod, only: prep_radiation, step_therm1, step_therm2, & - update_state, step_dyn_horiz, step_dyn_ridge, step_radiation, & - 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 - 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_cesm, 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)' - - character (len=char_len) :: plabeld - - 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, & - 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_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_fsd_out=tr_fsd) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - - !----------------------------------------------------------------- - ! 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 save_init - - !$OMP PARALLEL DO PRIVATE(iblk) - do iblk = 1, nblocks - - if (ktherm >= 0) then - - !----------------------------------------------------------------- - ! scale radiation fields - !----------------------------------------------------------------- - - if (calc_Tsfc) call prep_radiation (iblk) - - plabeld = 'post prep_radiation' - call debug_ice (iblk, plabeld) - - !----------------------------------------------------------------- - ! thermodynamics and biogeochemistry - !----------------------------------------------------------------- - - call step_therm1 (dt, iblk) ! vertical thermodynamics - - plabeld = 'post step_therm1' - call debug_ice (iblk, plabeld) - - call biogeochemistry (dt, iblk) ! biogeochemistry - - plabeld = 'post biogeochemistry' - call debug_ice (iblk, plabeld) - - call step_therm2 (dt, iblk) ! ice thickness distribution thermo - - plabeld = 'post step_therm2' - call debug_ice (iblk, plabeld) - - 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) - - plabeld = 'post step_dyn_horiz' - call debug_ice (iblk, plabeld) - - ! ridging - !$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 - - ! clean up, update tendency diagnostics - offset = c0 - call update_state (dt_dyn, daidtd, dvidtd, dagedtd, offset) - - enddo - - plabeld = 'post dynamics' - do iblk = 1, nblocks - call debug_ice (iblk, plabeld) - enddo - - !----------------------------------------------------------------- - ! albedo, shortwave radiation - !----------------------------------------------------------------- - - 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 - - if (ktherm >= 0) call step_radiation (dt, iblk) - - plabeld = 'post step_radiation' - call debug_ice (iblk, plabeld) - - !----------------------------------------------------------------- - ! get ready for coupling and the next time step - !----------------------------------------------------------------- - - call coupling_prep (iblk) - - plabeld = 'post coupling_prep' - call debug_ice (iblk, plabeld) - - 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_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_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, 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, & - 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, 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 - use ice_state, only: aice_init - use ice_flux, only: flatn_f, fsurfn_f -#endif - 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_numbers(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 - !----------------------------------------------------------------- - - call scale_fluxes (nx_block, ny_block, & - tmask (:,:,iblk), nbtrcr, icepack_max_aero, & - aice (:,:,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), & - faero_ocn(:,:,:,iblk), & - alvdr (:,:,iblk), alidr (:,:,iblk), & - alvdf (:,:,iblk), alidf (:,:,iblk), & - fzsal (:,:,iblk), fzsal_g (:,:,iblk), & - flux_bio(:,:,1:nbtrcr,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. - !--------------------------------------------------------------- - - 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 -#endif - call ice_timer_stop(timer_couple) ! atm/ocn coupling - - end subroutine coupling_prep - -#ifdef CICE_IN_NEMO - -!======================================================================= -! -! 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) - - - ! local variables - integer (kind=int_kind) :: & - i, j, n ! horizontal indices - - real (kind=dbl_kind) :: & - puny, & ! - rLsub ! 1/Lsub - - character(len=*), parameter :: subname = '(sfcflux_to_ocn)' - - 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__) - 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 - - - end subroutine sfcflux_to_ocn - -#endif - -!======================================================================= - - end module CICE_RunMod - -!======================================================================= diff --git a/cicecore/drivers/standalone/cice/CICE_InitMod.F90 b/cicecore/drivers/standalone/cice/CICE_InitMod.F90 index 0b61433a3..59bbca31c 100644 --- a/cicecore/drivers/standalone/cice/CICE_InitMod.F90 +++ b/cicecore/drivers/standalone/cice/CICE_InitMod.F90 @@ -77,7 +77,7 @@ subroutine cice_init 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 + 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 @@ -92,7 +92,7 @@ subroutine cice_init #endif logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers, & - tr_fsd, wave_spec + tr_iso, tr_fsd, wave_spec character(len=*), parameter :: subname = '(cice_init)' call init_communicate ! initial setup for message passing @@ -122,7 +122,6 @@ subroutine cice_init 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 @@ -134,6 +133,7 @@ subroutine cice_init endif call init_coupler_flux ! initialize fluxes exchanged with coupler + #ifdef popcice call sst_sss ! POP data for CICE initialization #endif @@ -181,6 +181,7 @@ subroutine cice_init 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) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) @@ -211,6 +212,8 @@ subroutine cice_init 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) @@ -239,20 +242,21 @@ subroutine init_restart use ice_calendar, only: time, calendar use ice_constants, only: c0 use ice_domain, only: nblocks - use ice_domain_size, only: ncat, n_aero, nfsd + 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_aerosol, init_hbrine, init_bgc, init_fsd + 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 @@ -265,13 +269,13 @@ subroutine init_restart iblk ! block index logical(kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_pond_cesm, tr_pond_lvl, & - tr_pond_topo, tr_fsd, tr_aero, tr_brine, & + 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_iage, nt_FY, nt_aero, nt_fsd, nt_isosno, nt_isoice character(len=*), parameter :: subname = '(init_restart)' @@ -285,10 +289,11 @@ subroutine init_restart 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_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_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__) @@ -393,6 +398,20 @@ subroutine init_restart 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 diff --git a/cicecore/drivers/standalone/cice/CICE_RunMod.F90 b/cicecore/drivers/standalone/cice/CICE_RunMod.F90 index ad974475b..7645c43f3 100644 --- a/cicecore/drivers/standalone/cice/CICE_RunMod.F90 +++ b/cicecore/drivers/standalone/cice/CICE_RunMod.F90 @@ -21,7 +21,7 @@ module CICE_RunMod 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_max_iso, icepack_max_aero use icepack_intfc, only: icepack_query_parameters use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_sizes @@ -47,12 +47,12 @@ subroutine CICE_Run use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & - faero_default + fiso_default, 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 + tr_iso, tr_aero, tr_zaero, skl_bgc, z_tracers, wave_spec, tr_fsd character(len=*), parameter :: subname = '(CICE_Run)' !-------------------------------------------------------------------- @@ -64,7 +64,8 @@ subroutine CICE_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, & + call icepack_query_tracer_flags(tr_iso_out=tr_iso, & + tr_aero_out=tr_aero, & tr_zaero_out=tr_zaero, & tr_fsd_out=tr_fsd) call icepack_warnings_flush(nu_diag) @@ -100,6 +101,8 @@ subroutine CICE_Run 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) @@ -151,7 +154,7 @@ subroutine ice_step use ice_restart_column, only: write_restart_age, write_restart_FY, & write_restart_lvl, write_restart_pond_cesm, write_restart_pond_lvl, & write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_bgc, write_restart_hbrine + 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, & @@ -171,7 +174,7 @@ subroutine ice_step logical (kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_fsd, & - tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero, & + 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)' @@ -182,7 +185,7 @@ subroutine ice_step 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_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_fsd_out=tr_fsd) + 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__) @@ -227,7 +230,7 @@ subroutine ice_step call biogeochemistry (dt, iblk) ! biogeochemistry call step_therm2 (dt, iblk) ! ice thickness distribution thermo - endif + endif ! ktherm > 0 enddo ! iblk !$OMP END PARALLEL DO @@ -322,6 +325,7 @@ subroutine ice_step 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_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 @@ -356,7 +360,8 @@ subroutine coupling_prep (iblk) 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, fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai + use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, & + 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 @@ -535,7 +540,8 @@ subroutine coupling_prep (iblk) !----------------------------------------------------------------- call scale_fluxes (nx_block, ny_block, & - tmask (:,:,iblk), nbtrcr, icepack_max_aero, & + tmask (:,:,iblk), nbtrcr, & + icepack_max_aero, & aice (:,:,iblk), Tf (:,:,iblk), & Tair (:,:,iblk), Qa (:,:,iblk), & strairxT (:,:,iblk), strairyT(:,:,iblk), & @@ -549,7 +555,10 @@ subroutine coupling_prep (iblk) alvdr (:,:,iblk), alidr (:,:,iblk), & alvdf (:,:,iblk), alidf (:,:,iblk), & fzsal (:,:,iblk), fzsal_g (:,:,iblk), & - flux_bio(:,:,1:nbtrcr,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 diff --git a/cicecore/drivers/standalone/cice/CICE_RunMod.F90_debug b/cicecore/drivers/standalone/cice/CICE_RunMod.F90_debug index 5de6b1cfd..7ca555433 100644 --- a/cicecore/drivers/standalone/cice/CICE_RunMod.F90_debug +++ b/cicecore/drivers/standalone/cice/CICE_RunMod.F90_debug @@ -21,9 +21,9 @@ 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_max_iso, icepack_max_aero use icepack_intfc, only: icepack_query_parameters - use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_numbers + use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_sizes implicit none private @@ -47,12 +47,12 @@ use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, & get_wave_spec use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & - faero_default + fiso_default, 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 + tr_iso, tr_aero, tr_zaero, skl_bgc, z_tracers, wave_spec, tr_fsd character(len=*), parameter :: subname = '(CICE_Run)' !-------------------------------------------------------------------- @@ -64,7 +64,8 @@ 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, & + call icepack_query_tracer_flags(tr_iso_out=tr_iso, & + tr_aero_out=tr_aero, & tr_zaero_out=tr_zaero, & tr_fsd_out=tr_fsd) call icepack_warnings_flush(nu_diag) @@ -100,6 +101,8 @@ 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) @@ -151,7 +154,7 @@ use ice_restart_column, only: write_restart_age, write_restart_FY, & write_restart_lvl, write_restart_pond_cesm, write_restart_pond_lvl, & write_restart_pond_topo, write_restart_aero, write_restart_fsd, & - write_restart_bgc, write_restart_hbrine + 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, & @@ -171,7 +174,7 @@ logical (kind=log_kind) :: & tr_iage, tr_FY, tr_lvl, tr_fsd, & - tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero, & + 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)' @@ -189,7 +192,7 @@ 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_brine_out=tr_brine, tr_aero_out=tr_aero, & - tr_fsd_out=tr_fsd) + 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__) @@ -273,8 +276,10 @@ ! momentum, stress, transport call step_dyn_horiz (dt_dyn) + do iblk = 1, nblocks plabeld = 'post step_dyn_horiz' call debug_ice (iblk, plabeld) + enddo ! iblk ! ridging !$OMP PARALLEL DO PRIVATE(iblk) @@ -283,6 +288,11 @@ enddo !$OMP END PARALLEL DO + do iblk = 1, nblocks + plabeld = 'post step_dyn_ridge' + call debug_ice (iblk, plabeld) + enddo ! iblk + ! clean up, update tendency diagnostics offset = c0 call update_state (dt_dyn, daidtd, dvidtd, dagedtd, offset) @@ -357,6 +367,7 @@ 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_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 @@ -391,7 +402,8 @@ 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, fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai + use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, & + 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 @@ -428,7 +440,7 @@ character(len=*), parameter :: subname = '(coupling_prep)' call icepack_query_parameters(puny_out=puny, rhofresh_out=rhofresh) - call icepack_query_tracer_numbers(nbtrcr_out=nbtrcr) + 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, & @@ -570,7 +582,8 @@ !----------------------------------------------------------------- call scale_fluxes (nx_block, ny_block, & - tmask (:,:,iblk), nbtrcr, icepack_max_aero, & + tmask (:,:,iblk), nbtrcr, & + icepack_max_aero, & aice (:,:,iblk), Tf (:,:,iblk), & Tair (:,:,iblk), Qa (:,:,iblk), & strairxT (:,:,iblk), strairyT(:,:,iblk), & @@ -584,7 +597,10 @@ alvdr (:,:,iblk), alidr (:,:,iblk), & alvdf (:,:,iblk), alidf (:,:,iblk), & fzsal (:,:,iblk), fzsal_g (:,:,iblk), & - flux_bio(:,:,1:nbtrcr,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 diff --git a/cicecore/shared/ice_domain_size.F90 b/cicecore/shared/ice_domain_size.F90 index 6f7a73aa1..56381b986 100644 --- a/cicecore/shared/ice_domain_size.F90 +++ b/cicecore/shared/ice_domain_size.F90 @@ -32,10 +32,11 @@ module ice_domain_size nfsd , & ! number of floe size categories nilyr , & ! number of ice layers per category nslyr , & ! number of snow layers per category - nblyr , & ! number of bio/brine layers per category + nblyr , & ! number of bio/brine layers per category + n_iso , & ! number of isotopes in use n_aero , & ! number of aerosols in use - n_zaero , & ! number of z aerosols in use - n_algae , & ! number of algae in use + n_zaero , & ! number of z aerosols in use + n_algae , & ! number of algae in use n_doc , & ! number of DOC pools in use n_dic , & ! number of DIC pools in use n_don , & ! number of DON pools in use diff --git a/cicecore/shared/ice_fileunits.F90 b/cicecore/shared/ice_fileunits.F90 index 00f7acaef..cf67538aa 100644 --- a/cicecore/shared/ice_fileunits.F90 +++ b/cicecore/shared/ice_fileunits.F90 @@ -54,6 +54,8 @@ module ice_fileunits nu_restart_pond,& ! restart input file for melt pond tracer nu_dump_fsd , & ! dump file for restarting floe size distribution nu_restart_fsd, & ! restart input file for floe size distribution + nu_dump_iso , & ! dump file for restarting isotope tracers + nu_restart_iso, & ! restart input file for isotope tracers nu_dump_aero , & ! dump file for restarting aerosol tracer nu_restart_aero,& ! restart input file for aerosol tracer nu_dump_bgc , & ! dump file for restarting bgc @@ -130,6 +132,8 @@ subroutine init_fileunits call get_fileunit(nu_restart_pond) call get_fileunit(nu_dump_fsd) call get_fileunit(nu_restart_fsd) + call get_fileunit(nu_dump_iso) + call get_fileunit(nu_restart_iso) call get_fileunit(nu_dump_aero) call get_fileunit(nu_restart_aero) call get_fileunit(nu_dump_bgc) @@ -217,6 +221,8 @@ subroutine release_all_fileunits call release_fileunit(nu_restart_pond) call release_fileunit(nu_dump_fsd) call release_fileunit(nu_restart_fsd) + call release_fileunit(nu_dump_iso) + call release_fileunit(nu_restart_iso) call release_fileunit(nu_dump_aero) call release_fileunit(nu_restart_aero) call release_fileunit(nu_dump_bgc) diff --git a/cicecore/shared/ice_init_column.F90 b/cicecore/shared/ice_init_column.F90 index 19deb0159..fbcc8413b 100644 --- a/cicecore/shared/ice_init_column.F90 +++ b/cicecore/shared/ice_init_column.F90 @@ -45,7 +45,7 @@ module ice_init_column init_age, init_FY, init_lvl, init_fsd, & init_meltponds_cesm, init_meltponds_lvl, init_meltponds_topo, & init_aerosol, init_bgc, init_hbrine, init_zbgc, input_zbgc, & - count_tracers + count_tracers, init_isotope ! namelist parameters needed locally @@ -671,6 +671,21 @@ end subroutine init_fsd !======================================================================= +! Initialize isotope tracers (call prior to reading restart data) + + subroutine init_isotope(isosno, isoice) + + real(kind=dbl_kind), dimension(:,:,:,:), intent(out) :: & + isosno, isoice + character(len=*),parameter :: subname='(init_isotope)' + + isosno(:,:,:,:) = c0 + isoice(:,:,:,:) = c0 + + end subroutine init_isotope + +!======================================================================= + ! Initialize ice aerosol tracer (call prior to reading restart data) subroutine init_aerosol(aero) @@ -1731,7 +1746,7 @@ end subroutine input_zbgc subroutine count_tracers - use ice_domain_size, only: nilyr, nslyr, nblyr, nfsd, & + use ice_domain_size, only: nilyr, nslyr, nblyr, nfsd, n_iso, & n_aero, n_zaero, n_algae, n_doc, n_dic, n_don, n_fed, n_fep ! local variables @@ -1743,10 +1758,10 @@ 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_pond_cesm, 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 + integer (kind=int_kind) :: nt_fsd, nt_isosno, nt_isoice integer (kind=int_kind) :: & nbtrcr, nbtrcr_sw, & @@ -1829,6 +1844,7 @@ subroutine count_tracers tr_lvl_out=tr_lvl, 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, tr_brine_out=tr_brine, tr_fsd_out=tr_fsd, & + 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, & @@ -1897,13 +1913,22 @@ subroutine count_tracers ntrcr = ntrcr + nfsd endif + nt_isosno = 0 + nt_isoice = 0 + if (tr_iso) then + nt_isosno = ntrcr + 1 ! isotopes in snow + ntrcr = ntrcr + n_iso + nt_isoice = ntrcr + 1 ! isotopes in ice + ntrcr = ntrcr + n_iso + endif + nt_aero = 0 if (tr_aero) then nt_aero = ntrcr + 1 ntrcr = ntrcr + 4*n_aero ! 4 dEdd layers, n_aero species else !tcx, modify code so we don't have to reset n_aero here - n_aero = 0 + n_aero = 0 !echmod - this is not getting set correctly (overwritten later?) endif !----------------------------------------------------------------- @@ -2178,6 +2203,8 @@ subroutine count_tracers if (nt_hpnd <= 0) nt_hpnd = ntrcr if (nt_ipnd <= 0) nt_ipnd = 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 @@ -2201,7 +2228,7 @@ 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_fbri_in=nt_fbri, & + 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_S_in=nt_bgc_S, & nt_bgc_N_in=nt_bgc_N, nt_bgc_chl_in=nt_bgc_chl, & diff --git a/cicecore/shared/ice_restart_column.F90 b/cicecore/shared/ice_restart_column.F90 index 34055a751..e830dd50b 100644 --- a/cicecore/shared/ice_restart_column.F90 +++ b/cicecore/shared/ice_restart_column.F90 @@ -33,6 +33,7 @@ module ice_restart_column write_restart_pond_lvl, read_restart_pond_lvl, & write_restart_pond_topo, read_restart_pond_topo, & 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 @@ -45,6 +46,7 @@ module ice_restart_column restart_pond_lvl , & ! if .true., read meltponds restart file restart_pond_topo, & ! if .true., read meltponds 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 @@ -551,6 +553,89 @@ end subroutine read_restart_fsd !======================================================================= +! Dumps all values needed for restarting +! author Elizabeth C. Hunke, LANL + + subroutine write_restart_iso() + + use ice_domain_size, only: n_iso + use ice_fileunits, only: nu_dump_iso + use ice_state, only: trcrn + + ! local variables + + logical (kind=log_kind) :: diag + integer (kind=int_kind) :: nt_isosno, nt_isoice, k + 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) + 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, n_iso + write(ck,'(i3.3)') k + call write_restart_field(nu_dump_iso,0, trcrn(:,:,nt_isosno+k-1,:,:), & + 'ruf8','isosno'//trim(ck),ncat,diag) + enddo + + do k = 1, n_iso + write(ck,'(i3.3)') k + call write_restart_field(nu_dump_iso,0, trcrn(:,:,nt_isoice+k-1,:,:), & + 'ruf8','isoice'//trim(ck),ncat,diag) + enddo + + end subroutine write_restart_iso + +!======================================================================= + +! Reads all values needed to restart isotope tracers +! author Elizabeth C. Hunke, LANL + + subroutine read_restart_iso() + + use ice_domain_size, only: n_iso + use ice_fileunits, only: nu_restart_iso + use ice_state, only: trcrn + + ! local variables + + logical (kind=log_kind) :: & + diag + integer (kind=int_kind) :: nt_isosno, nt_isoice, k + 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) + 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, n_iso + write(ck,'(i3.3)') k + call read_restart_field(nu_restart_iso,0,trcrn(:,:,nt_isosno+k-1,:,:), & + 'ruf8','isosno'//trim(ck),ncat,diag, & + field_type=field_type_scalar,field_loc=field_loc_center) + enddo + + do k = 1, n_iso + write(ck,'(i3.3)') k + call read_restart_field(nu_restart_iso,0,trcrn(:,:,nt_isoice+k-1,:,:), & + 'ruf8','isoice'//trim(ck),ncat,diag, & + field_type=field_type_scalar,field_loc=field_loc_center) + enddo + + end subroutine read_restart_iso + +!======================================================================= + ! Dumps all values needed for restarting ! ! authors Elizabeth Hunke, LANL (original version) diff --git a/configuration/scripts/ice_in b/configuration/scripts/ice_in index 406e8ec91..3e21dd332 100644 --- a/configuration/scripts/ice_in +++ b/configuration/scripts/ice_in @@ -63,6 +63,7 @@ / &tracer_nml + n_iso = 0 n_aero = 1 n_zaero = 0 n_algae = 0 @@ -83,6 +84,8 @@ restart_pond_topo = .false. tr_pond_lvl = .true. restart_pond_lvl = .false. + tr_iso = .false. + restart_iso = .false. tr_aero = .false. restart_aero = .false. tr_fsd = .false. @@ -529,9 +532,12 @@ / &icefields_bgc_nml + f_fiso_atm = 'x' + f_fiso_ocn = 'x' + f_iso = 'x' f_faero_atm = 'x' f_faero_ocn = 'x' - f_aero = 'x' + f_aero = 'x' f_fbio = 'm' f_fbio_ai = 'm' f_zaero = 'x' diff --git a/configuration/scripts/machines/env.badger_intel b/configuration/scripts/machines/env.badger_intel index 3e7bb4f8c..8fe69148b 100755 --- a/configuration/scripts/machines/env.badger_intel +++ b/configuration/scripts/machines/env.badger_intel @@ -37,7 +37,8 @@ setenv ICE_MACHINE_WKDIR /net/scratch3/$user/CICE_RUNS setenv ICE_MACHINE_INPUTDATA /usr/projects/climate/eclare/DATA/Consortium setenv ICE_MACHINE_BASELINE /net/scratch3/$user/CICE_BASELINE setenv ICE_MACHINE_SUBMIT "sbatch " -setenv ICE_MACHINE_ACCT e3sm +#setenv ICE_MACHINE_ACCT e3sm +setenv ICE_MACHINE_ACCT climatehilat setenv ICE_MACHINE_QUEUE "default" setenv ICE_MACHINE_TPNODE 16 setenv ICE_MACHINE_BLDTHRDS 1 diff --git a/configuration/scripts/options/set_nml.isotope b/configuration/scripts/options/set_nml.isotope new file mode 100644 index 000000000..b3042ee5f --- /dev/null +++ b/configuration/scripts/options/set_nml.isotope @@ -0,0 +1,2 @@ +n_iso = 3 +tr_iso = .true. diff --git a/configuration/scripts/tests/base_suite.ts b/configuration/scripts/tests/base_suite.ts index 4b0d35e5a..fad8b22f3 100755 --- a/configuration/scripts/tests/base_suite.ts +++ b/configuration/scripts/tests/base_suite.ts @@ -45,3 +45,6 @@ smoke gx3 4x2 fsd1,diag24,run5day,debug smoke gx3 8x2 fsd12,diag24,run5day,short restart gx3 4x2 fsd12,debug,short smoke gx3 8x2 fsd12ww3,diag24,run1day,medium +smoke gx3 4x1 isotope,debug +restart gx3 8x2 isotope + diff --git a/doc/source/developer_guide/dg_other.rst b/doc/source/developer_guide/dg_other.rst index 2a46186bd..7853cb66b 100644 --- a/doc/source/developer_guide/dg_other.rst +++ b/doc/source/developer_guide/dg_other.rst @@ -132,8 +132,8 @@ tracer. A number of optional tracers are available in the code, including ice age, first-year ice area, melt pond area and volume, brine height, -aerosols, and level ice area and volume (from which ridged ice -quantities are derived). Salinity, enthalpies, age, aerosols, level-ice +aerosols, water isotopes, and level ice area and volume (from which ridged ice +quantities are derived). Salinity, enthalpies, age, aerosols, isotopes, level-ice volume, brine height and most melt pond quantities are volume-weighted tracers, while first-year area, pond area, and level-ice area are area-weighted tracers. Biogeochemistry tracers in the skeletal layer are area-weighted, diff --git a/doc/source/science_guide/sg_tracers.rst b/doc/source/science_guide/sg_tracers.rst index bc55a47f9..bbd18eb1f 100644 --- a/doc/source/science_guide/sg_tracers.rst +++ b/doc/source/science_guide/sg_tracers.rst @@ -87,6 +87,7 @@ is not in use. " ", " ", "apnd", "nt_vpnd", " " " ", " ", "apnd", "nt_ipnd", " " "tr_aero", "n_aero", "vice, vsno", "nt_aero"," " + "tr_iso", "n_iso", "vice, vsno", "nt_iso"," " "tr_brine", " ", "vice", "nt_fbri", " " "tr_fsd","nfsd","aice","nt_fsd"," " "solve_zsal", "n_trzs", "fbri or (a,v)ice", "nt_bgc_S", " " @@ -114,5 +115,4 @@ Users may add any number of additional tracers that are transported conservative 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, age of the ice, aerosols, -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 index 411b22fb8..4ab427737 100755 --- a/doc/source/user_guide/ug_case_settings.rst +++ b/doc/source/user_guide/ug_case_settings.rst @@ -206,6 +206,7 @@ Table of namelist options "","*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" @@ -227,6 +228,8 @@ Table of namelist options "","``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", "" "","", "", "", "" diff --git a/icepack b/icepack index edb8c3459..1ae044604 160000 --- a/icepack +++ b/icepack @@ -1 +1 @@ -Subproject commit edb8c3459359f22af20d39d7defe97c4a8b2a419 +Subproject commit 1ae044604498b8d268df6c577556d22d2baa7758 From 85ba54dc5fc66ca2ee12abb650d0ba06753577fb Mon Sep 17 00:00:00 2001 From: mhrib <38077893+mhrib@users.noreply.github.com> Date: Fri, 10 Apr 2020 02:21:04 +0200 Subject: [PATCH 02/19] HYCOM notation: ewndsp,nwndsp --> wndewd,wndnwd (#425) --- cicecore/cicedynB/general/ice_forcing.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index 0632408bf..2bbf72e11 100755 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -4362,8 +4362,8 @@ subroutine hycom_atm_files fsw_file = trim(atm_data_dir)//'/forcing.shwflx.nc' flw_file = trim(atm_data_dir)//'/forcing.radflx.nc' rain_file = trim(atm_data_dir)//'/forcing.precip.nc' - uwind_file = trim(atm_data_dir)//'/forcing.ewndsp.nc' !actually Xward, not Eward - vwind_file = trim(atm_data_dir)//'/forcing.nwndsp.nc' !actually Yward, not Nward + uwind_file = trim(atm_data_dir)//'/forcing.wndewd.nc' + vwind_file = trim(atm_data_dir)//'/forcing.wndnwd.nc' tair_file = trim(atm_data_dir)//'/forcing.airtmp.nc' humid_file = trim(atm_data_dir)//'/forcing.vapmix.nc' @@ -4469,11 +4469,11 @@ subroutine hycom_atm_data call read_data_nc_hycom (read6, recnum, & tair_file, fieldname, Tair_data, & field_loc_center, field_type_scalar) - fieldname = 'ewndsp' + fieldname = 'wndewd' call read_data_nc_hycom (read6, recnum, & uwind_file, fieldname, uatm_data, & field_loc_center, field_type_vector) - fieldname = 'nwndsp' + fieldname = 'wndnwd' call read_data_nc_hycom (read6, recnum, & vwind_file, fieldname, vatm_data, & field_loc_center, field_type_vector) From d529df8cf473cec234a4f5c1bb8d4cef3bf1f5a1 Mon Sep 17 00:00:00 2001 From: Tony Craig Date: Thu, 9 Apr 2020 17:21:27 -0700 Subject: [PATCH 03/19] Jedi DA modifications (#427) --- .../dynamics/ice_transport_driver.F90 | 4 +-- cicecore/cicedynB/general/ice_forcing.F90 | 12 +++---- cicecore/cicedynB/general/ice_forcing_bgc.F90 | 8 ++--- .../infrastructure/comm/mpi/ice_boundary.F90 | 14 ++++---- .../cicedynB/infrastructure/ice_blocks.F90 | 14 ++++---- .../cicedynB/infrastructure/ice_restoring.F90 | 4 +-- cicecore/shared/ice_distribution.F90 | 32 +++++++++++++++++-- cicecore/shared/ice_fileunits.F90 | 2 +- 8 files changed, 57 insertions(+), 33 deletions(-) diff --git a/cicecore/cicedynB/dynamics/ice_transport_driver.F90 b/cicecore/cicedynB/dynamics/ice_transport_driver.F90 index b3c72e8ca..7eaba64cf 100644 --- a/cicecore/cicedynB/dynamics/ice_transport_driver.F90 +++ b/cicecore/cicedynB/dynamics/ice_transport_driver.F90 @@ -44,11 +44,11 @@ module ice_transport_driver integer (kind=int_kind) :: & ntrace ! number of tracers in use - integer (kind=int_kind), dimension(:), allocatable :: & + integer (kind=int_kind), dimension(:), allocatable, public :: & 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 :: & + logical (kind=log_kind), dimension (:), allocatable, public :: & has_dependents ! true if a tracer has dependent tracers integer (kind=int_kind), parameter :: & diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index 2bbf72e11..64f4b4834 100755 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -72,7 +72,7 @@ module ice_forcing sublim_file, & snow_file - character (char_len_long), dimension(:), allocatable :: & ! input data file names + character (char_len_long), dimension(:), allocatable, public :: & ! input data file names topmelt_file, & botmelt_file @@ -84,10 +84,10 @@ module ice_forcing oldrecnum = 0 , & ! old record number (save between steps) oldrecnum4X = 0 ! - real (kind=dbl_kind), dimension(:,:,:), allocatable :: & + real (kind=dbl_kind), dimension(:,:,:), allocatable, public :: & cldf ! cloud fraction - real (kind=dbl_kind), dimension(:,:,:,:), allocatable :: & + real (kind=dbl_kind), dimension(:,:,:,:), allocatable, public :: & fsw_data, & ! field values at 2 temporal data points cldf_data, & fsnow_data, & @@ -107,8 +107,7 @@ module ice_forcing sublim_data, & frain_data - real (kind=dbl_kind), & - dimension(:,:,:,:,:), allocatable :: & + real (kind=dbl_kind), dimension(:,:,:,:,:), allocatable, public :: & topmelt_data, & botmelt_data @@ -141,8 +140,7 @@ module ice_forcing frcidr = 0.31_dbl_kind, & ! frac of incoming sw in near IR direct band frcidf = 0.17_dbl_kind ! frac of incoming sw in near IR diffuse band - real (kind=dbl_kind), & - dimension (:,:,:,:,:), allocatable :: & + real (kind=dbl_kind), dimension (:,:,:,:,:), allocatable, public :: & ocn_frc_m ! ocn data for 12 months logical (kind=log_kind), public :: & diff --git a/cicecore/cicedynB/general/ice_forcing_bgc.F90 b/cicecore/cicedynB/general/ice_forcing_bgc.F90 index 9d49e4349..4eedcfb80 100644 --- a/cicecore/cicedynB/general/ice_forcing_bgc.F90 +++ b/cicecore/cicedynB/general/ice_forcing_bgc.F90 @@ -35,11 +35,11 @@ module ice_forcing_bgc integer (kind=int_kind) :: & bgcrecnum = 0 ! old record number (save between steps) - real (kind=dbl_kind), dimension(:,:,:), allocatable :: & - nitdat , & ! data value toward which nitrate is restored - sildat ! data value toward which silicate is restored + real (kind=dbl_kind), dimension(:,:,:), allocatable, public :: & + nitdat , & ! data value toward which nitrate is restored + sildat ! data value toward which silicate is restored - real (kind=dbl_kind), dimension(:,:,:,:), allocatable, save :: & + real (kind=dbl_kind), dimension(:,:,:,:), allocatable, public :: & nit_data, & ! field values at 2 temporal data points sil_data diff --git a/cicecore/cicedynB/infrastructure/comm/mpi/ice_boundary.F90 b/cicecore/cicedynB/infrastructure/comm/mpi/ice_boundary.F90 index 3dce5a42e..884ee6331 100644 --- a/cicecore/cicedynB/infrastructure/comm/mpi/ice_boundary.F90 +++ b/cicecore/cicedynB/infrastructure/comm/mpi/ice_boundary.F90 @@ -100,19 +100,19 @@ module ice_boundary ! !----------------------------------------------------------------------- - integer (int_kind) :: & + integer (int_kind), public :: & bufSizeSend, &! max buffer size for send messages bufSizeRecv ! max buffer size for recv messages - integer (int_kind), dimension(:,:), allocatable :: & + integer (int_kind), dimension(:,:), allocatable, public :: & bufSendI4, &! buffer for use to send in 2D i4 halo updates bufRecvI4 ! buffer for use to recv in 2D i4 halo updates - real (real_kind), dimension(:,:), allocatable :: & + real (real_kind), dimension(:,:), allocatable, public :: & bufSendR4, &! buffer for use to send in 2D r4 halo updates bufRecvR4 ! buffer for use to recv in 2D r4 halo updates - real (dbl_kind), dimension(:,:), allocatable :: & + real (dbl_kind), dimension(:,:), allocatable, public :: & bufSendR8, &! buffer for use to send in 2D r8 halo updates bufRecvR8 ! buffer for use to recv in 2D r8 halo updates @@ -122,13 +122,13 @@ module ice_boundary ! !----------------------------------------------------------------------- - integer (int_kind), dimension(:,:), allocatable :: & + integer (int_kind), dimension(:,:), allocatable, public :: & bufTripoleI4 - real (real_kind), dimension(:,:), allocatable :: & + real (real_kind), dimension(:,:), allocatable, public :: & bufTripoleR4 - real (dbl_kind), dimension(:,:), allocatable :: & + real (dbl_kind), dimension(:,:), allocatable, public :: & bufTripoleR8 !*********************************************************************** diff --git a/cicecore/cicedynB/infrastructure/ice_blocks.F90 b/cicecore/cicedynB/infrastructure/ice_blocks.F90 index b95ad6acb..5177dd047 100644 --- a/cicecore/cicedynB/infrastructure/ice_blocks.F90 +++ b/cicecore/cicedynB/infrastructure/ice_blocks.F90 @@ -89,15 +89,15 @@ module ice_blocks ! !----------------------------------------------------------------------- - type (block), dimension(:), allocatable :: & + type (block), dimension(:), allocatable, public :: & all_blocks ! block information for all blocks in domain - integer (int_kind), dimension(:,:),allocatable :: & + integer (int_kind), dimension(:,:),allocatable, public :: & all_blocks_ij ! block index stored in Cartesian order ! useful for determining block index ! of neighbor blocks - integer (int_kind), dimension(:,:), allocatable, target :: & + integer (int_kind), dimension(:,:), allocatable, target, public :: & i_global, &! global i index for each point in each block j_global ! global j index for each point in each block @@ -157,10 +157,10 @@ subroutine create_blocks(nx_global, ny_global, ew_boundary_type, & ! !---------------------------------------------------------------------- - allocate(all_blocks(nblocks_tot)) - allocate(i_global(nx_block,nblocks_tot), & - j_global(ny_block,nblocks_tot)) - allocate(all_blocks_ij(nblocks_x,nblocks_y)) + if (.not.allocated(all_blocks)) allocate(all_blocks(nblocks_tot)) + if (.not.allocated(i_global)) allocate(i_global(nx_block,nblocks_tot)) + if (.not.allocated(j_global)) allocate(j_global(ny_block,nblocks_tot)) + if (.not.allocated(all_blocks_ij)) allocate(all_blocks_ij(nblocks_x,nblocks_y)) !---------------------------------------------------------------------- ! diff --git a/cicecore/cicedynB/infrastructure/ice_restoring.F90 b/cicecore/cicedynB/infrastructure/ice_restoring.F90 index 1ef7b9531..09db9c273 100644 --- a/cicecore/cicedynB/infrastructure/ice_restoring.F90 +++ b/cicecore/cicedynB/infrastructure/ice_restoring.F90 @@ -32,12 +32,12 @@ module ice_restoring ! state of the ice for each category !----------------------------------------------------------------- - real (kind=dbl_kind), dimension (:,:,:,:), allocatable :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & aicen_rest , & ! concentration of ice vicen_rest , & ! volume per unit area of ice (m) vsnon_rest ! volume per unit area of snow (m) - real (kind=dbl_kind), dimension (:,:,:,:,:), allocatable :: & + real (kind=dbl_kind), dimension (:,:,:,:,:), allocatable, public :: & trcrn_rest ! tracers !======================================================================= diff --git a/cicecore/shared/ice_distribution.F90 b/cicecore/shared/ice_distribution.F90 index 4af95ae1f..8c5808820 100644 --- a/cicecore/shared/ice_distribution.F90 +++ b/cicecore/shared/ice_distribution.F90 @@ -118,8 +118,7 @@ function create_distribution(dist_type, nprocs, work_per_block) case('spacecurve') - create_distribution = create_distrb_spacecurve(nprocs, & - work_per_block) + create_distribution = create_distrb_spacecurve(nprocs, work_per_block) case default @@ -364,7 +363,7 @@ subroutine ice_distributionDestroy(distribution) ! !---------------------------------------------------------------------- - distribution%nprocs = 0 + distribution%nprocs = 0 distribution%communicator = 0 distribution%numLocalBlocks = 0 @@ -377,6 +376,9 @@ subroutine ice_distributionDestroy(distribution) deallocate(distribution%blockLocation, stat=istat) deallocate(distribution%blockLocalID , stat=istat) deallocate(distribution%blockGlobalID, stat=istat) + deallocate(distribution%blockCnt , stat=istat) + deallocate(distribution%blockindex , stat=istat) + !----------------------------------------------------------------------- @@ -611,6 +613,12 @@ function create_distrb_cart(nprocs, workPerBlock) result(newDistrb) return endif + allocate (newDistrb%blockCnt(nprocs)) + newDistrb%blockCnt(:) = 0 + + allocate(newDistrb%blockIndex(nprocs,max_blocks)) + newDistrb%blockIndex(:,:) = 0 + !---------------------------------------------------------------------- ! ! distribute blocks linearly across processors in each direction @@ -640,6 +648,8 @@ function create_distrb_cart(nprocs, workPerBlock) result(newDistrb) localID = localID + 1 newDistrb%blockLocation(globalID) = processor newDistrb%blockLocalID (globalID) = localID + newDistrb%blockCnt(processor) = newDistrb%blockCnt(processor) + 1 + newDistrb%blockIndex(processor,localID) = globalID else ! no work - eliminate block from distribution newDistrb%blockLocation(globalID) = 0 newDistrb%blockLocalID (globalID) = 0 @@ -966,6 +976,12 @@ function create_distrb_rake(nprocs, workPerBlock) result(newDistrb) return endif + allocate (newDistrb%blockCnt(nprocs)) + newDistrb%blockCnt(:) = 0 + + allocate(newDistrb%blockIndex(nprocs,max_blocks)) + newDistrb%blockIndex(:,:) = 0 + allocate(procTmp(nprocs), stat=istat) if (istat > 0) then call abort_ice( & @@ -981,11 +997,13 @@ function create_distrb_rake(nprocs, workPerBlock) result(newDistrb) if (pid > 0) then procTmp(pid) = procTmp(pid) + 1 newDistrb%blockLocalID (n) = procTmp(pid) + newDistrb%blockIndex(pid,procTmp(pid)) = n else newDistrb%blockLocalID (n) = 0 endif end do + newDistrb%blockCnt(:) = procTmp(:) newDistrb%numLocalBlocks = procTmp(my_task+1) if (minval(procTmp) < 1) then @@ -2146,6 +2164,12 @@ function create_distrb_spacecurve(nprocs,work_per_block) dist%blockLocation=0 dist%blockLocalID =0 + allocate (dist%blockCnt(nprocs)) + dist%blockCnt(:) = 0 + + allocate(dist%blockIndex(nprocs,max_blocks)) + dist%blockIndex(:,:) = 0 + !---------------------------------------------------------------------- ! Create the array to hold the SFC and indices into it !---------------------------------------------------------------------- @@ -2281,12 +2305,14 @@ function create_distrb_spacecurve(nprocs,work_per_block) if(pid>0) then proc_tmp(pid) = proc_tmp(pid) + 1 dist%blockLocalID(n) = proc_tmp(pid) + dist%blockIndex(pid,proc_tmp(pid)) = n else dist%blockLocalID(n) = 0 endif enddo dist%numLocalBlocks = proc_tmp(my_task+1) + dist%blockCnt(:) = proc_tmp(:) if (dist%numLocalBlocks > 0) then allocate (dist%blockGlobalID(dist%numLocalBlocks)) diff --git a/cicecore/shared/ice_fileunits.F90 b/cicecore/shared/ice_fileunits.F90 index cf67538aa..4c91fdb2a 100644 --- a/cicecore/shared/ice_fileunits.F90 +++ b/cicecore/shared/ice_fileunits.F90 @@ -108,7 +108,7 @@ subroutine init_fileunits character(len=*),parameter :: subname='(init_fileunits)' - allocate(ice_IOUnitsInUse(ice_IOUnitsMaxUnit)) + if (.not.allocated(ice_IOUnitsInUse)) allocate(ice_IOUnitsInUse(ice_IOUnitsMaxUnit)) ice_IOUnitsInUse = .false. ice_IOUnitsInUse(ice_stdin) = .true. ! reserve unit 5 From a7c2893e0dc3d69e608da3fd7d2676bc979a8eec Mon Sep 17 00:00:00 2001 From: mhrib <38077893+mhrib@users.noreply.github.com> Date: Fri, 10 Apr 2020 02:22:01 +0200 Subject: [PATCH 04/19] Secure, that best guess for max_blocks is always >= 1 (#431) --- cicecore/cicedynB/infrastructure/ice_domain.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/cicecore/cicedynB/infrastructure/ice_domain.F90 b/cicecore/cicedynB/infrastructure/ice_domain.F90 index 51a9eaa69..3be2449f7 100644 --- a/cicecore/cicedynB/infrastructure/ice_domain.F90 +++ b/cicecore/cicedynB/infrastructure/ice_domain.F90 @@ -188,6 +188,7 @@ subroutine init_domain_blocks ( (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 endif From 1c6c225ec6bd0635025d9aef969a1c25f5c74204 Mon Sep 17 00:00:00 2001 From: Tony Craig Date: Thu, 9 Apr 2020 17:22:24 -0700 Subject: [PATCH 05/19] update test reporting (#428) --- cice.setup | 51 +++++++++++++------ configuration/scripts/cice.test.setup.csh | 7 +++ .../scripts/tests/report_results.csh | 31 +++++++++-- .../scripts/tests/test_logbfb.script | 5 -- .../scripts/tests/test_restart.script | 10 ---- configuration/scripts/tests/test_smoke.script | 5 -- doc/source/user_guide/ug_testing.rst | 6 ++- 7 files changed, 75 insertions(+), 40 deletions(-) diff --git a/cice.setup b/cice.setup index 95c809323..cf9842b3d 100755 --- a/cice.setup +++ b/cice.setup @@ -941,9 +941,6 @@ EOF2 exit -1 endif -# # Initial test_output file -# echo "#---" >! test_output -# echo "PEND ${testname_noid} " >> test_output endif #------------------------------------------------------------ @@ -1004,31 +1001,55 @@ EOF0 # 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 failures = \`cat ./results.log | grep FAIL | 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\` +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" >> results.log +echo "#totl = \$total total" >> results.log +echo "#chkd = \$chkcnt checked" >> results.log echo "#pass = \$success" >> results.log -echo "#fail = \$failures" >> 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 - run has been submitted to queue and is waiting or failed submission" -echo " FAIL - test is still executing, did not complete, or completed and failed" +echo " PEND - status is undertermined; test may still be queued, running, or timed out" +echo " FAIL - test failed" echo "" -echo "\$success of \$total tests PASSED" -echo "\$failures of \$total tests FAILED" -echo "\$pends of \$total tests PENDING" +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 diff --git a/configuration/scripts/cice.test.setup.csh b/configuration/scripts/cice.test.setup.csh index 16fd84a69..535a2ac06 100755 --- a/configuration/scripts/cice.test.setup.csh +++ b/configuration/scripts/cice.test.setup.csh @@ -40,6 +40,13 @@ if ( ! -f ${ICE_RUNDIR}/cice ) then exit 99 endif +# Initial test results and Reset test results for rerun +mv -f ${ICE_CASEDIR}/test_output ${ICE_CASEDIR}/test_output.prev +echo "#---" >! ${ICE_CASEDIR}/test_output +cat ${ICE_CASEDIR}/test_output.prev | grep -i "${ICE_TESTNAME} build" >> ${ICE_CASEDIR}/test_output +echo "PEND ${ICE_TESTNAME} run" >> ${ICE_CASEDIR}/test_output +rm -f ${ICE_CASEDIR}/test_output.prev + EOF2 if ( -f ${ICE_SCRIPTS}/tests/test_${ICE_TEST}.script) then diff --git a/configuration/scripts/tests/report_results.csh b/configuration/scripts/tests/report_results.csh index 711dc3e3d..143fb9465 100755 --- a/configuration/scripts/tests/report_results.csh +++ b/configuration/scripts/tests/report_results.csh @@ -1,5 +1,19 @@ #!/bin/csh -f +if ($#argv == 0) then + echo "${0}: Running results.csh" + ./results.csh >& /dev/null +else if ($#argv == 1) then + if ("$argv[1]" =~ "-n") then + #continue + else + echo "$0 usage:" + echo "$0 [-n]" + echo " -n : do NOT run results.csh (by default it does)" + exit -1 + endif +endif + if (! -e results.log) then echo " " echo "${0}: ERROR results.log does not exist, try running results.csh" @@ -79,12 +93,21 @@ unset noglob foreach compiler ( ${compilers} ) - set ofile = "${shhash}.${mach}.${compiler}.${xcdat}.${xctim}" - set outfile = "${wikiname}/${tsubdir}/${ofile}.md" + set cnt = 0 + set found = 1 + while ($found == 1) + set ofile = "${shhash}.${mach}.${compiler}.${xcdat}.${xctim}.$cnt" + set outfile = "${wikiname}/${tsubdir}/${ofile}.md" + if (-e ${outfile}) then + @ cnt = $cnt + 1 + else + set found = 0 + endif + end + mkdir -p ${wikiname}/${tsubdir} echo "${0}: writing to ${outfile}" - if (-e ${outfile}) rm -f ${outfile} cat >! ${outfile} << EOF @@ -103,7 +126,7 @@ EOF foreach case ( ${cases} ) if ( ${case} =~ *_${compiler}_* ) then -# check thata case results are meaningful +# check that case results are meaningful set fbuild = `grep " ${case} " results.log | grep " build" | cut -c 1-4` set frun = `grep " ${case} " results.log | grep " run" | cut -c 1-4` set ftest = `grep " ${case} " results.log | grep " test" | cut -c 1-4` diff --git a/configuration/scripts/tests/test_logbfb.script b/configuration/scripts/tests/test_logbfb.script index fbce5d918..d8e594e81 100644 --- a/configuration/scripts/tests/test_logbfb.script +++ b/configuration/scripts/tests/test_logbfb.script @@ -4,11 +4,6 @@ # This is identical to a smoke test, but triggers bfbcompare with log files instead of restarts # cice.run returns -1 if run did not complete successfully -mv -f ${ICE_CASEDIR}/test_output ${ICE_CASEDIR}/test_output.prev -cat ${ICE_CASEDIR}/test_output.prev | grep -iv "${ICE_TESTNAME} run" >! ${ICE_CASEDIR}/test_output -rm -f ${ICE_CASEDIR}/test_output.prev -echo "RUN ${ICE_TESTNAME} run " >> ${ICE_CASEDIR}/test_output - ./cice.run set res="$status" diff --git a/configuration/scripts/tests/test_restart.script b/configuration/scripts/tests/test_restart.script index 20953b1e1..59729b361 100644 --- a/configuration/scripts/tests/test_restart.script +++ b/configuration/scripts/tests/test_restart.script @@ -7,14 +7,6 @@ cp ice_in ice_in.0 ${ICE_CASEDIR}/casescripts/parse_namelist.sh ice_in ${ICE_CASEDIR}/casescripts/test_nml.restart1 cp ice_in ice_in.1 -mv -f ${ICE_CASEDIR}/test_output ${ICE_CASEDIR}/test_output.prev -cat ${ICE_CASEDIR}/test_output.prev | grep -iv "${ICE_TESTNAME} run" >! ${ICE_CASEDIR}/test_output -mv -f ${ICE_CASEDIR}/test_output ${ICE_CASEDIR}/test_output.prev -cat ${ICE_CASEDIR}/test_output.prev | grep -iv "${ICE_TESTNAME} test" >! ${ICE_CASEDIR}/test_output -rm -f ${ICE_CASEDIR}/test_output.prev -echo "RUN ${ICE_TESTNAME} run " >> ${ICE_CASEDIR}/test_output -echo "PEND ${ICE_TESTNAME} test " >> ${ICE_CASEDIR}/test_output - ./cice.run set res="$status" @@ -27,8 +19,6 @@ if ( $res != 0 ) then echo "FAIL ${ICE_TESTNAME} run" >> ${ICE_CASEDIR}/test_output echo "FAIL ${ICE_TESTNAME} test " >> ${ICE_CASEDIR}/test_output exit 99 -else - echo "PASS ${ICE_TESTNAME} initialrun" >> ${ICE_CASEDIR}/test_output endif # Prepend 'base_' to the final restart file to save for comparison diff --git a/configuration/scripts/tests/test_smoke.script b/configuration/scripts/tests/test_smoke.script index 42a963b47..f39f7cb4a 100644 --- a/configuration/scripts/tests/test_smoke.script +++ b/configuration/scripts/tests/test_smoke.script @@ -3,11 +3,6 @@ # Run the CICE model # cice.run returns -1 if run did not complete successfully -mv -f ${ICE_CASEDIR}/test_output ${ICE_CASEDIR}/test_output.prev -cat ${ICE_CASEDIR}/test_output.prev | grep -iv "${ICE_TESTNAME} run" >! ${ICE_CASEDIR}/test_output -rm -f ${ICE_CASEDIR}/test_output.prev -echo "RUN ${ICE_TESTNAME} run " >> ${ICE_CASEDIR}/test_output - ./cice.run set res="$status" diff --git a/doc/source/user_guide/ug_testing.rst b/doc/source/user_guide/ug_testing.rst index 48679577c..81d1bddd3 100644 --- a/doc/source/user_guide/ug_testing.rst +++ b/doc/source/user_guide/ug_testing.rst @@ -645,7 +645,11 @@ To post results, once a test suite is complete, run ``results.csh`` and ./results.csh ./report_results.csh -The reporting can also be automated by adding ``--report`` to ``cice.setup`` +``report_results.csh`` will run ``results.csh`` by default automatically, but +we recommmend running it manually first to verify results before publishing +them. ``report_results.csh -n`` will turn off automatic running of ``results.csh``. + +The reporting can also be automated in a test suite by adding ``--report`` to ``cice.setup`` :: ./cice.setup --suite base_suite --mach conrad --env cray --testid v01a --report From 31a1975df2a76fd24cf08c97aa909fea3a8f7ae5 Mon Sep 17 00:00:00 2001 From: Tony Craig Date: Thu, 9 Apr 2020 17:22:40 -0700 Subject: [PATCH 06/19] update cori batch setup (#432) --- configuration/scripts/cice.batch.csh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/scripts/cice.batch.csh b/configuration/scripts/cice.batch.csh index 0450d2647..e8ec14cab 100755 --- a/configuration/scripts/cice.batch.csh +++ b/configuration/scripts/cice.batch.csh @@ -119,7 +119,7 @@ else if (${ICE_MACHINE} =~ cori*) then @ nthrds2 = ${nthrds} * 2 cat >> ${jobfile} << EOFB #SBATCH -J ${ICE_CASENAME} -###SBATCH -A ${acct} +#SBATCH -A ${acct} #SBATCH --qos ${queue} #SBATCH --time ${batchtime} #SBATCH --nodes ${nnodes} From 6d8a6b4d2b19d2b5d1f709908dfca8168fec624b Mon Sep 17 00:00:00 2001 From: "David A. Bailey" Date: Fri, 10 Apr 2020 16:16:36 -0600 Subject: [PATCH 07/19] Add ksno as a namelist parameter (#433) --- cicecore/cicedynB/general/ice_init.F90 | 8 ++++++-- configuration/scripts/ice_in | 1 + doc/source/user_guide/ug_case_settings.rst | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cicecore/cicedynB/general/ice_init.F90 b/cicecore/cicedynB/general/ice_init.F90 index 08476ca57..ffb070644 100644 --- a/cicecore/cicedynB/general/ice_init.F90 +++ b/cicecore/cicedynB/general/ice_init.F90 @@ -132,7 +132,7 @@ subroutine input_data integer (kind=int_kind) :: numin, numax ! unit number limits integer (kind=int_kind) :: rpcesm, rplvl, rptopo - real (kind=dbl_kind) :: Cf, puny + real (kind=dbl_kind) :: Cf, ksno, puny integer :: abort_flag character (len=64) :: tmpstr @@ -176,7 +176,7 @@ subroutine input_data n_doc, n_dic, n_don, n_fed, n_fep namelist /thermo_nml/ & - kitd, ktherm, conduct, & + kitd, ktherm, conduct, ksno, & a_rapid_mode, Rac_rapid_mode, aspect_rapid_mode, & dSdt_slow_mode, phi_c_slow_mode, phi_i_mushy @@ -296,6 +296,7 @@ subroutine input_data krdg_redist = 1 ! 1 = new redistribution, 0 = Hibler 80 mu_rdg = 3 ! e-folding scale of ridged ice, krdg_partic=1 (m^0.5) Cf = 17.0_dbl_kind ! ratio of ridging work to PE change in ridging + ksno = 0.3_dbl_kind ! snow thermal conductivity close_boundaries = .false. ! true = set land on edges of grid basalstress= .false. ! if true, basal stress for landfast is on k1 = 8.0_dbl_kind ! 1st free parameter for landfast parameterization @@ -576,6 +577,7 @@ subroutine input_data call broadcast_scalar(krdg_redist, master_task) call broadcast_scalar(mu_rdg, master_task) call broadcast_scalar(Cf, master_task) + call broadcast_scalar(ksno, master_task) call broadcast_scalar(basalstress, master_task) call broadcast_scalar(k1, master_task) call broadcast_scalar(k2, master_task) @@ -949,6 +951,7 @@ subroutine input_data ice_IOUnitsMaxUnit = numax call icepack_init_parameters(Cf_in=Cf) + call icepack_init_parameters(ksno_in=ksno) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname//'Icepack Abort1', & file=__FILE__, line=__LINE__) @@ -1073,6 +1076,7 @@ subroutine input_data trim(advection) write(nu_diag,1030) ' shortwave = ', & trim(shortwave) + write(nu_diag,1000) ' ksno = ', ksno if (cpl_bgc) then write(nu_diag,1000) ' BGC coupling is switched ON' else diff --git a/configuration/scripts/ice_in b/configuration/scripts/ice_in index 3e21dd332..dcfedf772 100644 --- a/configuration/scripts/ice_in +++ b/configuration/scripts/ice_in @@ -96,6 +96,7 @@ kitd = 1 ktherm = 2 conduct = 'bubbly' + ksno = 0.3d0 a_rapid_mode = 0.5e-3 Rac_rapid_mode = 10.0 aspect_rapid_mode = 1.0 diff --git a/doc/source/user_guide/ug_case_settings.rst b/doc/source/user_guide/ug_case_settings.rst index 4ab427737..b3088963d 100755 --- a/doc/source/user_guide/ug_case_settings.rst +++ b/doc/source/user_guide/ug_case_settings.rst @@ -243,6 +243,7 @@ Table of namelist options "","", "``-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" From c0e10057b4c0b3cd6ed245c1a05ab459f8d14e29 Mon Sep 17 00:00:00 2001 From: Tony Craig Date: Fri, 17 Apr 2020 10:05:56 -0700 Subject: [PATCH 08/19] Add Code Coverage Capability (#434) * add codecov.yml * update for codecov * update code coverage implementation * update documentation * update documentation * update error message in cice.setup * update travis testing to eliminate error by adding sleep between icepack.setup calls --- .travis.yml | 4 +- README.md | 1 + cice.setup | 109 ++++++++++++++++-- codecov.yml | 6 + configuration/scripts/cice.build | 2 +- configuration/scripts/cice.settings | 1 + .../scripts/machines/Macros.gaffney_gnu | 20 +++- .../scripts/machines/Macros.gordon_gnu | 20 +++- .../scripts/machines/Macros.izumi_gnu | 16 ++- .../scripts/machines/Macros.onyx_gnu | 20 +++- .../scripts/machines/Macros.travisCI_gnu | 20 +++- configuration/scripts/tests/nothread_suite.ts | 12 ++ .../scripts/tests/report_results.csh | 2 + doc/source/user_guide/ug_testing.rst | 52 +++++++++ 14 files changed, 255 insertions(+), 30 deletions(-) create mode 100644 codecov.yml diff --git a/.travis.yml b/.travis.yml index bb8dd37b4..f8f5aeadc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,9 +33,9 @@ install: script: # verify cice.setup --case and cice.setup --test don't error then run test suite - - "./cice.setup --case trcase --mach travisCI --env gnu --pes 2x2 -s diag1" + - "./cice.setup --case trcase --mach travisCI --env gnu --pes 2x2 -s diag1 && sleep 4" - "./cice.setup --test smoke --testid trtest --mach travisCI --env gnu - --pes 2x2 -s diag1" + --pes 2x2 -s diag1 && sleep 4" - "./cice.setup --suite travis_suite --testid travisCItest --mach travisCI --env gnu; cd testsuite.travisCItest && diff --git a/README.md b/README.md index 662dbc17f..1ecd483fe 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![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. diff --git a/cice.setup b/cice.setup index cf9842b3d..d70aece61 100755 --- a/cice.setup +++ b/cice.setup @@ -34,7 +34,10 @@ set stime = `date -u "+%H%M%S"` set docase = 0 set dotest = 0 set dosuite = 0 +set codecov = 0 # code coverage measurement and reporting +set codecovflag = false set suitebuild = true +set suitereuse = true set suiterun = false set suitesubmit = true @@ -81,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] + [--bcmp DIR][--tdir PATH][--report || --codecov] [--setup-only || --setup-build || --setup-build-run || --setup-build-submit] DESCRIPTION @@ -108,6 +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 + --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 @@ -224,26 +229,36 @@ while (1) set report = 1 shift argv + else if ("$option" == "--codecov") then + set codecov = 1 + set codecovflag = true + set suitereuse = false + shift argv + else if ("$option" == "--setup-only") then set suitebuild = false + set suitereuse = true set suiterun = false set suitesubmit = false shift argv else if ("$option" == "--setup-build") then set suitebuild = true + set suitereuse = true set suiterun = false set suitesubmit = false shift argv else if ("$option" == "--setup-build-run") then set suitebuild = true + set suitereuse = true set suiterun = true set suitesubmit = false shift argv else if ("$option" == "--setup-build-submit") then set suitebuild = true + set suitereuse = true set suiterun = false set suitesubmit = true shift argv @@ -252,11 +267,11 @@ while (1) else shift argv if ( $#argv < 1 ) then - echo "${0}: ERROR1 in $option" + echo "${0}: ERROR in $option, unsupported or missing an argument" exit -1 endif - if ($argv[1] =~ $dash* ) then - echo "${0}: ERROR2 in $option" + if ("$argv[1]" =~ "$dash*" ) then + echo "${0}: ERROR in $option, possibly missing an argument" exit -1 endif @@ -321,7 +336,30 @@ if (${dosum} > 1) then exit -1 endif +if ($codecov == 1 && $report == 1) then + echo "${0}: ERROR in arguments, not recommmended to set both --codecov and --report" + exit -1 +endif + +if ($codecov == 1 && "$compilers" != "gnu") then + echo "${0}: ERROR in arguments, must use --env gnu with --codecov" + exit -1 +endif + +if ($codecov == 1 && `where curl` == "" && `where wget` == "") then + echo "${0}: ERROR 'curl' or 'wget' is required for --codecov" + exit -1 +endif + if (${dosuite} == 0) then + if ($report == 1) then + echo "${0}: ERROR in arguments, must use --suite with --report" + exit -1 + endif + if ($codecov == 1) then + echo "${0}: ERROR in arguments, must use --suite with --codecov" + exit -1 + endif if ("$compilers" =~ "*,*") then echo "${0}: ERROR in arguments, cannot set multiple compilers without --suite" exit -1 @@ -355,7 +393,7 @@ endif if ( ${tdir} != ${spval} ) then set tsdir = ${tdir} endif -if (-e $tsfile) then +if (-e ${tsfile}) then echo "${0}: ERROR in tsfile, this should never happen" exit -1 endif @@ -416,11 +454,15 @@ else set nonomatch && rm -f ciceexe.* && unset nonomatch set dobuild = true +set doreuse = true set dorun = false set dosubmit = true if (\$?SUITE_BUILD) then set dobuild = "\${SUITE_BUILD}" endif +if (\$?SUITE_REUSEBUILD) then + set doreuse = "\${SUITE_REUSEBUILD}" +endif if (\$?SUITE_RUN) then set dorun = "\${SUITE_RUN}" endif @@ -429,6 +471,7 @@ if (\$?SUITE_SUBMIT) then endif echo \${0}: dobuild = \${dobuild} +echo \${0}: doreuse = \${doreuse} echo \${0}: dorun = \${dorun} echo \${0}: dosubmit = \${dosubmit} @@ -449,16 +492,30 @@ echo "#hash = ${hash}" >> results.log echo "#hshs = ${shhash}" >> results.log echo "#hshu = ${hashuser}" >> results.log echo "#hshd = ${hashdate}" >> results.log +echo "#suit = ${testsuite}" >> results.log echo "#date = ${cdate}" >> results.log echo "#time = ${ctime}" >> results.log echo "#mach = ${machine}" >> results.log echo "#user = ${user}" >> results.log echo "#vers = ${vers}" >> results.log echo "#------- " >> results.log +EOF0 + +cat >! ${tsdir}/report_codecov.csh << EOF0 +#!/bin/csh -f + +#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 use_curl = 1 + EOF0 chmod +x ${tsdir}/suite.submit chmod +x ${tsdir}/results.csh + chmod +x ${tsdir}/report_codecov.csh endif @@ -734,6 +791,8 @@ EOF endif endif + set rundir = ${ICE_MACHINE_WKDIR}/${casename} + #------------------------------------------------------------ # Compute a default blocksize @@ -755,6 +814,7 @@ EOF echo "ICE_CASEDIR = ${casedir}" echo "ICE_MACHINE = ${machine}" 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}" @@ -809,7 +869,7 @@ setenv ICE_CASEDIR ${casedir} setenv ICE_MACHINE ${machine} setenv ICE_COMPILER ${compiler} setenv ICE_MACHCOMP ${machcomp} -setenv ICE_RUNDIR ${ICE_MACHINE_WKDIR}/${casename} +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 @@ -829,6 +889,7 @@ setenv ICE_TESTID ${testid} setenv ICE_BFBCOMP ${fbfbcomp} setenv ICE_ACCOUNT ${acct} setenv ICE_QUEUE ${queue} +setenv ICE_CODECOV ${codecovflag} EOF1 if (${sets} != "") then @@ -952,6 +1013,12 @@ EOF2 cat >> ${tsdir}/results.csh << EOF cat ${testname_base}/test_output >> results.log +EOF + + cat >> ${tsdir}/report_codecov.csh << EOF +mkdir ${testname_base}/codecov_output +cp ${rundir}/compile/*.{gcno,gcda} ${testname_base}/codecov_output/ + EOF cat >> ${tsdir}/suite.submit << EOF @@ -961,9 +1028,13 @@ echo "${testname_base}" cd ${testname_base} source ./cice.settings if (\${dobuild} == true) then - set ciceexe = "../ciceexe.\${ICE_COMPILER}.\${ICE_COMMDIR}.\${ICE_BLDDEBUG}.\${ICE_THREADED}.\${ICE_IOTYPE}" - ./cice.build --exe \${ciceexe} - if !(-e \${ciceexe}) cp -p \${ICE_RUNDIR}/cice \${ciceexe} + if (\${doreuse} == true) then + set ciceexe = "../ciceexe.\${ICE_COMPILER}.\${ICE_COMMDIR}.\${ICE_BLDDEBUG}.\${ICE_THREADED}.\${ICE_IOTYPE}" + ./cice.build --exe \${ciceexe} + if !(-e \${ciceexe}) cp -p \${ICE_RUNDIR}/cice \${ciceexe} + else + ./cice.build + endif endif if (\${dosubmit} == true) then ./cice.submit | tee -a ../suite.jobs @@ -1059,9 +1130,24 @@ setenv ICE_MACHINE_QSTAT ${ICE_MACHINE_QSTAT} EOF0 endif +cat >> ${tsdir}/report_codecov.csh << EOF +source ${ICE_SCRIPTS}/machines/env.${machcomp} + +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 + +sleep 10 +rm -r -f ./*/codecov_output + +EOF + # build and submit tests cd ${tsdir} setenv SUITE_BUILD ${suitebuild} + setenv SUITE_REUSEBUILD ${suitereuse} setenv SUITE_RUN ${suiterun} setenv SUITE_SUBMIT ${suitesubmit} ./suite.submit | tee suite.log @@ -1071,6 +1157,11 @@ EOF0 ./results.csh ./report_results.csh endif + if ($codecov == 1) then + echo "Generating codecov reports" + ./poll_queue.csh + ./report_codecov.csh + endif cd ${ICE_SANDBOX} endif diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..e7f6a6e2f --- /dev/null +++ b/codecov.yml @@ -0,0 +1,6 @@ +coverage: + range: "20...100" + round: down + precision: 2 + +comment: false diff --git a/configuration/scripts/cice.build b/configuration/scripts/cice.build index 61d639e09..2534bfa7e 100755 --- a/configuration/scripts/cice.build +++ b/configuration/scripts/cice.build @@ -1,7 +1,7 @@ #! /bin/csh -f #==================================== -# If the cice binary is passed as an argument and the file exists, +# If the cice binary is passed via the --exe argument and the file exists, # copy it into the run directory and don't build the model. set dohelp = 0 diff --git a/configuration/scripts/cice.settings b/configuration/scripts/cice.settings index 8bb860916..7d9bce65c 100755 --- a/configuration/scripts/cice.settings +++ b/configuration/scripts/cice.settings @@ -40,4 +40,5 @@ if (${ICE_NTASKS} == 1) setenv ICE_COMMDIR serial ### Specialty code setenv ICE_BLDDEBUG false # build debug flags +setenv ICE_CODECOV false # build debug flags diff --git a/configuration/scripts/machines/Macros.gaffney_gnu b/configuration/scripts/machines/Macros.gaffney_gnu index b2f178247..0d13560de 100644 --- a/configuration/scripts/machines/Macros.gaffney_gnu +++ b/configuration/scripts/machines/Macros.gaffney_gnu @@ -4,7 +4,7 @@ CPP := ftn -E CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} -CFLAGS := -c -O2 +CFLAGS := -c FIXEDFLAGS := -ffixed-line-length-132 FREEFLAGS := -ffree-form @@ -12,9 +12,21 @@ 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 -else - FFLAGS += -O2 + FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow + CFLAGS += -O0 +endif + +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_CODECOV), true) + FFLAGS += -O2 + CFLAGS += -O2 +endif endif SCC := gcc diff --git a/configuration/scripts/machines/Macros.gordon_gnu b/configuration/scripts/machines/Macros.gordon_gnu index 131f539c1..2e80f7364 100644 --- a/configuration/scripts/machines/Macros.gordon_gnu +++ b/configuration/scripts/machines/Macros.gordon_gnu @@ -4,7 +4,7 @@ CPP := ftn -E CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} -CFLAGS := -c -O2 +CFLAGS := -c FIXEDFLAGS := -ffixed-line-length-132 FREEFLAGS := -ffree-form @@ -12,9 +12,21 @@ 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 -else - FFLAGS += -O2 + FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow + CFLAGS += -O0 +endif + +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_CODECOV), true) + FFLAGS += -O2 + CFLAGS += -O2 +endif endif SCC := cc diff --git a/configuration/scripts/machines/Macros.izumi_gnu b/configuration/scripts/machines/Macros.izumi_gnu index 6526ac767..cdc6620f4 100644 --- a/configuration/scripts/machines/Macros.izumi_gnu +++ b/configuration/scripts/machines/Macros.izumi_gnu @@ -4,7 +4,7 @@ CPP := /usr/bin/cpp CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} -CFLAGS := -c -O2 +CFLAGS := -c FIXEDFLAGS := -ffixed-line-length-132 FREEFLAGS := -ffree-form @@ -13,8 +13,20 @@ FFLAGS_NOOPT:= -O0 ifeq ($(ICE_BLDDEBUG), true) FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow -else + CFLAGS += -O0 +endif + +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_CODECOV), true) FFLAGS += -O2 + CFLAGS += -O2 +endif endif SCC := gcc diff --git a/configuration/scripts/machines/Macros.onyx_gnu b/configuration/scripts/machines/Macros.onyx_gnu index 14784e625..d423cd9ab 100644 --- a/configuration/scripts/machines/Macros.onyx_gnu +++ b/configuration/scripts/machines/Macros.onyx_gnu @@ -4,7 +4,7 @@ CPP := ftn -E CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} -CFLAGS := -c -O2 +CFLAGS := -c FIXEDFLAGS := -ffixed-line-length-132 FREEFLAGS := -ffree-form @@ -12,9 +12,21 @@ 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 -else - FFLAGS += -O2 + FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow + CFLAGS += -O0 +endif + +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_CODECOV), true) + FFLAGS += -O2 + CFLAGS += -O2 +endif endif SCC := cc diff --git a/configuration/scripts/machines/Macros.travisCI_gnu b/configuration/scripts/machines/Macros.travisCI_gnu index 66fb30a07..aa7b12c05 100644 --- a/configuration/scripts/machines/Macros.travisCI_gnu +++ b/configuration/scripts/machines/Macros.travisCI_gnu @@ -4,7 +4,7 @@ CPP := cpp CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} -CFLAGS := -c -O2 +CFLAGS := -c FIXEDFLAGS := -ffixed-line-length-132 FREEFLAGS := -ffree-form @@ -12,9 +12,21 @@ 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 -else - FFLAGS += -O2 + FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow + CFLAGS += -O0 +endif + +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_CODECOV), true) + FFLAGS += -O2 + CFLAGS += -O2 +endif endif SCC := gcc diff --git a/configuration/scripts/tests/nothread_suite.ts b/configuration/scripts/tests/nothread_suite.ts index 5db402d34..49f834a98 100644 --- a/configuration/scripts/tests/nothread_suite.ts +++ b/configuration/scripts/tests/nothread_suite.ts @@ -26,6 +26,12 @@ restart gx3 20x1 alt02,debug,short restart gx3 24x1 alt03,debug,short smoke gx3 24x1 alt04,debug,short smoke gx3 32x1 alt05,debug,short +restart gx3 16x1 isotope +smoke gx3 6x1 isotope,debug +smoke gx3 8x1 fsd1,diag24,run5day,debug +smoke gx3 16x1 fsd12,diag24,run5day,short +restart gx3 12x1 fsd12,debug,short +smoke gx3 20x1 fsd12ww3,diag24,run1day,medium restart gbox128 8x1 short restart gbox128 16x1 boxdyn,short @@ -37,6 +43,12 @@ smoke gbox128 24x1 boxrestore,short,debug restart gbox80 1x1 box2001 smoke gbox80 1x1 boxslotcyl +smoke gx3 16x1 jra55_gx3_2008,medium,run90day +restart gx3 12x1 jra55_gx3,short +#tcraig, hangs nodes intermittently on izumi +#smoke gx1 24x1 jra55_gx1_2008,medium,run90day +#restart gx1 24x1 jra55_gx1,short + smoke gx3 16x1 bgcz smoke gx3 16x1 bgcz,debug smoke gx3 24x1 bgcskl,debug diff --git a/configuration/scripts/tests/report_results.csh b/configuration/scripts/tests/report_results.csh index 143fb9465..4a64deff8 100755 --- a/configuration/scripts/tests/report_results.csh +++ b/configuration/scripts/tests/report_results.csh @@ -39,6 +39,7 @@ set hash = `grep "#hash = " results.log | cut -c 9-` set shhash = `grep "#hshs = " results.log | cut -c 9-` set hashuser = `grep "#hshu = " results.log | cut -c 9-` set hashdate = `grep "#hshd = " results.log | cut -c 9-` +set testsuites = `grep "#suit = " results.log | cut -c 9-` set cdat = `grep "#date = " results.log | cut -c 9-` set ctim = `grep "#time = " results.log | cut -c 9-` set user = `grep "#user = " results.log | cut -c 9-` @@ -56,6 +57,7 @@ set compilers = `grep -v "#" results.log | grep ${mach}_ | cut -d "_" -f 2 | sor #echo "debug ${shhash}" #echo "debug ${hashuser}" #echo "debug ${hashdate}" +#echo "debug ${testsuites}" #echo "debug ${cdat}" #echo "debug ${ctim}" #echo "debug ${user}" diff --git a/doc/source/user_guide/ug_testing.rst b/doc/source/user_guide/ug_testing.rst index 81d1bddd3..52621d612 100644 --- a/doc/source/user_guide/ug_testing.rst +++ b/doc/source/user_guide/ug_testing.rst @@ -380,6 +380,9 @@ 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. +``--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``. @@ -657,6 +660,55 @@ The reporting can also be automated in a test suite by adding ``--report`` to `` With ``--report``, the suite will create all the tests, build and submit them, wait for all runs to be complete, and run the results and report_results scripts. +.. _codecoverage: + +Code Coverage Testing +------------------------------ + +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. +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: From 9d07d0b872f712b1159d393e38d005df9a65e4ce Mon Sep 17 00:00:00 2001 From: Tony Craig Date: Fri, 24 Apr 2020 10:36:03 -0700 Subject: [PATCH 09/19] Update code coverage documentation (#436) * update code coverage documentation * remove cice_test_codecov script * update code coverage documentation * Update configuration/scripts/tests/cice_test_codecov.csh Co-Authored-By: Philippe Blain * update codecov script and documentation Co-authored-by: Philippe Blain --- cice.setup | 15 +++- .../scripts/tests/cice_test_codecov.csh | 75 +++++++++++++++++++ doc/source/user_guide/ug_testing.rst | 29 +++---- 3 files changed, 97 insertions(+), 22 deletions(-) create mode 100755 configuration/scripts/tests/cice_test_codecov.csh diff --git a/cice.setup b/cice.setup index d70aece61..f7ff12bd6 100755 --- a/cice.setup +++ b/cice.setup @@ -504,11 +504,18 @@ EOF0 cat >! ${tsdir}/report_codecov.csh << EOF0 #!/bin/csh -f -#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}" +# 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 +set report_name = "${shhash}:${branch}:${machine} ${testsuite}" set use_curl = 1 EOF0 diff --git a/configuration/scripts/tests/cice_test_codecov.csh b/configuration/scripts/tests/cice_test_codecov.csh new file mode 100755 index 000000000..0b2d970ec --- /dev/null +++ b/configuration/scripts/tests/cice_test_codecov.csh @@ -0,0 +1,75 @@ +#!/bin/csh + +# This was a script on gordon +# This script should only be run on hardware with the gnu compiler with a +# modified Macros file to turn on the codecov flags +# This should be run interactively because git push will require login information + +#PBS -N cice_test +#PBS -q standard +#PBS -A NRLSS03755018 +#PBS -l application=Regional-Arctic-System-Model +#PBS -l select=1:ncpus=32:mpiprocs=32 +#PBS -l walltime=24:00:00 +#PBS -j oe +#PBS -M anthony.p.craig@gmail.com +#PBS -m be + +#set verbose +module load costinit git + +set scrdir = "~" +set testdir = "~/cice_testing" +set date0 = `date -u "+%y%m%d"` +set date = ${date0}cc + +mkdir -p ${testdir} + +cd ${testdir} + +# Check out current cice master +echo " " +echo "*** checkout current cice master ***" +git clone https://github.com/cice-consortium/cice cice.master.${date} --recursive +cd cice.master.${date} +set hash = `git rev-parse --short HEAD ` +cd ../ + +# Check out test_cice_icepack, remove all code and copy from cice master +# Need to be careful about dot files, particularly .git* files +# This copies in all files via standard file expansion (except dot files at root) +# This also copies in all dot file at the root that do not start with .g (ie. .git*) +echo " " +echo "*** checkout current test_cice_master ***" +git clone https://github.com/apcraig/test_cice_icepack test_cice_icepack.${date} +cd test_cice_icepack.${date} +echo " " +echo "*** remove current files and copy in cice master files ***" +set verbose +git rm -r * >& /dev/null +cp -p -r ../cice.master.${date}/* . +cp -p ../cice.master.${date}/.[a-f,h-z]* . + +# Clean up icepack .git stuff and commit +rm -r -f icepack/.git* +git add . +unset verbose +echo " " +echo "*** git status of changes ***" +git status +echo " " +echo "*** commit changes ***" +git commit -m "update test_cice_icepack master to ${hash}" + +# Push test_cice_icepack +echo " " +echo "*** push changes to test_cice_icepack ***" +git push origin master + +# Run test suite +echo " " +echo "*** run test suite ***" +./cice.setup --suite first_suite,base_suite,travis_suite,decomp_suite,reprosum_suite,quick_suite -m gordon -e gnu --testid T${date} --codecov --queue standard + +# The test suite will wait until all jobs are complete then run report_codecov.csh +# If that fails, you can run report_codecov.csh manually after all jobs are done diff --git a/doc/source/user_guide/ug_testing.rst b/doc/source/user_guide/ug_testing.rst index 52621d612..04b82a401 100644 --- a/doc/source/user_guide/ug_testing.rst +++ b/doc/source/user_guide/ug_testing.rst @@ -668,32 +668,25 @@ Code Coverage Testing 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. -This option is currently only available with the gnu compiler and on a few systems. +This option is currently only available with the gnu compiler and on a few systems +with modified Macros files. 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:: +to be copied into the Test_CICE_Icepack repository, then the full test suite +can be run with the gnu compiler with the ``--codecov`` argument. - 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. +**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 From 40daaf4d46593296dd2e5144d8f54f6e6bbfe7aa Mon Sep 17 00:00:00 2001 From: Philippe Blain Date: Mon, 11 May 2020 12:03:45 -0400 Subject: [PATCH 10/19] Update ECCC machines (#438) * machines: rename brooks to daley brooks has been decommissioned, daley replaces it. * machines: port to daley (ECCC) * machines: port to banting (ECCC) * machines: add GNU port for banting and daley * machines: disable HDF5 locking for ECCC machines * machines: eccc: use sice500 account for input data --- configuration/scripts/cice.batch.csh | 2 +- configuration/scripts/cice.launch.csh | 2 +- .../scripts/machines/Macros.banting_gnu | 39 ++++++++++ .../scripts/machines/Macros.banting_intel | 40 ++++++++++ .../scripts/machines/Macros.brooks_intel | 73 ------------------- .../scripts/machines/Macros.daley_gnu | 39 ++++++++++ .../scripts/machines/Macros.daley_intel | 40 ++++++++++ .../scripts/machines/env.banting_gnu | 36 +++++++++ .../scripts/machines/env.banting_intel | 31 ++++++++ .../scripts/machines/env.brooks_intel | 26 ------- configuration/scripts/machines/env.daley_gnu | 36 +++++++++ .../scripts/machines/env.daley_intel | 31 ++++++++ 12 files changed, 294 insertions(+), 101 deletions(-) create mode 100644 configuration/scripts/machines/Macros.banting_gnu create mode 100644 configuration/scripts/machines/Macros.banting_intel delete mode 100644 configuration/scripts/machines/Macros.brooks_intel create mode 100644 configuration/scripts/machines/Macros.daley_gnu create mode 100644 configuration/scripts/machines/Macros.daley_intel create mode 100755 configuration/scripts/machines/env.banting_gnu create mode 100755 configuration/scripts/machines/env.banting_intel delete mode 100755 configuration/scripts/machines/env.brooks_intel create mode 100755 configuration/scripts/machines/env.daley_gnu create mode 100755 configuration/scripts/machines/env.daley_intel diff --git a/configuration/scripts/cice.batch.csh b/configuration/scripts/cice.batch.csh index e8ec14cab..6797a9f61 100755 --- a/configuration/scripts/cice.batch.csh +++ b/configuration/scripts/cice.batch.csh @@ -196,7 +196,7 @@ cat >> ${jobfile} << EOFB #SBATCH --qos=standby EOFB -else if (${ICE_MACHINE} =~ brooks*) then +else if (${ICE_MACHINE} =~ daley* || ${ICE_MACHINE} =~ banting*) then cat >> ${jobfile} << EOFB #PBS -N ${ICE_CASENAME} #PBS -j oe diff --git a/configuration/scripts/cice.launch.csh b/configuration/scripts/cice.launch.csh index 17a260e06..296878914 100755 --- a/configuration/scripts/cice.launch.csh +++ b/configuration/scripts/cice.launch.csh @@ -153,7 +153,7 @@ EOFR endif #======= -else if (${ICE_MACHINE} =~ brooks*) then +else if (${ICE_MACHINE} =~ daley* || ${ICE_MACHINE} =~ banting*) then if (${ICE_COMMDIR} =~ serial*) then cat >> ${jobfile} << EOFR ./cice >&! \$ICE_RUNLOG_FILE diff --git a/configuration/scripts/machines/Macros.banting_gnu b/configuration/scripts/machines/Macros.banting_gnu new file mode 100644 index 000000000..769470f6d --- /dev/null +++ b/configuration/scripts/machines/Macros.banting_gnu @@ -0,0 +1,39 @@ +#============================================================================== +# Makefile macros for ECCC banting +#============================================================================== +# For use with GNU compiler +#============================================================================== + +CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} +CFLAGS := -c -O2 +#-xHost + +FREEFLAGS := -ffree-form +FFLAGS := -fconvert=big-endian -fbacktrace -ffree-line-length-none +#-xHost + +ifeq ($(ICE_BLDDEBUG), true) + FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow +else + FFLAGS += -O2 +endif + +SCC := cc +SFC := ftn +MPICC := cc +MPIFC := ftn + +ifeq ($(ICE_COMMDIR), mpi) + FC := $(MPIFC) + CC := $(MPICC) +else + FC := $(SFC) + CC := $(SCC) +endif +LD:= $(FC) + +ifeq ($(ICE_THREADED), true) + LDFLAGS += -fopenmp + CFLAGS += -fopenmp + FFLAGS += -fopenmp +endif diff --git a/configuration/scripts/machines/Macros.banting_intel b/configuration/scripts/machines/Macros.banting_intel new file mode 100644 index 000000000..d16ed432a --- /dev/null +++ b/configuration/scripts/machines/Macros.banting_intel @@ -0,0 +1,40 @@ +#============================================================================== +# Makefile macros for ECCC banting +#============================================================================== +# For use with intel compiler +#============================================================================== + +CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} +CFLAGS := -c -O2 -fp-model precise +#-xHost + +FREEFLAGS := -FR +FFLAGS := -fp-model source -convert big_endian -assume byterecl -ftz -traceback -diag-disable 5140 +#-xHost + +ifeq ($(ICE_BLDDEBUG), true) + FFLAGS += -O0 -g -check -fpe0 -ftrapuv -fp-model except -check noarg_temp_created +# -heap-arrays 1024 +else + FFLAGS += -O2 +endif + +SCC := cc +SFC := ftn +MPICC := cc +MPIFC := ftn + +ifeq ($(ICE_COMMDIR), mpi) + FC := $(MPIFC) + CC := $(MPICC) +else + FC := $(SFC) + CC := $(SCC) +endif +LD:= $(FC) + +ifeq ($(ICE_THREADED), true) + LDFLAGS += -qopenmp + CFLAGS += -qopenmp + FFLAGS += -qopenmp +endif diff --git a/configuration/scripts/machines/Macros.brooks_intel b/configuration/scripts/machines/Macros.brooks_intel deleted file mode 100644 index a6fecdbbb..000000000 --- a/configuration/scripts/machines/Macros.brooks_intel +++ /dev/null @@ -1,73 +0,0 @@ -#============================================================================== -# Makefile macros for ECCC brooks -#============================================================================== -# For use with intel compiler -#============================================================================== - -CPP := fpp -CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} -CFLAGS := -c -O2 -fp-model precise -#-xHost - -FIXEDFLAGS := -132 -FREEFLAGS := -FR -FFLAGS := -fp-model source -convert big_endian -assume byterecl -ftz -traceback -diag-disable 5140 -#-xHost -FFLAGS_NOOPT:= -O0 - -ifeq ($(ICE_BLDDEBUG), true) - FFLAGS += -O0 -g -check -fpe0 -ftrapuv -fp-model except -check noarg_temp_created -# -heap-arrays 1024 -else - FFLAGS += -O2 -endif - -SCC := cc -SFC := ftn -MPICC := cc -MPIFC := ftn - -ifeq ($(ICE_COMMDIR), mpi) - FC := $(MPIFC) - CC := $(MPICC) -else - FC := $(SFC) - CC := $(SCC) -endif -LD:= $(FC) - -#NETCDF_PATH := /fs/ssm/hpco/tmp/eccc/201402/04/intel-2016.1.150/ubuntu-14.04-amd64-64/ - -PIO_CONFIG_OPTS:= --enable-filesystem-hints=gpfs - -#PNETCDF_PATH := $(PNETCDF) -#PNETCDF_PATH := /glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib - -INCLDIR := $(INCLDIR) - -LIB_NETCDF := $(NETCDF_PATH)/lib -LIB_PNETCDF := $(PNETCDF_PATH)/lib -LIB_MPI := $(IMPILIBDIR) - -#SLIBS := -L$(LIB_NETCDF) -lnetcdff -lnetcdf -L$(LIB_PNETCDF) -lpnetcdf -lgptl -#SLIBS := -L$(LIB_NETCDF) -lnetcdff -lnetcdf - -ifeq ($(ICE_IOTYPE), netcdf) - INCLDIR += $(shell nf-config --fflags) - SLIBS := $(shell nf-config --flibs) -endif - - -ifeq ($(ICE_THREADED), true) - LDFLAGS += -qopenmp - CFLAGS += -qopenmp - FFLAGS += -qopenmp -endif - -### if using parallel I/O, load all 3 libraries. PIO must be first! -ifeq ($(ICE_IOTYPE), pio) - PIO_PATH:=/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib - INCLDIR += -I/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/include - SLIBS := $(SLIBS) -L$(PIO_PATH) -lpiof -endif - diff --git a/configuration/scripts/machines/Macros.daley_gnu b/configuration/scripts/machines/Macros.daley_gnu new file mode 100644 index 000000000..be01e67fe --- /dev/null +++ b/configuration/scripts/machines/Macros.daley_gnu @@ -0,0 +1,39 @@ +#============================================================================== +# Makefile macros for ECCC daley +#============================================================================== +# For use with GNU compiler +#============================================================================== + +CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} +CFLAGS := -c -O2 +#-xHost + +FREEFLAGS := -ffree-form +FFLAGS := -fconvert=big-endian -fbacktrace -ffree-line-length-none +#-xHost + +ifeq ($(ICE_BLDDEBUG), true) + FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow +else + FFLAGS += -O2 +endif + +SCC := cc +SFC := ftn +MPICC := cc +MPIFC := ftn + +ifeq ($(ICE_COMMDIR), mpi) + FC := $(MPIFC) + CC := $(MPICC) +else + FC := $(SFC) + CC := $(SCC) +endif +LD:= $(FC) + +ifeq ($(ICE_THREADED), true) + LDFLAGS += -fopenmp + CFLAGS += -fopenmp + FFLAGS += -fopenmp +endif diff --git a/configuration/scripts/machines/Macros.daley_intel b/configuration/scripts/machines/Macros.daley_intel new file mode 100644 index 000000000..5aeb4c438 --- /dev/null +++ b/configuration/scripts/machines/Macros.daley_intel @@ -0,0 +1,40 @@ +#============================================================================== +# Makefile macros for ECCC daley +#============================================================================== +# For use with intel compiler +#============================================================================== + +CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} +CFLAGS := -c -O2 -fp-model precise +#-xHost + +FREEFLAGS := -FR +FFLAGS := -fp-model source -convert big_endian -assume byterecl -ftz -traceback -diag-disable 5140 +#-xHost + +ifeq ($(ICE_BLDDEBUG), true) + FFLAGS += -O0 -g -check -fpe0 -ftrapuv -fp-model except -check noarg_temp_created +# -heap-arrays 1024 +else + FFLAGS += -O2 +endif + +SCC := cc +SFC := ftn +MPICC := cc +MPIFC := ftn + +ifeq ($(ICE_COMMDIR), mpi) + FC := $(MPIFC) + CC := $(MPICC) +else + FC := $(SFC) + CC := $(SCC) +endif +LD:= $(FC) + +ifeq ($(ICE_THREADED), true) + LDFLAGS += -qopenmp + CFLAGS += -qopenmp + FFLAGS += -qopenmp +endif diff --git a/configuration/scripts/machines/env.banting_gnu b/configuration/scripts/machines/env.banting_gnu new file mode 100755 index 000000000..7b1a55eac --- /dev/null +++ b/configuration/scripts/machines/env.banting_gnu @@ -0,0 +1,36 @@ +#!/bin/csh -f + +set inp = "undefined" +if ($#argv == 1) then + set inp = $1 +endif + +if ("$inp" != "-nomodules") then + +source /opt/modules/default/init/csh # Initialize modules for csh +# Clear environment +module unload craype-x86-skylake +module unload PrgEnv-intel + +module load PrgEnv-gnu # GNU compiler +module load craype-x86-skylake # Reload +module load cray-mpich # MPI (Cray MPICH) +module load cray-netcdf # NetCDF +module load cray-hdf5 # HDF5 +setenv HDF5_USE_FILE_LOCKING FALSE # necessary since data is on an NFS filesystem + +endif + +setenv ICE_MACHINE_ENVNAME banting +setenv ICE_MACHINE_COMPILER gnu +setenv ICE_MACHINE_MAKE make +setenv ICE_MACHINE_WKDIR ~/data/banting/cice/runs +setenv ICE_MACHINE_INPUTDATA /home/ords/cmdd/cmde/sice500/ +setenv ICE_MACHINE_BASELINE ~/data/banting/cice/baselines +setenv ICE_MACHINE_SUBMIT "qsub" +setenv ICE_MACHINE_TPNODE 40 +setenv ICE_MACHINE_MAXRUNLENGTH 3 +setenv ICE_MACHINE_ACCT P0000000 +setenv ICE_MACHINE_QUEUE "development" +setenv ICE_MACHINE_BLDTHRDS 18 +setenv ICE_MACHINE_QSTAT "qstat " diff --git a/configuration/scripts/machines/env.banting_intel b/configuration/scripts/machines/env.banting_intel new file mode 100755 index 000000000..48dce9d1e --- /dev/null +++ b/configuration/scripts/machines/env.banting_intel @@ -0,0 +1,31 @@ +#!/bin/csh -f + +set inp = "undefined" +if ($#argv == 1) then + set inp = $1 +endif + +if ("$inp" != "-nomodules") then + +source /opt/modules/default/init/csh # Initialize modules for csh +module load PrgEnv-intel # Intel compiler +module load cray-mpich # MPI (Cray MPICH) +module load cray-netcdf # NetCDF +module load cray-hdf5 # HDF5 +setenv HDF5_USE_FILE_LOCKING FALSE # necessary since data is on an NFS filesystem + +endif + +setenv ICE_MACHINE_ENVNAME banting +setenv ICE_MACHINE_COMPILER intel +setenv ICE_MACHINE_MAKE make +setenv ICE_MACHINE_WKDIR ~/data/banting/cice/runs +setenv ICE_MACHINE_INPUTDATA /home/ords/cmdd/cmde/sice500/ +setenv ICE_MACHINE_BASELINE ~/data/banting/cice/baselines +setenv ICE_MACHINE_SUBMIT "qsub" +setenv ICE_MACHINE_TPNODE 40 +setenv ICE_MACHINE_MAXRUNLENGTH 3 +setenv ICE_MACHINE_ACCT P0000000 +setenv ICE_MACHINE_QUEUE "development" +setenv ICE_MACHINE_BLDTHRDS 18 +setenv ICE_MACHINE_QSTAT "qstat " diff --git a/configuration/scripts/machines/env.brooks_intel b/configuration/scripts/machines/env.brooks_intel deleted file mode 100755 index 4a51b5bb1..000000000 --- a/configuration/scripts/machines/env.brooks_intel +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/csh -f - -source /opt/modules/default/init/csh -module load PrgEnv-intel # Intel compiler -module load cray-mpich # MPI (Cray MPICH) -module load cray-netcdf # NetCDF -module load cray-hdf5 # HDF5 - -setenv ICE_MACHINE_ENVNAME brooks -setenv ICE_MACHINE_COMPILER intel -setenv ICE_MACHINE_MAKE make -setenv ICE_MACHINE_WKDIR ~/data/brooks/cice/runs -setenv ICE_MACHINE_INPUTDATA /home/ords/cmdd/cmde/phb001/ -setenv ICE_MACHINE_BASELINE ~/data/brooks/cice/baselines -setenv ICE_MACHINE_SUBMIT "qsub" -setenv ICE_MACHINE_TPNODE 36 -setenv ICE_MACHINE_MAXRUNLENGTH 3 -setenv ICE_MACHINE_ACCT P0000000 -setenv ICE_MACHINE_QUEUE "development" -setenv ICE_MACHINE_BLDTHRDS 4 -setenv ICE_MACHINE_QSTAT "qstat " - -if (-e ~/.cice_proj) then - set account_name = `head -1 ~/.cice_proj` - setenv CICE_ACCT ${account_name} -endif diff --git a/configuration/scripts/machines/env.daley_gnu b/configuration/scripts/machines/env.daley_gnu new file mode 100755 index 000000000..f77bf2d88 --- /dev/null +++ b/configuration/scripts/machines/env.daley_gnu @@ -0,0 +1,36 @@ +#!/bin/csh -f + +set inp = "undefined" +if ($#argv == 1) then + set inp = $1 +endif + +if ("$inp" != "-nomodules") then + +source /opt/modules/default/init/csh # Initialize modules for csh +# Clear environment +module unload craype-x86-skylake +module unload PrgEnv-intel + +module load PrgEnv-gnu # GNU compiler +module load craype-x86-skylake # Reload +module load cray-mpich # MPI (Cray MPICH) +module load cray-netcdf # NetCDF +module load cray-hdf5 # HDF5 +setenv HDF5_USE_FILE_LOCKING FALSE # necessary since data is on an NFS filesystem + +endif + +setenv ICE_MACHINE_ENVNAME daley +setenv ICE_MACHINE_COMPILER gnu +setenv ICE_MACHINE_MAKE make +setenv ICE_MACHINE_WKDIR ~/data/daley/cice/runs +setenv ICE_MACHINE_INPUTDATA /home/ords/cmdd/cmde/sice500/ +setenv ICE_MACHINE_BASELINE ~/data/daley/cice/baselines +setenv ICE_MACHINE_SUBMIT "qsub" +setenv ICE_MACHINE_TPNODE 40 +setenv ICE_MACHINE_MAXRUNLENGTH 3 +setenv ICE_MACHINE_ACCT P0000000 +setenv ICE_MACHINE_QUEUE "development" +setenv ICE_MACHINE_BLDTHRDS 18 +setenv ICE_MACHINE_QSTAT "qstat " diff --git a/configuration/scripts/machines/env.daley_intel b/configuration/scripts/machines/env.daley_intel new file mode 100755 index 000000000..0d25f983f --- /dev/null +++ b/configuration/scripts/machines/env.daley_intel @@ -0,0 +1,31 @@ +#!/bin/csh -f + +set inp = "undefined" +if ($#argv == 1) then + set inp = $1 +endif + +if ("$inp" != "-nomodules") then + +source /opt/modules/default/init/csh # Initialize modules for csh +module load PrgEnv-intel # Intel compiler +module load cray-mpich # MPI (Cray MPICH) +module load cray-netcdf # NetCDF +module load cray-hdf5 # HDF5 +setenv HDF5_USE_FILE_LOCKING FALSE # necessary since data is on an NFS filesystem + +endif + +setenv ICE_MACHINE_ENVNAME daley +setenv ICE_MACHINE_COMPILER intel +setenv ICE_MACHINE_MAKE make +setenv ICE_MACHINE_WKDIR ~/data/daley/cice/runs +setenv ICE_MACHINE_INPUTDATA /home/ords/cmdd/cmde/sice500/ +setenv ICE_MACHINE_BASELINE ~/data/daley/cice/baselines +setenv ICE_MACHINE_SUBMIT "qsub" +setenv ICE_MACHINE_TPNODE 40 +setenv ICE_MACHINE_MAXRUNLENGTH 3 +setenv ICE_MACHINE_ACCT P0000000 +setenv ICE_MACHINE_QUEUE "development" +setenv ICE_MACHINE_BLDTHRDS 18 +setenv ICE_MACHINE_QSTAT "qstat " From 6ddb5e4cb93d8b02259b3a5e08846a04693ab381 Mon Sep 17 00:00:00 2001 From: "David A. Bailey" Date: Tue, 12 May 2020 12:09:55 -0600 Subject: [PATCH 11/19] Use JRA55 forcing for tx1 grid (#435) --- cicecore/cicedynB/general/ice_forcing.F90 | 27 +++++++++++++++++++++- configuration/scripts/options/set_nml.tx1 | 10 ++++---- doc/source/user_guide/ug_case_settings.rst | 1 + 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index 64f4b4834..52d4124b4 100755 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -116,7 +116,7 @@ module ice_forcing ocn_data_format, & ! 'bin'=binary or 'nc'=netcdf atm_data_type, & ! 'default', 'monthly', 'ncar', ! 'LYq' or 'hadgem' or 'oned' or - ! 'JRA55_gx1' or 'JRA55_gx3' + ! 'JRA55_gx1' or 'JRA55_gx3' or 'JRA55_tx1' bgc_data_type, & ! 'default', 'clim' ocn_data_type, & ! 'default', 'clim', 'ncar', 'oned', ! 'hadgem_sst' or 'hadgem_sst_uvocn' @@ -241,6 +241,7 @@ subroutine init_forcing_atmo if (use_leap_years .and. (trim(atm_data_type) /= 'JRA55_gx1' .and. & trim(atm_data_type) /= 'JRA55_gx3' .and. & + trim(atm_data_type) /= 'JRA55_tx1' .and. & trim(atm_data_type) /= 'hycom' .and. & trim(atm_data_type) /= 'box2001')) then write(nu_diag,*) 'use_leap_years option is currently only supported for' @@ -261,6 +262,8 @@ subroutine init_forcing_atmo call JRA55_gx1_files(fyear) elseif (trim(atm_data_type) == 'JRA55_gx3') then call JRA55_gx3_files(fyear) + elseif (trim(atm_data_type) == 'JRA55_tx1') then + call JRA55_tx1_files(fyear) elseif (trim(atm_data_type) == 'hadgem') then call hadgem_files(fyear) elseif (trim(atm_data_type) == 'monthly') then @@ -560,6 +563,8 @@ subroutine get_forcing_atmo call JRA55_data(fyear) elseif (trim(atm_data_type) == 'JRA55_gx3') then call JRA55_data(fyear) + elseif (trim(atm_data_type) == 'JRA55_tx1') then + call JRA55_data(fyear) elseif (trim(atm_data_type) == 'hadgem') then call hadgem_data elseif (trim(atm_data_type) == 'monthly') then @@ -1405,6 +1410,10 @@ subroutine file_year (data_file, yr) i = index(data_file,'.nc') - 5 tmpname = data_file write(data_file,'(a,i4.4,a)') tmpname(1:i), yr, '.nc' + elseif (trim(atm_data_type) == 'JRA55_tx1') then ! netcdf + i = index(data_file,'.nc') - 5 + tmpname = data_file + write(data_file,'(a,i4.4,a)') tmpname(1:i), yr, '.nc' else ! LANL/NCAR naming convention i = index(data_file,'.dat') - 5 tmpname = data_file @@ -2047,6 +2056,22 @@ subroutine JRA55_gx1_files(yr) write (nu_diag,*) trim(uwind_file) endif end subroutine JRA55_gx1_files + subroutine JRA55_tx1_files(yr) +! + integer (kind=int_kind), intent(in) :: & + yr ! current forcing year + + character(len=*), parameter :: subname = '(JRA55_tx1_files)' + + uwind_file = & + trim(atm_data_dir)//'/8XDAILY/JRA55_03hr_forcing_tx1_2005.nc' + call file_year(uwind_file,yr) + if (my_task == master_task) then + write (nu_diag,*) ' ' + write (nu_diag,*) 'Atmospheric data files:' + write (nu_diag,*) trim(uwind_file) + endif + end subroutine JRA55_tx1_files subroutine JRA55_gx3_files(yr) ! integer (kind=int_kind), intent(in) :: & diff --git a/configuration/scripts/options/set_nml.tx1 b/configuration/scripts/options/set_nml.tx1 index 120f7249f..dfdf6f19b 100644 --- a/configuration/scripts/options/set_nml.tx1 +++ b/configuration/scripts/options/set_nml.tx1 @@ -5,8 +5,8 @@ grid_format = 'bin' grid_type = 'tripole' grid_file = 'ICE_MACHINE_INPUTDATA/CICE_data/grid/tx1/grid_tx1.bin' kmt_file = 'ICE_MACHINE_INPUTDATA/CICE_data/grid/tx1/kmt_tx1.bin' -fyear_init = 1997 -atm_data_format = 'bin' -atm_data_type = 'clim' -atm_data_dir = 'none' - +atm_data_dir = 'ICE_MACHINE_INPUTDATA/CICE_data/forcing/tx1/JRA55' +atm_data_format = 'nc' +atm_data_type = 'JRA55_tx1' +year_init = 2005 +fyear_init = 2005 diff --git a/doc/source/user_guide/ug_case_settings.rst b/doc/source/user_guide/ug_case_settings.rst index b3088963d..033d4e8c2 100755 --- a/doc/source/user_guide/ug_case_settings.rst +++ b/doc/source/user_guide/ug_case_settings.rst @@ -356,6 +356,7 @@ Table of namelist options "","", "``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`", "" + "","", "``JRA55_tx1``", "JRA55 forcing data for tx1 grid :cite:`Tsujino18`", "" "","", "``monthly``", "monthly forcing data", "" "","", "``ncar``", "NCAR bulk forcing data", "" "","", "``box2001``", "forcing data for :cite:`Hunke01` box problem", "" From b08a97c6e047274c4bcba20b444f7209691ac5ad Mon Sep 17 00:00:00 2001 From: Robert Grumbine Date: Fri, 15 May 2020 12:12:01 -0400 Subject: [PATCH 12/19] NOAA machine pass of base_suite #155 (#372) * update to include a 'high_Sierra' machine with gnu compilers, only marginally modified from the travisCI env and Macros. * Syncing theia and upstream/master branch * theia execution * intel compiler version tests -- 15.0.0 or greater * working on variations for round robin test * syncing to main * sync * testing * end test * successful on phase2 for all regression tests * start on phase3 execution * add phase3 system * syncing and phase3 modules * update configs manually from master * env edit * builds on phase3 now * test * trying to pull/merge cice master * theia * successful theia build * garbage * update theia intel env * mods for running in NOAA * start towards hera * tmp * theia passes with most recent of all modules * moving to hera * clean regression run on hera * cleanup * phase3 work * minor manual move towards master copy * re-fix phase3 script * nearing full phase3 * update path for data * actual final version of phase3 * from master * cicecore updating from master * from consortium/master * more from master * retry sync * manual add/subtrace * script perms and large diff files * retrieve hera * docs and cicecore sync to master * machine syncing * couple more * some more * finally the right template * finally correct template * typography in master * restore working batch.csh * towards matching consortium master * last? add for syncing * Revert icepack to 1.1.2 Co-authored-by: Tony Craig --- .gitignore | 1 + configuration/scripts/cice.batch.csh | 34 ++++++++++- configuration/scripts/cice.launch.csh | 14 +++++ .../scripts/machines/Macros.hera_intel | 60 +++++++++++++++++++ configuration/scripts/machines/env.hera_intel | 26 ++++++++ .../scripts/machines/env.high_Sierra_gnu | 2 +- .../scripts/machines/env.phase3_intel | 12 ++-- 7 files changed, 142 insertions(+), 7 deletions(-) create mode 100644 configuration/scripts/machines/Macros.hera_intel create mode 100755 configuration/scripts/machines/env.hera_intel diff --git a/.gitignore b/.gitignore index f32b5b0ea..2a2a5fdb6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ doc/build # Ignore macOS cache files .DS_Store + # Ignore testsuite file/directories testsuite* caselist* diff --git a/configuration/scripts/cice.batch.csh b/configuration/scripts/cice.batch.csh index 6797a9f61..73e50bf47 100755 --- a/configuration/scripts/cice.batch.csh +++ b/configuration/scripts/cice.batch.csh @@ -213,7 +213,20 @@ cat >> ${jobfile} << EOFB #SBATCH -N ${nnodes} #SBATCH -e slurm%j.err #SBATCH -o slurm%j.out -#SBATCH --mail-type END,FAIL +#SBATCH --mail-type FAIL +#SBATCH --mail-user=robert.grumbine@noaa.gov +EOFB + +else if (${ICE_MACHINE} =~ hera*) then +cat >> ${jobfile} << EOFB +#SBATCH -J ${ICE_CASENAME} +#SBATCH -t `echo ${batchtime} | cut -f1-2 -d:` +#SBATCH -q batch +#SBATCH -A marine-cpu +#SBATCH -N ${nnodes} +#SBATCH -e slurm%j.err +#SBATCH -o slurm%j.out +#SBATCH --mail-type FAIL #SBATCH --mail-user=robert.grumbine@noaa.gov EOFB @@ -223,8 +236,25 @@ cat >> ${jobfile} << EOFB EOFB else if (${ICE_MACHINE} =~ phase3*) then +if ( ${nnodes} > 15) then + setenv p3tile 16 + setenv mem `expr 100 \* 1024 / $nnodes` +else + setenv p3tile ${nnodes} + setenv mem 8192 +endif +echo mem = ${mem} nnodes and p3tiles ${nnodes} ${p3tile} p3tile must be le nnodes cat >> ${jobfile} << EOFB -# nothing to do +#BSUB -J ${ICE_CASENAME} +#BSUB -q "dev_shared" +#BSUB -P RTO-T2O +#BSUB -W `echo ${batchtime} | cut -f1-2 -d:` +#BSUB -n ${nnodes} +#BSUB -R "affinity[core]" +#BSUB -R "span[ptile=${p3tile}]" +#BSUB -R "rusage[mem=${mem}]" +#BSUB -o /u/Robert.Grumbine/${ICE_CASENAME}.out.%J +#BSUB -e /u/Robert.Grumbine/${ICE_CASENAME}.err.%J EOFB else if (${ICE_MACHINE} =~ high_Sierra*) then diff --git a/configuration/scripts/cice.launch.csh b/configuration/scripts/cice.launch.csh index 296878914..48d6c0062 100755 --- a/configuration/scripts/cice.launch.csh +++ b/configuration/scripts/cice.launch.csh @@ -197,6 +197,20 @@ cat >> ${jobfile} << EOFR ./cice >&! \$ICE_RUNLOG_FILE EOFR +#======= +else if (${ICE_MACHINE} =~ phase3*) then +cat >> ${jobfile} << EOFR +mpirun -np ${ntasks} ./cice >&! \$ICE_RUNLOG_FILE +EOFR + +#======= +else if (${ICE_MACHINE} =~ phase2*) then +cat >> ${jobfile} << EOFR +mpirun -np ${ntasks} ./cice >&! \$ICE_RUNLOG_FILE +EOFR + +======= + #======= else if (${ICE_MACHINE} =~ travisCI*) then if (${ICE_COMMDIR} =~ serial*) then diff --git a/configuration/scripts/machines/Macros.hera_intel b/configuration/scripts/machines/Macros.hera_intel new file mode 100644 index 000000000..38cc62ed8 --- /dev/null +++ b/configuration/scripts/machines/Macros.hera_intel @@ -0,0 +1,60 @@ +#============================================================================== +# Makefile macros for theia - intel and openmpi compilers +#============================================================================== + +CPP := cpp +CPPDEFS := -DFORTRANUNDERSCORE -DNO_R16 -DHAVE_F2008_CONTIGUOUS -DLINUX -DCPRINTEL ${ICE_CPPDEFS} +CFLAGS := -c -O2 -xHost + +FIXEDFLAGS := -132 +FREEFLAGS := -FR +FFLAGS := -fp-model precise -convert big_endian -assume byterecl -ftz -traceback -xHost + +FFLAGS_NOOPT:= -O0 + +ifeq ($(ICE_BLDDEBUG), true) +#RG: this looks more like gfortran options: +## FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow + FFLAGS += -O0 -g -check-bounds -implicit-none -fpe3 +else + FFLAGS += -O2 +endif + +#Note that on theia mpif90 refers to gfortran even though it is in the intel bin +FC := mpiifort +MPIFC:= mpiifort +LD:= $(MPIFC) + +NETCDF_PATH := $(NETCDF) + +ifeq ($(ICE_IOTYPE), netcdf) + NETCDF_PATH := $(shell nc-config --prefix) + INCLDIR := $(INCLDIR) -I$(NETCDF_PATH)/include + LIB_NETCDF := $(NETCDF_PATH)/lib + LIB_PNETCDF := + SLIBS := -L$(LIB_NETCDF) -lnetcdf -lnetcdff +else + SLIBS := +endif + +LIB_MPI := + + +SCC := icc +SFC := ifort +MPICC := mpiicc +MPIFC := mpiifort + +ifeq ($(ICE_COMMDIR), mpi) + FC := $(MPIFC) + CC := $(MPICC) +else + FC := $(SFC) + CC := $(SCC) +endif + +ifeq ($(ICE_THREADED), true) + LDFLAGS += -fopenmp + CFLAGS += -fopenmp + FFLAGS += -fopenmp +endif diff --git a/configuration/scripts/machines/env.hera_intel b/configuration/scripts/machines/env.hera_intel new file mode 100755 index 000000000..ef3afdb7a --- /dev/null +++ b/configuration/scripts/machines/env.hera_intel @@ -0,0 +1,26 @@ +#!/bin/csh -f + +source /etc/profile.d/modules.csh +#module list +module purge +module load intel/18.0.5.274 +module load impi/2018.0.4 +module load esmf/7.1.0r +module load hdf5/1.10.4 netcdf/4.6.1 +module load wgrib wgrib2 +#echo renewed modules: +#module list + +setenv ICE_MACHINE_ENVNAME hera +setenv ICE_MACHINE_COMPILER intel +setenv ICE_MACHINE_MAKE make +setenv ICE_MACHINE_WKDIR /home/Robert.Grumbine/rgdev/CICE_RUNS +setenv ICE_MACHINE_INPUTDATA /home/Robert.Grumbine/rgdev/ +setenv ICE_MACHINE_BASELINE /home/Robert.Grumbine/rgdev/CICE_BASELINE +setenv ICE_MACHINE_SUBMIT "sbatch" +setenv ICE_MACHINE_TPNODE 4 +setenv ICE_MACHINE_ACCT P0000000 +setenv ICE_MACHINE_QUEUE "batch" +setenv ICE_MACHINE_BLDTHRDS 1 +setenv ICE_MACHINE_QSTAT " " +#setenv ICE_MACHINE_QUIETMODE true diff --git a/configuration/scripts/machines/env.high_Sierra_gnu b/configuration/scripts/machines/env.high_Sierra_gnu index cabd66944..db8bc01a3 100755 --- a/configuration/scripts/machines/env.high_Sierra_gnu +++ b/configuration/scripts/machines/env.high_Sierra_gnu @@ -4,7 +4,7 @@ setenv ICE_MACHINE_ENVNAME high_Sierra setenv ICE_MACHINE_COMPILER gnu setenv ICE_MACHINE_MAKE make setenv ICE_MACHINE_WKDIR /Volumes/ncep/CICE_RUNS -setenv ICE_MACHINE_INPUTDATA /Volumes/Data/CICE_data +setenv ICE_MACHINE_INPUTDATA /Volumes/Data/ setenv ICE_MACHINE_BASELINE /Volumes/ncep/CICE_BASELINE setenv ICE_MACHINE_SUBMIT " " setenv ICE_MACHINE_TPNODE 4 diff --git a/configuration/scripts/machines/env.phase3_intel b/configuration/scripts/machines/env.phase3_intel index 03aa7083f..4c8f65eee 100755 --- a/configuration/scripts/machines/env.phase3_intel +++ b/configuration/scripts/machines/env.phase3_intel @@ -1,8 +1,12 @@ -#!/bin/csh -f --login +#!/bin/csh -f -source /etc/profile.d/lmod.csh +#. $MODULESHOME/init/csh +source $MODULESHOME/init/csh +echo done with init.csh +module use -a $MODULESHOME/modulefiles module purge +module load lsf/10.1 module load ips/18.0.1.163 module load impi/18.0.1 module load NetCDF/4.5.0 @@ -15,10 +19,10 @@ setenv ICE_MACHINE_MAKE gmake setenv ICE_MACHINE_WKDIR /u/Robert.Grumbine/noscrub/CICE_RUNS setenv ICE_MACHINE_INPUTDATA /u/Robert.Grumbine/noscrub/ setenv ICE_MACHINE_BASELINE /u/Robert.Grumbine/noscrub/CICE_BASELINE -setenv ICE_MACHINE_SUBMIT " " +setenv ICE_MACHINE_SUBMIT "bsub < " setenv ICE_MACHINE_TPNODE 4 setenv ICE_MACHINE_QUEUE "default" setenv ICE_MACHINE_ACCT P0000000 setenv ICE_MACHINE_BLDTHRDS 1 -setenv ICE_MACHINE_QSTAT "qstat " +setenv ICE_MACHINE_QSTAT "bjobs " From bce31c2f85da934f0778f5adf938800d1977521a Mon Sep 17 00:00:00 2001 From: Tony Craig Date: Fri, 15 May 2020 09:15:15 -0700 Subject: [PATCH 13/19] update io_pio and io_pio2 for fsd input and output fields (#444) --- .../io/io_pio/ice_history_write.F90 | 150 ++++++++++++++++-- .../infrastructure/io/io_pio/ice_restart.F90 | 17 +- .../io/io_pio2/ice_history_write.F90 | 148 +++++++++++++++-- .../infrastructure/io/io_pio2/ice_restart.F90 | 17 +- 4 files changed, 302 insertions(+), 30 deletions(-) diff --git a/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 b/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 index 43e5dab74..23baeb40a 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 @@ -53,7 +53,7 @@ subroutine ice_write_hist (ns) dxu, dxt, dyu, dyt, HTN, HTE, ANGLE, ANGLET, tmask, & lont_bounds, latt_bounds, lonu_bounds, latu_bounds use ice_history_shared - use ice_arrays_column, only: hin_max + use ice_arrays_column, only: hin_max, floe_rad_c use ice_restart_shared, only: runid, lcdf64 use netcdf #endif @@ -67,13 +67,13 @@ subroutine ice_write_hist (ns) #ifdef ncdf integer (kind=int_kind) :: i,j,k,ic,n,nn, & ncid,status,imtid,jmtid,kmtidi,kmtids,kmtidb, cmtid,timid, & - length,nvertexid,ivertex,kmtida + length,nvertexid,ivertex,kmtida,fmtid integer (kind=int_kind), dimension(2) :: dimid2 integer (kind=int_kind), dimension(3) :: dimid3 integer (kind=int_kind), dimension(4) :: dimidz integer (kind=int_kind), dimension(5) :: dimidcz integer (kind=int_kind), dimension(3) :: dimid_nverts - integer (kind=int_kind), dimension(5) :: dimidex + integer (kind=int_kind), dimension(6) :: dimidex real (kind=real_kind) :: ltime real (kind= dbl_kind) :: ltime2 character (char_len) :: title @@ -89,7 +89,8 @@ subroutine ice_write_hist (ns) type(file_desc_t) :: File type(io_desc_t) :: iodesc2d, & iodesc3dc, iodesc3dv, iodesc3di, iodesc3db, iodesc3da, & - iodesc4di, iodesc4ds + iodesc3df, & + iodesc4di, iodesc4ds, iodesc4df type(var_desc_t) :: varid ! 4 coordinate variables: TLON, TLAT, ULON, ULAT @@ -168,9 +169,11 @@ subroutine ice_write_hist (ns) call ice_pio_initdecomp(ndim3=nzilyr, iodesc=iodesc3di) call ice_pio_initdecomp(ndim3=nzblyr, iodesc=iodesc3db) call ice_pio_initdecomp(ndim3=nzalyr, iodesc=iodesc3da) + call ice_pio_initdecomp(ndim3=nfsd_hist, iodesc=iodesc3df) call ice_pio_initdecomp(ndim3=nverts, inner_dim=.true., iodesc=iodesc3dv) call ice_pio_initdecomp(ndim3=nzilyr, ndim4=ncat_hist, iodesc=iodesc4di) call ice_pio_initdecomp(ndim3=nzslyr, ndim4=ncat_hist, iodesc=iodesc4ds) + call ice_pio_initdecomp(ndim3=nzslyr, ndim4=nfsd_hist, iodesc=iodesc4df) ltime2 = time/int(secday) ltime = real(time/int(secday),kind=real_kind) @@ -192,6 +195,7 @@ subroutine ice_write_hist (ns) status = pio_def_dim(File,'nkaer',nzalyr,kmtida) status = pio_def_dim(File,'time',PIO_UNLIMITED,timid) status = pio_def_dim(File,'nvertices',nverts,nvertexid) + status = pio_def_dim(File,'nf',nfsd_hist,fmtid) !----------------------------------------------------------------- ! define coordinate variables: time, time_bounds @@ -261,6 +265,7 @@ subroutine ice_write_hist (ns) var_nz(3) = coord_attributes('VGRDs', 'vertical snow levels', '1') var_nz(4) = coord_attributes('VGRDb', 'vertical ice-bio levels', '1') var_nz(5) = coord_attributes('VGRDa', 'vertical snow-ice-bio levels', '1') + var_nz(6) = coord_attributes('NFSD', 'category floe size (center)', 'm') !----------------------------------------------------------------- ! define information for optional time-invariant variables @@ -342,12 +347,13 @@ subroutine ice_write_hist (ns) endif enddo - ! Extra dimensions (NCAT, NZILYR, NZSLYR, NZBLYR, NZALYR) + ! Extra dimensions (NCAT, NZILYR, NZSLYR, NZBLYR, NZALYR, NFSD) dimidex(1)=cmtid dimidex(2)=kmtidi dimidex(3)=kmtids dimidex(4)=kmtidb dimidex(5)=kmtida + dimidex(6)=fmtid do i = 1, nvarz if (igrdz(i)) then @@ -605,6 +611,43 @@ subroutine ice_write_hist (ns) endif enddo ! num_avail_hist_fields_3Da + !----------------------------------------------------------------- + ! 3D (fsd) + !----------------------------------------------------------------- + + dimidz(1) = imtid + dimidz(2) = jmtid + dimidz(3) = fmtid + dimidz(4) = timid + + do n = n3Dacum + 1, n3Dfcum + if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then + status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & + pio_real, dimidz, varid) + status = pio_put_att(File,varid,'units', & + trim(avail_hist_fields(n)%vunit)) + status = pio_put_att(File,varid, 'long_name', & + trim(avail_hist_fields(n)%vdesc)) + status = pio_put_att(File,varid,'coordinates', & + trim(avail_hist_fields(n)%vcoord)) + status = pio_put_att(File,varid,'cell_measures', & + trim(avail_hist_fields(n)%vcellmeas)) + status = pio_put_att(File,varid,'missing_value',spval) + status = pio_put_att(File,varid,'_FillValue',spval) + + ! Add cell_methods attribute to variables if averaged + if (hist_avg .and. histfreq(ns) /= '1') then + status = pio_put_att(File,varid,'cell_methods','time: mean') + endif + + if (histfreq(ns) == '1' .or. .not. hist_avg) then + status = pio_put_att(File,varid,'time_rep','instantaneous') + else + status = pio_put_att(File,varid,'time_rep','averaged') + endif + endif + enddo ! num_avail_hist_fields_3Df + !----------------------------------------------------------------- ! define attributes for 4D variables ! time coordinate is dropped @@ -620,7 +663,7 @@ subroutine ice_write_hist (ns) dimidcz(4) = cmtid dimidcz(5) = timid - do n = n3Dacum + 1, n4Dicum + do n = n3Dfcum + 1, n4Dicum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & pio_real, dimidcz, varid) @@ -686,6 +729,45 @@ subroutine ice_write_hist (ns) endif enddo ! num_avail_hist_fields_4Ds + + !----------------------------------------------------------------- + ! 4D (fsd layers) + !----------------------------------------------------------------- + + dimidcz(1) = imtid + dimidcz(2) = jmtid + dimidcz(3) = fmtid + dimidcz(4) = cmtid + dimidcz(5) = timid + + do n = n4Dscum + 1, n4Dfcum + if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then + status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & + pio_real, dimidcz, varid) + status = pio_put_att(File,varid,'units', & + trim(avail_hist_fields(n)%vunit)) + status = pio_put_att(File,varid, 'long_name', & + trim(avail_hist_fields(n)%vdesc)) + status = pio_put_att(File,varid,'coordinates', & + trim(avail_hist_fields(n)%vcoord)) + status = pio_put_att(File,varid,'cell_measures', & + trim(avail_hist_fields(n)%vcellmeas)) + status = pio_put_att(File,varid,'missing_value',spval) + status = pio_put_att(File,varid,'_FillValue',spval) + + ! Add cell_methods attribute to variables if averaged + if (hist_avg .and. histfreq(ns) /= '1') then + status = pio_put_att(File,varid,'cell_methods','time: mean') + endif + + if (histfreq(ns) == '1' .or. .not. hist_avg) then + status = pio_put_att(File,varid,'time_rep','instantaneous') + else + status = pio_put_att(File,varid,'time_rep','averaged') + endif + endif + enddo ! num_avail_hist_fields_4Df + !----------------------------------------------------------------- ! global attributes !----------------------------------------------------------------- @@ -780,7 +862,7 @@ subroutine ice_write_hist (ns) workr2, status, fillval=spval_dbl) enddo - ! Extra dimensions (NCAT, VGRD*) + ! Extra dimensions (NCAT, NFSD, VGRD*) do i = 1, nvarz if (igrdz(i)) then @@ -788,6 +870,8 @@ subroutine ice_write_hist (ns) SELECT CASE (var_nz(i)%short_name) CASE ('NCAT') status = pio_put_var(File, varid, hin_max(1:ncat_hist)) + CASE ('NFSD') + status = pio_put_var(File, varid, floe_rad_c(1:nfsd_hist)) CASE ('VGRDi') status = pio_put_var(File, varid, (/(k, k=1,nzilyr)/)) CASE ('VGRDs') @@ -984,10 +1068,31 @@ subroutine ice_write_hist (ns) enddo ! num_avail_hist_fields_3Db deallocate(workr3) - allocate(workr4(nx_block,ny_block,nblocks,ncat_hist,nzilyr)) - ! 4D (categories, vertical ice) - do n = n3Dacum+1, n4Dicum + ! 3D (fsd) + allocate(workr3(nx_block,ny_block,nblocks,nfsd_hist)) + do n = n3Dacum+1, n3Dfcum nn = n - n3Dacum + if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then + status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) + if (status /= pio_noerr) call abort_ice(subname// & + 'ERROR: getting varid for '//avail_hist_fields(n)%vname) + do j = 1, nblocks + do i = 1, nfsd_hist + workr3(:,:,j,i) = a3Df(:,:,i,nn,j) + enddo + enddo + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +! call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) + call pio_write_darray(File, varid, iodesc3df,& + workr3, status, fillval=spval_dbl) + endif + enddo ! num_avail_hist_fields_3Df + deallocate(workr3) + + allocate(workr4(nx_block,ny_block,nblocks,ncat_hist,nzilyr)) + ! 4D (categories, fsd) + do n = n3Dfcum+1, n4Dicum + nn = n - n3Dfcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) if (status /= pio_noerr) call abort_ice(subname// & @@ -1029,6 +1134,29 @@ subroutine ice_write_hist (ns) enddo ! num_avail_hist_fields_4Di deallocate(workr4) + allocate(workr4(nx_block,ny_block,nblocks,ncat_hist,nfsd_hist)) + ! 4D (categories, vertical ice) + do n = n4Dscum+1, n4Dfcum + nn = n - n4Dscum + if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then + status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) + if (status /= pio_noerr) call abort_ice(subname// & + 'ERROR: getting varid for '//avail_hist_fields(n)%vname) + do j = 1, nblocks + do i = 1, ncat_hist + do k = 1, nfsd_hist + workr4(:,:,j,i,k) = a4Ds(:,:,k,i,nn,j) + enddo ! k + enddo ! i + enddo ! j + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +! call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) + call pio_write_darray(File, varid, iodesc4df,& + workr4, status, fillval=spval_dbl) + endif + enddo ! num_avail_hist_fields_4Di + deallocate(workr4) + ! similarly for num_avail_hist_fields_4Db (define workr4b, iodesc4db) @@ -1042,8 +1170,10 @@ subroutine ice_write_hist (ns) call pio_freedecomp(File,iodesc3di) call pio_freedecomp(File,iodesc3db) call pio_freedecomp(File,iodesc3da) + call pio_freedecomp(File,iodesc3df) call pio_freedecomp(File,iodesc4di) call pio_freedecomp(File,iodesc4ds) + call pio_freedecomp(File,iodesc4df) !----------------------------------------------------------------- ! close output dataset diff --git a/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 b/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 index d673c7f7a..c207d5b25 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 @@ -126,7 +126,7 @@ subroutine init_restart_write(filename_spec) 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 + n_dic, n_don, n_fed, n_fep, nfsd use ice_dyn_shared, only: kdyn use ice_arrays_column, only: oceanmixed_ice @@ -138,10 +138,10 @@ subroutine init_restart_write(filename_spec) 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_zaero, tr_bgc_Fe, & + tr_bgc_hum, tr_fsd integer (kind=int_kind) :: & nbtrcr @@ -178,7 +178,7 @@ subroutine init_restart_write(filename_spec) 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_bgc_hum_out=tr_bgc_hum, tr_fsd_out=tr_fsd) 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) @@ -473,6 +473,13 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'qsno'//trim(nchar),dims) enddo + 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 diff --git a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 index 771d0e313..229aa9e51 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 @@ -53,7 +53,7 @@ subroutine ice_write_hist (ns) dxu, dxt, dyu, dyt, HTN, HTE, ANGLE, ANGLET, tmask, & lont_bounds, latt_bounds, lonu_bounds, latu_bounds use ice_history_shared - use ice_arrays_column, only: hin_max + use ice_arrays_column, only: hin_max, floe_rad_c use ice_restart_shared, only: runid, lcdf64 use netcdf #endif @@ -67,13 +67,13 @@ subroutine ice_write_hist (ns) #ifdef ncdf integer (kind=int_kind) :: i,j,k,ic,n,nn, & ncid,status,imtid,jmtid,kmtidi,kmtids,kmtidb, cmtid,timid, & - length,nvertexid,ivertex,kmtida + length,nvertexid,ivertex,kmtida,fmtid integer (kind=int_kind), dimension(2) :: dimid2 integer (kind=int_kind), dimension(3) :: dimid3 integer (kind=int_kind), dimension(4) :: dimidz integer (kind=int_kind), dimension(5) :: dimidcz integer (kind=int_kind), dimension(3) :: dimid_nverts - integer (kind=int_kind), dimension(5) :: dimidex + integer (kind=int_kind), dimension(6) :: dimidex real (kind=real_kind) :: ltime real (kind= dbl_kind) :: ltime2 character (char_len) :: title @@ -89,7 +89,8 @@ subroutine ice_write_hist (ns) type(file_desc_t) :: File type(io_desc_t) :: iodesc2d, & iodesc3dc, iodesc3dv, iodesc3di, iodesc3db, iodesc3da, & - iodesc4di, iodesc4ds + iodesc3df, & + iodesc4di, iodesc4ds, iodesc4df type(var_desc_t) :: varid ! 4 coordinate variables: TLON, TLAT, ULON, ULAT @@ -168,9 +169,11 @@ subroutine ice_write_hist (ns) call ice_pio_initdecomp(ndim3=nzilyr, iodesc=iodesc3di) call ice_pio_initdecomp(ndim3=nzblyr, iodesc=iodesc3db) call ice_pio_initdecomp(ndim3=nzalyr, iodesc=iodesc3da) + call ice_pio_initdecomp(ndim3=nfsd_hist, iodesc=iodesc3df) call ice_pio_initdecomp(ndim3=nverts, inner_dim=.true., iodesc=iodesc3dv) call ice_pio_initdecomp(ndim3=nzilyr, ndim4=ncat_hist, iodesc=iodesc4di) call ice_pio_initdecomp(ndim3=nzslyr, ndim4=ncat_hist, iodesc=iodesc4ds) + call ice_pio_initdecomp(ndim3=nzslyr, ndim4=nfsd_hist, iodesc=iodesc4df) ltime2 = time/int(secday) ltime = real(time/int(secday),kind=real_kind) @@ -192,6 +195,7 @@ subroutine ice_write_hist (ns) status = pio_def_dim(File,'nkaer',nzalyr,kmtida) status = pio_def_dim(File,'time',PIO_UNLIMITED,timid) status = pio_def_dim(File,'nvertices',nverts,nvertexid) + status = pio_def_dim(File,'nf',nfsd_hist,fmtid) !----------------------------------------------------------------- ! define coordinate variables: time, time_bounds @@ -261,6 +265,7 @@ subroutine ice_write_hist (ns) var_nz(3) = coord_attributes('VGRDs', 'vertical snow levels', '1') var_nz(4) = coord_attributes('VGRDb', 'vertical ice-bio levels', '1') var_nz(5) = coord_attributes('VGRDa', 'vertical snow-ice-bio levels', '1') + var_nz(6) = coord_attributes('NFSD', 'category floe size (center)', 'm') !----------------------------------------------------------------- ! define information for optional time-invariant variables @@ -342,12 +347,13 @@ subroutine ice_write_hist (ns) endif enddo - ! Extra dimensions (NCAT, NZILYR, NZSLYR, NZBLYR, NZALYR) + ! Extra dimensions (NCAT, NZILYR, NZSLYR, NZBLYR, NZALYR, NFSD) dimidex(1)=cmtid dimidex(2)=kmtidi dimidex(3)=kmtids dimidex(4)=kmtidb dimidex(5)=kmtida + dimidex(6)=fmtid do i = 1, nvarz if (igrdz(i)) then @@ -605,6 +611,43 @@ subroutine ice_write_hist (ns) endif enddo ! num_avail_hist_fields_3Da + !----------------------------------------------------------------- + ! 3D (fsd) + !----------------------------------------------------------------- + + dimidz(1) = imtid + dimidz(2) = jmtid + dimidz(3) = fmtid + dimidz(4) = timid + + do n = n3Dacum + 1, n3Dfcum + if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then + status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & + pio_real, dimidz, varid) + status = pio_put_att(File,varid,'units', & + trim(avail_hist_fields(n)%vunit)) + status = pio_put_att(File,varid, 'long_name', & + trim(avail_hist_fields(n)%vdesc)) + status = pio_put_att(File,varid,'coordinates', & + trim(avail_hist_fields(n)%vcoord)) + status = pio_put_att(File,varid,'cell_measures', & + trim(avail_hist_fields(n)%vcellmeas)) + status = pio_put_att(File,varid,'missing_value',spval) + status = pio_put_att(File,varid,'_FillValue',spval) + + ! Add cell_methods attribute to variables if averaged + if (hist_avg .and. histfreq(ns) /= '1') then + status = pio_put_att(File,varid,'cell_methods','time: mean') + endif + + if (histfreq(ns) == '1' .or. .not. hist_avg) then + status = pio_put_att(File,varid,'time_rep','instantaneous') + else + status = pio_put_att(File,varid,'time_rep','averaged') + endif + endif + enddo ! num_avail_hist_fields_3Df + !----------------------------------------------------------------- ! define attributes for 4D variables ! time coordinate is dropped @@ -620,7 +663,7 @@ subroutine ice_write_hist (ns) dimidcz(4) = cmtid dimidcz(5) = timid - do n = n3Dacum + 1, n4Dicum + do n = n3Dfcum + 1, n4Dicum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & pio_real, dimidcz, varid) @@ -686,6 +729,45 @@ subroutine ice_write_hist (ns) endif enddo ! num_avail_hist_fields_4Ds + + !----------------------------------------------------------------- + ! 4D (fsd layers) + !----------------------------------------------------------------- + + dimidcz(1) = imtid + dimidcz(2) = jmtid + dimidcz(3) = fmtid + dimidcz(4) = cmtid + dimidcz(5) = timid + + do n = n4Dscum + 1, n4Dfcum + if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then + status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & + pio_real, dimidcz, varid) + status = pio_put_att(File,varid,'units', & + trim(avail_hist_fields(n)%vunit)) + status = pio_put_att(File,varid, 'long_name', & + trim(avail_hist_fields(n)%vdesc)) + status = pio_put_att(File,varid,'coordinates', & + trim(avail_hist_fields(n)%vcoord)) + status = pio_put_att(File,varid,'cell_measures', & + trim(avail_hist_fields(n)%vcellmeas)) + status = pio_put_att(File,varid,'missing_value',spval) + status = pio_put_att(File,varid,'_FillValue',spval) + + ! Add cell_methods attribute to variables if averaged + if (hist_avg .and. histfreq(ns) /= '1') then + status = pio_put_att(File,varid,'cell_methods','time: mean') + endif + + if (histfreq(ns) == '1' .or. .not. hist_avg) then + status = pio_put_att(File,varid,'time_rep','instantaneous') + else + status = pio_put_att(File,varid,'time_rep','averaged') + endif + endif + enddo ! num_avail_hist_fields_4Df + !----------------------------------------------------------------- ! global attributes !----------------------------------------------------------------- @@ -780,7 +862,7 @@ subroutine ice_write_hist (ns) workr2, status, fillval=spval_dbl) enddo - ! Extra dimensions (NCAT, VGRD*) + ! Extra dimensions (NCAT, NFSD, VGRD*) do i = 1, nvarz if (igrdz(i)) then @@ -788,6 +870,8 @@ subroutine ice_write_hist (ns) SELECT CASE (var_nz(i)%short_name) CASE ('NCAT') status = pio_put_var(File, varid, hin_max(1:ncat_hist)) + CASE ('NFSD') + status = pio_put_var(File, varid, floe_rad_c(1:nfsd_hist)) CASE ('VGRDi') status = pio_put_var(File, varid, (/(k, k=1,nzilyr)/)) CASE ('VGRDs') @@ -983,10 +1067,30 @@ subroutine ice_write_hist (ns) enddo ! num_avail_hist_fields_3Db deallocate(workr3) - allocate(workr4(nx_block,ny_block,nblocks,ncat_hist,nzilyr)) - ! 4D (categories, vertical ice) - do n = n3Dacum+1, n4Dicum + ! 3D (fsd) + allocate(workr3(nx_block,ny_block,nblocks,nfsd_hist)) + do n = n3Dacum+1, n3Dfcum nn = n - n3Dacum + if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then + status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) + if (status /= pio_noerr) call abort_ice(subname// & + 'ERROR: getting varid for '//avail_hist_fields(n)%vname) + do j = 1, nblocks + do i = 1, nfsd_hist + workr3(:,:,j,i) = a3Df(:,:,i,nn,j) + enddo + enddo + call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) + call pio_write_darray(File, varid, iodesc3df,& + workr3, status, fillval=spval_dbl) + endif + enddo ! num_avail_hist_fields_3Df + deallocate(workr3) + + allocate(workr4(nx_block,ny_block,nblocks,ncat_hist,nzilyr)) + ! 4D (categories, fsd) + do n = n3Dfcum+1, n4Dicum + nn = n - n3Dfcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) if (status /= pio_noerr) call abort_ice(subname// & @@ -1027,6 +1131,28 @@ subroutine ice_write_hist (ns) enddo ! num_avail_hist_fields_4Di deallocate(workr4) + allocate(workr4(nx_block,ny_block,nblocks,ncat_hist,nfsd_hist)) + ! 4D (categories, vertical ice) + do n = n4Dscum+1, n4Dfcum + nn = n - n4Dscum + if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then + status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) + if (status /= pio_noerr) call abort_ice(subname// & + 'ERROR: getting varid for '//avail_hist_fields(n)%vname) + do j = 1, nblocks + do i = 1, ncat_hist + do k = 1, nfsd_hist + workr4(:,:,j,i,k) = a4Ds(:,:,k,i,nn,j) + enddo ! k + enddo ! i + enddo ! j + call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) + call pio_write_darray(File, varid, iodesc4df,& + workr4, status, fillval=spval_dbl) + endif + enddo ! num_avail_hist_fields_4Di + deallocate(workr4) + ! similarly for num_avail_hist_fields_4Db (define workr4b, iodesc4db) @@ -1040,8 +1166,10 @@ subroutine ice_write_hist (ns) call pio_freedecomp(File,iodesc3di) call pio_freedecomp(File,iodesc3db) call pio_freedecomp(File,iodesc3da) + call pio_freedecomp(File,iodesc3df) call pio_freedecomp(File,iodesc4di) call pio_freedecomp(File,iodesc4ds) + call pio_freedecomp(File,iodesc4df) !----------------------------------------------------------------- ! close output dataset diff --git a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 index d673c7f7a..c207d5b25 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 @@ -126,7 +126,7 @@ subroutine init_restart_write(filename_spec) 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 + n_dic, n_don, n_fed, n_fep, nfsd use ice_dyn_shared, only: kdyn use ice_arrays_column, only: oceanmixed_ice @@ -138,10 +138,10 @@ subroutine init_restart_write(filename_spec) 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_zaero, tr_bgc_Fe, & + tr_bgc_hum, tr_fsd integer (kind=int_kind) :: & nbtrcr @@ -178,7 +178,7 @@ subroutine init_restart_write(filename_spec) 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_bgc_hum_out=tr_bgc_hum, tr_fsd_out=tr_fsd) 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) @@ -473,6 +473,13 @@ subroutine init_restart_write(filename_spec) call define_rest_field(File,'qsno'//trim(nchar),dims) enddo + 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 From 9ead578078b381294cac60a712d98cd4b3dd2772 Mon Sep 17 00:00:00 2001 From: "David A. Bailey" Date: Wed, 20 May 2020 10:42:42 -0600 Subject: [PATCH 14/19] Precision (#446) * Add history_precision option for history files. * Update to work with pio2 * Precision updates * Fix missing value precision * Add documentation * revert the Macros and env * revert cice.build * Move abort statement for history_precision --- .../cicedynB/analysis/ice_history_shared.F90 | 2 + cicecore/cicedynB/general/ice_init.F90 | 13 +- .../io/io_binary/ice_history_write.F90 | 27 ++- .../io/io_netcdf/ice_history_write.F90 | 213 ++++++++++++++---- .../io/io_pio/ice_history_write.F90 | 162 +++++++++---- .../infrastructure/io/io_pio/ice_pio.F90 | 1 - .../io/io_pio2/ice_history_write.F90 | 158 +++++++++---- .../infrastructure/io/io_pio2/ice_pio.F90 | 3 - configuration/scripts/ice_in | 1 + .../scripts/options/set_nml.precision8 | 1 + configuration/scripts/tests/base_suite.ts | 1 + doc/source/cice_index.rst | 1 + doc/source/user_guide/ug_case_settings.rst | 1 + doc/source/user_guide/ug_implementation.rst | 3 + 14 files changed, 437 insertions(+), 150 deletions(-) create mode 100644 configuration/scripts/options/set_nml.precision8 diff --git a/cicecore/cicedynB/analysis/ice_history_shared.F90 b/cicecore/cicedynB/analysis/ice_history_shared.F90 index 60740aea1..6c4d3acf3 100644 --- a/cicecore/cicedynB/analysis/ice_history_shared.F90 +++ b/cicecore/cicedynB/analysis/ice_history_shared.F90 @@ -33,6 +33,8 @@ module ice_history_shared private public :: define_hist_field, accum_hist_field, icefields_nml, construct_filename + integer (kind=int_kind), public :: history_precision + logical (kind=log_kind), public :: & hist_avg ! if true, write averaged data instead of snapshots diff --git a/cicecore/cicedynB/general/ice_init.F90 b/cicecore/cicedynB/general/ice_init.F90 index ffb070644..e96fc99d2 100644 --- a/cicecore/cicedynB/general/ice_init.F90 +++ b/cicecore/cicedynB/general/ice_init.F90 @@ -76,7 +76,8 @@ subroutine input_data restart, restart_ext, restart_dir, restart_file, pointer_file, & runid, runtype, use_restart_time, restart_format, lcdf64 use ice_history_shared, only: hist_avg, history_dir, history_file, & - incond_dir, incond_file, version_name + incond_dir, incond_file, version_name, & + history_precision use ice_flux, only: update_ocn_f, l_mpond_fresh use ice_flux, only: default_season use ice_flux_bgc, only: cpl_bgc @@ -152,7 +153,7 @@ subroutine input_data diagfreq, diag_type, diag_file, & print_global, print_points, latpnt, lonpnt, & dbug, histfreq, histfreq_n, hist_avg, & - history_dir, history_file, cpl_bgc, & + history_dir, history_file, history_precision, cpl_bgc, & write_ic, incond_dir, incond_file, version_name namelist /grid_nml/ & @@ -251,6 +252,7 @@ subroutine input_data hist_avg = .true. ! if true, write time-averages (not snapshots) history_dir = './' ! write to executable dir for default history_file = 'iceh' ! history file name prefix + history_precision = 4 ! precision of history files write_ic = .false. ! write out initial condition cpl_bgc = .false. ! history file name prefix incond_dir = history_dir ! write to history dir for default @@ -536,6 +538,7 @@ subroutine input_data call broadcast_scalar(hist_avg, master_task) call broadcast_scalar(history_dir, master_task) call broadcast_scalar(history_file, master_task) + call broadcast_scalar(history_precision, master_task) call broadcast_scalar(write_ic, master_task) call broadcast_scalar(cpl_bgc, master_task) call broadcast_scalar(incond_dir, master_task) @@ -935,6 +938,11 @@ subroutine input_data abort_flag = 19 endif + if(history_precision .ne. 4 .and. history_precision .ne. 8) then + write (nu_diag,*) 'ERROR: bad value for history_precision, allowed values: 4, 8' + abort_flag = 22 + endif + if (.not.(trim(dumpfreq) == 'y' .or. trim(dumpfreq) == 'Y' .or. & trim(dumpfreq) == 'm' .or. trim(dumpfreq) == 'M' .or. & trim(dumpfreq) == 'd' .or. trim(dumpfreq) == 'D' .or. & @@ -993,6 +1001,7 @@ subroutine input_data trim(history_dir) write(nu_diag,*) ' history_file = ', & trim(history_file) + write(nu_diag,1020) ' history_precision = ', history_precision if (write_ic) then write(nu_diag,*) 'Initial condition will be written in ', & trim(incond_dir) diff --git a/cicecore/cicedynB/infrastructure/io/io_binary/ice_history_write.F90 b/cicecore/cicedynB/infrastructure/io/io_binary/ice_history_write.F90 index dd525df6d..4154c59c1 100644 --- a/cicecore/cicedynB/infrastructure/io/io_binary/ice_history_write.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_binary/ice_history_write.F90 @@ -62,6 +62,10 @@ subroutine ice_write_hist(ns) integer (kind=int_kind) :: icategory,i_aice + character (len=4) :: & + atype ! format for output array + ! (real/integer, 4-byte/8-byte) + character (char_len) :: current_date,current_time character (len=16) :: c_aice logical (kind=log_kind) :: diag @@ -70,6 +74,9 @@ subroutine ice_write_hist(ns) diag = .false. + atype = 'rda4' + if (history_precision == 8) atype = 'rda8' + if (my_task == master_task) then call construct_filename(ncfile(ns),'da',ns) @@ -124,7 +131,7 @@ subroutine ice_write_hist(ns) write (nu_hdr, 996) nrec,'tarea','area of T grid cells','m^2' write (nu_hdr, * ) 'History variables: (left column = nrec)' endif ! my_task = master_task - call ice_write(nu_history, nrec, tarea, 'rda4', diag) + call ice_write(nu_history, nrec, tarea, atype, diag) do n=1,num_avail_hist_fields_2D if (avail_hist_fields(n)%vhistfreq == histfreq(ns)) then @@ -160,7 +167,7 @@ subroutine ice_write_hist(ns) endif endif - call ice_write(nu_history, nrec, a2D(:,:,n,:), 'rda4', diag) + call ice_write(nu_history, nrec, a2D(:,:,n,:), atype, diag) endif enddo ! num_avail_hist_fields_2D @@ -183,7 +190,7 @@ subroutine ice_write_hist(ns) endif endif - call ice_write(nu_history, nrec, a3Dc(:,:,nn,n-n2D,:), 'rda4', diag) + call ice_write(nu_history, nrec, a3Dc(:,:,nn,n-n2D,:), atype, diag) enddo ! ncat endif @@ -207,7 +214,7 @@ subroutine ice_write_hist(ns) endif endif - call ice_write(nu_history, nrec, a3Dz(:,:,k,n-n3Dccum,:), 'rda4', diag) + call ice_write(nu_history, nrec, a3Dz(:,:,k,n-n3Dccum,:), atype, diag) enddo ! nzilyr endif @@ -231,7 +238,7 @@ subroutine ice_write_hist(ns) endif endif - call ice_write(nu_history, nrec, a3Db(:,:,k,n-n3Dzcum,:), 'rda4', diag) + call ice_write(nu_history, nrec, a3Db(:,:,k,n-n3Dzcum,:), atype, diag) enddo ! nzilyr endif @@ -255,7 +262,7 @@ subroutine ice_write_hist(ns) endif endif - call ice_write(nu_history, nrec, a3Da(:,:,k,n-n3Dbcum,:), 'rda4', diag) + call ice_write(nu_history, nrec, a3Da(:,:,k,n-n3Dbcum,:), atype, diag) enddo ! nzilyr endif @@ -279,7 +286,7 @@ subroutine ice_write_hist(ns) endif endif - call ice_write(nu_history, nrec, a3Df(:,:,k,n-n3Dacum,:), 'rda4', diag) + call ice_write(nu_history, nrec, a3Df(:,:,k,n-n3Dacum,:), atype, diag) enddo ! nfsd_hist endif @@ -304,7 +311,7 @@ subroutine ice_write_hist(ns) endif endif - call ice_write(nu_history, nrec, a4Di(:,:,k,nn,n-n3Dfcum,:), 'rda4', diag) + call ice_write(nu_history, nrec, a4Di(:,:,k,nn,n-n3Dfcum,:), atype, diag) enddo ! nzilyr enddo ! ncat_hist @@ -330,7 +337,7 @@ subroutine ice_write_hist(ns) endif endif - call ice_write(nu_history, nrec, a4Ds(:,:,k,nn,n-n4Dicum,:), 'rda4', diag) + call ice_write(nu_history, nrec, a4Ds(:,:,k,nn,n-n4Dicum,:), atype, diag) enddo ! nzilyr enddo ! ncat_hist @@ -356,7 +363,7 @@ subroutine ice_write_hist(ns) endif endif - call ice_write(nu_history, nrec, a4Df(:,:,k,nn,n-n4Dscum,:), 'rda4', diag) + call ice_write(nu_history, nrec, a4Df(:,:,k,nn,n-n4Dscum,:), atype, diag) enddo ! nfsd_hist enddo ! ncat_hist diff --git a/cicecore/cicedynB/infrastructure/io/io_netcdf/ice_history_write.F90 b/cicecore/cicedynB/infrastructure/io/io_netcdf/ice_history_write.F90 index ff16c637b..5b6aa0dd8 100644 --- a/cicecore/cicedynB/infrastructure/io/io_netcdf/ice_history_write.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_netcdf/ice_history_write.F90 @@ -18,7 +18,7 @@ module ice_history_write - use ice_constants, only: c0, c360, spval + use ice_constants, only: c0, c360, spval, spval_dbl use ice_fileunits, only: nu_diag use ice_exit, only: abort_ice use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted @@ -86,6 +86,8 @@ subroutine ice_write_hist (ns) integer (kind=int_kind) :: ind,boundid + integer (kind=int_kind) :: lprecision + character (char_len) :: start_time,current_date,current_time character (len=8) :: cdate @@ -123,6 +125,9 @@ subroutine ice_write_hist (ns) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) + lprecision = nf90_float + if (history_precision == 8) lprecision = nf90_double + if (my_task == master_task) then ! ltime=time/int(secday) @@ -243,7 +248,7 @@ subroutine ice_write_hist (ns) if (hist_avg) then dimid(1) = boundid dimid(2) = timid - status = nf90_def_var(ncid,'time_bounds',nf90_float,dimid(1:2),varid) + status = nf90_def_var(ncid,'time_bounds',lprecision,dimid(1:2),varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining var time_bounds') status = nf90_put_att(ncid,varid,'long_name', & @@ -344,7 +349,7 @@ subroutine ice_write_hist (ns) dimid(3) = timid do i = 1, ncoord - status = nf90_def_var(ncid, coord_var(i)%short_name, nf90_float, & + status = nf90_def_var(ncid, coord_var(i)%short_name, lprecision, & dimid(1:2), varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining short_name for '//coord_var(i)%short_name) @@ -354,10 +359,18 @@ subroutine ice_write_hist (ns) status = nf90_put_att(ncid, varid, 'units', coord_var(i)%units) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining units for '//coord_var(i)%short_name) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//coord_var(i)%short_name) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//coord_var(i)%short_name) if (coord_var(i)%short_name == 'ULAT') then @@ -384,7 +397,7 @@ subroutine ice_write_hist (ns) do i = 1, nvarz if (igrdz(i)) then status = nf90_def_var(ncid, var_nz(i)%short_name, & - nf90_float, dimidex(i), varid) + lprecision, dimidex(i), varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining short_name for '//var_nz(i)%short_name) status = nf90_put_att(ncid,varid,'long_name',var_nz(i)%long_name) @@ -398,7 +411,7 @@ subroutine ice_write_hist (ns) ! Attributes for tmask, blkmask defined separately, since they have no units if (igrd(n_tmask)) then - status = nf90_def_var(ncid, 'tmask', nf90_float, dimid(1:2), varid) + status = nf90_def_var(ncid, 'tmask', lprecision, dimid(1:2), varid) if (status /= nf90_noerr) call abort_ice(subname//'ERROR: defining var tmask') status = nf90_put_att(ncid,varid, 'long_name', 'ocean grid mask') if (status /= nf90_noerr) call abort_ice(subname//'ERROR: tmask long_name') @@ -406,14 +419,22 @@ subroutine ice_write_hist (ns) if (status /= nf90_noerr) call abort_ice(subname//'ERROR: tmask units') status = nf90_put_att(ncid,varid,'comment', '0 = land, 1 = ocean') if (status /= nf90_noerr) call abort_ice(subname//'ERROR: tmask comment') - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname//'ERROR: defining missing_value for tmask') - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname//'ERROR: defining _FillValue for tmask') endif if (igrd(n_blkmask)) then - status = nf90_def_var(ncid, 'blkmask', nf90_float, dimid(1:2), varid) + status = nf90_def_var(ncid, 'blkmask', lprecision, dimid(1:2), varid) if (status /= nf90_noerr) call abort_ice(subname//'ERROR: defining var blkmask') status = nf90_put_att(ncid,varid, 'long_name', 'ice grid block mask') if (status /= nf90_noerr) call abort_ice(subname//'ERROR: blkmask long_name') @@ -421,16 +442,24 @@ subroutine ice_write_hist (ns) if (status /= nf90_noerr) call abort_ice(subname//'ERROR: blkmask units') status = nf90_put_att(ncid,varid,'comment', 'mytask + iblk/100') if (status /= nf90_noerr) call abort_ice(subname//'ERROR: blkmask comment') - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname//'ERROR: defining missing_value for blkmask') - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname//'ERROR: defining _FillValue for blkmask') endif do i = 3, nvar ! note n_tmask=1, n_blkmask=2 if (igrd(i)) then status = nf90_def_var(ncid, var(i)%req%short_name, & - nf90_float, dimid(1:2), varid) + lprecision, dimid(1:2), varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//var(i)%req%short_name) status = nf90_put_att(ncid,varid, 'long_name', var(i)%req%long_name) @@ -442,10 +471,18 @@ subroutine ice_write_hist (ns) status = nf90_put_att(ncid, varid, 'coordinates', var(i)%coordinates) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining coordinates for '//var(i)%req%short_name) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//var(i)%req%short_name) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//var(i)%req%short_name) endif @@ -458,7 +495,7 @@ subroutine ice_write_hist (ns) do i = 1, nvar_verts if (f_bounds) then status = nf90_def_var(ncid, var_nverts(i)%short_name, & - nf90_float,dimid_nverts, varid) + lprecision,dimid_nverts, varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//var_nverts(i)%short_name) status = nf90_put_att(ncid,varid, 'long_name', var_nverts(i)%long_name) @@ -467,10 +504,18 @@ subroutine ice_write_hist (ns) status = nf90_put_att(ncid, varid, 'units', var_nverts(i)%units) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining units for '//var_nverts(i)%short_name) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//var_nverts(i)%short_name) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//var_nverts(i)%short_name) endif @@ -479,7 +524,7 @@ subroutine ice_write_hist (ns) do n=1,num_avail_hist_fields_2D if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = nf90_def_var(ncid, avail_hist_fields(n)%vname, & - nf90_float, dimid, varid) + lprecision, dimid, varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//avail_hist_fields(n)%vname) status = nf90_put_att(ncid,varid,'units', & @@ -498,10 +543,18 @@ subroutine ice_write_hist (ns) avail_hist_fields(n)%vcellmeas) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining cell measures for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//avail_hist_fields(n)%vname) @@ -542,7 +595,7 @@ subroutine ice_write_hist (ns) do n = n2D + 1, n3Dccum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = nf90_def_var(ncid, avail_hist_fields(n)%vname, & - nf90_float, dimidz, varid) + lprecision, dimidz, varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//avail_hist_fields(n)%vname) status = nf90_put_att(ncid,varid,'units', & @@ -561,10 +614,18 @@ subroutine ice_write_hist (ns) avail_hist_fields(n)%vcellmeas) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining cell measures for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//avail_hist_fields(n)%vname) @@ -593,7 +654,7 @@ subroutine ice_write_hist (ns) do n = n3Dccum + 1, n3Dzcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = nf90_def_var(ncid, avail_hist_fields(n)%vname, & - nf90_float, dimidz, varid) + lprecision, dimidz, varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//avail_hist_fields(n)%vname) status = nf90_put_att(ncid,varid,'units', & @@ -612,10 +673,18 @@ subroutine ice_write_hist (ns) avail_hist_fields(n)%vcellmeas) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining cell measures for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//avail_hist_fields(n)%vname) @@ -630,7 +699,7 @@ subroutine ice_write_hist (ns) do n = n3Dzcum + 1, n3Dbcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = nf90_def_var(ncid, avail_hist_fields(n)%vname, & - nf90_float, dimidz, varid) + lprecision, dimidz, varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//avail_hist_fields(n)%vname) status = nf90_put_att(ncid,varid,'units', & @@ -649,10 +718,18 @@ subroutine ice_write_hist (ns) avail_hist_fields(n)%vcellmeas) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining cell measures for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//avail_hist_fields(n)%vname) @@ -667,7 +744,7 @@ subroutine ice_write_hist (ns) do n = n3Dbcum + 1, n3Dacum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = nf90_def_var(ncid, avail_hist_fields(n)%vname, & - nf90_float, dimidz, varid) + lprecision, dimidz, varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//avail_hist_fields(n)%vname) status = nf90_put_att(ncid,varid,'units', & @@ -686,10 +763,18 @@ subroutine ice_write_hist (ns) avail_hist_fields(n)%vcellmeas) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining cell measures for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//avail_hist_fields(n)%vname) @@ -704,7 +789,7 @@ subroutine ice_write_hist (ns) do n = n3Dacum + 1, n3Dfcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = nf90_def_var(ncid, avail_hist_fields(n)%vname, & - nf90_float, dimidz, varid) + lprecision, dimidz, varid) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//avail_hist_fields(n)%vname) status = nf90_put_att(ncid,varid,'units', & @@ -723,10 +808,18 @@ subroutine ice_write_hist (ns) avail_hist_fields(n)%vcellmeas) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining cell measures for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//avail_hist_fields(n)%vname) @@ -742,8 +835,8 @@ subroutine ice_write_hist (ns) do n = n3Dfcum + 1, n4Dicum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = nf90_def_var(ncid, avail_hist_fields(n)%vname, & -! nf90_float, dimidcz, varid) - nf90_float, dimidcz(1:4), varid) ! ferret +! lprecision, dimidcz, varid) + lprecision, dimidcz(1:4), varid) ! ferret if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//avail_hist_fields(n)%vname) status = nf90_put_att(ncid,varid,'units', & @@ -762,10 +855,18 @@ subroutine ice_write_hist (ns) avail_hist_fields(n)%vcellmeas) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining cell measures for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//avail_hist_fields(n)%vname) @@ -795,8 +896,8 @@ subroutine ice_write_hist (ns) do n = n4Dicum + 1, n4Dscum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = nf90_def_var(ncid, avail_hist_fields(n)%vname, & -! nf90_float, dimidcz, varid) - nf90_float, dimidcz(1:4), varid) ! ferret +! lprecision, dimidcz, varid) + lprecision, dimidcz(1:4), varid) ! ferret if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//avail_hist_fields(n)%vname) status = nf90_put_att(ncid,varid,'units', & @@ -815,10 +916,18 @@ subroutine ice_write_hist (ns) avail_hist_fields(n)%vcellmeas) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining cell measures for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//avail_hist_fields(n)%vname) @@ -848,8 +957,8 @@ subroutine ice_write_hist (ns) do n = n4Dscum + 1, n4Dfcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = nf90_def_var(ncid, avail_hist_fields(n)%vname, & -! nf90_float, dimidcz, varid) - nf90_float, dimidcz(1:4), varid) ! ferret +! lprecision, dimidcz, varid) + lprecision, dimidcz(1:4), varid) ! ferret if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining variable '//avail_hist_fields(n)%vname) status = nf90_put_att(ncid,varid,'units', & @@ -868,10 +977,18 @@ subroutine ice_write_hist (ns) avail_hist_fields(n)%vcellmeas) if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining cell measures for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'missing_value',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'missing_value',spval) + else + status = nf90_put_att(ncid,varid,'missing_value',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining missing_value for '//avail_hist_fields(n)%vname) - status = nf90_put_att(ncid,varid,'_FillValue',spval) + if (lprecision == nf90_float) then + status = nf90_put_att(ncid,varid,'_FillValue',spval) + else + status = nf90_put_att(ncid,varid,'_FillValue',spval_dbl) + endif if (status /= nf90_noerr) call abort_ice(subname// & 'ERROR: defining _FillValue for '//avail_hist_fields(n)%vname) diff --git a/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 b/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 index 23baeb40a..9c20daf20 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 @@ -137,6 +137,8 @@ subroutine ice_write_hist (ns) real (kind=dbl_kind) :: secday real (kind=dbl_kind) :: rad_to_deg + integer (kind=int_kind) :: lprecision + character(len=*), parameter :: subname = '(ice_write_hist)' call icepack_query_parameters(secday_out=secday) @@ -178,6 +180,10 @@ subroutine ice_write_hist (ns) ltime2 = time/int(secday) ltime = real(time/int(secday),kind=real_kind) + ! option of turning on double precision history files + lprecision = pio_real + if (history_precision == 8) lprecision = pio_double + !----------------------------------------------------------------- ! define dimensions !----------------------------------------------------------------- @@ -332,12 +338,17 @@ subroutine ice_write_hist (ns) dimid2(2) = jmtid do i = 1, ncoord - status = pio_def_var(File, trim(coord_var(i)%short_name), pio_real, & + status = pio_def_var(File, trim(coord_var(i)%short_name), lprecision, & dimid2, varid) status = pio_put_att(File,varid,'long_name',trim(coord_var(i)%long_name)) status = pio_put_att(File, varid, 'units', trim(coord_var(i)%units)) - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif if (coord_var(i)%short_name == 'ULAT') then status = pio_put_att(File,varid,'comment', & trim('Latitude of NE corner of T grid cell')) @@ -357,7 +368,7 @@ subroutine ice_write_hist (ns) do i = 1, nvarz if (igrdz(i)) then - status = pio_def_var(File, trim(var_nz(i)%short_name), pio_real, & + status = pio_def_var(File, trim(var_nz(i)%short_name), lprecision, & (/dimidex(i)/), varid) status = pio_put_att(File, varid, 'long_name', var_nz(i)%long_name) status = pio_put_att(File, varid, 'units' , var_nz(i)%units) @@ -366,31 +377,46 @@ subroutine ice_write_hist (ns) ! Attributes for tmask defined separately, since it has no units if (igrd(n_tmask)) then - status = pio_def_var(File, 'tmask', pio_real, dimid2, varid) + status = pio_def_var(File, 'tmask', lprecision, dimid2, varid) status = pio_put_att(File,varid, 'long_name', 'ocean grid mask') status = pio_put_att(File, varid, 'coordinates', 'TLON TLAT') - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif status = pio_put_att(File,varid,'comment', '0 = land, 1 = ocean') endif if (igrd(n_blkmask)) then - status = pio_def_var(File, 'blkmask', pio_real, dimid2, varid) + status = pio_def_var(File, 'blkmask', lprecision, dimid2, varid) status = pio_put_att(File,varid, 'long_name', 'ice grid block mask') status = pio_put_att(File, varid, 'coordinates', 'TLON TLAT') status = pio_put_att(File,varid,'comment', 'mytask + iblk/100') - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif endif do i = 3, nvar ! note: n_tmask=1, n_blkmask=2 if (igrd(i)) then status = pio_def_var(File, trim(var(i)%req%short_name), & - pio_real, dimid2, varid) + lprecision, dimid2, varid) status = pio_put_att(File,varid, 'long_name', trim(var(i)%req%long_name)) status = pio_put_att(File, varid, 'units', trim(var(i)%req%units)) status = pio_put_att(File, varid, 'coordinates', trim(var(i)%coordinates)) - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif endif enddo @@ -401,13 +427,18 @@ subroutine ice_write_hist (ns) do i = 1, nvar_verts if (f_bounds) then status = pio_def_var(File, trim(var_nverts(i)%short_name), & - pio_real,dimid_nverts, varid) + lprecision,dimid_nverts, varid) status = & pio_put_att(File,varid, 'long_name', trim(var_nverts(i)%long_name)) status = & pio_put_att(File, varid, 'units', trim(var_nverts(i)%units)) - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif endif enddo @@ -426,7 +457,7 @@ subroutine ice_write_hist (ns) do n=1,num_avail_hist_fields_2D if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimid3, varid) + lprecision, dimid3, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -435,8 +466,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -475,7 +511,7 @@ subroutine ice_write_hist (ns) do n = n2D + 1, n3Dccum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidz, varid) + lprecision, dimidz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -484,8 +520,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -512,7 +553,7 @@ subroutine ice_write_hist (ns) do n = n3Dccum + 1, n3Dzcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidz, varid) + lprecision, dimidz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -521,8 +562,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -549,7 +595,7 @@ subroutine ice_write_hist (ns) do n = n3Dzcum + 1, n3Dbcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidz, varid) + lprecision, dimidz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -558,8 +604,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -586,7 +637,7 @@ subroutine ice_write_hist (ns) do n = n3Dbcum + 1, n3Dacum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidz, varid) + lprecision, dimidz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -595,8 +646,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -632,8 +688,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -666,7 +727,7 @@ subroutine ice_write_hist (ns) do n = n3Dfcum + 1, n4Dicum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidcz, varid) + lprecision, dimidcz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -675,8 +736,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -704,7 +770,7 @@ subroutine ice_write_hist (ns) do n = n4Dicum + 1, n4Dscum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidcz, varid) + lprecision, dimidcz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -713,8 +779,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -752,8 +823,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -1061,7 +1137,6 @@ subroutine ice_write_hist (ns) enddo enddo call pio_setframe(varid, int(1,kind=PIO_OFFSET)) -! call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) call pio_write_darray(File, varid, iodesc3da,& workr3, status, fillval=spval_dbl) endif @@ -1082,7 +1157,6 @@ subroutine ice_write_hist (ns) enddo enddo call pio_setframe(varid, int(1,kind=PIO_OFFSET)) -! call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) call pio_write_darray(File, varid, iodesc3df,& workr3, status, fillval=spval_dbl) endif @@ -1127,7 +1201,6 @@ subroutine ice_write_hist (ns) enddo ! i enddo ! j call pio_setframe(varid, int(1,kind=PIO_OFFSET)) -! call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) call pio_write_darray(File, varid, iodesc4ds,& workr4, status, fillval=spval_dbl) endif @@ -1150,7 +1223,6 @@ subroutine ice_write_hist (ns) enddo ! i enddo ! j call pio_setframe(varid, int(1,kind=PIO_OFFSET)) -! call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) call pio_write_darray(File, varid, iodesc4df,& workr4, status, fillval=spval_dbl) endif diff --git a/cicecore/cicedynB/infrastructure/io/io_pio/ice_pio.F90 b/cicecore/cicedynB/infrastructure/io/io_pio/ice_pio.F90 index 5fff64944..d6aa65ae1 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio/ice_pio.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio/ice_pio.F90 @@ -6,7 +6,6 @@ module ice_pio use shr_kind_mod, only: r8 => shr_kind_r8, in=>shr_kind_in use shr_kind_mod, only: cl => shr_kind_cl - use shr_sys_mod , only: shr_sys_flush use ice_kinds_mod use ice_blocks use ice_broadcast diff --git a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 index 229aa9e51..209aa47b7 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 @@ -137,6 +137,8 @@ subroutine ice_write_hist (ns) real (kind=dbl_kind) :: secday real (kind=dbl_kind) :: rad_to_deg + integer (kind=int_kind) :: lprecision + character(len=*), parameter :: subname = '(ice_write_hist)' call icepack_query_parameters(secday_out=secday) @@ -178,6 +180,10 @@ subroutine ice_write_hist (ns) ltime2 = time/int(secday) ltime = real(time/int(secday),kind=real_kind) + ! option of turning on double precision history files + lprecision = pio_real + if (history_precision == 8) lprecision = pio_double + !----------------------------------------------------------------- ! define dimensions !----------------------------------------------------------------- @@ -332,12 +338,17 @@ subroutine ice_write_hist (ns) dimid2(2) = jmtid do i = 1, ncoord - status = pio_def_var(File, trim(coord_var(i)%short_name), pio_real, & + status = pio_def_var(File, trim(coord_var(i)%short_name), lprecision, & dimid2, varid) status = pio_put_att(File,varid,'long_name',trim(coord_var(i)%long_name)) status = pio_put_att(File, varid, 'units', trim(coord_var(i)%units)) - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif if (coord_var(i)%short_name == 'ULAT') then status = pio_put_att(File,varid,'comment', & trim('Latitude of NE corner of T grid cell')) @@ -357,7 +368,7 @@ subroutine ice_write_hist (ns) do i = 1, nvarz if (igrdz(i)) then - status = pio_def_var(File, trim(var_nz(i)%short_name), pio_real, & + status = pio_def_var(File, trim(var_nz(i)%short_name), lprecision, & (/dimidex(i)/), varid) status = pio_put_att(File, varid, 'long_name', var_nz(i)%long_name) status = pio_put_att(File, varid, 'units' , var_nz(i)%units) @@ -366,31 +377,46 @@ subroutine ice_write_hist (ns) ! Attributes for tmask defined separately, since it has no units if (igrd(n_tmask)) then - status = pio_def_var(File, 'tmask', pio_real, dimid2, varid) + status = pio_def_var(File, 'tmask', lprecision, dimid2, varid) status = pio_put_att(File,varid, 'long_name', 'ocean grid mask') status = pio_put_att(File, varid, 'coordinates', 'TLON TLAT') - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif status = pio_put_att(File,varid,'comment', '0 = land, 1 = ocean') endif if (igrd(n_blkmask)) then - status = pio_def_var(File, 'blkmask', pio_real, dimid2, varid) + status = pio_def_var(File, 'blkmask', lprecision, dimid2, varid) status = pio_put_att(File,varid, 'long_name', 'ice grid block mask') status = pio_put_att(File, varid, 'coordinates', 'TLON TLAT') status = pio_put_att(File,varid,'comment', 'mytask + iblk/100') - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif endif do i = 3, nvar ! note: n_tmask=1, n_blkmask=2 if (igrd(i)) then status = pio_def_var(File, trim(var(i)%req%short_name), & - pio_real, dimid2, varid) + lprecision, dimid2, varid) status = pio_put_att(File,varid, 'long_name', trim(var(i)%req%long_name)) status = pio_put_att(File, varid, 'units', trim(var(i)%req%units)) status = pio_put_att(File, varid, 'coordinates', trim(var(i)%coordinates)) - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif endif enddo @@ -401,13 +427,18 @@ subroutine ice_write_hist (ns) do i = 1, nvar_verts if (f_bounds) then status = pio_def_var(File, trim(var_nverts(i)%short_name), & - pio_real,dimid_nverts, varid) + lprecision,dimid_nverts, varid) status = & pio_put_att(File,varid, 'long_name', trim(var_nverts(i)%long_name)) status = & pio_put_att(File, varid, 'units', trim(var_nverts(i)%units)) - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif endif enddo @@ -426,7 +457,7 @@ subroutine ice_write_hist (ns) do n=1,num_avail_hist_fields_2D if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimid3, varid) + lprecision, dimid3, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -435,8 +466,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -475,7 +511,7 @@ subroutine ice_write_hist (ns) do n = n2D + 1, n3Dccum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidz, varid) + lprecision, dimidz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -484,8 +520,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -512,7 +553,7 @@ subroutine ice_write_hist (ns) do n = n3Dccum + 1, n3Dzcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidz, varid) + lprecision, dimidz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -521,8 +562,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -549,7 +595,7 @@ subroutine ice_write_hist (ns) do n = n3Dzcum + 1, n3Dbcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidz, varid) + lprecision, dimidz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -558,8 +604,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -586,7 +637,7 @@ subroutine ice_write_hist (ns) do n = n3Dbcum + 1, n3Dacum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidz, varid) + lprecision, dimidz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -595,8 +646,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -632,8 +688,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -666,7 +727,7 @@ subroutine ice_write_hist (ns) do n = n3Dfcum + 1, n4Dicum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidcz, varid) + lprecision, dimidcz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -675,8 +736,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -704,7 +770,7 @@ subroutine ice_write_hist (ns) do n = n4Dicum + 1, n4Dscum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidcz, varid) + lprecision, dimidcz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -713,8 +779,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then @@ -752,8 +823,13 @@ subroutine ice_write_hist (ns) trim(avail_hist_fields(n)%vcoord)) status = pio_put_att(File,varid,'cell_measures', & trim(avail_hist_fields(n)%vcellmeas)) - status = pio_put_att(File,varid,'missing_value',spval) - status = pio_put_att(File,varid,'_FillValue',spval) + if (lprecision == pio_real) then + status = pio_put_att(File, varid, 'missing_value', spval) + status = pio_put_att(File, varid,'_FillValue',spval) + else + status = pio_put_att(File, varid, 'missing_value', spval_dbl) + status = pio_put_att(File, varid,'_FillValue',spval_dbl) + endif ! Add cell_methods attribute to variables if averaged if (hist_avg .and. histfreq(ns) /= '1') then diff --git a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_pio.F90 b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_pio.F90 index 5fff64944..564c9cd3b 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_pio.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_pio.F90 @@ -4,9 +4,6 @@ module ice_pio - use shr_kind_mod, only: r8 => shr_kind_r8, in=>shr_kind_in - use shr_kind_mod, only: cl => shr_kind_cl - use shr_sys_mod , only: shr_sys_flush use ice_kinds_mod use ice_blocks use ice_broadcast diff --git a/configuration/scripts/ice_in b/configuration/scripts/ice_in index dcfedf772..bba1309b5 100644 --- a/configuration/scripts/ice_in +++ b/configuration/scripts/ice_in @@ -37,6 +37,7 @@ hist_avg = .true. history_dir = './history/' history_file = 'iceh' + history_precision = 4 write_ic = .true. incond_dir = './history/' incond_file = 'iceh_ic' diff --git a/configuration/scripts/options/set_nml.precision8 b/configuration/scripts/options/set_nml.precision8 new file mode 100644 index 000000000..5243ef8df --- /dev/null +++ b/configuration/scripts/options/set_nml.precision8 @@ -0,0 +1 @@ +history_precision = 8 diff --git a/configuration/scripts/tests/base_suite.ts b/configuration/scripts/tests/base_suite.ts index fad8b22f3..f2ac2b69b 100755 --- a/configuration/scripts/tests/base_suite.ts +++ b/configuration/scripts/tests/base_suite.ts @@ -12,6 +12,7 @@ restart gx1 40x4 droundrobin,medium restart tx1 40x4 dsectrobin,medium restart gx3 4x4 none restart gx3 4x4 iobinary +restart gx3 4x4 precision8 restart gx3 6x2 alt01 restart gx3 8x2 alt02 restart gx3 4x2 alt03 diff --git a/doc/source/cice_index.rst b/doc/source/cice_index.rst index 3f0aa482a..5111df406 100644 --- a/doc/source/cice_index.rst +++ b/doc/source/cice_index.rst @@ -274,6 +274,7 @@ either Celsius or Kelvin units). "histfreq_n", ":math:`\bullet` integer output frequency in histfreq units", "" "history_dir", ":math:`\bullet` path to history output files", "" "history_file", ":math:`\bullet` history output file prefix", "" + "history_precision", ":math:`\bullet` history output precision: 4 or 8 byte", "4" "hm", "land/boundary mask, thickness (T-cell)", "" "hmix", "ocean mixed layer depth", "20. m" "hour", "hour of the year", "" diff --git a/doc/source/user_guide/ug_case_settings.rst b/doc/source/user_guide/ug_case_settings.rst index 033d4e8c2..4e185d151 100755 --- a/doc/source/user_guide/ug_case_settings.rst +++ b/doc/source/user_guide/ug_case_settings.rst @@ -140,6 +140,7 @@ Table of namelist options "","", "false", "write snapshots of data", "" "","``history_dir``", "path/", "path to history output directory", "" "","``history_file``", "filename prefix", "output file for history", "‘iceh’" + "","``history_precision``", "integer", "history file precision: 4 or 8 byte", "4" "","``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’" diff --git a/doc/source/user_guide/ug_implementation.rst b/doc/source/user_guide/ug_implementation.rst index bba0b5f46..b144b32f2 100644 --- a/doc/source/user_guide/ug_implementation.rst +++ b/doc/source/user_guide/ug_implementation.rst @@ -807,6 +807,9 @@ Additionally, a new history output variable, ``f_CMIP``, has been added. When `` is added to the **icefields\_nml** section of **ice\_in** then all SIMIP variables will be turned on for output at the frequency specified by ``f_CMIP``. +It may also be helpful for debugging to increase the precision of the history file +output from 4 bytes to 8 bytes. This is changed through the ``history_precision`` +namelist flag. **************** Diagnostic files From 6daeab569af22071bf0431881709228ea93da3d9 Mon Sep 17 00:00:00 2001 From: Tony Craig Date: Fri, 22 May 2020 09:35:14 -0700 Subject: [PATCH 15/19] PIO standalone capability and IO testing additions (#447) * add pio standalone capability on cheyenne, add cheyenne_gnu, cheyenne_pgi, fix several bugs in history implementation, add histall setting, add io_suite * add history_format, add support for pio1.10.1 and pio2.4.2 testing on cheyenne, add support for pio netcdf and pnetcdf testing, clean up Macros files pio settings, clean up some log output * clean up restart_format * fix bug in drivers/mct/cesm1/CICE_RunMod.F90 and update documentation * rebase to current master, fix a couple of minor precision8 bugs, update test suites, update io_pio * add set_nml.cdf64 * fix error in mct/cesm1 code * fix nfsd default value and remove io_pio * update documentation and add nfsd error check --- cicecore/cicedynB/analysis/ice_history.F90 | 20 +- .../cicedynB/analysis/ice_history_fsd.F90 | 22 +- .../cicedynB/analysis/ice_history_shared.F90 | 27 +- cicecore/cicedynB/dynamics/ice_dyn_eap.F90 | 3 +- .../dynamics/ice_transport_driver.F90 | 42 +- cicecore/cicedynB/general/ice_init.F90 | 30 +- cicecore/cicedynB/infrastructure/ice_grid.F90 | 2 +- .../infrastructure/ice_restart_driver.F90 | 2 +- .../io/io_binary/ice_history_write.F90 | 13 +- .../io/io_binary/ice_restart.F90 | 2 +- .../io/io_pio/ice_history_write.F90 | 1268 ----------------- .../infrastructure/io/io_pio/ice_pio.F90 | 364 ----- .../infrastructure/io/io_pio/ice_restart.F90 | 891 ------------ .../io/io_pio2/ice_history_write.F90 | 65 +- .../infrastructure/io/io_pio2/ice_pio.F90 | 76 +- .../infrastructure/io/io_pio2/ice_restart.F90 | 46 +- cicecore/drivers/mct/cesm1/CICE_RunMod.F90 | 2 +- configuration/scripts/cice.build | 4 +- configuration/scripts/cice.settings | 2 +- configuration/scripts/ice_in | 6 +- .../scripts/machines/Macros.badger_intel | 7 - .../scripts/machines/Macros.cesium_intel | 7 - .../scripts/machines/Macros.cheyenne_gnu | 78 + .../scripts/machines/Macros.cheyenne_intel | 14 +- .../scripts/machines/Macros.cheyenne_pgi | 67 + .../scripts/machines/Macros.conrad_cray | 7 - .../scripts/machines/Macros.conrad_gnu | 7 - .../scripts/machines/Macros.conrad_intel | 7 - .../scripts/machines/Macros.conrad_pgi | 7 - .../scripts/machines/Macros.cori_intel | 7 - .../scripts/machines/Macros.fram_intel | 7 - .../scripts/machines/Macros.gaffney_gnu | 7 - .../scripts/machines/Macros.gaffney_intel | 7 - .../scripts/machines/Macros.gordon_cray | 7 - .../scripts/machines/Macros.gordon_gnu | 7 - .../scripts/machines/Macros.gordon_intel | 7 - .../scripts/machines/Macros.gordon_pgi | 7 - .../scripts/machines/Macros.hobart_intel | 7 - .../scripts/machines/Macros.hobart_nag | 6 - .../scripts/machines/Macros.izumi_gnu | 7 - .../scripts/machines/Macros.izumi_intel | 7 - .../scripts/machines/Macros.izumi_nag | 6 - .../scripts/machines/Macros.izumi_pgi | 7 - .../scripts/machines/Macros.koehr_intel | 7 - .../scripts/machines/Macros.millikan_intel | 7 - .../scripts/machines/Macros.onyx_cray | 7 - .../scripts/machines/Macros.onyx_gnu | 7 - .../scripts/machines/Macros.onyx_intel | 7 - .../scripts/machines/Macros.phase2_intel | 6 - .../scripts/machines/Macros.phase3_intel | 6 - .../scripts/machines/Macros.testmachine_intel | 7 - .../scripts/machines/Macros.thunder_intel | 7 - .../scripts/machines/env.cheyenne_gnu | 43 + .../scripts/machines/env.cheyenne_intel | 11 + .../scripts/machines/env.cheyenne_pgi | 43 + .../scripts/options/set_env.ionetcdf | 1 + configuration/scripts/options/set_env.iopio1 | 1 + configuration/scripts/options/set_env.iopio1p | 1 + configuration/scripts/options/set_env.iopio2 | 1 + configuration/scripts/options/set_env.iopio2p | 1 + configuration/scripts/options/set_nml.box2001 | 1 - configuration/scripts/options/set_nml.boxdyn | 1 - configuration/scripts/options/set_nml.cdf64 | 1 + configuration/scripts/options/set_nml.histall | 224 +++ configuration/scripts/options/set_nml.iopio1 | 2 + configuration/scripts/options/set_nml.iopio1p | 2 + configuration/scripts/options/set_nml.iopio2 | 2 + configuration/scripts/options/set_nml.iopio2p | 2 + configuration/scripts/tests/base_suite.ts | 33 +- configuration/scripts/tests/io_suite.ts | 67 + doc/source/cice_index.rst | 3 + doc/source/user_guide/ug_case_settings.rst | 8 +- doc/source/user_guide/ug_implementation.rst | 24 +- 73 files changed, 856 insertions(+), 2861 deletions(-) delete mode 100644 cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 delete mode 100644 cicecore/cicedynB/infrastructure/io/io_pio/ice_pio.F90 delete mode 100644 cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 create mode 100644 configuration/scripts/machines/Macros.cheyenne_gnu create mode 100644 configuration/scripts/machines/Macros.cheyenne_pgi create mode 100755 configuration/scripts/machines/env.cheyenne_gnu create mode 100755 configuration/scripts/machines/env.cheyenne_pgi create mode 100644 configuration/scripts/options/set_env.ionetcdf create mode 100644 configuration/scripts/options/set_env.iopio1 create mode 100644 configuration/scripts/options/set_env.iopio1p create mode 100644 configuration/scripts/options/set_env.iopio2 create mode 100644 configuration/scripts/options/set_env.iopio2p create mode 100644 configuration/scripts/options/set_nml.cdf64 create mode 100644 configuration/scripts/options/set_nml.histall create mode 100644 configuration/scripts/options/set_nml.iopio1 create mode 100644 configuration/scripts/options/set_nml.iopio1p create mode 100644 configuration/scripts/options/set_nml.iopio2 create mode 100644 configuration/scripts/options/set_nml.iopio2p create mode 100755 configuration/scripts/tests/io_suite.ts diff --git a/cicecore/cicedynB/analysis/ice_history.F90 b/cicecore/cicedynB/analysis/ice_history.F90 index 21fea93fe..660676a64 100644 --- a/cicecore/cicedynB/analysis/ice_history.F90 +++ b/cicecore/cicedynB/analysis/ice_history.F90 @@ -30,10 +30,11 @@ module ice_history use ice_kinds_mod + use ice_communicate, only: my_task, master_task use ice_constants, only: c0, c1, c2, c100, c360, c180, & p001, p25, p5, mps_to_cmpdy, kg_to_g, spval use ice_fileunits, only: nu_nml, nml_filename, nu_diag, & - get_fileunit, release_fileunit + get_fileunit, release_fileunit, flush_fileunit use ice_exit, only: abort_ice use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted use icepack_intfc, only: icepack_snow_temperature, icepack_ice_temperature @@ -62,7 +63,6 @@ subroutine init_hist (dt) use ice_blocks, only: nx_block, ny_block use ice_broadcast, only: broadcast_scalar, broadcast_array - use ice_communicate, only: my_task, master_task use ice_calendar, only: yday, days_per_year, histfreq, & histfreq_n, nstreams use ice_domain_size, only: max_blocks, max_nstrm, nilyr, nslyr, nblyr, ncat, nfsd @@ -1570,10 +1570,6 @@ subroutine init_hist (dt) if (allocated(Tsnz4d)) deallocate(Tsnz4d) allocate(Tsnz4d(nx_block,ny_block,nzslyr,ncat_hist)) endif - if (f_Sinz (1:1) /= 'x') then - if (allocated(Sinz4d)) deallocate(Sinz4d) - allocate(Sinz4d(nx_block,ny_block,nzilyr,ncat_hist)) - endif !----------------------------------------------------------------- ! 4D (floe size, thickness categories) variables looped separately @@ -1616,6 +1612,8 @@ subroutine init_hist (dt) ntmp(:) = 0 if (my_task == master_task) then write(nu_diag,*) ' ' + write(nu_diag,*) 'total number of history fields = ',num_avail_hist_fields_tot + write(nu_diag,*) 'max number of history fields = ',max_avail_hist_fields write(nu_diag,*) 'The following variables will be ', & 'written to the history tape: ' write(nu_diag,101) 'description','units','variable','frequency','x' @@ -1687,7 +1685,7 @@ subroutine init_hist (dt) if (allocated(a3Df)) a3Df(:,:,:,:,:) = c0 if (allocated(a4Di)) a4Di(:,:,:,:,:,:) = c0 if (allocated(a4Ds)) a4Ds(:,:,:,:,:,:) = c0 - if (allocated(a4Ds)) a4Df(:,:,:,:,:,:) = c0 + if (allocated(a4Df)) a4Df(:,:,:,:,:,:) = c0 avgct(:) = c0 albcnt(:,:,:,:) = c0 @@ -2970,7 +2968,7 @@ subroutine accum_hist (dt) enddo enddo enddo - call accum_hist_field(n_Tinz-n3Dacum, iblk, nzilyr, ncat_hist, & + call accum_hist_field(n_Tinz-n3Dfcum, iblk, nzilyr, ncat_hist, & Tinz4d(:,:,1:nzilyr,1:ncat_hist), a4Di) endif if (f_Sinz (1:1) /= 'x') then @@ -2984,7 +2982,7 @@ subroutine accum_hist (dt) enddo enddo enddo - call accum_hist_field(n_Sinz-n3Dacum, iblk, nzilyr, ncat_hist, & + call accum_hist_field(n_Sinz-n3Dfcum, iblk, nzilyr, ncat_hist, & Sinz4d(:,:,1:nzilyr,1:ncat_hist), a4Di) endif @@ -3796,7 +3794,7 @@ subroutine accum_hist (dt) enddo ! n do n = 1, num_avail_hist_fields_4Di - nn = n3Dacum + n + nn = n3Dfcum + n if (avail_hist_fields(nn)%vhistfreq == histfreq(ns)) then do k = 1, nzilyr do ic = 1, ncat_hist @@ -4025,7 +4023,7 @@ subroutine accum_hist (dt) if (avail_hist_fields(n)%vhistfreq == histfreq(ns)) a3Df(:,:,:,nn,:) = c0 enddo do n = n3Dfcum + 1, n4Dicum - nn = n - n3Dacum + nn = n - n3Dfcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns)) a4Di(:,:,:,:,nn,:) = c0 enddo do n = n4Dicum + 1, n4Dscum diff --git a/cicecore/cicedynB/analysis/ice_history_fsd.F90 b/cicecore/cicedynB/analysis/ice_history_fsd.F90 index 7b5a1470d..b44869445 100644 --- a/cicecore/cicedynB/analysis/ice_history_fsd.F90 +++ b/cicecore/cicedynB/analysis/ice_history_fsd.F90 @@ -428,11 +428,6 @@ subroutine accum_hist_fsd (iblk) call accum_hist_field(n_fsdperim, iblk, worka, a2D) endif - - - - - endif ! a2D allocated ! 3D category fields @@ -474,19 +469,20 @@ subroutine accum_hist_fsd (iblk) if (allocated(a4Df)) then if (f_afsdn(1:1) /= 'x') then + do n = 1, ncat_hist + do k = 1, nfsd_hist do j = 1, ny_block do i = 1, nx_block - do n = 1, ncat_hist - do k = 1, nfsd_hist - workd(i,j,k,n) = trcrn(i,j,nt_fsd+k-1,n,iblk) & - * aicen_init(i,j,n,iblk)/floe_binwidth(k) - end do - end do + workd(i,j,k,n) = trcrn(i,j,nt_fsd+k-1,n,iblk) & + * aicen_init(i,j,n,iblk)/floe_binwidth(k) + end do end do end do - call accum_hist_field(n_afsdn-n4Dscum, iblk, & - nfsd_hist, ncat_hist, workd, a4Df) + end do + call accum_hist_field(n_afsdn-n4Dscum, iblk, nfsd_hist, ncat_hist, & + workd(:,:,1:nfsd_hist,1:ncat_hist), a4Df) endif + endif ! a4Df allocated endif ! tr_fsd diff --git a/cicecore/cicedynB/analysis/ice_history_shared.F90 b/cicecore/cicedynB/analysis/ice_history_shared.F90 index 6c4d3acf3..b5f2226fa 100644 --- a/cicecore/cicedynB/analysis/ice_history_shared.F90 +++ b/cicecore/cicedynB/analysis/ice_history_shared.F90 @@ -24,8 +24,10 @@ module ice_history_shared use ice_kinds_mod + use ice_communicate, only: my_task, master_task use ice_domain_size, only: max_nstrm use ice_exit, only: abort_ice + use ice_fileunits, only: nu_diag use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted implicit none @@ -52,6 +54,9 @@ module ice_history_shared character (len=char_len), public :: & version_name + character (len=char_len), public :: & + history_format + !--------------------------------------------------------------- ! Instructions for adding a field: (search for 'example') ! Here: @@ -79,7 +84,7 @@ module ice_history_shared end type integer (kind=int_kind), parameter, public :: & - max_avail_hist_fields = 600 ! Max number of history fields + max_avail_hist_fields = 800 ! Max number of history fields integer (kind=int_kind), public :: & num_avail_hist_fields_tot = 0, & ! Current, total number of defined fields @@ -111,8 +116,8 @@ module ice_history_shared nzblyr , & ! bio grid nzalyr ! aerosols (2 snow & nblyr+2 bio) - type (ice_hist_field), dimension(max_avail_hist_fields), public :: & - avail_hist_fields + type (ice_hist_field), public :: & + avail_hist_fields(max_avail_hist_fields) integer (kind=int_kind), parameter, public :: & nvar = 12 , & ! number of grid fields that can be written @@ -806,8 +811,13 @@ subroutine define_hist_field(id, vname, vunit, vcoord, vcellmeas, & num_avail_hist_fields_4Df = num_avail_hist_fields_4Df + 1 endif - if (num_avail_hist_fields_tot > max_avail_hist_fields) & - call abort_ice(subname//'ERROR: Need to increase max_avail_hist_fields') + if (num_avail_hist_fields_tot > max_avail_hist_fields) then + if (my_task == master_task) then + write(nu_diag,*) subname,' num_avail_hist_fields_tot = ',num_avail_hist_fields_tot + write(nu_diag,*) subname,' max_avail_hist_fields = ',max_avail_hist_fields + endif + call abort_ice(subname//'ERROR: Need in computation of max_avail_hist_fields') + endif if (num_avail_hist_fields_tot /= & num_avail_hist_fields_2D + & @@ -819,8 +829,11 @@ subroutine define_hist_field(id, vname, vunit, vcoord, vcellmeas, & num_avail_hist_fields_4Di + & num_avail_hist_fields_4Ds + & num_avail_hist_fields_4Df) then - call abort_ice(subname//'ERROR: num_avail_hist_fields error') - endif + if (my_task == master_task) then + write(nu_diag,*) subname,' num_avail_hist_fields_tot = ',num_avail_hist_fields_tot + endif + call abort_ice(subname//'ERROR: in num_avail_hist_fields') + endif id(ns) = num_avail_hist_fields_tot diff --git a/cicecore/cicedynB/dynamics/ice_dyn_eap.F90 b/cicecore/cicedynB/dynamics/ice_dyn_eap.F90 index 8239d00d5..360e72a9c 100644 --- a/cicecore/cicedynB/dynamics/ice_dyn_eap.F90 +++ b/cicecore/cicedynB/dynamics/ice_dyn_eap.F90 @@ -2144,7 +2144,6 @@ subroutine read_restart_eap() use ice_domain, only: nblocks, halo_info use ice_grid, only: grid_type use ice_restart, only: read_restart_field - use ice_restart_shared, only: restart_format ! local variables @@ -2183,7 +2182,7 @@ subroutine read_restart_eap() call read_restart_field(nu_restart_eap,0,a12_4,'ruf8', & 'a12_4',1,diag,field_loc_center,field_type_scalar) ! a12_4 - if (trim(grid_type) == 'tripole' .and. trim(restart_format) == 'pio') then + if (trim(grid_type) == 'tripole') then call ice_HaloUpdate_stress(a11_1, a11_3, halo_info, & field_loc_center, field_type_scalar) diff --git a/cicecore/cicedynB/dynamics/ice_transport_driver.F90 b/cicecore/cicedynB/dynamics/ice_transport_driver.F90 index 7eaba64cf..988640332 100644 --- a/cicecore/cicedynB/dynamics/ice_transport_driver.F90 +++ b/cicecore/cicedynB/dynamics/ice_transport_driver.F90 @@ -147,68 +147,70 @@ subroutine init_transport ! diagnostic output if (my_task == master_task) then - write (nu_diag, *) 'tracer index depend type has_dependents' + write (nu_diag, *) 'tracer index depend type has_dependents' nt = 1 - write(nu_diag,*) ' hi ',nt,depend(nt),tracer_type(nt),& + write(nu_diag,1000) 'hi ',nt,depend(nt),tracer_type(nt),& has_dependents(nt) nt = 2 - write(nu_diag,*) ' hs ',nt,depend(nt),tracer_type(nt),& + 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,*) 'nt_Tsfc',nt,depend(nt),tracer_type(nt),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) '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),& + write(nu_diag,1000) 'nt_bgc_S ',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 diff --git a/cicecore/cicedynB/general/ice_init.F90 b/cicecore/cicedynB/general/ice_init.F90 index e96fc99d2..3cd7e4746 100644 --- a/cicecore/cicedynB/general/ice_init.F90 +++ b/cicecore/cicedynB/general/ice_init.F90 @@ -77,7 +77,7 @@ subroutine input_data runid, runtype, use_restart_time, restart_format, lcdf64 use ice_history_shared, only: hist_avg, history_dir, history_file, & incond_dir, incond_file, version_name, & - history_precision + history_precision, history_format use ice_flux, only: update_ocn_f, l_mpond_fresh use ice_flux, only: default_season use ice_flux_bgc, only: cpl_bgc @@ -150,7 +150,7 @@ subroutine input_data ice_ic, restart, restart_dir, restart_file, & restart_ext, use_restart_time, restart_format, lcdf64, & pointer_file, dumpfreq, dumpfreq_n, dump_last, & - diagfreq, diag_type, diag_file, & + diagfreq, diag_type, diag_file, history_format,& print_global, print_points, latpnt, lonpnt, & dbug, histfreq, histfreq_n, hist_avg, & history_dir, history_file, history_precision, cpl_bgc, & @@ -250,6 +250,7 @@ subroutine input_data histfreq(5) = 'y' ! output frequency option for different streams histfreq_n(:) = 1 ! output frequency hist_avg = .true. ! if true, write time-averages (not snapshots) + history_format = 'default' ! history file format history_dir = './' ! write to executable dir for default history_file = 'iceh' ! history file name prefix history_precision = 4 ! precision of history files @@ -264,9 +265,9 @@ subroutine input_data restart_dir = './' ! write to executable dir for default restart_file = 'iced' ! restart file name prefix restart_ext = .false. ! if true, read/write ghost cells - use_restart_time = .true. ! if true, use time info written in file + use_restart_time = .true. ! if true, use time info written in file pointer_file = 'ice.restart_file' - restart_format = 'nc' ! file format ('bin'=binary or 'nc'=netcdf or 'pio') + restart_format = 'default' ! restart file format lcdf64 = .false. ! 64 bit offset for netCDF ice_ic = 'default' ! latitude and sst-dependent grid_format = 'bin' ! file format ('bin'=binary or 'nc'=netcdf) @@ -278,7 +279,7 @@ subroutine input_data kmt_file = 'unknown_kmt_file' version_name = 'unknown_version_name' ncat = 0 ! number of ice thickness categories - nfsd = 0 ! number of floe size categories (1 = default) + nfsd = 1 ! number of floe size categories (1 = default) nilyr = 0 ! number of vertical ice layers nslyr = 0 ! number of vertical snow layers nblyr = 0 ! number of bio layers @@ -539,6 +540,7 @@ subroutine input_data call broadcast_scalar(history_dir, master_task) call broadcast_scalar(history_file, master_task) call broadcast_scalar(history_precision, master_task) + call broadcast_scalar(history_format, master_task) call broadcast_scalar(write_ic, master_task) call broadcast_scalar(cpl_bgc, master_task) call broadcast_scalar(incond_dir, master_task) @@ -846,7 +848,7 @@ subroutine input_data if (my_task == master_task) then write(nu_diag,*) subname//' ERROR: isotopes activated but' write(nu_diag,*) subname//' ERROR: not allocated in tracer array.' - write(nu_diag,*) subname//' ERROR: Activate in compilation script.' + write(nu_diag,*) subname//' ERROR: if tr_iso, n_iso must be > 0.' endif abort_flag = 31 endif @@ -855,11 +857,19 @@ subroutine input_data if (my_task == master_task) then write(nu_diag,*) subname//' ERROR: aerosols activated but' write(nu_diag,*) subname//' ERROR: not allocated in tracer array.' - write(nu_diag,*) subname//' ERROR: Activate in compilation script.' + write(nu_diag,*) subname//' ERROR: if tr_aero, n_aero must be > 0.' endif abort_flag = 9 endif + if (nfsd < 1) then + if (my_task == master_task) then + write(nu_diag,*) subname//' ERROR: nfsd < 1' + write(nu_diag,*) subname//' ERROR: not allowed due to history implementation.' + endif + abort_flag = 32 + endif + if (trim(shortwave) /= 'dEdd' .and. tr_aero) then if (my_task == master_task) then write(nu_diag,*) subname//' ERROR: tr_aero=T, invalid shortwave' @@ -1002,6 +1012,8 @@ subroutine input_data write(nu_diag,*) ' history_file = ', & trim(history_file) write(nu_diag,1020) ' history_precision = ', history_precision + write(nu_diag,*) ' history_format = ', & + trim(history_format) if (write_ic) then write(nu_diag,*) 'Initial condition will be written in ', & trim(incond_dir) @@ -1165,8 +1177,8 @@ subroutine input_data oceanmixed_ice write(nu_diag,1010) ' wave_spec = ', wave_spec if (wave_spec) then - write(nu_diag,*) ' wave_spec_type = ', wave_spec_type - write(nu_diag,*) ' wave_spec_file = ', wave_spec_file + write(nu_diag,*) ' wave_spec_type = ', trim(wave_spec_type) + write(nu_diag,*) ' wave_spec_file = ', trim(wave_spec_file) endif write(nu_diag,1020) ' nfreq = ', nfreq write(nu_diag,*) ' tfrz_option = ', & diff --git a/cicecore/cicedynB/infrastructure/ice_grid.F90 b/cicecore/cicedynB/infrastructure/ice_grid.F90 index 20df6b236..8df66042b 100644 --- a/cicecore/cicedynB/infrastructure/ice_grid.F90 +++ b/cicecore/cicedynB/infrastructure/ice_grid.F90 @@ -2411,7 +2411,7 @@ subroutine get_bathymetry_popfile ! create thickness profile k1 = min(5,nlevel) do k = 1,k1 - thick(k) = max(10000._dbl_kind/float(nlevel),500.) + thick(k) = max(10000._dbl_kind/float(nlevel),500._dbl_kind) enddo do k = k1+1,nlevel thick(k) = min(thick(k-1)*1.2_dbl_kind,20000._dbl_kind) diff --git a/cicecore/cicedynB/infrastructure/ice_restart_driver.F90 b/cicecore/cicedynB/infrastructure/ice_restart_driver.F90 index 5bc945fa2..d3829b9c4 100644 --- a/cicecore/cicedynB/infrastructure/ice_restart_driver.F90 +++ b/cicecore/cicedynB/infrastructure/ice_restart_driver.F90 @@ -883,7 +883,7 @@ subroutine restartfile_v4 (ice_ic) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - ! creates netcdf if restart_format = 'nc' + ! creates new file filename = trim(restart_dir) // '/iced.converted' call dumpfile(filename) call final_restart diff --git a/cicecore/cicedynB/infrastructure/io/io_binary/ice_history_write.F90 b/cicecore/cicedynB/infrastructure/io/io_binary/ice_history_write.F90 index 4154c59c1..b98e09814 100644 --- a/cicecore/cicedynB/infrastructure/io/io_binary/ice_history_write.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_binary/ice_history_write.F90 @@ -74,8 +74,14 @@ subroutine ice_write_hist(ns) diag = .false. + ! single precision atype = 'rda4' - if (history_precision == 8) atype = 'rda8' + nbits = 32 + if (history_precision == 8) then + ! double precision + atype = 'rda8' + nbits = 64 + endif if (my_task == master_task) then @@ -92,7 +98,6 @@ subroutine ice_write_hist(ns) !----------------------------------------------------------------- ! create history files !----------------------------------------------------------------- - nbits = 32 ! single precision call ice_open(nu_history, ncfile(ns), nbits) ! direct access open(nu_hdr,file=hdrfile,form='formatted',status='unknown') ! ascii @@ -322,7 +327,7 @@ subroutine ice_write_hist(ns) if (avail_hist_fields(n)%vhistfreq == histfreq(ns)) then do nn = 1, ncat_hist - do k = 1, nzilyr + do k = 1, nzslyr nrec = nrec + 1 if (my_task == master_task) then write (nu_hdr, 993) nrec,trim(avail_hist_fields(n)%vname), & @@ -338,7 +343,7 @@ subroutine ice_write_hist(ns) endif call ice_write(nu_history, nrec, a4Ds(:,:,k,nn,n-n4Dicum,:), atype, diag) - enddo ! nzilyr + enddo ! nzslyr enddo ! ncat_hist endif diff --git a/cicecore/cicedynB/infrastructure/io/io_binary/ice_restart.F90 b/cicecore/cicedynB/infrastructure/io/io_binary/ice_restart.F90 index 8ecfeb6f1..b1a2d026b 100644 --- a/cicecore/cicedynB/infrastructure/io/io_binary/ice_restart.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_binary/ice_restart.F90 @@ -11,7 +11,7 @@ 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, restart_format, lenstr + runid, runtype, use_restart_time, 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 diff --git a/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 b/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 deleted file mode 100644 index 9c20daf20..000000000 --- a/cicecore/cicedynB/infrastructure/io/io_pio/ice_history_write.F90 +++ /dev/null @@ -1,1268 +0,0 @@ -!======================================================================= -! -! Writes history in netCDF format -! -! authors Tony Craig and Bruce Briegleb, NCAR -! Elizabeth C. Hunke and William H. Lipscomb, LANL -! C. M. Bitz, UW -! -! 2004 WHL: Block structure added -! 2006 ECH: Accepted some CESM code into mainstream CICE -! Added ice_present, aicen, vicen; removed aice1...10, vice1...1. -! Added histfreq_n and histfreq='h' options, removed histfreq='w' -! Converted to free source form (F90) -! Added option for binary output instead of netCDF -! 2009 D Bailey and ECH: Generalized for multiple frequency output -! 2010 Alison McLaren and ECH: Added 3D capability -! - module ice_history_write - - use ice_kinds_mod - use ice_fileunits, only: nu_diag - use ice_exit, only: abort_ice - use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted - use icepack_intfc, only: icepack_query_parameters - - implicit none - private - public :: ice_write_hist - -!======================================================================= - - contains - -!======================================================================= -! -! write average ice quantities or snapshots -! -! author: Elizabeth C. Hunke, LANL - - subroutine ice_write_hist (ns) - -#ifdef ncdf - use ice_blocks, only: nx_block, ny_block - use ice_broadcast, only: broadcast_scalar - use ice_calendar, only: time, sec, idate, idate0, write_ic, & - histfreq, dayyr, days_per_year, use_leap_years - use ice_communicate, only: my_task, master_task - use ice_constants, only: c0, c360, spval, spval_dbl - use ice_domain, only: distrb_info, nblocks - use ice_domain_size, only: nx_global, ny_global, max_blocks, max_nstrm - use ice_gather_scatter, only: gather_global - use ice_grid, only: TLON, TLAT, ULON, ULAT, hm, bm, tarea, uarea, & - dxu, dxt, dyu, dyt, HTN, HTE, ANGLE, ANGLET, tmask, & - lont_bounds, latt_bounds, lonu_bounds, latu_bounds - use ice_history_shared - use ice_arrays_column, only: hin_max, floe_rad_c - use ice_restart_shared, only: runid, lcdf64 - use netcdf -#endif - use ice_pio - use pio - - integer (kind=int_kind), intent(in) :: ns - - ! local variables - -#ifdef ncdf - integer (kind=int_kind) :: i,j,k,ic,n,nn, & - ncid,status,imtid,jmtid,kmtidi,kmtids,kmtidb, cmtid,timid, & - length,nvertexid,ivertex,kmtida,fmtid - integer (kind=int_kind), dimension(2) :: dimid2 - integer (kind=int_kind), dimension(3) :: dimid3 - integer (kind=int_kind), dimension(4) :: dimidz - integer (kind=int_kind), dimension(5) :: dimidcz - integer (kind=int_kind), dimension(3) :: dimid_nverts - integer (kind=int_kind), dimension(6) :: dimidex - real (kind=real_kind) :: ltime - real (kind= dbl_kind) :: ltime2 - character (char_len) :: title - character (char_len_long) :: ncfile(max_nstrm) - - integer (kind=int_kind) :: iyear, imonth, iday - integer (kind=int_kind) :: icategory,ind,i_aice,boundid - - character (char_len) :: start_time,current_date,current_time - character (len=16) :: c_aice - character (len=8) :: cdate - - type(file_desc_t) :: File - type(io_desc_t) :: iodesc2d, & - iodesc3dc, iodesc3dv, iodesc3di, iodesc3db, iodesc3da, & - iodesc3df, & - iodesc4di, iodesc4ds, iodesc4df - type(var_desc_t) :: varid - - ! 4 coordinate variables: TLON, TLAT, ULON, ULAT - INTEGER (kind=int_kind), PARAMETER :: ncoord = 4 - - ! 4 vertices in each grid cell - INTEGER (kind=int_kind), PARAMETER :: nverts = 4 - - ! 4 variables describe T, U grid boundaries: - ! lont_bounds, latt_bounds, lonu_bounds, latu_bounds - INTEGER (kind=int_kind), PARAMETER :: nvar_verts = 4 - - TYPE coord_attributes ! netcdf coordinate attributes - character (len=11) :: short_name - character (len=45) :: long_name - character (len=20) :: units - END TYPE coord_attributes - - TYPE req_attributes ! req'd netcdf attributes - type (coord_attributes) :: req - character (len=20) :: coordinates - END TYPE req_attributes - - TYPE(req_attributes), dimension(nvar) :: var - TYPE(coord_attributes), dimension(ncoord) :: coord_var - TYPE(coord_attributes), dimension(nvar_verts) :: var_nverts - TYPE(coord_attributes), dimension(nvarz) :: var_nz - CHARACTER (char_len), dimension(ncoord) :: coord_bounds - - real (kind=dbl_kind), allocatable :: workr2(:,:,:) - real (kind=dbl_kind), allocatable :: workr3(:,:,:,:) - real (kind=dbl_kind), allocatable :: workr4(:,:,:,:,:) - real (kind=dbl_kind), allocatable :: workr3v(:,:,:,:) - - character(len=char_len_long) :: & - filename - - integer (kind=int_kind), dimension(1) :: & - tim_start,tim_length ! dimension quantities for netCDF - - integer (kind=int_kind), dimension(2) :: & - bnd_start,bnd_length ! dimension quantities for netCDF - - real (kind=dbl_kind) :: secday - real (kind=dbl_kind) :: rad_to_deg - - integer (kind=int_kind) :: lprecision - - character(len=*), parameter :: subname = '(ice_write_hist)' - - call icepack_query_parameters(secday_out=secday) - call icepack_query_parameters(rad_to_deg_out=rad_to_deg) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) - - if (my_task == master_task) then - call construct_filename(ncfile(ns),'nc',ns) - - ! add local directory path name to ncfile - if (write_ic) then - ncfile(ns) = trim(incond_dir)//ncfile(ns) - else - ncfile(ns) = trim(history_dir)//ncfile(ns) - endif - filename = ncfile(ns) - end if - call broadcast_scalar(filename, master_task) - - ! create file - - File%fh=-1 - call ice_pio_init(mode='write', filename=trim(filename), File=File, & - clobber=.true., cdf64=lcdf64) - - call ice_pio_initdecomp(iodesc=iodesc2d) - call ice_pio_initdecomp(ndim3=ncat_hist, iodesc=iodesc3dc) - call ice_pio_initdecomp(ndim3=nzilyr, iodesc=iodesc3di) - call ice_pio_initdecomp(ndim3=nzblyr, iodesc=iodesc3db) - call ice_pio_initdecomp(ndim3=nzalyr, iodesc=iodesc3da) - call ice_pio_initdecomp(ndim3=nfsd_hist, iodesc=iodesc3df) - call ice_pio_initdecomp(ndim3=nverts, inner_dim=.true., iodesc=iodesc3dv) - call ice_pio_initdecomp(ndim3=nzilyr, ndim4=ncat_hist, iodesc=iodesc4di) - call ice_pio_initdecomp(ndim3=nzslyr, ndim4=ncat_hist, iodesc=iodesc4ds) - call ice_pio_initdecomp(ndim3=nzslyr, ndim4=nfsd_hist, iodesc=iodesc4df) - - ltime2 = time/int(secday) - ltime = real(time/int(secday),kind=real_kind) - - ! option of turning on double precision history files - lprecision = pio_real - if (history_precision == 8) lprecision = pio_double - - !----------------------------------------------------------------- - ! define dimensions - !----------------------------------------------------------------- - - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_def_dim(File,'d2',2,boundid) - endif - - status = pio_def_dim(File,'ni',nx_global,imtid) - status = pio_def_dim(File,'nj',ny_global,jmtid) - status = pio_def_dim(File,'nc',ncat_hist,cmtid) - status = pio_def_dim(File,'nkice',nzilyr,kmtidi) - status = pio_def_dim(File,'nksnow',nzslyr,kmtids) - status = pio_def_dim(File,'nkbio',nzblyr,kmtidb) - status = pio_def_dim(File,'nkaer',nzalyr,kmtida) - status = pio_def_dim(File,'time',PIO_UNLIMITED,timid) - status = pio_def_dim(File,'nvertices',nverts,nvertexid) - status = pio_def_dim(File,'nf',nfsd_hist,fmtid) - - !----------------------------------------------------------------- - ! define coordinate variables: time, time_bounds - !----------------------------------------------------------------- - -!sgl status = pio_def_var(File,'time',pio_real,(/timid/),varid) - status = pio_def_var(File,'time',pio_double,(/timid/),varid) - status = pio_put_att(File,varid,'long_name','model time') - - write(cdate,'(i8.8)') idate0 - write(title,'(a,a,a,a,a,a,a)') 'days since ', & - cdate(1:4),'-',cdate(5:6),'-',cdate(7:8),' 00:00:00' - status = pio_put_att(File,varid,'units',trim(title)) - - if (days_per_year == 360) then - status = pio_put_att(File,varid,'calendar','360_day') - elseif (days_per_year == 365 .and. .not.use_leap_years ) then - status = pio_put_att(File,varid,'calendar','NoLeap') - elseif (use_leap_years) then - status = pio_put_att(File,varid,'calendar','Gregorian') - else - call abort_ice(subname//'ERROR: invalid calendar settings') - endif - - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_put_att(File,varid,'bounds','time_bounds') - endif - - ! Define attributes for time_bounds if hist_avg is true - if (hist_avg .and. histfreq(ns) /= '1') then - dimid2(1) = boundid - dimid2(2) = timid -!sgl status = pio_def_var(File,'time_bounds',pio_real,dimid2,varid) - status = pio_def_var(File,'time_bounds',pio_double,dimid2,varid) - status = pio_put_att(File,varid,'long_name', & - 'boundaries for time-averaging interval') - write(cdate,'(i8.8)') idate0 - write(title,'(a,a,a,a,a,a,a,a)') 'days since ', & - cdate(1:4),'-',cdate(5:6),'-',cdate(7:8),' 00:00:00' - status = pio_put_att(File,varid,'units',trim(title)) - endif - - !----------------------------------------------------------------- - ! define information for required time-invariant variables - !----------------------------------------------------------------- - - ind = 0 - ind = ind + 1 - coord_var(ind) = coord_attributes('TLON', & - 'T grid center longitude', 'degrees_east') - coord_bounds(ind) = 'lont_bounds' - ind = ind + 1 - coord_var(ind) = coord_attributes('TLAT', & - 'T grid center latitude', 'degrees_north') - coord_bounds(ind) = 'latt_bounds' - ind = ind + 1 - coord_var(ind) = coord_attributes('ULON', & - 'U grid center longitude', 'degrees_east') - coord_bounds(ind) = 'lonu_bounds' - ind = ind + 1 - coord_var(ind) = coord_attributes('ULAT', & - 'U grid center latitude', 'degrees_north') - coord_bounds(ind) = 'latu_bounds' - - var_nz(1) = coord_attributes('NCAT', 'category maximum thickness', 'm') - var_nz(2) = coord_attributes('VGRDi', 'vertical ice levels', '1') - var_nz(3) = coord_attributes('VGRDs', 'vertical snow levels', '1') - var_nz(4) = coord_attributes('VGRDb', 'vertical ice-bio levels', '1') - var_nz(5) = coord_attributes('VGRDa', 'vertical snow-ice-bio levels', '1') - var_nz(6) = coord_attributes('NFSD', 'category floe size (center)', 'm') - - !----------------------------------------------------------------- - ! define information for optional time-invariant variables - !----------------------------------------------------------------- - - var(n_tmask)%req = coord_attributes('tmask', & - 'ocean grid mask', ' ') - var(n_tmask)%coordinates = 'TLON TLAT' - - var(n_blkmask)%req = coord_attributes('blkmask', & - 'ice grid block mask', ' ') - var(n_blkmask)%coordinates = 'TLON TLAT' - - var(n_tarea)%req = coord_attributes('tarea', & - 'area of T grid cells', 'm^2') - var(n_tarea)%coordinates = 'TLON TLAT' - - var(n_uarea)%req = coord_attributes('uarea', & - 'area of U grid cells', 'm^2') - var(n_uarea)%coordinates = 'ULON ULAT' - var(n_dxt)%req = coord_attributes('dxt', & - 'T cell width through middle', 'm') - var(n_dxt)%coordinates = 'TLON TLAT' - var(n_dyt)%req = coord_attributes('dyt', & - 'T cell height through middle', 'm') - var(n_dyt)%coordinates = 'TLON TLAT' - var(n_dxu)%req = coord_attributes('dxu', & - 'U cell width through middle', 'm') - var(n_dxu)%coordinates = 'ULON ULAT' - var(n_dyu)%req = coord_attributes('dyu', & - 'U cell height through middle', 'm') - var(n_dyu)%coordinates = 'ULON ULAT' - var(n_HTN)%req = coord_attributes('HTN', & - 'T cell width on North side','m') - var(n_HTN)%coordinates = 'TLON TLAT' - var(n_HTE)%req = coord_attributes('HTE', & - 'T cell width on East side', 'm') - var(n_HTE)%coordinates = 'TLON TLAT' - var(n_ANGLE)%req = coord_attributes('ANGLE', & - 'angle grid makes with latitude line on U grid', & - 'radians') - var(n_ANGLE)%coordinates = 'ULON ULAT' - var(n_ANGLET)%req = coord_attributes('ANGLET', & - 'angle grid makes with latitude line on T grid', & - 'radians') - var(n_ANGLET)%coordinates = 'TLON TLAT' - - ! These fields are required for CF compliance - ! dimensions (nx,ny,nverts) - var_nverts(n_lont_bnds) = coord_attributes('lont_bounds', & - 'longitude boundaries of T cells', 'degrees_east') - var_nverts(n_latt_bnds) = coord_attributes('latt_bounds', & - 'latitude boundaries of T cells', 'degrees_north') - var_nverts(n_lonu_bnds) = coord_attributes('lonu_bounds', & - 'longitude boundaries of U cells', 'degrees_east') - var_nverts(n_latu_bnds) = coord_attributes('latu_bounds', & - 'latitude boundaries of U cells', 'degrees_north') - - !----------------------------------------------------------------- - ! define attributes for time-invariant variables - !----------------------------------------------------------------- - - dimid2(1) = imtid - dimid2(2) = jmtid - - do i = 1, ncoord - status = pio_def_var(File, trim(coord_var(i)%short_name), lprecision, & - dimid2, varid) - status = pio_put_att(File,varid,'long_name',trim(coord_var(i)%long_name)) - status = pio_put_att(File, varid, 'units', trim(coord_var(i)%units)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - if (coord_var(i)%short_name == 'ULAT') then - status = pio_put_att(File,varid,'comment', & - trim('Latitude of NE corner of T grid cell')) - endif - if (f_bounds) then - status = pio_put_att(File, varid, 'bounds', trim(coord_bounds(i))) - endif - enddo - - ! Extra dimensions (NCAT, NZILYR, NZSLYR, NZBLYR, NZALYR, NFSD) - dimidex(1)=cmtid - dimidex(2)=kmtidi - dimidex(3)=kmtids - dimidex(4)=kmtidb - dimidex(5)=kmtida - dimidex(6)=fmtid - - do i = 1, nvarz - if (igrdz(i)) then - status = pio_def_var(File, trim(var_nz(i)%short_name), lprecision, & - (/dimidex(i)/), varid) - status = pio_put_att(File, varid, 'long_name', var_nz(i)%long_name) - status = pio_put_att(File, varid, 'units' , var_nz(i)%units) - endif - enddo - - ! Attributes for tmask defined separately, since it has no units - if (igrd(n_tmask)) then - status = pio_def_var(File, 'tmask', lprecision, dimid2, varid) - status = pio_put_att(File,varid, 'long_name', 'ocean grid mask') - status = pio_put_att(File, varid, 'coordinates', 'TLON TLAT') - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - status = pio_put_att(File,varid,'comment', '0 = land, 1 = ocean') - endif - if (igrd(n_blkmask)) then - status = pio_def_var(File, 'blkmask', lprecision, dimid2, varid) - status = pio_put_att(File,varid, 'long_name', 'ice grid block mask') - status = pio_put_att(File, varid, 'coordinates', 'TLON TLAT') - status = pio_put_att(File,varid,'comment', 'mytask + iblk/100') - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - endif - - do i = 3, nvar ! note: n_tmask=1, n_blkmask=2 - if (igrd(i)) then - status = pio_def_var(File, trim(var(i)%req%short_name), & - lprecision, dimid2, varid) - status = pio_put_att(File,varid, 'long_name', trim(var(i)%req%long_name)) - status = pio_put_att(File, varid, 'units', trim(var(i)%req%units)) - status = pio_put_att(File, varid, 'coordinates', trim(var(i)%coordinates)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - endif - enddo - - ! Fields with dimensions (nverts,nx,ny) - dimid_nverts(1) = nvertexid - dimid_nverts(2) = imtid - dimid_nverts(3) = jmtid - do i = 1, nvar_verts - if (f_bounds) then - status = pio_def_var(File, trim(var_nverts(i)%short_name), & - lprecision,dimid_nverts, varid) - status = & - pio_put_att(File,varid, 'long_name', trim(var_nverts(i)%long_name)) - status = & - pio_put_att(File, varid, 'units', trim(var_nverts(i)%units)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - endif - enddo - - !----------------------------------------------------------------- - ! define attributes for time-variant variables - !----------------------------------------------------------------- - - !----------------------------------------------------------------- - ! 2D - !----------------------------------------------------------------- - - dimid3(1) = imtid - dimid3(2) = jmtid - dimid3(3) = timid - - do n=1,num_avail_hist_fields_2D - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - lprecision, dimid3, varid) - status = pio_put_att(File,varid,'units', & - trim(avail_hist_fields(n)%vunit)) - status = pio_put_att(File,varid, 'long_name', & - trim(avail_hist_fields(n)%vdesc)) - status = pio_put_att(File,varid,'coordinates', & - trim(avail_hist_fields(n)%vcoord)) - status = pio_put_att(File,varid,'cell_measures', & - trim(avail_hist_fields(n)%vcellmeas)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - - ! Add cell_methods attribute to variables if averaged - if (hist_avg .and. histfreq(ns) /= '1') then - if (TRIM(avail_hist_fields(n)%vname)/='sig1' & - .or.TRIM(avail_hist_fields(n)%vname)/='sig2' & - .or.TRIM(avail_hist_fields(n)%vname)/='sistreave' & - .or.TRIM(avail_hist_fields(n)%vname)/='sistremax' & - .or.TRIM(avail_hist_fields(n)%vname)/='sigP') then - status = pio_put_att(File,varid,'cell_methods','time: mean') - endif - endif - - if (histfreq(ns) == '1' .or. .not. hist_avg & - .or. n==n_divu(ns) .or. n==n_shear(ns) & ! snapshots - .or. n==n_sig1(ns) .or. n==n_sig2(ns) & - .or. n==n_sigP(ns) .or. n==n_trsig(ns) & - .or. n==n_sistreave(ns) .or. n==n_sistremax(ns) & - .or. n==n_mlt_onset(ns) .or. n==n_frz_onset(ns) & - .or. n==n_hisnap(ns) .or. n==n_aisnap(ns)) then - status = pio_put_att(File,varid,'time_rep','instantaneous') - else - status = pio_put_att(File,varid,'time_rep','averaged') - endif - endif - enddo ! num_avail_hist_fields_2D - - !----------------------------------------------------------------- - ! 3D (category) - !----------------------------------------------------------------- - - dimidz(1) = imtid - dimidz(2) = jmtid - dimidz(3) = cmtid - dimidz(4) = timid - - do n = n2D + 1, n3Dccum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - lprecision, dimidz, varid) - status = pio_put_att(File,varid,'units', & - trim(avail_hist_fields(n)%vunit)) - status = pio_put_att(File,varid, 'long_name', & - trim(avail_hist_fields(n)%vdesc)) - status = pio_put_att(File,varid,'coordinates', & - trim(avail_hist_fields(n)%vcoord)) - status = pio_put_att(File,varid,'cell_measures', & - trim(avail_hist_fields(n)%vcellmeas)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - - ! Add cell_methods attribute to variables if averaged - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_put_att(File,varid,'cell_methods','time: mean') - endif - - if (histfreq(ns) == '1' .or. .not. hist_avg) then - status = pio_put_att(File,varid,'time_rep','instantaneous') - else - status = pio_put_att(File,varid,'time_rep','averaged') - endif - endif - enddo ! num_avail_hist_fields_3Dc - - !----------------------------------------------------------------- - ! 3D (ice layers) - !----------------------------------------------------------------- - - dimidz(1) = imtid - dimidz(2) = jmtid - dimidz(3) = kmtidi - dimidz(4) = timid - - do n = n3Dccum + 1, n3Dzcum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - lprecision, dimidz, varid) - status = pio_put_att(File,varid,'units', & - trim(avail_hist_fields(n)%vunit)) - status = pio_put_att(File,varid, 'long_name', & - trim(avail_hist_fields(n)%vdesc)) - status = pio_put_att(File,varid,'coordinates', & - trim(avail_hist_fields(n)%vcoord)) - status = pio_put_att(File,varid,'cell_measures', & - trim(avail_hist_fields(n)%vcellmeas)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - - ! Add cell_methods attribute to variables if averaged - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_put_att(File,varid,'cell_methods','time: mean') - endif - - if (histfreq(ns) == '1' .or. .not. hist_avg) then - status = pio_put_att(File,varid,'time_rep','instantaneous') - else - status = pio_put_att(File,varid,'time_rep','averaged') - endif - endif - enddo ! num_avail_hist_fields_3Dz - - !----------------------------------------------------------------- - ! 3D (biology ice layers) - !----------------------------------------------------------------- - - dimidz(1) = imtid - dimidz(2) = jmtid - dimidz(3) = kmtidb - dimidz(4) = timid - - do n = n3Dzcum + 1, n3Dbcum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - lprecision, dimidz, varid) - status = pio_put_att(File,varid,'units', & - trim(avail_hist_fields(n)%vunit)) - status = pio_put_att(File,varid, 'long_name', & - trim(avail_hist_fields(n)%vdesc)) - status = pio_put_att(File,varid,'coordinates', & - trim(avail_hist_fields(n)%vcoord)) - status = pio_put_att(File,varid,'cell_measures', & - trim(avail_hist_fields(n)%vcellmeas)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - - ! Add cell_methods attribute to variables if averaged - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_put_att(File,varid,'cell_methods','time: mean') - endif - - if (histfreq(ns) == '1' .or. .not. hist_avg) then - status = pio_put_att(File,varid,'time_rep','instantaneous') - else - status = pio_put_att(File,varid,'time_rep','averaged') - endif - endif - enddo ! num_avail_hist_fields_3Db - - !----------------------------------------------------------------- - ! 3D (biology snow layers) - !----------------------------------------------------------------- - - dimidz(1) = imtid - dimidz(2) = jmtid - dimidz(3) = kmtida - dimidz(4) = timid - - do n = n3Dbcum + 1, n3Dacum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - lprecision, dimidz, varid) - status = pio_put_att(File,varid,'units', & - trim(avail_hist_fields(n)%vunit)) - status = pio_put_att(File,varid, 'long_name', & - trim(avail_hist_fields(n)%vdesc)) - status = pio_put_att(File,varid,'coordinates', & - trim(avail_hist_fields(n)%vcoord)) - status = pio_put_att(File,varid,'cell_measures', & - trim(avail_hist_fields(n)%vcellmeas)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - - ! Add cell_methods attribute to variables if averaged - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_put_att(File,varid,'cell_methods','time: mean') - endif - - if (histfreq(ns) == '1' .or. .not. hist_avg) then - status = pio_put_att(File,varid,'time_rep','instantaneous') - else - status = pio_put_att(File,varid,'time_rep','averaged') - endif - endif - enddo ! num_avail_hist_fields_3Da - - !----------------------------------------------------------------- - ! 3D (fsd) - !----------------------------------------------------------------- - - dimidz(1) = imtid - dimidz(2) = jmtid - dimidz(3) = fmtid - dimidz(4) = timid - - do n = n3Dacum + 1, n3Dfcum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidz, varid) - status = pio_put_att(File,varid,'units', & - trim(avail_hist_fields(n)%vunit)) - status = pio_put_att(File,varid, 'long_name', & - trim(avail_hist_fields(n)%vdesc)) - status = pio_put_att(File,varid,'coordinates', & - trim(avail_hist_fields(n)%vcoord)) - status = pio_put_att(File,varid,'cell_measures', & - trim(avail_hist_fields(n)%vcellmeas)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - - ! Add cell_methods attribute to variables if averaged - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_put_att(File,varid,'cell_methods','time: mean') - endif - - if (histfreq(ns) == '1' .or. .not. hist_avg) then - status = pio_put_att(File,varid,'time_rep','instantaneous') - else - status = pio_put_att(File,varid,'time_rep','averaged') - endif - endif - enddo ! num_avail_hist_fields_3Df - - !----------------------------------------------------------------- - ! define attributes for 4D variables - ! time coordinate is dropped - !----------------------------------------------------------------- - - !----------------------------------------------------------------- - ! 4D (ice categories) - !----------------------------------------------------------------- - - dimidcz(1) = imtid - dimidcz(2) = jmtid - dimidcz(3) = kmtidi - dimidcz(4) = cmtid - dimidcz(5) = timid - - do n = n3Dfcum + 1, n4Dicum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - lprecision, dimidcz, varid) - status = pio_put_att(File,varid,'units', & - trim(avail_hist_fields(n)%vunit)) - status = pio_put_att(File,varid, 'long_name', & - trim(avail_hist_fields(n)%vdesc)) - status = pio_put_att(File,varid,'coordinates', & - trim(avail_hist_fields(n)%vcoord)) - status = pio_put_att(File,varid,'cell_measures', & - trim(avail_hist_fields(n)%vcellmeas)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - - ! Add cell_methods attribute to variables if averaged - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_put_att(File,varid,'cell_methods','time: mean') - endif - - if (histfreq(ns) == '1' .or. .not. hist_avg) then - status = pio_put_att(File,varid,'time_rep','instantaneous') - else - status = pio_put_att(File,varid,'time_rep','averaged') - endif - endif - enddo ! num_avail_hist_fields_4Di - - !----------------------------------------------------------------- - ! 4D (snow layers) - !----------------------------------------------------------------- - - dimidcz(1) = imtid - dimidcz(2) = jmtid - dimidcz(3) = kmtids - dimidcz(4) = cmtid - dimidcz(5) = timid - - do n = n4Dicum + 1, n4Dscum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - lprecision, dimidcz, varid) - status = pio_put_att(File,varid,'units', & - trim(avail_hist_fields(n)%vunit)) - status = pio_put_att(File,varid, 'long_name', & - trim(avail_hist_fields(n)%vdesc)) - status = pio_put_att(File,varid,'coordinates', & - trim(avail_hist_fields(n)%vcoord)) - status = pio_put_att(File,varid,'cell_measures', & - trim(avail_hist_fields(n)%vcellmeas)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - - ! Add cell_methods attribute to variables if averaged - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_put_att(File,varid,'cell_methods','time: mean') - endif - - if (histfreq(ns) == '1' .or. .not. hist_avg) then - status = pio_put_att(File,varid,'time_rep','instantaneous') - else - status = pio_put_att(File,varid,'time_rep','averaged') - endif - endif - enddo ! num_avail_hist_fields_4Ds - - - !----------------------------------------------------------------- - ! 4D (fsd layers) - !----------------------------------------------------------------- - - dimidcz(1) = imtid - dimidcz(2) = jmtid - dimidcz(3) = fmtid - dimidcz(4) = cmtid - dimidcz(5) = timid - - do n = n4Dscum + 1, n4Dfcum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidcz, varid) - status = pio_put_att(File,varid,'units', & - trim(avail_hist_fields(n)%vunit)) - status = pio_put_att(File,varid, 'long_name', & - trim(avail_hist_fields(n)%vdesc)) - status = pio_put_att(File,varid,'coordinates', & - trim(avail_hist_fields(n)%vcoord)) - status = pio_put_att(File,varid,'cell_measures', & - trim(avail_hist_fields(n)%vcellmeas)) - if (lprecision == pio_real) then - status = pio_put_att(File, varid, 'missing_value', spval) - status = pio_put_att(File, varid,'_FillValue',spval) - else - status = pio_put_att(File, varid, 'missing_value', spval_dbl) - status = pio_put_att(File, varid,'_FillValue',spval_dbl) - endif - - ! Add cell_methods attribute to variables if averaged - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_put_att(File,varid,'cell_methods','time: mean') - endif - - if (histfreq(ns) == '1' .or. .not. hist_avg) then - status = pio_put_att(File,varid,'time_rep','instantaneous') - else - status = pio_put_att(File,varid,'time_rep','averaged') - endif - endif - enddo ! num_avail_hist_fields_4Df - - !----------------------------------------------------------------- - ! global attributes - !----------------------------------------------------------------- - ! ... the user should change these to something useful ... - !----------------------------------------------------------------- -#ifdef CESMCOUPLED - status = pio_put_att(File,pio_global,'title',runid) -#else - title = 'sea ice model output for CICE' - status = pio_put_att(File,pio_global,'title',trim(title)) -#endif - title = 'Diagnostic and Prognostic Variables' - status = pio_put_att(File,pio_global,'contents',trim(title)) - - write(title,'(2a)') 'Los Alamos Sea Ice Model, ', trim(version_name) - status = pio_put_att(File,pio_global,'source',trim(title)) - - if (use_leap_years) then - write(title,'(a,i3,a)') 'This year has ',int(dayyr),' days' - else - write(title,'(a,i3,a)') 'All years have exactly ',int(dayyr),' days' - endif - status = pio_put_att(File,pio_global,'comment',trim(title)) - - write(title,'(a,i8.8)') 'File written on model date ',idate - status = pio_put_att(File,pio_global,'comment2',trim(title)) - - write(title,'(a,i6)') 'seconds elapsed into model date: ',sec - status = pio_put_att(File,pio_global,'comment3',trim(title)) - - title = 'CF-1.0' - status = & - pio_put_att(File,pio_global,'conventions',trim(title)) - - call date_and_time(date=current_date, time=current_time) - write(start_time,1000) current_date(1:4), current_date(5:6), & - current_date(7:8), current_time(1:2), & - current_time(3:4) -1000 format('This dataset was created on ', & - a,'-',a,'-',a,' at ',a,':',a) - status = pio_put_att(File,pio_global,'history',trim(start_time)) - - status = pio_put_att(File,pio_global,'io_flavor','io_pio') - - !----------------------------------------------------------------- - ! end define mode - !----------------------------------------------------------------- - - status = pio_enddef(File) - - !----------------------------------------------------------------- - ! write time variable - !----------------------------------------------------------------- - - status = pio_inq_varid(File,'time',varid) -!sgl status = pio_put_var(File,varid,(/1/),ltime) - status = pio_put_var(File,varid,(/1/),ltime2) - - !----------------------------------------------------------------- - ! write time_bounds info - !----------------------------------------------------------------- - - if (hist_avg .and. histfreq(ns) /= '1') then - status = pio_inq_varid(File,'time_bounds',varid) - time_bounds=(/time_beg(ns),time_end(ns)/) - bnd_start = (/1,1/) - bnd_length = (/2,1/) - status = pio_put_var(File,varid,ival=time_bounds, & - start=bnd_start(:),count=bnd_length(:)) - endif - - !----------------------------------------------------------------- - ! write coordinate variables - !----------------------------------------------------------------- - - allocate(workr2(nx_block,ny_block,nblocks)) - - do i = 1,ncoord - status = pio_inq_varid(File, coord_var(i)%short_name, varid) - SELECT CASE (coord_var(i)%short_name) - CASE ('TLON') - ! Convert T grid longitude from -180 -> 180 to 0 to 360 - workr2(:,:,:) = mod(tlon(:,:,1:nblocks)*rad_to_deg + c360, c360) - CASE ('TLAT') - workr2(:,:,:) = tlat(:,:,1:nblocks)*rad_to_deg - CASE ('ULON') - workr2(:,:,:) = ulon(:,:,1:nblocks)*rad_to_deg - CASE ('ULAT') - workr2(:,:,:) = ulat(:,:,1:nblocks)*rad_to_deg - END SELECT - call pio_write_darray(File, varid, iodesc2d, & - workr2, status, fillval=spval_dbl) - enddo - - ! Extra dimensions (NCAT, NFSD, VGRD*) - - do i = 1, nvarz - if (igrdz(i)) then - status = pio_inq_varid(File, var_nz(i)%short_name, varid) - SELECT CASE (var_nz(i)%short_name) - CASE ('NCAT') - status = pio_put_var(File, varid, hin_max(1:ncat_hist)) - CASE ('NFSD') - status = pio_put_var(File, varid, floe_rad_c(1:nfsd_hist)) - CASE ('VGRDi') - status = pio_put_var(File, varid, (/(k, k=1,nzilyr)/)) - CASE ('VGRDs') - status = pio_put_var(File, varid, (/(k, k=1,nzslyr)/)) - CASE ('VGRDb') - status = pio_put_var(File, varid, (/(k, k=1,nzblyr)/)) - CASE ('VGRDa') - status = pio_put_var(File, varid, (/(k, k=1,nzalyr)/)) - END SELECT - endif - enddo - - !----------------------------------------------------------------- - ! write grid masks, area and rotation angle - !----------------------------------------------------------------- - -! if (igrd(n_tmask)) then -! status = pio_inq_varid(File, 'tmask', varid) -! call pio_write_darray(File, varid, iodesc2d, & -! hm(:,:,1:nblocks), status, fillval=spval_dbl) -! endif -! if (igrd(n_blkmask)) then -! status = pio_inq_varid(File, 'blkmask', varid) -! call pio_write_darray(File, varid, iodesc2d, & -! bm(:,:,1:nblocks), status, fillval=spval_dbl) -! endif - - do i = 1, nvar ! note: n_tmask=1, n_blkmask=2 - if (igrd(i)) then - SELECT CASE (var(i)%req%short_name) - CASE ('tmask') - workr2 = hm(:,:,1:nblocks) - CASE ('blkmask') - workr2 = bm(:,:,1:nblocks) - CASE ('tarea') - workr2 = tarea(:,:,1:nblocks) - CASE ('uarea') - workr2 = uarea(:,:,1:nblocks) - CASE ('dxu') - workr2 = dxu(:,:,1:nblocks) - CASE ('dyu') - workr2 = dyu(:,:,1:nblocks) - CASE ('dxt') - workr2 = dxt(:,:,1:nblocks) - CASE ('dyt') - workr2 = dyt(:,:,1:nblocks) - CASE ('HTN') - workr2 = HTN(:,:,1:nblocks) - CASE ('HTE') - workr2 = HTE(:,:,1:nblocks) - CASE ('ANGLE') - workr2 = ANGLE(:,:,1:nblocks) - CASE ('ANGLET') - workr2 = ANGLET(:,:,1:nblocks) - END SELECT - status = pio_inq_varid(File, var(i)%req%short_name, varid) - call pio_write_darray(File, varid, iodesc2d, & - workr2, status, fillval=spval_dbl) - endif - enddo - - !---------------------------------------------------------------- - ! Write coordinates of grid box vertices - !---------------------------------------------------------------- - - if (f_bounds) then - allocate(workr3v(nverts,nx_block,ny_block,nblocks)) - workr3v (:,:,:,:) = c0 - do i = 1, nvar_verts - SELECT CASE (var_nverts(i)%short_name) - CASE ('lont_bounds') - do ivertex = 1, nverts - workr3v(ivertex,:,:,:) = lont_bounds(ivertex,:,:,1:nblocks) - enddo - CASE ('latt_bounds') - do ivertex = 1, nverts - workr3v(ivertex,:,:,:) = latt_bounds(ivertex,:,:,1:nblocks) - enddo - CASE ('lonu_bounds') - do ivertex = 1, nverts - workr3v(ivertex,:,:,:) = lonu_bounds(ivertex,:,:,1:nblocks) - enddo - CASE ('latu_bounds') - do ivertex = 1, nverts - workr3v(ivertex,:,:,:) = latu_bounds(ivertex,:,:,1:nblocks) - enddo - END SELECT - - status = pio_inq_varid(File, var_nverts(i)%short_name, varid) - call pio_write_darray(File, varid, iodesc3dv, & - workr3v, status, fillval=spval_dbl) - enddo - deallocate(workr3v) - endif ! f_bounds - - - !----------------------------------------------------------------- - ! write variable data - !----------------------------------------------------------------- - - ! 2D - do n=1,num_avail_hist_fields_2D - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) - if (status /= pio_noerr) call abort_ice(subname// & - 'ERROR getting varid for '//avail_hist_fields(n)%vname) - workr2(:,:,:) = a2D(:,:,n,1:nblocks) - call pio_setframe(varid, int(1,kind=PIO_OFFSET)) - call pio_write_darray(File, varid, iodesc2d,& - workr2, status, fillval=spval_dbl) - endif - enddo ! num_avail_hist_fields_2D - - deallocate(workr2) - - ! 3D (category) - allocate(workr3(nx_block,ny_block,nblocks,ncat_hist)) - do n = n2D + 1, n3Dccum - nn = n - n2D - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) - if (status /= pio_noerr) call abort_ice(subname// & - 'ERROR: getting varid for '//avail_hist_fields(n)%vname) - do j = 1, nblocks - do i = 1, ncat_hist - workr3(:,:,j,i) = a3Dc(:,:,i,nn,j) - enddo - enddo - call pio_setframe(varid, int(1,kind=PIO_OFFSET)) - call pio_write_darray(File, varid, iodesc3dc,& - workr3, status, fillval=spval_dbl) - endif - enddo ! num_avail_hist_fields_3Dc - deallocate(workr3) - - ! 3D (vertical ice) - allocate(workr3(nx_block,ny_block,nblocks,nzilyr)) - do n = n3Dccum+1, n3Dzcum - nn = n - n3Dccum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) - if (status /= pio_noerr) call abort_ice(subname// & - 'ERROR: getting varid for '//avail_hist_fields(n)%vname) - do j = 1, nblocks - do i = 1, nzilyr - workr3(:,:,j,i) = a3Dz(:,:,i,nn,j) - enddo - enddo - call pio_setframe(varid, int(1,kind=PIO_OFFSET)) - call pio_write_darray(File, varid, iodesc3di,& - workr3, status, fillval=spval_dbl) - endif - enddo ! num_avail_hist_fields_3Dz - deallocate(workr3) - - ! 3D (vertical ice biology) - allocate(workr3(nx_block,ny_block,nblocks,nzblyr)) - do n = n3Dzcum+1, n3Dbcum - nn = n - n3Dzcum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) - if (status /= pio_noerr) call abort_ice(subname// & - 'ERROR: getting varid for '//avail_hist_fields(n)%vname) - do j = 1, nblocks - do i = 1, nzblyr - workr3(:,:,j,i) = a3Db(:,:,i,nn,j) - enddo - enddo - call pio_setframe(varid, int(1,kind=PIO_OFFSET)) - call pio_write_darray(File, varid, iodesc3db,& - workr3, status, fillval=spval_dbl) - endif - enddo ! num_avail_hist_fields_3Db - deallocate(workr3) - - ! 3D (vertical snow biology) - allocate(workr3(nx_block,ny_block,nblocks,nzalyr)) - do n = n3Dbcum+1, n3Dacum - nn = n - n3Dbcum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) - if (status /= pio_noerr) call abort_ice(subname// & - 'ERROR: getting varid for '//avail_hist_fields(n)%vname) - do j = 1, nblocks - do i = 1, nzalyr - workr3(:,:,j,i) = a3Da(:,:,i,nn,j) - enddo - enddo - call pio_setframe(varid, int(1,kind=PIO_OFFSET)) - call pio_write_darray(File, varid, iodesc3da,& - workr3, status, fillval=spval_dbl) - endif - enddo ! num_avail_hist_fields_3Db - deallocate(workr3) - - ! 3D (fsd) - allocate(workr3(nx_block,ny_block,nblocks,nfsd_hist)) - do n = n3Dacum+1, n3Dfcum - nn = n - n3Dacum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) - if (status /= pio_noerr) call abort_ice(subname// & - 'ERROR: getting varid for '//avail_hist_fields(n)%vname) - do j = 1, nblocks - do i = 1, nfsd_hist - workr3(:,:,j,i) = a3Df(:,:,i,nn,j) - enddo - enddo - call pio_setframe(varid, int(1,kind=PIO_OFFSET)) - call pio_write_darray(File, varid, iodesc3df,& - workr3, status, fillval=spval_dbl) - endif - enddo ! num_avail_hist_fields_3Df - deallocate(workr3) - - allocate(workr4(nx_block,ny_block,nblocks,ncat_hist,nzilyr)) - ! 4D (categories, fsd) - do n = n3Dfcum+1, n4Dicum - nn = n - n3Dfcum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) - if (status /= pio_noerr) call abort_ice(subname// & - 'ERROR: getting varid for '//avail_hist_fields(n)%vname) - do j = 1, nblocks - do i = 1, ncat_hist - do k = 1, nzilyr - workr4(:,:,j,i,k) = a4Di(:,:,k,i,nn,j) - enddo ! k - enddo ! i - enddo ! j - call pio_setframe(varid, int(1,kind=PIO_OFFSET)) - call pio_write_darray(File, varid, iodesc4di,& - workr4, status, fillval=spval_dbl) - endif - enddo ! num_avail_hist_fields_4Di - deallocate(workr4) - - allocate(workr4(nx_block,ny_block,nblocks,ncat_hist,nzslyr)) - ! 4D (categories, vertical ice) - do n = n4Dicum+1, n4Dscum - nn = n - n4Dicum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) - if (status /= pio_noerr) call abort_ice(subname// & - 'ERROR: getting varid for '//avail_hist_fields(n)%vname) - do j = 1, nblocks - do i = 1, ncat_hist - do k = 1, nzslyr - workr4(:,:,j,i,k) = a4Ds(:,:,k,i,nn,j) - enddo ! k - enddo ! i - enddo ! j - call pio_setframe(varid, int(1,kind=PIO_OFFSET)) - call pio_write_darray(File, varid, iodesc4ds,& - workr4, status, fillval=spval_dbl) - endif - enddo ! num_avail_hist_fields_4Di - deallocate(workr4) - - allocate(workr4(nx_block,ny_block,nblocks,ncat_hist,nfsd_hist)) - ! 4D (categories, vertical ice) - do n = n4Dscum+1, n4Dfcum - nn = n - n4Dscum - if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then - status = pio_inq_varid(File,avail_hist_fields(n)%vname,varid) - if (status /= pio_noerr) call abort_ice(subname// & - 'ERROR: getting varid for '//avail_hist_fields(n)%vname) - do j = 1, nblocks - do i = 1, ncat_hist - do k = 1, nfsd_hist - workr4(:,:,j,i,k) = a4Ds(:,:,k,i,nn,j) - enddo ! k - enddo ! i - enddo ! j - call pio_setframe(varid, int(1,kind=PIO_OFFSET)) - call pio_write_darray(File, varid, iodesc4df,& - workr4, status, fillval=spval_dbl) - endif - enddo ! num_avail_hist_fields_4Di - deallocate(workr4) - -! similarly for num_avail_hist_fields_4Db (define workr4b, iodesc4db) - - - !----------------------------------------------------------------- - ! clean-up PIO descriptors - !----------------------------------------------------------------- - - call pio_freedecomp(File,iodesc2d) - call pio_freedecomp(File,iodesc3dv) - call pio_freedecomp(File,iodesc3dc) - call pio_freedecomp(File,iodesc3di) - call pio_freedecomp(File,iodesc3db) - call pio_freedecomp(File,iodesc3da) - call pio_freedecomp(File,iodesc3df) - call pio_freedecomp(File,iodesc4di) - call pio_freedecomp(File,iodesc4ds) - call pio_freedecomp(File,iodesc4df) - - !----------------------------------------------------------------- - ! close output dataset - !----------------------------------------------------------------- - - call pio_closefile(File) - if (my_task == master_task) then - write(nu_diag,*) ' ' - write(nu_diag,*) 'Finished writing ',trim(ncfile(ns)) - endif - -#endif - - end subroutine ice_write_hist - -!======================================================================= - - end module ice_history_write - -!======================================================================= diff --git a/cicecore/cicedynB/infrastructure/io/io_pio/ice_pio.F90 b/cicecore/cicedynB/infrastructure/io/io_pio/ice_pio.F90 deleted file mode 100644 index d6aa65ae1..000000000 --- a/cicecore/cicedynB/infrastructure/io/io_pio/ice_pio.F90 +++ /dev/null @@ -1,364 +0,0 @@ -!============================================================================ -! Writes netcdf files -! Created by Mariana Vertenstein, June 2009 - - module ice_pio - - use shr_kind_mod, only: r8 => shr_kind_r8, in=>shr_kind_in - use shr_kind_mod, only: cl => shr_kind_cl - use ice_kinds_mod - use ice_blocks - use ice_broadcast - use ice_communicate - use ice_domain, only : nblocks, blocks_ice - use ice_domain_size - use ice_fileunits - use ice_exit, only: abort_ice - use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted - use pio - - implicit none - private - - interface ice_pio_initdecomp - module procedure ice_pio_initdecomp_2d - module procedure ice_pio_initdecomp_3d - module procedure ice_pio_initdecomp_4d - module procedure ice_pio_initdecomp_3d_inner - end interface - - public ice_pio_init - public ice_pio_initdecomp - - type(iosystem_desc_t), pointer, public :: ice_pio_subsystem - -!=============================================================================== - - contains - -!=============================================================================== - -! Initialize the io subsystem -! 2009-Feb-17 - J. Edwards - initial version - - subroutine ice_pio_init(mode, filename, File, clobber, cdf64) - - use shr_pio_mod, only: shr_pio_getiosys, shr_pio_getiotype - - implicit none - character(len=*) , intent(in), optional :: mode - character(len=*) , intent(in), optional :: filename - type(file_desc_t) , intent(inout), optional :: File - logical , intent(in), optional :: clobber - logical , intent(in), optional :: cdf64 - - ! local variables - - integer (int_kind) :: & - nml_error ! namelist read error flag - - integer :: pio_iotype - logical :: exists - logical :: lclobber - logical :: lcdf64 - integer :: status - integer :: nmode - character(len=*), parameter :: subname = '(ice_pio_init)' - logical, save :: first_call = .true. - - ice_pio_subsystem => shr_pio_getiosys(inst_name) - pio_iotype = shr_pio_getiotype(inst_name) - - if (present(mode) .and. present(filename) .and. present(File)) then - - if (trim(mode) == 'write') then - lclobber = .false. - if (present(clobber)) lclobber=clobber - - lcdf64 = .false. - if (present(cdf64)) lcdf64=cdf64 - - if (File%fh<0) then - ! filename not open - inquire(file=trim(filename),exist=exists) - if (exists) then - if (lclobber) then - nmode = pio_clobber - if (lcdf64) nmode = ior(nmode,PIO_64BIT_OFFSET) - status = pio_createfile(ice_pio_subsystem, File, pio_iotype, trim(filename), nmode) - if (my_task == master_task) then - write(nu_diag,*) subname,' create file ',trim(filename) - end if - else - nmode = pio_write - status = pio_openfile(ice_pio_subsystem, File, pio_iotype, trim(filename), nmode) - if (my_task == master_task) then - write(nu_diag,*) subname,' open file ',trim(filename) - end if - endif - else - nmode = pio_noclobber - if (lcdf64) nmode = ior(nmode,PIO_64BIT_OFFSET) - status = pio_createfile(ice_pio_subsystem, File, pio_iotype, trim(filename), nmode) - if (my_task == master_task) then - write(nu_diag,*) subname,' create file ',trim(filename) - end if - endif - else - ! filename is already open, just return - endif - end if - - if (trim(mode) == 'read') then - inquire(file=trim(filename),exist=exists) - if (exists) then - status = pio_openfile(ice_pio_subsystem, File, pio_iotype, trim(filename), pio_nowrite) - else - if(my_task==master_task) then - write(nu_diag,*) 'ice_pio_ropen ERROR: file invalid ',trim(filename) - end if - call abort_ice(subname//'ERROR: aborting with invalid file') - endif - end if - - end if - - end subroutine ice_pio_init - -!================================================================================ - - subroutine ice_pio_initdecomp_2d(iodesc) - - type(io_desc_t), intent(out) :: iodesc - - integer (kind=int_kind) :: & - iblk,ilo,ihi,jlo,jhi,lon,lat,i,j,n,k - - type(block) :: this_block - - integer(kind=int_kind), pointer :: dof2d(:) - character(len=*), parameter :: subname = '(ice_pio_initdecomp_2d)' - - allocate(dof2d(nx_block*ny_block*nblocks)) - - n=0 - 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=1,ny_block - do i=1,nx_block - n = n+1 - if (j < jlo .or. j>jhi) then - dof2d(n) = 0 - else if (i < ilo .or. i > ihi) then - dof2d(n) = 0 - else - lon = this_block%i_glob(i) - lat = this_block%j_glob(j) - dof2d(n) = (lat-1)*nx_global + lon - endif - enddo !i - enddo !j - end do - - call pio_initdecomp(ice_pio_subsystem, pio_double, (/nx_global,ny_global/), & - dof2d, iodesc) - - deallocate(dof2d) - - end subroutine ice_pio_initdecomp_2d - -!================================================================================ - - subroutine ice_pio_initdecomp_3d (ndim3, iodesc, remap) - - integer(kind=int_kind), intent(in) :: ndim3 - type(io_desc_t), intent(out) :: iodesc - logical, optional :: remap - integer (kind=int_kind) :: & - iblk,ilo,ihi,jlo,jhi,lon,lat,i,j,n,k - - type(block) :: this_block - logical :: lremap - integer(kind=int_kind), pointer :: dof3d(:) - character(len=*), parameter :: subname = '(ice_pio_initdecomp_2d)' - - allocate(dof3d(nx_block*ny_block*nblocks*ndim3)) - lremap=.false. - if (present(remap)) lremap=remap - if (lremap) then - ! Reorder the ndim3 and nblocks loops to avoid a temporary array in restart read/write - n=0 - 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 k=1,ndim3 - do j=1,ny_block - do i=1,nx_block - n = n+1 - if (j < jlo .or. j>jhi) then - dof3d(n)=0 - else if (i < ilo .or. i > ihi) then - dof3d(n) = 0 - else - lon = this_block%i_glob(i) - lat = this_block%j_glob(j) - dof3d(n) = ((lat-1)*nx_global + lon) + (k-1)*nx_global*ny_global - endif - enddo !i - enddo !j - enddo !ndim3 - enddo ! iblk - else - n=0 - do k=1,ndim3 - 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=1,ny_block - do i=1,nx_block - n = n+1 - if (j < jlo .or. j>jhi) then - dof3d(n)=0 - else if (i < ilo .or. i > ihi) then - dof3d(n) = 0 - else - lon = this_block%i_glob(i) - lat = this_block%j_glob(j) - dof3d(n) = ((lat-1)*nx_global + lon) + (k-1)*nx_global*ny_global - endif - enddo !i - enddo !j - enddo ! iblk - enddo !ndim3 - endif - - call pio_initdecomp(ice_pio_subsystem, pio_double, (/nx_global,ny_global,ndim3/), & - dof3d, iodesc) - - deallocate(dof3d) - - end subroutine ice_pio_initdecomp_3d - -!================================================================================ - - subroutine ice_pio_initdecomp_3d_inner(ndim3, inner_dim, iodesc) - - integer(kind=int_kind), intent(in) :: ndim3 - logical, intent(in) :: inner_dim - type(io_desc_t), intent(out) :: iodesc - - integer (kind=int_kind) :: & - iblk,ilo,ihi,jlo,jhi,lon,lat,i,j,n,k - - type(block) :: this_block - - integer(kind=int_kind), pointer :: dof3d(:) - - character(len=*), parameter :: subname = '(ice_pio_initdecomp_3d_inner)' - - allocate(dof3d(nx_block*ny_block*nblocks*ndim3)) - - n=0 - 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=1,ny_block - do i=1,nx_block - do k=1,ndim3 - n = n+1 - if (j < jlo .or. j>jhi) then - dof3d(n) = 0 - else if (i < ilo .or. i > ihi) then - dof3d(n) = 0 - else - lon = this_block%i_glob(i) - lat = this_block%j_glob(j) - dof3d(n) = k + ((lon-1) + (lat-1)*nx_global)*ndim3 - endif - end do !ndim3 - enddo !i - enddo !j - end do !iblk - - call pio_initdecomp(ice_pio_subsystem, pio_double, (/ndim3,nx_global,ny_global/), & - dof3d, iodesc) - - deallocate(dof3d) - - end subroutine ice_pio_initdecomp_3d_inner - -!================================================================================ - - subroutine ice_pio_initdecomp_4d (ndim3, ndim4, iodesc) - - integer(kind=int_kind), intent(in) :: ndim3, ndim4 - type(io_desc_t), intent(out) :: iodesc - - integer (kind=int_kind) :: & - iblk,ilo,ihi,jlo,jhi,lon,lat,i,j,n,k,l - - type(block) :: this_block - - integer(kind=int_kind), pointer :: dof4d(:) - - character(len=*), parameter :: subname = '(ice_pio_initdecomp_4d)' - - allocate(dof4d(nx_block*ny_block*nblocks*ndim3*ndim4)) - - n=0 - do l=1,ndim4 - do k=1,ndim3 - 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=1,ny_block - do i=1,nx_block - n = n+1 - if (j < jlo .or. j>jhi) then - dof4d(n)=0 - else if (i < ilo .or. i > ihi) then - dof4d(n) = 0 - else - lon = this_block%i_glob(i) - lat = this_block%j_glob(j) - dof4d(n) = ((lat-1)*nx_global + lon) & - + (k-1)*nx_global*ny_global & - + (l-1)*nx_global*ny_global*ndim3 - endif - enddo !i - enddo !j - enddo ! iblk - enddo !ndim3 - enddo !ndim4 - - call pio_initdecomp(ice_pio_subsystem, pio_double, & - (/nx_global,ny_global,ndim3,ndim4/), dof4d, iodesc) - - deallocate(dof4d) - - end subroutine ice_pio_initdecomp_4d - -!================================================================================ - - end module ice_pio - -!================================================================================ diff --git a/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 b/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 deleted file mode 100644 index c207d5b25..000000000 --- a/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 +++ /dev/null @@ -1,891 +0,0 @@ -!======================================================================= -! -! Read and write ice model restart files using pio interfaces. -! authors David A Bailey, NCAR - - module ice_restart - - use ice_broadcast - 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 - use ice_pio - use pio - use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted - use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_indices - use icepack_intfc, only: icepack_query_parameters, icepack_query_tracer_sizes - - implicit none - private - public :: init_restart_write, init_restart_read, & - read_restart_field, write_restart_field, final_restart - - type(file_desc_t) :: File - type(var_desc_t) :: vardesc - - type(io_desc_t) :: iodesc2d - type(io_desc_t) :: iodesc3d_ncat - -!======================================================================= - - contains - -!======================================================================= - -! Sets up restart file for reading. -! author David A Bailey, NCAR - - subroutine init_restart_read(ice_ic) - - 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 - - character(len=char_len_long), intent(in), optional :: ice_ic - - ! local variables - - character(len=char_len_long) :: & - filename, filename0 - - integer (kind=int_kind) :: status - - character(len=*), parameter :: subname = '(init_restart_read)' - - if (present(ice_ic)) then - filename = trim(ice_ic) - else - if (my_task == master_task) then - open(nu_rst_pointer,file=pointer_file) - read(nu_rst_pointer,'(a)') filename0 - filename = trim(filename0) - close(nu_rst_pointer) - write(nu_diag,*) 'Read ',pointer_file(1:lenstr(pointer_file)) - endif - call broadcast_scalar(filename, master_task) - endif - - if (my_task == master_task) then - write(nu_diag,*) 'Using restart dump=', trim(filename) - end if - - if (restart_format == 'pio') then - File%fh=-1 - 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 - 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) - status = pio_get_att(File, pio_global, 'sec', sec) - endif - endif ! use namelist values if use_restart_time = F - endif - - if (my_task == master_task) then - 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(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 - - end subroutine init_restart_read - -!======================================================================= - -! Sets up restart file for writing. -! author David A Bailey, NCAR - - subroutine init_restart_write(filename_spec) - - 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_dyn_shared, only: kdyn - use ice_arrays_column, only: oceanmixed_ice - - logical (kind=log_kind) :: & - solve_zsal, skl_bgc, z_tracers - - logical (kind=log_kind) :: & - 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_PON, tr_bgc_DON, & - tr_zaero, tr_bgc_Fe, & - tr_bgc_hum, tr_fsd - - integer (kind=int_kind) :: & - nbtrcr - - character(len=char_len_long), intent(in), optional :: 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, & - dimid_nilyr, dimid_nslyr, dimid_naero - - integer (kind=int_kind), allocatable :: dims(:) - - integer (kind=int_kind) :: & - k, n, & ! loop index - status ! status variable from netCDF routine - - character (len=3) :: nchar, ncharb - - character(len=*), parameter :: subname = '(init_restart_write)' - - 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_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(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, & - file=__FILE__, line=__LINE__) - - ! construct path/file - 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)),'.', & - iyear,'-',month,'-',mday,'-',sec - end if - - if (restart_format /= 'bin') filename = trim(filename) // '.nc' - - ! write pointer (path/file) - if (my_task == master_task) then - open(nu_rst_pointer,file=pointer_file) - write(nu_rst_pointer,'(a)') filename - close(nu_rst_pointer) - endif - - if (restart_format == 'pio') then - - File%fh=-1 - call ice_pio_init(mode='write',filename=trim(filename), File=File, & - 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,'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,'sec',sec) - - status = pio_def_dim(File,'ni',nx_global,dimid_ni) - status = pio_def_dim(File,'nj',ny_global,dimid_nj) - status = pio_def_dim(File,'ncat',ncat,dimid_ncat) - - !----------------------------------------------------------------- - ! 2D restart fields - !----------------------------------------------------------------- - - allocate(dims(2)) - - dims(1) = dimid_ni - dims(2) = dimid_nj - - call define_rest_field(File,'uvel',dims) - call define_rest_field(File,'vvel',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) - call define_rest_field(File,'swidr',dims) - call define_rest_field(File,'swidf',dims) - - call define_rest_field(File,'strocnxT',dims) - call define_rest_field(File,'strocnyT',dims) - - call define_rest_field(File,'stressp_1',dims) - call define_rest_field(File,'stressp_2',dims) - call define_rest_field(File,'stressp_3',dims) - call define_rest_field(File,'stressp_4',dims) - - call define_rest_field(File,'stressm_1',dims) - call define_rest_field(File,'stressm_2',dims) - call define_rest_field(File,'stressm_3',dims) - call define_rest_field(File,'stressm_4',dims) - - call define_rest_field(File,'stress12_1',dims) - call define_rest_field(File,'stress12_2',dims) - call define_rest_field(File,'stress12_3',dims) - call define_rest_field(File,'stress12_4',dims) - - call define_rest_field(File,'iceumask',dims) - - if (oceanmixed_ice) then - call define_rest_field(File,'sst',dims) - call define_rest_field(File,'frzmlt',dims) - endif - - if (tr_FY) then - call define_rest_field(File,'frz_onset',dims) - end if - - if (kdyn == 2) then - call define_rest_field(File,'a11_1',dims) - call define_rest_field(File,'a11_2',dims) - call define_rest_field(File,'a11_3',dims) - call define_rest_field(File,'a11_4',dims) - call define_rest_field(File,'a12_1',dims) - call define_rest_field(File,'a12_2',dims) - call define_rest_field(File,'a12_3',dims) - call define_rest_field(File,'a12_4',dims) - endif - - if (tr_pond_lvl) then - call define_rest_field(File,'fsnow',dims) - endif - - if (nbtrcr > 0) then - if (tr_bgc_N) then - do k=1,n_algae - write(nchar,'(i3.3)') k - call define_rest_field(File,'algalN'//trim(nchar),dims) - enddo - endif - if (tr_bgc_C) then - do k=1,n_doc - write(nchar,'(i3.3)') k - call define_rest_field(File,'doc'//trim(nchar),dims) - enddo - do k=1,n_dic - write(nchar,'(i3.3)') k - call define_rest_field(File,'dic'//trim(nchar),dims) - enddo - endif - call define_rest_field(File,'nit' ,dims) - if (tr_bgc_Am) & - call define_rest_field(File,'amm' ,dims) - if (tr_bgc_Sil) & - call define_rest_field(File,'sil' ,dims) - if (tr_bgc_hum) & - call define_rest_field(File,'hum' ,dims) - if (tr_bgc_DMS) then - call define_rest_field(File,'dmsp' ,dims) - call define_rest_field(File,'dms' ,dims) - endif - if (tr_bgc_DON) then - do k=1,n_don - write(nchar,'(i3.3)') k - call define_rest_field(File,'don'//trim(nchar),dims) - enddo - endif - if (tr_bgc_Fe ) then - do k=1,n_fed - write(nchar,'(i3.3)') k - call define_rest_field(File,'fed'//trim(nchar),dims) - enddo - do k=1,n_fep - write(nchar,'(i3.3)') k - call define_rest_field(File,'fep'//trim(nchar),dims) - enddo - endif - if (tr_zaero) then - do k=1,n_zaero - write(nchar,'(i3.3)') k - call define_rest_field(File,'zaeros'//trim(nchar),dims) - enddo - endif - endif !nbtrcr - - if (solve_zsal) call define_rest_field(File,'sss',dims) - - deallocate(dims) - - !----------------------------------------------------------------- - ! 3D restart fields (ncat) - !----------------------------------------------------------------- - - allocate(dims(3)) - - dims(1) = dimid_ni - dims(2) = dimid_nj - dims(3) = dimid_ncat - - call define_rest_field(File,'aicen',dims) - call define_rest_field(File,'vicen',dims) - call define_rest_field(File,'vsnon',dims) - call define_rest_field(File,'Tsfcn',dims) - - if (tr_iage) then - call define_rest_field(File,'iage',dims) - end if - - if (tr_FY) then - call define_rest_field(File,'FY',dims) - end if - - if (tr_lvl) then - call define_rest_field(File,'alvl',dims) - 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) - call define_rest_field(File,'ipnd',dims) - end if - - if (tr_pond_lvl) then - call define_rest_field(File,'apnd',dims) - call define_rest_field(File,'hpnd',dims) - call define_rest_field(File,'ipnd',dims) - call define_rest_field(File,'dhs',dims) - call define_rest_field(File,'ffrac',dims) - end if - - if (tr_brine) then - call define_rest_field(File,'fbrn',dims) - call define_rest_field(File,'first_ice',dims) - endif - - if (skl_bgc) then - do k = 1, n_algae - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_N'//trim(nchar) ,dims) - enddo - if (tr_bgc_C) then - ! do k = 1, n_algae - ! write(nchar,'(i3.3)') k - ! call define_rest_field(File,'bgc_C'//trim(nchar) ,dims) - ! enddo - do k = 1, n_doc - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_DOC'//trim(nchar) ,dims) - enddo - do k = 1, n_dic - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_DIC'//trim(nchar) ,dims) - enddo - endif - if (tr_bgc_chl) then - do k = 1, n_algae - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_chl'//trim(nchar) ,dims) - enddo - endif - call define_rest_field(File,'bgc_Nit' ,dims) - if (tr_bgc_Am) & - call define_rest_field(File,'bgc_Am' ,dims) - if (tr_bgc_Sil) & - call define_rest_field(File,'bgc_Sil' ,dims) - if (tr_bgc_hum) & - call define_rest_field(File,'bgc_hum' ,dims) - if (tr_bgc_DMS) then - call define_rest_field(File,'bgc_DMSPp',dims) - call define_rest_field(File,'bgc_DMSPd',dims) - call define_rest_field(File,'bgc_DMS' ,dims) - endif - if (tr_bgc_PON) & - call define_rest_field(File,'bgc_PON' ,dims) - if (tr_bgc_DON) then - do k = 1, n_don - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_DON'//trim(nchar) ,dims) - enddo - endif - if (tr_bgc_Fe ) then - do k = 1, n_fed - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_Fed'//trim(nchar) ,dims) - enddo - do k = 1, n_fep - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_Fep'//trim(nchar) ,dims) - enddo - endif - endif !skl_bgc - if (solve_zsal) & - call define_rest_field(File,'Rayleigh',dims) - - !----------------------------------------------------------------- - ! 4D restart fields, written as layers of 3D - !----------------------------------------------------------------- - - do k=1,nilyr - write(nchar,'(i3.3)') k - call define_rest_field(File,'sice'//trim(nchar),dims) - call define_rest_field(File,'qice'//trim(nchar),dims) - enddo - - do k=1,nslyr - write(nchar,'(i3.3)') k - call define_rest_field(File,'qsno'//trim(nchar),dims) - enddo - - 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 - call define_rest_field(File,'isosno'//nchar, dims) - call define_rest_field(File,'isoice'//nchar, dims) - enddo - endif - - if (tr_aero) then - do k=1,n_aero - write(nchar,'(i3.3)') k - call define_rest_field(File,'aerosnossl'//nchar, dims) - call define_rest_field(File,'aerosnoint'//nchar, dims) - call define_rest_field(File,'aeroicessl'//nchar, dims) - call define_rest_field(File,'aeroiceint'//nchar, dims) - 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 - write(ncharb,'(i3.3)') n - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'zaero'//trim(ncharb)//trim(nchar),dims) - enddo !k - enddo !n - endif !tr_zaero - if (tr_bgc_Nit) then - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_Nit'//trim(nchar),dims) - enddo - endif - if (tr_bgc_N) then - do n = 1, n_algae - write(ncharb,'(i3.3)') n - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_N'//trim(ncharb)//trim(nchar),dims) - enddo - enddo - endif - if (tr_bgc_C) then - ! do n = 1, n_algae - ! write(ncharb,'(i3.3)') n - ! do k = 1, nblyr+3 - ! write(nchar,'(i3.3)') k - ! call - ! define_rest_field(File,'bgc_C'//trim(ncharb)//trim(nchar),dims) - ! enddo - ! enddo - do n = 1, n_doc - write(ncharb,'(i3.3)') n - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_DOC'//trim(ncharb)//trim(nchar),dims) - enddo - enddo - do n = 1, n_dic - write(ncharb,'(i3.3)') n - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_DIC'//trim(ncharb)//trim(nchar),dims) - enddo - enddo - endif - if (tr_bgc_chl) then - do n = 1, n_algae - write(ncharb,'(i3.3)') n - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_chl'//trim(ncharb)//trim(nchar),dims) - enddo - enddo - endif - if (tr_bgc_Am) then - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_Am'//trim(nchar),dims) - enddo - endif - if (tr_bgc_Sil) then - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_Sil'//trim(nchar),dims) - enddo - endif - if (tr_bgc_hum) then - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_hum'//trim(nchar),dims) - enddo - endif - if (tr_bgc_DMS) then - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_DMSPp'//trim(nchar),dims) - call define_rest_field(File,'bgc_DMSPd'//trim(nchar),dims) - call define_rest_field(File,'bgc_DMS'//trim(nchar),dims) - enddo - endif - if (tr_bgc_PON) then - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_PON'//trim(nchar),dims) - enddo - endif - if (tr_bgc_DON) then - do n = 1, n_don - write(ncharb,'(i3.3)') n - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_DON'//trim(ncharb)//trim(nchar),dims) - enddo - enddo - endif - if (tr_bgc_Fe ) then - do n = 1, n_fed - write(ncharb,'(i3.3)') n - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_Fed'//trim(ncharb)//trim(nchar),dims) - enddo - enddo - do n = 1, n_fep - write(ncharb,'(i3.3)') n - do k = 1, nblyr+3 - write(nchar,'(i3.3)') k - call define_rest_field(File,'bgc_Fep'//trim(ncharb)//trim(nchar),dims) - enddo - enddo - endif - do k = 1, nbtrcr - write(nchar,'(i3.3)') k - call define_rest_field(File,'zbgc_frac'//trim(nchar),dims) - enddo - endif !z_tracers - - deallocate(dims) - status = pio_enddef(File) - - call ice_pio_initdecomp(iodesc=iodesc2d) - call ice_pio_initdecomp(ndim3=ncat , iodesc=iodesc3d_ncat, remap=.true.) - - endif - - if (my_task == master_task) then - write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) - endif - - end subroutine init_restart_write - -!======================================================================= - -! Reads a single restart field -! author David A Bailey, NCAR - - 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 - use ice_domain_size, only: max_blocks, ncat - use ice_global_reductions, only: global_minval, global_maxval, global_sum - - integer (kind=int_kind), intent(in) :: & - nu , & ! unit number (not used for netcdf) - ndim3 , & ! third dimension - nrec ! record number (0 for sequential access) - - real (kind=dbl_kind), dimension(nx_block,ny_block,ndim3,max_blocks), intent(inout) :: & - work ! input array (real, 8-byte) - - character (len=4), intent(in) :: & - atype ! format for output array - ! (real/integer, 4-byte/8-byte) - - logical (kind=log_kind), intent(in) :: & - diag ! if true, write diagnostic output - - character (len=*), intent(in) :: vname - - integer (kind=int_kind), optional, intent(in) :: & - field_loc, & ! location of field on staggered grid - field_type ! type of field (scalar, vector, angle) - - ! local variables - - integer (kind=int_kind) :: & - j, & ! dimension counter - n, & ! number of dimensions for variable - ndims, & ! number of variable dimensions - status ! status variable from netCDF routine - - real (kind=dbl_kind) :: amin,amax,asum - - character(len=*), parameter :: subname = '(read_restart_field)' - - if (restart_format == "pio") then - if (my_task == master_task) & - write(nu_diag,*)'Parallel restart file read: ',vname - - call pio_seterrorhandling(File, PIO_BCAST_ERROR) - - status = pio_inq_varid(File,trim(vname),vardesc) - - if (status /= 0) then - call abort_ice(subname//"ERROR: CICE restart? Missing variable: "//trim(vname)) - endif - - status = pio_inq_varndims(File, vardesc, ndims) - - call pio_seterrorhandling(File, PIO_INTERNAL_ERROR) - -! if (ndim3 == ncat .and. ncat>1) then - if (ndim3 == ncat .and. ndims == 3) then - call pio_read_darray(File, vardesc, iodesc3d_ncat, work, status) - if (present(field_loc)) then - do n=1,ndim3 - call ice_HaloUpdate (work(:,:,n,:), halo_info, & - field_loc, field_type) - enddo - endif -! elseif (ndim3 == 1) then - elseif (ndim3 == 1 .and. ndims == 2) then - call pio_read_darray(File, vardesc, iodesc2d, work, status) - if (present(field_loc)) then - call ice_HaloUpdate (work(:,:,1,:), halo_info, & - field_loc, field_type) - endif - else - write(nu_diag,*) "ndim3 not supported ",ndim3 - endif - - if (diag) then - if (ndim3 > 1) then - do n=1,ndim3 - amin = global_minval(work(:,:,n,:),distrb_info) - 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 and max =', amin, amax - write(nu_diag,*) ' sum =',asum - endif - enddo - else - amin = global_minval(work(:,:,1,:),distrb_info) - 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 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 - - end subroutine read_restart_field - -!======================================================================= - -! Writes a single restart field. -! author David A Bailey, NCAR - - 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 - use ice_global_reductions, only: global_minval, global_maxval, global_sum - - integer (kind=int_kind), intent(in) :: & - nu , & ! unit number - ndim3 , & ! third dimension - nrec ! record number (0 for sequential access) - - real (kind=dbl_kind), dimension(nx_block,ny_block,ndim3,max_blocks), intent(in) :: & - work ! input array (real, 8-byte) - - character (len=4), intent(in) :: & - atype ! format for output array - ! (real/integer, 4-byte/8-byte) - - logical (kind=log_kind), intent(in) :: & - diag ! if true, write diagnostic output - - character (len=*), intent(in) :: vname - - ! local variables - - integer (kind=int_kind) :: & - j, & ! dimension counter - n, & ! dimension counter - ndims, & ! number of variable dimensions - status ! status variable from netCDF routine - - real (kind=dbl_kind) :: amin,amax,asum - - character(len=*), parameter :: subname = '(write_restart_field)' - - 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 - call pio_write_darray(File, vardesc, iodesc3d_ncat,work(:,:,:,1:nblocks), & - status, fillval=c0) - elseif (ndims == 2) then - call pio_write_darray(File, vardesc, iodesc2d, work(:,:,1,1:nblocks), & - status, fillval=c0) - else - write(nu_diag,*) "ndims not supported",ndims,ndim3 - endif - - if (diag) then - if (ndim3 > 1) then - do n=1,ndim3 - amin = global_minval(work(:,:,n,:),distrb_info) - 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 and max =', amin, amax - write(nu_diag,*) ' sum =',asum - endif - enddo - else - amin = global_minval(work(:,:,1,:),distrb_info) - 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 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 - - end subroutine write_restart_field - -!======================================================================= - -! Finalize the restart file. -! author David A Bailey, NCAR - - subroutine final_restart() - - use ice_calendar, only: istep1, time, time_forc - use ice_communicate, only: my_task, master_task - - character(len=*), parameter :: subname = '(final_restart)' - - 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 - -!======================================================================= - -! Defines a restart field -! author David A Bailey, NCAR - - subroutine define_rest_field(File, vname, dims) - - type(file_desc_t) , intent(in) :: File - character (len=*) , intent(in) :: vname - integer (kind=int_kind), intent(in) :: dims(:) - - integer (kind=int_kind) :: & - status ! status variable from netCDF routine - - character(len=*), parameter :: subname = '(define_rest_field)' - - status = pio_def_var(File,trim(vname),pio_double,dims,vardesc) - - end subroutine define_rest_field - -!======================================================================= - - end module ice_restart - -!======================================================================= diff --git a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 index 209aa47b7..d030b439b 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_history_write.F90 @@ -78,6 +78,7 @@ subroutine ice_write_hist (ns) real (kind= dbl_kind) :: ltime2 character (char_len) :: title character (char_len_long) :: ncfile(max_nstrm) + integer (kind=int_kind) :: iotype integer (kind=int_kind) :: iyear, imonth, iday integer (kind=int_kind) :: icategory,ind,i_aice,boundid @@ -162,9 +163,11 @@ subroutine ice_write_hist (ns) ! create file + iotype = PIO_IOTYPE_NETCDF + if (history_format == 'pio_pnetcdf') iotype = PIO_IOTYPE_PNETCDF File%fh=-1 call ice_pio_init(mode='write', filename=trim(filename), File=File, & - clobber=.true., cdf64=lcdf64) + clobber=.true., cdf64=lcdf64, iotype=iotype) call ice_pio_initdecomp(iodesc=iodesc2d) call ice_pio_initdecomp(ndim3=ncat_hist, iodesc=iodesc3dc) @@ -172,10 +175,10 @@ subroutine ice_write_hist (ns) call ice_pio_initdecomp(ndim3=nzblyr, iodesc=iodesc3db) call ice_pio_initdecomp(ndim3=nzalyr, iodesc=iodesc3da) call ice_pio_initdecomp(ndim3=nfsd_hist, iodesc=iodesc3df) - call ice_pio_initdecomp(ndim3=nverts, inner_dim=.true., iodesc=iodesc3dv) - call ice_pio_initdecomp(ndim3=nzilyr, ndim4=ncat_hist, iodesc=iodesc4di) - call ice_pio_initdecomp(ndim3=nzslyr, ndim4=ncat_hist, iodesc=iodesc4ds) - call ice_pio_initdecomp(ndim3=nzslyr, ndim4=nfsd_hist, iodesc=iodesc4df) + call ice_pio_initdecomp(ndim3=nverts, iodesc=iodesc3dv, inner_dim=.true.) + call ice_pio_initdecomp(ndim3=nzilyr, ndim4=ncat_hist, iodesc=iodesc4di) + call ice_pio_initdecomp(ndim3=nzslyr, ndim4=ncat_hist, iodesc=iodesc4ds) + call ice_pio_initdecomp(ndim3=nfsd_hist, ndim4=ncat_hist, iodesc=iodesc4df) ltime2 = time/int(secday) ltime = real(time/int(secday),kind=real_kind) @@ -679,7 +682,7 @@ subroutine ice_write_hist (ns) do n = n3Dacum + 1, n3Dfcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidz, varid) + lprecision, dimidz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -814,7 +817,7 @@ subroutine ice_write_hist (ns) do n = n4Dscum + 1, n4Dfcum if (avail_hist_fields(n)%vhistfreq == histfreq(ns) .or. write_ic) then status = pio_def_var(File, trim(avail_hist_fields(n)%vname), & - pio_real, dimidcz, varid) + lprecision, dimidcz, varid) status = pio_put_att(File,varid,'units', & trim(avail_hist_fields(n)%vunit)) status = pio_put_att(File,varid, 'long_name', & @@ -886,7 +889,11 @@ subroutine ice_write_hist (ns) a,'-',a,'-',a,' at ',a,':',a) status = pio_put_att(File,pio_global,'history',trim(start_time)) - status = pio_put_att(File,pio_global,'io_flavor','io_pio') + if (history_format == 'pio_pnetcdf') then + status = pio_put_att(File,pio_global,'io_flavor','io_pio pnetcdf') + else + status = pio_put_att(File,pio_global,'io_flavor','io_pio netcdf') + endif !----------------------------------------------------------------- ! end define mode @@ -1055,7 +1062,11 @@ subroutine ice_write_hist (ns) if (status /= pio_noerr) call abort_ice(subname// & 'ERROR getting varid for '//avail_hist_fields(n)%vname) workr2(:,:,:) = a2D(:,:,n,1:nblocks) +#ifdef CESM1_PIO + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +#else call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) +#endif call pio_write_darray(File, varid, iodesc2d,& workr2, status, fillval=spval_dbl) endif @@ -1076,7 +1087,11 @@ subroutine ice_write_hist (ns) workr3(:,:,j,i) = a3Dc(:,:,i,nn,j) enddo enddo +#ifdef CESM1_PIO + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +#else call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) +#endif call pio_write_darray(File, varid, iodesc3dc,& workr3, status, fillval=spval_dbl) endif @@ -1096,7 +1111,11 @@ subroutine ice_write_hist (ns) workr3(:,:,j,i) = a3Dz(:,:,i,nn,j) enddo enddo +#ifdef CESM1_PIO + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +#else call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) +#endif call pio_write_darray(File, varid, iodesc3di,& workr3, status, fillval=spval_dbl) endif @@ -1116,7 +1135,11 @@ subroutine ice_write_hist (ns) workr3(:,:,j,i) = a3Db(:,:,i,nn,j) enddo enddo +#ifdef CESM1_PIO + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +#else call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) +#endif call pio_write_darray(File, varid, iodesc3db,& workr3, status, fillval=spval_dbl) endif @@ -1136,7 +1159,11 @@ subroutine ice_write_hist (ns) workr3(:,:,j,i) = a3Da(:,:,i,nn,j) enddo enddo +#ifdef CESM1_PIO + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +#else call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) +#endif call pio_write_darray(File, varid, iodesc3da,& workr3, status, fillval=spval_dbl) endif @@ -1156,7 +1183,11 @@ subroutine ice_write_hist (ns) workr3(:,:,j,i) = a3Df(:,:,i,nn,j) enddo enddo +#ifdef CESM1_PIO + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +#else call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) +#endif call pio_write_darray(File, varid, iodesc3df,& workr3, status, fillval=spval_dbl) endif @@ -1178,7 +1209,11 @@ subroutine ice_write_hist (ns) enddo ! k enddo ! i enddo ! j +#ifdef CESM1_PIO + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +#else call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) +#endif call pio_write_darray(File, varid, iodesc4di,& workr4, status, fillval=spval_dbl) endif @@ -1200,11 +1235,15 @@ subroutine ice_write_hist (ns) enddo ! k enddo ! i enddo ! j +#ifdef CESM1_PIO + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +#else call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) +#endif call pio_write_darray(File, varid, iodesc4ds,& workr4, status, fillval=spval_dbl) endif - enddo ! num_avail_hist_fields_4Di + enddo ! num_avail_hist_fields_4Ds deallocate(workr4) allocate(workr4(nx_block,ny_block,nblocks,ncat_hist,nfsd_hist)) @@ -1218,15 +1257,19 @@ subroutine ice_write_hist (ns) do j = 1, nblocks do i = 1, ncat_hist do k = 1, nfsd_hist - workr4(:,:,j,i,k) = a4Ds(:,:,k,i,nn,j) + workr4(:,:,j,i,k) = a4Df(:,:,k,i,nn,j) enddo ! k enddo ! i enddo ! j +#ifdef CESM1_PIO + call pio_setframe(varid, int(1,kind=PIO_OFFSET)) +#else call pio_setframe(File, varid, int(1,kind=PIO_OFFSET_KIND)) +#endif call pio_write_darray(File, varid, iodesc4df,& workr4, status, fillval=spval_dbl) endif - enddo ! num_avail_hist_fields_4Di + enddo ! num_avail_hist_fields_4Df deallocate(workr4) ! similarly for num_avail_hist_fields_4Db (define workr4b, iodesc4db) diff --git a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_pio.F90 b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_pio.F90 index 564c9cd3b..9c65b2ce1 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_pio.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_pio.F90 @@ -28,7 +28,11 @@ module ice_pio public ice_pio_init public ice_pio_initdecomp - type(iosystem_desc_t), pointer, public :: ice_pio_subsystem +#ifdef CESMCOUPLED + type(iosystem_desc_t), pointer :: ice_pio_subsystem +#else + type(iosystem_desc_t) :: ice_pio_subsystem +#endif !=============================================================================== @@ -39,9 +43,15 @@ module ice_pio ! Initialize the io subsystem ! 2009-Feb-17 - J. Edwards - initial version - subroutine ice_pio_init(mode, filename, File, clobber, cdf64) + subroutine ice_pio_init(mode, filename, File, clobber, cdf64, iotype) +#ifdef CESMCOUPLED use shr_pio_mod, only: shr_pio_getiosys, shr_pio_getiotype +#else +#ifdef GPTL + use perf_mod, only : t_initf +#endif +#endif implicit none character(len=*) , intent(in), optional :: mode @@ -49,12 +59,18 @@ subroutine ice_pio_init(mode, filename, File, clobber, cdf64) type(file_desc_t) , intent(inout), optional :: File logical , intent(in), optional :: clobber logical , intent(in), optional :: cdf64 + integer , intent(in), optional :: iotype ! local variables integer (int_kind) :: & nml_error ! namelist read error flag + integer :: nprocs + integer :: istride + integer :: basetask + integer :: numiotasks + integer :: rearranger integer :: pio_iotype logical :: exists logical :: lclobber @@ -64,8 +80,64 @@ subroutine ice_pio_init(mode, filename, File, clobber, cdf64) character(len=*), parameter :: subname = '(ice_pio_init)' logical, save :: first_call = .true. +#ifdef CESMCOUPLED ice_pio_subsystem => shr_pio_getiosys(inst_name) pio_iotype = shr_pio_getiotype(inst_name) +#else + +#ifdef GPTL + !--- initialize gptl + call t_initf('undefined_NLFileName', LogPrint=.false., mpicom=MPI_COMM_ICE, & + MasterTask=.true.) +#endif + + !--- initialize type of io + !pio_iotype = PIO_IOTYPE_PNETCDF + !pio_iotype = PIO_IOTYPE_NETCDF4C + !pio_iotype = PIO_IOTYPE_NETCDF4P + pio_iotype = PIO_IOTYPE_NETCDF + if (present(iotype)) then + pio_iotype = iotype + endif + + !--- initialize ice_pio_subsystem + nprocs = get_num_procs() + istride = 4 + basetask = min(1,nprocs-1) + numiotasks = max((nprocs-basetask)/istride,1) +!--tcraig this should work better but it causes pio2.4.4 to fail for reasons unknown +! numiotasks = 1 + (nprocs-basetask-1)/istride + rearranger = PIO_REARR_BOX + if (my_task == master_task) then + write(nu_diag,*) subname,' nprocs = ',nprocs + write(nu_diag,*) subname,' istride = ',istride + write(nu_diag,*) subname,' basetask = ',basetask + write(nu_diag,*) subname,' numiotasks = ',numiotasks + write(nu_diag,*) subname,' pio_iotype = ',pio_iotype + end if + + call pio_init(my_task, MPI_COMM_ICE, numiotasks, master_task, istride, & + rearranger, ice_pio_subsystem, base=basetask) + !--- initialize rearranger options + !pio_rearr_opt_comm_type = integer (PIO_REARR_COMM_[P2P,COLL]) + !pio_rearr_opt_fcd = integer, flow control (PIO_REARR_COMM_FC_[2D_ENABLE,1D_COMP2IO,1D_IO2COMP,2D_DISABLE]) + !pio_rearr_opt_c2i_enable_hs = logical + !pio_rearr_opt_c2i_enable_isend = logical + !pio_rearr_opt_c2i_max_pend_req = integer + !pio_rearr_opt_i2c_enable_hs = logical + !pio_rearr_opt_i2c_enable_isend = logical + !pio_rearr_opt_c2i_max_pend_req = integer + !ret = pio_set_rearr_opts(ice_pio_subsystem, pio_rearr_opt_comm_type,& + ! pio_rearr_opt_fcd,& + ! pio_rearr_opt_c2i_enable_hs, pio_rearr_opt_c2i_enable_isend,& + ! pio_rearr_opt_c2i_max_pend_req,& + ! pio_rearr_opt_i2c_enable_hs, pio_rearr_opt_i2c_enable_isend,& + ! pio_rearr_opt_i2c_max_pend_req) + !if(ret /= PIO_NOERR) then + ! call abort_ice(subname//'ERROR: aborting in pio_set_rearr_opts') + !end if + +#endif if (present(mode) .and. present(filename) .and. present(File)) then diff --git a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 index c207d5b25..5bb880dc5 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90 @@ -55,6 +55,8 @@ subroutine init_restart_read(ice_ic) integer (kind=int_kind) :: status + integer (kind=int_kind) :: iotype + character(len=*), parameter :: subname = '(init_restart_read)' if (present(ice_ic)) then @@ -74,9 +76,11 @@ subroutine init_restart_read(ice_ic) write(nu_diag,*) 'Using restart dump=', trim(filename) end if - if (restart_format == 'pio') then +! if (restart_format(1:3) == 'pio') then + iotype = PIO_IOTYPE_NETCDF + if (restart_format == 'pio_pnetcdf') iotype = PIO_IOTYPE_PNETCDF File%fh=-1 - call ice_pio_init(mode='read', filename=trim(filename), File=File) + call ice_pio_init(mode='read', filename=trim(filename), File=File, iotype=iotype) call ice_pio_initdecomp(iodesc=iodesc2d) call ice_pio_initdecomp(ndim3=ncat , iodesc=iodesc3d_ncat,remap=.true.) @@ -94,7 +98,7 @@ subroutine init_restart_read(ice_ic) 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,*) 'Restart read at istep=',istep0,time,time_forc @@ -160,6 +164,8 @@ 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 @@ -199,7 +205,7 @@ subroutine init_restart_write(filename_spec) iyear,'-',month,'-',mday,'-',sec end if - if (restart_format /= 'bin') filename = trim(filename) // '.nc' + if (restart_format(1:3) /= 'bin') filename = trim(filename) // '.nc' ! write pointer (path/file) if (my_task == master_task) then @@ -208,11 +214,13 @@ subroutine init_restart_write(filename_spec) close(nu_rst_pointer) endif - if (restart_format == 'pio') then +! if (restart_format(1:3) == 'pio') then + iotype = PIO_IOTYPE_NETCDF + if (restart_format == 'pio_pnetcdf') iotype = PIO_IOTYPE_PNETCDF File%fh=-1 call ice_pio_init(mode='write',filename=trim(filename), File=File, & - clobber=.true., cdf64=lcdf64 ) + clobber=.true., cdf64=lcdf64, iotype=iotype) status = pio_put_att(File,pio_global,'istep1',istep1) status = pio_put_att(File,pio_global,'time',time) @@ -631,7 +639,7 @@ subroutine init_restart_write(filename_spec) call ice_pio_initdecomp(iodesc=iodesc2d) call ice_pio_initdecomp(ndim3=ncat , iodesc=iodesc3d_ncat, remap=.true.) - endif +! endif ! restart_format if (my_task == master_task) then write(nu_diag,*) 'Writing ',filename(1:lenstr(filename)) @@ -688,7 +696,7 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & character(len=*), parameter :: subname = '(read_restart_field)' - if (restart_format == "pio") then +! if (restart_format(1:3) == "pio") then if (my_task == master_task) & write(nu_diag,*)'Parallel restart file read: ',vname @@ -747,9 +755,9 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & 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 ! restart_format end subroutine read_restart_field @@ -796,7 +804,7 @@ subroutine write_restart_field(nu,nrec,work,atype,vname,ndim3,diag) character(len=*), parameter :: subname = '(write_restart_field)' - if (restart_format == "pio") then +! if (restart_format(1:3) == "pio") then if (my_task == master_task) & write(nu_diag,*)'Parallel restart file write: ',vname @@ -835,9 +843,9 @@ subroutine write_restart_field(nu,nrec,work,atype,vname,ndim3,diag) 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 @@ -853,11 +861,9 @@ subroutine final_restart() character(len=*), parameter :: subname = '(final_restart)' - if (restart_format == 'pio') then - call PIO_freeDecomp(File,iodesc2d) - call PIO_freeDecomp(File,iodesc3d_ncat) - call pio_closefile(File) - endif + call PIO_freeDecomp(File,iodesc2d) + call PIO_freeDecomp(File,iodesc3d_ncat) + call pio_closefile(File) if (my_task == master_task) & write(nu_diag,*) 'Restart read/written ',istep1,time,time_forc diff --git a/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 b/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 index 09cffa0c7..f5e7de02f 100644 --- a/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 +++ b/cicecore/drivers/mct/cesm1/CICE_RunMod.F90 @@ -374,7 +374,7 @@ subroutine coupling_prep (iblk) 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 diff --git a/configuration/scripts/cice.build b/configuration/scripts/cice.build index 2534bfa7e..1a7f34c5e 100755 --- a/configuration/scripts/cice.build +++ b/configuration/scripts/cice.build @@ -120,8 +120,8 @@ setenv ICE_CPPDEFS " " if (${ICE_IOTYPE} == 'netcdf') then set IODIR = io_netcdf setenv ICE_CPPDEFS "${ICE_CPPDEFS} -Dncdf" -else if (${ICE_IOTYPE} == 'pio') then - set IODIR = io_pio +else if (${ICE_IOTYPE} =~ pio*) then + set IODIR = io_pio2 setenv ICE_CPPDEFS "${ICE_CPPDEFS} -Dncdf" else set IODIR = io_binary diff --git a/configuration/scripts/cice.settings b/configuration/scripts/cice.settings index 7d9bce65c..11aa5e578 100755 --- a/configuration/scripts/cice.settings +++ b/configuration/scripts/cice.settings @@ -13,7 +13,7 @@ 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_IOTYPE netcdf # set to none if netcdf library is unavailable +setenv ICE_IOTYPE netcdf # binary, netcdf, pio1, pio2 setenv ICE_CLEANBUILD true setenv ICE_QUIETMODE false setenv ICE_GRID undefined diff --git a/configuration/scripts/ice_in b/configuration/scripts/ice_in index bba1309b5..6c8fe2f36 100644 --- a/configuration/scripts/ice_in +++ b/configuration/scripts/ice_in @@ -11,7 +11,7 @@ restart = .true. restart_ext = .false. use_restart_time = .true. - restart_format = 'nc' + restart_format = 'default' lcdf64 = .false. numin = 21 numax = 89 @@ -38,6 +38,7 @@ history_dir = './history/' history_file = 'iceh' history_precision = 4 + history_format = 'default' write_ic = .true. incond_dir = './history/' incond_file = 'iceh_ic' @@ -494,7 +495,8 @@ f_fcondtopn_ai = 'x' f_fmelttn_ai = 'x' f_flatn_ai = 'x' - f_fsensn_ai = 'x' + f_fsensn_ai = 'x' + f_CMIP = 'x' / &icefields_mechred_nml diff --git a/configuration/scripts/machines/Macros.badger_intel b/configuration/scripts/machines/Macros.badger_intel index 9a92262c2..ce4eccc9c 100644 --- a/configuration/scripts/machines/Macros.badger_intel +++ b/configuration/scripts/machines/Macros.badger_intel @@ -54,10 +54,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp endif -### if using parallel I/O, load all 3 libraries. PIO must be first! -ifeq ($(ICE_IOTYPE), pio) - PIO_PATH:=/usr/projects/climate/SHARED_CLIMATE/software/conejo/pio/1.7.2/intel-13.0.1/openmpi-1.6.3/netcdf-3.6.3-parallel-netcdf-1.3.1/include - INCLDIR += -I$(PIO_PATH) - SLIBS := $(SLIBS) -L$(PIO_PATH) -lpio -endif - diff --git a/configuration/scripts/machines/Macros.cesium_intel b/configuration/scripts/machines/Macros.cesium_intel index 486ba10e4..1ab1a13de 100644 --- a/configuration/scripts/machines/Macros.cesium_intel +++ b/configuration/scripts/machines/Macros.cesium_intel @@ -58,10 +58,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -openmp endif -### if using parallel I/O, load all 3 libraries. PIO must be first! -ifeq ($(ICE_IOTYPE), pio) - PIO_PATH:=/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib - INCLDIR += -I/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/include - SLIBS := $(SLIBS) -L$(PIO_PATH) -lpiof -endif - diff --git a/configuration/scripts/machines/Macros.cheyenne_gnu b/configuration/scripts/machines/Macros.cheyenne_gnu new file mode 100644 index 000000000..657a66223 --- /dev/null +++ b/configuration/scripts/machines/Macros.cheyenne_gnu @@ -0,0 +1,78 @@ +#============================================================================== +# Makefile macros for NCAR cheyenne, gnu compiler +#============================================================================== + +CPP := ftn -E +CPPDEFS := -DFORTRANUNDERSCORE ${ICE_CPPDEFS} +CFLAGS := -c + +FIXEDFLAGS := -ffixed-line-length-132 +FREEFLAGS := -ffree-form +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 +endif + +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_CODECOV), true) + FFLAGS += -O2 + CFLAGS += -O2 +endif +endif + +SCC := gcc +SFC := gfortran +MPICC := mpicc +MPIFC := mpif90 + +ifeq ($(ICE_COMMDIR), mpi) + FC := $(MPIFC) + CC := $(MPICC) +else + FC := $(SFC) + CC := $(SCC) +endif +LD:= $(FC) + +NETCDF_PATH := $(NETCDF) + +PIO_CONFIG_OPTS:= --enable-filesystem-hints=gpfs + +#PNETCDF_PATH := $(PNETCDF) +#PNETCDF_PATH := /glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib + +INCLDIR := $(INCLDIR) + +LIB_NETCDF := $(NETCDF_PATH)/lib +#LIB_PNETCDF := $(PNETCDF_PATH)/lib +LIB_MPI := $(IMPILIBDIR) + +#SLIBS := -L$(LIB_NETCDF) -lnetcdf -lnetcdff -L$(LIB_PNETCDF) -lpnetcdf -lgptl +SLIBS := -L$(LIB_NETCDF) -lnetcdf -lnetcdff + +ifeq ($(ICE_THREADED), true) + LDFLAGS += -fopenmp + CFLAGS += -fopenmp + FFLAGS += -fopenmp +endif + +ifeq ($(ICE_IOTYPE), pio1) + LIB_PIO := $(PIO_LIBDIR) + SLIBS := $(SLIBS) -L$(LIB_PIO) -lpio +endif + +ifeq ($(ICE_IOTYPE), pio2) + CPPDEFS := $(CPPDEFS) -DGPTL + LIB_PIO := $(PIO_LIBDIR) + SLIBS := $(SLIBS) -L$(LIB_PIO) -lpiof -lpioc -lgptl +endif + diff --git a/configuration/scripts/machines/Macros.cheyenne_intel b/configuration/scripts/machines/Macros.cheyenne_intel index 86b9a1d4e..902224766 100644 --- a/configuration/scripts/machines/Macros.cheyenne_intel +++ b/configuration/scripts/machines/Macros.cheyenne_intel @@ -53,10 +53,14 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp endif -### if using parallel I/O, load all 3 libraries. PIO must be first! -ifeq ($(ICE_IOTYPE), pio) - PIO_PATH:=/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib - INCLDIR += -I/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/include - SLIBS := $(SLIBS) -L$(PIO_PATH) -lpiof +ifeq ($(ICE_IOTYPE), pio1) + LIB_PIO := $(PIO_LIBDIR) + SLIBS := $(SLIBS) -L$(LIB_PIO) -lpio +endif + +ifeq ($(ICE_IOTYPE), pio2) + CPPDEFS := $(CPPDEFS) -DGPTL + LIB_PIO := $(PIO_LIBDIR) + SLIBS := $(SLIBS) -L$(LIB_PIO) -lpiof -lpioc -lgptl endif diff --git a/configuration/scripts/machines/Macros.cheyenne_pgi b/configuration/scripts/machines/Macros.cheyenne_pgi new file mode 100644 index 000000000..c1a8a0465 --- /dev/null +++ b/configuration/scripts/machines/Macros.cheyenne_pgi @@ -0,0 +1,67 @@ +#============================================================================== +# Makefile macros for NCAR cheyenne, gnu compiler +#============================================================================== + +CPP := pgcc -Mcpp +CPPDEFS := -DFORTRANUNDERSCORE -DNO_R16 ${ICE_CPPDEFS} +CFLAGS := -c -O2 -Kieee + +FIXEDFLAGS := -Mextend +FREEFLAGS := -Mfree +FFLAGS := -Kieee -Mbyteswapio -traceback +FFLAGS_NOOPT:= -O0 + +ifeq ($(ICE_BLDDEBUG), true) +# FFLAGS += -O0 -g -Mbounds -Mchkptr + FFLAGS += -O0 -g -Mchkptr +else + FFLAGS += -O -g +endif + +SCC := pgcc +SFC := pgf90 +MPICC := mpicc +MPIFC := mpif90 + +ifeq ($(ICE_COMMDIR), mpi) + FC := $(MPIFC) + CC := $(MPICC) +else + FC := $(SFC) + CC := $(SCC) +endif +LD:= $(FC) + +NETCDF_PATH := $(NETCDF) + +PIO_CONFIG_OPTS:= --enable-filesystem-hints=gpfs + +#PNETCDF_PATH := $(PNETCDF) +#PNETCDF_PATH := /glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib + +INCLDIR := $(INCLDIR) + +LIB_NETCDF := $(NETCDF_PATH)/lib +#LIB_PNETCDF := $(PNETCDF_PATH)/lib +LIB_MPI := $(IMPILIBDIR) + +#SLIBS := -L$(LIB_NETCDF) -lnetcdf -lnetcdff -L$(LIB_PNETCDF) -lpnetcdf -lgptl +SLIBS := -L$(LIB_NETCDF) -lnetcdf -lnetcdff + +ifeq ($(ICE_THREADED), true) + LDFLAGS += -mp + CFLAGS += -mp + FFLAGS += -mp +endif + +ifeq ($(ICE_IOTYPE), pio1) + LIB_PIO := $(PIO_LIBDIR) + SLIBS := $(SLIBS) -L$(LIB_PIO) -lpio +endif + +ifeq ($(ICE_IOTYPE), pio2) + CPPDEFS := $(CPPDEFS) -DGPTL + LIB_PIO := $(PIO_LIBDIR) + SLIBS := $(SLIBS) -L$(LIB_PIO) -lpiof -lpioc -lgptl +endif + diff --git a/configuration/scripts/machines/Macros.conrad_cray b/configuration/scripts/machines/Macros.conrad_cray index f76652bed..19ddcb8f5 100644 --- a/configuration/scripts/machines/Macros.conrad_cray +++ b/configuration/scripts/machines/Macros.conrad_cray @@ -55,10 +55,3 @@ ifeq ($(ICE_THREADED), false) FFLAGS += -hnoomp 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.conrad_gnu b/configuration/scripts/machines/Macros.conrad_gnu index 2f54d753e..5459d9b6b 100644 --- a/configuration/scripts/machines/Macros.conrad_gnu +++ b/configuration/scripts/machines/Macros.conrad_gnu @@ -53,10 +53,3 @@ 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.conrad_intel b/configuration/scripts/machines/Macros.conrad_intel index a5cb37a5c..74a36304d 100644 --- a/configuration/scripts/machines/Macros.conrad_intel +++ b/configuration/scripts/machines/Macros.conrad_intel @@ -54,10 +54,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp 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.conrad_pgi b/configuration/scripts/machines/Macros.conrad_pgi index 29bcda360..ef0a25ab4 100644 --- a/configuration/scripts/machines/Macros.conrad_pgi +++ b/configuration/scripts/machines/Macros.conrad_pgi @@ -53,10 +53,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -mp 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.cori_intel b/configuration/scripts/machines/Macros.cori_intel index 8e006e4cc..93eccaacb 100644 --- a/configuration/scripts/machines/Macros.cori_intel +++ b/configuration/scripts/machines/Macros.cori_intel @@ -53,10 +53,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp 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.fram_intel b/configuration/scripts/machines/Macros.fram_intel index 27681178e..5804b1475 100644 --- a/configuration/scripts/machines/Macros.fram_intel +++ b/configuration/scripts/machines/Macros.fram_intel @@ -58,10 +58,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -openmp endif -### if using parallel I/O, load all 3 libraries. PIO must be first! -ifeq ($(ICE_IOTYPE), pio) - PIO_PATH:=/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib - INCLDIR += -I/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/include - SLIBS := $(SLIBS) -L$(PIO_PATH) -lpiof -endif - diff --git a/configuration/scripts/machines/Macros.gaffney_gnu b/configuration/scripts/machines/Macros.gaffney_gnu index 0d13560de..87b489ae1 100644 --- a/configuration/scripts/machines/Macros.gaffney_gnu +++ b/configuration/scripts/machines/Macros.gaffney_gnu @@ -66,10 +66,3 @@ 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.gaffney_intel b/configuration/scripts/machines/Macros.gaffney_intel index bfad4b54c..61dfe2518 100644 --- a/configuration/scripts/machines/Macros.gaffney_intel +++ b/configuration/scripts/machines/Macros.gaffney_intel @@ -55,10 +55,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp 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.gordon_cray b/configuration/scripts/machines/Macros.gordon_cray index 4f9c43da1..6c5032e0d 100644 --- a/configuration/scripts/machines/Macros.gordon_cray +++ b/configuration/scripts/machines/Macros.gordon_cray @@ -55,10 +55,3 @@ ifeq ($(ICE_THREADED), false) FFLAGS += -hnoomp 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.gordon_gnu b/configuration/scripts/machines/Macros.gordon_gnu index 2e80f7364..61c81f936 100644 --- a/configuration/scripts/machines/Macros.gordon_gnu +++ b/configuration/scripts/machines/Macros.gordon_gnu @@ -65,10 +65,3 @@ 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.gordon_intel b/configuration/scripts/machines/Macros.gordon_intel index 73214ec26..84659d00a 100644 --- a/configuration/scripts/machines/Macros.gordon_intel +++ b/configuration/scripts/machines/Macros.gordon_intel @@ -53,10 +53,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp 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.gordon_pgi b/configuration/scripts/machines/Macros.gordon_pgi index 45d03c64f..1190f6eca 100644 --- a/configuration/scripts/machines/Macros.gordon_pgi +++ b/configuration/scripts/machines/Macros.gordon_pgi @@ -53,10 +53,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -mp 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.hobart_intel b/configuration/scripts/machines/Macros.hobart_intel index f5b3044b0..f4dbedacf 100644 --- a/configuration/scripts/machines/Macros.hobart_intel +++ b/configuration/scripts/machines/Macros.hobart_intel @@ -40,10 +40,3 @@ LIB_MPI := $(IMPILIBDIR) SLIBS := -L$(LIB_NETCDF) -lnetcdf -lnetcdff -L/usr/lib64 -llapack -mkl=cluster -## 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.hobart_nag b/configuration/scripts/machines/Macros.hobart_nag index 2ed098893..998008972 100644 --- a/configuration/scripts/machines/Macros.hobart_nag +++ b/configuration/scripts/machines/Macros.hobart_nag @@ -40,9 +40,3 @@ LIB_MPI := $(IMPILIBDIR) SLIBS := -L/usr/local/nag-6.2/lib/NAG_Fortran -L$(LIB_NETCDF) -lnetcdf -lnetcdff -L/usr/lib64 -llapack -lblas -## 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) -lpiof -endif diff --git a/configuration/scripts/machines/Macros.izumi_gnu b/configuration/scripts/machines/Macros.izumi_gnu index cdc6620f4..7f2f4739e 100644 --- a/configuration/scripts/machines/Macros.izumi_gnu +++ b/configuration/scripts/machines/Macros.izumi_gnu @@ -55,10 +55,3 @@ 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.izumi_intel b/configuration/scripts/machines/Macros.izumi_intel index 0aee3cdd5..d4ace1d52 100644 --- a/configuration/scripts/machines/Macros.izumi_intel +++ b/configuration/scripts/machines/Macros.izumi_intel @@ -43,10 +43,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp 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.izumi_nag b/configuration/scripts/machines/Macros.izumi_nag index 3246635bc..c12edb904 100644 --- a/configuration/scripts/machines/Macros.izumi_nag +++ b/configuration/scripts/machines/Macros.izumi_nag @@ -45,9 +45,3 @@ else FFLAGS += -gline 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) -lpiof -endif diff --git a/configuration/scripts/machines/Macros.izumi_pgi b/configuration/scripts/machines/Macros.izumi_pgi index 31eca6039..f89ae78c8 100644 --- a/configuration/scripts/machines/Macros.izumi_pgi +++ b/configuration/scripts/machines/Macros.izumi_pgi @@ -43,10 +43,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -mp 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.koehr_intel b/configuration/scripts/machines/Macros.koehr_intel index d77e90768..284d30c55 100644 --- a/configuration/scripts/machines/Macros.koehr_intel +++ b/configuration/scripts/machines/Macros.koehr_intel @@ -55,10 +55,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp 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.millikan_intel b/configuration/scripts/machines/Macros.millikan_intel index 7bdaac0e6..bf92256f5 100644 --- a/configuration/scripts/machines/Macros.millikan_intel +++ b/configuration/scripts/machines/Macros.millikan_intel @@ -58,10 +58,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -openmp endif -### if using parallel I/O, load all 3 libraries. PIO must be first! -ifeq ($(ICE_IOTYPE), pio) - PIO_PATH:=/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib - INCLDIR += -I/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/include - SLIBS := $(SLIBS) -L$(PIO_PATH) -lpiof -endif - diff --git a/configuration/scripts/machines/Macros.onyx_cray b/configuration/scripts/machines/Macros.onyx_cray index aa185e2e5..6753a78e5 100644 --- a/configuration/scripts/machines/Macros.onyx_cray +++ b/configuration/scripts/machines/Macros.onyx_cray @@ -54,10 +54,3 @@ ifeq ($(ICE_THREADED), false) FFLAGS += -hnoomp 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 d423cd9ab..93de0a55d 100644 --- a/configuration/scripts/machines/Macros.onyx_gnu +++ b/configuration/scripts/machines/Macros.onyx_gnu @@ -65,10 +65,3 @@ 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_intel b/configuration/scripts/machines/Macros.onyx_intel index b7f685ac1..55f6fbbf5 100644 --- a/configuration/scripts/machines/Macros.onyx_intel +++ b/configuration/scripts/machines/Macros.onyx_intel @@ -53,10 +53,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp 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.phase2_intel b/configuration/scripts/machines/Macros.phase2_intel index 962aa84a6..9e74e0d44 100644 --- a/configuration/scripts/machines/Macros.phase2_intel +++ b/configuration/scripts/machines/Macros.phase2_intel @@ -49,9 +49,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp endif -### if using parallel I/O, load all 3 libraries. PIO must be first! -#ifeq ($(ICE_IOTYPE), pio) -# PIO_PATH:=/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib -# INCLDIR += -I/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/include -# SLIBS := $(SLIBS) -L$(PIO_PATH) -lpiof -#endif diff --git a/configuration/scripts/machines/Macros.phase3_intel b/configuration/scripts/machines/Macros.phase3_intel index 076b2aab1..de08fdfe0 100644 --- a/configuration/scripts/machines/Macros.phase3_intel +++ b/configuration/scripts/machines/Macros.phase3_intel @@ -50,9 +50,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp endif -### if using parallel I/O, load all 3 libraries. PIO must be first! -#ifeq ($(ICE_IOTYPE), pio) -# PIO_PATH:=/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib -# INCLDIR += -I/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/include -# SLIBS := $(SLIBS) -L$(PIO_PATH) -lpiof -#endif diff --git a/configuration/scripts/machines/Macros.testmachine_intel b/configuration/scripts/machines/Macros.testmachine_intel index 20c1f3610..9212cb384 100644 --- a/configuration/scripts/machines/Macros.testmachine_intel +++ b/configuration/scripts/machines/Macros.testmachine_intel @@ -52,10 +52,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp endif -### if using parallel I/O, load all 3 libraries. PIO must be first! -ifeq ($(ICE_IOTYPE), pio) - PIO_PATH:=/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/lib - INCLDIR += -I/glade/u/apps/ch/opt/pio/2.2/mpt/2.15f/intel/17.0.1/include - SLIBS := $(SLIBS) -L$(PIO_PATH) -lpiof -endif - diff --git a/configuration/scripts/machines/Macros.thunder_intel b/configuration/scripts/machines/Macros.thunder_intel index 581e31909..7163fb883 100644 --- a/configuration/scripts/machines/Macros.thunder_intel +++ b/configuration/scripts/machines/Macros.thunder_intel @@ -54,10 +54,3 @@ ifeq ($(ICE_THREADED), true) FFLAGS += -qopenmp 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/env.cheyenne_gnu b/configuration/scripts/machines/env.cheyenne_gnu new file mode 100755 index 000000000..f8f139dc0 --- /dev/null +++ b/configuration/scripts/machines/env.cheyenne_gnu @@ -0,0 +1,43 @@ +#!/bin/csh -f + +set inp = "undefined" +if ($#argv == 1) then + set inp = $1 +endif + +if ("$inp" != "-nomodules") then + +source /glade/u/apps/ch/opt/lmod/7.2.1/lmod/7.2.1/init/csh + +module purge +module load ncarenv/1.2 +module load gnu/8.3.0 +module load mpt/2.19 +module load ncarcompilers/0.5.0 +module load netcdf/4.6.3 + +if ($ICE_IOTYPE =~ pio*) then + module unload netcdf + module load netcdf-mpi/4.6.3 + module load pnetcdf/1.11.1 + if ($ICE_IOTYPE == "pio1") then + module load pio/1.10.1 + else + module load pio/2.4.4 + endif +endif + +endif + +setenv ICE_MACHINE_ENVNAME cheyenne +setenv ICE_MACHINE_COMPILER gnu +setenv ICE_MACHINE_MAKE gmake +setenv ICE_MACHINE_WKDIR /glade/scratch/$user/CICE_RUNS +setenv ICE_MACHINE_INPUTDATA /glade/p/cesm/pcwg_dev +setenv ICE_MACHINE_BASELINE /glade/scratch/$user/CICE_BASELINE +setenv ICE_MACHINE_SUBMIT "qsub" +setenv ICE_MACHINE_ACCT P00000000 +setenv ICE_MACHINE_QUEUE "regular" +setenv ICE_MACHINE_TPNODE 36 +setenv ICE_MACHINE_BLDTHRDS 1 +setenv ICE_MACHINE_QSTAT "qstat " diff --git a/configuration/scripts/machines/env.cheyenne_intel b/configuration/scripts/machines/env.cheyenne_intel index e05c51db2..82cfd3aeb 100755 --- a/configuration/scripts/machines/env.cheyenne_intel +++ b/configuration/scripts/machines/env.cheyenne_intel @@ -16,6 +16,17 @@ module load mpt/2.19 module load ncarcompilers/0.5.0 module load netcdf/4.6.3 +if ($ICE_IOTYPE =~ pio*) then + module unload netcdf + module load netcdf-mpi/4.6.3 + module load pnetcdf/1.11.1 + if ($ICE_IOTYPE == "pio1") then + module load pio/1.10.1 + else + module load pio/2.4.4 + endif +endif + endif setenv ICE_MACHINE_ENVNAME cheyenne diff --git a/configuration/scripts/machines/env.cheyenne_pgi b/configuration/scripts/machines/env.cheyenne_pgi new file mode 100755 index 000000000..864c907e3 --- /dev/null +++ b/configuration/scripts/machines/env.cheyenne_pgi @@ -0,0 +1,43 @@ +#!/bin/csh -f + +set inp = "undefined" +if ($#argv == 1) then + set inp = $1 +endif + +if ("$inp" != "-nomodules") then + +source /glade/u/apps/ch/opt/lmod/7.2.1/lmod/7.2.1/init/csh + +module purge +module load ncarenv/1.2 +module load pgi/19.9 +module load mpt/2.21 +module load ncarcompilers/0.5.0 +module load netcdf/4.7.3 + +if ($ICE_IOTYPE =~ pio*) then + module unload netcdf + module load netcdf-mpi/4.7.3 + module load pnetcdf/1.12.1 + if ($ICE_IOTYPE == "pio1") then + module load pio/1.10.1 + else + module load pio/2.4.4 + endif +endif + +endif + +setenv ICE_MACHINE_ENVNAME cheyenne +setenv ICE_MACHINE_COMPILER pgi +setenv ICE_MACHINE_MAKE gmake +setenv ICE_MACHINE_WKDIR /glade/scratch/$user/CICE_RUNS +setenv ICE_MACHINE_INPUTDATA /glade/p/cesm/pcwg_dev +setenv ICE_MACHINE_BASELINE /glade/scratch/$user/CICE_BASELINE +setenv ICE_MACHINE_SUBMIT "qsub" +setenv ICE_MACHINE_ACCT P00000000 +setenv ICE_MACHINE_QUEUE "regular" +setenv ICE_MACHINE_TPNODE 36 +setenv ICE_MACHINE_BLDTHRDS 1 +setenv ICE_MACHINE_QSTAT "qstat " diff --git a/configuration/scripts/options/set_env.ionetcdf b/configuration/scripts/options/set_env.ionetcdf new file mode 100644 index 000000000..1824dde94 --- /dev/null +++ b/configuration/scripts/options/set_env.ionetcdf @@ -0,0 +1 @@ +setenv ICE_IOTYPE netcdf diff --git a/configuration/scripts/options/set_env.iopio1 b/configuration/scripts/options/set_env.iopio1 new file mode 100644 index 000000000..8357b4aac --- /dev/null +++ b/configuration/scripts/options/set_env.iopio1 @@ -0,0 +1 @@ +setenv ICE_IOTYPE pio1 diff --git a/configuration/scripts/options/set_env.iopio1p b/configuration/scripts/options/set_env.iopio1p new file mode 100644 index 000000000..8357b4aac --- /dev/null +++ b/configuration/scripts/options/set_env.iopio1p @@ -0,0 +1 @@ +setenv ICE_IOTYPE pio1 diff --git a/configuration/scripts/options/set_env.iopio2 b/configuration/scripts/options/set_env.iopio2 new file mode 100644 index 000000000..415005ac4 --- /dev/null +++ b/configuration/scripts/options/set_env.iopio2 @@ -0,0 +1 @@ +setenv ICE_IOTYPE pio2 diff --git a/configuration/scripts/options/set_env.iopio2p b/configuration/scripts/options/set_env.iopio2p new file mode 100644 index 000000000..415005ac4 --- /dev/null +++ b/configuration/scripts/options/set_env.iopio2p @@ -0,0 +1 @@ +setenv ICE_IOTYPE pio2 diff --git a/configuration/scripts/options/set_nml.box2001 b/configuration/scripts/options/set_nml.box2001 index 0b4b9645a..79382d84e 100755 --- a/configuration/scripts/options/set_nml.box2001 +++ b/configuration/scripts/options/set_nml.box2001 @@ -3,7 +3,6 @@ npt = 240 ice_ic = 'default' restart = .false. restart_ext = .true. -restart_format = 'bin' histfreq = 'd','x','x','x','x' grid_type = 'rectangular' dxrect = 16.e5 diff --git a/configuration/scripts/options/set_nml.boxdyn b/configuration/scripts/options/set_nml.boxdyn index 118d93d79..1b74720c7 100644 --- a/configuration/scripts/options/set_nml.boxdyn +++ b/configuration/scripts/options/set_nml.boxdyn @@ -3,7 +3,6 @@ ice_ic = 'default' restart = .false. days_per_year = 360 npt = 72 -restart_format = 'bin' dumpfreq = 'd' dumpfreq_n = 2 histfreq = 'd','x','x','x','x' diff --git a/configuration/scripts/options/set_nml.cdf64 b/configuration/scripts/options/set_nml.cdf64 new file mode 100644 index 000000000..0fd700c64 --- /dev/null +++ b/configuration/scripts/options/set_nml.cdf64 @@ -0,0 +1 @@ +lcdf64 = .true. diff --git a/configuration/scripts/options/set_nml.histall b/configuration/scripts/options/set_nml.histall new file mode 100644 index 000000000..5fad1a7e2 --- /dev/null +++ b/configuration/scripts/options/set_nml.histall @@ -0,0 +1,224 @@ + histfreq = 'm','d','1','x','x' + histfreq_n = 1,1,6,1,1 + write_ic = .true. + f_tmask = .true. + f_blkmask = .true. + f_tarea = .true. + f_uarea = .true. + f_dxt = .true. + f_dyt = .true. + f_dxu = .true. + f_dyu = .true. + f_HTN = .true. + f_HTE = .true. + f_ANGLE = .true. + f_ANGLET = .true. + f_NCAT = .true. + f_VGRDi = .true. + f_VGRDs = .true. + f_VGRDb = .true. + f_VGRDa = .true. + f_bounds = .true. + f_CMIP = 'm' + f_aice = 'md1' + f_hi = '1dm' + f_hs = 'd1m' + f_Tsfc = 'md' + f_sice = 'md' + f_uvel = 'md' + f_vvel = 'dm' + f_uatm = 'dm' + f_vatm = 'dm' + f_fswdn = 'dm' + f_flwdn = 'md' + f_snowfrac = 'md' + f_snow = 'md' + f_snow_ai = 'md' + f_rain = 'md' + f_rain_ai = 'md' + f_sst = 'md' + f_sss = 'md' + f_uocn = 'md' + f_vocn = 'md' + f_frzmlt = 'md' + f_fswfac = 'md' + f_fswint_ai = 'md' + f_fswabs = 'md' + f_fswabs_ai = 'md' + f_albsni = 'md' + f_alvdr = 'md' + f_alidr = 'md' + f_alvdf = 'md' + f_alidf = 'md' + f_alvdr_ai = 'md' + f_alidr_ai = 'md' + f_alvdf_ai = 'md' + f_alidf_ai = 'md' + f_albice = 'md' + f_albsno = 'md' + f_albpnd = 'md' + f_coszen = 'md' + f_flat = 'md' + f_flat_ai = 'md' + f_fsens = 'md' + f_fsens_ai = 'md' + f_fswup = 'md' + f_flwup = 'md' + f_flwup_ai = 'md' + f_evap = 'md' + f_evap_ai = 'md' + f_Tair = 'md' + f_Tref = 'md' + f_Qref = 'md' + f_congel = 'md' + f_frazil = 'md' + f_snoice = 'md' + f_dsnow = 'md' + f_melts = 'md' + f_meltt = 'md' + f_meltb = 'md' + f_meltl = 'md' + f_fresh = 'md' + f_fresh_ai = 'md' + f_fsalt = 'md' + f_fsalt_ai = 'md' + f_fbot = 'md' + f_fhocn = 'md' + f_fhocn_ai = 'md' + f_fswthru = 'md' + f_fswthru_ai = 'md' + f_fsurf_ai = 'md' + f_fcondtop_ai = 'md' + f_fmeltt_ai = 'md' + f_strairx = 'md' + f_strairy = 'md' + f_strtltx = 'md' + f_strtlty = 'md' + f_strcorx = 'md' + f_strcory = 'md' + f_strocnx = 'md' + f_strocny = 'md' + f_strintx = 'md' + f_strinty = 'md' + f_taubx = 'md' + f_tauby = 'md' + f_strength = 'md' + f_divu = 'md' + f_shear = 'md' + f_sig1 = 'md' + f_sig2 = 'md' + f_sigP = 'md' + f_dvidtt = 'md' + f_dvidtd = 'md' + f_daidtt = 'md' + f_daidtd = 'md' + f_dagedtt = 'md' + f_dagedtd = 'md' + f_mlt_onset = 'md' + f_frz_onset = 'md' + f_hisnap = 'md' + f_aisnap = 'md' + f_trsig = 'md' + f_icepresent = 'md' + f_iage = 'md' + f_FY = 'md' + f_aicen = 'md' + f_vicen = 'md' + f_vsnon = 'md' + f_snowfracn = 'md' + f_keffn_top = 'md' + f_Tinz = 'md' + f_Sinz = 'md' + f_Tsnz = 'md' + f_fsurfn_ai = 'md' + f_fcondtopn_ai = 'md' + f_fmelttn_ai = 'md' + f_flatn_ai = 'md' + f_fsensn_ai = 'md' + f_alvl = 'md' + f_vlvl = 'md' + f_ardg = 'md' + f_vrdg = 'md' + f_dardg1dt = 'md' + f_dardg2dt = 'md' + f_dvirdgdt = 'md' + f_opening = 'md' + f_ardgn = 'md' + f_vrdgn = 'md' + f_dardg1ndt = 'md' + f_dardg2ndt = 'md' + f_dvirdgndt = 'md' + f_krdgn = 'md' + f_aparticn = 'md' + f_aredistn = 'md' + f_vredistn = 'md' + f_araftn = 'md' + f_vraftn = 'md' + f_apondn = 'md' + f_apeffn = 'md' + f_hpondn = 'md' + f_apond = 'md' + f_hpond = 'md' + f_ipond = 'md' + f_apeff = 'md' + f_apond_ai = 'md' + f_hpond_ai = 'md' + f_ipond_ai = 'md' + f_apeff_ai = 'md' + f_fiso_atm = 'md' + f_fiso_ocn = 'md' + f_iso = 'md' + f_faero_atm = 'md' + f_faero_ocn = 'md' + f_aero = 'md' + f_fbio = 'md' + f_fbio_ai = 'md' + f_zaero = 'md' + f_bgc_S = 'md' + f_bgc_N = 'md' + f_bgc_C = 'md' + f_bgc_DOC = 'md' + f_bgc_DIC = 'md' + f_bgc_chl = 'md' + f_bgc_Nit = 'md' + f_bgc_Am = 'md' + f_bgc_Sil = 'md' + f_bgc_DMSPp = 'md' + f_bgc_DMSPd = 'md' + f_bgc_DMS = 'md' + f_bgc_DON = 'md' + f_bgc_Fe = 'md' + f_bgc_hum = 'md' + f_bgc_PON = 'md' + f_bgc_ml = 'md' + f_upNO = 'md' + f_upNH = 'md' + f_bTin = 'md' + f_bphi = 'md' + f_iDi = 'md' + f_iki = 'md' + f_fbri = 'md' + f_hbri = 'md' + f_zfswin = 'md' + f_bionet = 'md' + f_biosnow = 'md' + f_grownet = 'md' + f_PPnet = 'md' + f_algalpeak = 'md' + f_zbgc_frac = 'md' + f_drag = 'md' + f_Cdn_atm = 'md' + f_Cdn_ocn = 'md' + f_fsdrad = 'md' + f_fsdperim = 'md' + f_afsd = 'md' + f_afsdn = 'md' + f_dafsd_newi = 'md' + f_dafsd_latg = 'md' + f_dafsd_latm = 'md' + f_dafsd_wave = 'md' + f_dafsd_weld = 'md' + f_wave_sig_ht = 'md' + f_aice_ww = 'md' + f_diam_ww = 'md' + f_hice_ww = 'md' diff --git a/configuration/scripts/options/set_nml.iopio1 b/configuration/scripts/options/set_nml.iopio1 new file mode 100644 index 000000000..655f2c96b --- /dev/null +++ b/configuration/scripts/options/set_nml.iopio1 @@ -0,0 +1,2 @@ +restart_format = 'pio_netcdf' +history_format = 'pio_netcdf' diff --git a/configuration/scripts/options/set_nml.iopio1p b/configuration/scripts/options/set_nml.iopio1p new file mode 100644 index 000000000..83c422403 --- /dev/null +++ b/configuration/scripts/options/set_nml.iopio1p @@ -0,0 +1,2 @@ +restart_format = 'pio_pnetcdf' +history_format = 'pio_pnetcdf' diff --git a/configuration/scripts/options/set_nml.iopio2 b/configuration/scripts/options/set_nml.iopio2 new file mode 100644 index 000000000..655f2c96b --- /dev/null +++ b/configuration/scripts/options/set_nml.iopio2 @@ -0,0 +1,2 @@ +restart_format = 'pio_netcdf' +history_format = 'pio_netcdf' diff --git a/configuration/scripts/options/set_nml.iopio2p b/configuration/scripts/options/set_nml.iopio2p new file mode 100644 index 000000000..e4cce54af --- /dev/null +++ b/configuration/scripts/options/set_nml.iopio2p @@ -0,0 +1,2 @@ +restart_format = 'pio_pnetcdf' +history_format = 'pio_netcdf' diff --git a/configuration/scripts/tests/base_suite.ts b/configuration/scripts/tests/base_suite.ts index f2ac2b69b..e96b07622 100755 --- a/configuration/scripts/tests/base_suite.ts +++ b/configuration/scripts/tests/base_suite.ts @@ -8,11 +8,9 @@ smoke gx3 8x2 diag24,run1year,medium 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 gx1 40x4 droundrobin,medium +restart tx1 40x4 dsectrobin,medium restart gx3 4x4 none -restart gx3 4x4 iobinary -restart gx3 4x4 precision8 restart gx3 6x2 alt01 restart gx3 8x2 alt02 restart gx3 4x2 alt03 @@ -23,24 +21,24 @@ restart gx3 8x2 alt02,debug,short restart gx3 4x2 alt03,debug,short smoke gx3 4x4 alt04,debug,short smoke gx3 4x4 alt05,debug,short -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 +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 bgcz,debug smoke gx3 8x1 bgcskl,debug #smoke gx3 4x1 bgcz,thread smoke_gx3_8x2_bgcz restart gx1 4x2 bgcsklclim,medium restart gx1 8x1 bgczclim,medium -smoke gx1 24x1 jra55_gx1_2008,medium,run90day +smoke gx1 24x1 jra55_gx1_2008,medium,run90day smoke gx3 8x1 jra55_gx3_2008,medium,run90day -restart gx1 24x1 jra55_gx1,short +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,short @@ -48,4 +46,7 @@ restart gx3 4x2 fsd12,debug,short smoke gx3 8x2 fsd12ww3,diag24,run1day,medium smoke gx3 4x1 isotope,debug restart gx3 8x2 isotope - +restart gx3 4x4 iobinary +restart gx3 4x4 histall,precision8,cdf64 +smoke gx3 30x1 bgcz,histall +smoke gx3 14x2 fsd12,histall diff --git a/configuration/scripts/tests/io_suite.ts b/configuration/scripts/tests/io_suite.ts new file mode 100755 index 000000000..c1edec292 --- /dev/null +++ b/configuration/scripts/tests/io_suite.ts @@ -0,0 +1,67 @@ +# Test Grid PEs Sets BFB-compare +restart gx3 8x4 debug,histall,iobinary,precision8 +restart gx3 12x2 alt01,histall,iobinary +restart gx3 16x2 alt02,histall,iobinary,precision8 +restart gx3 4x2 alt03,histall,iobinary +restart gx3 8x4 alt04,histall,iobinary,precision8 +restart gx3 4x4 alt05,histall,iobinary +restart gx3 32x1 bgcz,histall,iobinary,precision8 +restart gx3 16x2 bgcskl,histall,iobinary +restart gx3 14x2 isotope,histall,iobinary,precision8 +restart gx3 16x2 fsd12,histall,iobinary + +restart gx3 32x1 debug,histall,ionetcdf +restart gx3 15x2 alt01,histall,ionetcdf,precision8,cdf64 +restart gx3 15x2 alt02,histall,ionetcdf +restart gx3 24x1 alt03,histall,ionetcdf,precision8 +restart gx3 8x4 alt04,histall,ionetcdf,cdf64 +restart gx3 8x4 alt05,histall,ionetcdf,precision8,cdf64 +restart gx3 30x1 bgcz,histall,ionetcdf +restart gx3 15x2 bgcskl,histall,ionetcdf,precision8 +restart gx3 31x1 isotope,histall,ionetcdf,cdf64 +restart gx3 14x2 fsd12,histall,ionetcdf,precision8 + +restart gx3 16x2 debug,histall,iopio1,precision8,cdf64 +restart gx3 14x2 alt01,histall,iopio1,cdf64 +restart gx3 32x1 alt02,histall,iopio1,precision8 +restart gx3 24x1 alt03,histall,iopio1 +restart gx3 8x4 alt04,histall,iopio1,precision8,cdf64 +restart gx3 8x4 alt05,histall,iopio1,cdf64 +restart gx3 16x2 bgcz,histall,iopio1,precision8 +restart gx3 30x1 bgcskl,histall,iopio1 +restart gx3 8x4 isotope,histall,iopio1,precision8,cdf64 +restart gx3 12x2 fsd12,histall,iopio1,cdf64 + +restart gx3 16x2 debug,histall,iopio2 +restart gx3 14x2 alt01,histall,iopio2,precision8,cdf64 +restart gx3 32x1 alt02,histall,iopio2,cdf64 +restart gx3 24x1 alt03,histall,iopio2,precision8 +restart gx3 8x4 alt04,histall,iopio2 +restart gx3 8x4 alt05,histall,iopio2,precision8,cdf64 +restart gx3 16x2 bgcz,histall,iopio2,cdf64 +restart gx3 30x1 bgcskl,histall,iopio2,precision8 +restart gx3 8x4 isotope,histall,iopio2 +restart gx3 12x2 fsd12,histall,iopio2,precision8,cdf64 + +restart gx3 16x2 debug,histall,iopio1p,precision8 +restart gx3 14x2 alt01,histall,iopio1p +restart gx3 32x1 alt02,histall,iopio1p,precision8,cdf64 +restart gx3 24x1 alt03,histall,iopio1p,cdf64 +restart gx3 8x4 alt04,histall,iopio1p,precision8 +restart gx3 8x4 alt05,histall,iopio1p +restart gx3 16x2 bgcz,histall,iopio1p,precision8,cdf64 +restart gx3 30x1 bgcskl,histall,iopio1p,cdf64 +restart gx3 8x4 isotope,histall,iopio1p,precision8 +restart gx3 12x2 fsd12,histall,iopio1p + +restart gx3 16x2 debug,histall,iopio2p,cdf64 +restart gx3 14x2 alt01,histall,iopio2p,precision8 +restart gx3 32x1 alt02,histall,iopio2p +restart gx3 24x1 alt03,histall,iopio2p,precision8,cdf64 +restart gx3 8x4 alt04,histall,iopio2p,cdf64 +restart gx3 8x4 alt05,histall,iopio2p,precision8 +restart gx3 16x2 bgcz,histall,iopio2p +restart gx3 30x1 bgcskl,histall,iopio2p,precision8,cdf64 +restart gx3 8x4 isotope,histall,iopio2p,cdf64 +restart gx3 12x2 fsd12,histall,iopio2p,precision8 + diff --git a/doc/source/cice_index.rst b/doc/source/cice_index.rst index 5111df406..dd4926e16 100644 --- a/doc/source/cice_index.rst +++ b/doc/source/cice_index.rst @@ -22,9 +22,11 @@ either Celsius or Kelvin units). "a3Dz", "history field accumulations, 3D vertical", "" "a3Db", "history field accumulations, 3D bio grid", "" "a3Dc", "history field accumulations, 3D categories", "" + "a3Df", "history field accumulations, 3D fsd", "" "a4Di", "history field accumulations, 4D categories, vertical ice", "" "a4Db", "history field accumulations, 4D categories, vertical bio grid", "" "a4Ds", "history field accumulations, 4D categories, vertical snow", "" + "a4Df", "history field accumulations, 4D categories, fsd", "" "a_min", "minimum area concentration for computing velocity", "0.001" "a_rapid_mode", ":math:`{\bullet}` brine channel diameter", "" "advection", ":math:`\bullet` type of advection algorithm used (‘remap’ or ‘upwind’)", "remap" @@ -274,6 +276,7 @@ either Celsius or Kelvin units). "histfreq_n", ":math:`\bullet` integer output frequency in histfreq units", "" "history_dir", ":math:`\bullet` path to history output files", "" "history_file", ":math:`\bullet` history output file prefix", "" + "history_format", ":math:`\bullet` history file format", "" "history_precision", ":math:`\bullet` history output precision: 4 or 8 byte", "4" "hm", "land/boundary mask, thickness (T-cell)", "" "hmix", "ocean mixed layer depth", "20. m" diff --git a/doc/source/user_guide/ug_case_settings.rst b/doc/source/user_guide/ug_case_settings.rst index 4e185d151..bc05359fa 100755 --- a/doc/source/user_guide/ug_case_settings.rst +++ b/doc/source/user_guide/ug_case_settings.rst @@ -99,8 +99,9 @@ Table of namelist options "","", "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", "" + "","``restart_format``", "string", "restart file format", "default" + "","", "default", "read/write restart files in default format", "" + "","", "pio_pnetcdf", "read/write restart files with pnetcdf in pio", "" "","``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" @@ -141,6 +142,9 @@ Table of namelist options "","``history_dir``", "path/", "path to history output directory", "" "","``history_file``", "filename prefix", "output file for history", "‘iceh’" "","``history_precision``", "integer", "history file precision: 4 or 8 byte", "4" + "","``history_format``", "string", "history file format", "default" + "","", "default", "read/write restart files in default format", "" + "","", "pio_pnetcdf", "read/write restart files with pnetcdf in pio", "" "","``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’" diff --git a/doc/source/user_guide/ug_implementation.rst b/doc/source/user_guide/ug_implementation.rst index b144b32f2..b7d9c0f47 100644 --- a/doc/source/user_guide/ug_implementation.rst +++ b/doc/source/user_guide/ug_implementation.rst @@ -701,6 +701,15 @@ Model output History files ************* +CICE provides history data in binary unformatted or netCDF formats via +separate implementations of binary, netcdf, and pio source code under the +directory **infrastructure/io**. ``ICE_IOTYPE`` defined in cice.settings +specifies the IO type and defines which source code directory is compiled. +At the present time, binary, netcdf, and PIO are exclusive formats +for history and restart files, and history and restart file must use the same +io package. The namelist variable ``history_format`` further refines the +format approach or style for some io packages. + Model output data is averaged over the period(s) given by ``histfreq`` and ``histfreq_n``, and written to binary or netCDF files prepended by ``history_file`` in **ice_in**. These settings for history files are set in the @@ -711,7 +720,7 @@ depending on the output file format chosen in **cice.settings** (set ``ICE_IOTYPE``). The netCDF history files are CF-compliant; header information for data contained in the netCDF files is displayed with the command ``ncdump -h filename.nc``. Parallel netCDF output is available using the PIO library; the -attribute ``io_flavor`` distinguishes output files written with PIO from +output file attribute ``io_flavor`` distinguishes output files written with PIO from those written with standard netCDF. With binary files, a separate header file is written with equivalent information. Standard fields are output according to settings in the **icefields\_nml** section of **ice\_in** @@ -893,11 +902,14 @@ The timers use *MPI\_WTIME* for parallel runs and the F90 intrinsic Restart files ************* -CICE provides restart data in binary unformatted or netCDF formats, via -the ``ICE_IOTYPE`` flag in **cice.settings** and namelist variable -``restart_format``. Restart and history files must use the same format. As -with the history output, there is also an option for writing parallel netCDF -restart files using PIO. +CICE provides restart data in binary unformatted or netCDF formats via +separate implementations of binary, netcdf, and pio source code under the +directory **infrastructure/io**. ``ICE_IOTYPE`` defined in cice.settings +specifies the IO type and defines which source code directory is compiled. +At the present time, binary, netcdf, and PIO are exclusive formats +for history and restart files, and history and restart file must use the same +io package. The namelist variable ``restart_format`` further refines the +format approach or style for some io packages. The restart files created by CICE contain all of the variables needed for a full, exact restart. The filename begins with the character string From c1eef871c450e0b422aef2803632ff386999d270 Mon Sep 17 00:00:00 2001 From: Philippe Blain Date: Tue, 26 May 2020 15:48:37 -0400 Subject: [PATCH 16/19] scripts: add support for setting `ICE_CPPDEFS` in set_env.* options (#448) * cice.setup: remove deprecated variables from cice.settings.mods Let's not keep these commented variables in cice.settings.mods, they've been in the namelist for a while now. * cice.batch.csh: uniformize script output with other scripts Other scripts called by cice.setup output "running