Difference between revisions of "Programming/C-Sharp"

From HPC
Jump to: navigation , search
m
m
Line 90: Line 90:
 
* [[programming/OpenMP|OpenMP]]
 
* [[programming/OpenMP|OpenMP]]
 
* [[programming/OpenMPI|OpenMPI]]
 
* [[programming/OpenMPI|OpenMPI]]
{|
+
 
|style="width:5%; border-width: 0" | [[File:icon_home.png]]
+
==Navigation==
|style="width:95%; border-width: 0" |
+
 
 
* [[Main_Page|Home]]
 
* [[Main_Page|Home]]
* [[Applications|Application support]]
+
* [[Applications|Application support]]  
 
* [[General|General]]
 
* [[General|General]]
* [[Training|Training]]
+
* [[Programming|Programming support]] *
* [[Programming|Programming support]]
 
|-
 
|}
 

Revision as of 10:23, 10 June 2019

Programming Details

C# is a multi-paradigm programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming. Although originally developed by Microsoft for their own platform it has been standardised and a Linux version called MONO has been developed and matured.

The Mono project provides an open-source C# compiler, a complete open-source implementation of the Common Language Infrastructure including the required framework libraries as they appear in the ECMA specification, and a nearly complete implementation of the Microsoft proprietary .NET class libraries up to .NET 3.5. Note at this time Windows Presentation Foundation (WPF) does not exist.


Programming example

using System;
using MPI;

class Ring
{
    static void Main(string[] args)
    {
        using (new MPI.Environment(ref args))
        {
            Intracommunicator comm = Communicator.world;
            if (comm.Rank == 0)
            {
                // program for rank 0
            }
            else // not rank 0
            {
                // program for all other ranks
            }
        }
    }
}


Modules Available

The following modules are available:

  • module add mono/5.2.0


Compilation

The program would be compiled in the following way:

[username@login01 ~]$ module add mono/5.2.0
[username@login01 ~]$ mcs -out:cDEMO.exe cDEMO.cs

Usage Examples

Batch example

#!/bin/bash

#SBATCH -J openmpi-single-node
#SBATCH -N 1
#SBATCH --ntasks-per-node 28
#SBATCH -o %N.%j.%a.out
#SBATCH -e %N.%j.%a.err
#SBATCH -p compute
#SBATCH --exclusive

echo $SLURM_JOB_NODELIST

module purge
module add mono/4.4.1

export I_MPI_DEBUG=5
export I_MPI_FABRICS=shm:tmi
export I_MPI_FALLBACK=no

mono /home/user/CODE_SAMPLES/C-SHARP/cDEMO.exe


[username@login01 ~]$ sbatch demo.job
Submitted batch job 291552

Further Information

Navigation