writegrid subroutine

Write NetCDF files.

How to use

subroutine writegrid(ifile, idata[, headerfile])
Parameters:
  • ifile :: dataset file path [character] [1]
  • idata :: map structure to be readed [FPL defined type structure] [1]
Options:

headerfile :: text file with metadata informations [character] [optional] [1]

Return:

file :: NetCDF dataset

Call :

writegrid(ifile,idata[,headerfile])

[1](1, 2, 3) Defined by user

[Code example] Write data to NetCDF

Read netCDF temperature (°C) data, converts it to Farenheit and write other file.

program main
  use fpl
  implicit none

  !Definition of dataset structure
  !Variable to be read is float type, with 4 dimensions (longitude (float), latitude (float), time(float) and level(float))
  type(nc4d_float_llf_tf_lf) :: tempC

  character(len=32) :: input, output

  input = "database/temp.mon.nc"
  output = "database/temp.mon.farenheit.nc"

  !Definition of attributes for reading the dataset
  tempC%varname = "temp"
  tempC%lonname = "longitude"
  tempC%latname = "latitude"
  tempC%timename = "time"
  tempC%levelname = "level"

  !Reads data from file
  call readgrid(input, tempC)

  !Convertion Celsius to Farenheit
 
   where(tempC%ncdata.ne.tempC%FillValue) tempC%ncdata = (tempC%ncdata*9/5)+32
   
   !Definition of new variable unit
   tempC%varunits = "degF"

  !Write the data on file
  call writegrid(output, tempC)

end program main
#RedHat based systems
gfortran -o writegrid.out writegrid.f90 -I/usr/lib64/gfortran/modules/ -lFPL

#Debian based systems
gfortran -o writegrid.out writegrid.f90 -I/usr/include/ -lFPL

Important

-I<dir> This option specifies where to put .mod files for compiled modules. It is also added to the list of directories to Influencing the linking step. See the GNU Fortran Compiler Documentation .

<dir> is defined in Makefile as $(FPL_moddir). See Build Library.

After compilation run the program ./writegrid.out