Warning, /verification/seaice_obcs/input.tides/mk_tides.m is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit 672b8226 on 2024-05-18 15:32:33 UTC
672b822630 Jean*0001 % Generate example of OB input files for tidal-component velocity field
6f4cf52d27 Dimi*0002
672b822630 Jean*0003 % Tidal-component OB input files are real*4 IEEE big-endian binary
0004 % with dimension: OBlength x nTidalComp,
0005 % where OBlength is the length of the open boundary and nTidalComp is the
0006 % number of tidal components to use (i.e., the last non-zero "OBCS_tidalPeriod"
0007 % from "data.obcs"), not larger than "OBCS_tideCompSize" from "OBCS_PARAMS.h".
6f4cf52d27 Dimi*0008
672b822630 Jean*0009 % OB[N,S,E,W][am,ph][N,T]File :: Files with boundary conditions,
0010 % the letter combinations mean:
0011 % N/S/E/W :: northern/southern/eastern/western boundary
0012 % am/ph :: tidal amplitude (m/s) / phase (s)
0013 % N/T :: for the velocity Normal-component / Tangential-component
6f4cf52d27 Dimi*0014
672b822630 Jean*0015 % Tidal periods are specified using variable "OBCS_tidalPeriod" in "data.obcs"
6f4cf52d27 Dimi*0016 % Tidal amplitude is the maximum tidal velocity in m/s.
672b822630 Jean*0017 % Tidal phase indicates time in s of maximum positive tide relative to model Time=0.
6f4cf52d27 Dimi*0018
672b822630 Jean*0019 %- note: uses writebin.m which can be found in: MITgcm/utils/matlab/cs_grid/read_cs
6f4cf52d27 Dimi*0020
0021 % create tidal input files
0022 nx=10; ny=8;
672b822630 Jean*0023 nTidalComp=4;
6f4cf52d27 Dimi*0024 for ob={'N','S','E','W'}
0025 OBlength=ny;
0026 if any(strcmp(ob,{'N','S'}))
0027 OBlength=nx;
0028 end
0029 for fld={'am','ph'}
672b822630 Jean*0030 fnm1=['tidalComp.OB' ob{1} fld{1} 'Nvel.bin'];
0031 fnm2=['tidalComp.OB' ob{1} fld{1} 'Tvel.bin'];
0032 var1=zeros(OBlength,nTidalComp); var2=var1;
6f4cf52d27 Dimi*0033
672b822630 Jean*0034 % specify (0.03 m/s, 6 hr) for North boundary tidal component 3
6f4cf52d27 Dimi*0035 if strcmp(ob,'N')
0036 if strcmp(fld,'am')
672b822630 Jean*0037 var1(:,3) = var1(:,3) + 0.03;
6f4cf52d27 Dimi*0038 else
672b822630 Jean*0039 var1(:,3) = var1(:,3) + 6 * 3600;
6f4cf52d27 Dimi*0040 end
0041 end
0042
672b822630 Jean*0043 % specify ( 0.1 m/s, 2 hr) for South boundary tidal component 1
6f4cf52d27 Dimi*0044 if strcmp(ob,'S')
0045 if strcmp(fld,'am')
672b822630 Jean*0046 var1(:,1) = var1(:,1) + 0.1;
6f4cf52d27 Dimi*0047 else
672b822630 Jean*0048 var1(:,1) = var1(:,1) + 2 * 3600;
0049 end
0050 % also specify Tangential velocity (0.01 m/s, 3 hr)
0051 % for South boundary tidal component 1
0052 if strcmp(fld,'am')
0053 var2(:,1) = var1(:,1) + 0.01;
0054 else
0055 var2(:,1) = var2(:,1) + 3 * 3600;
6f4cf52d27 Dimi*0056 end
0057 end
0058
672b822630 Jean*0059 % specify ( 0.1 m/s, 4 hr) for East boundary tidal component 2
6f4cf52d27 Dimi*0060 if strcmp(ob,'E')
0061 if strcmp(fld,'am')
672b822630 Jean*0062 var1(:,2) = var1(:,2) + 0.1;
6f4cf52d27 Dimi*0063 else
672b822630 Jean*0064 var1(:,2) = var1(:,2) + 4 * 3600;
0065 end
0066 % also specify Tangential velocity (0.01 m/s, 5 hr)
0067 % for East boundary tidal component 2
0068 if strcmp(fld,'am')
0069 var2(:,2) = var2(:,2) + 0.01;
0070 else
0071 var2(:,2) = var2(:,2) + 5 * 3600;
6f4cf52d27 Dimi*0072 end
0073 end
0074
672b822630 Jean*0075 % specify (0.02 m/s, 8 hr) for West boundary tidal component 4
6f4cf52d27 Dimi*0076 if strcmp(ob,'W')
0077 if strcmp(fld,'am')
672b822630 Jean*0078 var1(:,4) = var1(:,4) + 0.02;
6f4cf52d27 Dimi*0079 else
672b822630 Jean*0080 var1(:,4) = var1(:,4) + 8 * 3600;
6f4cf52d27 Dimi*0081 end
0082 end
0083
672b822630 Jean*0084 fprintf(' writing bin file: %s ...',fnm1)
0085 writebin(fnm1,var1)
0086 fprintf(' done\n')
0087
0088 if strcmp(ob,'S') || strcmp(ob,'E')
0089 fprintf(' writing bin file: %s ...',fnm2)
0090 writebin(fnm2,var2)
0091 fprintf(' done\n')
0092 end
0093
6f4cf52d27 Dimi*0094 end
0095 end