transform [a] data to nc format

226 views
Skip to first unread message

jsmb...@gmail.com

unread,
Jan 7, 2019, 12:10:38 PM1/7/19
to HYCOM.org Forum
Hi Alan,

I need to transform [a] hycom data to nc format to analyze with matlab. 

Please, can you help me with some information, if there are some scripts that do that? and where Ican found these scripts?.

Thanks in advance,
Joel

alan.wa...@hycom.org

unread,
Jan 7, 2019, 1:46:01 PM1/7/19
to HYCOM.org Forum
The programs are typically in hycom/ALL/archive/src.  Note that the main program for archv2ncdf3z is archv2data3z.f (linked against horout_nc.f):

COAPS 109> ll archv*3z.f horout*.f
-rw-r-----. 1 awallcraft awallcraft  71350 Jul 30  2015 archv2data3z.f
-rw-r-----. 1 awallcraft awallcraft  40866 Sep  6  2012 horout.f
-rw-r-----. 1 awallcraft awallcraft 214475 Jul 26  2017 horout_nc.f

There are probably example scripts in any archive subdirectory for a HYCOM region.

I enclose a "3z" script that produces a subregion from a mean archive.  For snapshot archives, remove the keio line.

Alan.
ncdf3z_991_archMN.2014_04_ind.csh

mo so

unread,
Aug 7, 2023, 8:21:48 AM8/7/23
to HYCOM.org Forum, alan.wa...@hycom.org

Dear Alan,

I am trying to convert the model output to nc so that I can plot it with another package. But I was really confused. I tried all methods. I used different scripts to call archv2ncdf3z but I get the following error:

root@mostafa-G41D3C:/home/HYCOM/hycom/PEGh0.02/archive/ncdf_2012# csh 010_ncdf3z_2012.csh
C
setenv X 01.0
setenv R PEGh0.02
setenv EX /home/HYCOM/hycom/PEGh0.02/expt_01.0
source /home/HYCOM/hycom/PEGh0.02/expt_01.0/EXPT.src
setenv OS `uname`
uname
setenv R PEGh0.02
setenv V 2.3.0
setenv T 07
setenv K 41
setenv E 010
setenv X 01.0
setenv P /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/
setenv D /home/HYCOM/hycom/PEGh0.02/expt_01.0/data
setenv S /home/HYCOM/hycom/PEGh0.02/expt_01.0/data
setenv DS /home/HYCOM/hycom/PEGh0.02/datasets
setenv N CORE2_NYF
setenv MAKE_FORCE 0
setenv OMPI_ALLOW_RUN_AS_ROOT=1
setenv OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
setenv ARCHIVE 0
setenv QSUBMIT csh
setenv mnsqa 1
setenv mnsqe 0
setenv statm 0
setenv plots 0
setenv transp 0
setenv data2d 0
setenv netcdf 0
setenv SRC /home/HYCOM/hycom/ALL
setenv BINRUN
switch ( Linux )
setenv Y 2012
setenv IDM `grep idm ${D}/../blkdat.input | awk '{print $1}'`
grep idm /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/../blkdat.input
awk {print $1}
setenv JDM `grep jdm ${D}/../blkdat.input | awk '{print $1}'`
grep jdm /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/../blkdat.input
awk {print $1}
setenv YRFLAG `grep yrflag ${D}/../blkdat.input | awk '{print $1}'`
grep yrflag /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/../blkdat.input
awk {print $1}
if ( 3 == 3 ) then
setenv YY `echo ${Y} | awk '{printf("%03d", $1-1900)}'`
echo 2012
awk {printf("%03d", $1-1900)}
else
setenv P a
setenv J 004
if ( 3 == 3 ) then
if ( 004 == 004 ) setenv YY `echo ${Y} | awk '{printf("%03d", $1-1901)}'`
else
setenv A /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/../../archive
setenv ATMP /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/../../archive/ncdf_2012
if ( ! -d /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/../../archive/ncdf_2012 ) /bin/mkdir -p /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/../../archive/ncdf_2012
cd /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/../../archive/ncdf_2012
touch regional.depth.a regional.depth.b
/bin/rm regional.depth.a regional.depth.b
ln -sf /home/HYCOM/hycom/PEGh0.02/datasets/../topo/depth_PEGh0.02_07.a regional.depth.a
ln -sf /home/HYCOM/hycom/PEGh0.02/datasets/../topo/depth_PEGh0.02_07.b regional.depth.b
touch regional.grid.a regional.grid.b
if ( -z regional.grid.a ) then
/bin/rm regional.grid.a
/bin/ln -s /home/HYCOM/hycom/PEGh0.02/datasets/../topo/regional.grid.a regional.grid.a
endif
if ( -z regional.grid.b ) then
/bin/rm regional.grid.b
/bin/ln -s /home/HYCOM/hycom/PEGh0.02/datasets/../topo/regional.grid.b regional.grid.b
endif
setenv CDF030 /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/tarm_112/010_archm.2012_004_12.nc
/bin/rm /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/tarm_112/010_archm.2012_004_12.nc
/bin/rm: cannot remove '/home/HYCOM/hycom/PEGh0.02/expt_01.0/data/tarm_112/010_archm.2012_004_12_3z.nc': No such file or directory
/home/HYCOM/hycom/ALL/archive/src/archv2ncdf3z

xcspmd: idm,jdm = 1000  355

 input file: /home/HYCOM/hycom/PEGh0.02/expt_01.0/data/tarm_112/010_archm.2012_004_12.a
output type: netCDF
blkini: iexpt  =     0
blkini: yrflag =     3
blkini: idm    =  1000
blkini: jdm    =   355
blkini: kdm    =    41
blkinr: thbase =    34.0000 sig
blkinl: smooth =     F
blkini: iorign =     1
blkini: jorign =     1
blkini: idmp   =     0
blkini: jdmp   =     0

extracting i =    1 ... 1000         j =    1 ...  355

blkini: itype  =     1
blkini: kz     =    33
blkinr: z      =     0.0000 m
blkinr: z      =    10.0000 m
blkinr: z      =    20.0000 m
blkinr: z      =    30.0000 m
blkinr: z      =    50.0000 m
blkinr: z      =    75.0000 m
blkinr: z      =   100.0000 m
blkinr: z      =   125.0000 m
blkinr: z      =   150.0000 m
blkinr: z      =   200.0000 m
blkinr: z      =   250.0000 m
blkinr: z      =   300.0000 m
blkinr: z      =   400.0000 m
blkinr: z      =   500.0000 m
blkinr: z      =   600.0000 m
blkinr: z      =   700.0000 m
blkinr: z      =   800.0000 m
blkinr: z      =   900.0000 m
blkinr: z      =  1000.0000 m
blkinr: z      =  1100.0000 m
blkinr: z      =  1200.0000 m
blkinr: z      =  1300.0000 m
blkinr: z      =  1400.0000 m
blkinr: z      =  1500.0000 m
blkinr: z      =  1750.0000 m
blkinr: z      =  2000.0000 m
blkinr: z      =  2500.0000 m
blkinr: z      =  3000.0000 m
blkinr: z      =  3500.0000 m
blkinr: z      =  4000.0000 m
blkinr: z      =  4500.0000 m
blkinr: z      =  5000.0000 m
blkinr: z      =  5500.0000 m

blkini: botio  =     0
blkini: mltio  =     0
blkinr: tempml =     1.0000 degC
blkinr: densml =     0.0500 kg/m3
blkini: infio  =     0
blkini: wviio  =     0
 warning - wviio no longer used.
blkini: wvlio  =    30
blkini: uvlio  =    30
blkini: vvlio  =    30
blkini: splio  =     0
blkini: temio  =    30
blkini: salio  =    30
blkini: tthio  =    30
blkini: keio   =    30
0.313c CFSR wind, thermal, precip 1-hrly forcing ; LWcorr; WOA13 SSS relax;    
17T Sigma2*; WOA13; KPP; SeaWiFS chl; HYCOM; A=20;Smag=.05;momtyp=2;            
Z(7):1-7,Z(16):8,Z(2):10-16,Z(13):dp00/f/x=36/1.18/262;Z(3):400-600m;          
sigma:84-14m; depth_GOMb0.08_07; HYCOM 2.3.01; Nested in monthly GLBb0.08 53.X;
 iversn =           23
 iexpt  =           10
 yrflag =            3
 idm    =         1000
 jdm    =          355
field       time step   mean day  k  dens        min              max
artype = 2
montg1   =       8640  40545.000  0  0.000  -6.0174189E+00   2.5779257E+00
input  montg1   into montg  
srfhgt   =       8640  40548.000  0  0.000  -6.8497043E+00   1.1436163E+00
input  srfhgt   into srfht  
oneta    =       8640  40546.500  0  0.000   9.7696120E-01   1.0292256E+00
input  oneta    into surflx  
 time3 =    40545.000000000000        40548.000000000000        40546.500000000000    
surflx   =       8640  40546.500  0  0.000   0.0000000E+00   0.0000000E+00
input  surflx   into salflx  
wtrflx   =       8640  40546.500  0  0.000   1.2676506E+30   0.0000000E+00
input  wtrflx   into dpbl    
salflx   =       8640  40546.500  0  0.000   1.2676506E+30   0.0000000E+00
input  salflx   into dpmixl  
bl_dpth  =       8640  40546.500  0  0.000   1.1620463E+04   1.8827520E+05
input  bl_dpth  into tmix    
mix_dpth =       8640  40546.500  0  0.000   1.1620463E+04   1.8827520E+05
input  mix_dpth into smix    
tmix     =       8640  40546.500  0  0.000   9.0530758E+00   2.4939016E+01
input  tmix     into thmix  
smix     =       8640  40546.500  0  0.000   3.5419842E+01   4.0894417E+01
input  smix     into umix    
thmix    =       8640  40546.500  0 34.000  -9.2200441E+00  -4.3006558E+00
input  thmix    into vmix    
umix     =       8640  40546.500  0  0.000  -2.4261980E+00   2.5264771E+00
input  umix     into ubaro  
vmix     =       8640  40546.500  0  0.000  -2.2301686E+00   2.4593999E+00
input  vmix     into vbaro  
kemix    =       8640  40546.500  0 34.000   9.8777498E-08   3.4976270E+00

 error in getdat - layer            1  does not exist (kk=           41 )

Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG
/bin/rm -f regional.depth.a regional.depth.b regional.grid.a regional.grid.b
root@mostafa-G41D3C:/home/HYCOM/hycom/PEGh0.02/archive/ncdf_2012#


I checked the output files and there are no problems (attached) and they are the same as the correct output files. Also, according to the recommendations of the group, I checked the netcdf files and used hycom_2.2.72_ALL, but the error was not resolved. Is it possible to guide me so that I can do the conversion to netcdf? Thank you for your help and reply.

With respect,
Solgi

Unfortunately, the files are not attached. link of my files:

Error_Convert to nc:                   https://drive.google.com/file/d/1ZI--LQJbNCBE7NHVfkPfxdEpKXltDunM/view?usp=drive_link

Alan Wallcraft

unread,
Aug 7, 2023, 8:32:17 AM8/7/23
to HYCOM.org Forum, mo so, alan.wa...@hycom.org
The 3z program is not detecting "oneta".  Are you using the latest HYCOM-tools?  It definitely has logic to detect oneta.

Alan.

mo so

unread,
Aug 8, 2023, 4:47:58 AM8/8/23
to HYCOM.org Forum, Alan Wallcraft

Hi Alan,

Thanks for your reply, I used the latest HYCOM-tools and the problem was solved. Your answers are encouraging. Thank you very much.

Best regards,
Solgi
Reply all
Reply to author
Forward
0 new messages