【问题标题】:No error, but some functions of a library don't make their work没有错误,但是库的某些功能无法正常工作
【发布时间】:2013-11-19 12:10:26
【问题描述】:

我正在使用 cdi(气候数据接口,https://code.zmaw.de/projects/cdi/wiki)来创建一个 netcdf 文件。我在文档中做了一个例子来编写一个 netcdf 文件,它工作正常。但是当第一次使用 cdi 时,它不会创建时间轴。 见代码:

    ! Now, we create the output file.
        ! We first create the grid.
    gridID = gridCreate(y3D%GridType, NLons * NLats)

    CALL gridDefXsize(gridID, NLons)
    CALL gridDefYsize(gridID, NLats)
    CALL gridDefXvals(gridID, y3D%Lons)
    CALL gridDefYvals(gridID, y3D%Lats)

        ! Now, the z axis to be attached to the variable when created (there is one z axis per variable).
    zaxisID = zaxisCreate(y3D%ZAxisType, 1) ! We only support predictands with one level. 1 creates a surface level.


        ! Now create the variable list
    vlistID = vlistCreate()
        ! And define the variables in the variable list
    Prevision   = vlistDefVar(vlistID, gridID, zaxisID, TIME_VARIABLE)

        ! Now define the variable names
    CALL vlistDefVarName(vlistID, Prevision , "Prevision")


        ! Now the time axis and attach it to the variable list.
    taxisID = taxisCreate(TAXIS_RELATIVE)   !ABSOLUTE)
    write (*,*) "taxisID: ", taxisID
    CALL taxisDefRDate(taxisID, 19000101)
    CALL vlistDefTaxis(vlistID, taxisID)

        ! Now create the file
    streamID = streamOpenWrite(char(ResultsFile), OutType)
    if ( streamID < 0 ) then
        write (*,*) "ERROR while attempting to create the file ", char(ResultsFile), " to store the results."
        write (*,*) cdiStringError(streamID)
        stop
    end if
        ! Assign the variable list to the dataset
    CALL streamDefVlist(streamID, vlistID)

        ! Now we have to loop over the time steps to store the data.
    DO tsID = 0, NDates - 1
        ! Set the verification date
        write (*,*) "Date ", ar_DatesPredicted(tsID+1)
        CALL taxisDefVdate(taxisID, ar_DatesPredicted(tsID+1))
        ! Set the verification time to 12:00:00
        CALL taxisDefVtime(taxisID, 120000)
        ! Define the time step
        status = streamDefTimestep(streamID, tsID)
        write (*,*) "Number of records of the time step: ", status

        ! Write values of each variable
        CALL streamWriteVar(streamID, Prevision, ar_y_2DPrev(tsID+1, c_predictands)%Values, NMiss)

    END DO

    ! Close the output stream
    CALL streamClose(streamID)

    ! Destroy the objects
    CALL vlistDestroy(vlistID)
    CALL taxisDestroy(taxisID)
    CALL zaxisDestroy(zaxisID)
    CALL gridDestroy(gridID)        

【问题讨论】:

  • 当我说时间轴没有创建时,我的意思是当我用ncdump打开创建的netcdf文件时,它没有显示任何时间轴。

标签: linker shared-libraries static-libraries netcdf


【解决方案1】:

解决了!:

这个问题的原因是我安装了两个版本的 cdi 库。 一个是使用系统包管理器安装的,另一个是在我的主目录中手动安装的。 我与第一个链接以构建一些对象,并与另一个链接以构建其他对象。 一旦到处使用相同的版本,问题就消失了。

所以这是一个通用规则:不要混合同一个库的不同版本来链接。

感谢所有试图帮助我的人。

【讨论】:

    猜你喜欢
    • 2020-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-11
    • 1970-01-01
    • 2017-09-23
    • 2019-03-15
    相关资源
    最近更新 更多