TNO Intern

Commit b81c653e authored by Arjo Segers's avatar Arjo Segers
Browse files

Support packed variables in input/output of observation operator.

parent 0e8cdac4
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
cso.o : cso.F90 cso.inc cso_ncfile.o cso_profile.o cso_grid.o cso_sat.o cso_listing.o cso_rc.o cso_string.o cso_datetime.o cso_domains.o cso_logging.o cso_comm.o 
cso_comm.o : cso_comm.F90 cso.inc cso_logging.o 
cso_datetime.o : cso_datetime.F90 cso.inc cso_string.o cso_logging.o 
cso_domains.o : cso_domains.F90 cso.inc cso_comm.o cso_logging.o 
cso_exchange.o : cso_exchange.F90 cso.inc cso_logging.o 
cso.o : cso.F90 cso.inc cso_ncfile.o cso_profile.o cso_grid.o cso_tools.o cso_sat.o cso_listing.o cso_rc.o cso_string.o cso_datetime.o cso_domains.o cso_logging.o cso_comm.o 
cso_file.o : cso_file.F90 cso.inc cso_logging.o 
cso_grid.o : cso_grid.F90 cso.inc cso_ncfile.o cso_parray.o cso_logging.o 
cso_grid.o : cso_grid.F90 cso.inc cso_ncfile.o cso_tools.o cso_parray.o cso_logging.o 
cso_listing.o : cso_listing.F90 cso.inc cso_string.o cso_file.o cso_datetime.o cso_logging.o 
cso_logging.o : cso_logging.F90 cso.inc 
cso_mapping.o : cso_mapping.F90 cso.inc cso_parray.o cso_swapping.o cso_comm.o cso_logging.o 
@@ -13,9 +13,10 @@ cso_parray.o : cso_parray.F90 cso.inc cso_logging.o
cso_pixels.o : cso_pixels.F90 cso.inc cso_profile.o cso_exchange.o cso_string.o cso_swapping.o cso_parray.o cso_domains.o cso_comm.o cso_ncfile.o cso_logging.o 
cso_profile.o : cso_profile.F90 cso.inc cso_logging.o 
cso_rc.o : cso_rc.F90 cso.inc cso_datetime.o cso_file.o cso_string.o cso_logging.o 
cso_sat.o : cso_sat.F90 cso.inc cso_swapping.o cso_domains.o cso_string.o cso_rc.o cso_comm.o cso_exchange.o cso_mapping.o cso_pixels.o cso_logging.o 
cso_sat.o : cso_sat.F90 cso.inc cso_swapping.o cso_string.o cso_rc.o cso_comm.o cso_domains.o cso_exchange.o cso_mapping.o cso_pixels.o cso_logging.o 
cso_string.o : cso_string.F90 cso.inc cso_logging.o 
cso_swapping.o : cso_swapping.F90 cso.inc cso_parray.o cso_domains.o cso_comm.o cso_logging.o 
tutorial_oper_S4-syn.o : tutorial_oper_S4-syn.F90 cso.inc cso.o 
tutorial_oper_S5p.o : tutorial_oper_S5p.F90 cso.inc cso.o 
cso_tools.o : cso_tools.F90 cso.inc cso_logging.o 
tutorial_oper_adj-test.o : tutorial_oper_adj-test.F90 cso.inc cso.o 
tutorial_oper_S5p.o : tutorial_oper_S5p.F90 cso.inc cso.o 
tutorial_oper_swap.o : tutorial_oper_swap.F90 cso.inc cso.o 
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ module CSO
  use CSO_Rc
  use CSO_Listing
  use CSO_Sat
  use CSO_Tools
  use CSO_Grid
  use CSO_Profile
  use CSO_NcFile
+70 −0
Original line number Diff line number Diff line
@@ -224,6 +224,18 @@
!     call wrtcsol( 'time step  : ', dt ); call csoPr
!     call wrtcsol( 'time range : ', t1, ' to ', t2 ); call csoPr
!
!  Evaluate time templates in string:
!     %Y    : 4-digit year
!     %m    : 2-digit month
!     %d    : 2 digit day
!     %H    : 2 digit hour
!     %M    : 2 digit minute
!     %S    : 2 digit second
!  
!     t = TDate( year=2021, month=9, day=6, hour=0, min=0 )
!     line = 'file_%Y%m%d_%H%M.txt'
!     call CSO_Format( line, t, status )
!
!
! DEFAULTS
!
@@ -233,6 +245,12 @@
!     call CSO_DateTimeDefaults( [calendar='gregorian'] )
!
!
! HISTORY
!
!   2022-09, Arjo Segers
!     Added `CSO_Format` routine.
!
!  
!### macro's ##################################################################
!
#define TRACEBACK write (csol,'("in ",a," (",a,i6,")")') rname, __FILE__, __LINE__ ; call csoErr
@@ -303,6 +321,7 @@ module CSO_DateTimes
  public      ::  Pretty
  public      ::  wrtcsol
  public      ::  PrintDate
  public      ::  CSO_Format

  ! --- const -----------------------------------

@@ -3639,6 +3658,57 @@ contains
  end subroutine PrintDate
    
    
  ! **

  
  !
  ! Evaluate time templates:
  !   %Y    : 4-digit year
  !   %m    : 2-digit month
  !   %d    : 2 digit day
  !   %H    : 2 digit hour
  !   %M    : 2 digit minute
  !   %S    : 2 digit second
  !
  
  subroutine CSO_Format( s, t, status )
  
    use CSO_String, only : CSO_Replace
  
    ! --- in/out ---------------------------------
    
    character(len=*), intent(inout)     ::  s
    type(T_CSO_DateTime), intent(in)    ::  t
    integer, intent(out)                ::  status
    
    ! --- const ----------------------------------
    
    character(len=*), parameter  ::  rname = mname//'/CSO_Format'
    
    ! --- local ----------------------------------
    
    ! --- begin ----------------------------------
    
    ! replace templates:
    call CSO_Replace( s, '%Y', '(i4.4)', t%year  , status )
    IF_NOT_OK_RETURN(status=1)
    call CSO_Replace( s, '%m', '(i2.2)', t%month , status )
    IF_NOT_OK_RETURN(status=1)
    call CSO_Replace( s, '%d', '(i2.2)', t%day   , status )
    IF_NOT_OK_RETURN(status=1)
    call CSO_Replace( s, '%H', '(i2.2)', t%hour  , status )
    IF_NOT_OK_RETURN(status=1)
    call CSO_Replace( s, '%M', '(i2.2)', t%minute, status )
    IF_NOT_OK_RETURN(status=1)
    call CSO_Replace( s, '%S', '(i2.2)', t%second, status )
    IF_NOT_OK_RETURN(status=1)
    
    ! ok
    status = 0
    
  end subroutine CSO_Format


end module CSO_DateTimes

+87 −0
Original line number Diff line number Diff line
@@ -2,6 +2,12 @@
!
! File tools.
!
! HISTORY
!
!   2022-09, Arjo Segers
!     Added `CSO_CheckDir` routine.
!
!  
!#################################################################
!
#define TRACEBACK write (csol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call csoErr
@@ -24,6 +30,7 @@ module CSO_File
  
  public  ::  CSO_GetFU
  public  ::  CSO_GetDirname
  public  ::  CSO_CheckDir
  public  ::  T_CSO_TextFile


@@ -172,6 +179,86 @@ contains

  end subroutine CSO_GetDirname
  
  ! *
  
  subroutine CSO_CheckDir( filename, status )

#ifdef __INTEL_COMPILER
    use IFPort, only : System
    use IFPort, only : IErrNo
    use IFPort, only : E2BIG, ENOENT, ENOEXEC, ENOMEM
#endif

    ! --- in/out -----------------------
    
    character(len=*), intent(in)              ::  filename
    integer, intent(out)                      ::  status
    
    ! --- const --------------------------
    
    character(len=*), parameter   ::  rname = mname//'/CSO_CheckDir'
    
    ! --- local --------------------------
    
    character(len=1024)     ::  dirname
    logical                 ::  exist
    character(len=1024)     ::  command
#ifdef __INTEL_COMPILER
    integer                 ::  ierr
#endif

    ! --- begin --------------------------
    
    ! directory name:
    call CSO_GetDirname( filename, dirname, status )
    IF_NOT_OK_RETURN(status=1)
    ! directory in path?
    if ( len_trim(dirname) > 0 ) then
      ! check presence:
      inquire( file=trim(dirname)//'/.', exist=exist )
      ! not present?
      if ( .not. exist ) then
        ! command create including parent directories:
        command = 'mkdir -p '//trim(dirname)
        ! switch:
#ifdef __INTEL_COMPILER
        !~ use function from IFPort library:
        status = System( command )
        if ( status /= 0 ) then
          write (csol,'("return status ",i0," from system call:")') status; call csoErr
          write (csol,'("  ",a)') trim(command); call csoErr
          ierr = IErrNo()
          select case ( ierr )
            case ( E2BIG )
              write (csol,'("The argument list is too long.")'); call csoErr
            case ( ENOENT )
              write (csol,'("The command interpreter cannot be found.")'); call csoErr
            case ( ENOEXEC )
              write (csol,'("The command interpreter file has an invalid format and is not executable.")'); call csoErr
            case ( ENOMEM )
              write (csol,'("Not enough system resources are available to execute the command.")'); call csoErr
            case default
              write (csol,'("unsupported error code ",i0)') ierr; call csoErr
          end select
          TRACEBACK; status=1; return
        end if
#else
        !~ non-standard routine:
        call system( command, status )
        if ( status /= 0 ) then
          write (csol,'("return status ",i0," from system call:")') status; call csoErr
          write (csol,'("  ",a)') trim(command); call csoErr
          TRACEBACK; status=1; return
        end if
#endif
      end if ! dir not present yet
    end if ! dirname included
    
    ! ok
    status = 0

  end subroutine CSO_CheckDir


  ! ==============================================================
  ! ===
+14 −622

File changed.

Preview size limit exceeded, changes collapsed.

Loading