Changeset 5068 for LMDZ6/trunk/libf


Ignore:
Timestamp:
Jul 18, 2024, 12:14:04 PM (4 months ago)
Author:
abarral
Message:

[to be continued, but should be stable]
Create lmdz_netcdf.F90 as a wrapper around netcdf, to

1) expose netcdf as a pure Fortran module (rather than module + include header)
2) handle NC_DOUBLE in a centralized way

Use said module in dynredem_mod.F90, guide_mod.F90

Location:
LMDZ6/trunk/libf
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/dyn3d/dynredem_mod.F90

    r5060 r5068  
    9494!
    9595!===============================================================================
     96  USE lmdz_netcdf, ONLY: NF90_FORMAT
    9697  IMPLICIT NONE
    9798!===============================================================================
     
    102103  CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: units
    103104!===============================================================================
    104 #ifdef NC_DOUBLE
    105   CALL err(NF90_DEF_VAR(ncid,var,NF90_DOUBLE,did,nvarid),"inq",var)
    106 #else
    107   CALL err(NF90_DEF_VAR(ncid,var,NF90_FLOAT ,did,nvarid),"inq",var)
    108 #endif
     105  CALL err(NF90_DEF_VAR(ncid,var,NF90_FORMAT,did,nvarid),"inq",var)
    109106  IF(title/="")      CALL err(NF90_PUT_ATT(ncid,nvarid,"title",title),var)
    110107  IF(PRESENT(units)) CALL err(NF90_PUT_ATT(ncid,nvarid,"units",units),var)
  • LMDZ6/trunk/libf/dyn3d/guide_mod.F90

    r5067 r5068  
    99!=======================================================================
    1010
    11   USE getparam, only: ini_getparam, fin_getparam, getpar
     11  USE getparam, ONLY: ini_getparam, fin_getparam, getpar
    1212  USE Write_Field
    13   use netcdf, only: nf90_nowrite, nf90_open, nf90_inq_varid, nf90_close, &
    14                     nf90_inq_dimid, nf90_inquire_dimension
    15   use pres2lev_mod, only: pres2lev
     13  USE lmdz_netcdf, ONLY: nf90_nowrite, nf90_open, nf90_inq_varid, nf90_close, &
     14          nf90_inq_dimid, nf90_inquire_dimension, nf_put_var_rd, nf90_float, nf90_def_var, &
     15          nf_create, nf_def_dim, nf_open, nf_unlimited, nf_write, nf_enddef, nf_redef, &
     16          nf_close, nf_inq_varid, nf_put_vara_rd, nf90_get_var, nf90_noerr, nf_clobber, &
     17          nf_64bit_offset, nf_inq_dimid, nf_inq_dimlen
     18  USE pres2lev_mod, ONLY: pres2lev
    1619
    1720  IMPLICIT NONE
     
    7780    INCLUDE "dimensions.h"
    7881    INCLUDE "paramet.h"
    79     INCLUDE "netcdf.inc"
    8082
    8183    INTEGER                :: error,ncidpl,rid,rcod
     
    10891091!=======================================================================
    10901092  SUBROUTINE guide_read(timestep)
    1091 
    1092     use netcdf, only: NF90_GET_VAR, nf90_noerr
    1093 
    10941093    IMPLICIT NONE
    10951094
     
    13891388!=======================================================================
    13901389  SUBROUTINE guide_read2D(timestep)
    1391 
    1392     use netcdf, only: nf90_get_var, nf90_noerr
    1393 
    13941390    IMPLICIT NONE
    13951391
     
    16531649    USE comconst_mod, ONLY: pi
    16541650    USE comvert_mod, ONLY: presnivs
    1655     use netcdf95, only: nf95_def_var, nf95_put_var
    1656     use netcdf, only: nf90_float, nf90_def_var
    1657    
     1651    USE netcdf95, ONLY: nf95_def_var, nf95_put_var
     1652
    16581653    IMPLICIT NONE
    16591654
    16601655    INCLUDE "dimensions.h"
    16611656    INCLUDE "paramet.h"
    1662     INCLUDE "netcdf.inc"
    16631657    INCLUDE "comgeom2.h"
    16641658   
     
    17131707
    17141708! Enregistrement des variables dimensions
    1715 #ifdef NC_DOUBLE
    1716         ierr = NF_PUT_VAR_DOUBLE(nid,vid_lonu,rlonu*180./pi)
    1717         ierr = NF_PUT_VAR_DOUBLE(nid,vid_lonv,rlonv*180./pi)
    1718         ierr = NF_PUT_VAR_DOUBLE(nid,vid_latu,rlatu*180./pi)
    1719         ierr = NF_PUT_VAR_DOUBLE(nid,vid_latv,rlatv*180./pi)
    1720         ierr = NF_PUT_VAR_DOUBLE(nid,vid_lev,presnivs)
    1721         ierr = NF_PUT_VAR_DOUBLE(nid,vid_cu,cu)
    1722         ierr = NF_PUT_VAR_DOUBLE(nid,vid_cv,cv)
    1723         ierr = NF_PUT_VAR_DOUBLE(nid,vid_au,alpha_u)
    1724         ierr = NF_PUT_VAR_DOUBLE(nid,vid_av,alpha_v)
    1725 #else
    1726         ierr = NF_PUT_VAR_REAL(nid,vid_lonu,rlonu*180./pi)
    1727         ierr = NF_PUT_VAR_REAL(nid,vid_lonv,rlonv*180./pi)
    1728         ierr = NF_PUT_VAR_REAL(nid,vid_latu,rlatu*180./pi)
    1729         ierr = NF_PUT_VAR_REAL(nid,vid_latv,rlatv*180./pi)
    1730         ierr = NF_PUT_VAR_REAL(nid,vid_lev,presnivs)
    1731         ierr = NF_PUT_VAR_REAL(nid,vid_cu,cu)
    1732         ierr = NF_PUT_VAR_REAL(nid,vid_cv,cv)
    1733         ierr = NF_PUT_VAR_REAL(nid,vid_au,alpha_u)
    1734         ierr = NF_PUT_VAR_REAL(nid,vid_av,alpha_v)
    1735 #endif
     1709        ierr = nf_put_var_rd(nid,vid_lonu,rlonu*180./pi)
     1710        ierr = nf_put_var_rd(nid,vid_lonv,rlonv*180./pi)
     1711        ierr = nf_put_var_rd(nid,vid_latu,rlatu*180./pi)
     1712        ierr = nf_put_var_rd(nid,vid_latv,rlatv*180./pi)
     1713        ierr = nf_put_var_rd(nid,vid_lev,presnivs)
     1714        ierr = nf_put_var_rd(nid,vid_cu,cu)
     1715        ierr = nf_put_var_rd(nid,vid_cv,cv)
     1716        ierr = nf_put_var_rd(nid,vid_au,alpha_u)
     1717        ierr = nf_put_var_rd(nid,vid_av,alpha_v)
    17361718        call nf95_put_var(nid, varid_alpha_t, alpha_t)
    17371719        call nf95_put_var(nid, varid_alpha_q, alpha_q)
     
    18071789    END SELECT
    18081790
    1809 
    1810 #ifdef NC_DOUBLE
    1811     ierr = NF_PUT_VARA_DOUBLE(nid,varid,start,count,field2)
    1812 #else
    1813     ierr = NF_PUT_VARA_REAL(nid,varid,start,count,field2)
    1814 #endif
    1815 
     1791    ierr = nf_put_vara_rd(nid,varid,start,count,field2)
    18161792    ierr = NF_CLOSE(nid)
    18171793
Note: See TracChangeset for help on using the changeset viewer.