Ignore:
Timestamp:
Jul 2, 2013, 9:40:28 AM (11 years ago)
Author:
tnavarro
Message:

Possibility to store multiple initial states in one start/startfi. This is RETROCOMPATIBLE. New option ecrithist in run.def to write data in start/startfi every ecrithist dynamical timestep. New option timestart in run.def to initialize the GCM with the time timestart stored in start

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/util/expandstartfi.F90

    r803 r999  
    2020integer :: varid ! to store the ID of a variable
    2121integer :: datashape(4) ! to store dimension IDs of a given dataset
     22integer :: corner(3),edges(3) ! to read data with a time axis
    2223character(len=90) :: varname ! name of a variable
    2324character(len=90) :: varatt ! name of attribute of a variable
     
    2829integer :: nlayer_plus_1_dimid
    2930integer :: number_of_advected_fields_dimid
     31integer :: time_dimid
    3032integer :: nbindims ! number of dimensions in input file
    3133integer :: nbinvars ! number of variables in input file
     
    3638integer :: nlayer_plus_1
    3739integer :: number_of_advected_fields
     40integer :: timelen
    3841real,allocatable :: surf_field(:) ! to store a 1D field of physical_points elements
    3942real,allocatable :: subsurf_field(:,:) ! to store subsurface (2D field)
     
    155158endif
    156159
     160status=nf90_inq_dimid(inid,"Time",time_dimid)
     161if (status.ne.nf90_noerr) then
     162  write(*,*)"Failed to find Time dimension"
     163  write(*,*)trim(nf90_strerror(status))
     164  timelen = 0
     165else
     166  status=nf90_inquire_dimension(inid,time_dimid,len=timelen)
     167  if (status.ne.nf90_noerr) then
     168    write(*,*)"Failed to read Time dimension"
     169    write(*,*)trim(nf90_strerror(status))
     170   stop
     171  else
     172    write(*,*) " time length = ",timelen
     173  endif
     174endif
     175
    157176! 1.3 Allocate memory for input fields
    158177allocate(surf_field(physical_points))
     
    361380allocate(out_surf_field(lonlen,latlen))
    362381
     382shape(:) = 0
    363383do ivar=1,nbinvars ! loop on all input variables
    364384  ! find out what dimensions are linked to this variable
    365385  status=nf90_inquire_variable(inid,ivar,name=varname,ndims=nbdim,&
    366386                               dimids=shape,natts=nbatt)
    367   if ((nbdim==1).and.(shape(1)==physical_points_dimid)) then
     387  if (((nbdim==1).and.(shape(1)==physical_points_dimid))&
     388  .or.((nbdim==2).and.(shape(1)==physical_points_dimid)&
     389                 .and.(shape(2)==time_dimid))) then
     390 
     391    corner(1) = 1
     392    corner(2) = timelen
     393    edges(1)  = physical_points
     394    edges(2)  = 1
    368395   
    369396    ! skip "longitude" and "latitude"
     
    375402    ! load input data:
    376403    status=nf90_inq_varid(inid,varname,invarid)
    377     status=nf90_get_var(inid,invarid,surf_field)
     404    status=nf90_get_var(inid,invarid,surf_field,corner,edges)
    378405   
    379406    ! switch output file to to define mode
     
    455482  status=nf90_inquire_variable(inid,ivar,name=varname,ndims=nbdim,&
    456483                               dimids=shape,natts=nbatt)
    457   if ((nbdim==2).and.(shape(1)==physical_points_dimid) &
    458                 .and.(shape(2)==subsurface_layers_dimid)) then
     484  if (((nbdim==2).and.(shape(1)==physical_points_dimid)&
     485                 .and.(shape(2)==subsurface_layers_dimid))&
     486  .or.((nbdim==3).and.(shape(1)==physical_points_dimid)&
     487                 .and.(shape(2)==subsurface_layers_dimid)&
     488                 .and.(shape(3)==time_dimid))) then
     489   
     490    corner(1) = 1
     491    corner(2) = 1
     492    corner(3) = timelen
     493    edges(1)  = physical_points
     494    edges(2)  = subsurface_layers
     495    edges(3)  = 1
    459496   
    460497    write(*,*) " processing: ",trim(varname)
     
    462499    ! load input data:
    463500    status=nf90_inq_varid(inid,varname,invarid)
    464     status=nf90_get_var(inid,invarid,subsurf_field)
     501    status=nf90_get_var(inid,invarid,subsurf_field,corner,edges)
    465502   
    466503    ! switch output file to to define mode
Note: See TracChangeset for help on using the changeset viewer.