1 | ! --------------------------------------------- |
---|
2 | ! This module serves as a wrapper around netcdf. |
---|
3 | ! It serves two primary functions: |
---|
4 | ! 1) Turn netcdf into a "real" fortran module, without the INCLUDE call |
---|
5 | ! 2) Handle the NC_DOUBLE CPP key. Ideally, this key should ONLY appear here (WIP). TODO |
---|
6 | ! Ideally, the "real" netcdf module/headers should ONLY be called here. (WIP) TODO |
---|
7 | ! --------------------------------------------- |
---|
8 | ! TODO check that none of the wrapped functions remain elsewhere |
---|
9 | ! TODO check all uses of `use netcdf` + netcdf.inc |
---|
10 | |
---|
11 | MODULE lmdz_netcdf |
---|
12 | USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : REAL64, REAL32 |
---|
13 | USE netcdf |
---|
14 | IMPLICIT NONE |
---|
15 | ! Note: as we want to expose netcdf through this module, we don't make all PRIVATE by default as usual |
---|
16 | ! Instead, explicitely make PRIVATE the relevant items. |
---|
17 | PRIVATE CPP_NC_DOUBLE |
---|
18 | |
---|
19 | INCLUDE 'netcdf.inc' |
---|
20 | |
---|
21 | #ifdef NC_DOUBLE |
---|
22 | LOGICAL, PARAMETER :: CPP_NC_DOUBLE = .TRUE. ! Define a variable to reduce use of preprocessor ahead |
---|
23 | INTEGER, PARAMETER :: NF90_FORMAT = NF90_DOUBLE |
---|
24 | INTEGER, PARAMETER :: REAL_FORMAT = REAL64 |
---|
25 | #else |
---|
26 | LOGICAL, PARAMETER :: CPP_NC_DOUBLE = .FALSE. |
---|
27 | INTEGER, PARAMETER :: NF90_FORMAT = NF90_FLOAT |
---|
28 | INTEGER, PARAMETER :: REAL_FORMAT = REAL32 |
---|
29 | #endif |
---|
30 | CONTAINS |
---|
31 | |
---|
32 | END MODULE lmdz_netcdf |
---|