# include "odm.h"
inline void Usage ( const MString & arg0 )
{
message ( arg0 + " (<key>=<value>...) " ) ;
message ( " Keys are: " ) ;
message ( " action. What the program should do. May be: info, tsc, uv, genintfile. Default: info. " ) ;
message ( " Keys for action=info. Print some information about dataset. " ) ;
message ( " source. Required. May be: NEMO, HYCOM, AVISO, AVISOLOCAL, BINFILE " ) ;
message ( " Keys for source=NEMO " ) ;
message ( " dataset. Can be DT, NRT or NRT6. Default: DT " ) ;
message ( " Keys for source=HYCOM " ) ;
message ( " dataset. Can be Forecast, Hindcast or Reanalysis. Default: Forecast " ) ;
message ( " Keys for source=AVISO " ) ;
message ( " dataset. Can be DT, NRT, EckmanDT or EckmanNRT. Default: DT " ) ;
message ( " Keys for action=tsc. Get temperature, salinity, chlorofill from dataset. " ) ;
message ( " source. Required. May be: NEMO, HYCOM, AVISO, AVISOLOCAL, BINFILE " ) ;
message ( " var. Required. May be: U, U2, u, v, temp, ptemp, pdens, sal, chl, mld, ssh or w. " ) ;
message ( " time. Time moment or regular expression. If present, timeb and timee must be absent " ) ;
message ( " timeb, timee. Time interval. If present, time must be absent " ) ;
message ( " lonb, lone, latb, late. Required. Region of interest " ) ;
message ( " out. Output file. Default: out.bin " ) ;
message ( " Keys for source=NEMO " ) ;
message ( " dataset. Can be DT, NRT or NRT6. Default: DT " ) ;
message ( " layer and/or depth. Layer or depth of NEMO dataset. If depth is specified, layer is ignored. Both ignored, if var=mld or var=ssh. Default: layer=0 " ) ;
message ( " Keys for source=HYCOM " ) ;
message ( " dataset. Can be Forecast, Hindcast or Reanalysis. Default: Forecast " ) ;
message ( " layer and/or depth. Layer or depth of HYCOM dataset. If depth is specified, layer is ignored. Both ignored, if var=mld or var=ssh. Default: layer=0 " ) ;
message ( " Keys for source=AVISO " ) ;
message ( " dataset. Can be DT, NRT, EckmanDT or EckmanNRT. Default: DT " ) ;
message ( " layer and/or depth. Layer or depth of AVISO dataset. If depth is specified, layer is ignored. Both ignored for datasets DT and NRT. Default: layer=0 " ) ;
message ( " Keys for source=BINFILE " ) ;
message ( " dataset. Path or DataID of interpolation file " ) ;
message ( " Keys for action=uv. Get velocity field and its derivatives. " ) ;
message ( " source. Required. May be: NEMO, HYCOM, AVISO, AVISOLOCAL, BINFILE " ) ;
message ( " time. Time moment or regular expression. If present, timeb and timee must be absent " ) ;
message ( " timeb, timee. Time interval. If present, time must be absent " ) ;
message ( " out. Output file for components of velocity field, divergency, rotor and Okubo-Weiss parameter. If absent, this data not calculated. " ) ;
message ( " velout. Output file for sparse velocity field. If present, parameters shiftx, shifty, skipx, skipy controls the sparsing. " ) ;
message ( " shiftx, shifty. Shift of the sparsed grid. Used only if velout parameter is present. Default: 0 " ) ;
message ( " skipx, skipy. How many poinst skipped in the sparsed grid. Used only if velout parameter is present. Default: 1, output each point " ) ;
message ( " stpout. Output file for stationary points. If absent, this data not calculated. " ) ;
message ( " Keys for specific sources see in the section action=tsc. " ) ;
message ( " Keys for action=genintfile. Create file with velocity field for interpolation. " ) ;
message ( " source. Required. May be: NEMO, HYCOM, AVISO, AVISOLOCAL " ) ;
message ( " time. Time moment or regular expression. If present, timeb and timee must be absent " ) ;
message ( " timeb, timee. Time interval. If present, time must be absent " ) ;
message ( " out. Output file, required. " ) ;
message ( " Keys for specific sources see in the section action=tsc. " ) ;
}
int main ( int argc , char * * argv )
{
if ( argc = = 1 )
{
Usage ( argv [ 0 ] ) ;
return 2 ;
}
auto args = ParseArgs ( argc , argv ) ;
MString action = args . contains ( " action " ) ? args [ " action " ] : " info " ;
Data data ;
{
auto ret = data . Init ( args ) ;
if ( ret . Exist ( ) )
{
errmessage ( ret ) ;
return 1 ;
}
}
Action act ;
{
auto ret = act . Init ( args ) ;
if ( ret . Exist ( ) )
{
errmessage ( ret ) ;
return 1 ;
}
}
auto ret = std : : visit (
[ & act = std : : as_const ( act ) , & args = std : : as_const ( args ) ] ( auto & arg )
{
using DT = std : : decay_t < decltype ( arg ) > ;
return std : : visit (
[ & data = arg , & args = std : : as_const ( args ) ] ( const auto & arg )
{
using AT = std : : decay_t < decltype ( arg ) > ;
if constexpr ( IsActionSupported < DT , AT : : action > )
return DoAction < AT : : action > ( args , data ) ;
else
return MString ( " Unsupported combination of action and source " ) ;
} ,
act ) ;
} ,
data ) ;
if ( ret . Exist ( ) )
{
errmessage ( ret ) ;
return 1 ;
}
return 0 ;
}