adding variables in netcdf4 fortran 77 -


i'm trying save outputs of model (written in fortran 77) in netcdf4 format. i'm using gfortran. since i'm fresher in fortran, wrote simple code in create dummy variables , add test netcdf file emulating dimensions,variables , attributes of model. works perfectly.

i proceeded next step knowing code works. well, thing same code not work , cannot find out why. model code old , "organized" in 1 single .for file. interestingly enough, main code written subroutine. basic structure of program is:

  implicit real*8(a-h,o-z)    character dummy*80   ...   call main(delt,npl)         end        subroutine main(delt, npl)   *variable declarations*   ...   end 

my approach create netcdf file outside "main" subroutine. works , netcdf file created. inside "main" define dimensions , variable (since they're based on data generated inside subroutine). code works charm when add dimensions:

  setting dimensions   nc_status = nf_def_dim(ncid,'parcel_id', ntot, prcl_dimid)   if (nc_status .ne. nf_noerr) call handle_err(nc_status)   nc_status = nf_def_dim(ncid, 'time', icomp, time_dimid)   if (nc_status .ne. nf_noerr) call handle_err(nc_status)   end define mode.   nc_status = nf_enddef(ncid)   if (nc_status .ne. nf_noerr) call handle_err(nc_status)   close file   nc_status = nf_close(ncid)   if (nc_status .ne. nf_noerr) call handle_err(nc_status) 

the nc file generated has right dimensions right size. problem comes when try add variables:

  dimensions   nc_status = nf_def_dim(ncid,'parcel_id', ntot, prcl_dimid)   if (nc_status .ne. nf_noerr) call handle_err(nc_status)   nc_status = nf_def_dim(ncid, 'time', icomp, time_dimid)   if (nc_status .ne. nf_noerr) call handle_err(nc_status)   dimids(1) = prcl_dimid   dimids(2) = time_dimid    variables   **nc_status = nf_def_var(ncid, 'latitude', nf_float, 2, dimids,   +     lat_varid)**   if (nc_status .ne. nf_noerr) call handle_err(nc_status)    end define mode.   nc_status = nf_enddef(ncid)   if (nc_status .ne. nf_noerr) call handle_err(nc_status)    close file   nc_status = nf_close(ncid)   if (nc_status .ne. nf_noerr) call handle_err(nc_status) 

i following error bold-font part of code.

error: netcdf: not valid data type or _fillvalue type mismatch

first, code (exactly that) works when create simple fortran file dummy values. second, no fillvalue defined me. , third, nf_float valid data type according unidata website.

i've tried create whole netcdf4 inside "main" subroutine same error. i've used imagination trying figure out happening and, apparently, no 1 else had same problem (or @ least did not mention online...). i'm beginner in fortran , possible.

all best , sorry if stupid question you. hasnt been stupid me @ all!


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -