Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Méso-NH code
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Méso-NH
Méso-NH code
Commits
2860ba37
Commit
2860ba37
authored
9 years ago
by
WAUTELET Philippe
Browse files
Options
Downloads
Patches
Plain Diff
lfi2cdf: new option: '-r or --reduce' to reduce precision of float (double -> real)
parent
826170bd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tools/lfi2cdf/src/lfi2cdf.f90
+5
-4
5 additions, 4 deletions
tools/lfi2cdf/src/lfi2cdf.f90
tools/lfi2cdf/src/mode_util.f90
+11
-3
11 additions, 3 deletions
tools/lfi2cdf/src/mode_util.f90
tools/lfi2cdf/src/newmain.c
+10
-4
10 additions, 4 deletions
tools/lfi2cdf/src/newmain.c
with
26 additions
and
11 deletions
tools/lfi2cdf/src/lfi2cdf.f90
+
5
−
4
View file @
2860ba37
subroutine
LFI2CDFMAIN
(
hinfile
,
iiflen
,
ooutname
,
houtfile
,
ioflen
,
hvarlist
,
ivlen
,
olfi2cdf
,
olfilist
,
ohdf5
,
omerge
,
nb_levels
)
subroutine
LFI2CDFMAIN
(
hinfile
,
iiflen
,
ooutname
,
houtfile
,
ioflen
,
hvarlist
,
ivlen
,
olfi2cdf
,
olfilist
,
ohdf5
,
omerge
,
nb_levels
,&
oreduceprecision
)
USE
mode_util
USE
mode_util
IMPLICIT
NONE
IMPLICIT
NONE
INTEGER
::
iiflen
,
ioflen
,
ivlen
INTEGER
::
iiflen
,
ioflen
,
ivlen
...
@@ -6,7 +7,7 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o
...
@@ -6,7 +7,7 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o
CHARACTER
(
LEN
=
iiflen
)
::
hinfile
CHARACTER
(
LEN
=
iiflen
)
::
hinfile
CHARACTER
(
LEN
=
ioflen
)
::
houtfile
CHARACTER
(
LEN
=
ioflen
)
::
houtfile
CHARACTER
(
LEN
=
ivlen
)
::
hvarlist
CHARACTER
(
LEN
=
ivlen
)
::
hvarlist
LOGICAL
::
ooutname
,
olfi2cdf
,
olfilist
,
ohdf5
,
omerge
LOGICAL
::
ooutname
,
olfi2cdf
,
olfilist
,
ohdf5
,
omerge
,
oreduceprecision
INTEGER
::
ibuflen
INTEGER
::
ibuflen
INTEGER
::
ilu
INTEGER
::
ilu
...
@@ -43,7 +44,7 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o
...
@@ -43,7 +44,7 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o
!Standard treatment (one LFI file only)
!Standard treatment (one LFI file only)
IF
(
.not.
omerge
)
THEN
IF
(
.not.
omerge
)
THEN
CALL
parse_lfi
(
ilu
,
hvarlist
,
inaf
,
tzreclist
,
ibuflen
)
CALL
parse_lfi
(
ilu
,
hvarlist
,
inaf
,
tzreclist
,
ibuflen
)
CALL
def_ncdf
(
tzreclist
,
inaf
,
icdf_id
,
omerge
)
CALL
def_ncdf
(
tzreclist
,
inaf
,
oreduceprecision
,
icdf_id
,
omerge
)
CALL
fill_ncdf
(
ilu
,
icdf_id
,
tzreclist
,
inaf
,
ibuflen
)
CALL
fill_ncdf
(
ilu
,
icdf_id
,
tzreclist
,
inaf
,
ibuflen
)
ELSE
ELSE
!Treat several LFI files and merge into 1 NC file
!Treat several LFI files and merge into 1 NC file
...
@@ -56,7 +57,7 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o
...
@@ -56,7 +57,7 @@ subroutine LFI2CDFMAIN(hinfile,iiflen,ooutname,houtfile,ioflen,hvarlist,ivlen,o
!Read 1st LFI file
!Read 1st LFI file
CALL
parse_lfi
(
ilu
,
hvarlist
,
inaf
,
tzreclist
,
ibuflen
,
current_level
)
CALL
parse_lfi
(
ilu
,
hvarlist
,
inaf
,
tzreclist
,
ibuflen
,
current_level
)
CALL
def_ncdf
(
tzreclist
,
inaf
,
icdf_id
,
omerge
)
CALL
def_ncdf
(
tzreclist
,
inaf
,
oreduceprecision
,
icdf_id
,
omerge
)
DO
current_level
=
first_level
,
last_level
DO
current_level
=
first_level
,
last_level
print
*
,
'Treating level '
,
current_level
print
*
,
'Treating level '
,
current_level
...
...
This diff is collapsed.
Click to expand it.
tools/lfi2cdf/src/mode_util.f90
+
11
−
3
View file @
2860ba37
...
@@ -274,9 +274,10 @@ CONTAINS
...
@@ -274,9 +274,10 @@ CONTAINS
END
IF
END
IF
END
SUBROUTINE
HANDLE_ERR
END
SUBROUTINE
HANDLE_ERR
SUBROUTINE
def_ncdf
(
tpreclist
,
knaf
,
kcdf_id
,
omerge
)
SUBROUTINE
def_ncdf
(
tpreclist
,
knaf
,
oreduceprecision
,
kcdf_id
,
omerge
)
TYPE
(
workfield
),
DIMENSION
(:),
INTENT
(
INOUT
)
::
tpreclist
TYPE
(
workfield
),
DIMENSION
(:),
INTENT
(
INOUT
)
::
tpreclist
INTEGER
,
INTENT
(
IN
)
::
knaf
INTEGER
,
INTENT
(
IN
)
::
knaf
LOGICAL
,
INTENT
(
IN
)
::
oreduceprecision
INTEGER
,
INTENT
(
OUT
)::
kcdf_id
INTEGER
,
INTENT
(
OUT
)::
kcdf_id
LOGICAL
,
INTENT
(
IN
)
::
omerge
LOGICAL
,
INTENT
(
IN
)
::
omerge
...
@@ -284,10 +285,17 @@ CONTAINS
...
@@ -284,10 +285,17 @@ CONTAINS
INTEGER
::
ji
INTEGER
::
ji
TYPE
(
dimCDF
),
POINTER
::
tzdim
TYPE
(
dimCDF
),
POINTER
::
tzdim
INTEGER
::
invdims
INTEGER
::
invdims
INTEGER
::
type_float
INTEGER
,
DIMENSION
(
10
)
::
ivdims
INTEGER
,
DIMENSION
(
10
)
::
ivdims
CHARACTER
(
LEN
=
20
)
::
ycdfvar
CHARACTER
(
LEN
=
20
)
::
ycdfvar
IF
(
oreduceprecision
)
THEN
type_float
=
NF90_REAL
ELSE
type_float
=
NF90_DOUBLE
END
IF
! global attributes
! global attributes
status
=
NF90_PUT_ATT
(
kcdf_id
,
NF90_GLOBAL
,
'Title'
,
VERSION_ID
)
status
=
NF90_PUT_ATT
(
kcdf_id
,
NF90_GLOBAL
,
'Title'
,
VERSION_ID
)
IF
(
status
/
=
NF90_NOERR
)
CALL
HANDLE_ERR
(
status
,
__
LINE__
)
IF
(
status
/
=
NF90_NOERR
)
CALL
HANDLE_ERR
(
status
,
__
LINE__
)
...
@@ -360,7 +368,7 @@ CONTAINS
...
@@ -360,7 +368,7 @@ CONTAINS
CASE
(
FLOAT
)
CASE
(
FLOAT
)
! PRINT *,'FLOAT : ',tpreclist(ji)%name
! PRINT *,'FLOAT : ',tpreclist(ji)%name
status
=
NF90_DEF_VAR
(
kcdf_id
,
ycdfvar
,
NF90_DOUBLE
,&
status
=
NF90_DEF_VAR
(
kcdf_id
,
ycdfvar
,
type_float
,&
ivdims
(:
invdims
),
tpreclist
(
ji
)
%
id
)
ivdims
(:
invdims
),
tpreclist
(
ji
)
%
id
)
IF
(
status
/
=
NF90_NOERR
)
CALL
HANDLE_ERR
(
status
,
__
LINE__
)
IF
(
status
/
=
NF90_NOERR
)
CALL
HANDLE_ERR
(
status
,
__
LINE__
)
...
@@ -368,7 +376,7 @@ CONTAINS
...
@@ -368,7 +376,7 @@ CONTAINS
CASE
default
CASE
default
PRINT
*
,
'ATTENTION : '
,
TRIM
(
tpreclist
(
ji
)
%
name
),
' est de&
PRINT
*
,
'ATTENTION : '
,
TRIM
(
tpreclist
(
ji
)
%
name
),
' est de&
& TYPE inconnu --> force a REAL'
& TYPE inconnu --> force a REAL'
status
=
NF90_DEF_VAR
(
kcdf_id
,
ycdfvar
,
NF90_DOUBLE
,&
status
=
NF90_DEF_VAR
(
kcdf_id
,
ycdfvar
,
type_float
,&
ivdims
(:
invdims
),
tpreclist
(
ji
)
%
id
)
ivdims
(:
invdims
),
tpreclist
(
ji
)
%
id
)
IF
(
status
/
=
NF90_NOERR
)
CALL
HANDLE_ERR
(
status
,
__
LINE__
)
IF
(
status
/
=
NF90_NOERR
)
CALL
HANDLE_ERR
(
status
,
__
LINE__
)
...
...
This diff is collapsed.
Click to expand it.
tools/lfi2cdf/src/newmain.c
+
10
−
4
View file @
2860ba37
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
#define BUFSIZE 4096
#define BUFSIZE 4096
extern
lfi2cdfmain_
(
char
*
,
int
*
,
int
*
,
char
*
,
int
*
,
char
*
,
int
*
,
int
*
,
int
*
,
int
*
,
int
*
,
int
*
);
extern
lfi2cdfmain_
(
char
*
,
int
*
,
int
*
,
char
*
,
int
*
,
char
*
,
int
*
,
int
*
,
int
*
,
int
*
,
int
*
,
int
*
,
int
*
);
char
*
cleancomma
(
char
*
varlist
)
char
*
cleancomma
(
char
*
varlist
)
{
{
...
@@ -31,6 +31,7 @@ int main(int argc, char **argv)
...
@@ -31,6 +31,7 @@ int main(int argc, char **argv)
int
l2c_flag
;
int
l2c_flag
;
int
hdf5_flag
;
int
hdf5_flag
;
int
merge_flag
,
nb_levels
;
int
merge_flag
,
nb_levels
;
int
reduceprecision_flag
;
int
outname_flag
;
int
outname_flag
;
char
*
cmd
,
*
infile
;
char
*
cmd
,
*
infile
;
int
c
;
int
c
;
...
@@ -51,6 +52,7 @@ int main(int argc, char **argv)
...
@@ -51,6 +52,7 @@ int main(int argc, char **argv)
list_flag
=
0
;
list_flag
=
0
;
hdf5_flag
=
0
;
hdf5_flag
=
0
;
reduceprecision_flag
=
0
;
p
=
buff
;
p
=
buff
;
*
p
=
'\0'
;
*
p
=
'\0'
;
...
@@ -66,11 +68,12 @@ int main(int argc, char **argv)
...
@@ -66,11 +68,12 @@ int main(int argc, char **argv)
{
"list"
,
no_argument
,
0
,
'l'
},
{
"list"
,
no_argument
,
0
,
'l'
},
{
"merge"
,
required_argument
,
0
,
'm'
},
{
"merge"
,
required_argument
,
0
,
'm'
},
{
"output"
,
required_argument
,
0
,
'o'
},
{
"output"
,
required_argument
,
0
,
'o'
},
{
"reduce-precision"
,
no_argument
,
0
,
'r'
},
{
"var"
,
required_argument
,
0
,
'v'
},
{
"var"
,
required_argument
,
0
,
'v'
},
{
0
,
0
,
0
,
0
}
{
0
,
0
,
0
,
0
}
};
};
c
=
getopt_long
(
argc
,
argv
,
"4lm:o:v:"
,
c
=
getopt_long
(
argc
,
argv
,
"4lm:o:
r
v:"
,
long_options
,
&
option_index
);
long_options
,
&
option_index
);
if
(
c
==
-
1
)
if
(
c
==
-
1
)
break
;
break
;
...
@@ -97,6 +100,9 @@ int main(int argc, char **argv)
...
@@ -97,6 +100,9 @@ int main(int argc, char **argv)
outfile
=
optarg
;
outfile
=
optarg
;
olen
=
strlen
(
outfile
);
olen
=
strlen
(
outfile
);
break
;
break
;
case
'r'
:
reduceprecision_flag
=
1
;
break
;
case
'v'
:
case
'v'
:
if
(
l2c_flag
)
{
if
(
l2c_flag
)
{
lenopt
=
strlen
(
optarg
);
lenopt
=
strlen
(
optarg
);
...
@@ -118,7 +124,7 @@ int main(int argc, char **argv)
...
@@ -118,7 +124,7 @@ int main(int argc, char **argv)
}
}
if
(
optind
==
argc
)
{
if
(
optind
==
argc
)
{
printf
(
"usage : lfi2cdf [--cdf4 -4] [-l] [-v --var var1[,...]] [-m --merge number_of_z_levels] [-o --output output-file.nc] input-file.lfi
\n
"
);
printf
(
"usage : lfi2cdf [--cdf4 -4] [-l] [-v --var var1[,...]]
[-r --reduce-precision]
[-m --merge number_of_z_levels] [-o --output output-file.nc] input-file.lfi
\n
"
);
printf
(
" cdf2lfi [-o --output output-file.lfi] input-file.nc
\n
"
);
printf
(
" cdf2lfi [-o --output output-file.lfi] input-file.nc
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -156,7 +162,7 @@ int main(int argc, char **argv)
...
@@ -156,7 +162,7 @@ int main(int argc, char **argv)
*/
*/
lfi2cdfmain_
(
infile
,
&
ilen
,
&
outname_flag
,
outfile
,
&
olen
,
varlist
,
&
varlistlen
,
&
l2c_flag
,
&
list_flag
,
&
hdf5_flag
,
&
merge_flag
,
lfi2cdfmain_
(
infile
,
&
ilen
,
&
outname_flag
,
outfile
,
&
olen
,
varlist
,
&
varlistlen
,
&
l2c_flag
,
&
list_flag
,
&
hdf5_flag
,
&
merge_flag
,
&
nb_levels
);
&
nb_levels
,
&
reduceprecision_flag
);
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment