Ignore:
Timestamp:
Dec 20, 2013, 4:04:56 PM (11 years ago)
Author:
emillour
Message:

Mars GCM:
Series of changes to enable running in parallel (using LMDZ.COMMON dynamics);
Current LMDZ.MARS can still notheless be compiled and run in serial mode
"as previously".
Summary of main changes:

  • Main programs (newstart, start2archive, xvik) that used to be in dyn3d have been moved to phymars.
  • dyn3d/control.h is now module control_mod.F90
  • rearanged input/outputs routines everywhere to handle serial/MPI cases. physdem.F => phyredem.F90 , phyetat0.F => phyetat0.F90 ; all read/write routines for startfi files are gathered in module iostart.F90
  • added parallelism related routines init_phys_lmdz.F90, comgeomphy.F90, dimphy.F90, iniphysiq.F90, mod_grid_phy_lmdz.F90, mod_phys_lmdz_mpi_data.F90, mod_phys_lmdz_mpi_transfert.F90, mod_phys_lmdz_omp_data.F90, mod_phys_lmdz_omp_transfert.F90, mod_phys_lmdz_para.F90, mod_phys_lmdz_transfert_para.F90 in phymars and mod_const_mpi.F90 in dyn3d (for compliance with parallel case)
  • created generic routines 'planetwide_maxval' and 'planetwide_minval', in module "planetwide_mod", that enable obtaining the min and max of a field over the whole planet.

EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/libf/phymars/soil_settings.F

    r1047 r1130  
    11      subroutine soil_settings(nid,ngrid,nsoil,tsurf,tsoil,indextime)
    22
    3       use netcdf
     3!      use netcdf
    44      use comsoil_h, only: layer, mlayer, inertiedat, volcapa
     5      use iostart, only: inquire_field_ndims, get_var, get_field,
     6     &                   inquire_field, inquire_dimension_length
    57      implicit none
    68
     
    7476      real,parameter :: default_volcapa=1.e6
    7577
     78      logical :: found,ok
     79     
    7680!======================================================================
    7781
     
    8185! 1.1 Start by reading how many layers of soil there are
    8286
    83         ierr=nf90_inq_dimid(nid,"subsurface_layers",dimid)
    84         if (ierr.ne.nf90_noerr) then
    85          write(*,*)'soil_settings: Problem reading <subsurface_layers>'
    86          write(*,*)trim(nf90_strerror(ierr))
    87          call abort
    88         endif
    89 
    90         ierr=nf90_inquire_dimension(nid,dimid,len=dimlen)
    91         if (ierr.ne.nf90_noerr) then
    92          write(*,*)'soil_settings: Problem getting <subsurface_layers>',
    93      &             'length'
    94          write(*,*)trim(nf90_strerror(ierr))
    95          call abort
    96         endif
     87!       ierr=nf90_inq_dimid(nid,"subsurface_layers",dimid)
     88!       if (ierr.ne.nf90_noerr) then
     89!        write(*,*)'soil_settings: Problem reading <subsurface_layers>'
     90!         write(*,*)trim(nf90_strerror(ierr))
     91!        call abort
     92!       endif
     93
     94!       ierr=nf90_inquire_dimension(nid,dimid,len=dimlen)
     95!       if (ierr.ne.nf90_noerr) then
     96!        write(*,*)'soil_settings: Problem getting <subsurface_layers>',
     97!     &             'length'
     98!        write(*,*)trim(nf90_strerror(ierr))
     99!         call abort
     100!       endif
     101        dimlen=inquire_dimension_length("subsurface_layers")
    97102
    98103        if (dimlen.ne.nsoil) then
     
    107112!     (in ye old days, thermal inertia was only given at the "surface")
    108113      ! Look for thermal inertia data
    109       ierr=nf90_inq_varid(nid,"inertiedat",nvarid)
    110       if (ierr.NE.nf90_noerr) then
    111          write(*,*)'soil_settings: Field <inertiedat> not found!'
    112          write(*,*)trim(nf90_strerror(ierr))
    113          call abort
    114       endif
    115 
    116       ! Read the # of dimensions <inertidat> was defined as using
    117       ierr=nf90_inquire_variable(nid,nvarid,ndims=ndims)
    118       ! if (ndims.eq.1) then we have the "old 2D-surface" format
     114!      ierr=nf90_inq_varid(nid,"inertiedat",nvarid)
     115!      if (ierr.NE.nf90_noerr) then
     116!         write(*,*)'soil_settings: Field <inertiedat> not found!'
     117!         write(*,*)trim(nf90_strerror(ierr))
     118!         call abort
     119!      endif
     120!
     121!      ! Read the # of dimensions <inertidat> was defined as using
     122!      ierr=nf90_inquire_variable(nid,nvarid,ndims=ndims)
     123!      ! if (ndims.eq.1) then we have the "old 2D-surface" format
     124      ndims=inquire_field_ndims("inertiedat")
    119125
    120126! 1.3 Read depths values or set olddepthdef flag and values
     
    136142        enddo
    137143      else ! Look for depth
    138         ierr=nf90_inq_varid(nid,"soildepth",nvarid)
    139         if (ierr.ne.nf90_noerr) then
    140           write(*,*)'soil_settings: Field <soildepth> not found!'
    141           write(*,*)trim(nf90_strerror(ierr))
    142           call abort
    143         endif
     144!        ierr=nf90_inq_varid(nid,"soildepth",nvarid)
     145!        if (ierr.ne.nf90_noerr) then
     146!          write(*,*)'soil_settings: Field <soildepth> not found!'
     147!          write(*,*)trim(nf90_strerror(ierr))
     148!         call abort
     149!        endif
    144150        ! read <depth> coordinate
    145151        if (interpol) then !put values in oldmlayer
    146           ierr=nf90_get_var(nid,nvarid,oldmlayer)
    147           if (ierr.ne.nf90_noerr) then
    148            write(*,*)'soil_settings: Problem while reading <soildepth>'
    149            write(*,*)trim(nf90_strerror(ierr))
    150            call abort
     152!          ierr=nf90_get_var(nid,nvarid,oldmlayer)
     153!          if (ierr.ne.nf90_noerr) then
     154!           write(*,*)'soil_settings: Problem while reading <soildepth>'
     155!           write(*,*)trim(nf90_strerror(ierr))
     156!           call abort
     157!          endif
     158          call get_var("soildepth",oldmlayer,found)
     159          if (.not.found) then
     160            write(*,*)'soil_settings: Problem while reading <soildepth>'
    151161          endif
    152162        else ! put values in mlayer
    153           ierr=nf90_get_var(nid,nvarid,mlayer)
    154           if (ierr.ne.nf90_noerr) then
    155            write(*,*)'soil_settings: Problem while reading <soildepth>'
    156            write(*,*)trim(nf90_strerror(ierr))
    157            call abort
     163!          ierr=nf90_get_var(nid,nvarid,mlayer)
     164!          if (ierr.ne.nf90_noerr) then
     165!           write(*,*)'soil_settings: Problem while reading <soildepth>'
     166!           write(*,*)trim(nf90_strerror(ierr))
     167!           call abort
     168!          endif
     169          call get_var("soildepth",mlayer,found)
     170          if (.not.found) then
     171            write(*,*)'soil_settings: Problem while reading <soildepth>'
    158172          endif
    159173        endif !of if (interpol)
     
    217231
    218232! 3.1 Look (again) for thermal inertia data (to reset nvarid)
    219       ierr=nf90_inq_varid(nid,"inertiedat",nvarid)
    220       if (ierr.NE.nf90_noerr) then
    221          write(*,*)'soil_settings: Field <inertiedat> not found!'
    222          write(*,*)trim(nf90_strerror(ierr))
    223          call abort
    224       endif
     233!      ierr=nf90_inq_varid(nid,"inertiedat",nvarid)
     234!      if (ierr.NE.nf90_noerr) then
     235!         write(*,*)'soil_settings: Field <inertiedat> not found!'
     236!         write(*,*)trim(nf90_strerror(ierr))
     237!         call abort
     238!      endif
    225239
    226240! 3.2 Knowing the # of dimensions <inertidat> was defined as using,
     
    232246       ! Read Surface thermal inertia
    233247       allocate(surfinertia(ngrid))
    234        ierr=nf90_get_var(nid,nvarid,surfinertia)
    235         if (ierr.NE.nf90_noerr) then
    236          write(*,*)'soil_settings: Problem while reading <inertiedat>'
    237          write(*,*)trim(nf90_strerror(ierr))
     248!       ierr=nf90_get_var(nid,nvarid,surfinertia)
     249!        if (ierr.NE.nf90_noerr) then
     250!         write(*,*)'soil_settings: Problem while reading <inertiedat>'
     251!         write(*,*)trim(nf90_strerror(ierr))
     252!         call abort
     253!        endif
     254       call get_field("inertiedat",surfinertia,found)
     255       if (.not.found) then
     256         write(*,*) "soil_settings: Failed loading <inertiedat>"
    238257         call abort
    239         endif
     258       endif
    240259       
    241260       write(*,*)' => Building soil thermal inertia (using reference sur
     
    255274            stop
    256275           endif
    257          endif
    258          ierr=nf90_get_var(nid,nvarid,oldinertiedat)
    259         if (ierr.NE.nf90_noerr) then
    260          write(*,*)'soil_settings: Problem while reading <inertiedat>'
    261          write(*,*)trim(nf90_strerror(ierr))
    262          call abort
     276         endif ! of if (.not.allocated(oldinertiedat))
     277!         ierr=nf90_get_var(nid,nvarid,oldinertiedat)
     278!        if (ierr.NE.nf90_noerr) then
     279!         write(*,*)'soil_settings: Problem while reading <inertiedat>'
     280!         write(*,*)trim(nf90_strerror(ierr))
     281!         call abort
     282!        endif
     283        call get_field("inertiedat",oldinertiedat,found)
     284        if (.not.found) then
     285          write(*,*) "soil_settings: Failed loading <inertiedat>"
     286          call abort
    263287        endif
    264288       else ! put values in therm_i
    265         ierr=nf90_get_var(nid,nvarid,inertiedat)
    266         if (ierr.NE.nf90_noerr) then
    267          write(*,*)'soil_settings: Problem while reading <inertiedat>'
    268          write(*,*)trim(nf90_strerror(ierr))
    269          call abort
    270         endif
     289!        ierr=nf90_get_var(nid,nvarid,inertiedat)
     290!        if (ierr.NE.nf90_noerr) then
     291!         write(*,*)'soil_settings: Problem while reading <inertiedat>'
     292!         write(*,*)trim(nf90_strerror(ierr))
     293!         call abort
     294         call get_field("inertiedat",inertiedat,found)
     295         if (.not.found) then
     296           write(*,*) "soil_settings: Failed loading <inertiedat>"
     297           call abort
     298         endif
     299!        endif
    271300       endif ! of if (interpol)
    272301      endif ! of if (ndims.eq.1)
     
    275304! -------------------------
    276305
    277       ierr=nf90_inq_varid(nid,"tsoil",nvarid)
    278       if (ierr.ne.nf90_noerr) then
     306!      ierr=nf90_inq_varid(nid,"tsoil",nvarid)
     307      ok=inquire_field("tsoil")
     308!      if (ierr.ne.nf90_noerr) then
     309      if (.not.ok) then
    279310        write(*,*)'soil_settings: Field <tsoil> not found!'
    280311        write(*,*)' => Building <tsoil> from surface values <tsurf>'
     
    292323           endif
    293324         endif
    294         ierr=nf90_get_var(nid,nvarid,oldtsoil)
    295         if (ierr.ne.nf90_noerr) then
    296          write(*,*)'soil_settings: Problem while reading <tsoil>'
    297          write(*,*)trim(nf90_strerror(ierr))
    298          call abort
    299         endif
     325!        ierr=nf90_get_var(nid,nvarid,oldtsoil)
     326!        if (ierr.ne.nf90_noerr) then
     327!        write(*,*)'soil_settings: Problem while reading <tsoil>'
     328!         write(*,*)trim(nf90_strerror(ierr))
     329!        call abort
     330!       endif
     331         call get_field("tsoil",oldtsoil,found)
     332         if (.not.found) then
     333           write(*,*) "soil_settings: Failed loading <tsoil>"
     334           call abort
     335         endif
    300336       else ! put values in tsoil
    301         corner(1)=1
    302         corner(2)=1
    303         corner(3)=indextime
    304         edges(1)=ngrid
    305         edges(2)=nsoil
    306         edges(3)=1
    307         !ierr=nf90_get_var(nid,nvarid,tsoil,corner,edges)
    308         ierr=nf90_get_var(nid,nvarid,tsoil)
    309         if (ierr.ne.nf90_noerr) then
    310          write(*,*)'soil_settings: Problem while reading <tsoil>'
    311          write(*,*)trim(nf90_strerror(ierr))
    312          call abort
    313         endif
     337!        corner(1)=1
     338!        corner(2)=1
     339!        corner(3)=indextime
     340!        edges(1)=ngrid
     341!        edges(2)=nsoil
     342!        edges(3)=1
     343!        !ierr=nf90_get_var(nid,nvarid,tsoil,corner,edges)
     344!        ierr=nf90_get_var(nid,nvarid,tsoil)
     345!        if (ierr.ne.nf90_noerr) then
     346!        write(*,*)'soil_settings: Problem while reading <tsoil>'
     347!         write(*,*)trim(nf90_strerror(ierr))
     348!        call abort
     349!       endif
     350         call get_field("tsoil",tsoil,found,timeindex=indextime)
     351         if (.not.found) then
     352           write(*,*) "soil_settings: Failed loading <tsoil>"
     353           call abort
     354         endif
    314355       endif ! of if (interpol)
    315       endif
     356      endif! of if (.not.ok)
    316357
    317358! 5. If necessary, interpolate soil temperatures and thermal inertias
Note: See TracChangeset for help on using the changeset viewer.