From 0b2e4f350ee4895a25bbd34861bb84a00f9f881b Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Wed, 4 Dec 2024 22:53:33 +0100 Subject: [PATCH 01/25] refactoring bitsea imports --- .../float_preproc/float_extractor.py | 18 ++++++------- .../float_preproc/merge_arg_mis.py | 2 +- .../external_scripts/float_preproc/preproc.py | 25 +++++++++---------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/DA/external_scripts/float_preproc/float_extractor.py b/src/DA/external_scripts/float_preproc/float_extractor.py index a2d84d92..2cf21d69 100644 --- a/src/DA/external_scripts/float_preproc/float_extractor.py +++ b/src/DA/external_scripts/float_preproc/float_extractor.py @@ -38,15 +38,15 @@ def argument(): args = argument() -from commons.time_interval import TimeInterval -from commons.Timelist import TimeList -from instruments.matchup_manager import Matchup_Manager -import basins.OGS as OGS -from instruments.var_conversions import FLOATVARS -from commons.utils import addsep +from bitsea.commons.time_interval import TimeInterval +from bitsea.commons.Timelist import TimeList +from bitsea.instruments.matchup_manager import Matchup_Manager +import bitsea.basins.OGS as OGS +from bitsea.instruments.var_conversions import FLOATVARS +from bitsea.commons.utils import addsep from datetime import timedelta from datetime import datetime -from commons import timerequestors +from bitsea.commons import timerequestors import numpy as np import os,sys @@ -56,9 +56,9 @@ def argument(): sys.exit(1) assert profilesource in ["superfloat", "ppcon"] if profilesource=="superfloat": - from instruments import superfloat as bio_float + from bitsea.instruments import superfloat as bio_float if profilesource=="ppcon": - from instruments import float_ppcon as bio_float + from bitsea.instruments import float_ppcon as bio_float meantime=datetime.strptime(args.time,'%Y%m%d') diff --git a/src/DA/external_scripts/float_preproc/merge_arg_mis.py b/src/DA/external_scripts/float_preproc/merge_arg_mis.py index 33b88850..bc121ca7 100644 --- a/src/DA/external_scripts/float_preproc/merge_arg_mis.py +++ b/src/DA/external_scripts/float_preproc/merge_arg_mis.py @@ -1,5 +1,5 @@ import numpy as np -from commons.utils import file2stringlist +from bitsea.commons.utils import file2stringlist import argparse import os diff --git a/src/DA/external_scripts/float_preproc/preproc.py b/src/DA/external_scripts/float_preproc/preproc.py index 5b7c8f45..964b8654 100755 --- a/src/DA/external_scripts/float_preproc/preproc.py +++ b/src/DA/external_scripts/float_preproc/preproc.py @@ -49,19 +49,18 @@ def argument(): args = argument() -from instruments.matchup_manager import Matchup_Manager -from commons.mask import Mask -import basins.OGS as OGS -from instruments.var_conversions import FLOATVARS -from commons.utils import addsep +from bitsea.instruments.matchup_manager import Matchup_Manager +from bitsea.commons.mask import Mask +import bitsea.basins.OGS as OGS +from bitsea.instruments.var_conversions import FLOATVARS +from bitsea.commons.utils import addsep from datetime import datetime -from commons.layer import Layer -from commons.Timelist import TimeList -from commons import timerequestors +from bitsea.commons.layer import Layer +from bitsea.commons.Timelist import TimeList +from bitsea.commons import timerequestors import os,sys import numpy as np -import scipy.io.netcdf as NC -from instruments import check +from bitsea.instruments import check profilesource=os.getenv("PROFILES_SOURCE") if profilesource is None: @@ -69,12 +68,12 @@ def argument(): sys.exit(1) assert profilesource in ["superfloat", "ppcon"] if profilesource=="superfloat": - from instruments import superfloat as bio_float + from bitsea.instruments import superfloat as bio_float if profilesource=="ppcon": if args.variable == 'P_l': - from instruments import superfloat as bio_float ## ppcon chl not yet tested for DA + from bitsea.instruments import superfloat as bio_float ## ppcon chl not yet tested for DA else: - from instruments import float_ppcon as bio_float + from bitsea.instruments import float_ppcon as bio_float datestr = args.time From ce56ff6d4bad8a4562d131d6a6077fa2483a24cf Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Wed, 18 Dec 2024 09:48:13 +0100 Subject: [PATCH 02/25] Setting PYTHONPATH in Float_misfit_gen.sh --- src/DA/external_scripts/float_preproc/Float_misfit_gen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DA/external_scripts/float_preproc/Float_misfit_gen.sh b/src/DA/external_scripts/float_preproc/Float_misfit_gen.sh index b14d0840..2d209f38 100755 --- a/src/DA/external_scripts/float_preproc/Float_misfit_gen.sh +++ b/src/DA/external_scripts/float_preproc/Float_misfit_gen.sh @@ -25,7 +25,7 @@ echo "Float_misfit_gen.sh start " source ${OPA_SCRDIR}/opa_profile.inc #opa_prex "module unload numpy" opa_prex "source $OPA_VENV_1/bin/activate" -export PYTHONPATH=${PYTHONPATH}:$OPA_BITSEA +export PYTHONPATH=$OPA_BITSEA:${PYTHONPATH} while [ True ] ; do while [ True ] ; do From 0bf8f2b10a2b0a0dbe89404a5dd97bbda30830e6 Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Mon, 27 Jan 2025 15:51:37 +0100 Subject: [PATCH 03/25] domdec_generator uses new mask syntax --- preproc/domdec/domdec_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/preproc/domdec/domdec_generator.py b/preproc/domdec/domdec_generator.py index ed9f6987..4f2c5125 100644 --- a/preproc/domdec/domdec_generator.py +++ b/preproc/domdec/domdec_generator.py @@ -36,9 +36,9 @@ def argument(): max_proc_j = args.max_proc_j from domdec import * -from commons.mask import Mask +from bitsea.commons.mask import Mask -TheMask = Mask(args.maskfile, dzvarname="e3t_0") +TheMask = Mask.from_file(args.maskfile, e3t_var_name="e3t_0") tmask = TheMask.mask_at_level(0) jpjglo, jpiglo = tmask.shape From e7e0686c2076f296b6b50d5400408fe66ef43209 Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Wed, 29 Jan 2025 23:13:00 +0100 Subject: [PATCH 04/25] Using Path in float_preproc section --- .../float_preproc/merge_arg_mis.py | 25 +++++------- .../external_scripts/float_preproc/preproc.py | 38 +++++++++---------- 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/DA/external_scripts/float_preproc/merge_arg_mis.py b/src/DA/external_scripts/float_preproc/merge_arg_mis.py index bc121ca7..e2833fd7 100644 --- a/src/DA/external_scripts/float_preproc/merge_arg_mis.py +++ b/src/DA/external_scripts/float_preproc/merge_arg_mis.py @@ -1,7 +1,6 @@ -import numpy as np from bitsea.commons.utils import file2stringlist import argparse -import os +from bitsea.utilities.argparse_types import generic_path def argument(): @@ -12,19 +11,19 @@ def argument(): ) parser.add_argument( '--nit', '-n', - type = str, + type = generic_path, required = True, help = 'path of the input nitrate misfit file') parser.add_argument( '--chl', '-c', - type = str, + type = generic_path, required = True, help = 'path of the input chlorophyll misfit file') parser.add_argument( '--oxy', '-x', - type = str, + type = generic_path, required = True, help = 'path of the input oxygen misfit file') parser.add_argument( '--outfile', '-o', - type = str, + type = generic_path, help = 'path of the output misfit file') return parser.parse_args() @@ -36,8 +35,7 @@ def argument(): arg_misP_l = args.chl arg_misO2o = args.oxy -exists = os.path.isfile(arg_misN3n) -if exists: +if arg_misN3n.is_file(): merge1 = arg_misN3n N3nmis = file2stringlist(arg_misN3n) N3nmis0 = N3nmis[1:] @@ -47,8 +45,7 @@ def argument(): N3nmis0 = [] -exists = os.path.isfile(arg_misP_l) -if exists: +if arg_misP_l.is_file(): merge2 = arg_misP_l P_lmis = file2stringlist(arg_misP_l) P_lmis0 = P_lmis[1:] @@ -57,8 +54,7 @@ def argument(): P_lmis = [0] P_lmis0 = [] -exists = os.path.isfile(arg_misO2o) -if exists: +if arg_misO2o.is_file(): merge3 = arg_misO2o O2omis = file2stringlist(arg_misO2o) O2omis0 = O2omis[1:] @@ -73,7 +69,6 @@ def argument(): allmis = [str(totobs)] + allmis0 -ff = open(args.outfile,'wb') -ff.writelines((item + "\n").encode() for item in allmis ) +with open(args.outfile,'wb') as ff: + ff.writelines((item + "\n").encode() for item in allmis ) -ff.close() diff --git a/src/DA/external_scripts/float_preproc/preproc.py b/src/DA/external_scripts/float_preproc/preproc.py index 964b8654..3a8090b4 100755 --- a/src/DA/external_scripts/float_preproc/preproc.py +++ b/src/DA/external_scripts/float_preproc/preproc.py @@ -1,4 +1,6 @@ import argparse +from bitsea.utilities.argparse_types import existing_dir_path, existing_file_path, generic_path +from bitsea.utilities.argparse_types import date_from_str def argument(): parser = argparse.ArgumentParser(description=''' @@ -8,18 +10,18 @@ def argument(): ) parser.add_argument('--time', '-t', - type=str, + type=date_from_str, required=True, help='Input time in yyyymmdd format') parser.add_argument('--inputdir', '-i', - type=str, + type=existing_dir_path, required=True, help='input dir validation') parser.add_argument('--maskfile', '-m', - type=str, + type=existing_file_path, required=True) parser.add_argument('--basedir', '-b', - type=str, + type=existing_file_path, default=None, required=True, help='''output directory, where aveScan.py will run. @@ -35,12 +37,12 @@ def argument(): required=True, help=''' Depth of assimilation''') parser.add_argument('--misfit', - type=str, + type=generic_path, default=None, required=True, help=''' output misfit file ''') parser.add_argument('--outdir','-o ', - type=str, + type=existing_dir_path, default=None, required=True, help=''' output directory of check files''') @@ -53,7 +55,6 @@ def argument(): from bitsea.commons.mask import Mask import bitsea.basins.OGS as OGS from bitsea.instruments.var_conversions import FLOATVARS -from bitsea.commons.utils import addsep from datetime import datetime from bitsea.commons.layer import Layer from bitsea.commons.Timelist import TimeList @@ -77,9 +78,9 @@ def argument(): datestr = args.time -BASEDIR = addsep(args.basedir) -INPUTDIR = addsep(args.inputdir) -OUTDIR = addsep(args.outdir) +BASEDIR = args.basedir +INPUTDIR = args.inputdir +OUTDIR = args.outdir varmod = args.variable TheMask = Mask(args.maskfile) deplim = int(args.deplim) @@ -208,13 +209,12 @@ def choose_profile(float_track_list): testo += "\t%10.5f\t%i\n" % (errorfloat[month-1], Profile[ilev, 5]) MISFIT_LINES.append(testo) -f=open(args.misfit,'w') -topstr = "%i\n" % len(MISFIT_LINES) -f.write(topstr) -f.writelines(MISFIT_LINES) -f.close() +with open(args.misfit,'w') as f: + topstr = "%i\n" % len(MISFIT_LINES) + f.write(topstr) + f.writelines(MISFIT_LINES) + +checkfile_txt = OUTDIR / (datestr + varmod + '_check.txt') +with open(checkfile_txt,'wt') as fid: + fid.writelines(LINES) -checkfile_txt = OUTDIR + datestr + varmod + '_check.txt' -fid=open(checkfile_txt,'wt') -fid.writelines(LINES) -fid.close() From d57a0dba214545f2dccc3ab9353eec2818fc8413 Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Thu, 30 Jan 2025 11:37:22 +0100 Subject: [PATCH 05/25] Bug fix --- src/DA/external_scripts/float_preproc/preproc.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DA/external_scripts/float_preproc/preproc.py b/src/DA/external_scripts/float_preproc/preproc.py index 3a8090b4..60f7f17e 100755 --- a/src/DA/external_scripts/float_preproc/preproc.py +++ b/src/DA/external_scripts/float_preproc/preproc.py @@ -21,7 +21,7 @@ def argument(): type=existing_file_path, required=True) parser.add_argument('--basedir', '-b', - type=existing_file_path, + type=existing_dir_path, default=None, required=True, help='''output directory, where aveScan.py will run. @@ -77,7 +77,7 @@ def argument(): from bitsea.instruments import float_ppcon as bio_float -datestr = args.time +datestr = args.time.strftime("%Y%m%d") BASEDIR = args.basedir INPUTDIR = args.inputdir OUTDIR = args.outdir @@ -93,9 +93,9 @@ def argument(): erro2obase = 5. # (Approximation based on QuID V7c evaluation) Check_Obj = check.check(OUTDIR,verboselevel=1,threshold_nitrate=2) -year = int(datestr[0:4]) -month = int(datestr[4:6]) -day = int(datestr[6:8]) +year = args.time.year +month = args.time.month +day = Daint(datestr[6:8]) req = timerequestors.Daily_req(year, month, day) TI = req.time_interval From f8b268a4c5836e5cfb9b52dbdf17df796b28df8d Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Tue, 4 Feb 2025 14:11:10 +0100 Subject: [PATCH 06/25] Typo --- src/DA/external_scripts/float_preproc/preproc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DA/external_scripts/float_preproc/preproc.py b/src/DA/external_scripts/float_preproc/preproc.py index 60f7f17e..d274aeeb 100755 --- a/src/DA/external_scripts/float_preproc/preproc.py +++ b/src/DA/external_scripts/float_preproc/preproc.py @@ -95,7 +95,7 @@ def argument(): year = args.time.year month = args.time.month -day = Daint(datestr[6:8]) +day = args.time.day req = timerequestors.Daily_req(year, month, day) TI = req.time_interval From 69cd3361c50e960b70f9b48e24566d6fb50a5fb9 Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Mon, 9 Sep 2024 17:25:35 +0200 Subject: [PATCH 07/25] Ed, Eu, Es and PAR propagate value from 500m to bottom --- src/BIO-OPTICS/trc3streams.f90 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/BIO-OPTICS/trc3streams.f90 b/src/BIO-OPTICS/trc3streams.f90 index 7e0c7f44..01a40421 100644 --- a/src/BIO-OPTICS/trc3streams.f90 +++ b/src/BIO-OPTICS/trc3streams.f90 @@ -19,7 +19,7 @@ SUBROUTINE trc3streams(datestring) #if defined key_trc_nnpzddom || defined key_trc_npzd || key_trc_bfm - INTEGER :: jk,jj,ji,jl,bottom + INTEGER :: jk,jj,ji,jl,bottom, phys_bottom INTEGER :: day_of_year INTEGER :: MODE ! 0-exact, 1-approx INTEGER :: year, month, day, ihr @@ -66,8 +66,8 @@ SUBROUTINE trc3streams(datestring) if (bfmmask(1,jj,ji) == 0) CYCLE - bottom = mbathy(jj,ji) - bottom = min(bottom,jpk_opt) ! Stop at approx 500 mt + phys_bottom = mbathy(jj,ji) + bottom = min(phys_bottom,jpk_opt) ! Stop at approx 500 mt allocate( E(3,bottom+1,nlt)) allocate( PARz(bottom,nchl+1)) @@ -164,12 +164,27 @@ SUBROUTINE trc3streams(datestring) Eu(jk,jj,ji,jl) = E(3,jk,jl) enddo + + if (bottom.gt.phys_bottom) then + + do jk=bottom+1, phys_bottom ! propagation 500m --> phys_bottom of last value + Ed(jk,jj,ji,jl) = Ed(bottom, jj,ji, jl) + Es(jk,jj,ji,jl) = Es(bottom, jj,ji, jl) + Eu(jk,jj,ji,jl) = Eu(bottom, jj,ji, jl) + enddo + endif enddo do jl=1, nchl+1 do jk =1, bottom PAR(jk,jj,ji,jl) = PARz(jk,jl) enddo + if (bottom.gt.phys_bottom) then + do jk=bottom+1, phys_bottom ! propagation of last value + PAR(jk,jj,ji,jl) = PARz(bottom,jl) + enddo + endif + enddo From fc47e5239f1b4c34dc654d46d45ef3641ad055bc Mon Sep 17 00:00:00 2001 From: Paolo Lazzari Date: Fri, 6 Dec 2024 18:07:57 +0100 Subject: [PATCH 08/25] Update trc3streams.f90, bug fix on bottom light below optical model computation, now values are correctly propagated till seafloor. --- src/BIO-OPTICS/trc3streams.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BIO-OPTICS/trc3streams.f90 b/src/BIO-OPTICS/trc3streams.f90 index 01a40421..568e18d2 100644 --- a/src/BIO-OPTICS/trc3streams.f90 +++ b/src/BIO-OPTICS/trc3streams.f90 @@ -165,7 +165,7 @@ SUBROUTINE trc3streams(datestring) enddo - if (bottom.gt.phys_bottom) then + if (bottom.lt.phys_bottom) then do jk=bottom+1, phys_bottom ! propagation 500m --> phys_bottom of last value Ed(jk,jj,ji,jl) = Ed(bottom, jj,ji, jl) @@ -179,7 +179,7 @@ SUBROUTINE trc3streams(datestring) do jk =1, bottom PAR(jk,jj,ji,jl) = PARz(jk,jl) enddo - if (bottom.gt.phys_bottom) then + if (bottom.lt.phys_bottom) then do jk=bottom+1, phys_bottom ! propagation of last value PAR(jk,jj,ji,jl) = PARz(bottom,jl) enddo From 75e51ab9defd7297c5390acc3382a71aed9752e8 Mon Sep 17 00:00:00 2001 From: Paolo Lazzari Date: Thu, 17 Apr 2025 16:10:02 +0200 Subject: [PATCH 09/25] Correct propagation of Ed,Es,Eu (defined on a wgrid) when sea floor bottom (here called phys_bottom) is deeper than the 500m depth threshold for optical model computation --- src/BIO-OPTICS/trc3streams.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BIO-OPTICS/trc3streams.f90 b/src/BIO-OPTICS/trc3streams.f90 index 568e18d2..c6435083 100644 --- a/src/BIO-OPTICS/trc3streams.f90 +++ b/src/BIO-OPTICS/trc3streams.f90 @@ -165,12 +165,12 @@ SUBROUTINE trc3streams(datestring) enddo - if (bottom.lt.phys_bottom) then + if ((bottom+1).lt.phys_bottom) then do jk=bottom+1, phys_bottom ! propagation 500m --> phys_bottom of last value - Ed(jk,jj,ji,jl) = Ed(bottom, jj,ji, jl) - Es(jk,jj,ji,jl) = Es(bottom, jj,ji, jl) - Eu(jk,jj,ji,jl) = Eu(bottom, jj,ji, jl) + Ed(jk,jj,ji,jl) = Ed(bottom+1, jj,ji, jl) + Es(jk,jj,ji,jl) = Es(bottom+1, jj,ji, jl) + Eu(jk,jj,ji,jl) = Eu(bottom+1, jj,ji, jl) enddo endif enddo From 1f5dea7777aa35d0b13a726c1bb3115faa69d804 Mon Sep 17 00:00:00 2001 From: Giovanni Galli Date: Thu, 29 Aug 2024 11:30:29 +0200 Subject: [PATCH 10/25] now with 2x Detritus classes, R6 nd R8, both sinking with their own velocity. --- bfmv5/BFMtab.xml | 9 ++++++++ src/BIO/SED_mem.f90 | 49 +++++++++++++++++++++++------------------- src/BIO/trcsed.f90 | 20 +++++++++++------ src/General/memory.f90 | 3 ++- src/General/parlec.f90 | 16 +++++++++----- 5 files changed, 62 insertions(+), 35 deletions(-) diff --git a/bfmv5/BFMtab.xml b/bfmv5/BFMtab.xml index 0b3b6316..8a7053da 100644 --- a/bfmv5/BFMtab.xml +++ b/bfmv5/BFMtab.xml @@ -49,6 +49,10 @@ + + + + @@ -93,6 +97,7 @@ + @@ -124,14 +129,17 @@ + + + @@ -218,6 +226,7 @@ + diff --git a/src/BIO/SED_mem.f90 b/src/BIO/SED_mem.f90 index 0062dce6..6b0a87a2 100644 --- a/src/BIO/SED_mem.f90 +++ b/src/BIO/SED_mem.f90 @@ -16,7 +16,7 @@ MODULE SED_mem INTEGER :: dimen_jvsed - INTEGER :: nsed=22 + INTEGER :: nsed=26 INTEGER, allocatable :: sed_idx(:) INTEGER, allocatable :: jarr_sed(:,:),jarr_sed_flx(:,:) double precision, allocatable :: ztra(:,:) @@ -54,27 +54,32 @@ subroutine myalloc_SED() sed_idx(3) = ppR6p sed_idx(4) = ppR6s - sed_idx(5) = ppP1c - sed_idx(6) = ppP1n - sed_idx(7) = ppP1p - sed_idx(8) = ppP1s - sed_idx(9) = ppP1l - - sed_idx(10) = ppP2c - sed_idx(11) = ppP2n - sed_idx(12) = ppP2p - sed_idx(13) = ppP2l - - sed_idx(14) = ppP3c - sed_idx(15) = ppP3n - sed_idx(16) = ppP3p - sed_idx(17) = ppP3l - - sed_idx(18) = ppP4c - sed_idx(19) = ppP4n - sed_idx(20) = ppP4p - sed_idx(21) = ppP4l - sed_idx(22) = ppO5c + sed_idx(5) = ppR8c + sed_idx(6) = ppR8n + sed_idx(7) = ppR8p + sed_idx(8) = ppR8s + + sed_idx(9) = ppP1c + sed_idx(10) = ppP1n + sed_idx(11) = ppP1p + sed_idx(12) = ppP1s + sed_idx(13) = ppP1l + + sed_idx(14) = ppP2c + sed_idx(15) = ppP2n + sed_idx(16) = ppP2p + sed_idx(17) = ppP2l + + sed_idx(18) = ppP3c + sed_idx(19) = ppP3n + sed_idx(20) = ppP3p + sed_idx(21) = ppP3l + + sed_idx(22) = ppP4c + sed_idx(23) = ppP4n + sed_idx(24) = ppP4p + sed_idx(25) = ppP4l + sed_idx(26) = ppO5c allocate(jarr_sed(2, jpi*jpj)) jarr_sed = huge(jarr_sed(1,1)) allocate(jarr_sed_flx(jpk,jpi*jpj)) diff --git a/src/BIO/trcsed.f90 b/src/BIO/trcsed.f90 index b9c5c484..2ada62c4 100644 --- a/src/BIO/trcsed.f90 +++ b/src/BIO/trcsed.f90 @@ -133,39 +133,45 @@ SUBROUTINE trcsed -! Particulate +! Small Particulate DO js =1,4 DO jk = 2,jpkm1 - zwork(jk,js,1) = -vsed * trn(jk-1,jj,ji, sed_idx(js)) + zwork(jk,js,1) = -vsedR6 * trn(jk-1,jj,ji, sed_idx(js)) + END DO + END DO +! Large Particulate + DO js =5,8 + DO jk = 2,jpkm1 + zwork(jk,js,1) = -vsedR8 * trn(jk-1,jj,ji, sed_idx(js)) END DO END DO ! Diatoms - DO js =5,9 + DO js =9,13 DO jk = 2,jpkm1 zwork(jk,js,1) = -ogstm_sedipi(jk-1,jj,ji,1) * trn(jk-1,jj,ji, sed_idx(js)) END DO END DO ! Flagellates - DO js =10,13 + DO js =14,17 DO jk = 2,jpkm1 zwork(jk,js,1) = -ogstm_sedipi(jk-1,jj,ji,2) * trn(jk-1,jj,ji, sed_idx(js)) END DO END DO ! Picophytoplankton - DO js =14,17 + DO js =18,21 DO jk = 2,jpkm1 zwork(jk,js,1) = -ogstm_sedipi(jk-1,jj,ji,3) * trn(jk-1,jj,ji, sed_idx(js)) END DO END DO ! Dinoflagellates - DO js =18,21 + DO js =22,25 DO jk = 2,jpkm1 zwork(jk,js,1) = -ogstm_sedipi(jk-1,jj,ji,4) * trn(jk-1,jj,ji, sed_idx(js)) END DO END DO ! Calcite - DO js =22,22 + DO js =26,26 DO jk = 2,jpkm1 zwork(jk,js,1) = - vsedO5c * trn(jk-1,jj,ji, sed_idx(js)) END DO diff --git a/src/General/memory.f90 b/src/General/memory.f90 index 3530e752..d66d808d 100644 --- a/src/General/memory.f90 +++ b/src/General/memory.f90 @@ -391,7 +391,8 @@ MODULE myalloc LOGICAL atlantic_bfm ! atlantic buffer biology activation # if defined key_trc_bfm - double precision vsed ! sedimentation speed (NAMELIST) + double precision vsedR6 ! sedimentation speed of small detritus (NAMELIST) + double precision vsedR8 ! sedimentation speed of large detritus (NAMELIST) double precision vsedO5c ! sedimentation speed of calcite(NAMELIST) double precision bottom_flux ! (NAMELIST) diff --git a/src/General/parlec.f90 b/src/General/parlec.f90 index e7274704..c618d7a4 100644 --- a/src/General/parlec.f90 +++ b/src/General/parlec.f90 @@ -38,7 +38,7 @@ SUBROUTINE parlec NAMELIST/namhdf/ aht0 NAMELIST/nameos/ neos, rau0, ralpha, rbeta namelist /natnum/ rdt,variable_rdt, rsc,rtrn,ncor,ndttrc,ladv, lhdf, lsbc, lbfm, lzdf, lsnu, latmosph, & - ahtrb0,trcrat,ahtrc0,vsed,vsedO5c, photop,atlantic_bfm,bottom_flux,Euphotic_lev, IS_FREE_SURFACE + ahtrb0,trcrat,ahtrc0,vsedR6,vsedR8,vsedO5c, photop,atlantic_bfm,bottom_flux,Euphotic_lev, IS_FREE_SURFACE NAMELIST/General_IO/ nwritetrc, freq_ave_phys, freq_flux_dump, save_bkp_group2, deflate_ave, deflate_level_ave, deflate_rst, & deflate_level_rst, isCheckLOG, read_W_from_file, internal_sponging, ingv_files_direct_reading, ingv_lon_shift, & mld_flag, DvMLD, sigma, DvBackground @@ -143,7 +143,8 @@ SUBROUTINE parlec ahtrb0 = 0. trcrat = 1. ahtrc0 = aht0 - vsed = 3.0 + vsedR6 = 7.0 + vsedR8 = 15.0 vsedO5c = 30.0 photop = .FALSE. atlantic_bfm= .FALSE. @@ -176,7 +177,8 @@ SUBROUTINE parlec WRITE(numout,*) ' background diffusivity for passive tr = ', ahtrb0 WRITE(numout,*) ' ratio betweeen passive and active tr diffusion coeff= ', trcrat WRITE(numout,*) ' horizontal eddy diffus. for passive tr = ', ahtrc0 - WRITE(numout,*) ' detritus sedimentation speed vsed =', vsed/86400 + WRITE(numout,*) ' small detritus sedimentation speed vsedR6 =', vsedR6/86400 + WRITE(numout,*) ' large detritus sedimentation speed vsedR8 =', vsedR8/86400 WRITE(numout,*) ' calcite sedimentation speed vsedO5c =', vsedO5c/86400 WRITE(numout,*) ' photoperiod scaling photop =', photop WRITE(numout,*) ' activation of bfm in atlantic buffer =', atlantic_bfm @@ -184,8 +186,12 @@ SUBROUTINE parlec WRITE(numout,*) ' Euphotic level = ', Euphotic_lev ENDIF - IF (vsed .LT. 0.) THEN - write (*,*) 'vsed must be greated than 0 instead it is:', vsed/86400 + IF (vsedR6 .LT. 0.) THEN + write (*,*) 'vsedR6 must be greated than 0 instead it is:', vsedR6/86400 + STOP + ENDIF + IF (vsedR8 .LT. 0.) THEN + write (*,*) 'vsedR8 must be greated than 0 instead it is:', vsedR8/86400 STOP ENDIF IF (vsedO5c .LT. 0.) THEN From 50f5c9f4a8a658860b96cf18712fc50c933fc2e5 Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Mon, 14 Jul 2025 11:04:35 +0200 Subject: [PATCH 11/25] Exposing vsedR6,vsedR8 into namelist.init --- src/namelists/namelist.init | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/namelists/namelist.init b/src/namelists/namelist.init index 5a5762a9..80f88ca1 100644 --- a/src/namelists/namelist.init +++ b/src/namelists/namelist.init @@ -26,7 +26,8 @@ lbfm = .true., lzdf = .true., lsnu = .true., - vsed = 4.25, + vsedR6 = 7.0, + vsedR8 = 15.0, vsedO5c = 30.0, photop = .false. atlantic_bfm = .true. From e51045ade533ec7918b3702d236de08ee8d7da6d Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Mon, 14 Jul 2025 11:32:22 +0200 Subject: [PATCH 12/25] namelist.passivetrc with 58 bfm vars --- src/namelists/namelist.passivetrc | 694 ++++++++++++++++++------------ 1 file changed, 412 insertions(+), 282 deletions(-) diff --git a/src/namelists/namelist.passivetrc b/src/namelists/namelist.passivetrc index 03d0b8af..0472b7ac 100644 --- a/src/namelists/namelist.passivetrc +++ b/src/namelists/namelist.passivetrc @@ -209,51 +209,86 @@ ctrmax(42)=3.000000e-01 ctr_hf(42)=0 - ctrcnm(43)="R2c" + ctrcnm(43)="R1l" ctrcun(43)="mg C/m3" - ctrmax(43)=5.000000e+02 + ctrmax(43)=1.000000e+01 ctr_hf(43)=0 - ctrcnm(44)="R3c" + ctrcnm(44)="R2c" ctrcun(44)="mg C/m3" - ctrmax(44)=1.000000e+05 + ctrmax(44)=5.000000e+02 ctr_hf(44)=0 - ctrcnm(45)="R6c" + ctrcnm(45)="R2l" ctrcun(45)="mg C/m3" - ctrmax(45)=2.000000e+02 + ctrmax(45)=1.000000e+01 ctr_hf(45)=0 - ctrcnm(46)="R6n" - ctrcun(46)="mmol N/m3" - ctrmax(46)=4.000000e+00 + ctrcnm(46)="R3c" + ctrcun(46)="mg C/m3" + ctrmax(46)=1.000000e+05 ctr_hf(46)=0 - ctrcnm(47)="R6p" - ctrcun(47)="mmol P/m3" - ctrmax(47)=5.000000e-01 + ctrcnm(47)="R3l" + ctrcun(47)="mg C/m3" + ctrmax(47)=1.000000e+01 ctr_hf(47)=0 - ctrcnm(48)="R6s" - ctrcun(48)="mmol Si/m3" - ctrmax(48)=3.000000e+00 - ctr_hf(48)=0 + ctrcnm(48)="R6c" + ctrcun(48)="mg C/m3" + ctrmax(48)=2.000000e+02 + ctr_hf(48)=1 - ctrcnm(49)="O3c" - ctrcun(49)="mg C/m3" - ctrmax(49)=2.000000e+05 + ctrcnm(49)="R6n" + ctrcun(49)="mmol N/m3" + ctrmax(49)=4.000000e+00 ctr_hf(49)=0 - ctrcnm(50)="O3h" - ctrcun(50)="mmol eq/m3" - ctrmax(50)=2.000000e+04 + ctrcnm(50)="R6p" + ctrcun(50)="mmol P/m3" + ctrmax(50)=5.000000e-01 ctr_hf(50)=0 - ctrcnm(51)="O5c" - ctrcun(51)="mg C/m3" - ctrmax(51)=2.000000e+05 + ctrcnm(51)="R6s" + ctrcun(51)="mmol Si/m3" + ctrmax(51)=3.000000e+00 ctr_hf(51)=0 + ctrcnm(52)="R8c" + ctrcun(52)="mg C/m3" + ctrmax(52)=2.000000e+02 + ctr_hf(52)=1 + + ctrcnm(53)="R8n" + ctrcun(53)="mmol N/m3" + ctrmax(53)=4.000000e+00 + ctr_hf(53)=0 + + ctrcnm(54)="R8p" + ctrcun(54)="mmol P/m3" + ctrmax(54)=5.000000e-01 + ctr_hf(54)=0 + + ctrcnm(55)="R8s" + ctrcun(55)="mmol Si/m3" + ctrmax(55)=3.000000e+00 + ctr_hf(55)=0 + + ctrcnm(56)="O3c" + ctrcun(56)="mg C/m3" + ctrmax(56)=2.000000e+05 + ctr_hf(56)=0 + + ctrcnm(57)="O3h" + ctrcun(57)="mmol eq/m3" + ctrmax(57)=2.000000e+04 + ctr_hf(57)=0 + + ctrcnm(58)="O5c" + ctrcun(58)="mg C/m3" + ctrmax(58)=2.000000e+05 + ctr_hf(58)=0 + / &NATTRC_DIAG @@ -277,553 +312,648 @@ diahf(4)=0 diaWR(4)=0 - dianm(5)="ESS" - diaun(5)="g/m3" + dianm(5)="PAR_phyto1" + diaun(5)="uE/m2/s" diahf(5)=0 diaWR(5)=0 - dianm(6)="EPR" - diaun(6)="dbar" + dianm(6)="PAR_phyto2" + diaun(6)="uE/m2/s" diahf(6)=0 diaWR(6)=0 - dianm(7)="Depth" - diaun(7)="m" + dianm(7)="PAR_phyto3" + diaun(7)="uE/m2/s" diahf(7)=0 diaWR(7)=0 - dianm(8)="Volume" - diaun(8)="m3" + dianm(8)="PAR_phyto4" + diaun(8)="uE/m2/s" diahf(8)=0 diaWR(8)=0 - dianm(9)="Area" - diaun(9)="m2" + dianm(9)="PAR" + diaun(9)="uE/m2/s" diahf(9)=0 diaWR(9)=0 - dianm(10)="DIC" - diaun(10)="umol/kg" - diahf(10)=1 - diaWR(10)=1 + dianm(10)="Depth" + diaun(10)="m" + diahf(10)=0 + diaWR(10)=0 - dianm(11)="CO2" - diaun(11)="umol/kg" + dianm(11)="ESS" + diaun(11)="g/m3" diahf(11)=0 diaWR(11)=0 - dianm(12)="pCO2" - diaun(12)="uatm" - diahf(12)=1 - diaWR(12)=1 + dianm(12)="EPR" + diaun(12)="dbar" + diahf(12)=0 + diaWR(12)=0 - dianm(13)="HCO3" - diaun(13)="umol/kg" + dianm(13)="Volume" + diaun(13)="m3" diahf(13)=0 diaWR(13)=0 - dianm(14)="CO3" - diaun(14)="umol/kg" + dianm(14)="Area" + diaun(14)="m2" diahf(14)=0 diaWR(14)=0 - dianm(15)="ALK" - diaun(15)="umol eq/kg" - diahf(15)=1 + dianm(15)="DIC" + diaun(15)="umol/kg" + diahf(15)=0 diaWR(15)=1 - dianm(16)="pH" - diaun(16)="-" - diahf(16)=1 - diaWR(16)=1 + dianm(16)="CO2" + diaun(16)="umol/kg" + diahf(16)=0 + diaWR(16)=0 - dianm(17)="OCalc" - diaun(17)="-" + dianm(17)="pCO2" + diaun(17)="uatm" diahf(17)=0 - diaWR(17)=0 + diaWR(17)=1 - dianm(18)="OArag" - diaun(18)="-" + dianm(18)="HCO3" + diaun(18)="umol/kg" diahf(18)=0 diaWR(18)=0 - dianm(19)="totpelc" - diaun(19)="g C" + dianm(19)="CO3" + diaun(19)="umol/kg" diahf(19)=0 diaWR(19)=0 - dianm(20)="totpeln" - diaun(20)="g N" - diahf(20)=0 - diaWR(20)=0 + dianm(20)="ALK" + diaun(20)="umol eq/kg" + diahf(20)=1 + diaWR(20)=1 - dianm(21)="totpelp" - diaun(21)="g P" - diahf(21)=0 - diaWR(21)=0 + dianm(21)="pH" + diaun(21)="-" + diahf(21)=1 + diaWR(21)=1 - dianm(22)="totpels" - diaun(22)="g Si" + dianm(22)="OCalc" + diaun(22)="-" diahf(22)=0 diaWR(22)=0 - dianm(23)="cxoO2" - diaun(23)="mmol O2/m3" + dianm(23)="OArag" + diaun(23)="-" diahf(23)=0 diaWR(23)=0 - dianm(24)="eO2mO2" - diaun(24)="-" + dianm(24)="totpelc" + diaun(24)="g C" diahf(24)=0 diaWR(24)=0 - dianm(25)="Chla" - diaun(25)="mg Chl/m3" - diahf(25)=1 + dianm(25)="totpeln" + diaun(25)="g N" + diahf(25)=0 diaWR(25)=0 - dianm(26)="ffCO2" - diaun(26)="uatm" + dianm(26)="totpelp" + diaun(26)="g P" diahf(26)=0 - diaWR(26)=1 + diaWR(26)=0 - dianm(27)="flPTN6r" - diaun(27)="mmol O2/m3/d" + dianm(27)="totpels" + diaun(27)="g Si" diahf(27)=0 diaWR(27)=0 - dianm(28)="flN3O4n" - diaun(28)="mmol N/m3/d" + dianm(28)="cxoO2" + diaun(28)="mmol O2/m3" diahf(28)=0 diaWR(28)=0 - dianm(29)="flN4N3n" - diaun(29)="mmol N/m3/d" + dianm(29)="eO2mO2" + diaun(29)="-" diahf(29)=0 diaWR(29)=0 - dianm(30)="sediR2" - diaun(30)="m/d" + dianm(30)="Chla" + diaun(30)="mg Chl/m3" diahf(30)=0 diaWR(30)=0 - dianm(31)="sediR6" - diaun(31)="m/d" + dianm(31)="ffCO2" + diaun(31)="uatm" diahf(31)=0 - diaWR(31)=0 + diaWR(31)=1 - dianm(32)="sediO5" - diaun(32)="m/d" + dianm(32)="flPTN6r" + diaun(32)="mmol O2/m3/d" diahf(32)=0 diaWR(32)=0 - dianm(33)="xEPS" - diaun(33)="1/m" + dianm(33)="flN3O4n" + diaun(33)="mmol N/m3/d" diahf(33)=0 diaWR(33)=0 - dianm(34)="ABIO_eps" - diaun(34)="1/m" + dianm(34)="flN4N3n" + diaun(34)="mmol N/m3/d" diahf(34)=0 diaWR(34)=0 - dianm(35)="qpcPPY_iiP1" - diaun(35)="mmol P/mg C" + dianm(35)="sediR2" + diaun(35)="m/d" diahf(35)=0 diaWR(35)=0 - dianm(36)="qpcPPY_iiP2" - diaun(36)="mmol P/mg C" + dianm(36)="sediR6" + diaun(36)="m/d" diahf(36)=0 diaWR(36)=0 - dianm(37)="qpcPPY_iiP3" - diaun(37)="mmol P/mg C" + dianm(37)="sediR8" + diaun(37)="m/d" diahf(37)=0 diaWR(37)=0 - dianm(38)="qpcPPY_iiP4" - diaun(38)="mmol P/mg C" + dianm(38)="sediO5" + diaun(38)="m/d" diahf(38)=0 diaWR(38)=0 - dianm(39)="qncPPY_iiP1" - diaun(39)="mmol N/mg C" + dianm(39)="xEPS" + diaun(39)="1/m" diahf(39)=0 diaWR(39)=0 - dianm(40)="qncPPY_iiP2" - diaun(40)="mmol N/mg C" + dianm(40)="ABIO_eps" + diaun(40)="1/m" diahf(40)=0 diaWR(40)=0 - dianm(41)="qncPPY_iiP3" - diaun(41)="mmol N/mg C" + dianm(41)="qpcPPY_iiP1" + diaun(41)="mmol P/mg C" diahf(41)=0 diaWR(41)=0 - dianm(42)="qncPPY_iiP4" - diaun(42)="mmol N/mg C" + dianm(42)="qpcPPY_iiP2" + diaun(42)="mmol P/mg C" diahf(42)=0 diaWR(42)=0 - dianm(43)="qscPPY_iiP1" - diaun(43)="mmol Si/mg C" + dianm(43)="qpcPPY_iiP3" + diaun(43)="mmol P/mg C" diahf(43)=0 diaWR(43)=0 - dianm(44)="qscPPY_iiP2" - diaun(44)="mmol Si/mg C" + dianm(44)="qpcPPY_iiP4" + diaun(44)="mmol P/mg C" diahf(44)=0 diaWR(44)=0 - dianm(45)="qscPPY_iiP3" - diaun(45)="mmol Si/mg C" + dianm(45)="qncPPY_iiP1" + diaun(45)="mmol N/mg C" diahf(45)=0 diaWR(45)=0 - dianm(46)="qscPPY_iiP4" - diaun(46)="mmol Si/mg C" + dianm(46)="qncPPY_iiP2" + diaun(46)="mmol N/mg C" diahf(46)=0 diaWR(46)=0 - dianm(47)="qlcPPY_iiP1" - diaun(47)="mg Chl /mg C" + dianm(47)="qncPPY_iiP3" + diaun(47)="mmol N/mg C" diahf(47)=0 diaWR(47)=0 - dianm(48)="qlcPPY_iiP2" - diaun(48)="mg Chl /mg C" + dianm(48)="qncPPY_iiP4" + diaun(48)="mmol N/mg C" diahf(48)=0 diaWR(48)=0 - dianm(49)="qlcPPY_iiP3" - diaun(49)="mg Chl /mg C" + dianm(49)="qscPPY_iiP1" + diaun(49)="mmol Si/mg C" diahf(49)=0 diaWR(49)=0 - dianm(50)="qlcPPY_iiP4" - diaun(50)="mg Chl /mg C" + dianm(50)="qscPPY_iiP2" + diaun(50)="mmol Si/mg C" diahf(50)=0 diaWR(50)=0 - dianm(51)="qccPPY_iiP1" - diaun(51)="mg C/mg C" + dianm(51)="qscPPY_iiP3" + diaun(51)="mmol Si/mg C" diahf(51)=0 diaWR(51)=0 - dianm(52)="qccPPY_iiP2" - diaun(52)="mg C/mg C" + dianm(52)="qscPPY_iiP4" + diaun(52)="mmol Si/mg C" diahf(52)=0 diaWR(52)=0 - dianm(53)="qccPPY_iiP3" - diaun(53)="mg C/mg C" + dianm(53)="qlcPPY_iiP1" + diaun(53)="mg Chl /mg C" diahf(53)=0 diaWR(53)=0 - dianm(54)="qccPPY_iiP4" - diaun(54)="mg C/mg C" + dianm(54)="qlcPPY_iiP2" + diaun(54)="mg Chl /mg C" diahf(54)=0 diaWR(54)=0 - dianm(55)="BFM1D_exR2ac_iiP1" - diaun(55)="mg C/ m3/d" - diahf(55)=1 - diaWR(55)=1 + dianm(55)="qlcPPY_iiP3" + diaun(55)="mg Chl /mg C" + diahf(55)=0 + diaWR(55)=0 - dianm(56)="BFM1D_exR2ac_iiP2" - diaun(56)="mg C/ m3/d" - diahf(56)=1 - diaWR(56)=1 + dianm(56)="qlcPPY_iiP4" + diaun(56)="mg Chl /mg C" + diahf(56)=0 + diaWR(56)=0 - dianm(57)="BFM1D_exR2ac_iiP3" - diaun(57)="mg C/ m3/d" - diahf(57)=1 - diaWR(57)=1 + dianm(57)="qccPPY_iiP1" + diaun(57)="mg C/mg C" + diahf(57)=0 + diaWR(57)=0 - dianm(58)="BFM1D_exR2ac_iiP4" - diaun(58)="mg C/ m3/d" - diahf(58)=1 - diaWR(58)=1 + dianm(58)="qccPPY_iiP2" + diaun(58)="mg C/mg C" + diahf(58)=0 + diaWR(58)=0 - dianm(59)="qpcMEZ_iiZ3" - diaun(59)="mmol P/mg C" + dianm(59)="qccPPY_iiP3" + diaun(59)="mg C/mg C" diahf(59)=0 diaWR(59)=0 - dianm(60)="qpcMEZ_iiZ4" - diaun(60)="mmol P/mg C" + dianm(60)="qccPPY_iiP4" + diaun(60)="mg C/mg C" diahf(60)=0 diaWR(60)=0 - dianm(61)="qncMEZ_iiZ3" - diaun(61)="mmol N/mg C" + dianm(61)="BFM1D_exR2ac_iiP1" + diaun(61)="mg C/ m3/d" diahf(61)=0 - diaWR(61)=0 + diaWR(61)=1 - dianm(62)="qncMEZ_iiZ4" - diaun(62)="mmol N/mg C" + dianm(62)="BFM1D_exR2ac_iiP2" + diaun(62)="mg C/ m3/d" diahf(62)=0 - diaWR(62)=0 + diaWR(62)=1 - dianm(63)="qpcMIZ_iiZ5" - diaun(63)="mmol P/mg C" + dianm(63)="BFM1D_exR2ac_iiP3" + diaun(63)="mg C/ m3/d" diahf(63)=0 - diaWR(63)=0 + diaWR(63)=1 - dianm(64)="qpcMIZ_iiZ6" - diaun(64)="mmol P/mg C" + dianm(64)="BFM1D_exR2ac_iiP4" + diaun(64)="mg C/ m3/d" diahf(64)=0 - diaWR(64)=0 + diaWR(64)=1 - dianm(65)="qncMIZ_iiZ5" - diaun(65)="mmol N/mg C" + dianm(65)="BFM1D_exR2st_iiP1" + diaun(65)="mg C/ m3/d" diahf(65)=0 - diaWR(65)=0 + diaWR(65)=1 - dianm(66)="qncMIZ_iiZ6" - diaun(66)="mmol N/mg C" + dianm(66)="BFM1D_exR2st_iiP2" + diaun(66)="mg C/ m3/d" diahf(66)=0 - diaWR(66)=0 + diaWR(66)=1 - dianm(67)="qpcOMT_iiR1" - diaun(67)="mmol N/mg C" + dianm(67)="BFM1D_exR2st_iiP3" + diaun(67)="mg C/ m3/d" diahf(67)=0 - diaWR(67)=0 + diaWR(67)=1 - dianm(68)="qpcOMT_iiR2" - diaun(68)="mmol N/mg C" + dianm(68)="BFM1D_exR2st_iiP4" + diaun(68)="mg C/ m3/d" diahf(68)=0 - diaWR(68)=0 + diaWR(68)=1 - dianm(69)="qpcOMT_iiR3" - diaun(69)="mmol N/mg C" + dianm(69)="qpcMEZ_iiZ3" + diaun(69)="mmol P/mg C" diahf(69)=0 diaWR(69)=0 - dianm(70)="qpcOMT_iiR6" - diaun(70)="mmol N/mg C" + dianm(70)="qpcMEZ_iiZ4" + diaun(70)="mmol P/mg C" diahf(70)=0 diaWR(70)=0 - dianm(71)="qncOMT_iiR1" - diaun(71)="mmol P/mg C" + dianm(71)="qncMEZ_iiZ3" + diaun(71)="mmol N/mg C" diahf(71)=0 diaWR(71)=0 - dianm(72)="qncOMT_iiR2" - diaun(72)="mmol P/mg C" + dianm(72)="qncMEZ_iiZ4" + diaun(72)="mmol N/mg C" diahf(72)=0 diaWR(72)=0 - dianm(73)="qncOMT_iiR3" + dianm(73)="qpcMIZ_iiZ5" diaun(73)="mmol P/mg C" diahf(73)=0 diaWR(73)=0 - dianm(74)="qncOMT_iiR6" + dianm(74)="qpcMIZ_iiZ6" diaun(74)="mmol P/mg C" diahf(74)=0 diaWR(74)=0 - dianm(75)="qscOMT_iiR1" - diaun(75)="mmol Si/mg C" + dianm(75)="qncMIZ_iiZ5" + diaun(75)="mmol N/mg C" diahf(75)=0 diaWR(75)=0 - dianm(76)="qscOMT_iiR2" - diaun(76)="mmol Si/mg C" + dianm(76)="qncMIZ_iiZ6" + diaun(76)="mmol N/mg C" diahf(76)=0 diaWR(76)=0 - dianm(77)="qscOMT_iiR3" - diaun(77)="mmol Si/mg C" + dianm(77)="qpcOMT_iiR1" + diaun(77)="mmol N/mg C" diahf(77)=0 diaWR(77)=0 - dianm(78)="qscOMT_iiR6" - diaun(78)="mmol Si/mg C" + dianm(78)="qpcOMT_iiR2" + diaun(78)="mmol N/mg C" diahf(78)=0 diaWR(78)=0 - dianm(79)="qpcPBA_iiB1" - diaun(79)="mmol P/mg C" + dianm(79)="qpcOMT_iiR3" + diaun(79)="mmol N/mg C" diahf(79)=0 diaWR(79)=0 - dianm(80)="qncPBA_iiB1" + dianm(80)="qpcOMT_iiR6" diaun(80)="mmol N/mg C" diahf(80)=0 diaWR(80)=0 - dianm(81)="sediPPY_iiP1" - diaun(81)="m/d" + dianm(81)="qpcOMT_iiR8" + diaun(81)="mmol N/mg C" diahf(81)=0 diaWR(81)=0 - dianm(82)="sediPPY_iiP2" - diaun(82)="m/d" + dianm(82)="qncOMT_iiR1" + diaun(82)="mmol P/mg C" diahf(82)=0 diaWR(82)=0 - dianm(83)="sediPPY_iiP3" - diaun(83)="m/d" + dianm(83)="qncOMT_iiR2" + diaun(83)="mmol P/mg C" diahf(83)=0 diaWR(83)=0 - dianm(84)="sediPPY_iiP4" - diaun(84)="m/d" + dianm(84)="qncOMT_iiR3" + diaun(84)="mmol P/mg C" diahf(84)=0 diaWR(84)=0 - dianm(85)="sediMIZ_iiZ5" - diaun(85)="m/d" + dianm(85)="qncOMT_iiR6" + diaun(85)="mmol P/mg C" diahf(85)=0 diaWR(85)=0 - dianm(86)="sediMIZ_iiZ6" - diaun(86)="m/d" + dianm(86)="qncOMT_iiR8" + diaun(86)="mmol P/mg C" diahf(86)=0 diaWR(86)=0 - dianm(87)="sediMEZ_iiZ3" - diaun(87)="m/d" + dianm(87)="qlcOMT_iiR1" + diaun(87)="mmol mgC /mg C" diahf(87)=0 diaWR(87)=0 - dianm(88)="sediMEZ_iiZ4" - diaun(88)="m/d" + dianm(88)="qlcOMT_iiR2" + diaun(88)="mmol mgC /mg C" diahf(88)=0 diaWR(88)=0 - dianm(89)="sunPPY_iiP1" - diaun(89)="1/d" + dianm(89)="qlcOMT_iiR3" + diaun(89)="mmol mgC /mg C" diahf(89)=0 diaWR(89)=0 - dianm(90)="sunPPY_iiP2" - diaun(90)="1/d" + dianm(90)="qlcOMT_iiR6" + diaun(90)="mmol mgC /mg C" diahf(90)=0 diaWR(90)=0 - dianm(91)="sunPPY_iiP3" - diaun(91)="1/d" + dianm(91)="qlcOMT_iiR8" + diaun(91)="mmol mgC /mg C" diahf(91)=0 diaWR(91)=0 - dianm(92)="sunPPY_iiP4" - diaun(92)="1/d" + dianm(92)="qscOMT_iiR1" + diaun(92)="mmol Si/mg C" diahf(92)=0 diaWR(92)=0 - dianm(93)="eiPPY_iiP1" - diaun(93)="-" + dianm(93)="qscOMT_iiR2" + diaun(93)="mmol Si/mg C" diahf(93)=0 diaWR(93)=0 - dianm(94)="eiPPY_iiP2" - diaun(94)="-" + dianm(94)="qscOMT_iiR3" + diaun(94)="mmol Si/mg C" diahf(94)=0 diaWR(94)=0 - dianm(95)="eiPPY_iiP3" - diaun(95)="-" + dianm(95)="qscOMT_iiR6" + diaun(95)="mmol Si/mg C" diahf(95)=0 diaWR(95)=0 - dianm(96)="eiPPY_iiP4" - diaun(96)="-" + dianm(96)="qscOMT_iiR8" + diaun(96)="mmol Si/mg C" diahf(96)=0 diaWR(96)=0 - dianm(97)="ELiPPY_iiP1" - diaun(97)="W/m2" + dianm(97)="qpcPBA_iiB1" + diaun(97)="mmol P/mg C" diahf(97)=0 diaWR(97)=0 - dianm(98)="ELiPPY_iiP2" - diaun(98)="W/m2" + dianm(98)="qncPBA_iiB1" + diaun(98)="mmol N/mg C" diahf(98)=0 diaWR(98)=0 - dianm(99)="ELiPPY_iiP3" - diaun(99)="W/m2" + dianm(99)="sediPPY_iiP1" + diaun(99)="m/d" diahf(99)=0 diaWR(99)=0 - dianm(100)="ELiPPY_iiP4" - diaun(100)="W/m2" + dianm(100)="sediPPY_iiP2" + diaun(100)="m/d" diahf(100)=0 diaWR(100)=0 - dianm(101)="ruPPYc" - diaun(101)="mg C/m3/d" - diahf(101)=1 - diaWR(101)=1 - - dianm(102)="resPPYc" - diaun(102)="mg C/m3/d" - diahf(102)=1 - diaWR(102)=1 + dianm(101)="sediPPY_iiP3" + diaun(101)="m/d" + diahf(101)=0 + diaWR(101)=0 + + dianm(102)="sediPPY_iiP4" + diaun(102)="m/d" + diahf(102)=0 + diaWR(102)=0 + + dianm(103)="sediMIZ_iiZ5" + diaun(103)="m/d" + diahf(103)=0 + diaWR(103)=0 + + dianm(104)="sediMIZ_iiZ6" + diaun(104)="m/d" + diahf(104)=0 + diaWR(104)=0 + + dianm(105)="sediMEZ_iiZ3" + diaun(105)="m/d" + diahf(105)=0 + diaWR(105)=0 + + dianm(106)="sediMEZ_iiZ4" + diaun(106)="m/d" + diahf(106)=0 + diaWR(106)=0 + + dianm(107)="sunPPY_iiP1" + diaun(107)="1/d" + diahf(107)=0 + diaWR(107)=0 + + dianm(108)="sunPPY_iiP2" + diaun(108)="1/d" + diahf(108)=0 + diaWR(108)=0 + + dianm(109)="sunPPY_iiP3" + diaun(109)="1/d" + diahf(109)=0 + diaWR(109)=0 + + dianm(110)="sunPPY_iiP4" + diaun(110)="1/d" + diahf(110)=0 + diaWR(110)=0 + + dianm(111)="eiPPY_iiP1" + diaun(111)="-" + diahf(111)=0 + diaWR(111)=0 + + dianm(112)="eiPPY_iiP2" + diaun(112)="-" + diahf(112)=0 + diaWR(112)=0 + + dianm(113)="eiPPY_iiP3" + diaun(113)="-" + diahf(113)=0 + diaWR(113)=0 + + dianm(114)="eiPPY_iiP4" + diaun(114)="-" + diahf(114)=0 + diaWR(114)=0 + + dianm(115)="ELiPPY_iiP1" + diaun(115)="W/m2" + diahf(115)=0 + diaWR(115)=0 + + dianm(116)="ELiPPY_iiP2" + diaun(116)="W/m2" + diahf(116)=0 + diaWR(116)=0 + + dianm(117)="ELiPPY_iiP3" + diaun(117)="W/m2" + diahf(117)=0 + diaWR(117)=0 + + dianm(118)="ELiPPY_iiP4" + diaun(118)="W/m2" + diahf(118)=0 + diaWR(118)=0 + + dianm(119)="ruPPYc" + diaun(119)="mg C/m3/d" + diahf(119)=1 + diaWR(119)=1 + + dianm(120)="resPPYc" + diaun(120)="mg C/m3/d" + diahf(120)=1 + diaWR(120)=1 / &NATTRC_DIAG_2D - dianm_2d(1)="EPCO2air" - diaun_2d(1)="uatm" + dianm_2d(1)="COSED" + diaun_2d(1)="-" diahf_2d(1)=0 diaWR_2d(1)=0 - dianm_2d(2)="CO2airflux" - diaun_2d(2)="mmol/m2/d" - diahf_2d(2)=1 - diaWR_2d(2)=1 + dianm_2d(2)="EPCO2air" + diaun_2d(2)="uatm" + diahf_2d(2)=0 + diaWR_2d(2)=0 - dianm_2d(3)="Area2d" - diaun_2d(3)="m2" - diahf_2d(3)=0 - diaWR_2d(3)=0 + dianm_2d(3)="CO2airflux" + diaun_2d(3)="mmol/m2/d" + diahf_2d(3)=1 + diaWR_2d(3)=1 - dianm_2d(4)="ThereIsLight" - diaun_2d(4)="-" + dianm_2d(4)="Area2d" + diaun_2d(4)="m2" diahf_2d(4)=0 diaWR_2d(4)=0 - dianm_2d(5)="SUNQ" - diaun_2d(5)="h" + dianm_2d(5)="ThereIsLight" + diaun_2d(5)="-" diahf_2d(5)=0 diaWR_2d(5)=0 - dianm_2d(6)="EWIND" - diaun_2d(6)="m/s" + dianm_2d(6)="SUNQ" + diaun_2d(6)="h" diahf_2d(6)=0 diaWR_2d(6)=0 - dianm_2d(7)="totsysc" - diaun_2d(7)="g C" + dianm_2d(7)="EWIND" + diaun_2d(7)="m/s" diahf_2d(7)=0 - diaWR_2d(7)=1 + diaWR_2d(7)=0 - dianm_2d(8)="totsysn" - diaun_2d(8)="g N" + dianm_2d(8)="EICE" + diaun_2d(8)="-" diahf_2d(8)=0 diaWR_2d(8)=0 - dianm_2d(9)="totsysp" - diaun_2d(9)="g P" + dianm_2d(9)="totsysc" + diaun_2d(9)="g C" diahf_2d(9)=0 - diaWR_2d(9)=0 + diaWR_2d(9)=1 - dianm_2d(10)="totsyss" - diaun_2d(10)="g Si" + dianm_2d(10)="totsysn" + diaun_2d(10)="g N" diahf_2d(10)=0 diaWR_2d(10)=0 - dianm_2d(11)="EICE" - diaun_2d(11)="-" + dianm_2d(11)="totsysp" + diaun_2d(11)="g P" diahf_2d(11)=0 diaWR_2d(11)=0 + dianm_2d(12)="totsyss" + diaun_2d(12)="g Si" + diahf_2d(12)=0 + diaWR_2d(12)=0 + / From 0e17ab580338244063346f347b76cb353d32c164 Mon Sep 17 00:00:00 2001 From: Stefano Piani Date: Tue, 18 Feb 2025 19:23:28 +0100 Subject: [PATCH 13/25] Updated ogstm python scripts to be compatible with the "main" branch of bit.sea --- .../float_postproc/makeplots_postDA.py | 2 +- .../float_postproc/postproc_float_3dvar.py | 2 +- .../float_postproc/var_aggregator.py | 2 +- .../float_preproc/CheckFloatperDate.py | 2 +- .../CheckFloatperDate_calcalastd.py | 2 +- .../external_scripts/float_preproc/preproc.py | 2 +- .../float_preproc/var_aggregator.py | 2 +- src/DA/external_scripts/preproc.py | 2 +- src/DA/external_scripts/var_aggregator.py | 2 +- testcase/Main_create_TEST.py | 103 +++++++----------- testcase/checkdiff.py | 2 +- testcase/subgen.py | 2 +- 12 files changed, 50 insertions(+), 75 deletions(-) diff --git a/src/DA/external_scripts/float_postproc/makeplots_postDA.py b/src/DA/external_scripts/float_postproc/makeplots_postDA.py index 4d1b9897..2890f128 100644 --- a/src/DA/external_scripts/float_postproc/makeplots_postDA.py +++ b/src/DA/external_scripts/float_postproc/makeplots_postDA.py @@ -10,7 +10,7 @@ def plot_floatvsmodel(modelvarname,idate1,AllProfiles,AllChl, NewPres, Float,wmolist): - TheMask=Mask("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") + TheMask=Mask.from_file("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") nav_lev = TheMask.zlevels dz= TheMask.dz diff --git a/src/DA/external_scripts/float_postproc/postproc_float_3dvar.py b/src/DA/external_scripts/float_postproc/postproc_float_3dvar.py index 403483e3..0e60df55 100755 --- a/src/DA/external_scripts/float_postproc/postproc_float_3dvar.py +++ b/src/DA/external_scripts/float_postproc/postproc_float_3dvar.py @@ -74,7 +74,7 @@ def argument(): read_adjusted = [True] #,False,False] # MASK of the domain -TheMask=Mask("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") +TheMask=Mask.from_file("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") nav_lev = TheMask.zlevels layer=Layer(0,200) #layer of the Float profile???? diff --git a/src/DA/external_scripts/float_postproc/var_aggregator.py b/src/DA/external_scripts/float_postproc/var_aggregator.py index 5dded109..da2e9ad1 100644 --- a/src/DA/external_scripts/float_postproc/var_aggregator.py +++ b/src/DA/external_scripts/float_postproc/var_aggregator.py @@ -92,7 +92,7 @@ def addsep(string): SingleVar_filelist=glob.glob(PATH_NAME) SingleVar_filelist.sort() -TheMask=Mask(args.maskfile) +TheMask=Mask.from_file(args.maskfile) for N1pfile in SingleVar_filelist[rank::nranks]: dailyAve = os.path.basename(N1pfile) diff --git a/src/DA/external_scripts/float_preproc/CheckFloatperDate.py b/src/DA/external_scripts/float_preproc/CheckFloatperDate.py index 98f9bd74..314c8589 100755 --- a/src/DA/external_scripts/float_preproc/CheckFloatperDate.py +++ b/src/DA/external_scripts/float_preproc/CheckFloatperDate.py @@ -73,7 +73,7 @@ def argument(): read_adjusted = [True] #,False,False] # MASK of the domain -TheMask=Mask("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") +TheMask=Mask.from_file("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") nav_lev = TheMask.zlevels layer=Layer(0,200) #layer of the Float profile???? diff --git a/src/DA/external_scripts/float_preproc/CheckFloatperDate_calcalastd.py b/src/DA/external_scripts/float_preproc/CheckFloatperDate_calcalastd.py index a41de8e5..7c50ad13 100755 --- a/src/DA/external_scripts/float_preproc/CheckFloatperDate_calcalastd.py +++ b/src/DA/external_scripts/float_preproc/CheckFloatperDate_calcalastd.py @@ -72,7 +72,7 @@ def argument(): read_adjusted = [True] #,False,False] # MASK of the domain -TheMask=Mask("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") +TheMask=Mask.from_file("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") nav_lev = TheMask.zlevels layer=Layer(0,200) #layer of the Float profile???? diff --git a/src/DA/external_scripts/float_preproc/preproc.py b/src/DA/external_scripts/float_preproc/preproc.py index d274aeeb..181b5bb9 100755 --- a/src/DA/external_scripts/float_preproc/preproc.py +++ b/src/DA/external_scripts/float_preproc/preproc.py @@ -82,7 +82,7 @@ def argument(): INPUTDIR = args.inputdir OUTDIR = args.outdir varmod = args.variable -TheMask = Mask(args.maskfile) +TheMask = Mask.from_file(args.maskfile) deplim = int(args.deplim) nav_lev = TheMask.zlevels diff --git a/src/DA/external_scripts/float_preproc/var_aggregator.py b/src/DA/external_scripts/float_preproc/var_aggregator.py index 3350be6d..a221b310 100644 --- a/src/DA/external_scripts/float_preproc/var_aggregator.py +++ b/src/DA/external_scripts/float_preproc/var_aggregator.py @@ -93,7 +93,7 @@ def addsep(string): SingleVar_filelist=glob.glob(PATH_NAME) SingleVar_filelist.sort() -TheMask=Mask(args.maskfile) +TheMask=Mask.from_file(args.maskfile) for N1pfile in SingleVar_filelist[rank::nranks]: dailyAve = os.path.basename(N1pfile) diff --git a/src/DA/external_scripts/preproc.py b/src/DA/external_scripts/preproc.py index ff55be1e..ae549f56 100755 --- a/src/DA/external_scripts/preproc.py +++ b/src/DA/external_scripts/preproc.py @@ -67,7 +67,7 @@ def argument(): read_adjusted = [True] #,False,False] # MASK of the domain -TheMask=Mask("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") +TheMask=Mask.from_file("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") nav_lev = TheMask.zlevels layer=Layer(0,200) #layer of the Float profile???? diff --git a/src/DA/external_scripts/var_aggregator.py b/src/DA/external_scripts/var_aggregator.py index 5dded109..da2e9ad1 100644 --- a/src/DA/external_scripts/var_aggregator.py +++ b/src/DA/external_scripts/var_aggregator.py @@ -92,7 +92,7 @@ def addsep(string): SingleVar_filelist=glob.glob(PATH_NAME) SingleVar_filelist.sort() -TheMask=Mask(args.maskfile) +TheMask=Mask.from_file(args.maskfile) for N1pfile in SingleVar_filelist[rank::nranks]: dailyAve = os.path.basename(N1pfile) diff --git a/testcase/Main_create_TEST.py b/testcase/Main_create_TEST.py index 7a90cf3d..214e8809 100755 --- a/testcase/Main_create_TEST.py +++ b/testcase/Main_create_TEST.py @@ -1,64 +1,39 @@ -#! /usr/bin/python - -#AUTHOR PL 15.X.2013 - -# LOAD PACKAGES - -import os,sys - -import collections - -import numpy as np - -from mydtype import * - -import scipy.io.netcdf as NC - -import pickle - -import create_meshmask_nc as c_mask - -import create_Dom_Dec as c_dom - -import create_extinction_nc as c_ext - -import create_init_nc as c_init - -import create_forcings_nc as c_for - -import create_bc_nc as c_bc - -import deploy_code as d_code - -import create_events as c_events - -import create_da_nc as DA -import create_fluxes - -# MAIN PROGRAM - -TEST_LIST=np.loadtxt('TEST_LIST.dat', dtype=test_conf,skiprows=1,ndmin=1) - -for test in TEST_LIST: - - print(test['Dir']) - - DA.create_dataset(test) - - c_dom.create_Dom_Dec(test) - - c_mask.create_meshmask_nc(test) - - c_for.create_forcings_nc(test) - - c_ext.create_extinction_nc(test) - - c_bc.create_bc_nc(test) - - create_fluxes.create_fluxes(test) - - c_init.create_init_nc(test) - - d_code.deploy_code(test) - - c_events.create_events(test) +#! /usr/bin/python + +#AUTHOR PL 15.X.2013 + +# LOAD PACKAGES +import os,sys +import collections +import numpy as np +from mydtype import * +import scipy.io.netcdf as NC +import pickle +import create_meshmask_nc as c_mask +import create_Dom_Dec as c_dom +import create_extinction_nc as c_ext +import create_init_nc as c_init +import create_forcings_nc as c_for +import create_bc_nc as c_bc +import deploy_code as d_code +import create_events as c_events + +import create_da_nc as DA +import create_fluxes + + +# MAIN PROGRAM +TEST_LIST=np.loadtxt('TEST_LIST.dat', dtype=test_conf,skiprows=1,ndmin=1) + +for test in TEST_LIST: + print(test['Dir']) + DA.create_dataset(test) + c_dom.create_Dom_Dec(test) + c_mask.create_meshmask_nc(test) + c_for.create_forcings_nc(test) + c_ext.create_extinction_nc(test) + c_bc.create_bc_nc(test) + create_fluxes.create_fluxes(test) + c_init.create_init_nc(test) + d_code.deploy_code(test) + c_events.create_events(test) diff --git a/testcase/checkdiff.py b/testcase/checkdiff.py index 805ff2c9..6e0de45a 100644 --- a/testcase/checkdiff.py +++ b/testcase/checkdiff.py @@ -9,7 +9,7 @@ from commons.mask import Mask import os,glob -TheMask=Mask('/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/meshmask.nc') +TheMask=Mask.from_file('/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/meshmask.nc') DIR1 = "/gpfs/work/IscrC_MEDCOAST_0/test_swp/test_FSA/ogstm/testcase/TEST01/wrkdir/MODEL/AVE_FREQ_2/" DIR2 = "/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/AVE_FREQ_2/" diff --git a/testcase/subgen.py b/testcase/subgen.py index 7eb1114a..e0aa69f1 100644 --- a/testcase/subgen.py +++ b/testcase/subgen.py @@ -7,5 +7,5 @@ TheMask=Mask('meshmask.nc',dzvarname="e3t_0") for sub in OGS.Pred: - S=SubMask(sub,maskobject=TheMask) + S=SubMask(sub, TheMask) S.save_as_netcdf('submask.nc', maskvarname=sub.name) From a69d44440a8ddeb1bf6163b34e9e7b039c52a170 Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Wed, 24 Sep 2025 10:47:43 +0200 Subject: [PATCH 14/25] RANKS_PER_NODE has now 4 digits, useful for leonardo (112 cores per node) --- src/MPI/mpi_gather_info.f90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/MPI/mpi_gather_info.f90 b/src/MPI/mpi_gather_info.f90 index de1d2df7..96987084 100644 --- a/src/MPI/mpi_gather_info.f90 +++ b/src/MPI/mpi_gather_info.f90 @@ -70,9 +70,8 @@ MODULE MPI_GATHER_INFO double precision, allocatable :: tottrnIO(:,:,:) - CHARACTER(len=2) :: n_ranks_per_node_char INTEGER :: n_ranks_per_node - !WRITING_RANK = .FALSE. + CHARACTER(len=4) :: n_ranks_per_node_char CONTAINS From 0ba5394360fe3b5cf2e2193a241cd51c9bd7ee0f Mon Sep 17 00:00:00 2001 From: Stefano Piani Date: Tue, 18 Feb 2025 19:23:28 +0100 Subject: [PATCH 15/25] Updated ogstm python scripts to be compatible with the "main" branch of bit.sea --- .../float_postproc/makeplots_postDA.py | 2 +- .../float_postproc/postproc_float_3dvar.py | 2 +- .../float_postproc/var_aggregator.py | 2 +- .../float_preproc/CheckFloatperDate.py | 2 +- .../CheckFloatperDate_calcalastd.py | 2 +- .../external_scripts/float_preproc/preproc.py | 2 +- .../float_preproc/var_aggregator.py | 2 +- src/DA/external_scripts/preproc.py | 2 +- src/DA/external_scripts/var_aggregator.py | 2 +- testcase/Main_create_TEST.py | 103 +++++++----------- testcase/checkdiff.py | 2 +- testcase/subgen.py | 2 +- 12 files changed, 50 insertions(+), 75 deletions(-) diff --git a/src/DA/external_scripts/float_postproc/makeplots_postDA.py b/src/DA/external_scripts/float_postproc/makeplots_postDA.py index 4d1b9897..2890f128 100644 --- a/src/DA/external_scripts/float_postproc/makeplots_postDA.py +++ b/src/DA/external_scripts/float_postproc/makeplots_postDA.py @@ -10,7 +10,7 @@ def plot_floatvsmodel(modelvarname,idate1,AllProfiles,AllChl, NewPres, Float,wmolist): - TheMask=Mask("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") + TheMask=Mask.from_file("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") nav_lev = TheMask.zlevels dz= TheMask.dz diff --git a/src/DA/external_scripts/float_postproc/postproc_float_3dvar.py b/src/DA/external_scripts/float_postproc/postproc_float_3dvar.py index 403483e3..0e60df55 100755 --- a/src/DA/external_scripts/float_postproc/postproc_float_3dvar.py +++ b/src/DA/external_scripts/float_postproc/postproc_float_3dvar.py @@ -74,7 +74,7 @@ def argument(): read_adjusted = [True] #,False,False] # MASK of the domain -TheMask=Mask("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") +TheMask=Mask.from_file("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") nav_lev = TheMask.zlevels layer=Layer(0,200) #layer of the Float profile???? diff --git a/src/DA/external_scripts/float_postproc/var_aggregator.py b/src/DA/external_scripts/float_postproc/var_aggregator.py index 5dded109..da2e9ad1 100644 --- a/src/DA/external_scripts/float_postproc/var_aggregator.py +++ b/src/DA/external_scripts/float_postproc/var_aggregator.py @@ -92,7 +92,7 @@ def addsep(string): SingleVar_filelist=glob.glob(PATH_NAME) SingleVar_filelist.sort() -TheMask=Mask(args.maskfile) +TheMask=Mask.from_file(args.maskfile) for N1pfile in SingleVar_filelist[rank::nranks]: dailyAve = os.path.basename(N1pfile) diff --git a/src/DA/external_scripts/float_preproc/CheckFloatperDate.py b/src/DA/external_scripts/float_preproc/CheckFloatperDate.py index 98f9bd74..314c8589 100755 --- a/src/DA/external_scripts/float_preproc/CheckFloatperDate.py +++ b/src/DA/external_scripts/float_preproc/CheckFloatperDate.py @@ -73,7 +73,7 @@ def argument(): read_adjusted = [True] #,False,False] # MASK of the domain -TheMask=Mask("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") +TheMask=Mask.from_file("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") nav_lev = TheMask.zlevels layer=Layer(0,200) #layer of the Float profile???? diff --git a/src/DA/external_scripts/float_preproc/CheckFloatperDate_calcalastd.py b/src/DA/external_scripts/float_preproc/CheckFloatperDate_calcalastd.py index a41de8e5..7c50ad13 100755 --- a/src/DA/external_scripts/float_preproc/CheckFloatperDate_calcalastd.py +++ b/src/DA/external_scripts/float_preproc/CheckFloatperDate_calcalastd.py @@ -72,7 +72,7 @@ def argument(): read_adjusted = [True] #,False,False] # MASK of the domain -TheMask=Mask("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") +TheMask=Mask.from_file("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") nav_lev = TheMask.zlevels layer=Layer(0,200) #layer of the Float profile???? diff --git a/src/DA/external_scripts/float_preproc/preproc.py b/src/DA/external_scripts/float_preproc/preproc.py index d274aeeb..181b5bb9 100755 --- a/src/DA/external_scripts/float_preproc/preproc.py +++ b/src/DA/external_scripts/float_preproc/preproc.py @@ -82,7 +82,7 @@ def argument(): INPUTDIR = args.inputdir OUTDIR = args.outdir varmod = args.variable -TheMask = Mask(args.maskfile) +TheMask = Mask.from_file(args.maskfile) deplim = int(args.deplim) nav_lev = TheMask.zlevels diff --git a/src/DA/external_scripts/float_preproc/var_aggregator.py b/src/DA/external_scripts/float_preproc/var_aggregator.py index 3350be6d..a221b310 100644 --- a/src/DA/external_scripts/float_preproc/var_aggregator.py +++ b/src/DA/external_scripts/float_preproc/var_aggregator.py @@ -93,7 +93,7 @@ def addsep(string): SingleVar_filelist=glob.glob(PATH_NAME) SingleVar_filelist.sort() -TheMask=Mask(args.maskfile) +TheMask=Mask.from_file(args.maskfile) for N1pfile in SingleVar_filelist[rank::nranks]: dailyAve = os.path.basename(N1pfile) diff --git a/src/DA/external_scripts/preproc.py b/src/DA/external_scripts/preproc.py index ff55be1e..ae549f56 100755 --- a/src/DA/external_scripts/preproc.py +++ b/src/DA/external_scripts/preproc.py @@ -67,7 +67,7 @@ def argument(): read_adjusted = [True] #,False,False] # MASK of the domain -TheMask=Mask("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") +TheMask=Mask.from_file("/pico/home/usera07ogs/a07ogs00/OPA/V2C/etc/static-data/MED1672_cut/MASK/meshmask.nc") nav_lev = TheMask.zlevels layer=Layer(0,200) #layer of the Float profile???? diff --git a/src/DA/external_scripts/var_aggregator.py b/src/DA/external_scripts/var_aggregator.py index 5dded109..da2e9ad1 100644 --- a/src/DA/external_scripts/var_aggregator.py +++ b/src/DA/external_scripts/var_aggregator.py @@ -92,7 +92,7 @@ def addsep(string): SingleVar_filelist=glob.glob(PATH_NAME) SingleVar_filelist.sort() -TheMask=Mask(args.maskfile) +TheMask=Mask.from_file(args.maskfile) for N1pfile in SingleVar_filelist[rank::nranks]: dailyAve = os.path.basename(N1pfile) diff --git a/testcase/Main_create_TEST.py b/testcase/Main_create_TEST.py index 7a90cf3d..214e8809 100755 --- a/testcase/Main_create_TEST.py +++ b/testcase/Main_create_TEST.py @@ -1,64 +1,39 @@ -#! /usr/bin/python - -#AUTHOR PL 15.X.2013 - -# LOAD PACKAGES - -import os,sys - -import collections - -import numpy as np - -from mydtype import * - -import scipy.io.netcdf as NC - -import pickle - -import create_meshmask_nc as c_mask - -import create_Dom_Dec as c_dom - -import create_extinction_nc as c_ext - -import create_init_nc as c_init - -import create_forcings_nc as c_for - -import create_bc_nc as c_bc - -import deploy_code as d_code - -import create_events as c_events - -import create_da_nc as DA -import create_fluxes - -# MAIN PROGRAM - -TEST_LIST=np.loadtxt('TEST_LIST.dat', dtype=test_conf,skiprows=1,ndmin=1) - -for test in TEST_LIST: - - print(test['Dir']) - - DA.create_dataset(test) - - c_dom.create_Dom_Dec(test) - - c_mask.create_meshmask_nc(test) - - c_for.create_forcings_nc(test) - - c_ext.create_extinction_nc(test) - - c_bc.create_bc_nc(test) - - create_fluxes.create_fluxes(test) - - c_init.create_init_nc(test) - - d_code.deploy_code(test) - - c_events.create_events(test) +#! /usr/bin/python + +#AUTHOR PL 15.X.2013 + +# LOAD PACKAGES +import os,sys +import collections +import numpy as np +from mydtype import * +import scipy.io.netcdf as NC +import pickle +import create_meshmask_nc as c_mask +import create_Dom_Dec as c_dom +import create_extinction_nc as c_ext +import create_init_nc as c_init +import create_forcings_nc as c_for +import create_bc_nc as c_bc +import deploy_code as d_code +import create_events as c_events + +import create_da_nc as DA +import create_fluxes + + +# MAIN PROGRAM +TEST_LIST=np.loadtxt('TEST_LIST.dat', dtype=test_conf,skiprows=1,ndmin=1) + +for test in TEST_LIST: + print(test['Dir']) + DA.create_dataset(test) + c_dom.create_Dom_Dec(test) + c_mask.create_meshmask_nc(test) + c_for.create_forcings_nc(test) + c_ext.create_extinction_nc(test) + c_bc.create_bc_nc(test) + create_fluxes.create_fluxes(test) + c_init.create_init_nc(test) + d_code.deploy_code(test) + c_events.create_events(test) diff --git a/testcase/checkdiff.py b/testcase/checkdiff.py index 805ff2c9..6e0de45a 100644 --- a/testcase/checkdiff.py +++ b/testcase/checkdiff.py @@ -9,7 +9,7 @@ from commons.mask import Mask import os,glob -TheMask=Mask('/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/meshmask.nc') +TheMask=Mask.from_file('/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/meshmask.nc') DIR1 = "/gpfs/work/IscrC_MEDCOAST_0/test_swp/test_FSA/ogstm/testcase/TEST01/wrkdir/MODEL/AVE_FREQ_2/" DIR2 = "/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/AVE_FREQ_2/" diff --git a/testcase/subgen.py b/testcase/subgen.py index 7eb1114a..e0aa69f1 100644 --- a/testcase/subgen.py +++ b/testcase/subgen.py @@ -7,5 +7,5 @@ TheMask=Mask('meshmask.nc',dzvarname="e3t_0") for sub in OGS.Pred: - S=SubMask(sub,maskobject=TheMask) + S=SubMask(sub, TheMask) S.save_as_netcdf('submask.nc', maskvarname=sub.name) From 1e5e8ccbbc02f2218e88ea5cf0b1a67fe21e747c Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Tue, 21 Oct 2025 15:31:31 +0200 Subject: [PATCH 16/25] Don't use netcdf modules, use V10C installations --- compilers/machine_modules/g100.intel | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/compilers/machine_modules/g100.intel b/compilers/machine_modules/g100.intel index cebfb364..e1e8f9f0 100644 --- a/compilers/machine_modules/g100.intel +++ b/compilers/machine_modules/g100.intel @@ -4,17 +4,14 @@ module load intel/oneapi-2021--binary module load intelmpi/oneapi-2021--binary module load mkl/oneapi-2021--binary module load cmake/3.21.4 -module load netcdf/4.7.4--oneapi--2021.2.0-ifort -module load netcdff/4.5.3--oneapi--2021.2.0-ifort - -# modules define these $.._HOME env variable -export NETCDF_INC=$NETCDF_C_HOME/include -export NETCDF_LIB=$NETCDF_C_HOME/lib -export NETCDFF_INC=$NETCDF_FORTRAN_HOME/include -export NETCDFF_LIB=$NETCDF_FORTRAN_HOME/lib export OPA_HOME=/g100_work/OGS23_PRACE_IT/COPERNICUS/V10C export OPA_HOSTNAME=g100 + +export NETCDF_LIB=$OPA_HOME/HOST/$OPA_HOSTNAME/lib +export NETCDF_INC=$OPA_HOME/HOST/$OPA_HOSTNAME/include +export NETCDFF_LIB=$OPA_HOME/HOST/$OPA_HOSTNAME/lib +export NETCDFF_INC=$OPA_HOME/HOST/$OPA_HOSTNAME/include export PNETCDF_LIB=$OPA_HOME/HOST/$OPA_HOSTNAME/lib export PNETCDF_INC=$OPA_HOME/HOST/$OPA_HOSTNAME/include export PETSC_LIB=$OPA_HOME/HOST/$OPA_HOSTNAME/lib From ead1ba1be7fe9606340d1739ff4a688fd0df36ec Mon Sep 17 00:00:00 2001 From: Giacomo Zuccarino Date: Tue, 31 Mar 2026 10:13:20 +0200 Subject: [PATCH 17/25] add GSW functions inside PHYS --- src/PHYS/gsw_enthalpy_sso_0.f90 | 37 + src/PHYS/gsw_entropy_part.f90 | 62 + src/PHYS/gsw_gibbs.f90 | 325 +++++ src/PHYS/gsw_mod_error_functions.f90 | 194 +++ src/PHYS/gsw_mod_kinds.f90 | 16 + src/PHYS/gsw_mod_specvol_coefficients.f90 | 313 +++++ src/PHYS/gsw_mod_teos10_constants.f90 | 71 + src/PHYS/gsw_mod_toolbox.f90 | 1555 +++++++++++++++++++++ src/PHYS/gsw_p_from_z.f90 | 89 ++ src/PHYS/gsw_pt_from_t.f90 | 61 + src/PHYS/gsw_specvol_sso_0.f90 | 32 + 11 files changed, 2755 insertions(+) create mode 100644 src/PHYS/gsw_enthalpy_sso_0.f90 create mode 100644 src/PHYS/gsw_entropy_part.f90 create mode 100644 src/PHYS/gsw_gibbs.f90 create mode 100644 src/PHYS/gsw_mod_error_functions.f90 create mode 100644 src/PHYS/gsw_mod_kinds.f90 create mode 100644 src/PHYS/gsw_mod_specvol_coefficients.f90 create mode 100644 src/PHYS/gsw_mod_teos10_constants.f90 create mode 100644 src/PHYS/gsw_mod_toolbox.f90 create mode 100644 src/PHYS/gsw_p_from_z.f90 create mode 100644 src/PHYS/gsw_pt_from_t.f90 create mode 100644 src/PHYS/gsw_specvol_sso_0.f90 diff --git a/src/PHYS/gsw_enthalpy_sso_0.f90 b/src/PHYS/gsw_enthalpy_sso_0.f90 new file mode 100644 index 00000000..f5209b50 --- /dev/null +++ b/src/PHYS/gsw_enthalpy_sso_0.f90 @@ -0,0 +1,37 @@ +!========================================================================== +elemental function gsw_enthalpy_sso_0 (p) +!========================================================================== +! This function calculates enthalpy at the Standard Ocean Salinity, SSO, +! and at a Conservative Temperature of zero degrees C, as a function of +! pressure, p, in dbar, using a streamlined version of the +! computationally-efficient expression for specific volume, that is, a +! streamlined version of the code "gsw_enthalpy(SA,CT,p)". +!========================================================================== + +use gsw_mod_teos10_constants, only : db2pa + +use gsw_mod_specvol_coefficients + +use gsw_mod_kinds + +implicit none + +real (r8), intent(in) :: p + +real (r8) :: gsw_enthalpy_sso_0 + +real (r8) :: dynamic_enthalpy_sso_0_p, z + +z = p*1e-4_r8 + +dynamic_enthalpy_sso_0_p = & + z*( 9.726613854843870e-4_r8 + z*(-2.252956605630465e-5_r8 & + + z*( 2.376909655387404e-6_r8 + z*(-1.664294869986011e-7_r8 & + + z*(-5.988108894465758e-9_r8 + z*(h006 + h007*z)))))) + +gsw_enthalpy_sso_0 = dynamic_enthalpy_sso_0_p*db2pa*1e4_r8 + +return +end function + +!-------------------------------------------------------------------------- diff --git a/src/PHYS/gsw_entropy_part.f90 b/src/PHYS/gsw_entropy_part.f90 new file mode 100644 index 00000000..70fcd112 --- /dev/null +++ b/src/PHYS/gsw_entropy_part.f90 @@ -0,0 +1,62 @@ +!========================================================================== +elemental function gsw_entropy_part (sa, t, p) +!========================================================================== +! +! entropy minus the terms that are a function of only SA +! +! sa : Absolute Salinity [g/kg] +! t : in-situ temperature [deg C] +! p : sea pressure [dbar] +! +! gsw_entropy_part : entropy part +!-------------------------------------------------------------------------- + +use gsw_mod_teos10_constants, only : gsw_sfac + +use gsw_mod_kinds + +implicit none + +real (r8), intent(in) :: sa, t, p + +real (r8) :: gsw_entropy_part + +real (r8) :: x2, x, y, z, g03, g08 + +x2 = gsw_sfac*sa +x = sqrt(x2) +y = t*0.025_r8 +z = p*1e-4_r8 + +g03 = z*(-270.983805184062_r8 + & + z*(776.153611613101_r8 + z*(-196.51255088122_r8 + (28.9796526294175_r8 - 2.13290083518327_r8*z)*z))) + & + y*(-24715.571866078_r8 + z*(2910.0729080936_r8 + & + z*(-1513.116771538718_r8 + z*(546.959324647056_r8 + z*(-111.1208127634436_r8 + 8.68841343834394_r8*z)))) + & + y*(2210.2236124548363_r8 + z*(-2017.52334943521_r8 + & + z*(1498.081172457456_r8 + z*(-718.6359919632359_r8 + (146.4037555781616_r8 - 4.9892131862671505_r8*z)*z))) + & + y*(-592.743745734632_r8 + z*(1591.873781627888_r8 + & + z*(-1207.261522487504_r8 + (608.785486935364_r8 - 105.4993508931208_r8*z)*z)) + & + y*(290.12956292128547_r8 + z*(-973.091553087975_r8 + & + z*(602.603274510125_r8 + z*(-276.361526170076_r8 + 32.40953340386105_r8*z))) + & + y*(-113.90630790850321_r8 + y*(21.35571525415769_r8 - 67.41756835751434_r8*z) + & + z*(381.06836198507096_r8 + z*(-133.7383902842754_r8 + 49.023632509086724_r8*z))))))) + +g08 = x2*(z*(729.116529735046_r8 + & + z*(-343.956902961561_r8 + z*(124.687671116248_r8 + z*(-31.656964386073_r8 + 7.04658803315449_r8*z)))) + & + x*( x*(y*(-137.1145018408982_r8 + y*(148.10030845687618_r8 + y*(-68.5590309679152_r8 + 12.4848504784754_r8*y))) - & + 22.6683558512829_r8*z) + z*(-175.292041186547_r8 + (83.1923927801819_r8 - 29.483064349429_r8*z)*z) + & + y*(-86.1329351956084_r8 + z*(766.116132004952_r8 + z*(-108.3834525034224_r8 + 51.2796974779828_r8*z)) + & + y*(-30.0682112585625_r8 - 1380.9597954037708_r8*z + y*(3.50240264723578_r8 + 938.26075044542_r8*z)))) + & + y*(1760.062705994408_r8 + y*(-675.802947790203_r8 + & + y*(365.7041791005036_r8 + y*(-108.30162043765552_r8 + 12.78101825083098_r8*y) + & + z*(-1190.914967948748_r8 + (298.904564555024_r8 - 145.9491676006352_r8*z)*z)) + & + z*(2082.7344423998043_r8 + z*(-614.668925894709_r8 + (340.685093521782_r8 - 33.3848202979239_r8*z)*z))) + & + z*(-1721.528607567954_r8 + z*(674.819060538734_r8 + & + z*(-356.629112415276_r8 + (88.4080716616_r8 - 15.84003094423364_r8*z)*z))))) + +gsw_entropy_part = -(g03 + g08)*0.025_r8 + +return +end function + +!-------------------------------------------------------------------------- diff --git a/src/PHYS/gsw_gibbs.f90 b/src/PHYS/gsw_gibbs.f90 new file mode 100644 index 00000000..f957b8ac --- /dev/null +++ b/src/PHYS/gsw_gibbs.f90 @@ -0,0 +1,325 @@ +!========================================================================== +elemental function gsw_gibbs (ns, nt, np, sa, t, p) +!========================================================================== +! +! seawater specific Gibbs free energy and derivatives up to order 2 +! +! ns : order of s derivative +! nt : order of t derivative +! np : order of p derivative +! sa : Absolute Salinity [g/kg] +! t : temperature [deg C] +! p : sea pressure [dbar] +! +! gsw_gibbs : specific Gibbs energy or its derivative +!-------------------------------------------------------------------------- + +use gsw_mod_teos10_constants, only : gsw_sfac + +use gsw_mod_error_functions, only : gsw_error_code + +use gsw_mod_kinds + +implicit none + +integer, intent(in) :: ns, nt, np +real (r8), intent(in) :: sa, t, p + +real (r8) :: gsw_gibbs + +real (r8) :: x2, x, y, z, g03, g08 + +character (*), parameter :: func_name = "gsw_gibbs" + +x2 = gsw_sfac*sa +x = sqrt(x2) +y = t*0.025_r8 +z = p*1e-4_r8 + +if (ns.eq.0 .and. nt.eq.0 .and. np.eq.0) then + + g03 = 101.342743139674_r8 + z*(100015.695367145_r8 + & + z*(-2544.5765420363_r8 + z*(284.517778446287_r8 + & + z*(-33.3146754253611_r8 + (4.20263108803084_r8 - 0.546428511471039_r8*z)*z)))) + & + y*(5.90578347909402_r8 + z*(-270.983805184062_r8 + & + z*(776.153611613101_r8 + z*(-196.51255088122_r8 + (28.9796526294175_r8 - 2.13290083518327_r8*z)*z))) + & + y*(-12357.785933039_r8 + z*(1455.0364540468_r8 + & + z*(-756.558385769359_r8 + z*(273.479662323528_r8 + z*(-55.5604063817218_r8 + 4.34420671917197_r8*z)))) + & + y*(736.741204151612_r8 + z*(-672.50778314507_r8 + & + z*(499.360390819152_r8 + z*(-239.545330654412_r8 + (48.8012518593872_r8 - 1.66307106208905_r8*z)*z))) + & + y*(-148.185936433658_r8 + z*(397.968445406972_r8 + & + z*(-301.815380621876_r8 + (152.196371733841_r8 - 26.3748377232802_r8*z)*z)) + & + y*(58.0259125842571_r8 + z*(-194.618310617595_r8 + & + z*(120.520654902025_r8 + z*(-55.2723052340152_r8 + 6.48190668077221_r8*z))) + & + y*(-18.9843846514172_r8 + y*(3.05081646487967_r8 - 9.63108119393062_r8*z) + & + z*(63.5113936641785_r8 + z*(-22.2897317140459_r8 + 8.17060541818112_r8*z)))))))) + + g08 = x2*(1416.27648484197_r8 + z*(-3310.49154044839_r8 + & + z*(384.794152978599_r8 + z*(-96.5324320107458_r8 + (15.8408172766824_r8 - 2.62480156590992_r8*z)*z))) + & + x*(-2432.14662381794_r8 + x*(2025.80115603697_r8 + & + y*(543.835333000098_r8 + y*(-68.5572509204491_r8 + & + y*(49.3667694856254_r8 + y*(-17.1397577419788_r8 + 2.49697009569508_r8*y))) - 22.6683558512829_r8*z) + & + x*(-1091.66841042967_r8 - 196.028306689776_r8*y + & + x*(374.60123787784_r8 - 48.5891069025409_r8*x + 36.7571622995805_r8*y) + 36.0284195611086_r8*z) + & + z*(-54.7919133532887_r8 + (-4.08193978912261_r8 - 30.1755111971161_r8*z)*z)) + & + z*(199.459603073901_r8 + z*(-52.2940909281335_r8 + (68.0444942726459_r8 - 3.41251932441282_r8*z)*z)) + & + y*(-493.407510141682_r8 + z*(-175.292041186547_r8 + (83.1923927801819_r8 - 29.483064349429_r8*z)*z) + & + y*(-43.0664675978042_r8 + z*(383.058066002476_r8 + z*(-54.1917262517112_r8 + 25.6398487389914_r8*z)) + & + y*(-10.0227370861875_r8 - 460.319931801257_r8*z + y*(0.875600661808945_r8 + 234.565187611355_r8*z))))) + & + y*(168.072408311545_r8 + z*(729.116529735046_r8 + & + z*(-343.956902961561_r8 + z*(124.687671116248_r8 + z*(-31.656964386073_r8 + 7.04658803315449_r8*z)))) + & + y*(880.031352997204_r8 + y*(-225.267649263401_r8 + & + y*(91.4260447751259_r8 + y*(-21.6603240875311_r8 + 2.13016970847183_r8*y) + & + z*(-297.728741987187_r8 + (74.726141138756_r8 - 36.4872919001588_r8*z)*z)) + & + z*(694.244814133268_r8 + z*(-204.889641964903_r8 + (113.561697840594_r8 - 11.1282734326413_r8*z)*z))) + & + z*(-860.764303783977_r8 + z*(337.409530269367_r8 + & + z*(-178.314556207638_r8 + (44.2040358308_r8 - 7.92001547211682_r8*z)*z)))))) + + if (sa.gt.0.0_r8) & + g08 = g08 + x2*(5812.81456626732_r8 + 851.226734946706_r8*y)*log(x) + + gsw_gibbs = g03 + g08 + +elseif (ns.eq.1 .and. nt.eq.0 .and. np.eq.0) then + + g08 = 8645.36753595126_r8 + z*(-6620.98308089678_r8 + & + z*(769.588305957198_r8 + z*(-193.0648640214916_r8 + (31.6816345533648_r8 - 5.24960313181984_r8*z)*z))) + & + x*(-7296.43987145382_r8 + x*(8103.20462414788_r8 + & + y*(2175.341332000392_r8 + y*(-274.2290036817964_r8 + & + y*(197.4670779425016_r8 + y*(-68.5590309679152_r8 + 9.98788038278032_r8*y))) - 90.6734234051316_r8*z) + & + x*(-5458.34205214835_r8 - 980.14153344888_r8*y + & + x*(2247.60742726704_r8 - 340.1237483177863_r8*x + 220.542973797483_r8*y) + 180.142097805543_r8*z) + & + z*(-219.1676534131548_r8 + (-16.32775915649044_r8 - 120.7020447884644_r8*z)*z)) + & + z*(598.378809221703_r8 + z*(-156.8822727844005_r8 + (204.1334828179377_r8 - 10.23755797323846_r8*z)*z)) + & + y*(-1480.222530425046_r8 + z*(-525.876123559641_r8 + (249.57717834054571_r8 - 88.449193048287_r8*z)*z) + & + y*(-129.1994027934126_r8 + z*(1149.174198007428_r8 + z*(-162.5751787551336_r8 + 76.9195462169742_r8*z)) + & + y*(-30.0682112585625_r8 - 1380.9597954037708_r8*z + y*(2.626801985426835_r8 + 703.695562834065_r8*z))))) + & + y*(1187.3715515697959_r8 + z*(1458.233059470092_r8 + & + z*(-687.913805923122_r8 + z*(249.375342232496_r8 + z*(-63.313928772146_r8 + 14.09317606630898_r8*z)))) + & + y*(1760.062705994408_r8 + y*(-450.535298526802_r8 + & + y*(182.8520895502518_r8 + y*(-43.3206481750622_r8 + 4.26033941694366_r8*y) + & + z*(-595.457483974374_r8 + (149.452282277512_r8 - 72.9745838003176_r8*z)*z)) + & + z*(1388.489628266536_r8 + z*(-409.779283929806_r8 + (227.123395681188_r8 - 22.2565468652826_r8*z)*z))) + & + z*(-1721.528607567954_r8 + z*(674.819060538734_r8 + & + z*(-356.629112415276_r8 + (88.4080716616_r8 - 15.84003094423364_r8*z)*z))))) + + if (sa.gt.0_r8) then + g08 = g08 + (11625.62913253464_r8 + 1702.453469893412_r8*y)*log(x) + else + g08 = 0.0_r8 + endif + + gsw_gibbs = 0.5*gsw_sfac*g08 + +elseif (ns.eq.0 .and. nt.eq.1 .and. np.eq.0) then + + g03 = 5.90578347909402_r8 + z*(-270.983805184062_r8 + & + z*(776.153611613101_r8 + z*(-196.51255088122_r8 + (28.9796526294175_r8 - 2.13290083518327_r8*z)*z))) + & + y*(-24715.571866078_r8 + z*(2910.0729080936_r8 + & + z*(-1513.116771538718_r8 + z*(546.959324647056_r8 + z*(-111.1208127634436_r8 + 8.68841343834394_r8*z)))) + & + y*(2210.2236124548363_r8 + z*(-2017.52334943521_r8 + & + z*(1498.081172457456_r8 + z*(-718.6359919632359_r8 + (146.4037555781616_r8 - 4.9892131862671505_r8*z)*z))) + & + y*(-592.743745734632_r8 + z*(1591.873781627888_r8 + & + z*(-1207.261522487504_r8 + (608.785486935364_r8 - 105.4993508931208_r8*z)*z)) + & + y*(290.12956292128547_r8 + z*(-973.091553087975_r8 + & + z*(602.603274510125_r8 + z*(-276.361526170076_r8 + 32.40953340386105_r8*z))) + & + y*(-113.90630790850321_r8 + y*(21.35571525415769_r8 - 67.41756835751434_r8*z) + & + z*(381.06836198507096_r8 + z*(-133.7383902842754_r8 + 49.023632509086724_r8*z))))))) + + g08 = x2*(168.072408311545_r8 + z*(729.116529735046_r8 + & + z*(-343.956902961561_r8 + z*(124.687671116248_r8 + z*(-31.656964386073_r8 + 7.04658803315449_r8*z)))) + & + x*(-493.407510141682_r8 + x*(543.835333000098_r8 + x*(-196.028306689776_r8 + 36.7571622995805_r8*x) + & + y*(-137.1145018408982_r8 + y*(148.10030845687618_r8 + y*(-68.5590309679152_r8 + 12.4848504784754_r8*y))) - & + 22.6683558512829_r8*z) + z*(-175.292041186547_r8 + (83.1923927801819_r8 - 29.483064349429_r8*z)*z) + & + y*(-86.1329351956084_r8 + z*(766.116132004952_r8 + z*(-108.3834525034224_r8 + 51.2796974779828_r8*z)) + & + y*(-30.0682112585625_r8 - 1380.9597954037708_r8*z + y*(3.50240264723578_r8 + 938.26075044542_r8*z)))) + & + y*(1760.062705994408_r8 + y*(-675.802947790203_r8 + & + y*(365.7041791005036_r8 + y*(-108.30162043765552_r8 + 12.78101825083098_r8*y) + & + z*(-1190.914967948748_r8 + (298.904564555024_r8 - 145.9491676006352_r8*z)*z)) + & + z*(2082.7344423998043_r8 + z*(-614.668925894709_r8 + (340.685093521782_r8 - 33.3848202979239_r8*z)*z))) + & + z*(-1721.528607567954_r8 + z*(674.819060538734_r8 + & + z*(-356.629112415276_r8 + (88.4080716616_r8 - 15.84003094423364_r8*z)*z))))) + + if (sa.gt.0_r8) g08 = g08 + 851.226734946706_r8*x2*log(x) + + gsw_gibbs = (g03 + g08)*0.025_r8 + +elseif (ns.eq.0 .and. nt.eq.0 .and. np.eq.1) then + + g03 = 100015.695367145_r8 + z*(-5089.1530840726_r8 + & + z*(853.5533353388611_r8 + z*(-133.2587017014444_r8 + (21.0131554401542_r8 - 3.278571068826234_r8*z)*z))) + & + y*(-270.983805184062_r8 + z*(1552.307223226202_r8 + & + z*(-589.53765264366_r8 + (115.91861051767_r8 - 10.664504175916349_r8*z)*z)) + & + y*(1455.0364540468_r8 + z*(-1513.116771538718_r8 + & + z*(820.438986970584_r8 + z*(-222.2416255268872_r8 + 21.72103359585985_r8*z))) + & + y*(-672.50778314507_r8 + z*(998.720781638304_r8 + & + z*(-718.6359919632359_r8 + (195.2050074375488_r8 - 8.31535531044525_r8*z)*z)) + & + y*(397.968445406972_r8 + z*(-603.630761243752_r8 + (456.589115201523_r8 - 105.4993508931208_r8*z)*z) + & + y*(-194.618310617595_r8 + y*(63.5113936641785_r8 - 9.63108119393062_r8*y + & + z*(-44.5794634280918_r8 + 24.511816254543362_r8*z)) + & + z*(241.04130980405_r8 + z*(-165.8169157020456_r8 + & + 25.92762672308884_r8*z))))))) + + g08 = x2*(-3310.49154044839_r8 + z*(769.588305957198_r8 + & + z*(-289.5972960322374_r8 + (63.3632691067296_r8 - 13.1240078295496_r8*z)*z)) + & + x*(199.459603073901_r8 + x*(-54.7919133532887_r8 + 36.0284195611086_r8*x - 22.6683558512829_r8*y + & + (-8.16387957824522_r8 - 90.52653359134831_r8*z)*z) + & + z*(-104.588181856267_r8 + (204.1334828179377_r8 - 13.65007729765128_r8*z)*z) + & + y*(-175.292041186547_r8 + (166.3847855603638_r8 - 88.449193048287_r8*z)*z + & + y*(383.058066002476_r8 + y*(-460.319931801257_r8 + 234.565187611355_r8*y) + & + z*(-108.3834525034224_r8 + 76.9195462169742_r8*z)))) + & + y*(729.116529735046_r8 + z*(-687.913805923122_r8 + & + z*(374.063013348744_r8 + z*(-126.627857544292_r8 + 35.23294016577245_r8*z))) + & + y*(-860.764303783977_r8 + y*(694.244814133268_r8 + & + y*(-297.728741987187_r8 + (149.452282277512_r8 - 109.46187570047641_r8*z)*z) + & + z*(-409.779283929806_r8 + (340.685093521782_r8 - 44.5130937305652_r8*z)*z)) + & + z*(674.819060538734_r8 + z*(-534.943668622914_r8 + (176.8161433232_r8 - 39.600077360584095_r8*z)*z))))) + + gsw_gibbs = (g03 + g08)*1e-8_r8 + +elseif (ns.eq.0 .and. nt.eq.2 .and. np.eq.0) then + + g03 = -24715.571866078_r8 + z*(2910.0729080936_r8 + z* & + (-1513.116771538718_r8 + z*(546.959324647056_r8 + z*(-111.1208127634436_r8 + 8.68841343834394_r8*z)))) + & + y*(4420.4472249096725_r8 + z*(-4035.04669887042_r8 + & + z*(2996.162344914912_r8 + z*(-1437.2719839264719_r8 + (292.8075111563232_r8 - 9.978426372534301_r8*z)*z))) + & + y*(-1778.231237203896_r8 + z*(4775.621344883664_r8 + & + z*(-3621.784567462512_r8 + (1826.356460806092_r8 - 316.49805267936244_r8*z)*z)) + & + y*(1160.5182516851419_r8 + z*(-3892.3662123519_r8 + & + z*(2410.4130980405_r8 + z*(-1105.446104680304_r8 + 129.6381336154442_r8*z))) + & + y*(-569.531539542516_r8 + y*(128.13429152494615_r8 - 404.50541014508605_r8*z) + & + z*(1905.341809925355_r8 + z*(-668.691951421377_r8 + 245.11816254543362_r8*z)))))) + + g08 = x2*(1760.062705994408_r8 + x*(-86.1329351956084_r8 + & + x*(-137.1145018408982_r8 + y*(296.20061691375236_r8 + y*(-205.67709290374563_r8 + 49.9394019139016_r8*y))) + & + z*(766.116132004952_r8 + z*(-108.3834525034224_r8 + 51.2796974779828_r8*z)) + & + y*(-60.136422517125_r8 - 2761.9195908075417_r8*z + y*(10.50720794170734_r8 + 2814.78225133626_r8*z))) + & + y*(-1351.605895580406_r8 + y*(1097.1125373015109_r8 + y*(-433.20648175062206_r8 + 63.905091254154904_r8*y) + & + z*(-3572.7449038462437_r8 + (896.713693665072_r8 - 437.84750280190565_r8*z)*z)) + & + z*(4165.4688847996085_r8 + z*(-1229.337851789418_r8 + (681.370187043564_r8 - 66.7696405958478_r8*z)*z))) + & + z*(-1721.528607567954_r8 + z*(674.819060538734_r8 + & + z*(-356.629112415276_r8 + (88.4080716616_r8 - 15.84003094423364_r8*z)*z)))) + + gsw_gibbs = (g03 + g08)*0.000625_r8 + +elseif (ns.eq.1 .and. nt.eq.0 .and. np.eq.1) then + + g08 = -6620.98308089678_r8 + z*(1539.176611914396_r8 + & + z*(-579.1945920644748_r8 + (126.7265382134592_r8 - 26.2480156590992_r8*z)*z)) + & + x*(598.378809221703_r8 + x*(-219.1676534131548_r8 + 180.142097805543_r8*x - 90.6734234051316_r8*y + & + (-32.65551831298088_r8 - 362.10613436539325_r8*z)*z) + & + z*(-313.764545568801_r8 + (612.4004484538132_r8 - 40.95023189295384_r8*z)*z) + & + y*(-525.876123559641_r8 + (499.15435668109143_r8 - 265.347579144861_r8*z)*z + & + y*(1149.174198007428_r8 + y*(-1380.9597954037708_r8 + 703.695562834065_r8*y) + & + z*(-325.1503575102672_r8 + 230.7586386509226_r8*z)))) + & + y*(1458.233059470092_r8 + z*(-1375.827611846244_r8 + & + z*(748.126026697488_r8 + z*(-253.255715088584_r8 + 70.4658803315449_r8*z))) + & + y*(-1721.528607567954_r8 + y*(1388.489628266536_r8 + & + y*(-595.457483974374_r8 + (298.904564555024_r8 - 218.92375140095282_r8*z)*z) + & + z*(-819.558567859612_r8 + (681.370187043564_r8 - 89.0261874611304_r8*z)*z)) + & + z*(1349.638121077468_r8 + z*(-1069.887337245828_r8 + (353.6322866464_r8 - 79.20015472116819_r8*z)*z)))) + + gsw_gibbs = g08*gsw_sfac*0.5e-8_r8 + +elseif (ns.eq.0 .and. nt.eq.1 .and. np.eq.1) then + + g03 = -270.983805184062_r8 + z*(1552.307223226202_r8 + z*(-589.53765264366_r8 + & + (115.91861051767_r8 - 10.664504175916349_r8*z)*z)) + & + y*(2910.0729080936_r8 + z*(-3026.233543077436_r8 + & + z*(1640.877973941168_r8 + z*(-444.4832510537744_r8 + 43.4420671917197_r8*z))) + & + y*(-2017.52334943521_r8 + z*(2996.162344914912_r8 + & + z*(-2155.907975889708_r8 + (585.6150223126464_r8 - 24.946065931335752_r8*z)*z)) + & + y*(1591.873781627888_r8 + z*(-2414.523044975008_r8 + (1826.356460806092_r8 - 421.9974035724832_r8*z)*z) + & + y*(-973.091553087975_r8 + z*(1205.20654902025_r8 + z*(-829.084578510228_r8 + 129.6381336154442_r8*z)) + & + y*(381.06836198507096_r8 - 67.41756835751434_r8*y + z*(-267.4767805685508_r8 + 147.07089752726017_r8*z)))))) + + g08 = x2*(729.116529735046_r8 + z*(-687.913805923122_r8 + & + z*(374.063013348744_r8 + z*(-126.627857544292_r8 + 35.23294016577245_r8*z))) + & + x*(-175.292041186547_r8 - 22.6683558512829_r8*x + (166.3847855603638_r8 - 88.449193048287_r8*z)*z + & + y*(766.116132004952_r8 + y*(-1380.9597954037708_r8 + 938.26075044542_r8*y) + & + z*(-216.7669050068448_r8 + 153.8390924339484_r8*z))) + & + y*(-1721.528607567954_r8 + y*(2082.7344423998043_r8 + & + y*(-1190.914967948748_r8 + (597.809129110048_r8 - 437.84750280190565_r8*z)*z) + & + z*(-1229.337851789418_r8 + (1022.055280565346_r8 - 133.5392811916956_r8*z)*z)) + & + z*(1349.638121077468_r8 + z*(-1069.887337245828_r8 + (353.6322866464_r8 - 79.20015472116819_r8*z)*z)))) + + gsw_gibbs = (g03 + g08)*2.5e-10_r8 + +elseif (ns.eq.1 .and. nt.eq.1 .and. np.eq.0) then + + g08 = 1187.3715515697959_r8 + z*(1458.233059470092_r8 + & + z*(-687.913805923122_r8 + z*(249.375342232496_r8 + z*(-63.313928772146_r8 + 14.09317606630898_r8*z)))) + & + x*(-1480.222530425046_r8 + x*(2175.341332000392_r8 + x*(-980.14153344888_r8 + 220.542973797483_r8*x) + & + y*(-548.4580073635929_r8 + y*(592.4012338275047_r8 + y*(-274.2361238716608_r8 + 49.9394019139016_r8*y))) - & + 90.6734234051316_r8*z) + z*(-525.876123559641_r8 + (249.57717834054571_r8 - 88.449193048287_r8*z)*z) + & + y*(-258.3988055868252_r8 + z*(2298.348396014856_r8 + z*(-325.1503575102672_r8 + 153.8390924339484_r8*z)) + & + y*(-90.2046337756875_r8 - 4142.8793862113125_r8*z + y*(10.50720794170734_r8 + 2814.78225133626_r8*z)))) + & + y*(3520.125411988816_r8 + y*(-1351.605895580406_r8 + & + y*(731.4083582010072_r8 + y*(-216.60324087531103_r8 + 25.56203650166196_r8*y) + & + z*(-2381.829935897496_r8 + (597.809129110048_r8 - 291.8983352012704_r8*z)*z)) + & + z*(4165.4688847996085_r8 + z*(-1229.337851789418_r8 + (681.370187043564_r8 - 66.7696405958478_r8*z)*z))) + & + z*(-3443.057215135908_r8 + z*(1349.638121077468_r8 + & + z*(-713.258224830552_r8 + (176.8161433232_r8 - 31.68006188846728_r8*z)*z)))) + + if (sa.gt.0_r8) g08 = g08 + 1702.453469893412_r8*log(x) + + gsw_gibbs = 0.5_r8*gsw_sfac*0.025_r8*g08 + +elseif (ns.eq.2 .and. nt.eq.0 .and. np.eq.0) then + + g08 = 2.0_r8*(8103.20462414788_r8 + & + y*(2175.341332000392_r8 + y*(-274.2290036817964_r8 + & + y*(197.4670779425016_r8 + y*(-68.5590309679152_r8 + 9.98788038278032_r8*y))) - 90.6734234051316_r8*z) + & + 1.5_r8*x*(-5458.34205214835_r8 - 980.14153344888_r8*y + & + (4.0_r8/3.0_r8)*x*(2247.60742726704_r8 - 340.1237483177863_r8*1.25_r8*x + 220.542973797483_r8*y) + & + 180.142097805543_r8*z) + & + z*(-219.1676534131548_r8 + (-16.32775915649044_r8 - 120.7020447884644_r8*z)*z)) + + if (x.gt.0_r8) then + g08 = g08 + (-7296.43987145382_r8 + z*(598.378809221703_r8 + & + z*(-156.8822727844005_r8 + (204.1334828179377_r8 - 10.23755797323846_r8*z)*z)) + & + y*(-1480.222530425046_r8 + z*(-525.876123559641_r8 + & + (249.57717834054571_r8 - 88.449193048287_r8*z)*z) + & + y*(-129.1994027934126_r8 + z*(1149.174198007428_r8 + & + z*(-162.5751787551336_r8 + 76.9195462169742_r8*z)) + & + y*(-30.0682112585625_r8 - 1380.9597954037708_r8*z + & + y*(2.626801985426835_r8 + 703.695562834065_r8*z)))))/x + & + (11625.62913253464_r8 + 1702.453469893412_r8*y)/x2 + else + g08 = 0.0_r8 + end if + + gsw_gibbs = 0.25_r8*gsw_sfac*gsw_sfac*g08 + +elseif (ns.eq.0 .and. nt.eq.0 .and. np.eq.2) then + + g03 = -5089.1530840726_r8 + z*(1707.1066706777221_r8 + & + z*(-399.7761051043332_r8 + (84.0526217606168_r8 - 16.39285534413117_r8*z)*z)) + & + y*(1552.307223226202_r8 + z*(-1179.07530528732_r8 + (347.75583155301_r8 - 42.658016703665396_r8*z)*z) + & + y*(-1513.116771538718_r8 + z*(1640.877973941168_r8 + z*(-666.7248765806615_r8 + 86.8841343834394_r8*z)) + & + y*(998.720781638304_r8 + z*(-1437.2719839264719_r8 + (585.6150223126464_r8 - 33.261421241781_r8*z)*z) + & + y*(-603.630761243752_r8 + (913.178230403046_r8 - 316.49805267936244_r8*z)*z + & + y*(241.04130980405_r8 + y*(-44.5794634280918_r8 + 49.023632509086724_r8*z) + & + z*(-331.6338314040912_r8 + 77.78288016926652_r8*z)))))) + + g08 = x2*(769.588305957198_r8 + z*(-579.1945920644748_r8 + (190.08980732018878_r8 - 52.4960313181984_r8*z)*z) + & + x*(-104.588181856267_r8 + x*(-8.16387957824522_r8 - 181.05306718269662_r8*z) + & + (408.2669656358754_r8 - 40.95023189295384_r8*z)*z + & + y*(166.3847855603638_r8 - 176.898386096574_r8*z + y*(-108.3834525034224_r8 + 153.8390924339484_r8*z))) + & + y*(-687.913805923122_r8 + z*(748.126026697488_r8 + z*(-379.883572632876_r8 + 140.9317606630898_r8*z)) + & + y*(674.819060538734_r8 + z*(-1069.887337245828_r8 + (530.4484299696_r8 - 158.40030944233638_r8*z)*z) + & + y*(-409.779283929806_r8 + y*(149.452282277512_r8 - 218.92375140095282_r8*z) + & + (681.370187043564_r8 - 133.5392811916956_r8*z)*z)))) + + gsw_gibbs = (g03 + g08)*1e-16_r8 + +else + + gsw_gibbs = gsw_error_code(1,func_name) + +end if + +return +end function + +!-------------------------------------------------------------------------- diff --git a/src/PHYS/gsw_mod_error_functions.f90 b/src/PHYS/gsw_mod_error_functions.f90 new file mode 100644 index 00000000..78c378b7 --- /dev/null +++ b/src/PHYS/gsw_mod_error_functions.f90 @@ -0,0 +1,194 @@ +!========================================================================== +module gsw_mod_error_functions +!========================================================================== + +use gsw_mod_kinds + +implicit none + +logical, public :: gsw_error_check = .true. +logical, public :: gsw_abort_on_error = .true. + +real (r8), parameter, public :: gsw_error_limit = 1e10_r8 + +integer, private :: nfuncs = 41 + +integer, parameter, private :: maxlen = 40 +integer, parameter, private :: maxfuncs = 50 +character (len=maxlen), dimension(maxfuncs), private :: func_list + +data func_list / & + "gsw_ct_from_enthalpy_exact", & + "gsw_ct_from_enthalpy", & + "gsw_ct_from_rho", & + "gsw_deltasa_atlas", & + "gsw_deltasa_from_sp", & + "gsw_fdelta", & + "gsw_frazil_properties", & + "gsw_frazil_properties_potential", & + "gsw_frazil_properties_potential_poly", & + "gsw_geo_strf_dyn_height", & + "gsw_geo_strf_dyn_height_pc", & + "gsw_gibbs", & + "gsw_gibbs_ice", & + "gsw_ice_fraction_to_freeze_seawater", & + "gsw_ipv_vs_fnsquared_ratio", & + "gsw_melting_ice_into_seawater", & + "gsw_melting_ice_sa_ct_ratio", & + "gsw_melting_ice_sa_ct_ratio_poly", & + "gsw_melting_seaice_into_seawater", & + "gsw_melting_seaice_sa_ct_ratio", & + "gsw_melting_seaice_sa_ct_ratio_poly", & + "gsw_mlp", & + "gsw_nsquared", & + "gsw_nsquared_min", & + "gsw_pressure_freezing_ct", & + "gsw_rr68_interp_sa_ct", & + "gsw_saar", & + "gsw_sa_freezing_from_ct", & + "gsw_sa_freezing_from_ct_poly", & + "gsw_sa_freezing_from_t", & + "gsw_sa_freezing_from_t_poly", & + "gsw_sa_from_rho", & + "gsw_sa_from_sp", & + "gsw_sa_from_sstar", & + "gsw_seaice_fraction_to_freeze_seawater", & + "gsw_sp_from_c", & + "gsw_sp_from_sa", & + "gsw_sp_from_sstar", & + "gsw_sstar_from_sa", & + "gsw_sstar_from_sp", & + "gsw_turner_rsubrho", & + "", & + "", & + "", & + "", & + "", & + "", & + "", & + "", & + "" / + +public :: gsw_error_code +public :: gsw_error_handler +public :: gsw_error_addname + +private :: gsw_error_fnum + +contains + + elemental function gsw_error_code (err_num, func_name, error_code) + + ! Constructs an error code of the form 9.nabcxyz000000d15 + ! + ! where n = current error level (1-4) + ! abc = error code for level #1 + ! xyz = error code for level #2 + ! ... + ! and level error codes comprise ... + ! a = error number for level #1 (0-9) + ! bc = function number for level #1 + + implicit none + + integer, intent(in) :: err_num + character (*), intent(in) :: func_name + real (r8), intent(in), optional :: error_code + + integer :: ival, k + real (r8) :: gsw_error_code, base_code, mult + + if (present(error_code)) then + k = int(error_code/1.0e14_r8) - 90 + base_code = error_code + 1.0e14_r8 + mult = 10.0_r8**(11-k*3) + else + base_code = 9.1e15_r8 + mult = 1.0e11_r8 + end if + + ival = err_num*100 + gsw_error_fnum(func_name) + gsw_error_code = base_code + ival*mult + + end function gsw_error_code + + !========================================================================== + + elemental function gsw_error_fnum (func_name) + + implicit none + + character (*), intent(in) :: func_name + + integer :: gsw_error_fnum + + integer :: i + character (len=maxlen) :: fname + + fname = func_name + do i = 1, nfuncs + if (fname == func_list(i)) goto 100 + end do + gsw_error_fnum = 99 + return + +100 gsw_error_fnum = i + return + + end function gsw_error_fnum + + !========================================================================== + + subroutine gsw_error_handler (error_code) + + implicit none + + real (r8), intent(in) :: error_code + + integer, parameter :: i8 = selected_int_kind(14) + + integer (i8) :: base_code + + integer :: func_num, ival, i, k + + character (len=maxlen) :: func_name + + print '(/"Trace for error code: ", es20.13/)', error_code + + base_code = int(error_code - 9.0e15_r8, i8) + k = int(base_code/1.0e14_r8) + base_code = base_code/(10**(14-k*3)) + + do i = 1, k + ival = int(mod(base_code,1000)) + func_num = mod(ival,100) + if (func_num .le. nfuncs) then + func_name = func_list(func_num) + else + func_name = "unknown" + end if + print '(" Code: ",i1," in function: ",a)', ival/100, func_name + base_code = base_code/1000 + end do + + if (gsw_abort_on_error) stop + + end subroutine gsw_error_handler + + !========================================================================== + + subroutine gsw_error_addname (func_name) + + implicit none + + character (*), intent(in) :: func_name + + if (nfuncs.ge.maxfuncs) return + + nfuncs = nfuncs + 1 + func_list(nfuncs) = func_name + return + + end subroutine gsw_error_addname + +end module gsw_mod_error_functions diff --git a/src/PHYS/gsw_mod_kinds.f90 b/src/PHYS/gsw_mod_kinds.f90 new file mode 100644 index 00000000..7a2a8089 --- /dev/null +++ b/src/PHYS/gsw_mod_kinds.f90 @@ -0,0 +1,16 @@ +!========================================================================== +module gsw_mod_kinds +!========================================================================== + +implicit none + +integer, parameter :: r4 = selected_real_kind(6,30) + +integer, parameter :: r8 = selected_real_kind(14,30) + +end module + +!-------------------------------------------------------------------------- + + + diff --git a/src/PHYS/gsw_mod_specvol_coefficients.f90 b/src/PHYS/gsw_mod_specvol_coefficients.f90 new file mode 100644 index 00000000..7bc89c7b --- /dev/null +++ b/src/PHYS/gsw_mod_specvol_coefficients.f90 @@ -0,0 +1,313 @@ +!========================================================================== +module gsw_mod_specvol_coefficients +!========================================================================== + +use gsw_mod_kinds + +implicit none + +real (r8), parameter :: a000 = -1.56497346750e-5_r8 +real (r8), parameter :: a001 = 1.85057654290e-5_r8 +real (r8), parameter :: a002 = -1.17363867310e-6_r8 +real (r8), parameter :: a003 = -3.65270065530e-7_r8 +real (r8), parameter :: a004 = 3.14540999020e-7_r8 +real (r8), parameter :: a010 = 5.55242129680e-5_r8 +real (r8), parameter :: a011 = -2.34332137060e-5_r8 +real (r8), parameter :: a012 = 4.26100574800e-6_r8 +real (r8), parameter :: a013 = 5.73918103180e-7_r8 +real (r8), parameter :: a020 = -4.95634777770e-5_r8 +real (r8), parameter :: a021 = 2.37838968519e-5_r8 +real (r8), parameter :: a022 = -1.38397620111e-6_r8 +real (r8), parameter :: a030 = 2.76445290808e-5_r8 +real (r8), parameter :: a031 = -1.36408749928e-5_r8 +real (r8), parameter :: a032 = -2.53411666056e-7_r8 +real (r8), parameter :: a040 = -4.02698077700e-6_r8 +real (r8), parameter :: a041 = 2.53683834070e-6_r8 +real (r8), parameter :: a050 = 1.23258565608e-6_r8 +real (r8), parameter :: a100 = 3.50095997640e-5_r8 +real (r8), parameter :: a101 = -9.56770881560e-6_r8 +real (r8), parameter :: a102 = -5.56991545570e-6_r8 +real (r8), parameter :: a103 = -2.72956962370e-7_r8 +real (r8), parameter :: a110 = -7.48716846880e-5_r8 +real (r8), parameter :: a111 = -4.73566167220e-7_r8 +real (r8), parameter :: a112 = 7.82747741600e-7_r8 +real (r8), parameter :: a120 = 7.24244384490e-5_r8 +real (r8), parameter :: a121 = -1.03676320965e-5_r8 +real (r8), parameter :: a122 = 2.32856664276e-8_r8 +real (r8), parameter :: a130 = -3.50383492616e-5_r8 +real (r8), parameter :: a131 = 5.18268711320e-6_r8 +real (r8), parameter :: a140 = -1.65263794500e-6_r8 +real (r8), parameter :: a200 = -4.35926785610e-5_r8 +real (r8), parameter :: a201 = 1.11008347650e-5_r8 +real (r8), parameter :: a202 = 5.46207488340e-6_r8 +real (r8), parameter :: a210 = 7.18156455200e-5_r8 +real (r8), parameter :: a211 = 5.85666925900e-6_r8 +real (r8), parameter :: a212 = -1.31462208134e-6_r8 +real (r8), parameter :: a220 = -4.30608991440e-5_r8 +real (r8), parameter :: a221 = 9.49659182340e-7_r8 +real (r8), parameter :: a230 = 1.74814722392e-5_r8 +real (r8), parameter :: a300 = 3.45324618280e-5_r8 +real (r8), parameter :: a301 = -9.84471178440e-6_r8 +real (r8), parameter :: a302 = -1.35441856270e-6_r8 +real (r8), parameter :: a310 = -3.73971683740e-5_r8 +real (r8), parameter :: a311 = -9.76522784000e-7_r8 +real (r8), parameter :: a320 = 6.85899736680e-6_r8 +real (r8), parameter :: a400 = -1.19594097880e-5_r8 +real (r8), parameter :: a401 = 2.59092252600e-6_r8 +real (r8), parameter :: a410 = 7.71906784880e-6_r8 +real (r8), parameter :: a500 = 1.38645945810e-6_r8 + +real (r8), parameter :: b000 = -3.10389819760e-4_r8 +real (r8), parameter :: b003 = 3.63101885150e-7_r8 +real (r8), parameter :: b004 = -1.11471254230e-7_r8 +real (r8), parameter :: b010 = 3.50095997640e-5_r8 +real (r8), parameter :: b013 = -2.72956962370e-7_r8 +real (r8), parameter :: b020 = -3.74358423440e-5_r8 +real (r8), parameter :: b030 = 2.41414794830e-5_r8 +real (r8), parameter :: b040 = -8.75958731540e-6_r8 +real (r8), parameter :: b050 = -3.30527589000e-7_r8 +real (r8), parameter :: b100 = 1.33856134076e-3_r8 +real (r8), parameter :: b103 = 3.34926075600e-8_r8 +real (r8), parameter :: b110 = -8.71853571220e-5_r8 +real (r8), parameter :: b120 = 7.18156455200e-5_r8 +real (r8), parameter :: b130 = -2.87072660960e-5_r8 +real (r8), parameter :: b140 = 8.74073611960e-6_r8 +real (r8), parameter :: b200 = -2.55143801811e-3_r8 +real (r8), parameter :: b210 = 1.03597385484e-4_r8 +real (r8), parameter :: b220 = -5.60957525610e-5_r8 +real (r8), parameter :: b230 = 6.85899736680e-6_r8 +real (r8), parameter :: b300 = 2.32344279772e-3_r8 +real (r8), parameter :: b310 = -4.78376391520e-5_r8 +real (r8), parameter :: b320 = 1.54381356976e-5_r8 +real (r8), parameter :: b400 = -1.05461852535e-3_r8 +real (r8), parameter :: b410 = 6.93229729050e-6_r8 +real (r8), parameter :: b500 = 1.91594743830e-4_r8 +real (r8), parameter :: b001 = 2.42624687470e-5_r8 +real (r8), parameter :: b011 = -9.56770881560e-6_r8 +real (r8), parameter :: b021 = -2.36783083610e-7_r8 +real (r8), parameter :: b031 = -3.45587736550e-6_r8 +real (r8), parameter :: b041 = 1.29567177830e-6_r8 +real (r8), parameter :: b101 = -6.95849219480e-5_r8 +real (r8), parameter :: b111 = 2.22016695300e-5_r8 +real (r8), parameter :: b121 = 5.85666925900e-6_r8 +real (r8), parameter :: b131 = 6.33106121560e-7_r8 +real (r8), parameter :: b201 = 1.12412331915e-4_r8 +real (r8), parameter :: b211 = -2.95341353532e-5_r8 +real (r8), parameter :: b221 = -1.46478417600e-6_r8 +real (r8), parameter :: b301 = -6.92888744480e-5_r8 +real (r8), parameter :: b311 = 1.03636901040e-5_r8 +real (r8), parameter :: b401 = 1.54637136265e-5_r8 +real (r8), parameter :: b002 = -5.84844329840e-7_r8 +real (r8), parameter :: b012 = -5.56991545570e-6_r8 +real (r8), parameter :: b022 = 3.91373870800e-7_r8 +real (r8), parameter :: b032 = 7.76188880920e-9_r8 +real (r8), parameter :: b102 = -9.62445031940e-6_r8 +real (r8), parameter :: b112 = 1.09241497668e-5_r8 +real (r8), parameter :: b122 = -1.31462208134e-6_r8 +real (r8), parameter :: b202 = 1.47789320994e-5_r8 +real (r8), parameter :: b212 = -4.06325568810e-6_r8 +real (r8), parameter :: b302 = -7.12478989080e-6_r8 + +real (r8), parameter :: c000 = -6.07991438090e-5_r8 +real (r8), parameter :: c001 = 1.99712338438e-5_r8 +real (r8), parameter :: c002 = -3.39280843110e-6_r8 +real (r8), parameter :: c003 = 4.21246123200e-7_r8 +real (r8), parameter :: c004 = -6.32363064300e-8_r8 +real (r8), parameter :: c005 = 1.17681023580e-8_r8 +real (r8), parameter :: c010 = 1.85057654290e-5_r8 +real (r8), parameter :: c011 = -2.34727734620e-6_r8 +real (r8), parameter :: c012 = -1.09581019659e-6_r8 +real (r8), parameter :: c013 = 1.25816399608e-6_r8 +real (r8), parameter :: c020 = -1.17166068530e-5_r8 +real (r8), parameter :: c021 = 4.26100574800e-6_r8 +real (r8), parameter :: c022 = 8.60877154770e-7_r8 +real (r8), parameter :: c030 = 7.92796561730e-6_r8 +real (r8), parameter :: c031 = -9.22650800740e-7_r8 +real (r8), parameter :: c040 = -3.41021874820e-6_r8 +real (r8), parameter :: c041 = -1.26705833028e-7_r8 +real (r8), parameter :: c050 = 5.07367668140e-7_r8 +real (r8), parameter :: c100 = 2.42624687470e-5_r8 +real (r8), parameter :: c101 = -1.16968865968e-6_r8 +real (r8), parameter :: c102 = 1.08930565545e-6_r8 +real (r8), parameter :: c103 = -4.45885016920e-7_r8 +real (r8), parameter :: c110 = -9.56770881560e-6_r8 +real (r8), parameter :: c111 = -1.11398309114e-5_r8 +real (r8), parameter :: c112 = -8.18870887110e-7_r8 +real (r8), parameter :: c120 = -2.36783083610e-7_r8 +real (r8), parameter :: c121 = 7.82747741600e-7_r8 +real (r8), parameter :: c130 = -3.45587736550e-6_r8 +real (r8), parameter :: c131 = 1.55237776184e-8_r8 +real (r8), parameter :: c140 = 1.29567177830e-6_r8 +real (r8), parameter :: c200 = -3.47924609740e-5_r8 +real (r8), parameter :: c201 = -9.62445031940e-6_r8 +real (r8), parameter :: c202 = 5.02389113400e-8_r8 +real (r8), parameter :: c210 = 1.11008347650e-5_r8 +real (r8), parameter :: c211 = 1.09241497668e-5_r8 +real (r8), parameter :: c220 = 2.92833462950e-6_r8 +real (r8), parameter :: c221 = -1.31462208134e-6_r8 +real (r8), parameter :: c230 = 3.16553060780e-7_r8 +real (r8), parameter :: c300 = 3.74707773050e-5_r8 +real (r8), parameter :: c301 = 9.85262139960e-6_r8 +real (r8), parameter :: c310 = -9.84471178440e-6_r8 +real (r8), parameter :: c311 = -2.70883712540e-6_r8 +real (r8), parameter :: c320 = -4.88261392000e-7_r8 +real (r8), parameter :: c400 = -1.73222186120e-5_r8 +real (r8), parameter :: c401 = -3.56239494540e-6_r8 +real (r8), parameter :: c410 = 2.59092252600e-6_r8 +real (r8), parameter :: c500 = 3.09274272530e-6_r8 + +real (r8), parameter :: h001 = 1.07699958620e-3_r8 +real (r8), parameter :: h002 = -3.03995719050e-5_r8 +real (r8), parameter :: h003 = 3.32853897400e-6_r8 +real (r8), parameter :: h004 = -2.82734035930e-7_r8 +real (r8), parameter :: h005 = 2.10623061600e-8_r8 +real (r8), parameter :: h006 = -2.10787688100e-9_r8 +real (r8), parameter :: h007 = 2.80192913290e-10_r8 +real (r8), parameter :: h011 = -1.56497346750e-5_r8 +real (r8), parameter :: h012 = 9.25288271450e-6_r8 +real (r8), parameter :: h013 = -3.91212891030e-7_r8 +real (r8), parameter :: h014 = -9.13175163830e-8_r8 +real (r8), parameter :: h015 = 6.29081998040e-8_r8 +real (r8), parameter :: h021 = 2.77621064840e-5_r8 +real (r8), parameter :: h022 = -5.85830342650e-6_r8 +real (r8), parameter :: h023 = 7.10167624670e-7_r8 +real (r8), parameter :: h024 = 7.17397628980e-8_r8 +real (r8), parameter :: h031 = -1.65211592590e-5_r8 +real (r8), parameter :: h032 = 3.96398280870e-6_r8 +real (r8), parameter :: h033 = -1.53775133460e-7_r8 +real (r8), parameter :: h042 = -1.70510937410e-6_r8 +real (r8), parameter :: h043 = -2.11176388380e-8_r8 +real (r8), parameter :: h041 = 6.91113227020e-6_r8 +real (r8), parameter :: h051 = -8.05396155400e-7_r8 +real (r8), parameter :: h052 = 2.53683834070e-7_r8 +real (r8), parameter :: h061 = 2.05430942680e-7_r8 +real (r8), parameter :: h101 = -3.10389819760e-4_r8 +real (r8), parameter :: h102 = 1.21312343735e-5_r8 +real (r8), parameter :: h103 = -1.94948109950e-7_r8 +real (r8), parameter :: h104 = 9.07754712880e-8_r8 +real (r8), parameter :: h105 = -2.22942508460e-8_r8 +real (r8), parameter :: h111 = 3.50095997640e-5_r8 +real (r8), parameter :: h112 = -4.78385440780e-6_r8 +real (r8), parameter :: h113 = -1.85663848520e-6_r8 +real (r8), parameter :: h114 = -6.82392405930e-8_r8 +real (r8), parameter :: h121 = -3.74358423440e-5_r8 +real (r8), parameter :: h122 = -1.18391541805e-7_r8 +real (r8), parameter :: h123 = 1.30457956930e-7_r8 +real (r8), parameter :: h131 = 2.41414794830e-5_r8 +real (r8), parameter :: h132 = -1.72793868275e-6_r8 +real (r8), parameter :: h133 = 2.58729626970e-9_r8 +real (r8), parameter :: h141 = -8.75958731540e-6_r8 +real (r8), parameter :: h142 = 6.47835889150e-7_r8 +real (r8), parameter :: h151 = -3.30527589000e-7_r8 +real (r8), parameter :: h201 = 6.69280670380e-4_r8 +real (r8), parameter :: h202 = -1.73962304870e-5_r8 +real (r8), parameter :: h203 = -1.60407505320e-6_r8 +real (r8), parameter :: h204 = 4.18657594500e-9_r8 +real (r8), parameter :: h211 = -4.35926785610e-5_r8 +real (r8), parameter :: h212 = 5.55041738250e-6_r8 +real (r8), parameter :: h213 = 1.82069162780e-6_r8 +real (r8), parameter :: h221 = 3.59078227600e-5_r8 +real (r8), parameter :: h222 = 1.46416731475e-6_r8 +real (r8), parameter :: h223 = -2.19103680220e-7_r8 +real (r8), parameter :: h231 = -1.43536330480e-5_r8 +real (r8), parameter :: h232 = 1.58276530390e-7_r8 +real (r8), parameter :: h241 = 4.37036805980e-6_r8 +real (r8), parameter :: h301 = -8.50479339370e-4_r8 +real (r8), parameter :: h302 = 1.87353886525e-5_r8 +real (r8), parameter :: h303 = 1.64210356660e-6_r8 +real (r8), parameter :: h311 = 3.45324618280e-5_r8 +real (r8), parameter :: h312 = -4.92235589220e-6_r8 +real (r8), parameter :: h313 = -4.51472854230e-7_r8 +real (r8), parameter :: h321 = -1.86985841870e-5_r8 +real (r8), parameter :: h322 = -2.44130696000e-7_r8 +real (r8), parameter :: h331 = 2.28633245560e-6_r8 +real (r8), parameter :: h401 = 5.80860699430e-4_r8 +real (r8), parameter :: h402 = -8.66110930600e-6_r8 +real (r8), parameter :: h403 = -5.93732490900e-7_r8 +real (r8), parameter :: h411 = -1.19594097880e-5_r8 +real (r8), parameter :: h421 = 3.85953392440e-6_r8 +real (r8), parameter :: h412 = 1.29546126300e-6_r8 +real (r8), parameter :: h501 = -2.10923705070e-4_r8 +real (r8), parameter :: h502 = 1.54637136265e-6_r8 +real (r8), parameter :: h511 = 1.38645945810e-6_r8 +real (r8), parameter :: h601 = 3.19324573050e-5_r8 + +real (r8), parameter :: v000 = 1.0769995862e-3_r8 +real (r8), parameter :: v001 = -6.0799143809e-5_r8 +real (r8), parameter :: v002 = 9.9856169219e-6_r8 +real (r8), parameter :: v003 = -1.1309361437e-6_r8 +real (r8), parameter :: v004 = 1.0531153080e-7_r8 +real (r8), parameter :: v005 = -1.2647261286e-8_r8 +real (r8), parameter :: v006 = 1.9613503930e-9_r8 +real (r8), parameter :: v010 = -3.1038981976e-4_r8 +real (r8), parameter :: v011 = 2.4262468747e-5_r8 +real (r8), parameter :: v012 = -5.8484432984e-7_r8 +real (r8), parameter :: v013 = 3.6310188515e-7_r8 +real (r8), parameter :: v014 = -1.1147125423e-7_r8 +real (r8), parameter :: v020 = 6.6928067038e-4_r8 +real (r8), parameter :: v021 = -3.4792460974e-5_r8 +real (r8), parameter :: v022 = -4.8122251597e-6_r8 +real (r8), parameter :: v023 = 1.6746303780e-8_r8 +real (r8), parameter :: v030 = -8.5047933937e-4_r8 +real (r8), parameter :: v031 = 3.7470777305e-5_r8 +real (r8), parameter :: v032 = 4.9263106998e-6_r8 +real (r8), parameter :: v040 = 5.8086069943e-4_r8 +real (r8), parameter :: v041 = -1.7322218612e-5_r8 +real (r8), parameter :: v042 = -1.7811974727e-6_r8 +real (r8), parameter :: v050 = -2.1092370507e-4_r8 +real (r8), parameter :: v051 = 3.0927427253e-6_r8 +real (r8), parameter :: v060 = 3.1932457305e-5_r8 +real (r8), parameter :: v100 = -1.5649734675e-5_r8 +real (r8), parameter :: v101 = 1.8505765429e-5_r8 +real (r8), parameter :: v102 = -1.1736386731e-6_r8 +real (r8), parameter :: v103 = -3.6527006553e-7_r8 +real (r8), parameter :: v104 = 3.1454099902e-7_r8 +real (r8), parameter :: v110 = 3.5009599764e-5_r8 +real (r8), parameter :: v111 = -9.5677088156e-6_r8 +real (r8), parameter :: v112 = -5.5699154557e-6_r8 +real (r8), parameter :: v113 = -2.7295696237e-7_r8 +real (r8), parameter :: v120 = -4.3592678561e-5_r8 +real (r8), parameter :: v121 = 1.1100834765e-5_r8 +real (r8), parameter :: v122 = 5.4620748834e-6_r8 +real (r8), parameter :: v130 = 3.4532461828e-5_r8 +real (r8), parameter :: v131 = -9.8447117844e-6_r8 +real (r8), parameter :: v132 = -1.3544185627e-6_r8 +real (r8), parameter :: v140 = -1.1959409788e-5_r8 +real (r8), parameter :: v141 = 2.5909225260e-6_r8 +real (r8), parameter :: v150 = 1.3864594581e-6_r8 +real (r8), parameter :: v200 = 2.7762106484e-5_r8 +real (r8), parameter :: v201 = -1.1716606853e-5_r8 +real (r8), parameter :: v202 = 2.1305028740e-6_r8 +real (r8), parameter :: v203 = 2.8695905159e-7_r8 +real (r8), parameter :: v210 = -3.7435842344e-5_r8 +real (r8), parameter :: v211 = -2.3678308361e-7_r8 +real (r8), parameter :: v212 = 3.9137387080e-7_r8 +real (r8), parameter :: v220 = 3.5907822760e-5_r8 +real (r8), parameter :: v221 = 2.9283346295e-6_r8 +real (r8), parameter :: v222 = -6.5731104067e-7_r8 +real (r8), parameter :: v230 = -1.8698584187e-5_r8 +real (r8), parameter :: v231 = -4.8826139200e-7_r8 +real (r8), parameter :: v240 = 3.8595339244e-6_r8 +real (r8), parameter :: v300 = -1.6521159259e-5_r8 +real (r8), parameter :: v301 = 7.9279656173e-6_r8 +real (r8), parameter :: v302 = -4.6132540037e-7_r8 +real (r8), parameter :: v310 = 2.4141479483e-5_r8 +real (r8), parameter :: v311 = -3.4558773655e-6_r8 +real (r8), parameter :: v312 = 7.7618888092e-9_r8 +real (r8), parameter :: v320 = -1.4353633048e-5_r8 +real (r8), parameter :: v321 = 3.1655306078e-7_r8 +real (r8), parameter :: v330 = 2.2863324556e-6_r8 +real (r8), parameter :: v400 = 6.9111322702e-6_r8 +real (r8), parameter :: v401 = -3.4102187482e-6_r8 +real (r8), parameter :: v402 = -6.3352916514e-8_r8 +real (r8), parameter :: v410 = -8.7595873154e-6_r8 +real (r8), parameter :: v411 = 1.2956717783e-6_r8 +real (r8), parameter :: v420 = 4.3703680598e-6_r8 +real (r8), parameter :: v500 = -8.0539615540e-7_r8 +real (r8), parameter :: v501 = 5.0736766814e-7_r8 +real (r8), parameter :: v510 = -3.3052758900e-7_r8 +real (r8), parameter :: v600 = 2.0543094268e-7_r8 + +end module + +!-------------------------------------------------------------------------- diff --git a/src/PHYS/gsw_mod_teos10_constants.f90 b/src/PHYS/gsw_mod_teos10_constants.f90 new file mode 100644 index 00000000..a8ac2c33 --- /dev/null +++ b/src/PHYS/gsw_mod_teos10_constants.f90 @@ -0,0 +1,71 @@ +!========================================================================== +module gsw_mod_teos10_constants +!========================================================================== + +use gsw_mod_kinds + +implicit none + +real (r8), parameter :: db2pa = 1.0e4_r8 +real (r8), parameter :: rec_db2pa = 1.0e-4_r8 + +real (r8), parameter :: pa2db = 1.0e-4_r8 +real (r8), parameter :: rec_pa2db = 1.0e4_r8 + +real (r8), parameter :: pi = 3.141592653589793_r8 +real (r8), parameter :: deg2rad = pi/180.0_r8 +real (r8), parameter :: rad2deg = 180.0_r8/pi + +real (r8), parameter :: gamma = 2.26e-7_r8 + +! cp0 = The "specific heat" for use [ J/(kg K) ] +! with Conservative Temperature + +real (r8), parameter :: gsw_cp0 = 3991.86795711963_r8 + +! T0 = the Celcius zero point. [ K ] + +real (r8), parameter :: gsw_t0 = 273.15_r8 + +! P0 = Absolute Pressure of one standard atmosphere. [ Pa ] + +real (r8), parameter :: gsw_p0 = 101325.0_r8 + +! SSO = Standard Ocean Reference Salinity. [ g/kg ] + +real (r8), parameter :: gsw_sso = 35.16504_r8 +real (r8), parameter :: gsw_sqrtsso = 5.930011804372737_r8 + +! uPS = unit conversion factor for salinities [ g/kg ] + +real (r8), parameter :: gsw_ups = gsw_sso/35.0_r8 + +! sfac = 1/(40*gsw_ups) + +real (r8), parameter :: gsw_sfac = 0.0248826675584615_r8 + +! deltaS = 24, offset = deltaS*gsw_sfac + +real (r8), parameter :: offset = 5.971840214030754e-1_r8 + +! C3515 = Conductivity at (SP=35, t_68=15, p=0) [ mS/cm ] + +real (r8), parameter :: gsw_c3515 = 42.9140_r8 + +! SonCl = SP to Chlorinity ratio [ (g/kg)^-1 ] + +real (r8), parameter :: gsw_soncl = 1.80655_r8 + +! valence_factor = valence factor of sea salt of Reference Composition +! [ unitless ] + +real (r8), parameter :: gsw_valence_factor = 1.2452898_r8 + +! atomic_weight = mole-weighted atomic weight of sea salt of Reference +! Composition [ g/mol ] + +real (r8), parameter :: gsw_atomic_weight = 31.4038218_r8 + +end module + +!-------------------------------------------------------------------------- diff --git a/src/PHYS/gsw_mod_toolbox.f90 b/src/PHYS/gsw_mod_toolbox.f90 new file mode 100644 index 00000000..78efe227 --- /dev/null +++ b/src/PHYS/gsw_mod_toolbox.f90 @@ -0,0 +1,1555 @@ +module gsw_mod_toolbox + +use gsw_mod_kinds + +implicit none + +public :: gsw_add_barrier +public :: gsw_add_mean +public :: gsw_adiabatic_lapse_rate_from_ct +public :: gsw_adiabatic_lapse_rate_ice +public :: gsw_alpha +public :: gsw_alpha_on_beta +public :: gsw_alpha_wrt_t_exact +public :: gsw_alpha_wrt_t_ice +public :: gsw_beta +public :: gsw_beta_const_t_exact +public :: gsw_c_from_sp +public :: gsw_cabbeling +public :: gsw_chem_potential_water_ice +public :: gsw_chem_potential_water_t_exact +public :: gsw_cp_ice +public :: gsw_ct_first_derivatives +public :: gsw_ct_first_derivatives_wrt_t_exact +public :: gsw_ct_freezing +public :: gsw_ct_freezing_exact +public :: gsw_ct_freezing_first_derivatives +public :: gsw_ct_freezing_first_derivatives_poly +public :: gsw_ct_freezing_poly +public :: gsw_ct_from_enthalpy +public :: gsw_ct_from_enthalpy_exact +public :: gsw_ct_from_entropy +public :: gsw_ct_from_pt +public :: gsw_ct_from_rho +public :: gsw_ct_from_t +public :: gsw_ct_maxdensity +public :: gsw_ct_second_derivatives +public :: gsw_deltasa_atlas +public :: gsw_deltasa_from_sp +public :: gsw_dilution_coefficient_t_exact +public :: gsw_dynamic_enthalpy +public :: gsw_enthalpy +public :: gsw_enthalpy_ct_exact +public :: gsw_enthalpy_diff +public :: gsw_enthalpy_first_derivatives +public :: gsw_enthalpy_first_derivatives_ct_exact +public :: gsw_enthalpy_ice +public :: gsw_enthalpy_second_derivatives +public :: gsw_enthalpy_second_derivatives_ct_exact +public :: gsw_enthalpy_sso_0 +public :: gsw_enthalpy_t_exact +public :: gsw_entropy_first_derivatives +public :: gsw_entropy_from_pt +public :: gsw_entropy_from_t +public :: gsw_entropy_ice +public :: gsw_entropy_part +public :: gsw_entropy_part_zerop +public :: gsw_entropy_second_derivatives +public :: gsw_fdelta +public :: gsw_frazil_properties +public :: gsw_frazil_properties_potential +public :: gsw_frazil_properties_potential_poly +public :: gsw_frazil_ratios_adiabatic +public :: gsw_frazil_ratios_adiabatic_poly +public :: gsw_geo_strf_dyn_height +public :: gsw_geo_strf_dyn_height_pc +public :: gsw_gibbs +public :: gsw_gibbs_ice +public :: gsw_gibbs_ice_part_t +public :: gsw_gibbs_ice_pt0 +public :: gsw_gibbs_ice_pt0_pt0 +public :: gsw_gibbs_pt0_pt0 +public :: gsw_grav +public :: gsw_helmholtz_energy_ice +public :: gsw_hill_ratio_at_sp2 +public :: gsw_ice_fraction_to_freeze_seawater +public :: gsw_internal_energy +public :: gsw_internal_energy_ice +public :: gsw_ipv_vs_fnsquared_ratio +public :: gsw_kappa +public :: gsw_kappa_const_t_ice +public :: gsw_kappa_ice +public :: gsw_kappa_t_exact +public :: gsw_latentheat_evap_ct +public :: gsw_latentheat_evap_t +public :: gsw_latentheat_melting +public :: gsw_linear_interp_sa_ct +public :: gsw_melting_ice_equilibrium_sa_ct_ratio +public :: gsw_melting_ice_equilibrium_sa_ct_ratio_poly +public :: gsw_melting_ice_into_seawater +public :: gsw_melting_ice_sa_ct_ratio +public :: gsw_melting_ice_sa_ct_ratio_poly +public :: gsw_melting_seaice_equilibrium_sa_ct_ratio +public :: gsw_melting_seaice_equilibrium_sa_ct_ratio_poly +public :: gsw_melting_seaice_into_seawater +public :: gsw_melting_seaice_sa_ct_ratio +public :: gsw_melting_seaice_sa_ct_ratio_poly +public :: gsw_mlp +public :: gsw_nsquared +public :: gsw_nsquared_lowerlimit +public :: gsw_nsquared_min +public :: gsw_nsquared_min_const_t +public :: gsw_p_from_z +public :: gsw_pot_enthalpy_from_pt_ice +public :: gsw_pot_enthalpy_from_pt_ice_poly +public :: gsw_pot_enthalpy_ice_freezing +public :: gsw_pot_enthalpy_ice_freezing_first_derivatives +public :: gsw_pot_enthalpy_ice_freezing_first_derivatives_poly +public :: gsw_pot_enthalpy_ice_freezing_poly +public :: gsw_pot_rho_t_exact +public :: gsw_pressure_coefficient_ice +public :: gsw_pressure_freezing_ct +public :: gsw_pt0_cold_ice_poly +public :: gsw_pt0_from_t +public :: gsw_pt0_from_t_ice +public :: gsw_pt_first_derivatives +public :: gsw_pt_from_ct +public :: gsw_pt_from_entropy +public :: gsw_pt_from_pot_enthalpy_ice +public :: gsw_pt_from_pot_enthalpy_ice_poly +public :: gsw_pt_from_pot_enthalpy_ice_poly_dh +public :: gsw_pt_from_t +public :: gsw_pt_from_t_ice +public :: gsw_pt_second_derivatives +public :: gsw_rho +public :: gsw_rho_alpha_beta +public :: gsw_rho_alpha_beta_bsq +public :: gsw_rho_first_derivatives +public :: gsw_rho_first_derivatives_wrt_enthalpy +public :: gsw_rho_ice +public :: gsw_rho_second_derivatives +public :: gsw_rho_second_derivatives_wrt_enthalpy +public :: gsw_rho_t_exact +public :: gsw_rr68_interp_sa_ct +public :: gsw_sa_freezing_estimate +public :: gsw_sa_freezing_from_ct +public :: gsw_sa_freezing_from_ct_poly +public :: gsw_sa_freezing_from_t +public :: gsw_sa_freezing_from_t_poly +public :: gsw_sa_from_rho +public :: gsw_sa_from_sp +public :: gsw_sa_from_sp_baltic +public :: gsw_sa_from_sstar +public :: gsw_sa_p_inrange +public :: gsw_saar +public :: gsw_seaice_fraction_to_freeze_seawater +public :: gsw_sigma0 +public :: gsw_sigma1 +public :: gsw_sigma2 +public :: gsw_sigma3 +public :: gsw_sigma4 +public :: gsw_sound_speed +public :: gsw_sound_speed_ice +public :: gsw_sound_speed_t_exact +public :: gsw_sp_from_c +public :: gsw_sp_from_sa +public :: gsw_sp_from_sa_baltic +public :: gsw_sp_from_sk +public :: gsw_sp_from_sr +public :: gsw_sp_from_sstar +public :: gsw_specvol +public :: gsw_specvol_alpha_beta +public :: gsw_specvol_anom_standard +public :: gsw_specvol_first_derivatives +public :: gsw_specvol_first_derivatives_wrt_enthalpy +public :: gsw_specvol_ice +public :: gsw_specvol_second_derivatives +public :: gsw_specvol_second_derivatives_wrt_enthalpy +public :: gsw_specvol_sso_0 +public :: gsw_specvol_t_exact +public :: gsw_spiciness0 +public :: gsw_spiciness1 +public :: gsw_spiciness2 +public :: gsw_sr_from_sp +public :: gsw_sstar_from_sa +public :: gsw_sstar_from_sp +public :: gsw_t_deriv_chem_potential_water_t_exact +public :: gsw_t_freezing +public :: gsw_t_freezing_exact +public :: gsw_t_freezing_first_derivatives +public :: gsw_t_freezing_first_derivatives_poly +public :: gsw_t_freezing_poly +public :: gsw_t_from_ct +public :: gsw_t_from_pt0_ice +public :: gsw_thermobaric +public :: gsw_turner_rsubrho +public :: gsw_util_indx +public :: gsw_util_interp1q_int +public :: gsw_util_sort_real +public :: gsw_util_xinterp1 +public :: gsw_z_from_p + +interface + + pure subroutine gsw_add_barrier (input_data, long, lat, long_grid, & + lat_grid, dlong_grid, dlat_grid, output_data) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: long, lat, long_grid, lat_grid, dlong_grid + real (r8), intent(in) :: dlat_grid + real (r8), intent(in), dimension(4) :: input_data + real (r8), intent(out), dimension(4) :: output_data + end subroutine gsw_add_barrier + + pure subroutine gsw_add_mean (data_in, data_out) + use gsw_mod_kinds + implicit none + real (r8), intent(in), dimension(4) :: data_in + real (r8), intent(out), dimension(4) :: data_out + end subroutine gsw_add_mean + + elemental function gsw_adiabatic_lapse_rate_from_ct (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_adiabatic_lapse_rate_from_ct + end function gsw_adiabatic_lapse_rate_from_ct + + elemental function gsw_adiabatic_lapse_rate_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_adiabatic_lapse_rate_ice + end function gsw_adiabatic_lapse_rate_ice + + elemental function gsw_alpha (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_alpha + end function gsw_alpha + + elemental function gsw_alpha_on_beta (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_alpha_on_beta + end function gsw_alpha_on_beta + + elemental function gsw_alpha_wrt_t_exact (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_alpha_wrt_t_exact + end function gsw_alpha_wrt_t_exact + + elemental function gsw_alpha_wrt_t_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_alpha_wrt_t_ice + end function gsw_alpha_wrt_t_ice + + elemental function gsw_beta (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_beta + end function gsw_beta + + elemental function gsw_beta_const_t_exact (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_beta_const_t_exact + end function gsw_beta_const_t_exact + + elemental function gsw_c_from_sp (sp, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sp, t, p + real (r8) :: gsw_c_from_sp + end function gsw_c_from_sp + + elemental function gsw_cabbeling (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_cabbeling + end function gsw_cabbeling + + elemental function gsw_chem_potential_water_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_chem_potential_water_ice + end function gsw_chem_potential_water_ice + + elemental function gsw_chem_potential_water_t_exact (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_chem_potential_water_t_exact + end function gsw_chem_potential_water_t_exact + + elemental function gsw_cp_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_cp_ice + end function gsw_cp_ice + + elemental subroutine gsw_ct_first_derivatives (sa, pt, ct_sa, ct_pt) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, pt + real (r8), intent(out), optional :: ct_sa, ct_pt + end subroutine gsw_ct_first_derivatives + + elemental subroutine gsw_ct_first_derivatives_wrt_t_exact (sa, t, p, & + ct_sa_wrt_t, ct_t_wrt_t, ct_p_wrt_t) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8), intent(out), optional :: ct_p_wrt_t, ct_sa_wrt_t, ct_t_wrt_t + end subroutine gsw_ct_first_derivatives_wrt_t_exact + + elemental function gsw_ct_freezing (sa, p, saturation_fraction, poly) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, saturation_fraction + logical, intent(in), optional :: poly + real (r8) :: gsw_ct_freezing + end function gsw_ct_freezing + + elemental function gsw_ct_freezing_exact (sa, p, saturation_fraction) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, saturation_fraction + real (r8) :: gsw_ct_freezing_exact + end function gsw_ct_freezing_exact + + elemental subroutine gsw_ct_freezing_first_derivatives (sa, p, & + saturation_fraction, ctfreezing_sa, ctfreezing_p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, saturation_fraction + real (r8), intent(out), optional :: ctfreezing_sa, ctfreezing_p + end subroutine gsw_ct_freezing_first_derivatives + + elemental subroutine gsw_ct_freezing_first_derivatives_poly (sa, p, & + saturation_fraction, ctfreezing_sa, ctfreezing_p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, saturation_fraction + real (r8), intent(out), optional :: ctfreezing_sa, ctfreezing_p + end subroutine gsw_ct_freezing_first_derivatives_poly + + elemental function gsw_ct_freezing_poly (sa, p, saturation_fraction) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, saturation_fraction + real (r8) :: gsw_ct_freezing_poly + end function gsw_ct_freezing_poly + + elemental function gsw_ct_from_enthalpy (sa, h, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, h, p + real (r8) :: gsw_ct_from_enthalpy + end function gsw_ct_from_enthalpy + + elemental function gsw_ct_from_enthalpy_exact (sa, h, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, h, p + real (r8) :: gsw_ct_from_enthalpy_exact + end function gsw_ct_from_enthalpy_exact + + elemental function gsw_ct_from_entropy (sa, entropy) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, entropy + real (r8) :: gsw_ct_from_entropy + end function gsw_ct_from_entropy + + elemental function gsw_ct_from_pt (sa, pt) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, pt + real (r8) :: gsw_ct_from_pt + end function gsw_ct_from_pt + + elemental subroutine gsw_ct_from_rho (rho, sa, p, ct, ct_multiple) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: rho, sa, p + real (r8), intent(out) :: ct + real (r8), intent(out), optional :: ct_multiple + end subroutine gsw_ct_from_rho + + elemental function gsw_ct_from_t (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_ct_from_t + end function gsw_ct_from_t + + elemental function gsw_ct_maxdensity (sa, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8) :: gsw_ct_maxdensity + end function gsw_ct_maxdensity + + elemental subroutine gsw_ct_second_derivatives (sa, pt, ct_sa_sa, ct_sa_pt, & + ct_pt_pt) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, pt + real (r8), intent(out), optional :: ct_sa_sa, ct_sa_pt, ct_pt_pt + end subroutine gsw_ct_second_derivatives + + elemental function gsw_deltasa_atlas (p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: p, long, lat + real (r8) :: gsw_deltasa_atlas + end function gsw_deltasa_atlas + + elemental function gsw_deltasa_from_sp (sp, p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sp, p, long, lat + real (r8) :: gsw_deltasa_from_sp + end function gsw_deltasa_from_sp + + elemental function gsw_dilution_coefficient_t_exact (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_dilution_coefficient_t_exact + end function gsw_dilution_coefficient_t_exact + + elemental function gsw_dynamic_enthalpy (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_dynamic_enthalpy + end function gsw_dynamic_enthalpy + + elemental function gsw_enthalpy (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_enthalpy + end function gsw_enthalpy + + elemental function gsw_enthalpy_ct_exact (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_enthalpy_ct_exact + end function gsw_enthalpy_ct_exact + + elemental function gsw_enthalpy_diff (sa, ct, p_shallow, p_deep) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p_shallow, p_deep + real (r8) :: gsw_enthalpy_diff + end function gsw_enthalpy_diff + + elemental subroutine gsw_enthalpy_first_derivatives (sa, ct, p, h_sa, h_ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8), intent(out), optional :: h_sa, h_ct + end subroutine gsw_enthalpy_first_derivatives + + elemental subroutine gsw_enthalpy_first_derivatives_ct_exact (sa, ct, p, & + h_sa, h_ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8), intent(out), optional :: h_sa, h_ct + end subroutine gsw_enthalpy_first_derivatives_ct_exact + + elemental function gsw_enthalpy_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_enthalpy_ice + end function gsw_enthalpy_ice + + elemental subroutine gsw_enthalpy_second_derivatives (sa, ct, p, h_sa_sa, & + h_sa_ct, h_ct_ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8), intent(out), optional :: h_sa_sa, h_sa_ct, h_ct_ct + end subroutine gsw_enthalpy_second_derivatives + + elemental subroutine gsw_enthalpy_second_derivatives_ct_exact (sa, ct, p, & + h_sa_sa, h_sa_ct, h_ct_ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8), intent(out), optional :: h_sa_sa, h_sa_ct, h_ct_ct + end subroutine gsw_enthalpy_second_derivatives_ct_exact + + elemental function gsw_enthalpy_sso_0 (p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: p + real (r8) :: gsw_enthalpy_sso_0 + end function gsw_enthalpy_sso_0 + + elemental function gsw_enthalpy_t_exact (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_enthalpy_t_exact + end function gsw_enthalpy_t_exact + + elemental subroutine gsw_entropy_first_derivatives (sa, ct, eta_sa, eta_ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8), intent(out), optional :: eta_sa, eta_ct + end subroutine gsw_entropy_first_derivatives + + elemental function gsw_entropy_from_pt (sa, pt) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, pt + real (r8) :: gsw_entropy_from_pt + end function gsw_entropy_from_pt + + elemental function gsw_entropy_from_t (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_entropy_from_t + end function gsw_entropy_from_t + + elemental function gsw_entropy_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_entropy_ice + end function gsw_entropy_ice + + elemental function gsw_entropy_part (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_entropy_part + end function gsw_entropy_part + + elemental function gsw_entropy_part_zerop (sa, pt0) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, pt0 + real (r8) :: gsw_entropy_part_zerop + end function gsw_entropy_part_zerop + + elemental subroutine gsw_entropy_second_derivatives (sa, ct, eta_sa_sa, & + eta_sa_ct, eta_ct_ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8), intent(out), optional :: eta_sa_sa, eta_sa_ct, eta_ct_ct + end subroutine gsw_entropy_second_derivatives + + elemental function gsw_fdelta (p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: p, long, lat + real (r8) :: gsw_fdelta + end function gsw_fdelta + + elemental subroutine gsw_frazil_properties (sa_bulk, h_bulk, p, & + sa_final, ct_final, w_ih_final) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa_bulk, h_bulk, p + real (r8), intent(out) :: sa_final, ct_final, w_ih_final + end subroutine gsw_frazil_properties + + elemental subroutine gsw_frazil_properties_potential (sa_bulk, h_pot_bulk,& + p, sa_final, ct_final, w_ih_final) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa_bulk, h_pot_bulk, p + real (r8), intent(out) :: sa_final, ct_final, w_ih_final + end subroutine gsw_frazil_properties_potential + + elemental subroutine gsw_frazil_properties_potential_poly (sa_bulk, & + h_pot_bulk, p, sa_final, ct_final, w_ih_final) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa_bulk, h_pot_bulk, p + real (r8), intent(out) :: sa_final, ct_final, w_ih_final + end subroutine gsw_frazil_properties_potential_poly + + elemental subroutine gsw_frazil_ratios_adiabatic (sa, p, w_ih, & + dsa_dct_frazil, dsa_dp_frazil, dct_dp_frazil) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, w_ih + real (r8), intent(out) :: dsa_dct_frazil, dsa_dp_frazil, dct_dp_frazil + end subroutine gsw_frazil_ratios_adiabatic + + elemental subroutine gsw_frazil_ratios_adiabatic_poly (sa, p, w_ih, & + dsa_dct_frazil, dsa_dp_frazil, dct_dp_frazil) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, w_ih + real (r8), intent(out) :: dsa_dct_frazil, dsa_dp_frazil, dct_dp_frazil + end subroutine gsw_frazil_ratios_adiabatic_poly + + pure function gsw_geo_strf_dyn_height (sa, ct, p, p_ref) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa(:), ct(:), p(:), p_ref + real (r8) :: gsw_geo_strf_dyn_height(size(sa)) + end function gsw_geo_strf_dyn_height + + pure subroutine gsw_geo_strf_dyn_height_pc (sa, ct, delta_p, & + geo_strf_dyn_height_pc, p_mid) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa(:), ct(:), delta_p(:) + real (r8), intent(out) :: geo_strf_dyn_height_pc(:), p_mid(:) + end subroutine gsw_geo_strf_dyn_height_pc + + elemental function gsw_gibbs (ns, nt, np, sa, t, p) + use gsw_mod_kinds + implicit none + integer, intent(in) :: ns, nt, np + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_gibbs + end function gsw_gibbs + + elemental function gsw_gibbs_ice (nt, np, t, p) + use gsw_mod_kinds + implicit none + integer, intent(in) :: nt, np + real (r8), intent(in) :: t, p + real (r8) :: gsw_gibbs_ice + end function gsw_gibbs_ice + + elemental function gsw_gibbs_ice_part_t (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_gibbs_ice_part_t + end function gsw_gibbs_ice_part_t + + elemental function gsw_gibbs_ice_pt0 (pt0) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: pt0 + real (r8) :: gsw_gibbs_ice_pt0 + end function gsw_gibbs_ice_pt0 + + elemental function gsw_gibbs_ice_pt0_pt0 (pt0) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: pt0 + real (r8) :: gsw_gibbs_ice_pt0_pt0 + end function gsw_gibbs_ice_pt0_pt0 + + elemental function gsw_gibbs_pt0_pt0 (sa, pt0) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, pt0 + real (r8) :: gsw_gibbs_pt0_pt0 + end function gsw_gibbs_pt0_pt0 + + elemental function gsw_grav (lat, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: lat, p + real (r8) :: gsw_grav + end function gsw_grav + + elemental function gsw_helmholtz_energy_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_helmholtz_energy_ice + end function gsw_helmholtz_energy_ice + + elemental function gsw_hill_ratio_at_sp2 (t) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t + real (r8) :: gsw_hill_ratio_at_sp2 + end function gsw_hill_ratio_at_sp2 + + elemental subroutine gsw_ice_fraction_to_freeze_seawater (sa, ct, p, & + t_ih, sa_freeze, ct_freeze, w_ih) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p, t_ih + real (r8), intent(out) :: sa_freeze, ct_freeze, w_ih + end subroutine gsw_ice_fraction_to_freeze_seawater + + elemental function gsw_internal_energy (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_internal_energy + end function gsw_internal_energy + + elemental function gsw_internal_energy_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_internal_energy_ice + end function gsw_internal_energy_ice + + pure subroutine gsw_ipv_vs_fnsquared_ratio (sa, ct, p, p_ref, & + ipv_vs_fnsquared_ratio, p_mid) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa(:), ct(:), p(:), p_ref + real (r8), intent(out) :: ipv_vs_fnsquared_ratio(:), p_mid(:) + end subroutine gsw_ipv_vs_fnsquared_ratio + + elemental function gsw_kappa (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_kappa + end function gsw_kappa + + elemental function gsw_kappa_const_t_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_kappa_const_t_ice + end function gsw_kappa_const_t_ice + + elemental function gsw_kappa_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_kappa_ice + end function gsw_kappa_ice + + elemental function gsw_kappa_t_exact (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_kappa_t_exact + end function gsw_kappa_t_exact + + elemental function gsw_latentheat_evap_ct (sa, ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8) :: gsw_latentheat_evap_ct + end function gsw_latentheat_evap_ct + + elemental function gsw_latentheat_evap_t (sa, t) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t + real (r8) :: gsw_latentheat_evap_t + end function gsw_latentheat_evap_t + + elemental function gsw_latentheat_melting (sa, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8) :: gsw_latentheat_melting + end function gsw_latentheat_melting + + pure subroutine gsw_linear_interp_sa_ct (sa, ct, p, p_i, sa_i, ct_i) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa(:), ct(:), p(:), p_i(:) + real (r8), intent(out) :: sa_i(:), ct_i(:) + end subroutine gsw_linear_interp_sa_ct + + elemental function gsw_melting_ice_equilibrium_sa_ct_ratio (sa, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8) :: gsw_melting_ice_equilibrium_sa_ct_ratio + end function gsw_melting_ice_equilibrium_sa_ct_ratio + + elemental function gsw_melting_ice_equilibrium_sa_ct_ratio_poly (sa, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8) :: gsw_melting_ice_equilibrium_sa_ct_ratio_poly + end function gsw_melting_ice_equilibrium_sa_ct_ratio_poly + + elemental subroutine gsw_melting_ice_into_seawater (sa, ct, p, w_ih, t_ih,& + sa_final, ct_final, w_ih_final) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p, w_ih, t_ih + real (r8), intent(out) :: sa_final, ct_final, w_ih_final + end subroutine gsw_melting_ice_into_seawater + + elemental function gsw_melting_ice_sa_ct_ratio (sa, ct, p, t_ih) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p, t_ih + real (r8) :: gsw_melting_ice_sa_ct_ratio + end function gsw_melting_ice_sa_ct_ratio + + elemental function gsw_melting_ice_sa_ct_ratio_poly (sa, ct, p, t_ih) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p, t_ih + real (r8) :: gsw_melting_ice_sa_ct_ratio_poly + end function gsw_melting_ice_sa_ct_ratio_poly + + elemental function gsw_melting_seaice_equilibrium_sa_ct_ratio (sa, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8) :: gsw_melting_seaice_equilibrium_sa_ct_ratio + end function gsw_melting_seaice_equilibrium_sa_ct_ratio + + elemental function gsw_melting_seaice_equilibrium_sa_ct_ratio_poly (sa, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8) :: gsw_melting_seaice_equilibrium_sa_ct_ratio_poly + end function gsw_melting_seaice_equilibrium_sa_ct_ratio_poly + + elemental subroutine gsw_melting_seaice_into_seawater (sa, ct, p, & + w_seaice, sa_seaice, t_seaice, sa_final, ct_final) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p, w_seaice, sa_seaice, t_seaice + real (r8), intent(out) :: sa_final, ct_final + end subroutine gsw_melting_seaice_into_seawater + + elemental function gsw_melting_seaice_sa_ct_ratio (sa, ct, p, sa_seaice, & + t_seaice) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p, sa_seaice, t_seaice + real (r8) :: gsw_melting_seaice_sa_ct_ratio + end function gsw_melting_seaice_sa_ct_ratio + + elemental function gsw_melting_seaice_sa_ct_ratio_poly (sa, ct, p, & + sa_seaice, t_seaice) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p, sa_seaice, t_seaice + real (r8) :: gsw_melting_seaice_sa_ct_ratio_poly + end function gsw_melting_seaice_sa_ct_ratio_poly + + pure function gsw_mlp (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa(:), ct(:), p(:) + real (r8) :: gsw_mlp + end function gsw_mlp + + pure subroutine gsw_nsquared (sa, ct, p, lat, n2, p_mid) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa(:), ct(:), p(:), lat(:) + real (r8), intent(out) :: n2(:), p_mid(:) + end subroutine gsw_nsquared + + elemental function gsw_nsquared_lowerlimit (p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: p, long, lat + real (r8) :: gsw_nsquared_lowerlimit + end function gsw_nsquared_lowerlimit + + pure subroutine gsw_nsquared_min (sa, ct, p, lat, n2, n2_p, & + n2_specvol, n2_alpha, n2_beta, dsa, dct, dp) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa(:), ct(:), p(:), lat(:) + real (r8), intent(out) :: n2(:), n2_p(:), n2_specvol(:), n2_alpha(:) + real (r8), intent(out) :: n2_beta(:), dsa(:), dct(:), dp(:) + end subroutine gsw_nsquared_min + + pure subroutine gsw_nsquared_min_const_t (sa, t, p, lat, n2, n2_p, & + n2_specvol, n2_alpha, n2_beta, dsa, dct, dp, n2_beta_ratio) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa(:), t(:), p(:), lat + real (r8), intent(out) :: n2(:), n2_p(:), n2_specvol(:), n2_alpha(:) + real (r8), intent(out) :: n2_beta(:), dsa(:), dct(:), dp(:) + real (r8), intent(out) :: n2_beta_ratio(:) + end subroutine gsw_nsquared_min_const_t + + elemental function gsw_p_from_z (z, lat, geo_strf_dyn_height, & + sea_surface_geopotental) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: z, lat + real (r8), intent(in), optional :: geo_strf_dyn_height + real (r8), intent(in), optional :: sea_surface_geopotental + real (r8) :: gsw_p_from_z + end function gsw_p_from_z + + elemental function gsw_pot_enthalpy_from_pt_ice (pt0_ice) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: pt0_ice + real (r8) :: gsw_pot_enthalpy_from_pt_ice + end function gsw_pot_enthalpy_from_pt_ice + + elemental function gsw_pot_enthalpy_from_pt_ice_poly (pt0_ice) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: pt0_ice + real (r8) :: gsw_pot_enthalpy_from_pt_ice_poly + end function gsw_pot_enthalpy_from_pt_ice_poly + + elemental function gsw_pot_enthalpy_ice_freezing (sa, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8) :: gsw_pot_enthalpy_ice_freezing + end function gsw_pot_enthalpy_ice_freezing + + elemental subroutine gsw_pot_enthalpy_ice_freezing_first_derivatives (sa, & + p, pot_enthalpy_ice_freezing_sa, pot_enthalpy_ice_freezing_p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8), intent(out), optional :: pot_enthalpy_ice_freezing_sa + real (r8), intent(out), optional :: pot_enthalpy_ice_freezing_p + end subroutine gsw_pot_enthalpy_ice_freezing_first_derivatives + + elemental subroutine gsw_pot_enthalpy_ice_freezing_first_derivatives_poly(& + sa, p, pot_enthalpy_ice_freezing_sa, pot_enthalpy_ice_freezing_p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8), intent(out), optional :: pot_enthalpy_ice_freezing_sa + real (r8), intent(out), optional :: pot_enthalpy_ice_freezing_p + end subroutine gsw_pot_enthalpy_ice_freezing_first_derivatives_poly + + elemental function gsw_pot_enthalpy_ice_freezing_poly (sa, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8) :: gsw_pot_enthalpy_ice_freezing_poly + end function gsw_pot_enthalpy_ice_freezing_poly + + elemental function gsw_pot_rho_t_exact (sa, t, p, p_ref) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p, p_ref + real (r8) :: gsw_pot_rho_t_exact + end function gsw_pot_rho_t_exact + + elemental function gsw_pressure_coefficient_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_pressure_coefficient_ice + end function gsw_pressure_coefficient_ice + + elemental function gsw_pressure_freezing_ct (sa, ct, saturation_fraction) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, saturation_fraction + real (r8) :: gsw_pressure_freezing_ct + end function gsw_pressure_freezing_ct + + elemental function gsw_pt0_cold_ice_poly (pot_enthalpy_ice) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: pot_enthalpy_ice + real (r8) :: gsw_pt0_cold_ice_poly + end function gsw_pt0_cold_ice_poly + + elemental function gsw_pt0_from_t (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_pt0_from_t + end function gsw_pt0_from_t + + elemental function gsw_pt0_from_t_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_pt0_from_t_ice + end function gsw_pt0_from_t_ice + + elemental subroutine gsw_pt_first_derivatives (sa, ct, pt_sa, pt_ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8), intent(out), optional :: pt_sa, pt_ct + end subroutine gsw_pt_first_derivatives + + elemental function gsw_pt_from_ct (sa, ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8) :: gsw_pt_from_ct + end function gsw_pt_from_ct + + elemental function gsw_pt_from_entropy (sa, entropy) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, entropy + real (r8) :: gsw_pt_from_entropy + end function gsw_pt_from_entropy + + elemental function gsw_pt_from_pot_enthalpy_ice (pot_enthalpy_ice) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: pot_enthalpy_ice + real (r8) :: gsw_pt_from_pot_enthalpy_ice + end function gsw_pt_from_pot_enthalpy_ice + + elemental function gsw_pt_from_pot_enthalpy_ice_poly (pot_enthalpy_ice) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: pot_enthalpy_ice + real (r8) :: gsw_pt_from_pot_enthalpy_ice_poly + end function gsw_pt_from_pot_enthalpy_ice_poly + + elemental function gsw_pt_from_pot_enthalpy_ice_poly_dh (pot_enthalpy_ice) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: pot_enthalpy_ice + real (r8) :: gsw_pt_from_pot_enthalpy_ice_poly_dh + end function gsw_pt_from_pot_enthalpy_ice_poly_dh + + elemental function gsw_pt_from_t (sa, t, p, p_ref) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p, p_ref + real (r8) :: gsw_pt_from_t + end function gsw_pt_from_t + + elemental function gsw_pt_from_t_ice (t, p, p_ref) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p, p_ref + real (r8) :: gsw_pt_from_t_ice + end function gsw_pt_from_t_ice + + elemental subroutine gsw_pt_second_derivatives (sa, ct, pt_sa_sa, & + pt_sa_ct, pt_ct_ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8), intent(out), optional :: pt_sa_sa, pt_sa_ct, pt_ct_ct + end subroutine gsw_pt_second_derivatives + + elemental function gsw_rho (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_rho + end function gsw_rho + + elemental subroutine gsw_rho_alpha_beta (sa, ct, p, rho, alpha, beta) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8), intent(out), optional :: rho, alpha, beta + end subroutine gsw_rho_alpha_beta + + elemental subroutine gsw_rho_alpha_beta_bsq (sa, ct, p, rho, alpha, beta, & + stiffened) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + logical, intent(in), optional :: stiffened + real (r8), intent(out) :: rho + real (r8), intent(out), optional :: alpha, beta + end subroutine gsw_rho_alpha_beta_bsq + + elemental subroutine gsw_rho_first_derivatives (sa, ct, p, drho_dsa, & + drho_dct, drho_dp) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8), intent(out), optional :: drho_dsa, drho_dct, drho_dp + end subroutine gsw_rho_first_derivatives + + elemental subroutine gsw_rho_first_derivatives_wrt_enthalpy (sa, ct, p, & + rho_sa, rho_h) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8), intent(out), optional :: rho_sa, rho_h + end subroutine gsw_rho_first_derivatives_wrt_enthalpy + + elemental function gsw_rho_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_rho_ice + end function gsw_rho_ice + + elemental subroutine gsw_rho_second_derivatives (sa, ct, p, rho_sa_sa, & + rho_sa_ct, rho_ct_ct, rho_sa_p, rho_ct_p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8), intent(out), optional :: rho_sa_sa, rho_sa_ct, rho_ct_ct + real (r8), intent(out), optional :: rho_sa_p, rho_ct_p + end subroutine gsw_rho_second_derivatives + + elemental subroutine gsw_rho_second_derivatives_wrt_enthalpy (sa, ct, p, & + rho_sa_sa, rho_sa_h, rho_h_h) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8), intent(out), optional :: rho_sa_sa, rho_sa_h, rho_h_h + end subroutine gsw_rho_second_derivatives_wrt_enthalpy + + elemental function gsw_rho_t_exact (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_rho_t_exact + end function gsw_rho_t_exact + + pure subroutine gsw_rr68_interp_sa_ct (sa, ct, p, p_i, sa_i, ct_i) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa(:), ct(:), p(:), p_i(:) + real (r8), intent(out) :: sa_i(:), ct_i(:) + end subroutine gsw_rr68_interp_sa_ct + + elemental function gsw_sa_freezing_estimate (p, saturation_fraction, ct, t) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: p, saturation_fraction + real (r8), intent(in), optional :: ct, t + real (r8) :: gsw_sa_freezing_estimate + end function gsw_sa_freezing_estimate + + elemental function gsw_sa_freezing_from_ct (ct, p, saturation_fraction) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: ct, p, saturation_fraction + real (r8) :: gsw_sa_freezing_from_ct + end function gsw_sa_freezing_from_ct + + elemental function gsw_sa_freezing_from_ct_poly (ct, p, saturation_fraction) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: ct, p, saturation_fraction + real (r8) :: gsw_sa_freezing_from_ct_poly + end function gsw_sa_freezing_from_ct_poly + + elemental function gsw_sa_freezing_from_t (t, p, saturation_fraction) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p, saturation_fraction + real (r8) :: gsw_sa_freezing_from_t + end function gsw_sa_freezing_from_t + + elemental function gsw_sa_freezing_from_t_poly (t, p, saturation_fraction) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p, saturation_fraction + real (r8) :: gsw_sa_freezing_from_t_poly + end function gsw_sa_freezing_from_t_poly + + elemental function gsw_sa_from_rho (rho, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: rho, ct, p + real (r8) :: gsw_sa_from_rho + end function gsw_sa_from_rho + + elemental function gsw_sa_from_sp (sp, p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sp, p, long, lat + real (r8) :: gsw_sa_from_sp + end function gsw_sa_from_sp + + elemental function gsw_sa_from_sp_baltic (sp, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sp, long, lat + real (r8) :: gsw_sa_from_sp_baltic + end function gsw_sa_from_sp_baltic + + elemental function gsw_sa_from_sstar (sstar, p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sstar, p, long, lat + real (r8) :: gsw_sa_from_sstar + end function gsw_sa_from_sstar + + elemental function gsw_sa_p_inrange (sa, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + logical :: gsw_sa_p_inrange + end function gsw_sa_p_inrange + + elemental function gsw_saar (p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: p, long, lat + real (r8) :: gsw_saar + end function gsw_saar + + elemental subroutine gsw_seaice_fraction_to_freeze_seawater (sa, ct, p, & + sa_seaice, t_seaice, sa_freeze, ct_freeze, w_seaice) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p, sa_seaice, t_seaice + real (r8), intent(out) :: sa_freeze, ct_freeze, w_seaice + end subroutine gsw_seaice_fraction_to_freeze_seawater + + elemental function gsw_sigma0 (sa, ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8) :: gsw_sigma0 + end function gsw_sigma0 + + elemental function gsw_sigma1 (sa, ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8) :: gsw_sigma1 + end function gsw_sigma1 + + elemental function gsw_sigma2 (sa, ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8) :: gsw_sigma2 + end function gsw_sigma2 + + elemental function gsw_sigma3 (sa, ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8) :: gsw_sigma3 + end function gsw_sigma3 + + elemental function gsw_sigma4 (sa, ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8) :: gsw_sigma4 + end function gsw_sigma4 + + elemental function gsw_sound_speed (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_sound_speed + end function gsw_sound_speed + + elemental function gsw_sound_speed_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_sound_speed_ice + end function gsw_sound_speed_ice + + elemental function gsw_sound_speed_t_exact (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_sound_speed_t_exact + end function gsw_sound_speed_t_exact + + elemental function gsw_sp_from_c (c, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: c, t, p + real (r8) :: gsw_sp_from_c + end function gsw_sp_from_c + + elemental function gsw_sp_from_sa (sa, p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, long, lat + real (r8) :: gsw_sp_from_sa + end function gsw_sp_from_sa + + elemental function gsw_sp_from_sa_baltic (sa, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, long, lat + real (r8) :: gsw_sp_from_sa_baltic + end function gsw_sp_from_sa_baltic + + elemental function gsw_sp_from_sk (sk) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sk + real (r8) :: gsw_sp_from_sk + end function gsw_sp_from_sk + + elemental function gsw_sp_from_sr (sr) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sr + real (r8) :: gsw_sp_from_sr + end function gsw_sp_from_sr + + elemental function gsw_sp_from_sstar (sstar, p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sstar, p, long, lat + real (r8) :: gsw_sp_from_sstar + end function gsw_sp_from_sstar + + elemental function gsw_specvol (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_specvol + end function gsw_specvol + + elemental subroutine gsw_specvol_alpha_beta (sa, ct, p, specvol, alpha, & + beta) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8), intent(out), optional :: specvol, alpha, beta + end subroutine gsw_specvol_alpha_beta + + elemental function gsw_specvol_anom_standard (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_specvol_anom_standard + end function gsw_specvol_anom_standard + + elemental subroutine gsw_specvol_first_derivatives (sa, ct, p, v_sa, v_ct, & + v_p, iflag) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + integer, intent(in), optional :: iflag + real (r8), intent(out), optional :: v_sa, v_ct, v_p + end subroutine gsw_specvol_first_derivatives + + elemental subroutine gsw_specvol_first_derivatives_wrt_enthalpy (sa, ct, & + p, v_sa, v_h, iflag) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + integer, intent(in), optional :: iflag + real (r8), intent(out), optional :: v_sa, v_h + end subroutine gsw_specvol_first_derivatives_wrt_enthalpy + + elemental function gsw_specvol_ice (t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: t, p + real (r8) :: gsw_specvol_ice + end function gsw_specvol_ice + + elemental subroutine gsw_specvol_second_derivatives (sa, ct, p, v_sa_sa, & + v_sa_ct, v_ct_ct, v_sa_p, v_ct_p, iflag) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + integer, intent(in), optional :: iflag + real (r8), intent(out), optional :: v_sa_sa, v_sa_ct, v_ct_ct, v_sa_p, v_ct_p + end subroutine gsw_specvol_second_derivatives + + elemental subroutine gsw_specvol_second_derivatives_wrt_enthalpy (sa, ct, & + p, v_sa_sa, v_sa_h, v_h_h, iflag) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + integer, intent(in), optional :: iflag + real (r8), intent(out), optional :: v_sa_sa, v_sa_h, v_h_h + end subroutine gsw_specvol_second_derivatives_wrt_enthalpy + + elemental function gsw_specvol_sso_0 (p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: p + real (r8) :: gsw_specvol_sso_0 + end function gsw_specvol_sso_0 + + elemental function gsw_specvol_t_exact (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_specvol_t_exact + end function gsw_specvol_t_exact + + elemental function gsw_spiciness0 (sa, ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8) :: gsw_spiciness0 + end function gsw_spiciness0 + + elemental function gsw_spiciness1 (sa, ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8) :: gsw_spiciness1 + end function gsw_spiciness1 + + elemental function gsw_spiciness2 (sa, ct) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct + real (r8) :: gsw_spiciness2 + end function gsw_spiciness2 + + elemental function gsw_sr_from_sp (sp) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sp + real (r8) :: gsw_sr_from_sp + end function gsw_sr_from_sp + + elemental function gsw_sstar_from_sa (sa, p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, long, lat + real (r8) :: gsw_sstar_from_sa + end function gsw_sstar_from_sa + + elemental function gsw_sstar_from_sp (sp, p, long, lat) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sp, p, long, lat + real (r8) :: gsw_sstar_from_sp + end function gsw_sstar_from_sp + + elemental function gsw_t_deriv_chem_potential_water_t_exact (sa, t, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, t, p + real (r8) :: gsw_t_deriv_chem_potential_water_t_exact + end function gsw_t_deriv_chem_potential_water_t_exact + + elemental function gsw_t_freezing (sa, p, saturation_fraction, poly) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, saturation_fraction + logical, intent(in), optional :: poly + real (r8) :: gsw_t_freezing + end function gsw_t_freezing + + elemental function gsw_t_freezing_exact (sa, p, saturation_fraction) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, saturation_fraction + real (r8) :: gsw_t_freezing_exact + end function gsw_t_freezing_exact + + elemental subroutine gsw_t_freezing_first_derivatives (sa, p, & + saturation_fraction, tfreezing_sa, tfreezing_p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, saturation_fraction + real (r8), intent(out), optional :: tfreezing_sa, tfreezing_p + end subroutine gsw_t_freezing_first_derivatives + + elemental subroutine gsw_t_freezing_first_derivatives_poly (sa, p, & + saturation_fraction, tfreezing_sa, tfreezing_p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p, saturation_fraction + real (r8), intent(out), optional :: tfreezing_sa, tfreezing_p + end subroutine gsw_t_freezing_first_derivatives_poly + + elemental function gsw_t_freezing_poly (sa, p, saturation_fraction, polynomial) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, p + real (r8), intent(in), optional :: saturation_fraction + logical, intent(in), optional :: polynomial + real (r8) :: gsw_t_freezing_poly + end function gsw_t_freezing_poly + + elemental function gsw_t_from_ct (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_t_from_ct + end function gsw_t_from_ct + + elemental function gsw_t_from_pt0_ice (pt0_ice, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: pt0_ice, p + real (r8) :: gsw_t_from_pt0_ice + end function gsw_t_from_pt0_ice + + elemental function gsw_thermobaric (sa, ct, p) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa, ct, p + real (r8) :: gsw_thermobaric + end function gsw_thermobaric + + pure subroutine gsw_turner_rsubrho (sa, ct, p, tu, rsubrho, p_mid) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: sa(:), ct(:), p(:) + real (r8), intent(out) :: tu(:), rsubrho(:), p_mid(:) + end subroutine gsw_turner_rsubrho + + pure subroutine gsw_util_indx (x, n, z, k) + use gsw_mod_kinds + integer, intent(in) :: n + integer, intent(out) :: k + real (r8), intent(in), dimension(n) :: x + real (r8), intent(in) :: z + end subroutine gsw_util_indx + + pure function gsw_util_interp1q_int (x, iy, x_i) result(y_i) + use gsw_mod_kinds + implicit none + integer, intent(in) :: iy(:) + real (r8), intent(in) :: x(:), x_i(:) + real (r8) :: y_i(size(x_i)) + end function gsw_util_interp1q_int + + pure function gsw_util_sort_real (rarray) result(iarray) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: rarray(:) ! Values to be sorted + integer :: iarray(size(rarray)) ! Sorted ids + end function gsw_util_sort_real + + pure function gsw_util_xinterp1 (x, y, n, x0) + use gsw_mod_kinds + implicit none + integer, intent(in) :: n + real (r8), intent(in) :: x0 + real (r8), dimension(n), intent(in) :: x, y + real (r8) :: gsw_util_xinterp1 + end function gsw_util_xinterp1 + + elemental function gsw_z_from_p (p, lat, geo_strf_dyn_height, & + sea_surface_geopotental) + use gsw_mod_kinds + implicit none + real (r8), intent(in) :: p, lat + real (r8), intent(in), optional :: geo_strf_dyn_height + real (r8), intent(in), optional :: sea_surface_geopotental + real (r8) :: gsw_z_from_p + end function gsw_z_from_p + +end interface + +end module gsw_mod_toolbox diff --git a/src/PHYS/gsw_p_from_z.f90 b/src/PHYS/gsw_p_from_z.f90 new file mode 100644 index 00000000..4b7e861a --- /dev/null +++ b/src/PHYS/gsw_p_from_z.f90 @@ -0,0 +1,89 @@ +!========================================================================== +elemental function gsw_p_from_z (z, lat, geo_strf_dyn_height, & + sea_surface_geopotental) +!========================================================================== +! +! Calculates sea pressure from height using computationally-efficient +! 75-term expression for density, in terms of SA, CT and p (Roquet et al., +! 2015). Dynamic height anomaly, geo_strf_dyn_height, if provided, +! must be computed with its p_ref = 0 (the surface). Also if provided, +! sea_surface_geopotental is the geopotential at zero sea pressure. This +! function solves Eqn.(3.32.3) of IOC et al. (2010) iteratively for p. +! +! Note. Height (z) is NEGATIVE in the ocean. Depth is -z. +! Depth is not used in the GSW computer software library. +! +! z = height [ m ] +! lat = latitude in decimal degrees north [ -90 ... +90 ] +! +! OPTIONAL: +! geo_strf_dyn_height = dynamic height anomaly [ m^2/s^2 ] +! Note that the reference pressure, p_ref, of geo_strf_dyn_height must +! be zero (0) dbar. +! sea_surface_geopotental = geopotential at zero sea pressure [ m^2/s^2 ] +! +! p = sea pressure [ dbar ] +! ( i.e. absolute pressure - 10.1325 dbar ) +!========================================================================== + +use gsw_mod_toolbox, only : gsw_enthalpy_sso_0, gsw_specvol_sso_0 + +use gsw_mod_teos10_constants, only : db2pa, deg2rad, gamma + +use gsw_mod_kinds + +implicit none + +real (r8), intent(in) :: z, lat +real (r8), intent(in), optional :: geo_strf_dyn_height +real (r8), intent(in), optional :: sea_surface_geopotental + +real (r8) :: gsw_p_from_z + +real (r8) :: c1, df_dp, f, g, gs, p, p_mid, p_old, sin2 +real (r8) :: gsdh, ssg + +if (present(geo_strf_dyn_height)) then + gsdh = geo_strf_dyn_height +else + gsdh = 0.0_r8 +end if + +if (present(sea_surface_geopotental)) then + ssg = sea_surface_geopotental +else + ssg = 0.0_r8 +end if + +g = gamma ! If the graviational acceleration were to be regarded as + ! being depth-independent, which is often the case in + ! ocean models, then g would be set to be zero here, + ! and the code below works perfectly well. + +sin2 = sin(lat*deg2rad)**2 +gs = 9.780327_r8*(1.0_r8 + (5.2792e-3_r8 + (2.32e-5_r8*sin2))*sin2) + +! Get the first estimate of p from Saunders (1981) +c1 = 5.25e-3_r8*sin2 + 5.92e-3_r8 +p = -2.0_r8*z/((1.0_r8-c1) + sqrt((1.0_r8-c1)*(1.0_r8-c1) + 8.84e-6_r8*z)) + +! Initial value of the derivative of f +df_dp = db2pa*gsw_specvol_sso_0(p) + +f = gsw_enthalpy_sso_0(p) + gs*(z - 0.5_r8*g*(z*z)) - (gsdh + ssg) +p_old = p +p = p_old - f/df_dp +p_mid = 0.5_r8*(p + p_old) +df_dp = db2pa*gsw_specvol_sso_0(p_mid) +p = p_old - f/df_dp + +! After this one iteration through this modified Newton-Raphson iterative +! procedure (McDougall and Wotherspoon, 2013), the remaining error in p is +! at computer machine precision, being no more than 1.6e-10 dbar. + +gsw_p_from_z = p + +return +end function + +!-------------------------------------------------------------------------- diff --git a/src/PHYS/gsw_pt_from_t.f90 b/src/PHYS/gsw_pt_from_t.f90 new file mode 100644 index 00000000..e181450e --- /dev/null +++ b/src/PHYS/gsw_pt_from_t.f90 @@ -0,0 +1,61 @@ +!========================================================================== +elemental function gsw_pt_from_t (sa, t, p, p_ref) +!========================================================================== +! +! Calculates potential temperature of seawater from in-situ temperature +! +! sa : Absolute Salinity [g/kg] +! t : in-situ temperature [deg C] +! p : sea pressure [dbar] +! p_ref : reference sea pressure [dbar] +! +! gsw_pt_from_t : potential temperature [deg C] +!-------------------------------------------------------------------------- + +use gsw_mod_toolbox, only : gsw_entropy_part, gsw_gibbs + +use gsw_mod_teos10_constants, only : gsw_cp0, gsw_sso, gsw_t0, gsw_ups + +use gsw_mod_kinds + +implicit none + +real (r8), intent(in) :: sa, t, p, p_ref + +real (r8) :: gsw_pt_from_t + +integer no_iter +real (r8) :: s1, pt, pt_old, dentropy, dentropy_dt +real (r8) :: true_entropy_part, ptm + +integer, parameter :: n0=0, n2=2 + +s1 = sa/gsw_ups + +pt = t + (p-p_ref)*( 8.65483913395442e-6_r8 - & + s1 * 1.41636299744881e-6_r8 - & + (p+p_ref)* 7.38286467135737e-9_r8 + & + t *(-8.38241357039698e-6_r8 + & + s1 * 2.83933368585534e-8_r8 + & + t * 1.77803965218656e-8_r8 + & + (p+p_ref)* 1.71155619208233e-10_r8)) + +dentropy_dt = gsw_cp0/((gsw_t0 + pt)*(1.0_r8 - 0.05_r8*(1.0_r8 - sa/gsw_sso))) + +true_entropy_part = gsw_entropy_part(sa,t,p) + +do no_iter = 1, 2 + pt_old = pt + dentropy = gsw_entropy_part(sa,pt_old,p_ref) - true_entropy_part + pt = pt_old - dentropy/dentropy_dt + ptm = 0.5_r8*(pt + pt_old) + dentropy_dt = -gsw_gibbs(n0,n2,n0,sa,ptm,p_ref) + pt = pt_old - dentropy/dentropy_dt +end do + +gsw_pt_from_t = pt + +return +end function + +!-------------------------------------------------------------------------- diff --git a/src/PHYS/gsw_specvol_sso_0.f90 b/src/PHYS/gsw_specvol_sso_0.f90 new file mode 100644 index 00000000..84bf3c02 --- /dev/null +++ b/src/PHYS/gsw_specvol_sso_0.f90 @@ -0,0 +1,32 @@ +!========================================================================== +elemental function gsw_specvol_sso_0 (p) +!========================================================================== +! This function calculates specifc volume at the Standard Ocean Salinity, +! SSO, and at a Conservative Temperature of zero degrees C, as a function +! of pressure, p, in dbar, using a streamlined version of the CT version +! of specific volume, that is, a streamlined version of the code +! "gsw_specvol(SA,CT,p)". +!========================================================================== + +use gsw_mod_specvol_coefficients + +use gsw_mod_kinds + +implicit none + +real (r8), intent(in) :: p + +real (r8) :: gsw_specvol_sso_0 + +real (r8) :: z + +z = p*1e-4_r8 + +gsw_specvol_sso_0 = 9.726613854843870e-04_r8 + z*(-4.505913211160929e-05_r8 & + + z*(7.130728965927127e-06_r8 + z*(-6.657179479768312e-07_r8 & + + z*(-2.994054447232880e-08_r8 + z*(v005 + v006*z))))) + +return +end function + +!-------------------------------------------------------------------------- From ca11aec4d71c46168868e213d7423d5cf57d38d9 Mon Sep 17 00:00:00 2001 From: gzuccarino Date: Tue, 31 Mar 2026 10:35:42 +0200 Subject: [PATCH 18/25] compute in situ temperature in physics loading --- src/IO/forcing_phys.f90 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/IO/forcing_phys.f90 b/src/IO/forcing_phys.f90 index 4f5fc653..70b9a493 100644 --- a/src/IO/forcing_phys.f90 +++ b/src/IO/forcing_phys.f90 @@ -125,7 +125,8 @@ SUBROUTINE LOAD_PHYS(datestring) USE calendar USE myalloc USE TIME_MANAGER - + USE gsw_mod_toolbox, only : gsw_pt_from_t, gsw_p_from_z + IMPLICIT NONE character(LEN=17), INTENT(IN) :: datestring @@ -139,6 +140,7 @@ SUBROUTINE LOAD_PHYS(datestring) double precision, dimension(jpj,jpi) :: e1u_x_e2u, e1v_x_e2v, e1t_x_e2t double precision correction_e3t, s0,s1,s2 double precision kz_threshold, Kz_background, Kmin + double precision z, lat, pfz integer Ind_50m, Ind_150m, Ind_bottom if (variable_rdt) then @@ -185,6 +187,20 @@ SUBROUTINE LOAD_PHYS(datestring) call readnc_slice_float(nomefile,'vosaline',buf,ingv_lon_shift) sdta(:,:,:,2) = buf*tmask + do ji = 1, jpi + do jj = 1, jpj + do jk = 1, jpk + if (tmask(jk,jj,ji) .ne. 0.) then + z = -gdept(jk,jj,ji) ! get depth for a Tracer point + lat = gphit(jj,ji) ! get latitude for a Tracer point + pfz = gsw_p_from_z(z, lat) ! compute pressure at depth z and latitude lat + tdta(jk,jj,ji,2) = gsw_pt_from_t(sdta(jk,jj,ji,2), tdta(jk,jj,ji,2), 0.0d0, pfz) + endif + end do + end do + end do + + if (mld_flag) then call readnc_slice_float_2d(nomefile,'somxl010',buf2,ingv_lon_shift) avtdta(:,:,:,2)=0.0 From 373ee851a81f7212f0ea369140a44bc36ac51df6 Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Mon, 13 Apr 2026 16:57:49 +0200 Subject: [PATCH 19/25] merging from neccton, forcings and optics are in yyyy/mm dirs, tco3 and tclw are function of time instead of climatologies --- src/IO/forcing_atm_clim.f90 | 11 ----------- src/IO/forcing_kext.f90 | 25 +++++++++++++++++++------ src/IO/forcing_phys.f90 | 28 +++++++++++++++++----------- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/IO/forcing_atm_clim.f90 b/src/IO/forcing_atm_clim.f90 index 657a2364..4624cac2 100644 --- a/src/IO/forcing_atm_clim.f90 +++ b/src/IO/forcing_atm_clim.f90 @@ -116,12 +116,6 @@ SUBROUTINE LOAD_climatm(datestring) if(lwp) write(*,'(A,I4,A,A)') "LOAD_KEXT --> I am ", myrank, " starting reading atmospheric fields from ", nomefile - call readnc_slice_float_2d(nomefile,'tclw',buf2,0) - tclwIO(:,:,2) = buf2*tmask(1,:,:) - - call readnc_slice_float_2d(nomefile,'tco3',buf2,0) - tco3IO(:,:,2) = buf2*tmask(1,:,:) - call readnc_slice_float_2d(nomefile,'cdrem',buf2,0) cdremIO(:,:,2) = buf2*tmask(1,:,:) @@ -149,9 +143,6 @@ SUBROUTINE ACTUALIZE_climatm(zweigh) double precision, INTENT(IN) :: zweigh - - call actualize(zweigh,tclwIO,tclw) - call actualize(zweigh,tco3IO,tco3) call actualize(zweigh,cdremIO,cdrem) call actualize(zweigh,cldtcmIO,cldtcm) @@ -174,8 +165,6 @@ SUBROUTINE swap_climatm USE OPT_mem IMPLICIT NONE - call swap(tclwIO) - call swap(tco3IO) call swap(cdremIO) call swap(cldtcmIO) diff --git a/src/IO/forcing_kext.f90 b/src/IO/forcing_kext.f90 index 513c3672..6ed33653 100644 --- a/src/IO/forcing_kext.f90 +++ b/src/IO/forcing_kext.f90 @@ -106,14 +106,20 @@ SUBROUTINE LOAD_KEXT(datestring) CHARACTER(LEN=17), INTENT(IN) :: datestring - character(LEN=31) nomefile + character(LEN=39) nomefile, fileformat + character(LEN=4) yyyy + character(LEN=2) mm - nomefile='OPTICS/atm_yyyy0107-00:00:00.nc' + + nomefile='OPTICS/2019/12/atm.20191207-03:00:00.nc' + fileformat='("OPTICS/",A4,"/",A2,"/atm.",A17,".nc")' ! Starting I/O ! ********************************************************** - nomefile = 'OPTICS/atm.'//datestring//'.nc' + yyyy = datestring(1:4) + mm = datestring(5:6) + write(nomefile,fileformat) yyyy,mm,datestring if(lwp) write(*,'(A,I4,A,A)') "LOAD_KEXT --> I am ", myrank, " starting reading atmospheric fields from ", nomefile @@ -135,6 +141,12 @@ SUBROUTINE LOAD_KEXT(datestring) call readnc_slice_float_2d(nomefile,'w10',buf2,0) w10IO(:,:,2) = buf2*tmask(1,:,:) + call readnc_slice_float_2d(nomefile,'tclw',buf2,0) + tclwIO(:,:,2) = buf2*tmask(1,:,:) + call readnc_slice_float_2d(nomefile,'tco3',buf2,0) + tco3IO(:,:,2) = buf2*tmask(1,:,:) + + END SUBROUTINE LOAD_KEXT @@ -201,7 +213,8 @@ SUBROUTINE ACTUALIZE_KEXT(zweigh) call actualize(zweigh,d2mIO,d2m) call actualize(zweigh,tccIO,tcc) call actualize(zweigh,w10IO,w10) - + call actualize(zweigh,tclwIO,tclw) + call actualize(zweigh,tco3IO,tco3) @@ -226,8 +239,8 @@ SUBROUTINE swap_KEXT call swap(d2mIO) call swap(tccIO) call swap(w10IO) - - + call swap(tclwIO) + call swap(tco3IO) END SUBROUTINE swap_KEXT diff --git a/src/IO/forcing_phys.f90 b/src/IO/forcing_phys.f90 index 70b9a493..d228e124 100644 --- a/src/IO/forcing_phys.f90 +++ b/src/IO/forcing_phys.f90 @@ -133,8 +133,11 @@ SUBROUTINE LOAD_PHYS(datestring) LOGICAL :: B integer :: jk,jj,ji, jstart ! LOCAL - character(LEN=30) nomefile + character(LEN=38) nomefile character(LEN=36) DeltaT_name + character(LEN=4) yyyy + character(LEN=2) mm + character(LEN=40) fileformat double precision ssh(jpj,jpi) double precision diff_e3t(jpk,jpj,jpi) double precision, dimension(jpj,jpi) :: e1u_x_e2u, e1v_x_e2v, e1t_x_e2t @@ -152,18 +155,21 @@ SUBROUTINE LOAD_PHYS(datestring) jk = minval(imposed_deltaT) rdt = real(jk , 8) endif - nomefile='FORCINGS/U19951206-12:00:00.nc' + fileformat='("FORCINGS/",A4,"/",A2,"/",A1,A17,".nc")' + nomefile='FORCINGS/1995/12/U19951206-12:00:00.nc' + yyyy=datestring(1:4) + mm=datestring(5:6) ! Starting I/O ! U ********************************************************* - nomefile = 'FORCINGS/U'//datestring//'.nc' + write(nomefile,fileformat) yyyy,mm,"U",datestring if(lwp) write(*,'(A,I4,A,A)') "LOAD_PHYS --> I am ", myrank, " starting reading forcing fields from ", nomefile(1:30) call readnc_slice_float(nomefile,'vozocrtx',buf,ingv_lon_shift) udta(:,:,:,2) = buf * umask ! V ********************************************************* - nomefile = 'FORCINGS/V'//datestring//'.nc' + write(nomefile,fileformat) yyyy,mm,"V",datestring call readnc_slice_float(nomefile,'vomecrty',buf,ingv_lon_shift) vdta(:,:,:,2) = buf * vmask @@ -172,7 +178,7 @@ SUBROUTINE LOAD_PHYS(datestring) ! W ********************************************************* - nomefile = 'FORCINGS/W'//datestring//'.nc' + write(nomefile,fileformat) yyyy,mm,"W",datestring if (.not.mld_flag) then call readnc_slice_float(nomefile,'votkeavt',buf,ingv_lon_shift) avtdta(:,:,:,2) = buf*tmask @@ -180,7 +186,7 @@ SUBROUTINE LOAD_PHYS(datestring) ! T ********************************************************* - nomefile = 'FORCINGS/T'//datestring//'.nc' + write(nomefile,fileformat) yyyy,mm,"T",datestring call readnc_slice_float(nomefile,'votemper',buf,ingv_lon_shift) tdta(:,:,:,2) = buf*tmask @@ -291,22 +297,22 @@ SUBROUTINE LOAD_PHYS(datestring) if (ingv_files_direct_reading) then - nomefile = 'FORCINGS/U'//datestring//'.nc' + write(nomefile,fileformat) yyyy,mm,"U",datestring call readnc_slice_float_2d(nomefile,'sozotaux',buf2,ingv_lon_shift) taux = buf2*tmask(1,:,:)*umask(1,:,:) - nomefile = 'FORCINGS/V'//datestring//'.nc' + write(nomefile,fileformat) yyyy,mm,"V",datestring call readnc_slice_float_2d(nomefile,'sometauy',buf2,ingv_lon_shift) tauy = buf2*tmask(1,:,:)*vmask(1,:,:) call PURE_WIND_SPEED(taux,tauy,jpi,jpj, buf2) else - nomefile = 'FORCINGS/T'//datestring//'.nc' + write(nomefile,fileformat) yyyy,mm,"T",datestring call readnc_slice_float_2d(nomefile,'sowindsp',buf2,ingv_lon_shift) endif flxdta(:,:,jpwind,2) = buf2*tmask(1,:,:) * spongeT - nomefile = 'FORCINGS/T'//datestring//'.nc' + write(nomefile,fileformat) yyyy,mm,"T",datestring call readnc_slice_float_2d(nomefile,'soshfldo',buf2,ingv_lon_shift) flxdta(:,:,jpqsr ,2) = buf2*tmask(1,:,:) * spongeT flxdta(:,:,jpice ,2) = 0. @@ -314,7 +320,7 @@ SUBROUTINE LOAD_PHYS(datestring) if (read_W_from_file) then - nomefile = 'FORCINGS/W'//datestring//'.nc' + write(nomefile,fileformat) yyyy,mm,"W",datestring call readnc_slice_float(nomefile,'vovecrtz',buf,ingv_lon_shift) wdta(:,:,:,2) = buf * tmask else From c3d4ca465dde7288e1f8d2573ffd957bac4ee47e Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Tue, 14 Apr 2026 09:50:56 +0200 Subject: [PATCH 20/25] merging testcase from neccton branch --- testcase/KB/INIT_NWM_KB/init.O5c | 43 ++++++ testcase/KB/INIT_NWM_KB/init.R1l | 43 ++++++ testcase/KB/INIT_NWM_KB/init.R2l | 43 ++++++ testcase/KB/INIT_NWM_KB/init.R3l | 43 ++++++ testcase/KB/INIT_NWM_KB/init.R8c | 43 ++++++ testcase/KB/INIT_NWM_KB/init.R8n | 43 ++++++ testcase/KB/INIT_NWM_KB/init.R8p | 43 ++++++ testcase/KB/INIT_NWM_KB/init.R8s | 43 ++++++ testcase/Main_create_TEST.py | 11 +- testcase/bcs/abso_nn.dat | 33 +++++ testcase/bcs/abw25_morel.dat | 38 ++++++ testcase/bcs/acbc25b.dat | 86 ++++++++++++ testcase/bcs/atmo_nn.dat | 33 +++++ testcase/bcs/bin_n.dat | 33 +++++ testcase/bcs/cdom25b.dat | 40 ++++++ testcase/bcs/poc25b.dat | 40 ++++++ testcase/bcs/readme | 9 ++ testcase/bcs/slingo_nn.dat | 33 +++++ testcase/boundaries.nml | 1 + testcase/checkdiff.py | 2 +- testcase/create_Dom_Dec.py | 9 +- testcase/create_UVW.py | 4 +- testcase/create_bc_nc.py | 28 ++-- testcase/create_bfmmask_nc.py | 39 ++++++ testcase/create_events.py | 5 +- testcase/create_extinction_nc.py | 2 +- testcase/create_fluxes.py | 2 +- testcase/create_forcings_nc.py | 98 +++++++------- testcase/create_meshmask_nc.py | 136 +++++++++---------- testcase/create_optics_nc.py | 219 +++++++++++++++++++++++++++++++ testcase/deploy_code.py | 9 +- testcase/genInputsDatelists.sh | 79 ++++++++++- testcase/interpolation43.py | 2 +- testcase/mydtype.py | 10 +- testcase/oasim_config.yaml | 13 ++ testcase/subgen.py | 2 +- 36 files changed, 1203 insertions(+), 157 deletions(-) create mode 100644 testcase/KB/INIT_NWM_KB/init.O5c create mode 100644 testcase/KB/INIT_NWM_KB/init.R1l create mode 100644 testcase/KB/INIT_NWM_KB/init.R2l create mode 100644 testcase/KB/INIT_NWM_KB/init.R3l create mode 100644 testcase/KB/INIT_NWM_KB/init.R8c create mode 100644 testcase/KB/INIT_NWM_KB/init.R8n create mode 100644 testcase/KB/INIT_NWM_KB/init.R8p create mode 100644 testcase/KB/INIT_NWM_KB/init.R8s create mode 100644 testcase/bcs/abso_nn.dat create mode 100644 testcase/bcs/abw25_morel.dat create mode 100644 testcase/bcs/acbc25b.dat create mode 100644 testcase/bcs/atmo_nn.dat create mode 100644 testcase/bcs/bin_n.dat create mode 100644 testcase/bcs/cdom25b.dat create mode 100644 testcase/bcs/poc25b.dat create mode 100644 testcase/bcs/readme create mode 100644 testcase/bcs/slingo_nn.dat create mode 100644 testcase/boundaries.nml create mode 100644 testcase/create_bfmmask_nc.py create mode 100644 testcase/create_optics_nc.py create mode 100644 testcase/oasim_config.yaml diff --git a/testcase/KB/INIT_NWM_KB/init.O5c b/testcase/KB/INIT_NWM_KB/init.O5c new file mode 100644 index 00000000..16c4ec30 --- /dev/null +++ b/testcase/KB/INIT_NWM_KB/init.O5c @@ -0,0 +1,43 @@ +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 diff --git a/testcase/KB/INIT_NWM_KB/init.R1l b/testcase/KB/INIT_NWM_KB/init.R1l new file mode 100644 index 00000000..16c4ec30 --- /dev/null +++ b/testcase/KB/INIT_NWM_KB/init.R1l @@ -0,0 +1,43 @@ +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 diff --git a/testcase/KB/INIT_NWM_KB/init.R2l b/testcase/KB/INIT_NWM_KB/init.R2l new file mode 100644 index 00000000..16c4ec30 --- /dev/null +++ b/testcase/KB/INIT_NWM_KB/init.R2l @@ -0,0 +1,43 @@ +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 diff --git a/testcase/KB/INIT_NWM_KB/init.R3l b/testcase/KB/INIT_NWM_KB/init.R3l new file mode 100644 index 00000000..16c4ec30 --- /dev/null +++ b/testcase/KB/INIT_NWM_KB/init.R3l @@ -0,0 +1,43 @@ +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 diff --git a/testcase/KB/INIT_NWM_KB/init.R8c b/testcase/KB/INIT_NWM_KB/init.R8c new file mode 100644 index 00000000..e97c5017 --- /dev/null +++ b/testcase/KB/INIT_NWM_KB/init.R8c @@ -0,0 +1,43 @@ +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.01000000000000000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 +0.00000000000100000000 diff --git a/testcase/KB/INIT_NWM_KB/init.R8n b/testcase/KB/INIT_NWM_KB/init.R8n new file mode 100644 index 00000000..c86f9c71 --- /dev/null +++ b/testcase/KB/INIT_NWM_KB/init.R8n @@ -0,0 +1,43 @@ +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 diff --git a/testcase/KB/INIT_NWM_KB/init.R8p b/testcase/KB/INIT_NWM_KB/init.R8p new file mode 100644 index 00000000..16c4ec30 --- /dev/null +++ b/testcase/KB/INIT_NWM_KB/init.R8p @@ -0,0 +1,43 @@ +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00010000000000000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 +0.00000000000001000000 diff --git a/testcase/KB/INIT_NWM_KB/init.R8s b/testcase/KB/INIT_NWM_KB/init.R8s new file mode 100644 index 00000000..c86f9c71 --- /dev/null +++ b/testcase/KB/INIT_NWM_KB/init.R8s @@ -0,0 +1,43 @@ +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00100000000000000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 +0.00000000000010000000 diff --git a/testcase/Main_create_TEST.py b/testcase/Main_create_TEST.py index 214e8809..6ff1665a 100755 --- a/testcase/Main_create_TEST.py +++ b/testcase/Main_create_TEST.py @@ -1,8 +1,5 @@ #! /usr/bin/python - -#AUTHOR PL 15.X.2013 - -# LOAD PACKAGES +# #AUTHOR PL 15.X.2013 import os,sys import collections import numpy as np @@ -10,19 +7,19 @@ import scipy.io.netcdf as NC import pickle import create_meshmask_nc as c_mask +import create_bfmmask_nc as c_bfmmask import create_Dom_Dec as c_dom import create_extinction_nc as c_ext import create_init_nc as c_init import create_forcings_nc as c_for +import create_optics_nc as c_opt import create_bc_nc as c_bc import deploy_code as d_code import create_events as c_events - import create_da_nc as DA import create_fluxes -# MAIN PROGRAM TEST_LIST=np.loadtxt('TEST_LIST.dat', dtype=test_conf,skiprows=1,ndmin=1) for test in TEST_LIST: @@ -30,7 +27,9 @@ DA.create_dataset(test) c_dom.create_Dom_Dec(test) c_mask.create_meshmask_nc(test) + c_bfmmask.create_bfm_nc(test) c_for.create_forcings_nc(test) + c_opt.create_optics_nc(test) c_ext.create_extinction_nc(test) c_bc.create_bc_nc(test) create_fluxes.create_fluxes(test) diff --git a/testcase/bcs/abso_nn.dat b/testcase/bcs/abso_nn.dat new file mode 100644 index 00000000..1cde1056 --- /dev/null +++ b/testcase/bcs/abso_nn.dat @@ -0,0 +1,33 @@ + 187.5 312.5 0.6112000000 0.0567000000 + 312.5 337.5 0.0762000000 0.0187000000 + 337.5 362.5 0.0461000000 0.0135000000 + 362.5 387.5 0.0182000000 0.0100000000 + 387.5 412.5 0.0063000000 0.0076000000 + 412.5 437.5 0.0051000000 0.0058000000 + 437.5 462.5 0.0083000000 0.0045000000 + 462.5 487.5 0.0119000000 0.0036000000 + 487.5 512.5 0.0215000000 0.0029000000 + 512.5 537.5 0.0407000000 0.0023000000 + 537.5 562.5 0.0550000000 0.0019000000 + 562.5 587.5 0.0849000000 0.0016000000 + 587.5 612.5 0.1995000000 0.0014000000 + 612.5 637.5 0.2850000000 0.0012000000 + 637.5 662.5 0.3512000000 0.0009000000 + 662.5 687.5 0.4559000000 0.0007000000 + 687.5 712.5 0.6433000000 0.0007000000 + 712.5 750.0 1.4449000000 0.0006000000 + 750.0 800.0 2.3900000000 0.0004000000 + 800.0 900.0 3.7382000000 0.0002000000 + 900.0 1000.0 27.4805000000 0.0000000000 + 1000.0 1100.0 19.3470000000 0.0000000000 + 1100.0 1200.0 67.1800000000 0.0000000000 + 1200.0 1300.0 94.9976000000 0.0000000000 + 1300.0 1400.0 363.1256000000 0.0000000000 + 1400.0 1500.0 1118.6070000000 0.0000000000 + 1500.0 1600.0 944.8757000000 0.0000000000 + 1600.0 1700.0 519.5995000000 0.0000000000 + 1700.0 1800.0 646.7179000000 0.0000000000 + 1800.0 2000.0 3768.5610000000 0.0000000000 + 2000.0 2400.0 2628.0830000000 0.0000000000 + 2400.0 3400.0 437623.0000000000 0.0000000000 + 3400.0 4000.0 1338404.0000000000 0.0000000000 diff --git a/testcase/bcs/abw25_morel.dat b/testcase/bcs/abw25_morel.dat new file mode 100644 index 00000000..229fe589 --- /dev/null +++ b/testcase/bcs/abw25_morel.dat @@ -0,0 +1,38 @@ +Spectral seawater absorption and total scattering coefficients in +units of /m. Derived from Smith and Baker 1981 (200-300 nm), and +(730-800 nm), Morel et al 2007 (325-475), Pope and Fry 1997 (500-720), +Circio and Petty 1951 (800nm-2.5um), and Maul 1985 (2.5-4um). +Format i5,f15.4,f10.4 + 250 0.6112 0.0567 + 325 0.0218 0.0162 + 350 0.0081 0.0117 + 375 0.0057 0.0089 + 400 0.0047 0.0069 + 425 0.0049 0.0054 + 450 0.0085 0.0043 + 475 0.0117 0.0034 + 500 0.0215 0.0029 + 525 0.0407 0.0023 + 550 0.0550 0.0019 + 575 0.0849 0.0016 + 600 0.1995 0.0014 + 625 0.2850 0.0012 + 650 0.3512 0.0009 + 675 0.4559 0.0007 + 700 0.6433 0.0007 + 725 1.4449 0.0006 + 775 2.3900 0.0004 + 850 3.7382 0.0002 + 950 27.4805 0.0000 + 1050 19.3470 0.0000 + 1150 67.1800 0.0000 + 1250 94.9976 0.0000 + 1350 363.1256 0.0000 + 1450 1118.6070 0.0000 + 1550 944.8757 0.0000 + 1650 519.5995 0.0000 + 1750 646.7179 0.0000 + 1900 3768.5610 0.0000 + 2200 2628.0830 0.0000 + 2900 437623.0000 0.0000 + 3700 1338404.0000 0.0000 diff --git a/testcase/bcs/acbc25b.dat b/testcase/bcs/acbc25b.dat new file mode 100644 index 00000000..dfc5d426 --- /dev/null +++ b/testcase/bcs/acbc25b.dat @@ -0,0 +1,86 @@ +Phytoplankton chl-specific absorption and c-specific scattering +Computed in 02_PFTs&constituents_data_files_optimized_carbon.R +# aPS reconstructed (Hickman et al. 2010) from aPH compiled from literature (Álvarez et al. 2022 PiO) (m2 mgChla-1) +# aPH scaled to mean aPH (0.0152/0.0293/0.0443/0.0178) optimized in Álvarez et al. 2023 BGC (m2 mgChla-1) +# bPH from Dutkiewicz et al. 2015 (m2 mgC-1), not scaled. Non-spectral bb ratio (from Dut15 & Gregg17), it multiplies bPH in edeseu.F90 +Format I4,4F10.4 +Diatoms + 250 0.0016 0.0000 0.0035 0.0020 + 325 0.0075 0.0057 0.0035 0.0020 + 350 0.0142 0.0115 0.0035 0.0020 + 375 0.0210 0.0172 0.0035 0.0020 + 400 0.0270 0.0224 0.0035 0.0020 + 425 0.0316 0.0261 0.0034 0.0020 + 450 0.0300 0.0260 0.0034 0.0020 + 475 0.0238 0.0213 0.0035 0.0020 + 500 0.0191 0.0173 0.0036 0.0020 + 525 0.0127 0.0110 0.0037 0.0020 + 550 0.0081 0.0071 0.0036 0.0020 + 575 0.0057 0.0048 0.0036 0.0020 + 600 0.0054 0.0044 0.0035 0.0020 + 625 0.0068 0.0055 0.0034 0.0020 + 650 0.0083 0.0064 0.0032 0.0020 + 675 0.0154 0.0127 0.0030 0.0020 + 700 0.0037 0.0037 0.0031 0.0020 + 725 0.0014 0.0014 0.0031 0.0020 + 775 0.0002 0.0000 0.0031 0.0020 +Flagellates + 250 0.0028 0.0000 0.0066 0.0071 + 325 0.0130 0.0064 0.0066 0.0071 + 350 0.0248 0.0128 0.0066 0.0071 + 375 0.0365 0.0192 0.0066 0.0071 + 400 0.0502 0.0256 0.0066 0.0071 + 425 0.0626 0.0309 0.0064 0.0071 + 450 0.0595 0.0289 0.0064 0.0071 + 475 0.0508 0.0242 0.0068 0.0071 + 500 0.0358 0.0171 0.0076 0.0071 + 525 0.0190 0.0107 0.0081 0.0071 + 550 0.0118 0.0064 0.0084 0.0071 + 575 0.0110 0.0056 0.0084 0.0071 + 600 0.0119 0.0063 0.0082 0.0071 + 625 0.0143 0.0073 0.0080 0.0071 + 650 0.0182 0.0096 0.0078 0.0071 + 675 0.0294 0.0159 0.0073 0.0071 + 700 0.0063 0.0042 0.0080 0.0071 + 725 0.0017 0.0011 0.0080 0.0071 + 775 0.0006 0.0000 0.0080 0.0071 +Pico + 250 0.0042 0.0000 0.0054 0.0039 + 325 0.0192 0.0067 0.0054 0.0039 + 350 0.0365 0.0135 0.0054 0.0039 + 375 0.0539 0.0202 0.0054 0.0039 + 400 0.0725 0.0271 0.0054 0.0039 + 425 0.1026 0.0338 0.0051 0.0039 + 450 0.1038 0.0265 0.0050 0.0039 + 475 0.0824 0.0158 0.0051 0.0039 + 500 0.0571 0.0136 0.0052 0.0039 + 525 0.0279 0.0130 0.0050 0.0039 + 550 0.0241 0.0131 0.0048 0.0039 + 575 0.0161 0.0090 0.0046 0.0039 + 600 0.0125 0.0064 0.0043 0.0039 + 625 0.0147 0.0075 0.0040 0.0039 + 650 0.0215 0.0099 0.0037 0.0039 + 675 0.0335 0.0178 0.0035 0.0039 + 700 0.0070 0.0050 0.0038 0.0039 + 725 0.0017 0.0011 0.0038 0.0039 + 775 0.0000 0.0000 0.0038 0.0039 +Dino + 250 0.0022 0.0000 0.0007 0.0030 + 325 0.0103 0.0084 0.0007 0.0030 + 350 0.0196 0.0168 0.0007 0.0030 + 375 0.0289 0.0252 0.0007 0.0030 + 400 0.0353 0.0316 0.0007 0.0030 + 425 0.0360 0.0323 0.0007 0.0030 + 450 0.0342 0.0312 0.0007 0.0030 + 475 0.0290 0.0269 0.0007 0.0030 + 500 0.0224 0.0208 0.0007 0.0030 + 525 0.0160 0.0150 0.0008 0.0030 + 550 0.0106 0.0102 0.0008 0.0030 + 575 0.0068 0.0063 0.0009 0.0030 + 600 0.0061 0.0056 0.0009 0.0030 + 625 0.0069 0.0061 0.0009 0.0030 + 650 0.0082 0.0069 0.0009 0.0030 + 675 0.0168 0.0152 0.0009 0.0030 + 700 0.0030 0.0030 0.0010 0.0030 + 725 0.0004 0.0004 0.0010 0.0030 + 775 0.0000 0.0000 0.0010 0.0030 diff --git a/testcase/bcs/atmo_nn.dat b/testcase/bcs/atmo_nn.dat new file mode 100644 index 00000000..04310a7c --- /dev/null +++ b/testcase/bcs/atmo_nn.dat @@ -0,0 +1,33 @@ + 187.5 312.5 16.5280000000 2.8229000000 80.8836000000 0.0000000000 0.00000 0.00000 + 312.5 337.5 41.0035000000 0.8742000000 0.3584000000 0.0000000000 0.00000 0.00000 + 337.5 362.5 12.7915000000 0.5925000000 0.0016000000 0.0000000000 0.00000 0.00000 + 362.5 387.5 27.1180000000 0.4768000000 0.0001000000 0.0000000000 0.00000 0.00000 + 387.5 412.5 35.1935000000 0.3643000000 0.0000000000 0.0000000000 0.00000 0.00000 + 412.5 437.5 42.1795000000 0.2833000000 0.0008000000 0.0000000000 0.00000 0.00000 + 437.5 462.5 49.1940000000 0.2238000000 0.0040000000 0.0000000000 0.00000 0.00000 + 462.5 487.5 49.7700000000 0.1791000000 0.0121000000 0.0000000000 0.00000 0.00000 + 487.5 512.5 48.3945000000 0.1451000000 0.0279000000 0.0000000000 0.00000 0.00000 + 512.5 537.5 46.4935000000 0.1189000000 0.0529000000 0.0000000000 0.00000 0.00000 + 537.5 562.5 46.5160000000 0.0983000000 0.0832000000 0.0000000000 0.00000 0.00000 + 562.5 587.5 46.1380000000 0.0820000000 0.1140000000 0.0148000000 0.00000 0.00000 + 587.5 612.5 44.1230000000 0.0690000000 0.1176000000 0.0851000000 0.00000 0.00000 + 612.5 637.5 42.0468000000 0.0584000000 0.0967000000 0.0016000000 0.00580 0.00000 + 637.5 662.5 39.5245000000 0.0498000000 0.0643000000 0.0408000000 0.00000 0.00000 + 662.5 687.5 37.8730000000 0.0427000000 0.0416000000 0.0009000000 0.23330 0.00000 + 687.5 712.5 18.7465000000 0.0382000000 0.0261000000 0.1074000000 0.12990 0.00000 + 712.5 750.0 66.8775000000 0.0319000000 0.0132000000 0.1462000000 0.00000 0.00000 + 750.0 800.0 59.9900000000 0.0244000000 0.0072000000 0.0065000000 1.11760 0.00000 + 800.0 900.0 102.2358000000 0.0168000000 0.0020000000 0.0568000000 0.00010 0.00000 + 900.0 1000.0 84.7899000000 0.0108000000 0.0000000000 4.9142000000 0.00000 0.00000 + 1000.0 1100.0 67.8772000000 0.0072000000 0.0000000000 0.0279000000 0.00020 0.00020 + 1100.0 1200.0 56.0762000000 0.0050000000 0.0000000000 17.5902000000 0.00000 0.00000 + 1200.0 1300.0 46.1106000000 0.0032000000 0.0000000000 0.0479000000 0.00280 0.00050 + 1300.0 1400.0 37.3780000000 0.0026000000 0.0000000000 115.3197000000 0.00000 0.00030 + 1400.0 1500.0 31.8313000000 0.0020000000 0.0000000000 95.2031000000 0.00000 0.00230 + 1500.0 1600.0 27.2524000000 0.0015000000 0.0000000000 0.0364000000 0.00000 0.00140 + 1600.0 1700.0 22.7691000000 0.0012000000 0.0000000000 0.0082000000 0.00000 0.00100 + 1700.0 1800.0 18.6144000000 0.0009000000 0.0000000000 2.0008000000 0.00000 0.00010 + 1800.0 2000.0 27.9521000000 0.0007000000 0.0000000000 228.9211000000 0.00000 0.00870 + 2000.0 2400.0 33.6300000000 0.0004000000 0.0000000000 0.2550000000 0.00000 0.01180 + 2400.0 3400.0 32.5775000000 0.0001000000 0.0000000000 314.7111000000 0.00000 0.02560 + 3400.0 4000.0 7.2635000000 0.0000000000 0.0000000000 0.9158000000 0.00000 0.00030 diff --git a/testcase/bcs/bin_n.dat b/testcase/bcs/bin_n.dat new file mode 100644 index 00000000..171bdef2 --- /dev/null +++ b/testcase/bcs/bin_n.dat @@ -0,0 +1,33 @@ + 187.5 312.5 + 312.5 337.5 + 337.5 362.5 + 362.5 387.5 + 387.5 412.5 + 412.5 437.5 + 437.5 462.5 + 462.5 487.5 + 487.5 512.5 + 512.5 537.5 + 537.5 562.5 + 562.5 587.5 + 587.5 612.5 + 612.5 637.5 + 637.5 662.5 + 662.5 687.5 + 687.5 712.5 + 712.5 750.0 + 750.0 800.0 + 800.0 900.0 + 900.0 1000.0 + 1000.0 1100.0 + 1100.0 1200.0 + 1200.0 1300.0 + 1300.0 1400.0 + 1400.0 1500.0 + 1500.0 1600.0 + 1600.0 1700.0 + 1700.0 1800.0 + 1800.0 2000.0 + 2000.0 2400.0 + 2400.0 3400.0 + 3400.0 4000.0 diff --git a/testcase/bcs/cdom25b.dat b/testcase/bcs/cdom25b.dat new file mode 100644 index 00000000..b6e89567 --- /dev/null +++ b/testcase/bcs/cdom25b.dat @@ -0,0 +1,40 @@ +CDOM c-specific absorption +Computed in 02PFTs_&constituents_data_files_optimized.R +# S_350_500 = 0.0175/0.0162/0.0180 nm-1 (values optimized in Álvarez et al. 2023 BGC) +# a_cdom at 450nm = 0.015 m2 mgC-1 (from Dutkiewicz et al. 2015, 0.18 m2 mmolC-1) +# average of the integral in the waveband +Format I5,3E12.6 + 250 6.018665e-01 4.518833e-01 6.723253e-01 + 325 1.347623e-01 1.144199e-01 1.435199e-01 + 350 8.700911e-02 7.631544e-02 9.151231e-02 + 375 5.617730e-02 5.090063e-02 5.835083e-02 + 400 3.627079e-02 3.394954e-02 3.720613e-02 + 425 2.341818e-02 2.264355e-02 2.372368e-02 + 450 1.511992e-02 1.510273e-02 1.512688e-02 + 475 9.762151e-03 1.007317e-02 9.645327e-03 + 500 6.302918e-03 6.718569e-03 6.150132e-03 + 525 4.069470e-03 4.481130e-03 3.921497e-03 + 550 2.627447e-03 2.988810e-03 2.500457e-03 + 575 1.696407e-03 1.993467e-03 1.594362e-03 + 600 1.095283e-03 1.329596e-03 1.016610e-03 + 625 7.071679e-04 8.868098e-04 6.482191e-04 + 650 4.565819e-04 5.914816e-04 4.133228e-04 + 675 2.947914e-04 3.945045e-04 2.635462e-04 + 700 1.903316e-04 2.631254e-04 1.680445e-04 + 725 1.112534e-04 1.599539e-04 9.675851e-05 + 775 5.245761e-05 7.967812e-05 4.467127e-05 + 850 1.549168e-05 2.560683e-05 1.277305e-05 + 950 2.692050e-06 5.067558e-06 2.111370e-06 + 1050 4.678081e-07 1.002863e-06 3.490072e-07 + 1150 8.129285e-08 1.984653e-07 5.769050e-08 + 1250 1.412658e-08 3.927602e-08 9.536176e-09 + 1350 2.454831e-09 7.772674e-09 1.576319e-09 + 1450 4.265857e-10 1.538202e-09 2.605638e-10 + 1550 7.412949e-11 3.044082e-10 4.307091e-11 + 1650 1.288177e-11 6.024198e-11 7.119573e-12 + 1750 2.238517e-12 1.192181e-11 1.176858e-12 + 1900 2.282966e-13 1.413108e-12 1.133447e-13 + 2200 3.551070e-15 2.875512e-14 1.590810e-15 + 2900 1.296445e-18 1.766906e-17 4.754255e-19 + 3700 5.425470e-26 2.713099e-24 1.206762e-26 + 4000 0.000000e-00 0.000000e-00 0.000000e-00 diff --git a/testcase/bcs/poc25b.dat b/testcase/bcs/poc25b.dat new file mode 100644 index 00000000..9943af44 --- /dev/null +++ b/testcase/bcs/poc25b.dat @@ -0,0 +1,40 @@ +Detritus c-specific absorption and scattering +Computed in 02PFTs_&constituents_data_files_optimized.R +# S=0.013 from Gallegos et al. 2011 (nm-1), a(440)=0.00058 (m2 mgC-1) optimized in Álvarez et al. 2023 BGC +# exp=0.5 from Gallegos et al. 2011 (-), b(550)=0.0120 (m2 mgC-1) optimized in Álvarez et al. 2023 BGC +# bb is the actual value (m2 mgC-1), computed from b times the non-spectral bb ratio = 0.005 from Gallegos et al. 2011 +Format I5,E8.2,E9.3,E7.1 + 250 7.64e-03 1.794e-02 9.0e-05 + 325 2.60e-03 1.561e-02 7.8e-05 + 350 1.88e-03 1.505e-02 7.5e-05 + 375 1.36e-03 1.453e-02 7.3e-05 + 400 9.80e-04 1.407e-02 7.0e-05 + 425 7.10e-04 1.365e-02 6.8e-05 + 450 5.10e-04 1.327e-02 6.6e-05 + 475 3.70e-04 1.291e-02 6.5e-05 + 500 2.70e-04 1.259e-02 6.3e-05 + 525 1.90e-04 1.228e-02 6.1e-05 + 550 1.40e-04 1.200e-02 6.0e-05 + 575 1.00e-04 1.174e-02 5.9e-05 + 600 7.00e-05 1.149e-02 5.7e-05 + 625 5.00e-05 1.126e-02 5.6e-05 + 650 4.00e-05 1.104e-02 5.5e-05 + 675 3.00e-05 1.083e-02 5.4e-05 + 700 2.00e-05 1.064e-02 5.3e-05 + 725 1.00e-05 1.041e-02 5.2e-05 + 775 1.00e-05 1.011e-02 5.1e-05 + 850 0.00e+00 9.660e-03 4.8e-05 + 950 0.00e+00 9.130e-03 4.6e-05 + 1050 0.00e+00 8.690e-03 4.3e-05 + 1150 0.00e+00 8.300e-03 4.2e-05 + 1250 0.00e+00 7.960e-03 4.0e-05 + 1350 0.00e+00 7.660e-03 3.8e-05 + 1450 0.00e+00 7.390e-03 3.7e-05 + 1550 0.00e+00 7.150e-03 3.6e-05 + 1650 0.00e+00 6.930e-03 3.5e-05 + 1750 0.00e+00 6.730e-03 3.4e-05 + 1900 0.00e+00 6.460e-03 3.2e-05 + 2200 0.00e+00 6.010e-03 3.0e-05 + 2900 0.00e+00 5.250e-03 2.6e-05 + 3700 0.00e+00 4.630e-03 2.3e-05 + 4000 0.0 0.0 0.0 diff --git a/testcase/bcs/readme b/testcase/bcs/readme new file mode 100644 index 00000000..f0dc3f78 --- /dev/null +++ b/testcase/bcs/readme @@ -0,0 +1,9 @@ +total 32 +lrwxrwxrwx 1 plazzari interactive 65 Feb 6 15:16 abso_nn.dat -> /g100_work/OGS_devC/V9C/RUNS_SETUP/PREPROC/OPTICS/bcs/abso_nn.dat +lrwxrwxrwx 1 plazzari interactive 69 Feb 6 15:16 abw25_morel.dat -> /g100_work/OGS_devC/V9C/RUNS_SETUP/PREPROC/OPTICS/bcs/abw25_morel.dat +lrwxrwxrwx 1 plazzari interactive 99 May 18 17:37 acbc25b.dat -> /g100_work/OGS_devC/V10C/RUNS_SETUP/run3.19/CODE/ogstm/src/namelists/bcs_optimized_V10C/acbc25b.dat +lrwxrwxrwx 1 plazzari interactive 65 Feb 6 15:16 atmo_nn.dat -> /g100_work/OGS_devC/V9C/RUNS_SETUP/PREPROC/OPTICS/bcs/atmo_nn.dat +lrwxrwxrwx 1 plazzari interactive 63 Feb 6 15:16 bin_n.dat -> /g100_work/OGS_devC/V9C/RUNS_SETUP/PREPROC/OPTICS/bcs/bin_n.dat +lrwxrwxrwx 1 plazzari interactive 99 May 18 17:37 cdom25b.dat -> /g100_work/OGS_devC/V10C/RUNS_SETUP/run3.19/CODE/ogstm/src/namelists/bcs_optimized_V10C/cdom25b.dat +lrwxrwxrwx 1 plazzari interactive 98 May 18 17:37 poc25b.dat -> /g100_work/OGS_devC/V10C/RUNS_SETUP/run3.19/CODE/ogstm/src/namelists/bcs_optimized_V10C/poc25b.dat +lrwxrwxrwx 1 plazzari interactive 67 Feb 6 15:16 slingo_nn.dat -> /g100_work/OGS_devC/V9C/RUNS_SETUP/PREPROC/OPTICS/bcs/slingo_nn.dat diff --git a/testcase/bcs/slingo_nn.dat b/testcase/bcs/slingo_nn.dat new file mode 100644 index 00000000..e40703a1 --- /dev/null +++ b/testcase/bcs/slingo_nn.dat @@ -0,0 +1,33 @@ + 187.5 312.5 3.09400 1.2520000000 0.8440000000 1.5580000000 0.0000007900 0.0000003700 + 312.5 337.5 2.94400 1.2700000000 0.8410000000 1.6800000000 -0.0000006500 0.0000004300 + 337.5 362.5 3.30800 1.2460000000 0.8390000000 1.9460000000 -0.0000003000 0.0000002400 + 362.5 387.5 2.80100 1.2930000000 0.8360000000 2.1530000000 0.0000010000 0.0000000000 + 387.5 412.5 2.66800 1.3070000000 0.8400000000 1.8810000000 0.0000000000 0.0000000000 + 412.5 437.5 2.66800 1.3070000000 0.8400000000 1.8810000000 0.0000000000 0.0000000000 + 437.5 462.5 2.69800 1.3150000000 0.8200000000 3.0040000000 0.0000010000 0.0000000000 + 462.5 487.5 2.69800 1.3150000000 0.8200000000 3.0040000000 0.0000010000 0.0000000000 + 487.5 512.5 2.67200 1.3200000000 0.8280000000 2.4670000000 0.0000000000 0.0000000000 + 512.5 537.5 2.83800 1.3000000000 0.8250000000 2.7760000000 0.0000000000 0.0000000000 + 537.5 562.5 2.83800 1.3000000000 0.8250000000 2.7760000000 0.0000000000 0.0000000000 + 562.5 587.5 2.83100 1.3170000000 0.8280000000 2.4920000000 -0.0000012000 0.0000004000 + 587.5 612.5 2.83100 1.3170000000 0.8280000000 2.4920000000 -0.0000012000 0.0000004000 + 612.5 637.5 2.83100 1.3170000000 0.8280000000 2.4920000000 -0.0000012000 0.0000004000 + 637.5 662.5 2.89500 1.3150000000 0.8180000000 2.9890000000 -0.0000001200 0.0000004400 + 662.5 687.5 2.89500 1.3150000000 0.8180000000 2.9890000000 -0.0000001200 0.0000004400 + 687.5 712.5 3.11500 1.2440000000 0.8040000000 3.5200000000 -0.0000002700 0.0000014000 + 712.5 750.0 3.11500 1.2440000000 0.8040000000 3.5200000000 -0.0000002700 0.0000014000 + 750.0 800.0 2.65000 1.3490000000 0.8090000000 3.3870000000 0.0000023000 0.0000017000 + 800.0 900.0 2.62200 1.3620000000 0.8060000000 3.3550000000 0.0000033000 0.0000028000 + 900.0 1000.0 2.49700 1.3760000000 0.7830000000 5.0350000000 0.0000098000 0.0000210000 + 1000.0 1100.0 2.63200 1.3650000000 0.7840000000 4.7450000000 -0.0000460000 0.0000500000 + 1100.0 1200.0 2.58900 1.3850000000 0.7800000000 4.9890000000 -0.0000280000 0.0000800000 + 1200.0 1300.0 2.55100 1.4010000000 0.7730000000 5.4050000000 0.0000620000 0.0002600000 + 1300.0 1400.0 2.46300 1.4200000000 0.7540000000 6.5550000000 0.0002400000 0.0008560000 + 1400.0 1500.0 2.46300 1.4200000000 0.7540000000 6.5550000000 0.0002400000 0.0008560000 + 1500.0 1600.0 2.23700 1.4520000000 0.7490000000 6.9310000000 0.0001200000 0.0006670000 + 1600.0 1700.0 1.97000 1.5010000000 0.7400000000 7.4690000000 0.0012000000 0.0021600000 + 1700.0 1800.0 1.97000 1.5010000000 0.7400000000 7.4690000000 0.0012000000 0.0021600000 + 1800.0 2000.0 1.97000 1.5010000000 0.7400000000 7.4690000000 0.0012000000 0.0021600000 + 2000.0 2400.0 1.85000 1.5560000000 0.7690000000 5.1710000000 0.0001900000 0.0025400000 + 2400.0 3400.0 1.57900 1.6110000000 0.8510000000 2.8140000000 0.1230000000 0.0093500000 + 3400.0 4000.0 -1.02300 1.9330000000 0.7260000000 6.6520000000 0.0250000000 0.0122000000 diff --git a/testcase/boundaries.nml b/testcase/boundaries.nml new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/testcase/boundaries.nml @@ -0,0 +1 @@ +0 diff --git a/testcase/checkdiff.py b/testcase/checkdiff.py index 6e0de45a..805ff2c9 100644 --- a/testcase/checkdiff.py +++ b/testcase/checkdiff.py @@ -9,7 +9,7 @@ from commons.mask import Mask import os,glob -TheMask=Mask.from_file('/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/meshmask.nc') +TheMask=Mask('/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/meshmask.nc') DIR1 = "/gpfs/work/IscrC_MEDCOAST_0/test_swp/test_FSA/ogstm/testcase/TEST01/wrkdir/MODEL/AVE_FREQ_2/" DIR2 = "/gpfs/work/IscrC_MEDCOAST_0/test_swp/TEST01/wrkdir/MODEL/AVE_FREQ_2/" diff --git a/testcase/create_Dom_Dec.py b/testcase/create_Dom_Dec.py index 2ca2188f..58d979ce 100644 --- a/testcase/create_Dom_Dec.py +++ b/testcase/create_Dom_Dec.py @@ -7,8 +7,11 @@ import scipy.io.netcdf as NC import pickle -import imp -domdec = imp.load_source('domdec','../preproc/domdec/domdec.py') +import importlib.util + +spec = importlib.util.spec_from_file_location('domdec', '../preproc/domdec/domdec.py') +domdec = importlib.util.module_from_spec(spec) +spec.loader.exec_module(domdec) def create_Dom_Dec(test): @@ -54,6 +57,6 @@ def create_Dom_Dec(test): f01.close() f02.close() - tmask = np.ones((jpj,jpi),dtype=np.bool) + tmask = np.ones((jpj,jpi),dtype=bool) domdec.dump_outfile(tmask,nPx*nPy, nPx, nPy, filename=test['Dir'].decode() + '/domdec.txt') diff --git a/testcase/create_UVW.py b/testcase/create_UVW.py index 0c867706..6b5afefd 100644 --- a/testcase/create_UVW.py +++ b/testcase/create_UVW.py @@ -27,12 +27,12 @@ def h_vort1(jpi,jpj,jpk,D3U,D3V,Av,Au): for jk in range(jpk): # Velocities along jpj side Ly - Ly = np.arange(1+n,jpj-2-n , dtype=np.int) + Ly = np.arange(1+n,jpj-2-n , dtype=int) for jj in Ly: D3V[0,jk,jj,1+n ] = flux/Av[jk,jj,1+n ] # one side D3V[0,jk,jj,jpi-2-n] = -flux/Av[jk,jj,jpi-2-n] # Velocities along jpi side Lx - Lx = np.arange(1+n,jpi-2-n , dtype=np.int) + Lx = np.arange(1+n,jpi-2-n , dtype=int) for ji in Lx: D3U[0,jk,1+n,ji] = -flux/Au[jk,1+n,ji] # one side D3U[0,jk,jpj-2-n,ji] = flux/Au[jk,jpj-2-n,ji] diff --git a/testcase/create_bc_nc.py b/testcase/create_bc_nc.py index 45ee84a1..3abea4af 100644 --- a/testcase/create_bc_nc.py +++ b/testcase/create_bc_nc.py @@ -25,12 +25,12 @@ def create_bc_nc(test): tmask = M.variables['tmask'].data[0,:,:,:].astype(bool).copy() M.close() - D3=np.ones((1,jpk,jpj,jpi),np.float) - D2=np.ones((1,jpj,jpi),np.float) + D3=np.ones((1,jpk,jpj,jpi),np.float64) + D2=np.ones((1,jpj,jpi),np.float64) # Creating bounmask.nc - index=np.zeros((jpk,jpj,jpi),np.int) + index=np.zeros((jpk,jpj,jpi),int) waterpoints = 0; @@ -41,7 +41,7 @@ def create_bc_nc(test): waterpoints += 1 index[jk,jj,ji] = waterpoints - index_inv=np.zeros((waterpoints,3),np.int) + index_inv=np.zeros((waterpoints,3),int) waterpoints = 0; @@ -99,7 +99,7 @@ def create_bc_nc(test): if tmask[0,jj,ji]: atm_idxt += 1 - atm_index=np.ones((atm_idxt),np.float) + atm_index=np.ones((atm_idxt),np.float64) atm_idxt = 0; @@ -133,7 +133,7 @@ def create_bc_nc(test): filein.close() - D2=np.ones((jpj,jpi),np.float) + D2=np.ones((jpj,jpi),np.float64) for date in CO2_DATE: @@ -170,7 +170,7 @@ def create_bc_nc(test): if (jk ==0 ): tin_idxt += 1 - riv_index=np.ones((tin_idxt),np.int) + riv_index=np.ones((tin_idxt),int) tin_idxt = 0; @@ -183,12 +183,12 @@ def create_bc_nc(test): riv_index[tin_idxt]=index[jk,jj,ji] tin_idxt += 1 - riv_N1p=np.zeros(tin_idxt,dtype=float); riv_N1p[0]=0.35*10**(-5) - riv_N3n=np.zeros(tin_idxt,dtype=float); riv_N3n[0]=0.2*10**(-3) - riv_N5s=np.zeros(tin_idxt,dtype=float); riv_N5s[0]=1.0*10**(-4) - riv_O3c=np.zeros(tin_idxt,dtype=float); riv_O3c[0]=0.35 - riv_O3h=np.zeros(tin_idxt,dtype=float); riv_O3h[0]=0.01 - riv_O2o=np.zeros(tin_idxt,dtype=float); riv_O2o[0]=0.002 + riv_N1p=np.zeros(tin_idxt,dtype=np.float64); riv_N1p[0]=0.35*10**(-5) + riv_N3n=np.zeros(tin_idxt,dtype=np.float64); riv_N3n[0]=0.2*10**(-3) + riv_N5s=np.zeros(tin_idxt,dtype=np.float64); riv_N5s[0]=1.0*10**(-4) + riv_O3c=np.zeros(tin_idxt,dtype=np.float64); riv_O3c[0]=0.35 + riv_O3h=np.zeros(tin_idxt,dtype=np.float64); riv_O3h[0]=0.01 + riv_O2o=np.zeros(tin_idxt,dtype=np.float64); riv_O2o[0]=0.002 for date in TIN_DATE: # Create RIV file @@ -226,7 +226,7 @@ def create_bc_nc(test): if ( (ji==1) | (jj==1) ) | ( (ji==jpi-2) | (jj==jpj-2) ): gib_idxt += 1 - gib_index=np.ones((gib_idxt),np.int) + gib_index=np.ones((gib_idxt),int) gib_idxt = 0; diff --git a/testcase/create_bfmmask_nc.py b/testcase/create_bfmmask_nc.py new file mode 100644 index 00000000..3e64e0a8 --- /dev/null +++ b/testcase/create_bfmmask_nc.py @@ -0,0 +1,39 @@ +#! /usr/bin/python + +# LOAD PACKAGES +import os,sys + +import numpy as np + +from mydtype import * + +import scipy.io.netcdf as NC + +import pickle + +# Script to create bfm mask file + + +def create_bfm_nc(test): + x=test['jpi'] + y=test['jpj'] + z=test['jpk'] + + mask = np.ones((z,y,x),bool); + + ############################################################## + # write meshmask netcdf file ! + ############################################################## + os.system("mkdir -p " + test['Dir'].decode()) + + outfile = test['Dir'].decode() + '/bfmmask.nc'; + + ncOUT=NC.netcdf_file(outfile,"w"); + + ncOUT.createDimension('x',x); + ncOUT.createDimension('y',y); + ncOUT.createDimension('z',z); + + ncvar = ncOUT.createVariable('bfmmask','b',('z','y','x')) ; ncvar[:] = mask; + ncOUT.close() + diff --git a/testcase/create_events.py b/testcase/create_events.py index cb8d1889..ab5381da 100644 --- a/testcase/create_events.py +++ b/testcase/create_events.py @@ -1,4 +1,5 @@ import os,sys +import subprocess import numpy as np @@ -35,4 +36,6 @@ def create_events(test): f01 = open(filename,'w') f01.close() - os.system("./genInputsDatelists.sh " + test['Dir'].decode()) +# os.system("./genInputsDatelists.sh " + test['Dir'].decode()) + subprocess.run("cp genInputsDatelists.sh " + test['Dir'].decode() , shell=True) + subprocess.run("./genInputsDatelists.sh", shell=True, cwd=test['Dir'].decode()) diff --git a/testcase/create_extinction_nc.py b/testcase/create_extinction_nc.py index 1fc698f9..b127553c 100644 --- a/testcase/create_extinction_nc.py +++ b/testcase/create_extinction_nc.py @@ -21,7 +21,7 @@ def create_extinction_nc(test): mask2D = M.variables['tmask'].data[0,0,:,:].copy() M.close() - kextfact=np.ones((jpj,jpi),np.float); + kextfact=np.ones((jpj,jpi),np.float32); os.system("mkdir -p " + test['Dir'].decode() + '/KEXT') diff --git a/testcase/create_fluxes.py b/testcase/create_fluxes.py index 3136b20f..08d75ece 100644 --- a/testcase/create_fluxes.py +++ b/testcase/create_fluxes.py @@ -34,7 +34,7 @@ def create_fluxes(test): for i in range(1,jpi-1): for k in range(0,5): new_el = index[k,j_transect,i] - if new_el in LIST: print "already", i,k, new_el + if new_el in LIST: print("already", i,k, new_el) LIST.append(new_el) n=len(LIST) diff --git a/testcase/create_forcings_nc.py b/testcase/create_forcings_nc.py index 8942652f..f8701df1 100644 --- a/testcase/create_forcings_nc.py +++ b/testcase/create_forcings_nc.py @@ -4,7 +4,7 @@ from mydtype import * -import scipy.io.netcdf as NC +import netCDF4 as NC import pickle @@ -19,19 +19,19 @@ def create_forcings_nc(test): time = 1 maskfile=test['Dir'].decode() + '/meshmask.nc' - M=NC.netcdf_file(maskfile,"r") + M=NC.Dataset(maskfile,"r") - Lon = M.variables['glamt'].data[0,0,:,:].copy() - Lat = M.variables['gphit'].data[0,0,:,:].copy() - gdept = M.variables['gdept'].data[0,:,0,0].copy() - gdepw = M.variables['gdepw'].data[0,:,0,0].copy() - e1v = M.variables['e1v' ].data[0,0,:,:].copy() - e2u = M.variables['e2u' ].data[0,0,:,:].copy() + Lon = M.variables['glamt'][0,0,:,:].copy() + Lat = M.variables['gphit'][0,0,:,:].copy() + gdept = M.variables['gdept'][0,:,0,0].copy() + gdepw = M.variables['gdepw'][0,:,0,0].copy() + e1v = M.variables['e1v' ][0,0,:,:].copy() + e2u = M.variables['e2u' ][0,0,:,:].copy() - e3v0 = M.variables['e3v_0' ].data[0,:,:,:].copy() - e3u0 = M.variables['e3u_0' ].data[0,:,:,:].copy() - e3t0 = M.variables['e3t_0' ].data[0,:,:,:].copy() - e3w0 = M.variables['e3w_0' ].data[0,:,:,:].copy() + e3v0 = M.variables['e3v_0' ][0,:,:,:].copy() + e3u0 = M.variables['e3u_0' ][0,:,:,:].copy() + e3t0 = M.variables['e3t_0' ][0,:,:,:].copy() + e3w0 = M.variables['e3w_0' ][0,:,:,:].copy() M.close() @@ -39,31 +39,32 @@ def create_forcings_nc(test): e1v_aux = np.tile(e1v,[jpk,1,1]) e2u_aux = np.tile(e2u,[jpk,1,1]) - Av=np.ones((jpk,jpj,jpi),np.float) - Au=np.ones((jpk,jpj,jpi),np.float) + Av=np.ones((jpk,jpj,jpi),np.float64) + Au=np.ones((jpk,jpj,jpi),np.float64) for i in range(jpk): Av[i,:,:] = e1v_aux[i,:,:] * e3t[i] Au[i,:,:] = e2u_aux[i,:,:] * e3t[i] - D3T=np.zeros((1,jpk,jpj,jpi),np.float) - D3S=np.zeros((1,jpk,jpj,jpi),np.float) - D3K=np.zeros((1,jpk,jpj,jpi),np.float) + D3T=np.zeros((1,jpk,jpj,jpi),np.float64) + D3S=np.zeros((1,jpk,jpj,jpi),np.float64) + D3K=np.zeros((1,jpk,jpj,jpi),np.float64) - D2Q=np.zeros((1,jpj,jpi),np.float) - D2W=np.zeros((1,jpj,jpi),np.float) - D2H=np.zeros((1,jpj,jpi),np.float) - D2F=np.zeros((1,jpj,jpi),np.float) + D2Q=np.zeros((1,jpj,jpi),np.float64) + D2W=np.zeros((1,jpj,jpi),np.float64) + D2H=np.zeros((1,jpj,jpi),np.float64) + D2F=np.zeros((1,jpj,jpi),np.float64) - D3U=np.zeros((1,jpk,jpj,jpi),np.float) - D3V=np.zeros((1,jpk,jpj,jpi),np.float) - D3W=np.zeros((1,jpk,jpj,jpi),np.float) + D3U=np.zeros((1,jpk,jpj,jpi),np.float64) + D3V=np.zeros((1,jpk,jpj,jpi),np.float64) + D3W=np.zeros((1,jpk,jpj,jpi),np.float64) UVW.create_UVW(test,D3U,D3V,D3W,Av,Au) - D3=np.ones((1,jpk,jpj,jpi),np.float) - D2=np.ones((1,jpj,jpi),np.float) + D3=np.ones((1,jpk,jpj,jpi),np.float64) + D2=np.ones((1,jpj,jpi),np.float64) + SSH=np.zeros((1,jpj,jpi),np.float64)-0.6 FORCING_DATE=[] @@ -75,17 +76,21 @@ def create_forcings_nc(test): filein.close() os.system("mkdir -p " + test['Dir'].decode() + '/FORCINGS/') + os.system("mkdir -p " + test['Dir'].decode() + '/FORCINGS/yyyy') for date in FORCING_DATE: + yyyy=date[0:4] + mm=date[4:6] # Create T file TSKQWHF.create_TSKQWHF(test,date,D3T,D3S,D3K,D2Q,D2W,D2H,D2F) - outfile = test['Dir'].decode() + '/FORCINGS/T' + date + '.nc' - ncOUT = NC.netcdf_file(outfile,'w') + outfile = test['Dir'].decode() + '/FORCINGS/' + yyyy + '/' + mm + '/T' + date + '.nc' + os.system("mkdir -p " + test['Dir'].decode() + '/FORCINGS/yyyy/' + mm) + ncOUT = NC.Dataset(outfile,'w') + ncOUT.createDimension('time_counter',None); ncOUT.createDimension('x' ,jpi); ncOUT.createDimension('y' ,jpj); ncOUT.createDimension('deptht' ,jpk); - ncOUT.createDimension('time_counter',time); ncvar = ncOUT.createVariable('nav_lon' ,'f',('y','x') ); ncvar[:] = Lon; ncvar = ncOUT.createVariable('nav_lat' ,'f',('y','x') ); ncvar[:] = Lat; @@ -95,53 +100,56 @@ def create_forcings_nc(test): ncvar = ncOUT.createVariable('votemper' ,'f',('time_counter','deptht','y','x')); ncvar[:] = D3T; ncvar = ncOUT.createVariable('soshfldo' ,'f',('time_counter','y','x') ); ncvar[:] = D2Q; ncvar = ncOUT.createVariable('sowindsp' ,'f',('time_counter','y','x') ); ncvar[:] = D2W; - ncvar = ncOUT.createVariable('sossheig' ,'f',('time_counter','y','x') ); ncvar[:] = -0.60; + ncvar = ncOUT.createVariable('sossheig' ,'f',('time_counter','y','x') ); ncvar[:] = SSH; + ncOUT.close() # Create U file - outfile = test['Dir'].decode() + '/FORCINGS/U' + date + '.nc' - ncOUT = NC.netcdf_file(outfile,'w') + outfile = test['Dir'].decode() + '/FORCINGS/' + yyyy + '/' + mm + '/U' + date + '.nc' + ncOUT = NC.Dataset(outfile,'w') + ncOUT.createDimension('time_counter',None); ncOUT.createDimension('x' ,jpi); ncOUT.createDimension('y' ,jpj); - ncOUT.createDimension('deptht' ,jpk); - ncOUT.createDimension('time_counter',time); + ncOUT.createDimension('depthu' ,jpk); ncvar = ncOUT.createVariable('nav_lon' ,'f',('y','x') ); ncvar[:] = Lon; ncvar = ncOUT.createVariable('nav_lat' ,'f',('y','x') ); ncvar[:] = Lat; - ncvar = ncOUT.createVariable('deptht' ,'f',('deptht',) ); ncvar[:] = gdept; + ncvar = ncOUT.createVariable('depthu' ,'f',('depthu',) ); ncvar[:] = gdept; ncvar = ncOUT.createVariable('time_counter' ,'d',('time_counter',) ); ncvar = 1.; - ncvar = ncOUT.createVariable('vozocrtx' ,'f',('time_counter','deptht','y','x')); ncvar[:] = D3U; + ncvar = ncOUT.createVariable('vozocrtx' ,'f',('time_counter','depthu','y','x')); ncvar[:] = D3U; + ncvar = ncOUT.createVariable('sozotaux' ,'f',('time_counter','y','x')); ncvar[:] = D2; ncOUT.close() # Create V file - outfile = test['Dir'].decode() + '/FORCINGS/V' + date + '.nc' - ncOUT = NC.netcdf_file(outfile,'w') + outfile = test['Dir'].decode() + '/FORCINGS/' + yyyy + '/' + mm + '/V' + date + '.nc' + ncOUT = NC.Dataset(outfile,'w') + ncOUT.createDimension('time_counter',None); ncOUT.createDimension('x' ,jpi); ncOUT.createDimension('y' ,jpj); - ncOUT.createDimension('deptht' ,jpk); - ncOUT.createDimension('time_counter',time); + ncOUT.createDimension('depthv' ,jpk); ncvar = ncOUT.createVariable('nav_lon' ,'f',('y','x') ); ncvar[:] = Lon; ncvar = ncOUT.createVariable('nav_lat' ,'f',('y','x') ); ncvar[:] = Lat; - ncvar = ncOUT.createVariable('deptht' ,'f',('deptht',) ); ncvar[:] = gdept; + ncvar = ncOUT.createVariable('depthv' ,'f',('depthv',) ); ncvar[:] = gdept; ncvar = ncOUT.createVariable('time_counter' ,'d',('time_counter',) ); ncvar = 1.; - ncvar = ncOUT.createVariable('vomecrty' ,'f',('time_counter','deptht','y','x')); ncvar[:] = D3V; + ncvar = ncOUT.createVariable('vomecrty' ,'f',('time_counter','depthv','y','x')); ncvar[:] = D3V; + ncvar = ncOUT.createVariable('sometauy' ,'f',('time_counter','y','x')); ncvar[:] = D2; ncOUT.close() # Create W file - outfile = test['Dir'].decode() + '/FORCINGS/W' + date + '.nc' - ncOUT = NC.netcdf_file(outfile,'w') + outfile = test['Dir'].decode() + '/FORCINGS/' + yyyy + '/' + mm + '/W' + date + '.nc' + ncOUT = NC.Dataset(outfile,'w') + ncOUT.createDimension('time_counter',None); ncOUT.createDimension('x' ,jpi); ncOUT.createDimension('y' ,jpj); ncOUT.createDimension('depthw' ,jpk); - ncOUT.createDimension('time_counter',time); ncvar = ncOUT.createVariable('nav_lon' ,'f',('y','x') ); ncvar[:] = Lon; ncvar = ncOUT.createVariable('nav_lat' ,'f',('y','x') ); ncvar[:] = Lat; diff --git a/testcase/create_meshmask_nc.py b/testcase/create_meshmask_nc.py index fcff8366..c6de4084 100644 --- a/testcase/create_meshmask_nc.py +++ b/testcase/create_meshmask_nc.py @@ -35,34 +35,36 @@ def create_meshmask_nc(test): dx=test['dx'] dy=test['dy'] -# double coastp(y, x) ; - coastp = np.zeros((jpj,jpi),np.double) +# np.float64 coastp(y, x) ; + coastp = np.zeros((jpj,jpi),dtype=np.float64) -# double fmask(time, z, y, x) ; - fmask = np.ones((time,jpk,jpj,jpi),np.double); +# np.float64 fmask(time, z, y, x) ; + fmask = np.ones((time,jpk,jpj,jpi),np.float64); fmask[0,:,1, 0] = 0.; fmask[0,:,0, 1] = 0.; fmask[0,:,-1,0] = 0.; fmask[0,:,0,-1] = 0.; -# double gdept(time, z, y_a, x_a) ; +# np.float64 gdept(time, z, y_a, x_a) ; filein = 'KB'+'/gdept' + 'KB' + '.dat' - gdeptTOT = np.loadtxt(filein, dtype=np.double); + gdeptTOT = np.loadtxt(filein, dtype=np.float64); gdeptINT = interpolate(gdeptTOT, jpk) - gdept = np.zeros((time,jpk,y_a,x_a),np.double); - gdept[0,0:jpk,0,0] = gdeptINT[0:jpk]; + gdept = np.zeros((time,jpk,jpj,jpi),np.float64); + for jj in range(jpj): + for ji in range(jpi): + gdept[0,0:jpk,jj,ji] = gdeptINT[0:jpk]; -# double gdepw(time, z, y_a, x_a) ; +# np.float64 gdepw(time, z, y_a, x_a) ; filein = 'KB' + '/gdepw' + 'KB' + '.dat' - gdepwTOT = np.loadtxt(filein, dtype=np.double); + gdepwTOT = np.loadtxt(filein, dtype=np.float64); gdepwINT = interpolate(gdepwTOT, jpk) - gdepw = np.zeros((time,jpk,y_a,x_a),np.double); + gdepw = np.zeros((time,jpk,y_a,x_a),np.float64); gdepw[0,0:jpk,0,0] = gdepwINT[0:jpk]; -# double glamt(time, z_a, y, x) ; - glamt = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 glamt(time, z_a, y, x) ; + glamt = np.ones((time,z_a,jpj,jpi),np.float64); if iseven(jpi): for ji in range(jpi): glamt[0,0,:,ji]=test['lon0']-jpi/2.*dx+dx/2. + dx*ji; @@ -70,20 +72,20 @@ def create_meshmask_nc(test): for ji in range(jpi): glamt[0,0,:,ji]=test['lon0']-(jpi-1)/2.*dx + dx*ji; -# double glamu(time, z_a, y, x) ; - glamu = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 glamu(time, z_a, y, x) ; + glamu = np.ones((time,z_a,jpj,jpi),np.float64); glamu = glamt+dx/2.; -# double glamv(time, z_a, y, x) ; - glamv = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 glamv(time, z_a, y, x) ; + glamv = np.ones((time,z_a,jpj,jpi),np.float64); glamv = glamt; -# double glamf(time, z_a, y, x) ; - glamf = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 glamf(time, z_a, y, x) ; + glamf = np.ones((time,z_a,jpj,jpi),np.float64); glamf = glamt+dx/2.; -# double gphit(time, z_a, y, x) ; - gphit = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 gphit(time, z_a, y, x) ; + gphit = np.ones((time,z_a,jpj,jpi),np.float64); if iseven(jpj): for jj in range(jpj): gphit[0,0,jj,:]=test['lat0']-jpj/2.*dy+dy/2. + dy*jj; @@ -91,29 +93,29 @@ def create_meshmask_nc(test): for jj in range(jpj): gphit[0,0,jj,:]=test['lat0']-(jpj-1)/2.*dy + dy*jj; -# double gphiu(time, z_a, y, x) ; - gphiu = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 gphiu(time, z_a, y, x) ; + gphiu = np.ones((time,z_a,jpj,jpi),np.float64); gphiu = gphit -# double gphiv(time, z_a, y, x) ; - gphiv = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 gphiv(time, z_a, y, x) ; + gphiv = np.ones((time,z_a,jpj,jpi),np.float64); gphiv = gphit + dy/2. -# double gphif(time, z_a, y, x) ; - gphif = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 gphif(time, z_a, y, x) ; + gphif = np.ones((time,z_a,jpj,jpi),np.float64); gphif = gphit + dy/2. -# double ff(time, z_a, y, x) ; - ff = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 ff(time, z_a, y, x) ; + ff = np.ones((time,z_a,jpj,jpi),np.float64); # float nav_lat(y, x) ; - nav_lat = np.array(gphit,np.float); + nav_lat = np.array(gphit,np.float32); # float nav_lev(z) ; - nav_lev = np.array(gdept[0,0:jpk,0,0],np.float); + nav_lev = np.array(gdept[0,0:jpk,0,0],np.float32); # float nav_lon(y, x) ; - nav_lon = np.array(glamt,np.float); + nav_lon = np.array(glamt,np.float32); # float time(time) ; timef = 1.; @@ -121,8 +123,8 @@ def create_meshmask_nc(test): # short time_steps(time) ; time_steps = 1; -# double e1f(time, z_a, y, x) ; - e1f = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 e1f(time, z_a, y, x) ; + e1f = np.ones((time,z_a,jpj,jpi),np.float64); for jj in range(jpj-1): for ji in range(jpi-1): dlam_di = glamf[0,0,jj,ji+1]-glamf[0,0,jj,ji] @@ -131,8 +133,8 @@ def create_meshmask_nc(test): e1f[0,0,:,-1] =e1f[0,0,:,-2] e1f[0,0,-1,:] =e1f[0,0,-2,:] -# double e1t(time, z_a, y, x) ; - e1t = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 e1t(time, z_a, y, x) ; + e1t = np.ones((time,z_a,jpj,jpi),np.float64); for jj in range(jpj-1): for ji in range(jpi-1): @@ -142,8 +144,8 @@ def create_meshmask_nc(test): e1t[0,0,:,-1] =e1t[0,0,:,-2] e1t[0,0,-1,:] =e1t[0,0,-2,:] -# double e1u(time, z_a, y, x) ; - e1u = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 e1u(time, z_a, y, x) ; + e1u = np.ones((time,z_a,jpj,jpi),np.float64); for jj in range(jpj-1): for ji in range(jpi-1): @@ -153,8 +155,8 @@ def create_meshmask_nc(test): e1u[0,0,:,-1] =e1u[0,0,:,-2] e1u[0,0,-1,:] =e1u[0,0,-2,:] -# double e1v(time, z_a, y, x) ; - e1v = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 e1v(time, z_a, y, x) ; + e1v = np.ones((time,z_a,jpj,jpi),np.float64); for jj in range(jpj-1): for ji in range(jpi-1): @@ -164,8 +166,8 @@ def create_meshmask_nc(test): e1v[0,0,:,-1] =e1v[0,0,:,-2] e1v[0,0,-1,:] =e1v[0,0,-2,:] -# double e2f(time, z_a, y, x) ; - e2f = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 e2f(time, z_a, y, x) ; + e2f = np.ones((time,z_a,jpj,jpi),np.float64); for jj in range(jpj-1): for ji in range(jpi-1): @@ -175,8 +177,8 @@ def create_meshmask_nc(test): e2f[0,0,:,-1] =e2f[0,0,:,-2] e2f[0,0,-1,:] =e2f[0,0,-2,:] -# double e2t(time, z_a, y, x) ; - e2t = np.ones((time,z_a,jpj,jpi),np.double) +# np.float64 e2t(time, z_a, y, x) ; + e2t = np.ones((time,z_a,jpj,jpi),np.float64) for jj in range(jpj-1): for ji in range(jpi-1): @@ -186,8 +188,8 @@ def create_meshmask_nc(test): e2t[0,0,:,-1] =e2t[0,0,:,-2] e2t[0,0,-1,:] =e2t[0,0,-2,:] -# double e2u(time, z_a, y, x) ; - e2u = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 e2u(time, z_a, y, x) ; + e2u = np.ones((time,z_a,jpj,jpi),np.float64); for jj in range(jpj-1): for ji in range(jpi-1): @@ -197,8 +199,8 @@ def create_meshmask_nc(test): e2u[0,0,:,-1] =e2u[0,0,:,-2] e2u[0,0,-1,:] =e2u[0,0,-2,:] -# double e2v(time, z_a, y, x) ; - e2v = np.ones((time,z_a,jpj,jpi),np.double); +# np.float64 e2v(time, z_a, y, x) ; + e2v = np.ones((time,z_a,jpj,jpi),np.float64); for jj in range(jpj-1): for ji in range(jpi-1): @@ -209,56 +211,56 @@ def create_meshmask_nc(test): e2v[0,0,-1,:] =e2v[0,0,-2,:] -# double e3t(time, z, y, x) ; +# np.float64 e3t(time, z, y, x) ; filein = 'KB'+'/e3t' + 'KB' + '.dat' - e3tTOT = np.loadtxt(filein, dtype=np.double); + e3tTOT = np.loadtxt(filein, dtype=np.float64); e3tINT = interpolate(e3tTOT, jpk) - e3t = np.zeros((time,jpk,jpj,jpi),np.double); + e3t = np.zeros((time,jpk,jpj,jpi),np.float64); for jk in range(jpk): for jj in range(jpj): for ji in range(jpi): e3t[0,jk,jj,ji] = e3tINT[jk]; -# double e3u(time, z, y, x) ; +# np.float64 e3u(time, z, y, x) ; filein = 'KB'+'/e3t' + 'KB' + '.dat' - e3tTOT = np.loadtxt(filein, dtype=np.double); + e3tTOT = np.loadtxt(filein, dtype=np.float64); e3tINT = interpolate(e3tTOT, jpk) - e3u = np.zeros((time,jpk,jpj,jpi),np.double); + e3u = np.zeros((time,jpk,jpj,jpi),np.float64); for jk in range(jpk): for jj in range(jpj): for ji in range(jpi): e3u[0,jk,jj,ji] = e3tINT[jk]; -# double e3v(time, z, y, x) ; +# np.float64 e3v(time, z, y, x) ; filein = 'KB'+'/e3t' + 'KB' + '.dat' - e3tTOT = np.loadtxt(filein, dtype=np.double); + e3tTOT = np.loadtxt(filein, dtype=np.float64); e3tINT = interpolate(e3tTOT, jpk) - e3v = np.zeros((time,jpk,jpj,jpi),np.double); + e3v = np.zeros((time,jpk,jpj,jpi),np.float64); for jk in range(jpk): for jj in range(jpj): for ji in range(jpi): e3v[0,jk,jj,ji] = e3tINT[jk]; -# double e3w(time, z, y_a, x_a) ; +# np.float64 e3w(time, z, y_a, x_a) ; filein = 'KB'+'/e3w' + 'KB' + '.dat' - e3wTOT = np.loadtxt(filein, dtype=np.double); + e3wTOT = np.loadtxt(filein, dtype=np.float64); e3wINT = interpolate(e3wTOT, jpk) - e3w = np.zeros((time,jpk,jpj,jpi),np.double); + e3w = np.zeros((time,jpk,jpj,jpi),np.float64); for jk in range(jpk): for jj in range(jpj): for ji in range(jpi): e3w[0,jk,jj,ji] = e3wINT[jk]; -# double tmask(time, z, y, x) ; - tmask = np.ones((time,jpk,jpj,jpi),np.double); +# np.float64 tmask(time, z, y, x) ; + tmask = np.ones((time,jpk,jpj,jpi),np.float64); tmask[0,:,0, :] =0.; tmask[0,:,:, 0] =0.; tmask[0,:,-1,:] =0.; tmask[0,:,:,-1] =0.; tmask[0,-1,:,:] =0.; -# double umask(time, z, y, x) ; - umask = np.ones((time,jpk,jpj,jpi),np.double); +# np.float64 umask(time, z, y, x) ; + umask = np.ones((time,jpk,jpj,jpi),np.float64); umask[0,:,0, :] =0.; umask[0,:,:, 0] =0.; umask[0,:,-1,:] =0.; @@ -266,9 +268,9 @@ def create_meshmask_nc(test): umask[0,:,:,-2] =0.; umask[0,-1,:,:] =0.; -# double vmask(time, z, y, x) ; +# np.float64 vmask(time, z, y, x) ; - vmask = np.ones((time,jpk,jpj,jpi),np.double); + vmask = np.ones((time,jpk,jpj,jpi),np.float64); vmask[0,:,:, 0] =0.; vmask[0,:,0, :] =0.; vmask[0,:,-1,:] =0.; @@ -309,7 +311,7 @@ def create_meshmask_nc(test): ncvar = ncOUT.createVariable('e3w_0' ,'d',('time','z' , 'y', 'x')) ; ncvar[:] = e3w ncvar = ncOUT.createVariable('ff' ,'d',('time','z_a', 'y', 'x')) ; ncvar[:] = ff ; ncvar = ncOUT.createVariable('fmask' ,'d',('time','z', 'y', 'x')) ; ncvar[:] = fmask ; - ncvar = ncOUT.createVariable('gdept' ,'d',('time','z', 'y_a', 'x_a')) ; ncvar[:] = gdept ; + ncvar = ncOUT.createVariable('gdept' ,'d',('time','z', 'y', 'x')) ; ncvar[:] = gdept ; ncvar = ncOUT.createVariable('gdepw' ,'d',('time','z', 'y_a', 'x_a')) ; ncvar[:] = gdepw ; ncvar = ncOUT.createVariable('glamf' ,'d',('time','z_a', 'y', 'x')) ; ncvar[:] = glamf ; ncvar = ncOUT.createVariable('glamt' ,'d',('time','z_a', 'y', 'x')) ; ncvar[:] = glamt ; diff --git a/testcase/create_optics_nc.py b/testcase/create_optics_nc.py new file mode 100644 index 00000000..fabab719 --- /dev/null +++ b/testcase/create_optics_nc.py @@ -0,0 +1,219 @@ +import os,sys + +import numpy as np + +from mydtype import * + +import scipy.io.netcdf as NC + +import pickle + +#import create_UVW as UVW +#import create_TSKQWHF as TSKQWHF + +def create_optics_nc(test): + + jpi=test['jpi']; + jpj=test['jpj']; + jpk=test['jpk']; + time = 1 + maskfile=test['Dir'].decode() + '/meshmask.nc' + + M=NC.netcdf_file(maskfile,"r") + + Lon = M.variables['glamt'].data[0,0,:,:].copy() + Lat = M.variables['gphit'].data[0,0,:,:].copy() + gdept = M.variables['gdept'].data[0,:,0,0].copy() + gdepw = M.variables['gdepw'].data[0,:,0,0].copy() + e1v = M.variables['e1v' ].data[0,0,:,:].copy() + e2u = M.variables['e2u' ].data[0,0,:,:].copy() + + e3v0 = M.variables['e3v_0' ].data[0,:,:,:].copy() + e3u0 = M.variables['e3u_0' ].data[0,:,:,:].copy() + e3t0 = M.variables['e3t_0' ].data[0,:,:,:].copy() + e3w0 = M.variables['e3w_0' ].data[0,:,:,:].copy() + + + M.close() + e3t = e3t0 + e1v_aux = np.tile(e1v,[jpk,1,1]) + e2u_aux = np.tile(e2u,[jpk,1,1]) + + Av=np.ones((jpk,jpj,jpi),np.float64) + Au=np.ones((jpk,jpj,jpi),np.float64) + + for i in range(jpk): + Av[i,:,:] = e1v_aux[i,:,:] * e3t[i] + Au[i,:,:] = e2u_aux[i,:,:] * e3t[i] + + + D3T=np.zeros((1,jpk,jpj,jpi),np.float64) + D3S=np.zeros((1,jpk,jpj,jpi),np.float64) + D3K=np.zeros((1,jpk,jpj,jpi),np.float64) + + D2Q=np.zeros((1,jpj,jpi),np.float64) + D2W=np.zeros((1,jpj,jpi),np.float64) + D2H=np.zeros((1,jpj,jpi),np.float64) + D2F=np.zeros((1,jpj,jpi),np.float64) + + D3U=np.zeros((1,jpk,jpj,jpi),np.float64) + D3V=np.zeros((1,jpk,jpj,jpi),np.float64) + D3W=np.zeros((1,jpk,jpj,jpi),np.float64) + + + + OPTICS_DATE=[] + + filein=open('OPTICS/forcing_date_atm') + for var in filein: + OPTICS_DATE.append(var[:-1]) + + filein.close() + + os.system("mkdir -p " + test['Dir'].decode() + '/OPTICS') + + for date in OPTICS_DATE: + # Create T file +# TSKQWHF.create_TSKQWHF(test,date,D3T,D3S,D3K,D2Q,D2W,D2H,D2F) + yyyy=date[0:4] + mm=date[4:6] + outfile = test['Dir'].decode() + '/OPTICS/' + yyyy + '/' + mm + '/atm.' + date + '.nc' + os.system("mkdir -p " + test['Dir'].decode() + '/OPTICS/' + yyyy + '/' + mm) + ncOUT = NC.netcdf_file(outfile,'w') + + ncOUT.createDimension('lon' ,jpi); + ncOUT.createDimension('lat' ,jpj); + + ncvar = ncOUT.createVariable('lon' ,'f',('lon',) ); ncvar[:] = Lon[0,:]; + ncvar = ncOUT.createVariable('lat' ,'f',('lat',) ); ncvar[:] = Lat[:,0]; + ncvar = ncOUT.createVariable('sp' ,'f',('lat','lon') ); ncvar[:] = 100000; + ncvar = ncOUT.createVariable('msl' ,'f',('lat','lon') ); ncvar[:] = 100000; + ncvar = ncOUT.createVariable('u10' ,'f',('lat','lon') ); ncvar[:] = 5.0/np.sqrt(2.); + ncvar = ncOUT.createVariable('v10' ,'f',('lat','lon') ); ncvar[:] = 5.0/np.sqrt(2.); +# ncvar = ncOUT.createVariable('u10' ,'f',('lat','lon') ); ncvar[:] = D2W/np.sqrt(2.); +# ncvar = ncOUT.createVariable('v10' ,'f',('lat','lon') ); ncvar[:] = D2W/np.sqrt(2.); + ncvar = ncOUT.createVariable('tclw' ,'f',('lat','lon') ); ncvar[:] = 0.001; + ncvar = ncOUT.createVariable('tco3' ,'f',('lat','lon') ); ncvar[:] = 0.005; + ncvar = ncOUT.createVariable('t2m' ,'f',('lat','lon') ); ncvar[:] = 293.; + ncvar = ncOUT.createVariable('d2m' ,'f',('lat','lon') ); ncvar[:] = 293.; + ncvar = ncOUT.createVariable('tcc' ,'f',('lat','lon') ); ncvar[:] = 0.2; +# float lon(lon) ; +# lon:units = "degrees" ; +# lon:long_name = "longitude" ; +#float lat(lat) ; +# lat:units = "degrees" ; +# lat:long_name = "latitude" ; +#float sp(lat, lon) ; +# sp:long_name = "surface pressure" ; +# sp:units = "Pa" ; +# sp:orig = "ERA5" ; +#float msl(lat, lon) ; +# msl:long_name = "mean sea level pressure" ; +# msl:units = "Pa" ; +# msl:orig = "ERA5" ; +#float u10(lat, lon) ; +# u10:long_name = "zonal wind velocity" ; +# u10:units = "m s*-1" ; +# u10:orig = "ERA5" ; +#float v10(lat, lon) ; +# v10:long_name = "meridional wind velocity" ; +# v10:units = "m s*-1" ; +# v10:orig = "ERA5" ; +#float tclw(lat, lon) ; +# tclw:long_name = "Total column cloud liquid water" ; +# tclw:units = "kg m**-2" ; +# tclw:orig = "ERA5" ; +#float tco3(lat, lon) ; +# tco3:long_name = "Total column ozone" ; +# tco3:units = "kg m**-2" ; +# tco3:orig = "ERA5" ; +#float t2m(lat, lon) ; +# t2m:long_name = "2 metre temperature" ; +# t2m:units = "K" ; +# t2m:orig = "ERA5" ; +#float d2m(lat, lon) ; +# d2m:long_name = "2 metre dewpoint temperature" ; +# d2m:units = "K" ; +# d2m:orig = "ERA5" ; +#float tcc(lat, lon) ; +# tcc:long_name = "Total cloud cover" ; +# tcc:units = "[-]" ; +# tcc:orig = "ERA5" ; + ncOUT.close() + + # Create U file + filein=open('OPTICS/forcing_date_atmclim') + for var in filein: + OPTICS_DATE.append(var[:-1]) + + filein.close() + + os.system("mkdir -p " + test['Dir'].decode() + '/OPTICS') + + for date in OPTICS_DATE: + + outfile = test['Dir'].decode() + '/OPTICS/climatm.' + date + '.nc' + ncOUT = NC.netcdf_file(outfile,'w') + + + ncOUT.createDimension('lon' ,jpi); + ncOUT.createDimension('lat' ,jpj); + + ncvar = ncOUT.createVariable('lon' ,'f',('lon',) ); ncvar[:] = Lon[0,:]; + ncvar = ncOUT.createVariable('lat' ,'f',('lat',) ); ncvar[:] = Lat[:,0]; + + ncvar = ncOUT.createVariable('cdrem' ,'f',('lat','lon') ); ncvar[:] = 12.; + ncvar = ncOUT.createVariable('cldtcm' ,'f',('lat','lon') ); ncvar[:] = 15.; + + ncOUT.close() +#float cdrem(lat, lon) ; +# cdrem:long_name = "cloud droplet effective radius" ; +# cdrem:units = "[um]" ; +# cdrem:orig = "MODCLD" ; +#float cldtcm(lat, lon) ; +# cldtcm:long_name = "TODO" ; +# cldtcm:units = "TODO" ; +# cldtcm:orig = "MODCLD" ; + + # Create V file + filein=open('OPTICS/forcing_date_aero') + for var in filein: + OPTICS_DATE.append(var[:-1]) + + filein.close() + + os.system("mkdir -p " + test['Dir'].decode() + '/OPTICS') + + for date in OPTICS_DATE: + outfile = test['Dir'].decode() + '/OPTICS/aero.' + date + '.nc' + ncOUT = NC.netcdf_file(outfile,'w') + + ncOUT.createDimension('lon' ,jpi); + ncOUT.createDimension('lat' ,jpj); + ncOUT.createDimension('depth' ,jpk); + + ncvar = ncOUT.createVariable('lon' ,'f',('lon',) ); ncvar[:] = Lon[0,:]; + ncvar = ncOUT.createVariable('lat' ,'f',('lat',) ); ncvar[:] = Lat[:,0]; + + ncvar = ncOUT.createVariable('taua' ,'f',('depth','lat','lon') ); ncvar[:] = 0.2; + ncvar = ncOUT.createVariable('asymp' ,'f',('depth','lat','lon') ); ncvar[:] = 0.7; + ncvar = ncOUT.createVariable('ssalb' ,'f',('depth','lat','lon') ); ncvar[:] = 0.98; + +#float taua(depth, lat, lon) ; +# taua:_FillValue = 1.e+20f ; +# taua:long_name = "aerosol optical thickness" ; +# taua:units = "[-]" ; +# taua:orig = "MODIS_AEROSOL" ; +#float asymp(depth, lat, lon) ; +# asymp:_FillValue = 1.e+20f ; +# asymp:long_name = "aerosol asymmetry parameter" ; +# asymp:units = "[-]" ; +# asymp:orig = "MODIS_AEROSOL" ; +#float ssalb(depth, lat, lon) ; +# ssalb:_FillValue = 1.e+20f ; +# ssalb:long_name = "aerosol single scattering albedo" ; +# ssalb:units = "[-]" ; +# ssalb:orig = "MODIS_AEROSOL" ; + + ncOUT.close() + diff --git a/testcase/deploy_code.py b/testcase/deploy_code.py index 76e7d59b..178a8208 100644 --- a/testcase/deploy_code.py +++ b/testcase/deploy_code.py @@ -16,13 +16,18 @@ def deploy_code(test): # ogstm.xx --> executable CODEPATH = test['Code'].decode() CODEPATH = CODEPATH.replace("~",os.getenv("HOME")) - os.system("ln -fs " + CODEPATH + "/OGSTM_BUILD/ogstm.xx "+ test['Dir'].decode() + "/" ) + os.system("ln -fs " + CODEPATH + "OGSTM_BUILD_DBG/ogstm.xx "+ test['Dir'].decode() + "/" ) namelists= CODEPATH + "/ogstm/ready_for_model_namelists/* " os.system("cp -pf " + namelists + test['Dir'].decode() + "/") os.system("cp subgen.py " + test['Dir'].decode() ) + os.system("cp boundaries.nml " + test['Dir'].decode() ) + os.system("cp oasim_config.yaml " + test['Dir'].decode() ) + os.system("cp -r bcs " + test['Dir'].decode() ) print("edit namelist.init to set :") - print(" ingv_files_direct_reading = .false.") + print(" variable_rdt = .false.") + print(" mld_flag = .false.") +# print(" ingv_files_direct_reading = .false.") print(" ingv_lon_shift = 0 ") print(" is_free_surface = .false.") diff --git a/testcase/genInputsDatelists.sh b/testcase/genInputsDatelists.sh index 3acf735d..66657ecc 100755 --- a/testcase/genInputsDatelists.sh +++ b/testcase/genInputsDatelists.sh @@ -8,6 +8,10 @@ # Author: GB, 12.03.2012 + + +#################### Function definitions ####################### + function datelist { VAR=$1 for FILE in `ls $VAR*.nc` ; do @@ -18,12 +22,73 @@ done } -DIR=$1 +function datelist2 { +DIR=$1 +VAR=$2 +for yyyy in $(ls $DIR); do + [[ ${#yyyy} == 4 ]] || continue + for mm in $(ls $DIR/$yyyy) ; do + [[ ${#mm} == 2 ]] || continue + STR=$DIR/$yyyy/$mm/${VAR} + for FILE in $(ls ${STR}* 2>/dev/null ) ; do + V=${FILE#$STR} + echo ${V%.nc} + done + done +done + +} + +#################### Input parsing ############################## + +if [ $# -gt 1 ]; then BCS_FILE=$1; else BCS_FILE="boundaries.nml"; fi + + +#################### O-O boundary conditions #################### + +# Compatibility with old BCS names +declare -A BCS_NAMES +BCS_NAMES=( + ["riv"]="TIN" + ["atl"]="ATL" + ["gi1"]="GIB" + ["gi2"]="GIB" + ["gi3"]="GIB" +) + +tail -n +2 $BCS_FILE | while read BC_raw; do + + BC=$(echo $BC_raw | sed 's/"//g') + + BC_NAME=$(echo $BC | cut -d ' ' -f 1 | sed 's/,//g'); echo "BC_NAME="$BC_NAME + BC_LIST=$(echo $BC | cut -d ' ' -f 4 | sed 's/,//g') + BC_PERIODIC=$(echo $BC | cut -d ' ' -f 5 | sed 's/,//g') + + if [ $BC_PERIODIC == "T" ]; then + echo "BC/${BCS_NAMES[$BC_NAME]}_yyyy*" + ls BC/${BCS_NAMES[$BC_NAME]}_yyyy* | wc -l > $BC_LIST + ls BC/${BCS_NAMES[$BC_NAME]}_yyyy* | sed "s/^/'/g" | sed "s/$/'/g" >> $BC_LIST + else + ls BC/${BCS_NAMES[$BC_NAME]}_[0-9]* | wc -l > $BC_LIST + ls BC/${BCS_NAMES[$BC_NAME]}_[0-9]* | sed "s/^/'/g" | sed "s/$/'/g" >> $BC_LIST + fi + +done + + + +#################### Previous script ############################ + +datelist BC/ATM_ > AtmTimes +datelist BC/CO2_ > carbonTimes -datelist ${DIR}/BC/TIN_ > ${DIR}/RiversTimes -datelist ${DIR}/BC/GIB_ > ${DIR}/GibTimes -datelist ${DIR}/BC/ATM_ > ${DIR}/AtmTimes -datelist ${DIR}/BC/CO2_ > ${DIR}/carbonTimes +datelist2 FORCINGS U > forcingsTimes +if [ -d OPTICS ] ; then + datelist2 OPTICS atm. > optatmTimes + datelist OPTICS/climatm. > optclimTimes + datelist OPTICS/aero. > optAeroTimes +else + datelist KEXT/KextF_ > kextTimes +fi -datelist ${DIR}/FORCINGS/U > ${DIR}/forcingsTimes -datelist ${DIR}/KEXT/KextF_ > ${DIR}/kextTimes +#for I in `ls SATELLITE/ | cut -c 1-8` ; do echo $I-12:00:00 ; done > daTimes_sat diff --git a/testcase/interpolation43.py b/testcase/interpolation43.py index 830f3ca4..db9985d7 100644 --- a/testcase/interpolation43.py +++ b/testcase/interpolation43.py @@ -1,5 +1,5 @@ import numpy as np def interpolate(var43, nPoints): x = np.arange(43) - xNew=np.arange(nPoints,dtype=np.float)/nPoints*43 + xNew=np.arange(nPoints,dtype=np.float64)/nPoints*43 return np.interp(xNew,x,var43) diff --git a/testcase/mydtype.py b/testcase/mydtype.py index 7f0cec12..56cfb3bc 100644 --- a/testcase/mydtype.py +++ b/testcase/mydtype.py @@ -2,14 +2,14 @@ import numpy as np -test_conf=np.dtype([('jpi' ,np.int) ,('jpj',np.int) ,('jpk',np.int),\ - ('nprocx',np.int) ,('nprocy',np.int) ,\ - ('lon0' ,np.float),('lat0',np.float) ,\ - ('dx' ,np.float),('dy' ,np.float),\ +test_conf=np.dtype([('jpi' ,int) ,('jpj',int) ,('jpk',int),\ + ('nprocx',int) ,('nprocy',int) ,\ + ('lon0' ,float),('lat0',float) ,\ + ('dx' ,float),('dy' ,float),\ ('Start' ,'S100') ,('End' ,'S100') ,\ ('Dir','S100'),('Code','S100')]) -ext_data =np.dtype([('date','S17'),('kext',np.float)]) +ext_data =np.dtype([('date','S17'),('kext',float)]) def file2stringlist(filename): diff --git a/testcase/oasim_config.yaml b/testcase/oasim_config.yaml new file mode 100644 index 00000000..f5082dad --- /dev/null +++ b/testcase/oasim_config.yaml @@ -0,0 +1,13 @@ +input: + atmospheric_data_file: bcs/atmo_nn.dat + absorption_data_file: bcs/abso_nn.dat + cloud_slingo_file: bcs/slingo_nn.dat +compute: + integration_step_secs: 300.0 + max_integration_steps: 1000 + zenith_avg: true + local_time: true + am: 1.0 + vi: 25.0 +output: + bin_file: bcs/bin_n.dat diff --git a/testcase/subgen.py b/testcase/subgen.py index e0aa69f1..7eb1114a 100644 --- a/testcase/subgen.py +++ b/testcase/subgen.py @@ -7,5 +7,5 @@ TheMask=Mask('meshmask.nc',dzvarname="e3t_0") for sub in OGS.Pred: - S=SubMask(sub, TheMask) + S=SubMask(sub,maskobject=TheMask) S.save_as_netcdf('submask.nc', maskvarname=sub.name) From 7b59969a8728c3fd923d96cb6c9ebd66b7f83eee Mon Sep 17 00:00:00 2001 From: Paolo Lazzari Date: Tue, 22 Jul 2025 12:00:31 +0200 Subject: [PATCH 21/25] cleaning --- testcase/KB/INIT_NWM_KB/init.R7c | 43 -------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 testcase/KB/INIT_NWM_KB/init.R7c diff --git a/testcase/KB/INIT_NWM_KB/init.R7c b/testcase/KB/INIT_NWM_KB/init.R7c deleted file mode 100644 index 16c4ec30..00000000 --- a/testcase/KB/INIT_NWM_KB/init.R7c +++ /dev/null @@ -1,43 +0,0 @@ -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00010000000000000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 -0.00000000000001000000 From e008194ab912e39cd74f4ddbe85e40e1fde1e524 Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Wed, 15 Apr 2026 21:31:13 +0200 Subject: [PATCH 22/25] wind stress are defined on T mask --- src/IO/forcing_phys.f90 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/IO/forcing_phys.f90 b/src/IO/forcing_phys.f90 index d228e124..20384c13 100644 --- a/src/IO/forcing_phys.f90 +++ b/src/IO/forcing_phys.f90 @@ -295,24 +295,22 @@ SUBROUTINE LOAD_PHYS(datestring) + write(nomefile,fileformat) yyyy,mm,"T",datestring + call existvar(nomefile,'sowindsp',B) + if (B) then + call readnc_slice_float_2d(nomefile,'sowindsp',buf2,ingv_lon_shift) + else - if (ingv_files_direct_reading) then - write(nomefile,fileformat) yyyy,mm,"U",datestring call readnc_slice_float_2d(nomefile,'sozotaux',buf2,ingv_lon_shift) - taux = buf2*tmask(1,:,:)*umask(1,:,:) + taux = buf2*tmask(1,:,:) - write(nomefile,fileformat) yyyy,mm,"V",datestring call readnc_slice_float_2d(nomefile,'sometauy',buf2,ingv_lon_shift) - tauy = buf2*tmask(1,:,:)*vmask(1,:,:) + tauy = buf2*tmask(1,:,:) call PURE_WIND_SPEED(taux,tauy,jpi,jpj, buf2) - else - write(nomefile,fileformat) yyyy,mm,"T",datestring - call readnc_slice_float_2d(nomefile,'sowindsp',buf2,ingv_lon_shift) endif flxdta(:,:,jpwind,2) = buf2*tmask(1,:,:) * spongeT - write(nomefile,fileformat) yyyy,mm,"T",datestring call readnc_slice_float_2d(nomefile,'soshfldo',buf2,ingv_lon_shift) flxdta(:,:,jpqsr ,2) = buf2*tmask(1,:,:) * spongeT flxdta(:,:,jpice ,2) = 0. From 094c974425bd1ca3e7179c47ba168e0abffbc071 Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Wed, 15 Apr 2026 21:32:35 +0200 Subject: [PATCH 23/25] renaming w10 --> wsp10 for wind speed at 10m --- src/IO/forcing_kext.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IO/forcing_kext.f90 b/src/IO/forcing_kext.f90 index 6ed33653..d57edee5 100644 --- a/src/IO/forcing_kext.f90 +++ b/src/IO/forcing_kext.f90 @@ -138,7 +138,7 @@ SUBROUTINE LOAD_KEXT(datestring) call readnc_slice_float_2d(nomefile,'tcc',buf2,0) tccIO(:,:,2) = buf2*tmask(1,:,:) - call readnc_slice_float_2d(nomefile,'w10',buf2,0) + call readnc_slice_float_2d(nomefile,'wsp10',buf2,0) w10IO(:,:,2) = buf2*tmask(1,:,:) call readnc_slice_float_2d(nomefile,'tclw',buf2,0) From b5844d15f3182a10d76f68e1456ceb5ab35c2af4 Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Mon, 27 Apr 2026 15:18:28 +0200 Subject: [PATCH 24/25] Fixing horrible hard_open.f90 bug --- src/BC/hard_open.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BC/hard_open.f90 b/src/BC/hard_open.f90 index 1122b3b6..05955e12 100644 --- a/src/BC/hard_open.f90 +++ b/src/BC/hard_open.f90 @@ -544,7 +544,7 @@ subroutine apply_dirichlet(self) ! 2nd loop: provided variables on neighbors do j = 1, self%m_size - idx_i = self%m_neighbors(1, i) + idx_i = self%m_neighbors(1, j) idx_j = self%m_neighbors(2, j) idx_k = self%m_neighbors(3, j) From c62423321895087b70b96e01a85c121de5551e4a Mon Sep 17 00:00:00 2001 From: Giorgio Bolzon Date: Wed, 29 Apr 2026 15:58:43 +0200 Subject: [PATCH 25/25] printing all the forcing filename --- src/IO/forcing_phys.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IO/forcing_phys.f90 b/src/IO/forcing_phys.f90 index 20384c13..40081e07 100644 --- a/src/IO/forcing_phys.f90 +++ b/src/IO/forcing_phys.f90 @@ -163,7 +163,7 @@ SUBROUTINE LOAD_PHYS(datestring) ! Starting I/O ! U ********************************************************* write(nomefile,fileformat) yyyy,mm,"U",datestring - if(lwp) write(*,'(A,I4,A,A)') "LOAD_PHYS --> I am ", myrank, " starting reading forcing fields from ", nomefile(1:30) + if(lwp) write(*,'(A,I4,A,A)') "LOAD_PHYS --> I am ", myrank, " starting reading forcing fields from ", nomefile call readnc_slice_float(nomefile,'vozocrtx',buf,ingv_lon_shift) udta(:,:,:,2) = buf * umask