sustr and svstr Value has not been read

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Message
Author
User avatar
hpd14thu
Posts: 55
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

sustr and svstr Value has not been read

#1 Post by hpd14thu » Sun May 06, 2018 3:07 pm

My force file contains sustr and svstr , but when I run it , I find that these two variable has not been read.

I consider that there are some problems in my head file , but I don't know which CPP option I should add into head file.

Here is my head file:

/*
** svn $Id: sandy.h 25 2007-04-09 23:43:58Z jcwarner $
*******************************************************************************
** Copyright (c) 2002-2007 The ROMS/TOMS Group **
** Licensed under a MIT/X style license **
** See License_ROMS.txt **
*******************************************************************************
**
** Options for Sandy Test.
**
** Application flag: SANDY
*/

#define ROMS_MODEL
#undef NESTING
/*#define WRF_MODEL
#define SWAN_MODEL
#define MCT_LIB
#define MCT_INTERP_OC2AT
#define MCT_INTERP_WV2AT
#define MCT_INTERP_OC2WV*/

#if defined WRF_MODEL && defined SWAN_MODEL
# define DRAGLIM_DAVIS
# define COARE_TAYLOR_YELLAND
#endif

#ifdef ROMS_MODEL
/* Physics + numerics */
# define UV_ADV
# define UV_COR
# define UV_VIS2
# define MIX_S_UV
# undef TS_FIXED
# define TS_U3HADVECTION
# define TS_C4VADVECTION
# undef TS_MPDATA

# undef SSW_BBL
# ifdef SSW_BBL
# define SSW_CALC_ZNOT
/* # define ANA_SEDIMENT */
# else
# define UV_LOGDRAG
# endif
# if !defined SWAN_MODEL && defined SSW_BBL
# define ANA_WWAVE
# endif

# define DJ_GRADPS
# define TS_DIF2
# define MIX_GEO_TS
# define CURVGRID
# define SALINITY
# define SOLVE3D
# define AVERAGES
# define NONLIN_EOS


/* Grid and Initial */
# define MASKING

/* Forcing */
# ifdef WRF_MODEL
# undef BULK_FLUXES
# define ATM2OCN_FLUXES
# define ANA_SSFLUX
# undef LONGWAVE_OUT
/*# define ATM_PRESS*/
# else
/*# define BULK_FLUXES/*
# define ANA_SMFLUX
# define ANA_STFLUX
# define ANA_SSFLUX */
/*# define ATM_PRESS/*
/*# define LONGWAVE_OUT*/
# endif
# define ANA_BTFLUX
# define ANA_BSFLUX
# define ANA_SMFLUX
# define EMINUSP
/*# define SOLAR_SOURCE/*

/* Turbulence closure */
# define GLS_MIXING
# undef MY25_MIXING
# define AKLIMIT

# if defined GLS_MIXING || defined MY25_MIXING
# define KANTHA_CLAYSON
# define N2S2_HORAVG
# endif

/* Output */
# undef DIAGNOSTICS_UV
# undef DIAGNOSTICS_TS
#endif

jcwarner
Posts: 813
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: sustr and svstr Value has not been read

#2 Post by jcwarner » Sun May 06, 2018 3:54 pm

you basically have this set:
/* Forcing */
# ifdef WRF_MODEL
...
# else
/*# define BULK_FLUXES/*
# define ANA_SMFLUX
# endif

so you have ana_smflux on. that will look for analytical values and they are most likely set to 0. so you would want to use
#undef ANA_SMFLUX
and then it will look for su/vstr in forcing files.

User avatar
hpd14thu
Posts: 55
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

Re: sustr and svstr Value has not been read

#3 Post by hpd14thu » Sun May 06, 2018 5:02 pm

jcwarner wrote:you basically have this set:
/* Forcing */
# ifdef WRF_MODEL
...
# else
/*# define BULK_FLUXES/*
# define ANA_SMFLUX
# endif

so you have ana_smflux on. that will look for analytical values and they are most likely set to 0. so you would want to use
#undef ANA_SMFLUX
and then it will look for su/vstr in forcing files.
Thanks a million! I have solved this problem by this way. But there are another new question which I don't understand:

Here is result.out , the error shows in the last few lines :

ZFIRST

Operating system : Linux
CPU/hardware : x86_64
Compiler system : gfortran
Compiler command : /usr/local/mpich/bin/mpif90
Compiler flags : -frepack-arrays -O3 -ffast-math -ftree-vectorize -ftree-loop-linear -funroll-loops -w -ffree-form -ffree-line-length-none -frecord-marker=4 -fconvert=big-endian

Input Script :

SVN Root URL : https:://myroms.org/svn/src
SVN Revision :

Local Root : /home/hpd14/Documents/COAWST_V3.2
Header Dir : /home/hpd14/Documents/COAWST_V3.2/Projects/zfirst
Header file : zfirst.h
Analytical Dir: /home/hpd14/Documents/COAWST_V3.2/Projects/zfirst

Resolution, Grid 01: 0048x0048x020, Parallel Nodes: 1, Tiling: 001x001


Physical Parameters, Grid: 01
=============================

8640 ntimes Number of timesteps for 3-D equations.
0.020 dt Timestep size (s) for 3-D equations.
20 ndtfast Number of timesteps for 2-D equations between
each 3D timestep.
1 ERstr Starting ensemble/perturbation run number.
1 ERend Ending ensemble/perturbation run number.
0 nrrec Number of restart records to read from disk.
T LcycleRST Switch to recycle time-records in restart file.
120 nRST Number of timesteps between the writing of data
into restart fields.
1 ninfo Number of timesteps between print of information
to standard output.
T ldefout Switch to create a new output NetCDF file(s).
1 nHIS Number of timesteps between the writing fields
into history file.
1 ntsAVG Starting timestep for the accumulation of output
time-averaged data.
360 nAVG Number of timesteps between the writing of
time-averaged data into averages file.
0.0000E+00 nl_tnu2(01) NLM Horizontal, harmonic mixing coefficient
(m2/s) for tracer 01: temp
0.0000E+00 nl_tnu2(02) NLM Horizontal, harmonic mixing coefficient
(m2/s) for tracer 02: salt
5.0000E-02 nl_visc2 NLM Horizontal, harmonic mixing coefficient
(m2/s) for momentum.
F LuvSponge Turning OFF sponge on horizontal momentum.
F LtracerSponge(01) Turning OFF sponge on tracer 01: temp
F LtracerSponge(02) Turning OFF sponge on tracer 02: salt
5.0000E-06 Akt_bak(01) Background vertical mixing coefficient (m2/s)
for tracer 01: temp
5.0000E-06 Akt_bak(02) Background vertical mixing coefficient (m2/s)
for tracer 02: salt
5.0000E-05 Akv_bak Background vertical mixing coefficient (m2/s)
for momentum.
5.0000E-06 Akk_bak Background vertical mixing coefficient (m2/s)
for turbulent energy.
5.0000E-06 Akp_bak Background vertical mixing coefficient (m2/s)
for turbulent generic statistical field.
3.000 gls_p GLS stability exponent.
1.500 gls_m GLS turbulent kinetic energy exponent.
-1.000 gls_n GLS turbulent length scale exponent.
7.6000E-06 gls_Kmin GLS minimum value of turbulent kinetic energy.
1.0000E-12 gls_Pmin GLS minimum value of dissipation.
5.4770E-01 gls_cmu0 GLS stability coefficient.
1.4400E+00 gls_c1 GLS shear production coefficient.
1.9200E+00 gls_c2 GLS dissipation coefficient.
-4.0000E-01 gls_c3m GLS stable buoyancy production coefficient.
1.0000E+00 gls_c3p GLS unstable buoyancy production coefficient.
1.0000E+00 gls_sigk GLS constant Schmidt number for TKE.
1.3000E+00 gls_sigp GLS constant Schmidt number for PSI.
1400.000 charnok_alpha Charnok factor for Zos calculation.
0.500 zos_hsig_alpha Factor for Zos calculation using Hsig(Awave).
0.250 sz_alpha Factor for Wave dissipation surface tke flux .
100.000 crgban_cw Factor for Craig/Banner surface tke flux.
0.000 wec_alpha WEC factor for roller/breaking energy distribution.
3.0000E-04 rdrg Linear bottom drag coefficient (m/s).
2.5000E-02 rdrg2 Quadratic bottom drag coefficient.
2.0000E-02 Zob Bottom roughness (m).
5.0000E-01 Zos Surface roughness (m).
1 lmd_Jwt Jerlov water type.
2 Vtransform S-coordinate transformation equation.
4 Vstretching S-coordinate stretching function.
8.0000E+00 theta_s S-coordinate surface control parameter.
5.0000E-01 theta_b S-coordinate bottom control parameter.
20.000 Tcline S-coordinate surface/bottom layer width (m) used
in vertical coordinate stretching.
1025.000 rho0 Mean density (kg/m3) for Boussinesq approximation.
0.000 dstart Time-stamp assigned to model initialization (days).
0.00 time_ref Reference time for units attribute (yyyymmdd.dd)
0.0000E+00 Tnudg(01) Nudging/relaxation time scale (days)
for tracer 01: temp
0.0000E+00 Tnudg(02) Nudging/relaxation time scale (days)
for tracer 02: salt
0.0000E+00 Tnudg_SSS Nudging/relaxation time scale (days)
for sea surface salinity.
0.0000E+00 Znudg Nudging/relaxation time scale (days)
for free-surface.
0.0000E+00 M2nudg Nudging/relaxation time scale (days)
for 2D momentum.
0.0000E+00 M3nudg Nudging/relaxation time scale (days)
for 3D momentum.
0.0000E+00 obcfac Factor between passive and active
open boundary conditions.
F VolCons(1) NLM western edge boundary volume conservation.
F VolCons(2) NLM southern edge boundary volume conservation.
F VolCons(3) NLM eastern edge boundary volume conservation.
F VolCons(4) NLM northern edge boundary volume conservation.
10.000 T0 Background potential temperature (C) constant.
30.000 S0 Background salinity (PSU) constant.
1.000 gamma2 Slipperiness variable: free-slip (1.0) or
no-slip (-1.0).
F LuvSrc Turning OFF momentum point Sources/Sinks.
F LwSrc Turning OFF volume influx point Sources/Sinks.
F LtracerSrc(01) Turning OFF point Sources/Sinks on tracer 01: temp
F LtracerSrc(02) Turning OFF point Sources/Sinks on tracer 02: salt
F LsshCLM Turning OFF processing of SSH climatology.
F Lm2CLM Turning OFF processing of 2D momentum climatology.
F Lm3CLM Turning OFF processing of 3D momentum climatology.
F LtracerCLM(01) Turning OFF processing of climatology tracer 01: temp
F LtracerCLM(02) Turning OFF processing of climatology tracer 02: salt
F LnudgeM2CLM Turning OFF nudging of 2D momentum climatology.
F LnudgeM3CLM Turning OFF nudging of 3D momentum climatology.
F LnudgeTCLM(01) Turning OFF nudging of climatology tracer 01: temp
F LnudgeTCLM(02) Turning OFF nudging of climatology tracer 02: salt
T Hout(idFsur) Write out free-surface.
T Hout(idUbar) Write out 2D U-momentum component.
T Hout(idVbar) Write out 2D V-momentum component.
T Hout(idUvel) Write out 3D U-momentum component.
T Hout(idVvel) Write out 3D V-momentum component.
T Hout(idWvel) Write out W-momentum component.
T Hout(idOvel) Write out omega vertical velocity.
T Hout(idTvar) Write out tracer 01: temp
T Hout(idTvar) Write out tracer 02: salt
T Hout(idUsms) Write out surface U-momentum stress.
T Hout(idVsms) Write out surface V-momentum stress.
T Hout(idUbms) Write out bottom U-momentum stress.
T Hout(idVbms) Write out bottom V-momentum stress.

T Aout(idSdif) Write out averaged vertical diffusion: AKt(isalt).

Output/Input Files:

Output Restart File: ocean_rst.nc
Output History File: ocean_zfirst_his.nc
Output Averages File: ocean_avg.nc
Input Grid File: /home/hpd14/Documents/COAWST_V3.2/Projects/zfirst/zfirst_grid_cco.nc
Input Nonlinear Initial File: /home/hpd14/Documents/COAWST_V3.2/Projects/zfirst/zfirst_init_cco.nc
Input Forcing File 01: /home/hpd14/Documents/COAWST_V3.2/Projects/zfirst/zfirst_str.nc

Tile partition information for Grid 01: 0048x0048x0020 tiling: 001x001

tile Istr Iend Jstr Jend Npts

Number of tracers: 2
0 1 48 1 48 46080

Tile minimum and maximum fractional coordinates for Grid 01:
(interior points only)

tile Xmin Xmax Ymin Ymax grid

0 0.50 48.50 0.50 48.50 RHO-points

0 1.00 48.00 0.50 48.50 U-points

0 0.50 48.50 1.00 48.00 V-points

Maximum halo size in XI and ETA directions:

HaloSizeI(1) = 118
HaloSizeJ(1) = 118
TileSide(1) = 53
TileSize(1) = 2809


Lateral Boundary Conditions: NLM
============================

Variable Grid West Edge South Edge East Edge North Edge
--------- ---- ---------- ---------- ---------- ----------

zeta 1 Closed Closed Closed Closed

ubar 1 Closed Closed Closed Closed

vbar 1 Closed Closed Closed Closed

u 1 Closed Closed Closed Closed

v 1 Closed Closed Closed Closed

temp 1 Closed Closed Closed Closed

salt 1 Closed Closed Closed Closed

tke 1 Closed Closed Closed Closed

Activated C-preprocessing Options:

ZFIRST ZFIRST
ANA_BSFLUX Analytical kinematic bottom salinity flux.
ANA_BTFLUX Analytical kinematic bottom temperature flux.
ASSUMED_SHAPE Using assumed-shape arrays.
AVERAGES Writing out time-averaged nonlinear model fields.
CURVGRID Orthogonal curvilinear grid.
DJ_GRADPS Parabolic Splines density Jacobian (Shchepetkin, 2002).
DOUBLE_PRECISION Double precision arithmetic.
GLS_MIXING Generic Length-Scale turbulence closure.
KANTHA_CLAYSON Kantha and Clayson stability function formulation.
MASKING Land/Sea masking.
MIX_GEO_TS Mixing of tracers along geopotential surfaces.
MIX_S_UV Mixing of momentum along constant S-surfaces.
MPI MPI distributed-memory configuration.
NONLINEAR Nonlinear Model.
NONLIN_EOS Nonlinear Equation of State for seawater.
N2S2_HORAVG Horizontal smoothing of buoyancy and shear.
POWER_LAW Power-law shape time-averaging barotropic filter.
PROFILE Time profiling activated .
K_GSCHEME Third-order upstream advection of TKE fields.
!RST_SINGLE Double precision fields in restart NetCDF file.
SALINITY Using salinity.
SOLAR_SOURCE Solar Radiation Source Term.
SOLVE3D Solving 3D Primitive Equations.
TS_U3HADVECTION Third-order upstream horizontal advection of tracers.
TS_C4VADVECTION Fourth-order centered vertical advection of tracers.
TS_DIF2 Harmonic mixing of tracers.
UV_ADV Advection of momentum.
UV_COR Coriolis term.
UV_U3HADVECTION Third-order upstream horizontal advection of 3D momentum.
UV_C4VADVECTION Fourth-order centered vertical advection of momentum.
UV_LOGDRAG Logarithmic bottom stress.
UV_VIS2 Harmonic mixing of momentum.
VAR_RHO_2D Variable density barotropic mode.

Process Information:

Node # 0 (pid= 46871) is active.

INITIAL: Configuring and initializing forward nonlinear model ...
*******

Vertical S-coordinate System, Grid 01:

level S-coord Cs-curve Z at hmin at hc half way at hmax

20 0.0000000 0.0000000 0.000 0.000 0.000 0.000
19 -0.0500000 -0.0000692 -0.501 -0.501 -0.501 -0.501
18 -0.1000000 -0.0002879 -1.003 -1.003 -1.003 -1.003
17 -0.1500000 -0.0006915 -1.507 -1.507 -1.507 -1.507
16 -0.2000000 -0.0013455 -2.013 -2.013 -2.013 -2.013
15 -0.2500000 -0.0023555 -2.524 -2.524 -2.524 -2.524
14 -0.3000000 -0.0038848 -3.039 -3.039 -3.039 -3.039
13 -0.3500000 -0.0061801 -3.562 -3.562 -3.562 -3.562
12 -0.4000000 -0.0096110 -4.096 -4.096 -4.096 -4.096
11 -0.4500000 -0.0147275 -4.647 -4.647 -4.647 -4.647
10 -0.5000000 -0.0223460 -5.223 -5.223 -5.223 -5.223
9 -0.5500000 -0.0336719 -5.837 -5.837 -5.837 -5.837
8 -0.6000000 -0.0504756 -6.505 -6.505 -6.505 -6.505
7 -0.6500000 -0.0753361 -7.253 -7.253 -7.253 -7.253
6 -0.7000000 -0.1119642 -8.120 -8.120 -8.120 -8.120
5 -0.7500000 -0.1655988 -9.156 -9.156 -9.156 -9.156
4 -0.8000000 -0.2434198 -10.434 -10.434 -10.434 -10.434
3 -0.8500000 -0.3548031 -12.048 -12.048 -12.048 -12.048
2 -0.9000000 -0.5110137 -14.110 -14.110 -14.110 -14.110
1 -0.9500000 -0.7235564 -16.736 -16.736 -16.736 -16.736
0 -1.0000000 -1.0000000 -20.000 -20.000 -20.000 -20.000

Time Splitting Weights for Grid 01: ndtfast = 20 nfast = 29
==================================

Primary Secondary Accumulated to Current Step

1-0.0009651193358779 0.0500000000000000-0.0009651193358779 0.0500000000000000
2-0.0013488780126037 0.0500482559667939-0.0023139973484816 0.1000482559667939
3-0.0011514592651644 0.0501156998674241-0.0034654566136460 0.1501639558342180
4-0.0003735756740661 0.0501732728306823-0.0038390322877122 0.2003372286649003
5 0.0009829200513762 0.0501919516143856-0.0028561122363360 0.2505291802792859
6 0.0029141799764308 0.0501428056118168 0.0000580677400949 0.3006719858911027
7 0.0054132615310267 0.0499970966129953 0.0054713292711215 0.3506690825040980
8 0.0084687837865133 0.0497264335364439 0.0139401130576348 0.4003955160405419
9 0.0120633394191050 0.0493029943471183 0.0260034524767398 0.4496985103876601
10 0.0161716623600090 0.0486998273761630 0.0421751148367488 0.4983983377638231
11 0.0207585511322367 0.0478912442581626 0.0629336659689855 0.5462895820219857
12 0.0257765478740990 0.0468533167015507 0.0887102138430846 0.5931428987235364
13 0.0311633730493853 0.0455644893078458 0.1198735868924699 0.6387073880313822
14 0.0368391158442262 0.0440063206553765 0.1567127027366961 0.6827137086867586
15 0.0427031802506397 0.0421643648631652 0.1994158829873358 0.7248780735499238
16 0.0486309868367616 0.0400292058506332 0.2480468698240974 0.7649072794005570
17 0.0544704302037592 0.0375976565087951 0.3025173000278565 0.8025049359093521
18 0.0600380921294286 0.0348741349986072 0.3625553921572851 0.8373790709079593
19 0.0651152103984763 0.0318722303921357 0.4276706025557614 0.8692513013000950
20 0.0694434033194839 0.0286164698722119 0.4971140058752453 0.8978677711723069
21 0.0727201499285570 0.0251442997062377 0.5698341558038023 0.9230120708785446
22 0.0745940258796570 0.0215082922098099 0.6444281816834592 0.9445203630883545
23 0.0746596950216179 0.0177785909158270 0.7190878767050771 0.9622989540041815
24 0.0724526566618460 0.0140456061647461 0.7915405333669231 0.9763445601689277
25 0.0674437485167025 0.0104229733316538 0.8589842818836255 0.9867675335005816
26 0.0590334053485720 0.0070507859058187 0.9180176872321975 0.9938183194064003
27 0.0465456732896125 0.0040991156383901 0.9645633605218099 0.9979174350447905
28 0.0292219798521905 0.0017718319739095 0.9937853403740003 0.9996892670187000
29 0.0062146596259993 0.0003107329813000 0.9999999999999997 1.0000000000000000

ndtfast, nfast = 20 29 nfast/ndtfast = 1.45000

Centers of gravity and integrals (values must be 1, 1, approx 1/2, 1, 1):

1.000000000000 1.060707743385 0.530353871693 1.000000000000 1.000000000000

Power filter parameters, Fgamma, gamma = 0.28400 0.14200

Metrics information for Grid 01:
===============================

Minimum X-grid spacing, DXmin = 1.01116846E-03 km
Maximum X-grid spacing, DXmax = 1.01116846E-03 km
Minimum Y-grid spacing, DYmin = 9.87495621E-04 km
Maximum Y-grid spacing, DYmax = 9.87495621E-04 km
Minimum Z-grid spacing, DZmin = 5.00691658E-01 m
Maximum Z-grid spacing, DZmax = 3.26443623E+00 m

Minimum barotropic Courant Number = 1.00000000E+20
Maximum barotropic Courant Number = -1.00000000E+20
Maximum Coriolis Courant Number = -1.00000000E+20


NLM: GET_STATE - Read state initial conditions, t = 0 00:00:00
(Grid 01, File: zfirst_init_cco.nc, Rec=0001, Index=1)
- free-surface
(Min = 0.00000000E+00 Max = 0.00000000E+00)
- vertically integrated u-momentum component
(Min = 0.00000000E+00 Max = 0.00000000E+00)
- vertically integrated v-momentum component
(Min = 0.00000000E+00 Max = 0.00000000E+00)
- u-momentum component
(Min = 0.00000000E+00 Max = 0.00000000E+00)
- v-momentum component
(Min = 0.00000000E+00 Max = 0.00000000E+00)
- potential temperature
(Min = 0.00000000E+00 Max = 0.00000000E+00)
- salinity
(Min = 0.00000000E+00 Max = 0.00000000E+00)

REGRID - input gridded data does not contain model grid:

Gridded: LonMin = -13.6075 LonMax = 35.9397
LatMin = 97.6335 LatMax = 146.0208
Model: LonMin = 0.0000 LonMax = 0.0000
LatMin = 0.0000 LatMax = 0.0000

GET_2DFLD - error while reading variable: sustr at TIME index = 1

Elapsed CPU time (seconds):

Node # 0 CPU: 0.069
Total: 0.069

Nonlinear ocean model elapsed time profile, Grid: 01

Allocation and array initialization .............. 0.028 (40.5804 %)
2D/3D coupling, vertical metrics ................. 0.001 ( 1.4495 %)
Equation of state for seawater ................... 0.005 ( 7.2461 %)
Total: 0.034 49.2760

Nonlinear model message Passage profile, Grid: 01

Message Passage: data scattering.................. 0.003 ( 4.3485 %)
Total: 0.003 4.3485

All percentages are with respect to total time = 0.069


ROMS/TOMS - Output NetCDF summary for Grid 01:

ROMS/TOMS - I/O error ............... exit_flag: 4


ERROR: I/O related problem.

jcwarner
Posts: 813
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: sustr and svstr Value has not been read

#4 Post by jcwarner » Sun May 06, 2018 5:16 pm

Gridded: LonMin = -13.6075 LonMax = 35.9397
LatMin = 97.6335 LatMax = 146.0208
Model: LonMin = 0.0000 LonMax = 0.0000
LatMin = 0.0000 LatMax = 0.0000

your forcing file does not have any grid data. each field needs an attribute of lon and lat. see here
viewtopic.php?f=1&t=1348

User avatar
hpd14thu
Posts: 55
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

Re: sustr and svstr Value has not been read

#5 Post by hpd14thu » Sun May 06, 2018 5:23 pm

jcwarner wrote:Gridded: LonMin = -13.6075 LonMax = 35.9397
LatMin = 97.6335 LatMax = 146.0208
Model: LonMin = 0.0000 LonMax = 0.0000
LatMin = 0.0000 LatMax = 0.0000

your forcing file does not have any grid data. each field needs an attribute of lon and lat. see here
viewtopic.php?f=1&t=1348

Thank you for your reply. It is so kind of you!

But I have checked my forcing file , it seems that I have give each fiekd an attribute of x and y.

Here is my forcing.m ,which used to generate netcdf file:

function create_roms_stress(x,y,time,fn,varargin)



nc=netcdf.create(fn,'clobber');

if isempty(nc), return, end



disp(' ## Defining Global Attributes...')

netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'history', ['Created by ' mfilename ' on ' datestr(now)]);

netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'type', 'ROMS FORCING file');



% Dimensions:

disp(' ## Defining Dimensions...')

%dimid = netcdf.defDim(ncid,dimname,dimlen)



[ix iy]=size(x);

t=length(time);

x_dimID = netcdf.defDim(nc,'xrho',ix);

y_dimID = netcdf.defDim(nc,'yrho',iy);

t_dimID = netcdf.defDim(nc,'time',t);

% onedimID = netcdf.defDim(nc,'one',1);



% Variables and attributes:

disp(' ## Defining Variables, and Attributes...')

%varid = netcdf.defVar(ncid,varname,xtype,dimids)

%netcdf.putAtt(ncid,varid,attrname,attrvalue)



tID = netcdf.defVar(nc,'time','double',t_dimID);

netcdf.putAtt(nc,tID,'long_name','forcing time');

netcdf.putAtt(nc,tID,'units','days');

netcdf.putAtt(nc,tID,'field','time, scalar, series');



xID = netcdf.defVar(nc,'x','double',[x_dimID y_dimID]);

netcdf.putAtt(nc,xID,'long_name','x');

netcdf.putAtt(nc,xID,'units','meter');

netcdf.putAtt(nc,xID,'field','xp, scalar, series');



yID = netcdf.defVar(nc,'y','double',[x_dimID y_dimID]);

netcdf.putAtt(nc,yID,'long_name','y');

netcdf.putAtt(nc,yID,'units','meter');

netcdf.putAtt(nc,yID,'field','yp, scalar, series');



if sum(strcmpi(varargin,'sustr'))>0

st_dimID = netcdf.defDim(nc,'sms_time',t);

stID = netcdf.defVar(nc,'sms_time','double',st_dimID);

netcdf.putAtt(nc,stID,'long_name','sms_time');

netcdf.putAtt(nc,stID,'units','days');

netcdf.putAtt(nc,stID,'field','sms_time, scalar, series');



sustrID = netcdf.defVar(nc,'sustr','double',[x_dimID y_dimID st_dimID]);

netcdf.putAtt(nc,sustrID,'long_name','surface u-momentum stress');

netcdf.putAtt(nc,sustrID,'units','Newton meter-2');

netcdf.putAtt(nc,sustrID,'field','surface u-momentum stress, scalar, series');

netcdf.putAtt(nc,sustrID,'coordinates','x y');

netcdf.putAtt(nc,sustrID,'time','sms_time');

end



if sum(strcmpi(varargin,'svstr'))>0

if ~sum(strcmpi(varargin,'sustr'))>0

st_dimID = netcdf.defDim(nc,'sms_time',t);

stID = netcdf.defVar(nc,'sms_time','double',st_dimID);

netcdf.putAtt(nc,stID,'long_name','sms_time');

netcdf.putAtt(nc,stID,'units','days');

netcdf.putAtt(nc,stID,'field','sms_time, scalar, series');

end



svstrID = netcdf.defVar(nc,'svstr','double',[x_dimID y_dimID st_dimID]);

netcdf.putAtt(nc,svstrID,'long_name','surface v-momentum stress');

netcdf.putAtt(nc,svstrID,'units','Newton meter-2');

netcdf.putAtt(nc,svstrID,'field','surface v-momentum stre, scalar, series');

netcdf.putAtt(nc,svstrID,'coordinates','x y');

netcdf.putAtt(nc,svstrID,'time','sms_time');

end

if sum(strcmpi(varargin,'shflux'))>0

shft_dimID = netcdf.defDim(nc,'shf_time',t);

shftID = netcdf.defVar(nc,'shf_time','double',shft_dimID);

netcdf.putAtt(nc,stID,'long_name','surface heat flux time');

netcdf.putAtt(nc,stID,'units','days');

netcdf.putAtt(nc,stID,'field','shf_time, scalar, series');



shfluxID = netcdf.defVar(nc,'shflux','double',[x_dimID y_dimID shft_dimID]);

netcdf.putAtt(nc,shfluxID,'long_name','surface net heat flux');

netcdf.putAtt(nc,shfluxID,'units','Watts meter-2');

netcdf.putAtt(nc,shfluxID,'field','surface heat flux, scalar, series');

netcdf.putAtt(nc,shfluxID,'coordinates','x y');

netcdf.putAtt(nc,shfluxID,'time','shf_time');

end


netcdf.close(nc)

User avatar
kate
Posts: 3702
Joined: Wed Jul 02, 2003 5:29 pm
Location: IMS/UAF, USA

Re: sustr and svstr Value has not been read

#6 Post by kate » Mon May 07, 2018 1:14 pm

Gridded: LonMin = -13.6075 LonMax = 35.9397
LatMin = 97.6335 LatMax = 146.0208
Model: LonMin = 0.0000 LonMax = 0.0000
LatMin = 0.0000 LatMax = 0.0000
Your model grid doesn't appear to have lat,lon values in it. The gridded forcing does have them, though one might question your latitude values. Are you sure you didn't swap lat and lon?

fdaryabor
Posts: 78
Joined: Wed Jan 02, 2008 3:15 pm
Location: University of Copenhagen

Re: sustr and svstr Value has not been read

#7 Post by fdaryabor » Tue May 08, 2018 8:15 am

Dear,
As stated by Katherine and John, such errors :arrow: (GET_2DFLD - error while reading variable: or GET_3DFLD - error while reading variable:) are due to the definition of input variables. To avoid encountering such a problem is essential check consistency of the variables in ".nc" file with the list of variables sorted in ".../trunk/ROMS/External/varinfo.dat", even though although want to have an own script I suggest you that have a look at the Matlab toolbox from the ROMS repository. :arrow: "svn checkout https://www.myroms.org/svn/src/matlab MyDir"

Good luck to you,
Farshid

User avatar
hpd14thu
Posts: 55
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

Re: sustr and svstr Value has not been read

#8 Post by hpd14thu » Thu May 10, 2018 2:25 pm

kate wrote:
Gridded: LonMin = -13.6075 LonMax = 35.9397
LatMin = 97.6335 LatMax = 146.0208
Model: LonMin = 0.0000 LonMax = 0.0000
LatMin = 0.0000 LatMax = 0.0000
Your model grid doesn't appear to have lat,lon values in it. The gridded forcing does have them, though one might question your latitude values. Are you sure you didn't swap lat and lon?

Thanks a lot! I made some changes, and now there is another problem:

NETCDF_INQ_VAR - requested variable: x
not found in input file: /home/hpd14/Documents/COAWST_V3.2/Projects/zfirst/zfirst_str.nc
call from: get_varcoords.F

User avatar
hpd14thu
Posts: 55
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

Re: sustr and svstr Value has not been read

#9 Post by hpd14thu » Thu May 10, 2018 2:34 pm

fdaryabor wrote:Dear,
As stated by Katherine and John, such errors :arrow: (GET_2DFLD - error while reading variable: or GET_3DFLD - error while reading variable:) are due to the definition of input variables. To avoid encountering such a problem is essential check consistency of the variables in ".nc" file with the list of variables sorted in ".../trunk/ROMS/External/varinfo.dat", even though although want to have an own script I suggest you that have a look at the Matlab toolbox from the ROMS repository. :arrow: "svn checkout https://www.myroms.org/svn/src/matlab MyDir"

Good luck to you,
Farshid
Thanks a million, it's really so kind of you!
According to the BUG :GET_2DFLD - error while reading variable: sustr at TIME index = 1 ,
I have checked my sustr value in forcing file carefully, but I didn't find anything abnormal.
I don't know if there is anything wrong with the time value.( I'm not clear about the time value yet)
Here is my forcing file, if possible, could you please see if there is anything wrong in my forcing file? I really thank you for your self-giving help !
Attachments
zfirst_str_20180510.nc
(216.43 KiB) Downloaded 63 times

fdaryabor
Posts: 78
Joined: Wed Jan 02, 2008 3:15 pm
Location: University of Copenhagen

Re: sustr and svstr Value has not been read

#10 Post by fdaryabor » Thu May 10, 2018 7:26 pm

Dear,
Your attached file is completely wrong :shock: and it's not really readable for the ROMS, such attributions, dimensions and time format. I suggest you that follow directory :arrow: ".../trunk/Data/ROMS/CDL" it can help you to find your questions :?: . Good luck to you
Farshid

User avatar
hpd14thu
Posts: 55
Joined: Tue May 01, 2018 3:56 pm
Location: Tsinghua University

Re: sustr and svstr Value has not been read

#11 Post by hpd14thu » Fri May 11, 2018 2:44 am

fdaryabor wrote:Dear,
Your attached file is completely wrong :shock: and it's not really readable for the ROMS, such attributions, dimensions and time format. I suggest you that follow directory :arrow: ".../trunk/Data/ROMS/CDL" it can help you to find your questions :?: . Good luck to you
Farshid
Thanks a lot! I'm a beginner at computer programming. According to your suggestion, I found the frc_uvstress.cdl file in ".../trunk/Data/ROMS/CDL" which you recommend, and I transfered it into netcdf file. Then I use a matlab file(which named str_cdl_nc.m) to write values into the ncfile
.

But when I check the forcing.nc file. The value of sms time is very strange, and the dimension of it is incorrect.( I just want to calculate in 2 days since 0:00:00 0)

So I wonder if there is anything wrong in my matlab file(which used to write value into ncfile) ? Thank you so much!
Attachments
frc_uvstress.nc
(15.15 MiB) Downloaded 58 times
str_cdl_nc.m
(1.64 KiB) Downloaded 66 times

fdaryabor
Posts: 78
Joined: Wed Jan 02, 2008 3:15 pm
Location: University of Copenhagen

Re: sustr and svstr Value has not been read

#12 Post by fdaryabor » Fri May 11, 2018 12:53 pm

Dear,

Alright, use the following linux commands to convert nc2cdl.

:arrow: ncdump -b c myfile.nc > myfile.cdl

by the command "vim" or "gedit" (recommended for you to see as .txt file for edit) open myfile.cdl;

:arrow: gedit myfile.cdl

and also open "frcfile.cdl" from ../trunk/Data/ROMS/CDL;

:arrow: gedit frcfile.cdl

copy and paste "attributes, dimension, variables definition" from "frcfile.cdl" in "myfile.cdl", then convert "myfile.cdl" to ".nc" file as follow;

:arrow: ncgen -b myfile.cdl > myfile.nc

Now you try new ".nc" file and see how is work.

Good luck,

Post Reply