[cdftools] 204/228: JMM : add lon, lat variable in outputfile when using cdf2levitusgrid2d ( includes a modification in cdfio )

Alastair McKinstry mckinstry at moszumanska.debian.org
Fri Jun 12 08:21:50 UTC 2015


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch master
in repository cdftools.

commit 5d32d057a7269006130fb33f5cca27e73d87d9fa
Author: molines <molines at 1055176f-818a-41d9-83e1-73fbe5b947c5>
Date:   Wed Apr 17 16:27:00 2013 +0000

    JMM : add lon, lat variable in outputfile when using cdf2levitusgrid2d ( includes a modification in cdfio )
    
    
    git-svn-id: http://servforge.legi.grenoble-inp.fr/svn/CDFTOOLS/trunk@652 1055176f-818a-41d9-83e1-73fbe5b947c5
---
 cdf2levitusgrid2d.f90 |  4 +++-
 cdfio.f90             | 27 +++++++++++++++++++++------
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/cdf2levitusgrid2d.f90 b/cdf2levitusgrid2d.f90
index c489e56..dfbd269 100644
--- a/cdf2levitusgrid2d.f90
+++ b/cdf2levitusgrid2d.f90
@@ -188,7 +188,7 @@ PROGRAM cdf2levitusgrid2d
    tmasklev(:,:) = getvar(cf_levitus_mask, 'mask',     1, npilev, npjlev)
 
    ! create output fileset
-   ncout = create      (cf_out, cf_levitus_mask, npilev, npjlev, 0   )
+   ncout = create      (cf_out, cf_levitus_mask, npilev, npjlev, 0 ,cdlonvar='lon', cdlatvar='lat'  )
    ierr  = createvar   (ncout ,  stypvarout, 1,      ipkout,    id_varout    )
    ierr  = putheadervar(ncout ,  'dummy', npilev, npjlev, 0 , pnavlon=rlonlev, pnavlat=rlatlev )
 
@@ -196,6 +196,8 @@ PROGRAM cdf2levitusgrid2d
    ierr = putvar1d(ncout, tim,       npt, 'T')
    ierr = gettimeatt(cf_in, cn_vtimec, ctcalendar, cttitle, ctlong_name, ctaxis, ctunits, cttime_origin )
    ierr = puttimeatt(ncout, cn_vtimec, ctcalendar, cttitle, ctlong_name, ctaxis, ctunits, cttime_origin )
+   ierr = putvar1d( ncout, rlonlev(:,1), npilev, 'X')
+   ierr = putvar1d( ncout, rlatlev(1,:), npjlev, 'Y')
 
    zbt(:,:) = e1t(:,:) * e2t(:,:)    ! for surface weighting
 
diff --git a/cdfio.f90 b/cdfio.f90
index 9aa15c0..8d0483b 100644
--- a/cdfio.f90
+++ b/cdfio.f90
@@ -63,6 +63,7 @@
 
   PRIVATE 
   INTEGER(KIND=4) :: nid_x, nid_y, nid_z, nid_t, nid_lat, nid_lon, nid_dep, nid_tim
+  INTEGER(KIND=4) :: nid_lon1d, nid_lat1d
   LOGICAL         :: l_mbathy=.false.
   INTEGER(KIND=4), DIMENSION(:,:), ALLOCATABLE :: mbathy         !: for reading e3._ps in nemo3.x
   REAL(KIND=4),    DIMENSION(:,:), ALLOCATABLE :: e3t_ps, e3w_ps !: for reading e3._ps in nemo3.x
@@ -200,7 +201,8 @@ CONTAINS
   END FUNCTION copyatt
 
 
-  INTEGER(KIND=4) FUNCTION create( cdfile, cdfilref ,kx,ky,kz ,cdep, cdepvar, ld_xycoo)
+  INTEGER(KIND=4) FUNCTION create( cdfile, cdfilref ,kx,ky,kz ,cdep, cdepvar, &
+       &                           cdlonvar, cdlatvar,  ld_xycoo)
     !!---------------------------------------------------------------------
     !!                  ***  FUNCTION create  ***
     !!
@@ -212,14 +214,16 @@ CONTAINS
     !!----------------------------------------------------------------------
     CHARACTER(LEN=*),           INTENT(in) :: cdfile, cdfilref ! input file and reference file
     INTEGER(KIND=4),            INTENT(in) :: kx, ky, kz       ! dimension of the variable
-    CHARACTER(LEN=*), OPTIONAL, INTENT(in) :: cdep    ! name of vertical dim name if not standard
-    CHARACTER(LEN=*), OPTIONAL, INTENT(in) :: cdepvar ! name of vertical var name if it differs
-                                                      ! from vertical dimension name
+    CHARACTER(LEN=*), OPTIONAL, INTENT(in) :: cdep     ! name of vertical dim name if not standard
+    CHARACTER(LEN=*), OPTIONAL, INTENT(in) :: cdepvar  ! name of vertical var name if it differs
+                                                       ! from vertical dimension name
+    CHARACTER(LEN=*), OPTIONAL, INTENT(in) :: cdlonvar ! name of 1D longitude
+    CHARACTER(LEN=*), OPTIONAL, INTENT(in) :: cdlatvar ! name of 1D latitude
     LOGICAL,          OPTIONAL, INTENT(in) :: ld_xycoo ! if false then DO NOT read nav_lat nav_lat from input file
 
     INTEGER(KIND=4)               :: istatus, icout, incid, idum
     INTEGER(KIND=4) ,DIMENSION(4) :: invdim
-    CHARACTER(LEN=256)            :: cldep, cldepref, cldepvar
+    CHARACTER(LEN=256)            :: cldep, cldepref, cldepvar, clonvar, clatvar
     LOGICAL                       :: ll_xycoo
     !!----------------------------------------------------------------------
     istatus = NF90_CREATE(cdfile,cmode=or(NF90_CLOBBER,NF90_64BIT_OFFSET), ncid=icout)
@@ -267,6 +271,12 @@ CONTAINS
        istatus = NF90_DEF_VAR(icout,cn_vlat2d,NF90_FLOAT,(/nid_x, nid_y/), nid_lat)
        istatus = copyatt(cn_vlat2d, nid_lat,incid,icout)
     ENDIF
+    IF ( PRESENT(cdlonvar) ) THEN
+       istatus = NF90_DEF_VAR(icout,cdlonvar,NF90_FLOAT,(/nid_x/), nid_lon1d)
+    ENDIF
+    IF ( PRESENT(cdlatvar) ) THEN
+       istatus = NF90_DEF_VAR(icout,cdlatvar,NF90_FLOAT,(/nid_y/), nid_lat1d)
+    ENDIF
     IF ( kz /= 0 ) THEN
        istatus = NF90_DEF_VAR(icout,TRIM(cldepvar),NF90_FLOAT,(/nid_z/), nid_dep)
        ! JMM bug fix : if cdep present, then chose attribute from cldepref
@@ -2069,12 +2079,13 @@ CONTAINS
     !!               kid, into file id kout 
     !!
     !! ** Method  : cdtype is either T (time_counter) or D (depth.)
+    !!                         LON (1D longitude) or LAT (1D latitude)
     !!
     !!----------------------------------------------------------------------
     INTEGER(KIND=4),            INTENT(in) :: kout   ! ncid of output file
     REAL(KIND=4), DIMENSION(kk),INTENT(in) :: ptab   ! 1D array to write in file
     INTEGER(KIND=4),            INTENT(in) :: kk     ! number of elements in ptab
-    CHARACTER(LEN=1),           INTENT(in) :: cdtype ! either T or D
+    CHARACTER(LEN=1),           INTENT(in) :: cdtype ! either T or D LON or LAT
 
     INTEGER(KIND=4)               :: istatus, iid
     INTEGER(KIND=4), DIMENSION(1) :: istart, icount
@@ -2084,6 +2095,10 @@ CONTAINS
        iid = nid_tim
     CASE ('D', 'd' )
        iid = nid_dep
+    CASE ('X', 'x' )
+       iid = nid_lon1d
+    CASE ('Y', 'y' )
+       iid = nid_lat1d
     END SELECT
 
     istart(:) = 1

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cdftools.git



More information about the debian-science-commits mailing list